net/mlx5: fix representor item and meter
PATCH 1/1 net/mlx5: fix representor item and meter
When creating flow matching port representor item with meter action, it will fail due to incorrect parsing the item.
This patch fixes this issue by adding the correct item parse for port representor in validation.
--- drivers/net/mlx5/mlx5_flow.c | 50 ++++++++++++++++++++------------- drivers/net/mlx5/mlx5_flow_dv.c | 6 ++++ 2 files changed, 37 insertions(+), 19 deletions(-)
drivers/net/mlx5/mlx5_flow.c +31 -19
@@ -5469,6 +5469,7 @@ flow_meter_split_prep(struct rte_eth_dev *dev,switch (item_type) {case RTE_FLOW_ITEM_TYPE_PORT_ID :case RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT : +case RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR :if (mlx5_flow_get_item_vport_id (dev, items, &flow_src_port,NULL , error))return -rte_errno; if (!fm->def_policy && wks->policy->is_hierarchy &&
@@ -5483,11 +5484,6 @@ flow_meter_split_prep(struct rte_eth_dev *dev,memcpy (sfx_items, items,sizeof (*sfx_items)); sfx_items++;break ; -case RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR : - flow_src_port =0 ; -memcpy (sfx_items, items,sizeof (*sfx_items)); - sfx_items++; -break ;case RTE_FLOW_ITEM_TYPE_VLAN :/* Determine if copy vlan item below. */ vlan_item_src = items;
@@ -11402,27 +11398,43 @@ int mlx5_flow_get_item_vport_id(struct rte_eth_dev *dev, struct rte_flow_error *error) {struct mlx5_priv *port_priv; -const struct rte_flow_item_port_id *pid_v; +const struct rte_flow_item_port_id *pid_v =NULL ; +const struct rte_flow_item_ethdev *dev_v =NULL ;uint32_t esw_mgr_port; +uint32_t src_port; -if (item->type !=RTE_FLOW_ITEM_TYPE_PORT_ID && - item->type !=RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT ) +if (all_ports) + *all_ports = false; +switch (item->type) { +case RTE_FLOW_ITEM_TYPE_PORT_ID : + pid_v = item->spec; +if (!pid_v) +return 0 ; + src_port = pid_v->id; + esw_mgr_port =MLX5_PORT_ESW_MGR ; +break ; +case RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT : + dev_v = item->spec; +if (!dev_v) { +if (all_ports) + *all_ports = true; +return 0 ; + } + src_port = dev_v->port_id; + esw_mgr_port =MLX5_REPRESENTED_PORT_ESW_MGR ; +break ; +case RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR : + src_port =MLX5_REPRESENTED_PORT_ESW_MGR ; + esw_mgr_port =MLX5_REPRESENTED_PORT_ESW_MGR ; +break ; +default :return rte_flow_error_set (error,EINVAL ,RTE_FLOW_ERROR_TYPE_ITEM_SPEC ,NULL ,"Incorrect item type." ); - pid_v = item->spec; -if (!pid_v) { -if (all_ports) - *all_ports = (item->type ==RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT ); -return 0 ; } -if (all_ports) - *all_ports = false; - esw_mgr_port = (item->type ==RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT ) ? -MLX5_REPRESENTED_PORT_ESW_MGR :MLX5_PORT_ESW_MGR ; -if (pid_v->id == esw_mgr_port) { +if (src_port == esw_mgr_port) { *vport_id =mlx5_flow_get_esw_manager_vport_id (dev); }else { - port_priv =mlx5_port_to_eswitch_info (pid_v->id, false); + port_priv =mlx5_port_to_eswitch_info (src_port, false);if (!port_priv)return rte_flow_error_set (error,EINVAL ,RTE_FLOW_ERROR_TYPE_ITEM_SPEC ,NULL ,"Failed to get port info." );
drivers/net/mlx5/mlx5_flow_dv.c +6 -0
@@ -17056,6 +17056,9 @@ __flow_dv_create_policy_flow(struct rte_eth_dev *dev,if (item && item->type ==RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT ) ret =flow_dv_translate_item_represented_port (dev, value.buf, item, attr,MLX5_SET_MATCHER_SW_V ); +else if (item && item->type ==RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR ) + ret =flow_dv_translate_item_port_representor (dev, value.buf, +MLX5_SET_MATCHER_SW_V );else ret =flow_dv_translate_item_port_id (dev, value.buf, item, attr,MLX5_SET_MATCHER_SW_V );
@@ -17110,6 +17113,9 @@ __flow_dv_create_policy_matcher(struct rte_eth_dev *dev,if (item && item->type ==RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT ) ret =flow_dv_translate_item_represented_port (dev, matcher.mask.buf, item, attr,MLX5_SET_MATCHER_SW_M ); +else if (item && item->type ==RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR ) + ret =flow_dv_translate_item_port_representor (dev, matcher.mask.buf, +MLX5_SET_MATCHER_SW_M );else ret =flow_dv_translate_item_port_id (dev, matcher.mask.buf, item, attr,MLX5_SET_MATCHER_SW_M );
Signature · 1 line
2.20.0
Hi,
Quoted 10 lines
-----Original Message-----
From: Shun Hao <[email protected]>
Sent: Tuesday, November 8, 2022 10:51 AM
To: Slava Ovsiienko <[email protected]>; Matan Azrad <[email protected]>; Ori Kam <[email protected]>; Sean Zhang (Networking SW) <[email protected]>
Cc: [email protected]; Raslan Darawsheh <[email protected]>; [email protected]
Subject: [PATCH v1] net/mlx5: fix representor item and meter
Small change to the commit title:
net/mlx5: fix representor item with meter
Quoted 11 lines
When creating flow matching port representor item with meter action, it will fail due to incorrect parsing the item.
This patch fixes this issue by adding the correct item parse for port representor in validation.
Fixes 707d5e7d79 ("net/mlx5: support flow matching on representor ID")Signed-off-by Shun Hao <[email protected]>Acked-by Matan Azrad <[email protected]>
Patch applied to next-net-mlx,
Kindest regards,
Raslan Darawsheh