Skip to contentSkip to conversation

mlx5 unified fdb

PATCH In review Ophir Munk 3 participants 10 messages Feb 26, 2025 1 message not in the archive Network drivers

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Ophir Munk

author
#1 lore raw

v2 cover mlx5 unified fdb

V1: initial version
V2: rebase + determine unified fdb based on FW capability

Bing Zhao (1):
net/mlx5: remove unneeded FDB flag on representor action

Ophir Munk (3):
common/mlx5: support FDB unified capability query net/mlx5: support FDB unified domain net/mlx5/hws: allow different types in miss validation

 drivers/common/mlx5/mlx5_devx_cmds.c |   3 +
 drivers/common/mlx5/mlx5_devx_cmds.h |   1 +
 drivers/net/mlx5/hws/mlx5dr_table.c  |  18 +-
 drivers/net/mlx5/linux/mlx5_os.c     |  11 +
 drivers/net/mlx5/mlx5.h              |   8 +
 drivers/net/mlx5/mlx5_flow_hw.c      | 521 ++++++++++++++++++++++++-----------
 drivers/net/mlx5/mlx5_flow_meter.c   |  16 +-
 drivers/net/mlx5/mlx5_flow_quota.c   |   9 +-
 drivers/net/mlx5/mlx5_hws_cnt.c      |   9 +-
 9 files changed, 429 insertions(+), 167 deletions(-)
Signature · 1 line
2.8.4
author
#2 lore raw

PATCH v2 1/4 common/mlx5: support FDB unified capability query

This commit queries the FW for the new unified FDB mode and saves it in mlx5 shared device as fdb_unified_en bit.

---
 drivers/common/mlx5/mlx5_devx_cmds.c | 3 +++
 drivers/common/mlx5/mlx5_devx_cmds.h | 1 +
 2 files changed, 4 insertions(+)
