Skip to content

Commit 820a38d

Browse files
committed
Merge branch '40GbE' of git://git.kernel.org/pub/scm/linux/kernel/git/tnguy/net-queue
Tony Nguyen says: ==================== Intel Wired LAN Driver Updates 2023-08-16 (iavf, i40e) This series contains updates to iavf and i40e drivers. Piotr adds checks for unsupported Flow Director rules on iavf. Andrii replaces incorrect 'write' messaging on read operations for i40e. * '40GbE' of git://git.kernel.org/pub/scm/linux/kernel/git/tnguy/net-queue: i40e: fix misleading debug logs iavf: fix FDIR rule fields masks validation ==================== Link: https://lore.kernel.org/r/20230816193308.1307535-1-anthony.l.nguyen@intel.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2 parents e9bbd60 + 2f2beb8 commit 820a38d

File tree

4 files changed

+93
-12
lines changed

4 files changed

+93
-12
lines changed

drivers/net/ethernet/intel/i40e/i40e_nvm.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -210,11 +210,11 @@ static int i40e_read_nvm_word_srctl(struct i40e_hw *hw, u16 offset,
210210
* @hw: pointer to the HW structure.
211211
* @module_pointer: module pointer location in words from the NVM beginning
212212
* @offset: offset in words from module start
213-
* @words: number of words to write
214-
* @data: buffer with words to write to the Shadow RAM
213+
* @words: number of words to read
214+
* @data: buffer with words to read to the Shadow RAM
215215
* @last_command: tells the AdminQ that this is the last command
216216
*
217-
* Writes a 16 bit words buffer to the Shadow RAM using the admin command.
217+
* Reads a 16 bit words buffer to the Shadow RAM using the admin command.
218218
**/
219219
static int i40e_read_nvm_aq(struct i40e_hw *hw,
220220
u8 module_pointer, u32 offset,
@@ -234,18 +234,18 @@ static int i40e_read_nvm_aq(struct i40e_hw *hw,
234234
*/
235235
if ((offset + words) > hw->nvm.sr_size)
236236
i40e_debug(hw, I40E_DEBUG_NVM,
237-
"NVM write error: offset %d beyond Shadow RAM limit %d\n",
237+
"NVM read error: offset %d beyond Shadow RAM limit %d\n",
238238
(offset + words), hw->nvm.sr_size);
239239
else if (words > I40E_SR_SECTOR_SIZE_IN_WORDS)
240-
/* We can write only up to 4KB (one sector), in one AQ write */
240+
/* We can read only up to 4KB (one sector), in one AQ write */
241241
i40e_debug(hw, I40E_DEBUG_NVM,
242-
"NVM write fail error: tried to write %d words, limit is %d.\n",
242+
"NVM read fail error: tried to read %d words, limit is %d.\n",
243243
words, I40E_SR_SECTOR_SIZE_IN_WORDS);
244244
else if (((offset + (words - 1)) / I40E_SR_SECTOR_SIZE_IN_WORDS)
245245
!= (offset / I40E_SR_SECTOR_SIZE_IN_WORDS))
246-
/* A single write cannot spread over two sectors */
246+
/* A single read cannot spread over two sectors */
247247
i40e_debug(hw, I40E_DEBUG_NVM,
248-
"NVM write error: cannot spread over two sectors in a single write offset=%d words=%d\n",
248+
"NVM read error: cannot spread over two sectors in a single read offset=%d words=%d\n",
249249
offset, words);
250250
else
251251
ret_code = i40e_aq_read_nvm(hw, module_pointer,

drivers/net/ethernet/intel/iavf/iavf_ethtool.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1289,6 +1289,7 @@ iavf_add_fdir_fltr_info(struct iavf_adapter *adapter, struct ethtool_rx_flow_spe
12891289
fltr->ip_mask.src_port = fsp->m_u.tcp_ip4_spec.psrc;
12901290
fltr->ip_mask.dst_port = fsp->m_u.tcp_ip4_spec.pdst;
12911291
fltr->ip_mask.tos = fsp->m_u.tcp_ip4_spec.tos;
1292+
fltr->ip_ver = 4;
12921293
break;
12931294
case AH_V4_FLOW:
12941295
case ESP_V4_FLOW:
@@ -1300,6 +1301,7 @@ iavf_add_fdir_fltr_info(struct iavf_adapter *adapter, struct ethtool_rx_flow_spe
13001301
fltr->ip_mask.v4_addrs.dst_ip = fsp->m_u.ah_ip4_spec.ip4dst;
13011302
fltr->ip_mask.spi = fsp->m_u.ah_ip4_spec.spi;
13021303
fltr->ip_mask.tos = fsp->m_u.ah_ip4_spec.tos;
1304+
fltr->ip_ver = 4;
13031305
break;
13041306
case IPV4_USER_FLOW:
13051307
fltr->ip_data.v4_addrs.src_ip = fsp->h_u.usr_ip4_spec.ip4src;
@@ -1312,6 +1314,7 @@ iavf_add_fdir_fltr_info(struct iavf_adapter *adapter, struct ethtool_rx_flow_spe
13121314
fltr->ip_mask.l4_header = fsp->m_u.usr_ip4_spec.l4_4_bytes;
13131315
fltr->ip_mask.tos = fsp->m_u.usr_ip4_spec.tos;
13141316
fltr->ip_mask.proto = fsp->m_u.usr_ip4_spec.proto;
1317+
fltr->ip_ver = 4;
13151318
break;
13161319
case TCP_V6_FLOW:
13171320
case UDP_V6_FLOW:
@@ -1330,6 +1333,7 @@ iavf_add_fdir_fltr_info(struct iavf_adapter *adapter, struct ethtool_rx_flow_spe
13301333
fltr->ip_mask.src_port = fsp->m_u.tcp_ip6_spec.psrc;
13311334
fltr->ip_mask.dst_port = fsp->m_u.tcp_ip6_spec.pdst;
13321335
fltr->ip_mask.tclass = fsp->m_u.tcp_ip6_spec.tclass;
1336+
fltr->ip_ver = 6;
13331337
break;
13341338
case AH_V6_FLOW:
13351339
case ESP_V6_FLOW:
@@ -1345,6 +1349,7 @@ iavf_add_fdir_fltr_info(struct iavf_adapter *adapter, struct ethtool_rx_flow_spe
13451349
sizeof(struct in6_addr));
13461350
fltr->ip_mask.spi = fsp->m_u.ah_ip6_spec.spi;
13471351
fltr->ip_mask.tclass = fsp->m_u.ah_ip6_spec.tclass;
1352+
fltr->ip_ver = 6;
13481353
break;
13491354
case IPV6_USER_FLOW:
13501355
memcpy(&fltr->ip_data.v6_addrs.src_ip, fsp->h_u.usr_ip6_spec.ip6src,
@@ -1361,6 +1366,7 @@ iavf_add_fdir_fltr_info(struct iavf_adapter *adapter, struct ethtool_rx_flow_spe
13611366
fltr->ip_mask.l4_header = fsp->m_u.usr_ip6_spec.l4_4_bytes;
13621367
fltr->ip_mask.tclass = fsp->m_u.usr_ip6_spec.tclass;
13631368
fltr->ip_mask.proto = fsp->m_u.usr_ip6_spec.l4_proto;
1369+
fltr->ip_ver = 6;
13641370
break;
13651371
case ETHER_FLOW:
13661372
fltr->eth_data.etype = fsp->h_u.ether_spec.h_proto;
@@ -1371,6 +1377,10 @@ iavf_add_fdir_fltr_info(struct iavf_adapter *adapter, struct ethtool_rx_flow_spe
13711377
return -EINVAL;
13721378
}
13731379

1380+
err = iavf_validate_fdir_fltr_masks(adapter, fltr);
1381+
if (err)
1382+
return err;
1383+
13741384
if (iavf_fdir_is_dup_fltr(adapter, fltr))
13751385
return -EEXIST;
13761386

drivers/net/ethernet/intel/iavf/iavf_fdir.c

Lines changed: 73 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,79 @@ static const struct in6_addr ipv6_addr_full_mask = {
1818
}
1919
};
2020

21+
static const struct in6_addr ipv6_addr_zero_mask = {
22+
.in6_u = {
23+
.u6_addr8 = {
24+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
25+
}
26+
}
27+
};
28+
29+
/**
30+
* iavf_validate_fdir_fltr_masks - validate Flow Director filter fields masks
31+
* @adapter: pointer to the VF adapter structure
32+
* @fltr: Flow Director filter data structure
33+
*
34+
* Returns 0 if all masks of packet fields are either full or empty. Returns
35+
* error on at least one partial mask.
36+
*/
37+
int iavf_validate_fdir_fltr_masks(struct iavf_adapter *adapter,
38+
struct iavf_fdir_fltr *fltr)
39+
{
40+
if (fltr->eth_mask.etype && fltr->eth_mask.etype != htons(U16_MAX))
41+
goto partial_mask;
42+
43+
if (fltr->ip_ver == 4) {
44+
if (fltr->ip_mask.v4_addrs.src_ip &&
45+
fltr->ip_mask.v4_addrs.src_ip != htonl(U32_MAX))
46+
goto partial_mask;
47+
48+
if (fltr->ip_mask.v4_addrs.dst_ip &&
49+
fltr->ip_mask.v4_addrs.dst_ip != htonl(U32_MAX))
50+
goto partial_mask;
51+
52+
if (fltr->ip_mask.tos && fltr->ip_mask.tos != U8_MAX)
53+
goto partial_mask;
54+
} else if (fltr->ip_ver == 6) {
55+
if (memcmp(&fltr->ip_mask.v6_addrs.src_ip, &ipv6_addr_zero_mask,
56+
sizeof(struct in6_addr)) &&
57+
memcmp(&fltr->ip_mask.v6_addrs.src_ip, &ipv6_addr_full_mask,
58+
sizeof(struct in6_addr)))
59+
goto partial_mask;
60+
61+
if (memcmp(&fltr->ip_mask.v6_addrs.dst_ip, &ipv6_addr_zero_mask,
62+
sizeof(struct in6_addr)) &&
63+
memcmp(&fltr->ip_mask.v6_addrs.dst_ip, &ipv6_addr_full_mask,
64+
sizeof(struct in6_addr)))
65+
goto partial_mask;
66+
67+
if (fltr->ip_mask.tclass && fltr->ip_mask.tclass != U8_MAX)
68+
goto partial_mask;
69+
}
70+
71+
if (fltr->ip_mask.proto && fltr->ip_mask.proto != U8_MAX)
72+
goto partial_mask;
73+
74+
if (fltr->ip_mask.src_port && fltr->ip_mask.src_port != htons(U16_MAX))
75+
goto partial_mask;
76+
77+
if (fltr->ip_mask.dst_port && fltr->ip_mask.dst_port != htons(U16_MAX))
78+
goto partial_mask;
79+
80+
if (fltr->ip_mask.spi && fltr->ip_mask.spi != htonl(U32_MAX))
81+
goto partial_mask;
82+
83+
if (fltr->ip_mask.l4_header &&
84+
fltr->ip_mask.l4_header != htonl(U32_MAX))
85+
goto partial_mask;
86+
87+
return 0;
88+
89+
partial_mask:
90+
dev_err(&adapter->pdev->dev, "Failed to add Flow Director filter, partial masks are not supported\n");
91+
return -EOPNOTSUPP;
92+
}
93+
2194
/**
2295
* iavf_pkt_udp_no_pay_len - the length of UDP packet without payload
2396
* @fltr: Flow Director filter data structure
@@ -263,8 +336,6 @@ iavf_fill_fdir_ip4_hdr(struct iavf_fdir_fltr *fltr,
263336
VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT(hdr, IPV4, DST);
264337
}
265338

266-
fltr->ip_ver = 4;
267-
268339
return 0;
269340
}
270341

@@ -309,8 +380,6 @@ iavf_fill_fdir_ip6_hdr(struct iavf_fdir_fltr *fltr,
309380
VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT(hdr, IPV6, DST);
310381
}
311382

312-
fltr->ip_ver = 6;
313-
314383
return 0;
315384
}
316385

drivers/net/ethernet/intel/iavf/iavf_fdir.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ struct iavf_fdir_fltr {
110110
struct virtchnl_fdir_add vc_add_msg;
111111
};
112112

113+
int iavf_validate_fdir_fltr_masks(struct iavf_adapter *adapter,
114+
struct iavf_fdir_fltr *fltr);
113115
int iavf_fill_fdir_add_msg(struct iavf_adapter *adapter, struct iavf_fdir_fltr *fltr);
114116
void iavf_print_fdir_fltr(struct iavf_adapter *adapter, struct iavf_fdir_fltr *fltr);
115117
bool iavf_fdir_is_dup_fltr(struct iavf_adapter *adapter, struct iavf_fdir_fltr *fltr);

0 commit comments

Comments
 (0)