net/mlx5: support more REG C registers
Subsystems (2)
cover net/mlx5: support more REG C registers
Support increased number of REG_Cx registers.
Gregory Etelson (7):
net/mlx5/hws: Definer, add mlx5dr context to definer_conv_data net/mlx5: add flow_hw_get_reg_id_from_ctx()
net/mlx5/hws: Definer, use flow_hw_get_reg_id_from_ctx function call net/mlx5: add rte_device parameter to locate HWS registers net/mlx5: separate port REG_C registers usage
net/mlx5: merge REG_C aliases
net/mlx5: initialize HWS flow tags registers in shared dev context
Itamar Gozlan (1):
net/mlx5/hws: adding method to query rule hash
Ori Kam (5):
net/mlx5: add support for calc hash
net/mlx5: fix insert by index
net/mlx5: fix query for NIC flow cap
net/mlx5: add support for more registers
net/mlx5: add validation support for tags
drivers/common/mlx5/mlx5_devx_cmds.c | 17 ++- drivers/common/mlx5/mlx5_devx_cmds.h | 2 +- drivers/common/mlx5/mlx5_prm.h | 56 ++++++- drivers/net/mlx5/hws/meson.build | 1 + drivers/net/mlx5/hws/mlx5dr.h | 26 ++++ drivers/net/mlx5/hws/mlx5dr_cmd.c | 3 + drivers/net/mlx5/hws/mlx5dr_cmd.h | 3 +- drivers/net/mlx5/hws/mlx5dr_crc32.c | 61 ++++++++ drivers/net/mlx5/hws/mlx5dr_crc32.h | 13 ++ drivers/net/mlx5/hws/mlx5dr_definer.c | 20 ++- drivers/net/mlx5/hws/mlx5dr_internal.h | 1 + drivers/net/mlx5/hws/mlx5dr_rule.c | 37 +++++ drivers/net/mlx5/hws/mlx5dr_rule.h | 1 + drivers/net/mlx5/linux/mlx5_os.c | 39 +---- drivers/net/mlx5/mlx5.c | 79 +++++++++- drivers/net/mlx5/mlx5.h | 16 +- drivers/net/mlx5/mlx5_flow.c | 63 +++++--- drivers/net/mlx5/mlx5_flow.h | 68 ++++++--- drivers/net/mlx5/mlx5_flow_dv.c | 24 ++- drivers/net/mlx5/mlx5_flow_hw.c | 201 ++++++++----------------- drivers/net/mlx5/mlx5_flow_meter.c | 14 +- 21 files changed, 491 insertions(+), 254 deletions(-) create mode 100644 drivers/net/mlx5/hws/mlx5dr_crc32.c create mode 100644 drivers/net/mlx5/hws/mlx5dr_crc32.h
Signature · 1 line
2.39.2
PATCH 1/13 net/mlx5/hws: Definer, add mlx5dr context to definer_conv_data
New mlx5dr_context member replaces mlx5dr_cmd_query_caps. Capabilities structure is a member of mlx5dr_context.
--- drivers/net/mlx5/hws/mlx5dr_definer.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/mlx5/hws/mlx5dr_definer.c +2 -2
@@ -1185,7 +1185,7 @@ mlx5dr_definer_conv_item_gtp(struct mlx5dr_definer_conv_data *cd,return rte_errno; } -if (m->hdr.teid) { +if (m->teid) {if (!(caps->flex_protocols &MLX5_HCA_FLEX_GTPU_TEID_ENABLED )) { rte_errno =ENOTSUP ;return rte_errno;
@@ -1211,7 +1211,7 @@ mlx5dr_definer_conv_item_gtp(struct mlx5dr_definer_conv_data *cd, } -if (m->hdr.msg_type) { +if (m->msg_type) {if (!(caps->flex_protocols &MLX5_HCA_FLEX_GTPU_DW_0_ENABLED )) { rte_errno =ENOTSUP ;return rte_errno;
Signature · 1 line
2.39.2
PATCH 2/13 net/mlx5: add flow_hw_get_reg_id_from_ctx()
In reply to Gregory EtelsonThe new function call flow_hw_get_reg_id_from_ctx() maps input DR5 context and register type to REG_C register.
--- drivers/net/mlx5/mlx5_flow.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)
drivers/net/mlx5/mlx5_flow.h +22 -0
@@ -1714,6 +1714,28 @@ flow_hw_get_reg_id(enum rte_flow_item_type type, uint32_t id) } } +static __rte_always_inline int +flow_hw_get_reg_id_from_ctx (void *dr_ctx, +enum rte_flow_item_type type,uint32_t id) +{ +#ifdef HAVE_IBV_FLOW_DV_SUPPORT +uint16_t port; + + MLX5_ETH_FOREACH_DEV(port, NULL) { +struct mlx5_priv *priv; + + priv = rte_eth_devices[port].data->dev_private; +if (priv->dr_ctx == dr_ctx) +return flow_hw_get_reg_id (type, id); + } +#else +RTE_SET_USED (dr_ctx); +RTE_SET_USED (type); +RTE_SET_USED (id); +#endif +return REG_NON ; +} +void flow_hw_set_port_info (struct rte_eth_dev *dev);void flow_hw_clear_port_info (struct rte_eth_dev *dev);
Signature · 1 line
2.39.2
PATCH 3/13 net/mlx5/hws: Definer, use flow_hw_get_reg_id_from_ctx function call
In reply to Gregory EtelsonNew function call flow_hw_get_reg_id_from_ctx() matches REG_C register to input DR5 context.
--- drivers/net/mlx5/hws/mlx5dr_definer.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-)
drivers/net/mlx5/hws/mlx5dr_definer.c +11 -5
@@ -1541,7 +1541,9 @@ mlx5dr_definer_conv_item_tag(struct mlx5dr_definer_conv_data *cd,return 0 ;if (item->type ==RTE_FLOW_ITEM_TYPE_TAG ) - reg =flow_hw_get_reg_id (RTE_FLOW_ITEM_TYPE_TAG , v->index); + reg =flow_hw_get_reg_id_from_ctx (cd->ctx, +RTE_FLOW_ITEM_TYPE_TAG , + v->index);else reg = (int )v->index;
@@ -1601,7 +1603,9 @@ mlx5dr_definer_conv_item_quota(struct mlx5dr_definer_conv_data *cd, __rte_unused struct rte_flow_item *item, int item_idx) { - int mtr_reg = flow_hw_get_reg_id(RTE_FLOW_ITEM_TYPE_METER_COLOR, 0); + int mtr_reg = +flow_hw_get_reg_id_from_ctx (cd->ctx,RTE_FLOW_ITEM_TYPE_METER_COLOR , +0 );struct mlx5dr_definer_fc *fc;if (mtr_reg <0 ) {
@@ -1631,7 +1635,7 @@ mlx5dr_definer_conv_item_metadata(struct mlx5dr_definer_conv_data *cd,if (!m)return 0 ; - reg =flow_hw_get_reg_id (RTE_FLOW_ITEM_TYPE_META ,-1 ); + reg =flow_hw_get_reg_id_from_ctx (cd->ctx,RTE_FLOW_ITEM_TYPE_META ,-1 );if (reg <=0 ) {DR_LOG (ERR ,"Invalid register for item metadata" ); rte_errno =EINVAL ;
@@ -1939,7 +1943,8 @@ mlx5dr_definer_conv_item_conntrack(struct mlx5dr_definer_conv_data *cd,if (!m)return 0 ; - reg =flow_hw_get_reg_id (RTE_FLOW_ITEM_TYPE_CONNTRACK ,-1 ); + reg =flow_hw_get_reg_id_from_ctx (cd->ctx,RTE_FLOW_ITEM_TYPE_CONNTRACK , +-1 );if (reg <=0 ) {DR_LOG (ERR ,"Invalid register for item conntrack" ); rte_errno =EINVAL ;
@@ -2080,7 +2085,8 @@ mlx5dr_definer_conv_item_meter_color(struct mlx5dr_definer_conv_data *cd,if (!m)return 0 ; - reg =flow_hw_get_reg_id (RTE_FLOW_ITEM_TYPE_METER_COLOR ,0 ); + reg =flow_hw_get_reg_id_from_ctx (cd->ctx, +RTE_FLOW_ITEM_TYPE_METER_COLOR ,0 );MLX5_ASSERT (reg >0 ); fc =mlx5dr_definer_get_register_fc (cd, reg);
Signature · 1 line
2.39.2
PATCH 4/13 net/mlx5: add rte_device parameter to locate HWS registers
In reply to Gregory Etelson1. Add rte_eth_dev parameter to the flow_hw_get_reg_id()
2. Add mlx5_flow_hw_get_reg_id()
--- drivers/net/mlx5/mlx5_flow.c | 2 +- drivers/net/mlx5/mlx5_flow.h | 13 +++++++++++-- drivers/net/mlx5/mlx5_flow_dv.c | 12 ++++++------ drivers/net/mlx5/mlx5_flow_hw.c | 7 +++---- 4 files changed, 21 insertions(+), 13 deletions(-)
drivers/net/mlx5/mlx5_flow.c +1 -1
@@ -1718,7 +1718,7 @@ flow_drv_rxq_flags_set(struct rte_eth_dev *dev, } } -static void +void flow_rxq_mark_flag_set (struct rte_eth_dev *dev) {struct mlx5_priv *priv = dev->data->dev_private;
drivers/net/mlx5/mlx5_flow.h +11 -2
@@ -1681,8 +1681,10 @@ void flow_hw_clear_flow_metadata_config(void);* TODO: Per port / device, FDB or NIC for Meta matching. */ static __rte_always_inline int -flow_hw_get_reg_id (enum rte_flow_item_type type,uint32_t id) +flow_hw_get_reg_id (struct rte_eth_dev *dev, +enum rte_flow_item_type type,uint32_t id) { +RTE_SET_USED (dev);switch (type) {case RTE_FLOW_ITEM_TYPE_META :#ifdef HAVE_MLX5_HWS_SUPPORT
@@ -1726,7 +1728,8 @@ flow_hw_get_reg_id_from_ctx(void *dr_ctx, priv = rte_eth_devices[port].data->dev_private;if (priv->dr_ctx == dr_ctx) - return flow_hw_get_reg_id(type, id); +return flow_hw_get_reg_id (&rte_eth_devices[port], + type, id); }#else RTE_SET_USED (dr_ctx);
@@ -2877,6 +2880,12 @@ flow_hw_get_srh_flex_parser_byte_off_from_ctx(void *dr_ctx __rte_unused) }void mlx5_indirect_list_handles_release (struct rte_eth_dev *dev); +void +flow_rxq_mark_flag_set (struct rte_eth_dev *dev); +int +mlx5_flow_hw_get_reg_id (struct mlx5dr_context *ctx, +enum rte_flow_item_type type,uint32_t id); +#ifdef HAVE_MLX5_HWS_SUPPORT struct mlx5_mirror ;void
drivers/net/mlx5/mlx5_flow_dv.c +6 -6
@@ -1919,8 +1919,8 @@ mlx5_flow_field_id_to_modify_info off_be = (tag_index ==MLX5_LINEAR_HASH_TAG_INDEX ) ?16 - (data->offset + width) +16 : data->offset;if (priv->sh->config.dv_flow_en ==2 ) - reg =flow_hw_get_reg_id (RTE_FLOW_ITEM_TYPE_TAG , - tag_index); + reg =flow_hw_get_reg_id (dev,RTE_FLOW_ITEM_TYPE_TAG , + data->level);else reg =mlx5_flow_get_reg_id (dev,MLX5_APP_TAG , tag_index, error);
@@ -2025,7 +2025,7 @@ mlx5_flow_field_id_to_modify_infoif (priv->sh->config.dv_flow_en ==2 ) reg =flow_hw_get_reg_id - (RTE_FLOW_ITEM_TYPE_METER_COLOR ,0 ); + (dev,RTE_FLOW_ITEM_TYPE_METER_COLOR ,0 );else reg =mlx5_flow_get_reg_id (dev,MLX5_MTR_COLOR ,0 , error);
@@ -10256,7 +10256,7 @@ flow_dv_translate_item_meta(struct rte_eth_dev *dev,if (!!(key_type &MLX5_SET_MATCHER_SW )) reg =flow_dv_get_metadata_reg (dev, attr,NULL );else - reg =flow_hw_get_reg_id (RTE_FLOW_ITEM_TYPE_META ,0 ); + reg =flow_hw_get_reg_id (dev,RTE_FLOW_ITEM_TYPE_META ,0 );if (reg <0 )return ;MLX5_ASSERT (reg !=REG_NON );
@@ -10359,7 +10359,7 @@ flow_dv_translate_item_tag(struct rte_eth_dev *dev, void *key,if (!!(key_type &MLX5_SET_MATCHER_SW )) reg =mlx5_flow_get_reg_id (dev,MLX5_APP_TAG , index,NULL );else - reg =flow_hw_get_reg_id (RTE_FLOW_ITEM_TYPE_TAG , index); + reg =flow_hw_get_reg_id (dev,RTE_FLOW_ITEM_TYPE_TAG , index);MLX5_ASSERT (reg >0 );flow_dv_match_meta_reg (key, (enum modify_reg )reg, tag_v->data, tag_m->data); }
@@ -11057,7 +11057,7 @@ flow_dv_translate_item_meter_color(struct rte_eth_dev *dev, void *key,if (!!(key_type &MLX5_SET_MATCHER_SW )) reg =mlx5_flow_get_reg_id (dev,MLX5_MTR_COLOR ,0 ,NULL );else - reg =flow_hw_get_reg_id (RTE_FLOW_ITEM_TYPE_METER_COLOR ,0 ); + reg =flow_hw_get_reg_id (dev,RTE_FLOW_ITEM_TYPE_METER_COLOR ,0 );if (reg ==REG_NON )return ;flow_dv_match_meta_reg (key, (enum modify_reg )reg, value, mask);
drivers/net/mlx5/mlx5_flow_hw.c +3 -4
@@ -5595,9 +5595,8 @@ flow_hw_pattern_validate(struct rte_eth_dev *dev,if (tag ==NULL )return rte_flow_error_set (error,EINVAL ,RTE_FLOW_ERROR_TYPE_UNSPECIFIED , -NULL , -"Tag spec is NULL" ); - tag_idx =flow_hw_get_reg_id (RTE_FLOW_ITEM_TYPE_TAG , tag->index); +NULL ,"Tag spec is NULL" ); + tag_idx =flow_hw_get_reg_id (dev,RTE_FLOW_ITEM_TYPE_TAG , tag->index);if (tag_idx ==REG_NON ) return rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
@@ -5655,7 +5654,7 @@ flow_hw_pattern_validate(struct rte_eth_dev *dev,break ;case RTE_FLOW_ITEM_TYPE_METER_COLOR : { -int reg =flow_hw_get_reg_id (RTE_FLOW_ITEM_TYPE_METER_COLOR ,0 ); +int reg =flow_hw_get_reg_id (dev,RTE_FLOW_ITEM_TYPE_METER_COLOR ,0 );if (reg ==REG_NON ) return rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
Signature · 1 line
2.39.2
PATCH 5/13 net/mlx5: separate port REG_C registers usage
In reply to Gregory EtelsonCurrent implementation stored REG_C registers available for HWS tags in PMD global array. As the result, PMD could not work properly with different port types that allocate REG_C registers differently.
The patch stores registers available to a port in the port shared context. Register values will be assigned according to the port capabilities.
--- drivers/common/mlx5/mlx5_prm.h | 12 +++ drivers/net/mlx5/linux/mlx5_os.c | 16 ++-- drivers/net/mlx5/mlx5.c | 4 - drivers/net/mlx5/mlx5.h | 11 ++- drivers/net/mlx5/mlx5_flow.c | 29 ++----- drivers/net/mlx5/mlx5_flow.h | 25 ++---- drivers/net/mlx5/mlx5_flow_dv.c | 13 +-- drivers/net/mlx5/mlx5_flow_hw.c | 129 ++++------------------------- drivers/net/mlx5/mlx5_flow_meter.c | 14 ++-- 9 files changed, 78 insertions(+), 175 deletions(-)
drivers/common/mlx5/mlx5_prm.h +12 -0
@@ -864,6 +864,18 @@ enum modify_reg { REG_C_11, }; +static __rte_always_inline uint8_t +mlx5_regc_index (enum modify_reg regc_val) +{ +return (uint8_t )(regc_val -REG_C_0 ); +} + +static __rte_always_inline enum modify_reg +mlx5_regc_value (uint8_t regc_ix) +{ +return REG_C_0 + regc_ix; +} +/* Modification sub command. */ struct mlx5_modification_cmd { union {
drivers/net/mlx5/linux/mlx5_os.c +8 -8
@@ -1328,14 +1328,14 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,* Prefer REG_C_3 if it is available. */ if (reg_c_mask & (1 << (REG_C_3 -REG_C_0 ))) - priv->mtr_color_reg =REG_C_3 ; + sh->registers.mtr_color_reg =REG_C_3 ;else - priv->mtr_color_reg =ffs (reg_c_mask) - -1 +REG_C_0 ; + sh->registers.mtr_color_reg = +ffs (reg_c_mask) -1 +REG_C_0 ; priv->mtr_en =1 ; priv->mtr_reg_share = hca_attr->qos.flow_meter;DRV_LOG (DEBUG ,"The REG_C meter uses is %d" , - priv->mtr_color_reg); + sh->registers.mtr_color_reg); } }if (hca_attr->qos.sup && hca_attr->qos.flow_meter_aso_sup) {
@@ -1360,7 +1360,7 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, sh->tunnel_header_2_3 =1 ;#endif #ifdef HAVE_MLX5_DR_CREATE_ACTION_ASO -if (hca_attr->flow_hit_aso && priv->mtr_color_reg ==REG_C_3 ) { +if (hca_attr->flow_hit_aso && sh->registers.mtr_color_reg ==REG_C_3 ) { sh->flow_hit_aso_en =1 ; err =mlx5_flow_aso_age_mng_init (sh);if (err) {
@@ -1374,7 +1374,7 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,defined (HAVE_MLX5_DR_ACTION_ASO_CT)/* HWS create CT ASO SQ based on HWS configure queue number. */ if (sh->config.dv_flow_en != 2 && - hca_attr->ct_offload && priv->mtr_color_reg == REG_C_3) { + hca_attr->ct_offload && sh->registers.mtr_color_reg == REG_C_3) { err =mlx5_flow_aso_ct_mng_init (sh);if (err) { err = -err;
@@ -1618,8 +1618,8 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, goto error; }/* Only HWS requires this information. */ -flow_hw_init_tags_set (eth_dev); -flow_hw_init_flow_metadata_config (eth_dev); +if (sh->refcnt ==1 ) +flow_hw_init_tags_set (eth_dev);if (priv->sh->config.dv_esw_en &&flow_hw_create_vport_action (eth_dev)) { DRV_LOG(ERR, "port %u failed to create vport action",
drivers/net/mlx5/mlx5.c +0 -4
@@ -2173,10 +2173,6 @@ mlx5_dev_close(struct rte_eth_dev *dev)flow_hw_destroy_vport_action (dev);flow_hw_resource_release (dev);flow_hw_clear_port_info (dev); -if (priv->sh->config.dv_flow_en ==2 ) { -flow_hw_clear_flow_metadata_config (); -flow_hw_clear_tags_set (dev); - }#endif if (priv->rxq_privs !=NULL ) {/* XXX race condition if mlx5_rx_burst() is still running. */
drivers/net/mlx5/mlx5.h +9 -2
@@ -1373,6 +1373,14 @@ struct mlx5_hws_cnt_svc_mng { struct mlx5_hws_aso_mng aso_mng __rte_cache_aligned; }; +#define MLX5_FLOW_HW_TAGS_MAX 8 + +struct mlx5_dev_registers { +enum modify_reg mlx5_flow_hw_aso_tag; +enum modify_reg mtr_color_reg;/* Meter color match REG_C. */ +enum modify_reg hw_avl_tags[MLX5_FLOW_HW_TAGS_MAX ]; +}; +/* * Shared Infiniband device context for Master/Representors * which belong to same IB device with multiple IB ports.
@@ -1393,7 +1401,6 @@ struct mlx5_dev_ctx_shared { uint32_t drop_action_check_flag:1; /* Check Flag for drop action. */ uint32_t flow_priority_check_flag:1; /* Check Flag for flow priority. */ uint32_t metadata_regc_check_flag:1; /* Check Flag for metadata REGC. */ - uint32_t hws_tags:1; /* Check if tags info for HWS initialized. */ uint32_t shared_mark_enabled:1;/* If mark action is enabled on Rxqs (shared E-Switch domain). */ uint32_t lag_rx_port_affinity_en:1;
@@ -1482,6 +1489,7 @@ struct mlx5_dev_ctx_shared { uint32_t host_shaper_rate:8; uint32_t lwm_triggered:1;struct mlx5_hws_cnt_svc_mng *cnt_svc; +struct mlx5_dev_registers registers;struct mlx5_dev_shared_port port[];/* per device port data array. */ };
@@ -1811,7 +1819,6 @@ struct mlx5_priv {/* Hash table of Rx metadata register copy table. */ struct mlx5_mtr_config mtr_config;/* Meter configuration */ uint8_t mtr_sfx_reg;/* Meter prefix-suffix flow match REG_C. */ -uint8_t mtr_color_reg;/* Meter color match REG_C. */ struct mlx5_legacy_flow_meters flow_meters;/* MTR list. */ struct mlx5_l3t_tbl *mtr_profile_tbl;/* Meter index lookup table. */ struct mlx5_flow_meter_profile *mtr_profile_arr;/* Profile array. */
drivers/net/mlx5/mlx5_flow.c +9 -20
@@ -39,18 +39,6 @@*/ struct flow_hw_port_info mlx5_flow_hw_port_infos[RTE_MAX_ETHPORTS ]; -/* -* A global structure to save the available REG_C_x for tags usage. -* The Meter color REG (ASO) and the last available one will be reserved -* for PMD internal usage. -* Since there is no "port" concept in the driver, it is assumed that the -* available tags set will be the minimum intersection. -* 3 - in FDB mode / 5 - in legacy mode -*/ -uint32_t mlx5_flow_hw_avl_tags_init_cnt; -enum modify_reg mlx5_flow_hw_avl_tags[MLX5_FLOW_HW_TAGS_MAX ] = {REG_NON }; -enum modify_reg mlx5_flow_hw_aso_tag; -struct tunnel_default_miss_ctx {uint16_t *queue; __extension__
@@ -1320,6 +1308,7 @@ mlx5_flow_get_reg_id(struct rte_eth_dev *dev, {struct mlx5_priv *priv = dev->data->dev_private;struct mlx5_sh_config *config = &priv->sh->config; +struct mlx5_dev_registers *reg = &priv->sh->registers;enum modify_reg start_reg;bool skip_mtr_reg = false;
@@ -1375,23 +1364,23 @@ mlx5_flow_get_reg_id(struct rte_eth_dev *dev,* should use the meter color register for match. */ if (priv->mtr_reg_share) -return priv->mtr_color_reg; +return reg->mtr_color_reg;else -return priv->mtr_color_reg !=REG_C_2 ?REG_C_2 : +return reg->mtr_color_reg !=REG_C_2 ?REG_C_2 :REG_C_3 ;case MLX5_MTR_COLOR :case MLX5_ASO_FLOW_HIT :case MLX5_ASO_CONNTRACK :case MLX5_SAMPLE_ID :/* All features use the same REG_C. */ -MLX5_ASSERT (priv->mtr_color_reg !=REG_NON ); -return priv->mtr_color_reg; +MLX5_ASSERT (reg->mtr_color_reg !=REG_NON ); +return reg->mtr_color_reg;case MLX5_COPY_MARK :/* * Metadata COPY_MARK register using is in meter suffix sub * flow while with meter. It's safe to share the same register. */ -return priv->mtr_color_reg !=REG_C_2 ?REG_C_2 :REG_C_3 ; +return reg->mtr_color_reg !=REG_C_2 ?REG_C_2 :REG_C_3 ;case MLX5_APP_TAG :/* * If meter is enable, it will engage the register for color
@@ -1400,7 +1389,7 @@ mlx5_flow_get_reg_id(struct rte_eth_dev *dev,* match. * If meter is disable, free to use all available registers. */ - start_reg = priv->mtr_color_reg !=REG_C_2 ?REG_C_2 : + start_reg = reg->mtr_color_reg !=REG_C_2 ?REG_C_2 : (priv->mtr_reg_share ?REG_C_3 :REG_C_4 ); skip_mtr_reg = !!(priv->mtr_en && start_reg ==REG_C_2 );if (id > (uint32_t )(REG_C_7 - start_reg))
@@ -1418,7 +1407,7 @@ mlx5_flow_get_reg_id(struct rte_eth_dev *dev,* color register. */ if (skip_mtr_reg && priv->sh->flow_mreg_c - [id + start_reg -REG_C_0 ] >= priv->mtr_color_reg) { + [id + start_reg -REG_C_0 ] >= reg->mtr_color_reg) {if (id >= (uint32_t )(REG_C_7 - start_reg)) return rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM,
@@ -6491,7 +6480,7 @@ flow_sample_split_prep(struct rte_eth_dev *dev,* metadata regC is REG_NON, back to use application tag * index 0. */ -if (unlikely (priv->mtr_color_reg ==REG_NON )) +if (unlikely (priv->sh->registers.mtr_color_reg ==REG_NON )) ret =mlx5_flow_get_reg_id (dev,MLX5_APP_TAG ,0 , error);else ret =mlx5_flow_get_reg_id (dev,MLX5_SAMPLE_ID ,0 , error);
drivers/net/mlx5/mlx5_flow.h +7 -18
@@ -1621,11 +1621,6 @@ struct flow_hw_port_info {extern struct flow_hw_port_info mlx5_flow_hw_port_infos[RTE_MAX_ETHPORTS ]; -#define MLX5_FLOW_HW_TAGS_MAX 8 -extern uint32_t mlx5_flow_hw_avl_tags_init_cnt; -extern enum modify_reg mlx5_flow_hw_avl_tags[]; -extern enum modify_reg mlx5_flow_hw_aso_tag; -/* * Get metadata match tag and mask for given rte_eth_dev port. * Used in HWS rule creation.
@@ -1667,13 +1662,6 @@ flow_hw_get_wire_port(struct ibv_context *ibctx) }#endif -extern uint32_t mlx5_flow_hw_flow_metadata_config_refcnt; -extern uint8_t mlx5_flow_hw_flow_metadata_esw_en; -extern uint8_t mlx5_flow_hw_flow_metadata_xmeta_en; - -void flow_hw_init_flow_metadata_config (struct rte_eth_dev *dev); -void flow_hw_clear_flow_metadata_config (void ); -/* * Convert metadata or tag to the actual register. * META: Can only be used to match in the FDB in this stage, fixed C_1.
@@ -1684,12 +1672,14 @@ static __rte_always_inline int flow_hw_get_reg_id(struct rte_eth_dev *dev, enum rte_flow_item_type type, uint32_t id) { -RTE_SET_USED (dev); + struct mlx5_dev_ctx_shared *sh = MLX5_SH(dev); +struct mlx5_dev_registers *reg = &sh->registers; +switch (type) {case RTE_FLOW_ITEM_TYPE_META :#ifdef HAVE_MLX5_HWS_SUPPORT -if (mlx5_flow_hw_flow_metadata_esw_en && - mlx5_flow_hw_flow_metadata_xmeta_en ==MLX5_XMETA_MODE_META32_HWS ) { +if (sh->config.dv_esw_en && + sh->config.dv_xmeta_en ==MLX5_XMETA_MODE_META32_HWS ) {return REG_C_1 ; }#endif
@@ -1705,12 +1695,12 @@ flow_hw_get_reg_id(struct rte_eth_dev *dev,return REG_A ;case RTE_FLOW_ITEM_TYPE_CONNTRACK :case RTE_FLOW_ITEM_TYPE_METER_COLOR : -return mlx5_flow_hw_aso_tag; +return reg->mlx5_flow_hw_aso_tag;case RTE_FLOW_ITEM_TYPE_TAG :if (id ==MLX5_LINEAR_HASH_TAG_INDEX )return REG_C_3 ;MLX5_ASSERT (id <MLX5_FLOW_HW_TAGS_MAX ); -return mlx5_flow_hw_avl_tags[id]; +return reg->hw_avl_tags[id];default :return REG_NON ; }
@@ -1743,7 +1733,6 @@ void flow_hw_set_port_info(struct rte_eth_dev *dev);void flow_hw_clear_port_info (struct rte_eth_dev *dev);void flow_hw_init_tags_set (struct rte_eth_dev *dev); -void flow_hw_clear_tags_set (struct rte_eth_dev *dev);int flow_hw_create_vport_action (struct rte_eth_dev *dev);void flow_hw_destroy_vport_action (struct rte_eth_dev *dev);
drivers/net/mlx5/mlx5_flow_dv.c +8 -5
@@ -1919,7 +1919,8 @@ mlx5_flow_field_id_to_modify_info off_be = (tag_index ==MLX5_LINEAR_HASH_TAG_INDEX ) ?16 - (data->offset + width) +16 : data->offset;if (priv->sh->config.dv_flow_en ==2 ) - reg =flow_hw_get_reg_id (dev,RTE_FLOW_ITEM_TYPE_TAG , + reg =flow_hw_get_reg_id (dev, +RTE_FLOW_ITEM_TYPE_TAG , data->level);else reg = mlx5_flow_get_reg_id(dev, MLX5_APP_TAG,
@@ -2025,7 +2026,7 @@ mlx5_flow_field_id_to_modify_infoif (priv->sh->config.dv_flow_en ==2 ) reg =flow_hw_get_reg_id - (dev,RTE_FLOW_ITEM_TYPE_METER_COLOR ,0 ); + (dev,RTE_FLOW_ITEM_TYPE_METER_COLOR ,0 );else reg =mlx5_flow_get_reg_id (dev,MLX5_MTR_COLOR ,0 , error);
@@ -3922,7 +3923,7 @@ flow_dv_validate_item_meter_color(struct rte_eth_dev *dev, };int ret; -if (priv->mtr_color_reg ==REG_NON ) +if (priv->sh->registers.mtr_color_reg ==REG_NON )return rte_flow_error_set (error,ENOTSUP ,RTE_FLOW_ERROR_TYPE_ITEM , item, "meter color register"
@@ -8373,7 +8374,8 @@ flow_dv_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr,if (ret <0 )return ret;if ((action_flags &MLX5_FLOW_ACTION_SET_TAG ) && - tag_id ==0 && priv->mtr_color_reg ==REG_NON ) + tag_id ==0 && + priv->sh->registers.mtr_color_reg ==REG_NON )return rte_flow_error_set (error,EINVAL ,RTE_FLOW_ERROR_TYPE_ACTION ,NULL ,"sample after tag action causes metadata tag index 0 corruption" );
@@ -11057,7 +11059,8 @@ flow_dv_translate_item_meter_color(struct rte_eth_dev *dev, void *key,if (!!(key_type &MLX5_SET_MATCHER_SW )) reg =mlx5_flow_get_reg_id (dev,MLX5_MTR_COLOR ,0 ,NULL );else - reg =flow_hw_get_reg_id (dev,RTE_FLOW_ITEM_TYPE_METER_COLOR ,0 ); + reg =flow_hw_get_reg_id (dev, +RTE_FLOW_ITEM_TYPE_METER_COLOR ,0 );if (reg ==REG_NON )return ;flow_dv_match_meta_reg (key, (enum modify_reg )reg, value, mask);
drivers/net/mlx5/mlx5_flow_hw.c +17 -112
150 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_meter.c +8 -6
@@ -67,7 +67,7 @@ mlx5_flow_meter_action_create(struct mlx5_priv *priv, val = (ebs_eir >>ASO_DSEG_EBS_MAN_OFFSET ) &ASO_DSEG_MAN_MASK ;MLX5_SET (flow_meter_parameters, fmp, ebs_mantissa, val); mtr_init.next_table = def_policy->sub_policy.tbl_rsc->obj; - mtr_init.reg_c_index = priv->mtr_color_reg -REG_C_0 ; + mtr_init.reg_c_index = priv->sh->registers.mtr_color_reg -REG_C_0 ; mtr_init.flow_meter_parameter = fmp; mtr_init.flow_meter_parameter_sz =MLX5_ST_SZ_BYTES (flow_meter_parameters);
@@ -1597,6 +1597,7 @@ mlx5_flow_meter_action_modify(struct mlx5_priv *priv, uint64_t modify_bits, uint32_t active_state, uint32_t is_enable) { #ifdef HAVE_MLX5_DR_CREATE_ACTION_FLOW_METER + struct mlx5_dev_ctx_shared *sh = priv->sh;uint32_t in[MLX5_ST_SZ_DW (flow_meter_parameters)] = {0 };uint32_t *attr;struct mlx5dv_dr_flow_meter_attr mod_attr = {0 };
@@ -1604,19 +1605,20 @@ mlx5_flow_meter_action_modify(struct mlx5_priv *priv,struct mlx5_aso_mtr *aso_mtr =NULL ;uint32_t cbs_cir, ebs_eir, val; -if (priv->sh->meter_aso_en) { +if (sh->meter_aso_en) { fm->is_enable = !!is_enable; aso_mtr = container_of(fm, struct mlx5_aso_mtr, fm); - ret =mlx5_aso_meter_update_by_wqe (priv->sh,MLX5_HW_INV_QUEUE , - aso_mtr, &priv->mtr_bulk,NULL , true); + ret =mlx5_aso_meter_update_by_wqe (sh,MLX5_HW_INV_QUEUE , + aso_mtr, &priv->mtr_bulk, +NULL , true);if (ret)return ret; - ret =mlx5_aso_mtr_wait (priv->sh,MLX5_HW_INV_QUEUE , aso_mtr); + ret =mlx5_aso_mtr_wait (sh,MLX5_HW_INV_QUEUE , aso_mtr);if (ret)return ret; }else {/* Fill command parameters. */ - mod_attr.reg_c_index = priv->mtr_color_reg -REG_C_0 ; + mod_attr.reg_c_index = sh->registers.mtr_color_reg -REG_C_0 ; mod_attr.flow_meter_parameter = in; mod_attr.flow_meter_parameter_sz =MLX5_ST_SZ_BYTES (flow_meter_parameters);
Signature · 1 line
2.39.2
PATCH 6/13 net/mlx5: merge REG_C aliases
In reply to Gregory EtelsonMerge mtr_color_reg and mlx5_flow_hw_aso_tag
into aso_reg
--- drivers/net/mlx5/linux/mlx5_os.c | 10 +++++----- drivers/net/mlx5/mlx5.h | 3 +-- drivers/net/mlx5/mlx5_flow.c | 16 ++++++++-------- drivers/net/mlx5/mlx5_flow.h | 3 +-- drivers/net/mlx5/mlx5_flow_dv.c | 7 ++++--- drivers/net/mlx5/mlx5_flow_hw.c | 3 +-- drivers/net/mlx5/mlx5_flow_meter.c | 4 ++-- 7 files changed, 22 insertions(+), 24 deletions(-)
drivers/net/mlx5/linux/mlx5_os.c +5 -5
@@ -1328,14 +1328,14 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,* Prefer REG_C_3 if it is available. */ if (reg_c_mask & (1 << (REG_C_3 -REG_C_0 ))) - sh->registers.mtr_color_reg =REG_C_3 ; + sh->registers.aso_reg =REG_C_3 ;else - sh->registers.mtr_color_reg = + sh->registers.aso_reg =ffs (reg_c_mask) -1 +REG_C_0 ; priv->mtr_en =1 ; priv->mtr_reg_share = hca_attr->qos.flow_meter;DRV_LOG (DEBUG ,"The REG_C meter uses is %d" , - sh->registers.mtr_color_reg); + sh->registers.aso_reg); } }if (hca_attr->qos.sup && hca_attr->qos.flow_meter_aso_sup) {
@@ -1360,7 +1360,7 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, sh->tunnel_header_2_3 =1 ;#endif #ifdef HAVE_MLX5_DR_CREATE_ACTION_ASO -if (hca_attr->flow_hit_aso && sh->registers.mtr_color_reg ==REG_C_3 ) { +if (hca_attr->flow_hit_aso && sh->registers.aso_reg ==REG_C_3 ) { sh->flow_hit_aso_en =1 ; err =mlx5_flow_aso_age_mng_init (sh);if (err) {
@@ -1374,7 +1374,7 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,defined (HAVE_MLX5_DR_ACTION_ASO_CT)/* HWS create CT ASO SQ based on HWS configure queue number. */ if (sh->config.dv_flow_en != 2 && - hca_attr->ct_offload && sh->registers.mtr_color_reg == REG_C_3) { + hca_attr->ct_offload && sh->registers.aso_reg == REG_C_3) { err =mlx5_flow_aso_ct_mng_init (sh);if (err) { err = -err;
drivers/net/mlx5/mlx5.h +1 -2
@@ -1376,8 +1376,7 @@ struct mlx5_hws_cnt_svc_mng {#define MLX5_FLOW_HW_TAGS_MAX 8struct mlx5_dev_registers { -enum modify_reg mlx5_flow_hw_aso_tag; -enum modify_reg mtr_color_reg;/* Meter color match REG_C. */ +enum modify_reg aso_reg;enum modify_reg hw_avl_tags[MLX5_FLOW_HW_TAGS_MAX ]; };
drivers/net/mlx5/mlx5_flow.c +8 -8
@@ -1364,23 +1364,23 @@ mlx5_flow_get_reg_id(struct rte_eth_dev *dev,* should use the meter color register for match. */ if (priv->mtr_reg_share) -return reg->mtr_color_reg; +return reg->aso_reg;else -return reg->mtr_color_reg !=REG_C_2 ?REG_C_2 : +return reg->aso_reg !=REG_C_2 ?REG_C_2 :REG_C_3 ;case MLX5_MTR_COLOR :case MLX5_ASO_FLOW_HIT :case MLX5_ASO_CONNTRACK :case MLX5_SAMPLE_ID :/* All features use the same REG_C. */ -MLX5_ASSERT (reg->mtr_color_reg !=REG_NON ); -return reg->mtr_color_reg; +MLX5_ASSERT (reg->aso_reg !=REG_NON ); +return reg->aso_reg;case MLX5_COPY_MARK :/* * Metadata COPY_MARK register using is in meter suffix sub * flow while with meter. It's safe to share the same register. */ -return reg->mtr_color_reg !=REG_C_2 ?REG_C_2 :REG_C_3 ; +return reg->aso_reg !=REG_C_2 ?REG_C_2 :REG_C_3 ;case MLX5_APP_TAG :/* * If meter is enable, it will engage the register for color
@@ -1389,7 +1389,7 @@ mlx5_flow_get_reg_id(struct rte_eth_dev *dev,* match. * If meter is disable, free to use all available registers. */ - start_reg = reg->mtr_color_reg !=REG_C_2 ?REG_C_2 : + start_reg = reg->aso_reg !=REG_C_2 ?REG_C_2 : (priv->mtr_reg_share ?REG_C_3 :REG_C_4 ); skip_mtr_reg = !!(priv->mtr_en && start_reg ==REG_C_2 );if (id > (uint32_t )(REG_C_7 - start_reg))
@@ -1407,7 +1407,7 @@ mlx5_flow_get_reg_id(struct rte_eth_dev *dev,* color register. */ if (skip_mtr_reg && priv->sh->flow_mreg_c - [id + start_reg -REG_C_0 ] >= reg->mtr_color_reg) { + [id + start_reg -REG_C_0 ] >= reg->aso_reg) {if (id >= (uint32_t )(REG_C_7 - start_reg)) return rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM,
@@ -6480,7 +6480,7 @@ flow_sample_split_prep(struct rte_eth_dev *dev,* metadata regC is REG_NON, back to use application tag * index 0. */ -if (unlikely (priv->sh->registers.mtr_color_reg ==REG_NON )) +if (unlikely (priv->sh->registers.aso_reg ==REG_NON )) ret =mlx5_flow_get_reg_id (dev,MLX5_APP_TAG ,0 , error);else ret =mlx5_flow_get_reg_id (dev,MLX5_SAMPLE_ID ,0 , error);
drivers/net/mlx5/mlx5_flow.h +1 -2
@@ -1666,7 +1666,6 @@ flow_hw_get_wire_port(struct ibv_context *ibctx)* Convert metadata or tag to the actual register. * META: Can only be used to match in the FDB in this stage, fixed C_1. * TAG: C_x expect meter color reg and the reserved ones. -* TODO: Per port / device, FDB or NIC for Meta matching. */ static __rte_always_inline int flow_hw_get_reg_id(struct rte_eth_dev *dev,
@@ -1695,7 +1694,7 @@ flow_hw_get_reg_id(struct rte_eth_dev *dev,return REG_A ;case RTE_FLOW_ITEM_TYPE_CONNTRACK :case RTE_FLOW_ITEM_TYPE_METER_COLOR : -return reg->mlx5_flow_hw_aso_tag; +return reg->aso_reg;case RTE_FLOW_ITEM_TYPE_TAG :if (id ==MLX5_LINEAR_HASH_TAG_INDEX )return REG_C_3 ;
drivers/net/mlx5/mlx5_flow_dv.c +4 -3
@@ -2026,7 +2026,8 @@ mlx5_flow_field_id_to_modify_infoif (priv->sh->config.dv_flow_en ==2 ) reg =flow_hw_get_reg_id - (dev,RTE_FLOW_ITEM_TYPE_METER_COLOR ,0 ); + (dev, +RTE_FLOW_ITEM_TYPE_METER_COLOR ,0 );else reg =mlx5_flow_get_reg_id (dev,MLX5_MTR_COLOR ,0 , error);
@@ -3923,7 +3924,7 @@ flow_dv_validate_item_meter_color(struct rte_eth_dev *dev, };int ret; -if (priv->sh->registers.mtr_color_reg ==REG_NON ) +if (priv->sh->registers.aso_reg ==REG_NON )return rte_flow_error_set (error,ENOTSUP ,RTE_FLOW_ERROR_TYPE_ITEM , item, "meter color register"
@@ -8375,7 +8376,7 @@ flow_dv_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr,return ret;if ((action_flags &MLX5_FLOW_ACTION_SET_TAG ) && tag_id ==0 && - priv->sh->registers.mtr_color_reg ==REG_NON ) + priv->sh->registers.aso_reg ==REG_NON )return rte_flow_error_set (error,EINVAL ,RTE_FLOW_ERROR_TYPE_ACTION ,NULL ,"sample after tag action causes metadata tag index 0 corruption" );
drivers/net/mlx5/mlx5_flow_hw.c +1 -2
@@ -8470,7 +8470,7 @@ void flow_hw_init_tags_set(struct rte_eth_dev *dev)* The CAPA is global for common device but only used in net. * It is shared per eswitch domain. */ - unset |=1 <<mlx5_regc_index (reg->mtr_color_reg); + unset |=1 <<mlx5_regc_index (reg->aso_reg); unset |=1 <<mlx5_regc_index (REG_C_6 );if (sh->config.dv_esw_en) unset |=1 <<mlx5_regc_index (REG_C_0 );
@@ -8481,7 +8481,6 @@ void flow_hw_init_tags_set(struct rte_eth_dev *dev)if (!!((1 << i) & masks)) reg->hw_avl_tags[j++] =mlx5_regc_value (i); } - reg->mlx5_flow_hw_aso_tag = reg->mtr_color_reg; } static int
drivers/net/mlx5/mlx5_flow_meter.c +2 -2
@@ -67,7 +67,7 @@ mlx5_flow_meter_action_create(struct mlx5_priv *priv, val = (ebs_eir >>ASO_DSEG_EBS_MAN_OFFSET ) &ASO_DSEG_MAN_MASK ;MLX5_SET (flow_meter_parameters, fmp, ebs_mantissa, val); mtr_init.next_table = def_policy->sub_policy.tbl_rsc->obj; - mtr_init.reg_c_index = priv->sh->registers.mtr_color_reg -REG_C_0 ; + mtr_init.reg_c_index = priv->sh->registers.aso_reg -REG_C_0 ; mtr_init.flow_meter_parameter = fmp; mtr_init.flow_meter_parameter_sz =MLX5_ST_SZ_BYTES (flow_meter_parameters);
@@ -1618,7 +1618,7 @@ mlx5_flow_meter_action_modify(struct mlx5_priv *priv,return ret; }else {/* Fill command parameters. */ - mod_attr.reg_c_index = sh->registers.mtr_color_reg -REG_C_0 ; + mod_attr.reg_c_index = sh->registers.aso_reg -REG_C_0 ; mod_attr.flow_meter_parameter = in; mod_attr.flow_meter_parameter_sz =MLX5_ST_SZ_BYTES (flow_meter_parameters);
Signature · 1 line
2.39.2
PATCH 7/13 net/mlx5: initialize HWS flow tags registers in shared dev context
In reply to Gregory EtelsonMove HWS flow tags registers initialization to shared dev context.
--- drivers/net/mlx5/linux/mlx5_os.c | 35 ++------------- drivers/net/mlx5/mlx5.c | 75 ++++++++++++++++++++++++++++++++ drivers/net/mlx5/mlx5.h | 6 +++ drivers/net/mlx5/mlx5_flow.h | 3 -- drivers/net/mlx5/mlx5_flow_hw.c | 34 --------------- 5 files changed, 84 insertions(+), 69 deletions(-)
drivers/net/mlx5/linux/mlx5_os.c +3 -32
@@ -1304,38 +1304,12 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,struct mlx5_hca_attr *hca_attr = &sh->cdev->config.hca_attr; sh->steering_format_version = hca_attr->steering_format_version; -#if defined(HAVE_MLX5DV_DR ) && \ - (defined(HAVE_MLX5_DR_CREATE_ACTION_FLOW_METER ) || \ - defined(HAVE_MLX5_DR_CREATE_ACTION_ASO )) +#if defined(HAVE_MLX5_DR_CREATE_ACTION_ASO_EXT )if (hca_attr->qos.sup && hca_attr->qos.flow_meter_old && sh->config.dv_flow_en) { -uint8_t reg_c_mask = hca_attr->qos.flow_meter_reg_c_ids; -/* -* Meter needs two REG_C's for color match and pre-sfx -* flow match. Here get the REG_C for color match. -* REG_C_0 and REG_C_1 is reserved for metadata feature. -*/ - reg_c_mask &=0xfc ; -if (rte_popcount32 (reg_c_mask) <1 ) { - priv->mtr_en =0 ; -DRV_LOG (WARNING ,"No available register for" -" meter." ); - }else { -/* -* The meter color register is used by the -* flow-hit feature as well. -* The flow-hit feature must use REG_C_3 -* Prefer REG_C_3 if it is available. -*/ -if (reg_c_mask & (1 << (REG_C_3 -REG_C_0 ))) - sh->registers.aso_reg =REG_C_3 ; -else - sh->registers.aso_reg = -ffs (reg_c_mask) -1 +REG_C_0 ; +if (sh->registers.aso_reg !=REG_NON ) { priv->mtr_en =1 ; priv->mtr_reg_share = hca_attr->qos.flow_meter; -DRV_LOG (DEBUG ,"The REG_C meter uses is %d" , - sh->registers.aso_reg); } }if (hca_attr->qos.sup && hca_attr->qos.flow_meter_aso_sup) {
@@ -1358,7 +1332,7 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, sh->tunnel_header_0_1 =1 ;if (hca_attr->flow.tunnel_header_2_3) sh->tunnel_header_2_3 =1 ; -#endif +#endif /* HAVE_MLX5_DR_CREATE_ACTION_ASO_EXT */ #ifdef HAVE_MLX5_DR_CREATE_ACTION_ASO if (hca_attr->flow_hit_aso && sh->registers.aso_reg ==REG_C_3 ) { sh->flow_hit_aso_en =1 ;
@@ -1617,9 +1591,6 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, err =ENOTSUP ; goto error; } -/* Only HWS requires this information. */ -if (sh->refcnt ==1 ) -flow_hw_init_tags_set (eth_dev);if (priv->sh->config.dv_esw_en &&flow_hw_create_vport_action (eth_dev)) { DRV_LOG(ERR, "port %u failed to create vport action",
drivers/net/mlx5/mlx5.c +75 -0
87 lines not on this page · raw message
drivers/net/mlx5/mlx5.h +6 -0
@@ -1380,6 +1380,12 @@ struct mlx5_dev_registers {enum modify_reg hw_avl_tags[MLX5_FLOW_HW_TAGS_MAX ]; }; +#if defined(HAVE_MLX5DV_DR ) && \ + (defined(HAVE_MLX5_DR_CREATE_ACTION_FLOW_METER ) || \ + defined(HAVE_MLX5_DR_CREATE_ACTION_ASO )) +#define HAVE_MLX5_DR_CREATE_ACTION_ASO_EXT +#endif +/* * Shared Infiniband device context for Master/Representors * which belong to same IB device with multiple IB ports.
drivers/net/mlx5/mlx5_flow.h +0 -3
@@ -1730,9 +1730,6 @@ flow_hw_get_reg_id_from_ctx(void *dr_ctx,void flow_hw_set_port_info (struct rte_eth_dev *dev);void flow_hw_clear_port_info (struct rte_eth_dev *dev); - -void flow_hw_init_tags_set (struct rte_eth_dev *dev); -int flow_hw_create_vport_action (struct rte_eth_dev *dev);void flow_hw_destroy_vport_action (struct rte_eth_dev *dev);
drivers/net/mlx5/mlx5_flow_hw.c +0 -34
@@ -8449,40 +8449,6 @@ flow_hw_clear_port_info(struct rte_eth_dev *dev) info->is_wire =0 ; } -/* -* Initialize the information of available tag registers and an intersection -* of all the probed devices' REG_C_Xs. -* PS. No port concept in steering part, right now it cannot be per port level. -* -* @param[in] dev -* Pointer to the rte_eth_dev structure. -*/ -void flow_hw_init_tags_set (struct rte_eth_dev *dev) -{ -struct mlx5_dev_ctx_shared *sh =MLX5_SH (dev); -struct mlx5_dev_registers *reg = &sh->registers; -uint32_t meta_mode = sh->config.dv_xmeta_en; -uint8_t masks = (uint8_t )sh->cdev->config.hca_attr.set_reg_c; -uint8_t unset =0 ; -uint32_t i, j; - -/* -* The CAPA is global for common device but only used in net. -* It is shared per eswitch domain. -*/ - unset |=1 <<mlx5_regc_index (reg->aso_reg); - unset |=1 <<mlx5_regc_index (REG_C_6 ); -if (sh->config.dv_esw_en) - unset |=1 <<mlx5_regc_index (REG_C_0 ); -if (meta_mode ==MLX5_XMETA_MODE_META32_HWS ) - unset |=1 <<mlx5_regc_index (REG_C_1 ); - masks &= ~unset; -for (i =0 , j =0 ; i <MLX5_FLOW_HW_TAGS_MAX ; i++) { -if (!!((1 << i) & masks)) - reg->hw_avl_tags[j++] =mlx5_regc_value (i); - } -} - static int flow_hw_conntrack_destroy(struct rte_eth_dev *dev __rte_unused, uint32_t idx,
Signature · 1 line
2.39.2
PATCH 8/13 net/mlx5/hws: adding method to query rule hash
In reply to Gregory EtelsonFrom: Itamar Gozlan <[email protected]>
Add a method to the HW steering API that allows querying the hash result for a given matcher and a set of items. This can be used to predict the location of the rule in the hash table.
--- drivers/common/mlx5/mlx5_prm.h | 8 +++- drivers/net/mlx5/hws/meson.build | 1 + drivers/net/mlx5/hws/mlx5dr.h | 26 +++++++++++ drivers/net/mlx5/hws/mlx5dr_cmd.c | 3 ++ drivers/net/mlx5/hws/mlx5dr_cmd.h | 3 +- drivers/net/mlx5/hws/mlx5dr_crc32.c | 61 ++++++++++++++++++++++++++ drivers/net/mlx5/hws/mlx5dr_crc32.h | 13 ++++++ drivers/net/mlx5/hws/mlx5dr_internal.h | 1 + drivers/net/mlx5/hws/mlx5dr_rule.c | 37 ++++++++++++++++ drivers/net/mlx5/hws/mlx5dr_rule.h | 1 + 10 files changed, 152 insertions(+), 2 deletions(-) create mode 100644 drivers/net/mlx5/hws/mlx5dr_crc32.c create mode 100644 drivers/net/mlx5/hws/mlx5dr_crc32.h
drivers/common/mlx5/mlx5_prm.h +7 -1
@@ -2279,6 +2279,9 @@ enum { MLX5_GENERATE_WQE_TYPE_FLOW_UPDATE = 1 << 1, }; +enum { +MLX5_FLOW_TABLE_HASH_TYPE_CRC32 , +};/* * HCA Capabilities 2 */
@@ -2328,7 +2331,10 @@ struct mlx5_ifc_cmd_hca_cap_2_bits {u8 format_select_dw_gtpu_dw_2[0x8 ];u8 format_select_dw_gtpu_first_ext_dw_0[0x8 ];u8 generate_wqe_type[0x20 ]; -u8 reserved_at_2c0[0x540 ]; +u8 reserved_at_2c0[0x160 ]; +u8 reserved_at_420[0x1c ]; +u8 flow_table_hash_type[0x4 ]; +u8 reserved_at_440[0x3c0 ]; };struct mlx5_ifc_esw_cap_bits {
drivers/net/mlx5/hws/meson.build +1 -0
@@ -19,4 +19,5 @@ sources += files( 'mlx5dr_definer.c', 'mlx5dr_debug.c', 'mlx5dr_pat_arg.c', + 'mlx5dr_crc32.c', )
drivers/net/mlx5/hws/mlx5dr.h +26 -0
@@ -118,6 +118,11 @@ enum mlx5dr_matcher_distribute_mode { MLX5DR_MATCHER_DISTRIBUTE_BY_LINEAR = 0x1, }; +enum mlx5dr_rule_hash_calc_mode { +MLX5DR_RULE_HASH_CALC_MODE_RAW , +MLX5DR_RULE_HASH_CALC_MODE_IDX , +}; +struct mlx5dr_matcher_attr {/* Processing priority inside table */ uint32_t priority;
@@ -430,6 +435,27 @@ int mlx5dr_rule_action_update(struct mlx5dr_rule *rule_handle,struct mlx5dr_rule_action rule_actions[], struct mlx5dr_rule_attr *attr); +/* Calculate hash for a given set of items, which indicates rule location in +* the hash table. +* +* @param[in] matcher +* The matcher of the created rule. +* @param[in] items +* Matching pattern item definition. +* @param[in] mt_idx +* Match template index that the match was created with. +* @param[in] mode +* Hash calculation mode +* @param[in, out] ret_hash +* Returned calculated hash result +* @return zero on success non zero otherwise. +*/ +int mlx5dr_rule_hash_calculate (struct mlx5dr_matcher *matcher, +const struct rte_flow_item items[], +uint8_t mt_idx, +enum mlx5dr_rule_hash_calc_mode mode, +uint32_t *ret_hash); +/* Create direct rule drop action. * * @param[in] ctx
drivers/net/mlx5/hws/mlx5dr_cmd.c +3 -0
@@ -1154,6 +1154,9 @@ int mlx5dr_cmd_query_caps(struct ibv_context *ctx, (res &MLX5_CROSS_VHCA_ALLOWED_OBJS_FT ) && (res &MLX5_CROSS_VHCA_ALLOWED_OBJS_RTC ); + caps->flow_table_hash_type =MLX5_GET (query_hca_cap_out, out, + capability.cmd_hca_cap_2.flow_table_hash_type); +MLX5_SET (query_hca_cap_in, in, op_mod,MLX5_GET_HCA_CAP_OP_MOD_NIC_FLOW_TABLE |MLX5_HCA_CAP_OPMOD_GET_CUR );
drivers/net/mlx5/hws/mlx5dr_cmd.h +2 -1
@@ -217,10 +217,11 @@ struct mlx5dr_cmd_query_caps {uint8_t rtc_log_depth_max;uint8_t format_select_gtpu_dw_0;uint8_t format_select_gtpu_dw_1; +uint8_t flow_table_hash_type;uint8_t format_select_gtpu_dw_2;uint8_t format_select_gtpu_ext_dw_0; -uint32_t linear_match_definer;uint8_t access_index_mode; +uint32_t linear_match_definer;bool full_dw_jumbo_support;bool rtc_hash_split_table;bool rtc_linear_lookup_table;
drivers/net/mlx5/hws/mlx5dr_crc32.c new file +61 -0
61 lines not on this page · raw message
drivers/net/mlx5/hws/mlx5dr_crc32.h new file +13 -0
@@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright (c) 2023 NVIDIA Corporation & Affiliates +*/ + +#ifndef MLX5DR_CRC32_C_ +#define MLX5DR_CRC32_C_ + +/* Ethernet AUTODIN II CRC32 (little-endian) +* CRC32_POLY 0xedb88320 +*/ +uint32_t mlx5dr_crc32_calc (uint8_t *p,size_t len); + +#endif /* MLX5DR_CRC32_C_ */
drivers/net/mlx5/hws/mlx5dr_internal.h +1 -0
@@ -38,6 +38,7 @@#include "mlx5dr_matcher.h" #include "mlx5dr_debug.h" #include "mlx5dr_pat_arg.h" +#include "mlx5dr_crc32.h" #define DW_SIZE 4#define BITS_IN_BYTE 8
drivers/net/mlx5/hws/mlx5dr_rule.c +37 -0
@@ -770,3 +770,40 @@ size_t mlx5dr_rule_get_handle_size(void) {return sizeof (struct mlx5dr_rule ); } + +int mlx5dr_rule_hash_calculate (struct mlx5dr_matcher *matcher, +const struct rte_flow_item items[], +uint8_t mt_idx, +enum mlx5dr_rule_hash_calc_mode mode, +uint32_t *ret_hash) +{ +uint8_t tag[MLX5DR_STE_SZ ] = {0 }; +struct mlx5dr_match_template *mt; + +if (!matcher || !matcher->mt) { + rte_errno =EINVAL ; +return -rte_errno; + } + + mt = &matcher->mt[mt_idx]; + +if (mlx5dr_matcher_req_fw_wqe (matcher) || +mlx5dr_table_is_root (matcher->tbl) || + matcher->tbl->ctx->caps->access_index_mode ==MLX5DR_MATCHER_INSERT_BY_HASH || + matcher->tbl->ctx->caps->flow_table_hash_type !=MLX5_FLOW_TABLE_HASH_TYPE_CRC32 ) { + rte_errno =ENOTSUP ; +return -rte_errno; + } + +mlx5dr_definer_create_tag (items, mt->fc, mt->fc_sz, tag); +if (mlx5dr_matcher_mt_is_jumbo (mt)) + *ret_hash =mlx5dr_crc32_calc (tag,MLX5DR_JUMBO_TAG_SZ ); +else + *ret_hash =mlx5dr_crc32_calc (tag +MLX5DR_ACTIONS_SZ , +MLX5DR_MATCH_TAG_SZ ); + +if (mode ==MLX5DR_RULE_HASH_CALC_MODE_IDX ) + *ret_hash = *ret_hash & (BIT (matcher->attr.rule.num_log) -1 ); + +return 0 ; +}
drivers/net/mlx5/hws/mlx5dr_rule.h +1 -0
@@ -10,6 +10,7 @@ enum {MLX5DR_ACTIONS_SZ =12 ,MLX5DR_MATCH_TAG_SZ =32 ,MLX5DR_JUMBO_TAG_SZ =44 , + MLX5DR_STE_SZ = 64, }; enum mlx5dr_rule_status {
Signature · 1 line
2.39.2
RE: [PATCH 08/13] net/mlx5/hws: adding method to query rule hash
Quoted 6 lines
-----Original Message-----
From: Gregory Etelson <[email protected]>
Sent: Sunday, October 29, 2023 8:23 PM
Quoted 8 lines
From: Itamar Gozlan <[email protected]>
Add a method to the HW steering API that allows querying the hash result for a given matcher and a set of items. This can be used to predict the location of the rule in the hash table.
Signed-off-by Itamar Gozlan <[email protected]>---
Best,
Ori
PATCH 9/13 net/mlx5: add support for calc hash
In reply to Gregory EtelsonFrom: Ori Kam <[email protected]>
This commit adds calculate hash function support for mlx5 PMD.
--- drivers/net/mlx5/mlx5_flow.c | 32 ++++++++++++++++++++++++++++++++ drivers/net/mlx5/mlx5_flow.h | 8 ++++++++ drivers/net/mlx5/mlx5_flow_hw.c | 31 ++++++++++++++++++++++++++++++- 3 files changed, 70 insertions(+), 1 deletion(-)
drivers/net/mlx5/mlx5_flow.c +32 -0
@@ -1178,6 +1178,13 @@ mlx5_flow_async_action_list_handle_query_update(struct rte_eth_dev *dev,enum rte_flow_query_update_mode mode, void *user_data, struct rte_flow_error *error); +static int +mlx5_flow_calc_table_hash (struct rte_eth_dev *dev, +const struct rte_flow_template_table *table, +const struct rte_flow_item pattern[], +uint8_t pattern_template_index, +uint32_t *hash,struct rte_flow_error *error); +static const struct rte_flow_ops mlx5_flow_ops = { .validate = mlx5_flow_validate, .create = mlx5_flow_create,
@@ -1231,6 +1238,7 @@ static const struct rte_flow_ops mlx5_flow_ops = { mlx5_flow_action_list_handle_query_update, .async_action_list_handle_query_update = mlx5_flow_async_action_list_handle_query_update, + .flow_calc_table_hash = mlx5_flow_calc_table_hash, };/* Tunnel information. */
@@ -11058,6 +11066,30 @@ mlx5_flow_async_action_list_handle_query_update(struct rte_eth_dev *dev, } +static int +mlx5_flow_calc_table_hash (struct rte_eth_dev *dev, +const struct rte_flow_template_table *table, +const struct rte_flow_item pattern[], +uint8_t pattern_template_index, +uint32_t *hash,struct rte_flow_error *error) +{ +struct rte_flow_attr attr = { .transfer =0 }; +enum mlx5_flow_drv_type drv_type =flow_get_drv_type (dev, &attr); +const struct mlx5_flow_driver_ops *fops; + +if (drv_type ==MLX5_FLOW_TYPE_MIN || drv_type ==MLX5_FLOW_TYPE_MAX ) +return rte_flow_error_set (error,ENOTSUP , +RTE_FLOW_ERROR_TYPE_ACTION , +NULL ,"invalid driver type" ); + fops =flow_get_drv_ops (drv_type); +if (!fops || !fops->action_query_update) +return rte_flow_error_set (error,ENOTSUP , +RTE_FLOW_ERROR_TYPE_ACTION , +NULL ,"no query_update handler" ); +return fops->flow_calc_table_hash (dev, table, pattern, pattern_template_index, + hash, error); +} +/** * Destroy all indirect actions (shared RSS). *
drivers/net/mlx5/mlx5_flow.h +8 -0
@@ -2062,6 +2062,13 @@ typedef int const void **update, void **query, enum rte_flow_query_update_mode mode, void *user_data, struct rte_flow_error *error); +typedef int +(*mlx5_flow_calc_table_hash_t ) + (struct rte_eth_dev *dev, +const struct rte_flow_template_table *table, +const struct rte_flow_item pattern[], +uint8_t pattern_template_index, +uint32_t *hash,struct rte_flow_error *error);struct mlx5_flow_driver_ops {mlx5_flow_validate_t validate;
@@ -2133,6 +2140,7 @@ struct mlx5_flow_driver_ops { action_list_handle_query_update;mlx5_flow_async_action_list_handle_query_update_t async_action_list_handle_query_update; +mlx5_flow_calc_table_hash_t flow_calc_table_hash; };/* mlx5_flow.c */
drivers/net/mlx5/mlx5_flow_hw.c +30 -1
@@ -2773,7 +2773,7 @@ flow_hw_actions_construct(struct rte_eth_dev *dev,static const struct rte_flow_item *flow_hw_get_rule_items (struct rte_eth_dev *dev, -struct rte_flow_template_table *table, +const struct rte_flow_template_table *table,const struct rte_flow_item items[],uint8_t pattern_template_index,struct mlx5_hw_q_job *job)
@@ -10144,6 +10144,34 @@ flow_hw_action_list_handle_query_update(struct rte_eth_dev *dev, update, query, mode, NULL, error); } +static int +flow_hw_calc_table_hash (struct rte_eth_dev *dev, +const struct rte_flow_template_table *table, +const struct rte_flow_item pattern[], +uint8_t pattern_template_index, +uint32_t *hash,struct rte_flow_error *error) +{ +const struct rte_flow_item *items; +/* Temp job to allow adding missing items */ +static struct rte_flow_item tmp_items[MLX5_HW_MAX_ITEMS ]; +static struct mlx5_hw_q_job job = {.items = tmp_items}; +int res; + + items =flow_hw_get_rule_items (dev, table, pattern, + pattern_template_index, + &job); + res =mlx5dr_rule_hash_calculate (table->matcher, items, + pattern_template_index, +MLX5DR_RULE_HASH_CALC_MODE_RAW , + hash); +if (res) +return rte_flow_error_set (error, res, +RTE_FLOW_ERROR_TYPE_UNSPECIFIED , +NULL , +"hash could not be calculated" ); +return 0 ; +} +const struct mlx5_flow_driver_ops mlx5_flow_hw_drv_ops = { .info_get = flow_hw_info_get, .configure = flow_hw_configure,
@@ -10187,6 +10215,7 @@ const struct mlx5_flow_driver_ops mlx5_flow_hw_drv_ops = { .get_q_aged_flows = flow_hw_get_q_aged_flows, .item_create = flow_dv_item_create, .item_release = flow_dv_item_release, + .flow_calc_table_hash = flow_hw_calc_table_hash, };/**
Signature · 1 line
2.39.2
RE: [PATCH 09/13] net/mlx5: add support for calc hash
Hi,
Quoted 10 lines
-----Original Message-----
From: Gregory Etelson <[email protected]>
Sent: Sunday, October 29, 2023 19:23
To: [email protected]
Cc: Gregory Etelson <[email protected]>; Maayan Kashani <[email protected]>; Raslan Darawsheh <[email protected]>; Ori Kam <[email protected]>; Matan Azrad <[email protected]>; Slava Ovsiienko <[email protected]>; Suanming Mou <[email protected]>
Subject: [PATCH 09/13] net/mlx5: add support for calc hash
Quoted 8 lines
External email: Use caution opening links or attachments
From: Ori Kam <[email protected]>
This commit adds calculate hash function support for mlx5 PMD.
Signed-off-by Ori Kam <[email protected]>
Thanks,
Dariusz Sosnowski
PATCH 10/13 net/mlx5: fix insert by index
In reply to Gregory EtelsonFrom: Ori Kam <[email protected]>
Due to mlx5dr internal logic calling the rule_create function must have items structure.
This commit create such temp structure.
--- drivers/net/mlx5/mlx5_flow_hw.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/mlx5/mlx5_flow_hw.c +2 -1
@@ -2987,6 +2987,7 @@ flow_hw_async_flow_create_by_index(struct rte_eth_dev *dev,void *user_data, struct rte_flow_error *error) { + struct rte_flow_item items[] = {{.type = RTE_FLOW_ITEM_TYPE_END,}};struct mlx5_priv *priv = dev->data->dev_private; struct mlx5dr_rule_attr rule_attr = { .queue_id = queue,
@@ -3050,7 +3051,7 @@ flow_hw_async_flow_create_by_index(struct rte_eth_dev *dev, goto free; } ret =mlx5dr_rule_create (table->matcher, -0 ,NULL , action_template_index, rule_acts, +0 , items, action_template_index, rule_acts, &rule_attr, (struct mlx5dr_rule *)flow->rule);if (likely (!ret))return (struct rte_flow *)flow;
Signature · 1 line
2.39.2
RE: [PATCH 10/13] net/mlx5: fix insert by index
Hi,
Quoted 19 lines
-----Original Message-----
From: Gregory Etelson <[email protected]>
Sent: Sunday, October 29, 2023 19:23
To: [email protected]
Cc: Gregory Etelson <[email protected]>; Maayan Kashani <[email protected]>; Raslan Darawsheh <[email protected]>; Ori Kam <[email protected]>; Erez Shitrit <[email protected]>; Matan Azrad <[email protected]>; Slava Ovsiienko <[email protected]>; Suanming Mou <[email protected]>; Alex Vesker <[email protected]>
Subject: [PATCH 10/13] net/mlx5: fix insert by indexExternal email: Use caution opening links or attachments
From: Ori Kam <[email protected]>
Due to mlx5dr internal logic calling the
rule_createfunction must have items structure.
Quoted 6 lines
This commit create such temp structure.
Fixes fa16fead9a68 ("net/mlx5/hws: support rule update after its creation")Signed-off-by Ori Kam <[email protected]>
Thanks,
Dariusz Sosnowski
PATCH 11/13 net/mlx5: fix query for NIC flow cap
In reply to Gregory EtelsonFrom: Ori Kam <[email protected]>
Add query for nic flow table support bit.
--- drivers/common/mlx5/mlx5_devx_cmds.c | 1 + 1 file changed, 1 insertion(+)
drivers/common/mlx5/mlx5_devx_cmds.c +1 -0
@@ -1082,6 +1082,7 @@ mlx5_devx_cmd_query_hca_attr(void *ctx, attr->striding_rq =MLX5_GET (cmd_hca_cap, hcattr, striding_rq); attr->ext_stride_num_range =MLX5_GET (cmd_hca_cap, hcattr, ext_stride_num_range); + attr->nic_flow_table =MLX5_GET (cmd_hca_cap, hcattr, nic_flow_table); attr->max_flow_counter_15_0 =MLX5_GET (cmd_hca_cap, hcattr, max_flow_counter_15_0); attr->max_flow_counter_31_16 = MLX5_GET(cmd_hca_cap, hcattr,
Signature · 1 line
2.39.2
RE: [PATCH 11/13] net/mlx5: fix query for NIC flow cap
Hi,
Quoted 14 lines
-----Original Message-----
From: Gregory Etelson <[email protected]>
Sent: Sunday, October 29, 2023 19:23
To: [email protected]
Cc: Gregory Etelson <[email protected]>; Maayan Kashani <[email protected]>; Raslan Darawsheh <[email protected]>; Ori Kam <[email protected]>; Bing Zhao <[email protected]>; Matan Azrad <[email protected]>; Slava Ovsiienko <[email protected]>; Suanming Mou <[email protected]>
Subject: [PATCH 11/13] net/mlx5: fix query for NIC flow capExternal email: Use caution opening links or attachments
Quoted 8 lines
From: Ori Kam <[email protected]>
Add query for nic flow table support bit.
Fixes 5f44fb1958e5 ("common/mlx5: query capability of registers")Signed-off-by Ori Kam <[email protected]>
Thanks,
Dariusz Sosnowski
PATCH 12/13 net/mlx5: add support for more registers
In reply to Gregory EtelsonFrom: Ori Kam <[email protected]>
This commit adds the support for a additional registers that were added to the HW.
--- drivers/common/mlx5/mlx5_devx_cmds.c | 16 +++++++++---- drivers/common/mlx5/mlx5_devx_cmds.h | 2 +- drivers/common/mlx5/mlx5_prm.h | 36 ++++++++++++++++++++++++---- drivers/net/mlx5/mlx5.c | 4 ++-- drivers/net/mlx5/mlx5.h | 2 +- drivers/net/mlx5/mlx5_flow_dv.c | 4 ++++ drivers/net/mlx5/mlx5_flow_hw.c | 2 +- 7 files changed, 53 insertions(+), 13 deletions(-)
drivers/common/mlx5/mlx5_devx_cmds.c +12 -4
@@ -1229,7 +1229,7 @@ mlx5_devx_cmd_query_hca_attr(void *ctx, attr->modify_outer_ip_ecn =MLX5_GET (flow_table_nic_cap, hcattr, ft_header_modify_nic_receive.outer_ip_ecn); - attr->set_reg_c =0xff ; + attr->set_reg_c =0xffff ;if (attr->nic_flow_table) {#define GET_RX_REG_X_BITS \ MLX5_GET(flow_table_nic_cap, hcattr, \
@@ -1238,10 +1238,16 @@ mlx5_devx_cmd_query_hca_attr(void *ctx,MLX5_GET (flow_table_nic_cap, hcattr, \ ft_header_modify_nic_transmit.metadata_reg_c_x) -uint32_t tx_reg, rx_reg; +uint32_t tx_reg, rx_reg, reg_c_8_15; tx_reg =GET_TX_REG_X_BITS ; + reg_c_8_15 =MLX5_GET (flow_table_nic_cap, hcattr, + ft_field_support_2_nic_transmit.metadata_reg_c_8_15); + tx_reg |= ((0xff & reg_c_8_15) <<8 ); rx_reg =GET_RX_REG_X_BITS ; + reg_c_8_15 =MLX5_GET (flow_table_nic_cap, hcattr, + ft_field_support_2_nic_receive.metadata_reg_c_8_15); + rx_reg |= ((0xff & reg_c_8_15) <<8 ); attr->set_reg_c &= (rx_reg & tx_reg);#undef GET_RX_REG_X_BITS
@@ -1371,7 +1377,7 @@ mlx5_devx_cmd_query_hca_attr(void *ctx,MLX5_GET (esw_cap, hcattr, esw_manager_vport_number); }if (attr->eswitch_manager) { -uint32_t esw_reg; +uint32_t esw_reg, reg_c_8_15; hcattr = mlx5_devx_get_hca_cap(ctx, in, out, &rc, MLX5_GET_HCA_CAP_OP_MOD_ESW_FLOW_TABLE |
@@ -1380,7 +1386,9 @@ mlx5_devx_cmd_query_hca_attr(void *ctx,return rc; esw_reg =MLX5_GET (flow_table_esw_cap, hcattr, ft_header_modify_esw_fdb.metadata_reg_c_x); - attr->set_reg_c &= esw_reg; + reg_c_8_15 =MLX5_GET (flow_table_esw_cap, hcattr, + ft_field_support_2_esw_fdb.metadata_reg_c_8_15); + attr->set_reg_c &= ((0xff & reg_c_8_15) <<8 ) | esw_reg; }return 0 ; error:
drivers/common/mlx5/mlx5_devx_cmds.h +1 -1
@@ -301,7 +301,7 @@ struct mlx5_hca_attr { uint32_t cqe_compression_128:1; uint32_t multi_pkt_send_wqe:1; uint32_t enhanced_multi_pkt_send_wqe:1; - uint32_t set_reg_c:8; + uint32_t set_reg_c:16; uint32_t nic_flow_table:1; uint32_t modify_outer_ip_ecn:1;union {
drivers/common/mlx5/mlx5_prm.h +32 -4
@@ -840,6 +840,14 @@ enum mlx5_modification_field {MLX5_MODI_IN_MPLS_LABEL_3 ,MLX5_MODI_IN_MPLS_LABEL_4 ,MLX5_MODI_OUT_IPV6_NEXT_HDR =0x4A , +MLX5_MODI_META_REG_C_8 =0x8F , +MLX5_MODI_META_REG_C_9 =0x90 , +MLX5_MODI_META_REG_C_10 =0x91 , +MLX5_MODI_META_REG_C_11 =0x92 , +MLX5_MODI_META_REG_C_12 =0x93 , +MLX5_MODI_META_REG_C_13 =0x94 , +MLX5_MODI_META_REG_C_14 =0x95 , +MLX5_MODI_META_REG_C_15 =0x96 , MLX5_MODI_INVALID = INT_MAX, };
@@ -2227,8 +2235,22 @@ struct mlx5_ifc_ft_fields_support_2_bits {u8 inner_ipv4_checksum_ok[0x1 ];u8 inner_l4_checksum_ok[0x1 ];u8 outer_ipv4_checksum_ok[0x1 ]; -u8 outer_l4_checksum_ok[0x1 ]; -u8 reserved_at_20[0x60 ]; +u8 outer_l4_checksum_ok[0x1 ];/* end of DW0 */ +u8 reserved_at_20[0x18 ]; +union { +struct { +u8 metadata_reg_c_15[0x1 ]; +u8 metadata_reg_c_14[0x1 ]; +u8 metadata_reg_c_13[0x1 ]; +u8 metadata_reg_c_12[0x1 ]; +u8 metadata_reg_c_11[0x1 ]; +u8 metadata_reg_c_10[0x1 ]; +u8 metadata_reg_c_9[0x1 ]; +u8 metadata_reg_c_8[0x1 ]; + }; +u8 metadata_reg_c_8_15[0x8 ]; + };/* end of DW1 */ +u8 reserved_at_40[0x40 ]; };struct mlx5_ifc_flow_table_nic_cap_bits {
@@ -2250,7 +2272,10 @@ struct mlx5_ifc_flow_table_nic_cap_bits { ft_header_modify_nic_receive;struct mlx5_ifc_ft_fields_support_2_bits ft_field_support_2_nic_receive; -u8 reserved_at_1480[0x780 ]; +u8 reserved_at_1480[0x280 ]; +struct mlx5_ifc_ft_fields_support_2_bits + ft_field_support_2_nic_transmit; +u8 reserved_at_1780[0x480 ];struct mlx5_ifc_ft_fields_support_bits ft_header_modify_nic_transmit;u8 reserved_at_2000[0x6000 ];
@@ -2259,7 +2284,10 @@ struct mlx5_ifc_flow_table_nic_cap_bits {struct mlx5_ifc_flow_table_esw_cap_bits {u8 reserved_at_0[0x800 ];struct mlx5_ifc_ft_fields_support_bits ft_header_modify_esw_fdb; -u8 reserved_at_C00[0x7400 ]; +u8 reserved_at_C00[0x800 ]; +struct mlx5_ifc_ft_fields_support_2_bits + ft_field_support_2_esw_fdb; +u8 reserved_at_1480[0x6b80 ]; };enum mlx5_ifc_cross_vhca_object_to_object_supported_types {
drivers/net/mlx5/mlx5.c +2 -2
@@ -1604,8 +1604,8 @@ mlx5_init_hws_flow_tags_registers(struct mlx5_dev_ctx_shared *sh) {struct mlx5_dev_registers *reg = &sh->registers;uint32_t meta_mode = sh->config.dv_xmeta_en; -uint8_t masks = (uint8_t )sh->cdev->config.hca_attr.set_reg_c; -uint8_t unset =0 ; +uint16_t masks = (uint16_t )sh->cdev->config.hca_attr.set_reg_c; +uint16_t unset =0 ;uint32_t i, j;/*
drivers/net/mlx5/mlx5.h +1 -1
@@ -1373,7 +1373,7 @@ struct mlx5_hws_cnt_svc_mng { struct mlx5_hws_aso_mng aso_mng __rte_cache_aligned; }; -#define MLX5_FLOW_HW_TAGS_MAX 8 +#define MLX5_FLOW_HW_TAGS_MAX 12struct mlx5_dev_registers {enum modify_reg aso_reg;
drivers/net/mlx5/mlx5_flow_dv.c +4 -0
@@ -970,6 +970,10 @@ static enum mlx5_modification_field reg_to_field[] = { [REG_C_5] = MLX5_MODI_META_REG_C_5, [REG_C_6] = MLX5_MODI_META_REG_C_6, [REG_C_7] = MLX5_MODI_META_REG_C_7, + [REG_C_8] = MLX5_MODI_META_REG_C_8, + [REG_C_9] = MLX5_MODI_META_REG_C_9, + [REG_C_10] = MLX5_MODI_META_REG_C_10, + [REG_C_11] = MLX5_MODI_META_REG_C_11, };/**
drivers/net/mlx5/mlx5_flow_hw.c +1 -1
@@ -5615,7 +5615,7 @@ flow_hw_pattern_validate(struct rte_eth_dev *dev, {const struct rte_flow_item_tag *tag = (const struct rte_flow_item_tag *)items[i].spec; -uint8_t regcs = (uint8_t )priv->sh->cdev->config.hca_attr.set_reg_c; +uint16_t regcs = (uint8_t )priv->sh->cdev->config.hca_attr.set_reg_c;if (!((1 << (tag->index -REG_C_0 )) & regcs)) return rte_flow_error_set(error, EINVAL,
Signature · 1 line
2.39.2
RE: [PATCH 12/13] net/mlx5: add support for more registers
Hi,
Quoted 13 lines
-----Original Message-----
From: Gregory Etelson <[email protected]>
Sent: Sunday, October 29, 2023 19:23
To: [email protected]
Cc: Gregory Etelson <[email protected]>; Maayan Kashani <[email protected]>; Raslan Darawsheh <[email protected]>; Ori Kam <[email protected]>; Matan Azrad <[email protected]>; Slava Ovsiienko <[email protected]>; Suanming Mou <[email protected]>
Subject: [PATCH 12/13] net/mlx5: add support for more registersExternal email: Use caution opening links or attachments
Quoted 6 lines
From: Ori Kam <[email protected]>
This commit adds the support for a additional registers that were added to the HW.
Signed-off-by Ori Kam <[email protected]>
Thanks,
Dariusz Sosnowski
PATCH 13/13 net/mlx5: add validation support for tags
In reply to Gregory EtelsonFrom: Ori Kam <[email protected]>
This commit introduce validation for invalid tags
--- drivers/net/mlx5/mlx5_flow_hw.c | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-)
drivers/net/mlx5/mlx5_flow_hw.c +27 -3
@@ -4049,7 +4049,8 @@ flow_hw_modify_field_is_used(const struct rte_flow_action_modify_field *action, }static int -flow_hw_validate_action_modify_field (const struct rte_flow_action *action, +flow_hw_validate_action_modify_field (struct rte_eth_dev *dev, +const struct rte_flow_action *action,const struct rte_flow_action *mask,struct rte_flow_error *error) {
@@ -4118,6 +4119,22 @@ flow_hw_validate_action_modify_field(const struct rte_flow_action *action,if (ret)return ret; } +if ((action_conf->dst.field ==RTE_FLOW_FIELD_TAG && + action_conf->dst.tag_index >=MLX5_FLOW_HW_TAGS_MAX && + action_conf->dst.tag_index !=MLX5_LINEAR_HASH_TAG_INDEX ) || + (action_conf->src.field ==RTE_FLOW_FIELD_TAG && + action_conf->src.tag_index >=MLX5_FLOW_HW_TAGS_MAX && + action_conf->src.tag_index !=MLX5_LINEAR_HASH_TAG_INDEX )) +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , action, +"tag index is out of range" ); +if ((action_conf->dst.field ==RTE_FLOW_FIELD_TAG && +flow_hw_get_reg_id (dev,RTE_FLOW_ITEM_TYPE_TAG , action_conf->dst.tag_index) ==REG_NON ) || + (action_conf->src.field ==RTE_FLOW_FIELD_TAG && +flow_hw_get_reg_id (dev,RTE_FLOW_ITEM_TYPE_TAG , action_conf->src.tag_index) ==REG_NON )) +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , action, +"tag index is out of range" );if (mask_conf->width !=UINT32_MAX ) return rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, action,
@@ -4728,7 +4745,7 @@ mlx5_flow_hw_actions_validate(struct rte_eth_dev *dev, action_flags |=MLX5_FLOW_ACTION_METER ;break ;case RTE_FLOW_ACTION_TYPE_MODIFY_FIELD : - ret =flow_hw_validate_action_modify_field (action, mask, + ret =flow_hw_validate_action_modify_field (dev, action, mask, error);if (ret <0 )return ret;
@@ -5596,7 +5613,14 @@ flow_hw_pattern_validate(struct rte_eth_dev *dev,if (tag ==NULL )return rte_flow_error_set (error,EINVAL ,RTE_FLOW_ERROR_TYPE_UNSPECIFIED , -NULL ,"Tag spec is NULL" ); +NULL , +"Tag spec is NULL" ); +if (tag->index >=MLX5_FLOW_HW_TAGS_MAX && + tag->index !=MLX5_LINEAR_HASH_TAG_INDEX ) +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_UNSPECIFIED , +NULL , +"Invalid tag index" ); tag_idx =flow_hw_get_reg_id (dev,RTE_FLOW_ITEM_TYPE_TAG , tag->index);if (tag_idx ==REG_NON ) return rte_flow_error_set(error, EINVAL,
Signature · 1 line
2.39.2
RE: [PATCH 13/13] net/mlx5: add validation support for tags
Hi,
Quoted 10 lines
-----Original Message-----
From: Gregory Etelson <[email protected]>
Sent: Sunday, October 29, 2023 19:23
To: [email protected]
Cc: Gregory Etelson <[email protected]>; Maayan Kashani <[email protected]>; Raslan Darawsheh <[email protected]>; Ori Kam <[email protected]>; Matan Azrad <[email protected]>; Slava Ovsiienko <[email protected]>; Suanming Mou <[email protected]>
Subject: [PATCH 13/13] net/mlx5: add validation support for tags
Quoted 8 lines
External email: Use caution opening links or attachments
From: Ori Kam <[email protected]>
This commit introduce validation for invalid tags
Signed-off-by Ori Kam <[email protected]>
Thanks,
Dariusz Sosnowski
Hi,
Quoted 45 lines
-----Original Message-----
From: Gregory Etelson <[email protected]>
Sent: Monday, October 30, 2023 2:23 AM
To: [email protected]
Cc: Gregory Etelson <[email protected]>; Maayan Kashani <[email protected]>; Raslan Darawsheh <[email protected]>
Subject: [PATCH 00/13] net/mlx5: support more REG C registersSupport increased number of
REG_Cxregisters.Gregory Etelson (7):
net/mlx5/hws: Definer, add mlx5dr context todefiner_conv_datanet/mlx5: addflow_hw_get_reg_id_from_ctx()
net/mlx5/hws: Definer, useflow_hw_get_reg_id_from_ctxfunction call net/mlx5: addrte_deviceparameter to locate HWS registers net/mlx5: separate portREG_Cregisters usage
net/mlx5: mergeREG_Caliases
net/mlx5: initialize HWS flow tags registers in shared dev contextItamar Gozlan (1):
net/mlx5/hws: adding method to query rule hashOri Kam (5):
net/mlx5: add support for calc hash
net/mlx5: fix insert by index
net/mlx5: fix query for NIC flow cap
net/mlx5: add support for more registers
net/mlx5: add validation support for tagsdrivers/common/mlx5/mlx5_devx_cmds.c | 17 ++- drivers/common/mlx5/mlx5_devx_cmds.h | 2 +- drivers/common/mlx5/mlx5_prm.h | 56 ++++++- drivers/net/mlx5/hws/meson.build | 1 + drivers/net/mlx5/hws/mlx5dr.h | 26 ++++ drivers/net/mlx5/hws/mlx5dr_cmd.c | 3 + drivers/net/mlx5/hws/mlx5dr_cmd.h | 3 +- drivers/net/mlx5/hws/mlx5dr_crc32.c | 61 ++++++++ drivers/net/mlx5/hws/mlx5dr_crc32.h | 13 ++ drivers/net/mlx5/hws/mlx5dr_definer.c | 20 ++- drivers/net/mlx5/hws/mlx5dr_internal.h | 1 + drivers/net/mlx5/hws/mlx5dr_rule.c | 37 +++++ drivers/net/mlx5/hws/mlx5dr_rule.h | 1 + drivers/net/mlx5/linux/mlx5_os.c | 39 +---- drivers/net/mlx5/mlx5.c | 79 +++++++++- drivers/net/mlx5/mlx5.h | 16 +-
Quoted 8 lines
drivers/net/mlx5/mlx5_flow.c | 63 +++++--- drivers/net/mlx5/mlx5_flow.h | 68 ++++++--- drivers/net/mlx5/mlx5_flow_dv.c | 24 ++- drivers/net/mlx5/mlx5_flow_hw.c | 201 ++++++++----------------- drivers/net/mlx5/mlx5_flow_meter.c | 14 +- 21 files changed, 491 insertions(+), 254 deletions(-) create mode 100644 drivers/net/mlx5/hws/mlx5dr_crc32.c create mode 100644 drivers/net/mlx5/hws/mlx5dr_crc32.h
Series LGTM.
Thanks.
Quoted 3 lines
--
2.39.2
Hi,
Quoted 64 lines
-----Original Message-----
From: Suanming Mou <[email protected]>
Sent: Monday, October 30, 2023 10:38 AM
To: Gregory Etelson <[email protected]>; [email protected]
Cc: Gregory Etelson <[email protected]>; Maayan Kashani <[email protected]>; Raslan Darawsheh <[email protected]>
Subject: RE: [PATCH 00/13] net/mlx5: support more REG C registersHi,
Quoted 45 lines
-----Original Message-----
From: Gregory Etelson <[email protected]>
Sent: Monday, October 30, 2023 2:23 AM
To: [email protected]
Cc: Gregory Etelson <[email protected]>; Maayan Kashani <[email protected]>; Raslan Darawsheh <[email protected]>
Subject: [PATCH 00/13] net/mlx5: support more REG C registersSupport increased number of
REG_Cxregisters.Gregory Etelson (7):
net/mlx5/hws: Definer, add mlx5dr context todefiner_conv_datanet/mlx5: addflow_hw_get_reg_id_from_ctx()
net/mlx5/hws: Definer, useflow_hw_get_reg_id_from_ctxfunction call net/mlx5: addrte_deviceparameter to locate HWS registers net/mlx5: separate portREG_Cregisters usage
net/mlx5: mergeREG_Caliases
net/mlx5: initialize HWS flow tags registers in shared dev contextItamar Gozlan (1):
net/mlx5/hws: adding method to query rule hashOri Kam (5):
net/mlx5: add support for calc hash
net/mlx5: fix insert by index
net/mlx5: fix query for NIC flow cap
net/mlx5: add support for more registers
net/mlx5: add validation support for tagsdrivers/common/mlx5/mlx5_devx_cmds.c | 17 ++- drivers/common/mlx5/mlx5_devx_cmds.h | 2 +- drivers/common/mlx5/mlx5_prm.h | 56 ++++++- drivers/net/mlx5/hws/meson.build | 1 + drivers/net/mlx5/hws/mlx5dr.h | 26 ++++ drivers/net/mlx5/hws/mlx5dr_cmd.c | 3 + drivers/net/mlx5/hws/mlx5dr_cmd.h | 3 +- drivers/net/mlx5/hws/mlx5dr_crc32.c | 61 ++++++++ drivers/net/mlx5/hws/mlx5dr_crc32.h | 13 ++ drivers/net/mlx5/hws/mlx5dr_definer.c | 20 ++- drivers/net/mlx5/hws/mlx5dr_internal.h | 1 + drivers/net/mlx5/hws/mlx5dr_rule.c | 37 +++++ drivers/net/mlx5/hws/mlx5dr_rule.h | 1 + drivers/net/mlx5/linux/mlx5_os.c | 39 +---- drivers/net/mlx5/mlx5.c | 79 +++++++++- drivers/net/mlx5/mlx5.h | 16 +-Quoted 8 lines
drivers/net/mlx5/mlx5_flow.c | 63 +++++--- drivers/net/mlx5/mlx5_flow.h | 68 ++++++--- drivers/net/mlx5/mlx5_flow_dv.c | 24 ++- drivers/net/mlx5/mlx5_flow_hw.c | 201 ++++++++----------------- drivers/net/mlx5/mlx5_flow_meter.c | 14 +- 21 files changed, 491 insertions(+), 254 deletions(-) create mode 100644 drivers/net/mlx5/hws/mlx5dr_crc32.c create mode 100644 drivers/net/mlx5/hws/mlx5dr_crc32.h
Quoted 9 lines
Series LGTM.
Acked-by Suanming Mou <[email protected]>Thanks.
Quoted 3 lines
--
2.39.2
Series applied to next-net-mlx,
Kindest regards,
Raslan Darawsheh