Skip to contentSkip to conversation

net: hns3: enhance tc flow offload support

PATCH Applied Jijie Shao 3 participants 9 messages Jun 10 – Jun 14

Subsystems (4)
lore
Share & tools
lore

Jijie Shao

author maintainer
#0 lore raw

v4 cover net: hns3: enhance tc flow offload support

This patchset enhances the tc flow offload support for hns3 driver:

- Patch 1: Refactor hclge_add_cls_flower() to support more actions
- Patch 2: Improve unused_tuple parameter setting for separate src/dst configuration
- Patch 3: Add support for HCLGE_FD_ACTION_SELECT_QUEUE and HCLGE_FD_ACTION_DROP_PACKET actions
- Patch 4: Add support for FLOW_DISSECTOR_KEY_IP and FLOW_DISSECTOR_KEY_ENC_KEYID dissectors
- Patch 5: Add debugfs support for dumping FD rules
- Patch 6: Move FD code to a separate file (hclge_fd.c) for better code organization

---
v3 -> v4:
- Fix issues pointed out by Jakub Kicinski:
a) Fix byte order issue of KEY_OPT_VNI under big-endian architectures.
b) Fix issue where match.mask->ttl was silently ignored in FLOW_DISSECTOR_KEY_IP.
- Use NL_SET_ERR_MSG_MOD() and extack to return errors instead of dev_err(), as suggested by Jakub.
- Links:

    v3: https://lore.kernel.org/all/[email protected]/
    AI report: https://sashiko.dev/#/patchset/20260602133337.2216918-1-shaojijie%40huawei.com

v2 -> v3:
- Fix issues pointed out by Simon Horman and Paolo Abeni:
a) Fix incorrect condition for identifying unused tuples when IP/MAC addresses are all-zero but masks are non-zero.
b) Fix inappropriate log output in error paths.
c) Fix issue where tc flower supported keys did not distinguish between different FD modes.
d) Fix unnecessary distinction between IPv4 and IPv6 in debugfs.
- Links:

    v2: https://lore.kernel.org/all/[email protected]/
    AI report: https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260523105449.661848-1-shaojijie%40huawei.com

v1 -> v2:
- Fix "restricted __le32 degrades to integer" warnings, pointed out by Jakub.
- Fix "diagnostic behavior may be improved by adding 'format(printf, 5, 7)'" warnings, pointed out by Jakub.
- Link:

    v1: https://lore.kernel.org/all/[email protected]/

---

Jijie Shao (6):
net: hns3: refactor add_cls_flower to prepare for multiple actions
net: hns3: improve the unused_tuple parameter setting
net: hns3: support two more actions for tc flow
net: hns3: support IP and tunnel VNI dissectors for tc flow
net: hns3: debugfs support for dumping fd rules
net: hns3: move fd code to a separate file

 drivers/net/ethernet/hisilicon/hns3/Makefile  |    1 +
 drivers/net/ethernet/hisilicon/hns3/hnae3.h   |    3 +-
 .../ethernet/hisilicon/hns3/hns3_debugfs.c    |    6 +
 .../net/ethernet/hisilicon/hns3/hns3_enet.c   |    3 +-
 .../hisilicon/hns3/hns3pf/hclge_debugfs.c     |  155 +
 .../ethernet/hisilicon/hns3/hns3pf/hclge_fd.c | 2593 +++++++++++++++++
 .../ethernet/hisilicon/hns3/hns3pf/hclge_fd.h |   33 +
 .../hisilicon/hns3/hns3pf/hclge_main.c        | 2514 +---------------
 .../hisilicon/hns3/hns3pf/hclge_main.h        |    6 +
 9 files changed, 2840 insertions(+), 2474 deletions(-)
 create mode 100644 drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_fd.c
 create mode 100644 drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_fd.h

base-commit: 61abe5db23f0799e602352c796de6fcf76d23b41

Signature · 1 line
2.33.0
author maintainer
#1 lore raw

PATCH v4 1/6 net: hns3: refactor add_cls_flower to prepare for multiple actions

Remove the tc parameter from the add_cls_flower() ops callback and refactor action parsing to support future extensions for SELECT_QUEUE and DROP_PACKET actions.

