Skip to contentSkip to conversation

use traffic class PRM field for IPv6 modification

PATCH In review Gavin Li 2 participants 4 messages Jan 12, 2024 – Jan 17, 2024 Network drivers

lore
Share & tools
lore

Gavin Li

author
#0 lore raw

cover use traffic class PRM field for IPv6 modification

New field ID OUT_IPV6_TRAFFIC_CLASS for IPv6 was defined and will be used by both IPv6 ECN and DSCP.

To apply the new ID and keep backward compatibility with different RDMA core and FW releases
1) detect the support of the new ID in RDMA core and FW.
2) apply the new ID if possible otherwise, keep using the old ID.

Gavin Li (2):
net/mlx5: discover IPv6 traffic class support in RDMA core net/mlx5: use traffic class PRM field for IPv6 modification

 drivers/common/mlx5/mlx5_devx_cmds.c |  3 ++
 drivers/common/mlx5/mlx5_devx_cmds.h |  1 +
 drivers/common/mlx5/mlx5_prm.h       |  8 ++-
 drivers/net/mlx5/linux/mlx5_os.c     |  5 ++
 drivers/net/mlx5/mlx5.h              |  1 +
 drivers/net/mlx5/mlx5_flow.c         | 42 +++++++++++++++
 drivers/net/mlx5/mlx5_flow.h         |  4 ++
 drivers/net/mlx5/mlx5_flow_dv.c      | 78 ++++++++++++++++++++++++----
 drivers/net/mlx5/mlx5_flow_hw.c      |  7 +++
 9 files changed, 138 insertions(+), 11 deletions(-)
Signature · 1 line
2.39.1
author
#1 lore raw

PATCH 1/2 net/mlx5: discover IPv6 traffic class support in RDMA core

Previously, IPv6 traffic class used the same ids of IPv4 DSCP and ECN by rdam core and firmware. New FW support new IPv6 traffic class id which is recommended to be used though the old way is still working.

FW exposed a new cap bit to indicate the supporting of the new id while RDMA core does not have such mechanism.

To fix the backward compatibility issue of combination of RDMA core and FW of different versions, a new function and a new flag were introduced to check if the new IPv6 traffic class id is supported by RDMA core.

---
 drivers/net/mlx5/linux/mlx5_os.c |  4 +++
 drivers/net/mlx5/mlx5.h          |  1 +
 drivers/net/mlx5/mlx5_flow.c     | 42 ++++++++++++++++++++++++++++++++
 drivers/net/mlx5/mlx5_flow.h     |  1 +
 4 files changed, 48 insertions(+)
drivers/net/mlx5/linux/mlx5_os.c +4 -0
index ae82e1e5d8..5ae31c88f4 100644
@@ -1602,6 +1602,10 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,
 			goto error;
 	}
 	rte_rwlock_init(&priv->ind_tbls_lock);
