[PATCH 2/2] net/mlx5: use private structure for internal tag item
Bing Zhao
bingz at nvidia.com
Mon Nov 17 05:15:37 CET 2025
The legacy DV API is used to translate the mask of a matcher and the
value of a rule on the root table, no matter it is in SWS or HWS
mode. The structure "mlx5_rte_flow_item_tag" is used instead of
public "rte_flow_item_tag". This is used internally to speed up and
simplify the usage of the available REG_Cs.
Since the offsets of the fields are different, the DV API would get
the incorrect value when constructuing the matcher and value. The
private structure should be used for the DV API. Also, in the
validation stage, the proper structure should be used.
Fixes: 483181f7b6dd ("net/mlx5: support device control of representor matching")
Fixes: ddb68e47331e ("net/mlx5: add extended metadata mode for HWS")
Fixes: 26e1eaf2dac4 ("net/mlx5: support device control for E-Switch default rule")
Cc: stable at dpdk.org
Signed-off-by: Bing Zhao <bingz at nvidia.com>
---
drivers/net/mlx5/mlx5.h | 4 ++--
drivers/net/mlx5/mlx5_flow_hw.c | 41 ++++++++++++++++-----------------
2 files changed, 22 insertions(+), 23 deletions(-)
diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h
index 7e4bfacd11..3d1b5371f0 100644
--- a/drivers/net/mlx5/mlx5.h
+++ b/drivers/net/mlx5/mlx5.h
@@ -469,8 +469,8 @@ struct mlx5_flow_hw_pattern_params {
struct rte_flow_item items[MLX5_HW_MAX_ITEMS];
/** Temporary REPRESENTED_PORT item generated by PMD. */
struct rte_flow_item_ethdev port_spec;
- /** Temporary TAG item generated by PMD. */
- struct rte_flow_item_tag tag_spec;
+ /** Temporary internal MLX5_TAG item generated by PMD, no more than 2 DWs. */
+ uint8_t mlx5_tag_spec[sizeof(uint32_t) * 2];
};
/* HW steering flow management job descriptor. */
diff --git a/drivers/net/mlx5/mlx5_flow_hw.c b/drivers/net/mlx5/mlx5_flow_hw.c
index e0f79932a5..f5ad48c6d2 100644
--- a/drivers/net/mlx5/mlx5_flow_hw.c
+++ b/drivers/net/mlx5/mlx5_flow_hw.c
@@ -3855,7 +3855,7 @@ flow_hw_get_rule_items(struct rte_eth_dev *dev,
return NULL;
}
/* Set up represented port item in pattern params. */
- pp->port_spec = (struct rte_flow_item_ethdev){
+ pp->port_spec = (struct rte_flow_item_ethdev) {
.port_id = dev->data->port_id,
};
pp->items[0] = (struct rte_flow_item){
@@ -3870,12 +3870,13 @@ flow_hw_get_rule_items(struct rte_eth_dev *dev,
return NULL;
}
/* Set up tag item in pattern params. */
- pp->tag_spec = (struct rte_flow_item_tag){
+ pp->mlx5_tag_spec = (struct mlx5_rte_flow_item_tag) {
+ .id = REG_C_0, /* vport_meta_tag is using C_0 */
.data = flow_hw_tx_tag_regc_value(dev),
};
- pp->items[0] = (struct rte_flow_item){
+ pp->items[0] = (struct rte_flow_item) {
.type = (enum rte_flow_item_type)MLX5_RTE_FLOW_ITEM_TYPE_TAG,
- .spec = &pp->tag_spec,
+ .spec = &pp->mlx5_tag_spec,
};
rte_memcpy(&pp->items[1], items, sizeof(*items) * pt->orig_item_nb);
return pp->items;
@@ -8559,21 +8560,21 @@ __flow_hw_pattern_validate(struct rte_eth_dev *dev,
}
case MLX5_RTE_FLOW_ITEM_TYPE_TAG:
{
- const struct rte_flow_item_tag *tag =
- (const struct rte_flow_item_tag *)item->spec;
+ const struct mlx5_rte_flow_item_tag *mlx5_tag =
+ (const struct mlx5_rte_flow_item_tag *)item->spec;
uint16_t regcs = (uint8_t)priv->sh->cdev->config.hca_attr.set_reg_c;
- if (!((1 << (tag->index - REG_C_0)) & regcs))
+ if (!((1 << (mlx5_tag->id - REG_C_0)) & regcs))
return rte_flow_error_set(error, EINVAL,
RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
NULL,
"Unsupported internal tag index");
- if (tag_bitmap & (1 << tag->index))
+ if (tag_bitmap & (1 << mlx5_tag->id))
return rte_flow_error_set(error, EINVAL,
RTE_FLOW_ERROR_TYPE_ITEM,
NULL,
"Duplicated tag index");
- tag_bitmap |= 1 << tag->index;
+ tag_bitmap |= 1 << mlx5_tag->id;
break;
}
case RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT:
@@ -9028,13 +9029,13 @@ flow_hw_pattern_template_create(struct rte_eth_dev *dev,
.type = RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT,
.mask = &rte_flow_item_ethdev_mask,
};
- struct rte_flow_item_tag tag_v = {
+ struct mlx5_rte_flow_item_tag tag_v = {
.data = 0,
- .index = REG_C_0,
+ .id = REG_C_0,
};
- struct rte_flow_item_tag tag_m = {
+ struct mlx5_rte_flow_item_tag tag_m = {
.data = flow_hw_tx_tag_regc_mask(dev),
- .index = 0xff,
+ .id = (enum modify_reg)0xff,
};
struct rte_flow_item tag = {
.type = (enum rte_flow_item_type)MLX5_RTE_FLOW_ITEM_TYPE_TAG,
@@ -10119,11 +10120,11 @@ flow_hw_create_ctrl_regc_sq_pattern_template(struct rte_eth_dev *dev,
.relaxed_matching = 0,
.transfer = 1,
};
- struct rte_flow_item_tag reg_c0_spec = {
- .index = (uint8_t)REG_C_0,
+ struct mlx5_rte_flow_item_tag reg_c0_spec = {
+ .id = (uint8_t)REG_C_0,
};
- struct rte_flow_item_tag reg_c0_mask = {
- .index = 0xff,
+ struct mlx5_rte_flow_item_tag reg_c0_mask = {
+ .id = (enum modify_reg)0xff,
.data = flow_hw_esw_mgr_regc_marker_mask(dev),
};
struct mlx5_rte_flow_item_sq queue_mask = {
@@ -10131,14 +10132,12 @@ flow_hw_create_ctrl_regc_sq_pattern_template(struct rte_eth_dev *dev,
};
struct rte_flow_item items[] = {
{
- .type = (enum rte_flow_item_type)
- MLX5_RTE_FLOW_ITEM_TYPE_TAG,
+ .type = (enum rte_flow_item_type)MLX5_RTE_FLOW_ITEM_TYPE_TAG,
.spec = ®_c0_spec,
.mask = ®_c0_mask,
},
{
- .type = (enum rte_flow_item_type)
- MLX5_RTE_FLOW_ITEM_TYPE_SQ,
+ .type = (enum rte_flow_item_type)MLX5_RTE_FLOW_ITEM_TYPE_SQ,
.mask = &queue_mask,
},
{
--
2.34.1
More information about the dev
mailing list