Changes:
* Remove the tc parameter from the add_cls_flower() callback signature.
* Extract TC-based action parsing into hclge_get_tc_flower_action().
* Move the dissector->used_keys check from hclge_parse_cls_flower() to hclge_check_cls_flower(), and restrict ETH_ADDRS to HCLGE_FD_MODE_DEPTH_2K_WIDTH_400B_STAGE_1 mode since hardware only supports MAC matching there.
* Migrate error reporting from dev_err() to netlink extended ACK (extack).

---
 drivers/net/ethernet/hisilicon/hns3/hnae3.h   |  2 +-
 .../net/ethernet/hisilicon/hns3/hns3_enet.c   |  3 +-
 .../hisilicon/hns3/hns3pf/hclge_main.c        | 93 ++++++++++++-------
 3 files changed, 60 insertions(+), 38 deletions(-)
drivers/net/ethernet/hisilicon/hns3/hnae3.h +1 -1
index d7c3df1958f3..a724935b655a 100644
@@ -778,7 +778,7 @@ struct hnae3_ae_ops {
 				 u32 len, u8 *data);
 	bool (*get_cmdq_stat)(struct hnae3_handle *handle);
 	int (*add_cls_flower)(struct hnae3_handle *handle,
-			      struct flow_cls_offload *cls_flower, int tc);
+			      struct flow_cls_offload *cls_flower);
 	int (*del_cls_flower)(struct hnae3_handle *handle,
 			      struct flow_cls_offload *cls_flower);
 	bool (*cls_flower_active)(struct hnae3_handle *handle);
drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +1 -2
index 4c34a144d21c..6ecb32e28e79 100644
@@ -2678,13 +2678,12 @@ static int hns3_setup_tc(struct net_device *netdev, void *type_data)
 static int hns3_setup_tc_cls_flower(struct hns3_nic_priv *priv,
 				    struct flow_cls_offload *flow)
 {
-	int tc = tc_classid_to_hwtc(priv->netdev, flow->classid);
 	struct hnae3_handle *h = hns3_get_handle(priv->netdev);
 
 	switch (flow->command) {
 	case FLOW_CLS_REPLACE:
 		if (h->ae_algo->ops->add_cls_flower)
-			return h->ae_algo->ops->add_cls_flower(h, flow, tc);
+			return h->ae_algo->ops->add_cls_flower(h, flow);
 		break;
 	case FLOW_CLS_DESTROY:
 		if (h->ae_algo->ops->del_cls_flower)
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +58 -35

145 lines not on this page · raw message

Signature · 1 line
2.33.0
author maintainer
#2 lore raw

PATCH v4 2/6 net: hns3: improve the unused_tuple parameter setting

In reply to Jijie Shao

Currently, when the tc tool is used to set flow table rules, the IP address and MAC address can be configured separately, for example, src_xx or dst_xx can be configured separately.

Therefore, the driver needs to check whether the mask is all zero in keys, such as FLOW_DISSECTOR_KEY_IPV4_ADDRS, FLOW_DISSECTOR_KEY_IPV6_ADDRS, and FLOW_DISSECTOR_KEY_ETH_ADDRS.
If the mask is all zero, the tuple is not configured.
In this case, the driver adds the tuple to unused_tuple.

---
 .../net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c  | 12 ++++++++++++
 1 file changed, 12 insertions(+)
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +12 -0
index 77bd23e2c11e..176ea5aac8aa 100644
@@ -7242,6 +7242,10 @@ static void hclge_get_cls_key_mac(const struct flow_rule *flow,
 		ether_addr_copy(rule->tuples_mask.dst_mac, match.mask->dst);
 		ether_addr_copy(rule->tuples.src_mac, match.key->src);
 		ether_addr_copy(rule->tuples_mask.src_mac, match.mask->src);
+		if (is_zero_ether_addr(match.mask->dst))
+			rule->unused_tuple |= BIT(INNER_DST_MAC);
+		if (is_zero_ether_addr(match.mask->src))
+			rule->unused_tuple |= BIT(INNER_SRC_MAC);
 	} else {
 		rule->unused_tuple |= BIT(INNER_DST_MAC);
 		rule->unused_tuple |= BIT(INNER_SRC_MAC);
@@ -7290,6 +7294,10 @@ static int hclge_get_cls_key_ip(const struct flow_rule *flow,
 		rule->tuples.dst_ip[IPV4_INDEX] = be32_to_cpu(match.key->dst);
 		rule->tuples_mask.dst_ip[IPV4_INDEX] =
 						be32_to_cpu(match.mask->dst);
+		if (!match.mask->src)
+			rule->unused_tuple |= BIT(INNER_SRC_IP);
+		if (!match.mask->dst)
+			rule->unused_tuple |= BIT(INNER_DST_IP);
 	} else if (addr_type == FLOW_DISSECTOR_KEY_IPV6_ADDRS) {
 		struct flow_match_ipv6_addrs match;
 
@@ -7302,6 +7310,10 @@ static int hclge_get_cls_key_ip(const struct flow_rule *flow,
 				      match.key->dst.s6_addr32);
 		ipv6_addr_be32_to_cpu(rule->tuples_mask.dst_ip,
 				      match.mask->dst.s6_addr32);
+		if (ipv6_addr_any(&match.mask->src))
+			rule->unused_tuple |= BIT(INNER_SRC_IP);
+		if (ipv6_addr_any(&match.mask->dst))
+			rule->unused_tuple |= BIT(INNER_DST_IP);
 	} else {
 		rule->unused_tuple |= BIT(INNER_SRC_IP);
 		rule->unused_tuple |= BIT(INNER_DST_IP);
Signature · 1 line
2.33.0
author maintainer
#3 lore raw

PATCH v4 3/6 net: hns3: support two more actions for tc flow

In reply to Jijie Shao

Currently, the driver supports only one action:HCLGE_FD_ACTION_SELECT_TC.

This patch adds support for HCLGE_FD_ACTION_SELECT_QUEUE and HCLGE_FD_ACTION_DROP_PACKET.

A rule can have only one action. Therefore, the driver intercepts rules that have multiple actions or no action.

Note: The driver considers cls_flower->classid as an action:
HCLGE_FD_ACTION_SELECT_TC.

---
 .../hisilicon/hns3/hns3pf/hclge_main.c        | 63 ++++++++++++++++---
 1 file changed, 56 insertions(+), 7 deletions(-)
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +56 -7
index 176ea5aac8aa..ed7cd0a0d267 100644
@@ -7344,19 +7344,49 @@ static int hclge_get_tc_flower_action(struct hclge_dev *hdev,
 				      struct flow_cls_offload *cls_flower,
 				      struct hclge_fd_rule *rule)
 {
+	struct flow_rule *flow = flow_cls_offload_flow_rule(cls_flower);
 	struct netlink_ext_ack *extack = cls_flower->common.extack;
 	struct hnae3_handle *handle = &hdev->vport[0].nic;
+	struct flow_action *action = &flow->action;
+	struct flow_action_entry *act;
 	int tc;
 
-	tc = tc_classid_to_hwtc(handle->netdev, cls_flower->classid);
-	if (tc < 0 || tc > hdev->tc_max) {
-		NL_SET_ERR_MSG_FMT_MOD(extack, "invalid traffic class: %d", tc);
-		return -EINVAL;
+	if (!flow_action_has_entries(&flow->action)) {
+		tc = tc_classid_to_hwtc(handle->netdev, cls_flower->classid);
+		if (tc < 0 || tc > hdev->tc_max) {
+			NL_SET_ERR_MSG_FMT_MOD(extack,
+					       "invalid traffic class: %d",
+					       tc);
+			return -EINVAL;
+		}
+
+		rule->action = HCLGE_FD_ACTION_SELECT_TC;
+		rule->cls_flower.tc = tc;
+		return 0;
 	}
 
-	rule->action = HCLGE_FD_ACTION_SELECT_TC;
-	rule->cls_flower.tc = tc;
-	return 0;
+	act = &action->entries[0];
+	switch (act->id) {
+	case FLOW_ACTION_RX_QUEUE_MAPPING:
+		if (act->rx_queue >= handle->kinfo.num_tqps) {
+			NL_SET_ERR_MSG_FMT_MOD(extack,
+					       "queue id (%u) should be less than %u",
+					       act->rx_queue,
+					       handle->kinfo.num_tqps);
+			return -EINVAL;
+		}
+
+		rule->queue_id = act->rx_queue;
+		rule->action = HCLGE_FD_ACTION_SELECT_QUEUE;
+		return 0;
+	case FLOW_ACTION_DROP:
+		rule->action = HCLGE_FD_ACTION_DROP_PACKET;
+		return 0;
+	default:
+		NL_SET_ERR_MSG_FMT_MOD(extack,
+				       "unsupported action(%d)", act->id);
+		return -EOPNOTSUPP;
+	}
 }
 
 static int hclge_parse_cls_flower(struct hclge_dev *hdev,
@@ -7420,6 +7450,25 @@ static int hclge_check_cls_flower(struct hclge_dev *hdev,
 		return -EOPNOTSUPP;
 	}
 
+	/* driver will parses classid into an action */
+	if (cls_flower->classid && flow_action_has_entries(&flow->action)) {
+		NL_SET_ERR_MSG_MOD(extack,
+				   "cannot specify both classid and action");
+		return -EOPNOTSUPP;
+	}
+
+	if (!flow_action_has_entries(&flow->action) && !cls_flower->classid) {
+		NL_SET_ERR_MSG_MOD(extack,
+				   "must specify either classid or action");
+		return -EINVAL;
+	}
+
+	if (flow_action_has_entries(&flow->action) &&
+	    !flow_offload_has_one_action(&flow->action)) {
+		NL_SET_ERR_MSG_MOD(extack, "unsupported multiple actions");
+		return -EOPNOTSUPP;
+	}
+
 	return 0;
 }
 
Signature · 1 line
2.33.0
author maintainer
#4 lore raw

PATCH v4 4/6 net: hns3: support IP and tunnel VNI dissectors for tc flow

In reply to Jijie Shao

Currently, the driver does not support FLOW_DISSECTOR_KEY_IP and FLOW_DISSECTOR_KEY_ENC_KEYID. But the hardware supports ip_tos (FLOW_DISSECTOR_KEY_IP) and
outer_tun_vni (FLOW_DISSECTOR_KEY_ENC_KEYID).

This patch adds support for FLOW_DISSECTOR_KEY_IP and FLOW_DISSECTOR_KEY_ENC_KEYID.

Additionally, since tc flow cannot effectively support l2_user_def, l3_user_def, and l4_user_def, this patch explicitly sets them to not be used.

---
 .../hisilicon/hns3/hns3pf/hclge_main.c        | 91 +++++++++++++++++--
 .../hisilicon/hns3/hns3pf/hclge_main.h        |  4 +
 2 files changed, 88 insertions(+), 7 deletions(-)
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +84 -7
index ed7cd0a0d267..b8d4858fe39a 100644
@@ -16,7 +16,7 @@
 #include <linux/crash_dump.h>
 
 #include <net/rtnetlink.h>
-
+#include <net/vxlan.h>
 #include "hclge_cmd.h"
 #include "hclge_dcb.h"
 #include "hclge_main.h"
@@ -337,7 +337,9 @@ static const struct key_info tuple_key_info[] = {
 	{ OUTER_SRC_PORT, 16, KEY_OPT_LE16, -1, -1 },
 	{ OUTER_DST_PORT, 16, KEY_OPT_LE16, -1, -1 },
 	{ OUTER_L4_RSV, 32, KEY_OPT_LE32, -1, -1 },
-	{ OUTER_TUN_VNI, 24, KEY_OPT_VNI, -1, -1 },
+	{ OUTER_TUN_VNI, 24, KEY_OPT_VNI,
+	  offsetof(struct hclge_fd_rule, tuples.outer_tun_vni),
+	  offsetof(struct hclge_fd_rule, tuples_mask.outer_tun_vni) },
 	{ OUTER_TUN_FLOW_ID, 8, KEY_OPT_U8, -1, -1 },
 	{ INNER_DST_MAC, 48, KEY_OPT_MAC,
 	  offsetof(struct hclge_fd_rule, tuples.dst_mac),
@@ -5590,8 +5592,9 @@ static int hclge_init_fd_config(struct hclge_dev *hdev)
 
 	/* If use max 400bit key, we can support tuples for ether type */
 	if (hdev->fd_cfg.fd_mode == HCLGE_FD_MODE_DEPTH_2K_WIDTH_400B_STAGE_1) {
-		key_cfg->tuple_active |=
-				BIT(INNER_DST_MAC) | BIT(INNER_SRC_MAC);
+		key_cfg->tuple_active |= BIT(INNER_DST_MAC) |
+					 BIT(INNER_SRC_MAC) |
+					 BIT(OUTER_TUN_VNI);
 		if (hdev->ae_dev->dev_version >= HNAE3_DEVICE_VERSION_V3)
 			key_cfg->tuple_active |= HCLGE_FD_TUPLE_USER_DEF_TUPLES;
 	}
@@ -5713,6 +5716,7 @@ static bool hclge_fd_convert_tuple(u32 tuple_bit, u8 *key_x, u8 *key_y,
 	u16 tmp_x_s, tmp_y_s;
 	u32 tmp_x_l, tmp_y_l;
 	u8 *p = (u8 *)rule;
+	__le32 le_x, le_y;
 	int i;
 
 	if (rule->unused_tuple & BIT(tuple_bit))
@@ -5760,6 +5764,15 @@ static bool hclge_fd_convert_tuple(u32 tuple_bit, u8 *key_x, u8 *key_y,
 		*(__le32 *)key_x = cpu_to_le32(tmp_x_l);
 		*(__le32 *)key_y = cpu_to_le32(tmp_y_l);
 
+		return true;
+	case KEY_OPT_VNI:
+		calc_x(tmp_x_l, *(u32 *)(&p[offset]), *(u32 *)(&p[moffset]));
+		calc_y(tmp_y_l, *(u32 *)(&p[offset]), *(u32 *)(&p[moffset]));
+		le_x = cpu_to_le32(tmp_x_l);
+		le_y = cpu_to_le32(tmp_y_l);
+		memcpy(key_x, &le_x, HCLGE_VNI_LENGTH);
+		memcpy(key_y, &le_y, HCLGE_VNI_LENGTH);
+
 		return true;
 	default:
 		return false;
@@ -7340,6 +7353,62 @@ static void hclge_get_cls_key_port(const struct flow_rule *flow,
 	}
 }
 
+static int hclge_get_cls_enc_keyid(struct hclge_dev *hdev,
+				   const struct flow_rule *flow,
+				   struct hclge_fd_rule *rule,
+				   struct netlink_ext_ack *extack)
+{
+	if (flow_rule_match_key(flow, FLOW_DISSECTOR_KEY_ENC_KEYID)) {
+		struct flow_match_enc_keyid match;
+
+		flow_rule_match_enc_keyid(flow, &match);
+
+		/* vni is only 24 bits and must be greater than 0,
+		 * and it can not be masked.
+		 */
+		if (be32_to_cpu(match.mask->keyid) !=
+		    HCLGE_FD_VXLAN_VNI_UNMASK ||
+		    be32_to_cpu(match.key->keyid) >= VXLAN_N_VID ||
+		    !match.key->keyid) {
+			NL_SET_ERR_MSG_MOD(extack, "invalid enc_keyid");
+			return -EINVAL;
+		}
+
+		rule->tuples.outer_tun_vni = be32_to_cpu(match.key->keyid);
+		rule->tuples_mask.outer_tun_vni =
+						be32_to_cpu(match.mask->keyid);
+	} else {
+		rule->unused_tuple |= BIT(OUTER_TUN_VNI);
+	}
+
+	return 0;
+}
+
+static int hclge_get_cls_key_ip_tos(const struct flow_rule *flow,
+				    struct hclge_fd_rule *rule,
+				    struct netlink_ext_ack *extack)
+{
+	if (flow_rule_match_key(flow, FLOW_DISSECTOR_KEY_IP)) {
+		struct flow_match_ip match;
+
+		flow_rule_match_ip(flow, &match);
+
+		if (match.mask->ttl) {
+			NL_SET_ERR_MSG_MOD(extack, "unsupported TTL");
+			return -EOPNOTSUPP;
+		}
+
+		rule->tuples.ip_tos = match.key->tos;
+		rule->tuples_mask.ip_tos = match.mask->tos;
+		if (!rule->tuples_mask.ip_tos)
+			rule->unused_tuple |= BIT(INNER_IP_TOS);
+	} else {
+		rule->unused_tuple |= BIT(INNER_IP_TOS);
+	}
+
+	return 0;
+}
+
 static int hclge_get_tc_flower_action(struct hclge_dev *hdev,
 				      struct flow_cls_offload *cls_flower,
 				      struct hclge_fd_rule *rule)
@@ -7397,6 +7466,9 @@ static int hclge_parse_cls_flower(struct hclge_dev *hdev,
 	struct netlink_ext_ack *extack = cls_flower->common.extack;
 	int ret;
 
+	/* not support any user def tuples */
+	rule->unused_tuple |= HCLGE_FD_TUPLE_USER_DEF_TUPLES;
+
 	hclge_get_cls_key_basic(flow, rule);
 	hclge_get_cls_key_mac(flow, rule);
 	hclge_get_cls_key_vlan(flow, rule);
@@ -7406,8 +7478,11 @@ static int hclge_parse_cls_flower(struct hclge_dev *hdev,
 		return ret;
 
 	hclge_get_cls_key_port(flow, rule);
+	ret = hclge_get_cls_key_ip_tos(flow, rule, extack);
+	if (ret)
+		return ret;
 
-	return 0;
+	return hclge_get_cls_enc_keyid(hdev, flow, rule, extack);
 }
 
 static int hclge_check_cls_flower(struct hclge_dev *hdev,
@@ -7439,10 +7514,12 @@ static int hclge_check_cls_flower(struct hclge_dev *hdev,
 		       BIT_ULL(FLOW_DISSECTOR_KEY_VLAN) |
 		       BIT_ULL(FLOW_DISSECTOR_KEY_IPV4_ADDRS) |
 		       BIT_ULL(FLOW_DISSECTOR_KEY_IPV6_ADDRS) |
-		       BIT_ULL(FLOW_DISSECTOR_KEY_PORTS);
+		       BIT_ULL(FLOW_DISSECTOR_KEY_PORTS) |
+		       BIT_ULL(FLOW_DISSECTOR_KEY_IP);
 
 	if (hdev->fd_cfg.fd_mode == HCLGE_FD_MODE_DEPTH_2K_WIDTH_400B_STAGE_1)
-		support_keys |= BIT_ULL(FLOW_DISSECTOR_KEY_ETH_ADDRS);
+		support_keys |= BIT_ULL(FLOW_DISSECTOR_KEY_ETH_ADDRS) |
+				BIT_ULL(FLOW_DISSECTOR_KEY_ENC_KEYID);
 
 	if (dissector->used_keys & ~support_keys) {
 		NL_SET_ERR_MSG_FMT_MOD(extack, "unsupported key set: %#llx",
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h +4 -0
index 032b472d2368..ccb19d960690 100644
@@ -645,6 +645,9 @@ struct key_info {
 #define HCLGE_FD_USER_DEF_DATA		GENMASK(15, 0)
 #define HCLGE_FD_USER_DEF_OFFSET	GENMASK(15, 0)
 #define HCLGE_FD_USER_DEF_OFFSET_UNMASK	GENMASK(15, 0)
+#define HCLGE_FD_VXLAN_VNI_UNMASK	GENMASK(31, 0)
+
+#define HCLGE_VNI_LENGTH		3
 
 /* assigned by firmware, the real filter number for each pf may be less */
 #define MAX_FD_FILTER_NUM	4096
@@ -738,6 +741,7 @@ struct hclge_fd_rule_tuples {
 	u32 l4_user_def;
 	u8 ip_tos;
 	u8 ip_proto;
+	u32 outer_tun_vni;
 };
 
 struct hclge_fd_rule {
Signature · 1 line
2.33.0
author maintainer
#5 lore raw

PATCH v4 5/6 net: hns3: debugfs support for dumping fd rules

In reply to Jijie Shao

Currently, the tc tool only supports adding and deleting rules from the driver but does not support querying rules from the driver.

This patch adds a rule dump file in debugfs to check whether the driver's configuration matches the configuration issued by tc flow.

---
 drivers/net/ethernet/hisilicon/hns3/hnae3.h   |   1 +
 .../ethernet/hisilicon/hns3/hns3_debugfs.c    |   6 +
 .../hisilicon/hns3/hns3pf/hclge_debugfs.c     | 155 ++++++++++++++++++
 3 files changed, 162 insertions(+)
drivers/net/ethernet/hisilicon/hns3/hnae3.h +1 -0
index a724935b655a..a8798eecd9fb 100644
@@ -331,6 +331,7 @@ enum hnae3_dbg_cmd {
 	HNAE3_DBG_CMD_TX_QUEUE_INFO,
 	HNAE3_DBG_CMD_FD_TCAM,
 	HNAE3_DBG_CMD_FD_COUNTER,
+	HNAE3_DBG_CMD_FD_RULE,
 	HNAE3_DBG_CMD_MAC_TNL_STATUS,
 	HNAE3_DBG_CMD_SERV_INFO,
 	HNAE3_DBG_CMD_UMV_INFO,
drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c +6 -0
index 4cce4f4ba6b0..1347edac7699 100644
@@ -273,6 +273,12 @@ static struct hns3_dbg_cmd_info hns3_dbg_cmd[] = {
 		.dentry = HNS3_DBG_DENTRY_FD,
 		.init = hns3_dbg_common_init_t2,
 	},
+	{
+		.name = "fd_rule",
+		.cmd = HNAE3_DBG_CMD_FD_RULE,
+		.dentry = HNS3_DBG_DENTRY_FD,
+		.init = hns3_dbg_common_init_t2,
+	},
 	{
 		.name = "service_task_info",
 		.cmd = HNAE3_DBG_CMD_SERV_INFO,
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c +155 -0

167 lines not on this page · raw message

Signature · 1 line
2.33.0
author maintainer
#6 lore raw

PATCH v4 6/6 net: hns3: move fd code to a separate file

In reply to Jijie Shao

The hclge_main.c file has become very large,
so the fd code has been moved to a separate hclge_fd.c file. This patch only moves the code and does not modify any functionality.

---
 drivers/net/ethernet/hisilicon/hns3/Makefile  |    1 +
 .../ethernet/hisilicon/hns3/hns3pf/hclge_fd.c | 2593 ++++++++++++++++
 .../ethernet/hisilicon/hns3/hns3pf/hclge_fd.h |   33 +
 .../hisilicon/hns3/hns3pf/hclge_main.c        | 2675 +----------------
 .../hisilicon/hns3/hns3pf/hclge_main.h        |    2 +
 5 files changed, 2672 insertions(+), 2632 deletions(-)
 create mode 100644 drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_fd.c
 create mode 100644 drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_fd.h
drivers/net/ethernet/hisilicon/hns3/Makefile +1 -0
index e8af26da1fc1..5785d4c5709e 100644
@@ -24,5 +24,6 @@ hclgevf-objs = hns3vf/hclgevf_main.o hns3vf/hclgevf_mbx.o  hns3vf/hclgevf_devlin
 obj-$(CONFIG_HNS3_HCLGE) += hclge.o hclge-common.o
 hclge-objs = hns3pf/hclge_main.o hns3pf/hclge_mdio.o hns3pf/hclge_tm.o hns3pf/hclge_regs.o \
 		hns3pf/hclge_mbx.o hns3pf/hclge_err.o  hns3pf/hclge_debugfs.o hns3pf/hclge_ptp.o hns3pf/hclge_devlink.o \
+		hns3pf/hclge_fd.o
 
 hclge-$(CONFIG_HNS3_DCB) += hns3pf/hclge_dcb.o
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_fd.c new file +2593 -0

2,593 lines not on this page · raw message

drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_fd.h new file +33 -0
new file mode 100644
index 000000000000..2f66cc9c3c65
@@ -0,0 +1,33 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/* Copyright (c) 2026 Hisilicon Limited. */
+
+#ifndef __HCLGE_FD_H
+#define __HCLGE_FD_H
+
+struct hnae3_handle;
+struct hclge_dev;
+
+int hclge_init_fd_config(struct hclge_dev *hdev);
+int hclge_add_fd_entry(struct hnae3_handle *handle, struct ethtool_rxnfc *cmd);
+int hclge_del_fd_entry(struct hnae3_handle *handle, struct ethtool_rxnfc *cmd);
+void hclge_del_all_fd_entries(struct hclge_dev *hdev);
+int hclge_restore_fd_entries(struct hnae3_handle *handle);
+int hclge_get_fd_rule_cnt(struct hnae3_handle *handle,
+			  struct ethtool_rxnfc *cmd);
+int hclge_get_fd_rule_info(struct hnae3_handle *handle,
+			   struct ethtool_rxnfc *cmd);
+int hclge_get_all_rules(struct hnae3_handle *handle,
+			struct ethtool_rxnfc *cmd, u32 *rule_locs);
+void hclge_enable_fd(struct hnae3_handle *handle, bool enable);
+int hclge_add_fd_entry_by_arfs(struct hnae3_handle *handle, u16 queue_id,
+			       u16 flow_id, struct flow_keys *fkeys);
+int hclge_add_cls_flower(struct hnae3_handle *handle,
+			 struct flow_cls_offload *cls_flower);
+int hclge_del_cls_flower(struct hnae3_handle *handle,
+			 struct flow_cls_offload *cls_flower);
+bool hclge_is_cls_flower_active(struct hnae3_handle *handle);
+int hclge_clear_arfs_rules(struct hclge_dev *hdev);
+void hclge_sync_fd_table(struct hclge_dev *hdev);
+void hclge_rfs_filter_expire(struct hclge_dev *hdev);
+
+#endif
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +43 -2632

368 lines not on this page · raw message

drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h +2 -0
index ccb19d960690..87adeb64e6ea 100644

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.33.0

Part of the diff is not shown here. View the raw message.

reviewer
#7 lore raw
In reply to Jijie Shao
Quoted 8 lines · Jijie Shao

This patchset enhances the tc flow offload support for hns3 driver:

- Patch 1: Refactor hclge_add_cls_flower() to support more actions
- Patch 2: Improve unused_tuple parameter setting for separate src/dst configuration
- Patch 3: Add support for HCLGE_FD_ACTION_SELECT_QUEUE and HCLGE_FD_ACTION_DROP_PACKET actions
- Patch 4: Add support for FLOW_DISSECTOR_KEY_IP and FLOW_DISSECTOR_KEY_ENC_KEYID dissectors
- Patch 5: Add debugfs support for dumping FD rules
- Patch 6: Move FD code to a separate file (hclge_fd.c) for better code organization

Hi Jijie,

There is AI-generated review of this patch-set available on both
https://sashiko.dev and https://netdev-ai.bots.linux.dev/sashiko/
I would appreciate it if you could look over that with a view to addressing any issues that directly affect this patch.

...

#8 lore raw
In reply to Jijie Shao
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Quoted 10 lines · On Wed, 10 Jun 2026 14:06:12 +0800 you wrote:

This patchset enhances the tc flow offload support for hns3 driver:

- Patch 1: Refactor hclge_add_cls_flower() to support more actions
- Patch 2: Improve unused_tuple parameter setting for separate src/dst configuration
- Patch 3: Add support for HCLGE_FD_ACTION_SELECT_QUEUE and HCLGE_FD_ACTION_DROP_PACKET actions
- Patch 4: Add support for FLOW_DISSECTOR_KEY_IP and FLOW_DISSECTOR_KEY_ENC_KEYID dissectors
- Patch 5: Add debugfs support for dumping FD rules
- Patch 6: Move FD code to a separate file (hclge_fd.c) for better code organization

[...]

Here is the summary with links:
- [V4,net-next,1/6] net: hns3: refactor add_cls_flower to prepare for multiple actions

    https://git.kernel.org/netdev/net-next/c/d7db57e3b42a
  - [V4,net-next,2/6] net: hns3: improve the unused_tuple parameter setting
    https://git.kernel.org/netdev/net-next/c/1ad6f1ff3e96
  - [V4,net-next,3/6] net: hns3: support two more actions for tc flow
    https://git.kernel.org/netdev/net-next/c/e6703605b47e
  - [V4,net-next,4/6] net: hns3: support IP and tunnel VNI dissectors for tc flow
    https://git.kernel.org/netdev/net-next/c/cc2c4dbb00fb
  - [V4,net-next,5/6] net: hns3: debugfs support for dumping fd rules
    https://git.kernel.org/netdev/net-next/c/6c586b3ab8b7
  - [V4,net-next,6/6] net: hns3: move fd code to a separate file
    https://git.kernel.org/netdev/net-next/c/d76612e4aacf

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html