Skip to content

Commit b77c1e3

Browse files
committed
Merge branch '1GbE' of git://git.kernel.org/pub/scm/linux/kernel/git/tnguy/net-queue
Tony Nguyen says: ==================== Intel Wired LAN Driver Updates 2023-12-27 (igc) This series contains updates to igc driver only. Kurt Kanzenbach resolves issues around VLAN ntuple rules; correctly reporting back added rules and checking for valid values. * '1GbE' of git://git.kernel.org/pub/scm/linux/kernel/git/tnguy/net-queue: igc: Check VLAN EtherType mask igc: Check VLAN TCI mask igc: Report VLAN EtherType matching back to user ==================== Link: https://lore.kernel.org/r/20231227210041.3035055-1-anthony.l.nguyen@intel.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2 parents 0fa4f91 + 7afd49a commit b77c1e3

File tree

2 files changed

+40
-3
lines changed

2 files changed

+40
-3
lines changed

drivers/net/ethernet/intel/igc/igc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,7 @@ struct igc_nfc_filter {
568568
u16 etype;
569569
__be16 vlan_etype;
570570
u16 vlan_tci;
571+
u16 vlan_tci_mask;
571572
u8 src_addr[ETH_ALEN];
572573
u8 dst_addr[ETH_ALEN];
573574
u8 user_data[8];

drivers/net/ethernet/intel/igc/igc_ethtool.c

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -958,6 +958,7 @@ static int igc_ethtool_set_coalesce(struct net_device *netdev,
958958
}
959959

960960
#define ETHER_TYPE_FULL_MASK ((__force __be16)~0)
961+
#define VLAN_TCI_FULL_MASK ((__force __be16)~0)
961962
static int igc_ethtool_get_nfc_rule(struct igc_adapter *adapter,
962963
struct ethtool_rxnfc *cmd)
963964
{
@@ -980,10 +981,16 @@ static int igc_ethtool_get_nfc_rule(struct igc_adapter *adapter,
980981
fsp->m_u.ether_spec.h_proto = ETHER_TYPE_FULL_MASK;
981982
}
982983

984+
if (rule->filter.match_flags & IGC_FILTER_FLAG_VLAN_ETYPE) {
985+
fsp->flow_type |= FLOW_EXT;
986+
fsp->h_ext.vlan_etype = rule->filter.vlan_etype;
987+
fsp->m_ext.vlan_etype = ETHER_TYPE_FULL_MASK;
988+
}
989+
983990
if (rule->filter.match_flags & IGC_FILTER_FLAG_VLAN_TCI) {
984991
fsp->flow_type |= FLOW_EXT;
985992
fsp->h_ext.vlan_tci = htons(rule->filter.vlan_tci);
986-
fsp->m_ext.vlan_tci = htons(VLAN_PRIO_MASK);
993+
fsp->m_ext.vlan_tci = htons(rule->filter.vlan_tci_mask);
987994
}
988995

989996
if (rule->filter.match_flags & IGC_FILTER_FLAG_DST_MAC_ADDR) {
@@ -1218,6 +1225,7 @@ static void igc_ethtool_init_nfc_rule(struct igc_nfc_rule *rule,
12181225

12191226
if ((fsp->flow_type & FLOW_EXT) && fsp->m_ext.vlan_tci) {
12201227
rule->filter.vlan_tci = ntohs(fsp->h_ext.vlan_tci);
1228+
rule->filter.vlan_tci_mask = ntohs(fsp->m_ext.vlan_tci);
12211229
rule->filter.match_flags |= IGC_FILTER_FLAG_VLAN_TCI;
12221230
}
12231231

@@ -1255,11 +1263,19 @@ static void igc_ethtool_init_nfc_rule(struct igc_nfc_rule *rule,
12551263
memcpy(rule->filter.user_mask, fsp->m_ext.data, sizeof(fsp->m_ext.data));
12561264
}
12571265

1258-
/* When multiple filter options or user data or vlan etype is set, use a
1259-
* flex filter.
1266+
/* The i225/i226 has various different filters. Flex filters provide a
1267+
* way to match up to the first 128 bytes of a packet. Use them for:
1268+
* a) For specific user data
1269+
* b) For VLAN EtherType
1270+
* c) For full TCI match
1271+
* d) Or in case multiple filter criteria are set
1272+
*
1273+
* Otherwise, use the simple MAC, VLAN PRIO or EtherType filters.
12601274
*/
12611275
if ((rule->filter.match_flags & IGC_FILTER_FLAG_USER_DATA) ||
12621276
(rule->filter.match_flags & IGC_FILTER_FLAG_VLAN_ETYPE) ||
1277+
((rule->filter.match_flags & IGC_FILTER_FLAG_VLAN_TCI) &&
1278+
rule->filter.vlan_tci_mask == ntohs(VLAN_TCI_FULL_MASK)) ||
12631279
(rule->filter.match_flags & (rule->filter.match_flags - 1)))
12641280
rule->flex = true;
12651281
else
@@ -1329,6 +1345,26 @@ static int igc_ethtool_add_nfc_rule(struct igc_adapter *adapter,
13291345
return -EINVAL;
13301346
}
13311347

1348+
/* There are two ways to match the VLAN TCI:
1349+
* 1. Match on PCP field and use vlan prio filter for it
1350+
* 2. Match on complete TCI field and use flex filter for it
1351+
*/
1352+
if ((fsp->flow_type & FLOW_EXT) &&
1353+
fsp->m_ext.vlan_tci &&
1354+
fsp->m_ext.vlan_tci != htons(VLAN_PRIO_MASK) &&
1355+
fsp->m_ext.vlan_tci != VLAN_TCI_FULL_MASK) {
1356+
netdev_dbg(netdev, "VLAN mask not supported\n");
1357+
return -EOPNOTSUPP;
1358+
}
1359+
1360+
/* VLAN EtherType can only be matched by full mask. */
1361+
if ((fsp->flow_type & FLOW_EXT) &&
1362+
fsp->m_ext.vlan_etype &&
1363+
fsp->m_ext.vlan_etype != ETHER_TYPE_FULL_MASK) {
1364+
netdev_dbg(netdev, "VLAN EtherType mask not supported\n");
1365+
return -EOPNOTSUPP;
1366+
}
1367+
13321368
if (fsp->location >= IGC_MAX_RXNFC_RULES) {
13331369
netdev_dbg(netdev, "Invalid location\n");
13341370
return -EINVAL;

0 commit comments

Comments
 (0)