Skip to contentSkip to conversation

net/mlx5: enhancement metering support

RFC New Li Zhang 1 participant 9 messages Dec 15, 2020

Subsystems (2)
lore
Share & tools
lore

Li Zhang

author
#0 lore raw

cover net/mlx5: enhancement metering support

Li Zhang (8):
net/mlx5: use mask for meter register setting common/mlx5: add definitions for ASO flow meter common/mlx5: add read ASO flow meter HCA capability common/mlx5: add DevX API to create ASO flow meter object net/mlx5: flow meter pool to manage meter object net/mlx5: init/uninit flow meter queue for WQE net/mlx5: aso flow meter send WQE and CQE handle net/mlx5: add support of ASO meter action

 drivers/common/mlx5/mlx5_devx_cmds.c          |  68 ++
 drivers/common/mlx5/mlx5_devx_cmds.h          |  26 +-
 drivers/common/mlx5/mlx5_prm.h                |  75 ++-
 drivers/common/mlx5/version.map               |   3 +-
 drivers/net/mlx5/linux/mlx5_os.c              |  21 +-
 drivers/net/mlx5/meson.build                  |   2 +-
 drivers/net/mlx5/mlx5.c                       |  77 ++-
 drivers/net/mlx5/mlx5.h                       | 224 ++++++-
 drivers/net/mlx5/mlx5_flow.c                  | 132 +++-
 drivers/net/mlx5/mlx5_flow.h                  | 188 ++----
 .../mlx5/{mlx5_flow_age.c => mlx5_flow_aso.c} | 279 +++++++-
 drivers/net/mlx5/mlx5_flow_dv.c               | 280 ++++++--
 drivers/net/mlx5/mlx5_flow_meter.c            | 622 +++++++++++-------
 13 files changed, 1511 insertions(+), 486 deletions(-)
 rename drivers/net/mlx5/{mlx5_flow_age.c => mlx5_flow_aso.c} (69%)
Signature · 1 line
2.27.0
author
#1 lore raw

RFC 1/8 net/mlx5: use mask for meter register setting

ASO meter feature may require to locate the flow context tag action after the ASO action.
The register used for the meter tag is also used for the meter color:
Bits[0-7] A meter color value set by the HW. Bits[8-31] A flow meter context set by SW.

Currently the tag action for meter writes all the bits of the meter register, so it will potentially overwrite meter color when ASO meter action is before the tag action.

Set only 24-MSB-bits of meter register in the meter tag action.

---
 drivers/net/mlx5/mlx5_flow.c    | 22 ++++++++++++++++------
 drivers/net/mlx5/mlx5_flow.h    |  2 ++
 drivers/net/mlx5/mlx5_flow_dv.c |  2 ++
 3 files changed, 20 insertions(+), 6 deletions(-)
