]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
igc: Add wildcard rule support to ethtool NFC using Default Queue
authorSong Yoong Siang <yoong.siang.song@intel.com>
Fri, 20 Jun 2025 10:02:51 +0000 (18:02 +0800)
committerTony Nguyen <anthony.l.nguyen@intel.com>
Fri, 18 Jul 2025 16:02:28 +0000 (09:02 -0700)
Introduce support for a lowest priority wildcard (catch-all) rule in
ethtool's Network Flow Classification (NFC) for the igc driver. The
wildcard rule directs all unmatched network traffic, including traffic not
captured by Receive Side Scaling (RSS), to a specified queue. This
functionality utilizes the Default Queue feature available in I225/I226
hardware.

The implementation has been validated on Intel ADL-S systems with two
back-to-back connected I226 network interfaces.

Testing Procedure:
1. On the Device Under Test (DUT), verify the initial statistic:
   $ ethtool -S enp1s0 | grep rx_q.*packets
        rx_queue_0_packets: 0
        rx_queue_1_packets: 0
        rx_queue_2_packets: 0
        rx_queue_3_packets: 0

2. From the Link Partner, send 10 ARP packets:
   $ arping -c 10 -I enp170s0 169.254.1.2

3. On the DUT, verify the packet reception on Queue 0:
   $ ethtool -S enp1s0 | grep rx_q.*packets
        rx_queue_0_packets: 10
        rx_queue_1_packets: 0
        rx_queue_2_packets: 0
        rx_queue_3_packets: 0

4. On the DUT, add a wildcard rule to route all packets to Queue 3:
   $ sudo ethtool -N enp1s0 flow-type ether queue 3

5. From the Link Partner, send another 10 ARP packets:
   $ arping -c 10 -I enp170s0 169.254.1.2

6. Now, packets are routed to Queue 3 by the wildcard (Default Queue) rule:
   $ ethtool -S enp1s0 | grep rx_q.*packets
        rx_queue_0_packets: 10
        rx_queue_1_packets: 0
        rx_queue_2_packets: 0
        rx_queue_3_packets: 10

7. On the DUT, add a EtherType rule to route ARP packet to Queue 1:
   $ sudo ethtool -N enp1s0 flow-type ether proto 0x0806 queue 1

8. From the Link Partner, send another 10 ARP packets:
   $ arping -c 10 -I enp170s0 169.254.1.2

9. Now, packets are routed to Queue 1 by the EtherType rule because it is
   higher priority than the wildcard (Default Queue) rule:
   $ ethtool -S enp1s0 | grep rx_q.*packets
        rx_queue_0_packets: 10
        rx_queue_1_packets: 10
        rx_queue_2_packets: 0
        rx_queue_3_packets: 10

10. On the DUT, delete all the NFC rules:
    $ sudo ethtool -N enp1s0 delete 63
    $ sudo ethtool -N enp1s0 delete 64

11. From the Link Partner, send another 10 ARP packets:
    $ arping -c 10 -I enp170s0 169.254.1.2

12. Now, packets are routed to Queue 0 because the value of Default Queue
    is reset back to 0:
    $ ethtool -S enp1s0 | grep rx_q.*packets
         rx_queue_0_packets: 20
         rx_queue_1_packets: 10
         rx_queue_2_packets: 0
         rx_queue_3_packets: 10

Reviewed-by: Kurt Kanzenbach <kurt@linutronix.de>
Co-developed-by: Blanco Alcaine Hector <hector.blanco.alcaine@intel.com>
Signed-off-by: Blanco Alcaine Hector <hector.blanco.alcaine@intel.com>
Signed-off-by: Song Yoong Siang <yoong.siang.song@intel.com>
Tested-by: Mor Bar-Gabay <morx.bar.gabay@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
drivers/net/ethernet/intel/igc/igc.h
drivers/net/ethernet/intel/igc/igc_defines.h
drivers/net/ethernet/intel/igc/igc_ethtool.c
drivers/net/ethernet/intel/igc/igc_main.c

