net/mlx5: fix sync meter processing in HWS setup
cover net/mlx5: fix sync meter processing in HWS setup
Implement sync meter ASO interface for async calls in the template API environment.
Gregory Etelson (3):
net/mlx5: fix HWS meter actions availability net/mlx5: fix sync meter processing in HWS setup net/mlx5: fix indirect action async job initialization
drivers/net/mlx5/mlx5.h | 35 +++++- drivers/net/mlx5/mlx5_flow_aso.c | 178 ++++++++++++++++++----------- drivers/net/mlx5/mlx5_flow_hw.c | 119 ++++++++++--------- drivers/net/mlx5/mlx5_flow_meter.c | 55 ++++++--- 4 files changed, 251 insertions(+), 136 deletions(-)
Signature · 1 line
2.39.2
PATCH 1/3 net/mlx5: fix HWS meter actions availability
Allow compilation of HWS meter code only on platforms that support HWS.
--- drivers/net/mlx5/mlx5_flow_meter.c | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-)
drivers/net/mlx5/mlx5_flow_meter.c +24 -4
@@ -896,6 +896,7 @@ mlx5_flow_meter_profile_get(struct rte_eth_dev *dev, meter_profile_id); } +#if defined(HAVE_MLX5_HWS_SUPPORT )/** * Callback to add MTR profile with HWS. *
@@ -981,6 +982,7 @@ mlx5_flow_meter_profile_hws_delete(struct rte_eth_dev *dev,memset (fmp,0 ,sizeof (struct mlx5_flow_meter_profile )); return 0; } +#endif /** * Find policy by id.
@@ -1123,6 +1125,7 @@ mlx5_flow_meter_policy_validate(struct rte_eth_dev *dev,return 0 ; } +#if defined(HAVE_MLX5_HWS_SUPPORT )/** * Callback to check MTR policy action validate for HWS *
@@ -1159,6 +1162,7 @@ mlx5_flow_meter_policy_hws_validate(struct rte_eth_dev *dev, }return 0 ; } +#endif static int __mlx5_flow_meter_policy_delete(struct rte_eth_dev *dev,
@@ -1485,6 +1489,7 @@ mlx5_flow_meter_policy_get(struct rte_eth_dev *dev, &policy_idx); } +#if defined(HAVE_MLX5_HWS_SUPPORT )/** * Callback to delete MTR policy for HWS. *
@@ -1807,7 +1812,7 @@ mlx5_flow_meter_policy_hws_add(struct rte_eth_dev *dev,RTE_MTR_ERROR_TYPE_UNSPECIFIED , NULL, "Failed to create meter policy."); } - +#endif /** * Check meter validation. *
@@ -2177,6 +2182,7 @@ mlx5_flow_meter_create(struct rte_eth_dev *dev, uint32_t meter_id, NULL, "Failed to create devx meter."); } +#if defined(HAVE_MLX5_HWS_SUPPORT )/** * Create meter rules. *
@@ -2260,6 +2266,7 @@ mlx5_flow_meter_hws_create(struct rte_eth_dev *dev, uint32_t meter_id,__atomic_fetch_add (&policy->ref_cnt,1 , __ATOMIC_RELAXED);return 0 ; } +#endif static int mlx5_flow_meter_params_flush(struct rte_eth_dev *dev,
@@ -2744,6 +2751,7 @@ static const struct rte_mtr_ops mlx5_flow_mtr_ops = { .stats_read = mlx5_flow_meter_stats_read, }; +#if defined(HAVE_MLX5_HWS_SUPPORT )static const struct rte_mtr_ops mlx5_flow_mtr_hws_ops = { .capabilities_get = mlx5_flow_mtr_cap_get, .meter_profile_add = mlx5_flow_meter_profile_hws_add,
@@ -2762,6 +2770,7 @@ static const struct rte_mtr_ops mlx5_flow_mtr_hws_ops = { .stats_update = NULL, .stats_read = NULL, }; +#endif /** * Get meter operations.
@@ -2777,12 +2786,16 @@ static const struct rte_mtr_ops mlx5_flow_mtr_hws_ops = {int mlx5_flow_meter_ops_get(struct rte_eth_dev *dev __rte_unused, void *arg) { +#if defined(HAVE_MLX5_HWS_SUPPORT )struct mlx5_priv *priv = dev->data->dev_private;if (priv->sh->config.dv_flow_en ==2 ) *(const struct rte_mtr_ops **)arg = &mlx5_flow_mtr_hws_ops;else *(const struct rte_mtr_ops **)arg = &mlx5_flow_mtr_ops; +#else + *(const struct rte_mtr_ops **)arg = &mlx5_flow_mtr_ops; +#endif return 0 ; }
@@ -3161,7 +3174,6 @@ mlx5_flow_meter_flush(struct rte_eth_dev *dev, struct rte_mtr_error *error)struct mlx5_flow_meter_profile *fmp;struct mlx5_legacy_flow_meter *legacy_fm;struct mlx5_flow_meter_info *fm; -struct mlx5_flow_meter_policy *policy;struct mlx5_flow_meter_sub_policy *sub_policy;void *tmp;uint32_t i, mtr_idx, policy_idx;
@@ -3229,15 +3241,20 @@ mlx5_flow_meter_flush(struct rte_eth_dev *dev, struct rte_mtr_error *error)mlx5_l3t_destroy (priv->policy_idx_tbl); priv->policy_idx_tbl =NULL ; } +#if defined(HAVE_MLX5_HWS_SUPPORT )if (priv->mtr_policy_arr) { +struct mlx5_flow_meter_policy *policy; +for (i =0 ; i < priv->mtr_config.nb_meter_policies; i++) { policy =mlx5_flow_meter_policy_find (dev, i, &policy_idx); -if (policy->initialized) +if (policy->initialized) {mlx5_flow_meter_policy_hws_delete (dev, i, error); + } } } +#endif if (priv->mtr_profile_tbl) { MLX5_L3T_FOREACH(priv->mtr_profile_tbl, i, entry) { fmp = entry;
@@ -3251,14 +3268,17 @@ mlx5_flow_meter_flush(struct rte_eth_dev *dev, struct rte_mtr_error *error)mlx5_l3t_destroy (priv->mtr_profile_tbl); priv->mtr_profile_tbl =NULL ; } +#if defined(HAVE_MLX5_HWS_SUPPORT )if (priv->mtr_profile_arr) {for (i =0 ; i < priv->mtr_config.nb_meter_profiles; i++) { fmp =mlx5_flow_meter_profile_find (priv, i); -if (fmp->initialized) +if (fmp->initialized) {mlx5_flow_meter_profile_hws_delete (dev, i, error); + } } } +#endif /* Delete default policy table. */ mlx5_flow_destroy_def_policy (dev);if (priv->sh->refcnt ==1 )
Signature · 1 line
2.39.2
PATCH 2/3 net/mlx5: fix sync meter processing in HWS setup
In reply to Gregory EtelsonSynchronous calls for meter ASO try to pull pending completions from CQ, submit WR and return to caller. That avoids delays between WR post and HW response.
If the template API was activated, PMD will use control queue for sync operations.
PMD has different formats for the user_data context in sync and async meter ASO calls.
PMD port destruction procedure submits async operations to the port control queue and polls the queue CQs to clean HW responses.
Port destruction can pull a meter ASO completion from control CQ. Such completion has sync format, but was processed by async handler.
The patch implements sync meter ASO interface with async calls in the template API environment.
--- drivers/net/mlx5/mlx5.h | 35 +++++- drivers/net/mlx5/mlx5_flow_aso.c | 178 ++++++++++++++++++----------- drivers/net/mlx5/mlx5_flow_hw.c | 99 ++++++++-------- drivers/net/mlx5/mlx5_flow_meter.c | 27 +++-- 4 files changed, 216 insertions(+), 123 deletions(-)
drivers/net/mlx5/mlx5.h +30 -5
@@ -2033,6 +2033,30 @@ enum dr_dump_rec_type { DR_DUMP_REC_TYPE_PMD_COUNTER = 4430, }; +#if defined(HAVE_MLX5_HWS_SUPPORT ) +static __rte_always_inline struct mlx5_hw_q_job * +flow_hw_job_get (struct mlx5_priv *priv,uint32_t queue) +{ +MLX5_ASSERT (priv->hw_q[queue].job_idx <= priv->hw_q[queue].size); +return priv->hw_q[queue].job_idx ? + priv->hw_q[queue].job[--priv->hw_q[queue].job_idx] :NULL ; +} + +static __rte_always_inline void +flow_hw_job_put (struct mlx5_priv *priv,struct mlx5_hw_q_job *job,uint32_t queue) +{ +MLX5_ASSERT (priv->hw_q[queue].job_idx < priv->hw_q[queue].size); + priv->hw_q[queue].job[priv->hw_q[queue].job_idx++] = job; +} + +struct mlx5_hw_q_job * +mlx5_flow_action_job_init (struct mlx5_priv *priv,uint32_t queue, +const struct rte_flow_action_handle *handle, +void *user_data,void *query_data, +enum mlx5_hw_job_type type, +struct rte_flow_error *error); +#endif +/** * Indicates whether HW objects operations can be created by DevX. *
@@ -2443,11 +2467,12 @@ int mlx5_aso_flow_hit_queue_poll_start(struct mlx5_dev_ctx_shared *sh);int mlx5_aso_flow_hit_queue_poll_stop (struct mlx5_dev_ctx_shared *sh);void mlx5_aso_queue_uninit (struct mlx5_dev_ctx_shared *sh,enum mlx5_access_aso_opc_mod aso_opc_mod); -int mlx5_aso_meter_update_by_wqe (struct mlx5_dev_ctx_shared *sh,uint32_t queue, -struct mlx5_aso_mtr *mtr,struct mlx5_mtr_bulk *bulk, -void *user_data,bool push); -int mlx5_aso_mtr_wait (struct mlx5_dev_ctx_shared *sh,uint32_t queue, -struct mlx5_aso_mtr *mtr); +int mlx5_aso_meter_update_by_wqe (struct mlx5_priv *priv,uint32_t queue, +struct mlx5_aso_mtr *mtr, +struct mlx5_mtr_bulk *bulk, +struct mlx5_hw_q_job *job,bool push); +int mlx5_aso_mtr_wait (struct mlx5_priv *priv, +struct mlx5_aso_mtr *mtr,bool is_tmpl_api); int mlx5_aso_ct_update_by_wqe(struct mlx5_dev_ctx_shared *sh, uint32_t queue, struct mlx5_aso_ct_action *ct, const struct rte_flow_action_conntrack *profile,
drivers/net/mlx5/mlx5_flow_aso.c +114 -64
243 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_hw.c +54 -45
246 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_meter.c +18 -9
@@ -1897,12 +1897,12 @@ mlx5_flow_meter_action_modify(struct mlx5_priv *priv,if (sh->meter_aso_en) { fm->is_enable = !!is_enable; aso_mtr = container_of(fm, struct mlx5_aso_mtr, fm); - ret =mlx5_aso_meter_update_by_wqe (sh,MLX5_HW_INV_QUEUE , + ret =mlx5_aso_meter_update_by_wqe (priv,MLX5_HW_INV_QUEUE , aso_mtr, &priv->mtr_bulk,NULL , true);if (ret)return ret; - ret =mlx5_aso_mtr_wait (sh,MLX5_HW_INV_QUEUE , aso_mtr); + ret =mlx5_aso_mtr_wait (priv, aso_mtr, false);if (ret)return ret; }else {
@@ -2148,7 +2148,7 @@ mlx5_flow_meter_create(struct rte_eth_dev *dev, uint32_t meter_id,/* If ASO meter supported, update ASO flow meter by wqe. */ if (priv->sh->meter_aso_en) { aso_mtr = container_of(fm, struct mlx5_aso_mtr, fm); - ret =mlx5_aso_meter_update_by_wqe (priv->sh,MLX5_HW_INV_QUEUE , + ret =mlx5_aso_meter_update_by_wqe (priv,MLX5_HW_INV_QUEUE , aso_mtr, &priv->mtr_bulk,NULL , true);if (ret) goto error;
@@ -2210,6 +2210,7 @@ mlx5_flow_meter_hws_create(struct rte_eth_dev *dev, uint32_t meter_id,struct mlx5_flow_meter_info *fm;struct mlx5_flow_meter_policy *policy =NULL ;struct mlx5_aso_mtr *aso_mtr; +struct mlx5_hw_q_job *job;int ret; if (!priv->mtr_profile_arr ||
@@ -2255,12 +2256,20 @@ mlx5_flow_meter_hws_create(struct rte_eth_dev *dev, uint32_t meter_id, fm->shared = !!shared; fm->initialized =1 ;/* Update ASO flow meter by wqe. */ - ret =mlx5_aso_meter_update_by_wqe (priv->sh,MLX5_HW_INV_QUEUE , aso_mtr, - &priv->mtr_bulk,NULL , true); -if (ret) + job =mlx5_flow_action_job_init (priv,MLX5_HW_INV_QUEUE ,NULL ,NULL , +NULL ,MLX5_HW_Q_JOB_TYPE_CREATE ,NULL ); +if (!job) +return -rte_mtr_error_set (error,ENOMEM , +RTE_MTR_ERROR_TYPE_MTR_ID , +NULL ,"No job context." ); + ret =mlx5_aso_meter_update_by_wqe (priv,MLX5_HW_INV_QUEUE , aso_mtr, + &priv->mtr_bulk, job, true); +if (ret) { +flow_hw_job_put (priv, job,MLX5_HW_INV_QUEUE );return -rte_mtr_error_set (error,ENOTSUP , -RTE_MTR_ERROR_TYPE_UNSPECIFIED , -NULL ,"Failed to create devx meter." ); +RTE_MTR_ERROR_TYPE_UNSPECIFIED , +NULL ,"Failed to create devx meter." ); + } fm->active_state = params->meter_enable;__atomic_fetch_add (&fm->profile->ref_cnt,1 , __ATOMIC_RELAXED);__atomic_fetch_add (&policy->ref_cnt,1 , __ATOMIC_RELAXED);
@@ -2911,7 +2920,7 @@ mlx5_flow_meter_attach(struct mlx5_priv *priv,struct mlx5_aso_mtr *aso_mtr; aso_mtr = container_of(fm, struct mlx5_aso_mtr, fm); -if (mlx5_aso_mtr_wait (priv->sh,MLX5_HW_INV_QUEUE , aso_mtr)) { +if (mlx5_aso_mtr_wait (priv, aso_mtr, false)) { return rte_flow_error_set(error, ENOENT, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
Signature · 1 line
2.39.2
PATCH 3/3 net/mlx5: fix indirect action async job initialization
In reply to Gregory EtelsonMLX5 PMD driver supports 2 types of indirect actions:
legacy INDIRECT and INDIRECT_LIST.
PMD has different handlers for each of indirection actions types. Therefore PMD marks async job::indirect_type with relevant value.
PMD set the type only during indirect action creation. Legacy INDIRECT query could have get a job object used previously by INDIRECT_LIST action. In that case such job object was handled as INDIRECT_LIST because the job::indirect_type was not re-assigned.
The patch sets job::indirect_type during the job initialization according to operation type.
--- drivers/net/mlx5/mlx5_flow_hw.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-)
drivers/net/mlx5/mlx5_flow_hw.c +13 -11
@@ -188,6 +188,7 @@ flow_hw_action_job_init(struct mlx5_priv *priv, uint32_t queue,const struct rte_flow_action_handle *handle, void *user_data, void *query_data, enum mlx5_hw_job_type type, + enum mlx5_hw_indirect_type indirect_type, struct rte_flow_error *error); static int mlx5_tbl_multi_pattern_process(struct rte_eth_dev *dev,
@@ -1692,7 +1693,8 @@ flow_hw_meter_mark_compile(struct rte_eth_dev *dev,struct mlx5_aso_mtr *aso_mtr;struct mlx5_hw_q_job *job =flow_hw_action_job_init (priv, queue,NULL ,NULL ,NULL , -MLX5_HW_Q_JOB_TYPE_CREATE ,NULL ); +MLX5_HW_Q_JOB_TYPE_CREATE , +MLX5_HW_INDIRECT_TYPE_LEGACY ,NULL );if (!job)return -1 ;
@@ -10998,6 +11000,7 @@ flow_hw_action_job_init(struct mlx5_priv *priv, uint32_t queue,const struct rte_flow_action_handle *handle, void *user_data, void *query_data, enum mlx5_hw_job_type type, + enum mlx5_hw_indirect_type indirect_type, struct rte_flow_error *error) { struct mlx5_hw_q_job *job;
@@ -11015,6 +11018,7 @@ flow_hw_action_job_init(struct mlx5_priv *priv, uint32_t queue, job->action = handle; job->user_data = user_data; job->query.user = query_data; + job->indirect_type = indirect_type;return job; }
@@ -11026,7 +11030,7 @@ mlx5_flow_action_job_init(struct mlx5_priv *priv, uint32_t queue, struct rte_flow_error *error) {return flow_hw_action_job_init (priv, queue, handle, user_data, query_data, - type, error); + type,MLX5_HW_INDIRECT_TYPE_LEGACY , error); }static __rte_always_inline void
@@ -11096,7 +11100,7 @@ flow_hw_action_handle_create(struct rte_eth_dev *dev, uint32_t queue,if (attr || force_job) { job =flow_hw_action_job_init (priv, queue,NULL , user_data,NULL ,MLX5_HW_Q_JOB_TYPE_CREATE , - error); +MLX5_HW_INDIRECT_TYPE_LEGACY , error);if (!job)return NULL ; }
@@ -11165,7 +11169,6 @@ flow_hw_action_handle_create(struct rte_eth_dev *dev, uint32_t queue, }if (job && !force_job) { job->action = handle; - job->indirect_type =MLX5_HW_INDIRECT_TYPE_LEGACY ;flow_hw_action_finalize (dev, queue, job, push, aso, handle !=NULL ); }
@@ -11257,7 +11260,7 @@ flow_hw_action_handle_update(struct rte_eth_dev *dev, uint32_t queue,if (attr || force_job) { job =flow_hw_action_job_init (priv, queue, handle, user_data,NULL ,MLX5_HW_Q_JOB_TYPE_UPDATE , - error); +MLX5_HW_INDIRECT_TYPE_LEGACY , error);if (!job)return -rte_errno; }
@@ -11339,7 +11342,7 @@ flow_hw_action_handle_destroy(struct rte_eth_dev *dev, uint32_t queue,if (attr || force_job) { job =flow_hw_action_job_init (priv, queue, handle, user_data,NULL ,MLX5_HW_Q_JOB_TYPE_DESTROY , - error); +MLX5_HW_INDIRECT_TYPE_LEGACY , error);if (!job)return -rte_errno; }
@@ -11663,7 +11666,7 @@ flow_hw_action_handle_query(struct rte_eth_dev *dev, uint32_t queue,if (attr) { job =flow_hw_action_job_init (priv, queue, handle, user_data, data,MLX5_HW_Q_JOB_TYPE_QUERY , - error); +MLX5_HW_INDIRECT_TYPE_LEGACY , error);if (!job)return -rte_errno; }
@@ -11717,7 +11720,7 @@ flow_hw_async_action_handle_query_update job =flow_hw_action_job_init (priv, queue, handle, user_data, query,MLX5_HW_Q_JOB_TYPE_UPDATE_QUERY , - error); +MLX5_HW_INDIRECT_TYPE_LEGACY , error);if (!job)return -rte_errno; }
@@ -12397,7 +12400,7 @@ flow_hw_async_action_list_handle_create(struct rte_eth_dev *dev, uint32_t queue,if (attr) { job =flow_hw_action_job_init (priv, queue,NULL , user_data,NULL ,MLX5_HW_Q_JOB_TYPE_CREATE , - error); +MLX5_HW_INDIRECT_TYPE_LIST , error);if (!job)return NULL ; }
@@ -12417,7 +12420,6 @@ flow_hw_async_action_list_handle_create(struct rte_eth_dev *dev, uint32_t queue, }if (job) { job->action = handle; - job->indirect_type =MLX5_HW_INDIRECT_TYPE_LIST ;flow_hw_action_finalize (dev, queue, job, push, false, handle !=NULL ); }
@@ -12462,7 +12464,7 @@ flow_hw_async_action_list_handle_destroyif (attr) { job =flow_hw_action_job_init (priv, queue,NULL , user_data,NULL ,MLX5_HW_Q_JOB_TYPE_DESTROY , - error); +MLX5_HW_INDIRECT_TYPE_LIST , error);if (!job)return rte_errno; }
Signature · 1 line
2.39.2