drivers/net/mlx5/mlx5_flow.c +16 -6
index 6ea9d87d18..1cfa817ae9 100644
@@ -4161,9 +4161,11 @@ flow_hairpin_split(struct rte_eth_dev *dev,
 	rte_memcpy(actions_rx, actions, sizeof(struct rte_flow_action));
 	actions_rx++;
 	set_tag = (void *)actions_rx;
-	set_tag->id = mlx5_flow_get_reg_id(dev, MLX5_HAIRPIN_RX, 0, NULL);
+	*set_tag = (struct mlx5_rte_flow_action_set_tag) {
+		.id = mlx5_flow_get_reg_id(dev, MLX5_HAIRPIN_RX, 0, NULL),
+		.data = flow_id,
+	};
 	MLX5_ASSERT(set_tag->id > REG_NON);
-	set_tag->data = flow_id;
 	tag_action->conf = set_tag;
 	/* Create Tx item list. */
 	rte_memcpy(actions_tx, actions, sizeof(struct rte_flow_action));
@@ -4296,6 +4298,7 @@ flow_meter_split_prep(struct rte_eth_dev *dev,
 	struct mlx5_rte_flow_item_tag *tag_spec;
 	struct mlx5_rte_flow_item_tag *tag_mask;
 	uint32_t tag_id = 0;
+	uint32_t reg_id = 0;
 	bool copy_vlan = false;
 
 	/* Prepare the actions for prefix and suffix flow. */
@@ -4343,7 +4346,7 @@ flow_meter_split_prep(struct rte_eth_dev *dev,
 	actions_pre++;
 	/* Set the tag. */
 	set_tag = (void *)actions_pre;
-	set_tag->id = mlx5_flow_get_reg_id(dev, MLX5_MTR_SFX, 0, &error);
+	reg_id = mlx5_flow_get_reg_id(dev, MLX5_MTR_SFX, 0, &error);
 	mlx5_ipool_malloc(priv->sh->ipool[MLX5_IPOOL_RSS_EXPANTION_FLOW_ID],
 			  &tag_id);
 	if (tag_id >= (1 << (sizeof(tag_id) * 8 - MLX5_MTR_COLOR_BITS))) {
@@ -4355,7 +4358,12 @@ flow_meter_split_prep(struct rte_eth_dev *dev,
 	} else if (!tag_id) {
 		return 0;
 	}
-	set_tag->data = tag_id << MLX5_MTR_COLOR_BITS;
+	*set_tag = (struct mlx5_rte_flow_action_set_tag) {
+		.id = reg_id,
+		.offset = MLX5_MTR_COLOR_BITS,
+		.length = sizeof(tag_id) * 8 - MLX5_MTR_COLOR_BITS,
+		.data = tag_id,
+	};
 	assert(tag_action);
 	tag_action->conf = set_tag;
 	/* Prepare the suffix subflow items. */
@@ -4773,10 +4781,12 @@ flow_sample_split_prep(struct rte_eth_dev *dev,
 		ret = mlx5_flow_get_reg_id(dev, MLX5_APP_TAG, 0, error);
 		if (ret < 0)
 			return ret;
-		set_tag->id = ret;
 		mlx5_ipool_malloc(priv->sh->ipool
 				  [MLX5_IPOOL_RSS_EXPANTION_FLOW_ID], &tag_id);
-		set_tag->data = tag_id;
+		*set_tag = (struct mlx5_rte_flow_action_set_tag) {
+			.id = ret,
+			.data = tag_id,
+		};
 		/* Prepare the suffix subflow items. */
 		tag_spec = (void *)(sfx_items + SAMPLE_SUFFIX_ITEM);
 		tag_spec->data = tag_id;
drivers/net/mlx5/mlx5_flow.h +2 -0
index 66e19b627b..6bb7bae1bf 100644
@@ -55,6 +55,8 @@ struct mlx5_rte_flow_item_tag {
 /* Modify selected register. */
 struct mlx5_rte_flow_action_set_tag {
 	enum modify_reg id;
+	uint8_t offset;
+	uint8_t length;
 	uint32_t data;
 };
 
drivers/net/mlx5/mlx5_flow_dv.c +2 -0
index 4e5ca4f6c9..7905923665 100644
@@ -1015,6 +1015,8 @@ flow_dv_convert_action_set_reg
 	actions[i] = (struct mlx5_modification_cmd) {
 		.action_type = MLX5_MODIFICATION_TYPE_SET,
 		.field = reg_to_field[conf->id],
+		.offset = conf->offset,
+		.length = conf->length,
 	};
 	actions[i].data0 = rte_cpu_to_be_32(actions[i].data0);
 	actions[i].data1 = rte_cpu_to_be_32(conf->data);
Signature · 1 line
2.27.0
author
#2 lore raw

RFC 2/8 common/mlx5: add definitions for ASO flow meter

In reply to Li Zhang

This patch adds different PRM definitions, related to ASO flow meter feature, in MLX5 PMD code.

---
 drivers/common/mlx5/mlx5_prm.h | 75 ++++++++++++++++++++++++++++++++--
 1 file changed, 71 insertions(+), 4 deletions(-)
drivers/common/mlx5/mlx5_prm.h +71 -4
index 48fe54625f..de85b05066 100644
@@ -1066,6 +1066,8 @@ enum {
 			(1ULL << MLX5_GENERAL_OBJ_TYPE_FLEX_PARSE_GRAPH)
 #define MLX5_GENERAL_OBJ_TYPES_CAP_FLOW_HIT_ASO \
 			(1ULL << MLX5_GENERAL_OBJ_TYPE_FLOW_HIT_ASO)
+#define MLX5_GENERAL_OBJ_TYPES_CAP_FLOW_METER_ASO \
+			(1ULL << MLX5_GENERAL_OBJ_TYPE_FLOW_METER_ASO)
 #define MLX5_GENERAL_OBJ_TYPES_CAP_GENEVE_TLV_OPT \
 			(1ULL << MLX5_OBJ_TYPE_GENEVE_TLV_OPT)
 
@@ -1418,7 +1420,15 @@ struct mlx5_ifc_qos_cap_bits {
 	u8 reserved_at_c0[0x10];
 	u8 max_qos_para_vport[0x10];
 	u8 max_tsar_bw_share[0x20];
-	u8 reserved_at_100[0x6e8];
+	u8 nic_element_type[0x10];
+	u8 nic_tsar_type[0x10];
+	u8 reserved_at_120[0x3];
+	u8 log_meter_aso_granularity[0x5];
+	u8 reserved_at_128[0x3];
+	u8 log_meter_aso_max_alloc[0x5];
+	u8 reserved_at_130[0x3];
+	u8 log_max_num_meter_aso[0x5];
+	u8 reserved_at_138[0x6b0];
 };
 
 struct mlx5_ifc_per_protocol_networking_offload_caps_bits {
@@ -2159,6 +2169,8 @@ struct mlx5_ifc_flow_meter_parameters_bits {
 	u8         eir_mantissa[0x8];
 	u8         reserved_at_8[0x60];		// 14h-1Ch
 };
+#define MLX5_IFC_FLOW_METER_PARAM_MASK           UINT64_C(0x80FFFFFF)
+#define MLX5_IFC_FLOW_METER_DISABLE_CBS_CIR_VAL  0x14BF00C8
 
 enum {
 	MLX5_CQE_SIZE_64B = 0x0,
@@ -2243,6 +2255,7 @@ enum {
 	MLX5_GENERAL_OBJ_TYPE_VIRTQ = 0x000d,
 	MLX5_GENERAL_OBJ_TYPE_VIRTIO_Q_COUNTERS = 0x001c,
 	MLX5_GENERAL_OBJ_TYPE_FLEX_PARSE_GRAPH = 0x0022,
+	MLX5_GENERAL_OBJ_TYPE_FLOW_METER_ASO = 0x0024,
 	MLX5_GENERAL_OBJ_TYPE_FLOW_HIT_ASO = 0x0025,
 };
 
@@ -2251,7 +2264,9 @@ struct mlx5_ifc_general_obj_in_cmd_hdr_bits {
 	u8 reserved_at_10[0x20];
 	u8 obj_type[0x10];
 	u8 obj_id[0x20];
-	u8 reserved_at_60[0x20];
+	u8 reserved_at_60[0x3];
+	u8 log_obj_range[0x5];
+	u8 reserved_at_58[0x18];
 };
 
 struct mlx5_ifc_general_obj_out_cmd_hdr_bits {
@@ -2393,6 +2408,18 @@ struct mlx5_ifc_create_flow_hit_aso_in_bits {
 	struct mlx5_ifc_flow_hit_aso_bits flow_hit_aso;
 };
 
+struct mlx5_ifc_flow_meter_aso_bits {
+	u8 modify_field_select[0x40];
+	u8 reserved_at_40[0x48];
+	u8 access_pd[0x18];
+	u8 reserved_at_a0[0x160];
+	u8 parameters[0x200];
+};
+
+struct mlx5_ifc_create_flow_meter_aso_in_bits {
+	struct mlx5_ifc_general_obj_in_cmd_hdr_bits hdr;
+	struct mlx5_ifc_flow_meter_aso_bits flow_meter_aso;
+};
 enum mlx5_access_aso_opc_mod {
 	ASO_OPC_MOD_IPSEC = 0x0,
 	ASO_OPC_MOD_CONNECTION_TRACKING = 0x1,
@@ -2446,11 +2473,51 @@ struct mlx5_aso_cseg {
 	uint64_t data_mask;
 } __rte_packed;
 
+/* A meter data segment - 2 per ASO WQE. */
+struct mlx5_aso_mtr_dseg {
+	uint32_t v_bo_sc_bbog_mm;
+	/*
+	 * bit 31: valid, 30: bucket overflow, 28-29: start color,
+	 * 27: both buckets on green, 24-25: meter mode.
+	 */
+	uint32_t reserved;
+	uint32_t cbs_cir;
+	/*
+	 * bit 24-28: cbs_exponent, bit 16-23 cbs_mantissa,
+	 * bit 8-12: cir_exponent, bit 0-7 cir_mantissa.
+	 */
+	uint32_t c_tokens;
+	uint32_t ebs_eir;
+	/*
+	 * bit 24-28: ebs_exponent, bit 16-23 ebs_mantissa,
+	 * bit 8-12: eir_exponent, bit 0-7 eir_mantissa.
+	 */
+	uint32_t e_tokens;
+	uint64_t timestamp;
+} __rte_packed;
+
+#define ASO_DSEG_VALID_OFFSET	  31
+#define ASO_DSEG_BO_OFFSET	      30
+#define ASO_DSEG_SC_OFFSET	      28
+#define ASO_DSEG_CBS_EXP_OFFSET	  24
+#define ASO_DSEG_CBS_MAN_OFFSET	  16
+#define ASO_DSEG_CIR_EXP_MASK	  0x1F
+#define ASO_DSEG_CIR_EXP_OFFSET	  8
+#define ASO_DSEG_EBS_EXP_OFFSET	  24
+#define ASO_DSEG_EBS_MAN_OFFSET	  16
+#define ASO_DSEG_EXP_MASK	      0x1F
+#define ASO_DSEG_MAN_MASK	      0xFF
+
 #define MLX5_ASO_WQE_DSEG_SIZE	0x40
+#define MLX5_ASO_METERS_PER_WQE 2
+#define MLX5_ASO_MTRS_PER_POOL  128
 
-/* ASO WQE Data segment. */
+/* ASO WQE data segment. */
 struct mlx5_aso_dseg {
-	uint8_t data[MLX5_ASO_WQE_DSEG_SIZE];
+	union {
+		uint8_t data[MLX5_ASO_WQE_DSEG_SIZE];
+		struct mlx5_aso_mtr_dseg mtrs[MLX5_ASO_METERS_PER_WQE];
+	};
 } __rte_packed;
 
 /* ASO WQE. */
Signature · 1 line
2.27.0
author
#3 lore raw

RFC 3/8 common/mlx5: add read ASO flow meter HCA capability

In reply to Li Zhang

Read and store the device capability of FLOW_METER_ASO general object, using the DevX API.

---
 drivers/common/mlx5/mlx5_devx_cmds.c | 14 ++++++++++++++
 drivers/common/mlx5/mlx5_devx_cmds.h |  8 ++++++++
 2 files changed, 22 insertions(+)
drivers/common/mlx5/mlx5_devx_cmds.c +14 -0
index 485363192d..765553ed6b 100644
@@ -698,6 +698,9 @@ mlx5_devx_cmd_query_hca_attr(void *ctx,
 	attr->max_geneve_tlv_option_data_len = MLX5_GET(cmd_hca_cap, hcattr,
 			max_geneve_tlv_option_data_len);
 	attr->qos.sup = MLX5_GET(cmd_hca_cap, hcattr, qos);
+	attr->qos.flow_meter_aso_sup = !!(MLX5_GET64(cmd_hca_cap, hcattr,
+					 general_obj_types) &
+			      MLX5_GENERAL_OBJ_TYPES_CAP_FLOW_METER_ASO);
 	attr->vdpa.valid = !!(MLX5_GET64(cmd_hca_cap, hcattr,
 					 general_obj_types) &
 			      MLX5_GENERAL_OBJ_TYPES_CAP_VIRTQ_NET_Q);
@@ -756,6 +759,17 @@ mlx5_devx_cmd_query_hca_attr(void *ctx,
 				MLX5_GET(qos_cap, hcattr, packet_pacing);
 		attr->qos.wqe_rate_pp =
 				MLX5_GET(qos_cap, hcattr, wqe_rate_pp);
+		if (attr->qos.flow_meter_aso_sup) {
+			attr->qos.log_meter_aso_granularity =
+				MLX5_GET(qos_cap, hcattr,
+					log_meter_aso_granularity);
+			attr->qos.log_meter_aso_max_alloc =
+				MLX5_GET(qos_cap, hcattr,
+					log_meter_aso_max_alloc);
+			attr->qos.log_max_num_meter_aso =
+				MLX5_GET(qos_cap, hcattr,
+					log_max_num_meter_aso);
+		}
 	}
 	if (attr->vdpa.valid)
 		mlx5_devx_cmd_query_hca_vdpa_attr(ctx, &attr->vdpa);
drivers/common/mlx5/mlx5_devx_cmds.h +8 -0
index e0638f2064..13338c0e39 100644
@@ -42,10 +42,18 @@ struct mlx5_hca_qos_attr {
 	uint32_t wqe_rate_pp:1; /* Packet pacing WQE rate mode. */
 	uint32_t flow_meter_reg_share:1;
 	/* Whether reg_c share is supported. */
+	uint32_t flow_meter_aso_sup:1;
+	/* Whether FLOW_METER_ASO Object is supported. */
 	uint8_t log_max_flow_meter;
 	/* Power of the maximum supported meters. */
 	uint8_t flow_meter_reg_c_ids;
 	/* Bitmap of the reg_Cs available for flow meter to use. */
+	uint32_t log_meter_aso_granularity:5;
+	/* Power of the minimum allocation granularity Object. */
+	uint32_t log_meter_aso_max_alloc:5;
+	/* Power of the maximum allocation granularity Object. */
+	uint32_t log_max_num_meter_aso:5;
+	/* Power of the maximum number of supported objects. */
 
 };
 
Signature · 1 line
2.27.0
author
#4 lore raw

RFC 4/8 common/mlx5: add DevX API to create ASO flow meter object

In reply to Li Zhang

Add DevX API to create ASO flow meter object.

---
 drivers/common/mlx5/mlx5_devx_cmds.c | 54 ++++++++++++++++++++++++++++
 drivers/common/mlx5/mlx5_devx_cmds.h | 18 +++++++++-
 drivers/common/mlx5/version.map      |  3 +-
 3 files changed, 73 insertions(+), 2 deletions(-)
drivers/common/mlx5/mlx5_devx_cmds.c +54 -0
index 765553ed6b..742c6a4997 100644
@@ -2068,6 +2068,60 @@ mlx5_devx_cmd_create_flow_hit_aso_obj(void *ctx, uint32_t pd)
 	return flow_hit_aso_obj;
 }
 
+/**
+ * Create general object of type FLOW_METER_ASO using DevX API.
+ *
+ * @param[in] ctx
+ *   Context returned from mlx5 open_device() glue function.
+ * @param [in] pd
+ *   PD value to associate the FLOW_METER_ASO object with.
+ * @param [in] log_obj_size
+ *   log_obj_size define to allocate number of 2 * meters
+ *   in one FLOW_METER_ASO object.
+ *
+ * @return
+ *   The DevX object created, NULL otherwise and rte_errno is set.
+ */
+struct mlx5_devx_obj *
+mlx5_devx_cmd_create_flow_meter_aso_obj(void *ctx, uint32_t pd,
+						uint32_t log_obj_size)
+{
+	uint32_t in[MLX5_ST_SZ_DW(create_flow_meter_aso_in)] = {0};
+	uint32_t out[MLX5_ST_SZ_DW(general_obj_out_cmd_hdr)];
+	struct mlx5_devx_obj *flow_meter_aso_obj;
+	void *ptr;
+
+	flow_meter_aso_obj = mlx5_malloc(MLX5_MEM_ZERO,
+						sizeof(*flow_meter_aso_obj),
+						0, SOCKET_ID_ANY);
+	if (!flow_meter_aso_obj) {
+		DRV_LOG(ERR, "Failed to allocate FLOW_METER_ASO object data");
+		rte_errno = ENOMEM;
+		return NULL;
+	}
+	ptr = MLX5_ADDR_OF(create_flow_meter_aso_in, in, hdr);
+	MLX5_SET(general_obj_in_cmd_hdr, ptr, opcode,
+		MLX5_CMD_OP_CREATE_GENERAL_OBJECT);
+	MLX5_SET(general_obj_in_cmd_hdr, ptr, obj_type,
+		MLX5_GENERAL_OBJ_TYPE_FLOW_METER_ASO);
+	MLX5_SET(general_obj_in_cmd_hdr, ptr, log_obj_range,
+		log_obj_size);
+	ptr = MLX5_ADDR_OF(create_flow_meter_aso_in, in, flow_meter_aso);
+	MLX5_SET(flow_meter_aso, ptr, access_pd, pd);
+	flow_meter_aso_obj->obj = mlx5_glue->devx_obj_create(
+							ctx, in, sizeof(in),
+							out, sizeof(out));
+	if (!flow_meter_aso_obj->obj) {
+		rte_errno = errno;
+		DRV_LOG(ERR, "Failed to create FLOW_METER_ASO obj using DevX.");
+		mlx5_free(flow_meter_aso_obj);
+		return NULL;
+	}
+	flow_meter_aso_obj->id = MLX5_GET(general_obj_out_cmd_hdr,
+								out, obj_id);
+	return flow_meter_aso_obj;
+}
+
 /**
  * Create general object of type GENEVE TLV option using DevX API.
  *
drivers/common/mlx5/mlx5_devx_cmds.h +17 -1
index 13338c0e39..dbd7b66257 100644
@@ -517,5 +517,21 @@ int mlx5_devx_cmd_query_virtio_q_counters(struct mlx5_devx_obj *couners_obj,
 __rte_internal
 struct mlx5_devx_obj *mlx5_devx_cmd_create_flow_hit_aso_obj(void *ctx,
 							    uint32_t pd);
-
+/**
+ * Create general object of type FLOW_METER_ASO using DevX API..
+ *
+ * @param[in] ctx
+ *   Device context.
+ * @param [in] pd
+ *   PD value to associate the FLOW_METER_ASO object with.
+ * @param [in] log_obj_size
+ *   log_obj_size define to allocate number of 2 * meters
+ *   in one FLOW_METER_ASO object.
+ *
+ * @return
+ *   The DevX object created, NULL otherwise and rte_errno is set.
+ */
+__rte_internal
+struct mlx5_devx_obj *mlx5_devx_cmd_create_flow_meter_aso_obj(void *ctx,
+					uint32_t pd, uint32_t log_obj_size);
 #endif /* RTE_PMD_MLX5_DEVX_CMDS_H_ */
drivers/common/mlx5/version.map +2 -1
index 3c403d2feb..51b6fd7326 100644
@@ -21,7 +21,8 @@ INTERNAL {
 	mlx5_devx_cmd_create_tis;
 	mlx5_devx_cmd_create_virtio_q_counters;
 	mlx5_devx_cmd_create_virtq;
-        mlx5_devx_cmd_create_flow_hit_aso_obj;
+    mlx5_devx_cmd_create_flow_hit_aso_obj;
+	mlx5_devx_cmd_create_flow_meter_aso_obj;
 	mlx5_devx_cmd_create_geneve_tlv_option;
 	mlx5_devx_cmd_destroy;
 	mlx5_devx_cmd_flow_counter_alloc;
Signature · 1 line
2.27.0
author
#5 lore raw

RFC 5/8 net/mlx5: flow meter pool to manage meter object

In reply to Li Zhang

Add ASO flow meter pool to manage meter object

---
 drivers/net/mlx5/mlx5.c            |   2 +-
 drivers/net/mlx5/mlx5.h            | 190 ++++++++++++-
 drivers/net/mlx5/mlx5_flow.c       |  44 ++-
 drivers/net/mlx5/mlx5_flow.h       | 186 ++++---------
 drivers/net/mlx5/mlx5_flow_dv.c    | 208 +++++++++++++-
 drivers/net/mlx5/mlx5_flow_meter.c | 426 +++++++++++++++++------------
 6 files changed, 723 insertions(+), 333 deletions(-)
drivers/net/mlx5/mlx5.c +1 -1
index 71a81e7f7b..a66e441f67 100644
@@ -280,7 +280,7 @@ static const struct mlx5_indexed_pool_config mlx5_ipool_cfg[] = {
 	},
 #endif
 	[MLX5_IPOOL_MTR] = {
-		.size = sizeof(struct mlx5_flow_meter),
+		.size = sizeof(struct mlx5_legacy_flow_meter),
 		.trunk_size = 64,
 		.grow_trunk = 3,
 		.grow_shift = 2,
drivers/net/mlx5/mlx5.h +183 -7

242 lines not on this page · raw message

drivers/net/mlx5/mlx5_flow.c +41 -3

68 lines not on this page · raw message

drivers/net/mlx5/mlx5_flow.h +51 -135

248 lines not on this page · raw message

drivers/net/mlx5/mlx5_flow_dv.c +194 -14

285 lines not on this page · raw message

drivers/net/mlx5/mlx5_flow_meter.c +253 -173

689 lines not on this page · raw message

Signature · 1 line
2.27.0
author
#6 lore raw

RFC 6/8 net/mlx5: init/uninit flow meter queue for WQE

In reply to Li Zhang

Init/uninit flow meter SQ for WQE

---
 drivers/net/mlx5/linux/mlx5_os.c              | 17 ++++
 drivers/net/mlx5/meson.build                  |  2 +-
 drivers/net/mlx5/mlx5.c                       | 67 ++++++++++++-
 drivers/net/mlx5/mlx5.h                       | 20 ++--
 drivers/net/mlx5/mlx5_flow.h                  |  4 +-
 .../mlx5/{mlx5_flow_age.c => mlx5_flow_aso.c} | 97 ++++++++++++++++---
 drivers/net/mlx5/mlx5_flow_dv.c               |  7 +-
 7 files changed, 187 insertions(+), 27 deletions(-)
 rename drivers/net/mlx5/{mlx5_flow_age.c => mlx5_flow_aso.c} (87%)
drivers/net/mlx5/linux/mlx5_os.c +17 -0
index 4c7782f8ef..01b019c28d 100644
@@ -697,6 +697,7 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,
 	int own_domain_id = 0;
 	uint16_t port_id;
 	unsigned int i;
+	uint32_t log_obj_size;
 #ifdef HAVE_MLX5DV_DR_DEVX_PORT
 	struct mlx5dv_devx_port devx_port = { .comp_mask = 0 };
 #endif
@@ -1267,6 +1268,22 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,
 					priv->mtr_color_reg);
 			}
 		}
+		if (config->hca_attr.qos.sup &&
+			config->hca_attr.qos.flow_meter_aso_sup) {
+			log_obj_size =
+				rte_log2_u32(MLX5_ASO_MTRS_PER_POOL >> 1);
+			if (log_obj_size >=
+			config->hca_attr.qos.log_meter_aso_granularity &&
+			log_obj_size <=
+			config->hca_attr.qos.log_meter_aso_max_alloc) {
+				sh->meter_aso_en = 1;
+				err = mlx5_aso_flow_mtrs_mng_init(sh);
+				if (err) {
+					err = -err;
+					goto error;
+				}
+			}
+		}
 #endif
 #ifdef HAVE_MLX5_DR_CREATE_ACTION_ASO
 		if (config->hca_attr.flow_hit_aso &&
drivers/net/mlx5/meson.build +1 -1
index e7495a764a..ad501bd1e2 100644
@@ -16,7 +16,7 @@ sources = files(
 	'mlx5_flow_meter.c',
 	'mlx5_flow_dv.c',
 	'mlx5_flow_verbs.c',
-        'mlx5_flow_age.c',
+    'mlx5_flow_aso.c',
 	'mlx5_mac.c',
 	'mlx5_mr.c',
 	'mlx5_rss.c',
drivers/net/mlx5/mlx5.c +64 -3

91 lines not on this page · raw message

drivers/net/mlx5/mlx5.h +14 -6
index 41f2aed53b..d0c30939d2 100644
@@ -500,8 +500,13 @@ struct mlx5_aso_devx_mr {
 };
 
 struct mlx5_aso_sq_elem {
-	struct mlx5_aso_age_pool *pool;
-	uint16_t burst_size;
+	union {
+		struct {
+			struct mlx5_aso_age_pool *pool;
+			uint16_t burst_size;
+		};
+		struct mlx5_aso_mtr *mtr;
+	};
 };
 
 struct mlx5_aso_sq {
@@ -1244,6 +1249,7 @@ int mlx5_hairpin_cap_get(struct rte_eth_dev *dev,
 bool mlx5_flex_parser_ecpri_exist(struct rte_eth_dev *dev);
 int mlx5_flex_parser_ecpri_alloc(struct rte_eth_dev *dev);
 int mlx5_flow_aso_age_mng_init(struct mlx5_dev_ctx_shared *sh);
+int mlx5_aso_flow_mtrs_mng_init(struct mlx5_dev_ctx_shared *sh);
 
 /* mlx5_ethdev.c */
 
@@ -1505,9 +1511,11 @@ eth_tx_burst_t mlx5_select_tx_function(struct rte_eth_dev *dev);
 
 /* mlx5_flow_aso.c */
 
-int mlx5_aso_queue_init(struct mlx5_dev_ctx_shared *sh);
-int mlx5_aso_queue_start(struct mlx5_dev_ctx_shared *sh);
-int mlx5_aso_queue_stop(struct mlx5_dev_ctx_shared *sh);
-void mlx5_aso_queue_uninit(struct mlx5_dev_ctx_shared *sh);
+int mlx5_aso_queue_init(struct mlx5_dev_ctx_shared *sh,
+		enum mlx5_access_aso_opc_mod aso_opc_mod);
+int mlx5_aso_flow_hit_queue_poll_start(struct mlx5_dev_ctx_shared *sh);
+int mlx5_aso_flow_hit_queue_poll_stop(struct mlx5_dev_ctx_shared *sh);
+void mlx5_aso_queue_uninit(struct mlx5_dev_ctx_shared *sh,
+		enum mlx5_access_aso_opc_mod aso_opc_mod);
 
 #endif /* RTE_PMD_MLX5_H_ */
drivers/net/mlx5/mlx5_flow.h +2 -2
index 1c01c611e4..ab83f67638 100644
@@ -811,8 +811,8 @@ struct mlx5_flow {
 #define MLX5_FLOW_METER_DISABLE 0
 #define MLX5_FLOW_METER_ENABLE 1
 
-#define MLX5_ASO_CQE_RESPONSE_DELAY 10
-#define MLX5_MTR_POLL_CQE_TIMES    100000u  /* 1s*/
+#define MLX5_ASO_WQE_CQE_RESPONSE_DELAY   10u
+#define MLX5_MTR_POLL_WQE_CQE_TIMES       100000u
 
 #define MLX5_MAN_WIDTH 8
 /* Legacy Meter parameter structure. */
drivers/net/mlx5/mlx5_flow_aso.c renamed from drivers/net/mlx5/mlx5_flow_age.c +83 -14

153 lines not on this page · raw message

drivers/net/mlx5/mlx5_flow_dv.c +6 -1
index 5e1eb51c43..9bac7d3a02 100644
@@ -5283,6 +5283,11 @@ flow_dv_mtr_container_resize(struct rte_eth_dev *dev)
 		rte_errno = ENOMEM;
 		return -ENOMEM;
 	}
+	if (!mtrmng->n)
+		if (mlx5_aso_queue_init(priv->sh, ASO_OPC_MOD_POLICER)) {
+			mlx5_free(pools);
+			return -ENOMEM;
+		}
 	if (old_pools)
 		memcpy(pools, old_pools, mtrmng->n *
 				       sizeof(struct mlx5_aso_mtr_pool *));
@@ -9980,7 +9985,7 @@ flow_dv_aso_age_pools_resize(struct rte_eth_dev *dev)
 		mlx5_free(old_pools);
 	} else {
 		/* First ASO flow hit allocation - starting ASO data-path. */
-		int ret = mlx5_aso_queue_start(priv->sh);
+		int ret = mlx5_aso_flow_hit_queue_poll_start(priv->sh);
 
 		if (ret) {
 			mlx5_free(pools);
Signature · 1 line
2.27.0
author
#7 lore raw

RFC 7/8 net/mlx5: aso flow meter send WQE and CQE handle

In reply to Li Zhang

ASO flow meter send WQE and CQE handle functions

---
 drivers/net/mlx5/mlx5.h            |   4 +
 drivers/net/mlx5/mlx5_flow.h       |   2 +-
 drivers/net/mlx5/mlx5_flow_aso.c   | 182 +++++++++++++++++++++++++++++
 drivers/net/mlx5/mlx5_flow_dv.c    |   5 +-
 drivers/net/mlx5/mlx5_flow_meter.c | 144 ++++++++++++++---------
 5 files changed, 279 insertions(+), 58 deletions(-)
drivers/net/mlx5/mlx5.h +4 -0
index d0c30939d2..73d3698f1d 100644
@@ -1517,5 +1517,9 @@ int mlx5_aso_flow_hit_queue_poll_start(struct mlx5_dev_ctx_shared *sh);
 int mlx5_aso_flow_hit_queue_poll_stop(struct mlx5_dev_ctx_shared *sh);
 void mlx5_aso_queue_uninit(struct mlx5_dev_ctx_shared *sh,
 		enum mlx5_access_aso_opc_mod aso_opc_mod);
+int mlx5_aso_meter_update_by_wqe(struct mlx5_dev_ctx_shared *sh,
+		struct mlx5_aso_mtr *mtr);
+int mlx5_aso_mtr_wait(struct mlx5_dev_ctx_shared *sh,
+		struct mlx5_aso_mtr *mtr);
 
 #endif /* RTE_PMD_MLX5_H_ */
drivers/net/mlx5/mlx5_flow.h +1 -1
index ab83f67638..eaaa923778 100644
@@ -1016,7 +1016,7 @@ struct mlx5_flow_workspace {
 	struct mlx5_flow_rss_desc rss_desc;
 	uint32_t rssq_num; /* Allocated queue num in rss_desc. */
 	uint32_t flow_idx; /* Intermediate device flow index. */
-	struct mlx5_flow_meter_info *fm;/* the flow meter pointer. */
+	uint32_t mtr_idx;/* The aso meter index. */
 };
 
 struct mlx5_flow_split_info {
drivers/net/mlx5/mlx5_flow_aso.c +182 -0

185 lines not on this page · raw message

drivers/net/mlx5/mlx5_flow_dv.c +3 -2
index 9bac7d3a02..cc84cb3a52 100644
@@ -10753,11 +10753,12 @@ flow_dv_translate(struct rte_eth_dev *dev,
 						"meter not found "
 						"or invalid parameters");
 				flow->meter = mtr_idx;
-				wks->fm = fm;
+				wks->mtr_idx = mtr_idx;
 			}
 			/* Set the meter action. */
 			if (!fm) {
-				fm = wks->fm;
+				fm = flow_dv_meter_find_by_idx(priv,
+					wks->mtr_idx);
 				if (!fm)
 					return rte_flow_error_set(error,
 						rte_errno,
drivers/net/mlx5/mlx5_flow_meter.c +89 -55

226 lines not on this page · raw message

Signature · 1 line
2.27.0
author
#8 lore raw

RFC 8/8 net/mlx5: add support of ASO meter action

In reply to Li Zhang

When ASO action is available, use it as the meter action

---
 drivers/net/mlx5/linux/mlx5_os.c   |   4 +-
 drivers/net/mlx5/mlx5.c            |   8 ++
 drivers/net/mlx5/mlx5.h            |  18 ++---
 drivers/net/mlx5/mlx5_flow.c       |  66 +++++++++++-----
 drivers/net/mlx5/mlx5_flow_dv.c    |  74 ++++++++++--------
 drivers/net/mlx5/mlx5_flow_meter.c | 118 ++++++++++++++++++-----------
 6 files changed, 184 insertions(+), 104 deletions(-)
drivers/net/mlx5/linux/mlx5_os.c +3 -1
index 01b019c28d..28e383c7e2 100644
@@ -1233,7 +1233,9 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,
 				"required for coalescing is %d bytes",
 				config->hca_attr.lro_min_mss_size);
 		}
-#if defined(HAVE_MLX5DV_DR) && defined(HAVE_MLX5_DR_CREATE_ACTION_FLOW_METER)
+#if defined(HAVE_MLX5DV_DR) && \
+	(defined(HAVE_MLX5_DR_CREATE_ACTION_FLOW_METER) || \
+	 defined(HAVE_MLX5_DR_CREATE_ACTION_ASO))
 		if (config->hca_attr.qos.sup &&
 		    config->hca_attr.qos.srtcm_sup &&
 		    config->dv_flow_en) {
drivers/net/mlx5/mlx5.c +8 -0
index 9d77265e2e..224c8e3965 100644
@@ -584,13 +584,21 @@ static void
 mlx5_aso_flow_mtrs_mng_close(struct mlx5_dev_ctx_shared *sh)
 {
 	struct mlx5_aso_mtr_pool *mtr_pool;
+	struct mlx5_aso_mtr *aso_mtr;
 	struct mlx5_aso_mtr_pools_mng *mtrmng = sh->mtrmng;
 	uint32_t idx;
+	int i;
 
 	mlx5_aso_queue_uninit(sh, ASO_OPC_MOD_POLICER);
 	idx = mtrmng->n_valid;
 	while (idx--) {
 		mtr_pool = mtrmng->pools[idx];
+		for (i = 0; i < MLX5_ASO_MTRS_PER_POOL; i++) {
+			aso_mtr = &mtr_pool->mtrs[i];
+			if (aso_mtr->fm.meter_action)
+				claim_zero(mlx5_glue->destroy_flow_action
+						(aso_mtr->fm.meter_action));
+		}
 		claim_zero(mlx5_devx_cmd_destroy
 						(mtr_pool->devx_obj));
 		mtrmng->n_valid--;
drivers/net/mlx5/mlx5.h +8 -10
index 73d3698f1d..b4bd76e792 100644
@@ -645,8 +645,6 @@ struct mlx5_meter_domains_infos {
 	/**< Drop action as not matched. */
 	void *count_actns[RTE_MTR_DROPPED + 1];
 	/**< Counters for match and unmatched statistics. */
-	void *meter_action;
-	/**< Flow meter action. */
 };
 
 /* Meter parameter structure. */
@@ -697,6 +695,8 @@ struct mlx5_flow_meter_info {
 	/**< Meter shared or not. */
 	uint32_t is_enable:1;
 	/**< Meter disable/enable state. */
+	void *meter_action;
+	/**< Flow meter action. */
 };
 
 /* RFC2697 parameter structure. */
@@ -800,7 +800,7 @@ struct mlx5_flow_tbl_resource {
 /* Tables for metering splits should be added here. */
 #define MLX5_FLOW_TABLE_LEVEL_SUFFIX (MLX5_MAX_TABLES - 3)
 #define MLX5_FLOW_TABLE_LEVEL_METER (MLX5_MAX_TABLES - 4)
-#define MLX5_MAX_TABLES_EXTERNAL MLX5_FLOW_TABLE_LEVEL_METER
+#define MLX5_MAX_TABLES_EXTERNAL (MLX5_FLOW_TABLE_LEVEL_METER - 1)
 #define MLX5_MAX_TABLES_FDB UINT16_MAX
 #define MLX5_FLOW_TABLE_FACTOR 10
 
@@ -1458,13 +1458,11 @@ int mlx5_pmd_socket_init(void);
 int mlx5_flow_meter_ops_get(struct rte_eth_dev *dev, void *arg);
 struct mlx5_flow_meter_info *mlx5_flow_meter_find(struct mlx5_priv *priv,
 		uint32_t meter_id, uint32_t *mtr_idx);
-struct mlx5_flow_meter_info *mlx5_flow_meter_attach
-					(struct mlx5_priv *priv,
-					 uint32_t meter_id,
-					 const struct rte_flow_attr *attr,
-					 uint32_t *mtr_idx,
-					 struct rte_flow_error *error);
-void mlx5_flow_meter_detach(struct mlx5_flow_meter_info *fm);
+uint32_t mlx5_flow_meter_attach(struct mlx5_priv *priv, uint32_t meter_id,
+				const struct rte_flow_attr *attr,
+				struct rte_flow_error *error);
+void mlx5_flow_meter_detach(struct mlx5_priv *priv,
+			    struct mlx5_flow_meter_info *fm);
 
 /* mlx5_os.c */
 struct rte_pci_driver;
drivers/net/mlx5/mlx5_flow.c +49 -17

123 lines not on this page · raw message

drivers/net/mlx5/mlx5_flow_dv.c +43 -31

130 lines not on this page · raw message

drivers/net/mlx5/mlx5_flow_meter.c +73 -45

156 lines not on this page · raw message

Signature · 1 line
2.27.0