Add ASO meter support in MLX5 PMD
Subsystems (2)
cover Add ASO meter support in MLX5 PMD
To support more meters and better performance,
MLX HW provide ASO flow meter.
It can expose millions of ASO flow meter context's in HW. This ASO object can allocate the large bulk meter objects. This patch set implement the ASO flow meter for mlx5 driver. MLX5 PMD driver will be responsible for ASO flow meter manage to HW.
Li Zhang (10):
net/mlx5: optimize meter statistics
common/mlx5: add definitions for ASO flow meter common/mlx5: add read ASO flow meter HCA capability common/mlx5: add DevX API to create ASO flow meter object net/mlx5: flow meter pool to manage meter object net/mlx5: init/uninit flow meter queue for WQE net/mlx5: aso flow meter send WQE and CQE handle net/mlx5: add support of ASO meter action net/mlx5: make ASO meter queue thread-safe net/mlx5: allow multiple flow tables on the same level
Shun Hao (2):
net/mlx5: fix meter statistics
net/mlx5: use mask for meter register setting
Suanming Mou (1):
net/mlx5: support three level table walk
doc/guides/nics/mlx5.rst | 6 +
drivers/common/mlx5/mlx5_devx_cmds.c | 68 ++
drivers/common/mlx5/mlx5_devx_cmds.h | 26 +-
drivers/common/mlx5/mlx5_prm.h | 75 +-
drivers/common/mlx5/version.map | 1 +
drivers/net/mlx5/linux/mlx5_os.c | 29 +-
drivers/net/mlx5/meson.build | 2 +-
drivers/net/mlx5/mlx5.c | 104 ++-
drivers/net/mlx5/mlx5.h | 268 +++++-
drivers/net/mlx5/mlx5_flow.c | 321 +++++--
drivers/net/mlx5/mlx5_flow.h | 210 ++---
.../mlx5/{mlx5_flow_age.c => mlx5_flow_aso.c} | 288 +++++-
drivers/net/mlx5/mlx5_flow_dv.c | 787 +++++++++++-----
drivers/net/mlx5/mlx5_flow_meter.c | 873 ++++++++++++------
drivers/net/mlx5/mlx5_utils.h | 90 ++
15 files changed, 2319 insertions(+), 829 deletions(-)
rename drivers/net/mlx5/{mlx5_flow_age.c => mlx5_flow_aso.c} (65%)Signature · 1 line
2.27.0
PATCH 1/13 net/mlx5: support three level table walk
From: Suanming Mou <[email protected]>
This commit adds table entry walk for the three level table.
--- drivers/net/mlx5/mlx5_utils.h | 90 +++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+)
drivers/net/mlx5/mlx5_utils.h +90 -0
@@ -832,6 +832,91 @@ int32_t mlx5_l3t_clear_entry(struct mlx5_l3t_tbl *tbl, uint32_t idx);int32_t mlx5_l3t_set_entry (struct mlx5_l3t_tbl *tbl,uint32_t idx,union mlx5_l3t_data *data); +static inline void * +mlx5_l3t_get_next (struct mlx5_l3t_tbl *tbl,uint32_t *pos) +{ +struct mlx5_l3t_level_tbl *g_tbl, *m_tbl; +uint32_t i, j, k, g_start, m_start, e_start; +uint32_t idx = *pos; +void *e_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; + +if (!tbl) +return NULL ; + g_tbl = tbl->tbl; +if (!g_tbl) +return NULL ; + g_start = (idx >>MLX5_L3T_GT_OFFSET ) &MLX5_L3T_GT_MASK ; + m_start = (idx >>MLX5_L3T_MT_OFFSET ) &MLX5_L3T_MT_MASK ; + e_start = idx &MLX5_L3T_ET_MASK ; +for (i = g_start; i <MLX5_L3T_GT_SIZE ; i++) { + m_tbl = g_tbl->tbl[i]; +if (!m_tbl) { +/* Jump to new table, reset the sub table start. */ + m_start =0 ; + e_start =0 ; +continue ; + } +for (j = m_start; j <MLX5_L3T_MT_SIZE ; j++) { +if (!m_tbl->tbl[j]) { +/* +* Jump to new table, reset the sub table +* start. +*/ + e_start =0 ; +continue ; + } + e_tbl = m_tbl->tbl[j]; +switch (tbl->type) { +case MLX5_L3T_TYPE_WORD : + w_e_tbl = (struct mlx5_l3t_entry_word *)e_tbl; +for (k = e_start; k <MLX5_L3T_ET_SIZE ; k++) { +if (!w_e_tbl->entry[k].data) +continue ; + *pos = (i <<MLX5_L3T_GT_OFFSET ) | + (j <<MLX5_L3T_MT_OFFSET ) | k; +return (void *)&w_e_tbl->entry[k].data; + } +break ; +case MLX5_L3T_TYPE_DWORD : + dw_e_tbl = (struct mlx5_l3t_entry_dword *)e_tbl; +for (k = e_start; k <MLX5_L3T_ET_SIZE ; k++) { +if (!dw_e_tbl->entry[k].data) +continue ; + *pos = (i <<MLX5_L3T_GT_OFFSET ) | + (j <<MLX5_L3T_MT_OFFSET ) | k; +return (void *)&dw_e_tbl->entry[k].data; + } +break ; +case MLX5_L3T_TYPE_QWORD : + qw_e_tbl = (struct mlx5_l3t_entry_qword *)e_tbl; +for (k = e_start; k <MLX5_L3T_ET_SIZE ; k++) { +if (!qw_e_tbl->entry[k].data) +continue ; + *pos = (i <<MLX5_L3T_GT_OFFSET ) | + (j <<MLX5_L3T_MT_OFFSET ) | k; +return (void *)&qw_e_tbl->entry[k].data; + } +break ; +default : + ptr_e_tbl = (struct mlx5_l3t_entry_ptr *)e_tbl; +for (k = e_start; k <MLX5_L3T_ET_SIZE ; k++) { +if (!ptr_e_tbl->entry[k].data) +continue ; + *pos = (i <<MLX5_L3T_GT_OFFSET ) | + (j <<MLX5_L3T_MT_OFFSET ) | k; +return ptr_e_tbl->entry[k].data; + } +break ; + } + } + } +return NULL ; +} +/* * Macros for linked list based on indexed memory. * Example data structure:
@@ -907,4 +992,9 @@ struct { \ idx = (elem)->field.next, (elem) = \ (idx) ? mlx5_ipool_get(pool, idx) : NULL) +#define MLX5_L3T_FOREACH (tbl, idx, entry) \ + for (idx = 0, (entry) = mlx5_l3t_get_next((tbl), &idx); \ + (entry); \ + idx++, (entry) = mlx5_l3t_get_next((tbl), &idx)) +#endif /* RTE_PMD_MLX5_UTILS_H_ */
Signature · 1 line
2.27.0
PATCH 2/13 net/mlx5: fix meter statistics
In reply to Li ZhangFrom: Shun Hao <[email protected]>
This fixes the meter statistics issue that when using multiple meters, only one meter has stats value.
To match the correct meter in policer table, now the meter_id is also used in its match criteria, so only one color and one drop matcher are needed. And both meter_id and flow_id will be written to related registers in meter prefix flow.
--- drivers/net/mlx5/linux/mlx5_os.c | 9 +- drivers/net/mlx5/mlx5.c | 7 +- drivers/net/mlx5/mlx5.h | 25 +- drivers/net/mlx5/mlx5_flow.c | 182 +++++++---- drivers/net/mlx5/mlx5_flow.h | 40 +-- drivers/net/mlx5/mlx5_flow_dv.c | 489 ++++++++++++++++++----------- drivers/net/mlx5/mlx5_flow_meter.c | 53 +++- 7 files changed, 512 insertions(+), 293 deletions(-)
drivers/net/mlx5/linux/mlx5_os.c +7 -2
@@ -316,7 +316,13 @@ mlx5_alloc_shared_dr(struct mlx5_priv *priv) } sh->tx_domain = domain;#ifdef HAVE_MLX5DV_DR_ESWITCH + sh->esw_drop_action = mlx5_glue->dr_create_flow_action_drop ();if (priv->config.dv_esw_en) { +if (!sh->esw_drop_action) { +DRV_LOG (ERR ,"Failed to create eswitch drop action" ); + err = errno; + goto error; + } domain = mlx5_glue->dr_create_domain (sh->ctx,MLX5DV_DR_DOMAIN_TYPE_FDB );if (!domain) {
@@ -325,7 +331,6 @@ mlx5_alloc_shared_dr(struct mlx5_priv *priv) goto error; } sh->fdb_domain = domain; - sh->esw_drop_action = mlx5_glue->dr_create_flow_action_drop (); }#endif if (!sh->tunnel_hub)
@@ -1273,7 +1278,7 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, -1 +REG_C_0 ; priv->mtr_en =1 ; priv->mtr_reg_share = - config->hca_attr.qos.flow_meter; + config->hca_attr.qos.flow_meter;DRV_LOG (DEBUG ,"The REG_C meter uses is %d" , priv->mtr_color_reg); }
drivers/net/mlx5/mlx5.c +5 -2
@@ -275,10 +275,13 @@ static const struct mlx5_indexed_pool_config mlx5_ipool_cfg[] = { }, #endif [MLX5_IPOOL_MTR ] = { +/** +* The ipool index should grow continually from small to big, +* for meter idx, so not set grow_trunk to avoid meter index +* not jump continually. +*/ .size =sizeof (struct mlx5_flow_meter ), .trunk_size =64 , - .grow_trunk =3 , - .grow_shift =2 , .need_lock =1 , .release_mem_en =1 , .malloc = mlx5_malloc,
drivers/net/mlx5/mlx5.h +19 -6
@@ -188,6 +188,16 @@ struct mlx5_stats_ctrl {/* Maximal number of segments to split. */ #define MLX5_MAX_RXQ_NSEG (1u << MLX5_MAX_LOG_RQ_SEGS) +/* The bit size of one register. */ +#define MLX5_REG_BITS 32 + +/* Idle bits for non-color usage in color register. */ +#define MLX5_MTR_IDLE_BITS_IN_COLOR_REG (MLX5_REG_BITS - MLX5_MTR_COLOR_BITS) + +#define UINT32_T (x) ((uint32_t)(x)) + +#define LS32_MASK (bits) ((UINT32_T(1) << (bits)) - 1) +/* LRO configurations structure. */ struct mlx5_lro_config {uint32_t supported:1 ;/* Whether LRO is supported. */
@@ -944,9 +954,9 @@ struct mlx5_priv { unsigned int representor:1; /* Device is a port representor. */ unsigned int master:1; /* Device is a E-Switch master. */ unsigned int txpp_en:1; /* Tx packet pacing enabled. */ + unsigned int sampler_en:1; /* Whether support sampler. */ unsigned int mtr_en:1; /* Whether support meter. */ unsigned int mtr_reg_share:1; /* Whether support meter REG_C share. */ - unsigned int sampler_en:1; /* Whether support sampler. */uint16_t domain_id;/* Switch domain identifier. */ uint16_t vport_id;/* Associated VF vport index (if any). */ uint32_t vport_meta_tag;/* Used for vport index match ove VF LAG. */
@@ -1003,6 +1013,10 @@ struct mlx5_priv {uint32_t rss_shared_actions;/* RSS shared actions. */ struct mlx5_devx_obj *q_counters;/* DevX queue counter object. */ uint32_t counter_set_id;/* Queue counter ID to set in DevX objects. */ +uint8_t max_mtr_bits; +/* Indicate how many bits are used by meter id at the most. */ +uint8_t max_mtr_flow_bits; +/* Indicate how many bits are used by meter flow id at the most. */ };#define PORT_ID (priv) ((priv)->dev_data->port_id)
@@ -1271,11 +1285,10 @@ int mlx5_pmd_socket_init(void);int mlx5_flow_meter_ops_get (struct rte_eth_dev *dev,void *arg);struct mlx5_flow_meter *mlx5_flow_meter_find (struct mlx5_priv *priv,uint32_t meter_id); -struct mlx5_flow_meter *mlx5_flow_meter_attach - (struct mlx5_priv *priv, -uint32_t meter_id, -const struct rte_flow_attr *attr, -struct rte_flow_error *error); +int mlx5_flow_meter_attach (struct mlx5_priv *priv, +struct mlx5_flow_meter *fm, +const struct rte_flow_attr *attr, +struct rte_flow_error *error);void mlx5_flow_meter_detach (struct mlx5_flow_meter *fm);/* mlx5_os.c */
drivers/net/mlx5/mlx5_flow.c +119 -63
329 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow.h +22 -18
@@ -79,7 +79,7 @@ enum mlx5_feature_name {MLX5_APP_TAG ,MLX5_COPY_MARK ,MLX5_MTR_COLOR , -MLX5_MTR_SFX , +MLX5_MTR_ID , MLX5_ASO_FLOW_HIT, };
@@ -655,7 +655,8 @@ struct mlx5_flow_handle {uint64_t layers;/**< Bit-fields of present layers, see MLX5_FLOW_LAYER_*. */ void *drv_flow;/**< pointer to driver flow object. */ - uint32_t split_flow_id:28; /**< Sub flow unique match flow id. */ + uint32_t split_flow_id:27; /**< Sub flow unique match flow id. */ + uint32_t is_meter_flow_id:1; /**< Indate if flow_id is for meter. */ uint32_t mark:1; /**< Metadate rxq mark flag. */ uint32_t fate_action:3; /**< Fate action type. */union {
@@ -842,14 +843,16 @@ struct mlx5_meter_domain_info {/**< Meter table. */ struct mlx5_flow_tbl_resource *sfx_tbl;/**< Meter suffix table. */ -void *any_matcher; -/**< Meter color not match default criteria. */ -void *color_matcher; -/**< Meter color match criteria. */ +struct mlx5_flow_dv_matcher *drop_matcher; +/**< Matcher for Drop. */ +struct mlx5_flow_dv_matcher *color_matcher; +/**< Matcher for Color. */ void *jump_actn;/**< Meter match action. */ -void *policer_rules[RTE_MTR_DROPPED +1 ]; -/**< Meter policer for the match. */ +void *green_rule; +/**< Meter green rule. */ +void *drop_rule; +/**< Meter drop rule. */ };/* Meter table set for TX RX FDB. */
@@ -862,10 +865,10 @@ struct mlx5_meter_domains_infos {/**< RX meter table. */ struct mlx5_meter_domain_info transfer;/**< FDB meter table. */ -void *drop_actn; -/**< Drop action as not matched. */ -void *count_actns[RTE_MTR_DROPPED +1 ]; -/**< Counters for match and unmatched statistics. */ +void *green_count; +/**< Counters for green rule. */ +void *drop_count; +/**< Counters for green rule. */ uint32_t fmp[MLX5_ST_SZ_DW (flow_meter_parameters)];/**< Flow meter parameter. */ size_t fmp_size;
@@ -928,6 +931,8 @@ struct mlx5_flow_meter {/**< Meter state. */ uint32_t shared:1;/**< Meter shared or not. */ +struct mlx5_indexed_pool *flow_ipool; +/**< Index pool for flow id. */ };/* RFC2697 parameter structure. */
@@ -1148,6 +1153,7 @@ struct mlx5_flow_workspace {struct mlx5_flow_rss_desc rss_desc;uint32_t rssq_num;/* Allocated queue num in rss_desc. */ uint32_t flow_idx;/* Intermediate device flow index. */ +struct mlx5_flow_meter *fm;/* Pointer to the meter in flow. */ };struct mlx5_flow_split_info {
@@ -1188,8 +1194,7 @@ typedef int (*mlx5_flow_query_t)(struct rte_eth_dev *dev,void *data, struct rte_flow_error *error);typedef struct mlx5_meter_domains_infos *(*mlx5_flow_create_mtr_tbls_t ) - (struct rte_eth_dev *dev, -const struct mlx5_flow_meter *fm); + (struct rte_eth_dev *dev);typedef int (*mlx5_flow_destroy_mtr_tbls_t )(struct rte_eth_dev *dev,struct mlx5_meter_domains_infos *tbls);typedef int (*mlx5_flow_create_policer_rules_t )
@@ -1252,7 +1257,7 @@ struct mlx5_flow_driver_ops {mlx5_flow_query_t query;mlx5_flow_create_mtr_tbls_t create_mtr_tbls;mlx5_flow_destroy_mtr_tbls_t destroy_mtr_tbls; -mlx5_flow_create_policer_rules_t create_policer_rules; +mlx5_flow_create_policer_rules_t prepare_policer_rules;mlx5_flow_destroy_policer_rules_t destroy_policer_rules;mlx5_flow_counter_alloc_t counter_alloc;mlx5_flow_counter_free_t counter_free;
@@ -1452,11 +1457,10 @@ int mlx5_flow_validate_item_ecpri(const struct rte_flow_item *item,const struct rte_flow_item_ecpri *acc_mask, struct rte_flow_error *error);struct mlx5_meter_domains_infos *mlx5_flow_create_mtr_tbls - (struct rte_eth_dev *dev, -const struct mlx5_flow_meter *fm); + (struct rte_eth_dev *dev);int mlx5_flow_destroy_mtr_tbls (struct rte_eth_dev *dev,struct mlx5_meter_domains_infos *tbl); -int mlx5_flow_create_policer_rules (struct rte_eth_dev *dev, +int mlx5_flow_prepare_policer_rules (struct rte_eth_dev *dev,struct mlx5_flow_meter *fm,const struct rte_flow_attr *attr); int mlx5_flow_destroy_policer_rules(struct rte_eth_dev *dev,
drivers/net/mlx5/mlx5_flow_dv.c +303 -186
704 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_meter.c +37 -16
117 lines not on this page · raw message
Signature · 1 line
2.27.0
PATCH 3/13 net/mlx5: optimize meter statistics
In reply to Li Zhang1. It does not support yellow counter and return 0.
2. All the meter colors with drop action will be counted only by the global drop statistics.
3. Red color must be with drop action.
--- doc/guides/nics/mlx5.rst | 6 + drivers/net/mlx5/mlx5_flow.h | 24 ++-- drivers/net/mlx5/mlx5_flow_dv.c | 8 +- drivers/net/mlx5/mlx5_flow_meter.c | 217 +++++++++++++++++++---------- 4 files changed, 173 insertions(+), 82 deletions(-)
doc/guides/nics/mlx5.rst +6 -0
@@ -398,6 +398,12 @@ Limitations - Hairpin between two ports could only manual binding and explicit Tx flow mode. For single port hairpin, all the combinations of auto/manual binding and explicit/implicit Tx flow mode could be supported. - Hairpin in switchdev SR-IOV mode is not supported till now. +- Meter: + - All the meter colors with drop action will be counted only by the global drop statistics. + - Green color is not supported with drop action. + - Yellow detection is not supported. + - Red color must be with drop action. + Statistics ----------
drivers/net/mlx5/mlx5_flow.h +16 -8
@@ -831,10 +831,10 @@ struct mlx5_flow {/* Meter policer statistics */ struct mlx5_flow_policer_stats { -uint32_t cnt[RTE_COLORS +1 ]; -/**< Color counter, extra for drop. */ -uint64_t stats_mask; -/**< Statistics mask for the colors. */ +uint32_t pass_cnt; +/**< Color counter for pass. */ +uint32_t drop_cnt; +/**< Color counter for drop. */ };/* Meter table structure. */
@@ -892,10 +892,18 @@ struct mlx5_flow_meter {/** Policer actions (per meter output color). */ enum rte_mtr_policer_action action[RTE_COLORS ]; -/** Set of stats counters to be enabled. -* @see enum rte_mtr_stats_type -*/ -uint64_t stats_mask; + uint32_t green_bytes:1; +/** Set green bytes stats to be enabled. */ + uint32_t green_pkts:1; +/** Set green packets stats to be enabled. */ + uint32_t red_bytes:1; +/** Set red bytes stats to be enabled. */ + uint32_t red_pkts:1; +/** Set red packets stats to be enabled. */ + uint32_t bytes_dropped:1; +/** Set bytes dropped stats to be enabled. */ + uint32_t pkts_dropped:1; +/** Set packets dropped stats to be enabled. */ /**< Rule applies to ingress traffic. */ uint32_t ingress:1;
drivers/net/mlx5/mlx5_flow_dv.c +4 -4
@@ -13697,17 +13697,17 @@ flow_dv_prepare_policer_rules(struct rte_eth_dev *dev,int ret;/* Get the statistics counters for green/drop. */ -if (fm->policer_stats.cnt[RTE_COLOR_GREEN ]) { +if (fm->policer_stats.pass_cnt) { cnt =flow_dv_counter_get_by_idx (dev, - fm->policer_stats.cnt[RTE_COLOR_GREEN ], + fm->policer_stats.pass_cnt,NULL ); mtb->green_count = cnt->action; }else { mtb->green_count =NULL ; } -if (fm->policer_stats.cnt[RTE_MTR_DROPPED ]) { +if (fm->policer_stats.drop_cnt) { cnt =flow_dv_counter_get_by_idx (dev, - fm->policer_stats.cnt[RTE_MTR_DROPPED ], + fm->policer_stats.drop_cnt,NULL ); mtb->drop_count = cnt->action; }else {
drivers/net/mlx5/mlx5_flow_meter.c +147 -70
321 lines not on this page · raw message
Signature · 1 line
2.27.0
PATCH 4/13 net/mlx5: use mask for meter register setting
In reply to Li ZhangFrom: Shun Hao <[email protected]>
ASO meter feature may require to locate the flow context tag action after the ASO action.
When color register is shared by meter_id/flow_id, it's like:
Bits[0-7] A meter color value set by the HW. Bits[8-31] A flow id and meter id set by SW.
Currently the tag action for meter writes all the bits of the meter register, so it will potentially overwrite meter color when ASO meter action is before the tag action.
Set only 24-MSB-bits of meter register in the meter tag action.
--- drivers/net/mlx5/mlx5_flow.c | 27 +++++++++++++++++---------- drivers/net/mlx5/mlx5_flow.h | 2 ++ drivers/net/mlx5/mlx5_flow_dv.c | 2 ++ 3 files changed, 21 insertions(+), 10 deletions(-)
drivers/net/mlx5/mlx5_flow.c +17 -10
@@ -4274,9 +4274,11 @@ flow_hairpin_split(struct rte_eth_dev *dev,rte_memcpy (actions_rx, actions,sizeof (struct rte_flow_action )); actions_rx++; set_tag = (void *)actions_rx; - set_tag->id =mlx5_flow_get_reg_id (dev,MLX5_HAIRPIN_RX ,0 ,NULL ); + *set_tag = (struct mlx5_rte_flow_action_set_tag ) { + .id =mlx5_flow_get_reg_id (dev,MLX5_HAIRPIN_RX ,0 ,NULL ), + .data = flow_id, + };MLX5_ASSERT (set_tag->id >REG_NON ); - set_tag->data = flow_id; tag_action->conf = set_tag;/* Create Tx item list. */ rte_memcpy (actions_tx, actions,sizeof (struct rte_flow_action ));
@@ -4511,6 +4513,13 @@ flow_meter_split_prep(struct rte_eth_dev *dev, set_tag = (struct mlx5_rte_flow_action_set_tag *)actions_pre; tag_item_spec = (struct mlx5_rte_flow_item_tag *)sfx_items; tag_item_mask = tag_item_spec +1 ; +/* Both flow_id and meter_id share the same register. */ + *set_tag = (struct mlx5_rte_flow_action_set_tag ) { + .id =mlx5_flow_get_reg_id (dev,MLX5_MTR_ID ,0 , error), + .offset = mtr_id_offset, + .length = mtr_reg_bits, + .data = fm->idx, + };/* * The color Reg bits used by flow_id are growing from * msb to lsb, so must do bit reverse for flow_id val in RegC.
@@ -4518,12 +4527,8 @@ flow_meter_split_prep(struct rte_eth_dev *dev,for (shift =0 ; shift < flow_id_bits; shift++) flow_id_val = (flow_id_val <<1 ) | (((tag_id -1 ) >> shift) &0x1 ); -/* Both flow_id and meter_id share the same register. */ - set_tag->id =mlx5_flow_get_reg_id (dev,MLX5_MTR_ID ,0 , error); - set_tag->data = - (fm->idx | (flow_id_val << (mtr_reg_bits - flow_id_bits))) - << mtr_id_offset; - tag_item_spec->id = set_tag->id; + set_tag->data |= flow_id_val << (mtr_reg_bits - flow_id_bits); + tag_item_spec->id = set_tag->id << mtr_id_offset; tag_item_spec->data = set_tag->data; tag_item_mask->data =UINT32_MAX << mtr_id_offset; tag_action->type = (enum rte_flow_action_type)
@@ -4911,10 +4916,12 @@ flow_sample_split_prep(struct rte_eth_dev *dev, ret =mlx5_flow_get_reg_id (dev,MLX5_APP_TAG ,0 , error);if (ret <0 )return ret; - set_tag->id = ret;mlx5_ipool_malloc (priv->sh->ipool [MLX5_IPOOL_RSS_EXPANTION_FLOW_ID ], &tag_id); - set_tag->data = tag_id; + *set_tag = (struct mlx5_rte_flow_action_set_tag ) { + .id = ret, + .data = tag_id, + };/* Prepare the suffix subflow items. */ tag_spec = (void *)(sfx_items +SAMPLE_SUFFIX_ITEM ); tag_spec->data = tag_id;
drivers/net/mlx5/mlx5_flow.h +2 -0
@@ -55,6 +55,8 @@ struct mlx5_rte_flow_item_tag {/* Modify selected register. */ struct mlx5_rte_flow_action_set_tag {enum modify_reg id; +uint8_t offset; +uint8_t length;uint32_t data; };
drivers/net/mlx5/mlx5_flow_dv.c +2 -0
@@ -964,6 +964,8 @@ flow_dv_convert_action_set_reg actions[i] = (struct mlx5_modification_cmd ) { .action_type =MLX5_MODIFICATION_TYPE_SET , .field = reg_to_field[conf->id], + .offset = conf->offset, + .length = conf->length, }; actions[i].data0 =rte_cpu_to_be_32 (actions[i].data0); actions[i].data1 =rte_cpu_to_be_32 (conf->data);
Signature · 1 line
2.27.0
PATCH 5/13 common/mlx5: add definitions for ASO flow meter
In reply to Li ZhangThis patch adds different PRM definitions, related to ASO flow meter feature, in MLX5 PMD code.
--- drivers/common/mlx5/mlx5_prm.h | 75 ++++++++++++++++++++++++++++++++-- 1 file changed, 71 insertions(+), 4 deletions(-)
drivers/common/mlx5/mlx5_prm.h +71 -4
@@ -1129,6 +1129,8 @@ enum { (1ULL << MLX5_GENERAL_OBJ_TYPE_FLEX_PARSE_GRAPH)#define MLX5_GENERAL_OBJ_TYPES_CAP_FLOW_HIT_ASO \ (1ULL << MLX5_GENERAL_OBJ_TYPE_FLOW_HIT_ASO) +#define MLX5_GENERAL_OBJ_TYPES_CAP_FLOW_METER_ASO \ + (1ULL << MLX5_GENERAL_OBJ_TYPE_FLOW_METER_ASO)#define MLX5_GENERAL_OBJ_TYPES_CAP_GENEVE_TLV_OPT \ (1ULL << MLX5_OBJ_TYPE_GENEVE_TLV_OPT)
@@ -1514,7 +1516,15 @@ struct mlx5_ifc_qos_cap_bits {u8 reserved_at_c0[0x10 ];u8 max_qos_para_vport[0x10 ];u8 max_tsar_bw_share[0x20 ]; -u8 reserved_at_100[0x6e8 ]; +u8 nic_element_type[0x10 ]; +u8 nic_tsar_type[0x10 ]; +u8 reserved_at_120[0x3 ]; +u8 log_meter_aso_granularity[0x5 ]; +u8 reserved_at_128[0x3 ]; +u8 log_meter_aso_max_alloc[0x5 ]; +u8 reserved_at_130[0x3 ]; +u8 log_max_num_meter_aso[0x5 ]; +u8 reserved_at_138[0x6b0 ]; };struct mlx5_ifc_per_protocol_networking_offload_caps_bits {
@@ -2284,6 +2294,8 @@ struct mlx5_ifc_flow_meter_parameters_bits {u8 eir_mantissa[0x8 ];u8 reserved_at_8[0x60 ];// 14h-1Ch }; +#define MLX5_IFC_FLOW_METER_PARAM_MASK UINT64_C(0x80FFFFFF) +#define MLX5_IFC_FLOW_METER_DISABLE_CBS_CIR_VAL 0x14BF00C8enum {MLX5_CQE_SIZE_64B =0x0 ,
@@ -2411,6 +2423,7 @@ enum {MLX5_GENERAL_OBJ_TYPE_VIRTQ =0x000d ,MLX5_GENERAL_OBJ_TYPE_VIRTIO_Q_COUNTERS =0x001c ,MLX5_GENERAL_OBJ_TYPE_FLEX_PARSE_GRAPH =0x0022 , +MLX5_GENERAL_OBJ_TYPE_FLOW_METER_ASO =0x0024 , MLX5_GENERAL_OBJ_TYPE_FLOW_HIT_ASO = 0x0025, };
@@ -2419,7 +2432,9 @@ struct mlx5_ifc_general_obj_in_cmd_hdr_bits {u8 reserved_at_10[0x20 ];u8 obj_type[0x10 ];u8 obj_id[0x20 ]; -u8 reserved_at_60[0x20 ]; +u8 reserved_at_60[0x3 ]; +u8 log_obj_range[0x5 ]; +u8 reserved_at_58[0x18 ]; };struct mlx5_ifc_general_obj_out_cmd_hdr_bits {
@@ -2565,6 +2580,18 @@ struct mlx5_ifc_create_flow_hit_aso_in_bits {struct mlx5_ifc_flow_hit_aso_bits flow_hit_aso; }; +struct mlx5_ifc_flow_meter_aso_bits { +u8 modify_field_select[0x40 ]; +u8 reserved_at_40[0x48 ]; +u8 access_pd[0x18 ]; +u8 reserved_at_a0[0x160 ]; +u8 parameters[0x200 ]; +}; + +struct mlx5_ifc_create_flow_meter_aso_in_bits { +struct mlx5_ifc_general_obj_in_cmd_hdr_bits hdr; +struct mlx5_ifc_flow_meter_aso_bits flow_meter_aso; +};enum mlx5_access_aso_opc_mod {ASO_OPC_MOD_IPSEC =0x0 ,ASO_OPC_MOD_CONNECTION_TRACKING =0x1 ,
@@ -2618,11 +2645,51 @@ struct mlx5_aso_cseg {uint64_t data_mask; } __rte_packed; +/* A meter data segment - 2 per ASO WQE. */ +struct mlx5_aso_mtr_dseg { +uint32_t v_bo_sc_bbog_mm; +/* +* bit 31: valid, 30: bucket overflow, 28-29: start color, +* 27: both buckets on green, 24-25: meter mode. +*/ +uint32_t reserved; +uint32_t cbs_cir; +/* +* bit 24-28: cbs_exponent, bit 16-23 cbs_mantissa, +* bit 8-12: cir_exponent, bit 0-7 cir_mantissa. +*/ +uint32_t c_tokens; +uint32_t ebs_eir; +/* +* bit 24-28: ebs_exponent, bit 16-23 ebs_mantissa, +* bit 8-12: eir_exponent, bit 0-7 eir_mantissa. +*/ +uint32_t e_tokens; +uint64_t timestamp; +} __rte_packed; + +#define ASO_DSEG_VALID_OFFSET 31 +#define ASO_DSEG_BO_OFFSET 30 +#define ASO_DSEG_SC_OFFSET 28 +#define ASO_DSEG_CBS_EXP_OFFSET 24 +#define ASO_DSEG_CBS_MAN_OFFSET 16 +#define ASO_DSEG_CIR_EXP_MASK 0x1F +#define ASO_DSEG_CIR_EXP_OFFSET 8 +#define ASO_DSEG_EBS_EXP_OFFSET 24 +#define ASO_DSEG_EBS_MAN_OFFSET 16 +#define ASO_DSEG_EXP_MASK 0x1F +#define ASO_DSEG_MAN_MASK 0xFF +#define MLX5_ASO_WQE_DSEG_SIZE 0x40 +#define MLX5_ASO_METERS_PER_WQE 2 +#define MLX5_ASO_MTRS_PER_POOL 128 -/* ASO WQE Data segment. */ +/* ASO WQE data segment. */ struct mlx5_aso_dseg { -uint8_t data[MLX5_ASO_WQE_DSEG_SIZE ]; +union { +uint8_t data[MLX5_ASO_WQE_DSEG_SIZE ]; +struct mlx5_aso_mtr_dseg mtrs[MLX5_ASO_METERS_PER_WQE ]; + }; } __rte_packed;/* ASO WQE. */
Signature · 1 line
2.27.0
PATCH 6/13 common/mlx5: add read ASO flow meter HCA capability
In reply to Li ZhangRead and store the device capability of FLOW_METER_ASO general object, using the DevX API.
--- drivers/common/mlx5/mlx5_devx_cmds.c | 14 ++++++++++++++ drivers/common/mlx5/mlx5_devx_cmds.h | 8 ++++++++ 2 files changed, 22 insertions(+)
drivers/common/mlx5/mlx5_devx_cmds.c +14 -0
@@ -695,6 +695,9 @@ mlx5_devx_cmd_query_hca_attr(void *ctx, attr->max_geneve_tlv_option_data_len =MLX5_GET (cmd_hca_cap, hcattr, max_geneve_tlv_option_data_len); attr->qos.sup =MLX5_GET (cmd_hca_cap, hcattr, qos); + attr->qos.flow_meter_aso_sup = !!(MLX5_GET64 (cmd_hca_cap, hcattr, + general_obj_types) & +MLX5_GENERAL_OBJ_TYPES_CAP_FLOW_METER_ASO ); attr->vdpa.valid = !!(MLX5_GET64 (cmd_hca_cap, hcattr, general_obj_types) &MLX5_GENERAL_OBJ_TYPES_CAP_VIRTQ_NET_Q );
@@ -778,6 +781,17 @@ mlx5_devx_cmd_query_hca_attr(void *ctx,MLX5_GET (qos_cap, hcattr, packet_pacing); attr->qos.wqe_rate_pp =MLX5_GET (qos_cap, hcattr, wqe_rate_pp); +if (attr->qos.flow_meter_aso_sup) { + attr->qos.log_meter_aso_granularity = +MLX5_GET (qos_cap, hcattr, + log_meter_aso_granularity); + attr->qos.log_meter_aso_max_alloc = +MLX5_GET (qos_cap, hcattr, + log_meter_aso_max_alloc); + attr->qos.log_max_num_meter_aso = +MLX5_GET (qos_cap, hcattr, + log_max_num_meter_aso); + } }if (attr->vdpa.valid)mlx5_devx_cmd_query_hca_vdpa_attr (ctx, &attr->vdpa);
drivers/common/mlx5/mlx5_devx_cmds.h +8 -0
@@ -49,10 +49,18 @@ struct mlx5_hca_qos_attr {* Using older driver versions, flow_meter_old can be 1 * while flow_meter is 0. */ + uint32_t flow_meter_aso_sup:1; +/* Whether FLOW_METER_ASO Object is supported. */ uint8_t log_max_flow_meter;/* Power of the maximum supported meters. */ uint8_t flow_meter_reg_c_ids;/* Bitmap of the reg_Cs available for flow meter to use. */ + uint32_t log_meter_aso_granularity:5; +/* Power of the minimum allocation granularity Object. */ + uint32_t log_meter_aso_max_alloc:5; +/* Power of the maximum allocation granularity Object. */ + uint32_t log_max_num_meter_aso:5; +/* Power of the maximum number of supported objects. */ };
Signature · 1 line
2.27.0
PATCH 7/13 common/mlx5: add DevX API to create ASO flow meter object
In reply to Li ZhangAdd DevX API to create ASO flow meter object.
--- drivers/common/mlx5/mlx5_devx_cmds.c | 54 ++++++++++++++++++++++++++++ drivers/common/mlx5/mlx5_devx_cmds.h | 18 +++++++++- drivers/common/mlx5/version.map | 1 + 3 files changed, 72 insertions(+), 1 deletion(-)
drivers/common/mlx5/mlx5_devx_cmds.c +54 -0
@@ -2154,6 +2154,60 @@ mlx5_devx_cmd_alloc_pd(void *ctx)return ppd; } +/** +* Create general object of type FLOW_METER_ASO using DevX API. +* +* @param[in] ctx +* Context returned from mlx5 open_device() glue function. +* @param [in] pd +* PD value to associate the FLOW_METER_ASO object with. +* @param [in] log_obj_size +* log_obj_size define to allocate number of 2 * meters +* in one FLOW_METER_ASO object. +* +* @return +* The DevX object created, NULL otherwise and rte_errno is set. +*/ +struct mlx5_devx_obj * +mlx5_devx_cmd_create_flow_meter_aso_obj (void *ctx,uint32_t pd, +uint32_t log_obj_size) +{ +uint32_t in[MLX5_ST_SZ_DW (create_flow_meter_aso_in)] = {0 }; +uint32_t out[MLX5_ST_SZ_DW (general_obj_out_cmd_hdr)]; +struct mlx5_devx_obj *flow_meter_aso_obj; +void *ptr; + + flow_meter_aso_obj =mlx5_malloc (MLX5_MEM_ZERO , +sizeof (*flow_meter_aso_obj), +0 ,SOCKET_ID_ANY ); +if (!flow_meter_aso_obj) { +DRV_LOG (ERR ,"Failed to allocate FLOW_METER_ASO object data" ); + rte_errno =ENOMEM ; +return NULL ; + } + ptr =MLX5_ADDR_OF (create_flow_meter_aso_in, in, hdr); +MLX5_SET (general_obj_in_cmd_hdr, ptr, opcode, +MLX5_CMD_OP_CREATE_GENERAL_OBJECT ); +MLX5_SET (general_obj_in_cmd_hdr, ptr, obj_type, +MLX5_GENERAL_OBJ_TYPE_FLOW_METER_ASO ); +MLX5_SET (general_obj_in_cmd_hdr, ptr, log_obj_range, + log_obj_size); + ptr =MLX5_ADDR_OF (create_flow_meter_aso_in, in, flow_meter_aso); +MLX5_SET (flow_meter_aso, ptr, access_pd, pd); + flow_meter_aso_obj->obj = mlx5_glue->devx_obj_create ( + ctx, in,sizeof (in), + out,sizeof (out)); +if (!flow_meter_aso_obj->obj) { + rte_errno = errno; +DRV_LOG (ERR ,"Failed to create FLOW_METER_ASO obj using DevX." ); +mlx5_free (flow_meter_aso_obj); +return NULL ; + } + flow_meter_aso_obj->id =MLX5_GET (general_obj_out_cmd_hdr, + out, obj_id); +return flow_meter_aso_obj; +} +/** * Create general object of type GENEVE TLV option using DevX API. *
drivers/common/mlx5/mlx5_devx_cmds.h +17 -1
@@ -551,7 +551,6 @@ int mlx5_devx_cmd_query_virtio_q_counters(struct mlx5_devx_obj *couners_obj,__rte_internal struct mlx5_devx_obj *mlx5_devx_cmd_create_flow_hit_aso_obj(void *ctx,uint32_t pd); -__rte_internal struct mlx5_devx_obj *mlx5_devx_cmd_alloc_pd(void *ctx);
@@ -563,4 +562,21 @@ struct mlx5_devx_obj *mlx5_devx_cmd_queue_counter_alloc(void *ctx);__rte_internal int mlx5_devx_cmd_queue_counter_query(struct mlx5_devx_obj *dcs, int clear,uint32_t *out_of_buffers); +/** +* Create general object of type FLOW_METER_ASO using DevX API.. +* +* @param[in] ctx +* Device context. +* @param [in] pd +* PD value to associate the FLOW_METER_ASO object with. +* @param [in] log_obj_size +* log_obj_size define to allocate number of 2 * meters +* in one FLOW_METER_ASO object. +* +* @return +* The DevX object created, NULL otherwise and rte_errno is set. +*/ +__rte_internal +struct mlx5_devx_obj *mlx5_devx_cmd_create_flow_meter_aso_obj(void *ctx, +uint32_t pd,uint32_t log_obj_size);#endif /* RTE_PMD_MLX5_DEVX_CMDS_H_ */
drivers/common/mlx5/version.map +1 -0
@@ -23,6 +23,7 @@ INTERNAL { mlx5_devx_cmd_create_virtio_q_counters; mlx5_devx_cmd_create_virtq; mlx5_devx_cmd_create_flow_hit_aso_obj; + mlx5_devx_cmd_create_flow_meter_aso_obj; mlx5_devx_cmd_create_geneve_tlv_option; mlx5_devx_cmd_destroy; mlx5_devx_cmd_flow_counter_alloc;
Signature · 1 line
2.27.0
PATCH 8/13 net/mlx5: flow meter pool to manage meter object
In reply to Li ZhangAdd ASO flow meter pool to manage meter object
--- drivers/net/mlx5/mlx5.c | 2 +- drivers/net/mlx5/mlx5.h | 207 ++++++++++++- drivers/net/mlx5/mlx5_flow.c | 70 ++++- drivers/net/mlx5/mlx5_flow.h | 196 +++---------- drivers/net/mlx5/mlx5_flow_dv.c | 202 ++++++++++++- drivers/net/mlx5/mlx5_flow_meter.c | 450 ++++++++++++++++++----------- 6 files changed, 768 insertions(+), 359 deletions(-)
drivers/net/mlx5/mlx5.c +1 -1
@@ -280,7 +280,7 @@ static const struct mlx5_indexed_pool_config mlx5_ipool_cfg[] = {* for meter idx, so not set grow_trunk to avoid meter index * not jump continually. */ - .size = sizeof(struct mlx5_flow_meter), + .size = sizeof(struct mlx5_legacy_flow_meter), .trunk_size = 64, .need_lock = 1, .release_mem_en = 1,
drivers/net/mlx5/mlx5.h +200 -7
258 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow.c +54 -16
143 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow.h +48 -148
256 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_dv.c +188 -14
308 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_meter.c +277 -173
723 lines not on this page · raw message
Signature · 1 line
2.27.0
PATCH 9/13 net/mlx5: init/uninit flow meter queue for WQE
In reply to Li ZhangInit/uninit flow meter SQ for WQE
---
drivers/net/mlx5/linux/mlx5_os.c | 17 ++++
drivers/net/mlx5/meson.build | 2 +-
drivers/net/mlx5/mlx5.c | 78 ++++++++++++++-
drivers/net/mlx5/mlx5.h | 22 +++--
drivers/net/mlx5/mlx5_flow.h | 4 +-
.../mlx5/{mlx5_flow_age.c => mlx5_flow_aso.c} | 96 ++++++++++++++++---
drivers/net/mlx5/mlx5_flow_dv.c | 7 +-
drivers/net/mlx5/mlx5_flow_meter.c | 7 +-
8 files changed, 201 insertions(+), 32 deletions(-)
rename drivers/net/mlx5/{mlx5_flow_age.c => mlx5_flow_aso.c} (85%)drivers/net/mlx5/linux/mlx5_os.c +17 -0
@@ -813,6 +813,7 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,char name[RTE_ETH_NAME_MAX_LEN ];int own_domain_id =0 ;uint16_t port_id; +uint32_t log_obj_size;#ifdef HAVE_MLX5DV_DR_DEVX_PORT struct mlx5dv_devx_port devx_port = { .comp_mask =0 };#endif
@@ -1283,6 +1284,22 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, priv->mtr_color_reg); } } +if (config->hca_attr.qos.sup && + config->hca_attr.qos.flow_meter_aso_sup) { + log_obj_size = +rte_log2_u32 (MLX5_ASO_MTRS_PER_POOL >>1 ); +if (log_obj_size >= + config->hca_attr.qos.log_meter_aso_granularity && + log_obj_size <= + config->hca_attr.qos.log_meter_aso_max_alloc) { + sh->meter_aso_en =1 ; + err =mlx5_aso_flow_mtrs_mng_init (priv); +if (err) { + err = -err; + goto error; + } + } + }#endif #ifdef HAVE_MLX5_DR_CREATE_ACTION_ASO if (config->hca_attr.flow_hit_aso &&
drivers/net/mlx5/meson.build +1 -1
@@ -15,7 +15,7 @@ sources = files( 'mlx5_flow.c', 'mlx5_flow_meter.c', 'mlx5_flow_dv.c', - 'mlx5_flow_age.c', + 'mlx5_flow_aso.c', 'mlx5_mac.c', 'mlx5_mr.c', 'mlx5_rss.c',
drivers/net/mlx5/mlx5.c +75 -3
114 lines not on this page · raw message
drivers/net/mlx5/mlx5.h +15 -7
@@ -492,8 +492,13 @@ struct mlx5_aso_devx_mr { };struct mlx5_aso_sq_elem { -struct mlx5_aso_age_pool *pool; -uint16_t burst_size; +union { +struct { +struct mlx5_aso_age_pool *pool; +uint16_t burst_size; + }; +struct mlx5_aso_mtr *mtr; + }; };struct mlx5_aso_sq {
@@ -765,7 +770,6 @@ struct mlx5_aso_mtr_pools_mng {volatile uint16_t n_valid;/* Number of valid pools. */ uint16_t n;/* Number of pools. */ rte_spinlock_t mtrsl;/* The ASO flow meter free list lock. */ -struct mlx5_l3t_tbl *mtr_idx_tbl;/* Meter index lookup table. */ struct aso_meter_list meters;/* Free ASO flow meter list. */ struct mlx5_aso_sq sq;/*SQ using by ASO flow meter. */ struct mlx5_aso_mtr_pool **pools;/* ASO flow meter pool array. */
@@ -1196,6 +1200,7 @@ struct mlx5_priv {uint8_t mtr_color_reg;/* Meter color match REG_C. */ struct mlx5_mtr_profiles flow_meter_profiles;/* MTR profile list. */ struct mlx5_legacy_flow_meters flow_meters;/* MTR list. */ +struct mlx5_l3t_tbl *mtr_idx_tbl;/* Meter index lookup table. */ uint8_t skip_default_rss_reta;/* Skip configuration of default reta. */ uint8_t fdb_def_rule;/* Whether fdb jump to table 1 is configured. */ struct mlx5_mp_id mp_id;/* ID of a multi-process process */
@@ -1259,6 +1264,7 @@ int mlx5_hairpin_cap_get(struct rte_eth_dev *dev,bool mlx5_flex_parser_ecpri_exist (struct rte_eth_dev *dev);int mlx5_flex_parser_ecpri_alloc (struct rte_eth_dev *dev);int mlx5_flow_aso_age_mng_init (struct mlx5_dev_ctx_shared *sh); +int mlx5_aso_flow_mtrs_mng_init (struct mlx5_priv *priv);/* mlx5_ethdev.c */
@@ -1529,9 +1535,11 @@ eth_tx_burst_t mlx5_select_tx_function(struct rte_eth_dev *dev);/* mlx5_flow_aso.c */ -int mlx5_aso_queue_init (struct mlx5_dev_ctx_shared *sh); -int mlx5_aso_queue_start (struct mlx5_dev_ctx_shared *sh); -int mlx5_aso_queue_stop (struct mlx5_dev_ctx_shared *sh); -void mlx5_aso_queue_uninit (struct mlx5_dev_ctx_shared *sh); +int mlx5_aso_queue_init (struct mlx5_dev_ctx_shared *sh, +enum mlx5_access_aso_opc_mod aso_opc_mod); +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);#endif /* RTE_PMD_MLX5_H_ */
drivers/net/mlx5/mlx5_flow.h +2 -2
@@ -827,8 +827,8 @@ struct mlx5_flow {#define MLX5_FLOW_METER_DISABLE 0#define MLX5_FLOW_METER_ENABLE 1 -#define MLX5_ASO_CQE_RESPONSE_DELAY 10 -#define MLX5_MTR_POLL_CQE_TIMES 100000u +#define MLX5_ASO_WQE_CQE_RESPONSE_DELAY 10u +#define MLX5_MTR_POLL_WQE_CQE_TIMES 100000u#define MLX5_MAN_WIDTH 8/* Legacy Meter parameter structure. */
drivers/net/mlx5/mlx5_flow_aso.c renamed from drivers/net/mlx5/mlx5_flow_age.c +82 -14
156 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_dv.c +6 -1
@@ -5947,6 +5947,11 @@ flow_dv_mtr_container_resize(struct rte_eth_dev *dev) rte_errno =ENOMEM ;return -ENOMEM ; } +if (!mtrmng->n) +if (mlx5_aso_queue_init (priv->sh,ASO_OPC_MOD_POLICER )) { +mlx5_free (pools); +return -ENOMEM ; + }if (old_pools)memcpy (pools, old_pools, mtrmng->n *sizeof (struct mlx5_aso_mtr_pool *));
@@ -10818,7 +10823,7 @@ flow_dv_aso_age_pools_resize(struct rte_eth_dev *dev)mlx5_free (old_pools); }else {/* First ASO flow hit allocation - starting ASO data-path. */ -int ret =mlx5_aso_queue_start (priv->sh); +int ret =mlx5_aso_flow_hit_queue_poll_start (priv->sh);if (ret) {mlx5_free (pools);
drivers/net/mlx5/mlx5_flow_meter.c +3 -4
@@ -811,7 +811,6 @@ mlx5_flow_meter_destroy(struct rte_eth_dev *dev, uint32_t meter_id, struct rte_mtr_error *error) {struct mlx5_priv *priv = dev->data->dev_private; -struct mlx5_aso_mtr_pools_mng *mtrmng = priv->sh->mtrmng;struct mlx5_flow_meter_info *fm;const struct rte_flow_attr attr = { .ingress =1 ,
@@ -836,7 +835,7 @@ mlx5_flow_meter_destroy(struct rte_eth_dev *dev, uint32_t meter_id,RTE_MTR_ERROR_TYPE_UNSPECIFIED , NULL, "Meter object is being used.");if (priv->sh->meter_aso_en) { -if (mlx5_l3t_clear_entry (mtrmng->mtr_idx_tbl, meter_id)) +if (mlx5_l3t_clear_entry (priv->mtr_idx_tbl, meter_id))return -rte_mtr_error_set (error,EBUSY ,RTE_MTR_ERROR_TYPE_UNSPECIFIED ,NULL ,"Fail to delete ASO Meter in index table." );
@@ -1302,7 +1301,7 @@ mlx5_flow_meter_find(struct mlx5_priv *priv, uint32_t meter_id,rte_spinlock_unlock (&mtrmng->mtrsl);return NULL ; } -if (mlx5_l3t_get_entry (mtrmng->mtr_idx_tbl, meter_id, &data) || +if (mlx5_l3t_get_entry (priv->mtr_idx_tbl, meter_id, &data) || !data.dword) {rte_spinlock_unlock (&mtrmng->mtrsl);return NULL ;
@@ -1310,7 +1309,7 @@ mlx5_flow_meter_find(struct mlx5_priv *priv, uint32_t meter_id,if (mtr_idx) *mtr_idx = data.dword; aso_mtr =mlx5_aso_meter_by_idx (priv, data.dword); -mlx5_l3t_clear_entry (mtrmng->mtr_idx_tbl, meter_id); +mlx5_l3t_clear_entry (priv->mtr_idx_tbl, meter_id);if (meter_id == aso_mtr->fm.meter_id) {rte_spinlock_unlock (&mtrmng->mtrsl);return &aso_mtr->fm;
Signature · 1 line
2.27.0
PATCH 10/13 net/mlx5: aso flow meter send WQE and CQE handle
In reply to Li ZhangASO flow meter send WQE and CQE handle functions
--- drivers/net/mlx5/mlx5.h | 4 + drivers/net/mlx5/mlx5_flow_aso.c | 182 +++++++++++++++++++++++++++++ drivers/net/mlx5/mlx5_flow_meter.c | 143 ++++++++++++++--------- 3 files changed, 274 insertions(+), 55 deletions(-)
drivers/net/mlx5/mlx5.h +4 -0
@@ -1541,5 +1541,9 @@ 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, +struct mlx5_aso_mtr *mtr); +int mlx5_aso_mtr_wait (struct mlx5_dev_ctx_shared *sh, +struct mlx5_aso_mtr *mtr);#endif /* RTE_PMD_MLX5_H_ */
drivers/net/mlx5/mlx5_flow_aso.c +182 -0
185 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_meter.c +88 -55
221 lines not on this page · raw message
Signature · 1 line
2.27.0
PATCH 11/13 net/mlx5: add support of ASO meter action
In reply to Li ZhangWhen ASO action is available, use it as the meter action
--- drivers/net/mlx5/linux/mlx5_os.c | 7 ++- drivers/net/mlx5/mlx5.c | 8 +++ drivers/net/mlx5/mlx5.h | 7 ++- drivers/net/mlx5/mlx5_flow.c | 69 +++++++++++++++------ drivers/net/mlx5/mlx5_flow_dv.c | 26 ++++++-- drivers/net/mlx5/mlx5_flow_meter.c | 97 +++++++++++++++++++----------- 6 files changed, 153 insertions(+), 61 deletions(-)
drivers/net/mlx5/linux/mlx5_os.c +4 -3
@@ -813,7 +813,6 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,char name[RTE_ETH_NAME_MAX_LEN ];int own_domain_id =0 ;uint16_t port_id; -uint32_t log_obj_size;#ifdef HAVE_MLX5DV_DR_DEVX_PORT struct mlx5dv_devx_port devx_port = { .comp_mask =0 };#endif
@@ -1249,7 +1248,9 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,"required for coalescing is %d bytes" , config->hca_attr.lro_min_mss_size); } -#if defined(HAVE_MLX5DV_DR ) && defined(HAVE_MLX5_DR_CREATE_ACTION_FLOW_METER ) +#if defined(HAVE_MLX5DV_DR ) && \ + (defined(HAVE_MLX5_DR_CREATE_ACTION_FLOW_METER ) || \ + defined(HAVE_MLX5_DR_CREATE_ACTION_ASO ))if (config->hca_attr.qos.sup && config->hca_attr.qos.flow_meter_old && config->dv_flow_en) {
@@ -1286,7 +1287,7 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, }if (config->hca_attr.qos.sup && config->hca_attr.qos.flow_meter_aso_sup) { - log_obj_size = +uint32_t log_obj_size =rte_log2_u32 (MLX5_ASO_MTRS_PER_POOL >>1 ); if (log_obj_size >= config->hca_attr.qos.log_meter_aso_granularity &&
drivers/net/mlx5/mlx5.c +8 -0
@@ -605,13 +605,21 @@ static void mlx5_aso_flow_mtrs_mng_close(struct mlx5_dev_ctx_shared *sh) {struct mlx5_aso_mtr_pool *mtr_pool; +struct mlx5_aso_mtr *aso_mtr;struct mlx5_aso_mtr_pools_mng *mtrmng = sh->mtrmng;uint32_t idx; +int i;mlx5_aso_queue_uninit (sh,ASO_OPC_MOD_POLICER ); idx = mtrmng->n_valid;while (idx--) { mtr_pool = mtrmng->pools[idx]; +for (i =0 ; i <MLX5_ASO_MTRS_PER_POOL ; i++) { + aso_mtr = &mtr_pool->mtrs[i]; +if (aso_mtr->fm.meter_action) +claim_zero (mlx5_glue->destroy_flow_action + (aso_mtr->fm.meter_action)); + }claim_zero (mlx5_devx_cmd_destroy (mtr_pool->devx_obj)); mtrmng->n_valid--;
drivers/net/mlx5/mlx5.h +4 -3
@@ -635,8 +635,6 @@ struct mlx5_meter_domains_infos {/**< Counters for green rule. */ void *drop_count;/**< Counters for green rule. */ -void *meter_action; -/**< Flow meter action. */ };/* Meter parameter structure. */
@@ -699,6 +697,8 @@ struct mlx5_flow_meter_info {/**< Use count. */ struct mlx5_indexed_pool *flow_ipool;/**< Index pool for flow id. */ +void *meter_action; +/**< Flow meter action. */ };/* RFC2697 parameter structure. */
@@ -1488,7 +1488,8 @@ int mlx5_flow_meter_attach(struct mlx5_priv *priv,struct mlx5_flow_meter_info *fm, const struct rte_flow_attr *attr, struct rte_flow_error *error); -void mlx5_flow_meter_detach (struct mlx5_flow_meter_info *fm); +void mlx5_flow_meter_detach (struct mlx5_priv *priv, +struct mlx5_flow_meter_info *fm);/* mlx5_os.c */ struct rte_pci_driver ;
drivers/net/mlx5/mlx5_flow.c +52 -17
131 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_dv.c +22 -4
@@ -4887,9 +4887,11 @@ mlx5_flow_validate_action_meter(struct rte_eth_dev *dev,return rte_flow_error_set (error,EINVAL ,RTE_FLOW_ERROR_TYPE_ACTION ,NULL ,"Meter not found" ); -if (fm->ref_cnt && (!(fm->transfer == attr->transfer || +/* aso meter can always be shared by different domains */ +if (fm->ref_cnt && !priv->sh->meter_aso_en && + !(fm->transfer == attr->transfer || (!fm->ingress && !attr->ingress && attr->egress) || - (!fm->egress && !attr->egress && attr->ingress)))) + (!fm->egress && !attr->egress && attr->ingress)))return rte_flow_error_set (error,EINVAL ,RTE_FLOW_ERROR_TYPE_ACTION ,NULL , "Flow attributes are either invalid "
@@ -6058,6 +6060,8 @@ flow_dv_mtr_alloc(struct rte_eth_dev *dev)struct mlx5_aso_mtr *mtr_free =NULL ;struct mlx5_aso_mtr_pools_mng *mtrmng = priv->sh->mtrmng;struct mlx5_aso_mtr_pool *pool; +struct rte_flow_error error; +uint8_t reg_id;uint32_t mtr_idx =0 ;if (!priv->config.devx) {
@@ -6080,6 +6084,20 @@ flow_dv_mtr_alloc(struct rte_eth_dev *dev) struct mlx5_aso_mtr_pool, mtrs[mtr_free->offset]); mtr_idx =MLX5_MAKE_MTR_IDX (pool->index, mtr_free->offset); +if (!mtr_free->fm.meter_action) { + reg_id =mlx5_flow_get_reg_id (dev,MLX5_MTR_COLOR ,0 , &error); + mtr_free->fm.meter_action = + mlx5_glue->dv_create_flow_action_aso + (priv->sh->rx_domain, + pool->devx_obj->obj, + mtr_free->offset, + (1 <<MLX5_FLOW_COLOR_GREEN ), + reg_id -REG_C_0 ); +if (!mtr_free->fm.meter_action) { +flow_dv_aso_mtr_release_to_pool (dev, mtr_idx); +return 0 ; + } + }return mtr_idx; }
@@ -11579,7 +11597,7 @@ flow_dv_translate(struct rte_eth_dev *dev, NULL, "Failed to get meter in flow.");/* Set the meter action. */ dev_flow->dv.actions[actions_n++] = - wks->fm->mfts->meter_action; + wks->fm->meter_action; action_flags |=MLX5_FLOW_ACTION_METER ;break ;case RTE_FLOW_ACTION_TYPE_SET_IPV4_DSCP :
@@ -12688,7 +12706,7 @@ flow_dv_destroy(struct rte_eth_dev *dev, struct rte_flow *flow)if (flow->meter) { fm =flow_dv_meter_find_by_idx (priv, flow->meter);if (fm) -mlx5_flow_meter_detach (fm); +mlx5_flow_meter_detach (priv, fm); flow->meter =0 ; }if (flow->age)
drivers/net/mlx5/mlx5_flow_meter.c +63 -34
141 lines not on this page · raw message
Signature · 1 line
2.27.0
PATCH 12/13 net/mlx5: make ASO meter queue thread-safe
In reply to Li ZhangSynchronize ASO meter queue accesses from
different threads using a spinlock.
--- drivers/net/mlx5/mlx5.h | 1 + drivers/net/mlx5/mlx5_flow_aso.c | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-)
drivers/net/mlx5/mlx5.h +1 -0
@@ -503,6 +503,7 @@ struct mlx5_aso_sq_elem {struct mlx5_aso_sq {uint16_t log_desc_n; +rte_spinlock_t sqsl;struct mlx5_aso_cq cq;struct mlx5_devx_sq sq_obj;volatile uint64_t *uar_addr;
drivers/net/mlx5/mlx5_flow_aso.c +13 -3
@@ -275,6 +275,7 @@ mlx5_aso_sq_create(void *ctx, struct mlx5_aso_sq *sq, int socket, sq->tail =0 ; sq->sqn = sq->sq_obj.sq->id; sq->uar_addr =mlx5_os_get_devx_uar_reg_addr (uar); +rte_spinlock_init (&sq->sqsl);return 0 ; error:mlx5_aso_destroy_sq (sq);
@@ -666,12 +667,15 @@ mlx5_aso_mtr_sq_enqueue_single(struct mlx5_aso_sq *sq,struct mlx5_flow_meter_info *fm =NULL ;uint16_t size =1 << sq->log_desc_n;uint16_t mask = size -1 ; -uint16_t res = size - (uint16_t )(sq->head - sq->tail); +uint16_t res;uint32_t dseg_idx =0 ;struct mlx5_aso_mtr_pool *pool =NULL ; +rte_spinlock_lock (&sq->sqsl); + res = size - (uint16_t )(sq->head - sq->tail);if (unlikely (!res)) {DRV_LOG (ERR ,"Fail: SQ is full and no free WQE to send" ); +rte_spinlock_unlock (&sq->sqsl);return 0 ; } wqe = &sq->sq_obj.aso_wqes[sq->head & mask];
@@ -708,6 +712,7 @@ mlx5_aso_mtr_sq_enqueue_single(struct mlx5_aso_sq *sq,rte_wmb (); *sq->uar_addr = *(volatile uint64_t *)wqe;/* Assume 64 bit ARCH. */ rte_wmb (); +rte_spinlock_unlock (&sq->sqsl);return 1 ; }
@@ -738,12 +743,16 @@ mlx5_aso_mtr_completion_handle(struct mlx5_aso_sq *sq)const unsigned int mask = cq_size -1 ;uint32_t idx;uint32_t next_idx = cq->cq_ci & mask; -const uint16_t max = (uint16_t )(sq->head - sq->tail); +uint16_t max;uint16_t n =0 ;int ret; -if (unlikely (!max)) +rte_spinlock_lock (&sq->sqsl); + max = (uint16_t )(sq->head - sq->tail); +if (unlikely (!max)) { +rte_spinlock_unlock (&sq->sqsl);return ; + } do { idx = next_idx; next_idx = (cq->cq_ci + 1) & mask;
@@ -770,6 +779,7 @@ mlx5_aso_mtr_completion_handle(struct mlx5_aso_sq *sq)rte_io_wmb (); cq->cq_obj.db_rec[0 ] =rte_cpu_to_be_32 (cq->cq_ci); } +rte_spinlock_unlock (&sq->sqsl); }/**
Signature · 1 line
2.27.0
PATCH 13/13 net/mlx5: allow multiple flow tables on the same level
In reply to Li ZhangThe driver devices support creation of multiple flow tables. Jump action can be used in order to move the packet steering to different flow table.
Table 0 is always the root table for packet steering.
Jumping between tables may cause endless loops in steering mechanism, that's why each table has level attribute,
the driver sub-system may not allow jumping to table with equal or lower level than the current table.
Currently, in the driver, the table ID and level are always identical.
Allow multiple flow table creation with the same level attribute.
This patch adds the table id in flow table data entry, while allocates the flow table, if the table level is same but the different table id, the new table will be allocated with new table object id. It supports 4M multiple flow tables on the same level.
--- drivers/net/mlx5/mlx5.c | 9 ++-- drivers/net/mlx5/mlx5.h | 10 ++-- drivers/net/mlx5/mlx5_flow.c | 11 +++-- drivers/net/mlx5/mlx5_flow.h | 10 ++-- drivers/net/mlx5/mlx5_flow_dv.c | 83 +++++++++++++++++++-------------- 5 files changed, 71 insertions(+), 52 deletions(-)
drivers/net/mlx5/mlx5.c +6 -3
@@ -1265,9 +1265,12 @@ mlx5_alloc_table_hash_list(struct mlx5_priv *priv __rte_unused)* because DV expect to see them even if they cannot be created by * RDMA-CORE. */ -if (!flow_dv_tbl_resource_get (dev,0 ,0 ,0 ,0 ,NULL ,0 ,1 , &error) || - !flow_dv_tbl_resource_get (dev,0 ,1 ,0 ,0 ,NULL ,0 ,1 , &error) || - !flow_dv_tbl_resource_get (dev,0 ,0 ,1 ,0 ,NULL ,0 ,1 , &error)) { +if (!flow_dv_tbl_resource_get (dev,0 ,0 ,0 ,0 , +NULL ,0 ,1 ,0 , &error) || + !flow_dv_tbl_resource_get (dev,0 ,1 ,0 ,0 , +NULL ,0 ,1 ,0 , &error) || + !flow_dv_tbl_resource_get (dev,0 ,0 ,1 ,0 , +NULL ,0 ,1 ,0 , &error)) { err =ENOMEM ; goto error; }
drivers/net/mlx5/mlx5.h +6 -4
@@ -780,10 +780,12 @@ struct mlx5_aso_mtr_pools_mng {union mlx5_flow_tbl_key {struct {/* Table ID should be at the lowest address. */ -uint32_t table_id;/**< ID of the table. */ -uint16_t dummy;/**< Dummy table for DV API. */ -uint8_t domain;/**< 1 - FDB, 0 - NIC TX/RX. */ -uint8_t direction;/**< 1 - egress, 0 - ingress. */ +uint32_t level;/**< Level of the table. */ +uint32_t id:22 ;/**< ID of the table. */ +uint32_t dummy:1 ;/**< Dummy table for DV API. */ +uint32_t is_fdb:1 ;/**< 1 - FDB, 0 - NIC TX/RX. */ +uint32_t is_egress:1 ;/**< 1 - egress, 0 - ingress. */ +uint32_t reserved:7 ;/**< must be zero for comparison. */ };uint64_t v64;/**< full 64bits value of key */ };
drivers/net/mlx5/mlx5_flow.c +6 -5
@@ -5500,8 +5500,7 @@ flow_create_split_sample(struct rte_eth_dev *dev, struct mlx5_flow_tbl_data_entry, tbl); sfx_attr.group = sfx_attr.transfer ? - (sfx_tbl_data->table_id -1 ) : - sfx_tbl_data->table_id; + (sfx_tbl_data->level -1 ) : sfx_tbl_data->level; }else {MLX5_ASSERT (attr->transfer); sfx_attr.group = jump_table;
@@ -7754,10 +7753,12 @@ tunnel_mark_decode(struct rte_eth_dev *dev, uint32_t mark)union tunnel_offload_mark mbits = { .val = mark };union mlx5_flow_tbl_key table_key = { { - .table_id =tunnel_id_to_flow_tbl (mbits.table_id), + .level =tunnel_id_to_flow_tbl (mbits.table_id), + .id =0 , + .reserved =0 , .dummy =0 , - .domain = !!mbits.transfer, - .direction =0 , + .is_fdb = !!mbits.transfer, + .is_egress =0 , } }; he =mlx5_hlist_lookup (sh->flow_tbls, table_key.v64,NULL );
drivers/net/mlx5/mlx5_flow.h +6 -4
@@ -565,8 +565,9 @@ struct mlx5_flow_tbl_data_entry { uint32_t is_egress:1; /**< Egress table. */ uint32_t is_transfer:1; /**< Transfer table. */ uint32_t dummy:1; /**< DR table. */ - uint32_t reserve:27; /**< Reserved to future using. */ -uint32_t table_id;/**< Table ID. */ + uint32_t id:22; /**< Table ID. */ + uint32_t reserve:5; /**< Reserved to future using. */ +uint32_t level;/**< Table level. */ };/* Sub rdma-core actions list. */
@@ -1393,9 +1394,10 @@ int flow_dv_tbl_match_cb(struct mlx5_hlist *list,void flow_dv_tbl_remove_cb (struct mlx5_hlist *list,struct mlx5_hlist_entry *entry);struct mlx5_flow_tbl_resource *flow_dv_tbl_resource_get (struct rte_eth_dev *dev, -uint32_t table_id,uint8_t egress,uint8_t transfer, +uint32_t table_level,uint8_t egress,uint8_t transfer,bool external,const struct mlx5_flow_tunnel *tunnel, -uint32_t group_id,uint8_t dummy,struct rte_flow_error *error); +uint32_t group_id,uint8_t dummy, +uint32_t table_id,struct rte_flow_error *error);struct mlx5_hlist_entry *flow_dv_tag_create_cb (struct mlx5_hlist *list,uint64_t key,void *cb_ctx);
drivers/net/mlx5/mlx5_flow_dv.c +47 -36
204 lines not on this page · raw message
Signature · 1 line
2.27.0
v2 cover Add ASO meter support in MLX5 PMD
In reply to Li ZhangTo support more meters and better performance,
MLX HW provide ASO flow meter.
It can expose millions of ASO flow meter context's in HW. This ASO object can allocate the large bulk meter objects. This patch set implement the ASO flow meter for mlx5 driver. MLX5 PMD driver will be responsible for ASO flow meter manage to HW.
V2: Fix compile error issue (mlx5_glue->destroy_flow_action)
Li Zhang (10):
net/mlx5: optimize meter statistics
common/mlx5: add definitions for ASO flow meter common/mlx5: add read ASO flow meter HCA capability common/mlx5: add DevX API to create ASO flow meter object net/mlx5: flow meter pool to manage meter object net/mlx5: init/uninit flow meter queue for WQE net/mlx5: aso flow meter send WQE and CQE handle net/mlx5: add support of ASO meter action net/mlx5: make ASO meter queue thread-safe net/mlx5: allow multiple flow tables on the same level
Shun Hao (2):
net/mlx5: fix meter statistics
net/mlx5: use mask for meter register setting
Suanming Mou (1):
net/mlx5: support three level table walk
doc/guides/nics/mlx5.rst | 6 +
drivers/common/mlx5/mlx5_devx_cmds.c | 68 ++
drivers/common/mlx5/mlx5_devx_cmds.h | 26 +-
drivers/common/mlx5/mlx5_prm.h | 75 +-
drivers/common/mlx5/version.map | 1 +
drivers/net/mlx5/linux/mlx5_os.c | 29 +-
drivers/net/mlx5/meson.build | 2 +-
drivers/net/mlx5/mlx5.c | 106 ++-
drivers/net/mlx5/mlx5.h | 268 +++++-
drivers/net/mlx5/mlx5_flow.c | 321 +++++--
drivers/net/mlx5/mlx5_flow.h | 210 ++---
.../mlx5/{mlx5_flow_age.c => mlx5_flow_aso.c} | 291 +++++-
drivers/net/mlx5/mlx5_flow_dv.c | 789 +++++++++++-----
drivers/net/mlx5/mlx5_flow_meter.c | 873 ++++++++++++------
drivers/net/mlx5/mlx5_utils.h | 90 ++
15 files changed, 2325 insertions(+), 830 deletions(-)
rename drivers/net/mlx5/{mlx5_flow_age.c => mlx5_flow_aso.c} (65%)Signature · 1 line
2.27.0
PATCH v2 1/13 net/mlx5: support three level table walk
From: Suanming Mou <[email protected]>
This commit adds table entry walk for the three level table.
--- drivers/net/mlx5/mlx5_utils.h | 90 +++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+)
drivers/net/mlx5/mlx5_utils.h +90 -0
@@ -832,6 +832,91 @@ int32_t mlx5_l3t_clear_entry(struct mlx5_l3t_tbl *tbl, uint32_t idx);int32_t mlx5_l3t_set_entry (struct mlx5_l3t_tbl *tbl,uint32_t idx,union mlx5_l3t_data *data); +static inline void * +mlx5_l3t_get_next (struct mlx5_l3t_tbl *tbl,uint32_t *pos) +{ +struct mlx5_l3t_level_tbl *g_tbl, *m_tbl; +uint32_t i, j, k, g_start, m_start, e_start; +uint32_t idx = *pos; +void *e_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; + +if (!tbl) +return NULL ; + g_tbl = tbl->tbl; +if (!g_tbl) +return NULL ; + g_start = (idx >>MLX5_L3T_GT_OFFSET ) &MLX5_L3T_GT_MASK ; + m_start = (idx >>MLX5_L3T_MT_OFFSET ) &MLX5_L3T_MT_MASK ; + e_start = idx &MLX5_L3T_ET_MASK ; +for (i = g_start; i <MLX5_L3T_GT_SIZE ; i++) { + m_tbl = g_tbl->tbl[i]; +if (!m_tbl) { +/* Jump to new table, reset the sub table start. */ + m_start =0 ; + e_start =0 ; +continue ; + } +for (j = m_start; j <MLX5_L3T_MT_SIZE ; j++) { +if (!m_tbl->tbl[j]) { +/* +* Jump to new table, reset the sub table +* start. +*/ + e_start =0 ; +continue ; + } + e_tbl = m_tbl->tbl[j]; +switch (tbl->type) { +case MLX5_L3T_TYPE_WORD : + w_e_tbl = (struct mlx5_l3t_entry_word *)e_tbl; +for (k = e_start; k <MLX5_L3T_ET_SIZE ; k++) { +if (!w_e_tbl->entry[k].data) +continue ; + *pos = (i <<MLX5_L3T_GT_OFFSET ) | + (j <<MLX5_L3T_MT_OFFSET ) | k; +return (void *)&w_e_tbl->entry[k].data; + } +break ; +case MLX5_L3T_TYPE_DWORD : + dw_e_tbl = (struct mlx5_l3t_entry_dword *)e_tbl; +for (k = e_start; k <MLX5_L3T_ET_SIZE ; k++) { +if (!dw_e_tbl->entry[k].data) +continue ; + *pos = (i <<MLX5_L3T_GT_OFFSET ) | + (j <<MLX5_L3T_MT_OFFSET ) | k; +return (void *)&dw_e_tbl->entry[k].data; + } +break ; +case MLX5_L3T_TYPE_QWORD : + qw_e_tbl = (struct mlx5_l3t_entry_qword *)e_tbl; +for (k = e_start; k <MLX5_L3T_ET_SIZE ; k++) { +if (!qw_e_tbl->entry[k].data) +continue ; + *pos = (i <<MLX5_L3T_GT_OFFSET ) | + (j <<MLX5_L3T_MT_OFFSET ) | k; +return (void *)&qw_e_tbl->entry[k].data; + } +break ; +default : + ptr_e_tbl = (struct mlx5_l3t_entry_ptr *)e_tbl; +for (k = e_start; k <MLX5_L3T_ET_SIZE ; k++) { +if (!ptr_e_tbl->entry[k].data) +continue ; + *pos = (i <<MLX5_L3T_GT_OFFSET ) | + (j <<MLX5_L3T_MT_OFFSET ) | k; +return ptr_e_tbl->entry[k].data; + } +break ; + } + } + } +return NULL ; +} +/* * Macros for linked list based on indexed memory. * Example data structure:
@@ -907,4 +992,9 @@ struct { \ idx = (elem)->field.next, (elem) = \ (idx) ? mlx5_ipool_get(pool, idx) : NULL) +#define MLX5_L3T_FOREACH (tbl, idx, entry) \ + for (idx = 0, (entry) = mlx5_l3t_get_next((tbl), &idx); \ + (entry); \ + idx++, (entry) = mlx5_l3t_get_next((tbl), &idx)) +#endif /* RTE_PMD_MLX5_UTILS_H_ */
Signature · 1 line
2.27.0
PATCH v2 2/13 net/mlx5: fix meter statistics
In reply to Li ZhangFrom: Shun Hao <[email protected]>
This fixes the meter statistics issue that when using multiple meters, only one meter has stats value.
To match the correct meter in policer table, now the meter_id is also used in its match criteria, so only one color and one drop matcher are needed. And both meter_id and flow_id will be written to related registers in meter prefix flow.
--- drivers/net/mlx5/linux/mlx5_os.c | 9 +- drivers/net/mlx5/mlx5.c | 7 +- drivers/net/mlx5/mlx5.h | 25 +- drivers/net/mlx5/mlx5_flow.c | 182 +++++++---- drivers/net/mlx5/mlx5_flow.h | 40 +-- drivers/net/mlx5/mlx5_flow_dv.c | 489 ++++++++++++++++++----------- drivers/net/mlx5/mlx5_flow_meter.c | 53 +++- 7 files changed, 512 insertions(+), 293 deletions(-)
drivers/net/mlx5/linux/mlx5_os.c +7 -2
@@ -316,7 +316,13 @@ mlx5_alloc_shared_dr(struct mlx5_priv *priv) } sh->tx_domain = domain;#ifdef HAVE_MLX5DV_DR_ESWITCH + sh->esw_drop_action = mlx5_glue->dr_create_flow_action_drop ();if (priv->config.dv_esw_en) { +if (!sh->esw_drop_action) { +DRV_LOG (ERR ,"Failed to create eswitch drop action" ); + err = errno; + goto error; + } domain = mlx5_glue->dr_create_domain (sh->ctx,MLX5DV_DR_DOMAIN_TYPE_FDB );if (!domain) {
@@ -325,7 +331,6 @@ mlx5_alloc_shared_dr(struct mlx5_priv *priv) goto error; } sh->fdb_domain = domain; - sh->esw_drop_action = mlx5_glue->dr_create_flow_action_drop (); }#endif if (!sh->tunnel_hub)
@@ -1225,7 +1230,7 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, -1 +REG_C_0 ; priv->mtr_en =1 ; priv->mtr_reg_share = - config->hca_attr.qos.flow_meter; + config->hca_attr.qos.flow_meter;DRV_LOG (DEBUG ,"The REG_C meter uses is %d" , priv->mtr_color_reg); }
drivers/net/mlx5/mlx5.c +5 -2
@@ -275,10 +275,13 @@ static const struct mlx5_indexed_pool_config mlx5_ipool_cfg[] = { }, #endif [MLX5_IPOOL_MTR ] = { +/** +* The ipool index should grow continually from small to big, +* for meter idx, so not set grow_trunk to avoid meter index +* not jump continually. +*/ .size =sizeof (struct mlx5_flow_meter ), .trunk_size =64 , - .grow_trunk =3 , - .grow_shift =2 , .need_lock =1 , .release_mem_en =1 , .malloc = mlx5_malloc,
drivers/net/mlx5/mlx5.h +19 -6
@@ -187,6 +187,16 @@ struct mlx5_stats_ctrl {/* Maximal number of segments to split. */ #define MLX5_MAX_RXQ_NSEG (1u << MLX5_MAX_LOG_RQ_SEGS) +/* The bit size of one register. */ +#define MLX5_REG_BITS 32 + +/* Idle bits for non-color usage in color register. */ +#define MLX5_MTR_IDLE_BITS_IN_COLOR_REG (MLX5_REG_BITS - MLX5_MTR_COLOR_BITS) + +#define UINT32_T (x) ((uint32_t)(x)) + +#define LS32_MASK (bits) ((UINT32_T(1) << (bits)) - 1) +/* LRO configurations structure. */ struct mlx5_lro_config {uint32_t supported:1 ;/* Whether LRO is supported. */
@@ -928,9 +938,9 @@ struct mlx5_priv { unsigned int representor:1; /* Device is a port representor. */ unsigned int master:1; /* Device is a E-Switch master. */ unsigned int txpp_en:1; /* Tx packet pacing enabled. */ + unsigned int sampler_en:1; /* Whether support sampler. */ unsigned int mtr_en:1; /* Whether support meter. */ unsigned int mtr_reg_share:1; /* Whether support meter REG_C share. */ - unsigned int sampler_en:1; /* Whether support sampler. */uint16_t domain_id;/* Switch domain identifier. */ uint16_t vport_id;/* Associated VF vport index (if any). */ uint32_t vport_meta_tag;/* Used for vport index match ove VF LAG. */
@@ -989,6 +999,10 @@ struct mlx5_priv {uint32_t rss_shared_actions;/* RSS shared actions. */ struct mlx5_devx_obj *q_counters;/* DevX queue counter object. */ uint32_t counter_set_id;/* Queue counter ID to set in DevX objects. */ +uint8_t max_mtr_bits; +/* Indicate how many bits are used by meter id at the most. */ +uint8_t max_mtr_flow_bits; +/* Indicate how many bits are used by meter flow id at the most. */ };#define PORT_ID (priv) ((priv)->dev_data->port_id)
@@ -1246,11 +1260,10 @@ int mlx5_pmd_socket_init(void);int mlx5_flow_meter_ops_get (struct rte_eth_dev *dev,void *arg);struct mlx5_flow_meter *mlx5_flow_meter_find (struct mlx5_priv *priv,uint32_t meter_id); -struct mlx5_flow_meter *mlx5_flow_meter_attach - (struct mlx5_priv *priv, -uint32_t meter_id, -const struct rte_flow_attr *attr, -struct rte_flow_error *error); +int mlx5_flow_meter_attach (struct mlx5_priv *priv, +struct mlx5_flow_meter *fm, +const struct rte_flow_attr *attr, +struct rte_flow_error *error);void mlx5_flow_meter_detach (struct mlx5_flow_meter *fm);/* mlx5_os.c */
drivers/net/mlx5/mlx5_flow.c +119 -63
329 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow.h +22 -18
@@ -79,7 +79,7 @@ enum mlx5_feature_name {MLX5_APP_TAG ,MLX5_COPY_MARK ,MLX5_MTR_COLOR , -MLX5_MTR_SFX , +MLX5_MTR_ID , MLX5_ASO_FLOW_HIT, };
@@ -655,7 +655,8 @@ struct mlx5_flow_handle {uint64_t layers;/**< Bit-fields of present layers, see MLX5_FLOW_LAYER_*. */ void *drv_flow;/**< pointer to driver flow object. */ - uint32_t split_flow_id:28; /**< Sub flow unique match flow id. */ + uint32_t split_flow_id:27; /**< Sub flow unique match flow id. */ + uint32_t is_meter_flow_id:1; /**< Indate if flow_id is for meter. */ uint32_t mark:1; /**< Metadate rxq mark flag. */ uint32_t fate_action:3; /**< Fate action type. */union {
@@ -842,14 +843,16 @@ struct mlx5_meter_domain_info {/**< Meter table. */ struct mlx5_flow_tbl_resource *sfx_tbl;/**< Meter suffix table. */ -void *any_matcher; -/**< Meter color not match default criteria. */ -void *color_matcher; -/**< Meter color match criteria. */ +struct mlx5_flow_dv_matcher *drop_matcher; +/**< Matcher for Drop. */ +struct mlx5_flow_dv_matcher *color_matcher; +/**< Matcher for Color. */ void *jump_actn;/**< Meter match action. */ -void *policer_rules[RTE_MTR_DROPPED +1 ]; -/**< Meter policer for the match. */ +void *green_rule; +/**< Meter green rule. */ +void *drop_rule; +/**< Meter drop rule. */ };/* Meter table set for TX RX FDB. */
@@ -862,10 +865,10 @@ struct mlx5_meter_domains_infos {/**< RX meter table. */ struct mlx5_meter_domain_info transfer;/**< FDB meter table. */ -void *drop_actn; -/**< Drop action as not matched. */ -void *count_actns[RTE_MTR_DROPPED +1 ]; -/**< Counters for match and unmatched statistics. */ +void *green_count; +/**< Counters for green rule. */ +void *drop_count; +/**< Counters for green rule. */ uint32_t fmp[MLX5_ST_SZ_DW (flow_meter_parameters)];/**< Flow meter parameter. */ size_t fmp_size;
@@ -928,6 +931,8 @@ struct mlx5_flow_meter {/**< Meter state. */ uint32_t shared:1;/**< Meter shared or not. */ +struct mlx5_indexed_pool *flow_ipool; +/**< Index pool for flow id. */ };/* RFC2697 parameter structure. */
@@ -1148,6 +1153,7 @@ struct mlx5_flow_workspace {struct mlx5_flow_rss_desc rss_desc;uint32_t rssq_num;/* Allocated queue num in rss_desc. */ uint32_t flow_idx;/* Intermediate device flow index. */ +struct mlx5_flow_meter *fm;/* Pointer to the meter in flow. */ };struct mlx5_flow_split_info {
@@ -1188,8 +1194,7 @@ typedef int (*mlx5_flow_query_t)(struct rte_eth_dev *dev,void *data, struct rte_flow_error *error);typedef struct mlx5_meter_domains_infos *(*mlx5_flow_create_mtr_tbls_t ) - (struct rte_eth_dev *dev, -const struct mlx5_flow_meter *fm); + (struct rte_eth_dev *dev);typedef int (*mlx5_flow_destroy_mtr_tbls_t )(struct rte_eth_dev *dev,struct mlx5_meter_domains_infos *tbls);typedef int (*mlx5_flow_create_policer_rules_t )
@@ -1252,7 +1257,7 @@ struct mlx5_flow_driver_ops {mlx5_flow_query_t query;mlx5_flow_create_mtr_tbls_t create_mtr_tbls;mlx5_flow_destroy_mtr_tbls_t destroy_mtr_tbls; -mlx5_flow_create_policer_rules_t create_policer_rules; +mlx5_flow_create_policer_rules_t prepare_policer_rules;mlx5_flow_destroy_policer_rules_t destroy_policer_rules;mlx5_flow_counter_alloc_t counter_alloc;mlx5_flow_counter_free_t counter_free;
@@ -1452,11 +1457,10 @@ int mlx5_flow_validate_item_ecpri(const struct rte_flow_item *item,const struct rte_flow_item_ecpri *acc_mask, struct rte_flow_error *error);struct mlx5_meter_domains_infos *mlx5_flow_create_mtr_tbls - (struct rte_eth_dev *dev, -const struct mlx5_flow_meter *fm); + (struct rte_eth_dev *dev);int mlx5_flow_destroy_mtr_tbls (struct rte_eth_dev *dev,struct mlx5_meter_domains_infos *tbl); -int mlx5_flow_create_policer_rules (struct rte_eth_dev *dev, +int mlx5_flow_prepare_policer_rules (struct rte_eth_dev *dev,struct mlx5_flow_meter *fm,const struct rte_flow_attr *attr); int mlx5_flow_destroy_policer_rules(struct rte_eth_dev *dev,
drivers/net/mlx5/mlx5_flow_dv.c +303 -186
704 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_meter.c +37 -16
117 lines not on this page · raw message
Signature · 1 line
2.27.0
PATCH v2 3/13 net/mlx5: optimize meter statistics
In reply to Li Zhang1. It does not support yellow counter and return 0.
2. All the meter colors with drop action will be counted only by the global drop statistics.
3. Red color must be with drop action.
--- doc/guides/nics/mlx5.rst | 6 + drivers/net/mlx5/mlx5_flow.h | 24 ++-- drivers/net/mlx5/mlx5_flow_dv.c | 8 +- drivers/net/mlx5/mlx5_flow_meter.c | 217 +++++++++++++++++++---------- 4 files changed, 173 insertions(+), 82 deletions(-)
doc/guides/nics/mlx5.rst +6 -0
@@ -398,6 +398,12 @@ Limitations - Hairpin between two ports could only manual binding and explicit Tx flow mode. For single port hairpin, all the combinations of auto/manual binding and explicit/implicit Tx flow mode could be supported. - Hairpin in switchdev SR-IOV mode is not supported till now. +- Meter: + - All the meter colors with drop action will be counted only by the global drop statistics. + - Green color is not supported with drop action. + - Yellow detection is not supported. + - Red color must be with drop action. + Statistics ----------
drivers/net/mlx5/mlx5_flow.h +16 -8
@@ -831,10 +831,10 @@ struct mlx5_flow {/* Meter policer statistics */ struct mlx5_flow_policer_stats { -uint32_t cnt[RTE_COLORS +1 ]; -/**< Color counter, extra for drop. */ -uint64_t stats_mask; -/**< Statistics mask for the colors. */ +uint32_t pass_cnt; +/**< Color counter for pass. */ +uint32_t drop_cnt; +/**< Color counter for drop. */ };/* Meter table structure. */
@@ -892,10 +892,18 @@ struct mlx5_flow_meter {/** Policer actions (per meter output color). */ enum rte_mtr_policer_action action[RTE_COLORS ]; -/** Set of stats counters to be enabled. -* @see enum rte_mtr_stats_type -*/ -uint64_t stats_mask; + uint32_t green_bytes:1; +/** Set green bytes stats to be enabled. */ + uint32_t green_pkts:1; +/** Set green packets stats to be enabled. */ + uint32_t red_bytes:1; +/** Set red bytes stats to be enabled. */ + uint32_t red_pkts:1; +/** Set red packets stats to be enabled. */ + uint32_t bytes_dropped:1; +/** Set bytes dropped stats to be enabled. */ + uint32_t pkts_dropped:1; +/** Set packets dropped stats to be enabled. */ /**< Rule applies to ingress traffic. */ uint32_t ingress:1;
drivers/net/mlx5/mlx5_flow_dv.c +4 -4
@@ -13697,17 +13697,17 @@ flow_dv_prepare_policer_rules(struct rte_eth_dev *dev,int ret;/* Get the statistics counters for green/drop. */ -if (fm->policer_stats.cnt[RTE_COLOR_GREEN ]) { +if (fm->policer_stats.pass_cnt) { cnt =flow_dv_counter_get_by_idx (dev, - fm->policer_stats.cnt[RTE_COLOR_GREEN ], + fm->policer_stats.pass_cnt,NULL ); mtb->green_count = cnt->action; }else { mtb->green_count =NULL ; } -if (fm->policer_stats.cnt[RTE_MTR_DROPPED ]) { +if (fm->policer_stats.drop_cnt) { cnt =flow_dv_counter_get_by_idx (dev, - fm->policer_stats.cnt[RTE_MTR_DROPPED ], + fm->policer_stats.drop_cnt,NULL ); mtb->drop_count = cnt->action; }else {
drivers/net/mlx5/mlx5_flow_meter.c +147 -70
321 lines not on this page · raw message
Signature · 1 line
2.27.0
PATCH v2 4/13 net/mlx5: use mask for meter register setting
In reply to Li ZhangFrom: Shun Hao <[email protected]>
ASO meter feature may require to locate the flow context tag action after the ASO action.
When color register is shared by meter_id/flow_id, it's like:
Bits[0-7] A meter color value set by the HW. Bits[8-31] A flow id and meter id set by SW.
Currently the tag action for meter writes all the bits of the meter register, so it will potentially overwrite meter color when ASO meter action is before the tag action.
Set only 24-MSB-bits of meter register in the meter tag action.
--- drivers/net/mlx5/mlx5_flow.c | 27 +++++++++++++++++---------- drivers/net/mlx5/mlx5_flow.h | 2 ++ drivers/net/mlx5/mlx5_flow_dv.c | 2 ++ 3 files changed, 21 insertions(+), 10 deletions(-)
drivers/net/mlx5/mlx5_flow.c +17 -10
@@ -4274,9 +4274,11 @@ flow_hairpin_split(struct rte_eth_dev *dev,rte_memcpy (actions_rx, actions,sizeof (struct rte_flow_action )); actions_rx++; set_tag = (void *)actions_rx; - set_tag->id =mlx5_flow_get_reg_id (dev,MLX5_HAIRPIN_RX ,0 ,NULL ); + *set_tag = (struct mlx5_rte_flow_action_set_tag ) { + .id =mlx5_flow_get_reg_id (dev,MLX5_HAIRPIN_RX ,0 ,NULL ), + .data = flow_id, + };MLX5_ASSERT (set_tag->id >REG_NON ); - set_tag->data = flow_id; tag_action->conf = set_tag;/* Create Tx item list. */ rte_memcpy (actions_tx, actions,sizeof (struct rte_flow_action ));
@@ -4511,6 +4513,13 @@ flow_meter_split_prep(struct rte_eth_dev *dev, set_tag = (struct mlx5_rte_flow_action_set_tag *)actions_pre; tag_item_spec = (struct mlx5_rte_flow_item_tag *)sfx_items; tag_item_mask = tag_item_spec +1 ; +/* Both flow_id and meter_id share the same register. */ + *set_tag = (struct mlx5_rte_flow_action_set_tag ) { + .id =mlx5_flow_get_reg_id (dev,MLX5_MTR_ID ,0 , error), + .offset = mtr_id_offset, + .length = mtr_reg_bits, + .data = fm->idx, + };/* * The color Reg bits used by flow_id are growing from * msb to lsb, so must do bit reverse for flow_id val in RegC.
@@ -4518,13 +4527,9 @@ flow_meter_split_prep(struct rte_eth_dev *dev,for (shift =0 ; shift < flow_id_bits; shift++) flow_id_val = (flow_id_val <<1 ) | (((tag_id -1 ) >> shift) &0x1 ); -/* Both flow_id and meter_id share the same register. */ - set_tag->id =mlx5_flow_get_reg_id (dev,MLX5_MTR_ID ,0 , error); - set_tag->data = - (fm->idx | (flow_id_val << (mtr_reg_bits - flow_id_bits))) - << mtr_id_offset; + set_tag->data |= flow_id_val << (mtr_reg_bits - flow_id_bits); tag_item_spec->id = set_tag->id; - tag_item_spec->data = set_tag->data; + tag_item_spec->data = set_tag->data << mtr_id_offset; tag_item_mask->data =UINT32_MAX << mtr_id_offset; tag_action->type = (enum rte_flow_action_type )MLX5_RTE_FLOW_ACTION_TYPE_TAG ;
@@ -4911,10 +4916,12 @@ flow_sample_split_prep(struct rte_eth_dev *dev, ret =mlx5_flow_get_reg_id (dev,MLX5_APP_TAG ,0 , error);if (ret <0 )return ret; - set_tag->id = ret;mlx5_ipool_malloc (priv->sh->ipool [MLX5_IPOOL_RSS_EXPANTION_FLOW_ID ], &tag_id); - set_tag->data = tag_id; + *set_tag = (struct mlx5_rte_flow_action_set_tag ) { + .id = ret, + .data = tag_id, + };/* Prepare the suffix subflow items. */ tag_spec = (void *)(sfx_items +SAMPLE_SUFFIX_ITEM ); tag_spec->data = tag_id;
drivers/net/mlx5/mlx5_flow.h +2 -0
@@ -55,6 +55,8 @@ struct mlx5_rte_flow_item_tag {/* Modify selected register. */ struct mlx5_rte_flow_action_set_tag {enum modify_reg id; +uint8_t offset; +uint8_t length;uint32_t data; };
drivers/net/mlx5/mlx5_flow_dv.c +2 -0
@@ -964,6 +964,8 @@ flow_dv_convert_action_set_reg actions[i] = (struct mlx5_modification_cmd ) { .action_type =MLX5_MODIFICATION_TYPE_SET , .field = reg_to_field[conf->id], + .offset = conf->offset, + .length = conf->length, }; actions[i].data0 =rte_cpu_to_be_32 (actions[i].data0); actions[i].data1 =rte_cpu_to_be_32 (conf->data);
Signature · 1 line
2.27.0
PATCH v2 5/13 common/mlx5: add definitions for ASO flow meter
In reply to Li ZhangThis patch adds different PRM definitions, related to ASO flow meter feature, in MLX5 PMD code.
--- drivers/common/mlx5/mlx5_prm.h | 75 ++++++++++++++++++++++++++++++++-- 1 file changed, 71 insertions(+), 4 deletions(-)
drivers/common/mlx5/mlx5_prm.h +71 -4
@@ -1129,6 +1129,8 @@ enum { (1ULL << MLX5_GENERAL_OBJ_TYPE_FLEX_PARSE_GRAPH)#define MLX5_GENERAL_OBJ_TYPES_CAP_FLOW_HIT_ASO \ (1ULL << MLX5_GENERAL_OBJ_TYPE_FLOW_HIT_ASO) +#define MLX5_GENERAL_OBJ_TYPES_CAP_FLOW_METER_ASO \ + (1ULL << MLX5_GENERAL_OBJ_TYPE_FLOW_METER_ASO)#define MLX5_GENERAL_OBJ_TYPES_CAP_GENEVE_TLV_OPT \ (1ULL << MLX5_OBJ_TYPE_GENEVE_TLV_OPT)
@@ -1514,7 +1516,15 @@ struct mlx5_ifc_qos_cap_bits {u8 reserved_at_c0[0x10 ];u8 max_qos_para_vport[0x10 ];u8 max_tsar_bw_share[0x20 ]; -u8 reserved_at_100[0x6e8 ]; +u8 nic_element_type[0x10 ]; +u8 nic_tsar_type[0x10 ]; +u8 reserved_at_120[0x3 ]; +u8 log_meter_aso_granularity[0x5 ]; +u8 reserved_at_128[0x3 ]; +u8 log_meter_aso_max_alloc[0x5 ]; +u8 reserved_at_130[0x3 ]; +u8 log_max_num_meter_aso[0x5 ]; +u8 reserved_at_138[0x6b0 ]; };struct mlx5_ifc_per_protocol_networking_offload_caps_bits {
@@ -2284,6 +2294,8 @@ struct mlx5_ifc_flow_meter_parameters_bits {u8 eir_mantissa[0x8 ];u8 reserved_at_8[0x60 ];// 14h-1Ch }; +#define MLX5_IFC_FLOW_METER_PARAM_MASK UINT64_C(0x80FFFFFF) +#define MLX5_IFC_FLOW_METER_DISABLE_CBS_CIR_VAL 0x14BF00C8enum {MLX5_CQE_SIZE_64B =0x0 ,
@@ -2411,6 +2423,7 @@ enum {MLX5_GENERAL_OBJ_TYPE_VIRTQ =0x000d ,MLX5_GENERAL_OBJ_TYPE_VIRTIO_Q_COUNTERS =0x001c ,MLX5_GENERAL_OBJ_TYPE_FLEX_PARSE_GRAPH =0x0022 , +MLX5_GENERAL_OBJ_TYPE_FLOW_METER_ASO =0x0024 , MLX5_GENERAL_OBJ_TYPE_FLOW_HIT_ASO = 0x0025, };
@@ -2419,7 +2432,9 @@ struct mlx5_ifc_general_obj_in_cmd_hdr_bits {u8 reserved_at_10[0x20 ];u8 obj_type[0x10 ];u8 obj_id[0x20 ]; -u8 reserved_at_60[0x20 ]; +u8 reserved_at_60[0x3 ]; +u8 log_obj_range[0x5 ]; +u8 reserved_at_58[0x18 ]; };struct mlx5_ifc_general_obj_out_cmd_hdr_bits {
@@ -2565,6 +2580,18 @@ struct mlx5_ifc_create_flow_hit_aso_in_bits {struct mlx5_ifc_flow_hit_aso_bits flow_hit_aso; }; +struct mlx5_ifc_flow_meter_aso_bits { +u8 modify_field_select[0x40 ]; +u8 reserved_at_40[0x48 ]; +u8 access_pd[0x18 ]; +u8 reserved_at_a0[0x160 ]; +u8 parameters[0x200 ]; +}; + +struct mlx5_ifc_create_flow_meter_aso_in_bits { +struct mlx5_ifc_general_obj_in_cmd_hdr_bits hdr; +struct mlx5_ifc_flow_meter_aso_bits flow_meter_aso; +};enum mlx5_access_aso_opc_mod {ASO_OPC_MOD_IPSEC =0x0 ,ASO_OPC_MOD_CONNECTION_TRACKING =0x1 ,
@@ -2618,11 +2645,51 @@ struct mlx5_aso_cseg {uint64_t data_mask; } __rte_packed; +/* A meter data segment - 2 per ASO WQE. */ +struct mlx5_aso_mtr_dseg { +uint32_t v_bo_sc_bbog_mm; +/* +* bit 31: valid, 30: bucket overflow, 28-29: start color, +* 27: both buckets on green, 24-25: meter mode. +*/ +uint32_t reserved; +uint32_t cbs_cir; +/* +* bit 24-28: cbs_exponent, bit 16-23 cbs_mantissa, +* bit 8-12: cir_exponent, bit 0-7 cir_mantissa. +*/ +uint32_t c_tokens; +uint32_t ebs_eir; +/* +* bit 24-28: ebs_exponent, bit 16-23 ebs_mantissa, +* bit 8-12: eir_exponent, bit 0-7 eir_mantissa. +*/ +uint32_t e_tokens; +uint64_t timestamp; +} __rte_packed; + +#define ASO_DSEG_VALID_OFFSET 31 +#define ASO_DSEG_BO_OFFSET 30 +#define ASO_DSEG_SC_OFFSET 28 +#define ASO_DSEG_CBS_EXP_OFFSET 24 +#define ASO_DSEG_CBS_MAN_OFFSET 16 +#define ASO_DSEG_CIR_EXP_MASK 0x1F +#define ASO_DSEG_CIR_EXP_OFFSET 8 +#define ASO_DSEG_EBS_EXP_OFFSET 24 +#define ASO_DSEG_EBS_MAN_OFFSET 16 +#define ASO_DSEG_EXP_MASK 0x1F +#define ASO_DSEG_MAN_MASK 0xFF +#define MLX5_ASO_WQE_DSEG_SIZE 0x40 +#define MLX5_ASO_METERS_PER_WQE 2 +#define MLX5_ASO_MTRS_PER_POOL 128 -/* ASO WQE Data segment. */ +/* ASO WQE data segment. */ struct mlx5_aso_dseg { -uint8_t data[MLX5_ASO_WQE_DSEG_SIZE ]; +union { +uint8_t data[MLX5_ASO_WQE_DSEG_SIZE ]; +struct mlx5_aso_mtr_dseg mtrs[MLX5_ASO_METERS_PER_WQE ]; + }; } __rte_packed;/* ASO WQE. */
Signature · 1 line
2.27.0
PATCH v2 6/13 common/mlx5: add read ASO flow meter HCA capability
In reply to Li ZhangRead and store the device capability of FLOW_METER_ASO general object, using the DevX API.
--- drivers/common/mlx5/mlx5_devx_cmds.c | 14 ++++++++++++++ drivers/common/mlx5/mlx5_devx_cmds.h | 8 ++++++++ 2 files changed, 22 insertions(+)
drivers/common/mlx5/mlx5_devx_cmds.c +14 -0
@@ -695,6 +695,9 @@ mlx5_devx_cmd_query_hca_attr(void *ctx, attr->max_geneve_tlv_option_data_len =MLX5_GET (cmd_hca_cap, hcattr, max_geneve_tlv_option_data_len); attr->qos.sup =MLX5_GET (cmd_hca_cap, hcattr, qos); + attr->qos.flow_meter_aso_sup = !!(MLX5_GET64 (cmd_hca_cap, hcattr, + general_obj_types) & +MLX5_GENERAL_OBJ_TYPES_CAP_FLOW_METER_ASO ); attr->vdpa.valid = !!(MLX5_GET64 (cmd_hca_cap, hcattr, general_obj_types) &MLX5_GENERAL_OBJ_TYPES_CAP_VIRTQ_NET_Q );
@@ -778,6 +781,17 @@ mlx5_devx_cmd_query_hca_attr(void *ctx,MLX5_GET (qos_cap, hcattr, packet_pacing); attr->qos.wqe_rate_pp =MLX5_GET (qos_cap, hcattr, wqe_rate_pp); +if (attr->qos.flow_meter_aso_sup) { + attr->qos.log_meter_aso_granularity = +MLX5_GET (qos_cap, hcattr, + log_meter_aso_granularity); + attr->qos.log_meter_aso_max_alloc = +MLX5_GET (qos_cap, hcattr, + log_meter_aso_max_alloc); + attr->qos.log_max_num_meter_aso = +MLX5_GET (qos_cap, hcattr, + log_max_num_meter_aso); + } }if (attr->vdpa.valid)mlx5_devx_cmd_query_hca_vdpa_attr (ctx, &attr->vdpa);
drivers/common/mlx5/mlx5_devx_cmds.h +8 -0
@@ -49,10 +49,18 @@ struct mlx5_hca_qos_attr {* Using older driver versions, flow_meter_old can be 1 * while flow_meter is 0. */ + uint32_t flow_meter_aso_sup:1; +/* Whether FLOW_METER_ASO Object is supported. */ uint8_t log_max_flow_meter;/* Power of the maximum supported meters. */ uint8_t flow_meter_reg_c_ids;/* Bitmap of the reg_Cs available for flow meter to use. */ + uint32_t log_meter_aso_granularity:5; +/* Power of the minimum allocation granularity Object. */ + uint32_t log_meter_aso_max_alloc:5; +/* Power of the maximum allocation granularity Object. */ + uint32_t log_max_num_meter_aso:5; +/* Power of the maximum number of supported objects. */ };
Signature · 1 line
2.27.0
PATCH v2 7/13 common/mlx5: add DevX API to create ASO flow meter object
In reply to Li ZhangAdd DevX API to create ASO flow meter object.
--- drivers/common/mlx5/mlx5_devx_cmds.c | 54 ++++++++++++++++++++++++++++ drivers/common/mlx5/mlx5_devx_cmds.h | 18 +++++++++- drivers/common/mlx5/version.map | 1 + 3 files changed, 72 insertions(+), 1 deletion(-)
drivers/common/mlx5/mlx5_devx_cmds.c +54 -0
@@ -2154,6 +2154,60 @@ mlx5_devx_cmd_alloc_pd(void *ctx)return ppd; } +/** +* Create general object of type FLOW_METER_ASO using DevX API. +* +* @param[in] ctx +* Context returned from mlx5 open_device() glue function. +* @param [in] pd +* PD value to associate the FLOW_METER_ASO object with. +* @param [in] log_obj_size +* log_obj_size define to allocate number of 2 * meters +* in one FLOW_METER_ASO object. +* +* @return +* The DevX object created, NULL otherwise and rte_errno is set. +*/ +struct mlx5_devx_obj * +mlx5_devx_cmd_create_flow_meter_aso_obj (void *ctx,uint32_t pd, +uint32_t log_obj_size) +{ +uint32_t in[MLX5_ST_SZ_DW (create_flow_meter_aso_in)] = {0 }; +uint32_t out[MLX5_ST_SZ_DW (general_obj_out_cmd_hdr)]; +struct mlx5_devx_obj *flow_meter_aso_obj; +void *ptr; + + flow_meter_aso_obj =mlx5_malloc (MLX5_MEM_ZERO , +sizeof (*flow_meter_aso_obj), +0 ,SOCKET_ID_ANY ); +if (!flow_meter_aso_obj) { +DRV_LOG (ERR ,"Failed to allocate FLOW_METER_ASO object data" ); + rte_errno =ENOMEM ; +return NULL ; + } + ptr =MLX5_ADDR_OF (create_flow_meter_aso_in, in, hdr); +MLX5_SET (general_obj_in_cmd_hdr, ptr, opcode, +MLX5_CMD_OP_CREATE_GENERAL_OBJECT ); +MLX5_SET (general_obj_in_cmd_hdr, ptr, obj_type, +MLX5_GENERAL_OBJ_TYPE_FLOW_METER_ASO ); +MLX5_SET (general_obj_in_cmd_hdr, ptr, log_obj_range, + log_obj_size); + ptr =MLX5_ADDR_OF (create_flow_meter_aso_in, in, flow_meter_aso); +MLX5_SET (flow_meter_aso, ptr, access_pd, pd); + flow_meter_aso_obj->obj = mlx5_glue->devx_obj_create ( + ctx, in,sizeof (in), + out,sizeof (out)); +if (!flow_meter_aso_obj->obj) { + rte_errno = errno; +DRV_LOG (ERR ,"Failed to create FLOW_METER_ASO obj using DevX." ); +mlx5_free (flow_meter_aso_obj); +return NULL ; + } + flow_meter_aso_obj->id =MLX5_GET (general_obj_out_cmd_hdr, + out, obj_id); +return flow_meter_aso_obj; +} +/** * Create general object of type GENEVE TLV option using DevX API. *
drivers/common/mlx5/mlx5_devx_cmds.h +17 -1
@@ -551,7 +551,6 @@ int mlx5_devx_cmd_query_virtio_q_counters(struct mlx5_devx_obj *couners_obj,__rte_internal struct mlx5_devx_obj *mlx5_devx_cmd_create_flow_hit_aso_obj(void *ctx,uint32_t pd); -__rte_internal struct mlx5_devx_obj *mlx5_devx_cmd_alloc_pd(void *ctx);
@@ -563,4 +562,21 @@ struct mlx5_devx_obj *mlx5_devx_cmd_queue_counter_alloc(void *ctx);__rte_internal int mlx5_devx_cmd_queue_counter_query(struct mlx5_devx_obj *dcs, int clear,uint32_t *out_of_buffers); +/** +* Create general object of type FLOW_METER_ASO using DevX API.. +* +* @param[in] ctx +* Device context. +* @param [in] pd +* PD value to associate the FLOW_METER_ASO object with. +* @param [in] log_obj_size +* log_obj_size define to allocate number of 2 * meters +* in one FLOW_METER_ASO object. +* +* @return +* The DevX object created, NULL otherwise and rte_errno is set. +*/ +__rte_internal +struct mlx5_devx_obj *mlx5_devx_cmd_create_flow_meter_aso_obj(void *ctx, +uint32_t pd,uint32_t log_obj_size);#endif /* RTE_PMD_MLX5_DEVX_CMDS_H_ */
drivers/common/mlx5/version.map +1 -0
@@ -23,6 +23,7 @@ INTERNAL { mlx5_devx_cmd_create_virtio_q_counters; mlx5_devx_cmd_create_virtq; mlx5_devx_cmd_create_flow_hit_aso_obj; + mlx5_devx_cmd_create_flow_meter_aso_obj; mlx5_devx_cmd_create_geneve_tlv_option; mlx5_devx_cmd_destroy; mlx5_devx_cmd_flow_counter_alloc;
Signature · 1 line
2.27.0
Re: [dpdk-dev] [PATCH v2 07/13] common/mlx5: add DevX API to create ASO flow meter object
Quoted 9 lines · Li Zhang
Add DevX API to create ASO flow meter object.
Signed-off-by Li Zhang <[email protected]>--- drivers/common/mlx5/mlx5_devx_cmds.c | 54 ++++++++++++++++++++++++++++ drivers/common/mlx5/mlx5_devx_cmds.h | 18 +++++++++- drivers/common/mlx5/version.map | 1 + 3 files changed, 72 insertions(+), 1 deletion(-)
PATCH v2 8/13 net/mlx5: flow meter pool to manage meter object
In reply to Li ZhangAdd ASO flow meter pool to manage meter object
--- drivers/net/mlx5/mlx5.c | 2 +- drivers/net/mlx5/mlx5.h | 207 ++++++++++++- drivers/net/mlx5/mlx5_flow.c | 70 ++++- drivers/net/mlx5/mlx5_flow.h | 196 +++---------- drivers/net/mlx5/mlx5_flow_dv.c | 202 ++++++++++++- drivers/net/mlx5/mlx5_flow_meter.c | 450 ++++++++++++++++++----------- 6 files changed, 768 insertions(+), 359 deletions(-)
drivers/net/mlx5/mlx5.c +1 -1
@@ -280,7 +280,7 @@ static const struct mlx5_indexed_pool_config mlx5_ipool_cfg[] = {* for meter idx, so not set grow_trunk to avoid meter index * not jump continually. */ - .size = sizeof(struct mlx5_flow_meter), + .size = sizeof(struct mlx5_legacy_flow_meter), .trunk_size = 64, .need_lock = 1, .release_mem_en = 1,
drivers/net/mlx5/mlx5.h +200 -7
258 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow.c +54 -16
143 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow.h +48 -148
256 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_dv.c +188 -14
308 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_meter.c +277 -173
723 lines not on this page · raw message
Signature · 1 line
2.27.0
PATCH v2 9/13 net/mlx5: init/uninit flow meter queue for WQE
In reply to Li ZhangInit/uninit flow meter SQ for WQE
---
drivers/net/mlx5/linux/mlx5_os.c | 17 ++++
drivers/net/mlx5/meson.build | 2 +-
drivers/net/mlx5/mlx5.c | 78 ++++++++++++++-
drivers/net/mlx5/mlx5.h | 22 +++--
drivers/net/mlx5/mlx5_flow.h | 4 +-
.../mlx5/{mlx5_flow_age.c => mlx5_flow_aso.c} | 96 ++++++++++++++++---
drivers/net/mlx5/mlx5_flow_dv.c | 7 +-
drivers/net/mlx5/mlx5_flow_meter.c | 7 +-
8 files changed, 201 insertions(+), 32 deletions(-)
rename drivers/net/mlx5/{mlx5_flow_age.c => mlx5_flow_aso.c} (85%)drivers/net/mlx5/linux/mlx5_os.c +17 -0
@@ -741,6 +741,7 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,int own_domain_id =0 ;uint16_t port_id;unsigned int i; +uint32_t log_obj_size;#ifdef HAVE_MLX5DV_DR_DEVX_PORT struct mlx5dv_devx_port devx_port = { .comp_mask =0 };#endif
@@ -1235,6 +1236,22 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, priv->mtr_color_reg); } } +if (config->hca_attr.qos.sup && + config->hca_attr.qos.flow_meter_aso_sup) { + log_obj_size = +rte_log2_u32 (MLX5_ASO_MTRS_PER_POOL >>1 ); +if (log_obj_size >= + config->hca_attr.qos.log_meter_aso_granularity && + log_obj_size <= + config->hca_attr.qos.log_meter_aso_max_alloc) { + sh->meter_aso_en =1 ; + err =mlx5_aso_flow_mtrs_mng_init (priv); +if (err) { + err = -err; + goto error; + } + } + }#endif #ifdef HAVE_MLX5_DR_CREATE_ACTION_ASO if (config->hca_attr.flow_hit_aso &&
drivers/net/mlx5/meson.build +1 -1
@@ -15,7 +15,7 @@ sources = files( 'mlx5_flow.c', 'mlx5_flow_meter.c', 'mlx5_flow_dv.c', - 'mlx5_flow_age.c', + 'mlx5_flow_aso.c', 'mlx5_mac.c', 'mlx5_mr.c', 'mlx5_rss.c',
drivers/net/mlx5/mlx5.c +75 -3
114 lines not on this page · raw message
drivers/net/mlx5/mlx5.h +15 -7
@@ -491,8 +491,13 @@ struct mlx5_aso_devx_mr { };struct mlx5_aso_sq_elem { -struct mlx5_aso_age_pool *pool; -uint16_t burst_size; +union { +struct { +struct mlx5_aso_age_pool *pool; +uint16_t burst_size; + }; +struct mlx5_aso_mtr *mtr; + }; };struct mlx5_aso_sq {
@@ -764,7 +769,6 @@ struct mlx5_aso_mtr_pools_mng {volatile uint16_t n_valid;/* Number of valid pools. */ uint16_t n;/* Number of pools. */ rte_spinlock_t mtrsl;/* The ASO flow meter free list lock. */ -struct mlx5_l3t_tbl *mtr_idx_tbl;/* Meter index lookup table. */ struct aso_meter_list meters;/* Free ASO flow meter list. */ struct mlx5_aso_sq sq;/*SQ using by ASO flow meter. */ struct mlx5_aso_mtr_pool **pools;/* ASO flow meter pool array. */
@@ -1182,6 +1186,7 @@ struct mlx5_priv {uint8_t mtr_color_reg;/* Meter color match REG_C. */ struct mlx5_mtr_profiles flow_meter_profiles;/* MTR profile list. */ struct mlx5_legacy_flow_meters flow_meters;/* MTR list. */ +struct mlx5_l3t_tbl *mtr_idx_tbl;/* Meter index lookup table. */ uint8_t skip_default_rss_reta;/* Skip configuration of default reta. */ uint8_t fdb_def_rule;/* Whether fdb jump to table 1 is configured. */ struct mlx5_mp_id mp_id;/* ID of a multi-process process */
@@ -1244,6 +1249,7 @@ int mlx5_hairpin_cap_get(struct rte_eth_dev *dev,bool mlx5_flex_parser_ecpri_exist (struct rte_eth_dev *dev);int mlx5_flex_parser_ecpri_alloc (struct rte_eth_dev *dev);int mlx5_flow_aso_age_mng_init (struct mlx5_dev_ctx_shared *sh); +int mlx5_aso_flow_mtrs_mng_init (struct mlx5_priv *priv);/* mlx5_ethdev.c */
@@ -1504,9 +1510,11 @@ eth_tx_burst_t mlx5_select_tx_function(struct rte_eth_dev *dev);/* mlx5_flow_aso.c */ -int mlx5_aso_queue_init (struct mlx5_dev_ctx_shared *sh); -int mlx5_aso_queue_start (struct mlx5_dev_ctx_shared *sh); -int mlx5_aso_queue_stop (struct mlx5_dev_ctx_shared *sh); -void mlx5_aso_queue_uninit (struct mlx5_dev_ctx_shared *sh); +int mlx5_aso_queue_init (struct mlx5_dev_ctx_shared *sh, +enum mlx5_access_aso_opc_mod aso_opc_mod); +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);#endif /* RTE_PMD_MLX5_H_ */
drivers/net/mlx5/mlx5_flow.h +2 -2
@@ -827,8 +827,8 @@ struct mlx5_flow {#define MLX5_FLOW_METER_DISABLE 0#define MLX5_FLOW_METER_ENABLE 1 -#define MLX5_ASO_CQE_RESPONSE_DELAY 10 -#define MLX5_MTR_POLL_CQE_TIMES 100000u +#define MLX5_ASO_WQE_CQE_RESPONSE_DELAY 10u +#define MLX5_MTR_POLL_WQE_CQE_TIMES 100000u#define MLX5_MAN_WIDTH 8/* Legacy Meter parameter structure. */
drivers/net/mlx5/mlx5_flow_aso.c renamed from drivers/net/mlx5/mlx5_flow_age.c +82 -14
156 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_dv.c +6 -1
@@ -5947,6 +5947,11 @@ flow_dv_mtr_container_resize(struct rte_eth_dev *dev) rte_errno =ENOMEM ;return -ENOMEM ; } +if (!mtrmng->n) +if (mlx5_aso_queue_init (priv->sh,ASO_OPC_MOD_POLICER )) { +mlx5_free (pools); +return -ENOMEM ; + }if (old_pools)memcpy (pools, old_pools, mtrmng->n *sizeof (struct mlx5_aso_mtr_pool *));
@@ -10818,7 +10823,7 @@ flow_dv_aso_age_pools_resize(struct rte_eth_dev *dev)mlx5_free (old_pools); }else {/* First ASO flow hit allocation - starting ASO data-path. */ -int ret =mlx5_aso_queue_start (priv->sh); +int ret =mlx5_aso_flow_hit_queue_poll_start (priv->sh);if (ret) {mlx5_free (pools);
drivers/net/mlx5/mlx5_flow_meter.c +3 -4
@@ -811,7 +811,6 @@ mlx5_flow_meter_destroy(struct rte_eth_dev *dev, uint32_t meter_id, struct rte_mtr_error *error) {struct mlx5_priv *priv = dev->data->dev_private; -struct mlx5_aso_mtr_pools_mng *mtrmng = priv->sh->mtrmng;struct mlx5_flow_meter_info *fm;const struct rte_flow_attr attr = { .ingress =1 ,
@@ -836,7 +835,7 @@ mlx5_flow_meter_destroy(struct rte_eth_dev *dev, uint32_t meter_id,RTE_MTR_ERROR_TYPE_UNSPECIFIED , NULL, "Meter object is being used.");if (priv->sh->meter_aso_en) { -if (mlx5_l3t_clear_entry (mtrmng->mtr_idx_tbl, meter_id)) +if (mlx5_l3t_clear_entry (priv->mtr_idx_tbl, meter_id))return -rte_mtr_error_set (error,EBUSY ,RTE_MTR_ERROR_TYPE_UNSPECIFIED ,NULL ,"Fail to delete ASO Meter in index table." );
@@ -1302,7 +1301,7 @@ mlx5_flow_meter_find(struct mlx5_priv *priv, uint32_t meter_id,rte_spinlock_unlock (&mtrmng->mtrsl);return NULL ; } -if (mlx5_l3t_get_entry (mtrmng->mtr_idx_tbl, meter_id, &data) || +if (mlx5_l3t_get_entry (priv->mtr_idx_tbl, meter_id, &data) || !data.dword) {rte_spinlock_unlock (&mtrmng->mtrsl);return NULL ;
@@ -1310,7 +1309,7 @@ mlx5_flow_meter_find(struct mlx5_priv *priv, uint32_t meter_id,if (mtr_idx) *mtr_idx = data.dword; aso_mtr =mlx5_aso_meter_by_idx (priv, data.dword); -mlx5_l3t_clear_entry (mtrmng->mtr_idx_tbl, meter_id); +mlx5_l3t_clear_entry (priv->mtr_idx_tbl, meter_id);if (meter_id == aso_mtr->fm.meter_id) {rte_spinlock_unlock (&mtrmng->mtrsl);return &aso_mtr->fm;
Signature · 1 line
2.27.0
PATCH v2 10/13 net/mlx5: aso flow meter send WQE and CQE handle
In reply to Li ZhangASO flow meter send WQE and CQE handle functions
--- drivers/net/mlx5/mlx5.h | 4 + drivers/net/mlx5/mlx5_flow_aso.c | 185 ++++++++++++++++++++++++++++- drivers/net/mlx5/mlx5_flow_meter.c | 143 +++++++++++++--------- 3 files changed, 276 insertions(+), 56 deletions(-)
drivers/net/mlx5/mlx5.h +4 -0
@@ -1516,5 +1516,9 @@ 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, +struct mlx5_aso_mtr *mtr); +int mlx5_aso_mtr_wait (struct mlx5_dev_ctx_shared *sh, +struct mlx5_aso_mtr *mtr);#endif /* RTE_PMD_MLX5_H_ */
drivers/net/mlx5/mlx5_flow_aso.c +184 -1
200 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_meter.c +88 -55
221 lines not on this page · raw message
Signature · 1 line
2.27.0
PATCH v2 11/13 net/mlx5: add support of ASO meter action
In reply to Li ZhangWhen ASO action is available, use it as the meter action
--- drivers/net/mlx5/linux/mlx5_os.c | 7 ++- drivers/net/mlx5/mlx5.c | 10 +++ drivers/net/mlx5/mlx5.h | 7 ++- drivers/net/mlx5/mlx5_flow.c | 69 +++++++++++++++------ drivers/net/mlx5/mlx5_flow_dv.c | 30 +++++++-- drivers/net/mlx5/mlx5_flow_meter.c | 97 +++++++++++++++++++----------- 6 files changed, 158 insertions(+), 62 deletions(-)
drivers/net/mlx5/linux/mlx5_os.c +4 -3
@@ -741,7 +741,6 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,int own_domain_id =0 ;uint16_t port_id;unsigned int i; -uint32_t log_obj_size;#ifdef HAVE_MLX5DV_DR_DEVX_PORT struct mlx5dv_devx_port devx_port = { .comp_mask =0 };#endif
@@ -1201,7 +1200,9 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,"required for coalescing is %d bytes" , config->hca_attr.lro_min_mss_size); } -#if defined(HAVE_MLX5DV_DR ) && defined(HAVE_MLX5_DR_CREATE_ACTION_FLOW_METER ) +#if defined(HAVE_MLX5DV_DR ) && \ + (defined(HAVE_MLX5_DR_CREATE_ACTION_FLOW_METER ) || \ + defined(HAVE_MLX5_DR_CREATE_ACTION_ASO ))if (config->hca_attr.qos.sup && config->hca_attr.qos.flow_meter_old && config->dv_flow_en) {
@@ -1238,7 +1239,7 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, }if (config->hca_attr.qos.sup && config->hca_attr.qos.flow_meter_aso_sup) { - log_obj_size = +uint32_t log_obj_size =rte_log2_u32 (MLX5_ASO_MTRS_PER_POOL >>1 ); if (log_obj_size >= config->hca_attr.qos.log_meter_aso_granularity &&
drivers/net/mlx5/mlx5.c +10 -0
@@ -585,13 +585,23 @@ static void mlx5_aso_flow_mtrs_mng_close(struct mlx5_dev_ctx_shared *sh) {struct mlx5_aso_mtr_pool *mtr_pool; +struct mlx5_aso_mtr *aso_mtr;struct mlx5_aso_mtr_pools_mng *mtrmng = sh->mtrmng;uint32_t idx; +int i;mlx5_aso_queue_uninit (sh,ASO_OPC_MOD_POLICER ); idx = mtrmng->n_valid;while (idx--) { mtr_pool = mtrmng->pools[idx]; +#ifdef HAVE_MLX5_DR_CREATE_ACTION_ASO +for (i =0 ; i <MLX5_ASO_MTRS_PER_POOL ; i++) { + aso_mtr = &mtr_pool->mtrs[i]; +if (aso_mtr->fm.meter_action) +claim_zero (mlx5_glue->destroy_flow_action + (aso_mtr->fm.meter_action)); + } +#endif /* HAVE_MLX5_DR_CREATE_ACTION_ASO */ claim_zero (mlx5_devx_cmd_destroy (mtr_pool->devx_obj)); mtrmng->n_valid--;
drivers/net/mlx5/mlx5.h +4 -3
@@ -634,8 +634,6 @@ struct mlx5_meter_domains_infos {/**< Counters for green rule. */ void *drop_count;/**< Counters for green rule. */ -void *meter_action; -/**< Flow meter action. */ };/* Meter parameter structure. */
@@ -698,6 +696,8 @@ struct mlx5_flow_meter_info {/**< Use count. */ struct mlx5_indexed_pool *flow_ipool;/**< Index pool for flow id. */ +void *meter_action; +/**< Flow meter action. */ };/* RFC2697 parameter structure. */
@@ -1463,7 +1463,8 @@ int mlx5_flow_meter_attach(struct mlx5_priv *priv,struct mlx5_flow_meter_info *fm, const struct rte_flow_attr *attr, struct rte_flow_error *error); -void mlx5_flow_meter_detach (struct mlx5_flow_meter_info *fm); +void mlx5_flow_meter_detach (struct mlx5_priv *priv, +struct mlx5_flow_meter_info *fm);/* mlx5_os.c */ struct rte_pci_driver ;
drivers/net/mlx5/mlx5_flow.c +52 -17
131 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_dv.c +25 -5
@@ -4887,9 +4887,11 @@ mlx5_flow_validate_action_meter(struct rte_eth_dev *dev,return rte_flow_error_set (error,EINVAL ,RTE_FLOW_ERROR_TYPE_ACTION ,NULL ,"Meter not found" ); -if (fm->ref_cnt && (!(fm->transfer == attr->transfer || +/* aso meter can always be shared by different domains */ +if (fm->ref_cnt && !priv->sh->meter_aso_en && + !(fm->transfer == attr->transfer || (!fm->ingress && !attr->ingress && attr->egress) || - (!fm->egress && !attr->egress && attr->ingress)))) + (!fm->egress && !attr->egress && attr->ingress)))return rte_flow_error_set (error,EINVAL ,RTE_FLOW_ERROR_TYPE_ACTION ,NULL , "Flow attributes are either invalid "
@@ -6058,6 +6060,8 @@ flow_dv_mtr_alloc(struct rte_eth_dev *dev)struct mlx5_aso_mtr *mtr_free =NULL ;struct mlx5_aso_mtr_pools_mng *mtrmng = priv->sh->mtrmng;struct mlx5_aso_mtr_pool *pool; +struct rte_flow_error error; +uint8_t reg_id;uint32_t mtr_idx =0 ;if (!priv->config.devx) {
@@ -6080,6 +6084,22 @@ flow_dv_mtr_alloc(struct rte_eth_dev *dev) struct mlx5_aso_mtr_pool, mtrs[mtr_free->offset]); mtr_idx =MLX5_MAKE_MTR_IDX (pool->index, mtr_free->offset); +if (!mtr_free->fm.meter_action) { +#ifdef HAVE_MLX5_DR_CREATE_ACTION_ASO + reg_id =mlx5_flow_get_reg_id (dev,MLX5_MTR_COLOR ,0 , &error); + mtr_free->fm.meter_action = + mlx5_glue->dv_create_flow_action_aso + (priv->sh->rx_domain, + pool->devx_obj->obj, + mtr_free->offset, + (1 <<MLX5_FLOW_COLOR_GREEN ), + reg_id -REG_C_0 ); +#endif /* HAVE_MLX5_DR_CREATE_ACTION_ASO */ +if (!mtr_free->fm.meter_action) { +flow_dv_aso_mtr_release_to_pool (dev, mtr_idx); +return 0 ; + } + }return mtr_idx; }
@@ -11579,7 +11599,7 @@ flow_dv_translate(struct rte_eth_dev *dev, NULL, "Failed to get meter in flow.");/* Set the meter action. */ dev_flow->dv.actions[actions_n++] = - wks->fm->mfts->meter_action; + wks->fm->meter_action; action_flags |=MLX5_FLOW_ACTION_METER ;break ;case RTE_FLOW_ACTION_TYPE_SET_IPV4_DSCP :
@@ -12688,7 +12708,7 @@ flow_dv_destroy(struct rte_eth_dev *dev, struct rte_flow *flow)if (flow->meter) { fm =flow_dv_meter_find_by_idx (priv, flow->meter);if (fm) -mlx5_flow_meter_detach (fm); +mlx5_flow_meter_detach (priv, fm); flow->meter =0 ; }if (flow->age)
@@ -13879,7 +13899,7 @@ flow_dv_prepare_policer_rules(struct rte_eth_dev *dev, mtb->drop_count =NULL ; }/** -* If flow meter has been initilized, all policer rules +* If flow meter has been initialized, all policer rules * are created. So can get if meter initialized by checking * any policer rule. */
drivers/net/mlx5/mlx5_flow_meter.c +63 -34
141 lines not on this page · raw message
Signature · 1 line
2.27.0
PATCH v2 12/13 net/mlx5: make ASO meter queue thread-safe
In reply to Li ZhangSynchronize ASO meter queue accesses from
different threads using a spinlock.
--- drivers/net/mlx5/mlx5.h | 1 + drivers/net/mlx5/mlx5_flow_aso.c | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-)
drivers/net/mlx5/mlx5.h +1 -0
@@ -502,6 +502,7 @@ struct mlx5_aso_sq_elem {struct mlx5_aso_sq {uint16_t log_desc_n; +rte_spinlock_t sqsl;struct mlx5_aso_cq cq;struct mlx5_devx_sq sq_obj;volatile uint64_t *uar_addr;
drivers/net/mlx5/mlx5_flow_aso.c +13 -3
@@ -276,6 +276,7 @@ mlx5_aso_sq_create(void *ctx, struct mlx5_aso_sq *sq, int socket, sq->tail =0 ; sq->sqn = sq->sq_obj.sq->id; sq->uar_addr =mlx5_os_get_devx_uar_reg_addr (uar); +rte_spinlock_init (&sq->sqsl);return 0 ; error:mlx5_aso_destroy_sq (sq);
@@ -667,12 +668,15 @@ mlx5_aso_mtr_sq_enqueue_single(struct mlx5_aso_sq *sq,struct mlx5_flow_meter_info *fm =NULL ;uint16_t size =1 << sq->log_desc_n;uint16_t mask = size -1 ; -uint16_t res = size - (uint16_t )(sq->head - sq->tail); +uint16_t res;uint32_t dseg_idx =0 ;struct mlx5_aso_mtr_pool *pool =NULL ; +rte_spinlock_lock (&sq->sqsl); + res = size - (uint16_t )(sq->head - sq->tail);if (unlikely (!res)) {DRV_LOG (ERR ,"Fail: SQ is full and no free WQE to send" ); +rte_spinlock_unlock (&sq->sqsl);return 0 ; } wqe = &sq->sq_obj.aso_wqes[sq->head & mask];
@@ -709,6 +713,7 @@ mlx5_aso_mtr_sq_enqueue_single(struct mlx5_aso_sq *sq,rte_wmb (); *sq->uar_addr = *(volatile uint64_t *)wqe;/* Assume 64 bit ARCH. */ rte_wmb (); +rte_spinlock_unlock (&sq->sqsl);return 1 ; }
@@ -739,12 +744,16 @@ mlx5_aso_mtr_completion_handle(struct mlx5_aso_sq *sq)const unsigned int mask = cq_size -1 ;uint32_t idx;uint32_t next_idx = cq->cq_ci & mask; -const uint16_t max = (uint16_t )(sq->head - sq->tail); +uint16_t max;uint16_t n =0 ;int ret; -if (unlikely (!max)) +rte_spinlock_lock (&sq->sqsl); + max = (uint16_t )(sq->head - sq->tail); +if (unlikely (!max)) { +rte_spinlock_unlock (&sq->sqsl);return ; + } do { idx = next_idx; next_idx = (cq->cq_ci + 1) & mask;
@@ -771,6 +780,7 @@ mlx5_aso_mtr_completion_handle(struct mlx5_aso_sq *sq)rte_io_wmb (); cq->cq_obj.db_rec[0 ] =rte_cpu_to_be_32 (cq->cq_ci); } +rte_spinlock_unlock (&sq->sqsl); }/**
Signature · 1 line
2.27.0
PATCH v2 13/13 net/mlx5: allow multiple flow tables on the same level
In reply to Li ZhangThe driver devices support creation of multiple flow tables. Jump action can be used in order to move the packet steering to different flow table.
Table 0 is always the root table for packet steering.
Jumping between tables may cause endless loops in steering mechanism, that's why each table has level attribute,
the driver sub-system may not allow jumping to table with equal or lower level than the current table.
Currently, in the driver, the table ID and level are always identical.
Allow multiple flow table creation with the same level attribute.
This patch adds the table id in flow table data entry, while allocates the flow table, if the table level is same but the different table id, the new table will be allocated with new table object id. It supports 4M multiple flow tables on the same level.
--- drivers/net/mlx5/mlx5.c | 9 ++-- drivers/net/mlx5/mlx5.h | 10 ++-- drivers/net/mlx5/mlx5_flow.c | 11 +++-- drivers/net/mlx5/mlx5_flow.h | 10 ++-- drivers/net/mlx5/mlx5_flow_dv.c | 83 +++++++++++++++++++-------------- 5 files changed, 71 insertions(+), 52 deletions(-)
drivers/net/mlx5/mlx5.c +6 -3
@@ -1246,9 +1246,12 @@ mlx5_alloc_table_hash_list(struct mlx5_priv *priv __rte_unused)* because DV expect to see them even if they cannot be created by * RDMA-CORE. */ -if (!flow_dv_tbl_resource_get (dev,0 ,0 ,0 ,0 ,NULL ,0 ,1 , &error) || - !flow_dv_tbl_resource_get (dev,0 ,1 ,0 ,0 ,NULL ,0 ,1 , &error) || - !flow_dv_tbl_resource_get (dev,0 ,0 ,1 ,0 ,NULL ,0 ,1 , &error)) { +if (!flow_dv_tbl_resource_get (dev,0 ,0 ,0 ,0 , +NULL ,0 ,1 ,0 , &error) || + !flow_dv_tbl_resource_get (dev,0 ,1 ,0 ,0 , +NULL ,0 ,1 ,0 , &error) || + !flow_dv_tbl_resource_get (dev,0 ,0 ,1 ,0 , +NULL ,0 ,1 ,0 , &error)) { err =ENOMEM ; goto error; }
drivers/net/mlx5/mlx5.h +6 -4
@@ -779,10 +779,12 @@ struct mlx5_aso_mtr_pools_mng {union mlx5_flow_tbl_key {struct {/* Table ID should be at the lowest address. */ -uint32_t table_id;/**< ID of the table. */ -uint16_t dummy;/**< Dummy table for DV API. */ -uint8_t domain;/**< 1 - FDB, 0 - NIC TX/RX. */ -uint8_t direction;/**< 1 - egress, 0 - ingress. */ +uint32_t level;/**< Level of the table. */ +uint32_t id:22 ;/**< ID of the table. */ +uint32_t dummy:1 ;/**< Dummy table for DV API. */ +uint32_t is_fdb:1 ;/**< 1 - FDB, 0 - NIC TX/RX. */ +uint32_t is_egress:1 ;/**< 1 - egress, 0 - ingress. */ +uint32_t reserved:7 ;/**< must be zero for comparison. */ };uint64_t v64;/**< full 64bits value of key */ };
drivers/net/mlx5/mlx5_flow.c +6 -5
@@ -5500,8 +5500,7 @@ flow_create_split_sample(struct rte_eth_dev *dev, struct mlx5_flow_tbl_data_entry, tbl); sfx_attr.group = sfx_attr.transfer ? - (sfx_tbl_data->table_id -1 ) : - sfx_tbl_data->table_id; + (sfx_tbl_data->level -1 ) : sfx_tbl_data->level; }else {MLX5_ASSERT (attr->transfer); sfx_attr.group = jump_table;
@@ -7754,10 +7753,12 @@ tunnel_mark_decode(struct rte_eth_dev *dev, uint32_t mark)union tunnel_offload_mark mbits = { .val = mark };union mlx5_flow_tbl_key table_key = { { - .table_id =tunnel_id_to_flow_tbl (mbits.table_id), + .level =tunnel_id_to_flow_tbl (mbits.table_id), + .id =0 , + .reserved =0 , .dummy =0 , - .domain = !!mbits.transfer, - .direction =0 , + .is_fdb = !!mbits.transfer, + .is_egress =0 , } }; he =mlx5_hlist_lookup (sh->flow_tbls, table_key.v64,NULL );
drivers/net/mlx5/mlx5_flow.h +6 -4
@@ -565,8 +565,9 @@ struct mlx5_flow_tbl_data_entry { uint32_t is_egress:1; /**< Egress table. */ uint32_t is_transfer:1; /**< Transfer table. */ uint32_t dummy:1; /**< DR table. */ - uint32_t reserve:27; /**< Reserved to future using. */ -uint32_t table_id;/**< Table ID. */ + uint32_t id:22; /**< Table ID. */ + uint32_t reserve:5; /**< Reserved to future using. */ +uint32_t level;/**< Table level. */ };/* Sub rdma-core actions list. */
@@ -1393,9 +1394,10 @@ int flow_dv_tbl_match_cb(struct mlx5_hlist *list,void flow_dv_tbl_remove_cb (struct mlx5_hlist *list,struct mlx5_hlist_entry *entry);struct mlx5_flow_tbl_resource *flow_dv_tbl_resource_get (struct rte_eth_dev *dev, -uint32_t table_id,uint8_t egress,uint8_t transfer, +uint32_t table_level,uint8_t egress,uint8_t transfer,bool external,const struct mlx5_flow_tunnel *tunnel, -uint32_t group_id,uint8_t dummy,struct rte_flow_error *error); +uint32_t group_id,uint8_t dummy, +uint32_t table_id,struct rte_flow_error *error);struct mlx5_hlist_entry *flow_dv_tag_create_cb (struct mlx5_hlist *list,uint64_t key,void *cb_ctx);
drivers/net/mlx5/mlx5_flow_dv.c +47 -36
204 lines not on this page · raw message
Signature · 1 line
2.27.0
v3 cover Add ASO meter support in MLX5 PMD
In reply to Li ZhangTo support more meters and better performance,
MLX HW provide ASO flow meter.
It can expose millions of ASO flow meter context's in HW. This ASO object can allocate the large bulk meter objects. This patch set implement the ASO flow meter for mlx5 driver. MLX5 PMD driver will be responsible for ASO flow meter manage to HW.
V2: Fix compile error issue (mlx5_glue->destroy_flow_action)
V3: Fix comments.
Li Zhang (10):
net/mlx5: optimize meter statistics
common/mlx5: add definitions for ASO flow meter common/mlx5: add read ASO flow meter HCA capability common/mlx5: add DevX API to create ASO flow meter object net/mlx5: flow meter pool to manage meter object net/mlx5: initialize the flow meter ASO SQ net/mlx5: aso flow meter send WQE and CQE handle net/mlx5: add support of ASO meter action net/mlx5: make ASO meter queue thread-safe net/mlx5: allow multiple flow tables on the same level
Shun Hao (3):
common/mlx5: add color register idle bits definition net/mlx5: fix meter statistics
net/mlx5: use mask for meter register setting
Suanming Mou (1):
net/mlx5: support three level table walk
doc/guides/nics/mlx5.rst | 6 +
drivers/common/mlx5/mlx5_devx_cmds.c | 68 ++
drivers/common/mlx5/mlx5_devx_cmds.h | 26 +-
drivers/common/mlx5/mlx5_prm.h | 81 +-
drivers/common/mlx5/version.map | 1 +
drivers/net/mlx5/linux/mlx5_os.c | 20 +-
drivers/net/mlx5/meson.build | 2 +-
drivers/net/mlx5/mlx5.c | 108 ++-
drivers/net/mlx5/mlx5.h | 258 +++++-
drivers/net/mlx5/mlx5_flow.c | 334 +++++--
drivers/net/mlx5/mlx5_flow.h | 212 ++---
.../mlx5/{mlx5_flow_age.c => mlx5_flow_aso.c} | 289 +++++-
drivers/net/mlx5/mlx5_flow_dv.c | 792 +++++++++++-----
drivers/net/mlx5/mlx5_flow_meter.c | 873 ++++++++++++------
drivers/net/mlx5/mlx5_utils.h | 90 ++
15 files changed, 2330 insertions(+), 830 deletions(-)
rename drivers/net/mlx5/{mlx5_flow_age.c => mlx5_flow_aso.c} (65%)Signature · 1 line
2.27.0
PATCH v3 1/14 net/mlx5: support three level table walk
From: Suanming Mou <[email protected]>
This commit adds table entry walk for the three level table.
--- drivers/net/mlx5/mlx5_utils.h | 90 +++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+)
drivers/net/mlx5/mlx5_utils.h +90 -0
@@ -834,6 +834,91 @@ int32_t mlx5_l3t_clear_entry(struct mlx5_l3t_tbl *tbl, uint32_t idx);int32_t mlx5_l3t_set_entry (struct mlx5_l3t_tbl *tbl,uint32_t idx,union mlx5_l3t_data *data); +static inline void * +mlx5_l3t_get_next (struct mlx5_l3t_tbl *tbl,uint32_t *pos) +{ +struct mlx5_l3t_level_tbl *g_tbl, *m_tbl; +uint32_t i, j, k, g_start, m_start, e_start; +uint32_t idx = *pos; +void *e_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; + +if (!tbl) +return NULL ; + g_tbl = tbl->tbl; +if (!g_tbl) +return NULL ; + g_start = (idx >>MLX5_L3T_GT_OFFSET ) &MLX5_L3T_GT_MASK ; + m_start = (idx >>MLX5_L3T_MT_OFFSET ) &MLX5_L3T_MT_MASK ; + e_start = idx &MLX5_L3T_ET_MASK ; +for (i = g_start; i <MLX5_L3T_GT_SIZE ; i++) { + m_tbl = g_tbl->tbl[i]; +if (!m_tbl) { +/* Jump to new table, reset the sub table start. */ + m_start =0 ; + e_start =0 ; +continue ; + } +for (j = m_start; j <MLX5_L3T_MT_SIZE ; j++) { +if (!m_tbl->tbl[j]) { +/* +* Jump to new table, reset the sub table +* start. +*/ + e_start =0 ; +continue ; + } + e_tbl = m_tbl->tbl[j]; +switch (tbl->type) { +case MLX5_L3T_TYPE_WORD : + w_e_tbl = (struct mlx5_l3t_entry_word *)e_tbl; +for (k = e_start; k <MLX5_L3T_ET_SIZE ; k++) { +if (!w_e_tbl->entry[k].data) +continue ; + *pos = (i <<MLX5_L3T_GT_OFFSET ) | + (j <<MLX5_L3T_MT_OFFSET ) | k; +return (void *)&w_e_tbl->entry[k].data; + } +break ; +case MLX5_L3T_TYPE_DWORD : + dw_e_tbl = (struct mlx5_l3t_entry_dword *)e_tbl; +for (k = e_start; k <MLX5_L3T_ET_SIZE ; k++) { +if (!dw_e_tbl->entry[k].data) +continue ; + *pos = (i <<MLX5_L3T_GT_OFFSET ) | + (j <<MLX5_L3T_MT_OFFSET ) | k; +return (void *)&dw_e_tbl->entry[k].data; + } +break ; +case MLX5_L3T_TYPE_QWORD : + qw_e_tbl = (struct mlx5_l3t_entry_qword *)e_tbl; +for (k = e_start; k <MLX5_L3T_ET_SIZE ; k++) { +if (!qw_e_tbl->entry[k].data) +continue ; + *pos = (i <<MLX5_L3T_GT_OFFSET ) | + (j <<MLX5_L3T_MT_OFFSET ) | k; +return (void *)&qw_e_tbl->entry[k].data; + } +break ; +default : + ptr_e_tbl = (struct mlx5_l3t_entry_ptr *)e_tbl; +for (k = e_start; k <MLX5_L3T_ET_SIZE ; k++) { +if (!ptr_e_tbl->entry[k].data) +continue ; + *pos = (i <<MLX5_L3T_GT_OFFSET ) | + (j <<MLX5_L3T_MT_OFFSET ) | k; +return ptr_e_tbl->entry[k].data; + } +break ; + } + } + } +return NULL ; +} +/* * Macros for linked list based on indexed memory. * Example data structure:
@@ -909,4 +994,9 @@ struct { \ idx = (elem)->field.next, (elem) = \ (idx) ? mlx5_ipool_get(pool, idx) : NULL) +#define MLX5_L3T_FOREACH (tbl, idx, entry) \ + for (idx = 0, (entry) = mlx5_l3t_get_next((tbl), &idx); \ + (entry); \ + idx++, (entry) = mlx5_l3t_get_next((tbl), &idx)) +#endif /* RTE_PMD_MLX5_UTILS_H_ */
Signature · 1 line
2.27.0
PATCH v3 2/14 common/mlx5: add color register idle bits definition
In reply to Li ZhangFrom: Shun Hao <[email protected]>
8 bits are used for meter color in meter register. When the meter register can be shared, the rest 24 bits can be used by others. This adds the definination for the 24 bits that can be shared.
--- drivers/common/mlx5/mlx5_prm.h | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/common/mlx5/mlx5_prm.h +6 -0
@@ -3382,6 +3382,12 @@ enum {/* The bits meter color use. */ #define MLX5_MTR_COLOR_BITS 8 +/* The bit size of one register. */ +#define MLX5_REG_BITS 32 + +/* Idle bits for non-color usage in color register. */ +#define MLX5_MTR_IDLE_BITS_IN_COLOR_REG (MLX5_REG_BITS - MLX5_MTR_COLOR_BITS) +/* Length mode of dynamic flex parser graph node. */ enum mlx5_parse_graph_node_len_mode {MLX5_GRAPH_NODE_LEN_FIXED =0x0 ,
Signature · 1 line
2.27.0
PATCH v3 3/14 net/mlx5: fix meter statistics
In reply to Li ZhangFrom: Shun Hao <[email protected]>
Currently, packets after meter will be steered to a global policer table,
which includes green/red color rules for every meter, so as to have counter statistics of each color in every meter.
There's a bug that all the rules in global policer table are matching only color criteria, so all packets will be counted to one meter only, and other meter statistics are always zero.
This patch does these:
1. The rules in policer table matches both meter index and color, so packet after meter could be counted to the correct meter counter.
2. The meter index and flow index are now sharing the available register bits dynamically. Meter index starts from lsb, and flow index starts from msb.
--- drivers/net/mlx5/mlx5.c | 7 +- drivers/net/mlx5/mlx5.h | 15 +- drivers/net/mlx5/mlx5_flow.c | 183 +++++++---- drivers/net/mlx5/mlx5_flow.h | 40 +-- drivers/net/mlx5/mlx5_flow_dv.c | 489 ++++++++++++++++++----------- drivers/net/mlx5/mlx5_flow_meter.c | 53 +++- 6 files changed, 496 insertions(+), 291 deletions(-)
drivers/net/mlx5/mlx5.c +5 -2
@@ -275,10 +275,13 @@ static const struct mlx5_indexed_pool_config mlx5_ipool_cfg[] = { }, #endif [MLX5_IPOOL_MTR ] = { +/** +* The ipool index should grow continually from small to big, +* for meter idx, so not set grow_trunk to avoid meter index +* not jump continually. +*/ .size =sizeof (struct mlx5_flow_meter ), .trunk_size =64 , - .grow_trunk =3 , - .grow_shift =2 , .need_lock =1 , .release_mem_en =1 , .malloc = mlx5_malloc,
drivers/net/mlx5/mlx5.h +9 -6
@@ -944,9 +944,9 @@ struct mlx5_priv { unsigned int representor:1; /* Device is a port representor. */ unsigned int master:1; /* Device is a E-Switch master. */ unsigned int txpp_en:1; /* Tx packet pacing enabled. */ + unsigned int sampler_en:1; /* Whether support sampler. */ unsigned int mtr_en:1; /* Whether support meter. */ unsigned int mtr_reg_share:1; /* Whether support meter REG_C share. */ - unsigned int sampler_en:1; /* Whether support sampler. */uint16_t domain_id;/* Switch domain identifier. */ uint16_t vport_id;/* Associated VF vport index (if any). */ uint32_t vport_meta_tag;/* Used for vport index match ove VF LAG. */
@@ -1003,6 +1003,10 @@ struct mlx5_priv {uint32_t rss_shared_actions;/* RSS shared actions. */ struct mlx5_devx_obj *q_counters;/* DevX queue counter object. */ uint32_t counter_set_id;/* Queue counter ID to set in DevX objects. */ +uint8_t max_mtr_bits; +/* Indicate how many bits are used by meter id at the most. */ +uint8_t max_mtr_flow_bits; +/* Indicate how many bits are used by meter flow id at the most. */ };#define PORT_ID (priv) ((priv)->dev_data->port_id)
@@ -1271,11 +1275,10 @@ int mlx5_pmd_socket_init(void);int mlx5_flow_meter_ops_get (struct rte_eth_dev *dev,void *arg);struct mlx5_flow_meter *mlx5_flow_meter_find (struct mlx5_priv *priv,uint32_t meter_id); -struct mlx5_flow_meter *mlx5_flow_meter_attach - (struct mlx5_priv *priv, -uint32_t meter_id, -const struct rte_flow_attr *attr, -struct rte_flow_error *error); +int mlx5_flow_meter_attach (struct mlx5_priv *priv, +struct mlx5_flow_meter *fm, +const struct rte_flow_attr *attr, +struct rte_flow_error *error);void mlx5_flow_meter_detach (struct mlx5_flow_meter *fm);/* mlx5_os.c */
drivers/net/mlx5/mlx5_flow.c +120 -63
330 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow.h +22 -18
@@ -79,7 +79,7 @@ enum mlx5_feature_name {MLX5_APP_TAG ,MLX5_COPY_MARK ,MLX5_MTR_COLOR , -MLX5_MTR_SFX , +MLX5_MTR_ID , MLX5_ASO_FLOW_HIT, };
@@ -655,7 +655,8 @@ struct mlx5_flow_handle {uint64_t layers;/**< Bit-fields of present layers, see MLX5_FLOW_LAYER_*. */ void *drv_flow;/**< pointer to driver flow object. */ - uint32_t split_flow_id:28; /**< Sub flow unique match flow id. */ + uint32_t split_flow_id:27; /**< Sub flow unique match flow id. */ + uint32_t is_meter_flow_id:1; /**< Indate if flow_id is for meter. */ uint32_t mark:1; /**< Metadate rxq mark flag. */ uint32_t fate_action:3; /**< Fate action type. */union {
@@ -842,14 +843,16 @@ struct mlx5_meter_domain_info {/**< Meter table. */ struct mlx5_flow_tbl_resource *sfx_tbl;/**< Meter suffix table. */ -void *any_matcher; -/**< Meter color not match default criteria. */ -void *color_matcher; -/**< Meter color match criteria. */ +struct mlx5_flow_dv_matcher *drop_matcher; +/**< Matcher for Drop. */ +struct mlx5_flow_dv_matcher *color_matcher; +/**< Matcher for Color. */ void *jump_actn;/**< Meter match action. */ -void *policer_rules[RTE_MTR_DROPPED +1 ]; -/**< Meter policer for the match. */ +void *green_rule; +/**< Meter green rule. */ +void *drop_rule; +/**< Meter drop rule. */ };/* Meter table set for TX RX FDB. */
@@ -862,10 +865,10 @@ struct mlx5_meter_domains_infos {/**< RX meter table. */ struct mlx5_meter_domain_info transfer;/**< FDB meter table. */ -void *drop_actn; -/**< Drop action as not matched. */ -void *count_actns[RTE_MTR_DROPPED +1 ]; -/**< Counters for match and unmatched statistics. */ +void *green_count; +/**< Counters for green rule. */ +void *drop_count; +/**< Counters for green rule. */ uint32_t fmp[MLX5_ST_SZ_DW (flow_meter_parameters)];/**< Flow meter parameter. */ size_t fmp_size;
@@ -928,6 +931,8 @@ struct mlx5_flow_meter {/**< Meter state. */ uint32_t shared:1;/**< Meter shared or not. */ +struct mlx5_indexed_pool *flow_ipool; +/**< Index pool for flow id. */ };/* RFC2697 parameter structure. */
@@ -1166,6 +1171,7 @@ struct mlx5_flow_workspace {struct mlx5_flow_rss_desc rss_desc;uint32_t rssq_num;/* Allocated queue num in rss_desc. */ uint32_t flow_idx;/* Intermediate device flow index. */ +struct mlx5_flow_meter *fm;/* Pointer to the meter in flow. */ };struct mlx5_flow_split_info {
@@ -1206,8 +1212,7 @@ typedef int (*mlx5_flow_query_t)(struct rte_eth_dev *dev,void *data, struct rte_flow_error *error);typedef struct mlx5_meter_domains_infos *(*mlx5_flow_create_mtr_tbls_t ) - (struct rte_eth_dev *dev, -const struct mlx5_flow_meter *fm); + (struct rte_eth_dev *dev);typedef int (*mlx5_flow_destroy_mtr_tbls_t )(struct rte_eth_dev *dev,struct mlx5_meter_domains_infos *tbls);typedef int (*mlx5_flow_create_policer_rules_t )
@@ -1270,7 +1275,7 @@ struct mlx5_flow_driver_ops {mlx5_flow_query_t query;mlx5_flow_create_mtr_tbls_t create_mtr_tbls;mlx5_flow_destroy_mtr_tbls_t destroy_mtr_tbls; -mlx5_flow_create_policer_rules_t create_policer_rules; +mlx5_flow_create_policer_rules_t prepare_policer_rules;mlx5_flow_destroy_policer_rules_t destroy_policer_rules;mlx5_flow_counter_alloc_t counter_alloc;mlx5_flow_counter_free_t counter_free;
@@ -1470,11 +1475,10 @@ int mlx5_flow_validate_item_ecpri(const struct rte_flow_item *item,const struct rte_flow_item_ecpri *acc_mask, struct rte_flow_error *error);struct mlx5_meter_domains_infos *mlx5_flow_create_mtr_tbls - (struct rte_eth_dev *dev, -const struct mlx5_flow_meter *fm); + (struct rte_eth_dev *dev);int mlx5_flow_destroy_mtr_tbls (struct rte_eth_dev *dev,struct mlx5_meter_domains_infos *tbl); -int mlx5_flow_create_policer_rules (struct rte_eth_dev *dev, +int mlx5_flow_prepare_policer_rules (struct rte_eth_dev *dev,struct mlx5_flow_meter *fm,const struct rte_flow_attr *attr); int mlx5_flow_destroy_policer_rules(struct rte_eth_dev *dev,
drivers/net/mlx5/mlx5_flow_dv.c +303 -186
704 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_meter.c +37 -16
117 lines not on this page · raw message
Signature · 1 line
2.27.0
PATCH v3 4/14 net/mlx5: optimize meter statistics
In reply to Li ZhangMeter statistics are each policer action each counter. Totally 4 counters per each meter.
It causes cache missed
and lead to data forwarding performance low.
To optimize it, support pass counter for green
and drop counter for red.
Totally two counters per each meter.
Also use the global drop statistics for
all meter drop action.
limitations as below:
1. It does not support yellow counter and return 0.
2. All the meter colors with drop action will be counted only by the global drop statistics.
3. Red color must be with drop action.
--- doc/guides/nics/mlx5.rst | 6 + drivers/net/mlx5/mlx5_flow.h | 24 ++-- drivers/net/mlx5/mlx5_flow_dv.c | 8 +- drivers/net/mlx5/mlx5_flow_meter.c | 217 +++++++++++++++++++---------- 4 files changed, 173 insertions(+), 82 deletions(-)
doc/guides/nics/mlx5.rst +6 -0
@@ -399,6 +399,12 @@ Limitations - Hairpin between two ports could only manual binding and explicit Tx flow mode. For single port hairpin, all the combinations of auto/manual binding and explicit/implicit Tx flow mode could be supported. - Hairpin in switchdev SR-IOV mode is not supported till now. +- Meter: + - All the meter colors with drop action will be counted only by the global drop statistics. + - Green color is not supported with drop action. + - Yellow detection is not supported. + - Red color must be with drop action. + Statistics ----------
drivers/net/mlx5/mlx5_flow.h +16 -8
@@ -831,10 +831,10 @@ struct mlx5_flow {/* Meter policer statistics */ struct mlx5_flow_policer_stats { -uint32_t cnt[RTE_COLORS +1 ]; -/**< Color counter, extra for drop. */ -uint64_t stats_mask; -/**< Statistics mask for the colors. */ +uint32_t pass_cnt; +/**< Color counter for pass. */ +uint32_t drop_cnt; +/**< Color counter for drop. */ };/* Meter table structure. */
@@ -892,10 +892,18 @@ struct mlx5_flow_meter {/** Policer actions (per meter output color). */ enum rte_mtr_policer_action action[RTE_COLORS ]; -/** Set of stats counters to be enabled. -* @see enum rte_mtr_stats_type -*/ -uint64_t stats_mask; + uint32_t green_bytes:1; +/** Set green bytes stats to be enabled. */ + uint32_t green_pkts:1; +/** Set green packets stats to be enabled. */ + uint32_t red_bytes:1; +/** Set red bytes stats to be enabled. */ + uint32_t red_pkts:1; +/** Set red packets stats to be enabled. */ + uint32_t bytes_dropped:1; +/** Set bytes dropped stats to be enabled. */ + uint32_t pkts_dropped:1; +/** Set packets dropped stats to be enabled. */ /**< Rule applies to ingress traffic. */ uint32_t ingress:1;
drivers/net/mlx5/mlx5_flow_dv.c +4 -4
@@ -13829,17 +13829,17 @@ flow_dv_prepare_policer_rules(struct rte_eth_dev *dev,int ret;/* Get the statistics counters for green/drop. */ -if (fm->policer_stats.cnt[RTE_COLOR_GREEN ]) { +if (fm->policer_stats.pass_cnt) { cnt =flow_dv_counter_get_by_idx (dev, - fm->policer_stats.cnt[RTE_COLOR_GREEN ], + fm->policer_stats.pass_cnt,NULL ); mtb->green_count = cnt->action; }else { mtb->green_count =NULL ; } -if (fm->policer_stats.cnt[RTE_MTR_DROPPED ]) { +if (fm->policer_stats.drop_cnt) { cnt =flow_dv_counter_get_by_idx (dev, - fm->policer_stats.cnt[RTE_MTR_DROPPED ], + fm->policer_stats.drop_cnt,NULL ); mtb->drop_count = cnt->action; }else {
drivers/net/mlx5/mlx5_flow_meter.c +147 -70
321 lines not on this page · raw message
Signature · 1 line
2.27.0
PATCH v3 5/14 net/mlx5: use mask for meter register setting
In reply to Li ZhangFrom: Shun Hao <[email protected]>
ASO meter feature may require to locate the flow context tag action after the ASO action.
When color register is shared by meter_id/flow_id, it's like:
Bits[0-7] A meter color value set by the HW. Bits[8-31] A flow id and meter id set by SW.
Currently the tag action for meter writes all the bits of the meter register, so it will potentially overwrite meter color when ASO meter action is before the tag action.
Set only 24-MSB-bits of meter register in the meter tag action.
--- drivers/net/mlx5/mlx5_flow.c | 28 ++++++++++++++++++---------- drivers/net/mlx5/mlx5_flow.h | 2 ++ drivers/net/mlx5/mlx5_flow_dv.c | 2 ++ 3 files changed, 22 insertions(+), 10 deletions(-)
drivers/net/mlx5/mlx5_flow.c +18 -10
@@ -4258,9 +4258,11 @@ flow_hairpin_split(struct rte_eth_dev *dev,rte_memcpy (actions_rx, actions,sizeof (struct rte_flow_action )); actions_rx++; set_tag = (void *)actions_rx; - set_tag->id =mlx5_flow_get_reg_id (dev,MLX5_HAIRPIN_RX ,0 ,NULL ); + *set_tag = (struct mlx5_rte_flow_action_set_tag ) { + .id =mlx5_flow_get_reg_id (dev,MLX5_HAIRPIN_RX ,0 ,NULL ), + .data = flow_id, + };MLX5_ASSERT (set_tag->id >REG_NON ); - set_tag->data = flow_id; tag_action->conf = set_tag;/* Create Tx item list. */ rte_memcpy (actions_tx, actions,sizeof (struct rte_flow_action ));
@@ -4496,6 +4498,14 @@ flow_meter_split_prep(struct rte_eth_dev *dev, set_tag = (struct mlx5_rte_flow_action_set_tag *)actions_pre; tag_item_spec = (struct mlx5_rte_flow_item_tag *)sfx_items; tag_item_mask = tag_item_spec +1 ; +/* Both flow_id and meter_id share the same register. */ + *set_tag = (struct mlx5_rte_flow_action_set_tag ) { + .id = (enum modify_reg )mlx5_flow_get_reg_id (dev,MLX5_MTR_ID , +0 , error), + .offset = mtr_id_offset, + .length = mtr_reg_bits, + .data = fm->idx, + };/* * The color Reg bits used by flow_id are growing from * msb to lsb, so must do bit reverse for flow_id val in RegC.
@@ -4503,13 +4513,9 @@ flow_meter_split_prep(struct rte_eth_dev *dev,for (shift =0 ; shift < flow_id_bits; shift++) flow_id_reversed = (flow_id_reversed <<1 ) | ((flow_id >> shift) &0x1 ); -/* Both flow_id and meter_id share the same register. */ - set_tag->id =mlx5_flow_get_reg_id (dev,MLX5_MTR_ID ,0 , error); - set_tag->data = - (fm->idx | (flow_id_reversed << (mtr_reg_bits - flow_id_bits))) - << mtr_id_offset; + set_tag->data |= flow_id_reversed << (mtr_reg_bits - flow_id_bits); tag_item_spec->id = set_tag->id; - tag_item_spec->data = set_tag->data; + tag_item_spec->data = set_tag->data << mtr_id_offset; tag_item_mask->data =UINT32_MAX << mtr_id_offset; tag_action->type = (enum rte_flow_action_type )MLX5_RTE_FLOW_ACTION_TYPE_TAG ;
@@ -4896,10 +4902,12 @@ flow_sample_split_prep(struct rte_eth_dev *dev, ret =mlx5_flow_get_reg_id (dev,MLX5_APP_TAG ,0 , error);if (ret <0 )return ret; - set_tag->id = ret;mlx5_ipool_malloc (priv->sh->ipool [MLX5_IPOOL_RSS_EXPANTION_FLOW_ID ], &tag_id); - set_tag->data = tag_id; + *set_tag = (struct mlx5_rte_flow_action_set_tag ) { + .id = ret, + .data = tag_id, + };/* Prepare the suffix subflow items. */ tag_spec = (void *)(sfx_items +SAMPLE_SUFFIX_ITEM ); tag_spec->data = tag_id;
drivers/net/mlx5/mlx5_flow.h +2 -0
@@ -55,6 +55,8 @@ struct mlx5_rte_flow_item_tag {/* Modify selected register. */ struct mlx5_rte_flow_action_set_tag {enum modify_reg id; +uint8_t offset; +uint8_t length;uint32_t data; };
drivers/net/mlx5/mlx5_flow_dv.c +2 -0
@@ -964,6 +964,8 @@ flow_dv_convert_action_set_reg actions[i] = (struct mlx5_modification_cmd ) { .action_type =MLX5_MODIFICATION_TYPE_SET , .field = reg_to_field[conf->id], + .offset = conf->offset, + .length = conf->length, }; actions[i].data0 =rte_cpu_to_be_32 (actions[i].data0); actions[i].data1 =rte_cpu_to_be_32 (conf->data);
Signature · 1 line
2.27.0
PATCH v3 6/14 common/mlx5: add definitions for ASO flow meter
In reply to Li ZhangThis patch adds different PRM definitions, related to ASO flow meter feature, in MLX5 PMD code.
--- drivers/common/mlx5/mlx5_prm.h | 75 ++++++++++++++++++++++++++++++++-- 1 file changed, 71 insertions(+), 4 deletions(-)
drivers/common/mlx5/mlx5_prm.h +71 -4
@@ -1129,6 +1129,8 @@ enum { (1ULL << MLX5_GENERAL_OBJ_TYPE_FLEX_PARSE_GRAPH)#define MLX5_GENERAL_OBJ_TYPES_CAP_FLOW_HIT_ASO \ (1ULL << MLX5_GENERAL_OBJ_TYPE_FLOW_HIT_ASO) +#define MLX5_GENERAL_OBJ_TYPES_CAP_FLOW_METER_ASO \ + (1ULL << MLX5_GENERAL_OBJ_TYPE_FLOW_METER_ASO)#define MLX5_GENERAL_OBJ_TYPES_CAP_GENEVE_TLV_OPT \ (1ULL << MLX5_OBJ_TYPE_GENEVE_TLV_OPT)
@@ -1514,7 +1516,15 @@ struct mlx5_ifc_qos_cap_bits {u8 reserved_at_c0[0x10 ];u8 max_qos_para_vport[0x10 ];u8 max_tsar_bw_share[0x20 ]; -u8 reserved_at_100[0x6e8 ]; +u8 nic_element_type[0x10 ]; +u8 nic_tsar_type[0x10 ]; +u8 reserved_at_120[0x3 ]; +u8 log_meter_aso_granularity[0x5 ]; +u8 reserved_at_128[0x3 ]; +u8 log_meter_aso_max_alloc[0x5 ]; +u8 reserved_at_130[0x3 ]; +u8 log_max_num_meter_aso[0x5 ]; +u8 reserved_at_138[0x6b0 ]; };struct mlx5_ifc_per_protocol_networking_offload_caps_bits {
@@ -2284,6 +2294,8 @@ struct mlx5_ifc_flow_meter_parameters_bits {u8 eir_mantissa[0x8 ];u8 reserved_at_8[0x60 ];// 14h-1Ch }; +#define MLX5_IFC_FLOW_METER_PARAM_MASK UINT64_C(0x80FFFFFF) +#define MLX5_IFC_FLOW_METER_DISABLE_CBS_CIR_VAL 0x14BF00C8enum {MLX5_CQE_SIZE_64B =0x0 ,
@@ -2411,6 +2423,7 @@ enum {MLX5_GENERAL_OBJ_TYPE_VIRTQ =0x000d ,MLX5_GENERAL_OBJ_TYPE_VIRTIO_Q_COUNTERS =0x001c ,MLX5_GENERAL_OBJ_TYPE_FLEX_PARSE_GRAPH =0x0022 , +MLX5_GENERAL_OBJ_TYPE_FLOW_METER_ASO =0x0024 , MLX5_GENERAL_OBJ_TYPE_FLOW_HIT_ASO = 0x0025, };
@@ -2419,7 +2432,9 @@ struct mlx5_ifc_general_obj_in_cmd_hdr_bits {u8 reserved_at_10[0x20 ];u8 obj_type[0x10 ];u8 obj_id[0x20 ]; -u8 reserved_at_60[0x20 ]; +u8 reserved_at_60[0x3 ]; +u8 log_obj_range[0x5 ]; +u8 reserved_at_58[0x18 ]; };struct mlx5_ifc_general_obj_out_cmd_hdr_bits {
@@ -2565,6 +2580,18 @@ struct mlx5_ifc_create_flow_hit_aso_in_bits {struct mlx5_ifc_flow_hit_aso_bits flow_hit_aso; }; +struct mlx5_ifc_flow_meter_aso_bits { +u8 modify_field_select[0x40 ]; +u8 reserved_at_40[0x48 ]; +u8 access_pd[0x18 ]; +u8 reserved_at_a0[0x160 ]; +u8 parameters[0x200 ]; +}; + +struct mlx5_ifc_create_flow_meter_aso_in_bits { +struct mlx5_ifc_general_obj_in_cmd_hdr_bits hdr; +struct mlx5_ifc_flow_meter_aso_bits flow_meter_aso; +};enum mlx5_access_aso_opc_mod {ASO_OPC_MOD_IPSEC =0x0 ,ASO_OPC_MOD_CONNECTION_TRACKING =0x1 ,
@@ -2618,11 +2645,51 @@ struct mlx5_aso_cseg {uint64_t data_mask; } __rte_packed; +/* A meter data segment - 2 per ASO WQE. */ +struct mlx5_aso_mtr_dseg { +uint32_t v_bo_sc_bbog_mm; +/* +* bit 31: valid, 30: bucket overflow, 28-29: start color, +* 27: both buckets on green, 24-25: meter mode. +*/ +uint32_t reserved; +uint32_t cbs_cir; +/* +* bit 24-28: cbs_exponent, bit 16-23 cbs_mantissa, +* bit 8-12: cir_exponent, bit 0-7 cir_mantissa. +*/ +uint32_t c_tokens; +uint32_t ebs_eir; +/* +* bit 24-28: ebs_exponent, bit 16-23 ebs_mantissa, +* bit 8-12: eir_exponent, bit 0-7 eir_mantissa. +*/ +uint32_t e_tokens; +uint64_t timestamp; +} __rte_packed; + +#define ASO_DSEG_VALID_OFFSET 31 +#define ASO_DSEG_BO_OFFSET 30 +#define ASO_DSEG_SC_OFFSET 28 +#define ASO_DSEG_CBS_EXP_OFFSET 24 +#define ASO_DSEG_CBS_MAN_OFFSET 16 +#define ASO_DSEG_CIR_EXP_MASK 0x1F +#define ASO_DSEG_CIR_EXP_OFFSET 8 +#define ASO_DSEG_EBS_EXP_OFFSET 24 +#define ASO_DSEG_EBS_MAN_OFFSET 16 +#define ASO_DSEG_EXP_MASK 0x1F +#define ASO_DSEG_MAN_MASK 0xFF +#define MLX5_ASO_WQE_DSEG_SIZE 0x40 +#define MLX5_ASO_METERS_PER_WQE 2 +#define MLX5_ASO_MTRS_PER_POOL 128 -/* ASO WQE Data segment. */ +/* ASO WQE data segment. */ struct mlx5_aso_dseg { -uint8_t data[MLX5_ASO_WQE_DSEG_SIZE ]; +union { +uint8_t data[MLX5_ASO_WQE_DSEG_SIZE ]; +struct mlx5_aso_mtr_dseg mtrs[MLX5_ASO_METERS_PER_WQE ]; + }; } __rte_packed;/* ASO WQE. */
Signature · 1 line
2.27.0
PATCH v3 7/14 common/mlx5: add read ASO flow meter HCA capability
In reply to Li ZhangRead and store the device capability of FLOW_METER_ASO general object, using the DevX API.
--- drivers/common/mlx5/mlx5_devx_cmds.c | 14 ++++++++++++++ drivers/common/mlx5/mlx5_devx_cmds.h | 8 ++++++++ 2 files changed, 22 insertions(+)
drivers/common/mlx5/mlx5_devx_cmds.c +14 -0
@@ -696,6 +696,9 @@ mlx5_devx_cmd_query_hca_attr(void *ctx, attr->max_geneve_tlv_option_data_len =MLX5_GET (cmd_hca_cap, hcattr, max_geneve_tlv_option_data_len); attr->qos.sup =MLX5_GET (cmd_hca_cap, hcattr, qos); + attr->qos.flow_meter_aso_sup = !!(MLX5_GET64 (cmd_hca_cap, hcattr, + general_obj_types) & +MLX5_GENERAL_OBJ_TYPES_CAP_FLOW_METER_ASO ); attr->vdpa.valid = !!(MLX5_GET64 (cmd_hca_cap, hcattr, general_obj_types) &MLX5_GENERAL_OBJ_TYPES_CAP_VIRTQ_NET_Q );
@@ -783,6 +786,17 @@ mlx5_devx_cmd_query_hca_attr(void *ctx,MLX5_GET (qos_cap, hcattr, packet_pacing); attr->qos.wqe_rate_pp =MLX5_GET (qos_cap, hcattr, wqe_rate_pp); +if (attr->qos.flow_meter_aso_sup) { + attr->qos.log_meter_aso_granularity = +MLX5_GET (qos_cap, hcattr, + log_meter_aso_granularity); + attr->qos.log_meter_aso_max_alloc = +MLX5_GET (qos_cap, hcattr, + log_meter_aso_max_alloc); + attr->qos.log_max_num_meter_aso = +MLX5_GET (qos_cap, hcattr, + log_max_num_meter_aso); + } }if (attr->vdpa.valid)mlx5_devx_cmd_query_hca_vdpa_attr (ctx, &attr->vdpa);
drivers/common/mlx5/mlx5_devx_cmds.h +8 -0
@@ -50,10 +50,18 @@ struct mlx5_hca_qos_attr {* Using older driver versions, flow_meter_old can be 1 * while flow_meter is 0. */ + uint32_t flow_meter_aso_sup:1; +/* Whether FLOW_METER_ASO Object is supported. */ uint8_t log_max_flow_meter;/* Power of the maximum supported meters. */ uint8_t flow_meter_reg_c_ids;/* Bitmap of the reg_Cs available for flow meter to use. */ + uint32_t log_meter_aso_granularity:5; +/* Power of the minimum allocation granularity Object. */ + uint32_t log_meter_aso_max_alloc:5; +/* Power of the maximum allocation granularity Object. */ + uint32_t log_max_num_meter_aso:5; +/* Power of the maximum number of supported objects. */ };
Signature · 1 line
2.27.0
PATCH v3 8/14 common/mlx5: add DevX API to create ASO flow meter object
In reply to Li ZhangAdd DevX API to create ASO flow meter object.
--- drivers/common/mlx5/mlx5_devx_cmds.c | 54 ++++++++++++++++++++++++++++ drivers/common/mlx5/mlx5_devx_cmds.h | 18 +++++++++- drivers/common/mlx5/version.map | 1 + 3 files changed, 72 insertions(+), 1 deletion(-)
drivers/common/mlx5/mlx5_devx_cmds.c +54 -0
@@ -2159,6 +2159,60 @@ mlx5_devx_cmd_alloc_pd(void *ctx)return ppd; } +/** +* Create general object of type FLOW_METER_ASO using DevX API. +* +* @param[in] ctx +* Context returned from mlx5 open_device() glue function. +* @param [in] pd +* PD value to associate the FLOW_METER_ASO object with. +* @param [in] log_obj_size +* log_obj_size define to allocate number of 2 * meters +* in one FLOW_METER_ASO object. +* +* @return +* The DevX object created, NULL otherwise and rte_errno is set. +*/ +struct mlx5_devx_obj * +mlx5_devx_cmd_create_flow_meter_aso_obj (void *ctx,uint32_t pd, +uint32_t log_obj_size) +{ +uint32_t in[MLX5_ST_SZ_DW (create_flow_meter_aso_in)] = {0 }; +uint32_t out[MLX5_ST_SZ_DW (general_obj_out_cmd_hdr)]; +struct mlx5_devx_obj *flow_meter_aso_obj; +void *ptr; + + flow_meter_aso_obj =mlx5_malloc (MLX5_MEM_ZERO , +sizeof (*flow_meter_aso_obj), +0 ,SOCKET_ID_ANY ); +if (!flow_meter_aso_obj) { +DRV_LOG (ERR ,"Failed to allocate FLOW_METER_ASO object data" ); + rte_errno =ENOMEM ; +return NULL ; + } + ptr =MLX5_ADDR_OF (create_flow_meter_aso_in, in, hdr); +MLX5_SET (general_obj_in_cmd_hdr, ptr, opcode, +MLX5_CMD_OP_CREATE_GENERAL_OBJECT ); +MLX5_SET (general_obj_in_cmd_hdr, ptr, obj_type, +MLX5_GENERAL_OBJ_TYPE_FLOW_METER_ASO ); +MLX5_SET (general_obj_in_cmd_hdr, ptr, log_obj_range, + log_obj_size); + ptr =MLX5_ADDR_OF (create_flow_meter_aso_in, in, flow_meter_aso); +MLX5_SET (flow_meter_aso, ptr, access_pd, pd); + flow_meter_aso_obj->obj = mlx5_glue->devx_obj_create ( + ctx, in,sizeof (in), + out,sizeof (out)); +if (!flow_meter_aso_obj->obj) { + rte_errno = errno; +DRV_LOG (ERR ,"Failed to create FLOW_METER_ASO obj using DevX." ); +mlx5_free (flow_meter_aso_obj); +return NULL ; + } + flow_meter_aso_obj->id =MLX5_GET (general_obj_out_cmd_hdr, + out, obj_id); +return flow_meter_aso_obj; +} +/** * Create general object of type GENEVE TLV option using DevX API. *
drivers/common/mlx5/mlx5_devx_cmds.h +17 -1
@@ -554,7 +554,6 @@ int mlx5_devx_cmd_query_virtio_q_counters(struct mlx5_devx_obj *couners_obj,__rte_internal struct mlx5_devx_obj *mlx5_devx_cmd_create_flow_hit_aso_obj(void *ctx,uint32_t pd); -__rte_internal struct mlx5_devx_obj *mlx5_devx_cmd_alloc_pd(void *ctx);
@@ -566,4 +565,21 @@ struct mlx5_devx_obj *mlx5_devx_cmd_queue_counter_alloc(void *ctx);__rte_internal int mlx5_devx_cmd_queue_counter_query(struct mlx5_devx_obj *dcs, int clear,uint32_t *out_of_buffers); +/** +* Create general object of type FLOW_METER_ASO using DevX API.. +* +* @param[in] ctx +* Device context. +* @param [in] pd +* PD value to associate the FLOW_METER_ASO object with. +* @param [in] log_obj_size +* log_obj_size define to allocate number of 2 * meters +* in one FLOW_METER_ASO object. +* +* @return +* The DevX object created, NULL otherwise and rte_errno is set. +*/ +__rte_internal +struct mlx5_devx_obj *mlx5_devx_cmd_create_flow_meter_aso_obj(void *ctx, +uint32_t pd,uint32_t log_obj_size);#endif /* RTE_PMD_MLX5_DEVX_CMDS_H_ */
drivers/common/mlx5/version.map +1 -0
@@ -25,6 +25,7 @@ INTERNAL { mlx5_devx_cmd_create_virtio_q_counters; # WINDOWS_NO_EXPORT mlx5_devx_cmd_create_virtq; mlx5_devx_cmd_create_flow_hit_aso_obj; + mlx5_devx_cmd_create_flow_meter_aso_obj; mlx5_devx_cmd_create_geneve_tlv_option; mlx5_devx_cmd_destroy; mlx5_devx_cmd_flow_counter_alloc;
Signature · 1 line
2.27.0
PATCH v3 9/14 net/mlx5: flow meter pool to manage meter object
In reply to Li ZhangAdd ASO flow meter pool to manage meter object
--- drivers/net/mlx5/mlx5.c | 2 +- drivers/net/mlx5/mlx5.h | 207 ++++++++++++- drivers/net/mlx5/mlx5_flow.c | 70 ++++- drivers/net/mlx5/mlx5_flow.h | 196 +++---------- drivers/net/mlx5/mlx5_flow_dv.c | 203 ++++++++++++- drivers/net/mlx5/mlx5_flow_meter.c | 450 ++++++++++++++++++----------- 6 files changed, 769 insertions(+), 359 deletions(-)
drivers/net/mlx5/mlx5.c +1 -1
@@ -280,7 +280,7 @@ static const struct mlx5_indexed_pool_config mlx5_ipool_cfg[] = {* for meter idx, so not set grow_trunk to avoid meter index * not jump continually. */ - .size = sizeof(struct mlx5_flow_meter), + .size = sizeof(struct mlx5_legacy_flow_meter), .trunk_size = 64, .need_lock = 1, .release_mem_en = 1,
drivers/net/mlx5/mlx5.h +200 -7
258 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow.c +54 -16
143 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow.h +48 -148
256 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_dv.c +189 -14
309 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_meter.c +277 -173
723 lines not on this page · raw message
Signature · 1 line
2.27.0
PATCH v3 10/14 net/mlx5: initialize the flow meter ASO SQ
In reply to Li ZhangInitialize the flow meter ASO SQ WQEs with
all the constant data that should not be updated
per enqueue operation.
---
drivers/net/mlx5/linux/mlx5_os.c | 17 ++++
drivers/net/mlx5/meson.build | 2 +-
drivers/net/mlx5/mlx5.c | 78 ++++++++++++++-
drivers/net/mlx5/mlx5.h | 22 +++--
drivers/net/mlx5/mlx5_flow.h | 4 +-
.../mlx5/{mlx5_flow_age.c => mlx5_flow_aso.c} | 96 ++++++++++++++++---
drivers/net/mlx5/mlx5_flow_dv.c | 7 +-
drivers/net/mlx5/mlx5_flow_meter.c | 7 +-
8 files changed, 201 insertions(+), 32 deletions(-)
rename drivers/net/mlx5/{mlx5_flow_age.c => mlx5_flow_aso.c} (85%)drivers/net/mlx5/linux/mlx5_os.c +17 -0
@@ -818,6 +818,7 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,char name[RTE_ETH_NAME_MAX_LEN ];int own_domain_id =0 ;uint16_t port_id; +uint32_t log_obj_size;#ifdef HAVE_MLX5DV_DR_DEVX_PORT struct mlx5dv_devx_port devx_port = { .comp_mask =0 };#endif
@@ -1288,6 +1289,22 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, priv->mtr_color_reg); } } +if (config->hca_attr.qos.sup && + config->hca_attr.qos.flow_meter_aso_sup) { + log_obj_size = +rte_log2_u32 (MLX5_ASO_MTRS_PER_POOL >>1 ); +if (log_obj_size >= + config->hca_attr.qos.log_meter_aso_granularity && + log_obj_size <= + config->hca_attr.qos.log_meter_aso_max_alloc) { + sh->meter_aso_en =1 ; + err =mlx5_aso_flow_mtrs_mng_init (priv); +if (err) { + err = -err; + goto error; + } + } + }#endif #ifdef HAVE_MLX5_DR_CREATE_ACTION_ASO if (config->hca_attr.flow_hit_aso &&
drivers/net/mlx5/meson.build +1 -1
@@ -15,7 +15,7 @@ sources = files( 'mlx5_flow.c', 'mlx5_flow_meter.c', 'mlx5_flow_dv.c', - 'mlx5_flow_age.c', + 'mlx5_flow_aso.c', 'mlx5_mac.c', 'mlx5_mr.c', 'mlx5_rss.c',
drivers/net/mlx5/mlx5.c +75 -3
114 lines not on this page · raw message
drivers/net/mlx5/mlx5.h +15 -7
@@ -482,8 +482,13 @@ struct mlx5_aso_devx_mr { };struct mlx5_aso_sq_elem { -struct mlx5_aso_age_pool *pool; -uint16_t burst_size; +union { +struct { +struct mlx5_aso_age_pool *pool; +uint16_t burst_size; + }; +struct mlx5_aso_mtr *mtr; + }; };struct mlx5_aso_sq {
@@ -755,7 +760,6 @@ struct mlx5_aso_mtr_pools_mng {volatile uint16_t n_valid;/* Number of valid pools. */ uint16_t n;/* Number of pools. */ rte_spinlock_t mtrsl;/* The ASO flow meter free list lock. */ -struct mlx5_l3t_tbl *mtr_idx_tbl;/* Meter index lookup table. */ struct aso_meter_list meters;/* Free ASO flow meter list. */ struct mlx5_aso_sq sq;/*SQ using by ASO flow meter. */ struct mlx5_aso_mtr_pool **pools;/* ASO flow meter pool array. */
@@ -1186,6 +1190,7 @@ struct mlx5_priv {uint8_t mtr_color_reg;/* Meter color match REG_C. */ struct mlx5_mtr_profiles flow_meter_profiles;/* MTR profile list. */ struct mlx5_legacy_flow_meters flow_meters;/* MTR list. */ +struct mlx5_l3t_tbl *mtr_idx_tbl;/* Meter index lookup table. */ uint8_t skip_default_rss_reta;/* Skip configuration of default reta. */ uint8_t fdb_def_rule;/* Whether fdb jump to table 1 is configured. */ struct mlx5_mp_id mp_id;/* ID of a multi-process process */
@@ -1249,6 +1254,7 @@ int mlx5_hairpin_cap_get(struct rte_eth_dev *dev,bool mlx5_flex_parser_ecpri_exist (struct rte_eth_dev *dev);int mlx5_flex_parser_ecpri_alloc (struct rte_eth_dev *dev);int mlx5_flow_aso_age_mng_init (struct mlx5_dev_ctx_shared *sh); +int mlx5_aso_flow_mtrs_mng_init (struct mlx5_priv *priv);/* mlx5_ethdev.c */
@@ -1519,9 +1525,11 @@ eth_tx_burst_t mlx5_select_tx_function(struct rte_eth_dev *dev);/* mlx5_flow_aso.c */ -int mlx5_aso_queue_init (struct mlx5_dev_ctx_shared *sh); -int mlx5_aso_queue_start (struct mlx5_dev_ctx_shared *sh); -int mlx5_aso_queue_stop (struct mlx5_dev_ctx_shared *sh); -void mlx5_aso_queue_uninit (struct mlx5_dev_ctx_shared *sh); +int mlx5_aso_queue_init (struct mlx5_dev_ctx_shared *sh, +enum mlx5_access_aso_opc_mod aso_opc_mod); +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);#endif /* RTE_PMD_MLX5_H_ */
drivers/net/mlx5/mlx5_flow.h +2 -2
@@ -827,8 +827,8 @@ struct mlx5_flow {#define MLX5_FLOW_METER_DISABLE 0#define MLX5_FLOW_METER_ENABLE 1 -#define MLX5_ASO_CQE_RESPONSE_DELAY 10 -#define MLX5_MTR_POLL_CQE_TIMES 100000u +#define MLX5_ASO_WQE_CQE_RESPONSE_DELAY 10u +#define MLX5_MTR_POLL_WQE_CQE_TIMES 100000u#define MLX5_MAN_WIDTH 8/* Legacy Meter parameter structure. */
drivers/net/mlx5/mlx5_flow_aso.c renamed from drivers/net/mlx5/mlx5_flow_age.c +82 -14
156 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_dv.c +6 -1
@@ -5961,6 +5961,11 @@ flow_dv_mtr_container_resize(struct rte_eth_dev *dev) rte_errno =ENOMEM ;return -ENOMEM ; } +if (!mtrmng->n) +if (mlx5_aso_queue_init (priv->sh,ASO_OPC_MOD_POLICER )) { +mlx5_free (pools); +return -ENOMEM ; + }if (old_pools)memcpy (pools, old_pools, mtrmng->n *sizeof (struct mlx5_aso_mtr_pool *));
@@ -10818,7 +10823,7 @@ flow_dv_aso_age_pools_resize(struct rte_eth_dev *dev)mlx5_free (old_pools); }else {/* First ASO flow hit allocation - starting ASO data-path. */ -int ret =mlx5_aso_queue_start (priv->sh); +int ret =mlx5_aso_flow_hit_queue_poll_start (priv->sh);if (ret) {mlx5_free (pools);
drivers/net/mlx5/mlx5_flow_meter.c +3 -4
@@ -811,7 +811,6 @@ mlx5_flow_meter_destroy(struct rte_eth_dev *dev, uint32_t meter_id, struct rte_mtr_error *error) {struct mlx5_priv *priv = dev->data->dev_private; -struct mlx5_aso_mtr_pools_mng *mtrmng = priv->sh->mtrmng;struct mlx5_flow_meter_info *fm;const struct rte_flow_attr attr = { .ingress =1 ,
@@ -836,7 +835,7 @@ mlx5_flow_meter_destroy(struct rte_eth_dev *dev, uint32_t meter_id,RTE_MTR_ERROR_TYPE_UNSPECIFIED , NULL, "Meter object is being used.");if (priv->sh->meter_aso_en) { -if (mlx5_l3t_clear_entry (mtrmng->mtr_idx_tbl, meter_id)) +if (mlx5_l3t_clear_entry (priv->mtr_idx_tbl, meter_id))return -rte_mtr_error_set (error,EBUSY ,RTE_MTR_ERROR_TYPE_UNSPECIFIED ,NULL ,"Fail to delete ASO Meter in index table." );
@@ -1302,7 +1301,7 @@ mlx5_flow_meter_find(struct mlx5_priv *priv, uint32_t meter_id,rte_spinlock_unlock (&mtrmng->mtrsl);return NULL ; } -if (mlx5_l3t_get_entry (mtrmng->mtr_idx_tbl, meter_id, &data) || +if (mlx5_l3t_get_entry (priv->mtr_idx_tbl, meter_id, &data) || !data.dword) {rte_spinlock_unlock (&mtrmng->mtrsl);return NULL ;
@@ -1310,7 +1309,7 @@ mlx5_flow_meter_find(struct mlx5_priv *priv, uint32_t meter_id,if (mtr_idx) *mtr_idx = data.dword; aso_mtr =mlx5_aso_meter_by_idx (priv, data.dword); -mlx5_l3t_clear_entry (mtrmng->mtr_idx_tbl, meter_id); +mlx5_l3t_clear_entry (priv->mtr_idx_tbl, meter_id);if (meter_id == aso_mtr->fm.meter_id) {rte_spinlock_unlock (&mtrmng->mtrsl);return &aso_mtr->fm;
Signature · 1 line
2.27.0
PATCH v3 11/14 net/mlx5: aso flow meter send WQE and CQE handle
In reply to Li ZhangASO flow meter send WQE and CQE handle functions
--- drivers/net/mlx5/mlx5.h | 4 + drivers/net/mlx5/mlx5_flow_aso.c | 183 ++++++++++++++++++++++++++++- drivers/net/mlx5/mlx5_flow_meter.c | 143 +++++++++++++--------- 3 files changed, 274 insertions(+), 56 deletions(-)
drivers/net/mlx5/mlx5.h +4 -0
@@ -1531,5 +1531,9 @@ 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, +struct mlx5_aso_mtr *mtr); +int mlx5_aso_mtr_wait (struct mlx5_dev_ctx_shared *sh, +struct mlx5_aso_mtr *mtr);#endif /* RTE_PMD_MLX5_H_ */
drivers/net/mlx5/mlx5_flow_aso.c +182 -1
192 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_meter.c +88 -55
221 lines not on this page · raw message
Signature · 1 line
2.27.0
PATCH v3 12/14 net/mlx5: add support of ASO meter action
In reply to Li ZhangWhen ASO action is available, use it as the meter action
--- drivers/net/mlx5/linux/mlx5_os.c | 7 ++- drivers/net/mlx5/mlx5.c | 12 ++++ drivers/net/mlx5/mlx5.h | 7 ++- drivers/net/mlx5/mlx5_flow.c | 74 +++++++++++++++++------ drivers/net/mlx5/mlx5_flow_dv.c | 29 +++++++-- drivers/net/mlx5/mlx5_flow_meter.c | 97 +++++++++++++++++++----------- 6 files changed, 164 insertions(+), 62 deletions(-)
drivers/net/mlx5/linux/mlx5_os.c +4 -3
@@ -818,7 +818,6 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,char name[RTE_ETH_NAME_MAX_LEN ];int own_domain_id =0 ;uint16_t port_id; -uint32_t log_obj_size;#ifdef HAVE_MLX5DV_DR_DEVX_PORT struct mlx5dv_devx_port devx_port = { .comp_mask =0 };#endif
@@ -1254,7 +1253,9 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,"required for coalescing is %d bytes" , config->hca_attr.lro_min_mss_size); } -#if defined(HAVE_MLX5DV_DR ) && defined(HAVE_MLX5_DR_CREATE_ACTION_FLOW_METER ) +#if defined(HAVE_MLX5DV_DR ) && \ + (defined(HAVE_MLX5_DR_CREATE_ACTION_FLOW_METER ) || \ + defined(HAVE_MLX5_DR_CREATE_ACTION_ASO ))if (config->hca_attr.qos.sup && config->hca_attr.qos.flow_meter_old && config->dv_flow_en) {
@@ -1291,7 +1292,7 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, }if (config->hca_attr.qos.sup && config->hca_attr.qos.flow_meter_aso_sup) { - log_obj_size = +uint32_t log_obj_size =rte_log2_u32 (MLX5_ASO_MTRS_PER_POOL >>1 ); if (log_obj_size >= config->hca_attr.qos.log_meter_aso_granularity &&
drivers/net/mlx5/mlx5.c +12 -0
@@ -607,11 +607,23 @@ mlx5_aso_flow_mtrs_mng_close(struct mlx5_dev_ctx_shared *sh)struct mlx5_aso_mtr_pool *mtr_pool;struct mlx5_aso_mtr_pools_mng *mtrmng = sh->mtrmng;uint32_t idx; +#ifdef HAVE_MLX5_DR_CREATE_ACTION_ASO +struct mlx5_aso_mtr *aso_mtr; +int i; +#endif /* HAVE_MLX5_DR_CREATE_ACTION_ASO */ mlx5_aso_queue_uninit (sh,ASO_OPC_MOD_POLICER ); idx = mtrmng->n_valid;while (idx--) { mtr_pool = mtrmng->pools[idx]; +#ifdef HAVE_MLX5_DR_CREATE_ACTION_ASO +for (i =0 ; i <MLX5_ASO_MTRS_PER_POOL ; i++) { + aso_mtr = &mtr_pool->mtrs[i]; +if (aso_mtr->fm.meter_action) +claim_zero (mlx5_glue->destroy_flow_action + (aso_mtr->fm.meter_action)); + } +#endif /* HAVE_MLX5_DR_CREATE_ACTION_ASO */ claim_zero (mlx5_devx_cmd_destroy (mtr_pool->devx_obj)); mtrmng->n_valid--;
drivers/net/mlx5/mlx5.h +4 -3
@@ -625,8 +625,6 @@ struct mlx5_meter_domains_infos {/**< Counters for green rule. */ void *drop_count;/**< Counters for green rule. */ -void *meter_action; -/**< Flow meter action. */ };/* Meter parameter structure. */
@@ -689,6 +687,8 @@ struct mlx5_flow_meter_info {/**< Use count. */ struct mlx5_indexed_pool *flow_ipool;/**< Index pool for flow id. */ +void *meter_action; +/**< Flow meter action. */ };/* RFC2697 parameter structure. */
@@ -1478,7 +1478,8 @@ int mlx5_flow_meter_attach(struct mlx5_priv *priv,struct mlx5_flow_meter_info *fm, const struct rte_flow_attr *attr, struct rte_flow_error *error); -void mlx5_flow_meter_detach (struct mlx5_flow_meter_info *fm); +void mlx5_flow_meter_detach (struct mlx5_priv *priv, +struct mlx5_flow_meter_info *fm);/* mlx5_os.c */ struct rte_pci_driver ;
drivers/net/mlx5/mlx5_flow.c +56 -18
135 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_dv.c +25 -4
@@ -4890,9 +4890,11 @@ mlx5_flow_validate_action_meter(struct rte_eth_dev *dev,return rte_flow_error_set (error,EINVAL ,RTE_FLOW_ERROR_TYPE_ACTION ,NULL ,"Meter not found" ); -if (fm->ref_cnt && (!(fm->transfer == attr->transfer || +/* aso meter can always be shared by different domains */ +if (fm->ref_cnt && !priv->sh->meter_aso_en && + !(fm->transfer == attr->transfer || (!fm->ingress && !attr->ingress && attr->egress) || - (!fm->egress && !attr->egress && attr->ingress)))) + (!fm->egress && !attr->egress && attr->ingress)))return rte_flow_error_set (error,EINVAL ,RTE_FLOW_ERROR_TYPE_ACTION ,NULL , "Flow attributes are either invalid "
@@ -6095,6 +6097,25 @@ flow_dv_mtr_alloc(struct rte_eth_dev *dev) struct mlx5_aso_mtr_pool, mtrs[mtr_free->offset]); mtr_idx =MLX5_MAKE_MTR_IDX (pool->index, mtr_free->offset); +if (!mtr_free->fm.meter_action) { +#ifdef HAVE_MLX5_DR_CREATE_ACTION_ASO +struct rte_flow_error error; +uint8_t reg_id; + + reg_id =mlx5_flow_get_reg_id (dev,MLX5_MTR_COLOR ,0 , &error); + mtr_free->fm.meter_action = + mlx5_glue->dv_create_flow_action_aso + (priv->sh->rx_domain, + pool->devx_obj->obj, + mtr_free->offset, + (1 <<MLX5_FLOW_COLOR_GREEN ), + reg_id -REG_C_0 ); +#endif /* HAVE_MLX5_DR_CREATE_ACTION_ASO */ +if (!mtr_free->fm.meter_action) { +flow_dv_aso_mtr_release_to_pool (dev, mtr_idx); +return 0 ; + } + }return mtr_idx; }
@@ -11579,7 +11600,7 @@ flow_dv_translate(struct rte_eth_dev *dev, NULL, "Failed to get meter in flow.");/* Set the meter action. */ dev_flow->dv.actions[actions_n++] = - wks->fm->mfts->meter_action; + wks->fm->meter_action; action_flags |=MLX5_FLOW_ACTION_METER ;break ;case RTE_FLOW_ACTION_TYPE_SET_IPV4_DSCP :
@@ -12741,7 +12762,7 @@ flow_dv_destroy(struct rte_eth_dev *dev, struct rte_flow *flow)if (flow->meter) { fm =flow_dv_meter_find_by_idx (priv, flow->meter);if (fm) -mlx5_flow_meter_detach (fm); +mlx5_flow_meter_detach (priv, fm); flow->meter =0 ; }if (flow->age)
drivers/net/mlx5/mlx5_flow_meter.c +63 -34
141 lines not on this page · raw message
Signature · 1 line
2.27.0
PATCH v3 13/14 net/mlx5: make ASO meter queue thread-safe
In reply to Li ZhangSynchronize ASO meter queue accesses from
different threads using a spinlock.
--- drivers/net/mlx5/mlx5.h | 1 + drivers/net/mlx5/mlx5_flow_aso.c | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-)
drivers/net/mlx5/mlx5.h +1 -0
@@ -493,6 +493,7 @@ struct mlx5_aso_sq_elem {struct mlx5_aso_sq {uint16_t log_desc_n; +rte_spinlock_t sqsl;struct mlx5_aso_cq cq;struct mlx5_devx_sq sq_obj;volatile uint64_t *uar_addr;
drivers/net/mlx5/mlx5_flow_aso.c +13 -3
@@ -274,6 +274,7 @@ mlx5_aso_sq_create(void *ctx, struct mlx5_aso_sq *sq, int socket, sq->tail =0 ; sq->sqn = sq->sq_obj.sq->id; sq->uar_addr =mlx5_os_get_devx_uar_reg_addr (uar); +rte_spinlock_init (&sq->sqsl);return 0 ; error:mlx5_aso_destroy_sq (sq);
@@ -665,12 +666,15 @@ mlx5_aso_mtr_sq_enqueue_single(struct mlx5_aso_sq *sq,struct mlx5_flow_meter_info *fm =NULL ;uint16_t size =1 << sq->log_desc_n;uint16_t mask = size -1 ; -uint16_t res = size - (uint16_t )(sq->head - sq->tail); +uint16_t res;uint32_t dseg_idx =0 ;struct mlx5_aso_mtr_pool *pool =NULL ; +rte_spinlock_lock (&sq->sqsl); + res = size - (uint16_t )(sq->head - sq->tail);if (unlikely (!res)) {DRV_LOG (ERR ,"Fail: SQ is full and no free WQE to send" ); +rte_spinlock_unlock (&sq->sqsl);return 0 ; } wqe = &sq->sq_obj.aso_wqes[sq->head & mask];
@@ -707,6 +711,7 @@ mlx5_aso_mtr_sq_enqueue_single(struct mlx5_aso_sq *sq,rte_wmb (); *sq->uar_addr = *(volatile uint64_t *)wqe;/* Assume 64 bit ARCH. */ rte_wmb (); +rte_spinlock_unlock (&sq->sqsl);return 1 ; }
@@ -737,12 +742,16 @@ mlx5_aso_mtr_completion_handle(struct mlx5_aso_sq *sq)const unsigned int mask = cq_size -1 ;uint32_t idx;uint32_t next_idx = cq->cq_ci & mask; -const uint16_t max = (uint16_t )(sq->head - sq->tail); +uint16_t max;uint16_t n =0 ;int ret; -if (unlikely (!max)) +rte_spinlock_lock (&sq->sqsl); + max = (uint16_t )(sq->head - sq->tail); +if (unlikely (!max)) { +rte_spinlock_unlock (&sq->sqsl);return ; + } do { idx = next_idx; next_idx = (cq->cq_ci + 1) & mask;
@@ -769,6 +778,7 @@ mlx5_aso_mtr_completion_handle(struct mlx5_aso_sq *sq)rte_io_wmb (); cq->cq_obj.db_rec[0 ] =rte_cpu_to_be_32 (cq->cq_ci); } +rte_spinlock_unlock (&sq->sqsl); }/**
Signature · 1 line
2.27.0
PATCH v3 14/14 net/mlx5: allow multiple flow tables on the same level
In reply to Li ZhangThe driver devices support creation of multiple flow tables. Jump action can be used in order to move the packet steering to different flow table.
Table 0 is always the root table for packet steering.
Jumping between tables may cause endless loops in steering mechanism, that's why each table has level attribute,
the driver sub-system may not allow jumping to table with equal or lower level than the current table.
Currently, in the driver, the table ID and level are always identical.
Allow multiple flow table creation with the same level attribute.
This patch adds the table id in flow table data entry, while allocates the flow table, if the table level is same but the different table id, the new table will be allocated with new table object id. It supports 4M multiple flow tables on the same level.
--- drivers/net/mlx5/mlx5.c | 9 ++-- drivers/net/mlx5/mlx5.h | 10 ++-- drivers/net/mlx5/mlx5_flow.c | 17 ++++--- drivers/net/mlx5/mlx5_flow.h | 12 +++-- drivers/net/mlx5/mlx5_flow_dv.c | 84 +++++++++++++++++++-------------- 5 files changed, 79 insertions(+), 53 deletions(-)
drivers/net/mlx5/mlx5.c +6 -3
@@ -1269,9 +1269,12 @@ mlx5_alloc_table_hash_list(struct mlx5_priv *priv __rte_unused)* because DV expect to see them even if they cannot be created by * RDMA-CORE. */ -if (!flow_dv_tbl_resource_get (dev,0 ,0 ,0 ,0 ,NULL ,0 ,1 , &error) || - !flow_dv_tbl_resource_get (dev,0 ,1 ,0 ,0 ,NULL ,0 ,1 , &error) || - !flow_dv_tbl_resource_get (dev,0 ,0 ,1 ,0 ,NULL ,0 ,1 , &error)) { +if (!flow_dv_tbl_resource_get (dev,0 ,0 ,0 ,0 , +NULL ,0 ,1 ,0 , &error) || + !flow_dv_tbl_resource_get (dev,0 ,1 ,0 ,0 , +NULL ,0 ,1 ,0 , &error) || + !flow_dv_tbl_resource_get (dev,0 ,0 ,1 ,0 , +NULL ,0 ,1 ,0 , &error)) { err =ENOMEM ; goto error; }
drivers/net/mlx5/mlx5.h +6 -4
@@ -770,10 +770,12 @@ struct mlx5_aso_mtr_pools_mng {union mlx5_flow_tbl_key {struct {/* Table ID should be at the lowest address. */ -uint32_t table_id;/**< ID of the table. */ -uint16_t dummy;/**< Dummy table for DV API. */ -uint8_t domain;/**< 1 - FDB, 0 - NIC TX/RX. */ -uint8_t direction;/**< 1 - egress, 0 - ingress. */ +uint32_t level;/**< Level of the table. */ +uint32_t id:22 ;/**< ID of the table. */ +uint32_t dummy:1 ;/**< Dummy table for DV API. */ +uint32_t is_fdb:1 ;/**< 1 - FDB, 0 - NIC TX/RX. */ +uint32_t is_egress:1 ;/**< 1 - egress, 0 - ingress. */ +uint32_t reserved:7 ;/**< must be zero for comparison. */ };uint64_t v64;/**< full 64bits value of key */ };
drivers/net/mlx5/mlx5_flow.c +11 -6
@@ -4342,6 +4342,9 @@ flow_create_split_inner(struct rte_eth_dev *dev, dev_flow->handle->mark =1 ;if (sub_flow) *sub_flow = dev_flow; +#ifdef HAVE_IBV_FLOW_DV_SUPPORT + dev_flow->dv.table_id = flow_split_info->table_id; +#endif return flow_drv_translate (dev, dev_flow, attr, items, actions, error); }
@@ -5489,8 +5492,7 @@ flow_create_split_sample(struct rte_eth_dev *dev, struct mlx5_flow_tbl_data_entry, tbl); sfx_attr.group = sfx_attr.transfer ? - (sfx_tbl_data->table_id -1 ) : - sfx_tbl_data->table_id; + (sfx_tbl_data->level -1 ) : sfx_tbl_data->level; }else {MLX5_ASSERT (attr->transfer); sfx_attr.group = jump_table;
@@ -5690,7 +5692,8 @@ flow_list_create(struct rte_eth_dev *dev, uint32_t *list, .skip_scale = 0, .flow_idx = 0, .prefix_mark = 0, - .prefix_layers = 0 + .prefix_layers = 0, + .table_id = 0 };int ret;
@@ -7743,10 +7746,12 @@ tunnel_mark_decode(struct rte_eth_dev *dev, uint32_t mark)union tunnel_offload_mark mbits = { .val = mark };union mlx5_flow_tbl_key table_key = { { - .table_id =tunnel_id_to_flow_tbl (mbits.table_id), + .level =tunnel_id_to_flow_tbl (mbits.table_id), + .id =0 , + .reserved =0 , .dummy =0 , - .domain = !!mbits.transfer, - .direction =0 , + .is_fdb = !!mbits.transfer, + .is_egress =0 , } }; he =mlx5_hlist_lookup (sh->flow_tbls, table_key.v64,NULL );
drivers/net/mlx5/mlx5_flow.h +8 -4
@@ -565,8 +565,9 @@ struct mlx5_flow_tbl_data_entry { uint32_t is_egress:1; /**< Egress table. */ uint32_t is_transfer:1; /**< Transfer table. */ uint32_t dummy:1; /**< DR table. */ - uint32_t reserve:27; /**< Reserved to future using. */ -uint32_t table_id;/**< Table ID. */ + uint32_t id:22; /**< Table ID. */ + uint32_t reserve:5; /**< Reserved to future using. */ +uint32_t level;/**< Table level. */ };/* Sub rdma-core actions list. */
@@ -700,6 +701,7 @@ struct mlx5_flow_handle {/** Device flow structure only for DV flow creation. */ struct mlx5_flow_dv_workspace {uint32_t group;/**< The group index. */ +uint32_t table_id;/**< Flow table identifier. */ uint8_t transfer;/**< 1 if the flow is E-Switch flow. */ int actions_n;/**< number of actions. */ void *actions[MLX5_DV_MAX_NUMBER_OF_ACTIONS ];/**< Action list. */
@@ -1060,6 +1062,7 @@ struct mlx5_flow_split_info {uint32_t flow_idx;/**< This memory pool index to the flow. */ uint32_t prefix_mark;/**< Prefix subflow mark flag. */ uint64_t prefix_layers;/**< Prefix subflow layers. */ +uint32_t table_id;/**< Flow table identifier. */ }; typedef int (*mlx5_flow_validate_t)(struct rte_eth_dev *dev,
@@ -1411,9 +1414,10 @@ int flow_dv_tbl_match_cb(struct mlx5_hlist *list,void flow_dv_tbl_remove_cb (struct mlx5_hlist *list,struct mlx5_hlist_entry *entry);struct mlx5_flow_tbl_resource *flow_dv_tbl_resource_get (struct rte_eth_dev *dev, -uint32_t table_id,uint8_t egress,uint8_t transfer, +uint32_t table_level,uint8_t egress,uint8_t transfer,bool external,const struct mlx5_flow_tunnel *tunnel, -uint32_t group_id,uint8_t dummy,struct rte_flow_error *error); +uint32_t group_id,uint8_t dummy, +uint32_t table_id,struct rte_flow_error *error);struct mlx5_hlist_entry *flow_dv_tag_create_cb (struct mlx5_hlist *list,uint64_t key,void *cb_ctx);
drivers/net/mlx5/mlx5_flow_dv.c +48 -36
205 lines not on this page · raw message
Signature · 1 line
2.27.0
v4 cover Add ASO meter support in MLX5 PMD
In reply to Li ZhangTo support more meters and better performance,
MLX HW provide ASO flow meter.
It can expose millions of ASO flow meter context's in HW. This ASO object can allocate the large bulk meter objects. This patch set implement the ASO flow meter for mlx5 driver. MLX5 PMD driver will be responsible for ASO flow meter manage to HW.
V2: Fix compile error issue (mlx5_glue->destroy_flow_action)
V3: Fix comments.
V4: Fix comments and add Acked
Li Zhang (10):
net/mlx5: optimize meter statistics
common/mlx5: add definitions for ASO flow meter common/mlx5: add read ASO flow meter HCA capability common/mlx5: add DevX API to create ASO flow meter object net/mlx5: flow meter pool to manage meter object net/mlx5: initialize the flow meter ASO SQ net/mlx5: aso flow meter send WQE and CQE handle net/mlx5: add support of ASO meter action net/mlx5: make ASO meter queue thread-safe net/mlx5: allow multiple flow tables on the same level
Shun Hao (3):
common/mlx5: add color register idle bits definition net/mlx5: fix meter statistics
net/mlx5: use mask for meter register setting
Suanming Mou (1):
net/mlx5: support three level table walk
doc/guides/nics/mlx5.rst | 6 +
drivers/common/mlx5/mlx5_devx_cmds.c | 68 ++
drivers/common/mlx5/mlx5_devx_cmds.h | 26 +-
drivers/common/mlx5/mlx5_prm.h | 81 +-
drivers/common/mlx5/version.map | 1 +
drivers/net/mlx5/linux/mlx5_os.c | 20 +-
drivers/net/mlx5/meson.build | 2 +-
drivers/net/mlx5/mlx5.c | 98 +-
drivers/net/mlx5/mlx5.h | 258 +++++-
drivers/net/mlx5/mlx5_flow.c | 334 +++++--
drivers/net/mlx5/mlx5_flow.h | 212 ++---
.../mlx5/{mlx5_flow_age.c => mlx5_flow_aso.c} | 289 +++++-
drivers/net/mlx5/mlx5_flow_dv.c | 792 +++++++++++-----
drivers/net/mlx5/mlx5_flow_meter.c | 873 ++++++++++++------
drivers/net/mlx5/mlx5_utils.h | 90 ++
15 files changed, 2320 insertions(+), 830 deletions(-)
rename drivers/net/mlx5/{mlx5_flow_age.c => mlx5_flow_aso.c} (65%)Signature · 1 line
2.27.0
PATCH v4 1/14 net/mlx5: support three level table walk
From: Suanming Mou <[email protected]>
This commit adds table entry walk for the three level table.
--- drivers/net/mlx5/mlx5_utils.h | 90 +++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+)
drivers/net/mlx5/mlx5_utils.h +90 -0
@@ -834,6 +834,91 @@ int32_t mlx5_l3t_clear_entry(struct mlx5_l3t_tbl *tbl, uint32_t idx);int32_t mlx5_l3t_set_entry (struct mlx5_l3t_tbl *tbl,uint32_t idx,union mlx5_l3t_data *data); +static inline void * +mlx5_l3t_get_next (struct mlx5_l3t_tbl *tbl,uint32_t *pos) +{ +struct mlx5_l3t_level_tbl *g_tbl, *m_tbl; +uint32_t i, j, k, g_start, m_start, e_start; +uint32_t idx = *pos; +void *e_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; + +if (!tbl) +return NULL ; + g_tbl = tbl->tbl; +if (!g_tbl) +return NULL ; + g_start = (idx >>MLX5_L3T_GT_OFFSET ) &MLX5_L3T_GT_MASK ; + m_start = (idx >>MLX5_L3T_MT_OFFSET ) &MLX5_L3T_MT_MASK ; + e_start = idx &MLX5_L3T_ET_MASK ; +for (i = g_start; i <MLX5_L3T_GT_SIZE ; i++) { + m_tbl = g_tbl->tbl[i]; +if (!m_tbl) { +/* Jump to new table, reset the sub table start. */ + m_start =0 ; + e_start =0 ; +continue ; + } +for (j = m_start; j <MLX5_L3T_MT_SIZE ; j++) { +if (!m_tbl->tbl[j]) { +/* +* Jump to new table, reset the sub table +* start. +*/ + e_start =0 ; +continue ; + } + e_tbl = m_tbl->tbl[j]; +switch (tbl->type) { +case MLX5_L3T_TYPE_WORD : + w_e_tbl = (struct mlx5_l3t_entry_word *)e_tbl; +for (k = e_start; k <MLX5_L3T_ET_SIZE ; k++) { +if (!w_e_tbl->entry[k].data) +continue ; + *pos = (i <<MLX5_L3T_GT_OFFSET ) | + (j <<MLX5_L3T_MT_OFFSET ) | k; +return (void *)&w_e_tbl->entry[k].data; + } +break ; +case MLX5_L3T_TYPE_DWORD : + dw_e_tbl = (struct mlx5_l3t_entry_dword *)e_tbl; +for (k = e_start; k <MLX5_L3T_ET_SIZE ; k++) { +if (!dw_e_tbl->entry[k].data) +continue ; + *pos = (i <<MLX5_L3T_GT_OFFSET ) | + (j <<MLX5_L3T_MT_OFFSET ) | k; +return (void *)&dw_e_tbl->entry[k].data; + } +break ; +case MLX5_L3T_TYPE_QWORD : + qw_e_tbl = (struct mlx5_l3t_entry_qword *)e_tbl; +for (k = e_start; k <MLX5_L3T_ET_SIZE ; k++) { +if (!qw_e_tbl->entry[k].data) +continue ; + *pos = (i <<MLX5_L3T_GT_OFFSET ) | + (j <<MLX5_L3T_MT_OFFSET ) | k; +return (void *)&qw_e_tbl->entry[k].data; + } +break ; +default : + ptr_e_tbl = (struct mlx5_l3t_entry_ptr *)e_tbl; +for (k = e_start; k <MLX5_L3T_ET_SIZE ; k++) { +if (!ptr_e_tbl->entry[k].data) +continue ; + *pos = (i <<MLX5_L3T_GT_OFFSET ) | + (j <<MLX5_L3T_MT_OFFSET ) | k; +return ptr_e_tbl->entry[k].data; + } +break ; + } + } + } +return NULL ; +} +/* * Macros for linked list based on indexed memory. * Example data structure:
@@ -909,4 +994,9 @@ struct { \ idx = (elem)->field.next, (elem) = \ (idx) ? mlx5_ipool_get(pool, idx) : NULL) +#define MLX5_L3T_FOREACH (tbl, idx, entry) \ + for (idx = 0, (entry) = mlx5_l3t_get_next((tbl), &idx); \ + (entry); \ + idx++, (entry) = mlx5_l3t_get_next((tbl), &idx)) +#endif /* RTE_PMD_MLX5_UTILS_H_ */
Signature · 1 line
2.27.0
PATCH v4 2/14 common/mlx5: add color register idle bits definition
In reply to Li ZhangFrom: Shun Hao <[email protected]>
8 bits are used for meter color in meter register. When the meter register can be shared, the rest 24 bits can be used by others. This adds the definination for the 24 bits that can be shared.
--- drivers/common/mlx5/mlx5_prm.h | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/common/mlx5/mlx5_prm.h +6 -0
@@ -3382,6 +3382,12 @@ enum {/* The bits meter color use. */ #define MLX5_MTR_COLOR_BITS 8 +/* The bit size of one register. */ +#define MLX5_REG_BITS 32 + +/* Idle bits for non-color usage in color register. */ +#define MLX5_MTR_IDLE_BITS_IN_COLOR_REG (MLX5_REG_BITS - MLX5_MTR_COLOR_BITS) +/* Length mode of dynamic flex parser graph node. */ enum mlx5_parse_graph_node_len_mode {MLX5_GRAPH_NODE_LEN_FIXED =0x0 ,
Signature · 1 line
2.27.0
PATCH v4 3/14 net/mlx5: fix meter statistics
In reply to Li ZhangFrom: Shun Hao <[email protected]>
Currently, packets after meter will be steered to a global policer table,
which includes green/red color rules for every meter, so as to have counter statistics of each color in every meter.
There's a bug that all the rules in global policer table are matching only color criteria, so all packets will be counted to one meter only, and other meter statistics are always zero.
This patch does these:
1. The rules in policer table matches both meter index and color, so packet after meter could be counted to the correct meter counter.
2. The meter index and flow index are now sharing the available register bits dynamically. Meter index starts from lsb, and flow index starts from msb.
--- drivers/net/mlx5/mlx5.c | 7 +- drivers/net/mlx5/mlx5.h | 15 +- drivers/net/mlx5/mlx5_flow.c | 183 +++++++---- drivers/net/mlx5/mlx5_flow.h | 40 +-- drivers/net/mlx5/mlx5_flow_dv.c | 489 ++++++++++++++++++----------- drivers/net/mlx5/mlx5_flow_meter.c | 53 +++- 6 files changed, 496 insertions(+), 291 deletions(-)
drivers/net/mlx5/mlx5.c +5 -2
@@ -275,10 +275,13 @@ static const struct mlx5_indexed_pool_config mlx5_ipool_cfg[] = { }, #endif [MLX5_IPOOL_MTR ] = { +/** +* The ipool index should grow continually from small to big, +* for meter idx, so not set grow_trunk to avoid meter index +* not jump continually. +*/ .size =sizeof (struct mlx5_flow_meter ), .trunk_size =64 , - .grow_trunk =3 , - .grow_shift =2 , .need_lock =1 , .release_mem_en =1 , .malloc = mlx5_malloc,
drivers/net/mlx5/mlx5.h +9 -6
@@ -944,9 +944,9 @@ struct mlx5_priv { unsigned int representor:1; /* Device is a port representor. */ unsigned int master:1; /* Device is a E-Switch master. */ unsigned int txpp_en:1; /* Tx packet pacing enabled. */ + unsigned int sampler_en:1; /* Whether support sampler. */ unsigned int mtr_en:1; /* Whether support meter. */ unsigned int mtr_reg_share:1; /* Whether support meter REG_C share. */ - unsigned int sampler_en:1; /* Whether support sampler. */uint16_t domain_id;/* Switch domain identifier. */ uint16_t vport_id;/* Associated VF vport index (if any). */ uint32_t vport_meta_tag;/* Used for vport index match ove VF LAG. */
@@ -1003,6 +1003,10 @@ struct mlx5_priv {uint32_t rss_shared_actions;/* RSS shared actions. */ struct mlx5_devx_obj *q_counters;/* DevX queue counter object. */ uint32_t counter_set_id;/* Queue counter ID to set in DevX objects. */ +uint8_t max_mtr_bits; +/* Indicate how many bits are used by meter id at the most. */ +uint8_t max_mtr_flow_bits; +/* Indicate how many bits are used by meter flow id at the most. */ };#define PORT_ID (priv) ((priv)->dev_data->port_id)
@@ -1271,11 +1275,10 @@ int mlx5_pmd_socket_init(void);int mlx5_flow_meter_ops_get (struct rte_eth_dev *dev,void *arg);struct mlx5_flow_meter *mlx5_flow_meter_find (struct mlx5_priv *priv,uint32_t meter_id); -struct mlx5_flow_meter *mlx5_flow_meter_attach - (struct mlx5_priv *priv, -uint32_t meter_id, -const struct rte_flow_attr *attr, -struct rte_flow_error *error); +int mlx5_flow_meter_attach (struct mlx5_priv *priv, +struct mlx5_flow_meter *fm, +const struct rte_flow_attr *attr, +struct rte_flow_error *error);void mlx5_flow_meter_detach (struct mlx5_flow_meter *fm);/* mlx5_os.c */
drivers/net/mlx5/mlx5_flow.c +120 -63
330 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow.h +22 -18
@@ -79,7 +79,7 @@ enum mlx5_feature_name {MLX5_APP_TAG ,MLX5_COPY_MARK ,MLX5_MTR_COLOR , -MLX5_MTR_SFX , +MLX5_MTR_ID , MLX5_ASO_FLOW_HIT, };
@@ -655,7 +655,8 @@ struct mlx5_flow_handle {uint64_t layers;/**< Bit-fields of present layers, see MLX5_FLOW_LAYER_*. */ void *drv_flow;/**< pointer to driver flow object. */ - uint32_t split_flow_id:28; /**< Sub flow unique match flow id. */ + uint32_t split_flow_id:27; /**< Sub flow unique match flow id. */ + uint32_t is_meter_flow_id:1; /**< Indate if flow_id is for meter. */ uint32_t mark:1; /**< Metadate rxq mark flag. */ uint32_t fate_action:3; /**< Fate action type. */union {
@@ -842,14 +843,16 @@ struct mlx5_meter_domain_info {/**< Meter table. */ struct mlx5_flow_tbl_resource *sfx_tbl;/**< Meter suffix table. */ -void *any_matcher; -/**< Meter color not match default criteria. */ -void *color_matcher; -/**< Meter color match criteria. */ +struct mlx5_flow_dv_matcher *drop_matcher; +/**< Matcher for Drop. */ +struct mlx5_flow_dv_matcher *color_matcher; +/**< Matcher for Color. */ void *jump_actn;/**< Meter match action. */ -void *policer_rules[RTE_MTR_DROPPED +1 ]; -/**< Meter policer for the match. */ +void *green_rule; +/**< Meter green rule. */ +void *drop_rule; +/**< Meter drop rule. */ };/* Meter table set for TX RX FDB. */
@@ -862,10 +865,10 @@ struct mlx5_meter_domains_infos {/**< RX meter table. */ struct mlx5_meter_domain_info transfer;/**< FDB meter table. */ -void *drop_actn; -/**< Drop action as not matched. */ -void *count_actns[RTE_MTR_DROPPED +1 ]; -/**< Counters for match and unmatched statistics. */ +void *green_count; +/**< Counters for green rule. */ +void *drop_count; +/**< Counters for green rule. */ uint32_t fmp[MLX5_ST_SZ_DW (flow_meter_parameters)];/**< Flow meter parameter. */ size_t fmp_size;
@@ -928,6 +931,8 @@ struct mlx5_flow_meter {/**< Meter state. */ uint32_t shared:1;/**< Meter shared or not. */ +struct mlx5_indexed_pool *flow_ipool; +/**< Index pool for flow id. */ };/* RFC2697 parameter structure. */
@@ -1166,6 +1171,7 @@ struct mlx5_flow_workspace {struct mlx5_flow_rss_desc rss_desc;uint32_t rssq_num;/* Allocated queue num in rss_desc. */ uint32_t flow_idx;/* Intermediate device flow index. */ +struct mlx5_flow_meter *fm;/* Pointer to the meter in flow. */ };struct mlx5_flow_split_info {
@@ -1206,8 +1212,7 @@ typedef int (*mlx5_flow_query_t)(struct rte_eth_dev *dev,void *data, struct rte_flow_error *error);typedef struct mlx5_meter_domains_infos *(*mlx5_flow_create_mtr_tbls_t ) - (struct rte_eth_dev *dev, -const struct mlx5_flow_meter *fm); + (struct rte_eth_dev *dev);typedef int (*mlx5_flow_destroy_mtr_tbls_t )(struct rte_eth_dev *dev,struct mlx5_meter_domains_infos *tbls);typedef int (*mlx5_flow_create_policer_rules_t )
@@ -1270,7 +1275,7 @@ struct mlx5_flow_driver_ops {mlx5_flow_query_t query;mlx5_flow_create_mtr_tbls_t create_mtr_tbls;mlx5_flow_destroy_mtr_tbls_t destroy_mtr_tbls; -mlx5_flow_create_policer_rules_t create_policer_rules; +mlx5_flow_create_policer_rules_t prepare_policer_rules;mlx5_flow_destroy_policer_rules_t destroy_policer_rules;mlx5_flow_counter_alloc_t counter_alloc;mlx5_flow_counter_free_t counter_free;
@@ -1470,11 +1475,10 @@ int mlx5_flow_validate_item_ecpri(const struct rte_flow_item *item,const struct rte_flow_item_ecpri *acc_mask, struct rte_flow_error *error);struct mlx5_meter_domains_infos *mlx5_flow_create_mtr_tbls - (struct rte_eth_dev *dev, -const struct mlx5_flow_meter *fm); + (struct rte_eth_dev *dev);int mlx5_flow_destroy_mtr_tbls (struct rte_eth_dev *dev,struct mlx5_meter_domains_infos *tbl); -int mlx5_flow_create_policer_rules (struct rte_eth_dev *dev, +int mlx5_flow_prepare_policer_rules (struct rte_eth_dev *dev,struct mlx5_flow_meter *fm,const struct rte_flow_attr *attr); int mlx5_flow_destroy_policer_rules(struct rte_eth_dev *dev,
drivers/net/mlx5/mlx5_flow_dv.c +303 -186
704 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_meter.c +37 -16
117 lines not on this page · raw message
Signature · 1 line
2.27.0
PATCH v4 4/14 net/mlx5: optimize meter statistics
In reply to Li ZhangMeter statistics are each policer action each counter. Totally 4 counters per each meter.
It causes cache missed
and lead to data forwarding performance low.
To optimize it, support pass counter for green
and drop counter for red.
Totally two counters per each meter.
Also use the global drop statistics for
all meter drop action.
limitations as below:
1. It does not support yellow counter and return 0.
2. All the meter colors with drop action will be counted only by the global drop statistics.
3. Red color must be with drop action.
--- doc/guides/nics/mlx5.rst | 6 + drivers/net/mlx5/mlx5_flow.h | 24 ++-- drivers/net/mlx5/mlx5_flow_dv.c | 8 +- drivers/net/mlx5/mlx5_flow_meter.c | 217 +++++++++++++++++++---------- 4 files changed, 173 insertions(+), 82 deletions(-)
doc/guides/nics/mlx5.rst +6 -0
@@ -399,6 +399,12 @@ Limitations - Hairpin between two ports could only manual binding and explicit Tx flow mode. For single port hairpin, all the combinations of auto/manual binding and explicit/implicit Tx flow mode could be supported. - Hairpin in switchdev SR-IOV mode is not supported till now. +- Meter: + - All the meter colors with drop action will be counted only by the global drop statistics. + - Green color is not supported with drop action. + - Yellow detection is not supported. + - Red color must be with drop action. + Statistics ----------
drivers/net/mlx5/mlx5_flow.h +16 -8
@@ -831,10 +831,10 @@ struct mlx5_flow {/* Meter policer statistics */ struct mlx5_flow_policer_stats { -uint32_t cnt[RTE_COLORS +1 ]; -/**< Color counter, extra for drop. */ -uint64_t stats_mask; -/**< Statistics mask for the colors. */ +uint32_t pass_cnt; +/**< Color counter for pass. */ +uint32_t drop_cnt; +/**< Color counter for drop. */ };/* Meter table structure. */
@@ -892,10 +892,18 @@ struct mlx5_flow_meter {/** Policer actions (per meter output color). */ enum rte_mtr_policer_action action[RTE_COLORS ]; -/** Set of stats counters to be enabled. -* @see enum rte_mtr_stats_type -*/ -uint64_t stats_mask; + uint32_t green_bytes:1; +/** Set green bytes stats to be enabled. */ + uint32_t green_pkts:1; +/** Set green packets stats to be enabled. */ + uint32_t red_bytes:1; +/** Set red bytes stats to be enabled. */ + uint32_t red_pkts:1; +/** Set red packets stats to be enabled. */ + uint32_t bytes_dropped:1; +/** Set bytes dropped stats to be enabled. */ + uint32_t pkts_dropped:1; +/** Set packets dropped stats to be enabled. */ /**< Rule applies to ingress traffic. */ uint32_t ingress:1;
drivers/net/mlx5/mlx5_flow_dv.c +4 -4
@@ -13829,17 +13829,17 @@ flow_dv_prepare_policer_rules(struct rte_eth_dev *dev,int ret;/* Get the statistics counters for green/drop. */ -if (fm->policer_stats.cnt[RTE_COLOR_GREEN ]) { +if (fm->policer_stats.pass_cnt) { cnt =flow_dv_counter_get_by_idx (dev, - fm->policer_stats.cnt[RTE_COLOR_GREEN ], + fm->policer_stats.pass_cnt,NULL ); mtb->green_count = cnt->action; }else { mtb->green_count =NULL ; } -if (fm->policer_stats.cnt[RTE_MTR_DROPPED ]) { +if (fm->policer_stats.drop_cnt) { cnt =flow_dv_counter_get_by_idx (dev, - fm->policer_stats.cnt[RTE_MTR_DROPPED ], + fm->policer_stats.drop_cnt,NULL ); mtb->drop_count = cnt->action; }else {
drivers/net/mlx5/mlx5_flow_meter.c +147 -70
321 lines not on this page · raw message
Signature · 1 line
2.27.0
PATCH v4 5/14 net/mlx5: use mask for meter register setting
In reply to Li ZhangFrom: Shun Hao <[email protected]>
ASO meter feature may require to locate the flow context tag action after the ASO action.
When color register is shared by meter_id/flow_id, it's like:
Bits[0-7] A meter color value set by the HW. Bits[8-31] A flow id and meter id set by SW.
Currently the tag action for meter writes all the bits of the meter register, so it will potentially overwrite meter color when ASO meter action is before the tag action.
Set only 24-MSB-bits of meter register in the meter tag action.
--- drivers/net/mlx5/mlx5_flow.c | 28 ++++++++++++++++++---------- drivers/net/mlx5/mlx5_flow.h | 2 ++ drivers/net/mlx5/mlx5_flow_dv.c | 2 ++ 3 files changed, 22 insertions(+), 10 deletions(-)
drivers/net/mlx5/mlx5_flow.c +18 -10
@@ -4258,9 +4258,11 @@ flow_hairpin_split(struct rte_eth_dev *dev,rte_memcpy (actions_rx, actions,sizeof (struct rte_flow_action )); actions_rx++; set_tag = (void *)actions_rx; - set_tag->id =mlx5_flow_get_reg_id (dev,MLX5_HAIRPIN_RX ,0 ,NULL ); + *set_tag = (struct mlx5_rte_flow_action_set_tag ) { + .id =mlx5_flow_get_reg_id (dev,MLX5_HAIRPIN_RX ,0 ,NULL ), + .data = flow_id, + };MLX5_ASSERT (set_tag->id >REG_NON ); - set_tag->data = flow_id; tag_action->conf = set_tag;/* Create Tx item list. */ rte_memcpy (actions_tx, actions,sizeof (struct rte_flow_action ));
@@ -4496,6 +4498,14 @@ flow_meter_split_prep(struct rte_eth_dev *dev, set_tag = (struct mlx5_rte_flow_action_set_tag *)actions_pre; tag_item_spec = (struct mlx5_rte_flow_item_tag *)sfx_items; tag_item_mask = tag_item_spec +1 ; +/* Both flow_id and meter_id share the same register. */ + *set_tag = (struct mlx5_rte_flow_action_set_tag ) { + .id = (enum modify_reg )mlx5_flow_get_reg_id (dev,MLX5_MTR_ID , +0 , error), + .offset = mtr_id_offset, + .length = mtr_reg_bits, + .data = fm->idx, + };/* * The color Reg bits used by flow_id are growing from * msb to lsb, so must do bit reverse for flow_id val in RegC.
@@ -4503,13 +4513,9 @@ flow_meter_split_prep(struct rte_eth_dev *dev,for (shift =0 ; shift < flow_id_bits; shift++) flow_id_reversed = (flow_id_reversed <<1 ) | ((flow_id >> shift) &0x1 ); -/* Both flow_id and meter_id share the same register. */ - set_tag->id =mlx5_flow_get_reg_id (dev,MLX5_MTR_ID ,0 , error); - set_tag->data = - (fm->idx | (flow_id_reversed << (mtr_reg_bits - flow_id_bits))) - << mtr_id_offset; + set_tag->data |= flow_id_reversed << (mtr_reg_bits - flow_id_bits); tag_item_spec->id = set_tag->id; - tag_item_spec->data = set_tag->data; + tag_item_spec->data = set_tag->data << mtr_id_offset; tag_item_mask->data =UINT32_MAX << mtr_id_offset; tag_action->type = (enum rte_flow_action_type )MLX5_RTE_FLOW_ACTION_TYPE_TAG ;
@@ -4896,10 +4902,12 @@ flow_sample_split_prep(struct rte_eth_dev *dev, ret =mlx5_flow_get_reg_id (dev,MLX5_APP_TAG ,0 , error);if (ret <0 )return ret; - set_tag->id = ret;mlx5_ipool_malloc (priv->sh->ipool [MLX5_IPOOL_RSS_EXPANTION_FLOW_ID ], &tag_id); - set_tag->data = tag_id; + *set_tag = (struct mlx5_rte_flow_action_set_tag ) { + .id = ret, + .data = tag_id, + };/* Prepare the suffix subflow items. */ tag_spec = (void *)(sfx_items +SAMPLE_SUFFIX_ITEM ); tag_spec->data = tag_id;
drivers/net/mlx5/mlx5_flow.h +2 -0
@@ -55,6 +55,8 @@ struct mlx5_rte_flow_item_tag {/* Modify selected register. */ struct mlx5_rte_flow_action_set_tag {enum modify_reg id; +uint8_t offset; +uint8_t length;uint32_t data; };
drivers/net/mlx5/mlx5_flow_dv.c +2 -0
@@ -964,6 +964,8 @@ flow_dv_convert_action_set_reg actions[i] = (struct mlx5_modification_cmd ) { .action_type =MLX5_MODIFICATION_TYPE_SET , .field = reg_to_field[conf->id], + .offset = conf->offset, + .length = conf->length, }; actions[i].data0 =rte_cpu_to_be_32 (actions[i].data0); actions[i].data1 =rte_cpu_to_be_32 (conf->data);
Signature · 1 line
2.27.0
PATCH v4 6/14 common/mlx5: add definitions for ASO flow meter
In reply to Li ZhangThis patch adds different PRM definitions, related to ASO flow meter feature, in MLX5 PMD code.
--- drivers/common/mlx5/mlx5_prm.h | 75 ++++++++++++++++++++++++++++++++-- 1 file changed, 71 insertions(+), 4 deletions(-)
drivers/common/mlx5/mlx5_prm.h +71 -4
@@ -1129,6 +1129,8 @@ enum { (1ULL << MLX5_GENERAL_OBJ_TYPE_FLEX_PARSE_GRAPH)#define MLX5_GENERAL_OBJ_TYPES_CAP_FLOW_HIT_ASO \ (1ULL << MLX5_GENERAL_OBJ_TYPE_FLOW_HIT_ASO) +#define MLX5_GENERAL_OBJ_TYPES_CAP_FLOW_METER_ASO \ + (1ULL << MLX5_GENERAL_OBJ_TYPE_FLOW_METER_ASO)#define MLX5_GENERAL_OBJ_TYPES_CAP_GENEVE_TLV_OPT \ (1ULL << MLX5_OBJ_TYPE_GENEVE_TLV_OPT)
@@ -1514,7 +1516,15 @@ struct mlx5_ifc_qos_cap_bits {u8 reserved_at_c0[0x10 ];u8 max_qos_para_vport[0x10 ];u8 max_tsar_bw_share[0x20 ]; -u8 reserved_at_100[0x6e8 ]; +u8 nic_element_type[0x10 ]; +u8 nic_tsar_type[0x10 ]; +u8 reserved_at_120[0x3 ]; +u8 log_meter_aso_granularity[0x5 ]; +u8 reserved_at_128[0x3 ]; +u8 log_meter_aso_max_alloc[0x5 ]; +u8 reserved_at_130[0x3 ]; +u8 log_max_num_meter_aso[0x5 ]; +u8 reserved_at_138[0x6b0 ]; };struct mlx5_ifc_per_protocol_networking_offload_caps_bits {
@@ -2284,6 +2294,8 @@ struct mlx5_ifc_flow_meter_parameters_bits {u8 eir_mantissa[0x8 ];u8 reserved_at_8[0x60 ];// 14h-1Ch }; +#define MLX5_IFC_FLOW_METER_PARAM_MASK UINT64_C(0x80FFFFFF) +#define MLX5_IFC_FLOW_METER_DISABLE_CBS_CIR_VAL 0x14BF00C8enum {MLX5_CQE_SIZE_64B =0x0 ,
@@ -2411,6 +2423,7 @@ enum {MLX5_GENERAL_OBJ_TYPE_VIRTQ =0x000d ,MLX5_GENERAL_OBJ_TYPE_VIRTIO_Q_COUNTERS =0x001c ,MLX5_GENERAL_OBJ_TYPE_FLEX_PARSE_GRAPH =0x0022 , +MLX5_GENERAL_OBJ_TYPE_FLOW_METER_ASO =0x0024 , MLX5_GENERAL_OBJ_TYPE_FLOW_HIT_ASO = 0x0025, };
@@ -2419,7 +2432,9 @@ struct mlx5_ifc_general_obj_in_cmd_hdr_bits {u8 reserved_at_10[0x20 ];u8 obj_type[0x10 ];u8 obj_id[0x20 ]; -u8 reserved_at_60[0x20 ]; +u8 reserved_at_60[0x3 ]; +u8 log_obj_range[0x5 ]; +u8 reserved_at_58[0x18 ]; };struct mlx5_ifc_general_obj_out_cmd_hdr_bits {
@@ -2565,6 +2580,18 @@ struct mlx5_ifc_create_flow_hit_aso_in_bits {struct mlx5_ifc_flow_hit_aso_bits flow_hit_aso; }; +struct mlx5_ifc_flow_meter_aso_bits { +u8 modify_field_select[0x40 ]; +u8 reserved_at_40[0x48 ]; +u8 access_pd[0x18 ]; +u8 reserved_at_a0[0x160 ]; +u8 parameters[0x200 ]; +}; + +struct mlx5_ifc_create_flow_meter_aso_in_bits { +struct mlx5_ifc_general_obj_in_cmd_hdr_bits hdr; +struct mlx5_ifc_flow_meter_aso_bits flow_meter_aso; +};enum mlx5_access_aso_opc_mod {ASO_OPC_MOD_IPSEC =0x0 ,ASO_OPC_MOD_CONNECTION_TRACKING =0x1 ,
@@ -2618,11 +2645,51 @@ struct mlx5_aso_cseg {uint64_t data_mask; } __rte_packed; +/* A meter data segment - 2 per ASO WQE. */ +struct mlx5_aso_mtr_dseg { +uint32_t v_bo_sc_bbog_mm; +/* +* bit 31: valid, 30: bucket overflow, 28-29: start color, +* 27: both buckets on green, 24-25: meter mode. +*/ +uint32_t reserved; +uint32_t cbs_cir; +/* +* bit 24-28: cbs_exponent, bit 16-23 cbs_mantissa, +* bit 8-12: cir_exponent, bit 0-7 cir_mantissa. +*/ +uint32_t c_tokens; +uint32_t ebs_eir; +/* +* bit 24-28: ebs_exponent, bit 16-23 ebs_mantissa, +* bit 8-12: eir_exponent, bit 0-7 eir_mantissa. +*/ +uint32_t e_tokens; +uint64_t timestamp; +} __rte_packed; + +#define ASO_DSEG_VALID_OFFSET 31 +#define ASO_DSEG_BO_OFFSET 30 +#define ASO_DSEG_SC_OFFSET 28 +#define ASO_DSEG_CBS_EXP_OFFSET 24 +#define ASO_DSEG_CBS_MAN_OFFSET 16 +#define ASO_DSEG_CIR_EXP_MASK 0x1F +#define ASO_DSEG_CIR_EXP_OFFSET 8 +#define ASO_DSEG_EBS_EXP_OFFSET 24 +#define ASO_DSEG_EBS_MAN_OFFSET 16 +#define ASO_DSEG_EXP_MASK 0x1F +#define ASO_DSEG_MAN_MASK 0xFF +#define MLX5_ASO_WQE_DSEG_SIZE 0x40 +#define MLX5_ASO_METERS_PER_WQE 2 +#define MLX5_ASO_MTRS_PER_POOL 128 -/* ASO WQE Data segment. */ +/* ASO WQE data segment. */ struct mlx5_aso_dseg { -uint8_t data[MLX5_ASO_WQE_DSEG_SIZE ]; +union { +uint8_t data[MLX5_ASO_WQE_DSEG_SIZE ]; +struct mlx5_aso_mtr_dseg mtrs[MLX5_ASO_METERS_PER_WQE ]; + }; } __rte_packed;/* ASO WQE. */
Signature · 1 line
2.27.0
PATCH v4 7/14 common/mlx5: add read ASO flow meter HCA capability
In reply to Li ZhangRead and store the device capability of FLOW_METER_ASO general object, using the DevX API.
--- drivers/common/mlx5/mlx5_devx_cmds.c | 14 ++++++++++++++ drivers/common/mlx5/mlx5_devx_cmds.h | 8 ++++++++ 2 files changed, 22 insertions(+)
drivers/common/mlx5/mlx5_devx_cmds.c +14 -0
@@ -696,6 +696,9 @@ mlx5_devx_cmd_query_hca_attr(void *ctx, attr->max_geneve_tlv_option_data_len =MLX5_GET (cmd_hca_cap, hcattr, max_geneve_tlv_option_data_len); attr->qos.sup =MLX5_GET (cmd_hca_cap, hcattr, qos); + attr->qos.flow_meter_aso_sup = !!(MLX5_GET64 (cmd_hca_cap, hcattr, + general_obj_types) & +MLX5_GENERAL_OBJ_TYPES_CAP_FLOW_METER_ASO ); attr->vdpa.valid = !!(MLX5_GET64 (cmd_hca_cap, hcattr, general_obj_types) &MLX5_GENERAL_OBJ_TYPES_CAP_VIRTQ_NET_Q );
@@ -783,6 +786,17 @@ mlx5_devx_cmd_query_hca_attr(void *ctx,MLX5_GET (qos_cap, hcattr, packet_pacing); attr->qos.wqe_rate_pp =MLX5_GET (qos_cap, hcattr, wqe_rate_pp); +if (attr->qos.flow_meter_aso_sup) { + attr->qos.log_meter_aso_granularity = +MLX5_GET (qos_cap, hcattr, + log_meter_aso_granularity); + attr->qos.log_meter_aso_max_alloc = +MLX5_GET (qos_cap, hcattr, + log_meter_aso_max_alloc); + attr->qos.log_max_num_meter_aso = +MLX5_GET (qos_cap, hcattr, + log_max_num_meter_aso); + } }if (attr->vdpa.valid)mlx5_devx_cmd_query_hca_vdpa_attr (ctx, &attr->vdpa);
drivers/common/mlx5/mlx5_devx_cmds.h +8 -0
@@ -50,10 +50,18 @@ struct mlx5_hca_qos_attr {* Using older driver versions, flow_meter_old can be 1 * while flow_meter is 0. */ + uint32_t flow_meter_aso_sup:1; +/* Whether FLOW_METER_ASO Object is supported. */ uint8_t log_max_flow_meter;/* Power of the maximum supported meters. */ uint8_t flow_meter_reg_c_ids;/* Bitmap of the reg_Cs available for flow meter to use. */ + uint32_t log_meter_aso_granularity:5; +/* Power of the minimum allocation granularity Object. */ + uint32_t log_meter_aso_max_alloc:5; +/* Power of the maximum allocation granularity Object. */ + uint32_t log_max_num_meter_aso:5; +/* Power of the maximum number of supported objects. */ };
Signature · 1 line
2.27.0
PATCH v4 8/14 common/mlx5: add DevX API to create ASO flow meter object
In reply to Li ZhangAdd DevX API to create ASO flow meter object.
--- drivers/common/mlx5/mlx5_devx_cmds.c | 54 ++++++++++++++++++++++++++++ drivers/common/mlx5/mlx5_devx_cmds.h | 18 +++++++++- drivers/common/mlx5/version.map | 1 + 3 files changed, 72 insertions(+), 1 deletion(-)
drivers/common/mlx5/mlx5_devx_cmds.c +54 -0
@@ -2159,6 +2159,60 @@ mlx5_devx_cmd_alloc_pd(void *ctx)return ppd; } +/** +* Create general object of type FLOW_METER_ASO using DevX API. +* +* @param[in] ctx +* Context returned from mlx5 open_device() glue function. +* @param [in] pd +* PD value to associate the FLOW_METER_ASO object with. +* @param [in] log_obj_size +* log_obj_size define to allocate number of 2 * meters +* in one FLOW_METER_ASO object. +* +* @return +* The DevX object created, NULL otherwise and rte_errno is set. +*/ +struct mlx5_devx_obj * +mlx5_devx_cmd_create_flow_meter_aso_obj (void *ctx,uint32_t pd, +uint32_t log_obj_size) +{ +uint32_t in[MLX5_ST_SZ_DW (create_flow_meter_aso_in)] = {0 }; +uint32_t out[MLX5_ST_SZ_DW (general_obj_out_cmd_hdr)]; +struct mlx5_devx_obj *flow_meter_aso_obj; +void *ptr; + + flow_meter_aso_obj =mlx5_malloc (MLX5_MEM_ZERO , +sizeof (*flow_meter_aso_obj), +0 ,SOCKET_ID_ANY ); +if (!flow_meter_aso_obj) { +DRV_LOG (ERR ,"Failed to allocate FLOW_METER_ASO object data" ); + rte_errno =ENOMEM ; +return NULL ; + } + ptr =MLX5_ADDR_OF (create_flow_meter_aso_in, in, hdr); +MLX5_SET (general_obj_in_cmd_hdr, ptr, opcode, +MLX5_CMD_OP_CREATE_GENERAL_OBJECT ); +MLX5_SET (general_obj_in_cmd_hdr, ptr, obj_type, +MLX5_GENERAL_OBJ_TYPE_FLOW_METER_ASO ); +MLX5_SET (general_obj_in_cmd_hdr, ptr, log_obj_range, + log_obj_size); + ptr =MLX5_ADDR_OF (create_flow_meter_aso_in, in, flow_meter_aso); +MLX5_SET (flow_meter_aso, ptr, access_pd, pd); + flow_meter_aso_obj->obj = mlx5_glue->devx_obj_create ( + ctx, in,sizeof (in), + out,sizeof (out)); +if (!flow_meter_aso_obj->obj) { + rte_errno = errno; +DRV_LOG (ERR ,"Failed to create FLOW_METER_ASO obj using DevX." ); +mlx5_free (flow_meter_aso_obj); +return NULL ; + } + flow_meter_aso_obj->id =MLX5_GET (general_obj_out_cmd_hdr, + out, obj_id); +return flow_meter_aso_obj; +} +/** * Create general object of type GENEVE TLV option using DevX API. *
drivers/common/mlx5/mlx5_devx_cmds.h +17 -1
@@ -554,7 +554,6 @@ int mlx5_devx_cmd_query_virtio_q_counters(struct mlx5_devx_obj *couners_obj,__rte_internal struct mlx5_devx_obj *mlx5_devx_cmd_create_flow_hit_aso_obj(void *ctx,uint32_t pd); -__rte_internal struct mlx5_devx_obj *mlx5_devx_cmd_alloc_pd(void *ctx);
@@ -566,4 +565,21 @@ struct mlx5_devx_obj *mlx5_devx_cmd_queue_counter_alloc(void *ctx);__rte_internal int mlx5_devx_cmd_queue_counter_query(struct mlx5_devx_obj *dcs, int clear,uint32_t *out_of_buffers); +/** +* Create general object of type FLOW_METER_ASO using DevX API.. +* +* @param[in] ctx +* Device context. +* @param [in] pd +* PD value to associate the FLOW_METER_ASO object with. +* @param [in] log_obj_size +* log_obj_size define to allocate number of 2 * meters +* in one FLOW_METER_ASO object. +* +* @return +* The DevX object created, NULL otherwise and rte_errno is set. +*/ +__rte_internal +struct mlx5_devx_obj *mlx5_devx_cmd_create_flow_meter_aso_obj(void *ctx, +uint32_t pd,uint32_t log_obj_size);#endif /* RTE_PMD_MLX5_DEVX_CMDS_H_ */
drivers/common/mlx5/version.map +1 -0
@@ -25,6 +25,7 @@ INTERNAL { mlx5_devx_cmd_create_virtio_q_counters; # WINDOWS_NO_EXPORT mlx5_devx_cmd_create_virtq; mlx5_devx_cmd_create_flow_hit_aso_obj; + mlx5_devx_cmd_create_flow_meter_aso_obj; mlx5_devx_cmd_create_geneve_tlv_option; mlx5_devx_cmd_destroy; mlx5_devx_cmd_flow_counter_alloc;
Signature · 1 line
2.27.0
PATCH v4 9/14 net/mlx5: flow meter pool to manage meter object
In reply to Li ZhangAdd ASO flow meter pool to manage meter object
--- drivers/net/mlx5/mlx5.c | 2 +- drivers/net/mlx5/mlx5.h | 207 ++++++++++++- drivers/net/mlx5/mlx5_flow.c | 70 ++++- drivers/net/mlx5/mlx5_flow.h | 196 +++---------- drivers/net/mlx5/mlx5_flow_dv.c | 203 ++++++++++++- drivers/net/mlx5/mlx5_flow_meter.c | 450 ++++++++++++++++++----------- 6 files changed, 769 insertions(+), 359 deletions(-)
drivers/net/mlx5/mlx5.c +1 -1
@@ -280,7 +280,7 @@ static const struct mlx5_indexed_pool_config mlx5_ipool_cfg[] = {* for meter idx, so not set grow_trunk to avoid meter index * not jump continually. */ - .size = sizeof(struct mlx5_flow_meter), + .size = sizeof(struct mlx5_legacy_flow_meter), .trunk_size = 64, .need_lock = 1, .release_mem_en = 1,
drivers/net/mlx5/mlx5.h +200 -7
258 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow.c +54 -16
143 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow.h +48 -148
256 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_dv.c +189 -14
309 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_meter.c +277 -173
723 lines not on this page · raw message
Signature · 1 line
2.27.0
PATCH v4 10/14 net/mlx5: initialize the flow meter ASO SQ
In reply to Li ZhangInitialize the flow meter ASO SQ WQEs with
all the constant data that should not be updated
per enqueue operation.
---
drivers/net/mlx5/linux/mlx5_os.c | 17 ++++
drivers/net/mlx5/meson.build | 2 +-
drivers/net/mlx5/mlx5.c | 68 ++++++++++++-
drivers/net/mlx5/mlx5.h | 22 +++--
drivers/net/mlx5/mlx5_flow.h | 4 +-
.../mlx5/{mlx5_flow_age.c => mlx5_flow_aso.c} | 96 ++++++++++++++++---
drivers/net/mlx5/mlx5_flow_dv.c | 7 +-
drivers/net/mlx5/mlx5_flow_meter.c | 7 +-
8 files changed, 191 insertions(+), 32 deletions(-)
rename drivers/net/mlx5/{mlx5_flow_age.c => mlx5_flow_aso.c} (85%)drivers/net/mlx5/linux/mlx5_os.c +17 -0
@@ -818,6 +818,7 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,char name[RTE_ETH_NAME_MAX_LEN ];int own_domain_id =0 ;uint16_t port_id; +uint32_t log_obj_size;#ifdef HAVE_MLX5DV_DR_DEVX_PORT struct mlx5dv_devx_port devx_port = { .comp_mask =0 };#endif
@@ -1288,6 +1289,22 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, priv->mtr_color_reg); } } +if (config->hca_attr.qos.sup && + config->hca_attr.qos.flow_meter_aso_sup) { + log_obj_size = +rte_log2_u32 (MLX5_ASO_MTRS_PER_POOL >>1 ); +if (log_obj_size >= + config->hca_attr.qos.log_meter_aso_granularity && + log_obj_size <= + config->hca_attr.qos.log_meter_aso_max_alloc) { + sh->meter_aso_en =1 ; + err =mlx5_aso_flow_mtrs_mng_init (priv); +if (err) { + err = -err; + goto error; + } + } + }#endif #ifdef HAVE_MLX5_DR_CREATE_ACTION_ASO if (config->hca_attr.flow_hit_aso &&
drivers/net/mlx5/meson.build +1 -1
@@ -15,7 +15,7 @@ sources = files( 'mlx5_flow.c', 'mlx5_flow_meter.c', 'mlx5_flow_dv.c', - 'mlx5_flow_age.c', + 'mlx5_flow_aso.c', 'mlx5_mac.c', 'mlx5_mr.c', 'mlx5_rss.c',
drivers/net/mlx5/mlx5.c +65 -3
92 lines not on this page · raw message
drivers/net/mlx5/mlx5.h +15 -7
@@ -482,8 +482,13 @@ struct mlx5_aso_devx_mr { };struct mlx5_aso_sq_elem { -struct mlx5_aso_age_pool *pool; -uint16_t burst_size; +union { +struct { +struct mlx5_aso_age_pool *pool; +uint16_t burst_size; + }; +struct mlx5_aso_mtr *mtr; + }; };struct mlx5_aso_sq {
@@ -755,7 +760,6 @@ struct mlx5_aso_mtr_pools_mng {volatile uint16_t n_valid;/* Number of valid pools. */ uint16_t n;/* Number of pools. */ rte_spinlock_t mtrsl;/* The ASO flow meter free list lock. */ -struct mlx5_l3t_tbl *mtr_idx_tbl;/* Meter index lookup table. */ struct aso_meter_list meters;/* Free ASO flow meter list. */ struct mlx5_aso_sq sq;/*SQ using by ASO flow meter. */ struct mlx5_aso_mtr_pool **pools;/* ASO flow meter pool array. */
@@ -1186,6 +1190,7 @@ struct mlx5_priv {uint8_t mtr_color_reg;/* Meter color match REG_C. */ struct mlx5_mtr_profiles flow_meter_profiles;/* MTR profile list. */ struct mlx5_legacy_flow_meters flow_meters;/* MTR list. */ +struct mlx5_l3t_tbl *mtr_idx_tbl;/* Meter index lookup table. */ uint8_t skip_default_rss_reta;/* Skip configuration of default reta. */ uint8_t fdb_def_rule;/* Whether fdb jump to table 1 is configured. */ struct mlx5_mp_id mp_id;/* ID of a multi-process process */
@@ -1249,6 +1254,7 @@ int mlx5_hairpin_cap_get(struct rte_eth_dev *dev,bool mlx5_flex_parser_ecpri_exist (struct rte_eth_dev *dev);int mlx5_flex_parser_ecpri_alloc (struct rte_eth_dev *dev);int mlx5_flow_aso_age_mng_init (struct mlx5_dev_ctx_shared *sh); +int mlx5_aso_flow_mtrs_mng_init (struct mlx5_priv *priv);/* mlx5_ethdev.c */
@@ -1519,9 +1525,11 @@ eth_tx_burst_t mlx5_select_tx_function(struct rte_eth_dev *dev);/* mlx5_flow_aso.c */ -int mlx5_aso_queue_init (struct mlx5_dev_ctx_shared *sh); -int mlx5_aso_queue_start (struct mlx5_dev_ctx_shared *sh); -int mlx5_aso_queue_stop (struct mlx5_dev_ctx_shared *sh); -void mlx5_aso_queue_uninit (struct mlx5_dev_ctx_shared *sh); +int mlx5_aso_queue_init (struct mlx5_dev_ctx_shared *sh, +enum mlx5_access_aso_opc_mod aso_opc_mod); +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);#endif /* RTE_PMD_MLX5_H_ */
drivers/net/mlx5/mlx5_flow.h +2 -2
@@ -827,8 +827,8 @@ struct mlx5_flow {#define MLX5_FLOW_METER_DISABLE 0#define MLX5_FLOW_METER_ENABLE 1 -#define MLX5_ASO_CQE_RESPONSE_DELAY 10 -#define MLX5_MTR_POLL_CQE_TIMES 100000u +#define MLX5_ASO_WQE_CQE_RESPONSE_DELAY 10u +#define MLX5_MTR_POLL_WQE_CQE_TIMES 100000u#define MLX5_MAN_WIDTH 8/* Legacy Meter parameter structure. */
drivers/net/mlx5/mlx5_flow_aso.c renamed from drivers/net/mlx5/mlx5_flow_age.c +82 -14
156 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_dv.c +6 -1
@@ -5961,6 +5961,11 @@ flow_dv_mtr_container_resize(struct rte_eth_dev *dev) rte_errno =ENOMEM ;return -ENOMEM ; } +if (!mtrmng->n) +if (mlx5_aso_queue_init (priv->sh,ASO_OPC_MOD_POLICER )) { +mlx5_free (pools); +return -ENOMEM ; + }if (old_pools)memcpy (pools, old_pools, mtrmng->n *sizeof (struct mlx5_aso_mtr_pool *));
@@ -10818,7 +10823,7 @@ flow_dv_aso_age_pools_resize(struct rte_eth_dev *dev)mlx5_free (old_pools); }else {/* First ASO flow hit allocation - starting ASO data-path. */ -int ret =mlx5_aso_queue_start (priv->sh); +int ret =mlx5_aso_flow_hit_queue_poll_start (priv->sh);if (ret) {mlx5_free (pools);
drivers/net/mlx5/mlx5_flow_meter.c +3 -4
@@ -811,7 +811,6 @@ mlx5_flow_meter_destroy(struct rte_eth_dev *dev, uint32_t meter_id, struct rte_mtr_error *error) {struct mlx5_priv *priv = dev->data->dev_private; -struct mlx5_aso_mtr_pools_mng *mtrmng = priv->sh->mtrmng;struct mlx5_flow_meter_info *fm;const struct rte_flow_attr attr = { .ingress =1 ,
@@ -836,7 +835,7 @@ mlx5_flow_meter_destroy(struct rte_eth_dev *dev, uint32_t meter_id,RTE_MTR_ERROR_TYPE_UNSPECIFIED , NULL, "Meter object is being used.");if (priv->sh->meter_aso_en) { -if (mlx5_l3t_clear_entry (mtrmng->mtr_idx_tbl, meter_id)) +if (mlx5_l3t_clear_entry (priv->mtr_idx_tbl, meter_id))return -rte_mtr_error_set (error,EBUSY ,RTE_MTR_ERROR_TYPE_UNSPECIFIED ,NULL ,"Fail to delete ASO Meter in index table." );
@@ -1302,7 +1301,7 @@ mlx5_flow_meter_find(struct mlx5_priv *priv, uint32_t meter_id,rte_spinlock_unlock (&mtrmng->mtrsl);return NULL ; } -if (mlx5_l3t_get_entry (mtrmng->mtr_idx_tbl, meter_id, &data) || +if (mlx5_l3t_get_entry (priv->mtr_idx_tbl, meter_id, &data) || !data.dword) {rte_spinlock_unlock (&mtrmng->mtrsl);return NULL ;
@@ -1310,7 +1309,7 @@ mlx5_flow_meter_find(struct mlx5_priv *priv, uint32_t meter_id,if (mtr_idx) *mtr_idx = data.dword; aso_mtr =mlx5_aso_meter_by_idx (priv, data.dword); -mlx5_l3t_clear_entry (mtrmng->mtr_idx_tbl, meter_id); +mlx5_l3t_clear_entry (priv->mtr_idx_tbl, meter_id);if (meter_id == aso_mtr->fm.meter_id) {rte_spinlock_unlock (&mtrmng->mtrsl);return &aso_mtr->fm;
Signature · 1 line
2.27.0
Re: [dpdk-dev] [PATCH v4 10/14] net/mlx5: initialize the flow meter ASO SQ
Hi Li,
Quoted 35 lines
-----Original Message-----
From: Li Zhang <[email protected]>
Sent: Wednesday, April 14, 2021 5:58 AM
To: [email protected]; Ori Kam <[email protected]>; Slava Ovsiienko <[email protected]>; Matan Azrad <[email protected]>; Shahaf Shuler <[email protected]>
Cc: [email protected]; NBU-Contact-Thomas Monjalon <[email protected]>; Raslan Darawsheh <[email protected]>; Roni Bar Yanai <[email protected]>
Subject: [PATCH v4 10/14] net/mlx5: initialize the flow meter ASO SQInitialize the flow meter ASO SQ WQEs with all the constant data that should not be updated per enqueue operation.
Signed-off-by Li Zhang <[email protected]>Acked-by Matan Azrad <[email protected]>--- drivers/net/mlx5/linux/mlx5_os.c | 17 ++++ drivers/net/mlx5/meson.build | 2 +- drivers/net/mlx5/mlx5.c | 68 ++++++++++++- drivers/net/mlx5/mlx5.h | 22 +++-- drivers/net/mlx5/mlx5_flow.h | 4 +- .../mlx5/{mlx5_flow_age.c => mlx5_flow_aso.c} | 96 ++++++++++++++++--- drivers/net/mlx5/mlx5_flow_dv.c | 7 +- drivers/net/mlx5/mlx5_flow_meter.c | 7 +- 8 files changed, 191 insertions(+), 32 deletions(-) rename drivers/net/mlx5/{mlx5_flow_age.c => mlx5_flow_aso.c} (85%)drivers/net/mlx5/linux/mlx5_os.c +0
-0
drivers/net/mlx5/linux/mlx5_os.c mlx5_dev_spawn(struct rte_device *dpdk_dev, · line 821
Quoted 4 lines
drivers/net/mlx5/linux/mlx5_os.c +1
-0@@ -818,6 +818,7 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,char name[RTE_ETH_NAME_MAX_LEN ];int own_domain_id =0 ;uint16_t port_id; +uint32_t log_obj_size;
This would raise this compilation error:rivers/libtmp_rte_net_mlx5.a.p/net_mlx5_linux_mlx5_os.c.o -MF drivers/libtmp_rte_net_mlx5.a.p/net_mlx5_linux_mlx5_os.c.o.d -o drivers/libtmp_rte_net_mlx5.a.p/net_mlx5_linux_mlx5_os.c.o -c ../../root/dpdk/drivers/net/mlx5/linux/mlx5_os.c ../../root/dpdk/drivers/net/mlx5/linux/mlx5_os.c: In function 'mlx5_dev_spawn':../../root/dpdk/drivers/net/mlx5/linux/mlx5_os.c:823:11: error: unused variable 'log_obj_size' [-Werror=unused-variable]
uint32_t log_obj_size;
^~~~~~~~~~~~When compiling with rdma-core-33
Kindest regards
Raslan Darawsheh
Re: [dpdk-dev] [PATCH v4 10/14] net/mlx5: initialize the flow meter ASO SQ
Hi Raslan,
Thanks. I will fix in the next patch.
Regards,
Li Zhang
Quoted 67 lines
-----Original Message-----
From: Raslan Darawsheh <[email protected]>
Sent: Thursday, April 15, 2021 9:05 PM
To: Li Zhang <[email protected]>; [email protected]; Ori Kam <[email protected]>; Slava Ovsiienko <[email protected]>; Matan Azrad <[email protected]>; Shahaf Shuler <[email protected]>
Cc: [email protected]; NBU-Contact-Thomas Monjalon <[email protected]>; Roni Bar Yanai <[email protected]>
Subject: RE: [PATCH v4 10/14] net/mlx5: initialize the flow meter ASO SQHi Li,
Quoted 7 lines
-----Original Message-----
From: Li Zhang <[email protected]>
Sent: Wednesday, April 14, 2021 5:58 AM
To: [email protected]; Ori Kam <[email protected]>; Slava Ovsiienko <[email protected]>; Matan Azrad <[email protected]>; Shahaf Shuler <[email protected]>
Cc: [email protected]; NBU-Contact-Thomas MonjalonQuoted 9 lines
Raslan Darawsheh <[email protected]>; Roni Bar Yanai <[email protected]>
Subject: [PATCH v4 10/14] net/mlx5: initialize the flow meter ASO SQInitialize the flow meter ASO SQ WQEs with all the constant data that should not be updated per enqueue operation.
Signed-off-by Li Zhang <[email protected]>Acked-by Matan Azrad <[email protected]>Quoted 7 lines
--- drivers/net/mlx5/linux/mlx5_os.c | 17 ++++ drivers/net/mlx5/meson.build | 2 +- drivers/net/mlx5/mlx5.c | 68 ++++++++++++- drivers/net/mlx5/mlx5.h | 22 +++-- drivers/net/mlx5/mlx5_flow.h | 4 +- .../mlx5/{mlx5_flow_age.c => mlx5_flow_aso.c} | 96 ++++++++++++++++---
Quoted 11 lines
drivers/net/mlx5/mlx5_flow_dv.c | 7 +- drivers/net/mlx5/mlx5_flow_meter.c | 7 +- 8 files changed, 191 insertions(+), 32 deletions(-) rename
drivers/net/mlx5/{mlx5_flow_age.c=>mlx5_flow_aso.c} (85%)drivers/net/mlx5/linux/mlx5_os.c +0
-0drivers/net/mlx5/linux/mlx5_os.c mlx5_dev_spawn(struct rte_device *dpdk_dev, · line 821
Quoted 4 lines
drivers/net/mlx5/linux/mlx5_os.c +1
-0@@ -818,6 +818,7 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,char name[RTE_ETH_NAME_MAX_LEN ];int own_domain_id =0 ;uint16_t port_id; +uint32_t log_obj_size;This would raise this compilation error:
rivers/libtmp_rte_net_mlx5.a.p/net_mlx5_linux_mlx5_os.c.o-MFdrivers/libtmp_rte_net_mlx5.a.p/net_mlx5_linux_mlx5_os.c.o.d-odrivers/libtmp_rte_net_mlx5.a.p/net_mlx5_linux_mlx5_os.c.o- c../../root/dpdk/drivers/net/mlx5/linux/mlx5_os.c../../root/dpdk/drivers/net/mlx5/linux/mlx5_os.c: In function 'mlx5_dev_spawn':../../root/dpdk/drivers/net/mlx5/linux/mlx5_os.c:823:11: error: unused variable 'log_obj_size' [-Werror=unused-variable]uint32_t log_obj_size; ^~~~~~~~~~~~When compiling with rdma-core-33
Kindest regards
Raslan Darawsheh
PATCH v4 11/14 net/mlx5: aso flow meter send WQE and CQE handle
In reply to Li ZhangASO flow meter send WQE and CQE handle functions
--- drivers/net/mlx5/mlx5.h | 4 + drivers/net/mlx5/mlx5_flow_aso.c | 183 ++++++++++++++++++++++++++++- drivers/net/mlx5/mlx5_flow_meter.c | 143 +++++++++++++--------- 3 files changed, 274 insertions(+), 56 deletions(-)
drivers/net/mlx5/mlx5.h +4 -0
@@ -1531,5 +1531,9 @@ 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, +struct mlx5_aso_mtr *mtr); +int mlx5_aso_mtr_wait (struct mlx5_dev_ctx_shared *sh, +struct mlx5_aso_mtr *mtr);#endif /* RTE_PMD_MLX5_H_ */
drivers/net/mlx5/mlx5_flow_aso.c +182 -1
192 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_meter.c +88 -55
221 lines not on this page · raw message
Signature · 1 line
2.27.0
PATCH v4 12/14 net/mlx5: add support of ASO meter action
In reply to Li ZhangWhen ASO action is available, use it as the meter action
--- drivers/net/mlx5/linux/mlx5_os.c | 7 ++- drivers/net/mlx5/mlx5.c | 12 ++++ drivers/net/mlx5/mlx5.h | 7 ++- drivers/net/mlx5/mlx5_flow.c | 74 +++++++++++++++++------ drivers/net/mlx5/mlx5_flow_dv.c | 29 +++++++-- drivers/net/mlx5/mlx5_flow_meter.c | 97 +++++++++++++++++++----------- 6 files changed, 164 insertions(+), 62 deletions(-)
drivers/net/mlx5/linux/mlx5_os.c +4 -3
@@ -818,7 +818,6 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,char name[RTE_ETH_NAME_MAX_LEN ];int own_domain_id =0 ;uint16_t port_id; -uint32_t log_obj_size;#ifdef HAVE_MLX5DV_DR_DEVX_PORT struct mlx5dv_devx_port devx_port = { .comp_mask =0 };#endif
@@ -1254,7 +1253,9 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,"required for coalescing is %d bytes" , config->hca_attr.lro_min_mss_size); } -#if defined(HAVE_MLX5DV_DR ) && defined(HAVE_MLX5_DR_CREATE_ACTION_FLOW_METER ) +#if defined(HAVE_MLX5DV_DR ) && \ + (defined(HAVE_MLX5_DR_CREATE_ACTION_FLOW_METER ) || \ + defined(HAVE_MLX5_DR_CREATE_ACTION_ASO ))if (config->hca_attr.qos.sup && config->hca_attr.qos.flow_meter_old && config->dv_flow_en) {
@@ -1291,7 +1292,7 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, }if (config->hca_attr.qos.sup && config->hca_attr.qos.flow_meter_aso_sup) { - log_obj_size = +uint32_t log_obj_size =rte_log2_u32 (MLX5_ASO_MTRS_PER_POOL >>1 ); if (log_obj_size >= config->hca_attr.qos.log_meter_aso_granularity &&
drivers/net/mlx5/mlx5.c +12 -0
@@ -607,11 +607,23 @@ mlx5_aso_flow_mtrs_mng_close(struct mlx5_dev_ctx_shared *sh)struct mlx5_aso_mtr_pool *mtr_pool;struct mlx5_aso_mtr_pools_mng *mtrmng = sh->mtrmng;uint32_t idx; +#ifdef HAVE_MLX5_DR_CREATE_ACTION_ASO +struct mlx5_aso_mtr *aso_mtr; +int i; +#endif /* HAVE_MLX5_DR_CREATE_ACTION_ASO */ mlx5_aso_queue_uninit (sh,ASO_OPC_MOD_POLICER ); idx = mtrmng->n_valid;while (idx--) { mtr_pool = mtrmng->pools[idx]; +#ifdef HAVE_MLX5_DR_CREATE_ACTION_ASO +for (i =0 ; i <MLX5_ASO_MTRS_PER_POOL ; i++) { + aso_mtr = &mtr_pool->mtrs[i]; +if (aso_mtr->fm.meter_action) +claim_zero (mlx5_glue->destroy_flow_action + (aso_mtr->fm.meter_action)); + } +#endif /* HAVE_MLX5_DR_CREATE_ACTION_ASO */ claim_zero (mlx5_devx_cmd_destroy (mtr_pool->devx_obj)); mtrmng->n_valid--;
drivers/net/mlx5/mlx5.h +4 -3
@@ -625,8 +625,6 @@ struct mlx5_meter_domains_infos {/**< Counters for green rule. */ void *drop_count;/**< Counters for green rule. */ -void *meter_action; -/**< Flow meter action. */ };/* Meter parameter structure. */
@@ -689,6 +687,8 @@ struct mlx5_flow_meter_info {/**< Use count. */ struct mlx5_indexed_pool *flow_ipool;/**< Index pool for flow id. */ +void *meter_action; +/**< Flow meter action. */ };/* RFC2697 parameter structure. */
@@ -1478,7 +1478,8 @@ int mlx5_flow_meter_attach(struct mlx5_priv *priv,struct mlx5_flow_meter_info *fm, const struct rte_flow_attr *attr, struct rte_flow_error *error); -void mlx5_flow_meter_detach (struct mlx5_flow_meter_info *fm); +void mlx5_flow_meter_detach (struct mlx5_priv *priv, +struct mlx5_flow_meter_info *fm);/* mlx5_os.c */ struct rte_pci_driver ;
drivers/net/mlx5/mlx5_flow.c +56 -18
135 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_dv.c +25 -4
@@ -4890,9 +4890,11 @@ mlx5_flow_validate_action_meter(struct rte_eth_dev *dev,return rte_flow_error_set (error,EINVAL ,RTE_FLOW_ERROR_TYPE_ACTION ,NULL ,"Meter not found" ); -if (fm->ref_cnt && (!(fm->transfer == attr->transfer || +/* aso meter can always be shared by different domains */ +if (fm->ref_cnt && !priv->sh->meter_aso_en && + !(fm->transfer == attr->transfer || (!fm->ingress && !attr->ingress && attr->egress) || - (!fm->egress && !attr->egress && attr->ingress)))) + (!fm->egress && !attr->egress && attr->ingress)))return rte_flow_error_set (error,EINVAL ,RTE_FLOW_ERROR_TYPE_ACTION ,NULL , "Flow attributes are either invalid "
@@ -6095,6 +6097,25 @@ flow_dv_mtr_alloc(struct rte_eth_dev *dev) struct mlx5_aso_mtr_pool, mtrs[mtr_free->offset]); mtr_idx =MLX5_MAKE_MTR_IDX (pool->index, mtr_free->offset); +if (!mtr_free->fm.meter_action) { +#ifdef HAVE_MLX5_DR_CREATE_ACTION_ASO +struct rte_flow_error error; +uint8_t reg_id; + + reg_id =mlx5_flow_get_reg_id (dev,MLX5_MTR_COLOR ,0 , &error); + mtr_free->fm.meter_action = + mlx5_glue->dv_create_flow_action_aso + (priv->sh->rx_domain, + pool->devx_obj->obj, + mtr_free->offset, + (1 <<MLX5_FLOW_COLOR_GREEN ), + reg_id -REG_C_0 ); +#endif /* HAVE_MLX5_DR_CREATE_ACTION_ASO */ +if (!mtr_free->fm.meter_action) { +flow_dv_aso_mtr_release_to_pool (dev, mtr_idx); +return 0 ; + } + }return mtr_idx; }
@@ -11579,7 +11600,7 @@ flow_dv_translate(struct rte_eth_dev *dev, NULL, "Failed to get meter in flow.");/* Set the meter action. */ dev_flow->dv.actions[actions_n++] = - wks->fm->mfts->meter_action; + wks->fm->meter_action; action_flags |=MLX5_FLOW_ACTION_METER ;break ;case RTE_FLOW_ACTION_TYPE_SET_IPV4_DSCP :
@@ -12741,7 +12762,7 @@ flow_dv_destroy(struct rte_eth_dev *dev, struct rte_flow *flow)if (flow->meter) { fm =flow_dv_meter_find_by_idx (priv, flow->meter);if (fm) -mlx5_flow_meter_detach (fm); +mlx5_flow_meter_detach (priv, fm); flow->meter =0 ; }if (flow->age)
drivers/net/mlx5/mlx5_flow_meter.c +63 -34
141 lines not on this page · raw message
Signature · 1 line
2.27.0
PATCH v4 13/14 net/mlx5: make ASO meter queue thread-safe
In reply to Li ZhangSynchronize ASO meter queue accesses from
different threads using a spinlock.
--- drivers/net/mlx5/mlx5.h | 1 + drivers/net/mlx5/mlx5_flow_aso.c | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-)
drivers/net/mlx5/mlx5.h +1 -0
@@ -493,6 +493,7 @@ struct mlx5_aso_sq_elem {struct mlx5_aso_sq {uint16_t log_desc_n; +rte_spinlock_t sqsl;struct mlx5_aso_cq cq;struct mlx5_devx_sq sq_obj;volatile uint64_t *uar_addr;
drivers/net/mlx5/mlx5_flow_aso.c +13 -3
@@ -274,6 +274,7 @@ mlx5_aso_sq_create(void *ctx, struct mlx5_aso_sq *sq, int socket, sq->tail =0 ; sq->sqn = sq->sq_obj.sq->id; sq->uar_addr =mlx5_os_get_devx_uar_reg_addr (uar); +rte_spinlock_init (&sq->sqsl);return 0 ; error:mlx5_aso_destroy_sq (sq);
@@ -665,12 +666,15 @@ mlx5_aso_mtr_sq_enqueue_single(struct mlx5_aso_sq *sq,struct mlx5_flow_meter_info *fm =NULL ;uint16_t size =1 << sq->log_desc_n;uint16_t mask = size -1 ; -uint16_t res = size - (uint16_t )(sq->head - sq->tail); +uint16_t res;uint32_t dseg_idx =0 ;struct mlx5_aso_mtr_pool *pool =NULL ; +rte_spinlock_lock (&sq->sqsl); + res = size - (uint16_t )(sq->head - sq->tail);if (unlikely (!res)) {DRV_LOG (ERR ,"Fail: SQ is full and no free WQE to send" ); +rte_spinlock_unlock (&sq->sqsl);return 0 ; } wqe = &sq->sq_obj.aso_wqes[sq->head & mask];
@@ -707,6 +711,7 @@ mlx5_aso_mtr_sq_enqueue_single(struct mlx5_aso_sq *sq,rte_wmb (); *sq->uar_addr = *(volatile uint64_t *)wqe;/* Assume 64 bit ARCH. */ rte_wmb (); +rte_spinlock_unlock (&sq->sqsl);return 1 ; }
@@ -737,12 +742,16 @@ mlx5_aso_mtr_completion_handle(struct mlx5_aso_sq *sq)const unsigned int mask = cq_size -1 ;uint32_t idx;uint32_t next_idx = cq->cq_ci & mask; -const uint16_t max = (uint16_t )(sq->head - sq->tail); +uint16_t max;uint16_t n =0 ;int ret; -if (unlikely (!max)) +rte_spinlock_lock (&sq->sqsl); + max = (uint16_t )(sq->head - sq->tail); +if (unlikely (!max)) { +rte_spinlock_unlock (&sq->sqsl);return ; + } do { idx = next_idx; next_idx = (cq->cq_ci + 1) & mask;
@@ -769,6 +778,7 @@ mlx5_aso_mtr_completion_handle(struct mlx5_aso_sq *sq)rte_io_wmb (); cq->cq_obj.db_rec[0 ] =rte_cpu_to_be_32 (cq->cq_ci); } +rte_spinlock_unlock (&sq->sqsl); }/**
Signature · 1 line
2.27.0
PATCH v4 14/14 net/mlx5: allow multiple flow tables on the same level
In reply to Li ZhangThe driver devices support creation of multiple flow tables. Jump action can be used in order to move the packet steering to different flow table.
Table 0 is always the root table for packet steering.
Jumping between tables may cause endless loops in steering mechanism, that's why each table has level attribute,
the driver sub-system may not allow jumping to table with equal or lower level than the current table.
Currently, in the driver, the table ID and level are always identical.
Allow multiple flow table creation with the same level attribute.
This patch adds the table id in flow table data entry, while allocates the flow table, if the table level is same but the different table id, the new table will be allocated with new table object id. It supports 4M multiple flow tables on the same level.
--- drivers/net/mlx5/mlx5.c | 9 ++-- drivers/net/mlx5/mlx5.h | 10 ++-- drivers/net/mlx5/mlx5_flow.c | 17 ++++--- drivers/net/mlx5/mlx5_flow.h | 12 +++-- drivers/net/mlx5/mlx5_flow_dv.c | 84 +++++++++++++++++++-------------- 5 files changed, 79 insertions(+), 53 deletions(-)
drivers/net/mlx5/mlx5.c +6 -3
@@ -1269,9 +1269,12 @@ mlx5_alloc_table_hash_list(struct mlx5_priv *priv __rte_unused)* because DV expect to see them even if they cannot be created by * RDMA-CORE. */ -if (!flow_dv_tbl_resource_get (dev,0 ,0 ,0 ,0 ,NULL ,0 ,1 , &error) || - !flow_dv_tbl_resource_get (dev,0 ,1 ,0 ,0 ,NULL ,0 ,1 , &error) || - !flow_dv_tbl_resource_get (dev,0 ,0 ,1 ,0 ,NULL ,0 ,1 , &error)) { +if (!flow_dv_tbl_resource_get (dev,0 ,0 ,0 ,0 , +NULL ,0 ,1 ,0 , &error) || + !flow_dv_tbl_resource_get (dev,0 ,1 ,0 ,0 , +NULL ,0 ,1 ,0 , &error) || + !flow_dv_tbl_resource_get (dev,0 ,0 ,1 ,0 , +NULL ,0 ,1 ,0 , &error)) { err =ENOMEM ; goto error; }
drivers/net/mlx5/mlx5.h +6 -4
@@ -770,10 +770,12 @@ struct mlx5_aso_mtr_pools_mng {union mlx5_flow_tbl_key {struct {/* Table ID should be at the lowest address. */ -uint32_t table_id;/**< ID of the table. */ -uint16_t dummy;/**< Dummy table for DV API. */ -uint8_t domain;/**< 1 - FDB, 0 - NIC TX/RX. */ -uint8_t direction;/**< 1 - egress, 0 - ingress. */ +uint32_t level;/**< Level of the table. */ +uint32_t id:22 ;/**< ID of the table. */ +uint32_t dummy:1 ;/**< Dummy table for DV API. */ +uint32_t is_fdb:1 ;/**< 1 - FDB, 0 - NIC TX/RX. */ +uint32_t is_egress:1 ;/**< 1 - egress, 0 - ingress. */ +uint32_t reserved:7 ;/**< must be zero for comparison. */ };uint64_t v64;/**< full 64bits value of key */ };
drivers/net/mlx5/mlx5_flow.c +11 -6
@@ -4342,6 +4342,9 @@ flow_create_split_inner(struct rte_eth_dev *dev, dev_flow->handle->mark =1 ;if (sub_flow) *sub_flow = dev_flow; +#ifdef HAVE_IBV_FLOW_DV_SUPPORT + dev_flow->dv.table_id = flow_split_info->table_id; +#endif return flow_drv_translate (dev, dev_flow, attr, items, actions, error); }
@@ -5489,8 +5492,7 @@ flow_create_split_sample(struct rte_eth_dev *dev, struct mlx5_flow_tbl_data_entry, tbl); sfx_attr.group = sfx_attr.transfer ? - (sfx_tbl_data->table_id -1 ) : - sfx_tbl_data->table_id; + (sfx_tbl_data->level -1 ) : sfx_tbl_data->level; }else {MLX5_ASSERT (attr->transfer); sfx_attr.group = jump_table;
@@ -5690,7 +5692,8 @@ flow_list_create(struct rte_eth_dev *dev, uint32_t *list, .skip_scale = 0, .flow_idx = 0, .prefix_mark = 0, - .prefix_layers = 0 + .prefix_layers = 0, + .table_id = 0 };int ret;
@@ -7743,10 +7746,12 @@ tunnel_mark_decode(struct rte_eth_dev *dev, uint32_t mark)union tunnel_offload_mark mbits = { .val = mark };union mlx5_flow_tbl_key table_key = { { - .table_id =tunnel_id_to_flow_tbl (mbits.table_id), + .level =tunnel_id_to_flow_tbl (mbits.table_id), + .id =0 , + .reserved =0 , .dummy =0 , - .domain = !!mbits.transfer, - .direction =0 , + .is_fdb = !!mbits.transfer, + .is_egress =0 , } }; he =mlx5_hlist_lookup (sh->flow_tbls, table_key.v64,NULL );
drivers/net/mlx5/mlx5_flow.h +8 -4
@@ -565,8 +565,9 @@ struct mlx5_flow_tbl_data_entry { uint32_t is_egress:1; /**< Egress table. */ uint32_t is_transfer:1; /**< Transfer table. */ uint32_t dummy:1; /**< DR table. */ - uint32_t reserve:27; /**< Reserved to future using. */ -uint32_t table_id;/**< Table ID. */ + uint32_t id:22; /**< Table ID. */ + uint32_t reserve:5; /**< Reserved to future using. */ +uint32_t level;/**< Table level. */ };/* Sub rdma-core actions list. */
@@ -700,6 +701,7 @@ struct mlx5_flow_handle {/** Device flow structure only for DV flow creation. */ struct mlx5_flow_dv_workspace {uint32_t group;/**< The group index. */ +uint32_t table_id;/**< Flow table identifier. */ uint8_t transfer;/**< 1 if the flow is E-Switch flow. */ int actions_n;/**< number of actions. */ void *actions[MLX5_DV_MAX_NUMBER_OF_ACTIONS ];/**< Action list. */
@@ -1060,6 +1062,7 @@ struct mlx5_flow_split_info {uint32_t flow_idx;/**< This memory pool index to the flow. */ uint32_t prefix_mark;/**< Prefix subflow mark flag. */ uint64_t prefix_layers;/**< Prefix subflow layers. */ +uint32_t table_id;/**< Flow table identifier. */ }; typedef int (*mlx5_flow_validate_t)(struct rte_eth_dev *dev,
@@ -1411,9 +1414,10 @@ int flow_dv_tbl_match_cb(struct mlx5_hlist *list,void flow_dv_tbl_remove_cb (struct mlx5_hlist *list,struct mlx5_hlist_entry *entry);struct mlx5_flow_tbl_resource *flow_dv_tbl_resource_get (struct rte_eth_dev *dev, -uint32_t table_id,uint8_t egress,uint8_t transfer, +uint32_t table_level,uint8_t egress,uint8_t transfer,bool external,const struct mlx5_flow_tunnel *tunnel, -uint32_t group_id,uint8_t dummy,struct rte_flow_error *error); +uint32_t group_id,uint8_t dummy, +uint32_t table_id,struct rte_flow_error *error);struct mlx5_hlist_entry *flow_dv_tag_create_cb (struct mlx5_hlist *list,uint64_t key,void *cb_ctx);
drivers/net/mlx5/mlx5_flow_dv.c +48 -36
205 lines not on this page · raw message
Signature · 1 line
2.27.0
v5 cover Add ASO meter support in MLX5 PMD
In reply to Li ZhangTo support more meters and better performance,
MLX HW provide ASO flow meter.
It can expose millions of ASO flow meter context's in HW. This ASO object can allocate the large bulk meter objects. This patch set implement the ASO flow meter for mlx5 driver. MLX5 PMD driver will be responsible for ASO flow meter manage to HW.
V2: Fix compile error issue (mlx5_glue->destroy_flow_action)
V3: Fix comments.
V4: Fix comments and add Acked.
V5: Fix unused log_obj_size issue.
Li Zhang (10):
net/mlx5: optimize meter statistics
common/mlx5: add definitions for ASO flow meter common/mlx5: add read ASO flow meter HCA capability common/mlx5: add DevX API to create ASO flow meter object net/mlx5: flow meter pool to manage meter object net/mlx5: initialize the flow meter ASO SQ net/mlx5: aso flow meter send WQE and CQE handle net/mlx5: add support of ASO meter action net/mlx5: make ASO meter queue thread-safe net/mlx5: allow multiple flow tables on the same level
Shun Hao (3):
common/mlx5: add color register idle bits definition net/mlx5: fix meter statistics
net/mlx5: use mask for meter register setting
Suanming Mou (1):
net/mlx5: support three level table walk
doc/guides/nics/mlx5.rst | 6 +
drivers/common/mlx5/mlx5_devx_cmds.c | 68 ++
drivers/common/mlx5/mlx5_devx_cmds.h | 26 +-
drivers/common/mlx5/mlx5_prm.h | 81 +-
drivers/common/mlx5/version.map | 1 +
drivers/net/mlx5/linux/mlx5_os.c | 20 +-
drivers/net/mlx5/meson.build | 2 +-
drivers/net/mlx5/mlx5.c | 98 +-
drivers/net/mlx5/mlx5.h | 258 +++++-
drivers/net/mlx5/mlx5_flow.c | 334 +++++--
drivers/net/mlx5/mlx5_flow.h | 212 ++---
.../mlx5/{mlx5_flow_age.c => mlx5_flow_aso.c} | 289 +++++-
drivers/net/mlx5/mlx5_flow_dv.c | 792 +++++++++++-----
drivers/net/mlx5/mlx5_flow_meter.c | 873 ++++++++++++------
drivers/net/mlx5/mlx5_utils.h | 90 ++
15 files changed, 2320 insertions(+), 830 deletions(-)
rename drivers/net/mlx5/{mlx5_flow_age.c => mlx5_flow_aso.c} (65%)Signature · 1 line
2.27.0
PATCH v5 1/14 net/mlx5: support three level table walk
From: Suanming Mou <[email protected]>
This commit adds table entry walk for the three level table.
--- drivers/net/mlx5/mlx5_utils.h | 90 +++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+)
drivers/net/mlx5/mlx5_utils.h +90 -0
@@ -834,6 +834,91 @@ int32_t mlx5_l3t_clear_entry(struct mlx5_l3t_tbl *tbl, uint32_t idx);int32_t mlx5_l3t_set_entry (struct mlx5_l3t_tbl *tbl,uint32_t idx,union mlx5_l3t_data *data); +static inline void * +mlx5_l3t_get_next (struct mlx5_l3t_tbl *tbl,uint32_t *pos) +{ +struct mlx5_l3t_level_tbl *g_tbl, *m_tbl; +uint32_t i, j, k, g_start, m_start, e_start; +uint32_t idx = *pos; +void *e_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; + +if (!tbl) +return NULL ; + g_tbl = tbl->tbl; +if (!g_tbl) +return NULL ; + g_start = (idx >>MLX5_L3T_GT_OFFSET ) &MLX5_L3T_GT_MASK ; + m_start = (idx >>MLX5_L3T_MT_OFFSET ) &MLX5_L3T_MT_MASK ; + e_start = idx &MLX5_L3T_ET_MASK ; +for (i = g_start; i <MLX5_L3T_GT_SIZE ; i++) { + m_tbl = g_tbl->tbl[i]; +if (!m_tbl) { +/* Jump to new table, reset the sub table start. */ + m_start =0 ; + e_start =0 ; +continue ; + } +for (j = m_start; j <MLX5_L3T_MT_SIZE ; j++) { +if (!m_tbl->tbl[j]) { +/* +* Jump to new table, reset the sub table +* start. +*/ + e_start =0 ; +continue ; + } + e_tbl = m_tbl->tbl[j]; +switch (tbl->type) { +case MLX5_L3T_TYPE_WORD : + w_e_tbl = (struct mlx5_l3t_entry_word *)e_tbl; +for (k = e_start; k <MLX5_L3T_ET_SIZE ; k++) { +if (!w_e_tbl->entry[k].data) +continue ; + *pos = (i <<MLX5_L3T_GT_OFFSET ) | + (j <<MLX5_L3T_MT_OFFSET ) | k; +return (void *)&w_e_tbl->entry[k].data; + } +break ; +case MLX5_L3T_TYPE_DWORD : + dw_e_tbl = (struct mlx5_l3t_entry_dword *)e_tbl; +for (k = e_start; k <MLX5_L3T_ET_SIZE ; k++) { +if (!dw_e_tbl->entry[k].data) +continue ; + *pos = (i <<MLX5_L3T_GT_OFFSET ) | + (j <<MLX5_L3T_MT_OFFSET ) | k; +return (void *)&dw_e_tbl->entry[k].data; + } +break ; +case MLX5_L3T_TYPE_QWORD : + qw_e_tbl = (struct mlx5_l3t_entry_qword *)e_tbl; +for (k = e_start; k <MLX5_L3T_ET_SIZE ; k++) { +if (!qw_e_tbl->entry[k].data) +continue ; + *pos = (i <<MLX5_L3T_GT_OFFSET ) | + (j <<MLX5_L3T_MT_OFFSET ) | k; +return (void *)&qw_e_tbl->entry[k].data; + } +break ; +default : + ptr_e_tbl = (struct mlx5_l3t_entry_ptr *)e_tbl; +for (k = e_start; k <MLX5_L3T_ET_SIZE ; k++) { +if (!ptr_e_tbl->entry[k].data) +continue ; + *pos = (i <<MLX5_L3T_GT_OFFSET ) | + (j <<MLX5_L3T_MT_OFFSET ) | k; +return ptr_e_tbl->entry[k].data; + } +break ; + } + } + } +return NULL ; +} +/* * Macros for linked list based on indexed memory. * Example data structure:
@@ -909,4 +994,9 @@ struct { \ idx = (elem)->field.next, (elem) = \ (idx) ? mlx5_ipool_get(pool, idx) : NULL) +#define MLX5_L3T_FOREACH (tbl, idx, entry) \ + for (idx = 0, (entry) = mlx5_l3t_get_next((tbl), &idx); \ + (entry); \ + idx++, (entry) = mlx5_l3t_get_next((tbl), &idx)) +#endif /* RTE_PMD_MLX5_UTILS_H_ */
Signature · 1 line
2.27.0
PATCH v5 2/14 common/mlx5: add color register idle bits definition
In reply to Li ZhangFrom: Shun Hao <[email protected]>
8 bits are used for meter color in meter register. When the meter register can be shared, the rest 24 bits can be used by others. This adds the definination for the 24 bits that can be shared.
--- drivers/common/mlx5/mlx5_prm.h | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/common/mlx5/mlx5_prm.h +6 -0
@@ -3382,6 +3382,12 @@ enum {/* The bits meter color use. */ #define MLX5_MTR_COLOR_BITS 8 +/* The bit size of one register. */ +#define MLX5_REG_BITS 32 + +/* Idle bits for non-color usage in color register. */ +#define MLX5_MTR_IDLE_BITS_IN_COLOR_REG (MLX5_REG_BITS - MLX5_MTR_COLOR_BITS) +/* Length mode of dynamic flex parser graph node. */ enum mlx5_parse_graph_node_len_mode {MLX5_GRAPH_NODE_LEN_FIXED =0x0 ,
Signature · 1 line
2.27.0
PATCH v5 3/14 net/mlx5: fix meter statistics
In reply to Li ZhangFrom: Shun Hao <[email protected]>
Currently, packets after meter will be steered to a global policer table,
which includes green/red color rules for every meter, so as to have counter statistics of each color in every meter.
There's a bug that all the rules in global policer table are matching only color criteria, so all packets will be counted to one meter only, and other meter statistics are always zero.
This patch does these:
1. The rules in policer table matches both meter index and color, so packet after meter could be counted to the correct meter counter.
2. The meter index and flow index are now sharing the available register bits dynamically. Meter index starts from lsb, and flow index starts from msb.
--- drivers/net/mlx5/mlx5.c | 7 +- drivers/net/mlx5/mlx5.h | 15 +- drivers/net/mlx5/mlx5_flow.c | 183 +++++++---- drivers/net/mlx5/mlx5_flow.h | 40 +-- drivers/net/mlx5/mlx5_flow_dv.c | 489 ++++++++++++++++++----------- drivers/net/mlx5/mlx5_flow_meter.c | 53 +++- 6 files changed, 496 insertions(+), 291 deletions(-)
drivers/net/mlx5/mlx5.c +5 -2
@@ -277,10 +277,13 @@ static const struct mlx5_indexed_pool_config mlx5_ipool_cfg[] = { }, #endif [MLX5_IPOOL_MTR ] = { +/** +* The ipool index should grow continually from small to big, +* for meter idx, so not set grow_trunk to avoid meter index +* not jump continually. +*/ .size =sizeof (struct mlx5_flow_meter ), .trunk_size =64 , - .grow_trunk =3 , - .grow_shift =2 , .need_lock =1 , .release_mem_en =1 , .malloc = mlx5_malloc,
drivers/net/mlx5/mlx5.h +9 -6
@@ -944,9 +944,9 @@ struct mlx5_priv { unsigned int representor:1; /* Device is a port representor. */ unsigned int master:1; /* Device is a E-Switch master. */ unsigned int txpp_en:1; /* Tx packet pacing enabled. */ + unsigned int sampler_en:1; /* Whether support sampler. */ unsigned int mtr_en:1; /* Whether support meter. */ unsigned int mtr_reg_share:1; /* Whether support meter REG_C share. */ - unsigned int sampler_en:1; /* Whether support sampler. */uint16_t domain_id;/* Switch domain identifier. */ uint16_t vport_id;/* Associated VF vport index (if any). */ uint32_t vport_meta_tag;/* Used for vport index match ove VF LAG. */
@@ -1003,6 +1003,10 @@ struct mlx5_priv {uint32_t rss_shared_actions;/* RSS shared actions. */ struct mlx5_devx_obj *q_counters;/* DevX queue counter object. */ uint32_t counter_set_id;/* Queue counter ID to set in DevX objects. */ +uint8_t max_mtr_bits; +/* Indicate how many bits are used by meter id at the most. */ +uint8_t max_mtr_flow_bits; +/* Indicate how many bits are used by meter flow id at the most. */ };#define PORT_ID (priv) ((priv)->dev_data->port_id)
@@ -1271,11 +1275,10 @@ int mlx5_pmd_socket_init(void);int mlx5_flow_meter_ops_get (struct rte_eth_dev *dev,void *arg);struct mlx5_flow_meter *mlx5_flow_meter_find (struct mlx5_priv *priv,uint32_t meter_id); -struct mlx5_flow_meter *mlx5_flow_meter_attach - (struct mlx5_priv *priv, -uint32_t meter_id, -const struct rte_flow_attr *attr, -struct rte_flow_error *error); +int mlx5_flow_meter_attach (struct mlx5_priv *priv, +struct mlx5_flow_meter *fm, +const struct rte_flow_attr *attr, +struct rte_flow_error *error);void mlx5_flow_meter_detach (struct mlx5_flow_meter *fm);/* mlx5_os.c */
drivers/net/mlx5/mlx5_flow.c +120 -63
330 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow.h +22 -18
@@ -79,7 +79,7 @@ enum mlx5_feature_name {MLX5_APP_TAG ,MLX5_COPY_MARK ,MLX5_MTR_COLOR , -MLX5_MTR_SFX , +MLX5_MTR_ID , MLX5_ASO_FLOW_HIT, };
@@ -655,7 +655,8 @@ struct mlx5_flow_handle {uint64_t layers;/**< Bit-fields of present layers, see MLX5_FLOW_LAYER_*. */ void *drv_flow;/**< pointer to driver flow object. */ - uint32_t split_flow_id:28; /**< Sub flow unique match flow id. */ + uint32_t split_flow_id:27; /**< Sub flow unique match flow id. */ + uint32_t is_meter_flow_id:1; /**< Indate if flow_id is for meter. */ uint32_t mark:1; /**< Metadate rxq mark flag. */ uint32_t fate_action:3; /**< Fate action type. */union {
@@ -842,14 +843,16 @@ struct mlx5_meter_domain_info {/**< Meter table. */ struct mlx5_flow_tbl_resource *sfx_tbl;/**< Meter suffix table. */ -void *any_matcher; -/**< Meter color not match default criteria. */ -void *color_matcher; -/**< Meter color match criteria. */ +struct mlx5_flow_dv_matcher *drop_matcher; +/**< Matcher for Drop. */ +struct mlx5_flow_dv_matcher *color_matcher; +/**< Matcher for Color. */ void *jump_actn;/**< Meter match action. */ -void *policer_rules[RTE_MTR_DROPPED +1 ]; -/**< Meter policer for the match. */ +void *green_rule; +/**< Meter green rule. */ +void *drop_rule; +/**< Meter drop rule. */ };/* Meter table set for TX RX FDB. */
@@ -862,10 +865,10 @@ struct mlx5_meter_domains_infos {/**< RX meter table. */ struct mlx5_meter_domain_info transfer;/**< FDB meter table. */ -void *drop_actn; -/**< Drop action as not matched. */ -void *count_actns[RTE_MTR_DROPPED +1 ]; -/**< Counters for match and unmatched statistics. */ +void *green_count; +/**< Counters for green rule. */ +void *drop_count; +/**< Counters for green rule. */ uint32_t fmp[MLX5_ST_SZ_DW (flow_meter_parameters)];/**< Flow meter parameter. */ size_t fmp_size;
@@ -928,6 +931,8 @@ struct mlx5_flow_meter {/**< Meter state. */ uint32_t shared:1;/**< Meter shared or not. */ +struct mlx5_indexed_pool *flow_ipool; +/**< Index pool for flow id. */ };/* RFC2697 parameter structure. */
@@ -1166,6 +1171,7 @@ struct mlx5_flow_workspace {struct mlx5_flow_rss_desc rss_desc;uint32_t rssq_num;/* Allocated queue num in rss_desc. */ uint32_t flow_idx;/* Intermediate device flow index. */ +struct mlx5_flow_meter *fm;/* Pointer to the meter in flow. */ };struct mlx5_flow_split_info {
@@ -1206,8 +1212,7 @@ typedef int (*mlx5_flow_query_t)(struct rte_eth_dev *dev,void *data, struct rte_flow_error *error);typedef struct mlx5_meter_domains_infos *(*mlx5_flow_create_mtr_tbls_t ) - (struct rte_eth_dev *dev, -const struct mlx5_flow_meter *fm); + (struct rte_eth_dev *dev);typedef int (*mlx5_flow_destroy_mtr_tbls_t )(struct rte_eth_dev *dev,struct mlx5_meter_domains_infos *tbls);typedef int (*mlx5_flow_create_policer_rules_t )
@@ -1270,7 +1275,7 @@ struct mlx5_flow_driver_ops {mlx5_flow_query_t query;mlx5_flow_create_mtr_tbls_t create_mtr_tbls;mlx5_flow_destroy_mtr_tbls_t destroy_mtr_tbls; -mlx5_flow_create_policer_rules_t create_policer_rules; +mlx5_flow_create_policer_rules_t prepare_policer_rules;mlx5_flow_destroy_policer_rules_t destroy_policer_rules;mlx5_flow_counter_alloc_t counter_alloc;mlx5_flow_counter_free_t counter_free;
@@ -1470,11 +1475,10 @@ int mlx5_flow_validate_item_ecpri(const struct rte_flow_item *item,const struct rte_flow_item_ecpri *acc_mask, struct rte_flow_error *error);struct mlx5_meter_domains_infos *mlx5_flow_create_mtr_tbls - (struct rte_eth_dev *dev, -const struct mlx5_flow_meter *fm); + (struct rte_eth_dev *dev);int mlx5_flow_destroy_mtr_tbls (struct rte_eth_dev *dev,struct mlx5_meter_domains_infos *tbl); -int mlx5_flow_create_policer_rules (struct rte_eth_dev *dev, +int mlx5_flow_prepare_policer_rules (struct rte_eth_dev *dev,struct mlx5_flow_meter *fm,const struct rte_flow_attr *attr); int mlx5_flow_destroy_policer_rules(struct rte_eth_dev *dev,
drivers/net/mlx5/mlx5_flow_dv.c +303 -186
704 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_meter.c +37 -16
117 lines not on this page · raw message
Signature · 1 line
2.27.0
PATCH v5 4/14 net/mlx5: optimize meter statistics
In reply to Li ZhangMeter statistics are each policer action each counter. Totally 4 counters per each meter.
It causes cache missed
and lead to data forwarding performance low.
To optimize it, support pass counter for green
and drop counter for red.
Totally two counters per each meter.
Also use the global drop statistics for
all meter drop action.
limitations as below:
1. It does not support yellow counter and return 0.
2. All the meter colors with drop action will be counted only by the global drop statistics.
3. Red color must be with drop action.
--- doc/guides/nics/mlx5.rst | 6 + drivers/net/mlx5/mlx5_flow.h | 24 ++-- drivers/net/mlx5/mlx5_flow_dv.c | 8 +- drivers/net/mlx5/mlx5_flow_meter.c | 217 +++++++++++++++++++---------- 4 files changed, 173 insertions(+), 82 deletions(-)
doc/guides/nics/mlx5.rst +6 -0
@@ -399,6 +399,12 @@ Limitations - Hairpin between two ports could only manual binding and explicit Tx flow mode. For single port hairpin, all the combinations of auto/manual binding and explicit/implicit Tx flow mode could be supported. - Hairpin in switchdev SR-IOV mode is not supported till now. +- Meter: + - All the meter colors with drop action will be counted only by the global drop statistics. + - Green color is not supported with drop action. + - Yellow detection is not supported. + - Red color must be with drop action. + Statistics ----------
drivers/net/mlx5/mlx5_flow.h +16 -8
@@ -831,10 +831,10 @@ struct mlx5_flow {/* Meter policer statistics */ struct mlx5_flow_policer_stats { -uint32_t cnt[RTE_COLORS +1 ]; -/**< Color counter, extra for drop. */ -uint64_t stats_mask; -/**< Statistics mask for the colors. */ +uint32_t pass_cnt; +/**< Color counter for pass. */ +uint32_t drop_cnt; +/**< Color counter for drop. */ };/* Meter table structure. */
@@ -892,10 +892,18 @@ struct mlx5_flow_meter {/** Policer actions (per meter output color). */ enum rte_mtr_policer_action action[RTE_COLORS ]; -/** Set of stats counters to be enabled. -* @see enum rte_mtr_stats_type -*/ -uint64_t stats_mask; + uint32_t green_bytes:1; +/** Set green bytes stats to be enabled. */ + uint32_t green_pkts:1; +/** Set green packets stats to be enabled. */ + uint32_t red_bytes:1; +/** Set red bytes stats to be enabled. */ + uint32_t red_pkts:1; +/** Set red packets stats to be enabled. */ + uint32_t bytes_dropped:1; +/** Set bytes dropped stats to be enabled. */ + uint32_t pkts_dropped:1; +/** Set packets dropped stats to be enabled. */ /**< Rule applies to ingress traffic. */ uint32_t ingress:1;
drivers/net/mlx5/mlx5_flow_dv.c +4 -4
@@ -13830,17 +13830,17 @@ flow_dv_prepare_policer_rules(struct rte_eth_dev *dev,int ret;/* Get the statistics counters for green/drop. */ -if (fm->policer_stats.cnt[RTE_COLOR_GREEN ]) { +if (fm->policer_stats.pass_cnt) { cnt =flow_dv_counter_get_by_idx (dev, - fm->policer_stats.cnt[RTE_COLOR_GREEN ], + fm->policer_stats.pass_cnt,NULL ); mtb->green_count = cnt->action; }else { mtb->green_count =NULL ; } -if (fm->policer_stats.cnt[RTE_MTR_DROPPED ]) { +if (fm->policer_stats.drop_cnt) { cnt =flow_dv_counter_get_by_idx (dev, - fm->policer_stats.cnt[RTE_MTR_DROPPED ], + fm->policer_stats.drop_cnt,NULL ); mtb->drop_count = cnt->action; }else {
drivers/net/mlx5/mlx5_flow_meter.c +147 -70
321 lines not on this page · raw message
Signature · 1 line
2.27.0
PATCH v5 5/14 net/mlx5: use mask for meter register setting
In reply to Li ZhangFrom: Shun Hao <[email protected]>
ASO meter feature may require to locate the flow context tag action after the ASO action.
When color register is shared by meter_id/flow_id, it's like:
Bits[0-7] A meter color value set by the HW. Bits[8-31] A flow id and meter id set by SW.
Currently the tag action for meter writes all the bits of the meter register, so it will potentially overwrite meter color when ASO meter action is before the tag action.
Set only 24-MSB-bits of meter register in the meter tag action.
--- drivers/net/mlx5/mlx5_flow.c | 28 ++++++++++++++++++---------- drivers/net/mlx5/mlx5_flow.h | 2 ++ drivers/net/mlx5/mlx5_flow_dv.c | 2 ++ 3 files changed, 22 insertions(+), 10 deletions(-)
drivers/net/mlx5/mlx5_flow.c +18 -10
@@ -4259,9 +4259,11 @@ flow_hairpin_split(struct rte_eth_dev *dev,rte_memcpy (actions_rx, actions,sizeof (struct rte_flow_action )); actions_rx++; set_tag = (void *)actions_rx; - set_tag->id =mlx5_flow_get_reg_id (dev,MLX5_HAIRPIN_RX ,0 ,NULL ); + *set_tag = (struct mlx5_rte_flow_action_set_tag ) { + .id =mlx5_flow_get_reg_id (dev,MLX5_HAIRPIN_RX ,0 ,NULL ), + .data = flow_id, + };MLX5_ASSERT (set_tag->id >REG_NON ); - set_tag->data = flow_id; tag_action->conf = set_tag;/* Create Tx item list. */ rte_memcpy (actions_tx, actions,sizeof (struct rte_flow_action ));
@@ -4497,6 +4499,14 @@ flow_meter_split_prep(struct rte_eth_dev *dev, set_tag = (struct mlx5_rte_flow_action_set_tag *)actions_pre; tag_item_spec = (struct mlx5_rte_flow_item_tag *)sfx_items; tag_item_mask = tag_item_spec +1 ; +/* Both flow_id and meter_id share the same register. */ + *set_tag = (struct mlx5_rte_flow_action_set_tag ) { + .id = (enum modify_reg )mlx5_flow_get_reg_id (dev,MLX5_MTR_ID , +0 , error), + .offset = mtr_id_offset, + .length = mtr_reg_bits, + .data = fm->idx, + };/* * The color Reg bits used by flow_id are growing from * msb to lsb, so must do bit reverse for flow_id val in RegC.
@@ -4504,13 +4514,9 @@ flow_meter_split_prep(struct rte_eth_dev *dev,for (shift =0 ; shift < flow_id_bits; shift++) flow_id_reversed = (flow_id_reversed <<1 ) | ((flow_id >> shift) &0x1 ); -/* Both flow_id and meter_id share the same register. */ - set_tag->id =mlx5_flow_get_reg_id (dev,MLX5_MTR_ID ,0 , error); - set_tag->data = - (fm->idx | (flow_id_reversed << (mtr_reg_bits - flow_id_bits))) - << mtr_id_offset; + set_tag->data |= flow_id_reversed << (mtr_reg_bits - flow_id_bits); tag_item_spec->id = set_tag->id; - tag_item_spec->data = set_tag->data; + tag_item_spec->data = set_tag->data << mtr_id_offset; tag_item_mask->data =UINT32_MAX << mtr_id_offset; tag_action->type = (enum rte_flow_action_type )MLX5_RTE_FLOW_ACTION_TYPE_TAG ;
@@ -4897,10 +4903,12 @@ flow_sample_split_prep(struct rte_eth_dev *dev, ret =mlx5_flow_get_reg_id (dev,MLX5_APP_TAG ,0 , error);if (ret <0 )return ret; - set_tag->id = ret;mlx5_ipool_malloc (priv->sh->ipool [MLX5_IPOOL_RSS_EXPANTION_FLOW_ID ], &tag_id); - set_tag->data = tag_id; + *set_tag = (struct mlx5_rte_flow_action_set_tag ) { + .id = ret, + .data = tag_id, + };/* Prepare the suffix subflow items. */ tag_spec = (void *)(sfx_items +SAMPLE_SUFFIX_ITEM ); tag_spec->data = tag_id;
drivers/net/mlx5/mlx5_flow.h +2 -0
@@ -55,6 +55,8 @@ struct mlx5_rte_flow_item_tag {/* Modify selected register. */ struct mlx5_rte_flow_action_set_tag {enum modify_reg id; +uint8_t offset; +uint8_t length;uint32_t data; };
drivers/net/mlx5/mlx5_flow_dv.c +2 -0
@@ -965,6 +965,8 @@ flow_dv_convert_action_set_reg actions[i] = (struct mlx5_modification_cmd ) { .action_type =MLX5_MODIFICATION_TYPE_SET , .field = reg_to_field[conf->id], + .offset = conf->offset, + .length = conf->length, }; actions[i].data0 =rte_cpu_to_be_32 (actions[i].data0); actions[i].data1 =rte_cpu_to_be_32 (conf->data);
Signature · 1 line
2.27.0
PATCH v5 6/14 common/mlx5: add definitions for ASO flow meter
In reply to Li ZhangThis patch adds different PRM definitions, related to ASO flow meter feature, in MLX5 PMD code.
--- drivers/common/mlx5/mlx5_prm.h | 75 ++++++++++++++++++++++++++++++++-- 1 file changed, 71 insertions(+), 4 deletions(-)
drivers/common/mlx5/mlx5_prm.h +71 -4
@@ -1129,6 +1129,8 @@ enum { (1ULL << MLX5_GENERAL_OBJ_TYPE_FLEX_PARSE_GRAPH)#define MLX5_GENERAL_OBJ_TYPES_CAP_FLOW_HIT_ASO \ (1ULL << MLX5_GENERAL_OBJ_TYPE_FLOW_HIT_ASO) +#define MLX5_GENERAL_OBJ_TYPES_CAP_FLOW_METER_ASO \ + (1ULL << MLX5_GENERAL_OBJ_TYPE_FLOW_METER_ASO)#define MLX5_GENERAL_OBJ_TYPES_CAP_GENEVE_TLV_OPT \ (1ULL << MLX5_OBJ_TYPE_GENEVE_TLV_OPT)
@@ -1514,7 +1516,15 @@ struct mlx5_ifc_qos_cap_bits {u8 reserved_at_c0[0x10 ];u8 max_qos_para_vport[0x10 ];u8 max_tsar_bw_share[0x20 ]; -u8 reserved_at_100[0x6e8 ]; +u8 nic_element_type[0x10 ]; +u8 nic_tsar_type[0x10 ]; +u8 reserved_at_120[0x3 ]; +u8 log_meter_aso_granularity[0x5 ]; +u8 reserved_at_128[0x3 ]; +u8 log_meter_aso_max_alloc[0x5 ]; +u8 reserved_at_130[0x3 ]; +u8 log_max_num_meter_aso[0x5 ]; +u8 reserved_at_138[0x6b0 ]; };struct mlx5_ifc_per_protocol_networking_offload_caps_bits {
@@ -2284,6 +2294,8 @@ struct mlx5_ifc_flow_meter_parameters_bits {u8 eir_mantissa[0x8 ];u8 reserved_at_8[0x60 ];// 14h-1Ch }; +#define MLX5_IFC_FLOW_METER_PARAM_MASK UINT64_C(0x80FFFFFF) +#define MLX5_IFC_FLOW_METER_DISABLE_CBS_CIR_VAL 0x14BF00C8enum {MLX5_CQE_SIZE_64B =0x0 ,
@@ -2411,6 +2423,7 @@ enum {MLX5_GENERAL_OBJ_TYPE_VIRTQ =0x000d ,MLX5_GENERAL_OBJ_TYPE_VIRTIO_Q_COUNTERS =0x001c ,MLX5_GENERAL_OBJ_TYPE_FLEX_PARSE_GRAPH =0x0022 , +MLX5_GENERAL_OBJ_TYPE_FLOW_METER_ASO =0x0024 , MLX5_GENERAL_OBJ_TYPE_FLOW_HIT_ASO = 0x0025, };
@@ -2419,7 +2432,9 @@ struct mlx5_ifc_general_obj_in_cmd_hdr_bits {u8 reserved_at_10[0x20 ];u8 obj_type[0x10 ];u8 obj_id[0x20 ]; -u8 reserved_at_60[0x20 ]; +u8 reserved_at_60[0x3 ]; +u8 log_obj_range[0x5 ]; +u8 reserved_at_58[0x18 ]; };struct mlx5_ifc_general_obj_out_cmd_hdr_bits {
@@ -2565,6 +2580,18 @@ struct mlx5_ifc_create_flow_hit_aso_in_bits {struct mlx5_ifc_flow_hit_aso_bits flow_hit_aso; }; +struct mlx5_ifc_flow_meter_aso_bits { +u8 modify_field_select[0x40 ]; +u8 reserved_at_40[0x48 ]; +u8 access_pd[0x18 ]; +u8 reserved_at_a0[0x160 ]; +u8 parameters[0x200 ]; +}; + +struct mlx5_ifc_create_flow_meter_aso_in_bits { +struct mlx5_ifc_general_obj_in_cmd_hdr_bits hdr; +struct mlx5_ifc_flow_meter_aso_bits flow_meter_aso; +};enum mlx5_access_aso_opc_mod {ASO_OPC_MOD_IPSEC =0x0 ,ASO_OPC_MOD_CONNECTION_TRACKING =0x1 ,
@@ -2618,11 +2645,51 @@ struct mlx5_aso_cseg {uint64_t data_mask; } __rte_packed; +/* A meter data segment - 2 per ASO WQE. */ +struct mlx5_aso_mtr_dseg { +uint32_t v_bo_sc_bbog_mm; +/* +* bit 31: valid, 30: bucket overflow, 28-29: start color, +* 27: both buckets on green, 24-25: meter mode. +*/ +uint32_t reserved; +uint32_t cbs_cir; +/* +* bit 24-28: cbs_exponent, bit 16-23 cbs_mantissa, +* bit 8-12: cir_exponent, bit 0-7 cir_mantissa. +*/ +uint32_t c_tokens; +uint32_t ebs_eir; +/* +* bit 24-28: ebs_exponent, bit 16-23 ebs_mantissa, +* bit 8-12: eir_exponent, bit 0-7 eir_mantissa. +*/ +uint32_t e_tokens; +uint64_t timestamp; +} __rte_packed; + +#define ASO_DSEG_VALID_OFFSET 31 +#define ASO_DSEG_BO_OFFSET 30 +#define ASO_DSEG_SC_OFFSET 28 +#define ASO_DSEG_CBS_EXP_OFFSET 24 +#define ASO_DSEG_CBS_MAN_OFFSET 16 +#define ASO_DSEG_CIR_EXP_MASK 0x1F +#define ASO_DSEG_CIR_EXP_OFFSET 8 +#define ASO_DSEG_EBS_EXP_OFFSET 24 +#define ASO_DSEG_EBS_MAN_OFFSET 16 +#define ASO_DSEG_EXP_MASK 0x1F +#define ASO_DSEG_MAN_MASK 0xFF +#define MLX5_ASO_WQE_DSEG_SIZE 0x40 +#define MLX5_ASO_METERS_PER_WQE 2 +#define MLX5_ASO_MTRS_PER_POOL 128 -/* ASO WQE Data segment. */ +/* ASO WQE data segment. */ struct mlx5_aso_dseg { -uint8_t data[MLX5_ASO_WQE_DSEG_SIZE ]; +union { +uint8_t data[MLX5_ASO_WQE_DSEG_SIZE ]; +struct mlx5_aso_mtr_dseg mtrs[MLX5_ASO_METERS_PER_WQE ]; + }; } __rte_packed;/* ASO WQE. */
Signature · 1 line
2.27.0
PATCH v5 7/14 common/mlx5: add read ASO flow meter HCA capability
In reply to Li ZhangRead and store the device capability of FLOW_METER_ASO general object, using the DevX API.
--- drivers/common/mlx5/mlx5_devx_cmds.c | 14 ++++++++++++++ drivers/common/mlx5/mlx5_devx_cmds.h | 8 ++++++++ 2 files changed, 22 insertions(+)
drivers/common/mlx5/mlx5_devx_cmds.c +14 -0
@@ -696,6 +696,9 @@ mlx5_devx_cmd_query_hca_attr(void *ctx, attr->max_geneve_tlv_option_data_len =MLX5_GET (cmd_hca_cap, hcattr, max_geneve_tlv_option_data_len); attr->qos.sup =MLX5_GET (cmd_hca_cap, hcattr, qos); + attr->qos.flow_meter_aso_sup = !!(MLX5_GET64 (cmd_hca_cap, hcattr, + general_obj_types) & +MLX5_GENERAL_OBJ_TYPES_CAP_FLOW_METER_ASO ); attr->vdpa.valid = !!(MLX5_GET64 (cmd_hca_cap, hcattr, general_obj_types) &MLX5_GENERAL_OBJ_TYPES_CAP_VIRTQ_NET_Q );
@@ -783,6 +786,17 @@ mlx5_devx_cmd_query_hca_attr(void *ctx,MLX5_GET (qos_cap, hcattr, packet_pacing); attr->qos.wqe_rate_pp =MLX5_GET (qos_cap, hcattr, wqe_rate_pp); +if (attr->qos.flow_meter_aso_sup) { + attr->qos.log_meter_aso_granularity = +MLX5_GET (qos_cap, hcattr, + log_meter_aso_granularity); + attr->qos.log_meter_aso_max_alloc = +MLX5_GET (qos_cap, hcattr, + log_meter_aso_max_alloc); + attr->qos.log_max_num_meter_aso = +MLX5_GET (qos_cap, hcattr, + log_max_num_meter_aso); + } }if (attr->vdpa.valid)mlx5_devx_cmd_query_hca_vdpa_attr (ctx, &attr->vdpa);
drivers/common/mlx5/mlx5_devx_cmds.h +8 -0
@@ -50,10 +50,18 @@ struct mlx5_hca_qos_attr {* Using older driver versions, flow_meter_old can be 1 * while flow_meter is 0. */ + uint32_t flow_meter_aso_sup:1; +/* Whether FLOW_METER_ASO Object is supported. */ uint8_t log_max_flow_meter;/* Power of the maximum supported meters. */ uint8_t flow_meter_reg_c_ids;/* Bitmap of the reg_Cs available for flow meter to use. */ + uint32_t log_meter_aso_granularity:5; +/* Power of the minimum allocation granularity Object. */ + uint32_t log_meter_aso_max_alloc:5; +/* Power of the maximum allocation granularity Object. */ + uint32_t log_max_num_meter_aso:5; +/* Power of the maximum number of supported objects. */ };
Signature · 1 line
2.27.0
PATCH v5 8/14 common/mlx5: add DevX API to create ASO flow meter object
In reply to Li ZhangAdd DevX API to create ASO flow meter object.
--- drivers/common/mlx5/mlx5_devx_cmds.c | 54 ++++++++++++++++++++++++++++ drivers/common/mlx5/mlx5_devx_cmds.h | 18 +++++++++- drivers/common/mlx5/version.map | 1 + 3 files changed, 72 insertions(+), 1 deletion(-)
drivers/common/mlx5/mlx5_devx_cmds.c +54 -0
@@ -2159,6 +2159,60 @@ mlx5_devx_cmd_alloc_pd(void *ctx)return ppd; } +/** +* Create general object of type FLOW_METER_ASO using DevX API. +* +* @param[in] ctx +* Context returned from mlx5 open_device() glue function. +* @param [in] pd +* PD value to associate the FLOW_METER_ASO object with. +* @param [in] log_obj_size +* log_obj_size define to allocate number of 2 * meters +* in one FLOW_METER_ASO object. +* +* @return +* The DevX object created, NULL otherwise and rte_errno is set. +*/ +struct mlx5_devx_obj * +mlx5_devx_cmd_create_flow_meter_aso_obj (void *ctx,uint32_t pd, +uint32_t log_obj_size) +{ +uint32_t in[MLX5_ST_SZ_DW (create_flow_meter_aso_in)] = {0 }; +uint32_t out[MLX5_ST_SZ_DW (general_obj_out_cmd_hdr)]; +struct mlx5_devx_obj *flow_meter_aso_obj; +void *ptr; + + flow_meter_aso_obj =mlx5_malloc (MLX5_MEM_ZERO , +sizeof (*flow_meter_aso_obj), +0 ,SOCKET_ID_ANY ); +if (!flow_meter_aso_obj) { +DRV_LOG (ERR ,"Failed to allocate FLOW_METER_ASO object data" ); + rte_errno =ENOMEM ; +return NULL ; + } + ptr =MLX5_ADDR_OF (create_flow_meter_aso_in, in, hdr); +MLX5_SET (general_obj_in_cmd_hdr, ptr, opcode, +MLX5_CMD_OP_CREATE_GENERAL_OBJECT ); +MLX5_SET (general_obj_in_cmd_hdr, ptr, obj_type, +MLX5_GENERAL_OBJ_TYPE_FLOW_METER_ASO ); +MLX5_SET (general_obj_in_cmd_hdr, ptr, log_obj_range, + log_obj_size); + ptr =MLX5_ADDR_OF (create_flow_meter_aso_in, in, flow_meter_aso); +MLX5_SET (flow_meter_aso, ptr, access_pd, pd); + flow_meter_aso_obj->obj = mlx5_glue->devx_obj_create ( + ctx, in,sizeof (in), + out,sizeof (out)); +if (!flow_meter_aso_obj->obj) { + rte_errno = errno; +DRV_LOG (ERR ,"Failed to create FLOW_METER_ASO obj using DevX." ); +mlx5_free (flow_meter_aso_obj); +return NULL ; + } + flow_meter_aso_obj->id =MLX5_GET (general_obj_out_cmd_hdr, + out, obj_id); +return flow_meter_aso_obj; +} +/** * Create general object of type GENEVE TLV option using DevX API. *
drivers/common/mlx5/mlx5_devx_cmds.h +17 -1
@@ -554,7 +554,6 @@ int mlx5_devx_cmd_query_virtio_q_counters(struct mlx5_devx_obj *couners_obj,__rte_internal struct mlx5_devx_obj *mlx5_devx_cmd_create_flow_hit_aso_obj(void *ctx,uint32_t pd); -__rte_internal struct mlx5_devx_obj *mlx5_devx_cmd_alloc_pd(void *ctx);
@@ -566,4 +565,21 @@ struct mlx5_devx_obj *mlx5_devx_cmd_queue_counter_alloc(void *ctx);__rte_internal int mlx5_devx_cmd_queue_counter_query(struct mlx5_devx_obj *dcs, int clear,uint32_t *out_of_buffers); +/** +* Create general object of type FLOW_METER_ASO using DevX API.. +* +* @param[in] ctx +* Device context. +* @param [in] pd +* PD value to associate the FLOW_METER_ASO object with. +* @param [in] log_obj_size +* log_obj_size define to allocate number of 2 * meters +* in one FLOW_METER_ASO object. +* +* @return +* The DevX object created, NULL otherwise and rte_errno is set. +*/ +__rte_internal +struct mlx5_devx_obj *mlx5_devx_cmd_create_flow_meter_aso_obj(void *ctx, +uint32_t pd,uint32_t log_obj_size);#endif /* RTE_PMD_MLX5_DEVX_CMDS_H_ */
drivers/common/mlx5/version.map +1 -0
@@ -25,6 +25,7 @@ INTERNAL { mlx5_devx_cmd_create_virtio_q_counters; # WINDOWS_NO_EXPORT mlx5_devx_cmd_create_virtq; mlx5_devx_cmd_create_flow_hit_aso_obj; + mlx5_devx_cmd_create_flow_meter_aso_obj; mlx5_devx_cmd_create_geneve_tlv_option; mlx5_devx_cmd_destroy; mlx5_devx_cmd_flow_counter_alloc;
Signature · 1 line
2.27.0
PATCH v5 9/14 net/mlx5: flow meter pool to manage meter object
In reply to Li ZhangAdd ASO flow meter pool to manage meter object
--- drivers/net/mlx5/mlx5.c | 2 +- drivers/net/mlx5/mlx5.h | 207 ++++++++++++- drivers/net/mlx5/mlx5_flow.c | 70 ++++- drivers/net/mlx5/mlx5_flow.h | 196 +++---------- drivers/net/mlx5/mlx5_flow_dv.c | 203 ++++++++++++- drivers/net/mlx5/mlx5_flow_meter.c | 450 ++++++++++++++++++----------- 6 files changed, 769 insertions(+), 359 deletions(-)
drivers/net/mlx5/mlx5.c +1 -1
@@ -282,7 +282,7 @@ static const struct mlx5_indexed_pool_config mlx5_ipool_cfg[] = {* for meter idx, so not set grow_trunk to avoid meter index * not jump continually. */ - .size = sizeof(struct mlx5_flow_meter), + .size = sizeof(struct mlx5_legacy_flow_meter), .trunk_size = 64, .need_lock = 1, .release_mem_en = 1,
drivers/net/mlx5/mlx5.h +200 -7
258 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow.c +54 -16
143 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow.h +48 -148
256 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_dv.c +189 -14
309 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_meter.c +277 -173
723 lines not on this page · raw message
Signature · 1 line
2.27.0
PATCH v5 10/14 net/mlx5: initialize the flow meter ASO SQ
In reply to Li ZhangInitialize the flow meter ASO SQ WQEs with
all the constant data that should not be updated
per enqueue operation.
---
drivers/net/mlx5/linux/mlx5_os.c | 16 ++++
drivers/net/mlx5/meson.build | 2 +-
drivers/net/mlx5/mlx5.c | 68 ++++++++++++-
drivers/net/mlx5/mlx5.h | 22 +++--
drivers/net/mlx5/mlx5_flow.h | 4 +-
.../mlx5/{mlx5_flow_age.c => mlx5_flow_aso.c} | 96 ++++++++++++++++---
drivers/net/mlx5/mlx5_flow_dv.c | 7 +-
drivers/net/mlx5/mlx5_flow_meter.c | 7 +-
8 files changed, 190 insertions(+), 32 deletions(-)
rename drivers/net/mlx5/{mlx5_flow_age.c => mlx5_flow_aso.c} (85%)drivers/net/mlx5/linux/mlx5_os.c +16 -0
@@ -1290,6 +1290,22 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, priv->mtr_color_reg); } } +if (config->hca_attr.qos.sup && + config->hca_attr.qos.flow_meter_aso_sup) { +uint32_t log_obj_size = +rte_log2_u32 (MLX5_ASO_MTRS_PER_POOL >>1 ); +if (log_obj_size >= + config->hca_attr.qos.log_meter_aso_granularity && + log_obj_size <= + config->hca_attr.qos.log_meter_aso_max_alloc) { + sh->meter_aso_en =1 ; + err =mlx5_aso_flow_mtrs_mng_init (priv); +if (err) { + err = -err; + goto error; + } + } + }#endif #ifdef HAVE_MLX5_DR_CREATE_ACTION_ASO if (config->hca_attr.flow_hit_aso &&
drivers/net/mlx5/meson.build +1 -1
@@ -15,7 +15,7 @@ sources = files( 'mlx5_flow.c', 'mlx5_flow_meter.c', 'mlx5_flow_dv.c', - 'mlx5_flow_age.c', + 'mlx5_flow_aso.c', 'mlx5_mac.c', 'mlx5_mr.c', 'mlx5_rss.c',
drivers/net/mlx5/mlx5.c +65 -3
92 lines not on this page · raw message
drivers/net/mlx5/mlx5.h +15 -7
@@ -482,8 +482,13 @@ struct mlx5_aso_devx_mr { };struct mlx5_aso_sq_elem { -struct mlx5_aso_age_pool *pool; -uint16_t burst_size; +union { +struct { +struct mlx5_aso_age_pool *pool; +uint16_t burst_size; + }; +struct mlx5_aso_mtr *mtr; + }; };struct mlx5_aso_sq {
@@ -755,7 +760,6 @@ struct mlx5_aso_mtr_pools_mng {volatile uint16_t n_valid;/* Number of valid pools. */ uint16_t n;/* Number of pools. */ rte_spinlock_t mtrsl;/* The ASO flow meter free list lock. */ -struct mlx5_l3t_tbl *mtr_idx_tbl;/* Meter index lookup table. */ struct aso_meter_list meters;/* Free ASO flow meter list. */ struct mlx5_aso_sq sq;/*SQ using by ASO flow meter. */ struct mlx5_aso_mtr_pool **pools;/* ASO flow meter pool array. */
@@ -1186,6 +1190,7 @@ struct mlx5_priv {uint8_t mtr_color_reg;/* Meter color match REG_C. */ struct mlx5_mtr_profiles flow_meter_profiles;/* MTR profile list. */ struct mlx5_legacy_flow_meters flow_meters;/* MTR list. */ +struct mlx5_l3t_tbl *mtr_idx_tbl;/* Meter index lookup table. */ uint8_t skip_default_rss_reta;/* Skip configuration of default reta. */ uint8_t fdb_def_rule;/* Whether fdb jump to table 1 is configured. */ struct mlx5_mp_id mp_id;/* ID of a multi-process process */
@@ -1249,6 +1254,7 @@ int mlx5_hairpin_cap_get(struct rte_eth_dev *dev,bool mlx5_flex_parser_ecpri_exist (struct rte_eth_dev *dev);int mlx5_flex_parser_ecpri_alloc (struct rte_eth_dev *dev);int mlx5_flow_aso_age_mng_init (struct mlx5_dev_ctx_shared *sh); +int mlx5_aso_flow_mtrs_mng_init (struct mlx5_priv *priv);/* mlx5_ethdev.c */
@@ -1519,9 +1525,11 @@ eth_tx_burst_t mlx5_select_tx_function(struct rte_eth_dev *dev);/* mlx5_flow_aso.c */ -int mlx5_aso_queue_init (struct mlx5_dev_ctx_shared *sh); -int mlx5_aso_queue_start (struct mlx5_dev_ctx_shared *sh); -int mlx5_aso_queue_stop (struct mlx5_dev_ctx_shared *sh); -void mlx5_aso_queue_uninit (struct mlx5_dev_ctx_shared *sh); +int mlx5_aso_queue_init (struct mlx5_dev_ctx_shared *sh, +enum mlx5_access_aso_opc_mod aso_opc_mod); +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);#endif /* RTE_PMD_MLX5_H_ */
drivers/net/mlx5/mlx5_flow.h +2 -2
@@ -827,8 +827,8 @@ struct mlx5_flow {#define MLX5_FLOW_METER_DISABLE 0#define MLX5_FLOW_METER_ENABLE 1 -#define MLX5_ASO_CQE_RESPONSE_DELAY 10 -#define MLX5_MTR_POLL_CQE_TIMES 100000u +#define MLX5_ASO_WQE_CQE_RESPONSE_DELAY 10u +#define MLX5_MTR_POLL_WQE_CQE_TIMES 100000u#define MLX5_MAN_WIDTH 8/* Legacy Meter parameter structure. */
drivers/net/mlx5/mlx5_flow_aso.c renamed from drivers/net/mlx5/mlx5_flow_age.c +82 -14
156 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_dv.c +6 -1
@@ -5962,6 +5962,11 @@ flow_dv_mtr_container_resize(struct rte_eth_dev *dev) rte_errno =ENOMEM ;return -ENOMEM ; } +if (!mtrmng->n) +if (mlx5_aso_queue_init (priv->sh,ASO_OPC_MOD_POLICER )) { +mlx5_free (pools); +return -ENOMEM ; + }if (old_pools)memcpy (pools, old_pools, mtrmng->n *sizeof (struct mlx5_aso_mtr_pool *));
@@ -10819,7 +10824,7 @@ flow_dv_aso_age_pools_resize(struct rte_eth_dev *dev)mlx5_free (old_pools); }else {/* First ASO flow hit allocation - starting ASO data-path. */ -int ret =mlx5_aso_queue_start (priv->sh); +int ret =mlx5_aso_flow_hit_queue_poll_start (priv->sh);if (ret) {mlx5_free (pools);
drivers/net/mlx5/mlx5_flow_meter.c +3 -4
@@ -811,7 +811,6 @@ mlx5_flow_meter_destroy(struct rte_eth_dev *dev, uint32_t meter_id, struct rte_mtr_error *error) {struct mlx5_priv *priv = dev->data->dev_private; -struct mlx5_aso_mtr_pools_mng *mtrmng = priv->sh->mtrmng;struct mlx5_flow_meter_info *fm;const struct rte_flow_attr attr = { .ingress =1 ,
@@ -836,7 +835,7 @@ mlx5_flow_meter_destroy(struct rte_eth_dev *dev, uint32_t meter_id,RTE_MTR_ERROR_TYPE_UNSPECIFIED , NULL, "Meter object is being used.");if (priv->sh->meter_aso_en) { -if (mlx5_l3t_clear_entry (mtrmng->mtr_idx_tbl, meter_id)) +if (mlx5_l3t_clear_entry (priv->mtr_idx_tbl, meter_id))return -rte_mtr_error_set (error,EBUSY ,RTE_MTR_ERROR_TYPE_UNSPECIFIED ,NULL ,"Fail to delete ASO Meter in index table." );
@@ -1302,7 +1301,7 @@ mlx5_flow_meter_find(struct mlx5_priv *priv, uint32_t meter_id,rte_spinlock_unlock (&mtrmng->mtrsl);return NULL ; } -if (mlx5_l3t_get_entry (mtrmng->mtr_idx_tbl, meter_id, &data) || +if (mlx5_l3t_get_entry (priv->mtr_idx_tbl, meter_id, &data) || !data.dword) {rte_spinlock_unlock (&mtrmng->mtrsl);return NULL ;
@@ -1310,7 +1309,7 @@ mlx5_flow_meter_find(struct mlx5_priv *priv, uint32_t meter_id,if (mtr_idx) *mtr_idx = data.dword; aso_mtr =mlx5_aso_meter_by_idx (priv, data.dword); -mlx5_l3t_clear_entry (mtrmng->mtr_idx_tbl, meter_id); +mlx5_l3t_clear_entry (priv->mtr_idx_tbl, meter_id);if (meter_id == aso_mtr->fm.meter_id) {rte_spinlock_unlock (&mtrmng->mtrsl);return &aso_mtr->fm;
Signature · 1 line
2.27.0
PATCH v5 11/14 net/mlx5: aso flow meter send WQE and CQE handle
In reply to Li ZhangASO flow meter send WQE and CQE handle functions
--- drivers/net/mlx5/mlx5.h | 4 + drivers/net/mlx5/mlx5_flow_aso.c | 183 ++++++++++++++++++++++++++++- drivers/net/mlx5/mlx5_flow_meter.c | 143 +++++++++++++--------- 3 files changed, 274 insertions(+), 56 deletions(-)
drivers/net/mlx5/mlx5.h +4 -0
@@ -1531,5 +1531,9 @@ 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, +struct mlx5_aso_mtr *mtr); +int mlx5_aso_mtr_wait (struct mlx5_dev_ctx_shared *sh, +struct mlx5_aso_mtr *mtr);#endif /* RTE_PMD_MLX5_H_ */
drivers/net/mlx5/mlx5_flow_aso.c +182 -1
192 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_meter.c +88 -55
221 lines not on this page · raw message
Signature · 1 line
2.27.0
Re: [dpdk-dev] [PATCH v5 11/14] net/mlx5: aso flow meter send WQE and CQE handle
Quoted 2 lines · Li Zhang
ASO flow meter send WQE and CQE handle functions
Can you please update patch title, to stat with the action?
And can you please clarify the abbreviations used, same for all patch commit logs?
Thanks.
Quoted 2 lines
Signed-off-by Li Zhang <[email protected]>Acked-by Matan Azrad <[email protected]>
<...>
Re: [dpdk-dev] [PATCH v5 11/14] net/mlx5: aso flow meter send WQE and CQE handle
19/04/2021 23:46, Ferruh Yigit:
Quoted 5 lines · Li Zhang
Quoted 2 lines
ASO flow meter send WQE and CQE handle functions
Can you please update patch title, to stat with the action?
You mean "start" with the action verb.
Quoted 1 line
And can you please clarify the abbreviations used, same for all patch commit logs?
And "aso" should be uppercase "ASO" like any acronym.
Re: [dpdk-dev] [PATCH v5 11/14] net/mlx5: aso flow meter send WQE and CQE handle
Hi,
Quoted 11 lines
-----Original Message-----
From: Thomas Monjalon <[email protected]>
Sent: Tuesday, April 20, 2021 6:02 AM
To: Li Zhang <[email protected]>; Ferruh Yigit <[email protected]>; Asaf Penso <[email protected]>
Cc: Ori Kam <[email protected]>; Slava Ovsiienko <[email protected]>; Matan Azrad <[email protected]>; [email protected]; Raslan Darawsheh <[email protected]>; Jiawei(Jonny) Wang <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v5 11/14] net/mlx5: aso flow meter send WQE and CQE handle
Quoted 9 lines
19/04/2021 23:46, Ferruh Yigit:
Quoted 5 lines · Li Zhang
Quoted 2 lines
ASO flow meter send WQE and CQE handle functions
Can you please update patch title, to stat with the action?
You mean "start" with the action verb.
Will change the title to:" net/mlx5: add meter ASO queue management"
Quoted 6 lines
Quoted 1 line
And can you please clarify the abbreviations used, same for all patch
commit logs?
And "aso" should be uppercase "ASO" like any acronym.
Yes, change to uppercase.
Thanks.
PATCH v5 12/14 net/mlx5: add support of ASO meter action
In reply to Li ZhangWhen ASO action is available, use it as the meter action
--- drivers/net/mlx5/linux/mlx5_os.c | 4 +- drivers/net/mlx5/mlx5.c | 12 ++++ drivers/net/mlx5/mlx5.h | 7 ++- drivers/net/mlx5/mlx5_flow.c | 74 +++++++++++++++++------ drivers/net/mlx5/mlx5_flow_dv.c | 29 +++++++-- drivers/net/mlx5/mlx5_flow_meter.c | 97 +++++++++++++++++++----------- 6 files changed, 163 insertions(+), 60 deletions(-)
drivers/net/mlx5/linux/mlx5_os.c +3 -1
@@ -1255,7 +1255,9 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,"required for coalescing is %d bytes" , config->hca_attr.lro_min_mss_size); } -#if defined(HAVE_MLX5DV_DR ) && defined(HAVE_MLX5_DR_CREATE_ACTION_FLOW_METER ) +#if defined(HAVE_MLX5DV_DR ) && \ + (defined(HAVE_MLX5_DR_CREATE_ACTION_FLOW_METER ) || \ + defined(HAVE_MLX5_DR_CREATE_ACTION_ASO ))if (config->hca_attr.qos.sup && config->hca_attr.qos.flow_meter_old && config->dv_flow_en) {
drivers/net/mlx5/mlx5.c +12 -0
@@ -609,11 +609,23 @@ mlx5_aso_flow_mtrs_mng_close(struct mlx5_dev_ctx_shared *sh)struct mlx5_aso_mtr_pool *mtr_pool;struct mlx5_aso_mtr_pools_mng *mtrmng = sh->mtrmng;uint32_t idx; +#ifdef HAVE_MLX5_DR_CREATE_ACTION_ASO +struct mlx5_aso_mtr *aso_mtr; +int i; +#endif /* HAVE_MLX5_DR_CREATE_ACTION_ASO */ mlx5_aso_queue_uninit (sh,ASO_OPC_MOD_POLICER ); idx = mtrmng->n_valid;while (idx--) { mtr_pool = mtrmng->pools[idx]; +#ifdef HAVE_MLX5_DR_CREATE_ACTION_ASO +for (i =0 ; i <MLX5_ASO_MTRS_PER_POOL ; i++) { + aso_mtr = &mtr_pool->mtrs[i]; +if (aso_mtr->fm.meter_action) +claim_zero (mlx5_glue->destroy_flow_action + (aso_mtr->fm.meter_action)); + } +#endif /* HAVE_MLX5_DR_CREATE_ACTION_ASO */ claim_zero (mlx5_devx_cmd_destroy (mtr_pool->devx_obj)); mtrmng->n_valid--;
drivers/net/mlx5/mlx5.h +4 -3
@@ -625,8 +625,6 @@ struct mlx5_meter_domains_infos {/**< Counters for green rule. */ void *drop_count;/**< Counters for green rule. */ -void *meter_action; -/**< Flow meter action. */ };/* Meter parameter structure. */
@@ -689,6 +687,8 @@ struct mlx5_flow_meter_info {/**< Use count. */ struct mlx5_indexed_pool *flow_ipool;/**< Index pool for flow id. */ +void *meter_action; +/**< Flow meter action. */ };/* RFC2697 parameter structure. */
@@ -1478,7 +1478,8 @@ int mlx5_flow_meter_attach(struct mlx5_priv *priv,struct mlx5_flow_meter_info *fm, const struct rte_flow_attr *attr, struct rte_flow_error *error); -void mlx5_flow_meter_detach (struct mlx5_flow_meter_info *fm); +void mlx5_flow_meter_detach (struct mlx5_priv *priv, +struct mlx5_flow_meter_info *fm);/* mlx5_os.c */ struct rte_pci_driver ;
drivers/net/mlx5/mlx5_flow.c +56 -18
135 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_dv.c +25 -4
@@ -4891,9 +4891,11 @@ mlx5_flow_validate_action_meter(struct rte_eth_dev *dev,return rte_flow_error_set (error,EINVAL ,RTE_FLOW_ERROR_TYPE_ACTION ,NULL ,"Meter not found" ); -if (fm->ref_cnt && (!(fm->transfer == attr->transfer || +/* aso meter can always be shared by different domains */ +if (fm->ref_cnt && !priv->sh->meter_aso_en && + !(fm->transfer == attr->transfer || (!fm->ingress && !attr->ingress && attr->egress) || - (!fm->egress && !attr->egress && attr->ingress)))) + (!fm->egress && !attr->egress && attr->ingress)))return rte_flow_error_set (error,EINVAL ,RTE_FLOW_ERROR_TYPE_ACTION ,NULL , "Flow attributes are either invalid "
@@ -6096,6 +6098,25 @@ flow_dv_mtr_alloc(struct rte_eth_dev *dev) struct mlx5_aso_mtr_pool, mtrs[mtr_free->offset]); mtr_idx =MLX5_MAKE_MTR_IDX (pool->index, mtr_free->offset); +if (!mtr_free->fm.meter_action) { +#ifdef HAVE_MLX5_DR_CREATE_ACTION_ASO +struct rte_flow_error error; +uint8_t reg_id; + + reg_id =mlx5_flow_get_reg_id (dev,MLX5_MTR_COLOR ,0 , &error); + mtr_free->fm.meter_action = + mlx5_glue->dv_create_flow_action_aso + (priv->sh->rx_domain, + pool->devx_obj->obj, + mtr_free->offset, + (1 <<MLX5_FLOW_COLOR_GREEN ), + reg_id -REG_C_0 ); +#endif /* HAVE_MLX5_DR_CREATE_ACTION_ASO */ +if (!mtr_free->fm.meter_action) { +flow_dv_aso_mtr_release_to_pool (dev, mtr_idx); +return 0 ; + } + }return mtr_idx; }
@@ -11580,7 +11601,7 @@ flow_dv_translate(struct rte_eth_dev *dev, NULL, "Failed to get meter in flow.");/* Set the meter action. */ dev_flow->dv.actions[actions_n++] = - wks->fm->mfts->meter_action; + wks->fm->meter_action; action_flags |=MLX5_FLOW_ACTION_METER ;break ;case RTE_FLOW_ACTION_TYPE_SET_IPV4_DSCP :
@@ -12742,7 +12763,7 @@ flow_dv_destroy(struct rte_eth_dev *dev, struct rte_flow *flow)if (flow->meter) { fm =flow_dv_meter_find_by_idx (priv, flow->meter);if (fm) -mlx5_flow_meter_detach (fm); +mlx5_flow_meter_detach (priv, fm); flow->meter =0 ; }if (flow->age)
drivers/net/mlx5/mlx5_flow_meter.c +63 -34
141 lines not on this page · raw message
Signature · 1 line
2.27.0
PATCH v5 13/14 net/mlx5: make ASO meter queue thread-safe
In reply to Li ZhangSynchronize ASO meter queue accesses from
different threads using a spinlock.
--- drivers/net/mlx5/mlx5.h | 1 + drivers/net/mlx5/mlx5_flow_aso.c | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-)
drivers/net/mlx5/mlx5.h +1 -0
@@ -493,6 +493,7 @@ struct mlx5_aso_sq_elem {struct mlx5_aso_sq {uint16_t log_desc_n; +rte_spinlock_t sqsl;struct mlx5_aso_cq cq;struct mlx5_devx_sq sq_obj;volatile uint64_t *uar_addr;
drivers/net/mlx5/mlx5_flow_aso.c +13 -3
@@ -274,6 +274,7 @@ mlx5_aso_sq_create(void *ctx, struct mlx5_aso_sq *sq, int socket, sq->tail =0 ; sq->sqn = sq->sq_obj.sq->id; sq->uar_addr =mlx5_os_get_devx_uar_reg_addr (uar); +rte_spinlock_init (&sq->sqsl);return 0 ; error:mlx5_aso_destroy_sq (sq);
@@ -665,12 +666,15 @@ mlx5_aso_mtr_sq_enqueue_single(struct mlx5_aso_sq *sq,struct mlx5_flow_meter_info *fm =NULL ;uint16_t size =1 << sq->log_desc_n;uint16_t mask = size -1 ; -uint16_t res = size - (uint16_t )(sq->head - sq->tail); +uint16_t res;uint32_t dseg_idx =0 ;struct mlx5_aso_mtr_pool *pool =NULL ; +rte_spinlock_lock (&sq->sqsl); + res = size - (uint16_t )(sq->head - sq->tail);if (unlikely (!res)) {DRV_LOG (ERR ,"Fail: SQ is full and no free WQE to send" ); +rte_spinlock_unlock (&sq->sqsl);return 0 ; } wqe = &sq->sq_obj.aso_wqes[sq->head & mask];
@@ -707,6 +711,7 @@ mlx5_aso_mtr_sq_enqueue_single(struct mlx5_aso_sq *sq,rte_wmb (); *sq->uar_addr = *(volatile uint64_t *)wqe;/* Assume 64 bit ARCH. */ rte_wmb (); +rte_spinlock_unlock (&sq->sqsl);return 1 ; }
@@ -737,12 +742,16 @@ mlx5_aso_mtr_completion_handle(struct mlx5_aso_sq *sq)const unsigned int mask = cq_size -1 ;uint32_t idx;uint32_t next_idx = cq->cq_ci & mask; -const uint16_t max = (uint16_t )(sq->head - sq->tail); +uint16_t max;uint16_t n =0 ;int ret; -if (unlikely (!max)) +rte_spinlock_lock (&sq->sqsl); + max = (uint16_t )(sq->head - sq->tail); +if (unlikely (!max)) { +rte_spinlock_unlock (&sq->sqsl);return ; + } do { idx = next_idx; next_idx = (cq->cq_ci + 1) & mask;
@@ -769,6 +778,7 @@ mlx5_aso_mtr_completion_handle(struct mlx5_aso_sq *sq)rte_io_wmb (); cq->cq_obj.db_rec[0 ] =rte_cpu_to_be_32 (cq->cq_ci); } +rte_spinlock_unlock (&sq->sqsl); }/**
Signature · 1 line
2.27.0
PATCH v5 14/14 net/mlx5: allow multiple flow tables on the same level
In reply to Li ZhangThe driver devices support creation of multiple flow tables. Jump action can be used in order to move the packet steering to different flow table.
Table 0 is always the root table for packet steering.
Jumping between tables may cause endless loops in steering mechanism, that's why each table has level attribute,
the driver sub-system may not allow jumping to table with equal or lower level than the current table.
Currently, in the driver, the table ID and level are always identical.
Allow multiple flow table creation with the same level attribute.
This patch adds the table id in flow table data entry, while allocates the flow table, if the table level is same but the different table id, the new table will be allocated with new table object id. It supports 4M multiple flow tables on the same level.
--- drivers/net/mlx5/mlx5.c | 9 ++-- drivers/net/mlx5/mlx5.h | 10 ++-- drivers/net/mlx5/mlx5_flow.c | 17 ++++--- drivers/net/mlx5/mlx5_flow.h | 12 +++-- drivers/net/mlx5/mlx5_flow_dv.c | 84 +++++++++++++++++++-------------- 5 files changed, 79 insertions(+), 53 deletions(-)
drivers/net/mlx5/mlx5.c +6 -3
@@ -1271,9 +1271,12 @@ mlx5_alloc_table_hash_list(struct mlx5_priv *priv __rte_unused)* because DV expect to see them even if they cannot be created by * RDMA-CORE. */ -if (!flow_dv_tbl_resource_get (dev,0 ,0 ,0 ,0 ,NULL ,0 ,1 , &error) || - !flow_dv_tbl_resource_get (dev,0 ,1 ,0 ,0 ,NULL ,0 ,1 , &error) || - !flow_dv_tbl_resource_get (dev,0 ,0 ,1 ,0 ,NULL ,0 ,1 , &error)) { +if (!flow_dv_tbl_resource_get (dev,0 ,0 ,0 ,0 , +NULL ,0 ,1 ,0 , &error) || + !flow_dv_tbl_resource_get (dev,0 ,1 ,0 ,0 , +NULL ,0 ,1 ,0 , &error) || + !flow_dv_tbl_resource_get (dev,0 ,0 ,1 ,0 , +NULL ,0 ,1 ,0 , &error)) { err =ENOMEM ; goto error; }
drivers/net/mlx5/mlx5.h +6 -4
@@ -770,10 +770,12 @@ struct mlx5_aso_mtr_pools_mng {union mlx5_flow_tbl_key {struct {/* Table ID should be at the lowest address. */ -uint32_t table_id;/**< ID of the table. */ -uint16_t dummy;/**< Dummy table for DV API. */ -uint8_t domain;/**< 1 - FDB, 0 - NIC TX/RX. */ -uint8_t direction;/**< 1 - egress, 0 - ingress. */ +uint32_t level;/**< Level of the table. */ +uint32_t id:22 ;/**< ID of the table. */ +uint32_t dummy:1 ;/**< Dummy table for DV API. */ +uint32_t is_fdb:1 ;/**< 1 - FDB, 0 - NIC TX/RX. */ +uint32_t is_egress:1 ;/**< 1 - egress, 0 - ingress. */ +uint32_t reserved:7 ;/**< must be zero for comparison. */ };uint64_t v64;/**< full 64bits value of key */ };
drivers/net/mlx5/mlx5_flow.c +11 -6
@@ -4343,6 +4343,9 @@ flow_create_split_inner(struct rte_eth_dev *dev, dev_flow->handle->mark =1 ;if (sub_flow) *sub_flow = dev_flow; +#ifdef HAVE_IBV_FLOW_DV_SUPPORT + dev_flow->dv.table_id = flow_split_info->table_id; +#endif return flow_drv_translate (dev, dev_flow, attr, items, actions, error); }
@@ -5490,8 +5493,7 @@ flow_create_split_sample(struct rte_eth_dev *dev, struct mlx5_flow_tbl_data_entry, tbl); sfx_attr.group = sfx_attr.transfer ? - (sfx_tbl_data->table_id -1 ) : - sfx_tbl_data->table_id; + (sfx_tbl_data->level -1 ) : sfx_tbl_data->level; }else {MLX5_ASSERT (attr->transfer); sfx_attr.group = jump_table;
@@ -5691,7 +5693,8 @@ flow_list_create(struct rte_eth_dev *dev, uint32_t *list, .skip_scale = 0, .flow_idx = 0, .prefix_mark = 0, - .prefix_layers = 0 + .prefix_layers = 0, + .table_id = 0 };int ret;
@@ -7747,10 +7750,12 @@ tunnel_mark_decode(struct rte_eth_dev *dev, uint32_t mark)union tunnel_offload_mark mbits = { .val = mark };union mlx5_flow_tbl_key table_key = { { - .table_id =tunnel_id_to_flow_tbl (mbits.table_id), + .level =tunnel_id_to_flow_tbl (mbits.table_id), + .id =0 , + .reserved =0 , .dummy =0 , - .domain = !!mbits.transfer, - .direction =0 , + .is_fdb = !!mbits.transfer, + .is_egress =0 , } }; he =mlx5_hlist_lookup (sh->flow_tbls, table_key.v64,NULL );
drivers/net/mlx5/mlx5_flow.h +8 -4
@@ -565,8 +565,9 @@ struct mlx5_flow_tbl_data_entry { uint32_t is_egress:1; /**< Egress table. */ uint32_t is_transfer:1; /**< Transfer table. */ uint32_t dummy:1; /**< DR table. */ - uint32_t reserve:27; /**< Reserved to future using. */ -uint32_t table_id;/**< Table ID. */ + uint32_t id:22; /**< Table ID. */ + uint32_t reserve:5; /**< Reserved to future using. */ +uint32_t level;/**< Table level. */ };/* Sub rdma-core actions list. */
@@ -700,6 +701,7 @@ struct mlx5_flow_handle {/** Device flow structure only for DV flow creation. */ struct mlx5_flow_dv_workspace {uint32_t group;/**< The group index. */ +uint32_t table_id;/**< Flow table identifier. */ uint8_t transfer;/**< 1 if the flow is E-Switch flow. */ int actions_n;/**< number of actions. */ void *actions[MLX5_DV_MAX_NUMBER_OF_ACTIONS ];/**< Action list. */
@@ -1060,6 +1062,7 @@ struct mlx5_flow_split_info {uint32_t flow_idx;/**< This memory pool index to the flow. */ uint32_t prefix_mark;/**< Prefix subflow mark flag. */ uint64_t prefix_layers;/**< Prefix subflow layers. */ +uint32_t table_id;/**< Flow table identifier. */ }; typedef int (*mlx5_flow_validate_t)(struct rte_eth_dev *dev,
@@ -1411,9 +1414,10 @@ int flow_dv_tbl_match_cb(struct mlx5_hlist *list,void flow_dv_tbl_remove_cb (struct mlx5_hlist *list,struct mlx5_hlist_entry *entry);struct mlx5_flow_tbl_resource *flow_dv_tbl_resource_get (struct rte_eth_dev *dev, -uint32_t table_id,uint8_t egress,uint8_t transfer, +uint32_t table_level,uint8_t egress,uint8_t transfer,bool external,const struct mlx5_flow_tunnel *tunnel, -uint32_t group_id,uint8_t dummy,struct rte_flow_error *error); +uint32_t group_id,uint8_t dummy, +uint32_t table_id,struct rte_flow_error *error);struct mlx5_hlist_entry *flow_dv_tag_create_cb (struct mlx5_hlist *list,uint64_t key,void *cb_ctx);
drivers/net/mlx5/mlx5_flow_dv.c +48 -36
205 lines not on this page · raw message
Signature · 1 line
2.27.0
Hi,
Quoted 61 lines
-----Original Message-----
From: Li Zhang <[email protected]>
Sent: Thursday, April 15, 2021 6:11 PM
To: [email protected]; Ori Kam <[email protected]>; Slava Ovsiienko <[email protected]>; Matan Azrad <[email protected]>; Shahaf Shuler <[email protected]>
Cc: [email protected]; NBU-Contact-Thomas Monjalon <[email protected]>; Raslan Darawsheh <[email protected]>; Roni Bar Yanai <[email protected]>
Subject: [PATCH v5 00/14] Add ASO meter support in MLX5 PMDTo support more meters and better performance,
MLX HW provide ASO flow meter.
It can expose millions of ASO flow meter context's in HW. This ASO object can allocate the large bulk meter objects. This patch set implement the ASO flow meter for mlx5 driver. MLX5 PMD driver will be responsible for ASO flow meter manage to HW.V2: Fix compile error issue (
mlx5_glue->destroy_flow_action)
V3: Fix comments.
V4: Fix comments and add Acked.
V5: Fix unusedlog_obj_sizeissue.Li Zhang (10):
net/mlx5: optimize meter statistics
common/mlx5: add definitions for ASO flow meter common/mlx5: add read ASO flow meter HCA capability common/mlx5: add DevX API to create ASO flow meter object net/mlx5: flow meter pool to manage meter object net/mlx5: initialize the flow meter ASO SQ net/mlx5: aso flow meter send WQE and CQE handle net/mlx5: add support of ASO meter action net/mlx5: make ASO meter queue thread-safe net/mlx5: allow multiple flow tables on the same levelShun Hao (3):
common/mlx5: add color register idle bits definition net/mlx5: fix meter statistics
net/mlx5: use mask for meter register settingSuanming Mou (1):
net/mlx5: support three level table walkdoc/guides/nics/mlx5.rst | 6 + drivers/common/mlx5/mlx5_devx_cmds.c | 68 ++ drivers/common/mlx5/mlx5_devx_cmds.h | 26 +- drivers/common/mlx5/mlx5_prm.h | 81 +- drivers/common/mlx5/version.map | 1 + drivers/net/mlx5/linux/mlx5_os.c | 20 +- drivers/net/mlx5/meson.build | 2 +- drivers/net/mlx5/mlx5.c | 98 +- drivers/net/mlx5/mlx5.h | 258 +++++- drivers/net/mlx5/mlx5_flow.c | 334 +++++-- drivers/net/mlx5/mlx5_flow.h | 212 ++--- .../mlx5/{mlx5_flow_age.c => mlx5_flow_aso.c} | 289 +++++- drivers/net/mlx5/mlx5_flow_dv.c | 792 +++++++++++----- drivers/net/mlx5/mlx5_flow_meter.c | 873 ++++++++++++------ drivers/net/mlx5/mlx5_utils.h | 90 ++ 15 files changed, 2320 insertions(+), 830 deletions(-) rename drivers/net/mlx5/{mlx5_flow_age.c => mlx5_flow_aso.c} (65%)
Quoted 2 lines
--
2.27.0
Series applied to next-net-mlx,
Kindest regards,
Raslan Darawsheh
Quoted 7 lines · Li Zhang
To support more meters and better performance,
MLX HW provide ASO flow meter.
It can expose millions of ASO flow meter context's in HW. This ASO object can allocate the large bulk meter objects. This patch set implement the ASO flow meter for mlx5 driver. MLX5 PMD driver will be responsible for ASO flow meter manage to HW.
What is ASO?
Search yields "Advanced Steering Operation" but that seems Mellanox jargon,
would you mind adding some mlx documentation to describe it? If there are some design considerations around it, it may be good to document that too. Also please provide the long version of the abbreviation in the commit log, at least at first usage of it.
And what do you think mentioning from this new support in the release notes?
Thanks,
ferruh
Quoted 43 lines
V2: Fix compile error issue (
mlx5_glue->destroy_flow_action)
V3: Fix comments.
V4: Fix comments and add Acked.
V5: Fix unusedlog_obj_sizeissue.Li Zhang (10):
net/mlx5: optimize meter statistics common/mlx5: add definitions for ASO flow meter common/mlx5: add read ASO flow meter HCA capability common/mlx5: add DevX API to create ASO flow meter object net/mlx5: flow meter pool to manage meter object net/mlx5: initialize the flow meter ASO SQ net/mlx5: aso flow meter send WQE and CQE handle net/mlx5: add support of ASO meter action net/mlx5: make ASO meter queue thread-safe net/mlx5: allow multiple flow tables on the same levelShun Hao (3):
common/mlx5: add color register idle bits definition net/mlx5: fix meter statistics
net/mlx5: use mask for meter register settingSuanming Mou (1):
net/mlx5: support three level table walkdoc/guides/nics/mlx5.rst | 6 + drivers/common/mlx5/mlx5_devx_cmds.c | 68 ++ drivers/common/mlx5/mlx5_devx_cmds.h | 26 +- drivers/common/mlx5/mlx5_prm.h | 81 +- drivers/common/mlx5/version.map | 1 + drivers/net/mlx5/linux/mlx5_os.c | 20 +- drivers/net/mlx5/meson.build | 2 +- drivers/net/mlx5/mlx5.c | 98 +- drivers/net/mlx5/mlx5.h | 258 +++++- drivers/net/mlx5/mlx5_flow.c | 334 +++++-- drivers/net/mlx5/mlx5_flow.h | 212 ++--- .../mlx5/{mlx5_flow_age.c => mlx5_flow_aso.c} | 289 +++++- drivers/net/mlx5/mlx5_flow_dv.c | 792 +++++++++++----- drivers/net/mlx5/mlx5_flow_meter.c | 873 ++++++++++++------ drivers/net/mlx5/mlx5_utils.h | 90 ++ 15 files changed, 2320 insertions(+), 830 deletions(-)rename
drivers/net/mlx5/{mlx5_flow_age.c=>mlx5_flow_aso.c} (65%)
19/04/2021 23:42, Ferruh Yigit:
Quoted 9 lines · Li Zhang
Quoted 7 lines
To support more meters and better performance,
MLX HW provide ASO flow meter.
It can expose millions of ASO flow meter context's in HW. This ASO object can allocate the large bulk meter objects. This patch set implement the ASO flow meter for mlx5 driver. MLX5 PMD driver will be responsible for ASO flow meter manage to HW.
Quoted 8 lines
What is ASO?
Search yields "Advanced Steering Operation" but that seems Mellanox jargon, would you mind adding some mlx documentation to describe it? If there are some design considerations around it, it may be good to document that too. Also please provide the long version of the abbreviation in the commit log, at least at first usage of it.And what do you think mentioning from this new support in the release notes?
Yes, new PMD feature should be announced in the release notes, it seems to be a miss.
Quoted 16 lines
Quoted 16 lines
doc/guides/nics/mlx5.rst | 6 + drivers/common/mlx5/mlx5_devx_cmds.c | 68 ++ drivers/common/mlx5/mlx5_devx_cmds.h | 26 +- drivers/common/mlx5/mlx5_prm.h | 81 +- drivers/common/mlx5/version.map | 1 + drivers/net/mlx5/linux/mlx5_os.c | 20 +- drivers/net/mlx5/meson.build | 2 +- drivers/net/mlx5/mlx5.c | 98 +- drivers/net/mlx5/mlx5.h | 258 +++++- drivers/net/mlx5/mlx5_flow.c | 334 +++++-- drivers/net/mlx5/mlx5_flow.h | 212 ++--- .../mlx5/{mlx5_flow_age.c => mlx5_flow_aso.c} | 289 +++++- drivers/net/mlx5/mlx5_flow_dv.c | 792 +++++++++++----- drivers/net/mlx5/mlx5_flow_meter.c | 873 ++++++++++++------ drivers/net/mlx5/mlx5_utils.h | 90 ++ 15 files changed, 2320 insertions(+), 830 deletions(-)
Hi,
Quoted 21 lines
-----Original Message-----
From: Thomas Monjalon <[email protected]>
Sent: Tuesday, April 20, 2021 5:59 AM
To: Li Zhang <[email protected]>; Ferruh Yigit <[email protected]>
Cc: Ori Kam <[email protected]>; Slava Ovsiienko <[email protected]>; Matan Azrad <[email protected]>; [email protected]; Raslan Darawsheh <[email protected]>; Asaf Penso <[email protected]>; Jiawei(Jonny) Wang <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v5 00/14] Add ASO meter support in MLX5 PMD19/04/2021 23:42, Ferruh Yigit:
Quoted 9 lines · Li Zhang
Quoted 7 lines
To support more meters and better performance, MLX HW provide ASO flow meter.
It can expose millions of ASO flow meter context's in HW. This ASO object can allocate the large bulk meter objects. This patch set implement the ASO flow meter for mlx5 driver. MLX5 PMD driver will be responsible for ASO flow meter manage to HW.
Quoted 5 lines
Quoted 4 lines
What is ASO?
Search yields "Advanced Steering Operation" but that seems Mellanox jargon, would you mind adding some mlx documentation to describe it? If there are some design considerations around it, it may be good todocument that too.
Yes, ASO means (Advanced Steering Operation) and it's MLX5 internal usage, we adds the usage in the commit log.
Quoted 3 lines
Quoted 3 lines
Also please provide the long version of the abbreviation in the commit log, at least at first usage of it.
Ok, will add it.
Quoted 6 lines
Quoted 1 line
And what do you think mentioning from this new support in the release
notes?
Yes, new PMD feature should be announced in the release notes, it seems to be a miss.
Yes, will add the description in release_notes_21.05.rst
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
doc/guides/nics/mlx5.rst | 6 + drivers/common/mlx5/mlx5_devx_cmds.c | 68 ++ drivers/common/mlx5/mlx5_devx_cmds.h | 26 +- drivers/common/mlx5/mlx5_prm.h | 81 +- drivers/common/mlx5/version.map | 1 + drivers/net/mlx5/linux/mlx5_os.c | 20 +- drivers/net/mlx5/meson.build | 2 +- drivers/net/mlx5/mlx5.c | 98 +-
Quoted 10 lines
Quoted 8 lines
Quoted 8 lines
drivers/net/mlx5/mlx5.h | 258 +++++- drivers/net/mlx5/mlx5_flow.c | 334 +++++-- drivers/net/mlx5/mlx5_flow.h | 212 ++--- .../mlx5/{mlx5_flow_age.c => mlx5_flow_aso.c} | 289 +++++- drivers/net/mlx5/mlx5_flow_dv.c | 792 +++++++++++----- drivers/net/mlx5/mlx5_flow_meter.c | 873 ++++++++++++------ drivers/net/mlx5/mlx5_utils.h | 90 ++ 15 files changed, 2320 insertions(+), 830 deletions(-)
Thanks.
v6 cover Add ASO meter support in MLX5 PMD
In reply to Li ZhangTo support more meters and better performance,
MLX HW provides ASO (Advanced Steering Operation) flow meter. It can expose millions of ASO flow meter context's in HW. This ASO object can allocate the large bulk meter objects. This patch set implement the ASO flow meter for mlx5 driver. MLX5 PMD driver will be responsible for ASO flow meter manage to HW.
V2: Fix compile error issue (mlx5_glue->destroy_flow_action)
V3: Fix comments.
V4: Fix comments and add Acked.
V5: Fix unused log_obj_size issue.
V6: Fix comments and update release notes.
Jiawei Wang (1):
doc: update release notes for ASO meter
Li Zhang (10):
net/mlx5: optimize meter statistics
common/mlx5: add definitions for ASO flow meter common/mlx5: add read ASO flow meter HCA capability common/mlx5: add DevX API to create ASO flow meter object net/mlx5: flow meter pool to manage meter object net/mlx5: initialize the flow meter ASO SQ net/mlx5: add meter ASO queue management net/mlx5: add support of ASO meter action net/mlx5: make ASO meter queue thread-safe net/mlx5: allow multiple flow tables on the same level
Shun Hao (3):
common/mlx5: add color register idle bits definition net/mlx5: fix meter statistics
net/mlx5: use mask for meter register setting
Suanming Mou (1):
net/mlx5: support three level table walk
doc/guides/nics/mlx5.rst | 6 + doc/guides/rel_notes/release_21_05.rst | 1 + drivers/common/mlx5/mlx5_devx_cmds.c | 68 +++ drivers/common/mlx5/mlx5_devx_cmds.h | 26 +- drivers/common/mlx5/mlx5_prm.h | 81 ++- drivers/common/mlx5/version.map | 1 + drivers/net/mlx5/linux/mlx5_os.c | 20 +- drivers/net/mlx5/meson.build | 2 +- drivers/net/mlx5/mlx5.c | 98 +++- drivers/net/mlx5/mlx5.h | 258 +++++++++- drivers/net/mlx5/mlx5_flow.c | 334 +++++++++---- drivers/net/mlx5/mlx5_flow.h | 212 +++----- drivers/net/mlx5/mlx5_flow_age.c | 591 ---------------------- drivers/net/mlx5/mlx5_flow_aso.c | 850 ++++++++++++++++++++++++++++++++ drivers/net/mlx5/mlx5_flow_dv.c | 792 +++++++++++++++++++++--------- drivers/net/mlx5/mlx5_flow_meter.c | 873 +++++++++++++++++++++------------ drivers/net/mlx5/mlx5_utils.h | 90 ++++ 17 files changed, 2897 insertions(+), 1406 deletions(-) delete mode 100644 drivers/net/mlx5/mlx5_flow_age.c create mode 100644 drivers/net/mlx5/mlx5_flow_aso.c
Signature · 1 line
1.8.3.1
PATCH v6 1/15 net/mlx5: support three level table walk
From: Suanming Mou <[email protected]>
This commit adds table entry walk for the three level table.
--- drivers/net/mlx5/mlx5_utils.h | 90 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+)
drivers/net/mlx5/mlx5_utils.h +90 -0
@@ -834,6 +834,91 @@ int32_t mlx5_l3t_prepare_entry(struct mlx5_l3t_tbl *tbl, uint32_t idx,int32_t mlx5_l3t_set_entry (struct mlx5_l3t_tbl *tbl,uint32_t idx,union mlx5_l3t_data *data); +static inline void * +mlx5_l3t_get_next (struct mlx5_l3t_tbl *tbl,uint32_t *pos) +{ +struct mlx5_l3t_level_tbl *g_tbl, *m_tbl; +uint32_t i, j, k, g_start, m_start, e_start; +uint32_t idx = *pos; +void *e_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; + +if (!tbl) +return NULL ; + g_tbl = tbl->tbl; +if (!g_tbl) +return NULL ; + g_start = (idx >>MLX5_L3T_GT_OFFSET ) &MLX5_L3T_GT_MASK ; + m_start = (idx >>MLX5_L3T_MT_OFFSET ) &MLX5_L3T_MT_MASK ; + e_start = idx &MLX5_L3T_ET_MASK ; +for (i = g_start; i <MLX5_L3T_GT_SIZE ; i++) { + m_tbl = g_tbl->tbl[i]; +if (!m_tbl) { +/* Jump to new table, reset the sub table start. */ + m_start =0 ; + e_start =0 ; +continue ; + } +for (j = m_start; j <MLX5_L3T_MT_SIZE ; j++) { +if (!m_tbl->tbl[j]) { +/* +* Jump to new table, reset the sub table +* start. +*/ + e_start =0 ; +continue ; + } + e_tbl = m_tbl->tbl[j]; +switch (tbl->type) { +case MLX5_L3T_TYPE_WORD : + w_e_tbl = (struct mlx5_l3t_entry_word *)e_tbl; +for (k = e_start; k <MLX5_L3T_ET_SIZE ; k++) { +if (!w_e_tbl->entry[k].data) +continue ; + *pos = (i <<MLX5_L3T_GT_OFFSET ) | + (j <<MLX5_L3T_MT_OFFSET ) | k; +return (void *)&w_e_tbl->entry[k].data; + } +break ; +case MLX5_L3T_TYPE_DWORD : + dw_e_tbl = (struct mlx5_l3t_entry_dword *)e_tbl; +for (k = e_start; k <MLX5_L3T_ET_SIZE ; k++) { +if (!dw_e_tbl->entry[k].data) +continue ; + *pos = (i <<MLX5_L3T_GT_OFFSET ) | + (j <<MLX5_L3T_MT_OFFSET ) | k; +return (void *)&dw_e_tbl->entry[k].data; + } +break ; +case MLX5_L3T_TYPE_QWORD : + qw_e_tbl = (struct mlx5_l3t_entry_qword *)e_tbl; +for (k = e_start; k <MLX5_L3T_ET_SIZE ; k++) { +if (!qw_e_tbl->entry[k].data) +continue ; + *pos = (i <<MLX5_L3T_GT_OFFSET ) | + (j <<MLX5_L3T_MT_OFFSET ) | k; +return (void *)&qw_e_tbl->entry[k].data; + } +break ; +default : + ptr_e_tbl = (struct mlx5_l3t_entry_ptr *)e_tbl; +for (k = e_start; k <MLX5_L3T_ET_SIZE ; k++) { +if (!ptr_e_tbl->entry[k].data) +continue ; + *pos = (i <<MLX5_L3T_GT_OFFSET ) | + (j <<MLX5_L3T_MT_OFFSET ) | k; +return ptr_e_tbl->entry[k].data; + } +break ; + } + } + } +return NULL ; +} +/* * Macros for linked list based on indexed memory. * Example data structure:
@@ -909,4 +994,9 @@ struct { \ idx = (elem)->field.next, (elem) = \ (idx) ? mlx5_ipool_get(pool, idx) : NULL) +#define MLX5_L3T_FOREACH (tbl, idx, entry) \ + for (idx = 0, (entry) = mlx5_l3t_get_next((tbl), &idx); \ + (entry); \ + idx++, (entry) = mlx5_l3t_get_next((tbl), &idx)) +#endif /* RTE_PMD_MLX5_UTILS_H_ */
Signature · 1 line
1.8.3.1
PATCH v6 2/15 common/mlx5: add color register idle bits definition
In reply to Jiawei WangFrom: Shun Hao <[email protected]>
8 bits are used for meter color in meter register. When the meter register can be shared, the rest 24 bits can be used by others. This adds the definination for the 24 bits that can be shared.
--- drivers/common/mlx5/mlx5_prm.h | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/common/mlx5/mlx5_prm.h +6 -0
@@ -3382,6 +3382,12 @@ enum {/* The bits meter color use. */ #define MLX5_MTR_COLOR_BITS 8 +/* The bit size of one register. */ +#define MLX5_REG_BITS 32 + +/* Idle bits for non-color usage in color register. */ +#define MLX5_MTR_IDLE_BITS_IN_COLOR_REG (MLX5_REG_BITS - MLX5_MTR_COLOR_BITS) +/* Length mode of dynamic flex parser graph node. */ enum mlx5_parse_graph_node_len_mode {MLX5_GRAPH_NODE_LEN_FIXED =0x0 ,
Signature · 1 line
1.8.3.1
PATCH v6 3/15 net/mlx5: fix meter statistics
In reply to Jiawei WangFrom: Shun Hao <[email protected]>
Currently, packets after meter will be steered to a global policer table,
which includes green/red color rules for every meter, so as to have counter statistics of each color in every meter.
There's a bug that all the rules in global policer table are matching only color criteria, so all packets will be counted to one meter only, and other meter statistics are always zero.
This patch does these:
1. The rules in policer table matches both meter index and color, so packet after meter could be counted to the correct meter counter.
2. The meter index and flow index are now sharing the available register bits dynamically. Meter index starts from lsb, and flow index starts from msb.
--- drivers/net/mlx5/mlx5.c | 7 +- drivers/net/mlx5/mlx5.h | 15 +- drivers/net/mlx5/mlx5_flow.c | 183 +++++++++----- drivers/net/mlx5/mlx5_flow.h | 40 +-- drivers/net/mlx5/mlx5_flow_dv.c | 489 +++++++++++++++++++++++-------------- drivers/net/mlx5/mlx5_flow_meter.c | 53 ++-- 6 files changed, 496 insertions(+), 291 deletions(-)
drivers/net/mlx5/mlx5.c +5 -2
@@ -277,10 +277,13 @@ static LIST_HEAD(, mlx5_dev_ctx_shared) mlx5_dev_ctx_list = }, #endif [MLX5_IPOOL_MTR ] = { +/** +* The ipool index should grow continually from small to big, +* for meter idx, so not set grow_trunk to avoid meter index +* not jump continually. +*/ .size =sizeof (struct mlx5_flow_meter ), .trunk_size =64 , - .grow_trunk =3 , - .grow_shift =2 , .need_lock =1 , .release_mem_en =1 , .malloc = mlx5_malloc,
drivers/net/mlx5/mlx5.h +9 -6
@@ -953,9 +953,9 @@ struct mlx5_priv { unsigned int representor:1; /* Device is a port representor. */ unsigned int master:1; /* Device is a E-Switch master. */ unsigned int txpp_en:1; /* Tx packet pacing enabled. */ + unsigned int sampler_en:1; /* Whether support sampler. */ unsigned int mtr_en:1; /* Whether support meter. */ unsigned int mtr_reg_share:1; /* Whether support meter REG_C share. */ - unsigned int sampler_en:1; /* Whether support sampler. */uint16_t domain_id;/* Switch domain identifier. */ uint16_t vport_id;/* Associated VF vport index (if any). */ uint32_t vport_meta_tag;/* Used for vport index match ove VF LAG. */
@@ -1012,6 +1012,10 @@ struct mlx5_priv {uint32_t rss_shared_actions;/* RSS shared actions. */ struct mlx5_devx_obj *q_counters;/* DevX queue counter object. */ uint32_t counter_set_id;/* Queue counter ID to set in DevX objects. */ +uint8_t max_mtr_bits; +/* Indicate how many bits are used by meter id at the most. */ +uint8_t max_mtr_flow_bits; +/* Indicate how many bits are used by meter flow id at the most. */ };#define PORT_ID (priv) ((priv)->dev_data->port_id)
@@ -1280,11 +1284,10 @@ int mlx5_mp_os_req_queue_control(struct rte_eth_dev *dev, uint16_t queue_id,int mlx5_flow_meter_ops_get (struct rte_eth_dev *dev,void *arg);struct mlx5_flow_meter *mlx5_flow_meter_find (struct mlx5_priv *priv,uint32_t meter_id); -struct mlx5_flow_meter *mlx5_flow_meter_attach - (struct mlx5_priv *priv, -uint32_t meter_id, -const struct rte_flow_attr *attr, -struct rte_flow_error *error); +int mlx5_flow_meter_attach (struct mlx5_priv *priv, +struct mlx5_flow_meter *fm, +const struct rte_flow_attr *attr, +struct rte_flow_error *error);void mlx5_flow_meter_detach (struct mlx5_flow_meter *fm);/* mlx5_os.c */
drivers/net/mlx5/mlx5_flow.c +120 -63
330 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow.h +22 -18
@@ -78,7 +78,7 @@ enum mlx5_feature_name {MLX5_APP_TAG ,MLX5_COPY_MARK ,MLX5_MTR_COLOR , -MLX5_MTR_SFX , +MLX5_MTR_ID , MLX5_ASO_FLOW_HIT, };
@@ -654,7 +654,8 @@ struct mlx5_flow_handle {uint64_t layers;/**< Bit-fields of present layers, see MLX5_FLOW_LAYER_*. */ void *drv_flow;/**< pointer to driver flow object. */ - uint32_t split_flow_id:28; /**< Sub flow unique match flow id. */ + uint32_t split_flow_id:27; /**< Sub flow unique match flow id. */ + uint32_t is_meter_flow_id:1; /**< Indate if flow_id is for meter. */ uint32_t mark:1; /**< Metadate rxq mark flag. */ uint32_t fate_action:3; /**< Fate action type. */union {
@@ -841,14 +842,16 @@ struct mlx5_meter_domain_info {/**< Meter table. */ struct mlx5_flow_tbl_resource *sfx_tbl;/**< Meter suffix table. */ -void *any_matcher; -/**< Meter color not match default criteria. */ -void *color_matcher; -/**< Meter color match criteria. */ +struct mlx5_flow_dv_matcher *drop_matcher; +/**< Matcher for Drop. */ +struct mlx5_flow_dv_matcher *color_matcher; +/**< Matcher for Color. */ void *jump_actn;/**< Meter match action. */ -void *policer_rules[RTE_MTR_DROPPED +1 ]; -/**< Meter policer for the match. */ +void *green_rule; +/**< Meter green rule. */ +void *drop_rule; +/**< Meter drop rule. */ };/* Meter table set for TX RX FDB. */
@@ -861,10 +864,10 @@ struct mlx5_meter_domains_infos {/**< RX meter table. */ struct mlx5_meter_domain_info transfer;/**< FDB meter table. */ -void *drop_actn; -/**< Drop action as not matched. */ -void *count_actns[RTE_MTR_DROPPED +1 ]; -/**< Counters for match and unmatched statistics. */ +void *green_count; +/**< Counters for green rule. */ +void *drop_count; +/**< Counters for green rule. */ uint32_t fmp[MLX5_ST_SZ_DW (flow_meter_parameters)];/**< Flow meter parameter. */ size_t fmp_size;
@@ -927,6 +930,8 @@ struct mlx5_flow_meter {/**< Meter state. */ uint32_t shared:1;/**< Meter shared or not. */ +struct mlx5_indexed_pool *flow_ipool; +/**< Index pool for flow id. */ };/* RFC2697 parameter structure. */
@@ -1165,6 +1170,7 @@ struct mlx5_flow_workspace {struct mlx5_flow_rss_desc rss_desc;uint32_t rssq_num;/* Allocated queue num in rss_desc. */ uint32_t flow_idx;/* Intermediate device flow index. */ +struct mlx5_flow_meter *fm;/* Pointer to the meter in flow. */ };struct mlx5_flow_split_info {
@@ -1205,8 +1211,7 @@ typedef int (*mlx5_flow_query_t)(struct rte_eth_dev *dev,void *data, struct rte_flow_error *error);typedef struct mlx5_meter_domains_infos *(*mlx5_flow_create_mtr_tbls_t ) - (struct rte_eth_dev *dev, -const struct mlx5_flow_meter *fm); + (struct rte_eth_dev *dev);typedef int (*mlx5_flow_destroy_mtr_tbls_t )(struct rte_eth_dev *dev,struct mlx5_meter_domains_infos *tbls);typedef int (*mlx5_flow_create_policer_rules_t )
@@ -1269,7 +1274,7 @@ struct mlx5_flow_driver_ops {mlx5_flow_query_t query;mlx5_flow_create_mtr_tbls_t create_mtr_tbls;mlx5_flow_destroy_mtr_tbls_t destroy_mtr_tbls; -mlx5_flow_create_policer_rules_t create_policer_rules; +mlx5_flow_create_policer_rules_t prepare_policer_rules;mlx5_flow_destroy_policer_rules_t destroy_policer_rules;mlx5_flow_counter_alloc_t counter_alloc;mlx5_flow_counter_free_t counter_free;
@@ -1469,11 +1474,10 @@ int mlx5_flow_validate_item_ecpri(const struct rte_flow_item *item,const struct rte_flow_item_ecpri *acc_mask, struct rte_flow_error *error);struct mlx5_meter_domains_infos *mlx5_flow_create_mtr_tbls - (struct rte_eth_dev *dev, -const struct mlx5_flow_meter *fm); + (struct rte_eth_dev *dev);int mlx5_flow_destroy_mtr_tbls (struct rte_eth_dev *dev,struct mlx5_meter_domains_infos *tbl); -int mlx5_flow_create_policer_rules (struct rte_eth_dev *dev, +int mlx5_flow_prepare_policer_rules (struct rte_eth_dev *dev,struct mlx5_flow_meter *fm,const struct rte_flow_attr *attr); int mlx5_flow_destroy_policer_rules(struct rte_eth_dev *dev,
drivers/net/mlx5/mlx5_flow_dv.c +303 -186
703 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_meter.c +37 -16
117 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH v6 4/15 net/mlx5: optimize meter statistics
In reply to Jiawei WangFrom: Li Zhang <[email protected]>
Meter statistics are each policer action each counter. Totally 4 counters per each meter.
It causes cache missed
and lead to data forwarding performance low.
To optimize it, support pass counter for green
and drop counter for red.
Totally two counters per each meter.
Also use the global drop statistics for
all meter drop action.
limitations as below:
1. It does not support yellow counter and return 0.
2. All the meter colors with drop action will be counted only by the global drop statistics.
3. Red color must be with drop action.
--- doc/guides/nics/mlx5.rst | 6 + drivers/net/mlx5/mlx5_flow.h | 24 ++-- drivers/net/mlx5/mlx5_flow_dv.c | 8 +- drivers/net/mlx5/mlx5_flow_meter.c | 217 +++++++++++++++++++++++++------------ 4 files changed, 173 insertions(+), 82 deletions(-)
doc/guides/nics/mlx5.rst +6 -0
@@ -399,6 +399,12 @@ Limitations - Hairpin between two ports could only manual binding and explicit Tx flow mode. For single port hairpin, all the combinations of auto/manual binding and explicit/implicit Tx flow mode could be supported. - Hairpin in switchdev SR-IOV mode is not supported till now. +- Meter: + - All the meter colors with drop action will be counted only by the global drop statistics. + - Green color is not supported with drop action. + - Yellow detection is not supported. + - Red color must be with drop action. + Statistics ----------
drivers/net/mlx5/mlx5_flow.h +16 -8
@@ -830,10 +830,10 @@ struct mlx5_flow {/* Meter policer statistics */ struct mlx5_flow_policer_stats { -uint32_t cnt[RTE_COLORS +1 ]; -/**< Color counter, extra for drop. */ -uint64_t stats_mask; -/**< Statistics mask for the colors. */ +uint32_t pass_cnt; +/**< Color counter for pass. */ +uint32_t drop_cnt; +/**< Color counter for drop. */ };/* Meter table structure. */
@@ -891,10 +891,18 @@ struct mlx5_flow_meter {/** Policer actions (per meter output color). */ enum rte_mtr_policer_action action[RTE_COLORS ]; -/** Set of stats counters to be enabled. -* @see enum rte_mtr_stats_type -*/ -uint64_t stats_mask; + uint32_t green_bytes:1; +/** Set green bytes stats to be enabled. */ + uint32_t green_pkts:1; +/** Set green packets stats to be enabled. */ + uint32_t red_bytes:1; +/** Set red bytes stats to be enabled. */ + uint32_t red_pkts:1; +/** Set red packets stats to be enabled. */ + uint32_t bytes_dropped:1; +/** Set bytes dropped stats to be enabled. */ + uint32_t pkts_dropped:1; +/** Set packets dropped stats to be enabled. */ /**< Rule applies to ingress traffic. */ uint32_t ingress:1;
drivers/net/mlx5/mlx5_flow_dv.c +4 -4
@@ -13848,17 +13848,17 @@ struct mlx5_cache_entry *int ret;/* Get the statistics counters for green/drop. */ -if (fm->policer_stats.cnt[RTE_COLOR_GREEN ]) { +if (fm->policer_stats.pass_cnt) { cnt =flow_dv_counter_get_by_idx (dev, - fm->policer_stats.cnt[RTE_COLOR_GREEN ], + fm->policer_stats.pass_cnt,NULL ); mtb->green_count = cnt->action; }else { mtb->green_count =NULL ; } -if (fm->policer_stats.cnt[RTE_MTR_DROPPED ]) { +if (fm->policer_stats.drop_cnt) { cnt =flow_dv_counter_get_by_idx (dev, - fm->policer_stats.cnt[RTE_MTR_DROPPED ], + fm->policer_stats.drop_cnt,NULL ); mtb->drop_count = cnt->action; }else {
drivers/net/mlx5/mlx5_flow_meter.c +147 -70
321 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH v6 5/15 net/mlx5: use mask for meter register setting
In reply to Jiawei WangFrom: Shun Hao <[email protected]>
ASO (Advanced Steering Operation) meter feature may require to locate the flow context tag action after the ASO action. When color register is shared by meter_id/flow_id, it's like:
Bits[0-7] A meter color value set by the HW. Bits[8-31] A flow id and meter id set by SW.
Currently the tag action for meter writes all the bits of the meter register, so it will potentially overwrite meter color when ASO meter action is before the tag action.
Set only 24-MSB-bits of meter register in the meter tag action.
--- drivers/net/mlx5/mlx5_flow.c | 28 ++++++++++++++++++---------- drivers/net/mlx5/mlx5_flow.h | 2 ++ drivers/net/mlx5/mlx5_flow_dv.c | 2 ++ 3 files changed, 22 insertions(+), 10 deletions(-)
drivers/net/mlx5/mlx5_flow.c +18 -10
@@ -4258,9 +4258,11 @@ struct mlx5_hlist_entry *rte_memcpy (actions_rx, actions,sizeof (struct rte_flow_action )); actions_rx++; set_tag = (void *)actions_rx; - set_tag->id =mlx5_flow_get_reg_id (dev,MLX5_HAIRPIN_RX ,0 ,NULL ); + *set_tag = (struct mlx5_rte_flow_action_set_tag ) { + .id =mlx5_flow_get_reg_id (dev,MLX5_HAIRPIN_RX ,0 ,NULL ), + .data = flow_id, + };MLX5_ASSERT (set_tag->id >REG_NON ); - set_tag->data = flow_id; tag_action->conf = set_tag;/* Create Tx item list. */ rte_memcpy (actions_tx, actions,sizeof (struct rte_flow_action ));
@@ -4496,6 +4498,14 @@ struct mlx5_hlist_entry * set_tag = (struct mlx5_rte_flow_action_set_tag *)actions_pre; tag_item_spec = (struct mlx5_rte_flow_item_tag *)sfx_items; tag_item_mask = tag_item_spec +1 ; +/* Both flow_id and meter_id share the same register. */ + *set_tag = (struct mlx5_rte_flow_action_set_tag ) { + .id = (enum modify_reg )mlx5_flow_get_reg_id (dev,MLX5_MTR_ID , +0 , error), + .offset = mtr_id_offset, + .length = mtr_reg_bits, + .data = fm->idx, + };/* * The color Reg bits used by flow_id are growing from * msb to lsb, so must do bit reverse for flow_id val in RegC.
@@ -4503,13 +4513,9 @@ struct mlx5_hlist_entry *for (shift =0 ; shift < flow_id_bits; shift++) flow_id_reversed = (flow_id_reversed <<1 ) | ((flow_id >> shift) &0x1 ); -/* Both flow_id and meter_id share the same register. */ - set_tag->id =mlx5_flow_get_reg_id (dev,MLX5_MTR_ID ,0 , error); - set_tag->data = - (fm->idx | (flow_id_reversed << (mtr_reg_bits - flow_id_bits))) - << mtr_id_offset; + set_tag->data |= flow_id_reversed << (mtr_reg_bits - flow_id_bits); tag_item_spec->id = set_tag->id; - tag_item_spec->data = set_tag->data; + tag_item_spec->data = set_tag->data << mtr_id_offset; tag_item_mask->data =UINT32_MAX << mtr_id_offset; tag_action->type = (enum rte_flow_action_type )MLX5_RTE_FLOW_ACTION_TYPE_TAG ;
@@ -4904,10 +4910,12 @@ struct mlx5_hlist_entry * ret =mlx5_flow_get_reg_id (dev,MLX5_APP_TAG ,0 , error);if (ret <0 )return ret; - set_tag->id = ret;mlx5_ipool_malloc (priv->sh->ipool [MLX5_IPOOL_RSS_EXPANTION_FLOW_ID ], &tag_id); - set_tag->data = tag_id; + *set_tag = (struct mlx5_rte_flow_action_set_tag ) { + .id = ret, + .data = tag_id, + };/* Prepare the suffix subflow items. */ tag_spec = (void *)(sfx_items +SAMPLE_SUFFIX_ITEM ); tag_spec->data = tag_id;
drivers/net/mlx5/mlx5_flow.h +2 -0
@@ -54,6 +54,8 @@ struct mlx5_rte_flow_item_tag {/* Modify selected register. */ struct mlx5_rte_flow_action_set_tag {enum modify_reg id; +uint8_t offset; +uint8_t length;uint32_t data; };
drivers/net/mlx5/mlx5_flow_dv.c +2 -0
@@ -965,6 +965,8 @@ struct field_modify_info modify_tcp[] = { actions[i] = (struct mlx5_modification_cmd ) { .action_type =MLX5_MODIFICATION_TYPE_SET , .field = reg_to_field[conf->id], + .offset = conf->offset, + .length = conf->length, }; actions[i].data0 =rte_cpu_to_be_32 (actions[i].data0); actions[i].data1 =rte_cpu_to_be_32 (conf->data);
Signature · 1 line
1.8.3.1
PATCH v6 6/15 common/mlx5: add definitions for ASO flow meter
In reply to Jiawei WangFrom: Li Zhang <[email protected]>
This patch adds different PRM definitions, related to ASO (Advanced Steering Operation) flow meter feature, in MLX5 PMD code.
--- drivers/common/mlx5/mlx5_prm.h | 75 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 71 insertions(+), 4 deletions(-)
drivers/common/mlx5/mlx5_prm.h +71 -4
@@ -1129,6 +1129,8 @@ enum { (1ULL << MLX5_GENERAL_OBJ_TYPE_FLEX_PARSE_GRAPH)#define MLX5_GENERAL_OBJ_TYPES_CAP_FLOW_HIT_ASO \ (1ULL << MLX5_GENERAL_OBJ_TYPE_FLOW_HIT_ASO) +#define MLX5_GENERAL_OBJ_TYPES_CAP_FLOW_METER_ASO \ + (1ULL << MLX5_GENERAL_OBJ_TYPE_FLOW_METER_ASO)#define MLX5_GENERAL_OBJ_TYPES_CAP_GENEVE_TLV_OPT \ (1ULL << MLX5_OBJ_TYPE_GENEVE_TLV_OPT)
@@ -1514,7 +1516,15 @@ struct mlx5_ifc_qos_cap_bits {u8 reserved_at_c0[0x10 ];u8 max_qos_para_vport[0x10 ];u8 max_tsar_bw_share[0x20 ]; -u8 reserved_at_100[0x6e8 ]; +u8 nic_element_type[0x10 ]; +u8 nic_tsar_type[0x10 ]; +u8 reserved_at_120[0x3 ]; +u8 log_meter_aso_granularity[0x5 ]; +u8 reserved_at_128[0x3 ]; +u8 log_meter_aso_max_alloc[0x5 ]; +u8 reserved_at_130[0x3 ]; +u8 log_max_num_meter_aso[0x5 ]; +u8 reserved_at_138[0x6b0 ]; };struct mlx5_ifc_per_protocol_networking_offload_caps_bits {
@@ -2284,6 +2294,8 @@ struct mlx5_ifc_flow_meter_parameters_bits {u8 eir_mantissa[0x8 ];u8 reserved_at_8[0x60 ];// 14h-1Ch }; +#define MLX5_IFC_FLOW_METER_PARAM_MASK UINT64_C(0x80FFFFFF) +#define MLX5_IFC_FLOW_METER_DISABLE_CBS_CIR_VAL 0x14BF00C8enum {MLX5_CQE_SIZE_64B =0x0 ,
@@ -2411,6 +2423,7 @@ enum {MLX5_GENERAL_OBJ_TYPE_VIRTQ =0x000d ,MLX5_GENERAL_OBJ_TYPE_VIRTIO_Q_COUNTERS =0x001c ,MLX5_GENERAL_OBJ_TYPE_FLEX_PARSE_GRAPH =0x0022 , +MLX5_GENERAL_OBJ_TYPE_FLOW_METER_ASO =0x0024 , MLX5_GENERAL_OBJ_TYPE_FLOW_HIT_ASO = 0x0025, };
@@ -2419,7 +2432,9 @@ struct mlx5_ifc_general_obj_in_cmd_hdr_bits {u8 reserved_at_10[0x20 ];u8 obj_type[0x10 ];u8 obj_id[0x20 ]; -u8 reserved_at_60[0x20 ]; +u8 reserved_at_60[0x3 ]; +u8 log_obj_range[0x5 ]; +u8 reserved_at_58[0x18 ]; };struct mlx5_ifc_general_obj_out_cmd_hdr_bits {
@@ -2565,6 +2580,18 @@ struct mlx5_ifc_create_flow_hit_aso_in_bits {struct mlx5_ifc_flow_hit_aso_bits flow_hit_aso; }; +struct mlx5_ifc_flow_meter_aso_bits { +u8 modify_field_select[0x40 ]; +u8 reserved_at_40[0x48 ]; +u8 access_pd[0x18 ]; +u8 reserved_at_a0[0x160 ]; +u8 parameters[0x200 ]; +}; + +struct mlx5_ifc_create_flow_meter_aso_in_bits { +struct mlx5_ifc_general_obj_in_cmd_hdr_bits hdr; +struct mlx5_ifc_flow_meter_aso_bits flow_meter_aso; +};enum mlx5_access_aso_opc_mod {ASO_OPC_MOD_IPSEC =0x0 ,ASO_OPC_MOD_CONNECTION_TRACKING =0x1 ,
@@ -2618,11 +2645,51 @@ struct mlx5_aso_cseg {uint64_t data_mask; } __rte_packed; +/* A meter data segment - 2 per ASO WQE. */ +struct mlx5_aso_mtr_dseg { +uint32_t v_bo_sc_bbog_mm; +/* +* bit 31: valid, 30: bucket overflow, 28-29: start color, +* 27: both buckets on green, 24-25: meter mode. +*/ +uint32_t reserved; +uint32_t cbs_cir; +/* +* bit 24-28: cbs_exponent, bit 16-23 cbs_mantissa, +* bit 8-12: cir_exponent, bit 0-7 cir_mantissa. +*/ +uint32_t c_tokens; +uint32_t ebs_eir; +/* +* bit 24-28: ebs_exponent, bit 16-23 ebs_mantissa, +* bit 8-12: eir_exponent, bit 0-7 eir_mantissa. +*/ +uint32_t e_tokens; +uint64_t timestamp; +} __rte_packed; + +#define ASO_DSEG_VALID_OFFSET 31 +#define ASO_DSEG_BO_OFFSET 30 +#define ASO_DSEG_SC_OFFSET 28 +#define ASO_DSEG_CBS_EXP_OFFSET 24 +#define ASO_DSEG_CBS_MAN_OFFSET 16 +#define ASO_DSEG_CIR_EXP_MASK 0x1F +#define ASO_DSEG_CIR_EXP_OFFSET 8 +#define ASO_DSEG_EBS_EXP_OFFSET 24 +#define ASO_DSEG_EBS_MAN_OFFSET 16 +#define ASO_DSEG_EXP_MASK 0x1F +#define ASO_DSEG_MAN_MASK 0xFF +#define MLX5_ASO_WQE_DSEG_SIZE 0x40 +#define MLX5_ASO_METERS_PER_WQE 2 +#define MLX5_ASO_MTRS_PER_POOL 128 -/* ASO WQE Data segment. */ +/* ASO WQE data segment. */ struct mlx5_aso_dseg { -uint8_t data[MLX5_ASO_WQE_DSEG_SIZE ]; +union { +uint8_t data[MLX5_ASO_WQE_DSEG_SIZE ]; +struct mlx5_aso_mtr_dseg mtrs[MLX5_ASO_METERS_PER_WQE ]; + }; } __rte_packed;/* ASO WQE. */
Signature · 1 line
1.8.3.1
PATCH v6 7/15 common/mlx5: add read ASO flow meter HCA capability
In reply to Jiawei WangFrom: Li Zhang <[email protected]>
Read and store the device capability of FLOW_METER_ASO general object, using the DevX API.
--- drivers/common/mlx5/mlx5_devx_cmds.c | 14 ++++++++++++++ drivers/common/mlx5/mlx5_devx_cmds.h | 8 ++++++++ 2 files changed, 22 insertions(+)
drivers/common/mlx5/mlx5_devx_cmds.c +14 -0
@@ -696,6 +696,9 @@ struct mlx5_devx_obj * attr->max_geneve_tlv_option_data_len =MLX5_GET (cmd_hca_cap, hcattr, max_geneve_tlv_option_data_len); attr->qos.sup =MLX5_GET (cmd_hca_cap, hcattr, qos); + attr->qos.flow_meter_aso_sup = !!(MLX5_GET64 (cmd_hca_cap, hcattr, + general_obj_types) & +MLX5_GENERAL_OBJ_TYPES_CAP_FLOW_METER_ASO ); attr->vdpa.valid = !!(MLX5_GET64 (cmd_hca_cap, hcattr, general_obj_types) &MLX5_GENERAL_OBJ_TYPES_CAP_VIRTQ_NET_Q );
@@ -783,6 +786,17 @@ struct mlx5_devx_obj *MLX5_GET (qos_cap, hcattr, packet_pacing); attr->qos.wqe_rate_pp =MLX5_GET (qos_cap, hcattr, wqe_rate_pp); +if (attr->qos.flow_meter_aso_sup) { + attr->qos.log_meter_aso_granularity = +MLX5_GET (qos_cap, hcattr, + log_meter_aso_granularity); + attr->qos.log_meter_aso_max_alloc = +MLX5_GET (qos_cap, hcattr, + log_meter_aso_max_alloc); + attr->qos.log_max_num_meter_aso = +MLX5_GET (qos_cap, hcattr, + log_max_num_meter_aso); + } }if (attr->vdpa.valid)mlx5_devx_cmd_query_hca_vdpa_attr (ctx, &attr->vdpa);
drivers/common/mlx5/mlx5_devx_cmds.h +8 -0
@@ -50,10 +50,18 @@ struct mlx5_hca_qos_attr {* Using older driver versions, flow_meter_old can be 1 * while flow_meter is 0. */ + uint32_t flow_meter_aso_sup:1; +/* Whether FLOW_METER_ASO Object is supported. */ uint8_t log_max_flow_meter;/* Power of the maximum supported meters. */ uint8_t flow_meter_reg_c_ids;/* Bitmap of the reg_Cs available for flow meter to use. */ + uint32_t log_meter_aso_granularity:5; +/* Power of the minimum allocation granularity Object. */ + uint32_t log_meter_aso_max_alloc:5; +/* Power of the maximum allocation granularity Object. */ + uint32_t log_max_num_meter_aso:5; +/* Power of the maximum number of supported objects. */ };
Signature · 1 line
1.8.3.1
PATCH v6 8/15 common/mlx5: add DevX API to create ASO flow meter object
In reply to Jiawei WangFrom: Li Zhang <[email protected]>
Add DevX API to create ASO flow meter object.
--- drivers/common/mlx5/mlx5_devx_cmds.c | 54 ++++++++++++++++++++++++++++++++++++ drivers/common/mlx5/mlx5_devx_cmds.h | 18 +++++++++++- drivers/common/mlx5/version.map | 1 + 3 files changed, 72 insertions(+), 1 deletion(-)
drivers/common/mlx5/mlx5_devx_cmds.c +54 -0
@@ -2174,6 +2174,60 @@ struct mlx5_devx_obj * }/** +* Create general object of type FLOW_METER_ASO using DevX API. +* +* @param[in] ctx +* Context returned from mlx5 open_device() glue function. +* @param [in] pd +* PD value to associate the FLOW_METER_ASO object with. +* @param [in] log_obj_size +* log_obj_size define to allocate number of 2 * meters +* in one FLOW_METER_ASO object. +* +* @return +* The DevX object created, NULL otherwise and rte_errno is set. +*/ +struct mlx5_devx_obj * +mlx5_devx_cmd_create_flow_meter_aso_obj (void *ctx,uint32_t pd, +uint32_t log_obj_size) +{ +uint32_t in[MLX5_ST_SZ_DW (create_flow_meter_aso_in)] = {0 }; +uint32_t out[MLX5_ST_SZ_DW (general_obj_out_cmd_hdr)]; +struct mlx5_devx_obj *flow_meter_aso_obj; +void *ptr; + + flow_meter_aso_obj =mlx5_malloc (MLX5_MEM_ZERO , +sizeof (*flow_meter_aso_obj), +0 ,SOCKET_ID_ANY ); +if (!flow_meter_aso_obj) { +DRV_LOG (ERR ,"Failed to allocate FLOW_METER_ASO object data" ); + rte_errno =ENOMEM ; +return NULL ; + } + ptr =MLX5_ADDR_OF (create_flow_meter_aso_in, in, hdr); +MLX5_SET (general_obj_in_cmd_hdr, ptr, opcode, +MLX5_CMD_OP_CREATE_GENERAL_OBJECT ); +MLX5_SET (general_obj_in_cmd_hdr, ptr, obj_type, +MLX5_GENERAL_OBJ_TYPE_FLOW_METER_ASO ); +MLX5_SET (general_obj_in_cmd_hdr, ptr, log_obj_range, + log_obj_size); + ptr =MLX5_ADDR_OF (create_flow_meter_aso_in, in, flow_meter_aso); +MLX5_SET (flow_meter_aso, ptr, access_pd, pd); + flow_meter_aso_obj->obj = mlx5_glue->devx_obj_create ( + ctx, in,sizeof (in), + out,sizeof (out)); +if (!flow_meter_aso_obj->obj) { + rte_errno = errno; +DRV_LOG (ERR ,"Failed to create FLOW_METER_ASO obj using DevX." ); +mlx5_free (flow_meter_aso_obj); +return NULL ; + } + flow_meter_aso_obj->id =MLX5_GET (general_obj_out_cmd_hdr, + out, obj_id); +return flow_meter_aso_obj; +} + +/** * Create general object of type GENEVE TLV option using DevX API. * * @param[in] ctx
drivers/common/mlx5/mlx5_devx_cmds.h +17 -1
@@ -556,7 +556,6 @@ int mlx5_devx_cmd_query_virtio_q_counters(struct mlx5_devx_obj *couners_obj,__rte_internal struct mlx5_devx_obj *mlx5_devx_cmd_create_flow_hit_aso_obj(void *ctx,uint32_t pd); -__rte_internal struct mlx5_devx_obj *mlx5_devx_cmd_alloc_pd(void *ctx);
@@ -568,4 +567,21 @@ struct mlx5_devx_obj *mlx5_devx_cmd_create_flow_hit_aso_obj(void *ctx,__rte_internal int mlx5_devx_cmd_queue_counter_query(struct mlx5_devx_obj *dcs, int clear,uint32_t *out_of_buffers); +/** +* Create general object of type FLOW_METER_ASO using DevX API.. +* +* @param[in] ctx +* Device context. +* @param [in] pd +* PD value to associate the FLOW_METER_ASO object with. +* @param [in] log_obj_size +* log_obj_size define to allocate number of 2 * meters +* in one FLOW_METER_ASO object. +* +* @return +* The DevX object created, NULL otherwise and rte_errno is set. +*/ +__rte_internal +struct mlx5_devx_obj *mlx5_devx_cmd_create_flow_meter_aso_obj(void *ctx, +uint32_t pd,uint32_t log_obj_size);#endif /* RTE_PMD_MLX5_DEVX_CMDS_H_ */
drivers/common/mlx5/version.map +1 -0
@@ -25,6 +25,7 @@ INTERNAL { mlx5_devx_cmd_create_virtio_q_counters; # WINDOWS_NO_EXPORT mlx5_devx_cmd_create_virtq; mlx5_devx_cmd_create_flow_hit_aso_obj; + mlx5_devx_cmd_create_flow_meter_aso_obj; mlx5_devx_cmd_create_geneve_tlv_option; mlx5_devx_cmd_destroy; mlx5_devx_cmd_flow_counter_alloc;
Signature · 1 line
1.8.3.1
PATCH v6 9/15 net/mlx5: flow meter pool to manage meter object
In reply to Jiawei WangFrom: Li Zhang <[email protected]>
Add ASO flow meter pool to manage meter object
--- drivers/net/mlx5/mlx5.c | 2 +- drivers/net/mlx5/mlx5.h | 207 ++++++++++++++++- drivers/net/mlx5/mlx5_flow.c | 70 ++++-- drivers/net/mlx5/mlx5_flow.h | 196 ++++------------ drivers/net/mlx5/mlx5_flow_dv.c | 203 +++++++++++++++-- drivers/net/mlx5/mlx5_flow_meter.c | 450 +++++++++++++++++++++++-------------- 6 files changed, 769 insertions(+), 359 deletions(-)
drivers/net/mlx5/mlx5.c +1 -1
@@ -282,7 +282,7 @@ static LIST_HEAD(, mlx5_dev_ctx_shared) mlx5_dev_ctx_list =* for meter idx, so not set grow_trunk to avoid meter index * not jump continually. */ - .size = sizeof(struct mlx5_flow_meter), + .size = sizeof(struct mlx5_legacy_flow_meter), .trunk_size = 64, .need_lock = 1, .release_mem_en = 1,
drivers/net/mlx5/mlx5.h +200 -7
258 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow.c +54 -16
143 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow.h +48 -148
256 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_dv.c +189 -14
309 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_meter.c +277 -173
724 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH v6 10/15 net/mlx5: initialize the flow meter ASO SQ
In reply to Jiawei WangFrom: Li Zhang <[email protected]>
Initialize the flow meter ASO SQ WQEs with
all the constant data that should not be updated
per enqueue operation.
--- drivers/net/mlx5/linux/mlx5_os.c | 16 + drivers/net/mlx5/meson.build | 2 +- drivers/net/mlx5/mlx5.c | 68 +++- drivers/net/mlx5/mlx5.h | 22 +- drivers/net/mlx5/mlx5_flow.h | 4 +- drivers/net/mlx5/mlx5_flow_age.c | 591 --------------------------------- drivers/net/mlx5/mlx5_flow_aso.c | 659 +++++++++++++++++++++++++++++++++++++ drivers/net/mlx5/mlx5_flow_dv.c | 7 +- drivers/net/mlx5/mlx5_flow_meter.c | 7 +- 9 files changed, 767 insertions(+), 609 deletions(-) delete mode 100644 drivers/net/mlx5/mlx5_flow_age.c create mode 100644 drivers/net/mlx5/mlx5_flow_aso.c
drivers/net/mlx5/linux/mlx5_os.c +16 -0
@@ -1290,6 +1290,22 @@ priv->mtr_color_reg); } } +if (config->hca_attr.qos.sup && + config->hca_attr.qos.flow_meter_aso_sup) { +uint32_t log_obj_size = +rte_log2_u32 (MLX5_ASO_MTRS_PER_POOL >>1 ); +if (log_obj_size >= + config->hca_attr.qos.log_meter_aso_granularity && + log_obj_size <= + config->hca_attr.qos.log_meter_aso_max_alloc) { + sh->meter_aso_en =1 ; + err =mlx5_aso_flow_mtrs_mng_init (priv); +if (err) { + err = -err; + goto error; + } + } + }#endif #ifdef HAVE_MLX5_DR_CREATE_ACTION_ASO if (config->hca_attr.flow_hit_aso &&
drivers/net/mlx5/meson.build +1 -1
@@ -15,7 +15,7 @@ sources = files( 'mlx5_flow.c', 'mlx5_flow_meter.c', 'mlx5_flow_dv.c', - 'mlx5_flow_age.c', + 'mlx5_flow_aso.c', 'mlx5_mac.c', 'mlx5_mr.c', 'mlx5_rss.c',
drivers/net/mlx5/mlx5.c +65 -3
92 lines not on this page · raw message
drivers/net/mlx5/mlx5.h +15 -7
@@ -491,8 +491,13 @@ struct mlx5_aso_devx_mr { };struct mlx5_aso_sq_elem { -struct mlx5_aso_age_pool *pool; -uint16_t burst_size; +union { +struct { +struct mlx5_aso_age_pool *pool; +uint16_t burst_size; + }; +struct mlx5_aso_mtr *mtr; + }; };struct mlx5_aso_sq {
@@ -764,7 +769,6 @@ struct mlx5_aso_mtr_pools_mng {volatile uint16_t n_valid;/* Number of valid pools. */ uint16_t n;/* Number of pools. */ rte_spinlock_t mtrsl;/* The ASO flow meter free list lock. */ -struct mlx5_l3t_tbl *mtr_idx_tbl;/* Meter index lookup table. */ struct aso_meter_list meters;/* Free ASO flow meter list. */ struct mlx5_aso_sq sq;/*SQ using by ASO flow meter. */ struct mlx5_aso_mtr_pool **pools;/* ASO flow meter pool array. */
@@ -1195,6 +1199,7 @@ struct mlx5_priv {uint8_t mtr_color_reg;/* Meter color match REG_C. */ struct mlx5_mtr_profiles flow_meter_profiles;/* MTR profile list. */ struct mlx5_legacy_flow_meters flow_meters;/* MTR list. */ +struct mlx5_l3t_tbl *mtr_idx_tbl;/* Meter index lookup table. */ uint8_t skip_default_rss_reta;/* Skip configuration of default reta. */ uint8_t fdb_def_rule;/* Whether fdb jump to table 1 is configured. */ struct mlx5_mp_id mp_id;/* ID of a multi-process process */
@@ -1258,6 +1263,7 @@ int mlx5_hairpin_cap_get(struct rte_eth_dev *dev,bool mlx5_flex_parser_ecpri_exist (struct rte_eth_dev *dev);int mlx5_flex_parser_ecpri_alloc (struct rte_eth_dev *dev);int mlx5_flow_aso_age_mng_init (struct mlx5_dev_ctx_shared *sh); +int mlx5_aso_flow_mtrs_mng_init (struct mlx5_priv *priv);/* mlx5_ethdev.c */
@@ -1528,9 +1534,11 @@ int mlx5_txpp_xstats_get_names(struct rte_eth_dev *dev,/* mlx5_flow_aso.c */ -int mlx5_aso_queue_init (struct mlx5_dev_ctx_shared *sh); -int mlx5_aso_queue_start (struct mlx5_dev_ctx_shared *sh); -int mlx5_aso_queue_stop (struct mlx5_dev_ctx_shared *sh); -void mlx5_aso_queue_uninit (struct mlx5_dev_ctx_shared *sh); +int mlx5_aso_queue_init (struct mlx5_dev_ctx_shared *sh, +enum mlx5_access_aso_opc_mod aso_opc_mod); +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);#endif /* RTE_PMD_MLX5_H_ */
drivers/net/mlx5/mlx5_flow.h +2 -2
@@ -826,8 +826,8 @@ struct mlx5_flow {#define MLX5_FLOW_METER_DISABLE 0#define MLX5_FLOW_METER_ENABLE 1 -#define MLX5_ASO_CQE_RESPONSE_DELAY 10 -#define MLX5_MTR_POLL_CQE_TIMES 100000u +#define MLX5_ASO_WQE_CQE_RESPONSE_DELAY 10u +#define MLX5_MTR_POLL_WQE_CQE_TIMES 100000u#define MLX5_MAN_WIDTH 8/* Legacy Meter parameter structure. */
drivers/net/mlx5/mlx5_flow_age.c deleted +0 -591
591 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_aso.c new file +659 -0
659 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_dv.c +6 -1
@@ -5962,6 +5962,11 @@ struct mlx5_hlist_entry * rte_errno =ENOMEM ;return -ENOMEM ; } +if (!mtrmng->n) +if (mlx5_aso_queue_init (priv->sh,ASO_OPC_MOD_POLICER )) { +mlx5_free (pools); +return -ENOMEM ; + }if (old_pools)memcpy (pools, old_pools, mtrmng->n *sizeof (struct mlx5_aso_mtr_pool *));
@@ -10834,7 +10839,7 @@ struct mlx5_cache_entry *mlx5_free (old_pools); }else {/* First ASO flow hit allocation - starting ASO data-path. */ -int ret =mlx5_aso_queue_start (priv->sh); +int ret =mlx5_aso_flow_hit_queue_poll_start (priv->sh);if (ret) {mlx5_free (pools);
drivers/net/mlx5/mlx5_flow_meter.c +3 -4
@@ -811,7 +811,6 @@ struct rte_mtr_error *error) {struct mlx5_priv *priv = dev->data->dev_private; -struct mlx5_aso_mtr_pools_mng *mtrmng = priv->sh->mtrmng;struct mlx5_flow_meter_info *fm;const struct rte_flow_attr attr = { .ingress =1 ,
@@ -836,7 +835,7 @@RTE_MTR_ERROR_TYPE_UNSPECIFIED , NULL, "Meter object is being used.");if (priv->sh->meter_aso_en) { -if (mlx5_l3t_clear_entry (mtrmng->mtr_idx_tbl, meter_id)) +if (mlx5_l3t_clear_entry (priv->mtr_idx_tbl, meter_id))return -rte_mtr_error_set (error,EBUSY ,RTE_MTR_ERROR_TYPE_UNSPECIFIED ,NULL ,"Fail to delete ASO Meter in index table." );
@@ -1302,7 +1301,7 @@ struct mlx5_flow_meter_info *rte_spinlock_unlock (&mtrmng->mtrsl);return NULL ; } -if (mlx5_l3t_get_entry (mtrmng->mtr_idx_tbl, meter_id, &data) || +if (mlx5_l3t_get_entry (priv->mtr_idx_tbl, meter_id, &data) || !data.dword) {rte_spinlock_unlock (&mtrmng->mtrsl);return NULL ;
@@ -1310,7 +1309,7 @@ struct mlx5_flow_meter_info *if (mtr_idx) *mtr_idx = data.dword; aso_mtr =mlx5_aso_meter_by_idx (priv, data.dword); -mlx5_l3t_clear_entry (mtrmng->mtr_idx_tbl, meter_id); +mlx5_l3t_clear_entry (priv->mtr_idx_tbl, meter_id);if (meter_id == aso_mtr->fm.meter_id) {rte_spinlock_unlock (&mtrmng->mtrsl);return &aso_mtr->fm;
Signature · 1 line
1.8.3.1
PATCH v6 11/15 net/mlx5: add meter ASO queue management
In reply to Jiawei WangFrom: Li Zhang <[email protected]>
This patch adds the ASO queue management for flow meter, includes send WQE and CQE handle functions.
--- drivers/net/mlx5/mlx5.h | 4 + drivers/net/mlx5/mlx5_flow_aso.c | 183 ++++++++++++++++++++++++++++++++++++- drivers/net/mlx5/mlx5_flow_meter.c | 143 ++++++++++++++++++----------- 3 files changed, 274 insertions(+), 56 deletions(-)
drivers/net/mlx5/mlx5.h +4 -0
@@ -1540,5 +1540,9 @@ int mlx5_aso_queue_init(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, +struct mlx5_aso_mtr *mtr); +int mlx5_aso_mtr_wait (struct mlx5_dev_ctx_shared *sh, +struct mlx5_aso_mtr *mtr);#endif /* RTE_PMD_MLX5_H_ */
drivers/net/mlx5/mlx5_flow_aso.c +182 -1
192 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_meter.c +88 -55
221 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH v6 12/15 net/mlx5: add support of ASO meter action
In reply to Jiawei WangFrom: Li Zhang <[email protected]>
When ASO action is available, use it as the meter action
--- drivers/net/mlx5/linux/mlx5_os.c | 4 +- drivers/net/mlx5/mlx5.c | 12 +++++ drivers/net/mlx5/mlx5.h | 7 +-- drivers/net/mlx5/mlx5_flow.c | 74 ++++++++++++++++++++++------- drivers/net/mlx5/mlx5_flow_dv.c | 29 ++++++++++-- drivers/net/mlx5/mlx5_flow_meter.c | 97 +++++++++++++++++++++++++------------- 6 files changed, 163 insertions(+), 60 deletions(-)
drivers/net/mlx5/linux/mlx5_os.c +3 -1
@@ -1255,7 +1255,9 @@"required for coalescing is %d bytes" , config->hca_attr.lro_min_mss_size); } -#if defined(HAVE_MLX5DV_DR ) && defined(HAVE_MLX5_DR_CREATE_ACTION_FLOW_METER ) +#if defined(HAVE_MLX5DV_DR ) && \ + (defined(HAVE_MLX5_DR_CREATE_ACTION_FLOW_METER ) || \ + defined(HAVE_MLX5_DR_CREATE_ACTION_ASO ))if (config->hca_attr.qos.sup && config->hca_attr.qos.flow_meter_old && config->dv_flow_en) {
drivers/net/mlx5/mlx5.c +12 -0
@@ -609,11 +609,23 @@ static LIST_HEAD(, mlx5_dev_ctx_shared) mlx5_dev_ctx_list =struct mlx5_aso_mtr_pool *mtr_pool;struct mlx5_aso_mtr_pools_mng *mtrmng = sh->mtrmng;uint32_t idx; +#ifdef HAVE_MLX5_DR_CREATE_ACTION_ASO +struct mlx5_aso_mtr *aso_mtr; +int i; +#endif /* HAVE_MLX5_DR_CREATE_ACTION_ASO */ mlx5_aso_queue_uninit (sh,ASO_OPC_MOD_POLICER ); idx = mtrmng->n_valid;while (idx--) { mtr_pool = mtrmng->pools[idx]; +#ifdef HAVE_MLX5_DR_CREATE_ACTION_ASO +for (i =0 ; i <MLX5_ASO_MTRS_PER_POOL ; i++) { + aso_mtr = &mtr_pool->mtrs[i]; +if (aso_mtr->fm.meter_action) +claim_zero (mlx5_glue->destroy_flow_action + (aso_mtr->fm.meter_action)); + } +#endif /* HAVE_MLX5_DR_CREATE_ACTION_ASO */ claim_zero (mlx5_devx_cmd_destroy (mtr_pool->devx_obj)); mtrmng->n_valid--;
drivers/net/mlx5/mlx5.h +4 -3
@@ -634,8 +634,6 @@ struct mlx5_meter_domains_infos {/**< Counters for green rule. */ void *drop_count;/**< Counters for green rule. */ -void *meter_action; -/**< Flow meter action. */ };/* Meter parameter structure. */
@@ -698,6 +696,8 @@ struct mlx5_flow_meter_info {/**< Use count. */ struct mlx5_indexed_pool *flow_ipool;/**< Index pool for flow id. */ +void *meter_action; +/**< Flow meter action. */ };/* RFC2697 parameter structure. */
@@ -1487,7 +1487,8 @@ int mlx5_flow_meter_attach(struct mlx5_priv *priv,struct mlx5_flow_meter_info *fm, const struct rte_flow_attr *attr, struct rte_flow_error *error); -void mlx5_flow_meter_detach (struct mlx5_flow_meter_info *fm); +void mlx5_flow_meter_detach (struct mlx5_priv *priv, +struct mlx5_flow_meter_info *fm);/* mlx5_os.c */ struct rte_pci_driver ;
drivers/net/mlx5/mlx5_flow.c +56 -18
135 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_dv.c +25 -4
@@ -4891,9 +4891,11 @@ struct mlx5_cache_entry *return rte_flow_error_set (error,EINVAL ,RTE_FLOW_ERROR_TYPE_ACTION ,NULL ,"Meter not found" ); -if (fm->ref_cnt && (!(fm->transfer == attr->transfer || +/* aso meter can always be shared by different domains */ +if (fm->ref_cnt && !priv->sh->meter_aso_en && + !(fm->transfer == attr->transfer || (!fm->ingress && !attr->ingress && attr->egress) || - (!fm->egress && !attr->egress && attr->ingress)))) + (!fm->egress && !attr->egress && attr->ingress)))return rte_flow_error_set (error,EINVAL ,RTE_FLOW_ERROR_TYPE_ACTION ,NULL , "Flow attributes are either invalid "
@@ -6096,6 +6098,25 @@ struct mlx5_hlist_entry * struct mlx5_aso_mtr_pool, mtrs[mtr_free->offset]); mtr_idx =MLX5_MAKE_MTR_IDX (pool->index, mtr_free->offset); +if (!mtr_free->fm.meter_action) { +#ifdef HAVE_MLX5_DR_CREATE_ACTION_ASO +struct rte_flow_error error; +uint8_t reg_id; + + reg_id =mlx5_flow_get_reg_id (dev,MLX5_MTR_COLOR ,0 , &error); + mtr_free->fm.meter_action = + mlx5_glue->dv_create_flow_action_aso + (priv->sh->rx_domain, + pool->devx_obj->obj, + mtr_free->offset, + (1 <<MLX5_FLOW_COLOR_GREEN ), + reg_id -REG_C_0 ); +#endif /* HAVE_MLX5_DR_CREATE_ACTION_ASO */ +if (!mtr_free->fm.meter_action) { +flow_dv_aso_mtr_release_to_pool (dev, mtr_idx); +return 0 ; + } + }return mtr_idx; }
@@ -11595,7 +11616,7 @@ struct mlx5_cache_entry * NULL, "Failed to get meter in flow.");/* Set the meter action. */ dev_flow->dv.actions[actions_n++] = - wks->fm->mfts->meter_action; + wks->fm->meter_action; action_flags |=MLX5_FLOW_ACTION_METER ;break ;case RTE_FLOW_ACTION_TYPE_SET_IPV4_DSCP :
@@ -12757,7 +12778,7 @@ struct mlx5_cache_entry *if (flow->meter) { fm =flow_dv_meter_find_by_idx (priv, flow->meter);if (fm) -mlx5_flow_meter_detach (fm); +mlx5_flow_meter_detach (priv, fm); flow->meter =0 ; }if (flow->age)
drivers/net/mlx5/mlx5_flow_meter.c +63 -34
141 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH v6 13/15 net/mlx5: make ASO meter queue thread-safe
In reply to Jiawei WangFrom: Li Zhang <[email protected]>
Synchronize ASO meter queue accesses from
different threads using a spinlock.
--- drivers/net/mlx5/mlx5.h | 1 + drivers/net/mlx5/mlx5_flow_aso.c | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-)
drivers/net/mlx5/mlx5.h +1 -0
@@ -502,6 +502,7 @@ struct mlx5_aso_sq_elem {struct mlx5_aso_sq {uint16_t log_desc_n; +rte_spinlock_t sqsl;struct mlx5_aso_cq cq;struct mlx5_devx_sq sq_obj;volatile uint64_t *uar_addr;
drivers/net/mlx5/mlx5_flow_aso.c +13 -3
@@ -274,6 +274,7 @@ sq->tail =0 ; sq->sqn = sq->sq_obj.sq->id; sq->uar_addr =mlx5_os_get_devx_uar_reg_addr (uar); +rte_spinlock_init (&sq->sqsl);return 0 ; error:mlx5_aso_destroy_sq (sq);
@@ -665,12 +666,15 @@struct mlx5_flow_meter_info *fm =NULL ;uint16_t size =1 << sq->log_desc_n;uint16_t mask = size -1 ; -uint16_t res = size - (uint16_t )(sq->head - sq->tail); +uint16_t res;uint32_t dseg_idx =0 ;struct mlx5_aso_mtr_pool *pool =NULL ; +rte_spinlock_lock (&sq->sqsl); + res = size - (uint16_t )(sq->head - sq->tail);if (unlikely (!res)) {DRV_LOG (ERR ,"Fail: SQ is full and no free WQE to send" ); +rte_spinlock_unlock (&sq->sqsl);return 0 ; } wqe = &sq->sq_obj.aso_wqes[sq->head & mask];
@@ -707,6 +711,7 @@rte_wmb (); *sq->uar_addr = *(volatile uint64_t *)wqe;/* Assume 64 bit ARCH. */ rte_wmb (); +rte_spinlock_unlock (&sq->sqsl);return 1 ; }
@@ -737,12 +742,16 @@const unsigned int mask = cq_size -1 ;uint32_t idx;uint32_t next_idx = cq->cq_ci & mask; -const uint16_t max = (uint16_t )(sq->head - sq->tail); +uint16_t max;uint16_t n =0 ;int ret; -if (unlikely (!max)) +rte_spinlock_lock (&sq->sqsl); + max = (uint16_t )(sq->head - sq->tail); +if (unlikely (!max)) { +rte_spinlock_unlock (&sq->sqsl);return ; + } do { idx = next_idx; next_idx = (cq->cq_ci + 1) & mask;
@@ -769,6 +778,7 @@rte_io_wmb (); cq->cq_obj.db_rec[0 ] =rte_cpu_to_be_32 (cq->cq_ci); } +rte_spinlock_unlock (&sq->sqsl); }/**
Signature · 1 line
1.8.3.1
PATCH v6 14/15 net/mlx5: allow multiple flow tables on the same level
In reply to Jiawei WangFrom: Li Zhang <[email protected]>
The driver devices support creation of multiple flow tables. Jump action can be used in order to move the packet steering to different flow table.
Table 0 is always the root table for packet steering.
Jumping between tables may cause endless loops in steering mechanism, that's why each table has level attribute,
the driver sub-system may not allow jumping to table with equal or lower level than the current table.
Currently, in the driver, the table ID and level are always identical.
Allow multiple flow table creation with the same level attribute.
This patch adds the table id in flow table data entry, while allocates the flow table, if the table level is same but the different table id, the new table will be allocated with new table object id. It supports 4M multiple flow tables on the same level.
--- drivers/net/mlx5/mlx5.c | 9 +++-- drivers/net/mlx5/mlx5.h | 10 +++-- drivers/net/mlx5/mlx5_flow.c | 17 ++++++--- drivers/net/mlx5/mlx5_flow.h | 12 ++++-- drivers/net/mlx5/mlx5_flow_dv.c | 84 +++++++++++++++++++++++------------------ 5 files changed, 79 insertions(+), 53 deletions(-)
drivers/net/mlx5/mlx5.c +6 -3
@@ -1271,9 +1271,12 @@ struct mlx5_dev_ctx_shared ** because DV expect to see them even if they cannot be created by * RDMA-CORE. */ -if (!flow_dv_tbl_resource_get (dev,0 ,0 ,0 ,0 ,NULL ,0 ,1 , &error) || - !flow_dv_tbl_resource_get (dev,0 ,1 ,0 ,0 ,NULL ,0 ,1 , &error) || - !flow_dv_tbl_resource_get (dev,0 ,0 ,1 ,0 ,NULL ,0 ,1 , &error)) { +if (!flow_dv_tbl_resource_get (dev,0 ,0 ,0 ,0 , +NULL ,0 ,1 ,0 , &error) || + !flow_dv_tbl_resource_get (dev,0 ,1 ,0 ,0 , +NULL ,0 ,1 ,0 , &error) || + !flow_dv_tbl_resource_get (dev,0 ,0 ,1 ,0 , +NULL ,0 ,1 ,0 , &error)) { err =ENOMEM ; goto error; }
drivers/net/mlx5/mlx5.h +6 -4
@@ -779,10 +779,12 @@ struct mlx5_aso_mtr_pools_mng {union mlx5_flow_tbl_key {struct {/* Table ID should be at the lowest address. */ -uint32_t table_id;/**< ID of the table. */ -uint16_t dummy;/**< Dummy table for DV API. */ -uint8_t domain;/**< 1 - FDB, 0 - NIC TX/RX. */ -uint8_t direction;/**< 1 - egress, 0 - ingress. */ +uint32_t level;/**< Level of the table. */ +uint32_t id:22 ;/**< ID of the table. */ +uint32_t dummy:1 ;/**< Dummy table for DV API. */ +uint32_t is_fdb:1 ;/**< 1 - FDB, 0 - NIC TX/RX. */ +uint32_t is_egress:1 ;/**< 1 - egress, 0 - ingress. */ +uint32_t reserved:7 ;/**< must be zero for comparison. */ };uint64_t v64;/**< full 64bits value of key */ };
drivers/net/mlx5/mlx5_flow.c +11 -6
@@ -4342,6 +4342,9 @@ struct mlx5_hlist_entry * dev_flow->handle->mark =1 ;if (sub_flow) *sub_flow = dev_flow; +#ifdef HAVE_IBV_FLOW_DV_SUPPORT + dev_flow->dv.table_id = flow_split_info->table_id; +#endif return flow_drv_translate (dev, dev_flow, attr, items, actions, error); }
@@ -5497,8 +5500,7 @@ struct mlx5_hlist_entry * struct mlx5_flow_tbl_data_entry, tbl); sfx_attr.group = sfx_attr.transfer ? - (sfx_tbl_data->table_id -1 ) : - sfx_tbl_data->table_id; + (sfx_tbl_data->level -1 ) : sfx_tbl_data->level; }else {MLX5_ASSERT (attr->transfer); sfx_attr.group = jump_table;
@@ -5698,7 +5700,8 @@ struct mlx5_hlist_entry * .skip_scale = 0, .flow_idx = 0, .prefix_mark = 0, - .prefix_layers = 0 + .prefix_layers = 0, + .table_id = 0 };int ret;
@@ -7784,10 +7787,12 @@ int rte_pmd_mlx5_sync_flow(uint16_t port_id, uint32_t domains)union tunnel_offload_mark mbits = { .val = mark };union mlx5_flow_tbl_key table_key = { { - .table_id =tunnel_id_to_flow_tbl (mbits.table_id), + .level =tunnel_id_to_flow_tbl (mbits.table_id), + .id =0 , + .reserved =0 , .dummy =0 , - .domain = !!mbits.transfer, - .direction =0 , + .is_fdb = !!mbits.transfer, + .is_egress =0 , } }; he =mlx5_hlist_lookup (sh->flow_tbls, table_key.v64,NULL );
drivers/net/mlx5/mlx5_flow.h +8 -4
@@ -564,8 +564,9 @@ struct mlx5_flow_tbl_data_entry { uint32_t is_egress:1; /**< Egress table. */ uint32_t is_transfer:1; /**< Transfer table. */ uint32_t dummy:1; /**< DR table. */ - uint32_t reserve:27; /**< Reserved to future using. */ -uint32_t table_id;/**< Table ID. */ + uint32_t id:22; /**< Table ID. */ + uint32_t reserve:5; /**< Reserved to future using. */ +uint32_t level;/**< Table level. */ };/* Sub rdma-core actions list. */
@@ -699,6 +700,7 @@ struct mlx5_flow_handle {/** Device flow structure only for DV flow creation. */ struct mlx5_flow_dv_workspace {uint32_t group;/**< The group index. */ +uint32_t table_id;/**< Flow table identifier. */ uint8_t transfer;/**< 1 if the flow is E-Switch flow. */ int actions_n;/**< number of actions. */ void *actions[MLX5_DV_MAX_NUMBER_OF_ACTIONS ];/**< Action list. */
@@ -1059,6 +1061,7 @@ struct mlx5_flow_split_info {uint32_t flow_idx;/**< This memory pool index to the flow. */ uint32_t prefix_mark;/**< Prefix subflow mark flag. */ uint64_t prefix_layers;/**< Prefix subflow layers. */ +uint32_t table_id;/**< Flow table identifier. */ }; typedef int (*mlx5_flow_validate_t)(struct rte_eth_dev *dev,
@@ -1410,9 +1413,10 @@ int flow_dv_tbl_match_cb(struct mlx5_hlist *list,void flow_dv_tbl_remove_cb (struct mlx5_hlist *list,struct mlx5_hlist_entry *entry);struct mlx5_flow_tbl_resource *flow_dv_tbl_resource_get (struct rte_eth_dev *dev, -uint32_t table_id,uint8_t egress,uint8_t transfer, +uint32_t table_level,uint8_t egress,uint8_t transfer,bool external,const struct mlx5_flow_tunnel *tunnel, -uint32_t group_id,uint8_t dummy,struct rte_flow_error *error); +uint32_t group_id,uint8_t dummy, +uint32_t table_id,struct rte_flow_error *error);struct mlx5_hlist_entry *flow_dv_tag_create_cb (struct mlx5_hlist *list,uint64_t key,void *cb_ctx);
drivers/net/mlx5/mlx5_flow_dv.c +48 -36
205 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH v6 15/15 doc: update release notes for ASO meter
In reply to Jiawei WangThis patches updates the release notes for ASO meter supports. MLX5 PMD can scale the meter usage from 4K to millions with this feature.
--- doc/guides/rel_notes/release_21_05.rst | 1 + 1 file changed, 1 insertion(+)
doc/guides/rel_notes/release_21_05.rst +1 -0
@@ -156,6 +156,7 @@ New Features * Added support for VXLAN and NVGRE encap as sample actions. * Support push VLAN on ingress traffic and pop VLAN on egress traffic in E-Switch mode. + * Added support for ASO (Advanced Steering Operation) meter. * **Updated NXP DPAA driver.**
Signature · 1 line
1.8.3.1
Re: [dpdk-dev] [PATCH v6 15/15] doc: update release notes for ASO meter
Hi,
Quoted 10 lines
-----Original Message-----
From: Jiawei Wang <[email protected]>
Sent: Tuesday, April 20, 2021 1:55 PM
To: Matan Azrad <[email protected]>; Ori Kam <[email protected]>; Slava Ovsiienko <[email protected]>; [email protected]; NBU-Contact- Thomas Monjalon <[email protected]>
Cc: [email protected]; Raslan Darawsheh <[email protected]>; Asaf Penso <[email protected]>
Subject: [PATCH v6 15/15] doc: update release notes for ASO meter
Quoted 5 lines
This patches updates the release notes for ASO meter supports. MLX5 PMD can scale the meter usage from 4K to millions with this feature.
Signed-off-by Jiawei Wang <[email protected]>
Kindest regards
Raslan Darawsheh
Re: [dpdk-dev] [PATCH v6 15/15] doc: update release notes for ASO meter
In reply to Jiawei WangQuoted 5 lines · Jiawei Wang
This patches updates the release notes for ASO meter supports. MLX5 PMD can scale the meter usage from 4K to millions with this feature.
Signed-off-by Jiawei Wang <[email protected]>
doc update squashed to 12/15 in next-net, preferred to have doc update with patch.
Hi,
Quoted 70 lines
-----Original Message-----
From: Jiawei Wang <[email protected]>
Sent: Tuesday, April 20, 2021 1:55 PM
To: Matan Azrad <[email protected]>; Ori Kam <[email protected]>; Slava Ovsiienko <[email protected]>; [email protected]; NBU-Contact- Thomas Monjalon <[email protected]>
Cc: [email protected]; Raslan Darawsheh <[email protected]>; Asaf Penso <[email protected]>
Subject: [PATCH v6 00/15] Add ASO meter support in MLX5 PMDTo support more meters and better performance,
MLX HW provides ASO (Advanced Steering Operation) flow meter. It can expose millions of ASO flow meter context's in HW. This ASO object can allocate the large bulk meter objects. This patch set implement the ASO flow meter for mlx5 driver. MLX5 PMD driver will be responsible for ASO flow meter manage to HW.V2: Fix compile error issue (
mlx5_glue->destroy_flow_action)
V3: Fix comments.
V4: Fix comments and add Acked.
V5: Fix unusedlog_obj_sizeissue.
V6: Fix comments and update release notes.Jiawei Wang (1):
doc: update release notes for ASO meterLi Zhang (10):
net/mlx5: optimize meter statistics
common/mlx5: add definitions for ASO flow meter common/mlx5: add read ASO flow meter HCA capability common/mlx5: add DevX API to create ASO flow meter object net/mlx5: flow meter pool to manage meter object net/mlx5: initialize the flow meter ASO SQ net/mlx5: add meter ASO queue management net/mlx5: add support of ASO meter action net/mlx5: make ASO meter queue thread-safe net/mlx5: allow multiple flow tables on the same levelShun Hao (3):
common/mlx5: add color register idle bits definition net/mlx5: fix meter statistics
net/mlx5: use mask for meter register settingSuanming Mou (1):
net/mlx5: support three level table walkdoc/guides/nics/mlx5.rst | 6 + doc/guides/rel_notes/release_21_05.rst | 1 + drivers/common/mlx5/mlx5_devx_cmds.c | 68 +++ drivers/common/mlx5/mlx5_devx_cmds.h | 26 +- drivers/common/mlx5/mlx5_prm.h | 81 ++- drivers/common/mlx5/version.map | 1 + drivers/net/mlx5/linux/mlx5_os.c | 20 +- drivers/net/mlx5/meson.build | 2 +- drivers/net/mlx5/mlx5.c | 98 +++- drivers/net/mlx5/mlx5.h | 258 +++++++++- drivers/net/mlx5/mlx5_flow.c | 334 +++++++++---- drivers/net/mlx5/mlx5_flow.h | 212 +++----- drivers/net/mlx5/mlx5_flow_age.c | 591 ---------------------- drivers/net/mlx5/mlx5_flow_aso.c | 850 ++++++++++++++++++++++++++++++++ drivers/net/mlx5/mlx5_flow_dv.c | 792 +++++++++++++++++++++------ --- drivers/net/mlx5/mlx5_flow_meter.c | 873 +++++++++++++++++++++---- -------- drivers/net/mlx5/mlx5_utils.h | 90 ++++ 17 files changed, 2897 insertions(+), 1406 deletions(-) delete mode 100644 drivers/net/mlx5/mlx5_flow_age.c create mode 100644 drivers/net/mlx5/mlx5_flow_aso.c
Quoted 2 lines
--
1.8.3.1
Removed V5 and v6 applied to next-net-mlx,
Kindest regards,
Raslan Darawsheh
Quoted 28 lines · Jiawei Wang
To support more meters and better performance,
MLX HW provides ASO (Advanced Steering Operation) flow meter. It can expose millions of ASO flow meter context's in HW. This ASO object can allocate the large bulk meter objects. This patch set implement the ASO flow meter for mlx5 driver. MLX5 PMD driver will be responsible for ASO flow meter manage to HW.V2: Fix compile error issue (
mlx5_glue->destroy_flow_action)
V3: Fix comments.
V4: Fix comments and add Acked.
V5: Fix unusedlog_obj_sizeissue.
V6: Fix comments and update release notes.Jiawei Wang (1):
doc: update release notes for ASO meterLi Zhang (10):
net/mlx5: optimize meter statistics common/mlx5: add definitions for ASO flow meter common/mlx5: add read ASO flow meter HCA capability common/mlx5: add DevX API to create ASO flow meter object net/mlx5: flow meter pool to manage meter object net/mlx5: initialize the flow meter ASO SQ net/mlx5: add meter ASO queue management net/mlx5: add support of ASO meter action net/mlx5: make ASO meter queue thread-safe net/mlx5: allow multiple flow tables on the same level
Quoted 8 lines
Shun Hao (3):
common/mlx5: add color register idle bits definition net/mlx5: fix meter statistics
net/mlx5: use mask for meter register settingSuanming Mou (1):
net/mlx5: support three level table walk
Hi Li,
The request in previous patch was to add some documentation on the new feature in driver documentation, plus some design documentation if needed, not just release notes update.
But this patch become on the critical path for -rc1, since an mlx ethdev patch depends on this patch, I want to block them for the release, instead does it make sense the have the documentation update for the -rc2, what do you think?
Thanks,
ferruh
Quoted 55 lines
-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Wednesday, April 21, 2021 11:32 AM
To: Jiawei(Jonny) Wang <[email protected]>; Matan Azrad <[email protected]>; Ori Kam <[email protected]>; Slava Ovsiienko <[email protected]>; NBU-Contact-Thomas Monjalon <[email protected]>
Cc: [email protected]; Raslan Darawsheh <[email protected]>; Asaf Penso <[email protected]>
Subject: Re: [PATCH v6 00/15] Add ASO meter support in MLX5 PMDQuoted 28 lines · Jiawei Wang
To support more meters and better performance, MLX HW provides ASO (Advanced Steering Operation) flow meter.
It can expose millions of ASO flow meter context's in HW. This ASO object can allocate the large bulk meter objects. This patch set implement the ASO flow meter for mlx5 driver. MLX5 PMD driver will be responsible for ASO flow meter manage to HW.V2: Fix compile error issue (
mlx5_glue->destroy_flow_action)
V3: Fix comments.
V4: Fix comments and add Acked.
V5: Fix unusedlog_obj_sizeissue.
V6: Fix comments and update release notes.Jiawei Wang (1):
doc: update release notes for ASO meterLi Zhang (10):
net/mlx5: optimize meter statistics common/mlx5: add definitions for ASO flow meter common/mlx5: add read ASO flow meter HCA capability common/mlx5: add DevX API to create ASO flow meter object net/mlx5: flow meter pool to manage meter object net/mlx5: initialize the flow meter ASO SQ net/mlx5: add meter ASO queue management net/mlx5: add support of ASO meter action net/mlx5: make ASO meter queue thread-safe net/mlx5: allow multiple flow tables on the same levelQuoted 8 lines
Shun Hao (3):
common/mlx5: add color register idle bits definition net/mlx5: fix meter statistics
net/mlx5: use mask for meter register settingSuanming Mou (1):
net/mlx5: support three level table walkHi Li,
The request in previous patch was to add some documentation on the new feature in driver documentation, plus some design documentation if needed, not just release notes update.
Quoted 7 lines
But this patch become on the critical path for -rc1, since an mlx ethdev patch depends on this patch, I want to block them for the release, instead does it make sense the have the documentation update for the -rc2, what do you think?
Thanks,
ferruh
Hello Ferruh,
The ASO is not a new concept, and is already used by other features like shared RSS and sharing Aging. Regardless, I agree we can improve documention of the driver, as always 😊
We'll take it as part of -rc2, and would appreciate the integration of this patchset in the meanwhile.
Quoted 60 lines · Asaf Penso
Quoted 60 lines
-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Wednesday, April 21, 2021 11:32 AM
To: Jiawei(Jonny) Wang <[email protected]>; Matan Azrad <[email protected]>; Ori Kam <[email protected]>; Slava Ovsiienko <[email protected]>; NBU-Contact-Thomas Monjalon <[email protected]>
Cc: [email protected]; Raslan Darawsheh <[email protected]>; Asaf Penso <[email protected]>
Subject: Re: [PATCH v6 00/15] Add ASO meter support in MLX5 PMDQuoted 28 lines · Jiawei Wang
To support more meters and better performance, MLX HW provides ASO (Advanced Steering Operation) flow meter.
It can expose millions of ASO flow meter context's in HW. This ASO object can allocate the large bulk meter objects. This patch set implement the ASO flow meter for mlx5 driver. MLX5 PMD driver will be responsible for ASO flow meter manage to HW.V2: Fix compile error issue (
mlx5_glue->destroy_flow_action)
V3: Fix comments.
V4: Fix comments and add Acked.
V5: Fix unusedlog_obj_sizeissue.
V6: Fix comments and update release notes.Jiawei Wang (1):
doc: update release notes for ASO meterLi Zhang (10):
net/mlx5: optimize meter statistics common/mlx5: add definitions for ASO flow meter common/mlx5: add read ASO flow meter HCA capability common/mlx5: add DevX API to create ASO flow meter object net/mlx5: flow meter pool to manage meter object net/mlx5: initialize the flow meter ASO SQ net/mlx5: add meter ASO queue management net/mlx5: add support of ASO meter action net/mlx5: make ASO meter queue thread-safe net/mlx5: allow multiple flow tables on the same levelQuoted 8 lines
Shun Hao (3):
common/mlx5: add color register idle bits definition net/mlx5: fix meter statistics
net/mlx5: use mask for meter register settingSuanming Mou (1):
net/mlx5: support three level table walkHi Li,
The request in previous patch was to add some documentation on the new feature in driver documentation, plus some design documentation if needed, not just release notes update.
But this patch become on the critical path for -rc1, since an mlx ethdev patch depends on this patch, I want to block them for the release, instead does it make sense the have the documentation update for the -rc2, what do you think?
Quoted 6 lines
Quoted 2 lines
Thanks,
ferruhHello Ferruh,
The ASO is not a new concept, and is already used by other features like shared RSS and sharing Aging. Regardless, I agree we can improve documention of the driver, as always 😊
+1
Quoted 2 lines
We'll take it as part of -rc2, and would appreciate the integration of this patchset in the meanwhile.
A correction from above, "I _don't_ want to block them for the release" and already working on it, the documentation update can be merged on -rc2.
Thanks.