net/mlx5: fix shared RSS action release
PATCH 1/1 net/mlx5: fix shared RSS action release
As shared RSS action is global standalone action, the shared action should be maintained only by the shared action management functions.
Currently, the shared RSS action hrxq uses the same fate action type with existed general queues, and implicitly uses the deprecate refcnt increment to indicate the hrxq is in using which leads the hrxq be released when flow is destroyed.
This commit adds a new fate action type for shared RSS action to handle the shared RSS action release correctly.
--- drivers/net/mlx5/mlx5.h | 3 +- drivers/net/mlx5/mlx5_flow.c | 7 ++- drivers/net/mlx5/mlx5_flow.h | 4 +- drivers/net/mlx5/mlx5_flow_dv.c | 88 +++++++++++++++++++++++++------------- drivers/net/mlx5/mlx5_flow_verbs.c | 2 +- drivers/net/mlx5/mlx5_rxq.c | 36 ++++++++-------- 6 files changed, 86 insertions(+), 54 deletions(-)
drivers/net/mlx5/mlx5.h +1 -2
@@ -789,11 +789,11 @@ struct mlx5_flow_rss_desc {uint8_t key[MLX5_RSS_HASH_KEY_LEN ];/**< RSS hash key. */ uint32_t key_len;/**< RSS hash key len. */ uint32_t tunnel;/**< Queue in tunnel. */ +uint32_t shared_rss;/**< Shared RSS index. */ union {uint16_t *queue;/**< Destination queues. */ const uint16_t *const_q;/**< Const pointer convert. */ }; -bool standalone;/**< Queue is standalone or not. */ };#define MLX5_PROC_PRIV (port_id) \
@@ -836,7 +836,6 @@ struct mlx5_ind_table_obj { __extension__ struct mlx5_hrxq { struct mlx5_cache_entry entry; /* Cache entry. */ - uint32_t refcnt; /* Reference counter. */ uint32_t standalone:1; /* This object used in shared action. */ struct mlx5_ind_table_obj *ind_table; /* Indirection table. */ RTE_STD_C11
drivers/net/mlx5/mlx5_flow.c +6 -1
@@ -5622,7 +5622,7 @@ struct tunnel_default_miss_ctx { buf->entries =1 ; buf->entry[0 ].pattern = (void *)(uintptr_t )items; } - flow->shared_rss =flow_get_shared_rss_action (dev, shared_actions, + rss_desc->shared_rss =flow_get_shared_rss_action (dev, shared_actions, shared_actions_n);/* * Record the start index when there is a nested call. All sub-flows
@@ -5729,6 +5729,11 @@ struct tunnel_default_miss_ctx { ret = rte_errno;/* Save rte_errno before cleanup. */ flow_mreg_del_copy_action (dev, flow);flow_drv_destroy (dev, flow); +if (rss_desc->shared_rss) +__atomic_sub_fetch (&((struct mlx5_shared_action_rss *) +mlx5_ipool_get + (priv->sh->ipool[MLX5_IPOOL_RSS_SHARED_ACTIONS ], + rss_desc->shared_rss))->refcnt,1 , __ATOMIC_RELAXED);mlx5_ipool_free (priv->sh->ipool[MLX5_IPOOL_RTE_FLOW ], idx); rte_errno = ret;/* Restore rte_errno. */ ret = rte_errno;
drivers/net/mlx5/mlx5_flow.h +3 -1
@@ -388,6 +388,7 @@ enum mlx5_flow_fate_type {MLX5_FLOW_FATE_PORT_ID ,MLX5_FLOW_FATE_DROP ,MLX5_FLOW_FATE_DEFAULT_MISS , +MLX5_FLOW_FATE_SHARED_RSS , MLX5_FLOW_FATE_MAX, };
@@ -651,6 +652,8 @@ struct mlx5_flow_handle {/**< Generic value indicates the fate action. */ uint32_t rix_default_fate;/**< Indicates default miss fate action. */ +uint32_t rix_srss; +/**< Indicates shared RSS fate action. */ };#ifdef HAVE_IBV_FLOW_DV_SUPPORT struct mlx5_flow_handle_dv dvh;
@@ -1024,7 +1027,6 @@ struct tunnel_tbl_entry {/* Flow structure. */ struct rte_flow {ILIST_ENTRY (uint32_t )next;/**< Index to the next flow structure. */ -uint32_t shared_rss;/** < Shared RSS action ID. */ uint32_t dev_handles;/**< Device flow handles that are part of the flow. */ uint32_t drv_type:2 ;/**< Driver type. */
drivers/net/mlx5/mlx5_flow_dv.c +58 -30
200 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_verbs.c +1 -1
@@ -1972,7 +1972,7 @@ rss_desc->hash_fields = dev_flow->hash_fields; rss_desc->tunnel = !!(handle->layers &MLX5_FLOW_LAYER_TUNNEL ); - rss_desc->standalone = false; + rss_desc->shared_rss =0 ; hrxq_idx =mlx5_hrxq_get (dev, rss_desc); hrxq =mlx5_ipool_get (priv->sh->ipool[MLX5_IPOOL_HRXQ ], hrxq_idx);
drivers/net/mlx5/mlx5_rxq.c +17 -19
@@ -2211,8 +2211,9 @@ struct mlx5_ind_table_obj *struct mlx5_priv *priv = dev->data->dev_private;const uint8_t *rss_key = rss_desc->key;uint32_t rss_key_len = rss_desc->key_len; +bool standalone = !!rss_desc->shared_rss;const uint16_t *queues = - rss_desc->standalone ? rss_desc->const_q : rss_desc->queue; + standalone ? rss_desc->const_q : rss_desc->queue;uint32_t queues_n = rss_desc->queue_num;struct mlx5_hrxq *hrxq =NULL ;uint32_t hrxq_idx =0 ;
@@ -2220,16 +2221,17 @@ struct mlx5_ind_table_obj *int ret; queues_n = rss_desc->hash_fields ? queues_n :1 ; - ind_tbl =mlx5_ind_table_obj_get (dev, queues, queues_n); + ind_tbl = standalone ?NULL : +mlx5_ind_table_obj_get (dev, queues, queues_n);if (!ind_tbl) ind_tbl =mlx5_ind_table_obj_new (dev, queues, queues_n, - rss_desc->standalone); + standalone);if (!ind_tbl)return NULL ; hrxq =mlx5_ipool_zmalloc (priv->sh->ipool[MLX5_IPOOL_HRXQ ], &hrxq_idx);if (!hrxq) goto error; - hrxq->standalone = rss_desc->standalone; + hrxq->standalone = standalone; hrxq->idx = hrxq_idx; hrxq->ind_table = ind_tbl; hrxq->rss_key_len = rss_key_len;
@@ -2240,7 +2242,7 @@ struct mlx5_ind_table_obj * goto error;return hrxq; error: -mlx5_ind_table_obj_release (dev, ind_tbl, rss_desc->standalone); +mlx5_ind_table_obj_release (dev, ind_tbl, standalone);if (hrxq)mlx5_ipool_free (priv->sh->ipool[MLX5_IPOOL_HRXQ ], hrxq_idx);return NULL ;
@@ -2294,7 +2296,7 @@ uint32_t mlx5_hrxq_get(struct rte_eth_dev *dev, .data = rss_desc, }; -if (rss_desc->standalone) { +if (rss_desc->shared_rss) { hrxq =__mlx5_hrxq_create (dev, rss_desc); }else { entry =mlx5_cache_register (&priv->hrxqs, &ctx);
@@ -2344,11 +2346,8 @@ struct mlx5_hrxq *struct mlx5_hrxq *hrxq =NULL ;int ret; -if (priv->drop_queue.hrxq) { -__atomic_fetch_add (&priv->drop_queue.hrxq->refcnt,1 , - __ATOMIC_RELAXED); +if (priv->drop_queue.hrxq)return priv->drop_queue.hrxq; - } hrxq =mlx5_malloc (MLX5_MEM_ZERO ,sizeof (*hrxq),0 ,SOCKET_ID_ANY );if (!hrxq) { DRV_LOG(WARNING,
@@ -2367,7 +2366,6 @@ struct mlx5_hrxq * ret = priv->obj_ops.drop_action_create (dev);if (ret <0 ) goto error; -__atomic_store_n (&hrxq->refcnt,1 , __ATOMIC_RELAXED);return hrxq; error:if (hrxq) {
@@ -2391,14 +2389,14 @@ struct mlx5_hrxq *struct mlx5_priv *priv = dev->data->dev_private;struct mlx5_hrxq *hrxq = priv->drop_queue.hrxq; -if (__atomic_sub_fetch (&hrxq->refcnt,1 , __ATOMIC_RELAXED) ==0 ) { - priv->obj_ops.drop_action_destroy (dev); -mlx5_free (priv->drop_queue.rxq); -mlx5_free (hrxq->ind_table); -mlx5_free (hrxq); - priv->drop_queue.rxq =NULL ; - priv->drop_queue.hrxq =NULL ; - } +if (!priv->drop_queue.hrxq) +return ; + priv->obj_ops.drop_action_destroy (dev); +mlx5_free (priv->drop_queue.rxq); +mlx5_free (hrxq->ind_table); +mlx5_free (hrxq); + priv->drop_queue.rxq =NULL ; + priv->drop_queue.hrxq =NULL ; }/**
Signature · 1 line
1.8.3.1
Hi,
Quoted 16 lines
-----Original Message-----
From: Suanming Mou <[email protected]>
Sent: Friday, November 6, 2020 5:08 AM
To: Slava Ovsiienko <[email protected]>; Matan Azrad <[email protected]>
Cc: Raslan Darawsheh <[email protected]>; [email protected]
Subject: [PATCH] net/mlx5: fix shared RSS action releaseAs shared RSS action is global standalone action, the shared action should be maintained only by the shared action management functions.
Currently, the shared RSS action hrxq uses the same fate action type with existed general queues, and implicitly uses the deprecate refcnt increment to indicate the hrxq is in using which leads the hrxq be released when flow is destroyed.
Quoted 8 lines
This commit adds a new fate action type for shared RSS action to handle the shared RSS action release correctly.
Fixes e1592b6c4dea ("net/mlx5: make Rx queue thread safe")Signed-off-by Suanming Mou <[email protected]>Acked-by Matan Azrad <[email protected]>---
Patch applied to next-net-mlx,
Kindest regards,
Raslan Darawsheh
Quoted 8 lines · Suanming Mou
As shared RSS action is global standalone action, the shared action should be maintained only by the shared action management functions.
Currently, the shared RSS action hrxq uses the same fate action type with existed general queues, and implicitly uses the deprecate refcnt increment to indicate the hrxq is in using which leads the hrxq be released when flow is destroyed.
Can you please re-word above paragraph to make it easier to understand?
Thanks,
ferruh
Quoted 7 lines
This commit adds a new fate action type for shared RSS action to handle the shared RSS action release correctly.
Fixes e1592b6c4dea ("net/mlx5: make Rx queue thread safe")Signed-off-by Suanming Mou <[email protected]>Acked-by Matan Azrad <[email protected]>
<...>
Quoted 14 lines
-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Tuesday, November 10, 2020 2:17 AM
To: Suanming Mou <[email protected]>; Slava Ovsiienko <[email protected]>; Matan Azrad <[email protected]>
Cc: Raslan Darawsheh <[email protected]>; [email protected]
Subject: Re: [dpdk-dev] [PATCH] net/mlx5: fix shared RSS action releaseQuoted 3 lines · Suanming Mou
As shared RSS action is global standalone action, the shared action should be maintained only by the shared action management functions.
Quoted 7 lines
Quoted 5 lines
Currently, the shared RSS action hrxq uses the same fate action type with existed general queues, and implicitly uses the deprecate refcnt increment to indicate the hrxq is in using which leads the hrxq be released when flow is destroyed.
Can you please re-word above paragraph to make it easier to understand?
OK, will send V2 with the update.
Quoted 13 lines
Thanks,
ferruhQuoted 7 lines
This commit adds a new fate action type for shared RSS action to handle the shared RSS action release correctly.
Fixes e1592b6c4dea ("net/mlx5: make Rx queue thread safe")Signed-off-by Suanming Mou <[email protected]>Acked-by Matan Azrad <[email protected]><...>
PATCH v2 1/1 net/mlx5: fix shared RSS action release
In reply to Suanming MouAs shared RSS action will be shared by multiple flows, the action is created as global standalone action and managed only by the relevant shared action management functions.
Currently, hrxqs will be created by shared RSS action or general queue action. For hrxqs created by shared RSS action, they should also only be released with shared RSS action. It's not correct to release the shared RSS action hrxqs as general queue actions do in flow destroy.
This commit adds a new fate action type for shared RSS action to handle the shared RSS action hrxq release correctly.
---
v2:
- commit log update.
--- drivers/net/mlx5/mlx5.h | 3 +- drivers/net/mlx5/mlx5_flow.c | 7 ++- drivers/net/mlx5/mlx5_flow.h | 4 +- drivers/net/mlx5/mlx5_flow_dv.c | 88 +++++++++++++++++++++++++------------- drivers/net/mlx5/mlx5_flow_verbs.c | 2 +- drivers/net/mlx5/mlx5_rxq.c | 36 ++++++++-------- 6 files changed, 86 insertions(+), 54 deletions(-)
drivers/net/mlx5/mlx5.h +1 -2
@@ -789,11 +789,11 @@ struct mlx5_flow_rss_desc {uint8_t key[MLX5_RSS_HASH_KEY_LEN ];/**< RSS hash key. */ uint32_t key_len;/**< RSS hash key len. */ uint32_t tunnel;/**< Queue in tunnel. */ +uint32_t shared_rss;/**< Shared RSS index. */ union {uint16_t *queue;/**< Destination queues. */ const uint16_t *const_q;/**< Const pointer convert. */ }; -bool standalone;/**< Queue is standalone or not. */ };#define MLX5_PROC_PRIV (port_id) \
@@ -836,7 +836,6 @@ struct mlx5_ind_table_obj { __extension__ struct mlx5_hrxq { struct mlx5_cache_entry entry; /* Cache entry. */ - uint32_t refcnt; /* Reference counter. */ uint32_t standalone:1; /* This object used in shared action. */ struct mlx5_ind_table_obj *ind_table; /* Indirection table. */ RTE_STD_C11
drivers/net/mlx5/mlx5_flow.c +6 -1
@@ -5622,7 +5622,7 @@ struct tunnel_default_miss_ctx { buf->entries =1 ; buf->entry[0 ].pattern = (void *)(uintptr_t )items; } - flow->shared_rss =flow_get_shared_rss_action (dev, shared_actions, + rss_desc->shared_rss =flow_get_shared_rss_action (dev, shared_actions, shared_actions_n);/* * Record the start index when there is a nested call. All sub-flows
@@ -5729,6 +5729,11 @@ struct tunnel_default_miss_ctx { ret = rte_errno;/* Save rte_errno before cleanup. */ flow_mreg_del_copy_action (dev, flow);flow_drv_destroy (dev, flow); +if (rss_desc->shared_rss) +__atomic_sub_fetch (&((struct mlx5_shared_action_rss *) +mlx5_ipool_get + (priv->sh->ipool[MLX5_IPOOL_RSS_SHARED_ACTIONS ], + rss_desc->shared_rss))->refcnt,1 , __ATOMIC_RELAXED);mlx5_ipool_free (priv->sh->ipool[MLX5_IPOOL_RTE_FLOW ], idx); rte_errno = ret;/* Restore rte_errno. */ ret = rte_errno;
drivers/net/mlx5/mlx5_flow.h +3 -1
@@ -388,6 +388,7 @@ enum mlx5_flow_fate_type {MLX5_FLOW_FATE_PORT_ID ,MLX5_FLOW_FATE_DROP ,MLX5_FLOW_FATE_DEFAULT_MISS , +MLX5_FLOW_FATE_SHARED_RSS , MLX5_FLOW_FATE_MAX, };
@@ -651,6 +652,8 @@ struct mlx5_flow_handle {/**< Generic value indicates the fate action. */ uint32_t rix_default_fate;/**< Indicates default miss fate action. */ +uint32_t rix_srss; +/**< Indicates shared RSS fate action. */ };#ifdef HAVE_IBV_FLOW_DV_SUPPORT struct mlx5_flow_handle_dv dvh;
@@ -1024,7 +1027,6 @@ struct tunnel_tbl_entry {/* Flow structure. */ struct rte_flow {ILIST_ENTRY (uint32_t )next;/**< Index to the next flow structure. */ -uint32_t shared_rss;/** < Shared RSS action ID. */ uint32_t dev_handles;/**< Device flow handles that are part of the flow. */ uint32_t drv_type:2 ;/**< Driver type. */
drivers/net/mlx5/mlx5_flow_dv.c +58 -30
200 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_verbs.c +1 -1
@@ -1972,7 +1972,7 @@ rss_desc->hash_fields = dev_flow->hash_fields; rss_desc->tunnel = !!(handle->layers &MLX5_FLOW_LAYER_TUNNEL ); - rss_desc->standalone = false; + rss_desc->shared_rss =0 ; hrxq_idx =mlx5_hrxq_get (dev, rss_desc); hrxq =mlx5_ipool_get (priv->sh->ipool[MLX5_IPOOL_HRXQ ], hrxq_idx);
drivers/net/mlx5/mlx5_rxq.c +17 -19
@@ -2211,8 +2211,9 @@ struct mlx5_ind_table_obj *struct mlx5_priv *priv = dev->data->dev_private;const uint8_t *rss_key = rss_desc->key;uint32_t rss_key_len = rss_desc->key_len; +bool standalone = !!rss_desc->shared_rss;const uint16_t *queues = - rss_desc->standalone ? rss_desc->const_q : rss_desc->queue; + standalone ? rss_desc->const_q : rss_desc->queue;uint32_t queues_n = rss_desc->queue_num;struct mlx5_hrxq *hrxq =NULL ;uint32_t hrxq_idx =0 ;
@@ -2220,16 +2221,17 @@ struct mlx5_ind_table_obj *int ret; queues_n = rss_desc->hash_fields ? queues_n :1 ; - ind_tbl =mlx5_ind_table_obj_get (dev, queues, queues_n); + ind_tbl = standalone ?NULL : +mlx5_ind_table_obj_get (dev, queues, queues_n);if (!ind_tbl) ind_tbl =mlx5_ind_table_obj_new (dev, queues, queues_n, - rss_desc->standalone); + standalone);if (!ind_tbl)return NULL ; hrxq =mlx5_ipool_zmalloc (priv->sh->ipool[MLX5_IPOOL_HRXQ ], &hrxq_idx);if (!hrxq) goto error; - hrxq->standalone = rss_desc->standalone; + hrxq->standalone = standalone; hrxq->idx = hrxq_idx; hrxq->ind_table = ind_tbl; hrxq->rss_key_len = rss_key_len;
@@ -2240,7 +2242,7 @@ struct mlx5_ind_table_obj * goto error;return hrxq; error: -mlx5_ind_table_obj_release (dev, ind_tbl, rss_desc->standalone); +mlx5_ind_table_obj_release (dev, ind_tbl, standalone);if (hrxq)mlx5_ipool_free (priv->sh->ipool[MLX5_IPOOL_HRXQ ], hrxq_idx);return NULL ;
@@ -2294,7 +2296,7 @@ uint32_t mlx5_hrxq_get(struct rte_eth_dev *dev, .data = rss_desc, }; -if (rss_desc->standalone) { +if (rss_desc->shared_rss) { hrxq =__mlx5_hrxq_create (dev, rss_desc); }else { entry =mlx5_cache_register (&priv->hrxqs, &ctx);
@@ -2344,11 +2346,8 @@ struct mlx5_hrxq *struct mlx5_hrxq *hrxq =NULL ;int ret; -if (priv->drop_queue.hrxq) { -__atomic_fetch_add (&priv->drop_queue.hrxq->refcnt,1 , - __ATOMIC_RELAXED); +if (priv->drop_queue.hrxq)return priv->drop_queue.hrxq; - } hrxq =mlx5_malloc (MLX5_MEM_ZERO ,sizeof (*hrxq),0 ,SOCKET_ID_ANY );if (!hrxq) { DRV_LOG(WARNING,
@@ -2367,7 +2366,6 @@ struct mlx5_hrxq * ret = priv->obj_ops.drop_action_create (dev);if (ret <0 ) goto error; -__atomic_store_n (&hrxq->refcnt,1 , __ATOMIC_RELAXED);return hrxq; error:if (hrxq) {
@@ -2391,14 +2389,14 @@ struct mlx5_hrxq *struct mlx5_priv *priv = dev->data->dev_private;struct mlx5_hrxq *hrxq = priv->drop_queue.hrxq; -if (__atomic_sub_fetch (&hrxq->refcnt,1 , __ATOMIC_RELAXED) ==0 ) { - priv->obj_ops.drop_action_destroy (dev); -mlx5_free (priv->drop_queue.rxq); -mlx5_free (hrxq->ind_table); -mlx5_free (hrxq); - priv->drop_queue.rxq =NULL ; - priv->drop_queue.hrxq =NULL ; - } +if (!priv->drop_queue.hrxq) +return ; + priv->obj_ops.drop_action_destroy (dev); +mlx5_free (priv->drop_queue.rxq); +mlx5_free (hrxq->ind_table); +mlx5_free (hrxq); + priv->drop_queue.rxq =NULL ; + priv->drop_queue.hrxq =NULL ; }/**
Signature · 1 line
1.8.3.1
Ferruh Yigit
AppliedQuoted 10 lines · Suanming Mou
As shared RSS action will be shared by multiple flows, the action is created as global standalone action and managed only by the relevant shared action management functions.
Currently, hrxqs will be created by shared RSS action or general queue action. For hrxqs created by shared RSS action, they should also only be released with shared RSS action. It's not correct to release the shared RSS action hrxqs as general queue actions do in flow destroy.
Quoted 7 lines
This commit adds a new fate action type for shared RSS action to handle the shared RSS action hrxq release correctly.
Fixes e1592b6c4dea ("net/mlx5: make Rx queue thread safe")Signed-off-by Suanming Mou <[email protected]>Acked-by Matan Azrad <[email protected]>
Applied to dpdk-next-net/main, thanks.