index fdec66caef4d1aa48672dbb0da239f71a2a28441..266bfcf2a28f0298b9c92f88c3260288d8e3e669 100644 (file)
@@ -631,6 +631,7 @@ enum igc_filter_match_flags {
        IGC_FILTER_FLAG_DST_MAC_ADDR =  BIT(3),
        IGC_FILTER_FLAG_USER_DATA =     BIT(4),
        IGC_FILTER_FLAG_VLAN_ETYPE =    BIT(5),
+       IGC_FILTER_FLAG_DEFAULT_QUEUE = BIT(6),
 };
 
 struct igc_nfc_filter {
@@ -658,10 +659,14 @@ struct igc_nfc_rule {
        bool flex;
 };
 
-/* IGC supports a total of 32 NFC rules: 16 MAC address based, 8 VLAN priority
- * based, 8 ethertype based and 32 Flex filter based rules.
+/* IGC supports a total of 65 NFC rules, listed below in order of priority:
+ *  - 16 MAC address based filtering rules (highest priority)
+ *  - 8 ethertype based filtering rules
+ *  - 32 Flex filter based filtering rules
+ *  - 8 VLAN priority based filtering rules
+ *  - 1 default queue rule (lowest priority)
  */
-#define IGC_MAX_RXNFC_RULES            64
+#define IGC_MAX_RXNFC_RULES            65
 
 struct igc_flex_filter {
        u8 index;
index d80254f2a2784b7b0ffe1025f4cc7b5f6aefb0f5..498ba1522ca4d4bef9b9d20993c64c012e801dee 100644 (file)
 #define IGC_MRQC_RSS_FIELD_IPV6_TCP    0x00200000
 #define IGC_MRQC_RSS_FIELD_IPV4_UDP    0x00400000
 #define IGC_MRQC_RSS_FIELD_IPV6_UDP    0x00800000
+#define IGC_MRQC_DEFAULT_QUEUE_MASK    GENMASK(5, 3)
 
 /* Header split receive */
 #define IGC_RFCTL_IPV6_EX_DIS  0x00010000
index a7f397b58cd6c53e6402694daaf9195a83235daf..ecb35b693ce559e8be1b38d62c6f12f0f3e18d6a 100644 (file)
@@ -1283,6 +1283,24 @@ static void igc_ethtool_init_nfc_rule(struct igc_nfc_rule *rule,
                rule->flex = true;
        else
                rule->flex = false;
+
+       /* The wildcard rule is only applied if:
+        *  a) None of the other filtering rules match (match_flags is zero)
+        *  b) The flow type is ETHER_FLOW only (no additional fields set)
+        *  c) Mask for Source MAC address is not specified (all zeros)
+        *  d) Mask for Destination MAC address is not specified (all zeros)
+        *  e) Mask for L2 EtherType is not specified (zero)
+        *
+        * If all these conditions are met, the rule is treated as a wildcard
+        * rule. Default queue feature will be used, so that all packets that do
+        * not match any other rule will be routed to the default queue.
+        */
+       if (!rule->filter.match_flags &&
+           fsp->flow_type == ETHER_FLOW &&
+           is_zero_ether_addr(fsp->m_u.ether_spec.h_source) &&
+           is_zero_ether_addr(fsp->m_u.ether_spec.h_dest) &&
+           !fsp->m_u.ether_spec.h_proto)
+               rule->filter.match_flags = IGC_FILTER_FLAG_DEFAULT_QUEUE;
 }
 
 /**
index 32ea4fdd3e2bc904a466e700c863e5d8e09e1361..458e5eaa92e56e81db026ab3df514df9ae38bf1c 100644 (file)
@@ -3874,6 +3874,22 @@ static void igc_del_flex_filter(struct igc_adapter *adapter,
        wr32(IGC_WUFC, wufc);
 }
 
+static void igc_set_default_queue_filter(struct igc_adapter *adapter, u32 queue)
+{
+       struct igc_hw *hw = &adapter->hw;
+       u32 mrqc = rd32(IGC_MRQC);
+
+       mrqc &= ~IGC_MRQC_DEFAULT_QUEUE_MASK;
+       mrqc |= FIELD_PREP(IGC_MRQC_DEFAULT_QUEUE_MASK, queue);
+       wr32(IGC_MRQC, mrqc);
+}
+
+static void igc_reset_default_queue_filter(struct igc_adapter *adapter)
+{
+       /* Reset the default queue to its default value which is Queue 0 */
+       igc_set_default_queue_filter(adapter, 0);
+}
+
 static int igc_enable_nfc_rule(struct igc_adapter *adapter,
                               struct igc_nfc_rule *rule)
 {
@@ -3912,6 +3928,9 @@ static int igc_enable_nfc_rule(struct igc_adapter *adapter,
                        return err;
        }
 
+       if (rule->filter.match_flags & IGC_FILTER_FLAG_DEFAULT_QUEUE)
+               igc_set_default_queue_filter(adapter, rule->action);
+
        return 0;
 }
 
@@ -3939,6 +3958,9 @@ static void igc_disable_nfc_rule(struct igc_adapter *adapter,
        if (rule->filter.match_flags & IGC_FILTER_FLAG_DST_MAC_ADDR)
                igc_del_mac_filter(adapter, IGC_MAC_FILTER_TYPE_DST,
                                   rule->filter.dst_addr);
+
+       if (rule->filter.match_flags & IGC_FILTER_FLAG_DEFAULT_QUEUE)
+               igc_reset_default_queue_filter(adapter);
 }
 
 /**