Skip to content

Commit a83024b

Browse files
committed
Merge branch 'cxgb4-cxgb4vf-fix-warnings-reported-by-sparse'
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]>
2 parents 6199496 + 20bb0c8 commit a83024b

File tree

18 files changed

+211
-169
lines changed

18 files changed

+211
-169
lines changed

drivers/net/ethernet/chelsio/cxgb4/cudbg_lib.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1975,7 +1975,6 @@ int cudbg_collect_dump_context(struct cudbg_init *pdbg_init,
19751975
u8 mem_type[CTXT_INGRESS + 1] = { 0 };
19761976
struct cudbg_buffer temp_buff = { 0 };
19771977
struct cudbg_ch_cntxt *buff;
1978-
u64 *dst_off, *src_off;
19791978
u8 *ctx_buf;
19801979
u8 i, k;
19811980
int rc;
@@ -2044,8 +2043,11 @@ int cudbg_collect_dump_context(struct cudbg_init *pdbg_init,
20442043
}
20452044

20462045
for (j = 0; j < max_ctx_qid; j++) {
2046+
__be64 *dst_off;
2047+
u64 *src_off;
2048+
20472049
src_off = (u64 *)(ctx_buf + j * SGE_CTXT_SIZE);
2048-
dst_off = (u64 *)buff->data;
2050+
dst_off = (__be64 *)buff->data;
20492051

20502052
/* The data is stored in 64-bit cpu order. Convert it
20512053
* to big endian before parsing.

drivers/net/ethernet/chelsio/cxgb4/cxgb4_dcb.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,9 @@ static inline __u8 bitswap_1(unsigned char val)
136136
((val & 0x02) << 5) |
137137
((val & 0x01) << 7);
138138
}
139+
140+
extern const char * const dcb_ver_array[];
141+
139142
#define CXGB4_DCB_ENABLED true
140143

141144
#else /* !CONFIG_CHELSIO_T4_DCB */

drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2379,7 +2379,6 @@ static const struct file_operations rss_vf_config_debugfs_fops = {
23792379
};
23802380

23812381
#ifdef CONFIG_CHELSIO_T4_DCB
2382-
extern char *dcb_ver_array[];
23832382

23842383
/* Data Center Briging information for each port.
23852384
*/

drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,7 @@ static void fw_caps_to_lmm(enum fw_port_type port_type,
588588
/**
589589
* lmm_to_fw_caps - translate ethtool Link Mode Mask to Firmware
590590
* capabilities
591-
* @et_lmm: ethtool Link Mode Mask
591+
* @link_mode_mask: ethtool Link Mode Mask
592592
*
593593
* Translate ethtool Link Mode Mask into a Firmware Port capabilities
594594
* value.

drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,9 @@ static void set_nat_params(struct adapter *adap, struct filter_entry *f,
165165
unsigned int tid, bool dip, bool sip, bool dp,
166166
bool sp)
167167
{
168+
u8 *nat_lp = (u8 *)&f->fs.nat_lport;
169+
u8 *nat_fp = (u8 *)&f->fs.nat_fport;
170+
168171
if (dip) {
169172
if (f->fs.type) {
170173
set_tcb_field(adap, f, tid, TCB_SND_UNA_RAW_W,
@@ -236,8 +239,9 @@ static void set_nat_params(struct adapter *adap, struct filter_entry *f,
236239
}
237240

238241
set_tcb_field(adap, f, tid, TCB_PDU_HDR_LEN_W, WORD_MASK,
239-
(dp ? f->fs.nat_lport : 0) |
240-
(sp ? f->fs.nat_fport << 16 : 0), 1);
242+
(dp ? (nat_lp[1] | nat_lp[0] << 8) : 0) |
243+
(sp ? (nat_fp[1] << 16 | nat_fp[0] << 24) : 0),
244+
1);
241245
}
242246

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

911915
if (adapter->params.filter2_wr_support) {
916+
u8 *nat_lp = (u8 *)&f->fs.nat_lport;
917+
u8 *nat_fp = (u8 *)&f->fs.nat_fport;
918+
912919
fwr->natmode_to_ulp_type =
913920
FW_FILTER2_WR_ULP_TYPE_V(f->fs.nat_mode ?
914921
ULP_MODE_TCPDDP :
915922
ULP_MODE_NONE) |
916923
FW_FILTER2_WR_NATMODE_V(f->fs.nat_mode);
917924
memcpy(fwr->newlip, f->fs.nat_lip, sizeof(fwr->newlip));
918925
memcpy(fwr->newfip, f->fs.nat_fip, sizeof(fwr->newfip));
919-
fwr->newlport = htons(f->fs.nat_lport);
920-
fwr->newfport = htons(f->fs.nat_fport);
926+
fwr->newlport = htons(nat_lp[1] | nat_lp[0] << 8);
927+
fwr->newfport = htons(nat_fp[1] | nat_fp[0] << 8);
921928
}
922929

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

11071114
addr = (struct in_addr *)ipmask;
1108-
if (addr->s_addr == 0xffffffff)
1115+
if (ntohl(addr->s_addr) == 0xffffffff)
11091116
return true;
11101117
} else if (family == AF_INET6) {
11111118
struct in6_addr *addr6;
11121119

11131120
addr6 = (struct in6_addr *)ipmask;
1114-
if (addr6->s6_addr32[0] == 0xffffffff &&
1115-
addr6->s6_addr32[1] == 0xffffffff &&
1116-
addr6->s6_addr32[2] == 0xffffffff &&
1117-
addr6->s6_addr32[3] == 0xffffffff)
1121+
if (ntohl(addr6->s6_addr32[0]) == 0xffffffff &&
1122+
ntohl(addr6->s6_addr32[1]) == 0xffffffff &&
1123+
ntohl(addr6->s6_addr32[2]) == 0xffffffff &&
1124+
ntohl(addr6->s6_addr32[3]) == 0xffffffff)
11181125
return true;
11191126
}
11201127
return false;

drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ static int set_rxmode(struct net_device *dev, int mtu, bool sleep_ok)
449449
* or -1
450450
* @addr: the new MAC address value
451451
* @persist: whether a new MAC allocation should be persistent
452-
* @add_smt: if true also add the address to the HW SMT
452+
* @smt_idx: the destination to store the new SMT index.
453453
*
454454
* Modifies an MPS filter and sets it to the new MAC address if
455455
* @tcam_idx >= 0, or adds the MAC address to a new filter if
@@ -1615,6 +1615,7 @@ static int tid_init(struct tid_info *t)
16151615
* @stid: the server TID
16161616
* @sip: local IP address to bind server to
16171617
* @sport: the server's TCP port
1618+
* @vlan: the VLAN header information
16181619
* @queue: queue to direct messages from this server to
16191620
*
16201621
* Create an IP server for the given port and address.
@@ -2609,7 +2610,7 @@ int cxgb4_create_server_filter(const struct net_device *dev, unsigned int stid,
26092610

26102611
/* Clear out filter specifications */
26112612
memset(&f->fs, 0, sizeof(struct ch_filter_specification));
2612-
f->fs.val.lport = cpu_to_be16(sport);
2613+
f->fs.val.lport = be16_to_cpu(sport);
26132614
f->fs.mask.lport = ~0;
26142615
val = (u8 *)&sip;
26152616
if ((val[0] | val[1] | val[2] | val[3]) != 0) {
@@ -5377,10 +5378,10 @@ static inline bool is_x_10g_port(const struct link_config *lc)
53775378
static int cfg_queues(struct adapter *adap)
53785379
{
53795380
u32 avail_qsets, avail_eth_qsets, avail_uld_qsets;
5380-
u32 i, n10g = 0, qidx = 0, n1g = 0;
53815381
u32 ncpus = num_online_cpus();
53825382
u32 niqflint, neq, num_ulds;
53835383
struct sge *s = &adap->sge;
5384+
u32 i, n10g = 0, qidx = 0;
53845385
u32 q10g = 0, q1g;
53855386

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

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

5447-
while ((q10g * n10g) > (avail_eth_qsets - n1g * q1g))
5447+
while ((q10g * n10g) >
5448+
(avail_eth_qsets - (adap->params.nports - n10g) * q1g))
54485449
q10g--;
54495450

54505451
#else /* !CONFIG_CHELSIO_T4_DCB */

drivers/net/ethernet/chelsio/cxgb4/cxgb4_ptp.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ int cxgb4_ptp_redirect_rx_packet(struct adapter *adapter, struct port_info *pi)
194194
}
195195

196196
/**
197+
* cxgb4_ptp_adjfreq - Adjust frequency of PHC cycle counter
197198
* @ptp: ptp clock structure
198199
* @ppb: Desired frequency change in parts per billion
199200
*
@@ -229,7 +230,7 @@ static int cxgb4_ptp_adjfreq(struct ptp_clock_info *ptp, s32 ppb)
229230

230231
/**
231232
* cxgb4_ptp_fineadjtime - Shift the time of the hardware clock
232-
* @ptp: ptp clock structure
233+
* @adapter: board private structure
233234
* @delta: Desired change in nanoseconds
234235
*
235236
* Adjust the timer by resetting the timecounter structure.

drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.c

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,6 @@ static struct ch_tc_pedit_fields pedits[] = {
5858
PEDIT_FIELDS(IP6_, DST_63_32, 4, nat_lip, 4),
5959
PEDIT_FIELDS(IP6_, DST_95_64, 4, nat_lip, 8),
6060
PEDIT_FIELDS(IP6_, DST_127_96, 4, nat_lip, 12),
61-
PEDIT_FIELDS(TCP_, SPORT, 2, nat_fport, 0),
62-
PEDIT_FIELDS(TCP_, DPORT, 2, nat_lport, 0),
63-
PEDIT_FIELDS(UDP_, SPORT, 2, nat_fport, 0),
64-
PEDIT_FIELDS(UDP_, DPORT, 2, nat_lport, 0),
6561
};
6662

6763
static struct ch_tc_flower_entry *allocate_flower_entry(void)
@@ -156,14 +152,14 @@ static void cxgb4_process_flow_match(struct net_device *dev,
156152
struct flow_match_ports match;
157153

158154
flow_rule_match_ports(rule, &match);
159-
fs->val.lport = cpu_to_be16(match.key->dst);
160-
fs->mask.lport = cpu_to_be16(match.mask->dst);
161-
fs->val.fport = cpu_to_be16(match.key->src);
162-
fs->mask.fport = cpu_to_be16(match.mask->src);
155+
fs->val.lport = be16_to_cpu(match.key->dst);
156+
fs->mask.lport = be16_to_cpu(match.mask->dst);
157+
fs->val.fport = be16_to_cpu(match.key->src);
158+
fs->mask.fport = be16_to_cpu(match.mask->src);
163159

164160
/* also initialize nat_lport/fport to same values */
165-
fs->nat_lport = cpu_to_be16(match.key->dst);
166-
fs->nat_fport = cpu_to_be16(match.key->src);
161+
fs->nat_lport = fs->val.lport;
162+
fs->nat_fport = fs->val.fport;
167163
}
168164

169165
if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_IP)) {
@@ -354,25 +350,19 @@ static void process_pedit_field(struct ch_filter_specification *fs, u32 val,
354350
switch (offset) {
355351
case PEDIT_TCP_SPORT_DPORT:
356352
if (~mask & PEDIT_TCP_UDP_SPORT_MASK)
357-
offload_pedit(fs, cpu_to_be32(val) >> 16,
358-
cpu_to_be32(mask) >> 16,
359-
TCP_SPORT);
353+
fs->nat_fport = val;
360354
else
361-
offload_pedit(fs, cpu_to_be32(val),
362-
cpu_to_be32(mask), TCP_DPORT);
355+
fs->nat_lport = val >> 16;
363356
}
364357
fs->nat_mode = NAT_MODE_ALL;
365358
break;
366359
case FLOW_ACT_MANGLE_HDR_TYPE_UDP:
367360
switch (offset) {
368361
case PEDIT_UDP_SPORT_DPORT:
369362
if (~mask & PEDIT_TCP_UDP_SPORT_MASK)
370-
offload_pedit(fs, cpu_to_be32(val) >> 16,
371-
cpu_to_be32(mask) >> 16,
372-
UDP_SPORT);
363+
fs->nat_fport = val;
373364
else
374-
offload_pedit(fs, cpu_to_be32(val),
375-
cpu_to_be32(mask), UDP_DPORT);
365+
fs->nat_lport = val >> 16;
376366
}
377367
fs->nat_mode = NAT_MODE_ALL;
378368
}

drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ static int fill_match_fields(struct adapter *adap,
4848
bool next_header)
4949
{
5050
unsigned int i, j;
51-
u32 val, mask;
51+
__be32 val, mask;
5252
int off, err;
5353
bool found;
5454

@@ -228,7 +228,7 @@ int cxgb4_config_knode(struct net_device *dev, struct tc_cls_u32_offload *cls)
228228
const struct cxgb4_next_header *next;
229229
bool found = false;
230230
unsigned int i, j;
231-
u32 val, mask;
231+
__be32 val, mask;
232232
int off;
233233

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

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

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

260-
if (next[i].match_off == off &&
261-
next[i].match_val == val &&
262-
next[i].match_mask == mask) {
260+
if (next[i].key.off == off &&
261+
next[i].key.val == val &&
262+
next[i].key.mask == mask) {
263263
found = true;
264264
break;
265265
}

0 commit comments

Comments
 (0)