+	if (sh->config.dv_flow_en == 1 &&
+	    !priv->sh->ipv6_tc_fallback &&
+	    mlx5_flow_discover_ipv6_tc_support(eth_dev))
+		priv->sh->ipv6_tc_fallback = 1;
 	if (priv->sh->config.dv_flow_en == 2) {
 #ifdef HAVE_MLX5_HWS_SUPPORT
 		if (priv->sh->config.dv_esw_en) {
drivers/net/mlx5/mlx5.h +1 -0
index 263ebead7f..779805bcd8 100644
@@ -1444,6 +1444,7 @@ struct mlx5_dev_ctx_shared {
 	uint32_t lag_rx_port_affinity_en:1;
 	/* lag_rx_port_affinity is supported. */
 	uint32_t hws_max_log_bulk_sz:5;
+	uint32_t ipv6_tc_fallback:1;
 	/* Log of minimal HWS counters created hard coded. */
 	uint32_t hws_max_nb_counters; /* Maximal number for HWS counters. */
 	uint32_t max_port; /* Maximal IB device port index. */
drivers/net/mlx5/mlx5_flow.c +42 -0

45 lines not on this page · raw message

drivers/net/mlx5/mlx5_flow.h +1 -0
index 120609c595..33d4a28077 100644
@@ -2638,6 +2638,7 @@ void mlx5_flow_destroy_sub_policy_with_rxq(struct rte_eth_dev *dev,
 		struct mlx5_flow_meter_policy *mtr_policy);
 int mlx5_flow_dv_discover_counter_offset_support(struct rte_eth_dev *dev);
 int mlx5_flow_discover_dr_action_support(struct rte_eth_dev *dev);
+int mlx5_flow_discover_ipv6_tc_support(struct rte_eth_dev *dev);
 int mlx5_action_handle_attach(struct rte_eth_dev *dev);
 int mlx5_action_handle_detach(struct rte_eth_dev *dev);
 int mlx5_action_handle_flush(struct rte_eth_dev *dev);
Signature · 1 line
2.39.1
author
#2 lore raw

PATCH 2/2 net/mlx5: use traffic class PRM field for IPv6 modification

In reply to Gavin Li

New PRM defined new field OUT_IPV6_TRAFFIC_CLASS for IPv6 which will be used by both IPv6 ECN and DSCP. A new cap bit modify_out_ipv6_traffic_class is added. It can be used to check if the new field is supported by FW.

However, IPv6 ECN and DSCP starts from different offset in the same byte. Update SWS and HWS to used the new filed and introduce extra offset for IPv6 DSCP data and mask to solve the issue.

---
 drivers/common/mlx5/mlx5_devx_cmds.c |  3 ++
 drivers/common/mlx5/mlx5_devx_cmds.h |  1 +
 drivers/common/mlx5/mlx5_prm.h       |  8 ++-
 drivers/net/mlx5/linux/mlx5_os.c     |  5 +-
 drivers/net/mlx5/mlx5_flow.h         |  3 ++
 drivers/net/mlx5/mlx5_flow_dv.c      | 78 ++++++++++++++++++++++++----
 drivers/net/mlx5/mlx5_flow_hw.c      |  7 +++
 7 files changed, 92 insertions(+), 13 deletions(-)
drivers/common/mlx5/mlx5_devx_cmds.c +3 -0
index 4d8818924a..3a894f894a 100644
@@ -1229,6 +1229,9 @@ mlx5_devx_cmd_query_hca_attr(void *ctx,
 	attr->modify_outer_ip_ecn = MLX5_GET
 		(flow_table_nic_cap, hcattr,
 		 ft_header_modify_nic_receive.outer_ip_ecn);
+	attr->modify_outer_ipv6_traffic_class = MLX5_GET
+		(flow_table_nic_cap, hcattr,
+		 ft_header_modify_nic_receive.outer_ipv6_traffic_class);
 	attr->set_reg_c = 0xffff;
 	if (attr->nic_flow_table) {
 #define GET_RX_REG_X_BITS \
drivers/common/mlx5/mlx5_devx_cmds.h +1 -0
index 7f23e925a5..4a6008dc1a 100644
@@ -304,6 +304,7 @@ struct mlx5_hca_attr {
 	uint32_t set_reg_c:16;
 	uint32_t nic_flow_table:1;
 	uint32_t modify_outer_ip_ecn:1;
+	uint32_t modify_outer_ipv6_traffic_class:1;
 	union {
 		uint32_t max_flow_counter;
 		struct {
drivers/common/mlx5/mlx5_prm.h +6 -2
index 0d46ba9c40..69404b5ed8 100644
@@ -848,6 +848,7 @@ enum mlx5_modification_field {
 	MLX5_MODI_META_REG_C_13 = 0x94,
 	MLX5_MODI_META_REG_C_14 = 0x95,
 	MLX5_MODI_META_REG_C_15 = 0x96,
+	MLX5_MODI_OUT_IPV6_TRAFFIC_CLASS = 0x11C,
 	MLX5_MODI_OUT_IPV4_TOTAL_LEN = 0x11D,
 	MLX5_MODI_OUT_IPV6_PAYLOAD_LEN = 0x11E,
 	MLX5_MODI_OUT_IPV4_IHL = 0x11F,
@@ -2202,7 +2203,9 @@ struct mlx5_ifc_ft_fields_support_bits {
 		u8 metadata_reg_c_x[0x8];
 	}; /* end of DW3 */
 	/* set_action_field_support_2 */
-	u8 reserved_at_80[0x80];
+	u8 reserved_at_80[0x37];
+	u8 outer_ipv6_traffic_class[0x1];
+	u8 reserved_at_B8[0x48];
 	/* add_action_field_support */
 	u8 reserved_at_100[0x80];
 	/* add_action_field_support_2 */
@@ -2240,7 +2243,8 @@ struct mlx5_ifc_ft_fields_support_2_bits {
 	u8 inner_l4_checksum_ok[0x1];
 	u8 outer_ipv4_checksum_ok[0x1];
 	u8 outer_l4_checksum_ok[0x1]; /* end of DW0 */
-	u8 reserved_at_20[0x18];
+	u8 reserved_at_20[0x17];
+	u8 outer_ipv6_traffic_class[0x1];
 	union {
 		struct {
 			u8 metadata_reg_c_15[0x1];
drivers/net/mlx5/linux/mlx5_os.c +3 -2
index 5ae31c88f4..6ea0296109 100644
@@ -1602,9 +1602,10 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,
 			goto error;
 	}
 	rte_rwlock_init(&priv->ind_tbls_lock);
-	if (sh->config.dv_flow_en == 1 &&
+	if (!priv->sh->cdev->config.hca_attr.modify_outer_ipv6_traffic_class ||
+	    (sh->config.dv_flow_en == 1 &&
 	    !priv->sh->ipv6_tc_fallback &&
-	    mlx5_flow_discover_ipv6_tc_support(eth_dev))
+	    mlx5_flow_discover_ipv6_tc_support(eth_dev)))
 		priv->sh->ipv6_tc_fallback = 1;
 	if (priv->sh->config.dv_flow_en == 2) {
 #ifdef HAVE_MLX5_HWS_SUPPORT
drivers/net/mlx5/mlx5_flow.h +3 -0
index 33d4a28077..fe4f46724b 100644
@@ -413,6 +413,9 @@ enum mlx5_feature_name {
 #define IPPROTO_MPLS 137
 #endif
 
+#define MLX5_IPV6_HDR_ECN_MASK 0x3
+#define MLX5_IPV6_HDR_DSCP_SHIFT 2
+
 /* UDP port number for MPLS */
 #define MLX5_UDP_PORT_MPLS 6635
 
drivers/net/mlx5/mlx5_flow_dv.c +69 -9

154 lines not on this page · raw message

drivers/net/mlx5/mlx5_flow_hw.c +7 -0
index c4a90a3690..504a250e44 100644
@@ -2862,6 +2862,13 @@ flow_hw_modify_field_construct(struct mlx5_hw_q_job *job,
 		}
 		off_b = rte_bsf32(mask);
 		data = flow_dv_fetch_field(values + field->offset, field->size);
+		/*
+		 * IPV6 DSCP uses OUT_IPV6_TRAFFIC_CLASS as ID but it starts from 2
+		 * bits left. Shift the data left for IPV6 DSCP
+		 */
+		if (field->id == MLX5_MODI_OUT_IPV6_TRAFFIC_CLASS &&
+		    !(mask & MLX5_IPV6_HDR_ECN_MASK))
+			data <<= MLX5_IPV6_HDR_DSCP_SHIFT;
 		data = (data & mask) >> off_b;
 		job->mhdr_cmd[i++].data1 = rte_cpu_to_be_32(data);
 		++field;
Signature · 1 line
2.39.1
#3 lore raw
In reply to Gavin Li

Hi,

Quoted 34 lines

-----Original Message-----
From: Gavin Li <[email protected]>
Sent: Friday, January 12, 2024 9:51 AM
To: [email protected]; Dariusz Sosnowski <[email protected]>; Slava Ovsiienko <[email protected]>; Ori Kam <[email protected]>; Suanming Mou <[email protected]>; Matan Azrad <[email protected]>
Cc: Jiawei(Jonny) Wang <[email protected]>; Raslan Darawsheh <[email protected]>
Subject: [V1 0/2] use traffic class PRM field for IPv6 modification

New field ID OUT_IPV6_TRAFFIC_CLASS for IPv6 was defined and will be used by both IPv6 ECN and DSCP.

To apply the new ID and keep backward compatibility with different RDMA core and FW releases
1) detect the support of the new ID in RDMA core and FW.
2) apply the new ID if possible otherwise, keep using the old ID.

Gavin Li (2):
net/mlx5: discover IPv6 traffic class support in RDMA core net/mlx5: use traffic class PRM field for IPv6 modification

 drivers/common/mlx5/mlx5_devx_cmds.c |  3 ++
drivers/common/mlx5/mlx5_devx_cmds.h |  1 +
 drivers/common/mlx5/mlx5_prm.h       |  8 ++-
 drivers/net/mlx5/linux/mlx5_os.c     |  5 ++
 drivers/net/mlx5/mlx5.h              |  1 +
 drivers/net/mlx5/mlx5_flow.c         | 42 +++++++++++++++
 drivers/net/mlx5/mlx5_flow.h         |  4 ++
 drivers/net/mlx5/mlx5_flow_dv.c      | 78 ++++++++++++++++++++++++----
 drivers/net/mlx5/mlx5_flow_hw.c      |  7 +++
 9 files changed, 138 insertions(+), 11 deletions(-)
Quoted 2 lines

--
2.39.1

Series applied to next-net-mlx
Kindest regards
Raslan Darawsheh