Skip to contentSkip to conversation

igb: offloading of receive filters

PATCH Superseded Vinicius Costa Gomes 2 participants 13 messages Mar 2, 2018 – Mar 6, 2018

Subsystems (3)

v2 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

v2 cover igb: offloading of receive filters

Hi,

Changes from v1:
- Addressed review comments from Alexander Duyck and Florian Fainelli;
- Adding and removing cls_flower filters are now proposed in the same patch;
- cls_flower filters are kept in a separated list from "ethtool" filters (so that section of the original cover letter is no longer valid);
- The patch adding support for ethtool filters is now independent from the rest of the series;

Original cover letter:

This series enables some ethtool and tc-flower filters to be offloaded to igb-based network controllers. This is useful when the system configurator want to steer kinds of traffic to a specific hardware queue.

The first two commits are bug fixes.

The basis of this series is to export the internal API used to configure address filters, so they can be used by ethtool, and extending the functionality so an source address can be handled.

Then, we enable the tc-flower offloading implementation to re-use the same infrastructure as ethtool, and storing them in the per-adapter "nfc" (Network Filter Config?) list. But for consistency, for destructive access they are separated, i.e. an filter added by tc-flower can only be removed by tc-flower, but ethtool can read them all.

Only support for VLAN Prio, Source and Destination MAC Address, and Ethertype is enabled for now.

Open question:
- igb is initialized with the number of traffic classes as 1, if we want to use multiple traffic classes we need to increase this value, the only way I could find is to use mqprio (for example). Should igb be initialized with, say, the number of queues as its "num_tc"?

Vinicius Costa Gomes (8):
igb: Fix not adding filter elements to the list
igb: Fix queue selection on MAC filters on i210 and i211
igb: Enable the hardware traffic class feature bit for igb models
igb: Add support for MAC address filters specifying source addresses
igb: Enable nfc filters to specify MAC addresses
igb: Add MAC address support for ethtool nftuple filters
igb: Add the skeletons for tc-flower offloading
igb: Add support for adding offloaded clsflower filters

 drivers/net/ethernet/intel/igb/e1000_defines.h |   2 +
 drivers/net/ethernet/intel/igb/igb.h           |  12 +
 drivers/net/ethernet/intel/igb/igb_ethtool.c   |  65 +++++-
 drivers/net/ethernet/intel/igb/igb_main.c      | 294 ++++++++++++++++++++++++-
 4 files changed, 359 insertions(+), 14 deletions(-)

--
2.16.2

#1 lore raw

PATCH v2 1/8 igb: Fix not adding filter elements to the list

Because the order of the parameters passes to 'hlist_add_behind()' was inverted, the 'parent' node was added "behind" the 'input', as input is not in the list, this causes the 'input' node to be lost.

Fixes 0e71def25281 ("igb: add support of RX network flow classification")
---
 drivers/net/ethernet/intel/igb/igb_ethtool.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/intel/igb/igb_ethtool.c +1 -1
index 606e6761758f..143f0bb34e4d 100644
@@ -2864,7 +2864,7 @@ static int igb_update_ethtool_nfc_entry(struct igb_adapter *adapter,
 
 	/* add filter to the list */
 	if (parent)
-		hlist_add_behind(&parent->nfc_node, &input->nfc_node);
+		hlist_add_behind(&input->nfc_node, &parent->nfc_node);
 	else
 		hlist_add_head(&input->nfc_node, &adapter->nfc_filter_list);
 
Signature · 1 line
2.16.2
#2 lore raw

PATCH v2 2/8 igb: Fix queue selection on MAC filters on i210 and i211

In reply to Vinicius Costa Gomes

On the RAH registers there are semantic differences on the meaning of the "queue" parameter for traffic steering depending on the controller
model: there is the 82575 meaning, which "queue" means a RX Hardware Queue, and the i350 meaning, where it is a reception pool.

The previous behaviour was having no effect for i210 and i211 based controllers because the QSEL bit of the RAH register wasn't being set.

This patch separates the condition in discrete cases, so the different handling is clearer.

Fixes 83c21335c876 ("igb: improve MAC filter handling")
---
 drivers/net/ethernet/intel/igb/e1000_defines.h |  1 +
 drivers/net/ethernet/intel/igb/igb_main.c      | 15 +++++++++++----
 2 files changed, 12 insertions(+), 4 deletions(-)
drivers/net/ethernet/intel/igb/e1000_defines.h +1 -0
index 83cabff1e0ab..573bf177fd08 100644
@@ -490,6 +490,7 @@
  * manageability enabled, allowing us room for 15 multicast addresses.
  */
 #define E1000_RAH_AV  0x80000000        /* Receive descriptor valid */
+#define E1000_RAH_QSEL_ENABLE 0x10000000
 #define E1000_RAL_MAC_ADDR_LEN 4
 #define E1000_RAH_MAC_ADDR_LEN 2
 #define E1000_RAH_POOL_MASK 0x03FC0000
drivers/net/ethernet/intel/igb/igb_main.c +11 -4
index b88fae785369..0ea32be07d71 100644
@@ -8741,12 +8741,19 @@ static void igb_rar_set_index(struct igb_adapter *adapter, u32 index)
 		if (is_valid_ether_addr(addr))
 			rar_high |= E1000_RAH_AV;
 
-		if (hw->mac.type == e1000_82575)
+		switch (hw->mac.type) {
+		case e1000_82575:
+		case e1000_i210:
+		case e1000_i211:
+			rar_high |= E1000_RAH_QSEL_ENABLE;
 			rar_high |= E1000_RAH_POOL_1 *
-				    adapter->mac_table[index].queue;
-		else
+				      adapter->mac_table[index].queue;
+			break;
+		default:
 			rar_high |= E1000_RAH_POOL_1 <<
-				    adapter->mac_table[index].queue;
+				adapter->mac_table[index].queue;
+			break;
+		}
 	}
 
 	wr32(E1000_RAL(index), rar_low);
Signature · 1 line
2.16.2
#3 lore raw

PATCH v2 3/8 igb: Enable the hardware traffic class feature bit for igb models

In reply to Vinicius Costa Gomes

This will allow functionality depending on the hardware being traffic class aware to work. In particular the tc-flower offloading checks verifies that this bit is set.

---
 drivers/net/ethernet/intel/igb/igb_main.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/net/ethernet/intel/igb/igb_main.c +3 -0
index 0ea32be07d71..3c4d209aad76 100644
@@ -2804,6 +2804,9 @@ static int igb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 	if (hw->mac.type >= e1000_82576)
 		netdev->features |= NETIF_F_SCTP_CRC;
 