drivers/common/mlx5/mlx5_devx_cmds.c +3 -0
index bba00a9..f504b29 100644
@@ -1349,6 +1349,9 @@ mlx5_devx_cmd_query_hca_attr(void *ctx,
 		attr->max_header_modify_pattern_length = MLX5_GET(wqe_based_flow_table_cap,
 								  hcattr,
 								  max_header_modify_pattern_length);
+		attr->fdb_unified_en = MLX5_GET(wqe_based_flow_table_cap,
+						hcattr,
+						fdb_unified_en);
 	}
 	/* Query HCA attribute for ROCE. */
 	if (attr->roce) {
drivers/common/mlx5/mlx5_devx_cmds.h +1 -0
index 38548b4..8de4210 100644
@@ -325,6 +325,7 @@ struct mlx5_hca_attr {
 	uint32_t cross_vhca:1;
 	uint32_t lag_rx_port_affinity:1;
 	uint32_t wqe_based_flow_table_sup:1;
+	uint32_t fdb_unified_en:1;
 	uint8_t max_header_modify_pattern_length;
 	uint64_t system_image_guid;
 	uint32_t log_max_conn_track_offload:5;
Signature · 1 line
2.8.4
Acked-by on v2 1/4
#3 lore raw

RE: [PATCH V2 1/4] common/mlx5: support FDB unified capability query

Quoted 12 lines

-----Original Message-----
From: Ophir Munk <[email protected]>
Sent: Wednesday, February 26, 2025 9:39 AM
To: Dariusz Sosnowski <[email protected]>; Slava Ovsiienko <[email protected]>; Bing Zhao <[email protected]>; Ori Kam <[email protected]>; Suanming Mou <[email protected]>; Matan Azrad <[email protected]>
Cc: [email protected]; Raslan Darawsheh <[email protected]>
Subject: [PATCH V2 1/4] common/mlx5: support FDB unified capability query

Quoted 4 lines

This commit queries the FW for the new unified FDB mode and saves it in mlx5 shared device as fdb_unified_en bit.

Best regards,
Dariusz Sosnowski

author
#4 lore raw

PATCH v2 2/4 net/mlx5: support FDB unified domain

In reply to Ophir Munk

Legacy FDB domain is enhanced with optional three sub-domains: FDB_RX FDB_TX and FDB_UNIFIED. Based on FW capability bit mlx5 will work in either legacy or unified mode. To work in fdb unified mode the flow attribute transfer bit must be set and the fdb sub domains are determined by the table specialize flags SPECIALIZE_TRANSFER_WIRE_ORIG and SPECIALIZE_TRANSFER_VPORT_ORIG.

+------------+-------------+--------------+
| WIRE_ORIG  | VPORT_ORIG  | FDB domain   |
+------------+-------------+--------------+
| 0          | 0           | FDB_UNIFIED  |
| 0          | 1           | FDB_TX       |
| 1          | 0           | FDB_RX       |
+------------+-------------+--------------+

There can be no two groups which only differ in their fdb sub domain. A table must be created in a group which has the same fdb sub domain.

---
 drivers/net/mlx5/linux/mlx5_os.c   |  11 +
 drivers/net/mlx5/mlx5.h            |   8 +
 drivers/net/mlx5/mlx5_flow_hw.c    | 519 ++++++++++++++++++++++++++-----------
 drivers/net/mlx5/mlx5_flow_meter.c |  16 +-
 drivers/net/mlx5/mlx5_flow_quota.c |   9 +-
 drivers/net/mlx5/mlx5_hws_cnt.c    |   9 +-
 6 files changed, 409 insertions(+), 163 deletions(-)
drivers/net/mlx5/linux/mlx5_os.c +11 -0
index 091f288..7f13cb2 100644
@@ -1707,6 +1707,17 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,
 	LIST_INIT(&priv->hw_ext_ctrl_flows);
 	if (priv->sh->config.dv_flow_en == 2) {
 #ifdef HAVE_MLX5_HWS_SUPPORT
+		/*
+		 * Unified FDB flag is only needed for the actions created on the transfer
+		 * port. proxy port. It is not needed on the following ports:
+		 *   1. NIC PF / VF / SF
+		 *   2. in Verbs or DV/DR mode
+		 *   3. with unsupported FW
+		 *   4. all representors in HWS
+		 */
+		priv->unified_fdb_en = !!priv->master && sh->cdev->config.hca_attr.fdb_unified_en;
+		DRV_LOG(DEBUG, "port %u: unified FDB %s enabled.",
+			eth_dev->data->port_id, priv->unified_fdb_en ? "is" : "isn't");
 		if (priv->sh->config.dv_esw_en) {
 			uint32_t usable_bits;
 			uint32_t required_bits;
drivers/net/mlx5/mlx5.h +8 -0
index 2b590c9..f73f6e6 100644
@@ -1986,6 +1986,7 @@ struct mlx5_priv {
 	uint32_t mark_enabled:1; /* If mark action is enabled on rxqs. */
 	uint32_t num_lag_ports:4; /* Number of ports can be bonded. */
 	uint32_t tunnel_enabled:1; /* If tunnel offloading is enabled on rxqs. */
+	uint32_t unified_fdb_en:1; /* Unified FDB flag per port. */
 	uint16_t domain_id; /* Switch domain identifier. */
 	uint16_t vport_id; /* Associated VF vport index (if any). */
 	uint32_t vport_meta_tag; /* Used for vport index match ove VF LAG. */
@@ -2226,6 +2227,13 @@ mlx5_is_port_on_mpesw_device(struct mlx5_priv *priv)
 	return priv->mpesw_port >= 0;
 }
 
+static inline bool
+is_unified_fdb(const struct mlx5_priv *priv)
+{
+	/* Only needed on proxy port in E-Switch mode. */
+	return priv->unified_fdb_en;
+}
+
 /* mlx5.c */
 
 int mlx5_getenv_int(const char *);
drivers/net/mlx5/mlx5_flow_hw.c +363 -156

913 lines not on this page · raw message

drivers/net/mlx5/mlx5_flow_meter.c +13 -3
index 804f437..dab3c4b 100644
@@ -105,7 +105,11 @@ mlx5_flow_meter_init_guest(struct rte_eth_dev *dev)
 	priv->hws_mpool->devx_obj = host_priv->hws_mpool->devx_obj;
 	flags = MLX5DR_ACTION_FLAG_HWS_RX | MLX5DR_ACTION_FLAG_HWS_TX;
 	if (priv->sh->config.dv_esw_en && priv->master)
-		flags |= MLX5DR_ACTION_FLAG_HWS_FDB;
+		flags |= (is_unified_fdb(priv) ?
+			 (MLX5DR_ACTION_FLAG_HWS_FDB_RX |
+			  MLX5DR_ACTION_FLAG_HWS_FDB_TX |
+			  MLX5DR_ACTION_FLAG_HWS_FDB_UNIFIED) :
+			 MLX5DR_ACTION_FLAG_HWS_FDB);
 	priv->hws_mpool->action = mlx5dr_action_create_aso_meter
 			(priv->dr_ctx, (struct mlx5dr_devx_obj *)priv->hws_mpool->devx_obj,
 			 reg_id - REG_C_0, flags);
@@ -188,8 +192,14 @@ mlx5_flow_meter_init(struct rte_eth_dev *dev,
 		goto err;
 	}
 	flags = MLX5DR_ACTION_FLAG_HWS_RX | MLX5DR_ACTION_FLAG_HWS_TX;
-	if (priv->sh->config.dv_esw_en && priv->master)
-		flags |= MLX5DR_ACTION_FLAG_HWS_FDB;
+	if (priv->sh->config.dv_esw_en && priv->master) {
+		flags |= ((is_unified_fdb(priv)) ?
+			(MLX5DR_ACTION_FLAG_HWS_FDB_RX |
+			 MLX5DR_ACTION_FLAG_HWS_FDB_TX |
+			 MLX5DR_ACTION_FLAG_HWS_FDB_UNIFIED) :
+			 MLX5DR_ACTION_FLAG_HWS_FDB);
+	}
+
 	priv->mtr_bulk.action = mlx5dr_action_create_aso_meter
 			(priv->dr_ctx, (struct mlx5dr_devx_obj *)dcs,
 				reg_id - REG_C_0, flags);
drivers/net/mlx5/mlx5_flow_quota.c +7 -2
index 6ad0e8a..d94167d 100644
@@ -741,8 +741,13 @@ mlx5_flow_quota_init(struct rte_eth_dev *dev, uint32_t nb_quotas)
 		ret = mlx5_quota_init_guest(priv);
 	if (ret)
 		goto err;
-	if (priv->sh->config.dv_esw_en && priv->master)
-		flags |= MLX5DR_ACTION_FLAG_HWS_FDB;
+	if (priv->sh->config.dv_esw_en && priv->master) {
+		flags |= (is_unified_fdb(priv) ?
+				(MLX5DR_ACTION_FLAG_HWS_FDB_RX |
+				 MLX5DR_ACTION_FLAG_HWS_FDB_TX |
+				 MLX5DR_ACTION_FLAG_HWS_FDB_UNIFIED) :
+				MLX5DR_ACTION_FLAG_HWS_FDB);
+	}
 	qctx->dr_action = mlx5dr_action_create_aso_meter
 		(priv->dr_ctx, (struct mlx5dr_devx_obj *)qctx->devx_obj,
 		 reg_id - REG_C_0, flags);
drivers/net/mlx5/mlx5_hws_cnt.c +7 -2
index eaceedd..7b5e731 100644
@@ -666,8 +666,13 @@ mlx5_hws_cnt_pool_action_create(struct mlx5_priv *priv,
 	uint32_t flags;
 
 	flags = MLX5DR_ACTION_FLAG_HWS_RX | MLX5DR_ACTION_FLAG_HWS_TX;
-	if (priv->sh->config.dv_esw_en && priv->master)
-		flags |= MLX5DR_ACTION_FLAG_HWS_FDB;
+	if (priv->sh->config.dv_esw_en && priv->master) {
+		flags |= (is_unified_fdb(priv) ?
+				(MLX5DR_ACTION_FLAG_HWS_FDB_RX |
+				 MLX5DR_ACTION_FLAG_HWS_FDB_TX |
+				 MLX5DR_ACTION_FLAG_HWS_FDB_UNIFIED) :
+				MLX5DR_ACTION_FLAG_HWS_FDB);
+	}
 	for (idx = 0; idx < hpool->dcs_mng.batch_total; idx++) {
 		struct mlx5_hws_cnt_dcs *hdcs = &hpool->dcs_mng.dcs[idx];
 		struct mlx5_hws_cnt_dcs *dcs = &cpool->dcs_mng.dcs[idx];
Signature · 1 line
2.8.4
Acked-by on v2 2/4
#5 lore raw

RE: [PATCH V2 2/4] net/mlx5: support FDB unified domain

Quoted 27 lines

-----Original Message-----
From: Ophir Munk <[email protected]>
Sent: Wednesday, February 26, 2025 9:39 AM
To: Dariusz Sosnowski <[email protected]>; Slava Ovsiienko <[email protected]>; Bing Zhao <[email protected]>; Ori Kam <[email protected]>; Suanming Mou <[email protected]>; Matan Azrad <[email protected]>
Cc: [email protected]; Raslan Darawsheh <[email protected]>
Subject: [PATCH V2 2/4] net/mlx5: support FDB unified domain

Legacy FDB domain is enhanced with optional three sub-domains: FDB_RX FDB_TX and FDB_UNIFIED. Based on FW capability bit mlx5 will work in either legacy or unified mode. To work in fdb unified mode the flow attribute transfer bit must be set and the fdb sub domains are determined by the table specialize flags SPECIALIZE_TRANSFER_WIRE_ORIG and SPECIALIZE_TRANSFER_VPORT_ORIG.

+------------+-------------+--------------+
| WIRE_ORIG  | VPORT_ORIG  | FDB domain   |
+------------+-------------+--------------+
| 0          | 0           | FDB_UNIFIED  |
| 0          | 1           | FDB_TX       |
| 1          | 0           | FDB_RX       |
+------------+-------------+--------------+
Quoted 4 lines

There can be no two groups which only differ in their fdb sub domain. A table must be created in a group which has the same fdb sub domain.

Best regards,
Dariusz Sosnowski

author
#6 lore raw

PATCH v2 3/4 net/mlx5: remove unneeded FDB flag on representor action

In reply to Ophir Munk

From: Bing Zhao <[email protected]>

The "send_to_kernel" action is shared and created during the HWS configuration stage. By default, the NIC Rx and Tx flags are needed.

There is only one case that the FDB* flags are needed when creating the action, the same as other shared actions. Only the transfer proxy port needs the FDB* flags for shared actions.

Removing the unneeded FDB flags will help to save the resources of memory and STCs.

Fixes 07836ba156cb ("net/mlx5: fix device checking for send to kernel action")
---
 drivers/net/mlx5/mlx5_flow_hw.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)
drivers/net/mlx5/mlx5_flow_hw.c +6 -8
index 1cc074d..f0888db 100644
@@ -9649,21 +9649,18 @@ _create_send_to_kernel_actions(struct mlx5_priv *priv, int type)
 }
 
 static void
-flow_hw_create_send_to_kernel_actions(struct mlx5_priv *priv)
+flow_hw_create_send_to_kernel_actions(struct mlx5_priv *priv, bool is_proxy)
 {
 #ifdef HAVE_MLX5DV_DR_ACTION_CREATE_DEST_ROOT_TABLE
 	int i, from, to;
-	bool is_vf_sf_dev = priv->sh->dev_cap.vf || priv->sh->dev_cap.sf;
 	bool unified_fdb = is_unified_fdb(priv);
 
 	for (i = MLX5DR_TABLE_TYPE_NIC_RX; i <= MLX5DR_TABLE_TYPE_NIC_TX; i++)
 		_create_send_to_kernel_actions(priv, i);
 
-	if (priv->sh->config.dv_esw_en && !is_vf_sf_dev) {
-		from = unified_fdb ? MLX5DR_TABLE_TYPE_FDB_RX :
-					MLX5DR_TABLE_TYPE_FDB;
-		to = unified_fdb ? MLX5DR_TABLE_TYPE_FDB_UNIFIED :
-				      MLX5DR_TABLE_TYPE_FDB;
+	if (is_proxy) {
+		from = unified_fdb ? MLX5DR_TABLE_TYPE_FDB_RX : MLX5DR_TABLE_TYPE_FDB;
+		to = unified_fdb ? MLX5DR_TABLE_TYPE_FDB_UNIFIED : MLX5DR_TABLE_TYPE_FDB;
 		for (i = from; i <= to; i++)
 			_create_send_to_kernel_actions(priv, i);
 	}
@@ -9674,6 +9671,7 @@ static void
 flow_hw_destroy_send_to_kernel_action(struct mlx5_priv *priv)
 {
 	int i;
+
 	for (i = MLX5DR_TABLE_TYPE_NIC_RX; i < MLX5DR_TABLE_TYPE_MAX; i++) {
 		if (priv->hw_send_to_kernel[i]) {
 			mlx5dr_action_destroy(priv->hw_send_to_kernel[i]);
@@ -12171,7 +12169,7 @@ __flow_hw_configure(struct rte_eth_dev *dev,
 		}
 	}
 	if (!priv->shared_host)
-		flow_hw_create_send_to_kernel_actions(priv);
+		flow_hw_create_send_to_kernel_actions(priv, is_proxy);
 	if (port_attr->nb_conn_tracks || (host_priv && host_priv->hws_ctpool)) {
 		if (mlx5_flow_ct_init(dev, port_attr->nb_conn_tracks, nb_q_updated))
 			goto err;
Signature · 1 line
2.8.4
Acked-by on v2 3/4
#7 lore raw

RE: [PATCH V2 3/4] net/mlx5: remove unneeded FDB flag on representor action

Quoted 23 lines

-----Original Message-----
From: Ophir Munk <[email protected]>
Sent: Wednesday, February 26, 2025 9:39 AM
To: Dariusz Sosnowski <[email protected]>; Slava Ovsiienko <[email protected]>; Bing Zhao <[email protected]>; Ori Kam <[email protected]>; Suanming Mou <[email protected]>; Matan Azrad <[email protected]>
Cc: [email protected]; Raslan Darawsheh <[email protected]>; Jiawei(Jonny) Wang <[email protected]>
Subject: [PATCH V2 3/4] net/mlx5: remove unneeded FDB flag on representor action

From: Bing Zhao <[email protected]>

The "send_to_kernel" action is shared and created during the HWS configuration stage. By default, the NIC Rx and Tx flags are needed.

There is only one case that the FDB* flags are needed when creating the action, the same as other shared actions. Only the transfer proxy port needs the FDB* flags for shared actions.

Quoted 7 lines

Removing the unneeded FDB flags will help to save the resources of memory and STCs.

Fixes 07836ba156cb ("net/mlx5: fix device checking for send to kernel action")

Best regards,
Dariusz Sosnowski

author
#8 lore raw

PATCH v2 4/4 net/mlx5/hws: allow different types in miss validation

In reply to Ophir Munk

In validating Jump from group A to default miss group B DPDK requests that both groups types will be identical. In practice jumping from FDB_UNIFIED to FDB_RX or FDB_TX group types (or vice versa) is allowed. This commit enables this jumping between the different types.

Fixes b81f95ca770d ("net/mlx5/hws: support default miss table")
---
 drivers/net/mlx5/hws/mlx5dr_table.c | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)
drivers/net/mlx5/hws/mlx5dr_table.c +16 -2
index b371f42..c1c60b4 100644
@@ -626,6 +626,19 @@ int mlx5dr_table_connect_to_miss_table(struct mlx5dr_table *src_tbl,
 	return 0;
 }
 
+static bool mlx5dr_table_set_default_miss_valid_types(enum mlx5dr_table_type from,
+						      enum mlx5dr_table_type to)
+{
+	if (from == to ||
+	    ((from == MLX5DR_TABLE_TYPE_FDB_UNIFIED &&
+	     (to == MLX5DR_TABLE_TYPE_FDB_RX || to == MLX5DR_TABLE_TYPE_FDB_TX)) ||
+	     (to == MLX5DR_TABLE_TYPE_FDB_UNIFIED &&
+	     (from == MLX5DR_TABLE_TYPE_FDB_RX || from == MLX5DR_TABLE_TYPE_FDB_TX))))
+		return true;
+
+	return false;
+}
+
 static int mlx5dr_table_set_default_miss_not_valid(struct mlx5dr_table *tbl,
 						   struct mlx5dr_table *miss_tbl)
 {
@@ -637,8 +650,9 @@ static int mlx5dr_table_set_default_miss_not_valid(struct mlx5dr_table *tbl,
 	}
 
 	if (mlx5dr_table_is_root(tbl) ||
-	    (miss_tbl && mlx5dr_table_is_root(miss_tbl)) ||
-	    (miss_tbl && miss_tbl->type != tbl->type)) {
+	    (miss_tbl &&
+	     ((mlx5dr_table_is_root(miss_tbl)) ||
+	     !mlx5dr_table_set_default_miss_valid_types(tbl->type, miss_tbl->type)))) {
 		DR_LOG(ERR, "Invalid arguments");
 		rte_errno = EINVAL;
 		return -rte_errno;
Signature · 1 line
2.8.4
Acked-by on v2 4/4
#9 lore raw

RE: [PATCH V2 4/4] net/mlx5/hws: allow different types in miss validation

Quoted 12 lines

-----Original Message-----
From: Ophir Munk <[email protected]>
Sent: Wednesday, February 26, 2025 9:39 AM
To: Dariusz Sosnowski <[email protected]>; Slava Ovsiienko <[email protected]>; Bing Zhao <[email protected]>; Ori Kam <[email protected]>; Suanming Mou <[email protected]>; Matan Azrad <[email protected]>
Cc: [email protected]; Raslan Darawsheh <[email protected]>
Subject: [PATCH V2 4/4] net/mlx5/hws: allow different types in miss validation

Quoted 8 lines

In validating Jump from group A to default miss group B DPDK requests that both groups types will be identical. In practice jumping from FDB_UNIFIED to FDB_RX or FDB_TX group types (or vice versa) is allowed.
This commit enables this jumping between the different types.

Fixes b81f95ca770d ("net/mlx5/hws: support default miss table")

Best regards,
Dariusz Sosnowski

#10 lore raw
In reply to Ophir Munk

Hi,

From: Ophir Munk <[email protected]>
Sent: Wednesday, February 26, 2025 10:38 AM
To: Dariusz Sosnowski; Slava Ovsiienko; Bing Zhao; Ori Kam; Suanming Mou; Matan Azrad
Cc: [email protected]; Raslan Darawsheh
Subject: [PATCH V2 0/4] mlx5 unified fdb

V1: initial version
V2: rebase + determine unified fdb based on FW capability

Bing Zhao (1):
net/mlx5: remove unneeded FDB flag on representor action

Ophir Munk (3):
common/mlx5: support FDB unified capability query net/mlx5: support FDB unified domain net/mlx5/hws: allow different types in miss validation

 drivers/common/mlx5/mlx5_devx_cmds.c |   3 +
 drivers/common/mlx5/mlx5_devx_cmds.h |   1 +
 drivers/net/mlx5/hws/mlx5dr_table.c  |  18 +-
 drivers/net/mlx5/linux/mlx5_os.c     |  11 +
 drivers/net/mlx5/mlx5.h              |   8 +
 drivers/net/mlx5/mlx5_flow_hw.c      | 521 ++++++++++++++++++++++++-----------
 drivers/net/mlx5/mlx5_flow_meter.c   |  16 +-
 drivers/net/mlx5/mlx5_flow_quota.c   |   9 +-
 drivers/net/mlx5/mlx5_hws_cnt.c      |   9 +-
 9 files changed, 429 insertions(+), 167 deletions(-)

--
2.8.4

rebased squashed second and third patch together,
series applied to next-net-mlx,

Kindest regards,
Raslan Darawsheh