net/mlx5: make counter thread safe
cover net/mlx5: make counter thread safe
The mlx5 PMD is going to support multiple-thread flow operations. This patch set makes the counter action to be thread safe.
Suanming Mou (6):
net/mlx5: locate aging pools in the general container net/mlx5: optimize shared counter memory net/mlx5: remove single counter container net/mlx5: synchronize flow counter pool creation net/mlx5: make three level table thread safe net/mlx5: make shared counters thread safe
drivers/net/mlx5/linux/mlx5_os.c | 36 ++- drivers/net/mlx5/mlx5.c | 38 ++- drivers/net/mlx5/mlx5.h | 81 +++--- drivers/net/mlx5/mlx5_flow.c | 266 +++++++++++++----- drivers/net/mlx5/mlx5_flow.h | 2 + drivers/net/mlx5/mlx5_flow_dv.c | 555 ++++++++++--------------------------- drivers/net/mlx5/mlx5_flow_verbs.c | 78 +++--- drivers/net/mlx5/mlx5_utils.c | 144 +++++++--- drivers/net/mlx5/mlx5_utils.h | 52 ++-- 9 files changed, 618 insertions(+), 634 deletions(-)
Signature · 1 line
1.8.3.1
PATCH 1/6 net/mlx5: locate aging pools in the general container
Commit [1] introduced different container for the aging counter pools. In order to save container memory the aging counter pools can be located in the general pool container.
This patch locates the aging counter pools in the general pool container. Remove the aging container management.
[1] commit fd143711a6ea ("net/mlx5: separate aging counter pool range")
--- drivers/net/mlx5/mlx5.c | 7 ++-- drivers/net/mlx5/mlx5.h | 17 +++++---- drivers/net/mlx5/mlx5_flow.c | 19 +++------- drivers/net/mlx5/mlx5_flow_dv.c | 78 ++++++++++++++++++-------------------- drivers/net/mlx5/mlx5_flow_verbs.c | 4 +- 5 files changed, 57 insertions(+), 68 deletions(-)
drivers/net/mlx5/mlx5.c +4 -3
@@ -458,7 +458,7 @@ struct mlx5_flow_id_pool *static void mlx5_flow_counters_mng_init (struct mlx5_dev_ctx_shared *sh) { -int i; +int i, j;memset (&sh->cmng,0 ,sizeof (sh->cmng));TAILQ_INIT (&sh->cmng.flow_counters);
@@ -468,7 +468,8 @@ struct mlx5_flow_id_pool * sh->cmng.ccont[i].last_pool_idx =POOL_IDX_INVALID ;TAILQ_INIT (&sh->cmng.ccont[i].pool_list);rte_spinlock_init (&sh->cmng.ccont[i].resize_sl); -TAILQ_INIT (&sh->cmng.ccont[i].counters); +for (j =0 ; j <MLX5_COUNTER_TYPE_MAX ; j++) +TAILQ_INIT (&sh->cmng.ccont[i].counters[j]);rte_spinlock_init (&sh->cmng.ccont[i].csl); } }
@@ -513,7 +514,7 @@ struct mlx5_flow_id_pool * }for (i =0 ; i <MLX5_CCONT_TYPE_MAX ; ++i) {struct mlx5_flow_counter_pool *pool; -uint32_t batch = !!(i >1 ); +uint32_t batch = (i ==MLX5_CCONT_TYPE_BATCH );if (!sh->cmng.ccont[i].pools)continue ;
drivers/net/mlx5/mlx5.h +9 -8
@@ -270,7 +270,6 @@ struct mlx5_drop {#define MLX5_COUNTERS_PER_POOL 512#define MLX5_MAX_PENDING_QUERIES 4#define MLX5_CNT_CONTAINER_RESIZE 64 -#define MLX5_CNT_AGE_OFFSET 0x80000000#define CNT_SIZE (sizeof(struct mlx5_flow_counter))#define CNTEXT_SIZE (sizeof(struct mlx5_flow_counter_ext))#define AGE_SIZE (sizeof(struct mlx5_age_param))
@@ -279,7 +278,6 @@ struct mlx5_drop {#define CNT_POOL_TYPE_AGE (1 << 1)#define IS_EXT_POOL (pool) (((pool)->type) & CNT_POOL_TYPE_EXT)#define IS_AGE_POOL (pool) (((pool)->type) & CNT_POOL_TYPE_AGE) -#define MLX_CNT_IS_AGE (counter) ((counter) & MLX5_CNT_AGE_OFFSET ? 1 : 0)#define MLX5_CNT_LEN (pool) \ (CNT_SIZE + \ (IS_AGE_POOL(pool) ? AGE_SIZE : 0) + \
@@ -322,17 +320,20 @@ enum { AGE_TMOUT, /* Timeout, wait for rte_flow_get_aged_flows and destroy. */ }; -#define MLX5_CNT_CONTAINER (sh, batch, age) (&(sh)->cmng.ccont \ - [(batch) * 2 + (age)]) +#define MLX5_CNT_CONTAINER (sh, batch) (&(sh)->cmng.ccont[batch])enum {MLX5_CCONT_TYPE_SINGLE , -MLX5_CCONT_TYPE_SINGLE_FOR_AGE ,MLX5_CCONT_TYPE_BATCH , -MLX5_CCONT_TYPE_BATCH_FOR_AGE ,MLX5_CCONT_TYPE_MAX , }; +enum mlx5_counter_type { +MLX5_COUNTER_TYPE_ORIGIN , +MLX5_COUNTER_TYPE_AGE , +MLX5_COUNTER_TYPE_MAX , +}; +/* Counter age parameter. */ struct mlx5_age_param {rte_atomic16_t state;/**< Age state. */
@@ -427,7 +428,8 @@ struct mlx5_pools_container {int max_id;/* The maximum counter ID in the pools. */ rte_spinlock_t resize_sl;/* The resize lock. */ rte_spinlock_t csl;/* The counter free list lock. */ -struct mlx5_counters counters;/* Free counter list. */ +struct mlx5_counters counters[MLX5_COUNTER_TYPE_MAX ]; +/* Free counter list. */ struct mlx5_counter_pools pool_list;/* Counter pool list. */ struct mlx5_flow_counter_pool **pools;/* Counter pool array. */ struct mlx5_counter_stats_mem_mng *mem_mng;
@@ -441,7 +443,6 @@ struct mlx5_flow_counter_mng {uint8_t pending_queries;uint8_t batch;uint16_t pool_index; -uint8_t age;uint8_t query_thread_on; LIST_HEAD(mem_mngs, mlx5_counter_stats_mem_mng) mem_mngs; LIST_HEAD(stat_raws, mlx5_counter_stats_raw) free_stat_raws;
drivers/net/mlx5/mlx5_flow.c +6 -13
@@ -5940,7 +5940,6 @@ struct mlx5_meter_domains_infos *uint16_t offset;int ret;uint8_t batch = sh->cmng.batch; -uint8_t age = sh->cmng.age;uint16_t pool_index = sh->cmng.pool_index;struct mlx5_pools_container *cont;struct mlx5_flow_counter_pool *pool;
@@ -5949,7 +5948,7 @@ struct mlx5_meter_domains_infos *if (sh->cmng.pending_queries >=MLX5_MAX_PENDING_QUERIES ) goto set_alarm; next_container: - cont =MLX5_CNT_CONTAINER (sh, batch, age); + cont =MLX5_CNT_CONTAINER (sh, batch);rte_spinlock_lock (&cont->resize_sl);if (!cont->pools) {rte_spinlock_unlock (&cont->resize_sl);
@@ -5958,11 +5957,6 @@ struct mlx5_meter_domains_infos * goto set_alarm; batch ^=0x1 ; pool_index =0 ; -if (batch ==0 && pool_index ==0 ) { - age ^=0x1 ; - sh->cmng.batch = batch; - sh->cmng.age = age; - } goto next_container; } pool = cont->pools[pool_index];
@@ -6011,13 +6005,10 @@ struct mlx5_meter_domains_infos *if (pool_index >=rte_atomic16_read (&cont->n_valid)) { batch ^=0x1 ; pool_index =0 ; -if (batch ==0 && pool_index ==0 ) - age ^=0x1 ; } set_alarm: sh->cmng.batch = batch; sh->cmng.pool_index = pool_index; - sh->cmng.age = age;mlx5_set_query_alarm (sh); }
@@ -6103,10 +6094,12 @@ struct mlx5_meter_domains_infos *struct mlx5_flow_counter_pool *pool = (struct mlx5_flow_counter_pool *)(uintptr_t )async_id;struct mlx5_counter_stats_raw *raw_to_free; -uint8_t age = !!IS_AGE_POOL (pool);uint8_t query_gen = pool->query_gen ^1 ;struct mlx5_pools_container *cont = -MLX5_CNT_CONTAINER (sh, !IS_EXT_POOL (pool), age); +MLX5_CNT_CONTAINER (sh, !IS_EXT_POOL (pool)); +enum mlx5_counter_type cnt_type = +IS_AGE_POOL (pool) ?MLX5_COUNTER_TYPE_AGE : +MLX5_COUNTER_TYPE_ORIGIN ;if (unlikely (status)) { raw_to_free = pool->raw_hw;
@@ -6121,7 +6114,7 @@ struct mlx5_meter_domains_infos *rte_io_wmb ();if (!TAILQ_EMPTY (&pool->counters[query_gen])) {rte_spinlock_lock (&cont->csl); -TAILQ_CONCAT (&cont->counters, +TAILQ_CONCAT (&cont->counters[cnt_type], &pool->counters[query_gen], next);rte_spinlock_unlock (&cont->csl); }
drivers/net/mlx5/mlx5_flow_dv.c +36 -42
173 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_verbs.c +2 -2
@@ -159,7 +159,7 @@ struct mlx5_flow_counter_pool **ppool) {struct mlx5_priv *priv = dev->data->dev_private; -struct mlx5_pools_container *cont =MLX5_CNT_CONTAINER (priv->sh,0 ,0 ); +struct mlx5_pools_container *cont =MLX5_CNT_CONTAINER (priv->sh,0 );struct mlx5_flow_counter_pool *pool; idx--;
@@ -254,7 +254,7 @@ flow_verbs_counter_new(struct rte_eth_dev *dev, uint32_t shared, uint32_t id) { struct mlx5_priv *priv = dev->data->dev_private; -struct mlx5_pools_container *cont =MLX5_CNT_CONTAINER (priv->sh,0 ,0 ); +struct mlx5_pools_container *cont =MLX5_CNT_CONTAINER (priv->sh,0 );struct mlx5_flow_counter_pool *pool =NULL ;struct mlx5_flow_counter_ext *cnt_ext =NULL ;struct mlx5_flow_counter *cnt =NULL ;
Signature · 1 line
1.8.3.1
PATCH 2/6 net/mlx5: optimize shared counter memory
In reply to Suanming MouCurrently, when a counter is allocated, the counter list entry memory will not be used until the counter is released and added back to the counter container free list. In this case, if a counter is allocated as shared counter, the shared information can be save to the counter list entry memory. This adjustment engages to save more memory for the shared counter.
One more thing is that now the shared counter is only available for single counter as shared counter may be applied to both root and none root table, but batch counter with offset is not supported in root table in some old OFED version. The batch counter with offset is now fully supported in the current OFED. This commit is also the initialize change for the batch counter with offeset can be shared in the later change.
--- drivers/net/mlx5/mlx5.h | 33 +++++++++------- drivers/net/mlx5/mlx5_flow_dv.c | 78 +++++++++++++++----------------------- drivers/net/mlx5/mlx5_flow_verbs.c | 60 +++++++++++++++++------------ 3 files changed, 86 insertions(+), 85 deletions(-)
drivers/net/mlx5/mlx5.h +20 -13
@@ -270,6 +270,10 @@ struct mlx5_drop {#define MLX5_COUNTERS_PER_POOL 512#define MLX5_MAX_PENDING_QUERIES 4#define MLX5_CNT_CONTAINER_RESIZE 64 +#define MLX5_CNT_SHARED_OFFSET 0x80000000 +#define IS_SHARED_CNT (cnt) (!!((cnt) & MLX5_CNT_SHARED_OFFSET)) +#define IS_BATCH_CNT (cnt) (((cnt) & (MLX5_CNT_SHARED_OFFSET - 1)) >= \ + MLX5_CNT_BATCH_OFFSET)#define CNT_SIZE (sizeof(struct mlx5_flow_counter))#define CNTEXT_SIZE (sizeof(struct mlx5_flow_counter_ext))#define AGE_SIZE (sizeof(struct mlx5_age_param))
@@ -348,11 +352,21 @@ struct flow_counter_stats {uint64_t bytes; }; +/* Shared counters information for counters. */ +struct mlx5_flow_counter_shared { +uint32_t ref_cnt;/**< Reference counter. */ +uint32_t id;/**< User counter ID. */ +}; +struct mlx5_flow_counter_pool ;/* Generic counters information. */ struct mlx5_flow_counter { -TAILQ_ENTRY (mlx5_flow_counter) next; -/**< Pointer to the next flow counter structure. */ +union { +TAILQ_ENTRY (mlx5_flow_counter) next; +/**< Pointer to the next flow counter structure. */ +struct mlx5_flow_counter_shared shared_info; +/**< Shared counter information. */ + };union {uint64_t hits;/**< Reset value of hits packets. */ struct mlx5_flow_counter_pool *pool;/**< Counter pool. */
@@ -361,22 +375,15 @@ struct mlx5_flow_counter {void *action;/**< Pointer to the dv action. */ }; -/* Extend counters information for none batch counters. */ +/* Extend counters information for none batch fallback counters. */ struct mlx5_flow_counter_ext { -uint32_t shared:1 ;/**< Share counter ID with other flow rules. */ -uint32_t batch:1 ;uint32_t skipped:1 ;/* This counter is skipped or not. */ -/**< Whether the counter was allocated by batch command. */ -uint32_t ref_cnt:29 ;/**< Reference counter. */ -uint32_t id;/**< User counter ID. */ -union {/**< Holds the counters for the rule. */ #if defined(HAVE_IBV_DEVICE_COUNTERS_SET_V42 ) -struct ibv_counter_set *cs; +struct ibv_counter_set *cs;#elif defined(HAVE_IBV_DEVICE_COUNTERS_SET_V45 ) -struct ibv_counters *cs; +struct ibv_counters *cs;#endif -struct mlx5_devx_obj *dcs;/**< Counter Devx object. */ - }; +struct mlx5_devx_obj *dcs;/**< Counter Devx object. */ };TAILQ_HEAD (mlx5_counters, mlx5_flow_counter);
drivers/net/mlx5/mlx5_flow_dv.c +31 -47
130 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_verbs.c +35 -25
104 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH 3/6 net/mlx5: remove single counter container
In reply to Suanming MouA flow counter which was allocated by a batch API couldn't be assigned to a flow in the root table (group 0) in old rdma-core version. Hence, a root table flow counter required PMD mechanism to manage counters which were allocated singly.
Currently, the batch counters have already been supported in root table includes a new rdma-core version with MLX5_FLOW_ACTION_COUNTER_OFFSET enum and with a kernel driver includes MLX5_IB_ATTR_CREATE_FLOW_ARR_COUNTERS_DEVX_OFFSET enum.
When the PMD uses rdma-core API to assign a batch counter to a root table flow using invalid counter offset, it should get an error only if the batch counter assignment for root table is supported. Using this trial in the initialization time can help to detect the support.
Using the above trial, if the support is valid, remove the management of single counter container in the fast counter mechanism. Otherwise, move the counter mechanism to fallback mode.
--- drivers/net/mlx5/linux/mlx5_os.c | 36 +++- drivers/net/mlx5/mlx5.c | 39 ++--- drivers/net/mlx5/mlx5.h | 27 +-- drivers/net/mlx5/mlx5_flow.c | 152 ++++++++++------- drivers/net/mlx5/mlx5_flow.h | 2 + drivers/net/mlx5/mlx5_flow_dv.c | 337 +++++++++++++------------------------ drivers/net/mlx5/mlx5_flow_verbs.c | 26 +-- 7 files changed, 273 insertions(+), 346 deletions(-)
drivers/net/mlx5/linux/mlx5_os.c +28 -8
@@ -512,6 +512,32 @@ }/** +* DV flow counter mode detect and config. +* +* @param dev +* Pointer to rte_eth_dev structure. +* +*/ +static void +mlx5_flow_counter_mode_config (struct rte_eth_dev *dev) +{ +struct mlx5_priv *priv = dev->data->dev_private; + +/* If devx is not supported, counters are not working. */ +if (!priv->config.devx) +return ; + priv->counter_fallback =0 ; +if (!priv->config.hca_attr.flow_counters_dump || + (mlx5_flow_discover_counter_offset_support (dev) == -ENOTSUP )) + priv->counter_fallback =1 ; +#ifndef HAVE_IBV_DEVX_ASYNC + priv->counter_fallback =1 ; +#endif +if (priv->counter_fallback) +DRV_LOG (INFO ,"Use fall-back DV counter management" ); +} + +/** * Spawn an Ethernet device from Verbs information. * * @param dpdk_dev
@@ -979,19 +1005,11 @@DRV_LOG (INFO ,"Rx CQE padding is enabled" ); }if (config->devx) { - priv->counter_fallback =0 ; err =mlx5_devx_cmd_query_hca_attr (sh->ctx, &config->hca_attr);if (err) { err = -err; goto error; } -if (!config->hca_attr.flow_counters_dump) - priv->counter_fallback =1 ; -#ifndef HAVE_IBV_DEVX_ASYNC - priv->counter_fallback =1 ; -#endif -if (priv->counter_fallback) -DRV_LOG (INFO ,"Use fall-back DV counter management" );/* Check for LRO support. */ if (config->dest_tir && config->hca_attr.lro_cap && config->dv_flow_en) {
@@ -1364,6 +1382,8 @@ goto error; } } +if (priv->config.dv_flow_en) +mlx5_flow_counter_mode_config (eth_dev);return eth_dev; error:if (priv) {
drivers/net/mlx5/mlx5.c +17 -22
@@ -458,20 +458,18 @@ struct mlx5_flow_id_pool *static void mlx5_flow_counters_mng_init (struct mlx5_dev_ctx_shared *sh) { -int i, j; +int i;memset (&sh->cmng,0 ,sizeof (sh->cmng));TAILQ_INIT (&sh->cmng.flow_counters); -for (i =0 ; i <MLX5_CCONT_TYPE_MAX ; ++i) { - sh->cmng.ccont[i].min_id =MLX5_CNT_BATCH_OFFSET ; - sh->cmng.ccont[i].max_id =-1 ; - sh->cmng.ccont[i].last_pool_idx =POOL_IDX_INVALID ; -TAILQ_INIT (&sh->cmng.ccont[i].pool_list); -rte_spinlock_init (&sh->cmng.ccont[i].resize_sl); -for (j =0 ; j <MLX5_COUNTER_TYPE_MAX ; j++) -TAILQ_INIT (&sh->cmng.ccont[i].counters[j]); -rte_spinlock_init (&sh->cmng.ccont[i].csl); - } + sh->cmng.min_id =MLX5_CNT_BATCH_OFFSET ; + sh->cmng.max_id =-1 ; + sh->cmng.last_pool_idx =POOL_IDX_INVALID ; +TAILQ_INIT (&sh->cmng.pool_list); +rte_spinlock_init (&sh->cmng.resize_sl); +for (i =0 ; i <MLX5_COUNTER_TYPE_MAX ; i++) +TAILQ_INIT (&sh->cmng.counters[i]); +rte_spinlock_init (&sh->cmng.csl); }/**
@@ -501,7 +499,6 @@ struct mlx5_flow_id_pool * mlx5_flow_counters_mng_close(struct mlx5_dev_ctx_shared *sh) {struct mlx5_counter_stats_mem_mng *mng; -int i;int j;int retries =1024 ;
@@ -512,15 +509,13 @@ struct mlx5_flow_id_pool *break ;rte_pause (); } -for (i =0 ; i <MLX5_CCONT_TYPE_MAX ; ++i) { + +if (sh->cmng.pools) {struct mlx5_flow_counter_pool *pool; -uint32_t batch = (i ==MLX5_CCONT_TYPE_BATCH ); -if (!sh->cmng.ccont[i].pools) -continue ; - pool =TAILQ_FIRST (&sh->cmng.ccont[i].pool_list); + pool =TAILQ_FIRST (&sh->cmng.pool_list);while (pool) { -if (batch && pool->min_dcs) +if (!IS_EXT_POOL (pool) && pool->min_dcs)claim_zero (mlx5_devx_cmd_destroy (pool->min_dcs));for (j =0 ; j <MLX5_COUNTERS_PER_POOL ; ++j) {
@@ -529,17 +524,17 @@ struct mlx5_flow_id_pool * (mlx5_glue->destroy_flow_action (MLX5_POOL_GET_CNT (pool, j)->action)); -if (!batch &&MLX5_GET_POOL_CNT_EXT +if (IS_EXT_POOL (pool) &&MLX5_GET_POOL_CNT_EXT (pool, j)->dcs)claim_zero (mlx5_devx_cmd_destroy (MLX5_GET_POOL_CNT_EXT (pool, j)->dcs)); } -TAILQ_REMOVE (&sh->cmng.ccont[i].pool_list, pool, next); +TAILQ_REMOVE (&sh->cmng.pool_list, pool, next);mlx5_free (pool); - pool =TAILQ_FIRST (&sh->cmng.ccont[i].pool_list); + pool =TAILQ_FIRST (&sh->cmng.pool_list); } -mlx5_free (sh->cmng.ccont[i].pools); +mlx5_free (sh->cmng.pools); } mng =LIST_FIRST (&sh->cmng.mem_mngs);while (mng) {
drivers/net/mlx5/mlx5.h +7 -20
@@ -280,8 +280,10 @@ struct mlx5_drop {#define MLX5_AGING_TIME_DELAY 7#define CNT_POOL_TYPE_EXT (1 << 0)#define CNT_POOL_TYPE_AGE (1 << 1) +#define IS_EXT_POOL (pool) (((pool)->type) & CNT_POOL_TYPE_EXT)#define IS_AGE_POOL (pool) (((pool)->type) & CNT_POOL_TYPE_AGE) +#define MLX5_CNT_LEN (pool) \ (CNT_SIZE + \ (IS_AGE_POOL(pool) ? AGE_SIZE : 0) + \
@@ -324,14 +326,6 @@ enum { AGE_TMOUT, /* Timeout, wait for rte_flow_get_aged_flows and destroy. */ }; -#define MLX5_CNT_CONTAINER (sh, batch) (&(sh)->cmng.ccont[batch]) - -enum { -MLX5_CCONT_TYPE_SINGLE , -MLX5_CCONT_TYPE_BATCH , -MLX5_CCONT_TYPE_MAX , -}; -enum mlx5_counter_type {MLX5_COUNTER_TYPE_ORIGIN ,MLX5_COUNTER_TYPE_AGE ,
@@ -377,7 +371,6 @@ struct mlx5_flow_counter {/* Extend counters information for none batch fallback counters. */ struct mlx5_flow_counter_ext { -uint32_t skipped:1 ;/* This counter is skipped or not. */ #if defined(HAVE_IBV_DEVICE_COUNTERS_SET_V42 )struct ibv_counter_set *cs;#elif defined(HAVE_IBV_DEVICE_COUNTERS_SET_V45 )
@@ -397,9 +390,8 @@ struct mlx5_flow_counter_pool {rte_atomic64_t a64_dcs; };/* The devx object of the minimum counter ID. */ - uint32_t index:28; /* Pool index in container. */ + uint32_t index:29; /* Pool index in container. */ uint32_t type:2; /* Memory type behind the counter array. */ - uint32_t skip_cnt:1; /* Pool contains skipped counter. */ volatile uint32_t query_gen:1; /* Query round. */rte_spinlock_t sl;/* The pool lock. */ struct mlx5_counter_stats_raw *raw;
@@ -419,15 +411,14 @@ struct mlx5_counter_stats_mem_mng {/* Raw memory structure for the counter statistics values of a pool. */ struct mlx5_counter_stats_raw {LIST_ENTRY (mlx5_counter_stats_raw) next; -int min_dcs_id;struct mlx5_counter_stats_mem_mng *mem_mng;volatile struct flow_counter_stats *data; };TAILQ_HEAD (mlx5_counter_pools, mlx5_flow_counter_pool); -/* Container structure for counter pools. */ -struct mlx5_pools_container { +/* Counter global management structure. */ +struct mlx5_flow_counter_mng {rte_atomic16_t n_valid;/* Number of valid pools. */ uint16_t n;/* Number of pools. */ uint16_t last_pool_idx;/* Last used pool index */
@@ -441,14 +432,8 @@ struct mlx5_pools_container {struct mlx5_flow_counter_pool **pools;/* Counter pool array. */ struct mlx5_counter_stats_mem_mng *mem_mng;/* Hold the memory management for the next allocated pools raws. */ -}; - -/* Counter global management structure. */ -struct mlx5_flow_counter_mng { -struct mlx5_pools_container ccont[MLX5_CCONT_TYPE_MAX ];struct mlx5_counters flow_counters;/* Legacy flow counter list. */ uint8_t pending_queries; -uint8_t batch;uint16_t pool_index;uint8_t query_thread_on; LIST_HEAD(mem_mngs, mlx5_counter_stats_mem_mng) mem_mngs;
@@ -838,6 +823,8 @@ struct mlx5_priv {struct mlx5_flow_meters flow_meters;/* MTR list. */ uint8_t skip_default_rss_reta;/* Skip configuration of default reta. */ uint8_t fdb_def_rule;/* Whether fdb jump to table 1 is configured. */ +void *cnt_action;/* Counter action to validate invalid offset. */ +struct mlx5_devx_obj *cnt_dcs;/* Counter validate devx object. */ struct mlx5_mp_id mp_id;/* ID of a multi-process process */ LIST_HEAD(fdir, mlx5_fdir_flow) fdir_flows; /* fdir flows. */ };
drivers/net/mlx5/mlx5_flow.c +91 -61
221 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow.h +2 -0
@@ -35,6 +35,7 @@ enum mlx5_rte_flow_action_type {MLX5_RTE_FLOW_ACTION_TYPE_MARK ,MLX5_RTE_FLOW_ACTION_TYPE_COPY_MREG ,MLX5_RTE_FLOW_ACTION_TYPE_DEFAULT_MISS , + MLX5_RTE_FLOW_ACTION_TYPE_COUNT, };/* Matches on selected register. */
@@ -1069,4 +1070,5 @@ int mlx5_flow_destroy_policer_rules(struct rte_eth_dev *dev, const struct rte_flow_attr *attr);int mlx5_flow_meter_flush (struct rte_eth_dev *dev,struct rte_mtr_error *error); +int mlx5_flow_discover_counter_offset_support (struct rte_eth_dev *dev);#endif /* RTE_PMD_MLX5_FLOW_H_ */
drivers/net/mlx5/mlx5_flow_dv.c +115 -222
589 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_verbs.c +13 -13
@@ -159,11 +159,11 @@ struct mlx5_flow_counter_pool **ppool) {struct mlx5_priv *priv = dev->data->dev_private; -struct mlx5_pools_container *cont =MLX5_CNT_CONTAINER (priv->sh,0 ); +struct mlx5_flow_counter_mng *cmng = &priv->sh->cmng;struct mlx5_flow_counter_pool *pool; idx = (idx -1 ) & (MLX5_CNT_SHARED_OFFSET -1 ); - pool = cont->pools[idx /MLX5_COUNTERS_PER_POOL ]; + pool = cmng->pools[idx /MLX5_COUNTERS_PER_POOL ];MLX5_ASSERT (pool);if (ppool) *ppool = pool;
@@ -254,12 +254,12 @@ flow_verbs_counter_new(struct rte_eth_dev *dev, uint32_t shared, uint32_t id) { struct mlx5_priv *priv = dev->data->dev_private; -struct mlx5_pools_container *cont =MLX5_CNT_CONTAINER (priv->sh,0 ); +struct mlx5_flow_counter_mng *cmng = &priv->sh->cmng;struct mlx5_flow_counter_pool *pool =NULL ;struct mlx5_flow_counter_ext *cnt_ext =NULL ;struct mlx5_flow_counter *cnt =NULL ;union mlx5_l3t_data data; -uint32_t n_valid =rte_atomic16_read (&cont->n_valid); +uint32_t n_valid =rte_atomic16_read (&cmng->n_valid);uint32_t pool_idx, cnt_idx;uint32_t i;int ret;
@@ -275,7 +275,7 @@return data.dword; }for (pool_idx =0 ; pool_idx < n_valid; ++pool_idx) { - pool = cont->pools[pool_idx]; + pool = cmng->pools[pool_idx];if (!pool)continue ; cnt =TAILQ_FIRST (&pool->counters[0 ]);
@@ -286,7 +286,7 @@struct mlx5_flow_counter_pool **pools;uint32_t size; -if (n_valid == cont->n) { +if (n_valid == cmng->n) {/* Resize the container pool array. */ size =sizeof (struct mlx5_flow_counter_pool *) * (n_valid +MLX5_CNT_CONTAINER_RESIZE );
@@ -295,13 +295,13 @@if (!pools)return 0 ;if (n_valid) { -memcpy (pools, cont->pools, +memcpy (pools, cmng->pools,sizeof (struct mlx5_flow_counter_pool *) * n_valid); -mlx5_free (cont->pools); +mlx5_free (cmng->pools); } - cont->pools = pools; - cont->n +=MLX5_CNT_CONTAINER_RESIZE ; + cmng->pools = pools; + cmng->n +=MLX5_CNT_CONTAINER_RESIZE ; }/* Allocate memory for new pool*/ size = sizeof(*pool) + (sizeof(*cnt_ext) + sizeof(*cnt)) *
@@ -315,10 +315,10 @@TAILQ_INSERT_HEAD (&pool->counters[0 ], cnt, next); } cnt =MLX5_POOL_GET_CNT (pool,0 ); - cont->pools[n_valid] = pool; + cmng->pools[n_valid] = pool; pool_idx = n_valid; -rte_atomic16_add (&cont->n_valid,1 ); -TAILQ_INSERT_HEAD (&cont->pool_list, pool, next); +rte_atomic16_add (&cmng->n_valid,1 ); +TAILQ_INSERT_HEAD (&cmng->pool_list, pool, next); } i =MLX5_CNT_ARRAY_IDX (pool, cnt); cnt_idx =MLX5_MAKE_CNT_IDX (pool_idx, i);
Signature · 1 line
1.8.3.1
PATCH 4/6 net/mlx5: synchronize flow counter pool creation
In reply to Suanming MouCurrently, counter operations are not thread safe as the counter pools' array resize is not protected.
This commit protects the container pools' array resize using a spinlock. The original counter pool statistic memory allocate is moved to the host thread in order to minimize the critical section. Since that pool statistic memory is required only in query time. The container pools' array should be resized by the user threads, the new pool may be used by other rte_flow APIs before the host thread resize is done, if the pool is not saved to the pools' array, the specified counter memory will not be found as the pool is not saved to the counter management pool array. The pool raw statistic memory will be filled in host thread.
The shared counters will be protected in other commit.
--- drivers/net/mlx5/mlx5.c | 12 ++- drivers/net/mlx5/mlx5.h | 11 ++- drivers/net/mlx5/mlx5_flow.c | 127 ++++++++++++++++++++++++++++++-- drivers/net/mlx5/mlx5_flow_dv.c | 146 ++++++------------------------------- drivers/net/mlx5/mlx5_flow_verbs.c | 5 +- 5 files changed, 160 insertions(+), 141 deletions(-)
drivers/net/mlx5/mlx5.c +5 -7
@@ -465,8 +465,7 @@ struct mlx5_flow_id_pool * sh->cmng.min_id =MLX5_CNT_BATCH_OFFSET ; sh->cmng.max_id =-1 ; sh->cmng.last_pool_idx =POOL_IDX_INVALID ; -TAILQ_INIT (&sh->cmng.pool_list); -rte_spinlock_init (&sh->cmng.resize_sl); +rte_spinlock_init (&sh->cmng.pool_update_sl);for (i =0 ; i <MLX5_COUNTER_TYPE_MAX ; i++)TAILQ_INIT (&sh->cmng.counters[i]);rte_spinlock_init (&sh->cmng.csl);
@@ -499,7 +498,7 @@ struct mlx5_flow_id_pool * mlx5_flow_counters_mng_close(struct mlx5_dev_ctx_shared *sh) {struct mlx5_counter_stats_mem_mng *mng; -int j; +int i, j;int retries =1024 ; rte_errno =0 ;
@@ -512,9 +511,10 @@ struct mlx5_flow_id_pool *if (sh->cmng.pools) {struct mlx5_flow_counter_pool *pool; +int n_valid = sh->cmng.n_valid; - pool =TAILQ_FIRST (&sh->cmng.pool_list); -while (pool) { +for (i =0 ; i < n_valid; ++i) { + pool = sh->cmng.pools[i];if (!IS_EXT_POOL (pool) && pool->min_dcs)claim_zero (mlx5_devx_cmd_destroy (pool->min_dcs));
@@ -530,9 +530,7 @@ struct mlx5_flow_id_pool * (MLX5_GET_POOL_CNT_EXT (pool, j)->dcs)); } -TAILQ_REMOVE (&sh->cmng.pool_list, pool, next);mlx5_free (pool); - pool =TAILQ_FIRST (&sh->cmng.pool_list); }mlx5_free (sh->cmng.pools); }
drivers/net/mlx5/mlx5.h +7 -4
@@ -395,7 +395,11 @@ struct mlx5_flow_counter_pool { volatile uint32_t query_gen:1; /* Query round. */rte_spinlock_t sl;/* The pool lock. */ struct mlx5_counter_stats_raw *raw; -struct mlx5_counter_stats_raw *raw_hw;/* The raw on HW working. */ +union { +struct rte_eth_dev *dev;/* The counter pool create device. */ +struct mlx5_counter_stats_raw *raw_hw; +/* The raw on HW working. */ + }; };struct mlx5_counter_stats_raw ;
@@ -419,16 +423,15 @@ struct mlx5_counter_stats_raw {/* Counter global management structure. */ struct mlx5_flow_counter_mng { -rte_atomic16_t n_valid;/* Number of valid pools. */ +volatile uint16_t n_valid;/* Number of valid pools. */ uint16_t n;/* Number of pools. */ uint16_t last_pool_idx;/* Last used pool index */ int min_id;/* The minimum counter ID in the pools. */ int max_id;/* The maximum counter ID in the pools. */ -rte_spinlock_t resize_sl;/* The resize lock. */ +rte_spinlock_t pool_update_sl;/* The pool update lock. */ rte_spinlock_t csl;/* The counter free list lock. */ struct mlx5_counters counters[MLX5_COUNTER_TYPE_MAX ];/* Free counter list. */ -struct mlx5_counter_pools pool_list;/* Counter pool list. */ struct mlx5_flow_counter_pool **pools;/* Counter pool array. */ struct mlx5_counter_stats_mem_mng *mem_mng;/* Hold the memory management for the next allocated pools raws. */
drivers/net/mlx5/mlx5_flow.c +122 -5
170 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_dv.c +24 -122
207 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_verbs.c +2 -3
@@ -259,7 +259,7 @@struct mlx5_flow_counter_ext *cnt_ext =NULL ;struct mlx5_flow_counter *cnt =NULL ;union mlx5_l3t_data data; -uint32_t n_valid =rte_atomic16_read (&cmng->n_valid); +uint32_t n_valid = cmng->n_valid;uint32_t pool_idx, cnt_idx;uint32_t i;int ret;
@@ -317,8 +317,7 @@ cnt =MLX5_POOL_GET_CNT (pool,0 ); cmng->pools[n_valid] = pool; pool_idx = n_valid; -rte_atomic16_add (&cmng->n_valid,1 ); -TAILQ_INSERT_HEAD (&cmng->pool_list, pool, next); + cmng->n_valid++; } i =MLX5_CNT_ARRAY_IDX (pool, cnt); cnt_idx =MLX5_MAKE_CNT_IDX (pool_idx, i);
Signature · 1 line
1.8.3.1
PATCH 5/6 net/mlx5: make three level table thread safe
In reply to Suanming MouThis commit adds thread safety support in three level table using spinlock and reference counter for each the table entry.
--- drivers/net/mlx5/mlx5_utils.c | 144 +++++++++++++++++++++++++++++++----------- drivers/net/mlx5/mlx5_utils.h | 52 ++++++++++----- 2 files changed, 142 insertions(+), 54 deletions(-)
drivers/net/mlx5/mlx5_utils.c +106 -38
@@ -551,26 +551,23 @@ struct mlx5_l3t_tbl * tbl->type = type;switch (type) {case MLX5_L3T_TYPE_WORD : - l3t_ip_cfg.size =sizeof (struct mlx5_l3t_entry_word ) + -sizeof (uint16_t ) *MLX5_L3T_ET_SIZE ; + l3t_ip_cfg.size =sizeof (struct mlx5_l3t_entry_word ); l3t_ip_cfg.type ="mlx5_l3t_e_tbl_w" ;break ;case MLX5_L3T_TYPE_DWORD : - l3t_ip_cfg.size =sizeof (struct mlx5_l3t_entry_dword ) + -sizeof (uint32_t ) *MLX5_L3T_ET_SIZE ; + l3t_ip_cfg.size =sizeof (struct mlx5_l3t_entry_dword ); l3t_ip_cfg.type ="mlx5_l3t_e_tbl_dw" ;break ;case MLX5_L3T_TYPE_QWORD : - l3t_ip_cfg.size =sizeof (struct mlx5_l3t_entry_qword ) + -sizeof (uint64_t ) *MLX5_L3T_ET_SIZE ; + l3t_ip_cfg.size =sizeof (struct mlx5_l3t_entry_qword ); l3t_ip_cfg.type ="mlx5_l3t_e_tbl_qw" ;break ;default : - l3t_ip_cfg.size =sizeof (struct mlx5_l3t_entry_ptr ) + -sizeof (void *) *MLX5_L3T_ET_SIZE ; + l3t_ip_cfg.size =sizeof (struct mlx5_l3t_entry_ptr ); l3t_ip_cfg.type ="mlx5_l3t_e_tbl_tpr" ;break ; } +rte_spinlock_init (&tbl->sl); tbl->eip =mlx5_ipool_create (&l3t_ip_cfg);if (!tbl->eip) { rte_errno =ENOMEM ;
@@ -620,46 +617,63 @@ struct mlx5_l3t_tbl *mlx5_free (tbl); } -uint32_t +int32_t mlx5_l3t_get_entry (struct mlx5_l3t_tbl *tbl,uint32_t idx,union mlx5_l3t_data *data) {struct mlx5_l3t_level_tbl *g_tbl, *m_tbl; +struct mlx5_l3t_entry_word *w_e_tbl; +struct mlx5_l3t_entry_dword *dw_e_tbl; +struct mlx5_l3t_entry_qword *qw_e_tbl; +struct mlx5_l3t_entry_ptr *ptr_e_tbl;void *e_tbl;uint32_t entry_idx; +int32_t ret =-1 ; +rte_spinlock_lock (&tbl->sl); g_tbl = tbl->tbl;if (!g_tbl) -return -1 ; + goto out; m_tbl = g_tbl->tbl[(idx >>MLX5_L3T_GT_OFFSET ) &MLX5_L3T_GT_MASK ];if (!m_tbl) -return -1 ; + goto out; e_tbl = m_tbl->tbl[(idx >>MLX5_L3T_MT_OFFSET ) &MLX5_L3T_MT_MASK ];if (!e_tbl) -return -1 ; + goto out; + ret =0 ; entry_idx = idx &MLX5_L3T_ET_MASK ;switch (tbl->type) {case MLX5_L3T_TYPE_WORD : - data->word = ((struct mlx5_l3t_entry_word *)e_tbl)->entry - [entry_idx]; + w_e_tbl = (struct mlx5_l3t_entry_word *)e_tbl; + data->word = w_e_tbl->entry[entry_idx].data; +if (w_e_tbl->entry[entry_idx].data) + w_e_tbl->entry[entry_idx].ref_cnt++;break ;case MLX5_L3T_TYPE_DWORD : - data->dword = ((struct mlx5_l3t_entry_dword *)e_tbl)->entry - [entry_idx]; + dw_e_tbl = (struct mlx5_l3t_entry_dword *)e_tbl; + data->dword = dw_e_tbl->entry[entry_idx].data; +if (dw_e_tbl->entry[entry_idx].data) + dw_e_tbl->entry[entry_idx].ref_cnt++;break ;case MLX5_L3T_TYPE_QWORD : - data->qword = ((struct mlx5_l3t_entry_qword *)e_tbl)->entry - [entry_idx]; + qw_e_tbl = (struct mlx5_l3t_entry_qword *)e_tbl; + data->qword = qw_e_tbl->entry[entry_idx].data; +if (qw_e_tbl->entry[entry_idx].data) + qw_e_tbl->entry[entry_idx].ref_cnt++;break ;default : - data->ptr = ((struct mlx5_l3t_entry_ptr *)e_tbl)->entry - [entry_idx]; + ptr_e_tbl = (struct mlx5_l3t_entry_ptr *)e_tbl; + data->ptr = ptr_e_tbl->entry[entry_idx].data; +if (ptr_e_tbl->entry[entry_idx].data) + ptr_e_tbl->entry[entry_idx].ref_cnt++;break ; } -return 0 ; +out: +rte_spinlock_unlock (&tbl->sl); +return ret; } -void +int32_t mlx5_l3t_clear_entry (struct mlx5_l3t_tbl *tbl,uint32_t idx) {struct mlx5_l3t_level_tbl *g_tbl, *m_tbl;
@@ -670,36 +684,54 @@ struct mlx5_l3t_tbl *void *e_tbl;uint32_t entry_idx;uint64_t ref_cnt; +int32_t ret =-1 ; +rte_spinlock_lock (&tbl->sl); g_tbl = tbl->tbl;if (!g_tbl) -return ; + goto out; m_tbl = g_tbl->tbl[(idx >>MLX5_L3T_GT_OFFSET ) &MLX5_L3T_GT_MASK ];if (!m_tbl) -return ; + goto out; e_tbl = m_tbl->tbl[(idx >>MLX5_L3T_MT_OFFSET ) &MLX5_L3T_MT_MASK ];if (!e_tbl) -return ; + goto out; entry_idx = idx &MLX5_L3T_ET_MASK ;switch (tbl->type) {case MLX5_L3T_TYPE_WORD : w_e_tbl = (struct mlx5_l3t_entry_word *)e_tbl; - w_e_tbl->entry[entry_idx] =0 ; +MLX5_ASSERT (w_e_tbl->entry[entry_idx].ref_cnt); + ret = --w_e_tbl->entry[entry_idx].ref_cnt; +if (ret) + goto out; + w_e_tbl->entry[entry_idx].data =0 ; ref_cnt = --w_e_tbl->ref_cnt;break ;case MLX5_L3T_TYPE_DWORD : dw_e_tbl = (struct mlx5_l3t_entry_dword *)e_tbl; - dw_e_tbl->entry[entry_idx] =0 ; +MLX5_ASSERT (dw_e_tbl->entry[entry_idx].ref_cnt); + ret = --dw_e_tbl->entry[entry_idx].ref_cnt; +if (ret) + goto out; + dw_e_tbl->entry[entry_idx].data =0 ; ref_cnt = --dw_e_tbl->ref_cnt;break ;case MLX5_L3T_TYPE_QWORD : qw_e_tbl = (struct mlx5_l3t_entry_qword *)e_tbl; - qw_e_tbl->entry[entry_idx] =0 ; +MLX5_ASSERT (qw_e_tbl->entry[entry_idx].ref_cnt); + ret = --qw_e_tbl->entry[entry_idx].ref_cnt; +if (ret) + goto out; + qw_e_tbl->entry[entry_idx].data =0 ; ref_cnt = --qw_e_tbl->ref_cnt;break ;default : ptr_e_tbl = (struct mlx5_l3t_entry_ptr *)e_tbl; - ptr_e_tbl->entry[entry_idx] =NULL ; +MLX5_ASSERT (ptr_e_tbl->entry[entry_idx].ref_cnt); + ret = --ptr_e_tbl->entry[entry_idx].ref_cnt; +if (ret) + goto out; + ptr_e_tbl->entry[entry_idx].data =NULL ; ref_cnt = --ptr_e_tbl->ref_cnt;break ; }
@@ -718,9 +750,12 @@ struct mlx5_l3t_tbl * } } } +out: +rte_spinlock_unlock (&tbl->sl); +return ret; } -uint32_t +int32_t mlx5_l3t_set_entry (struct mlx5_l3t_tbl *tbl,uint32_t idx,union mlx5_l3t_data *data) {
@@ -731,8 +766,10 @@ struct mlx5_l3t_tbl *struct mlx5_l3t_entry_ptr *ptr_e_tbl;void *e_tbl;uint32_t entry_idx, tbl_idx =0 ; +int32_t ret =-1 ;/* Check the global table, create it if empty. */ +rte_spinlock_lock (&tbl->sl); g_tbl = tbl->tbl;if (!g_tbl) { g_tbl = mlx5_malloc(MLX5_MEM_ZERO,
@@ -741,7 +778,7 @@ struct mlx5_l3t_tbl * SOCKET_ID_ANY);if (!g_tbl) { rte_errno =ENOMEM ; -return -1 ; + goto out; } tbl->tbl = g_tbl; }
@@ -757,7 +794,7 @@ struct mlx5_l3t_tbl * SOCKET_ID_ANY);if (!m_tbl) { rte_errno =ENOMEM ; -return -1 ; + goto out; } g_tbl->tbl[(idx >>MLX5_L3T_GT_OFFSET ) &MLX5_L3T_GT_MASK ] = m_tbl;
@@ -772,7 +809,7 @@ struct mlx5_l3t_tbl * e_tbl =mlx5_ipool_zmalloc (tbl->eip, &tbl_idx);if (!e_tbl) { rte_errno =ENOMEM ; -return -1 ; + goto out; } ((struct mlx5_l3t_entry_word *)e_tbl)->idx = tbl_idx; m_tbl->tbl[(idx >> MLX5_L3T_MT_OFFSET) & MLX5_L3T_MT_MASK] =
@@ -783,24 +820,55 @@ struct mlx5_l3t_tbl *switch (tbl->type) {case MLX5_L3T_TYPE_WORD : w_e_tbl = (struct mlx5_l3t_entry_word *)e_tbl; - w_e_tbl->entry[entry_idx] = data->word; +if (w_e_tbl->entry[entry_idx].data) { + data->word = w_e_tbl->entry[entry_idx].data; + w_e_tbl->entry[entry_idx].ref_cnt++; + rte_errno =EEXIST ; + goto out; + } + w_e_tbl->entry[entry_idx].data = data->word; + w_e_tbl->entry[entry_idx].ref_cnt =1 ; w_e_tbl->ref_cnt++;break ;case MLX5_L3T_TYPE_DWORD : dw_e_tbl = (struct mlx5_l3t_entry_dword *)e_tbl; - dw_e_tbl->entry[entry_idx] = data->dword; +if (dw_e_tbl->entry[entry_idx].data) { + data->dword = dw_e_tbl->entry[entry_idx].data; + dw_e_tbl->entry[entry_idx].ref_cnt++; + rte_errno =EEXIST ; + goto out; + } + dw_e_tbl->entry[entry_idx].data = data->dword; + dw_e_tbl->entry[entry_idx].ref_cnt =1 ; dw_e_tbl->ref_cnt++;break ;case MLX5_L3T_TYPE_QWORD : qw_e_tbl = (struct mlx5_l3t_entry_qword *)e_tbl; - qw_e_tbl->entry[entry_idx] = data->qword; +if (qw_e_tbl->entry[entry_idx].data) { + data->qword = qw_e_tbl->entry[entry_idx].data; + qw_e_tbl->entry[entry_idx].ref_cnt++; + rte_errno =EEXIST ; + goto out; + } + qw_e_tbl->entry[entry_idx].data = data->qword; + qw_e_tbl->entry[entry_idx].ref_cnt =1 ; qw_e_tbl->ref_cnt++;break ;default : ptr_e_tbl = (struct mlx5_l3t_entry_ptr *)e_tbl; - ptr_e_tbl->entry[entry_idx] = data->ptr; +if (ptr_e_tbl->entry[entry_idx].data) { + data->ptr = ptr_e_tbl->entry[entry_idx].data; + ptr_e_tbl->entry[entry_idx].ref_cnt++; + rte_errno =EEXIST ; + goto out; + } + ptr_e_tbl->entry[entry_idx].data = data->ptr; + ptr_e_tbl->entry[entry_idx].ref_cnt =1 ; ptr_e_tbl->ref_cnt++;break ; } -return 0 ; + ret =0 ; +out: +rte_spinlock_unlock (&tbl->sl); +return ret; }
drivers/net/mlx5/mlx5_utils.h +36 -16
103 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH 6/6 net/mlx5: make shared counters thread safe
In reply to Suanming MouThe shared counters save the counter index to three level table. As three level table supports multiple-thread opertations now, the shared counters can take advantage of the table to support multiple-thread.
Once multiple threads saves the same ID counter to the same table entry at the same time, only one will be success, others will get the EEXIST errno with entry reference counter increase. In this case, the other duplicate created counter will be released.
--- drivers/net/mlx5/mlx5.h | 1 - drivers/net/mlx5/mlx5_flow_dv.c | 62 +++++++++++--------------------------- drivers/net/mlx5/mlx5_flow_verbs.c | 19 +++--------- 3 files changed, 21 insertions(+), 61 deletions(-)
drivers/net/mlx5/mlx5.h +0 -1
@@ -348,7 +348,6 @@ struct flow_counter_stats {/* Shared counters information for counters. */ struct mlx5_flow_counter_shared { -uint32_t ref_cnt;/**< Reference counter. */ uint32_t id;/**< User counter ID. */ };
drivers/net/mlx5/mlx5_flow_dv.c +17 -45
93 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_verbs.c +4 -15
@@ -265,15 +265,8 @@int ret;if (shared && !mlx5_l3t_get_entry (priv->sh->cnt_id_tbl, id, &data) && - data.dword) { - cnt =flow_verbs_counter_get_by_idx (dev, data.dword,NULL ); -if (cnt->shared_info.ref_cnt +1 ==0 ) { - rte_errno =E2BIG ; -return 0 ; - } - cnt->shared_info.ref_cnt++; + data.dword)return data.dword; - }for (pool_idx =0 ; pool_idx < n_valid; ++pool_idx) { pool = cmng->pools[pool_idx];if (!pool)
@@ -325,7 +318,6 @@ data.dword = cnt_idx;if (mlx5_l3t_set_entry (priv->sh->cnt_id_tbl, id, &data))return 0 ; - cnt->shared_info.ref_cnt =1 ; cnt->shared_info.id = id; cnt_idx |=MLX5_CNT_SHARED_OFFSET ; }
@@ -360,12 +352,9 @@struct mlx5_flow_counter_ext *cnt_ext; cnt =flow_verbs_counter_get_by_idx (dev, counter, &pool); -if (IS_SHARED_CNT (counter)) { -if (--cnt->shared_info.ref_cnt) -return ; -mlx5_l3t_clear_entry (priv->sh->cnt_id_tbl, - cnt->shared_info.id); - } +if (IS_SHARED_CNT (counter) && +mlx5_l3t_clear_entry (priv->sh->cnt_id_tbl, cnt->shared_info.id)) +return ; cnt_ext =MLX5_CNT_TO_CNT_EXT (pool, cnt);#if defined(HAVE_IBV_DEVICE_COUNTERS_SET_V42 )claim_zero (mlx5_glue->destroy_counter_set (cnt_ext->cs));
Signature · 1 line
1.8.3.1
v2 cover net/mlx5: make counter thread safe
In reply to Suanming MouThe mlx5 PMD is going to support multiple-thread flow operations. This patchset makes the counter action to be thread safe.
Suanming Mou (8):
net/mlx5: locate aging pools in the general container net/mlx5: optimize shared counter memory net/mlx5: remove single counter container net/mlx5: synchronize flow counter pool creation net/mlx5: make three level table thread safe net/mlx5: make shared counters thread safe net/mlx5: rename flow counter macro net/mlx5: optimize counter extend memory
--
v2:
- Optimize the fallback non-batch counter memory.
- Add MLX5_ prefix to counter macro.
- Rebase on top of the latest code.
--
drivers/net/mlx5/linux/mlx5_os.c | 53 ++- drivers/net/mlx5/mlx5.c | 51 ++- drivers/net/mlx5/mlx5.h | 146 ++++---- drivers/net/mlx5/mlx5_flow.c | 183 ++++++---- drivers/net/mlx5/mlx5_flow.h | 1 + drivers/net/mlx5/mlx5_flow_dv.c | 706 ++++++++++++++----------------------- drivers/net/mlx5/mlx5_flow_verbs.c | 130 ++++--- drivers/net/mlx5/mlx5_utils.c | 191 ++++++++-- drivers/net/mlx5/mlx5_utils.h | 81 ++++- 9 files changed, 824 insertions(+), 718 deletions(-)
Signature · 1 line
1.8.3.1
PATCH v2 1/8 net/mlx5: locate aging pools in the general container
Commit [1] introduced different container for the aging counter pools. In order to save container memory the aging counter pools can be located in the general pool container.
This patch locates the aging counter pools in the general pool container. Remove the aging container management.
[1] commit fd143711a6ea ("net/mlx5: separate aging counter pool range")
--- drivers/net/mlx5/mlx5.c | 7 ++-- drivers/net/mlx5/mlx5.h | 17 +++++---- drivers/net/mlx5/mlx5_flow.c | 19 +++------- drivers/net/mlx5/mlx5_flow_dv.c | 76 ++++++++++++++++++-------------------- drivers/net/mlx5/mlx5_flow_verbs.c | 4 +- 5 files changed, 56 insertions(+), 67 deletions(-)
drivers/net/mlx5/mlx5.c +4 -3
@@ -480,7 +480,7 @@ struct mlx5_flow_id_pool *static void mlx5_flow_counters_mng_init (struct mlx5_dev_ctx_shared *sh) { -int i; +int i, j;memset (&sh->cmng,0 ,sizeof (sh->cmng));TAILQ_INIT (&sh->cmng.flow_counters);
@@ -490,7 +490,8 @@ struct mlx5_flow_id_pool * sh->cmng.ccont[i].last_pool_idx =POOL_IDX_INVALID ;TAILQ_INIT (&sh->cmng.ccont[i].pool_list);rte_spinlock_init (&sh->cmng.ccont[i].resize_sl); -TAILQ_INIT (&sh->cmng.ccont[i].counters); +for (j =0 ; j <MLX5_COUNTER_TYPE_MAX ; j++) +TAILQ_INIT (&sh->cmng.ccont[i].counters[j]);rte_spinlock_init (&sh->cmng.ccont[i].csl); } }
@@ -535,7 +536,7 @@ struct mlx5_flow_id_pool * }for (i =0 ; i <MLX5_CCONT_TYPE_MAX ; ++i) {struct mlx5_flow_counter_pool *pool; -uint32_t batch = !!(i >1 ); +uint32_t batch = (i ==MLX5_CCONT_TYPE_BATCH );if (!sh->cmng.ccont[i].pools)continue ;
drivers/net/mlx5/mlx5.h +9 -8
@@ -272,7 +272,6 @@ struct mlx5_drop {#define MLX5_COUNTERS_PER_POOL 512#define MLX5_MAX_PENDING_QUERIES 4#define MLX5_CNT_CONTAINER_RESIZE 64 -#define MLX5_CNT_AGE_OFFSET 0x80000000#define CNT_SIZE (sizeof(struct mlx5_flow_counter))#define CNTEXT_SIZE (sizeof(struct mlx5_flow_counter_ext))#define AGE_SIZE (sizeof(struct mlx5_age_param))
@@ -280,7 +279,6 @@ struct mlx5_drop {#define CNT_POOL_TYPE_AGE (1 << 1)#define IS_EXT_POOL (pool) (((pool)->type) & CNT_POOL_TYPE_EXT)#define IS_AGE_POOL (pool) (((pool)->type) & CNT_POOL_TYPE_AGE) -#define MLX_CNT_IS_AGE (counter) ((counter) & MLX5_CNT_AGE_OFFSET ? 1 : 0)#define MLX5_CNT_LEN (pool) \ (CNT_SIZE + \ (IS_AGE_POOL(pool) ? AGE_SIZE : 0) + \
@@ -321,17 +319,20 @@ enum { AGE_TMOUT, /* Timeout, wait for rte_flow_get_aged_flows and destroy. */ }; -#define MLX5_CNT_CONTAINER (sh, batch, age) (&(sh)->cmng.ccont \ - [(batch) * 2 + (age)]) +#define MLX5_CNT_CONTAINER (sh, batch) (&(sh)->cmng.ccont[batch])enum {MLX5_CCONT_TYPE_SINGLE , -MLX5_CCONT_TYPE_SINGLE_FOR_AGE ,MLX5_CCONT_TYPE_BATCH , -MLX5_CCONT_TYPE_BATCH_FOR_AGE ,MLX5_CCONT_TYPE_MAX , }; +enum mlx5_counter_type { +MLX5_COUNTER_TYPE_ORIGIN , +MLX5_COUNTER_TYPE_AGE , +MLX5_COUNTER_TYPE_MAX , +}; +/* Counter age parameter. */ struct mlx5_age_param {uint16_t state;/**< Age state (atomically accessed). */
@@ -426,7 +427,8 @@ struct mlx5_pools_container {int max_id;/* The maximum counter ID in the pools. */ rte_spinlock_t resize_sl;/* The resize lock. */ rte_spinlock_t csl;/* The counter free list lock. */ -struct mlx5_counters counters;/* Free counter list. */ +struct mlx5_counters counters[MLX5_COUNTER_TYPE_MAX ]; +/* Free counter list. */ struct mlx5_counter_pools pool_list;/* Counter pool list. */ struct mlx5_flow_counter_pool **pools;/* Counter pool array. */ struct mlx5_counter_stats_mem_mng *mem_mng;
@@ -440,7 +442,6 @@ struct mlx5_flow_counter_mng {uint8_t pending_queries;uint8_t batch;uint16_t pool_index; -uint8_t age;uint8_t query_thread_on; LIST_HEAD(mem_mngs, mlx5_counter_stats_mem_mng) mem_mngs; LIST_HEAD(stat_raws, mlx5_counter_stats_raw) free_stat_raws;
drivers/net/mlx5/mlx5_flow.c +6 -13
@@ -6649,7 +6649,6 @@ struct mlx5_meter_domains_infos *uint16_t offset;int ret;uint8_t batch = sh->cmng.batch; -uint8_t age = sh->cmng.age;uint16_t pool_index = sh->cmng.pool_index;struct mlx5_pools_container *cont;struct mlx5_flow_counter_pool *pool;
@@ -6658,7 +6657,7 @@ struct mlx5_meter_domains_infos *if (sh->cmng.pending_queries >=MLX5_MAX_PENDING_QUERIES ) goto set_alarm; next_container: - cont =MLX5_CNT_CONTAINER (sh, batch, age); + cont =MLX5_CNT_CONTAINER (sh, batch);rte_spinlock_lock (&cont->resize_sl);if (!cont->pools) {rte_spinlock_unlock (&cont->resize_sl);
@@ -6667,11 +6666,6 @@ struct mlx5_meter_domains_infos * goto set_alarm; batch ^=0x1 ; pool_index =0 ; -if (batch ==0 && pool_index ==0 ) { - age ^=0x1 ; - sh->cmng.batch = batch; - sh->cmng.age = age; - } goto next_container; } pool = cont->pools[pool_index];
@@ -6720,13 +6714,10 @@ struct mlx5_meter_domains_infos *if (pool_index >=rte_atomic16_read (&cont->n_valid)) { batch ^=0x1 ; pool_index =0 ; -if (batch ==0 && pool_index ==0 ) - age ^=0x1 ; } set_alarm: sh->cmng.batch = batch; sh->cmng.pool_index = pool_index; - sh->cmng.age = age;mlx5_set_query_alarm (sh); }
@@ -6817,10 +6808,12 @@ struct mlx5_meter_domains_infos *struct mlx5_flow_counter_pool *pool = (struct mlx5_flow_counter_pool *)(uintptr_t )async_id;struct mlx5_counter_stats_raw *raw_to_free; -uint8_t age = !!IS_AGE_POOL (pool);uint8_t query_gen = pool->query_gen ^1 ;struct mlx5_pools_container *cont = -MLX5_CNT_CONTAINER (sh, !IS_EXT_POOL (pool), age); +MLX5_CNT_CONTAINER (sh, !IS_EXT_POOL (pool)); +enum mlx5_counter_type cnt_type = +IS_AGE_POOL (pool) ?MLX5_COUNTER_TYPE_AGE : +MLX5_COUNTER_TYPE_ORIGIN ;if (unlikely (status)) { raw_to_free = pool->raw_hw;
@@ -6835,7 +6828,7 @@ struct mlx5_meter_domains_infos *rte_io_wmb ();if (!TAILQ_EMPTY (&pool->counters[query_gen])) {rte_spinlock_lock (&cont->csl); -TAILQ_CONCAT (&cont->counters, +TAILQ_CONCAT (&cont->counters[cnt_type], &pool->counters[query_gen], next);rte_spinlock_unlock (&cont->csl); }
drivers/net/mlx5/mlx5_flow_dv.c +35 -41
173 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_verbs.c +2 -2
@@ -159,7 +159,7 @@ struct mlx5_flow_counter_pool **ppool) {struct mlx5_priv *priv = dev->data->dev_private; -struct mlx5_pools_container *cont =MLX5_CNT_CONTAINER (priv->sh,0 ,0 ); +struct mlx5_pools_container *cont =MLX5_CNT_CONTAINER (priv->sh,0 );struct mlx5_flow_counter_pool *pool; idx--;
@@ -254,7 +254,7 @@ flow_verbs_counter_new(struct rte_eth_dev *dev, uint32_t shared, uint32_t id) { struct mlx5_priv *priv = dev->data->dev_private; -struct mlx5_pools_container *cont =MLX5_CNT_CONTAINER (priv->sh,0 ,0 ); +struct mlx5_pools_container *cont =MLX5_CNT_CONTAINER (priv->sh,0 );struct mlx5_flow_counter_pool *pool =NULL ;struct mlx5_flow_counter_ext *cnt_ext =NULL ;struct mlx5_flow_counter *cnt =NULL ;
Signature · 1 line
1.8.3.1
PATCH v2 2/8 net/mlx5: optimize shared counter memory
In reply to Suanming MouInstead of using special memory to indicate shared counter, this patch does the optimization to use the counter handler reserved memory to indicate it. The counter index with MLX5_CNT_SHARED_OFFSET means the shared counter.
This patch is also an arrangement for a new adjustment to use batch counter as shared counter.
--- drivers/net/mlx5/mlx5.h | 36 +++++++++++++----- drivers/net/mlx5/mlx5_flow_dv.c | 78 +++++++++++++++----------------------- drivers/net/mlx5/mlx5_flow_verbs.c | 60 +++++++++++++++++------------ 3 files changed, 93 insertions(+), 81 deletions(-)
drivers/net/mlx5/mlx5.h +27 -9
@@ -272,6 +272,10 @@ struct mlx5_drop {#define MLX5_COUNTERS_PER_POOL 512#define MLX5_MAX_PENDING_QUERIES 4#define MLX5_CNT_CONTAINER_RESIZE 64 +#define MLX5_CNT_SHARED_OFFSET 0x80000000 +#define IS_SHARED_CNT (cnt) (!!((cnt) & MLX5_CNT_SHARED_OFFSET)) +#define IS_BATCH_CNT (cnt) (((cnt) & (MLX5_CNT_SHARED_OFFSET - 1)) >= \ + MLX5_CNT_BATCH_OFFSET)#define CNT_SIZE (sizeof(struct mlx5_flow_counter))#define CNTEXT_SIZE (sizeof(struct mlx5_flow_counter_ext))#define AGE_SIZE (sizeof(struct mlx5_age_param))
@@ -348,10 +352,29 @@ struct flow_counter_stats {uint64_t bytes; }; +/* Shared counters information for counters. */ +struct mlx5_flow_counter_shared { +uint32_t ref_cnt;/**< Reference counter. */ +uint32_t id;/**< User counter ID. */ +}; + +struct mlx5_flow_counter_pool ;/* Generic counters information. */ struct mlx5_flow_counter { -TAILQ_ENTRY (mlx5_flow_counter) next; -/**< Pointer to the next flow counter structure. */ +union { +/* +* User-defined counter shared info is only used during +* counter active time. And aging counter sharing is not +* supported, so active shared counter will not be chained +* to the aging list. For shared counter, only when it is +* released, the TAILQ entry memory will be used, at that +* time, shared memory is not used anymore. +*/ +TAILQ_ENTRY (mlx5_flow_counter) next; +/**< Pointer to the next flow counter structure. */ +struct mlx5_flow_counter_shared shared_info; +/**< Shared counter information. */ + };union {uint64_t hits;/**< Reset value of hits packets. */ struct mlx5_flow_counter_pool *pool;/**< Counter pool. */
@@ -360,15 +383,10 @@ struct mlx5_flow_counter {void *action;/**< Pointer to the dv action. */ }; -/* Extend counters information for none batch counters. */ +/* Extend counters information for none batch fallback counters. */ struct mlx5_flow_counter_ext { -uint32_t shared:1 ;/**< Share counter ID with other flow rules. */ -uint32_t batch:1 ;uint32_t skipped:1 ;/* This counter is skipped or not. */ -/**< Whether the counter was allocated by batch command. */ -uint32_t ref_cnt:29 ;/**< Reference counter. */ -uint32_t id;/**< User counter ID. */ -union {/**< Holds the counters for the rule. */ +union {#if defined(HAVE_IBV_DEVICE_COUNTERS_SET_V42 )struct ibv_counter_set *cs;#elif defined(HAVE_IBV_DEVICE_COUNTERS_SET_V45 )
drivers/net/mlx5/mlx5_flow_dv.c +31 -47
130 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_verbs.c +35 -25
104 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH v2 3/8 net/mlx5: remove single counter container
In reply to Suanming MouA flow counter which was allocated by a batch API couldn't be assigned to a flow in the root table (group 0) in old rdma-core version. Hence, a root table flow counter required PMD mechanism to manage counters which were allocated singly.
Currently, the batch counters have already been supported in root table includes a new rdma-core version with MLX5_FLOW_ACTION_COUNTER_OFFSET enum and with a kernel driver includes MLX5_IB_ATTR_CREATE_FLOW_ARR_COUNTERS_DEVX_OFFSET enum.
When the PMD uses rdma-core API to assign a batch counter to a root table flow using invalid counter offset, it should get an error only if the batch counter assignment for root table is supported. Using this trial in the initialization time can help to detect the support.
Using the above trial, if the support is valid, remove the management of single counter container in the fast counter mechanism. Otherwise, move the counter mechanism to fallback mode.
--- drivers/net/mlx5/linux/mlx5_os.c | 42 +++- drivers/net/mlx5/mlx5.c | 38 ++-- drivers/net/mlx5/mlx5.h | 28 +-- drivers/net/mlx5/mlx5_flow.c | 76 ++----- drivers/net/mlx5/mlx5_flow.h | 1 + drivers/net/mlx5/mlx5_flow_dv.c | 397 ++++++++++++++++--------------------- drivers/net/mlx5/mlx5_flow_verbs.c | 26 +-- 7 files changed, 258 insertions(+), 350 deletions(-)
drivers/net/mlx5/linux/mlx5_os.c +34 -8
@@ -562,6 +562,39 @@ }/** +* DV flow counter mode detect and config. +* +* @param dev +* Pointer to rte_eth_dev structure. +* +*/ +static void +mlx5_flow_counter_mode_config(struct rte_eth_dev *dev __rte_unused) +{ +#ifdef HAVE_IBV_FLOW_DV_SUPPORT +struct mlx5_priv *priv = dev->data->dev_private; + +/* If devx is not supported or not DV mode, counters are not working. */ +if (!priv->config.devx || !priv->config.dv_flow_en) +return ; +#ifndef HAVE_IBV_DEVX_ASYNC + priv->counter_fallback =1 ; +#else + priv->counter_fallback =0 ; +if (!priv->config.hca_attr.flow_counters_dump || + !(priv->config.hca_attr.flow_counter_bulk_alloc_bitmap &0x4 ) || + (mlx5_flow_dv_discover_counter_offset_support (dev) == -ENOTSUP )) + priv->counter_fallback =1 ; +#endif +if (priv->counter_fallback) +DRV_LOG (INFO ,"Use fall-back DV counter management. Flow " +"counter dump:%d, bulk_alloc_bitmap:0x%hhx." , + priv->config.hca_attr.flow_counters_dump, + priv->config.hca_attr.flow_counter_bulk_alloc_bitmap); +#endif +} + +/** * Spawn an Ethernet device from Verbs information. * * @param dpdk_dev
@@ -1029,19 +1062,11 @@DRV_LOG (INFO ,"Rx CQE padding is enabled" ); }if (config->devx) { - priv->counter_fallback =0 ; err =mlx5_devx_cmd_query_hca_attr (sh->ctx, &config->hca_attr);if (err) { err = -err; goto error; } -if (!config->hca_attr.flow_counters_dump) - priv->counter_fallback =1 ; -#ifndef HAVE_IBV_DEVX_ASYNC - priv->counter_fallback =1 ; -#endif -if (priv->counter_fallback) -DRV_LOG (INFO ,"Use fall-back DV counter management" );/* Check for LRO support. */ if (config->dest_tir && config->hca_attr.lro_cap && config->dv_flow_en) {
@@ -1443,6 +1468,7 @@ goto error; } } +mlx5_flow_counter_mode_config (eth_dev);return eth_dev; error:if (priv) {
drivers/net/mlx5/mlx5.c +17 -21
@@ -480,19 +480,18 @@ struct mlx5_flow_id_pool *static void mlx5_flow_counters_mng_init (struct mlx5_dev_ctx_shared *sh) { -int i, j; +int i;memset (&sh->cmng,0 ,sizeof (sh->cmng));TAILQ_INIT (&sh->cmng.flow_counters); -for (i =0 ; i <MLX5_CCONT_TYPE_MAX ; ++i) { - sh->cmng.ccont[i].min_id =MLX5_CNT_BATCH_OFFSET ; - sh->cmng.ccont[i].max_id =-1 ; - sh->cmng.ccont[i].last_pool_idx =POOL_IDX_INVALID ; -TAILQ_INIT (&sh->cmng.ccont[i].pool_list); -rte_spinlock_init (&sh->cmng.ccont[i].resize_sl); -for (j =0 ; j <MLX5_COUNTER_TYPE_MAX ; j++) -TAILQ_INIT (&sh->cmng.ccont[i].counters[j]); -rte_spinlock_init (&sh->cmng.ccont[i].csl); + sh->cmng.min_id =MLX5_CNT_BATCH_OFFSET ; + sh->cmng.max_id =-1 ; + sh->cmng.last_pool_idx =POOL_IDX_INVALID ; +TAILQ_INIT (&sh->cmng.pool_list); +rte_spinlock_init (&sh->cmng.resize_sl); +for (i =0 ; i <MLX5_COUNTER_TYPE_MAX ; i++) { +TAILQ_INIT (&sh->cmng.counters[i]); +rte_spinlock_init (&sh->cmng.csl[i]); } }
@@ -523,7 +522,6 @@ struct mlx5_flow_id_pool * mlx5_flow_counters_mng_close(struct mlx5_dev_ctx_shared *sh) {struct mlx5_counter_stats_mem_mng *mng; -int i;int j;int retries =1024 ;
@@ -534,15 +532,13 @@ struct mlx5_flow_id_pool *break ;rte_pause (); } -for (i =0 ; i <MLX5_CCONT_TYPE_MAX ; ++i) { + +if (sh->cmng.pools) {struct mlx5_flow_counter_pool *pool; -uint32_t batch = (i ==MLX5_CCONT_TYPE_BATCH ); -if (!sh->cmng.ccont[i].pools) -continue ; - pool =TAILQ_FIRST (&sh->cmng.ccont[i].pool_list); + pool =TAILQ_FIRST (&sh->cmng.pool_list);while (pool) { -if (batch && pool->min_dcs) +if (!IS_EXT_POOL (pool) && pool->min_dcs)claim_zero (mlx5_devx_cmd_destroy (pool->min_dcs));for (j =0 ; j <MLX5_COUNTERS_PER_POOL ; ++j) {
@@ -551,17 +547,17 @@ struct mlx5_flow_id_pool * (mlx5_glue->destroy_flow_action (MLX5_POOL_GET_CNT (pool, j)->action)); -if (!batch &&MLX5_GET_POOL_CNT_EXT +if (IS_EXT_POOL (pool) &&MLX5_GET_POOL_CNT_EXT (pool, j)->dcs)claim_zero (mlx5_devx_cmd_destroy (MLX5_GET_POOL_CNT_EXT (pool, j)->dcs)); } -TAILQ_REMOVE (&sh->cmng.ccont[i].pool_list, pool, next); +TAILQ_REMOVE (&sh->cmng.pool_list, pool, next);mlx5_free (pool); - pool =TAILQ_FIRST (&sh->cmng.ccont[i].pool_list); + pool =TAILQ_FIRST (&sh->cmng.pool_list); } -mlx5_free (sh->cmng.ccont[i].pools); +mlx5_free (sh->cmng.pools); } mng =LIST_FIRST (&sh->cmng.mem_mngs);while (mng) {
drivers/net/mlx5/mlx5.h +7 -21
@@ -281,8 +281,10 @@ struct mlx5_drop {#define AGE_SIZE (sizeof(struct mlx5_age_param))#define CNT_POOL_TYPE_EXT (1 << 0)#define CNT_POOL_TYPE_AGE (1 << 1) +#define IS_EXT_POOL (pool) (((pool)->type) & CNT_POOL_TYPE_EXT)#define IS_AGE_POOL (pool) (((pool)->type) & CNT_POOL_TYPE_AGE) +#define MLX5_CNT_LEN (pool) \ (CNT_SIZE + \ (IS_AGE_POOL(pool) ? AGE_SIZE : 0) + \
@@ -323,14 +325,6 @@ enum { AGE_TMOUT, /* Timeout, wait for rte_flow_get_aged_flows and destroy. */ }; -#define MLX5_CNT_CONTAINER (sh, batch) (&(sh)->cmng.ccont[batch]) - -enum { -MLX5_CCONT_TYPE_SINGLE , -MLX5_CCONT_TYPE_BATCH , -MLX5_CCONT_TYPE_MAX , -}; -enum mlx5_counter_type {MLX5_COUNTER_TYPE_ORIGIN ,MLX5_COUNTER_TYPE_AGE ,
@@ -385,7 +379,6 @@ struct mlx5_flow_counter {/* Extend counters information for none batch fallback counters. */ struct mlx5_flow_counter_ext { -uint32_t skipped:1 ;/* This counter is skipped or not. */ union {#if defined(HAVE_IBV_DEVICE_COUNTERS_SET_V42 )struct ibv_counter_set *cs;
@@ -409,9 +402,8 @@ struct mlx5_flow_counter_pool {/* The devx object of the minimum counter ID. */ uint64_t time_of_last_age_check;/* System time (from rte_rdtsc()) read in the last aging check. */ - uint32_t index:28; /* Pool index in container. */ + uint32_t index:29; /* Pool index in container. */ uint32_t type:2; /* Memory type behind the counter array. */ - uint32_t skip_cnt:1; /* Pool contains skipped counter. */ volatile uint32_t query_gen:1; /* Query round. */rte_spinlock_t sl;/* The pool lock. */ struct mlx5_counter_stats_raw *raw;
@@ -429,36 +421,30 @@ struct mlx5_counter_stats_mem_mng {/* Raw memory structure for the counter statistics values of a pool. */ struct mlx5_counter_stats_raw {LIST_ENTRY (mlx5_counter_stats_raw) next; -int min_dcs_id;struct mlx5_counter_stats_mem_mng *mem_mng;volatile struct flow_counter_stats *data; };TAILQ_HEAD (mlx5_counter_pools, mlx5_flow_counter_pool); -/* Container structure for counter pools. */ -struct mlx5_pools_container { +/* Counter global management structure. */ +struct mlx5_flow_counter_mng {rte_atomic16_t n_valid;/* Number of valid pools. */ uint16_t n;/* Number of pools. */ uint16_t last_pool_idx;/* Last used pool index */ int min_id;/* The minimum counter ID in the pools. */ int max_id;/* The maximum counter ID in the pools. */ rte_spinlock_t resize_sl;/* The resize lock. */ -rte_spinlock_t csl;/* The counter free list lock. */ +rte_spinlock_t csl[MLX5_COUNTER_TYPE_MAX ]; +/* The counter free list lock. */ struct mlx5_counters counters[MLX5_COUNTER_TYPE_MAX ];/* Free counter list. */ struct mlx5_counter_pools pool_list;/* Counter pool list. */ struct mlx5_flow_counter_pool **pools;/* Counter pool array. */ struct mlx5_counter_stats_mem_mng *mem_mng;/* Hold the memory management for the next allocated pools raws. */ -}; - -/* Counter global management structure. */ -struct mlx5_flow_counter_mng { -struct mlx5_pools_container ccont[MLX5_CCONT_TYPE_MAX ];struct mlx5_counters flow_counters;/* Legacy flow counter list. */ uint8_t pending_queries; -uint8_t batch;uint16_t pool_index;uint8_t query_thread_on; LIST_HEAD(mem_mngs, mlx5_counter_stats_mem_mng) mem_mngs;
drivers/net/mlx5/mlx5_flow.c +14 -62
138 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow.h +1 -0
@@ -1144,4 +1144,5 @@ int mlx5_flow_destroy_policer_rules(struct rte_eth_dev *dev, const struct rte_flow_attr *attr);int mlx5_flow_meter_flush (struct rte_eth_dev *dev,struct rte_mtr_error *error); +int mlx5_flow_dv_discover_counter_offset_support (struct rte_eth_dev *dev);#endif /* RTE_PMD_MLX5_FLOW_H_ */
drivers/net/mlx5/mlx5_flow_dv.c +172 -225
640 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_verbs.c +13 -13
@@ -159,11 +159,11 @@ struct mlx5_flow_counter_pool **ppool) {struct mlx5_priv *priv = dev->data->dev_private; -struct mlx5_pools_container *cont =MLX5_CNT_CONTAINER (priv->sh,0 ); +struct mlx5_flow_counter_mng *cmng = &priv->sh->cmng;struct mlx5_flow_counter_pool *pool; idx = (idx -1 ) & (MLX5_CNT_SHARED_OFFSET -1 ); - pool = cont->pools[idx /MLX5_COUNTERS_PER_POOL ]; + pool = cmng->pools[idx /MLX5_COUNTERS_PER_POOL ];MLX5_ASSERT (pool);if (ppool) *ppool = pool;
@@ -254,12 +254,12 @@ flow_verbs_counter_new(struct rte_eth_dev *dev, uint32_t shared, uint32_t id) { struct mlx5_priv *priv = dev->data->dev_private; -struct mlx5_pools_container *cont =MLX5_CNT_CONTAINER (priv->sh,0 ); +struct mlx5_flow_counter_mng *cmng = &priv->sh->cmng;struct mlx5_flow_counter_pool *pool =NULL ;struct mlx5_flow_counter_ext *cnt_ext =NULL ;struct mlx5_flow_counter *cnt =NULL ;union mlx5_l3t_data data; -uint32_t n_valid =rte_atomic16_read (&cont->n_valid); +uint32_t n_valid =rte_atomic16_read (&cmng->n_valid);uint32_t pool_idx, cnt_idx;uint32_t i;int ret;
@@ -275,7 +275,7 @@return data.dword; }for (pool_idx =0 ; pool_idx < n_valid; ++pool_idx) { - pool = cont->pools[pool_idx]; + pool = cmng->pools[pool_idx];if (!pool)continue ; cnt =TAILQ_FIRST (&pool->counters[0 ]);
@@ -286,7 +286,7 @@struct mlx5_flow_counter_pool **pools;uint32_t size; -if (n_valid == cont->n) { +if (n_valid == cmng->n) {/* Resize the container pool array. */ size =sizeof (struct mlx5_flow_counter_pool *) * (n_valid +MLX5_CNT_CONTAINER_RESIZE );
@@ -295,13 +295,13 @@if (!pools)return 0 ;if (n_valid) { -memcpy (pools, cont->pools, +memcpy (pools, cmng->pools,sizeof (struct mlx5_flow_counter_pool *) * n_valid); -mlx5_free (cont->pools); +mlx5_free (cmng->pools); } - cont->pools = pools; - cont->n +=MLX5_CNT_CONTAINER_RESIZE ; + cmng->pools = pools; + cmng->n +=MLX5_CNT_CONTAINER_RESIZE ; }/* Allocate memory for new pool*/ size = sizeof(*pool) + (sizeof(*cnt_ext) + sizeof(*cnt)) *
@@ -315,10 +315,10 @@TAILQ_INSERT_HEAD (&pool->counters[0 ], cnt, next); } cnt =MLX5_POOL_GET_CNT (pool,0 ); - cont->pools[n_valid] = pool; + cmng->pools[n_valid] = pool; pool_idx = n_valid; -rte_atomic16_add (&cont->n_valid,1 ); -TAILQ_INSERT_HEAD (&cont->pool_list, pool, next); +rte_atomic16_add (&cmng->n_valid,1 ); +TAILQ_INSERT_HEAD (&cmng->pool_list, pool, next); } i =MLX5_CNT_ARRAY_IDX (pool, cnt); cnt_idx =MLX5_MAKE_CNT_IDX (pool_idx, i);
Signature · 1 line
1.8.3.1
PATCH v2 4/8 net/mlx5: synchronize flow counter pool creation
In reply to Suanming MouCurrently, counter operations are not thread safe as the counter pools' array resize is not protected.
This commit protects the container pools' array resize using a spinlock. The original counter pool statistic memory allocate is moved to the host thread in order to minimize the critical section. Since that pool statistic memory is required only in query time. The container pools' array should be resized by the user threads, the new pool may be used by other rte_flow APIs before the host thread resize is done, if the pool is not saved to the pools' array, the specified counter memory will not be found as the pool is not saved to the counter management pool array. The pool raw statistic memory will be filled in host thread.
The shared counters will be protected in other commit.
--- drivers/net/mlx5/linux/mlx5_os.c | 5 ++ drivers/net/mlx5/mlx5.c | 12 ++- drivers/net/mlx5/mlx5.h | 10 ++- drivers/net/mlx5/mlx5_flow.c | 120 +++++++++++++++++++++++++- drivers/net/mlx5/mlx5_flow_dv.c | 171 ++++++++++--------------------------- drivers/net/mlx5/mlx5_flow_verbs.c | 5 +- 6 files changed, 177 insertions(+), 146 deletions(-)
drivers/net/mlx5/linux/mlx5_os.c +5 -0
@@ -1067,6 +1067,11 @@ err = -err; goto error; } +/* Check relax ordering support. */ +if (config->hca_attr.relaxed_ordering_write && + config->hca_attr.relaxed_ordering_read && + !haswell_broadwell_cpu) + sh->cmng.relaxed_ordering =1 ;/* Check for LRO support. */ if (config->dest_tir && config->hca_attr.lro_cap && config->dv_flow_en) {
drivers/net/mlx5/mlx5.c +5 -7
@@ -487,8 +487,7 @@ struct mlx5_flow_id_pool * sh->cmng.min_id =MLX5_CNT_BATCH_OFFSET ; sh->cmng.max_id =-1 ; sh->cmng.last_pool_idx =POOL_IDX_INVALID ; -TAILQ_INIT (&sh->cmng.pool_list); -rte_spinlock_init (&sh->cmng.resize_sl); +rte_spinlock_init (&sh->cmng.pool_update_sl);for (i =0 ; i <MLX5_COUNTER_TYPE_MAX ; i++) {TAILQ_INIT (&sh->cmng.counters[i]);rte_spinlock_init (&sh->cmng.csl[i]);
@@ -522,7 +521,7 @@ struct mlx5_flow_id_pool * mlx5_flow_counters_mng_close(struct mlx5_dev_ctx_shared *sh) {struct mlx5_counter_stats_mem_mng *mng; -int j; +int i, j;int retries =1024 ; rte_errno =0 ;
@@ -535,9 +534,10 @@ struct mlx5_flow_id_pool *if (sh->cmng.pools) {struct mlx5_flow_counter_pool *pool; +uint16_t n_valid = sh->cmng.n_valid; - pool =TAILQ_FIRST (&sh->cmng.pool_list); -while (pool) { +for (i =0 ; i < n_valid; ++i) { + pool = sh->cmng.pools[i];if (!IS_EXT_POOL (pool) && pool->min_dcs)claim_zero (mlx5_devx_cmd_destroy (pool->min_dcs));
@@ -553,9 +553,7 @@ struct mlx5_flow_id_pool * (MLX5_GET_POOL_CNT_EXT (pool, j)->dcs)); } -TAILQ_REMOVE (&sh->cmng.pool_list, pool, next);mlx5_free (pool); - pool =TAILQ_FIRST (&sh->cmng.pool_list); }mlx5_free (sh->cmng.pools); }
drivers/net/mlx5/mlx5.h +6 -4
@@ -406,8 +406,10 @@ struct mlx5_flow_counter_pool { uint32_t type:2; /* Memory type behind the counter array. */ volatile uint32_t query_gen:1; /* Query round. */rte_spinlock_t sl;/* The pool lock. */ +rte_spinlock_t csl;/* The pool counter free list lock. */ struct mlx5_counter_stats_raw *raw; -struct mlx5_counter_stats_raw *raw_hw;/* The raw on HW working. */ +struct mlx5_counter_stats_raw *raw_hw; +/* The raw on HW working. */ };/* Memory management structure for group of counter statistics raws. */
@@ -429,17 +431,16 @@ struct mlx5_counter_stats_raw {/* Counter global management structure. */ struct mlx5_flow_counter_mng { -rte_atomic16_t n_valid;/* Number of valid pools. */ +volatile uint16_t n_valid;/* Number of valid pools. */ uint16_t n;/* Number of pools. */ uint16_t last_pool_idx;/* Last used pool index */ int min_id;/* The minimum counter ID in the pools. */ int max_id;/* The maximum counter ID in the pools. */ -rte_spinlock_t resize_sl;/* The resize lock. */ +rte_spinlock_t pool_update_sl;/* The pool update lock. */ rte_spinlock_t csl[MLX5_COUNTER_TYPE_MAX ];/* The counter free list lock. */ struct mlx5_counters counters[MLX5_COUNTER_TYPE_MAX ];/* Free counter list. */ -struct mlx5_counter_pools pool_list;/* Counter pool list. */ struct mlx5_flow_counter_pool **pools;/* Counter pool array. */ struct mlx5_counter_stats_mem_mng *mem_mng;/* Hold the memory management for the next allocated pools raws. */
@@ -447,6 +448,7 @@ struct mlx5_flow_counter_mng {uint8_t pending_queries;uint16_t pool_index;uint8_t query_thread_on; +bool relaxed_ordering; LIST_HEAD(mem_mngs, mlx5_counter_stats_mem_mng) mem_mngs; LIST_HEAD(stat_raws, mlx5_counter_stats_raw) free_stat_raws; };
drivers/net/mlx5/mlx5_flow.c +116 -4
160 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_dv.c +43 -128
251 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_verbs.c +2 -3
@@ -259,7 +259,7 @@struct mlx5_flow_counter_ext *cnt_ext =NULL ;struct mlx5_flow_counter *cnt =NULL ;union mlx5_l3t_data data; -uint32_t n_valid =rte_atomic16_read (&cmng->n_valid); +uint32_t n_valid = cmng->n_valid;uint32_t pool_idx, cnt_idx;uint32_t i;int ret;
@@ -317,8 +317,7 @@ cnt =MLX5_POOL_GET_CNT (pool,0 ); cmng->pools[n_valid] = pool; pool_idx = n_valid; -rte_atomic16_add (&cmng->n_valid,1 ); -TAILQ_INSERT_HEAD (&cmng->pool_list, pool, next); + cmng->n_valid++; } i =MLX5_CNT_ARRAY_IDX (pool, cnt); cnt_idx =MLX5_MAKE_CNT_IDX (pool_idx, i);
Signature · 1 line
1.8.3.1
PATCH v2 5/8 net/mlx5: make three level table thread safe
In reply to Suanming MouThis commit adds thread safety support in three level table using spinlock and reference counter for each table entry.
An new mlx5_l3t_prepare_entry() function is added in order to support multiple-thread operation.
--- drivers/net/mlx5/mlx5_utils.c | 191 ++++++++++++++++++++++++++++++++++-------- drivers/net/mlx5/mlx5_utils.h | 81 ++++++++++++++---- 2 files changed, 224 insertions(+), 48 deletions(-)
drivers/net/mlx5/mlx5_utils.c +157 -34
@@ -551,26 +551,23 @@ struct mlx5_l3t_tbl * tbl->type = type;switch (type) {case MLX5_L3T_TYPE_WORD : - l3t_ip_cfg.size =sizeof (struct mlx5_l3t_entry_word ) + -sizeof (uint16_t ) *MLX5_L3T_ET_SIZE ; + l3t_ip_cfg.size =sizeof (struct mlx5_l3t_entry_word ); l3t_ip_cfg.type ="mlx5_l3t_e_tbl_w" ;break ;case MLX5_L3T_TYPE_DWORD : - l3t_ip_cfg.size =sizeof (struct mlx5_l3t_entry_dword ) + -sizeof (uint32_t ) *MLX5_L3T_ET_SIZE ; + l3t_ip_cfg.size =sizeof (struct mlx5_l3t_entry_dword ); l3t_ip_cfg.type ="mlx5_l3t_e_tbl_dw" ;break ;case MLX5_L3T_TYPE_QWORD : - l3t_ip_cfg.size =sizeof (struct mlx5_l3t_entry_qword ) + -sizeof (uint64_t ) *MLX5_L3T_ET_SIZE ; + l3t_ip_cfg.size =sizeof (struct mlx5_l3t_entry_qword ); l3t_ip_cfg.type ="mlx5_l3t_e_tbl_qw" ;break ;default : - l3t_ip_cfg.size =sizeof (struct mlx5_l3t_entry_ptr ) + -sizeof (void *) *MLX5_L3T_ET_SIZE ; + l3t_ip_cfg.size =sizeof (struct mlx5_l3t_entry_ptr ); l3t_ip_cfg.type ="mlx5_l3t_e_tbl_tpr" ;break ; } +rte_spinlock_init (&tbl->sl); tbl->eip =mlx5_ipool_create (&l3t_ip_cfg);if (!tbl->eip) { rte_errno =ENOMEM ;
@@ -620,11 +617,15 @@ struct mlx5_l3t_tbl *mlx5_free (tbl); } -uint32_t -mlx5_l3t_get_entry (struct mlx5_l3t_tbl *tbl,uint32_t idx, -union mlx5_l3t_data *data) +static int32_t +__l3t_get_entry (struct mlx5_l3t_tbl *tbl,uint32_t idx, +union mlx5_l3t_data *data) {struct mlx5_l3t_level_tbl *g_tbl, *m_tbl; +struct mlx5_l3t_entry_word *w_e_tbl; +struct mlx5_l3t_entry_dword *dw_e_tbl; +struct mlx5_l3t_entry_qword *qw_e_tbl; +struct mlx5_l3t_entry_ptr *ptr_e_tbl;void *e_tbl;uint32_t entry_idx;
@@ -640,26 +641,46 @@ struct mlx5_l3t_tbl * entry_idx = idx &MLX5_L3T_ET_MASK ;switch (tbl->type) {case MLX5_L3T_TYPE_WORD : - data->word = ((struct mlx5_l3t_entry_word *)e_tbl)->entry - [entry_idx]; + w_e_tbl = (struct mlx5_l3t_entry_word *)e_tbl; + data->word = w_e_tbl->entry[entry_idx].data; +if (w_e_tbl->entry[entry_idx].data) + w_e_tbl->entry[entry_idx].ref_cnt++;break ;case MLX5_L3T_TYPE_DWORD : - data->dword = ((struct mlx5_l3t_entry_dword *)e_tbl)->entry - [entry_idx]; + dw_e_tbl = (struct mlx5_l3t_entry_dword *)e_tbl; + data->dword = dw_e_tbl->entry[entry_idx].data; +if (dw_e_tbl->entry[entry_idx].data) + dw_e_tbl->entry[entry_idx].ref_cnt++;break ;case MLX5_L3T_TYPE_QWORD : - data->qword = ((struct mlx5_l3t_entry_qword *)e_tbl)->entry - [entry_idx]; + qw_e_tbl = (struct mlx5_l3t_entry_qword *)e_tbl; + data->qword = qw_e_tbl->entry[entry_idx].data; +if (qw_e_tbl->entry[entry_idx].data) + qw_e_tbl->entry[entry_idx].ref_cnt++;break ;default : - data->ptr = ((struct mlx5_l3t_entry_ptr *)e_tbl)->entry - [entry_idx]; + ptr_e_tbl = (struct mlx5_l3t_entry_ptr *)e_tbl; + data->ptr = ptr_e_tbl->entry[entry_idx].data; +if (ptr_e_tbl->entry[entry_idx].data) + ptr_e_tbl->entry[entry_idx].ref_cnt++;break ; }return 0 ; } -void +int32_t +mlx5_l3t_get_entry (struct mlx5_l3t_tbl *tbl,uint32_t idx, +union mlx5_l3t_data *data) +{ +int ret; + +rte_spinlock_lock (&tbl->sl); + ret =__l3t_get_entry (tbl, idx, data); +rte_spinlock_unlock (&tbl->sl); +return ret; +} + +int32_t mlx5_l3t_clear_entry (struct mlx5_l3t_tbl *tbl,uint32_t idx) {struct mlx5_l3t_level_tbl *g_tbl, *m_tbl;
@@ -670,36 +691,54 @@ struct mlx5_l3t_tbl *void *e_tbl;uint32_t entry_idx;uint64_t ref_cnt; +int32_t ret =-1 ; +rte_spinlock_lock (&tbl->sl); g_tbl = tbl->tbl;if (!g_tbl) -return ; + goto out; m_tbl = g_tbl->tbl[(idx >>MLX5_L3T_GT_OFFSET ) &MLX5_L3T_GT_MASK ];if (!m_tbl) -return ; + goto out; e_tbl = m_tbl->tbl[(idx >>MLX5_L3T_MT_OFFSET ) &MLX5_L3T_MT_MASK ];if (!e_tbl) -return ; + goto out; entry_idx = idx &MLX5_L3T_ET_MASK ;switch (tbl->type) {case MLX5_L3T_TYPE_WORD : w_e_tbl = (struct mlx5_l3t_entry_word *)e_tbl; - w_e_tbl->entry[entry_idx] =0 ; +MLX5_ASSERT (w_e_tbl->entry[entry_idx].ref_cnt); + ret = --w_e_tbl->entry[entry_idx].ref_cnt; +if (ret) + goto out; + w_e_tbl->entry[entry_idx].data =0 ; ref_cnt = --w_e_tbl->ref_cnt;break ;case MLX5_L3T_TYPE_DWORD : dw_e_tbl = (struct mlx5_l3t_entry_dword *)e_tbl; - dw_e_tbl->entry[entry_idx] =0 ; +MLX5_ASSERT (dw_e_tbl->entry[entry_idx].ref_cnt); + ret = --dw_e_tbl->entry[entry_idx].ref_cnt; +if (ret) + goto out; + dw_e_tbl->entry[entry_idx].data =0 ; ref_cnt = --dw_e_tbl->ref_cnt;break ;case MLX5_L3T_TYPE_QWORD : qw_e_tbl = (struct mlx5_l3t_entry_qword *)e_tbl; - qw_e_tbl->entry[entry_idx] =0 ; +MLX5_ASSERT (qw_e_tbl->entry[entry_idx].ref_cnt); + ret = --qw_e_tbl->entry[entry_idx].ref_cnt; +if (ret) + goto out; + qw_e_tbl->entry[entry_idx].data =0 ; ref_cnt = --qw_e_tbl->ref_cnt;break ;default : ptr_e_tbl = (struct mlx5_l3t_entry_ptr *)e_tbl; - ptr_e_tbl->entry[entry_idx] =NULL ; +MLX5_ASSERT (ptr_e_tbl->entry[entry_idx].ref_cnt); + ret = --ptr_e_tbl->entry[entry_idx].ref_cnt; +if (ret) + goto out; + ptr_e_tbl->entry[entry_idx].data =NULL ; ref_cnt = --ptr_e_tbl->ref_cnt;break ; }
@@ -718,11 +757,14 @@ struct mlx5_l3t_tbl * } } } +out: +rte_spinlock_unlock (&tbl->sl); +return ret; } -uint32_t -mlx5_l3t_set_entry (struct mlx5_l3t_tbl *tbl,uint32_t idx, -union mlx5_l3t_data *data) +static int32_t +__l3t_set_entry (struct mlx5_l3t_tbl *tbl,uint32_t idx, +union mlx5_l3t_data *data) {struct mlx5_l3t_level_tbl *g_tbl, *m_tbl;struct mlx5_l3t_entry_word *w_e_tbl;
@@ -783,24 +825,105 @@ struct mlx5_l3t_tbl *switch (tbl->type) {case MLX5_L3T_TYPE_WORD : w_e_tbl = (struct mlx5_l3t_entry_word *)e_tbl; - w_e_tbl->entry[entry_idx] = data->word; +if (w_e_tbl->entry[entry_idx].data) { + data->word = w_e_tbl->entry[entry_idx].data; + w_e_tbl->entry[entry_idx].ref_cnt++; + rte_errno =EEXIST ; +return -1 ; + } + w_e_tbl->entry[entry_idx].data = data->word; + w_e_tbl->entry[entry_idx].ref_cnt =1 ; w_e_tbl->ref_cnt++;break ;case MLX5_L3T_TYPE_DWORD : dw_e_tbl = (struct mlx5_l3t_entry_dword *)e_tbl; - dw_e_tbl->entry[entry_idx] = data->dword; +if (dw_e_tbl->entry[entry_idx].data) { + data->dword = dw_e_tbl->entry[entry_idx].data; + dw_e_tbl->entry[entry_idx].ref_cnt++; + rte_errno =EEXIST ; +return -1 ; + } + dw_e_tbl->entry[entry_idx].data = data->dword; + dw_e_tbl->entry[entry_idx].ref_cnt =1 ; dw_e_tbl->ref_cnt++;break ;case MLX5_L3T_TYPE_QWORD : qw_e_tbl = (struct mlx5_l3t_entry_qword *)e_tbl; - qw_e_tbl->entry[entry_idx] = data->qword; +if (qw_e_tbl->entry[entry_idx].data) { + data->qword = qw_e_tbl->entry[entry_idx].data; + qw_e_tbl->entry[entry_idx].ref_cnt++; + rte_errno =EEXIST ; +return -1 ; + } + qw_e_tbl->entry[entry_idx].data = data->qword; + qw_e_tbl->entry[entry_idx].ref_cnt =1 ; qw_e_tbl->ref_cnt++;break ;default : ptr_e_tbl = (struct mlx5_l3t_entry_ptr *)e_tbl; - ptr_e_tbl->entry[entry_idx] = data->ptr; +if (ptr_e_tbl->entry[entry_idx].data) { + data->ptr = ptr_e_tbl->entry[entry_idx].data; + ptr_e_tbl->entry[entry_idx].ref_cnt++; + rte_errno =EEXIST ; +return -1 ; + } + ptr_e_tbl->entry[entry_idx].data = data->ptr; + ptr_e_tbl->entry[entry_idx].ref_cnt =1 ; ptr_e_tbl->ref_cnt++;break ; }return 0 ; } + +int32_t +mlx5_l3t_set_entry (struct mlx5_l3t_tbl *tbl,uint32_t idx, +union mlx5_l3t_data *data) +{ +int ret; + +rte_spinlock_lock (&tbl->sl); + ret =__l3t_set_entry (tbl, idx, data); +rte_spinlock_unlock (&tbl->sl); +return ret; +} + +int32_t +mlx5_l3t_prepare_entry (struct mlx5_l3t_tbl *tbl,uint32_t idx, +union mlx5_l3t_data *data, +mlx5_l3t_alloc_callback_fn cb,void *ctx) +{ +int32_t ret; + +rte_spinlock_lock (&tbl->sl); +/* Check if entry data is ready. */ + ret =__l3t_get_entry (tbl, idx, data); +if (!ret) { +switch (tbl->type) { +case MLX5_L3T_TYPE_WORD : +if (data->word) + goto out; +break ; +case MLX5_L3T_TYPE_DWORD : +if (data->dword) + goto out; +break ; +case MLX5_L3T_TYPE_QWORD : +if (data->qword) + goto out; +break ; +default : +if (data->ptr) + goto out; +break ; + } + } +/* Entry data is not ready, use user callback to create it. */ + ret =cb (ctx, data); +if (ret) + goto out; +/* Save the new allocated data to entry. */ + ret =__l3t_set_entry (tbl, idx, data); +out: +rte_spinlock_unlock (&tbl->sl); +return ret; +}
drivers/net/mlx5/mlx5_utils.h +67 -14
136 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH v2 6/8 net/mlx5: make shared counters thread safe
In reply to Suanming MouThe shared counters save the counter index to three level table. As three level table supports multiple-thread opertations now, the shared counters can take advantage of the table to support multiple-thread.
--- drivers/net/mlx5/mlx5.h | 7 ++- drivers/net/mlx5/mlx5_flow_dv.c | 124 +++++++++++++++++++------------------ drivers/net/mlx5/mlx5_flow_verbs.c | 19 ++---- 3 files changed, 73 insertions(+), 77 deletions(-)
drivers/net/mlx5/mlx5.h +6 -1
@@ -348,10 +348,15 @@ struct flow_counter_stats {/* Shared counters information for counters. */ struct mlx5_flow_counter_shared { -uint32_t ref_cnt;/**< Reference counter. */ uint32_t id;/**< User counter ID. */ }; +/* Shared counter configuration. */ +struct mlx5_shared_counter_conf { +struct rte_eth_dev *dev;/* The device shared counter belongs to. */ +uint32_t id;/* The shared counter ID. */ +}; +struct mlx5_flow_counter_pool ;/* Generic counters information. */ struct mlx5_flow_counter {
drivers/net/mlx5/mlx5_flow_dv.c +63 -61
176 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_verbs.c +4 -15
@@ -265,15 +265,8 @@int ret;if (shared && !mlx5_l3t_get_entry (priv->sh->cnt_id_tbl, id, &data) && - data.dword) { - cnt =flow_verbs_counter_get_by_idx (dev, data.dword,NULL ); -if (cnt->shared_info.ref_cnt +1 ==0 ) { - rte_errno =E2BIG ; -return 0 ; - } - cnt->shared_info.ref_cnt++; + data.dword)return data.dword; - }for (pool_idx =0 ; pool_idx < n_valid; ++pool_idx) { pool = cmng->pools[pool_idx];if (!pool)
@@ -325,7 +318,6 @@ data.dword = cnt_idx;if (mlx5_l3t_set_entry (priv->sh->cnt_id_tbl, id, &data))return 0 ; - cnt->shared_info.ref_cnt =1 ; cnt->shared_info.id = id; cnt_idx |=MLX5_CNT_SHARED_OFFSET ; }
@@ -360,12 +352,9 @@struct mlx5_flow_counter_ext *cnt_ext; cnt =flow_verbs_counter_get_by_idx (dev, counter, &pool); -if (IS_SHARED_CNT (counter)) { -if (--cnt->shared_info.ref_cnt) -return ; -mlx5_l3t_clear_entry (priv->sh->cnt_id_tbl, - cnt->shared_info.id); - } +if (IS_SHARED_CNT (counter) && +mlx5_l3t_clear_entry (priv->sh->cnt_id_tbl, cnt->shared_info.id)) +return ; cnt_ext =MLX5_CNT_TO_CNT_EXT (pool, cnt);#if defined(HAVE_IBV_DEVICE_COUNTERS_SET_V42 )claim_zero (mlx5_glue->destroy_counter_set (cnt_ext->cs));
Signature · 1 line
1.8.3.1
PATCH v2 7/8 net/mlx5: rename flow counter macro
In reply to Suanming MouAdd the MLX5_ prefix to the defined counter macro names.
--- drivers/net/mlx5/mlx5.h | 22 +++++++++++----------- drivers/net/mlx5/mlx5_flow_dv.c | 10 +++++----- drivers/net/mlx5/mlx5_flow_verbs.c | 2 +- 3 files changed, 17 insertions(+), 17 deletions(-)
drivers/net/mlx5/mlx5.h +11 -11
@@ -276,19 +276,19 @@ struct mlx5_drop {#define IS_SHARED_CNT (cnt) (!!((cnt) & MLX5_CNT_SHARED_OFFSET))#define IS_BATCH_CNT (cnt) (((cnt) & (MLX5_CNT_SHARED_OFFSET - 1)) >= \ MLX5_CNT_BATCH_OFFSET) -#define CNT_SIZE (sizeof(struct mlx5_flow_counter)) -#define CNTEXT_SIZE (sizeof(struct mlx5_flow_counter_ext)) -#define AGE_SIZE (sizeof(struct mlx5_age_param)) -#define CNT_POOL_TYPE_EXT (1 << 0) -#define CNT_POOL_TYPE_AGE (1 << 1) +#define MLX5_CNT_SIZE (sizeof(struct mlx5_flow_counter)) +#define MLX5_CNTEXT_SIZE (sizeof(struct mlx5_flow_counter_ext)) +#define MLX5_AGE_SIZE (sizeof(struct mlx5_age_param)) +#define MLX5_CNT_POOL_TYPE_EXT (1 << 0) +#define MLX5_CNT_POOL_TYPE_AGE (1 << 1) -#define IS_EXT_POOL (pool) (((pool)->type) & CNT_POOL_TYPE_EXT) -#define IS_AGE_POOL (pool) (((pool)->type) & CNT_POOL_TYPE_AGE) +#define IS_EXT_POOL (pool) (((pool)->type) & MLX5_CNT_POOL_TYPE_EXT) +#define IS_AGE_POOL (pool) (((pool)->type) & MLX5_CNT_POOL_TYPE_AGE)#define MLX5_CNT_LEN (pool) \ - (CNT_SIZE + \ - (IS_AGE_POOL(pool) ? AGE_SIZE : 0) + \ - (IS_EXT_POOL(pool) ? CNTEXT_SIZE : 0)) + (MLX5_CNT_SIZE + \ + (IS_AGE_POOL(pool) ? MLX5_AGE_SIZE : 0) + \ + (IS_EXT_POOL(pool) ? MLX5_CNTEXT_SIZE : 0))#define MLX5_POOL_GET_CNT (pool, index) \ ((struct mlx5_flow_counter *) \ ((uint8_t *)((pool) + 1) + (index) * (MLX5_CNT_LEN(pool))))
@@ -306,7 +306,7 @@ struct mlx5_drop {#define MLX5_CNT_TO_CNT_EXT (pool, cnt) \ ((struct mlx5_flow_counter_ext *)\ ((uint8_t *)((cnt) + 1) + \ - (IS_AGE_POOL(pool) ? AGE_SIZE : 0))) + (IS_AGE_POOL(pool) ? MLX5_AGE_SIZE : 0)))#define MLX5_GET_POOL_CNT_EXT (pool, offset) \ MLX5_CNT_TO_CNT_EXT(pool, MLX5_POOL_GET_CNT((pool), (offset)))#define MLX5_CNT_TO_AGE (cnt) \
drivers/net/mlx5/mlx5_flow_dv.c +5 -5
@@ -4787,9 +4787,9 @@ struct field_modify_info modify_tcp[] = {uint32_t fallback = priv->counter_fallback;uint32_t size =sizeof (*pool); - size +=MLX5_COUNTERS_PER_POOL *CNT_SIZE ; - size += (!fallback ?0 :MLX5_COUNTERS_PER_POOL *CNTEXT_SIZE ); - size += (!age ?0 :MLX5_COUNTERS_PER_POOL *AGE_SIZE ); + size +=MLX5_COUNTERS_PER_POOL *MLX5_CNT_SIZE ; + size += (!fallback ?0 :MLX5_COUNTERS_PER_POOL *MLX5_CNTEXT_SIZE ); + size += (!age ?0 :MLX5_COUNTERS_PER_POOL *MLX5_AGE_SIZE ); pool =mlx5_malloc (MLX5_MEM_ZERO , size,0 ,SOCKET_ID_ANY );if (!pool) { rte_errno =ENOMEM ;
@@ -4797,7 +4797,7 @@ struct field_modify_info modify_tcp[] = { } pool->raw =NULL ; pool->type =0 ; - pool->type |= (!age ?0 :CNT_POOL_TYPE_AGE ); + pool->type |= (!age ?0 :MLX5_CNT_POOL_TYPE_AGE ); pool->query_gen =0 ; pool->min_dcs = dcs;rte_spinlock_init (&pool->sl);
@@ -4822,7 +4822,7 @@ struct field_modify_info modify_tcp[] = {if (base > cmng->max_id) cmng->max_id = base +MLX5_COUNTERS_PER_POOL -1 ; cmng->last_pool_idx = pool->index; - pool->type |=CNT_POOL_TYPE_EXT ; + pool->type |=MLX5_CNT_POOL_TYPE_EXT ; }rte_spinlock_unlock (&cmng->pool_update_sl);return pool;
drivers/net/mlx5/mlx5_flow_verbs.c +1 -1
@@ -302,7 +302,7 @@ pool =mlx5_malloc (MLX5_MEM_ZERO , size,0 ,SOCKET_ID_ANY );if (!pool)return 0 ; - pool->type |=CNT_POOL_TYPE_EXT ; + pool->type |=MLX5_CNT_POOL_TYPE_EXT ;for (i =0 ; i <MLX5_COUNTERS_PER_POOL ; ++i) { cnt =MLX5_POOL_GET_CNT (pool, i);TAILQ_INSERT_HEAD (&pool->counters[0 ], cnt, next);
Signature · 1 line
1.8.3.1
PATCH v2 8/8 net/mlx5: optimize counter extend memory
In reply to Suanming MouCounter extend memory was allocated for non-batch counter to save the extra DevX object. Currently, for non-batch counter which does not support aging, entry in the generic counter struct is used only when counter is free in free list, and bytes in the struct is used only when counter is allocated in using.
In this case, the DevX object can be saved to the generic counter struct union with entry memory when counter is allocated and union with bytes when counter is free.
And pool type is also not needed as non-fallback mode only has generic counter and aging counter, just a bit to indicate the pool is aged or not will be enough.
This eliminates the counter extend info struct saves the memory.
--- drivers/net/mlx5/linux/mlx5_os.c | 22 +++++++++----- drivers/net/mlx5/mlx5.c | 18 ++++++----- drivers/net/mlx5/mlx5.h | 60 ++++++++++++++++++------------------ drivers/net/mlx5/mlx5_flow.c | 6 ++-- drivers/net/mlx5/mlx5_flow_dv.c | 38 +++++++++++------------ drivers/net/mlx5/mlx5_flow_verbs.c | 62 +++++++++++++++++--------------------- 6 files changed, 100 insertions(+), 106 deletions(-)
drivers/net/mlx5/linux/mlx5_os.c +14 -8
@@ -573,24 +573,30 @@ {#ifdef HAVE_IBV_FLOW_DV_SUPPORT struct mlx5_priv *priv = dev->data->dev_private; +struct mlx5_dev_ctx_shared *sh = priv->sh; +bool fallback; -/* If devx is not supported or not DV mode, counters are not working. */ -if (!priv->config.devx || !priv->config.dv_flow_en) -return ;#ifndef HAVE_IBV_DEVX_ASYNC - priv->counter_fallback =1 ; + fallback = true;#else - priv->counter_fallback =0 ; -if (!priv->config.hca_attr.flow_counters_dump || + fallback = false; +if (!priv->config.devx || !priv->config.dv_flow_en || + !priv->config.hca_attr.flow_counters_dump || !(priv->config.hca_attr.flow_counter_bulk_alloc_bitmap &0x4 ) || (mlx5_flow_dv_discover_counter_offset_support (dev) == -ENOTSUP )) - priv->counter_fallback =1 ; + fallback = true;#endif -if (priv->counter_fallback) +if (fallback)DRV_LOG (INFO ,"Use fall-back DV counter management. Flow " "counter dump:%d, bulk_alloc_bitmap:0x%hhx." , priv->config.hca_attr.flow_counters_dump, priv->config.hca_attr.flow_counter_bulk_alloc_bitmap); +/* Initialize fallback mode only on the port initializes sh. */ +if (sh->refcnt ==1 ) + sh->cmng.counter_fallback = fallback; +else if (fallback != sh->cmng.counter_fallback) +DRV_LOG (WARNING ,"Port %d in sh has different fallback mode " +"with others:%d." ,PORT_ID (priv), fallback);#endif }
drivers/net/mlx5/mlx5.c +10 -8
@@ -535,23 +535,25 @@ struct mlx5_flow_id_pool *if (sh->cmng.pools) {struct mlx5_flow_counter_pool *pool;uint16_t n_valid = sh->cmng.n_valid; +bool fallback = sh->cmng.counter_fallback;for (i =0 ; i < n_valid; ++i) { pool = sh->cmng.pools[i]; -if (!IS_EXT_POOL (pool) && pool->min_dcs) +if (!fallback && pool->min_dcs)claim_zero (mlx5_devx_cmd_destroy (pool->min_dcs));for (j =0 ; j <MLX5_COUNTERS_PER_POOL ; ++j) { -if (MLX5_POOL_GET_CNT (pool, j)->action) +struct mlx5_flow_counter *cnt = +MLX5_POOL_GET_CNT (pool, j); + +if (cnt->action)claim_zero (mlx5_glue->destroy_flow_action - (MLX5_POOL_GET_CNT - (pool, j)->action)); -if (IS_EXT_POOL (pool) &&MLX5_GET_POOL_CNT_EXT - (pool, j)->dcs) + (cnt->action)); +if (fallback &&MLX5_POOL_GET_CNT + (pool, j)->dcs_when_free)claim_zero (mlx5_devx_cmd_destroy - (MLX5_GET_POOL_CNT_EXT - (pool, j)->dcs)); + (cnt->dcs_when_free)); }mlx5_free (pool); }
drivers/net/mlx5/mlx5.h +29 -31
110 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow.c +3 -3
@@ -6876,14 +6876,14 @@ struct mlx5_meter_domains_infos *uint8_t query_gen = pool->query_gen ^1 ;struct mlx5_flow_counter_mng *cmng = &sh->cmng;enum mlx5_counter_type cnt_type = -IS_AGE_POOL (pool) ?MLX5_COUNTER_TYPE_AGE : -MLX5_COUNTER_TYPE_ORIGIN ; + pool->is_aged ?MLX5_COUNTER_TYPE_AGE : +MLX5_COUNTER_TYPE_ORIGIN ;if (unlikely (status)) { raw_to_free = pool->raw_hw; }else { raw_to_free = pool->raw; -if (IS_AGE_POOL (pool)) +if (pool->is_aged)mlx5_flow_aging_check (sh, pool);rte_spinlock_lock (&pool->sl); pool->raw = pool->raw_hw;
drivers/net/mlx5/mlx5_flow_dv.c +17 -21
@@ -4170,7 +4170,7 @@ struct field_modify_info modify_tcp[] = {struct mlx5_priv *priv = dev->data->dev_private;const struct rte_flow_action_age *age = action->conf; -if (!priv->config.devx || priv->counter_fallback) +if (!priv->config.devx || priv->sh->cmng.counter_fallback) return rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
@@ -4739,16 +4739,13 @@ struct field_modify_info modify_tcp[] = {struct mlx5_priv *priv = dev->data->dev_private;struct mlx5_flow_counter_pool *pool =NULL ;struct mlx5_flow_counter *cnt; -struct mlx5_flow_counter_ext *cnt_ext =NULL ;int offset; cnt =flow_dv_counter_get_by_idx (dev, counter, &pool);MLX5_ASSERT (pool); -if (priv->counter_fallback) { - cnt_ext =MLX5_CNT_TO_CNT_EXT (pool, cnt); -return mlx5_devx_cmd_flow_counter_query (cnt_ext->dcs,0 , +if (priv->sh->cmng.counter_fallback) +return mlx5_devx_cmd_flow_counter_query (cnt->dcs_when_active,0 ,0 , pkts, bytes,0 ,NULL ,NULL ,0 ); - }rte_spinlock_lock (&pool->sl);if (!pool->raw) { *pkts =0 ;
@@ -4784,11 +4781,10 @@ struct field_modify_info modify_tcp[] = {struct mlx5_priv *priv = dev->data->dev_private;struct mlx5_flow_counter_pool *pool;struct mlx5_flow_counter_mng *cmng = &priv->sh->cmng; -uint32_t fallback = priv->counter_fallback; +bool fallback = priv->sh->cmng.counter_fallback;uint32_t size =sizeof (*pool); size +=MLX5_COUNTERS_PER_POOL *MLX5_CNT_SIZE ; - size += (!fallback ?0 :MLX5_COUNTERS_PER_POOL *MLX5_CNTEXT_SIZE ); size += (!age ?0 :MLX5_COUNTERS_PER_POOL *MLX5_AGE_SIZE ); pool =mlx5_malloc (MLX5_MEM_ZERO , size,0 ,SOCKET_ID_ANY );if (!pool) {
@@ -4796,8 +4792,7 @@ struct field_modify_info modify_tcp[] = {return NULL ; } pool->raw =NULL ; - pool->type =0 ; - pool->type |= (!age ?0 :MLX5_CNT_POOL_TYPE_AGE ); + pool->is_aged = !!age; pool->query_gen =0 ; pool->min_dcs = dcs;rte_spinlock_init (&pool->sl);
@@ -4822,7 +4817,6 @@ struct field_modify_info modify_tcp[] = {if (base > cmng->max_id) cmng->max_id = base +MLX5_COUNTERS_PER_POOL -1 ; cmng->last_pool_idx = pool->index; - pool->type |=MLX5_CNT_POOL_TYPE_EXT ; }rte_spinlock_unlock (&cmng->pool_update_sl);return pool;
@@ -4855,7 +4849,7 @@ struct field_modify_info modify_tcp[] = {struct mlx5_flow_counter *cnt;enum mlx5_counter_type cnt_type = age ?MLX5_COUNTER_TYPE_AGE :MLX5_COUNTER_TYPE_ORIGIN ; -uint32_t fallback = priv->counter_fallback; +bool fallback = priv->sh->cmng.counter_fallback;uint32_t i;if (fallback) {
@@ -4874,7 +4868,7 @@ struct field_modify_info modify_tcp[] = { i = dcs->id %MLX5_COUNTERS_PER_POOL ; cnt =MLX5_POOL_GET_CNT (pool, i); cnt->pool = pool; -MLX5_GET_POOL_CNT_EXT (pool, i)->dcs = dcs; + cnt->dcs_when_free = dcs; *cnt_free = cnt;return pool; }
@@ -4919,8 +4913,7 @@ struct field_modify_info modify_tcp[] = {struct mlx5_priv *priv = dev->data->dev_private;struct mlx5_flow_counter_pool *pool =NULL ;struct mlx5_flow_counter *cnt_free =NULL ; -struct mlx5_flow_counter_ext *cnt_ext =NULL ; -uint32_t fallback = priv->counter_fallback; +bool fallback = priv->sh->cmng.counter_fallback;struct mlx5_flow_counter_mng *cmng = &priv->sh->cmng;enum mlx5_counter_type cnt_type = age ?MLX5_COUNTER_TYPE_AGE :MLX5_COUNTER_TYPE_ORIGIN ;
@@ -4940,7 +4933,7 @@ struct field_modify_info modify_tcp[] = { goto err; pool = cnt_free->pool;if (fallback) - cnt_ext =MLX5_CNT_TO_CNT_EXT (pool, cnt_free); + cnt_free->dcs_when_active = cnt_free->dcs_when_free;/* Create a DV counter action only in the first time usage. */ if (!cnt_free->action) {uint16_t offset;
@@ -4952,7 +4945,7 @@ struct field_modify_info modify_tcp[] = { dcs = pool->min_dcs; }else { offset =0 ; - dcs = cnt_ext->dcs; + dcs = cnt_free->dcs_when_free; } ret =mlx5_flow_os_create_flow_action_count (dcs->obj, offset, &cnt_free->action);
@@ -4974,6 +4967,8 @@ struct field_modify_info modify_tcp[] = { err:if (cnt_free) { cnt_free->pool = pool; +if (fallback) + cnt_free->dcs_when_free = cnt_free->dcs_when_active;rte_spinlock_lock (&cmng->csl[cnt_type]);TAILQ_INSERT_TAIL (&cmng->counters[cnt_type], cnt_free, next);rte_spinlock_unlock (&cmng->csl[cnt_type]);
@@ -5117,7 +5112,7 @@ struct field_modify_info modify_tcp[] = {if (IS_SHARED_CNT (counter) &&mlx5_l3t_clear_entry (priv->sh->cnt_id_tbl, cnt->shared_info.id))return ; -if (IS_AGE_POOL (pool)) +if (pool->is_aged)flow_dv_counter_remove_from_age (dev, counter, cnt); cnt->pool = pool;/*
@@ -5130,13 +5125,14 @@ struct field_modify_info modify_tcp[] = {* function both operate with the different list. * */ -if (!priv->counter_fallback) { +if (!priv->sh->cmng.counter_fallback) {rte_spinlock_lock (&pool->csl);TAILQ_INSERT_TAIL (&pool->counters[pool->query_gen], cnt, next);rte_spinlock_unlock (&pool->csl); }else { - cnt_type =IS_AGE_POOL (pool) ?MLX5_COUNTER_TYPE_AGE : -MLX5_COUNTER_TYPE_ORIGIN ; + cnt->dcs_when_free = cnt->dcs_when_active; + cnt_type = pool->is_aged ?MLX5_COUNTER_TYPE_AGE : +MLX5_COUNTER_TYPE_ORIGIN ;rte_spinlock_lock (&priv->sh->cmng.csl[cnt_type]);TAILQ_INSERT_TAIL (&priv->sh->cmng.counters[cnt_type], cnt, next);
drivers/net/mlx5/mlx5_flow_verbs.c +27 -35
167 lines not on this page · raw message
Signature · 1 line
1.8.3.1
Hi,
Quoted 40 lines
-----Original Message-----
From: dev <[email protected]> On Behalf Of Suanming Mou
Sent: Tuesday, October 20, 2020 6:02 AM
Cc: [email protected]
Subject: [dpdk-dev] [PATCH v2 0/8] net/mlx5: make counter thread safeThe mlx5 PMD is going to support multiple-thread flow operations. This patchset makes the counter action to be thread safe.
Suanming Mou (8):
net/mlx5: locate aging pools in the general container net/mlx5: optimize shared counter memory net/mlx5: remove single counter container net/mlx5: synchronize flow counter pool creation net/mlx5: make three level table thread safe net/mlx5: make shared counters thread safe net/mlx5: rename flow counter macro net/mlx5: optimize counter extend memory--
v2:
- Optimize the fallback non-batch counter memory.
- AddMLX5_prefix to counter macro.
- Rebase on top of the latest code.--
drivers/net/mlx5/linux/mlx5_os.c | 53 ++- drivers/net/mlx5/mlx5.c | 51 ++- drivers/net/mlx5/mlx5.h | 146 ++++---- drivers/net/mlx5/mlx5_flow.c | 183 ++++++---- drivers/net/mlx5/mlx5_flow.h | 1 + drivers/net/mlx5/mlx5_flow_dv.c | 706 ++++++++++++++-------------------- --- drivers/net/mlx5/mlx5_flow_verbs.c | 130 ++++--- drivers/net/mlx5/mlx5_utils.c | 191 ++++++++-- drivers/net/mlx5/mlx5_utils.h | 81 ++++- 9 files changed, 824 insertions(+), 718 deletions(-)
Quoted 2 lines
--
1.8.3.1
Series applied to next-net-mlx,
Kindest regards,
Raslan Darawsheh