+	if (hw->mac.type >= e1000_i350)
+		netdev->features |= NETIF_F_HW_TC;
+
 #define IGB_GSO_PARTIAL_FEATURES (NETIF_F_GSO_GRE | \
 				  NETIF_F_GSO_GRE_CSUM | \
 				  NETIF_F_GSO_IPXIP4 | \
Signature · 1 line
2.16.2
#4 lore raw

PATCH v2 4/8 igb: Add support for MAC address filters specifying source addresses

In reply to Vinicius Costa Gomes

Makes it possible to direct packets to queues based on their source address. Documents the expected usage of the 'flags' parameter.

---
 drivers/net/ethernet/intel/igb/e1000_defines.h |  1 +
 drivers/net/ethernet/intel/igb/igb.h           |  1 +
 drivers/net/ethernet/intel/igb/igb_main.c      | 38 ++++++++++++++++++++++----
 3 files changed, 35 insertions(+), 5 deletions(-)
drivers/net/ethernet/intel/igb/e1000_defines.h +1 -0
index 573bf177fd08..c6f552de30dd 100644
@@ -490,6 +490,7 @@
  * manageability enabled, allowing us room for 15 multicast addresses.
  */
 #define E1000_RAH_AV  0x80000000        /* Receive descriptor valid */
+#define E1000_RAH_ASEL_SRC_ADDR 0x00010000
 #define E1000_RAH_QSEL_ENABLE 0x10000000
 #define E1000_RAL_MAC_ADDR_LEN 4
 #define E1000_RAH_MAC_ADDR_LEN 2
