net/mlx5: fix mark enabling for Rx datapath
PATCH 1/1 net/mlx5: fix mark enabling for Rx datapath
To optimize datapath, the mlx5 pmd checked for mark action on flow creation, and flagged possible destination rxqs (through queue/RSS actions), then it enabled the mark action logic only for flagged rxqs.
Mark action didn't work if no queue/rss action was in the same flow, even when the user use multi-group logic to manage the flows. So, if mark action is performed in group X and the packet is moved to group Y > X when the packet is forwarded to Rx queues, SW did not get the mark ID to the mbuf.
Flag Rx datapath to report mark action for any queue when the driver detects the first mark action after dev_start operation.
---
drivers/net/mlx5/mlx5.h | 1 + drivers/net/mlx5/mlx5_flow.c | 53 ++++++++++++++++-------------- drivers/net/mlx5/mlx5_flow.h | 2 +- drivers/net/mlx5/mlx5_flow_dv.c | 14 +++++--- drivers/net/mlx5/mlx5_flow_verbs.c | 4 +-- drivers/net/mlx5/mlx5_rx.h | 1 - 6 files changed, 41 insertions(+), 34 deletions(-)
drivers/net/mlx5/mlx5.h +1 -0
@@ -1413,6 +1413,7 @@ struct mlx5_priv { unsigned int mtr_en:1; /* Whether support meter. */ unsigned int mtr_reg_share:1; /* Whether support meter REG_C share. */ unsigned int lb_used:1; /* Loopback queue is referred to. */ + uint32_t mark_enabled:1; /* If mark action is enabled on rxqs. */uint16_t domain_id;/* Switch domain identifier. */ uint16_t vport_id;/* Associated VF vport index (if any). */ uint32_t vport_meta_tag;/* Used for vport index match ove VF LAG. */
drivers/net/mlx5/mlx5_flow.c +28 -25
131 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow.h +1 -1
@@ -697,7 +697,6 @@ struct mlx5_flow_handle {void *drv_flow;/**< pointer to driver flow object. */ uint32_t split_flow_id:27; /**< Sub flow unique match flow id. */ uint32_t is_meter_flow_id:1; /**< Indicate if flow_id is for meter. */ - uint32_t mark:1; /**< Metadata rxq mark flag. */ uint32_t fate_action:3; /**< Fate action type. */uint32_t flex_item;/**< referenced Flex Item bitmask. */ union {
@@ -1108,6 +1107,7 @@ struct mlx5_flow_workspace {/* The final policy when meter policy is hierarchy. */ uint32_t skip_matcher_reg:1;/* Indicates if need to skip matcher register in translate. */ + uint32_t mark:1; /* Indicates if flow contains mark action. */ };struct mlx5_flow_split_info {
drivers/net/mlx5/mlx5_flow_dv.c +9 -5
@@ -11645,7 +11645,7 @@ flow_dv_translate_action_sample(struct rte_eth_dev *dev, (((const struct rte_flow_action_mark *) (sub_actions->conf))->id); - dev_flow->handle->mark =1 ; + wks->mark =1 ; pre_rix = dev_flow->handle->dvh.rix_tag;/* Save the mark resource before sample */ pre_r = dev_flow->dv.tag_resource;
@@ -12805,7 +12805,7 @@ flow_dv_translate(struct rte_eth_dev *dev,break ;case RTE_FLOW_ACTION_TYPE_FLAG : action_flags |=MLX5_FLOW_ACTION_FLAG ; - dev_flow->handle->mark =1 ; + wks->mark =1 ;if (dev_conf->dv_xmeta_en !=MLX5_XMETA_MODE_LEGACY ) {struct rte_flow_action_mark mark = { .id =MLX5_FLOW_MARK_DEFAULT ,
@@ -12834,7 +12834,7 @@ flow_dv_translate(struct rte_eth_dev *dev,break ;case RTE_FLOW_ACTION_TYPE_MARK : action_flags |=MLX5_FLOW_ACTION_MARK ; - dev_flow->handle->mark =1 ; + wks->mark =1 ;if (dev_conf->dv_xmeta_en !=MLX5_XMETA_MODE_LEGACY ) {const struct rte_flow_action_mark *mark = (const struct rte_flow_action_mark *)
@@ -15402,7 +15402,9 @@ __flow_dv_create_domain_policy_acts(struct rte_eth_dev *dev, (MLX5_MAX_MODIFY_NUM + 1)]; } mhdr_dummy;struct mlx5_flow_dv_modify_hdr_resource *mhdr_res = &mhdr_dummy.res; +struct mlx5_flow_workspace *wks =mlx5_flow_get_thread_workspace (); +MLX5_ASSERT (wks); egress = (domain ==MLX5_MTR_DOMAIN_EGRESS ) ?1 :0 ; transfer = (domain ==MLX5_MTR_DOMAIN_TRANSFER ) ?1 :0 ;memset (&dh,0 ,sizeof (struct mlx5_flow_handle ));
@@ -15440,7 +15442,7 @@ __flow_dv_create_domain_policy_acts(struct rte_eth_dev *dev,NULL ,"cannot create policy " "mark action for this color"); - dev_flow.handle->mark =1 ; + wks->mark =1 ;if (flow_dv_tag_resource_register (dev, tag_be, &dev_flow, &flow_err)) return -rte_mtr_error_set(error,
@@ -16865,7 +16867,9 @@ __flow_dv_meter_get_rss_sub_policy(struct rte_eth_dev *dev,struct mlx5_meter_policy_action_container *act_cnt;uint32_t domain =MLX5_MTR_DOMAIN_INGRESS ;uint16_t sub_policy_num; +struct mlx5_flow_workspace *wks =mlx5_flow_get_thread_workspace (); +MLX5_ASSERT (wks);rte_spinlock_lock (&mtr_policy->sl);for (i =0 ; i <MLX5_MTR_RTE_COLORS ; i++) {if (!rss_desc[i])
@@ -16939,7 +16943,7 @@ __flow_dv_meter_get_rss_sub_policy(struct rte_eth_dev *dev,if (act_cnt->rix_mark || act_cnt->modify_hdr) {memset (&dh,0 ,sizeof (struct mlx5_flow_handle ));if (act_cnt->rix_mark) - dh.mark =1 ; + wks->mark =1 ; dh.fate_action =MLX5_FLOW_FATE_QUEUE ; dh.rix_hrxq = hrxq_idx[i];flow_drv_rxq_flags_set (dev, &dh);
drivers/net/mlx5/mlx5_flow_verbs.c +2 -2
@@ -1693,12 +1693,12 @@ flow_verbs_translate(struct rte_eth_dev *dev,case RTE_FLOW_ACTION_TYPE_FLAG :flow_verbs_translate_action_flag (dev_flow, actions); action_flags |=MLX5_FLOW_ACTION_FLAG ; - dev_flow->handle->mark =1 ; + wks->mark =1 ;break ;case RTE_FLOW_ACTION_TYPE_MARK :flow_verbs_translate_action_mark (dev_flow, actions); action_flags |=MLX5_FLOW_ACTION_MARK ; - dev_flow->handle->mark =1 ; + wks->mark =1 ;break ;case RTE_FLOW_ACTION_TYPE_DROP :flow_verbs_translate_action_drop (dev_flow, actions);
drivers/net/mlx5/mlx5_rx.h +0 -1
@@ -161,7 +161,6 @@ struct mlx5_rxq_ctrl {uint16_t share_qid;/* Shared RxQ ID in group. */ unsigned int started:1; /* Whether (shared) RXQ has been started. */ unsigned int irq:1; /* Whether IRQ is enabled. */ -uint32_t flow_mark_n;/* Number of Mark/Flag flows using this Queue. */ uint32_t flow_tunnels_n[MLX5_FLOW_TUNNEL ];/* Tunnels counters. */ uint32_t wqn;/* WQ number. */ uint32_t rxseg_n;/* Number of split segment descriptions. */
Signature · 1 line
2.17.1
Hi,
Quoted 20 lines
-----Original Message-----
From: Raja Zidane <[email protected]>
Sent: Sunday, January 16, 2022 5:24 PM
To: [email protected]
Cc: Matan Azrad <[email protected]>; [email protected]
Subject: [PATCH] net/mlx5: fix mark enabling for Rx datapathTo optimize datapath, the mlx5 pmd checked for mark action on flow creation, and flagged possible destination rxqs (through queue/RSS actions), then it enabled the mark action logic only for flagged rxqs.
Mark action didn't work if no queue/rss action was in the same flow, even when the user use multi-group logic to manage the flows. So, if mark action is performed in group X and the packet is moved to group Y > X when the packet is forwarded to Rx queues, SW did not get the mark ID to the mbuf.
Flag Rx datapath to report mark action for any queue when the driver detects the first mark action after
dev_startoperation.
Quoted 7 lines
Fixes 8e61555657b2 ("net/mlx5: fix shared RSS and mark actionscombination")
Cc: [email protected]Signed-off-by Raja Zidane <[email protected]>---
Acked-by Matan Azrad [email protected]
Patch applied to next-net-mlx,
Kindest regards,
Raslan Darawsheh