* [PATCH v1 1/2] net/mlx5: fix matcher layout size calculation
2023-05-16 5:40 [PATCH v1 0/2] Fix VXLAN matching Rongwei Liu
@ 2023-05-16 5:40 ` Rongwei Liu
2023-05-16 5:40 ` [PATCH v1 2/2] net/mlx5: fix VXLAN matching with zero value Rongwei Liu
2023-05-24 6:46 ` [PATCH v1 0/2] Fix VXLAN matching Raslan Darawsheh
2 siblings, 0 replies; 4+ messages in thread
From: Rongwei Liu @ 2023-05-16 5:40 UTC (permalink / raw)
To: dev, matan, viacheslavo, orika, thomas; +Cc: rongweil, stable, Raslan Darawsheh
Initially, the rdma-core library only supported misc0 to misc3 fields in
matching resources, misc4 and misc5 fields were added to handle new
features. The matcher layout, passing from DPDK to rdma-core, shouldn't
exceed the size of the engaged library version capabilities.
For now, there is no way to know what is the maximum capability of
rdma-core, and DPDK should limit the matcher layout to misc3 if
possible (no matching on fields misc4 and misc5 are requested by the
application).
The check if misc4 and misc5 features were requested was based on checking
the values against zeroes. The matching mask should be checked instead.
Fixes: 630a587bfb37 ("net/mlx5: support matching on VXLAN reserved field")
Cc: rongweil@nvidia.com
Cc: stable@dpdk.org
Signed-off-by: Rongwei Liu <rongweil@nvidia.com>
Acked-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
---
drivers/net/mlx5/mlx5_flow_dv.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index f136f43b0a..f44d621600 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -15167,7 +15167,7 @@ flow_dv_apply(struct rte_eth_dev *dev, struct rte_flow *flow,
}
dv->actions[n++] = priv->sh->default_miss_action;
}
- misc_mask = flow_dv_matcher_enable(dv->value.buf);
+ misc_mask = flow_dv_matcher_enable(dv_h->matcher->mask.buf);
__flow_dv_adjust_buf_size(&dv->value.size, misc_mask);
err = mlx5_flow_os_create_flow(dv_h->matcher->matcher_object,
(void *)&dv->value, n,
@@ -17367,7 +17367,7 @@ flow_dv_destroy_def_policy(struct rte_eth_dev *dev)
static int
__flow_dv_create_policy_flow(struct rte_eth_dev *dev,
uint32_t color_reg_c_idx,
- enum rte_color color, void *matcher_object,
+ enum rte_color color, struct mlx5_flow_dv_matcher *matcher,
int actions_n, void *actions,
bool match_src_port, const struct rte_flow_item *item,
void **rule, const struct rte_flow_attr *attr)
@@ -17397,9 +17397,9 @@ __flow_dv_create_policy_flow(struct rte_eth_dev *dev,
}
flow_dv_match_meta_reg(value.buf, (enum modify_reg)color_reg_c_idx,
rte_col_2_mlx5_col(color), UINT32_MAX);
- misc_mask = flow_dv_matcher_enable(value.buf);
+ misc_mask = flow_dv_matcher_enable(matcher->mask.buf);
__flow_dv_adjust_buf_size(&value.size, misc_mask);
- ret = mlx5_flow_os_create_flow(matcher_object, (void *)&value,
+ ret = mlx5_flow_os_create_flow(matcher->matcher_object, (void *)&value,
actions_n, actions, rule);
if (ret) {
DRV_LOG(ERR, "Failed to create meter policy%d flow.", color);
@@ -17553,7 +17553,7 @@ __flow_dv_create_domain_policy_rules(struct rte_eth_dev *dev,
/* Create flow, matching color. */
if (__flow_dv_create_policy_flow(dev,
color_reg_c_idx, (enum rte_color)i,
- color_rule->matcher->matcher_object,
+ color_rule->matcher,
acts[i].actions_n, acts[i].dv_actions,
svport_match, NULL, &color_rule->rule,
&attr)) {
@@ -18021,7 +18021,7 @@ flow_dv_create_mtr_tbls(struct rte_eth_dev *dev,
actions[i++] = priv->sh->dr_drop_action;
flow_dv_match_meta_reg_all(matcher_para.buf, value.buf,
(enum modify_reg)mtr_id_reg_c, 0, 0);
- misc_mask = flow_dv_matcher_enable(value.buf);
+ misc_mask = flow_dv_matcher_enable(mtrmng->def_matcher[domain]->mask.buf);
__flow_dv_adjust_buf_size(&value.size, misc_mask);
ret = mlx5_flow_os_create_flow
(mtrmng->def_matcher[domain]->matcher_object,
@@ -18066,7 +18066,7 @@ flow_dv_create_mtr_tbls(struct rte_eth_dev *dev,
fm->drop_cnt, NULL);
actions[i++] = cnt->action;
actions[i++] = priv->sh->dr_drop_action;
- misc_mask = flow_dv_matcher_enable(value.buf);
+ misc_mask = flow_dv_matcher_enable(drop_matcher->mask.buf);
__flow_dv_adjust_buf_size(&value.size, misc_mask);
ret = mlx5_flow_os_create_flow(drop_matcher->matcher_object,
(void *)&value, i, actions,
@@ -18546,7 +18546,7 @@ flow_dv_meter_hierarchy_rule_create(struct rte_eth_dev *dev,
goto err_exit;
}
if (__flow_dv_create_policy_flow(dev, color_reg_c_idx, (enum rte_color)j,
- color_rule->matcher->matcher_object,
+ color_rule->matcher,
acts.actions_n, acts.dv_actions,
true, item, &color_rule->rule, &attr)) {
rte_spinlock_unlock(&mtr_policy->sl);
@@ -19590,7 +19590,7 @@ flow_dv_discover_priorities(struct rte_eth_dev *dev,
break;
}
/* Try to apply the flow to HW. */
- misc_mask = flow_dv_matcher_enable(flow.dv.value.buf);
+ misc_mask = flow_dv_matcher_enable(flow.handle->dvh.matcher->mask.buf);
__flow_dv_adjust_buf_size(&flow.dv.value.size, misc_mask);
err = mlx5_flow_os_create_flow
(flow.handle->dvh.matcher->matcher_object,
--
2.27.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v1 2/2] net/mlx5: fix VXLAN matching with zero value
2023-05-16 5:40 [PATCH v1 0/2] Fix VXLAN matching Rongwei Liu
2023-05-16 5:40 ` [PATCH v1 1/2] net/mlx5: fix matcher layout size calculation Rongwei Liu
@ 2023-05-16 5:40 ` Rongwei Liu
2023-05-24 6:46 ` [PATCH v1 0/2] Fix VXLAN matching Raslan Darawsheh
2 siblings, 0 replies; 4+ messages in thread
From: Rongwei Liu @ 2023-05-16 5:40 UTC (permalink / raw)
To: dev, matan, viacheslavo, orika, thomas; +Cc: suanmingm, stable
When an application wants to match VxLAN last_rsvd value zero,
PMD sets the matching mask field to zero by mistake and it causes
traffic with any last_rsvd value hits. The matching mask should be
taken from application input directly, no need to perform the bit reset
operation.
Fixes: cd4ab742064a ("net/mlx5: split flow item matcher and value translation")
Cc: suanmingm@nvidia.com
Cc: stable@dpdk.org
Signed-off-by: Rongwei Liu <rongweil@nvidia.com>
Acked-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
---
drivers/net/mlx5/mlx5_flow_dv.c | 19 ++-----------------
1 file changed, 2 insertions(+), 17 deletions(-)
diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index f44d621600..1abc4acad7 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -9480,12 +9480,10 @@ flow_dv_translate_item_vxlan(struct rte_eth_dev *dev,
{
const struct rte_flow_item_vxlan *vxlan_m;
const struct rte_flow_item_vxlan *vxlan_v;
- const struct rte_flow_item_vxlan *vxlan_vv = item->spec;
void *headers_v;
void *misc_v;
void *misc5_v;
uint32_t tunnel_v;
- uint32_t *tunnel_header_v;
char *vni_v;
uint16_t dport;
int size;
@@ -9537,24 +9535,11 @@ flow_dv_translate_item_vxlan(struct rte_eth_dev *dev,
vni_v[i] = vxlan_m->hdr.vni[i] & vxlan_v->hdr.vni[i];
return;
}
- tunnel_header_v = (uint32_t *)MLX5_ADDR_OF(fte_match_set_misc5,
- misc5_v,
- tunnel_header_1);
tunnel_v = (vxlan_v->hdr.vni[0] & vxlan_m->hdr.vni[0]) |
(vxlan_v->hdr.vni[1] & vxlan_m->hdr.vni[1]) << 8 |
(vxlan_v->hdr.vni[2] & vxlan_m->hdr.vni[2]) << 16;
- *tunnel_header_v = tunnel_v;
- if (key_type == MLX5_SET_MATCHER_SW_M) {
- tunnel_v = (vxlan_vv->hdr.vni[0] & vxlan_m->hdr.vni[0]) |
- (vxlan_vv->hdr.vni[1] & vxlan_m->hdr.vni[1]) << 8 |
- (vxlan_vv->hdr.vni[2] & vxlan_m->hdr.vni[2]) << 16;
- if (!tunnel_v)
- *tunnel_header_v = 0x0;
- if (vxlan_vv->hdr.rsvd1 & vxlan_m->hdr.rsvd1)
- *tunnel_header_v |= vxlan_v->hdr.rsvd1 << 24;
- } else {
- *tunnel_header_v |= (vxlan_v->hdr.rsvd1 & vxlan_m->hdr.rsvd1) << 24;
- }
+ tunnel_v |= (vxlan_v->hdr.rsvd1 & vxlan_m->hdr.rsvd1) << 24;
+ MLX5_SET(fte_match_set_misc5, misc5_v, tunnel_header_1, RTE_BE32(tunnel_v));
}
/**
--
2.27.0
^ permalink raw reply [flat|nested] 4+ messages in thread