drivers/net/ethernet/intel/igb/igb.h +1 -0
index 1c6b8d9176a8..d5cd5f6708d9 100644
@@ -472,6 +472,7 @@ struct igb_mac_addr {
 
 #define IGB_MAC_STATE_DEFAULT	0x1
 #define IGB_MAC_STATE_IN_USE	0x2
+#define IGB_MAC_STATE_SRC_ADDR  0x4
 
 /* board specific private data structure */
 struct igb_adapter {
drivers/net/ethernet/intel/igb/igb_main.c +33 -5
index 3c4d209aad76..1df1c5a99a0d 100644
@@ -6838,8 +6838,13 @@ static void igb_set_default_mac_filter(struct igb_adapter *adapter)
 	igb_rar_set_index(adapter, 0);
 }
 
-static int igb_add_mac_filter(struct igb_adapter *adapter, const u8 *addr,
-			      const u8 queue)
+/* Add a MAC filter for 'addr' directing matching traffic to 'queue',
+ * 'flags' is used to indicate what kind of match is made, match is by
+ * default for the destination address, if matching by source address
+ * is desired the flag IGB_MAC_STATE_SRC_ADDR can be used.
+ */
+static int igb_add_mac_filter_flags(struct igb_adapter *adapter, const u8 *addr,
+				    const u8 queue, const u8 flags)
 {
 	struct e1000_hw *hw = &adapter->hw;
 	int rar_entries = hw->mac.rar_entry_count -
@@ -6859,7 +6864,7 @@ static int igb_add_mac_filter(struct igb_adapter *adapter, const u8 *addr,
 
 		ether_addr_copy(adapter->mac_table[i].addr, addr);
 		adapter->mac_table[i].queue = queue;
-		adapter->mac_table[i].state |= IGB_MAC_STATE_IN_USE;
+		adapter->mac_table[i].state |= IGB_MAC_STATE_IN_USE | flags;
 
 		igb_rar_set_index(adapter, i);
 		return i;
@@ -6868,8 +6873,20 @@ static int igb_add_mac_filter(struct igb_adapter *adapter, const u8 *addr,
 	return -ENOSPC;
 }
 
-static int igb_del_mac_filter(struct igb_adapter *adapter, const u8 *addr,
+static int igb_add_mac_filter(struct igb_adapter *adapter, const u8 *addr,
 			      const u8 queue)
+{
+	return igb_add_mac_filter_flags(adapter, addr, queue, 0);
+}
+
+/* Remove a MAC filter for 'addr' directing matching traffic to
+ * 'queue', 'flags' is used to indicate what kind of match need to be
+ * removed, match is by default for the destination address, if
+ * matching by source address is to be removed the flag
+ * IGB_MAC_STATE_SRC_ADDR can be used.
+ */
+static int igb_del_mac_filter_flags(struct igb_adapter *adapter, const u8 *addr,
+				    const u8 queue, const u8 flags)
 {
 	struct e1000_hw *hw = &adapter->hw;
 	int rar_entries = hw->mac.rar_entry_count -
@@ -6886,12 +6903,14 @@ static int igb_del_mac_filter(struct igb_adapter *adapter, const u8 *addr,
 	for (i = 0; i < rar_entries; i++) {
 		if (!(adapter->mac_table[i].state & IGB_MAC_STATE_IN_USE))
 			continue;
+		if ((adapter->mac_table[i].state & flags) != flags)
+			continue;
 		if (adapter->mac_table[i].queue != queue)
 			continue;
 		if (!ether_addr_equal(adapter->mac_table[i].addr, addr))
 			continue;
 
-		adapter->mac_table[i].state &= ~IGB_MAC_STATE_IN_USE;
+		adapter->mac_table[i].state = 0;
 		memset(adapter->mac_table[i].addr, 0, ETH_ALEN);
 		adapter->mac_table[i].queue = 0;
 
@@ -6902,6 +6921,12 @@ static int igb_del_mac_filter(struct igb_adapter *adapter, const u8 *addr,
 	return -ENOENT;
 }
 
+static int igb_del_mac_filter(struct igb_adapter *adapter, const u8 *addr,
+			      const u8 queue)
+{
+	return igb_del_mac_filter_flags(adapter, addr, queue, 0);
+}
+
 static int igb_uc_sync(struct net_device *netdev, const unsigned char *addr)
 {
 	struct igb_adapter *adapter = netdev_priv(netdev);
@@ -8744,6 +8769,9 @@ static void igb_rar_set_index(struct igb_adapter *adapter, u32 index)
 		if (is_valid_ether_addr(addr))
 			rar_high |= E1000_RAH_AV;
 
+		if (adapter->mac_table[index].state & IGB_MAC_STATE_SRC_ADDR)
+			rar_high |= E1000_RAH_ASEL_SRC_ADDR;
+
 		switch (hw->mac.type) {
 		case e1000_82575:
 		case e1000_i210:
Signature · 1 line
2.16.2
#5 lore raw

PATCH v2 5/8 igb: Enable nfc filters to specify MAC addresses

In reply to Vinicius Costa Gomes

This allows igb_add_filter()/igb_erase_filter() to work on filters that include MAC addresses (both source and destination).

For now, this only exposes the functionality, the next commit glues ethtool into this. Later in this series, these APIs are used to allow offloading of cls_flower filters.

---
 drivers/net/ethernet/intel/igb/igb.h         |  9 +++++++++
 drivers/net/ethernet/intel/igb/igb_ethtool.c | 28 ++++++++++++++++++++++++++++
 drivers/net/ethernet/intel/igb/igb_main.c    |  8 ++++----
 3 files changed, 41 insertions(+), 4 deletions(-)
drivers/net/ethernet/intel/igb/igb.h +9 -0
index d5cd5f6708d9..43ce6d64f693 100644
@@ -440,6 +440,8 @@ struct hwmon_buff {
 enum igb_filter_match_flags {
 	IGB_FILTER_FLAG_ETHER_TYPE = 0x1,
 	IGB_FILTER_FLAG_VLAN_TCI   = 0x2,
+	IGB_FILTER_FLAG_SRC_MAC_ADDR   = 0x4,
+	IGB_FILTER_FLAG_DST_MAC_ADDR   = 0x8,
 };
 
 #define IGB_MAX_RXNFC_FILTERS 16
@@ -454,6 +456,8 @@ struct igb_nfc_input {
 	u8 match_flags;
 	__be16 etype;
 	__be16 vlan_tci;
+	u8 src_addr[ETH_ALEN];
+	u8 dst_addr[ETH_ALEN];
 };
 
 struct igb_nfc_filter {
@@ -738,4 +742,9 @@ int igb_add_filter(struct igb_adapter *adapter,
 int igb_erase_filter(struct igb_adapter *adapter,
 		     struct igb_nfc_filter *input);
 
+int igb_add_mac_filter_flags(struct igb_adapter *adapter, const u8 *addr,
+			     const u8 queue, const u8 flags);
+int igb_del_mac_filter_flags(struct igb_adapter *adapter, const u8 *addr,
+			     const u8 queue, const u8 flags);
+
 #endif /* _IGB_H_ */
drivers/net/ethernet/intel/igb/igb_ethtool.c +28 -0
index 143f0bb34e4d..94fc9a4bed8b 100644
@@ -2775,6 +2775,25 @@ int igb_add_filter(struct igb_adapter *adapter, struct igb_nfc_filter *input)
 			return err;
 	}
 
+	if (input->filter.match_flags & IGB_FILTER_FLAG_DST_MAC_ADDR) {
+		err = igb_add_mac_filter_flags(adapter,
+					       input->filter.dst_addr,
+					       input->action, 0);
+		err = min_t(int, err, 0);
+		if (err)
+			return err;
+	}
+
+	if (input->filter.match_flags & IGB_FILTER_FLAG_SRC_MAC_ADDR) {
+		err = igb_add_mac_filter_flags(adapter,
+					       input->filter.src_addr,
+					       input->action,
+					       IGB_MAC_STATE_SRC_ADDR);
+		err = min_t(int, err, 0);
+		if (err)
+			return err;
+	}
+
 	if (input->filter.match_flags & IGB_FILTER_FLAG_VLAN_TCI)
 		err = igb_rxnfc_write_vlan_prio_filter(adapter, input);
 
@@ -2823,6 +2842,15 @@ int igb_erase_filter(struct igb_adapter *adapter, struct igb_nfc_filter *input)
 		igb_clear_vlan_prio_filter(adapter,
 					   ntohs(input->filter.vlan_tci));
 
+	if (input->filter.match_flags & IGB_FILTER_FLAG_SRC_MAC_ADDR)
+		igb_del_mac_filter_flags(adapter, input->filter.src_addr,
+					 input->action,
+					 IGB_MAC_STATE_SRC_ADDR);
+
+	if (input->filter.match_flags & IGB_FILTER_FLAG_DST_MAC_ADDR)
+		igb_del_mac_filter_flags(adapter, input->filter.dst_addr,
+					 input->action, 0);
+
 	return 0;
 }
 
drivers/net/ethernet/intel/igb/igb_main.c +4 -4
index 1df1c5a99a0d..71e03b5227df 100644
@@ -6843,8 +6843,8 @@ static void igb_set_default_mac_filter(struct igb_adapter *adapter)
  * default for the destination address, if matching by source address
  * is desired the flag IGB_MAC_STATE_SRC_ADDR can be used.
  */
-static int igb_add_mac_filter_flags(struct igb_adapter *adapter, const u8 *addr,
-				    const u8 queue, const u8 flags)
+int igb_add_mac_filter_flags(struct igb_adapter *adapter, const u8 *addr,
+			     const u8 queue, const u8 flags)
 {
 	struct e1000_hw *hw = &adapter->hw;
 	int rar_entries = hw->mac.rar_entry_count -
@@ -6885,8 +6885,8 @@ static int igb_add_mac_filter(struct igb_adapter *adapter, const u8 *addr,
  * matching by source address is to be removed the flag
  * IGB_MAC_STATE_SRC_ADDR can be used.
  */
-static int igb_del_mac_filter_flags(struct igb_adapter *adapter, const u8 *addr,
-				    const u8 queue, const u8 flags)
+int igb_del_mac_filter_flags(struct igb_adapter *adapter, const u8 *addr,
+			     const u8 queue, const u8 flags)
 {
 	struct e1000_hw *hw = &adapter->hw;
 	int rar_entries = hw->mac.rar_entry_count -
Signature · 1 line
2.16.2
#6 lore raw

PATCH v2 6/8 igb: Add MAC address support for ethtool nftuple filters

In reply to Vinicius Costa Gomes

This adds the capability of configuring the queue steering of arriving packets based on their source and destination MAC addresses.

In practical terms this adds support for the following use cases, characterized by these examples:

$ ethtool -N eth0 flow-type ether dst aa:aa:aa:aa:aa:aa action 0
(this will direct packets with destination address "aa:aa:aa:aa:aa:aa"
to the RX queue 0)
$ ethtool -N eth0 flow-type ether src 44:44:44:44:44:44 action 3
(this will direct packets with destination address "44:44:44:44:44:44"
to the RX queue 3)
---
 drivers/net/ethernet/intel/igb/igb_ethtool.c | 35 ++++++++++++++++++++++++----
 1 file changed, 31 insertions(+), 4 deletions(-)
drivers/net/ethernet/intel/igb/igb_ethtool.c +31 -4
index 94fc9a4bed8b..3f98299d4cd0 100644
@@ -2494,6 +2494,23 @@ static int igb_get_ethtool_nfc_entry(struct igb_adapter *adapter,
 			fsp->h_ext.vlan_tci = rule->filter.vlan_tci;
 			fsp->m_ext.vlan_tci = htons(VLAN_PRIO_MASK);
 		}
+		if (rule->filter.match_flags & IGB_FILTER_FLAG_DST_MAC_ADDR) {
+			ether_addr_copy(fsp->h_u.ether_spec.h_dest,
+					rule->filter.dst_addr);
+			/* As we only support matching by the full
+			 * mask, return the mask to userspace
+			 */
+			eth_broadcast_addr(fsp->m_u.ether_spec.h_dest);
+		}
+		if (rule->filter.match_flags & IGB_FILTER_FLAG_SRC_MAC_ADDR) {
+			ether_addr_copy(fsp->h_u.ether_spec.h_source,
+					rule->filter.src_addr);
+			/* As we only support matching by the full
+			 * mask, return the mask to userspace
+			 */
+			eth_broadcast_addr(fsp->m_u.ether_spec.h_source);
+		}
+
 		return 0;
 	}
 	return -EINVAL;
@@ -2932,10 +2949,6 @@ static int igb_add_ethtool_nfc_entry(struct igb_adapter *adapter,
 	if ((fsp->flow_type & ~FLOW_EXT) != ETHER_FLOW)
 		return -EINVAL;
 
-	if (fsp->m_u.ether_spec.h_proto != ETHER_TYPE_FULL_MASK &&
-	    fsp->m_ext.vlan_tci != htons(VLAN_PRIO_MASK))
-		return -EINVAL;
-
 	input = kzalloc(sizeof(*input), GFP_KERNEL);
 	if (!input)
 		return -ENOMEM;
@@ -2945,6 +2958,20 @@ static int igb_add_ethtool_nfc_entry(struct igb_adapter *adapter,
 		input->filter.match_flags = IGB_FILTER_FLAG_ETHER_TYPE;
 	}
 
+	/* Only support matching addresses by the full mask */
+	if (is_broadcast_ether_addr(fsp->m_u.ether_spec.h_source)) {
+		input->filter.match_flags |= IGB_FILTER_FLAG_SRC_MAC_ADDR;
+		ether_addr_copy(input->filter.src_addr,
+				fsp->h_u.ether_spec.h_source);
+	}
+
+	/* Only support matching addresses by the full mask */
+	if (is_broadcast_ether_addr(fsp->m_u.ether_spec.h_dest)) {
+		input->filter.match_flags |= IGB_FILTER_FLAG_DST_MAC_ADDR;
+		ether_addr_copy(input->filter.dst_addr,
+				fsp->h_u.ether_spec.h_dest);
+	}
+
 	if ((fsp->flow_type & FLOW_EXT) && fsp->m_ext.vlan_tci) {
 		if (fsp->m_ext.vlan_tci != htons(VLAN_PRIO_MASK)) {
 			err = -EINVAL;
Signature · 1 line
2.16.2
#7 lore raw

PATCH v2 7/8 igb: Add the skeletons for tc-flower offloading

In reply to Vinicius Costa Gomes

This adds basic functions needed to implement offloading for filters created by tc-flower.

---
 drivers/net/ethernet/intel/igb/igb_main.c | 66 +++++++++++++++++++++++++++++++
 1 file changed, 66 insertions(+)
drivers/net/ethernet/intel/igb/igb_main.c +66 -0
index 71e03b5227df..b5a6bd37bb16 100644
@@ -35,6 +35,7 @@
 #include <net/checksum.h>
 #include <net/ip6_checksum.h>
 #include <net/pkt_sched.h>
+#include <net/pkt_cls.h>
 #include <linux/net_tstamp.h>
 #include <linux/mii.h>
 #include <linux/ethtool.h>
@@ -2496,6 +2497,69 @@ static int igb_offload_cbs(struct igb_adapter *adapter,
 	return 0;
 }
 
+static int igb_configure_clsflower(struct igb_adapter *adapter,
+				   struct tc_cls_flower_offload *cls_flower)
+{
+	return -EOPNOTSUPP;
+}
+
+static int igb_delete_clsflower(struct igb_adapter *adapter,
+				struct tc_cls_flower_offload *cls_flower)
+{
+	return -EOPNOTSUPP;
+}
+
+static int igb_setup_tc_cls_flower(struct igb_adapter *adapter,
+				   struct tc_cls_flower_offload *cls_flower)
+{
+	switch (cls_flower->command) {
+	case TC_CLSFLOWER_REPLACE:
+		return igb_configure_clsflower(adapter, cls_flower);
+	case TC_CLSFLOWER_DESTROY:
+		return igb_delete_clsflower(adapter, cls_flower);
+	case TC_CLSFLOWER_STATS:
+		return -EOPNOTSUPP;
+	default:
+		return -EINVAL;
+	}
+}
+
+static int igb_setup_tc_block_cb(enum tc_setup_type type, void *type_data,
+				 void *cb_priv)
+{
+	struct igb_adapter *adapter = cb_priv;
+
+	if (!tc_cls_can_offload_and_chain0(adapter->netdev, type_data))
+		return -EOPNOTSUPP;
+
+	switch (type) {
+	case TC_SETUP_CLSFLOWER:
+		return igb_setup_tc_cls_flower(adapter, type_data);
+
+	default:
+		return -EOPNOTSUPP;
+	}
+}
+
+static int igb_setup_tc_block(struct igb_adapter *adapter,
+			      struct tc_block_offload *f)
+{
+	if (f->binder_type != TCF_BLOCK_BINDER_TYPE_CLSACT_INGRESS)
+		return -EOPNOTSUPP;
+
+	switch (f->command) {
+	case TC_BLOCK_BIND:
+		return tcf_block_cb_register(f->block, igb_setup_tc_block_cb,
+					     adapter, adapter);
+	case TC_BLOCK_UNBIND:
+		tcf_block_cb_unregister(f->block, igb_setup_tc_block_cb,
+					adapter);
+		return 0;
+	default:
+		return -EOPNOTSUPP;
+	}
+}
+
 static int igb_setup_tc(struct net_device *dev, enum tc_setup_type type,
 			void *type_data)
 {
@@ -2504,6 +2568,8 @@ static int igb_setup_tc(struct net_device *dev, enum tc_setup_type type,
 	switch (type) {
 	case TC_SETUP_QDISC_CBS:
 		return igb_offload_cbs(adapter, type_data);
+	case TC_SETUP_BLOCK:
+		return igb_setup_tc_block(adapter, type_data);
 
 	default:
 		return -EOPNOTSUPP;
Signature · 1 line
2.16.2
#8 lore raw

PATCH v2 8/8 igb: Add support for adding offloaded clsflower filters

In reply to Vinicius Costa Gomes

This allows filters added by tc-flower and specifying MAC addresses, Ethernet types, and the VLAN priority field, to be offloaded to the controller.

This reuses most of the infrastructure used by ethtool, ethtool can be used to read these filters, but modification and deletion can only be done via tc-flower.

---
 drivers/net/ethernet/intel/igb/igb.h      |   2 +
 drivers/net/ethernet/intel/igb/igb_main.c | 176 +++++++++++++++++++++++++++++-
 2 files changed, 176 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/igb/igb.h +2 -0
index 43ce6d64f693..0edd3a74d043 100644
@@ -463,6 +463,7 @@ struct igb_nfc_input {
 struct igb_nfc_filter {
 	struct hlist_node nfc_node;
 	struct igb_nfc_input filter;
+	unsigned long cookie;
 	u16 etype_reg_index;
 	u16 sw_idx;
 	u16 action;
@@ -601,6 +602,7 @@ struct igb_adapter {
 
 	/* RX network flow classification support */
 	struct hlist_head nfc_filter_list;
+	struct hlist_head cls_flower_list;
 	unsigned int nfc_filter_count;
 	/* lock for RX network flow classification filter */
 	spinlock_t nfc_lock;
drivers/net/ethernet/intel/igb/igb_main.c +174 -2

202 lines not on this page · raw message

Signature · 1 line
2.16.2
#9 lore raw

Re: [next-queue PATCH v2 8/8] igb: Add support for adding offloaded clsflower filters

Quoted 39 lines · Vinicius Costa Gomes

This allows filters added by tc-flower and specifying MAC addresses, Ethernet types, and the VLAN priority field, to be offloaded to the controller.

This reuses most of the infrastructure used by ethtool, ethtool can be used to read these filters, but modification and deletion can only be done via tc-flower.

---
 drivers/net/ethernet/intel/igb/igb.h      |   2 +
 drivers/net/ethernet/intel/igb/igb_main.c | 176 +++++++++++++++++++++++++++++-
 2 files changed, 176 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/igb/igb.h +2 -0
index 43ce6d64f693..0edd3a74d043 100644
@@ -463,6 +463,7 @@ struct igb_nfc_input {
 struct igb_nfc_filter {
 	struct hlist_node nfc_node;
 	struct igb_nfc_input filter;
+	unsigned long cookie;
 	u16 etype_reg_index;
 	u16 sw_idx;
 	u16 action;
@@ -601,6 +602,7 @@ struct igb_adapter {
 
 	/* RX network flow classification support */
 	struct hlist_head nfc_filter_list;
+	struct hlist_head cls_flower_list;
 	unsigned int nfc_filter_count;
 	/* lock for RX network flow classification filter */
 	spinlock_t nfc_lock;
drivers/net/ethernet/intel/igb/igb_main.c +0 -0
index b5a6bd37bb16..cbd2048b9110 100644

drivers/net/ethernet/intel/igb/igb_main.c static int igb_set_features(struct net_device *netdev, · line 2405

Quoted 9 lines
drivers/net/ethernet/intel/igb/igb_main.c +6 -0
@@ -2397,6 +2397,12 @@ static int igb_set_features(struct net_device *netdev,
 			hlist_del(&rule->nfc_node);
 			kfree(rule);
 		}
+		hlist_for_each_entry_safe(rule, node2,
+					  &adapter->cls_flower_list, nfc_node) {
+			igb_erase_filter(adapter, rule);
+			hlist_del(&rule->nfc_node);
+			kfree(rule);
+		}

Hm. I don't think you should flush cls filters when someone disables NTUPLE. (a) ntuple is independent, (b) the in_hw flag will no longer reflect the actual state of the system.

Quoted 11 lines
drivers/net/ethernet/intel/igb/igb_main.c +4 -0
 		spin_unlock(&adapter->nfc_lock);
 		adapter->nfc_filter_count = 0;
 	}
@@ -2497,16 +2503,179 @@ static int igb_offload_cbs(struct igb_adapter *adapter,
 	return 0;
 }
 
+#define ETHER_TYPE_FULL_MASK ((__force __be16)~0)
+
+static int igb_parse_cls_flower(struct igb_adapter *adapter,
+				struct tc_cls_flower_offload *f,

drivers/net/ethernet/intel/igb/igb_main.c static int igb_offload_cbs(struct igb_adapter *adapter, · line 2519

Quoted 10 lines
drivers/net/ethernet/intel/igb/igb_main.c +10 -0
+				int traffic_class,
+				struct igb_nfc_filter *input)
+{
+	if (f->dissector->used_keys &
+	    ~(BIT(FLOW_DISSECTOR_KEY_BASIC) |
+	      BIT(FLOW_DISSECTOR_KEY_CONTROL) |
+	      BIT(FLOW_DISSECTOR_KEY_ETH_ADDRS) |
+	      BIT(FLOW_DISSECTOR_KEY_VLAN))) {
+		dev_err(&adapter->pdev->dev, "Unsupported key used: 0x%x\n",
+			f->dissector->used_keys);

This will probably trigger for opportunistic offload (non-skip_sw) and confuse users.

drivers/net/ethernet/intel/igb/igb_main.c static int igb_offload_cbs(struct igb_adapter *adapter, · line 2532

Quoted 13 lines
drivers/net/ethernet/intel/igb/igb_main.c +13 -0
+		return -EOPNOTSUPP;
+	}
+
+	if (dissector_uses_key(f->dissector, FLOW_DISSECTOR_KEY_ETH_ADDRS)) {
+		struct flow_dissector_key_eth_addrs *key =
+			skb_flow_dissector_target(f->dissector,
+						  FLOW_DISSECTOR_KEY_ETH_ADDRS,
+						  f->key);
+
+		struct flow_dissector_key_eth_addrs *mask =
+			skb_flow_dissector_target(f->dissector,
+						  FLOW_DISSECTOR_KEY_ETH_ADDRS,
+						  f->mask);

You can do the assignment on separate lines to avoid strange variable declaration.

drivers/net/ethernet/intel/igb/igb_main.c static int igb_offload_cbs(struct igb_adapter *adapter, · line 2544

Quoted 11 lines
drivers/net/ethernet/intel/igb/igb_main.c +11 -0
+		if (is_broadcast_ether_addr(mask->dst)) {
+			input->filter.match_flags |=
+				IGB_FILTER_FLAG_DST_MAC_ADDR;
+			ether_addr_copy(input->filter.dst_addr, key->dst);
+		}
+
+		if (is_broadcast_ether_addr(mask->src)) {
+			input->filter.match_flags |=
+				IGB_FILTER_FLAG_SRC_MAC_ADDR;
+			ether_addr_copy(input->filter.src_addr, key->src);
+		}

If the mask is not full you need to reject the filter, I don't think you can just ignore the MAC if it's masked..

Same two comments for conditions below.

Quoted 41 lines
drivers/net/ethernet/intel/igb/igb_main.c +41 -0
+	}
+
+	if (dissector_uses_key(f->dissector, FLOW_DISSECTOR_KEY_BASIC)) {
+		struct flow_dissector_key_basic *key =
+			skb_flow_dissector_target(f->dissector,
+						  FLOW_DISSECTOR_KEY_BASIC,
+						  f->key);
+
+		struct flow_dissector_key_basic *mask =
+			skb_flow_dissector_target(f->dissector,
+						  FLOW_DISSECTOR_KEY_BASIC,
+						  f->mask);
+
+		if (mask->n_proto == ETHER_TYPE_FULL_MASK) {
+			input->filter.match_flags |=
+				IGB_FILTER_FLAG_ETHER_TYPE;
+			input->filter.etype = key->n_proto;
+		}
+	}
+
+	if (dissector_uses_key(f->dissector, FLOW_DISSECTOR_KEY_VLAN)) {
+		struct flow_dissector_key_vlan *key =
+			skb_flow_dissector_target(f->dissector,
+						  FLOW_DISSECTOR_KEY_VLAN,
+						  f->key);
+		struct flow_dissector_key_vlan *mask =
+			skb_flow_dissector_target(f->dissector,
+						  FLOW_DISSECTOR_KEY_VLAN,
+						  f->mask);
+
+		if (mask->vlan_priority) {
+			input->filter.match_flags |= IGB_FILTER_FLAG_VLAN_TCI;
+			input->filter.vlan_tci = key->vlan_priority;
+		}
+	}
+
+	input->action = traffic_class;
+	input->cookie = f->cookie;
+
+	return 0;
+}

drivers/net/ethernet/intel/igb/igb_main.c static int igb_offload_cbs(struct igb_adapter *adapter, · line 2594

Quoted 10 lines
drivers/net/ethernet/intel/igb/igb_main.c +6 -1
+
 static int igb_configure_clsflower(struct igb_adapter *adapter,
 				   struct tc_cls_flower_offload *cls_flower)
 {
-	return -EOPNOTSUPP;
+	struct igb_nfc_filter *filter, *f;
+	int err, tc;
+
+	if (!(adapter->netdev->hw_features & NETIF_F_NTUPLE))
+		return -EOPNOTSUPP;

I'd rather there wasn't dependency on NTUPLEs for cls offloads.

Quoted 13 lines
drivers/net/ethernet/intel/igb/igb_main.c +13 -0
+	tc = tc_classid_to_hwtc(adapter->netdev, cls_flower->classid);
+	if (tc < 0) {
+		dev_err(&adapter->pdev->dev, "Invalid traffic class\n");
+		return -EINVAL;
+	}
+
+	filter = kzalloc(sizeof(*filter), GFP_KERNEL);
+	if (!filter)
+		return -ENOMEM;
+
+	err = igb_parse_cls_flower(adapter, cls_flower, tc, filter);
+	if (err < 0) {
+		dev_err(&adapter->pdev->dev, "Invalid cls_flower filter\n");

drivers/net/ethernet/intel/igb/igb_main.c static int igb_offload_cbs(struct igb_adapter *adapter, · line 2618

Quoted 10 lines
drivers/net/ethernet/intel/igb/igb_main.c +10 -0
+		goto err_parse;
+	}
+
+	spin_lock(&adapter->nfc_lock);
+
+	hlist_for_each_entry(f, &adapter->nfc_filter_list, nfc_node) {
+		if (!memcmp(&f->filter, &filter->filter, sizeof(f->filter))) {
+			err = -EEXIST;
+			dev_err(&adapter->pdev->dev,
+				"This filter is already set in ethtool\n");

Consider using extack too, maybe?

Quoted 31 lines
drivers/net/ethernet/intel/igb/igb_main.c +30 -0
+			goto err_locked;
+		}
+	}
+
+	hlist_for_each_entry(f, &adapter->cls_flower_list, nfc_node) {
+		if (!memcmp(&f->filter, &filter->filter, sizeof(f->filter))) {
+			err = -EEXIST;
+			dev_err(&adapter->pdev->dev,
+				"This filter is already set in cls_flower\n");
+			goto err_locked;
+		}
+	}
+
+	err = igb_add_filter(adapter, filter);
+	if (err < 0)
+		goto err_locked;
+
+	hlist_add_head(&filter->nfc_node, &adapter->cls_flower_list);
+
+	spin_unlock(&adapter->nfc_lock);
+
+	return 0;
+
+err_locked:
+	spin_unlock(&adapter->nfc_lock);
+
+err_parse:
+	kfree(filter);
+
+	return err;
 }
#10 lore raw

Re: [next-queue PATCH v2 8/8] igb: Add support for adding offloaded clsflower filters

Hi,

Quoted 45 lines · Jakub Kicinski
Quoted 44 lines · Vinicius Costa Gomes

This allows filters added by tc-flower and specifying MAC addresses, Ethernet types, and the VLAN priority field, to be offloaded to the controller.

This reuses most of the infrastructure used by ethtool, ethtool can be used to read these filters, but modification and deletion can only be done via tc-flower.

---
 drivers/net/ethernet/intel/igb/igb.h      |   2 +
 drivers/net/ethernet/intel/igb/igb_main.c | 176 +++++++++++++++++++++++++++++-
 2 files changed, 176 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/igb/igb.h +2 -0
index 43ce6d64f693..0edd3a74d043 100644
@@ -463,6 +463,7 @@ struct igb_nfc_input {
 struct igb_nfc_filter {
 	struct hlist_node nfc_node;
 	struct igb_nfc_input filter;
+	unsigned long cookie;
 	u16 etype_reg_index;
 	u16 sw_idx;
 	u16 action;
@@ -601,6 +602,7 @@ struct igb_adapter {
 
 	/* RX network flow classification support */
 	struct hlist_head nfc_filter_list;
+	struct hlist_head cls_flower_list;
 	unsigned int nfc_filter_count;
 	/* lock for RX network flow classification filter */
 	spinlock_t nfc_lock;
drivers/net/ethernet/intel/igb/igb_main.c +2 -0
index b5a6bd37bb16..cbd2048b9110 100644
@@ -2397,6 +2397,12 @@ static int igb_set_features(struct net_device *netdev,
 			hlist_del(&rule->nfc_node);
 			kfree(rule);
 		}
+		hlist_for_each_entry_safe(rule, node2,
+					  &adapter->cls_flower_list, nfc_node) {
Quoted 8 lines

drivers/net/ethernet/intel/igb/igb_main.c static int igb_set_features(struct net_device *netdev, · line 2405

Quoted 4 lines
drivers/net/ethernet/intel/igb/igb_main.c +4 -0
+			igb_erase_filter(adapter, rule);
+			hlist_del(&rule->nfc_node);
+			kfree(rule);
+		}

Hm. I don't think you should flush cls filters when someone disables NTUPLE. (a) ntuple is independent, (b) the in_hw flag will no longer reflect the actual state of the system.

Makes total sense. Will fix.

Quoted 17 lines
Quoted 17 lines
drivers/net/ethernet/intel/igb/igb_main.c +9 -0
 		spin_unlock(&adapter->nfc_lock);
 		adapter->nfc_filter_count = 0;
 	}
@@ -2497,16 +2503,179 @@ static int igb_offload_cbs(struct igb_adapter *adapter,
 	return 0;
 }
 
+#define ETHER_TYPE_FULL_MASK ((__force __be16)~0)
+
+static int igb_parse_cls_flower(struct igb_adapter *adapter,
+				struct tc_cls_flower_offload *f,
+				int traffic_class,
+				struct igb_nfc_filter *input)
+{
+	if (f->dissector->used_keys &
+	    ~(BIT(FLOW_DISSECTOR_KEY_BASIC) |
Quoted 9 lines

drivers/net/ethernet/intel/igb/igb_main.c static int igb_offload_cbs(struct igb_adapter *adapter, · line 2519

Quoted 5 lines
drivers/net/ethernet/intel/igb/igb_main.c +5 -0
+	      BIT(FLOW_DISSECTOR_KEY_CONTROL) |
+	      BIT(FLOW_DISSECTOR_KEY_ETH_ADDRS) |
+	      BIT(FLOW_DISSECTOR_KEY_VLAN))) {
+		dev_err(&adapter->pdev->dev, "Unsupported key used: 0x%x\n",
+			f->dissector->used_keys);

This will probably trigger for opportunistic offload (non-skip_sw) and confuse users.

I see your point. I will change to 'dev_warn()', it should not surprise users too much, right?

Quoted 8 lines
Quoted 8 lines
drivers/net/ethernet/intel/igb/igb_main.c +8 -0
+		return -EOPNOTSUPP;
+	}
+
+	if (dissector_uses_key(f->dissector, FLOW_DISSECTOR_KEY_ETH_ADDRS)) {
+		struct flow_dissector_key_eth_addrs *key =
+			skb_flow_dissector_target(f->dissector,
+						  FLOW_DISSECTOR_KEY_ETH_ADDRS,
+						  f->key);
Quoted 9 lines

drivers/net/ethernet/intel/igb/igb_main.c static int igb_offload_cbs(struct igb_adapter *adapter, · line 2532

Quoted 5 lines
drivers/net/ethernet/intel/igb/igb_main.c +5 -0
+
+		struct flow_dissector_key_eth_addrs *mask =
+			skb_flow_dissector_target(f->dissector,
+						  FLOW_DISSECTOR_KEY_ETH_ADDRS,
+						  f->mask);

You can do the assignment on separate lines to avoid strange variable declaration.

Fair enough. Will fix.

Quoted 15 lines

drivers/net/ethernet/intel/igb/igb_main.c static int igb_offload_cbs(struct igb_adapter *adapter, · line 2544

Quoted 11 lines
drivers/net/ethernet/intel/igb/igb_main.c +11 -0
+		if (is_broadcast_ether_addr(mask->dst)) {
+			input->filter.match_flags |=
+				IGB_FILTER_FLAG_DST_MAC_ADDR;
+			ether_addr_copy(input->filter.dst_addr, key->dst);
+		}
+
+		if (is_broadcast_ether_addr(mask->src)) {
+			input->filter.match_flags |=
+				IGB_FILTER_FLAG_SRC_MAC_ADDR;
+			ether_addr_copy(input->filter.src_addr, key->src);
+		}

If the mask is not full you need to reject the filter, I don't think you can just ignore the MAC if it's masked..

Quoted 1 line

Same two comments for conditions below.

Yeah, being silent in these cases can cause some confusion. Will fix them.

Quoted 46 lines
Quoted 46 lines
drivers/net/ethernet/intel/igb/igb_main.c +42 -0
+	}
+
+	if (dissector_uses_key(f->dissector, FLOW_DISSECTOR_KEY_BASIC)) {
+		struct flow_dissector_key_basic *key =
+			skb_flow_dissector_target(f->dissector,
+						  FLOW_DISSECTOR_KEY_BASIC,
+						  f->key);
+
+		struct flow_dissector_key_basic *mask =
+			skb_flow_dissector_target(f->dissector,
+						  FLOW_DISSECTOR_KEY_BASIC,
+						  f->mask);
+
+		if (mask->n_proto == ETHER_TYPE_FULL_MASK) {
+			input->filter.match_flags |=
+				IGB_FILTER_FLAG_ETHER_TYPE;
+			input->filter.etype = key->n_proto;
+		}
+	}
+
+	if (dissector_uses_key(f->dissector, FLOW_DISSECTOR_KEY_VLAN)) {
+		struct flow_dissector_key_vlan *key =
+			skb_flow_dissector_target(f->dissector,
+						  FLOW_DISSECTOR_KEY_VLAN,
+						  f->key);
+		struct flow_dissector_key_vlan *mask =
+			skb_flow_dissector_target(f->dissector,
+						  FLOW_DISSECTOR_KEY_VLAN,
+						  f->mask);
+
+		if (mask->vlan_priority) {
+			input->filter.match_flags |= IGB_FILTER_FLAG_VLAN_TCI;
+			input->filter.vlan_tci = key->vlan_priority;
+		}
+	}
+
+	input->action = traffic_class;
+	input->cookie = f->cookie;
+
+	return 0;
+}
+
 static int igb_configure_clsflower(struct igb_adapter *adapter,
 				   struct tc_cls_flower_offload *cls_flower)
 {
Quoted 9 lines

drivers/net/ethernet/intel/igb/igb_main.c static int igb_offload_cbs(struct igb_adapter *adapter, · line 2594

Quoted 6 lines
drivers/net/ethernet/intel/igb/igb_main.c +5 -1
-	return -EOPNOTSUPP;
+	struct igb_nfc_filter *filter, *f;
+	int err, tc;
+
+	if (!(adapter->netdev->hw_features & NETIF_F_NTUPLE))
+		return -EOPNOTSUPP;

I'd rather there wasn't dependency on NTUPLEs for cls offloads.

Cool. Will remove this check.

Quoted 17 lines
Quoted 17 lines
drivers/net/ethernet/intel/igb/igb_main.c +17 -0
+	tc = tc_classid_to_hwtc(adapter->netdev, cls_flower->classid);
+	if (tc < 0) {
+		dev_err(&adapter->pdev->dev, "Invalid traffic class\n");
+		return -EINVAL;
+	}
+
+	filter = kzalloc(sizeof(*filter), GFP_KERNEL);
+	if (!filter)
+		return -ENOMEM;
+
+	err = igb_parse_cls_flower(adapter, cls_flower, tc, filter);
+	if (err < 0) {
+		dev_err(&adapter->pdev->dev, "Invalid cls_flower filter\n");
+		goto err_parse;
+	}
+
+	spin_lock(&adapter->nfc_lock);
Quoted 8 lines

drivers/net/ethernet/intel/igb/igb_main.c static int igb_offload_cbs(struct igb_adapter *adapter, · line 2618

Quoted 6 lines
drivers/net/ethernet/intel/igb/igb_main.c +6 -0
+
+	hlist_for_each_entry(f, &adapter->nfc_filter_list, nfc_node) {
+		if (!memcmp(&f->filter, &filter->filter, sizeof(f->filter))) {
+			err = -EEXIST;
+			dev_err(&adapter->pdev->dev,
+				"This filter is already set in ethtool\n");

Consider using extack too, maybe?

Yeah, will do.

Quoted 24 lines
Quoted 24 lines
drivers/net/ethernet/intel/igb/igb_main.c +23 -0
+			goto err_locked;
+		}
+	}
+
+	hlist_for_each_entry(f, &adapter->cls_flower_list, nfc_node) {
+		if (!memcmp(&f->filter, &filter->filter, sizeof(f->filter))) {
+			err = -EEXIST;
+			dev_err(&adapter->pdev->dev,
+				"This filter is already set in cls_flower\n");
+			goto err_locked;
+		}
+	}
+
+	err = igb_add_filter(adapter, filter);
+	if (err < 0)
+		goto err_locked;
+
+	hlist_add_head(&filter->nfc_node, &adapter->cls_flower_list);
+
+	spin_unlock(&adapter->nfc_lock);
+
+	return 0;
+
Quoted 8 lines

drivers/net/ethernet/intel/igb/igb_main.c static int igb_offload_cbs(struct igb_adapter *adapter, · line 2649

Quoted 8 lines
drivers/net/ethernet/intel/igb/igb_main.c +7 -0
+err_locked:
+	spin_unlock(&adapter->nfc_lock);
+
+err_parse:
+	kfree(filter);
+
+	return err;
 }

Cheers,
--
Vinicius

#11 lore raw

Re: [next-queue PATCH v2 8/8] igb: Add support for adding offloaded clsflower filters

Quoted 16 lines · Vinicius Costa Gomes
Quoted 7 lines
Quoted 7 lines
drivers/net/ethernet/intel/igb/igb_main.c +7 -0
+static int igb_parse_cls_flower(struct igb_adapter *adapter,
+				struct tc_cls_flower_offload *f,
+				int traffic_class,
+				struct igb_nfc_filter *input)
+{
+	if (f->dissector->used_keys &
+	    ~(BIT(FLOW_DISSECTOR_KEY_BASIC) |
Quoted 8 lines

drivers/net/ethernet/intel/igb/igb_main.c static int igb_offload_cbs(struct igb_adapter *adapter, · line 2519

Quoted 5 lines
drivers/net/ethernet/intel/igb/igb_main.c +5 -0
+	      BIT(FLOW_DISSECTOR_KEY_CONTROL) |
+	      BIT(FLOW_DISSECTOR_KEY_ETH_ADDRS) |
+	      BIT(FLOW_DISSECTOR_KEY_VLAN))) {
+		dev_err(&adapter->pdev->dev, "Unsupported key used: 0x%x\n",
+			f->dissector->used_keys);  

This will probably trigger for opportunistic offload (non-skip_sw) and confuse users.

Quoted 2 lines

I see your point. I will change to 'dev_warn()', it should not surprise users too much, right?

Yes, I think that would be fine, other drivers are doing that already.

IMHO best approach is to not print anything unless skip-sw is set. If you used netlink's extack capability exclusively it would "just work". Extack will only carry the error in case offload is requested. Could you consider using extack or do you have a preference to print into the logs? You could do both, too.

You can get to extack via f->common->extack.

#12 lore raw

Re: [next-queue PATCH v2 8/8] igb: Add support for adding offloaded clsflower filters

Hi,

Quoted 20 lines · Jakub Kicinski
Quoted 16 lines · Vinicius Costa Gomes
Quoted 7 lines
Quoted 7 lines
drivers/net/ethernet/intel/igb/igb_main.c +7 -0
+static int igb_parse_cls_flower(struct igb_adapter *adapter,
+				struct tc_cls_flower_offload *f,
+				int traffic_class,
+				struct igb_nfc_filter *input)
+{
+	if (f->dissector->used_keys &
+	    ~(BIT(FLOW_DISSECTOR_KEY_BASIC) |
Quoted 8 lines

drivers/net/ethernet/intel/igb/igb_main.c static int igb_offload_cbs(struct igb_adapter *adapter, · line 2519

Quoted 5 lines
drivers/net/ethernet/intel/igb/igb_main.c +5 -0
+	      BIT(FLOW_DISSECTOR_KEY_CONTROL) |
+	      BIT(FLOW_DISSECTOR_KEY_ETH_ADDRS) |
+	      BIT(FLOW_DISSECTOR_KEY_VLAN))) {
+		dev_err(&adapter->pdev->dev, "Unsupported key used: 0x%x\n",
+			f->dissector->used_keys);  

This will probably trigger for opportunistic offload (non-skip_sw) and confuse users.

Quoted 2 lines

I see your point. I will change to 'dev_warn()', it should not surprise users too much, right?

Quoted 7 lines

Yes, I think that would be fine, other drivers are doing that already.

IMHO best approach is to not print anything unless skip-sw is set. If you used netlink's extack capability exclusively it would "just work". Extack will only carry the error in case offload is requested. Could you consider using extack or do you have a preference to print into the logs? You could do both, too.

I will go with extack-only, but I had to tweak the message a little as there's no support for format strings in extack.

Quoted 2 lines

You can get to extack via f->common->extack.

Cheers,
--
Vinicius