Skip to content

Commit

Permalink
Merge branch 'cxgb4-cxgb4vf-fix-warnings-reported-by-sparse'
Browse files Browse the repository at this point in the history
Rahul Lakkireddy says:

====================
cxgb4/cxgb4vf: fix warnings reported by sparse

This series of patches fix various warnings reported by the sparse
tool.

Patches 1 and 2 fix lock context imbalance warnings.

Patch 3 fixes cast to restricted __be64 warning when fetching
timestamp in PTP path.

Patch 4 fixes several cast to restricted __be32 warnings in TC-U32
offload parser.

Patch 5 fixes several cast from restricted __be16 warnings in parsing
L4 ports for filters.

Patch 6 fixes several restricted __be32 degrades to integer warnings
when comparing IP address masks for exact-match filters.

Patch 7 fixes cast to restricted __be64 warning when fetching SGE
queue contexts in device dump collection.

Patch 8 fixes cast from restricted __sum16 warning when saving IPv4
partial checksum.

Patch 9 fixes issue with string array scope in DCB path.

Patch 10 fixes a set but unused variable warning when DCB is disabled.

Patch 11 fixes several kernel-doc comment warnings in cxgb4 driver.

Patch 12 fixes several kernel-doc comment warnings in cxgb4vf driver.
====================

Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
davem330 committed Jun 23, 2020
2 parents 6199496 + 20bb0c8 commit a83024b
Show file tree
Hide file tree
Showing 18 changed files with 211 additions and 169 deletions.
6 changes: 4 additions & 2 deletions drivers/net/ethernet/chelsio/cxgb4/cudbg_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -1975,7 +1975,6 @@ int cudbg_collect_dump_context(struct cudbg_init *pdbg_init,
u8 mem_type[CTXT_INGRESS + 1] = { 0 };
struct cudbg_buffer temp_buff = { 0 };
struct cudbg_ch_cntxt *buff;
u64 *dst_off, *src_off;
u8 *ctx_buf;
u8 i, k;
int rc;
Expand Down Expand Up @@ -2044,8 +2043,11 @@ int cudbg_collect_dump_context(struct cudbg_init *pdbg_init,
}

for (j = 0; j < max_ctx_qid; j++) {
__be64 *dst_off;
u64 *src_off;

src_off = (u64 *)(ctx_buf + j * SGE_CTXT_SIZE);
dst_off = (u64 *)buff->data;
dst_off = (__be64 *)buff->data;

/* The data is stored in 64-bit cpu order. Convert it
* to big endian before parsing.
Expand Down
3 changes: 3 additions & 0 deletions drivers/net/ethernet/chelsio/cxgb4/cxgb4_dcb.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@ static inline __u8 bitswap_1(unsigned char val)
((val & 0x02) << 5) |
((val & 0x01) << 7);
}

extern const char * const dcb_ver_array[];

#define CXGB4_DCB_ENABLED true

#else /* !CONFIG_CHELSIO_T4_DCB */
Expand Down
1 change: 0 additions & 1 deletion drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -2379,7 +2379,6 @@ static const struct file_operations rss_vf_config_debugfs_fops = {
};

#ifdef CONFIG_CHELSIO_T4_DCB
extern char *dcb_ver_array[];

/* Data Center Briging information for each port.
*/
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ static void fw_caps_to_lmm(enum fw_port_type port_type,
/**
* lmm_to_fw_caps - translate ethtool Link Mode Mask to Firmware
* capabilities
* @et_lmm: ethtool Link Mode Mask
* @link_mode_mask: ethtool Link Mode Mask
*
* Translate ethtool Link Mode Mask into a Firmware Port capabilities
* value.
Expand Down
25 changes: 16 additions & 9 deletions drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,9 @@ static void set_nat_params(struct adapter *adap, struct filter_entry *f,
unsigned int tid, bool dip, bool sip, bool dp,
bool sp)
{
u8 *nat_lp = (u8 *)&f->fs.nat_lport;
u8 *nat_fp = (u8 *)&f->fs.nat_fport;

if (dip) {
if (f->fs.type) {
set_tcb_field(adap, f, tid, TCB_SND_UNA_RAW_W,
Expand Down Expand Up @@ -236,8 +239,9 @@ static void set_nat_params(struct adapter *adap, struct filter_entry *f,
}

set_tcb_field(adap, f, tid, TCB_PDU_HDR_LEN_W, WORD_MASK,
(dp ? f->fs.nat_lport : 0) |
(sp ? f->fs.nat_fport << 16 : 0), 1);
(dp ? (nat_lp[1] | nat_lp[0] << 8) : 0) |
(sp ? (nat_fp[1] << 16 | nat_fp[0] << 24) : 0),
1);
}

/* Validate filter spec against configuration done on the card. */
Expand Down Expand Up @@ -909,15 +913,18 @@ int set_filter_wr(struct adapter *adapter, int fidx)
fwr->fpm = htons(f->fs.mask.fport);

if (adapter->params.filter2_wr_support) {
u8 *nat_lp = (u8 *)&f->fs.nat_lport;
u8 *nat_fp = (u8 *)&f->fs.nat_fport;

fwr->natmode_to_ulp_type =
FW_FILTER2_WR_ULP_TYPE_V(f->fs.nat_mode ?
ULP_MODE_TCPDDP :
ULP_MODE_NONE) |
FW_FILTER2_WR_NATMODE_V(f->fs.nat_mode);
memcpy(fwr->newlip, f->fs.nat_lip, sizeof(fwr->newlip));
memcpy(fwr->newfip, f->fs.nat_fip, sizeof(fwr->newfip));
fwr->newlport = htons(f->fs.nat_lport);
fwr->newfport = htons(f->fs.nat_fport);
fwr->newlport = htons(nat_lp[1] | nat_lp[0] << 8);
fwr->newfport = htons(nat_fp[1] | nat_fp[0] << 8);
}

/* Mark the filter as "pending" and ship off the Filter Work Request.
Expand Down Expand Up @@ -1105,16 +1112,16 @@ static bool is_addr_all_mask(u8 *ipmask, int family)
struct in_addr *addr;

addr = (struct in_addr *)ipmask;
if (addr->s_addr == 0xffffffff)
if (ntohl(addr->s_addr) == 0xffffffff)
return true;
} else if (family == AF_INET6) {
struct in6_addr *addr6;

addr6 = (struct in6_addr *)ipmask;
if (addr6->s6_addr32[0] == 0xffffffff &&
addr6->s6_addr32[1] == 0xffffffff &&
addr6->s6_addr32[2] == 0xffffffff &&
addr6->s6_addr32[3] == 0xffffffff)
if (ntohl(addr6->s6_addr32[0]) == 0xffffffff &&
ntohl(addr6->s6_addr32[1]) == 0xffffffff &&
ntohl(addr6->s6_addr32[2]) == 0xffffffff &&
ntohl(addr6->s6_addr32[3]) == 0xffffffff)
return true;
}
return false;
Expand Down
11 changes: 6 additions & 5 deletions drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ static int set_rxmode(struct net_device *dev, int mtu, bool sleep_ok)
* or -1
* @addr: the new MAC address value
* @persist: whether a new MAC allocation should be persistent
* @add_smt: if true also add the address to the HW SMT
* @smt_idx: the destination to store the new SMT index.
*
* Modifies an MPS filter and sets it to the new MAC address if
* @tcam_idx >= 0, or adds the MAC address to a new filter if
Expand Down Expand Up @@ -1615,6 +1615,7 @@ static int tid_init(struct tid_info *t)
* @stid: the server TID
* @sip: local IP address to bind server to
* @sport: the server's TCP port
* @vlan: the VLAN header information
* @queue: queue to direct messages from this server to
*
* Create an IP server for the given port and address.
Expand Down Expand Up @@ -2609,7 +2610,7 @@ int cxgb4_create_server_filter(const struct net_device *dev, unsigned int stid,

/* Clear out filter specifications */
memset(&f->fs, 0, sizeof(struct ch_filter_specification));
f->fs.val.lport = cpu_to_be16(sport);
f->fs.val.lport = be16_to_cpu(sport);
f->fs.mask.lport = ~0;
val = (u8 *)&sip;
if ((val[0] | val[1] | val[2] | val[3]) != 0) {
Expand Down Expand Up @@ -5377,10 +5378,10 @@ static inline bool is_x_10g_port(const struct link_config *lc)
static int cfg_queues(struct adapter *adap)
{
u32 avail_qsets, avail_eth_qsets, avail_uld_qsets;
u32 i, n10g = 0, qidx = 0, n1g = 0;
u32 ncpus = num_online_cpus();
u32 niqflint, neq, num_ulds;
struct sge *s = &adap->sge;
u32 i, n10g = 0, qidx = 0;
u32 q10g = 0, q1g;

/* Reduce memory usage in kdump environment, disable all offload. */
Expand Down Expand Up @@ -5426,7 +5427,6 @@ static int cfg_queues(struct adapter *adap)
if (n10g)
q10g = (avail_eth_qsets - (adap->params.nports - n10g)) / n10g;

n1g = adap->params.nports - n10g;
#ifdef CONFIG_CHELSIO_T4_DCB
/* For Data Center Bridging support we need to be able to support up
* to 8 Traffic Priorities; each of which will be assigned to its
Expand All @@ -5444,7 +5444,8 @@ static int cfg_queues(struct adapter *adap)
else
q10g = max(8U, q10g);

while ((q10g * n10g) > (avail_eth_qsets - n1g * q1g))
while ((q10g * n10g) >
(avail_eth_qsets - (adap->params.nports - n10g) * q1g))
q10g--;

#else /* !CONFIG_CHELSIO_T4_DCB */
Expand Down
3 changes: 2 additions & 1 deletion drivers/net/ethernet/chelsio/cxgb4/cxgb4_ptp.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ int cxgb4_ptp_redirect_rx_packet(struct adapter *adapter, struct port_info *pi)
}

/**
* cxgb4_ptp_adjfreq - Adjust frequency of PHC cycle counter
* @ptp: ptp clock structure
* @ppb: Desired frequency change in parts per billion
*
Expand Down Expand Up @@ -229,7 +230,7 @@ static int cxgb4_ptp_adjfreq(struct ptp_clock_info *ptp, s32 ppb)

/**
* cxgb4_ptp_fineadjtime - Shift the time of the hardware clock
* @ptp: ptp clock structure
* @adapter: board private structure
* @delta: Desired change in nanoseconds
*
* Adjust the timer by resetting the timecounter structure.
Expand Down
30 changes: 10 additions & 20 deletions drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,6 @@ static struct ch_tc_pedit_fields pedits[] = {
PEDIT_FIELDS(IP6_, DST_63_32, 4, nat_lip, 4),
PEDIT_FIELDS(IP6_, DST_95_64, 4, nat_lip, 8),
PEDIT_FIELDS(IP6_, DST_127_96, 4, nat_lip, 12),
PEDIT_FIELDS(TCP_, SPORT, 2, nat_fport, 0),
PEDIT_FIELDS(TCP_, DPORT, 2, nat_lport, 0),
PEDIT_FIELDS(UDP_, SPORT, 2, nat_fport, 0),
PEDIT_FIELDS(UDP_, DPORT, 2, nat_lport, 0),
};

static struct ch_tc_flower_entry *allocate_flower_entry(void)
Expand Down Expand Up @@ -156,14 +152,14 @@ static void cxgb4_process_flow_match(struct net_device *dev,
struct flow_match_ports match;

flow_rule_match_ports(rule, &match);
fs->val.lport = cpu_to_be16(match.key->dst);
fs->mask.lport = cpu_to_be16(match.mask->dst);
fs->val.fport = cpu_to_be16(match.key->src);
fs->mask.fport = cpu_to_be16(match.mask->src);
fs->val.lport = be16_to_cpu(match.key->dst);
fs->mask.lport = be16_to_cpu(match.mask->dst);
fs->val.fport = be16_to_cpu(match.key->src);
fs->mask.fport = be16_to_cpu(match.mask->src);

/* also initialize nat_lport/fport to same values */
fs->nat_lport = cpu_to_be16(match.key->dst);
fs->nat_fport = cpu_to_be16(match.key->src);
fs->nat_lport = fs->val.lport;
fs->nat_fport = fs->val.fport;
}

if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_IP)) {
Expand Down Expand Up @@ -354,25 +350,19 @@ static void process_pedit_field(struct ch_filter_specification *fs, u32 val,
switch (offset) {
case PEDIT_TCP_SPORT_DPORT:
if (~mask & PEDIT_TCP_UDP_SPORT_MASK)
offload_pedit(fs, cpu_to_be32(val) >> 16,
cpu_to_be32(mask) >> 16,
TCP_SPORT);
fs->nat_fport = val;
else
offload_pedit(fs, cpu_to_be32(val),
cpu_to_be32(mask), TCP_DPORT);
fs->nat_lport = val >> 16;
}
fs->nat_mode = NAT_MODE_ALL;
break;
case FLOW_ACT_MANGLE_HDR_TYPE_UDP:
switch (offset) {
case PEDIT_UDP_SPORT_DPORT:
if (~mask & PEDIT_TCP_UDP_SPORT_MASK)
offload_pedit(fs, cpu_to_be32(val) >> 16,
cpu_to_be32(mask) >> 16,
UDP_SPORT);
fs->nat_fport = val;
else
offload_pedit(fs, cpu_to_be32(val),
cpu_to_be32(mask), UDP_DPORT);
fs->nat_lport = val >> 16;
}
fs->nat_mode = NAT_MODE_ALL;
}
Expand Down
18 changes: 9 additions & 9 deletions drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ static int fill_match_fields(struct adapter *adap,
bool next_header)
{
unsigned int i, j;
u32 val, mask;
__be32 val, mask;
int off, err;
bool found;

Expand Down Expand Up @@ -228,7 +228,7 @@ int cxgb4_config_knode(struct net_device *dev, struct tc_cls_u32_offload *cls)
const struct cxgb4_next_header *next;
bool found = false;
unsigned int i, j;
u32 val, mask;
__be32 val, mask;
int off;

if (t->table[link_uhtid - 1].link_handle) {
Expand All @@ -242,10 +242,10 @@ int cxgb4_config_knode(struct net_device *dev, struct tc_cls_u32_offload *cls)

/* Try to find matches that allow jumps to next header. */
for (i = 0; next[i].jump; i++) {
if (next[i].offoff != cls->knode.sel->offoff ||
next[i].shift != cls->knode.sel->offshift ||
next[i].mask != cls->knode.sel->offmask ||
next[i].offset != cls->knode.sel->off)
if (next[i].sel.offoff != cls->knode.sel->offoff ||
next[i].sel.offshift != cls->knode.sel->offshift ||
next[i].sel.offmask != cls->knode.sel->offmask ||
next[i].sel.off != cls->knode.sel->off)
continue;

/* Found a possible candidate. Find a key that
Expand All @@ -257,9 +257,9 @@ int cxgb4_config_knode(struct net_device *dev, struct tc_cls_u32_offload *cls)
val = cls->knode.sel->keys[j].val;
mask = cls->knode.sel->keys[j].mask;

if (next[i].match_off == off &&
next[i].match_val == val &&
next[i].match_mask == mask) {
if (next[i].key.off == off &&
next[i].key.val == val &&
next[i].key.mask == mask) {
found = true;
break;
}
Expand Down
Loading

0 comments on commit a83024b

Please sign in to comment.