Support set vlan vid in non template on top of HWS. Update relevant return errors in the relevant functions to avoid crash. Mask the vlan vid action in non template mode such that the action template create will use the vid value.
Fixes: 00a0a6b80674 ("net/mlx5: support indirect actions in non-template setup") Cc: sta...@dpdk.org Signed-off-by: Maayan Kashani <mkash...@nvidia.com> Acked-by: Dariusz Sosnowski <dsosnow...@nvidia.com> --- drivers/net/mlx5/mlx5_flow_hw.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/drivers/net/mlx5/mlx5_flow_hw.c b/drivers/net/mlx5/mlx5_flow_hw.c index 3bfb2f35c12..ec047e855e3 100644 --- a/drivers/net/mlx5/mlx5_flow_hw.c +++ b/drivers/net/mlx5/mlx5_flow_hw.c @@ -714,6 +714,9 @@ flow_hw_action_flags_get(const struct rte_flow_action actions[], case RTE_FLOW_ACTION_TYPE_OF_POP_VLAN: action_flags |= MLX5_FLOW_ACTION_OF_POP_VLAN; break; + case RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID: + action_flags |= MLX5_FLOW_ACTION_OF_SET_VLAN_VID; + break; case RTE_FLOW_ACTION_TYPE_JUMP: action_flags |= MLX5_FLOW_ACTION_JUMP; break; @@ -7811,22 +7814,23 @@ flow_hw_parse_flow_actions_to_dr_actions(struct rte_eth_dev *dev, return -EINVAL; } -static void +static int flow_hw_set_vlan_vid(struct rte_eth_dev *dev, struct rte_flow_action *ra, struct rte_flow_action *rm, struct rte_flow_action_modify_field *spec, struct rte_flow_action_modify_field *mask, - int set_vlan_vid_ix) + int set_vlan_vid_ix, + struct rte_flow_error *error) { - struct rte_flow_error error; const bool masked = rm[set_vlan_vid_ix].conf && (((const struct rte_flow_action_of_set_vlan_vid *) rm[set_vlan_vid_ix].conf)->vlan_vid != 0); const struct rte_flow_action_of_set_vlan_vid *conf = ra[set_vlan_vid_ix].conf; int width = mlx5_flow_item_field_width(dev, RTE_FLOW_FIELD_VLAN_ID, 0, - NULL, &error); + NULL, error); + MLX5_ASSERT(width); *spec = (typeof(*spec)) { .operation = RTE_FLOW_MODIFY_SET, .dst = { @@ -7859,6 +7863,7 @@ flow_hw_set_vlan_vid(struct rte_eth_dev *dev, ra[set_vlan_vid_ix].conf = spec; rm[set_vlan_vid_ix].type = RTE_FLOW_ACTION_TYPE_MODIFY_FIELD; rm[set_vlan_vid_ix].conf = mask; + return 0; } static __rte_always_inline int @@ -8104,9 +8109,11 @@ __flow_hw_actions_template_create(struct rte_eth_dev *dev, tmp_mask, &ra, &rm, act_num); - flow_hw_set_vlan_vid(dev, ra, rm, - &set_vlan_vid_spec, &set_vlan_vid_mask, - set_vlan_vid_ix); + ret = flow_hw_set_vlan_vid(dev, ra, rm, + &set_vlan_vid_spec, &set_vlan_vid_mask, + set_vlan_vid_ix, error); + if (ret) + goto error; action_flags |= MLX5_FLOW_ACTION_MODIFY_FIELD; } if (action_flags & MLX5_FLOW_ACTION_QUOTA) { @@ -13744,6 +13751,10 @@ flow_nta_build_template_mask(const struct rte_flow_action actions[], action->conf)->definition; mask->conf = conf; break; + case RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID: + memset(conf, 0xff, sizeof(struct rte_flow_action_of_set_vlan_vid)); + mask->conf = conf; + break; default: break; } -- 2.21.0