net/mlx5: initial design of non template to hws
PATCH v4 1/11 net/mlx5: initial design of non template to hws
Implement the frame and needed building
blocks for non template to hws API's.
Added validate, list_create and list_destroy to mlx5_flow_hw_drv_ops. Rename old list_create/list_destroy functions to legacy_* and added a call from verbs/dv ops to the legacy functions.
Updated rte_flow_hw as needed.
Added rte_flow_nt2hws structure for non-template rule data.
squash to net/mlx5: initial design of non template to hws
--- drivers/net/mlx5/linux/mlx5_os.c | 8 +- drivers/net/mlx5/mlx5.h | 9 + drivers/net/mlx5/mlx5_flow.c | 139 +++++--- drivers/net/mlx5/mlx5_flow.h | 74 ++++- drivers/net/mlx5/mlx5_flow_dv.c | 192 +++++++++--- drivers/net/mlx5/mlx5_flow_hw.c | 487 +++++++++++++++++++++++++++-- drivers/net/mlx5/mlx5_flow_verbs.c | 2 + drivers/net/mlx5/mlx5_trigger.c | 6 + drivers/net/mlx5/windows/mlx5_os.c | 8 +- 9 files changed, 808 insertions(+), 117 deletions(-)
drivers/net/mlx5/linux/mlx5_os.c +7 -1
@@ -69,7 +69,7 @@ static rte_spinlock_t mlx5_shared_data_lock = RTE_SPINLOCK_INITIALIZER;static struct mlx5_local_data mlx5_local_data;/* rte flow indexed pool configuration. */ -static struct mlx5_indexed_pool_config icfg[] = { +static const struct mlx5_indexed_pool_config default_icfg[] = { { .size =sizeof (struct rte_flow ), .trunk_size =64 ,
@@ -1068,7 +1068,9 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,struct mlx5_port_info vport_info = { .query_flags =0 };int nl_rdma;int i; +struct mlx5_indexed_pool_config icfg[RTE_DIM (default_icfg)]; +memcpy (icfg, default_icfg,sizeof (icfg));/* Determine if this port representor is supposed to be spawned. */ if (switch_info->representor && dpdk_dev->devargs && !mlx5_representor_match (spawn, eth_da))
@@ -1539,6 +1541,10 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, icfg[i].release_mem_en = !!sh->config.reclaim_mode;if (sh->config.reclaim_mode) icfg[i].per_core_cache =0 ; +#ifdef HAVE_MLX5_HWS_SUPPORT +if (priv->sh->config.dv_flow_en ==2 ) + icfg[i].size =sizeof (struct rte_flow_hw ) +sizeof (struct rte_flow_nt2hws ); +#endif priv->flows[i] =mlx5_ipool_create (&icfg[i]);if (!priv->flows[i]) goto error;
drivers/net/mlx5/mlx5.h +9 -0
@@ -2293,6 +2293,15 @@ int mlx5_flow_validate(struct rte_eth_dev *dev,const struct rte_flow_item items[], const struct rte_flow_action actions[], struct rte_flow_error *error); +uint32_t +mlx5_flow_list_create (struct rte_eth_dev *dev,enum mlx5_flow_type type, +const struct rte_flow_attr *attr, +const struct rte_flow_item items[], +const struct rte_flow_action actions[], +bool external,struct rte_flow_error *error); +void +mlx5_flow_list_destroy (struct rte_eth_dev *dev,enum mlx5_flow_type type, +uint32_t flow_idx); struct rte_flow *mlx5_flow_create(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, const struct rte_flow_item items[],
drivers/net/mlx5/mlx5_flow.c +96 -43
311 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow.h +65 -9
131 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_dv.c +157 -35
316 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_hw.c +459 -28
568 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_verbs.c +2 -0
@@ -2183,6 +2183,8 @@ flow_verbs_sync_domain(struct rte_eth_dev *dev, uint32_t domains, }const struct mlx5_flow_driver_ops mlx5_flow_verbs_drv_ops = { + .list_create = flow_legacy_list_create, + .list_destroy = flow_legacy_list_destroy, .validate = flow_verbs_validate, .prepare = flow_verbs_prepare, .translate = flow_verbs_translate,
drivers/net/mlx5/mlx5_trigger.c +6 -0
@@ -1158,6 +1158,12 @@ mlx5_dev_start(struct rte_eth_dev *dev)DRV_LOG (DEBUG ,"port %u starting device" , dev->data->port_id);#ifdef HAVE_MLX5_HWS_SUPPORT if (priv->sh->config.dv_flow_en ==2 ) { +/*If previous configuration does not exist. */ +if (!(priv->dr_ctx)) { + ret =flow_hw_init (dev,NULL ); +if (ret) +return ret; + }/* If there is no E-Switch, then there are no start/stop order limitations. */ if (!priv->sh->config.dv_esw_en) goto continue_dev_start;
drivers/net/mlx5/windows/mlx5_os.c +7 -1
@@ -35,7 +35,7 @@ static const char *MZ_MLX5_PMD_SHARED_DATA = "mlx5_pmd_shared_data";static rte_spinlock_t mlx5_shared_data_lock =RTE_SPINLOCK_INITIALIZER ;/* rte flow indexed pool configuration. */ -static struct mlx5_indexed_pool_config icfg[] = { +static const struct mlx5_indexed_pool_config default_icfg[] = { { .size =sizeof (struct rte_flow ), .trunk_size =64 ,
@@ -352,7 +352,9 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,int own_domain_id =0 ;uint16_t port_id;int i; +struct mlx5_indexed_pool_config icfg[RTE_DIM (default_icfg)]; +memcpy (icfg, default_icfg,sizeof (icfg));/* Build device name. */ strlcpy (name, dpdk_dev->name,sizeof (name));/* check if the device is already spawned */
@@ -538,6 +540,10 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, icfg[i].release_mem_en = !!sh->config.reclaim_mode;if (sh->config.reclaim_mode) icfg[i].per_core_cache =0 ; +#ifdef HAVE_MLX5_HWS_SUPPORT +if (priv->sh->config.dv_flow_en ==2 ) + icfg[i].size =sizeof (struct rte_flow_hw ) +sizeof (struct rte_flow_nt2hws ); +#endif priv->flows[i] =mlx5_ipool_create (&icfg[i]);if (!priv->flows[i]) goto error;
Signature · 17 lines
2.25.1 From dceb3679ee066497fcb61ea6659d686966f36daf Mon Sep 17 00:00:00 2001 From: Bing Zhao <[email protected]> Date: Mon, 19 Jun 2023 13:16:28 +0800 Subject: [PATCH 02/11] net/mlx5: add dummy last action The RTE_FLOW_ACTION_TYPE_END action needs to be translated into the MLX5DR_ACTION_TYP_LAST for the future usage. It is only needed in the hardware steering backward compatible API. Signed-off-by: Bing Zhao <[email protected]> --- drivers/net/mlx5/mlx5.h | 1 + drivers/net/mlx5/mlx5_flow_hw.c | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+)
drivers/net/mlx5/mlx5.h +1 -0
@@ -1509,6 +1509,7 @@ struct mlx5_dev_ctx_shared {/* Direct Rules tables for FDB, NIC TX+RX */ void *dr_drop_action;/* Pointer to DR drop action, any domain. */ void *pop_vlan_action;/* Pointer to DR pop VLAN action. */ +void *hw_dummy_last;/* Pointer to the DR dummy end action, any domain. */ #if defined(HAVE_IBV_FLOW_DV_SUPPORT ) || !defined(HAVE_INFINIBAND_VERBS_H )struct mlx5_send_to_kernel_action send_to_kernel_action[MLX5DR_TABLE_TYPE_MAX ];#endif
drivers/net/mlx5/mlx5_flow_hw.c +19 -0
@@ -10639,6 +10639,17 @@ flow_hw_configure(struct rte_eth_dev *dev,if (ret) goto err; } +/* +* All domains will use the same dummy action, only used in the backward +* compatible API. Initialize it for only once. No order dependency. +*/ +if (!priv->sh->hw_dummy_last) { + priv->sh->hw_dummy_last =mlx5dr_action_create_last (priv->dr_ctx, +MLX5DR_ACTION_FLAG_HWS_RX ); +if (!priv->sh->hw_dummy_last) +/* Do not overwrite the rte_errno. */ + goto err; + }if (!priv->shared_host)flow_hw_create_send_to_kernel_actions (priv);if (port_attr->nb_conn_tracks || (host_priv && host_priv->hws_ctpool)) {
@@ -10717,6 +10728,10 @@ flow_hw_configure(struct rte_eth_dev *dev,flow_hw_ct_mng_destroy (dev, priv->ct_mng); priv->ct_mng =NULL ; } +if (priv->sh->hw_dummy_last) { +mlx5dr_action_destroy (priv->sh->hw_dummy_last); + priv->sh->hw_dummy_last =NULL ; + }flow_hw_destroy_send_to_kernel_action (priv);flow_hw_cleanup_ctrl_fdb_tables (dev);flow_hw_free_vport_actions (priv);
@@ -10832,6 +10847,10 @@ flow_hw_resource_release(struct rte_eth_dev *dev)mlx5dr_action_destroy (priv->hw_def_miss);flow_hw_destroy_nat64_actions (priv);flow_hw_destroy_vlan (dev); +if (priv->sh->hw_dummy_last) { +mlx5dr_action_destroy (priv->sh->hw_dummy_last); + priv->sh->hw_dummy_last =NULL ; + }flow_hw_destroy_send_to_kernel_action (priv);flow_hw_free_vport_actions (priv);if (priv->acts_ipool) {
Signature · 15 lines
2.25.1 From aaabbcdb925a109dc75abed20dbb0edc00f2b72e Mon Sep 17 00:00:00 2001 From: Bing Zhao <[email protected]> Date: Tue, 6 Jun 2023 14:25:17 +0800 Subject: [PATCH 03/11] net/mlx5: add basic actions support for non-template API Support JUMP / DROP / QUEUE / MARK / FLAG now. Signed-off-by: Bing Zhao <[email protected]> --- drivers/net/mlx5/mlx5_flow_hw.c | 153 ++++++++++++++++++++++++++++---- 1 file changed, 135 insertions(+), 18 deletions(-)
drivers/net/mlx5/mlx5_flow_hw.c +135 -18
187 lines not on this page · raw message
Signature · 17 lines
2.25.1 From 5695efb6fdfa1645d164559dc5f856e1a6975a3c Mon Sep 17 00:00:00 2001 From: Bing Zhao <[email protected]> Date: Fri, 1 Sep 2023 12:54:02 +0800 Subject: [PATCH 04/11] net/mlx5: add default miss action support in nt2hws mode The validation will be handled later. Now it only supports the SEND_TO_KERNEL on non-root tables. Signed-off-by: Bing Zhao <[email protected]> --- drivers/net/mlx5/mlx5_flow_hw.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-)
drivers/net/mlx5/mlx5_flow_hw.c +20 -3
@@ -12129,22 +12129,28 @@ flow_hw_translate_actions(struct rte_eth_dev *dev,enum mlx5_hw_action_flag_type flag_type;bool actions_end = false;uint64_t action_flags =0 ;/* to be used when needed */ +int ret;uint32_t actions_n =0 ;uint32_t mark_id;uint32_t jump_group; +uint32_t src_group =0 ;bool is_mark;struct mlx5_flow_template_table_cfg tbl_cfg;enum mlx5_flow_fate_type fate_type =MLX5_FLOW_FATE_NONE ; +RTE_SET_USED (action_flags); +/* The group in the attribute translation was done in advance. */ + ret =__translate_group (dev, attr, external, attr->group, &src_group, error); +if (ret) +return ret;if (attr->transfer) type =MLX5DR_TABLE_TYPE_FDB ;else if (attr->egress) type =MLX5DR_TABLE_TYPE_NIC_TX ;else type =MLX5DR_TABLE_TYPE_NIC_RX ; -/* The group in the attribute translation was done in advance. */ - flag_type = (attr->group ==0 ) ?MLX5_HW_ACTION_FLAG_ROOT : -MLX5_HW_ACTION_FLAG_NONE_ROOT ; + flag_type = (src_group ==0 ) ?MLX5_HW_ACTION_FLAG_ROOT : +MLX5_HW_ACTION_FLAG_NONE_ROOT ;for (; !actions_end; actions++) {switch (actions->type) {case RTE_FLOW_ACTION_TYPE_VOID :
@@ -12196,6 +12202,17 @@ flow_hw_translate_actions(struct rte_eth_dev *dev, action_flags |=MLX5_FLOW_ACTION_QUEUE ; fate_type =MLX5_FLOW_FATE_QUEUE ;break ; +case RTE_FLOW_ACTION_TYPE_SEND_TO_KERNEL : +if (src_group ==0 ) { +rte_flow_error_set (error,ENOTSUP , +RTE_FLOW_ERROR_TYPE_ACTION ,NULL , +"Send to kernel action on the root table is" +" not supported in HWS mode now." ); + goto clean_up; + } + hw_acts->rule_acts[actions_n++].action = priv->hw_send_to_kernel[type]; + action_flags |=MLX5_FLOW_ACTION_SEND_TO_KERNEL ; +break ;case RTE_FLOW_ACTION_TYPE_END :/* * Using NULL action right now, maybe a new API can be used
Signature · 30 lines
2.25.1 From 1c5c1c10eacd7eb5bae70f9a58081e4895696b56 Mon Sep 17 00:00:00 2001 From: Maayan Kashani <[email protected]> Date: Wed, 22 Nov 2023 09:44:17 +0200 Subject: [PATCH 05/11] net/mlx5: add ASO actions support to non-template mode This patch adds counter, connection tracking, meter and age actions support to non-template mode. For CT, counter and meter: if no previous allocation was handled by hw configure routine, Half of the maximum supported number of objects will be allocated. For AGE action, if no counters were allocated, allocate half of the maximum, and then allocate same number of AGE objects. Also extracted the shared host handling to the configure function. And align all ASO actions to have init function for future code improvement. This patch does not affect SW Steering flow engine. Signed-off-by: Maayan Kashani <[email protected]> --- drivers/net/mlx5/mlx5.h | 7 ++ drivers/net/mlx5/mlx5_flow_hw.c | 185 +++++++++++++++++++++++++++----- drivers/net/mlx5/mlx5_hws_cnt.c | 47 ++++---- drivers/net/mlx5/mlx5_hws_cnt.h | 10 +- 4 files changed, 190 insertions(+), 59 deletions(-)
drivers/net/mlx5/mlx5.h +7 -0
@@ -792,6 +792,13 @@ struct mlx5_dev_shared_port {/* Only yellow color valid. */ #define MLX5_MTR_POLICY_MODE_OY 3 +/* Max number of meters allocated in non template mode. */ +#define MLX5_MTR_NT_MAX (1 << 23)/*TODO verify number */ +/* Max number of connection tracking allocated in non template mode */ +#define MLX5_CT_NT_MAX (1 << 23)/*TODO verify number */ +/* Max number of counters allocated in non template mode */ +#define MLX5_CNT_MAX (1 << 23)/*TODO verify number */ +enum mlx5_meter_domain {MLX5_MTR_DOMAIN_INGRESS ,MLX5_MTR_DOMAIN_EGRESS ,
drivers/net/mlx5/mlx5_flow_hw.c +157 -28
280 lines not on this page · raw message
drivers/net/mlx5/mlx5_hws_cnt.c +20 -27
115 lines not on this page · raw message
drivers/net/mlx5/mlx5_hws_cnt.h +6 -4
@@ -712,9 +712,10 @@ mlx5_hws_cnt_service_thread_create(struct mlx5_dev_ctx_shared *sh);void mlx5_hws_cnt_service_thread_destroy (struct mlx5_dev_ctx_shared *sh); -struct mlx5_hws_cnt_pool * +int mlx5_hws_cnt_pool_create (struct rte_eth_dev *dev, -const struct rte_flow_port_attr *pattr,uint16_t nb_queue); +uint32_t nb_counters,uint16_t nb_queue, +struct mlx5_hws_cnt_pool *chost); void mlx5_hws_cnt_pool_destroy(struct mlx5_dev_ctx_shared *sh,
@@ -744,8 +745,9 @@ mlx5_hws_age_context_get(struct mlx5_priv *priv, uint32_t idx);int mlx5_hws_age_pool_init (struct rte_eth_dev *dev, -const struct rte_flow_port_attr *attr, -uint16_t nb_queues); +uint32_t nb_aging_objects, +uint16_t nb_queues, +bool strict_queue);void mlx5_hws_age_pool_destroy (struct mlx5_priv *priv);
Signature · 38 lines
2.25.1 From df1a2502e07b2b2aff2dad089547146f077050dd Mon Sep 17 00:00:00 2001 From: Maayan Kashani <[email protected]> Date: Sun, 31 Dec 2023 18:44:29 +0200 Subject: [PATCH 06/11] net/mlx5: fix segfault on counter pool destroy If the counter pool was not added to list, and an error state was reached, on attempt to destroy the counter pool, segmentation fault was received during list remove action. Added a check to verify the list is not empty before trying to remove the cpool from the list. Invalid state, leading to segfault, can also be reached in the following scenario: 1. mlx5_hws_cnt_pool_init() does a zmalloc and initializes most of the fields of cpool, but does not initialize the next field. 2. mlx5_hws_cnt_pool_dcs_alloc() attempts to bulk allocate flow counters. If this fails, we skip straight to 4. In HW, this can fail simply if FW doesn't support bulk flow counter allocation. 3. Right before the goto error, we insert the cpool to the hws_cpool_list. This is where the next field is initialized. 4. mlx5_hws_cnt_pool_destroy() assumes the cpool's next field is initialized and SEGVs if not. So, added a guard against cases where the entry was uninitialized (checking le_prev field is not NULL). Fixes: 6ac2104ac125 ("net/mlx5: fix counter query during port close") Cc: [email protected] Signed-off-by: Maayan Kashani <[email protected]> --- drivers/net/mlx5/mlx5_hws_cnt.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/mlx5/mlx5_hws_cnt.c +3 -1
@@ -718,7 +718,9 @@ mlx5_hws_cnt_pool_destroy(struct mlx5_dev_ctx_shared *sh,* Maybe blocked for at most 200ms here. */ rte_spinlock_lock (&sh->cpool_lock); -LIST_REMOVE (cpool, next); +/* Try to remove cpool before it was added to list caused segfault. */ +if (!LIST_EMPTY (&sh->hws_cpool_list) && cpool->next.le_prev) +LIST_REMOVE (cpool, next);rte_spinlock_unlock (&sh->cpool_lock);if (cpool->cfg.host_cpool ==NULL ) {if (--sh->cnt_svc->refcnt ==0 )
Signature · 38 lines
2.25.1 From 05d3f58305e87a0f79c2879d8edc94acf6e8f89b Mon Sep 17 00:00:00 2001 From: Maayan Kashani <[email protected]> Date: Wed, 13 Dec 2023 14:59:45 +0200 Subject: [PATCH 07/11] net/mlx5: abstract action handling and enable reconfigure MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit reuse HWS actions translation code in order to create the actions for lower layer. All actions are handled as non masked. Therefore, will be translated in the rule construct phase shared with the template code and not during the action template translate. Currently there is no option to reconfigure in template API’s. To support non template API and template API simultaneously, There is a need to enable the user to reconfigure after default configuration was applied by the driver on port start. Fix flow create ptr In SWS the return flow pointer is the flow index, in HWS the return flow pointer is the flow data pointer. Currently the return value of non template code did not Enable destroy or quary. Signed-off-by: Maayan Kashani <[email protected]> --- drivers/net/mlx5/mlx5.h | 25 +- drivers/net/mlx5/mlx5_flow.c | 31 +- drivers/net/mlx5/mlx5_flow.h | 14 +- drivers/net/mlx5/mlx5_flow_dv.c | 18 +- drivers/net/mlx5/mlx5_flow_hw.c | 811 ++++++++++++++++---------------- 5 files changed, 463 insertions(+), 436 deletions(-)
drivers/net/mlx5/mlx5.h +13 -12
@@ -793,11 +793,11 @@ struct mlx5_dev_shared_port {#define MLX5_MTR_POLICY_MODE_OY 3/* Max number of meters allocated in non template mode. */ -#define MLX5_MTR_NT_MAX (1 << 23)/*TODO verify number */ +#define MLX5_MTR_NT_MAX (1 << 23)/* Max number of connection tracking allocated in non template mode */ -#define MLX5_CT_NT_MAX (1 << 23)/*TODO verify number */ +#define MLX5_CT_NT_MAX (1 << 23)/* Max number of counters allocated in non template mode */ -#define MLX5_CNT_MAX (1 << 23)/*TODO verify number */ +#define MLX5_CNT_MAX (1 << 23)enum mlx5_meter_domain {MLX5_MTR_DOMAIN_INGRESS ,
@@ -1516,7 +1516,6 @@ struct mlx5_dev_ctx_shared {/* Direct Rules tables for FDB, NIC TX+RX */ void *dr_drop_action;/* Pointer to DR drop action, any domain. */ void *pop_vlan_action;/* Pointer to DR pop VLAN action. */ -void *hw_dummy_last;/* Pointer to the DR dummy end action, any domain. */ #if defined(HAVE_IBV_FLOW_DV_SUPPORT ) || !defined(HAVE_INFINIBAND_VERBS_H )struct mlx5_send_to_kernel_action send_to_kernel_action[MLX5DR_TABLE_TYPE_MAX ];#endif
@@ -1797,6 +1796,14 @@ struct mlx5_hw_ctrl_flow {struct mlx5_hw_ctrl_flow_info info; }; +/* HW Steering port configuration passed to rte_flow_configure(). */ +struct mlx5_flow_hw_attr { +struct rte_flow_port_attr port_attr; +uint16_t nb_queue; +struct rte_flow_queue_attr *queue_attr; +bool nt_mode; +}; +/* * Flow rule structure for flow engine mode control, focus on group 0. * Apply to all supported domains.
@@ -1818,12 +1825,6 @@ struct rte_pmd_mlx5_flow_engine_mode_info {/* The list is maintained in insertion order. */ LIST_HEAD(hot_up_info, mlx5_dv_flow_info) hot_upgrade; }; -/* HW Steering port configuration passed to rte_flow_configure(). */ -struct mlx5_flow_hw_attr { -struct rte_flow_port_attr port_attr; -uint16_t nb_queue; -struct rte_flow_queue_attr *queue_attr; -};struct mlx5_flow_hw_ctrl_rx ;
@@ -2301,7 +2302,7 @@ int mlx5_flow_validate(struct rte_eth_dev *dev,const struct rte_flow_item items[], const struct rte_flow_action actions[], struct rte_flow_error *error); -uint32_t +uintptr_t mlx5_flow_list_create(struct rte_eth_dev *dev, enum mlx5_flow_type type, const struct rte_flow_attr *attr, const struct rte_flow_item items[],
@@ -2309,7 +2310,7 @@ mlx5_flow_list_create(struct rte_eth_dev *dev, enum mlx5_flow_type type, bool external, struct rte_flow_error *error);void mlx5_flow_list_destroy (struct rte_eth_dev *dev,enum mlx5_flow_type type, -uint32_t flow_idx); +uintptr_t flow_idx); struct rte_flow *mlx5_flow_create(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, const struct rte_flow_item items[],
drivers/net/mlx5/mlx5_flow.c +14 -17
@@ -4930,7 +4930,7 @@ flow_check_hairpin_split(struct rte_eth_dev *dev,/* Declare flow create/destroy prototype in advance. */ -static uint32_t +static uintptr_t flow_drv_list_create(struct rte_eth_dev *dev, enum mlx5_flow_type type, const struct rte_flow_attr *attr, const struct rte_flow_item items[],
@@ -4939,7 +4939,7 @@ flow_drv_list_create(struct rte_eth_dev *dev, enum mlx5_flow_type type,static void flow_drv_list_destroy (struct rte_eth_dev *dev,enum mlx5_flow_type type, -uint32_t flow_idx); +uintptr_t flow_idx); int flow_dv_mreg_match_cb(void *tool_ctx __rte_unused,
@@ -7243,7 +7243,7 @@ flow_tunnel_from_rule(const struct mlx5_flow *flow)* @return * A flow index on success, 0 otherwise and rte_errno is set. */ -uint32_t +uintptr_t flow_legacy_list_create(struct rte_eth_dev *dev, enum mlx5_flow_type type, const struct rte_flow_attr *attr, const struct rte_flow_item items[],
@@ -7918,7 +7918,7 @@ mlx5_flow_create(struct rte_eth_dev *dev,struct mlx5_priv *priv = dev->data->dev_private;struct rte_flow_attr *new_attr = (void *)(uintptr_t )attr;uint32_t prio = attr->priority; -uint32_t flow_idx; +uintptr_t flow_idx;/* * If the device is not started yet, it is not allowed to created a
@@ -7952,7 +7952,7 @@ mlx5_flow_create(struct rte_eth_dev *dev,return (void *)(uintptr_t )flow_idx; } -uint32_t +uintptr_t mlx5_flow_list_create(struct rte_eth_dev *dev, enum mlx5_flow_type type, const struct rte_flow_attr *attr, const struct rte_flow_item items[],
@@ -7963,7 +7963,7 @@ mlx5_flow_list_create(struct rte_eth_dev *dev, enum mlx5_flow_type type, error); } -uint32_t +uintptr_t flow_drv_list_create(struct rte_eth_dev *dev, enum mlx5_flow_type type, const struct rte_flow_attr *attr, const struct rte_flow_item items[],
@@ -7988,7 +7988,7 @@ flow_drv_list_create(struct rte_eth_dev *dev, enum mlx5_flow_type type,*/ void flow_legacy_list_destroy (struct rte_eth_dev *dev,enum mlx5_flow_type type, -uint32_t flow_idx) +uintptr_t flow_idx) {struct mlx5_priv *priv = dev->data->dev_private;struct rte_flow *flow =mlx5_ipool_get (priv->flows[type], (uint32_t )flow_idx);
@@ -8019,7 +8019,7 @@ flow_legacy_list_destroy(struct rte_eth_dev *dev, enum mlx5_flow_type type,static void flow_drv_list_destroy (struct rte_eth_dev *dev,enum mlx5_flow_type type, -uint32_t flow_idx) +uintptr_t flow_idx) {const struct mlx5_flow_driver_ops *fops;struct rte_flow_attr attr = { .transfer =0 };
@@ -8031,7 +8031,7 @@ flow_drv_list_destroy(struct rte_eth_dev *dev, enum mlx5_flow_type type,void mlx5_flow_list_destroy (struct rte_eth_dev *dev,enum mlx5_flow_type type, -uint32_t flow_idx) +uintptr_t flow_idx) {flow_drv_list_destroy (dev, type, flow_idx); }
@@ -8060,12 +8060,14 @@ mlx5_flow_list_flush(struct rte_eth_dev *dev, enum mlx5_flow_type type,if (priv->sh->config.dv_flow_en ==2 && type ==MLX5_FLOW_TYPE_GEN ) {flow_hw_q_flow_flush (dev,NULL ); -return ; }#endif - MLX5_IPOOL_FOREACH(priv->flows[type], fidx, flow) { -flow_drv_list_destroy (dev, type, fidx); +if (priv->sh->config.dv_flow_en ==2 ) { +flow_drv_list_destroy (dev, type, (uintptr_t )flow); + }else { +flow_drv_list_destroy (dev, type, fidx); + }if (unlikely (mlx5_need_cache_flow (priv,NULL ) && type ==MLX5_FLOW_TYPE_GEN )) { flow_info =LIST_FIRST (&mode_info->hot_upgrade);while (flow_info) {
@@ -8526,11 +8528,6 @@ mlx5_flow_destroy(struct rte_eth_dev *dev,struct rte_pmd_mlx5_flow_engine_mode_info *mode_info = &priv->mode_info;struct mlx5_dv_flow_info *flow_info; -if (priv->sh->config.dv_flow_en ==2 ) -return rte_flow_error_set (error,ENOTSUP , -RTE_FLOW_ERROR_TYPE_UNSPECIFIED , -NULL , -"Flow non-Q destruction not supported" );flow_drv_list_destroy (dev,MLX5_FLOW_TYPE_GEN , (uintptr_t )(void *)flow);if (unlikely (mlx5_need_cache_flow (priv,NULL ))) {
drivers/net/mlx5/mlx5_flow.h +9 -5
@@ -1315,6 +1315,8 @@ struct rte_flow_nt2hws {struct mlx5dr_bwc_rule *nt_rule;/** The matcher for non template api. */ struct mlx5_flow_dv_matcher *matcher; +/**< Auxiliary data stored per flow. */ +struct rte_flow_hw_aux *flow_aux; } __rte_packed;/** HWS flow struct. */
@@ -1349,12 +1351,14 @@ struct rte_flow_hw {struct mlx5_hrxq *hrxq; }; +/** Equals true if it is non template rule. */ +bool nt_rule;/** * Padding for alignment to 56 bytes. * Since mlx5dr rule is 72 bytes, whole flow is contained within 128 B (2 cache lines). * This space is reserved for future additions to flow struct. */ -uint8_t padding[10 ]; +uint8_t padding[9 ];/** HWS layer data struct. */ uint8_t rule[]; } __rte_packed;
@@ -2116,7 +2120,7 @@ int flow_hw_init(struct rte_eth_dev *dev, struct rte_flow_error *error); -typedef uint32_t (*mlx5_flow_list_create_t)(struct rte_eth_dev *dev, +typedef uintptr_t (*mlx5_flow_list_create_t)(struct rte_eth_dev *dev, enum mlx5_flow_type type, const struct rte_flow_attr *attr, const struct rte_flow_item items[],
@@ -2125,7 +2129,7 @@ typedef uint32_t (*mlx5_flow_list_create_t)(struct rte_eth_dev *dev, struct rte_flow_error *error);typedef void (*mlx5_flow_list_destroy_t )(struct rte_eth_dev *dev,enum mlx5_flow_type type, -uint32_t flow_idx); +uintptr_t flow_idx); typedef int (*mlx5_flow_validate_t)(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, const struct rte_flow_item items[],
@@ -3317,13 +3321,13 @@ int mlx5_flow_item_field_width(struct rte_eth_dev *dev, enum rte_flow_field_id field, int inherit, const struct rte_flow_attr *attr, struct rte_flow_error *error); -uint32_t flow_legacy_list_create (struct rte_eth_dev *dev,enum mlx5_flow_type type, +uintptr_t flow_legacy_list_create (struct rte_eth_dev *dev,enum mlx5_flow_type type,const struct rte_flow_attr *attr,const struct rte_flow_item items[],const struct rte_flow_action actions[],bool external,struct rte_flow_error *error);void flow_legacy_list_destroy (struct rte_eth_dev *dev,enum mlx5_flow_type type, -uint32_t flow_idx); +uintptr_t flow_idx); static __rte_always_inline int flow_hw_get_srh_flex_parser_byte_off_from_ctx(void *dr_ctx __rte_unused)
drivers/net/mlx5/mlx5_flow_dv.c +15 -3
@@ -11843,12 +11843,14 @@ flow_matcher_create_cb(void *tool_ctx, void *cb_ctx)struct mlx5_flow_cb_ctx *ctx = cb_ctx;struct mlx5_flow_dv_matcher *ref = ctx->data;struct mlx5_flow_dv_matcher *resource; +#ifdef HAVE_MLX5_HWS_SUPPORT +const struct rte_flow_item *items; +#endif struct mlx5dv_flow_matcher_attr dv_attr = { .type =IBV_FLOW_ATTR_NORMAL , .match_mask = (void *)&ref->mask, }; -struct mlx5_flow_tbl_data_entry *tbl =container_of (ref->tbl, -typeof (*tbl), tbl); +struct mlx5_flow_tbl_data_entry *tbl;int ret; resource = mlx5_malloc(MLX5_MEM_ZERO, sizeof(*resource), 0,
@@ -11859,9 +11861,9 @@ flow_matcher_create_cb(void *tool_ctx, void *cb_ctx) "cannot create matcher");return NULL ; } -/*Consider memcpy(resource, ref, sizeof(*resource));*/ *resource = *ref;if (sh->config.dv_flow_en !=2 ) { + tbl =container_of (ref->tbl,typeof (*tbl), tbl); dv_attr.match_criteria_enable =flow_dv_matcher_enable (resource->mask.buf); __flow_dv_adjust_buf_size(&ref->mask.size,
@@ -11879,6 +11881,16 @@ flow_matcher_create_cb(void *tool_ctx, void *cb_ctx) "cannot create matcher");return NULL ; } + }else { +#ifdef HAVE_MLX5_HWS_SUPPORT + items = *((const struct rte_flow_item **)(ctx->data2)); + resource->matcher_object =mlx5dr_bwc_matcher_create + (resource->group->tbl, resource->priority, items); +if (!(resource->matcher_object)) +return NULL ; +#else +return NULL ; +#endif }return &resource->entry; }
drivers/net/mlx5/mlx5_flow_hw.c +412 -399
606 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 16 lines
2.25.1 From 5f2411e5bbeeb8866f4a01de5e58a5c47bf87a88 Mon Sep 17 00:00:00 2001 From: Maayan Kashani <[email protected]> Date: Mon, 26 Feb 2024 14:28:25 +0200 Subject: [PATCH 08/11] common/mlx5: read connection tracking attributes Need to read maximum connection tracking objects from HCA attributes. Signed-off-by: Maayan Kashani <[email protected]> --- drivers/common/mlx5/mlx5_devx_cmds.c | 3 +++ drivers/common/mlx5/mlx5_devx_cmds.h | 1 + 2 files changed, 4 insertions(+)
The rest of this diff is not shown. View the raw message.
Signature · 21 lines
2.25.1 From 52f092243ef81427fca2fda82845077b9f8b8e3c Mon Sep 17 00:00:00 2001 From: Maayan Kashani <[email protected]> Date: Sun, 28 Jan 2024 14:09:21 +0200 Subject: [PATCH 09/11] net/mlx5: support bulk actions in non template mode Add support for encap/decap/modify header action for non template API. Save 1 action per bulk according to action data. Reuse action if possible. Store actions same as for SWS today, use same key structure. Signed-off-by: Maayan Kashani <[email protected]> --- drivers/net/mlx5/mlx5_flow.h | 44 ++++-- drivers/net/mlx5/mlx5_flow_dv.c | 268 ++++++++++++++++++++------------ drivers/net/mlx5/mlx5_flow_hw.c | 184 ++++++++++++++++++++-- 3 files changed, 368 insertions(+), 128 deletions(-)
drivers/net/mlx5/mlx5_flow.h +32 -12
44 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_dv.c +165 -103
268 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_hw.c +171 -13
184 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 17 lines
2.25.1 From 5f3ca4ddaf1764ecd78f66629655508fd39b2aa7 Mon Sep 17 00:00:00 2001 From: Maayan Kashani <[email protected]> Date: Sun, 10 Mar 2024 16:17:06 +0200 Subject: [PATCH 10/11] net/mlx5: use non const max number for ASO actions For ASO max allocations in non-template mode, Read FW capabilities instead of using consts. Signed-off-by: Maayan Kashani <[email protected]> --- drivers/net/mlx5/mlx5.h | 17 ++++++++++++----- drivers/net/mlx5/mlx5_flow_hw.c | 13 +++++++++---- drivers/net/mlx5/mlx5_flow_meter.c | 25 +++++++++++++++++++++---- 3 files changed, 42 insertions(+), 13 deletions(-)
The rest of this diff is not shown. View the raw message.
Signature · 18 lines
2.25.1 From 3833d67a02a9df5bda034c236923c6353ed363f6 Mon Sep 17 00:00:00 2001 From: Maayan Kashani <[email protected]> Date: Sun, 10 Mar 2024 16:22:53 +0200 Subject: [PATCH 11/11] net/mlx5: initial design changes Change flow_drv_list_create/destroy to mlx5_flow_list_create/destroy. Remove resource release function inlining. Check number of queues in template mode in hw configure function. Use user priority to calculate matcher priority. Signed-off-by: Maayan Kashani <[email protected]> --- drivers/net/mlx5/mlx5_flow.c | 70 +++++++--------------- drivers/net/mlx5/mlx5_flow_hw.c | 100 +++++++++++++++----------------- 2 files changed, 68 insertions(+), 102 deletions(-)
drivers/net/mlx5/mlx5_flow.c +20 -50
70 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_hw.c +48 -52
100 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.25.1
Part of the diff is not shown here. View the raw message.
PATCH v2 5/34 net/mlx5: initial design of non template to hws
Implement the frame and needed building
blocks for non template to hws API's.
Added validate, list_create and list_destroy to mlx5_flow_hw_drv_ops. Rename old list_create/list_destroy functions to legacy_* and added a call from verbs/dv ops to the legacy functions.
Updated rte_flow_hw as needed.
Added rte_flow_nt2hws structure for non-template rule data.
squash to net/mlx5: initial design of non template to hws
--- drivers/net/mlx5/linux/mlx5_os.c | 8 +- drivers/net/mlx5/mlx5.h | 9 + drivers/net/mlx5/mlx5_flow.c | 139 +++++--- drivers/net/mlx5/mlx5_flow.h | 74 ++++- drivers/net/mlx5/mlx5_flow_dv.c | 192 +++++++++--- drivers/net/mlx5/mlx5_flow_hw.c | 487 +++++++++++++++++++++++++++-- drivers/net/mlx5/mlx5_flow_verbs.c | 2 + drivers/net/mlx5/mlx5_trigger.c | 6 + drivers/net/mlx5/windows/mlx5_os.c | 8 +- 9 files changed, 808 insertions(+), 117 deletions(-)
drivers/net/mlx5/linux/mlx5_os.c +7 -1
@@ -69,7 +69,7 @@ static rte_spinlock_t mlx5_shared_data_lock = RTE_SPINLOCK_INITIALIZER;static struct mlx5_local_data mlx5_local_data;/* rte flow indexed pool configuration. */ -static struct mlx5_indexed_pool_config icfg[] = { +static const struct mlx5_indexed_pool_config default_icfg[] = { { .size =sizeof (struct rte_flow ), .trunk_size =64 ,
@@ -1068,7 +1068,9 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,struct mlx5_port_info vport_info = { .query_flags =0 };int nl_rdma;int i; +struct mlx5_indexed_pool_config icfg[RTE_DIM (default_icfg)]; +memcpy (icfg, default_icfg,sizeof (icfg));/* Determine if this port representor is supposed to be spawned. */ if (switch_info->representor && dpdk_dev->devargs && !mlx5_representor_match (spawn, eth_da))
@@ -1539,6 +1541,10 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, icfg[i].release_mem_en = !!sh->config.reclaim_mode;if (sh->config.reclaim_mode) icfg[i].per_core_cache =0 ; +#ifdef HAVE_MLX5_HWS_SUPPORT +if (priv->sh->config.dv_flow_en ==2 ) + icfg[i].size =sizeof (struct rte_flow_hw ) +sizeof (struct rte_flow_nt2hws ); +#endif priv->flows[i] =mlx5_ipool_create (&icfg[i]);if (!priv->flows[i]) goto error;
drivers/net/mlx5/mlx5.h +9 -0
@@ -2293,6 +2293,15 @@ int mlx5_flow_validate(struct rte_eth_dev *dev,const struct rte_flow_item items[], const struct rte_flow_action actions[], struct rte_flow_error *error); +uint32_t +mlx5_flow_list_create (struct rte_eth_dev *dev,enum mlx5_flow_type type, +const struct rte_flow_attr *attr, +const struct rte_flow_item items[], +const struct rte_flow_action actions[], +bool external,struct rte_flow_error *error); +void +mlx5_flow_list_destroy (struct rte_eth_dev *dev,enum mlx5_flow_type type, +uint32_t flow_idx); struct rte_flow *mlx5_flow_create(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, const struct rte_flow_item items[],
drivers/net/mlx5/mlx5_flow.c +96 -43
311 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow.h +65 -9
131 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_dv.c +157 -35
316 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_hw.c +459 -28
568 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_verbs.c +2 -0
@@ -2183,6 +2183,8 @@ flow_verbs_sync_domain(struct rte_eth_dev *dev, uint32_t domains, }const struct mlx5_flow_driver_ops mlx5_flow_verbs_drv_ops = { + .list_create = flow_legacy_list_create, + .list_destroy = flow_legacy_list_destroy, .validate = flow_verbs_validate, .prepare = flow_verbs_prepare, .translate = flow_verbs_translate,
drivers/net/mlx5/mlx5_trigger.c +6 -0
@@ -1158,6 +1158,12 @@ mlx5_dev_start(struct rte_eth_dev *dev)DRV_LOG (DEBUG ,"port %u starting device" , dev->data->port_id);#ifdef HAVE_MLX5_HWS_SUPPORT if (priv->sh->config.dv_flow_en ==2 ) { +/*If previous configuration does not exist. */ +if (!(priv->dr_ctx)) { + ret =flow_hw_init (dev,NULL ); +if (ret) +return ret; + }/* If there is no E-Switch, then there are no start/stop order limitations. */ if (!priv->sh->config.dv_esw_en) goto continue_dev_start;
drivers/net/mlx5/windows/mlx5_os.c +7 -1
@@ -35,7 +35,7 @@ static const char *MZ_MLX5_PMD_SHARED_DATA = "mlx5_pmd_shared_data";static rte_spinlock_t mlx5_shared_data_lock =RTE_SPINLOCK_INITIALIZER ;/* rte flow indexed pool configuration. */ -static struct mlx5_indexed_pool_config icfg[] = { +static const struct mlx5_indexed_pool_config default_icfg[] = { { .size =sizeof (struct rte_flow ), .trunk_size =64 ,
@@ -352,7 +352,9 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,int own_domain_id =0 ;uint16_t port_id;int i; +struct mlx5_indexed_pool_config icfg[RTE_DIM (default_icfg)]; +memcpy (icfg, default_icfg,sizeof (icfg));/* Build device name. */ strlcpy (name, dpdk_dev->name,sizeof (name));/* check if the device is already spawned */
@@ -538,6 +540,10 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, icfg[i].release_mem_en = !!sh->config.reclaim_mode;if (sh->config.reclaim_mode) icfg[i].per_core_cache =0 ; +#ifdef HAVE_MLX5_HWS_SUPPORT +if (priv->sh->config.dv_flow_en ==2 ) + icfg[i].size =sizeof (struct rte_flow_hw ) +sizeof (struct rte_flow_nt2hws ); +#endif priv->flows[i] =mlx5_ipool_create (&icfg[i]);if (!priv->flows[i]) goto error;
Signature · 1 line
2.25.1
PATCH v2 6/34 net/mlx5: add dummy last action
From: Bing Zhao <[email protected]>
The RTE_FLOW_ACTION_TYPE_END action needs to be translated into the MLX5DR_ACTION_TYP_LAST for the future usage. It is only needed in the hardware steering backward compatible API.
--- drivers/net/mlx5/mlx5.h | 1 + drivers/net/mlx5/mlx5_flow_hw.c | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+)
drivers/net/mlx5/mlx5.h +1 -0
@@ -1509,6 +1509,7 @@ struct mlx5_dev_ctx_shared {/* Direct Rules tables for FDB, NIC TX+RX */ void *dr_drop_action;/* Pointer to DR drop action, any domain. */ void *pop_vlan_action;/* Pointer to DR pop VLAN action. */ +void *hw_dummy_last;/* Pointer to the DR dummy end action, any domain. */ #if defined(HAVE_IBV_FLOW_DV_SUPPORT ) || !defined(HAVE_INFINIBAND_VERBS_H )struct mlx5_send_to_kernel_action send_to_kernel_action[MLX5DR_TABLE_TYPE_MAX ];#endif
drivers/net/mlx5/mlx5_flow_hw.c +19 -0
@@ -10639,6 +10639,17 @@ flow_hw_configure(struct rte_eth_dev *dev,if (ret) goto err; } +/* +* All domains will use the same dummy action, only used in the backward +* compatible API. Initialize it for only once. No order dependency. +*/ +if (!priv->sh->hw_dummy_last) { + priv->sh->hw_dummy_last =mlx5dr_action_create_last (priv->dr_ctx, +MLX5DR_ACTION_FLAG_HWS_RX ); +if (!priv->sh->hw_dummy_last) +/* Do not overwrite the rte_errno. */ + goto err; + }if (!priv->shared_host)flow_hw_create_send_to_kernel_actions (priv);if (port_attr->nb_conn_tracks || (host_priv && host_priv->hws_ctpool)) {
@@ -10717,6 +10728,10 @@ flow_hw_configure(struct rte_eth_dev *dev,flow_hw_ct_mng_destroy (dev, priv->ct_mng); priv->ct_mng =NULL ; } +if (priv->sh->hw_dummy_last) { +mlx5dr_action_destroy (priv->sh->hw_dummy_last); + priv->sh->hw_dummy_last =NULL ; + }flow_hw_destroy_send_to_kernel_action (priv);flow_hw_cleanup_ctrl_fdb_tables (dev);flow_hw_free_vport_actions (priv);
@@ -10832,6 +10847,10 @@ flow_hw_resource_release(struct rte_eth_dev *dev)mlx5dr_action_destroy (priv->hw_def_miss);flow_hw_destroy_nat64_actions (priv);flow_hw_destroy_vlan (dev); +if (priv->sh->hw_dummy_last) { +mlx5dr_action_destroy (priv->sh->hw_dummy_last); + priv->sh->hw_dummy_last =NULL ; + }flow_hw_destroy_send_to_kernel_action (priv);flow_hw_free_vport_actions (priv);if (priv->acts_ipool) {
Signature · 1 line
2.25.1
PATCH v2 7/34 net/mlx5: add basic actions support for non-template API
In reply to Maayan KashaniFrom: Bing Zhao <[email protected]>
Support JUMP / DROP / QUEUE / MARK / FLAG now.
--- drivers/net/mlx5/mlx5_flow_hw.c | 153 ++++++++++++++++++++++++++++---- 1 file changed, 135 insertions(+), 18 deletions(-)
drivers/net/mlx5/mlx5_flow_hw.c +135 -18
@@ -604,8 +604,7 @@ flow_hw_jump_release(struct rte_eth_dev *dev, struct mlx5_hw_jump_action *jump)struct mlx5_priv *priv = dev->data->dev_private;struct mlx5_flow_group *grp; - grp =container_of - (jump, struct mlx5_flow_group, jump); + grp = container_of(jump, struct mlx5_flow_group, jump);mlx5_hlist_unregister (priv->sh->flow_tbls, &grp->entry); }
@@ -705,17 +704,9 @@ flow_hw_template_destroy_mhdr_action(struct mlx5_hw_modify_header_action *mhdr)* Pointer to the template HW steering DR actions. */ static void -__flow_hw_action_template_destroy (struct rte_eth_dev *dev, -struct mlx5_hw_actions *acts) +__flow_hw_actions_release (struct rte_eth_dev *dev,struct mlx5_hw_actions *acts) {struct mlx5_priv *priv = dev->data->dev_private; -struct mlx5_action_construct_data *data; - -while (!LIST_EMPTY (&acts->act_list)) { - data =LIST_FIRST (&acts->act_list); -LIST_REMOVE (data, next); -mlx5_ipool_free (priv->acts_ipool, data->idx); - }if (acts->mark) if (!(rte_atomic_fetch_sub_explicit(&priv->hws_mark_refcnt, 1,
@@ -760,6 +751,32 @@ __flow_hw_action_template_destroy(struct rte_eth_dev *dev, } } +/** +* Destroy DR actions created by action template. +* +* For DR actions created during table creation's action translate. +* Need to destroy the DR action when destroying the table. +* +* @param[in] dev +* Pointer to the rte_eth_dev structure. +* @param[in] acts +* Pointer to the template HW steering DR actions. +*/ +static void +__flow_hw_action_template_destroy (struct rte_eth_dev *dev,struct mlx5_hw_actions *acts) +{ +struct mlx5_priv *priv = dev->data->dev_private; +struct mlx5_action_construct_data *data; + +while (!LIST_EMPTY (&acts->act_list)) { + data =LIST_FIRST (&acts->act_list); +LIST_REMOVE (data, next); +mlx5_ipool_free (priv->acts_ipool, data->idx); + } + +__flow_hw_actions_release (dev, acts); +} +/** * Append dynamic action to the dynamic action list. *
@@ -12098,14 +12115,113 @@ static int flow_hw_prepare(struct rte_eth_dev *dev,return 0 ; } -static int flow_hw_translate_actions(struct rte_eth_dev *dev __rte_unused, - const struct rte_flow_attr *attr __rte_unused, - const struct rte_flow_action actions[] __rte_unused, - struct rte_flow_hw *flow __rte_unused, - struct rte_flow_error *error __rte_unused) +static int +flow_hw_translate_actions (struct rte_eth_dev *dev, +const struct rte_flow_attr *attr, +const struct rte_flow_action actions[], +struct rte_flow_hw *flow, +struct mlx5_hw_actions *hw_acts, +bool external, +struct rte_flow_error *error) { -/* TODO implement */ +struct mlx5_priv *priv = dev->data->dev_private; +enum mlx5dr_table_type type; +enum mlx5_hw_action_flag_type flag_type; +bool actions_end = false; +uint64_t action_flags =0 ;/* to be used when needed */ +uint32_t actions_n =0 ; +uint32_t mark_id; +uint32_t jump_group; +bool is_mark; +struct mlx5_flow_template_table_cfg tbl_cfg; +enum mlx5_flow_fate_type fate_type =MLX5_FLOW_FATE_NONE ; + +if (attr->transfer) + type =MLX5DR_TABLE_TYPE_FDB ; +else if (attr->egress) + type =MLX5DR_TABLE_TYPE_NIC_TX ; +else + type =MLX5DR_TABLE_TYPE_NIC_RX ; +/* The group in the attribute translation was done in advance. */ + flag_type = (attr->group ==0 ) ?MLX5_HW_ACTION_FLAG_ROOT : +MLX5_HW_ACTION_FLAG_NONE_ROOT ; +for (; !actions_end; actions++) { +switch (actions->type) { +case RTE_FLOW_ACTION_TYPE_VOID : +break ; +case RTE_FLOW_ACTION_TYPE_DROP : + hw_acts->rule_acts[actions_n++].action = priv->hw_drop[flag_type]; + fate_type =MLX5_FLOW_FATE_DROP ; +break ; +case RTE_FLOW_ACTION_TYPE_FLAG : +case RTE_FLOW_ACTION_TYPE_MARK : + is_mark = actions->type ==RTE_FLOW_ACTION_TYPE_MARK ; + mark_id = is_mark ? + ((const struct rte_flow_action_mark *)(actions->conf))->id : +MLX5_FLOW_MARK_DEFAULT ; + hw_acts->rule_acts[actions_n].tag.value =mlx5_flow_mark_set (mark_id); + hw_acts->rule_acts[actions_n].action = priv->hw_tag[flag_type]; + actions_n++; + action_flags |= is_mark ?MLX5_FLOW_ACTION_MARK :MLX5_FLOW_ACTION_FLAG ; + hw_acts->mark = true; +rte_atomic_fetch_add_explicit (&priv->hws_mark_refcnt,1 , + rte_memory_order_relaxed); +flow_hw_rxq_flag_set (dev, true); +break ; +case RTE_FLOW_ACTION_TYPE_JUMP : + jump_group = ((const struct rte_flow_action_jump *)actions->conf)->group; + tbl_cfg.attr.flow_attr = *attr; + tbl_cfg.external = external; +/* The flow_hw_jump_action_register() can be refactored. */ + hw_acts->jump =flow_hw_jump_action_register (dev, &tbl_cfg, + jump_group, error); +if (hw_acts->jump ==NULL ) + goto clean_up; + hw_acts->rule_acts[actions_n++].action = + (flag_type ==MLX5_HW_ACTION_FLAG_NONE_ROOT ) ? + hw_acts->jump->hws_action : hw_acts->jump->root_action; + action_flags |=MLX5_FLOW_ACTION_JUMP ; + fate_type =MLX5_FLOW_FATE_JUMP ; +break ; +case RTE_FLOW_ACTION_TYPE_QUEUE : +/* Right now, only Rx supports the TIR, validation is needed. */ + hw_acts->tir =flow_hw_tir_action_register (dev, + mlx5_hw_act_flag[flag_type][type], actions); +if (hw_acts->tir ==NULL ) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION ,NULL , +"Failed to translate queue." ); + goto clean_up; + } + action_flags |=MLX5_FLOW_ACTION_QUEUE ; + fate_type =MLX5_FLOW_FATE_QUEUE ; +break ; +case RTE_FLOW_ACTION_TYPE_END : +/* +* Using NULL action right now, maybe a new API can be used +* to create a dummy action with type MLX5DR_ACTION_TYP_LAST. +*/ + hw_acts->rule_acts[actions_n++].action = priv->sh->hw_dummy_last; + actions_end = true; +break ; +default : +break ; + } + } +if (fate_type ==MLX5_FLOW_FATE_QUEUE ) { + hw_acts->rule_acts[actions_n++].action = hw_acts->tir->action; + flow->hrxq = hw_acts->tir; + }else { +if (fate_type ==MLX5_FLOW_FATE_JUMP ) + flow->jump = hw_acts->jump; + } +/* Total actions number should be validated before. */ +MLX5_ASSERT (actions_n <=MLX5_HW_MAX_ACTS );return 0 ; +clean_up: +/* Make sure that there is no garbage in the actions. */ +__flow_hw_actions_release (dev, hw_acts); +return -rte_errno; } static int flow_hw_register_matcher(struct rte_eth_dev *dev,
@@ -12299,7 +12415,8 @@ static int flow_hw_create_flow(struct rte_eth_dev *dev,if (ret) goto error; - ret =flow_hw_translate_actions (dev, attr, actions, *flow, error); +/* Note: the actions should be saved in the sub-flow rule itself for reference. */ + ret =flow_hw_translate_actions (dev, attr, actions, *flow, &hw_act, external, error);if (ret) goto error;
Signature · 1 line
2.25.1
PATCH v2 8/34 net/mlx5: add default miss action support in nt2hws mode
In reply to Maayan KashaniFrom: Bing Zhao <[email protected]>
The validation will be handled later.
Now it only supports the SEND_TO_KERNEL on non-root tables.
--- drivers/net/mlx5/mlx5_flow_hw.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-)
drivers/net/mlx5/mlx5_flow_hw.c +20 -3
@@ -12129,22 +12129,28 @@ flow_hw_translate_actions(struct rte_eth_dev *dev,enum mlx5_hw_action_flag_type flag_type;bool actions_end = false;uint64_t action_flags =0 ;/* to be used when needed */ +int ret;uint32_t actions_n =0 ;uint32_t mark_id;uint32_t jump_group; +uint32_t src_group =0 ;bool is_mark;struct mlx5_flow_template_table_cfg tbl_cfg;enum mlx5_flow_fate_type fate_type =MLX5_FLOW_FATE_NONE ; +RTE_SET_USED (action_flags); +/* The group in the attribute translation was done in advance. */ + ret =__translate_group (dev, attr, external, attr->group, &src_group, error); +if (ret) +return ret;if (attr->transfer) type =MLX5DR_TABLE_TYPE_FDB ;else if (attr->egress) type =MLX5DR_TABLE_TYPE_NIC_TX ;else type =MLX5DR_TABLE_TYPE_NIC_RX ; -/* The group in the attribute translation was done in advance. */ - flag_type = (attr->group ==0 ) ?MLX5_HW_ACTION_FLAG_ROOT : -MLX5_HW_ACTION_FLAG_NONE_ROOT ; + flag_type = (src_group ==0 ) ?MLX5_HW_ACTION_FLAG_ROOT : +MLX5_HW_ACTION_FLAG_NONE_ROOT ;for (; !actions_end; actions++) {switch (actions->type) {case RTE_FLOW_ACTION_TYPE_VOID :
@@ -12196,6 +12202,17 @@ flow_hw_translate_actions(struct rte_eth_dev *dev, action_flags |=MLX5_FLOW_ACTION_QUEUE ; fate_type =MLX5_FLOW_FATE_QUEUE ;break ; +case RTE_FLOW_ACTION_TYPE_SEND_TO_KERNEL : +if (src_group ==0 ) { +rte_flow_error_set (error,ENOTSUP , +RTE_FLOW_ERROR_TYPE_ACTION ,NULL , +"Send to kernel action on the root table is" +" not supported in HWS mode now." ); + goto clean_up; + } + hw_acts->rule_acts[actions_n++].action = priv->hw_send_to_kernel[type]; + action_flags |=MLX5_FLOW_ACTION_SEND_TO_KERNEL ; +break ;case RTE_FLOW_ACTION_TYPE_END :/* * Using NULL action right now, maybe a new API can be used
Signature · 1 line
2.25.1
PATCH v2 9/34 net/mlx5: add ASO actions support to non-template mode
In reply to Maayan KashaniThis patch adds counter, connection tracking, meter and age actions support to non-template mode.
For CT, counter and meter: if no previous allocation was handled by hw configure routine,
Half of the maximum supported number of objects will be allocated. For AGE action, if no counters were allocated,
allocate half of the maximum,
and then allocate same number of AGE objects.
Also extracted the shared host handling to the configure function. And align all ASO actions to have init function
for future code improvement.
This patch does not affect SW Steering flow engine.
--- drivers/net/mlx5/mlx5.h | 7 ++ drivers/net/mlx5/mlx5_flow_hw.c | 185 +++++++++++++++++++++++++++----- drivers/net/mlx5/mlx5_hws_cnt.c | 47 ++++---- drivers/net/mlx5/mlx5_hws_cnt.h | 10 +- 4 files changed, 190 insertions(+), 59 deletions(-)
drivers/net/mlx5/mlx5.h +7 -0
@@ -792,6 +792,13 @@ struct mlx5_dev_shared_port {/* Only yellow color valid. */ #define MLX5_MTR_POLICY_MODE_OY 3 +/* Max number of meters allocated in non template mode. */ +#define MLX5_MTR_NT_MAX (1 << 23)/*TODO verify number */ +/* Max number of connection tracking allocated in non template mode */ +#define MLX5_CT_NT_MAX (1 << 23)/*TODO verify number */ +/* Max number of counters allocated in non template mode */ +#define MLX5_CNT_MAX (1 << 23)/*TODO verify number */ +enum mlx5_meter_domain {MLX5_MTR_DOMAIN_INGRESS ,MLX5_MTR_DOMAIN_EGRESS ,
drivers/net/mlx5/mlx5_flow_hw.c +157 -28
280 lines not on this page · raw message
drivers/net/mlx5/mlx5_hws_cnt.c +20 -27
115 lines not on this page · raw message
drivers/net/mlx5/mlx5_hws_cnt.h +6 -4
@@ -712,9 +712,10 @@ mlx5_hws_cnt_service_thread_create(struct mlx5_dev_ctx_shared *sh);void mlx5_hws_cnt_service_thread_destroy (struct mlx5_dev_ctx_shared *sh); -struct mlx5_hws_cnt_pool * +int mlx5_hws_cnt_pool_create (struct rte_eth_dev *dev, -const struct rte_flow_port_attr *pattr,uint16_t nb_queue); +uint32_t nb_counters,uint16_t nb_queue, +struct mlx5_hws_cnt_pool *chost); void mlx5_hws_cnt_pool_destroy(struct mlx5_dev_ctx_shared *sh,
@@ -744,8 +745,9 @@ mlx5_hws_age_context_get(struct mlx5_priv *priv, uint32_t idx);int mlx5_hws_age_pool_init (struct rte_eth_dev *dev, -const struct rte_flow_port_attr *attr, -uint16_t nb_queues); +uint32_t nb_aging_objects, +uint16_t nb_queues, +bool strict_queue);void mlx5_hws_age_pool_destroy (struct mlx5_priv *priv);
Signature · 1 line
2.25.1
PATCH v2 10/34 net/mlx5: fix segfault on counter pool destroy
In reply to Maayan KashaniIf the counter pool was not added to list,
and an error state was reached,
on attempt to destroy the counter pool, segmentation fault was received during list remove action.
Added a check to verify the list is not empty before trying to remove the cpool from the list.
Invalid state, leading to segfault,
can also be reached in the following scenario:
1. mlx5_hws_cnt_pool_init() does a zmalloc and initializes most
of the fields of cpool, but does not initialize the next field.
2. mlx5_hws_cnt_pool_dcs_alloc() attempts to bulk allocate flow counters.
If this fails, we skip straight to 4.
In HW, this can fail simply if FW doesn't support bulk flow counter allocation.
3. Right before the goto error, we insert the cpool to the hws_cpool_list.
This is where the next field is initialized.
4. mlx5_hws_cnt_pool_destroy() assumes the cpool's next field
is initialized and SEGVs if not.
So, added a guard against cases where the entry was uninitialized (checking le_prev field is not NULL).
--- drivers/net/mlx5/mlx5_hws_cnt.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/mlx5/mlx5_hws_cnt.c +3 -1
@@ -718,7 +718,9 @@ mlx5_hws_cnt_pool_destroy(struct mlx5_dev_ctx_shared *sh,* Maybe blocked for at most 200ms here. */ rte_spinlock_lock (&sh->cpool_lock); -LIST_REMOVE (cpool, next); +/* Try to remove cpool before it was added to list caused segfault. */ +if (!LIST_EMPTY (&sh->hws_cpool_list) && cpool->next.le_prev) +LIST_REMOVE (cpool, next);rte_spinlock_unlock (&sh->cpool_lock);if (cpool->cfg.host_cpool ==NULL ) {if (--sh->cnt_svc->refcnt ==0 )
Signature · 1 line
2.25.1
PATCH v2 11/34 net/mlx5: abstract action handling and enable reconfigure
In reply to Maayan Kashanireuse HWS actions translation code in order to create the actions for lower layer.
All actions are handled as non masked. Therefore, will be translated in the rule construct phase shared with the template code
and not during the action template translate.
Currently there is no option to reconfigure in template API’s. To support non template API and template API simultaneously, There is a need to enable the user to reconfigure after default configuration was applied by the driver on port start.
Fix flow create ptr
In SWS the return flow pointer is the flow index, in HWS the return flow pointer is the flow data pointer. Currently the return value of non template code did not Enable destroy or quary.
--- drivers/net/mlx5/mlx5.h | 25 +- drivers/net/mlx5/mlx5_flow.c | 31 +- drivers/net/mlx5/mlx5_flow.h | 14 +- drivers/net/mlx5/mlx5_flow_dv.c | 18 +- drivers/net/mlx5/mlx5_flow_hw.c | 811 ++++++++++++++++---------------- 5 files changed, 463 insertions(+), 436 deletions(-)
drivers/net/mlx5/mlx5.h +13 -12
@@ -793,11 +793,11 @@ struct mlx5_dev_shared_port {#define MLX5_MTR_POLICY_MODE_OY 3/* Max number of meters allocated in non template mode. */ -#define MLX5_MTR_NT_MAX (1 << 23)/*TODO verify number */ +#define MLX5_MTR_NT_MAX (1 << 23)/* Max number of connection tracking allocated in non template mode */ -#define MLX5_CT_NT_MAX (1 << 23)/*TODO verify number */ +#define MLX5_CT_NT_MAX (1 << 23)/* Max number of counters allocated in non template mode */ -#define MLX5_CNT_MAX (1 << 23)/*TODO verify number */ +#define MLX5_CNT_MAX (1 << 23)enum mlx5_meter_domain {MLX5_MTR_DOMAIN_INGRESS ,
@@ -1516,7 +1516,6 @@ struct mlx5_dev_ctx_shared {/* Direct Rules tables for FDB, NIC TX+RX */ void *dr_drop_action;/* Pointer to DR drop action, any domain. */ void *pop_vlan_action;/* Pointer to DR pop VLAN action. */ -void *hw_dummy_last;/* Pointer to the DR dummy end action, any domain. */ #if defined(HAVE_IBV_FLOW_DV_SUPPORT ) || !defined(HAVE_INFINIBAND_VERBS_H )struct mlx5_send_to_kernel_action send_to_kernel_action[MLX5DR_TABLE_TYPE_MAX ];#endif
@@ -1797,6 +1796,14 @@ struct mlx5_hw_ctrl_flow {struct mlx5_hw_ctrl_flow_info info; }; +/* HW Steering port configuration passed to rte_flow_configure(). */ +struct mlx5_flow_hw_attr { +struct rte_flow_port_attr port_attr; +uint16_t nb_queue; +struct rte_flow_queue_attr *queue_attr; +bool nt_mode; +}; +/* * Flow rule structure for flow engine mode control, focus on group 0. * Apply to all supported domains.
@@ -1818,12 +1825,6 @@ struct rte_pmd_mlx5_flow_engine_mode_info {/* The list is maintained in insertion order. */ LIST_HEAD(hot_up_info, mlx5_dv_flow_info) hot_upgrade; }; -/* HW Steering port configuration passed to rte_flow_configure(). */ -struct mlx5_flow_hw_attr { -struct rte_flow_port_attr port_attr; -uint16_t nb_queue; -struct rte_flow_queue_attr *queue_attr; -};struct mlx5_flow_hw_ctrl_rx ;
@@ -2301,7 +2302,7 @@ int mlx5_flow_validate(struct rte_eth_dev *dev,const struct rte_flow_item items[], const struct rte_flow_action actions[], struct rte_flow_error *error); -uint32_t +uintptr_t mlx5_flow_list_create(struct rte_eth_dev *dev, enum mlx5_flow_type type, const struct rte_flow_attr *attr, const struct rte_flow_item items[],
@@ -2309,7 +2310,7 @@ mlx5_flow_list_create(struct rte_eth_dev *dev, enum mlx5_flow_type type, bool external, struct rte_flow_error *error);void mlx5_flow_list_destroy (struct rte_eth_dev *dev,enum mlx5_flow_type type, -uint32_t flow_idx); +uintptr_t flow_idx); struct rte_flow *mlx5_flow_create(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, const struct rte_flow_item items[],
drivers/net/mlx5/mlx5_flow.c +14 -17
@@ -4930,7 +4930,7 @@ flow_check_hairpin_split(struct rte_eth_dev *dev,/* Declare flow create/destroy prototype in advance. */ -static uint32_t +static uintptr_t flow_drv_list_create(struct rte_eth_dev *dev, enum mlx5_flow_type type, const struct rte_flow_attr *attr, const struct rte_flow_item items[],
@@ -4939,7 +4939,7 @@ flow_drv_list_create(struct rte_eth_dev *dev, enum mlx5_flow_type type,static void flow_drv_list_destroy (struct rte_eth_dev *dev,enum mlx5_flow_type type, -uint32_t flow_idx); +uintptr_t flow_idx); int flow_dv_mreg_match_cb(void *tool_ctx __rte_unused,
@@ -7243,7 +7243,7 @@ flow_tunnel_from_rule(const struct mlx5_flow *flow)* @return * A flow index on success, 0 otherwise and rte_errno is set. */ -uint32_t +uintptr_t flow_legacy_list_create(struct rte_eth_dev *dev, enum mlx5_flow_type type, const struct rte_flow_attr *attr, const struct rte_flow_item items[],
@@ -7918,7 +7918,7 @@ mlx5_flow_create(struct rte_eth_dev *dev,struct mlx5_priv *priv = dev->data->dev_private;struct rte_flow_attr *new_attr = (void *)(uintptr_t )attr;uint32_t prio = attr->priority; -uint32_t flow_idx; +uintptr_t flow_idx;/* * If the device is not started yet, it is not allowed to created a
@@ -7952,7 +7952,7 @@ mlx5_flow_create(struct rte_eth_dev *dev,return (void *)(uintptr_t )flow_idx; } -uint32_t +uintptr_t mlx5_flow_list_create(struct rte_eth_dev *dev, enum mlx5_flow_type type, const struct rte_flow_attr *attr, const struct rte_flow_item items[],
@@ -7963,7 +7963,7 @@ mlx5_flow_list_create(struct rte_eth_dev *dev, enum mlx5_flow_type type, error); } -uint32_t +uintptr_t flow_drv_list_create(struct rte_eth_dev *dev, enum mlx5_flow_type type, const struct rte_flow_attr *attr, const struct rte_flow_item items[],
@@ -7988,7 +7988,7 @@ flow_drv_list_create(struct rte_eth_dev *dev, enum mlx5_flow_type type,*/ void flow_legacy_list_destroy (struct rte_eth_dev *dev,enum mlx5_flow_type type, -uint32_t flow_idx) +uintptr_t flow_idx) {struct mlx5_priv *priv = dev->data->dev_private;struct rte_flow *flow =mlx5_ipool_get (priv->flows[type], (uint32_t )flow_idx);
@@ -8019,7 +8019,7 @@ flow_legacy_list_destroy(struct rte_eth_dev *dev, enum mlx5_flow_type type,static void flow_drv_list_destroy (struct rte_eth_dev *dev,enum mlx5_flow_type type, -uint32_t flow_idx) +uintptr_t flow_idx) {const struct mlx5_flow_driver_ops *fops;struct rte_flow_attr attr = { .transfer =0 };
@@ -8031,7 +8031,7 @@ flow_drv_list_destroy(struct rte_eth_dev *dev, enum mlx5_flow_type type,void mlx5_flow_list_destroy (struct rte_eth_dev *dev,enum mlx5_flow_type type, -uint32_t flow_idx) +uintptr_t flow_idx) {flow_drv_list_destroy (dev, type, flow_idx); }
@@ -8060,12 +8060,14 @@ mlx5_flow_list_flush(struct rte_eth_dev *dev, enum mlx5_flow_type type,if (priv->sh->config.dv_flow_en ==2 && type ==MLX5_FLOW_TYPE_GEN ) {flow_hw_q_flow_flush (dev,NULL ); -return ; }#endif - MLX5_IPOOL_FOREACH(priv->flows[type], fidx, flow) { -flow_drv_list_destroy (dev, type, fidx); +if (priv->sh->config.dv_flow_en ==2 ) { +flow_drv_list_destroy (dev, type, (uintptr_t )flow); + }else { +flow_drv_list_destroy (dev, type, fidx); + }if (unlikely (mlx5_need_cache_flow (priv,NULL ) && type ==MLX5_FLOW_TYPE_GEN )) { flow_info =LIST_FIRST (&mode_info->hot_upgrade);while (flow_info) {
@@ -8526,11 +8528,6 @@ mlx5_flow_destroy(struct rte_eth_dev *dev,struct rte_pmd_mlx5_flow_engine_mode_info *mode_info = &priv->mode_info;struct mlx5_dv_flow_info *flow_info; -if (priv->sh->config.dv_flow_en ==2 ) -return rte_flow_error_set (error,ENOTSUP , -RTE_FLOW_ERROR_TYPE_UNSPECIFIED , -NULL , -"Flow non-Q destruction not supported" );flow_drv_list_destroy (dev,MLX5_FLOW_TYPE_GEN , (uintptr_t )(void *)flow);if (unlikely (mlx5_need_cache_flow (priv,NULL ))) {
drivers/net/mlx5/mlx5_flow.h +9 -5
@@ -1315,6 +1315,8 @@ struct rte_flow_nt2hws {struct mlx5dr_bwc_rule *nt_rule;/** The matcher for non template api. */ struct mlx5_flow_dv_matcher *matcher; +/**< Auxiliary data stored per flow. */ +struct rte_flow_hw_aux *flow_aux; } __rte_packed;/** HWS flow struct. */
@@ -1349,12 +1351,14 @@ struct rte_flow_hw {struct mlx5_hrxq *hrxq; }; +/** Equals true if it is non template rule. */ +bool nt_rule;/** * Padding for alignment to 56 bytes. * Since mlx5dr rule is 72 bytes, whole flow is contained within 128 B (2 cache lines). * This space is reserved for future additions to flow struct. */ -uint8_t padding[10 ]; +uint8_t padding[9 ];/** HWS layer data struct. */ uint8_t rule[]; } __rte_packed;
@@ -2116,7 +2120,7 @@ int flow_hw_init(struct rte_eth_dev *dev, struct rte_flow_error *error); -typedef uint32_t (*mlx5_flow_list_create_t)(struct rte_eth_dev *dev, +typedef uintptr_t (*mlx5_flow_list_create_t)(struct rte_eth_dev *dev, enum mlx5_flow_type type, const struct rte_flow_attr *attr, const struct rte_flow_item items[],
@@ -2125,7 +2129,7 @@ typedef uint32_t (*mlx5_flow_list_create_t)(struct rte_eth_dev *dev, struct rte_flow_error *error);typedef void (*mlx5_flow_list_destroy_t )(struct rte_eth_dev *dev,enum mlx5_flow_type type, -uint32_t flow_idx); +uintptr_t flow_idx); typedef int (*mlx5_flow_validate_t)(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, const struct rte_flow_item items[],
@@ -3317,13 +3321,13 @@ int mlx5_flow_item_field_width(struct rte_eth_dev *dev, enum rte_flow_field_id field, int inherit, const struct rte_flow_attr *attr, struct rte_flow_error *error); -uint32_t flow_legacy_list_create (struct rte_eth_dev *dev,enum mlx5_flow_type type, +uintptr_t flow_legacy_list_create (struct rte_eth_dev *dev,enum mlx5_flow_type type,const struct rte_flow_attr *attr,const struct rte_flow_item items[],const struct rte_flow_action actions[],bool external,struct rte_flow_error *error);void flow_legacy_list_destroy (struct rte_eth_dev *dev,enum mlx5_flow_type type, -uint32_t flow_idx); +uintptr_t flow_idx); static __rte_always_inline int flow_hw_get_srh_flex_parser_byte_off_from_ctx(void *dr_ctx __rte_unused)
drivers/net/mlx5/mlx5_flow_dv.c +15 -3
@@ -11843,12 +11843,14 @@ flow_matcher_create_cb(void *tool_ctx, void *cb_ctx)struct mlx5_flow_cb_ctx *ctx = cb_ctx;struct mlx5_flow_dv_matcher *ref = ctx->data;struct mlx5_flow_dv_matcher *resource; +#ifdef HAVE_MLX5_HWS_SUPPORT +const struct rte_flow_item *items; +#endif struct mlx5dv_flow_matcher_attr dv_attr = { .type =IBV_FLOW_ATTR_NORMAL , .match_mask = (void *)&ref->mask, }; -struct mlx5_flow_tbl_data_entry *tbl =container_of (ref->tbl, -typeof (*tbl), tbl); +struct mlx5_flow_tbl_data_entry *tbl;int ret; resource = mlx5_malloc(MLX5_MEM_ZERO, sizeof(*resource), 0,
@@ -11859,9 +11861,9 @@ flow_matcher_create_cb(void *tool_ctx, void *cb_ctx) "cannot create matcher");return NULL ; } -/*Consider memcpy(resource, ref, sizeof(*resource));*/ *resource = *ref;if (sh->config.dv_flow_en !=2 ) { + tbl =container_of (ref->tbl,typeof (*tbl), tbl); dv_attr.match_criteria_enable =flow_dv_matcher_enable (resource->mask.buf); __flow_dv_adjust_buf_size(&ref->mask.size,
@@ -11879,6 +11881,16 @@ flow_matcher_create_cb(void *tool_ctx, void *cb_ctx) "cannot create matcher");return NULL ; } + }else { +#ifdef HAVE_MLX5_HWS_SUPPORT + items = *((const struct rte_flow_item **)(ctx->data2)); + resource->matcher_object =mlx5dr_bwc_matcher_create + (resource->group->tbl, resource->priority, items); +if (!(resource->matcher_object)) +return NULL ; +#else +return NULL ; +#endif }return &resource->entry; }
drivers/net/mlx5/mlx5_flow_hw.c +412 -399
1,332 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v2 12/34 common/mlx5: read connection tracking attributes
In reply to Maayan KashaniNeed to read maximum connection tracking
objects from HCA attributes.
--- drivers/common/mlx5/mlx5_devx_cmds.c | 3 +++ drivers/common/mlx5/mlx5_devx_cmds.h | 1 + 2 files changed, 4 insertions(+)
drivers/common/mlx5/mlx5_devx_cmds.c +3 -0
@@ -1170,6 +1170,9 @@ mlx5_devx_cmd_query_hca_attr(void *ctx, (rc &MLX5_CROSS_VHCA_ALLOWED_OBJS_TIR ) && (rc &MLX5_CROSS_VHCA_ALLOWED_OBJS_FT ) && (rc &MLX5_CROSS_VHCA_ALLOWED_OBJS_RTC ); +if (attr->ct_offload) + attr->log_max_conn_track_offload =MLX5_GET (cmd_hca_cap_2, hcattr, + log_max_conn_track_offload); }if (attr->log_min_stride_wqe_sz ==0 ) attr->log_min_stride_wqe_sz =MLX5_MPRQ_LOG_MIN_STRIDE_WQE_SIZE ;
drivers/common/mlx5/mlx5_devx_cmds.h +1 -0
@@ -326,6 +326,7 @@ struct mlx5_hca_attr { uint32_t wqe_based_flow_table_sup:1;uint8_t max_header_modify_pattern_length;uint64_t system_image_guid; + uint32_t log_max_conn_track_offload:5; };/* LAG Context. */
Signature · 1 line
2.25.1
PATCH v2 13/34 net/mlx5: support bulk actions in non template mode
In reply to Maayan KashaniAdd support for encap/decap/modify header action for non template API.
Save 1 action per bulk according to action data. Reuse action if possible.
Store actions same as for SWS today, use same key structure.
--- drivers/net/mlx5/mlx5_flow.h | 44 ++++-- drivers/net/mlx5/mlx5_flow_dv.c | 268 ++++++++++++++++++++------------ drivers/net/mlx5/mlx5_flow_hw.c | 184 ++++++++++++++++++++-- 3 files changed, 368 insertions(+), 128 deletions(-)
drivers/net/mlx5/mlx5_flow.h +32 -12
@@ -666,6 +666,10 @@ struct mlx5_flow_dv_modify_hdr_resource {struct mlx5_list_entry entry;void *action;/**< Modify header action object. */ uint32_t idx; +#ifdef HAVE_MLX5_HWS_SUPPORT +void *mh_dr_pattern;/**< Modify header DR pattern(HWS only). */ +#endif +uint64_t flags;/**< Flags for RDMA API(HWS only). */ /* Key area for hash list matching: */ uint8_t ft_type;/**< Flow table type, Rx or Tx. */ uint8_t actions_num;/**< Number of modification actions. */
@@ -1317,7 +1321,11 @@ struct rte_flow_nt2hws {struct mlx5_flow_dv_matcher *matcher;/**< Auxiliary data stored per flow. */ struct rte_flow_hw_aux *flow_aux; -} __rte_packed; +/** Modify header pointer. */ +struct mlx5_flow_dv_modify_hdr_resource *modify_hdr; +/** Encap/decap index. */ +uint32_t rix_encap_decap; +};/** HWS flow struct. */ struct rte_flow_hw {
@@ -3079,14 +3087,14 @@ struct mlx5_list_entry *flow_dv_tag_clone_cb(void *tool_ctx, void *cb_ctx);void flow_dv_tag_clone_free_cb (void *tool_ctx,struct mlx5_list_entry *entry); -int flow_dv_modify_match_cb (void *tool_ctx,struct mlx5_list_entry *entry, +int flow_modify_match_cb (void *tool_ctx,struct mlx5_list_entry *entry,void *cb_ctx); -struct mlx5_list_entry *flow_dv_modify_create_cb (void *tool_ctx,void *ctx); -void flow_dv_modify_remove_cb (void *tool_ctx,struct mlx5_list_entry *entry); -struct mlx5_list_entry *flow_dv_modify_clone_cb (void *tool_ctx, +struct mlx5_list_entry *flow_modify_create_cb (void *tool_ctx,void *ctx); +void flow_modify_remove_cb (void *tool_ctx,struct mlx5_list_entry *entry); +struct mlx5_list_entry *flow_modify_clone_cb (void *tool_ctx,struct mlx5_list_entry *oentry,void *ctx); -void flow_dv_modify_clone_free_cb (void *tool_ctx, +void flow_modify_clone_free_cb (void *tool_ctx,struct mlx5_list_entry *entry);struct mlx5_list_entry *flow_dv_mreg_create_cb (void *tool_ctx,void *ctx);
@@ -3098,18 +3106,30 @@ struct mlx5_list_entry *flow_dv_mreg_clone_cb(void *tool_ctx, void *ctx);void flow_dv_mreg_clone_free_cb (void *tool_ctx,struct mlx5_list_entry *entry); -int flow_dv_encap_decap_match_cb (void *tool_ctx,struct mlx5_list_entry *entry, +int flow_encap_decap_match_cb (void *tool_ctx,struct mlx5_list_entry *entry,void *cb_ctx); -struct mlx5_list_entry *flow_dv_encap_decap_create_cb (void *tool_ctx, +struct mlx5_list_entry *flow_encap_decap_create_cb (void *tool_ctx,void *cb_ctx); -void flow_dv_encap_decap_remove_cb (void *tool_ctx, +void flow_encap_decap_remove_cb (void *tool_ctx,struct mlx5_list_entry *entry); -struct mlx5_list_entry *flow_dv_encap_decap_clone_cb (void *tool_ctx, +struct mlx5_list_entry *flow_encap_decap_clone_cb (void *tool_ctx,struct mlx5_list_entry *entry,void *cb_ctx); -void flow_dv_encap_decap_clone_free_cb (void *tool_ctx, +void flow_encap_decap_clone_free_cb (void *tool_ctx,struct mlx5_list_entry *entry); - +int __flow_encap_decap_resource_register + (struct rte_eth_dev *dev, +struct mlx5_flow_dv_encap_decap_resource *resource, +bool is_root, +struct mlx5_flow_dv_encap_decap_resource **encap_decap, +struct rte_flow_error *error); +int __flow_modify_hdr_resource_register + (struct rte_eth_dev *dev, +struct mlx5_flow_dv_modify_hdr_resource *resource, +struct mlx5_flow_dv_modify_hdr_resource **modify, +struct rte_flow_error *error); +int flow_encap_decap_resource_release (struct rte_eth_dev *dev, +uint32_t encap_decap_idx);int flow_matcher_match_cb (void *tool_ctx,struct mlx5_list_entry *entry,void *ctx);struct mlx5_list_entry *flow_matcher_create_cb (void *tool_ctx,void *ctx);
drivers/net/mlx5/mlx5_flow_dv.c +165 -103
459 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_hw.c +171 -13
299 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v2 14/34 net/mlx5: use non const max number for ASO actions
In reply to Maayan KashaniFor ASO max allocations in non-template mode,
Read FW capabilities instead of using consts.
--- drivers/net/mlx5/mlx5.h | 17 ++++++++++++----- drivers/net/mlx5/mlx5_flow_hw.c | 13 +++++++++---- drivers/net/mlx5/mlx5_flow_meter.c | 25 +++++++++++++++++++++---- 3 files changed, 42 insertions(+), 13 deletions(-)
drivers/net/mlx5/mlx5.h +12 -5
@@ -792,12 +792,18 @@ struct mlx5_dev_shared_port {/* Only yellow color valid. */ #define MLX5_MTR_POLICY_MODE_OY 3 +/* Max number of meters. */ +#define MLX5_MTR_MAX (priv) (mlx5_flow_mtr_max_get(priv))/* Max number of meters allocated in non template mode. */ -#define MLX5_MTR_NT_MAX (1 << 23) -/* Max number of connection tracking allocated in non template mode */ -#define MLX5_CT_NT_MAX (1 << 23) -/* Max number of counters allocated in non template mode */ -#define MLX5_CNT_MAX (1 << 23) +#define MLX5_MTR_NT_MAX (priv) (MLX5_MTR_MAX(priv) >> 1) +/* Max number of connection tracking. */ +#define MLX5_CT_MAX (priv) (1 << (priv)->sh->cdev->config.hca_attr.log_max_conn_track_offload) +/* Max number of connection tracking allocated in non template mode. */ +#define MLX5_CT_NT_MAX (priv) (MLX5_CT_MAX(priv) >> 1) +/* Max number of counters. */ +#define MLX5_CNT_MAX (priv) ((priv)->sh->hws_max_nb_counters) +/* Max number of counters allocated in non template mode. */ +#define MLX5_CNT_NT_MAX (priv) (MLX5_CNT_MAX(priv) >> 1)enum mlx5_meter_domain {MLX5_MTR_DOMAIN_INGRESS ,
@@ -2423,6 +2429,7 @@ mlx5_flow_meter_hierarchy_get_final_policy(struct rte_eth_dev *dev,int mlx5_flow_meter_flush (struct rte_eth_dev *dev,struct rte_mtr_error *error);void mlx5_flow_meter_rxq_flush (struct rte_eth_dev *dev); +uint32_t mlx5_flow_mtr_max_get (struct mlx5_priv *priv);/* mlx5_os.c */
drivers/net/mlx5/mlx5_flow_hw.c +9 -4
@@ -12522,6 +12522,7 @@ static int flow_hw_ensure_action_pools_allocated(struct rte_eth_dev *dev,bool actions_end = false;struct mlx5_priv *priv = dev->data->dev_private;int ret; +uint obj_num;for (; !actions_end; actions++) {switch ((int )actions->type) {
@@ -12530,7 +12531,8 @@ static int flow_hw_ensure_action_pools_allocated(struct rte_eth_dev *dev,if (!priv->hws_age_req) {/* If no counters were previously allocated. */ if (!priv->hws_cpool) { - ret =mlx5_hws_cnt_pool_create (dev,MLX5_CNT_MAX , + obj_num =MLX5_CNT_NT_MAX (priv); + ret =mlx5_hws_cnt_pool_create (dev, obj_num, priv->nb_queue,NULL );if (ret) goto err;
@@ -12548,7 +12550,8 @@ static int flow_hw_ensure_action_pools_allocated(struct rte_eth_dev *dev,case RTE_FLOW_ACTION_TYPE_COUNT :/* If no counters were previously allocated. */ if (!priv->hws_cpool) { - ret =mlx5_hws_cnt_pool_create (dev,MLX5_CNT_MAX , + obj_num =MLX5_CNT_NT_MAX (priv); + ret =mlx5_hws_cnt_pool_create (dev, obj_num, priv->nb_queue,NULL );if (ret) goto err;
@@ -12557,7 +12560,8 @@ static int flow_hw_ensure_action_pools_allocated(struct rte_eth_dev *dev,case RTE_FLOW_ACTION_TYPE_CONNTRACK :/* If no CT were previously allocated. */ if (!priv->hws_ctpool) { - ret =mlx5_flow_ct_init (dev,MLX5_CT_NT_MAX , priv->nb_queue); + obj_num =MLX5_CT_NT_MAX (priv); + ret =mlx5_flow_ct_init (dev, obj_num, priv->nb_queue);if (ret) goto err; }
@@ -12565,7 +12569,8 @@ static int flow_hw_ensure_action_pools_allocated(struct rte_eth_dev *dev,case RTE_FLOW_ACTION_TYPE_METER_MARK :/* If no meters were previously allocated. */ if (!priv->hws_mpool) { - ret =mlx5_flow_meter_init (dev,MLX5_MTR_NT_MAX ,0 ,0 , + obj_num =MLX5_MTR_NT_MAX (priv); + ret =mlx5_flow_meter_init (dev, obj_num,0 ,0 , priv->nb_queue);if (ret) goto err;
drivers/net/mlx5/mlx5_flow_meter.c +21 -4
@@ -704,6 +704,26 @@ mlx5_flow_meter_param_fill(struct mlx5_flow_meter_profile *fmp,return 0 ; } +/** +* Callback to get MTR maximum objects number. +* +* @param[in] priv +* Pointer to Ethernet device. +* +* @return +* Max number of meters. +*/ +uint32_t +mlx5_flow_mtr_max_get (struct mlx5_priv *priv) +{ +struct mlx5_hca_qos_attr *qattr = &priv->sh->cdev->config.hca_attr.qos; + +/* Max number of meters. */ +return ((priv->sh->meter_aso_en) ? +1 << (qattr->log_max_num_meter_aso +1 ) : + qattr->log_max_flow_meter); +} +/** * Callback to get MTR capabilities. *
@@ -730,14 +750,11 @@ mlx5_flow_mtr_cap_get(struct rte_eth_dev *dev,RTE_MTR_ERROR_TYPE_UNSPECIFIED ,NULL , "Meter is not supported");memset (cap,0 ,sizeof (*cap)); + cap->n_max =mlx5_flow_mtr_max_get (priv);if (priv->sh->meter_aso_en) { -/* 2 meters per one ASO cache line. */ - cap->n_max =1 << (qattr->log_max_num_meter_aso +1 ); cap->srtcm_rfc2697_packet_mode_supported =1 ; cap->trtcm_rfc2698_packet_mode_supported =1 ; cap->trtcm_rfc4115_packet_mode_supported =1 ; - }else { - cap->n_max =1 << qattr->log_max_flow_meter; } cap->srtcm_rfc2697_byte_mode_supported =1 ; cap->trtcm_rfc2698_byte_mode_supported =1 ;
Signature · 1 line
2.25.1
PATCH v2 15/34 net/mlx5: initial design changes
In reply to Maayan KashaniChange flow_drv_list_create/destroy to mlx5_flow_list_create/destroy. Remove resource release function inlining.
Check number of queues in template mode in hw configure function. Use user priority to calculate matcher priority.
--- drivers/net/mlx5/mlx5_flow.c | 70 +++++++--------------- drivers/net/mlx5/mlx5_flow_hw.c | 100 +++++++++++++++----------------- 2 files changed, 68 insertions(+), 102 deletions(-)
drivers/net/mlx5/mlx5_flow.c +20 -50
@@ -4928,19 +4928,6 @@ flow_check_hairpin_split(struct rte_eth_dev *dev,return 0 ; } -/* Declare flow create/destroy prototype in advance. */ - -static uintptr_t -flow_drv_list_create (struct rte_eth_dev *dev,enum mlx5_flow_type type, -const struct rte_flow_attr *attr, -const struct rte_flow_item items[], -const struct rte_flow_action actions[], -bool external,struct rte_flow_error *error); - -static void -flow_drv_list_destroy (struct rte_eth_dev *dev,enum mlx5_flow_type type, -uintptr_t flow_idx); -int flow_dv_mreg_match_cb(void *tool_ctx __rte_unused,struct mlx5_list_entry *entry,void *cb_ctx)
@@ -5059,7 +5046,7 @@ flow_dv_mreg_create_cb(void *tool_ctx, void *cb_ctx)* be applied, removed, deleted in arbitrary order * by list traversing. */ - mcp_res->rix_flow =flow_drv_list_create (dev,MLX5_FLOW_TYPE_MCP , + mcp_res->rix_flow =mlx5_flow_list_create (dev,MLX5_FLOW_TYPE_MCP , &attr, items, actions, false, error);if (!mcp_res->rix_flow) {mlx5_ipool_free (priv->sh->ipool[MLX5_IPOOL_MCP ], idx);
@@ -5153,7 +5140,7 @@ flow_dv_mreg_remove_cb(void *tool_ctx, struct mlx5_list_entry *entry)struct mlx5_priv *priv = dev->data->dev_private;MLX5_ASSERT (mcp_res->rix_flow); -flow_drv_list_destroy (dev,MLX5_FLOW_TYPE_MCP , mcp_res->rix_flow); +mlx5_flow_list_destroy (dev,MLX5_FLOW_TYPE_MCP , mcp_res->rix_flow);mlx5_ipool_free (priv->sh->ipool[MLX5_IPOOL_MCP ], mcp_res->idx); }
@@ -7540,7 +7527,7 @@ mlx5_flow_create_esw_table_zero_flow(struct rte_eth_dev *dev) };struct rte_flow_error error; -return (void *)(uintptr_t )flow_drv_list_create (dev,MLX5_FLOW_TYPE_CTL , +return (void *)(uintptr_t )mlx5_flow_list_create (dev,MLX5_FLOW_TYPE_CTL , &attr, &pattern, actions, false, &error); }
@@ -7608,14 +7595,14 @@ mlx5_flow_create_devx_sq_miss_flow(struct rte_eth_dev *dev, uint32_t sq_num)* Creates group 0, highest priority jump flow. * Matches txq to bypass kernel packets. */ -if (flow_drv_list_create (dev,MLX5_FLOW_TYPE_CTL , &attr, pattern, actions, +if (mlx5_flow_list_create (dev,MLX5_FLOW_TYPE_CTL , &attr, pattern, actions, false, &error) ==0 )return 0 ;/* Create group 1, lowest priority redirect flow for txq. */ attr.group =1 ; actions[0 ].conf = &port; actions[0 ].type =RTE_FLOW_ACTION_TYPE_PORT_ID ; -return flow_drv_list_create (dev,MLX5_FLOW_TYPE_CTL , &attr, pattern, +return mlx5_flow_list_create (dev,MLX5_FLOW_TYPE_CTL , &attr, pattern, actions, false, &error); }
@@ -7771,7 +7758,7 @@ mlx5_flow_cache_flow_toggle(struct rte_eth_dev *dev, bool orig_prio) flow_info->flow_idx_low_prio);if (high && low) {RTE_SWAP (*low, *high); -flow_drv_list_destroy (dev,MLX5_FLOW_TYPE_GEN , +mlx5_flow_list_destroy (dev,MLX5_FLOW_TYPE_GEN , flow_info->flow_idx_low_prio); flow_info->flow_idx_high_prio =0 ; }
@@ -7785,7 +7772,7 @@ mlx5_flow_cache_flow_toggle(struct rte_eth_dev *dev, bool orig_prio)while (flow_info) {if (flow_info->orig_prio != flow_info->attr.priority) {if (flow_info->flow_idx_high_prio) -flow_drv_list_destroy (dev,MLX5_FLOW_TYPE_GEN , +mlx5_flow_list_destroy (dev,MLX5_FLOW_TYPE_GEN , flow_info->flow_idx_high_prio);else break ;
@@ -7940,12 +7927,13 @@ mlx5_flow_create(struct rte_eth_dev *dev, RTE_PMD_MLX5_FLOW_ENGINE_FLAG_STANDBY_DUP_INGRESS))) new_attr->priority += 1; } - flow_idx =flow_drv_list_create (dev,MLX5_FLOW_TYPE_GEN , attr, items, actions, true, error); + flow_idx =mlx5_flow_list_create (dev,MLX5_FLOW_TYPE_GEN , attr, items, actions, + true, error);if (!flow_idx)return NULL ;if (unlikely (mlx5_need_cache_flow (priv, attr))) {if (mlx5_flow_cache_flow_info (dev, attr, prio, items, actions, flow_idx)) { -flow_drv_list_destroy (dev,MLX5_FLOW_TYPE_GEN , flow_idx); +mlx5_flow_list_destroy (dev,MLX5_FLOW_TYPE_GEN , flow_idx); flow_idx =0 ; } }
@@ -7958,17 +7946,6 @@ mlx5_flow_list_create(struct rte_eth_dev *dev, enum mlx5_flow_type type,const struct rte_flow_item items[], const struct rte_flow_action actions[], bool external, struct rte_flow_error *error) -{ - return flow_drv_list_create(dev, type, attr, items, actions, external, -error ); -} - -uintptr_t -flow_drv_list_create (struct rte_eth_dev *dev,enum mlx5_flow_type type, -const struct rte_flow_attr *attr, -const struct rte_flow_item items[], -const struct rte_flow_action actions[], -bool external,struct rte_flow_error *error) { const struct mlx5_flow_driver_ops *fops;enum mlx5_flow_drv_type drv_type =flow_get_drv_type (dev, attr);
@@ -8017,8 +7994,8 @@ flow_legacy_list_destroy(struct rte_eth_dev *dev, enum mlx5_flow_type type,mlx5_ipool_free (priv->flows[type], flow_idx); } -static void -flow_drv_list_destroy (struct rte_eth_dev *dev,enum mlx5_flow_type type, +void +mlx5_flow_list_destroy (struct rte_eth_dev *dev,enum mlx5_flow_type type,uintptr_t flow_idx) {const struct mlx5_flow_driver_ops *fops;
@@ -8029,13 +8006,6 @@ flow_drv_list_destroy(struct rte_eth_dev *dev, enum mlx5_flow_type type, fops->list_destroy (dev, type, flow_idx); } -void -mlx5_flow_list_destroy (struct rte_eth_dev *dev,enum mlx5_flow_type type, -uintptr_t flow_idx) -{ -flow_drv_list_destroy (dev, type, flow_idx); -} -/** * Destroy all flows. *
@@ -8064,9 +8034,9 @@ mlx5_flow_list_flush(struct rte_eth_dev *dev, enum mlx5_flow_type type,#endif MLX5_IPOOL_FOREACH(priv->flows[type], fidx, flow) {if (priv->sh->config.dv_flow_en ==2 ) { -flow_drv_list_destroy (dev, type, (uintptr_t )flow); +mlx5_flow_list_destroy (dev, type, (uintptr_t )flow); }else { -flow_drv_list_destroy (dev, type, fidx); +mlx5_flow_list_destroy (dev, type, fidx); }if (unlikely (mlx5_need_cache_flow (priv,NULL ) && type ==MLX5_FLOW_TYPE_GEN )) { flow_info =LIST_FIRST (&mode_info->hot_upgrade);
@@ -8339,7 +8309,7 @@ mlx5_ctrl_flow_source_queue(struct rte_eth_dev *dev, actions[0 ].type =RTE_FLOW_ACTION_TYPE_JUMP ; actions[0 ].conf = &jump; actions[1 ].type =RTE_FLOW_ACTION_TYPE_END ; - flow_idx =flow_drv_list_create (dev,MLX5_FLOW_TYPE_CTL , + flow_idx =mlx5_flow_list_create (dev,MLX5_FLOW_TYPE_CTL , &attr, items, actions, false, &error);if (!flow_idx) { DRV_LOG(DEBUG,
@@ -8429,7 +8399,7 @@ mlx5_ctrl_flow_vlan(struct rte_eth_dev *dev, action_rss.types =0 ;for (i =0 ; i != priv->reta_idx_n; ++i) queue[i] = (*priv->reta_idx)[i]; - flow_idx =flow_drv_list_create (dev,MLX5_FLOW_TYPE_CTL , + flow_idx =mlx5_flow_list_create (dev,MLX5_FLOW_TYPE_CTL , &attr, items, actions, false, &error);if (!flow_idx)return -rte_errno;
@@ -8504,7 +8474,7 @@ mlx5_flow_lacp_miss(struct rte_eth_dev *dev) }, };struct rte_flow_error error; -uint32_t flow_idx =flow_drv_list_create (dev,MLX5_FLOW_TYPE_CTL , +uint32_t flow_idx =mlx5_flow_list_create (dev,MLX5_FLOW_TYPE_CTL , &attr, items, actions, false, &error);
@@ -8528,7 +8498,7 @@ mlx5_flow_destroy(struct rte_eth_dev *dev,struct rte_pmd_mlx5_flow_engine_mode_info *mode_info = &priv->mode_info;struct mlx5_dv_flow_info *flow_info; -flow_drv_list_destroy (dev,MLX5_FLOW_TYPE_GEN , +mlx5_flow_list_destroy (dev,MLX5_FLOW_TYPE_GEN , (uintptr_t )(void *)flow);if (unlikely (mlx5_need_cache_flow (priv,NULL ))) { flow_info =LIST_FIRST (&mode_info->hot_upgrade);
@@ -9840,14 +9810,14 @@ mlx5_flow_discover_mreg_c(struct rte_eth_dev *dev)if (!priv->sh->config.dv_flow_en)break ;/* Create internal flow, validation skips copy action. */ - flow_idx =flow_drv_list_create (dev,MLX5_FLOW_TYPE_GEN , &attr, + flow_idx =mlx5_flow_list_create (dev,MLX5_FLOW_TYPE_GEN , &attr, items, actions, false, &error); flow =mlx5_ipool_get (priv->flows[MLX5_FLOW_TYPE_GEN ], flow_idx);if (!flow)continue ; priv->sh->flow_mreg_c[n++] = idx; -flow_drv_list_destroy (dev,MLX5_FLOW_TYPE_GEN , flow_idx); +mlx5_flow_list_destroy (dev,MLX5_FLOW_TYPE_GEN , flow_idx); }for (; n <MLX5_MREG_C_NUM ; ++n) priv->sh->flow_mreg_c[n] =REG_NON ;
drivers/net/mlx5/mlx5_flow_hw.c +48 -52
190 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v3 1/11 net/mlx5: initial design of non template to hws
In reply to Maayan KashaniImplement the frame and needed building
blocks for non template to hws API's.
Added validate, list_create and list_destroy to mlx5_flow_hw_drv_ops. Rename old list_create/list_destroy functions to legacy_* and added a call from verbs/dv ops to the legacy functions.
Updated rte_flow_hw as needed.
Added rte_flow_nt2hws structure for non-template rule data.
squash to net/mlx5: initial design of non template to hws
--- drivers/net/mlx5/linux/mlx5_os.c | 8 +- drivers/net/mlx5/mlx5.h | 9 + drivers/net/mlx5/mlx5_flow.c | 139 +++++--- drivers/net/mlx5/mlx5_flow.h | 74 ++++- drivers/net/mlx5/mlx5_flow_dv.c | 192 +++++++++--- drivers/net/mlx5/mlx5_flow_hw.c | 487 +++++++++++++++++++++++++++-- drivers/net/mlx5/mlx5_flow_verbs.c | 2 + drivers/net/mlx5/mlx5_trigger.c | 6 + drivers/net/mlx5/windows/mlx5_os.c | 8 +- 9 files changed, 808 insertions(+), 117 deletions(-)
drivers/net/mlx5/linux/mlx5_os.c +7 -1
@@ -69,7 +69,7 @@ static rte_spinlock_t mlx5_shared_data_lock = RTE_SPINLOCK_INITIALIZER;static struct mlx5_local_data mlx5_local_data;/* rte flow indexed pool configuration. */ -static struct mlx5_indexed_pool_config icfg[] = { +static const struct mlx5_indexed_pool_config default_icfg[] = { { .size =sizeof (struct rte_flow ), .trunk_size =64 ,
@@ -1068,7 +1068,9 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,struct mlx5_port_info vport_info = { .query_flags =0 };int nl_rdma;int i; +struct mlx5_indexed_pool_config icfg[RTE_DIM (default_icfg)]; +memcpy (icfg, default_icfg,sizeof (icfg));/* Determine if this port representor is supposed to be spawned. */ if (switch_info->representor && dpdk_dev->devargs && !mlx5_representor_match (spawn, eth_da))
@@ -1539,6 +1541,10 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, icfg[i].release_mem_en = !!sh->config.reclaim_mode;if (sh->config.reclaim_mode) icfg[i].per_core_cache =0 ; +#ifdef HAVE_MLX5_HWS_SUPPORT +if (priv->sh->config.dv_flow_en ==2 ) + icfg[i].size =sizeof (struct rte_flow_hw ) +sizeof (struct rte_flow_nt2hws ); +#endif priv->flows[i] =mlx5_ipool_create (&icfg[i]);if (!priv->flows[i]) goto error;
drivers/net/mlx5/mlx5.h +9 -0
@@ -2293,6 +2293,15 @@ int mlx5_flow_validate(struct rte_eth_dev *dev,const struct rte_flow_item items[], const struct rte_flow_action actions[], struct rte_flow_error *error); +uint32_t +mlx5_flow_list_create (struct rte_eth_dev *dev,enum mlx5_flow_type type, +const struct rte_flow_attr *attr, +const struct rte_flow_item items[], +const struct rte_flow_action actions[], +bool external,struct rte_flow_error *error); +void +mlx5_flow_list_destroy (struct rte_eth_dev *dev,enum mlx5_flow_type type, +uint32_t flow_idx); struct rte_flow *mlx5_flow_create(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, const struct rte_flow_item items[],
drivers/net/mlx5/mlx5_flow.c +96 -43
311 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow.h +65 -9
131 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_dv.c +157 -35
316 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_hw.c +459 -28
568 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_verbs.c +2 -0
@@ -2183,6 +2183,8 @@ flow_verbs_sync_domain(struct rte_eth_dev *dev, uint32_t domains, }const struct mlx5_flow_driver_ops mlx5_flow_verbs_drv_ops = { + .list_create = flow_legacy_list_create, + .list_destroy = flow_legacy_list_destroy, .validate = flow_verbs_validate, .prepare = flow_verbs_prepare, .translate = flow_verbs_translate,
drivers/net/mlx5/mlx5_trigger.c +6 -0
@@ -1158,6 +1158,12 @@ mlx5_dev_start(struct rte_eth_dev *dev)DRV_LOG (DEBUG ,"port %u starting device" , dev->data->port_id);#ifdef HAVE_MLX5_HWS_SUPPORT if (priv->sh->config.dv_flow_en ==2 ) { +/*If previous configuration does not exist. */ +if (!(priv->dr_ctx)) { + ret =flow_hw_init (dev,NULL ); +if (ret) +return ret; + }/* If there is no E-Switch, then there are no start/stop order limitations. */ if (!priv->sh->config.dv_esw_en) goto continue_dev_start;
drivers/net/mlx5/windows/mlx5_os.c +7 -1
@@ -35,7 +35,7 @@ static const char *MZ_MLX5_PMD_SHARED_DATA = "mlx5_pmd_shared_data";static rte_spinlock_t mlx5_shared_data_lock =RTE_SPINLOCK_INITIALIZER ;/* rte flow indexed pool configuration. */ -static struct mlx5_indexed_pool_config icfg[] = { +static const struct mlx5_indexed_pool_config default_icfg[] = { { .size =sizeof (struct rte_flow ), .trunk_size =64 ,
@@ -352,7 +352,9 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,int own_domain_id =0 ;uint16_t port_id;int i; +struct mlx5_indexed_pool_config icfg[RTE_DIM (default_icfg)]; +memcpy (icfg, default_icfg,sizeof (icfg));/* Build device name. */ strlcpy (name, dpdk_dev->name,sizeof (name));/* check if the device is already spawned */
@@ -538,6 +540,10 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, icfg[i].release_mem_en = !!sh->config.reclaim_mode;if (sh->config.reclaim_mode) icfg[i].per_core_cache =0 ; +#ifdef HAVE_MLX5_HWS_SUPPORT +if (priv->sh->config.dv_flow_en ==2 ) + icfg[i].size =sizeof (struct rte_flow_hw ) +sizeof (struct rte_flow_nt2hws ); +#endif priv->flows[i] =mlx5_ipool_create (&icfg[i]);if (!priv->flows[i]) goto error;
Signature · 1 line
2.25.1
PATCH v3 2/11 net/mlx5: add dummy last action
From: Bing Zhao <[email protected]>
The RTE_FLOW_ACTION_TYPE_END action needs to be translated into the MLX5DR_ACTION_TYP_LAST for the future usage. It is only needed in the hardware steering backward compatible API.
--- drivers/net/mlx5/mlx5.h | 1 + drivers/net/mlx5/mlx5_flow_hw.c | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+)
drivers/net/mlx5/mlx5.h +1 -0
@@ -1509,6 +1509,7 @@ struct mlx5_dev_ctx_shared {/* Direct Rules tables for FDB, NIC TX+RX */ void *dr_drop_action;/* Pointer to DR drop action, any domain. */ void *pop_vlan_action;/* Pointer to DR pop VLAN action. */ +void *hw_dummy_last;/* Pointer to the DR dummy end action, any domain. */ #if defined(HAVE_IBV_FLOW_DV_SUPPORT ) || !defined(HAVE_INFINIBAND_VERBS_H )struct mlx5_send_to_kernel_action send_to_kernel_action[MLX5DR_TABLE_TYPE_MAX ];#endif
drivers/net/mlx5/mlx5_flow_hw.c +19 -0
@@ -10639,6 +10639,17 @@ flow_hw_configure(struct rte_eth_dev *dev,if (ret) goto err; } +/* +* All domains will use the same dummy action, only used in the backward +* compatible API. Initialize it for only once. No order dependency. +*/ +if (!priv->sh->hw_dummy_last) { + priv->sh->hw_dummy_last =mlx5dr_action_create_last (priv->dr_ctx, +MLX5DR_ACTION_FLAG_HWS_RX ); +if (!priv->sh->hw_dummy_last) +/* Do not overwrite the rte_errno. */ + goto err; + }if (!priv->shared_host)flow_hw_create_send_to_kernel_actions (priv);if (port_attr->nb_conn_tracks || (host_priv && host_priv->hws_ctpool)) {
@@ -10717,6 +10728,10 @@ flow_hw_configure(struct rte_eth_dev *dev,flow_hw_ct_mng_destroy (dev, priv->ct_mng); priv->ct_mng =NULL ; } +if (priv->sh->hw_dummy_last) { +mlx5dr_action_destroy (priv->sh->hw_dummy_last); + priv->sh->hw_dummy_last =NULL ; + }flow_hw_destroy_send_to_kernel_action (priv);flow_hw_cleanup_ctrl_fdb_tables (dev);flow_hw_free_vport_actions (priv);
@@ -10832,6 +10847,10 @@ flow_hw_resource_release(struct rte_eth_dev *dev)mlx5dr_action_destroy (priv->hw_def_miss);flow_hw_destroy_nat64_actions (priv);flow_hw_destroy_vlan (dev); +if (priv->sh->hw_dummy_last) { +mlx5dr_action_destroy (priv->sh->hw_dummy_last); + priv->sh->hw_dummy_last =NULL ; + }flow_hw_destroy_send_to_kernel_action (priv);flow_hw_free_vport_actions (priv);if (priv->acts_ipool) {
Signature · 1 line
2.25.1
PATCH v3 3/11 net/mlx5: add basic actions support for non-template API
In reply to Maayan KashaniFrom: Bing Zhao <[email protected]>
Support JUMP / DROP / QUEUE / MARK / FLAG now.
--- drivers/net/mlx5/mlx5_flow_hw.c | 153 ++++++++++++++++++++++++++++---- 1 file changed, 135 insertions(+), 18 deletions(-)
drivers/net/mlx5/mlx5_flow_hw.c +135 -18
@@ -604,8 +604,7 @@ flow_hw_jump_release(struct rte_eth_dev *dev, struct mlx5_hw_jump_action *jump)struct mlx5_priv *priv = dev->data->dev_private;struct mlx5_flow_group *grp; - grp =container_of - (jump, struct mlx5_flow_group, jump); + grp = container_of(jump, struct mlx5_flow_group, jump);mlx5_hlist_unregister (priv->sh->flow_tbls, &grp->entry); }
@@ -705,17 +704,9 @@ flow_hw_template_destroy_mhdr_action(struct mlx5_hw_modify_header_action *mhdr)* Pointer to the template HW steering DR actions. */ static void -__flow_hw_action_template_destroy (struct rte_eth_dev *dev, -struct mlx5_hw_actions *acts) +__flow_hw_actions_release (struct rte_eth_dev *dev,struct mlx5_hw_actions *acts) {struct mlx5_priv *priv = dev->data->dev_private; -struct mlx5_action_construct_data *data; - -while (!LIST_EMPTY (&acts->act_list)) { - data =LIST_FIRST (&acts->act_list); -LIST_REMOVE (data, next); -mlx5_ipool_free (priv->acts_ipool, data->idx); - }if (acts->mark) if (!(rte_atomic_fetch_sub_explicit(&priv->hws_mark_refcnt, 1,
@@ -760,6 +751,32 @@ __flow_hw_action_template_destroy(struct rte_eth_dev *dev, } } +/** +* Destroy DR actions created by action template. +* +* For DR actions created during table creation's action translate. +* Need to destroy the DR action when destroying the table. +* +* @param[in] dev +* Pointer to the rte_eth_dev structure. +* @param[in] acts +* Pointer to the template HW steering DR actions. +*/ +static void +__flow_hw_action_template_destroy (struct rte_eth_dev *dev,struct mlx5_hw_actions *acts) +{ +struct mlx5_priv *priv = dev->data->dev_private; +struct mlx5_action_construct_data *data; + +while (!LIST_EMPTY (&acts->act_list)) { + data =LIST_FIRST (&acts->act_list); +LIST_REMOVE (data, next); +mlx5_ipool_free (priv->acts_ipool, data->idx); + } + +__flow_hw_actions_release (dev, acts); +} +/** * Append dynamic action to the dynamic action list. *
@@ -12098,14 +12115,113 @@ static int flow_hw_prepare(struct rte_eth_dev *dev,return 0 ; } -static int flow_hw_translate_actions(struct rte_eth_dev *dev __rte_unused, - const struct rte_flow_attr *attr __rte_unused, - const struct rte_flow_action actions[] __rte_unused, - struct rte_flow_hw *flow __rte_unused, - struct rte_flow_error *error __rte_unused) +static int +flow_hw_translate_actions (struct rte_eth_dev *dev, +const struct rte_flow_attr *attr, +const struct rte_flow_action actions[], +struct rte_flow_hw *flow, +struct mlx5_hw_actions *hw_acts, +bool external, +struct rte_flow_error *error) { -/* TODO implement */ +struct mlx5_priv *priv = dev->data->dev_private; +enum mlx5dr_table_type type; +enum mlx5_hw_action_flag_type flag_type; +bool actions_end = false; +uint64_t action_flags =0 ;/* to be used when needed */ +uint32_t actions_n =0 ; +uint32_t mark_id; +uint32_t jump_group; +bool is_mark; +struct mlx5_flow_template_table_cfg tbl_cfg; +enum mlx5_flow_fate_type fate_type =MLX5_FLOW_FATE_NONE ; + +if (attr->transfer) + type =MLX5DR_TABLE_TYPE_FDB ; +else if (attr->egress) + type =MLX5DR_TABLE_TYPE_NIC_TX ; +else + type =MLX5DR_TABLE_TYPE_NIC_RX ; +/* The group in the attribute translation was done in advance. */ + flag_type = (attr->group ==0 ) ?MLX5_HW_ACTION_FLAG_ROOT : +MLX5_HW_ACTION_FLAG_NONE_ROOT ; +for (; !actions_end; actions++) { +switch (actions->type) { +case RTE_FLOW_ACTION_TYPE_VOID : +break ; +case RTE_FLOW_ACTION_TYPE_DROP : + hw_acts->rule_acts[actions_n++].action = priv->hw_drop[flag_type]; + fate_type =MLX5_FLOW_FATE_DROP ; +break ; +case RTE_FLOW_ACTION_TYPE_FLAG : +case RTE_FLOW_ACTION_TYPE_MARK : + is_mark = actions->type ==RTE_FLOW_ACTION_TYPE_MARK ; + mark_id = is_mark ? + ((const struct rte_flow_action_mark *)(actions->conf))->id : +MLX5_FLOW_MARK_DEFAULT ; + hw_acts->rule_acts[actions_n].tag.value =mlx5_flow_mark_set (mark_id); + hw_acts->rule_acts[actions_n].action = priv->hw_tag[flag_type]; + actions_n++; + action_flags |= is_mark ?MLX5_FLOW_ACTION_MARK :MLX5_FLOW_ACTION_FLAG ; + hw_acts->mark = true; +rte_atomic_fetch_add_explicit (&priv->hws_mark_refcnt,1 , + rte_memory_order_relaxed); +flow_hw_rxq_flag_set (dev, true); +break ; +case RTE_FLOW_ACTION_TYPE_JUMP : + jump_group = ((const struct rte_flow_action_jump *)actions->conf)->group; + tbl_cfg.attr.flow_attr = *attr; + tbl_cfg.external = external; +/* The flow_hw_jump_action_register() can be refactored. */ + hw_acts->jump =flow_hw_jump_action_register (dev, &tbl_cfg, + jump_group, error); +if (hw_acts->jump ==NULL ) + goto clean_up; + hw_acts->rule_acts[actions_n++].action = + (flag_type ==MLX5_HW_ACTION_FLAG_NONE_ROOT ) ? + hw_acts->jump->hws_action : hw_acts->jump->root_action; + action_flags |=MLX5_FLOW_ACTION_JUMP ; + fate_type =MLX5_FLOW_FATE_JUMP ; +break ; +case RTE_FLOW_ACTION_TYPE_QUEUE : +/* Right now, only Rx supports the TIR, validation is needed. */ + hw_acts->tir =flow_hw_tir_action_register (dev, + mlx5_hw_act_flag[flag_type][type], actions); +if (hw_acts->tir ==NULL ) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION ,NULL , +"Failed to translate queue." ); + goto clean_up; + } + action_flags |=MLX5_FLOW_ACTION_QUEUE ; + fate_type =MLX5_FLOW_FATE_QUEUE ; +break ; +case RTE_FLOW_ACTION_TYPE_END : +/* +* Using NULL action right now, maybe a new API can be used +* to create a dummy action with type MLX5DR_ACTION_TYP_LAST. +*/ + hw_acts->rule_acts[actions_n++].action = priv->sh->hw_dummy_last; + actions_end = true; +break ; +default : +break ; + } + } +if (fate_type ==MLX5_FLOW_FATE_QUEUE ) { + hw_acts->rule_acts[actions_n++].action = hw_acts->tir->action; + flow->hrxq = hw_acts->tir; + }else { +if (fate_type ==MLX5_FLOW_FATE_JUMP ) + flow->jump = hw_acts->jump; + } +/* Total actions number should be validated before. */ +MLX5_ASSERT (actions_n <=MLX5_HW_MAX_ACTS );return 0 ; +clean_up: +/* Make sure that there is no garbage in the actions. */ +__flow_hw_actions_release (dev, hw_acts); +return -rte_errno; } static int flow_hw_register_matcher(struct rte_eth_dev *dev,
@@ -12299,7 +12415,8 @@ static int flow_hw_create_flow(struct rte_eth_dev *dev,if (ret) goto error; - ret =flow_hw_translate_actions (dev, attr, actions, *flow, error); +/* Note: the actions should be saved in the sub-flow rule itself for reference. */ + ret =flow_hw_translate_actions (dev, attr, actions, *flow, &hw_act, external, error);if (ret) goto error;
Signature · 1 line
2.25.1
PATCH v3 4/11 net/mlx5: add default miss action support in nt2hws mode
In reply to Maayan KashaniFrom: Bing Zhao <[email protected]>
The validation will be handled later.
Now it only supports the SEND_TO_KERNEL on non-root tables.
--- drivers/net/mlx5/mlx5_flow_hw.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-)
drivers/net/mlx5/mlx5_flow_hw.c +20 -3
@@ -12129,22 +12129,28 @@ flow_hw_translate_actions(struct rte_eth_dev *dev,enum mlx5_hw_action_flag_type flag_type;bool actions_end = false;uint64_t action_flags =0 ;/* to be used when needed */ +int ret;uint32_t actions_n =0 ;uint32_t mark_id;uint32_t jump_group; +uint32_t src_group =0 ;bool is_mark;struct mlx5_flow_template_table_cfg tbl_cfg;enum mlx5_flow_fate_type fate_type =MLX5_FLOW_FATE_NONE ; +RTE_SET_USED (action_flags); +/* The group in the attribute translation was done in advance. */ + ret =__translate_group (dev, attr, external, attr->group, &src_group, error); +if (ret) +return ret;if (attr->transfer) type =MLX5DR_TABLE_TYPE_FDB ;else if (attr->egress) type =MLX5DR_TABLE_TYPE_NIC_TX ;else type =MLX5DR_TABLE_TYPE_NIC_RX ; -/* The group in the attribute translation was done in advance. */ - flag_type = (attr->group ==0 ) ?MLX5_HW_ACTION_FLAG_ROOT : -MLX5_HW_ACTION_FLAG_NONE_ROOT ; + flag_type = (src_group ==0 ) ?MLX5_HW_ACTION_FLAG_ROOT : +MLX5_HW_ACTION_FLAG_NONE_ROOT ;for (; !actions_end; actions++) {switch (actions->type) {case RTE_FLOW_ACTION_TYPE_VOID :
@@ -12196,6 +12202,17 @@ flow_hw_translate_actions(struct rte_eth_dev *dev, action_flags |=MLX5_FLOW_ACTION_QUEUE ; fate_type =MLX5_FLOW_FATE_QUEUE ;break ; +case RTE_FLOW_ACTION_TYPE_SEND_TO_KERNEL : +if (src_group ==0 ) { +rte_flow_error_set (error,ENOTSUP , +RTE_FLOW_ERROR_TYPE_ACTION ,NULL , +"Send to kernel action on the root table is" +" not supported in HWS mode now." ); + goto clean_up; + } + hw_acts->rule_acts[actions_n++].action = priv->hw_send_to_kernel[type]; + action_flags |=MLX5_FLOW_ACTION_SEND_TO_KERNEL ; +break ;case RTE_FLOW_ACTION_TYPE_END :/* * Using NULL action right now, maybe a new API can be used
Signature · 1 line
2.25.1
PATCH v3 5/11 net/mlx5: add ASO actions support to non-template mode
In reply to Maayan KashaniThis patch adds counter, connection tracking, meter and age actions support to non-template mode.
For CT, counter and meter: if no previous allocation was handled by hw configure routine,
Half of the maximum supported number of objects will be allocated. For AGE action, if no counters were allocated,
allocate half of the maximum,
and then allocate same number of AGE objects.
Also extracted the shared host handling to the configure function. And align all ASO actions to have init function
for future code improvement.
This patch does not affect SW Steering flow engine.
--- drivers/net/mlx5/mlx5.h | 7 ++ drivers/net/mlx5/mlx5_flow_hw.c | 185 +++++++++++++++++++++++++++----- drivers/net/mlx5/mlx5_hws_cnt.c | 47 ++++---- drivers/net/mlx5/mlx5_hws_cnt.h | 10 +- 4 files changed, 190 insertions(+), 59 deletions(-)
drivers/net/mlx5/mlx5.h +7 -0
@@ -792,6 +792,13 @@ struct mlx5_dev_shared_port {/* Only yellow color valid. */ #define MLX5_MTR_POLICY_MODE_OY 3 +/* Max number of meters allocated in non template mode. */ +#define MLX5_MTR_NT_MAX (1 << 23)/*TODO verify number */ +/* Max number of connection tracking allocated in non template mode */ +#define MLX5_CT_NT_MAX (1 << 23)/*TODO verify number */ +/* Max number of counters allocated in non template mode */ +#define MLX5_CNT_MAX (1 << 23)/*TODO verify number */ +enum mlx5_meter_domain {MLX5_MTR_DOMAIN_INGRESS ,MLX5_MTR_DOMAIN_EGRESS ,
drivers/net/mlx5/mlx5_flow_hw.c +157 -28
280 lines not on this page · raw message
drivers/net/mlx5/mlx5_hws_cnt.c +20 -27
115 lines not on this page · raw message
drivers/net/mlx5/mlx5_hws_cnt.h +6 -4
@@ -712,9 +712,10 @@ mlx5_hws_cnt_service_thread_create(struct mlx5_dev_ctx_shared *sh);void mlx5_hws_cnt_service_thread_destroy (struct mlx5_dev_ctx_shared *sh); -struct mlx5_hws_cnt_pool * +int mlx5_hws_cnt_pool_create (struct rte_eth_dev *dev, -const struct rte_flow_port_attr *pattr,uint16_t nb_queue); +uint32_t nb_counters,uint16_t nb_queue, +struct mlx5_hws_cnt_pool *chost); void mlx5_hws_cnt_pool_destroy(struct mlx5_dev_ctx_shared *sh,
@@ -744,8 +745,9 @@ mlx5_hws_age_context_get(struct mlx5_priv *priv, uint32_t idx);int mlx5_hws_age_pool_init (struct rte_eth_dev *dev, -const struct rte_flow_port_attr *attr, -uint16_t nb_queues); +uint32_t nb_aging_objects, +uint16_t nb_queues, +bool strict_queue);void mlx5_hws_age_pool_destroy (struct mlx5_priv *priv);
Signature · 1 line
2.25.1
PATCH v3 6/11 net/mlx5: fix segfault on counter pool destroy
In reply to Maayan KashaniIf the counter pool was not added to list,
and an error state was reached,
on attempt to destroy the counter pool, segmentation fault was received during list remove action.
Added a check to verify the list is not empty before trying to remove the cpool from the list.
Invalid state, leading to segfault,
can also be reached in the following scenario:
1. mlx5_hws_cnt_pool_init() does a zmalloc and initializes most
of the fields of cpool, but does not initialize the next field.
2. mlx5_hws_cnt_pool_dcs_alloc() attempts to bulk allocate flow counters.
If this fails, we skip straight to 4.
In HW, this can fail simply if FW doesn't support bulk flow counter allocation.
3. Right before the goto error, we insert the cpool to the hws_cpool_list.
This is where the next field is initialized.
4. mlx5_hws_cnt_pool_destroy() assumes the cpool's next field
is initialized and SEGVs if not.
So, added a guard against cases where the entry was uninitialized (checking le_prev field is not NULL).
--- drivers/net/mlx5/mlx5_hws_cnt.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/mlx5/mlx5_hws_cnt.c +3 -1
@@ -718,7 +718,9 @@ mlx5_hws_cnt_pool_destroy(struct mlx5_dev_ctx_shared *sh,* Maybe blocked for at most 200ms here. */ rte_spinlock_lock (&sh->cpool_lock); -LIST_REMOVE (cpool, next); +/* Try to remove cpool before it was added to list caused segfault. */ +if (!LIST_EMPTY (&sh->hws_cpool_list) && cpool->next.le_prev) +LIST_REMOVE (cpool, next);rte_spinlock_unlock (&sh->cpool_lock);if (cpool->cfg.host_cpool ==NULL ) {if (--sh->cnt_svc->refcnt ==0 )
Signature · 1 line
2.25.1
PATCH v3 7/11 net/mlx5: abstract action handling and enable reconfigure
In reply to Maayan Kashanireuse HWS actions translation code in order to create the actions for lower layer.
All actions are handled as non masked. Therefore, will be translated in the rule construct phase shared with the template code
and not during the action template translate.
Currently there is no option to reconfigure in template API’s. To support non template API and template API simultaneously, There is a need to enable the user to reconfigure after default configuration was applied by the driver on port start.
Fix flow create ptr
In SWS the return flow pointer is the flow index, in HWS the return flow pointer is the flow data pointer. Currently the return value of non template code did not Enable destroy or quary.
--- drivers/net/mlx5/mlx5.h | 25 +- drivers/net/mlx5/mlx5_flow.c | 31 +- drivers/net/mlx5/mlx5_flow.h | 14 +- drivers/net/mlx5/mlx5_flow_dv.c | 18 +- drivers/net/mlx5/mlx5_flow_hw.c | 811 ++++++++++++++++---------------- 5 files changed, 463 insertions(+), 436 deletions(-)
drivers/net/mlx5/mlx5.h +13 -12
@@ -793,11 +793,11 @@ struct mlx5_dev_shared_port {#define MLX5_MTR_POLICY_MODE_OY 3/* Max number of meters allocated in non template mode. */ -#define MLX5_MTR_NT_MAX (1 << 23)/*TODO verify number */ +#define MLX5_MTR_NT_MAX (1 << 23)/* Max number of connection tracking allocated in non template mode */ -#define MLX5_CT_NT_MAX (1 << 23)/*TODO verify number */ +#define MLX5_CT_NT_MAX (1 << 23)/* Max number of counters allocated in non template mode */ -#define MLX5_CNT_MAX (1 << 23)/*TODO verify number */ +#define MLX5_CNT_MAX (1 << 23)enum mlx5_meter_domain {MLX5_MTR_DOMAIN_INGRESS ,
@@ -1516,7 +1516,6 @@ struct mlx5_dev_ctx_shared {/* Direct Rules tables for FDB, NIC TX+RX */ void *dr_drop_action;/* Pointer to DR drop action, any domain. */ void *pop_vlan_action;/* Pointer to DR pop VLAN action. */ -void *hw_dummy_last;/* Pointer to the DR dummy end action, any domain. */ #if defined(HAVE_IBV_FLOW_DV_SUPPORT ) || !defined(HAVE_INFINIBAND_VERBS_H )struct mlx5_send_to_kernel_action send_to_kernel_action[MLX5DR_TABLE_TYPE_MAX ];#endif
@@ -1797,6 +1796,14 @@ struct mlx5_hw_ctrl_flow {struct mlx5_hw_ctrl_flow_info info; }; +/* HW Steering port configuration passed to rte_flow_configure(). */ +struct mlx5_flow_hw_attr { +struct rte_flow_port_attr port_attr; +uint16_t nb_queue; +struct rte_flow_queue_attr *queue_attr; +bool nt_mode; +}; +/* * Flow rule structure for flow engine mode control, focus on group 0. * Apply to all supported domains.
@@ -1818,12 +1825,6 @@ struct rte_pmd_mlx5_flow_engine_mode_info {/* The list is maintained in insertion order. */ LIST_HEAD(hot_up_info, mlx5_dv_flow_info) hot_upgrade; }; -/* HW Steering port configuration passed to rte_flow_configure(). */ -struct mlx5_flow_hw_attr { -struct rte_flow_port_attr port_attr; -uint16_t nb_queue; -struct rte_flow_queue_attr *queue_attr; -};struct mlx5_flow_hw_ctrl_rx ;
@@ -2301,7 +2302,7 @@ int mlx5_flow_validate(struct rte_eth_dev *dev,const struct rte_flow_item items[], const struct rte_flow_action actions[], struct rte_flow_error *error); -uint32_t +uintptr_t mlx5_flow_list_create(struct rte_eth_dev *dev, enum mlx5_flow_type type, const struct rte_flow_attr *attr, const struct rte_flow_item items[],
@@ -2309,7 +2310,7 @@ mlx5_flow_list_create(struct rte_eth_dev *dev, enum mlx5_flow_type type, bool external, struct rte_flow_error *error);void mlx5_flow_list_destroy (struct rte_eth_dev *dev,enum mlx5_flow_type type, -uint32_t flow_idx); +uintptr_t flow_idx); struct rte_flow *mlx5_flow_create(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, const struct rte_flow_item items[],
drivers/net/mlx5/mlx5_flow.c +14 -17
@@ -4930,7 +4930,7 @@ flow_check_hairpin_split(struct rte_eth_dev *dev,/* Declare flow create/destroy prototype in advance. */ -static uint32_t +static uintptr_t flow_drv_list_create(struct rte_eth_dev *dev, enum mlx5_flow_type type, const struct rte_flow_attr *attr, const struct rte_flow_item items[],
@@ -4939,7 +4939,7 @@ flow_drv_list_create(struct rte_eth_dev *dev, enum mlx5_flow_type type,static void flow_drv_list_destroy (struct rte_eth_dev *dev,enum mlx5_flow_type type, -uint32_t flow_idx); +uintptr_t flow_idx); int flow_dv_mreg_match_cb(void *tool_ctx __rte_unused,
@@ -7243,7 +7243,7 @@ flow_tunnel_from_rule(const struct mlx5_flow *flow)* @return * A flow index on success, 0 otherwise and rte_errno is set. */ -uint32_t +uintptr_t flow_legacy_list_create(struct rte_eth_dev *dev, enum mlx5_flow_type type, const struct rte_flow_attr *attr, const struct rte_flow_item items[],
@@ -7918,7 +7918,7 @@ mlx5_flow_create(struct rte_eth_dev *dev,struct mlx5_priv *priv = dev->data->dev_private;struct rte_flow_attr *new_attr = (void *)(uintptr_t )attr;uint32_t prio = attr->priority; -uint32_t flow_idx; +uintptr_t flow_idx;/* * If the device is not started yet, it is not allowed to created a
@@ -7952,7 +7952,7 @@ mlx5_flow_create(struct rte_eth_dev *dev,return (void *)(uintptr_t )flow_idx; } -uint32_t +uintptr_t mlx5_flow_list_create(struct rte_eth_dev *dev, enum mlx5_flow_type type, const struct rte_flow_attr *attr, const struct rte_flow_item items[],
@@ -7963,7 +7963,7 @@ mlx5_flow_list_create(struct rte_eth_dev *dev, enum mlx5_flow_type type, error); } -uint32_t +uintptr_t flow_drv_list_create(struct rte_eth_dev *dev, enum mlx5_flow_type type, const struct rte_flow_attr *attr, const struct rte_flow_item items[],
@@ -7988,7 +7988,7 @@ flow_drv_list_create(struct rte_eth_dev *dev, enum mlx5_flow_type type,*/ void flow_legacy_list_destroy (struct rte_eth_dev *dev,enum mlx5_flow_type type, -uint32_t flow_idx) +uintptr_t flow_idx) {struct mlx5_priv *priv = dev->data->dev_private;struct rte_flow *flow =mlx5_ipool_get (priv->flows[type], (uint32_t )flow_idx);
@@ -8019,7 +8019,7 @@ flow_legacy_list_destroy(struct rte_eth_dev *dev, enum mlx5_flow_type type,static void flow_drv_list_destroy (struct rte_eth_dev *dev,enum mlx5_flow_type type, -uint32_t flow_idx) +uintptr_t flow_idx) {const struct mlx5_flow_driver_ops *fops;struct rte_flow_attr attr = { .transfer =0 };
@@ -8031,7 +8031,7 @@ flow_drv_list_destroy(struct rte_eth_dev *dev, enum mlx5_flow_type type,void mlx5_flow_list_destroy (struct rte_eth_dev *dev,enum mlx5_flow_type type, -uint32_t flow_idx) +uintptr_t flow_idx) {flow_drv_list_destroy (dev, type, flow_idx); }
@@ -8060,12 +8060,14 @@ mlx5_flow_list_flush(struct rte_eth_dev *dev, enum mlx5_flow_type type,if (priv->sh->config.dv_flow_en ==2 && type ==MLX5_FLOW_TYPE_GEN ) {flow_hw_q_flow_flush (dev,NULL ); -return ; }#endif - MLX5_IPOOL_FOREACH(priv->flows[type], fidx, flow) { -flow_drv_list_destroy (dev, type, fidx); +if (priv->sh->config.dv_flow_en ==2 ) { +flow_drv_list_destroy (dev, type, (uintptr_t )flow); + }else { +flow_drv_list_destroy (dev, type, fidx); + }if (unlikely (mlx5_need_cache_flow (priv,NULL ) && type ==MLX5_FLOW_TYPE_GEN )) { flow_info =LIST_FIRST (&mode_info->hot_upgrade);while (flow_info) {
@@ -8526,11 +8528,6 @@ mlx5_flow_destroy(struct rte_eth_dev *dev,struct rte_pmd_mlx5_flow_engine_mode_info *mode_info = &priv->mode_info;struct mlx5_dv_flow_info *flow_info; -if (priv->sh->config.dv_flow_en ==2 ) -return rte_flow_error_set (error,ENOTSUP , -RTE_FLOW_ERROR_TYPE_UNSPECIFIED , -NULL , -"Flow non-Q destruction not supported" );flow_drv_list_destroy (dev,MLX5_FLOW_TYPE_GEN , (uintptr_t )(void *)flow);if (unlikely (mlx5_need_cache_flow (priv,NULL ))) {
drivers/net/mlx5/mlx5_flow.h +9 -5
@@ -1315,6 +1315,8 @@ struct rte_flow_nt2hws {struct mlx5dr_bwc_rule *nt_rule;/** The matcher for non template api. */ struct mlx5_flow_dv_matcher *matcher; +/**< Auxiliary data stored per flow. */ +struct rte_flow_hw_aux *flow_aux; } __rte_packed;/** HWS flow struct. */
@@ -1349,12 +1351,14 @@ struct rte_flow_hw {struct mlx5_hrxq *hrxq; }; +/** Equals true if it is non template rule. */ +bool nt_rule;/** * Padding for alignment to 56 bytes. * Since mlx5dr rule is 72 bytes, whole flow is contained within 128 B (2 cache lines). * This space is reserved for future additions to flow struct. */ -uint8_t padding[10 ]; +uint8_t padding[9 ];/** HWS layer data struct. */ uint8_t rule[]; } __rte_packed;
@@ -2116,7 +2120,7 @@ int flow_hw_init(struct rte_eth_dev *dev, struct rte_flow_error *error); -typedef uint32_t (*mlx5_flow_list_create_t)(struct rte_eth_dev *dev, +typedef uintptr_t (*mlx5_flow_list_create_t)(struct rte_eth_dev *dev, enum mlx5_flow_type type, const struct rte_flow_attr *attr, const struct rte_flow_item items[],
@@ -2125,7 +2129,7 @@ typedef uint32_t (*mlx5_flow_list_create_t)(struct rte_eth_dev *dev, struct rte_flow_error *error);typedef void (*mlx5_flow_list_destroy_t )(struct rte_eth_dev *dev,enum mlx5_flow_type type, -uint32_t flow_idx); +uintptr_t flow_idx); typedef int (*mlx5_flow_validate_t)(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, const struct rte_flow_item items[],
@@ -3317,13 +3321,13 @@ int mlx5_flow_item_field_width(struct rte_eth_dev *dev, enum rte_flow_field_id field, int inherit, const struct rte_flow_attr *attr, struct rte_flow_error *error); -uint32_t flow_legacy_list_create (struct rte_eth_dev *dev,enum mlx5_flow_type type, +uintptr_t flow_legacy_list_create (struct rte_eth_dev *dev,enum mlx5_flow_type type,const struct rte_flow_attr *attr,const struct rte_flow_item items[],const struct rte_flow_action actions[],bool external,struct rte_flow_error *error);void flow_legacy_list_destroy (struct rte_eth_dev *dev,enum mlx5_flow_type type, -uint32_t flow_idx); +uintptr_t flow_idx); static __rte_always_inline int flow_hw_get_srh_flex_parser_byte_off_from_ctx(void *dr_ctx __rte_unused)
drivers/net/mlx5/mlx5_flow_dv.c +15 -3
@@ -11843,12 +11843,14 @@ flow_matcher_create_cb(void *tool_ctx, void *cb_ctx)struct mlx5_flow_cb_ctx *ctx = cb_ctx;struct mlx5_flow_dv_matcher *ref = ctx->data;struct mlx5_flow_dv_matcher *resource; +#ifdef HAVE_MLX5_HWS_SUPPORT +const struct rte_flow_item *items; +#endif struct mlx5dv_flow_matcher_attr dv_attr = { .type =IBV_FLOW_ATTR_NORMAL , .match_mask = (void *)&ref->mask, }; -struct mlx5_flow_tbl_data_entry *tbl =container_of (ref->tbl, -typeof (*tbl), tbl); +struct mlx5_flow_tbl_data_entry *tbl;int ret; resource = mlx5_malloc(MLX5_MEM_ZERO, sizeof(*resource), 0,
@@ -11859,9 +11861,9 @@ flow_matcher_create_cb(void *tool_ctx, void *cb_ctx) "cannot create matcher");return NULL ; } -/*Consider memcpy(resource, ref, sizeof(*resource));*/ *resource = *ref;if (sh->config.dv_flow_en !=2 ) { + tbl =container_of (ref->tbl,typeof (*tbl), tbl); dv_attr.match_criteria_enable =flow_dv_matcher_enable (resource->mask.buf); __flow_dv_adjust_buf_size(&ref->mask.size,
@@ -11879,6 +11881,16 @@ flow_matcher_create_cb(void *tool_ctx, void *cb_ctx) "cannot create matcher");return NULL ; } + }else { +#ifdef HAVE_MLX5_HWS_SUPPORT + items = *((const struct rte_flow_item **)(ctx->data2)); + resource->matcher_object =mlx5dr_bwc_matcher_create + (resource->group->tbl, resource->priority, items); +if (!(resource->matcher_object)) +return NULL ; +#else +return NULL ; +#endif }return &resource->entry; }
drivers/net/mlx5/mlx5_flow_hw.c +412 -399
1,332 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v3 8/11 common/mlx5: read connection tracking attributes
In reply to Maayan KashaniNeed to read maximum connection tracking
objects from HCA attributes.
--- drivers/common/mlx5/mlx5_devx_cmds.c | 3 +++ drivers/common/mlx5/mlx5_devx_cmds.h | 1 + 2 files changed, 4 insertions(+)
drivers/common/mlx5/mlx5_devx_cmds.c +3 -0
@@ -1170,6 +1170,9 @@ mlx5_devx_cmd_query_hca_attr(void *ctx, (rc &MLX5_CROSS_VHCA_ALLOWED_OBJS_TIR ) && (rc &MLX5_CROSS_VHCA_ALLOWED_OBJS_FT ) && (rc &MLX5_CROSS_VHCA_ALLOWED_OBJS_RTC ); +if (attr->ct_offload) + attr->log_max_conn_track_offload =MLX5_GET (cmd_hca_cap_2, hcattr, + log_max_conn_track_offload); }if (attr->log_min_stride_wqe_sz ==0 ) attr->log_min_stride_wqe_sz =MLX5_MPRQ_LOG_MIN_STRIDE_WQE_SIZE ;
drivers/common/mlx5/mlx5_devx_cmds.h +1 -0
@@ -326,6 +326,7 @@ struct mlx5_hca_attr { uint32_t wqe_based_flow_table_sup:1;uint8_t max_header_modify_pattern_length;uint64_t system_image_guid; + uint32_t log_max_conn_track_offload:5; };/* LAG Context. */
Signature · 1 line
2.25.1
PATCH v3 9/11 net/mlx5: support bulk actions in non template mode
In reply to Maayan KashaniAdd support for encap/decap/modify header action for non template API.
Save 1 action per bulk according to action data. Reuse action if possible.
Store actions same as for SWS today, use same key structure.
--- drivers/net/mlx5/mlx5_flow.h | 44 ++++-- drivers/net/mlx5/mlx5_flow_dv.c | 268 ++++++++++++++++++++------------ drivers/net/mlx5/mlx5_flow_hw.c | 184 ++++++++++++++++++++-- 3 files changed, 368 insertions(+), 128 deletions(-)
drivers/net/mlx5/mlx5_flow.h +32 -12
@@ -666,6 +666,10 @@ struct mlx5_flow_dv_modify_hdr_resource {struct mlx5_list_entry entry;void *action;/**< Modify header action object. */ uint32_t idx; +#ifdef HAVE_MLX5_HWS_SUPPORT +void *mh_dr_pattern;/**< Modify header DR pattern(HWS only). */ +#endif +uint64_t flags;/**< Flags for RDMA API(HWS only). */ /* Key area for hash list matching: */ uint8_t ft_type;/**< Flow table type, Rx or Tx. */ uint8_t actions_num;/**< Number of modification actions. */
@@ -1317,7 +1321,11 @@ struct rte_flow_nt2hws {struct mlx5_flow_dv_matcher *matcher;/**< Auxiliary data stored per flow. */ struct rte_flow_hw_aux *flow_aux; -} __rte_packed; +/** Modify header pointer. */ +struct mlx5_flow_dv_modify_hdr_resource *modify_hdr; +/** Encap/decap index. */ +uint32_t rix_encap_decap; +};/** HWS flow struct. */ struct rte_flow_hw {
@@ -3079,14 +3087,14 @@ struct mlx5_list_entry *flow_dv_tag_clone_cb(void *tool_ctx, void *cb_ctx);void flow_dv_tag_clone_free_cb (void *tool_ctx,struct mlx5_list_entry *entry); -int flow_dv_modify_match_cb (void *tool_ctx,struct mlx5_list_entry *entry, +int flow_modify_match_cb (void *tool_ctx,struct mlx5_list_entry *entry,void *cb_ctx); -struct mlx5_list_entry *flow_dv_modify_create_cb (void *tool_ctx,void *ctx); -void flow_dv_modify_remove_cb (void *tool_ctx,struct mlx5_list_entry *entry); -struct mlx5_list_entry *flow_dv_modify_clone_cb (void *tool_ctx, +struct mlx5_list_entry *flow_modify_create_cb (void *tool_ctx,void *ctx); +void flow_modify_remove_cb (void *tool_ctx,struct mlx5_list_entry *entry); +struct mlx5_list_entry *flow_modify_clone_cb (void *tool_ctx,struct mlx5_list_entry *oentry,void *ctx); -void flow_dv_modify_clone_free_cb (void *tool_ctx, +void flow_modify_clone_free_cb (void *tool_ctx,struct mlx5_list_entry *entry);struct mlx5_list_entry *flow_dv_mreg_create_cb (void *tool_ctx,void *ctx);
@@ -3098,18 +3106,30 @@ struct mlx5_list_entry *flow_dv_mreg_clone_cb(void *tool_ctx, void *ctx);void flow_dv_mreg_clone_free_cb (void *tool_ctx,struct mlx5_list_entry *entry); -int flow_dv_encap_decap_match_cb (void *tool_ctx,struct mlx5_list_entry *entry, +int flow_encap_decap_match_cb (void *tool_ctx,struct mlx5_list_entry *entry,void *cb_ctx); -struct mlx5_list_entry *flow_dv_encap_decap_create_cb (void *tool_ctx, +struct mlx5_list_entry *flow_encap_decap_create_cb (void *tool_ctx,void *cb_ctx); -void flow_dv_encap_decap_remove_cb (void *tool_ctx, +void flow_encap_decap_remove_cb (void *tool_ctx,struct mlx5_list_entry *entry); -struct mlx5_list_entry *flow_dv_encap_decap_clone_cb (void *tool_ctx, +struct mlx5_list_entry *flow_encap_decap_clone_cb (void *tool_ctx,struct mlx5_list_entry *entry,void *cb_ctx); -void flow_dv_encap_decap_clone_free_cb (void *tool_ctx, +void flow_encap_decap_clone_free_cb (void *tool_ctx,struct mlx5_list_entry *entry); - +int __flow_encap_decap_resource_register + (struct rte_eth_dev *dev, +struct mlx5_flow_dv_encap_decap_resource *resource, +bool is_root, +struct mlx5_flow_dv_encap_decap_resource **encap_decap, +struct rte_flow_error *error); +int __flow_modify_hdr_resource_register + (struct rte_eth_dev *dev, +struct mlx5_flow_dv_modify_hdr_resource *resource, +struct mlx5_flow_dv_modify_hdr_resource **modify, +struct rte_flow_error *error); +int flow_encap_decap_resource_release (struct rte_eth_dev *dev, +uint32_t encap_decap_idx);int flow_matcher_match_cb (void *tool_ctx,struct mlx5_list_entry *entry,void *ctx);struct mlx5_list_entry *flow_matcher_create_cb (void *tool_ctx,void *ctx);
drivers/net/mlx5/mlx5_flow_dv.c +165 -103
459 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_hw.c +171 -13
299 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v3 10/11 net/mlx5: use non const max number for ASO actions
In reply to Maayan KashaniFor ASO max allocations in non-template mode,
Read FW capabilities instead of using consts.
--- drivers/net/mlx5/mlx5.h | 17 ++++++++++++----- drivers/net/mlx5/mlx5_flow_hw.c | 13 +++++++++---- drivers/net/mlx5/mlx5_flow_meter.c | 25 +++++++++++++++++++++---- 3 files changed, 42 insertions(+), 13 deletions(-)
drivers/net/mlx5/mlx5.h +12 -5
@@ -792,12 +792,18 @@ struct mlx5_dev_shared_port {/* Only yellow color valid. */ #define MLX5_MTR_POLICY_MODE_OY 3 +/* Max number of meters. */ +#define MLX5_MTR_MAX (priv) (mlx5_flow_mtr_max_get(priv))/* Max number of meters allocated in non template mode. */ -#define MLX5_MTR_NT_MAX (1 << 23) -/* Max number of connection tracking allocated in non template mode */ -#define MLX5_CT_NT_MAX (1 << 23) -/* Max number of counters allocated in non template mode */ -#define MLX5_CNT_MAX (1 << 23) +#define MLX5_MTR_NT_MAX (priv) (MLX5_MTR_MAX(priv) >> 1) +/* Max number of connection tracking. */ +#define MLX5_CT_MAX (priv) (1 << (priv)->sh->cdev->config.hca_attr.log_max_conn_track_offload) +/* Max number of connection tracking allocated in non template mode. */ +#define MLX5_CT_NT_MAX (priv) (MLX5_CT_MAX(priv) >> 1) +/* Max number of counters. */ +#define MLX5_CNT_MAX (priv) ((priv)->sh->hws_max_nb_counters) +/* Max number of counters allocated in non template mode. */ +#define MLX5_CNT_NT_MAX (priv) (MLX5_CNT_MAX(priv) >> 1)enum mlx5_meter_domain {MLX5_MTR_DOMAIN_INGRESS ,
@@ -2423,6 +2429,7 @@ mlx5_flow_meter_hierarchy_get_final_policy(struct rte_eth_dev *dev,int mlx5_flow_meter_flush (struct rte_eth_dev *dev,struct rte_mtr_error *error);void mlx5_flow_meter_rxq_flush (struct rte_eth_dev *dev); +uint32_t mlx5_flow_mtr_max_get (struct mlx5_priv *priv);/* mlx5_os.c */
drivers/net/mlx5/mlx5_flow_hw.c +9 -4
@@ -12522,6 +12522,7 @@ static int flow_hw_ensure_action_pools_allocated(struct rte_eth_dev *dev,bool actions_end = false;struct mlx5_priv *priv = dev->data->dev_private;int ret; +uint obj_num;for (; !actions_end; actions++) {switch ((int )actions->type) {
@@ -12530,7 +12531,8 @@ static int flow_hw_ensure_action_pools_allocated(struct rte_eth_dev *dev,if (!priv->hws_age_req) {/* If no counters were previously allocated. */ if (!priv->hws_cpool) { - ret =mlx5_hws_cnt_pool_create (dev,MLX5_CNT_MAX , + obj_num =MLX5_CNT_NT_MAX (priv); + ret =mlx5_hws_cnt_pool_create (dev, obj_num, priv->nb_queue,NULL );if (ret) goto err;
@@ -12548,7 +12550,8 @@ static int flow_hw_ensure_action_pools_allocated(struct rte_eth_dev *dev,case RTE_FLOW_ACTION_TYPE_COUNT :/* If no counters were previously allocated. */ if (!priv->hws_cpool) { - ret =mlx5_hws_cnt_pool_create (dev,MLX5_CNT_MAX , + obj_num =MLX5_CNT_NT_MAX (priv); + ret =mlx5_hws_cnt_pool_create (dev, obj_num, priv->nb_queue,NULL );if (ret) goto err;
@@ -12557,7 +12560,8 @@ static int flow_hw_ensure_action_pools_allocated(struct rte_eth_dev *dev,case RTE_FLOW_ACTION_TYPE_CONNTRACK :/* If no CT were previously allocated. */ if (!priv->hws_ctpool) { - ret =mlx5_flow_ct_init (dev,MLX5_CT_NT_MAX , priv->nb_queue); + obj_num =MLX5_CT_NT_MAX (priv); + ret =mlx5_flow_ct_init (dev, obj_num, priv->nb_queue);if (ret) goto err; }
@@ -12565,7 +12569,8 @@ static int flow_hw_ensure_action_pools_allocated(struct rte_eth_dev *dev,case RTE_FLOW_ACTION_TYPE_METER_MARK :/* If no meters were previously allocated. */ if (!priv->hws_mpool) { - ret =mlx5_flow_meter_init (dev,MLX5_MTR_NT_MAX ,0 ,0 , + obj_num =MLX5_MTR_NT_MAX (priv); + ret =mlx5_flow_meter_init (dev, obj_num,0 ,0 , priv->nb_queue);if (ret) goto err;
drivers/net/mlx5/mlx5_flow_meter.c +21 -4
@@ -704,6 +704,26 @@ mlx5_flow_meter_param_fill(struct mlx5_flow_meter_profile *fmp,return 0 ; } +/** +* Callback to get MTR maximum objects number. +* +* @param[in] priv +* Pointer to Ethernet device. +* +* @return +* Max number of meters. +*/ +uint32_t +mlx5_flow_mtr_max_get (struct mlx5_priv *priv) +{ +struct mlx5_hca_qos_attr *qattr = &priv->sh->cdev->config.hca_attr.qos; + +/* Max number of meters. */ +return ((priv->sh->meter_aso_en) ? +1 << (qattr->log_max_num_meter_aso +1 ) : + qattr->log_max_flow_meter); +} +/** * Callback to get MTR capabilities. *
@@ -730,14 +750,11 @@ mlx5_flow_mtr_cap_get(struct rte_eth_dev *dev,RTE_MTR_ERROR_TYPE_UNSPECIFIED ,NULL , "Meter is not supported");memset (cap,0 ,sizeof (*cap)); + cap->n_max =mlx5_flow_mtr_max_get (priv);if (priv->sh->meter_aso_en) { -/* 2 meters per one ASO cache line. */ - cap->n_max =1 << (qattr->log_max_num_meter_aso +1 ); cap->srtcm_rfc2697_packet_mode_supported =1 ; cap->trtcm_rfc2698_packet_mode_supported =1 ; cap->trtcm_rfc4115_packet_mode_supported =1 ; - }else { - cap->n_max =1 << qattr->log_max_flow_meter; } cap->srtcm_rfc2697_byte_mode_supported =1 ; cap->trtcm_rfc2698_byte_mode_supported =1 ;
Signature · 1 line
2.25.1
PATCH v3 11/11 net/mlx5: initial design changes
In reply to Maayan KashaniChange flow_drv_list_create/destroy to mlx5_flow_list_create/destroy. Remove resource release function inlining.
Check number of queues in template mode in hw configure function. Use user priority to calculate matcher priority.
--- drivers/net/mlx5/mlx5_flow.c | 70 +++++++--------------- drivers/net/mlx5/mlx5_flow_hw.c | 100 +++++++++++++++----------------- 2 files changed, 68 insertions(+), 102 deletions(-)
drivers/net/mlx5/mlx5_flow.c +20 -50
@@ -4928,19 +4928,6 @@ flow_check_hairpin_split(struct rte_eth_dev *dev,return 0 ; } -/* Declare flow create/destroy prototype in advance. */ - -static uintptr_t -flow_drv_list_create (struct rte_eth_dev *dev,enum mlx5_flow_type type, -const struct rte_flow_attr *attr, -const struct rte_flow_item items[], -const struct rte_flow_action actions[], -bool external,struct rte_flow_error *error); - -static void -flow_drv_list_destroy (struct rte_eth_dev *dev,enum mlx5_flow_type type, -uintptr_t flow_idx); -int flow_dv_mreg_match_cb(void *tool_ctx __rte_unused,struct mlx5_list_entry *entry,void *cb_ctx)
@@ -5059,7 +5046,7 @@ flow_dv_mreg_create_cb(void *tool_ctx, void *cb_ctx)* be applied, removed, deleted in arbitrary order * by list traversing. */ - mcp_res->rix_flow =flow_drv_list_create (dev,MLX5_FLOW_TYPE_MCP , + mcp_res->rix_flow =mlx5_flow_list_create (dev,MLX5_FLOW_TYPE_MCP , &attr, items, actions, false, error);if (!mcp_res->rix_flow) {mlx5_ipool_free (priv->sh->ipool[MLX5_IPOOL_MCP ], idx);
@@ -5153,7 +5140,7 @@ flow_dv_mreg_remove_cb(void *tool_ctx, struct mlx5_list_entry *entry)struct mlx5_priv *priv = dev->data->dev_private;MLX5_ASSERT (mcp_res->rix_flow); -flow_drv_list_destroy (dev,MLX5_FLOW_TYPE_MCP , mcp_res->rix_flow); +mlx5_flow_list_destroy (dev,MLX5_FLOW_TYPE_MCP , mcp_res->rix_flow);mlx5_ipool_free (priv->sh->ipool[MLX5_IPOOL_MCP ], mcp_res->idx); }
@@ -7540,7 +7527,7 @@ mlx5_flow_create_esw_table_zero_flow(struct rte_eth_dev *dev) };struct rte_flow_error error; -return (void *)(uintptr_t )flow_drv_list_create (dev,MLX5_FLOW_TYPE_CTL , +return (void *)(uintptr_t )mlx5_flow_list_create (dev,MLX5_FLOW_TYPE_CTL , &attr, &pattern, actions, false, &error); }
@@ -7608,14 +7595,14 @@ mlx5_flow_create_devx_sq_miss_flow(struct rte_eth_dev *dev, uint32_t sq_num)* Creates group 0, highest priority jump flow. * Matches txq to bypass kernel packets. */ -if (flow_drv_list_create (dev,MLX5_FLOW_TYPE_CTL , &attr, pattern, actions, +if (mlx5_flow_list_create (dev,MLX5_FLOW_TYPE_CTL , &attr, pattern, actions, false, &error) ==0 )return 0 ;/* Create group 1, lowest priority redirect flow for txq. */ attr.group =1 ; actions[0 ].conf = &port; actions[0 ].type =RTE_FLOW_ACTION_TYPE_PORT_ID ; -return flow_drv_list_create (dev,MLX5_FLOW_TYPE_CTL , &attr, pattern, +return mlx5_flow_list_create (dev,MLX5_FLOW_TYPE_CTL , &attr, pattern, actions, false, &error); }
@@ -7771,7 +7758,7 @@ mlx5_flow_cache_flow_toggle(struct rte_eth_dev *dev, bool orig_prio) flow_info->flow_idx_low_prio);if (high && low) {RTE_SWAP (*low, *high); -flow_drv_list_destroy (dev,MLX5_FLOW_TYPE_GEN , +mlx5_flow_list_destroy (dev,MLX5_FLOW_TYPE_GEN , flow_info->flow_idx_low_prio); flow_info->flow_idx_high_prio =0 ; }
@@ -7785,7 +7772,7 @@ mlx5_flow_cache_flow_toggle(struct rte_eth_dev *dev, bool orig_prio)while (flow_info) {if (flow_info->orig_prio != flow_info->attr.priority) {if (flow_info->flow_idx_high_prio) -flow_drv_list_destroy (dev,MLX5_FLOW_TYPE_GEN , +mlx5_flow_list_destroy (dev,MLX5_FLOW_TYPE_GEN , flow_info->flow_idx_high_prio);else break ;
@@ -7940,12 +7927,13 @@ mlx5_flow_create(struct rte_eth_dev *dev, RTE_PMD_MLX5_FLOW_ENGINE_FLAG_STANDBY_DUP_INGRESS))) new_attr->priority += 1; } - flow_idx =flow_drv_list_create (dev,MLX5_FLOW_TYPE_GEN , attr, items, actions, true, error); + flow_idx =mlx5_flow_list_create (dev,MLX5_FLOW_TYPE_GEN , attr, items, actions, + true, error);if (!flow_idx)return NULL ;if (unlikely (mlx5_need_cache_flow (priv, attr))) {if (mlx5_flow_cache_flow_info (dev, attr, prio, items, actions, flow_idx)) { -flow_drv_list_destroy (dev,MLX5_FLOW_TYPE_GEN , flow_idx); +mlx5_flow_list_destroy (dev,MLX5_FLOW_TYPE_GEN , flow_idx); flow_idx =0 ; } }
@@ -7958,17 +7946,6 @@ mlx5_flow_list_create(struct rte_eth_dev *dev, enum mlx5_flow_type type,const struct rte_flow_item items[], const struct rte_flow_action actions[], bool external, struct rte_flow_error *error) -{ - return flow_drv_list_create(dev, type, attr, items, actions, external, -error ); -} - -uintptr_t -flow_drv_list_create (struct rte_eth_dev *dev,enum mlx5_flow_type type, -const struct rte_flow_attr *attr, -const struct rte_flow_item items[], -const struct rte_flow_action actions[], -bool external,struct rte_flow_error *error) { const struct mlx5_flow_driver_ops *fops;enum mlx5_flow_drv_type drv_type =flow_get_drv_type (dev, attr);
@@ -8017,8 +7994,8 @@ flow_legacy_list_destroy(struct rte_eth_dev *dev, enum mlx5_flow_type type,mlx5_ipool_free (priv->flows[type], flow_idx); } -static void -flow_drv_list_destroy (struct rte_eth_dev *dev,enum mlx5_flow_type type, +void +mlx5_flow_list_destroy (struct rte_eth_dev *dev,enum mlx5_flow_type type,uintptr_t flow_idx) {const struct mlx5_flow_driver_ops *fops;
@@ -8029,13 +8006,6 @@ flow_drv_list_destroy(struct rte_eth_dev *dev, enum mlx5_flow_type type, fops->list_destroy (dev, type, flow_idx); } -void -mlx5_flow_list_destroy (struct rte_eth_dev *dev,enum mlx5_flow_type type, -uintptr_t flow_idx) -{ -flow_drv_list_destroy (dev, type, flow_idx); -} -/** * Destroy all flows. *
@@ -8064,9 +8034,9 @@ mlx5_flow_list_flush(struct rte_eth_dev *dev, enum mlx5_flow_type type,#endif MLX5_IPOOL_FOREACH(priv->flows[type], fidx, flow) {if (priv->sh->config.dv_flow_en ==2 ) { -flow_drv_list_destroy (dev, type, (uintptr_t )flow); +mlx5_flow_list_destroy (dev, type, (uintptr_t )flow); }else { -flow_drv_list_destroy (dev, type, fidx); +mlx5_flow_list_destroy (dev, type, fidx); }if (unlikely (mlx5_need_cache_flow (priv,NULL ) && type ==MLX5_FLOW_TYPE_GEN )) { flow_info =LIST_FIRST (&mode_info->hot_upgrade);
@@ -8339,7 +8309,7 @@ mlx5_ctrl_flow_source_queue(struct rte_eth_dev *dev, actions[0 ].type =RTE_FLOW_ACTION_TYPE_JUMP ; actions[0 ].conf = &jump; actions[1 ].type =RTE_FLOW_ACTION_TYPE_END ; - flow_idx =flow_drv_list_create (dev,MLX5_FLOW_TYPE_CTL , + flow_idx =mlx5_flow_list_create (dev,MLX5_FLOW_TYPE_CTL , &attr, items, actions, false, &error);if (!flow_idx) { DRV_LOG(DEBUG,
@@ -8429,7 +8399,7 @@ mlx5_ctrl_flow_vlan(struct rte_eth_dev *dev, action_rss.types =0 ;for (i =0 ; i != priv->reta_idx_n; ++i) queue[i] = (*priv->reta_idx)[i]; - flow_idx =flow_drv_list_create (dev,MLX5_FLOW_TYPE_CTL , + flow_idx =mlx5_flow_list_create (dev,MLX5_FLOW_TYPE_CTL , &attr, items, actions, false, &error);if (!flow_idx)return -rte_errno;
@@ -8504,7 +8474,7 @@ mlx5_flow_lacp_miss(struct rte_eth_dev *dev) }, };struct rte_flow_error error; -uint32_t flow_idx =flow_drv_list_create (dev,MLX5_FLOW_TYPE_CTL , +uint32_t flow_idx =mlx5_flow_list_create (dev,MLX5_FLOW_TYPE_CTL , &attr, items, actions, false, &error);
@@ -8528,7 +8498,7 @@ mlx5_flow_destroy(struct rte_eth_dev *dev,struct rte_pmd_mlx5_flow_engine_mode_info *mode_info = &priv->mode_info;struct mlx5_dv_flow_info *flow_info; -flow_drv_list_destroy (dev,MLX5_FLOW_TYPE_GEN , +mlx5_flow_list_destroy (dev,MLX5_FLOW_TYPE_GEN , (uintptr_t )(void *)flow);if (unlikely (mlx5_need_cache_flow (priv,NULL ))) { flow_info =LIST_FIRST (&mode_info->hot_upgrade);
@@ -9840,14 +9810,14 @@ mlx5_flow_discover_mreg_c(struct rte_eth_dev *dev)if (!priv->sh->config.dv_flow_en)break ;/* Create internal flow, validation skips copy action. */ - flow_idx =flow_drv_list_create (dev,MLX5_FLOW_TYPE_GEN , &attr, + flow_idx =mlx5_flow_list_create (dev,MLX5_FLOW_TYPE_GEN , &attr, items, actions, false, &error); flow =mlx5_ipool_get (priv->flows[MLX5_FLOW_TYPE_GEN ], flow_idx);if (!flow)continue ; priv->sh->flow_mreg_c[n++] = idx; -flow_drv_list_destroy (dev,MLX5_FLOW_TYPE_GEN , flow_idx); +mlx5_flow_list_destroy (dev,MLX5_FLOW_TYPE_GEN , flow_idx); }for (; n <MLX5_MREG_C_NUM ; ++n) priv->sh->flow_mreg_c[n] =REG_NON ;
drivers/net/mlx5/mlx5_flow_hw.c +48 -52
190 lines not on this page · raw message
Signature · 1 line
2.25.1
v4 cover non-template pmd basic func
In reply to Maayan KashaniImplementing non-template rules creation supporting direct actions possible.
Bing Zhao (3):
net/mlx5: add dummy last action
net/mlx5: add basic actions support for non-template API net/mlx5: add default miss action support in nt2hws mode
Maayan Kashani (8):
net/mlx5: initial design of non template to hws net/mlx5: add ASO actions support to non-template mode net/mlx5: fix segfault on counter pool destroy net/mlx5: abstract action handling and enable reconfigure common/mlx5: read connection tracking attributes net/mlx5: support bulk actions in non template mode net/mlx5: use non const max number for ASO actions net/mlx5: initial design changes
drivers/common/mlx5/mlx5_devx_cmds.c | 3 + drivers/common/mlx5/mlx5_devx_cmds.h | 1 + drivers/net/mlx5/linux/mlx5_os.c | 8 +- drivers/net/mlx5/mlx5.h | 37 +- drivers/net/mlx5/mlx5_flow.c | 142 +-- drivers/net/mlx5/mlx5_flow.h | 122 ++- drivers/net/mlx5/mlx5_flow_dv.c | 474 +++++--- drivers/net/mlx5/mlx5_flow_hw.c | 1501 ++++++++++++++++++++------ drivers/net/mlx5/mlx5_flow_meter.c | 25 +- drivers/net/mlx5/mlx5_flow_verbs.c | 2 + drivers/net/mlx5/mlx5_hws_cnt.c | 51 +- drivers/net/mlx5/mlx5_hws_cnt.h | 10 +- drivers/net/mlx5/mlx5_trigger.c | 6 + drivers/net/mlx5/windows/mlx5_os.c | 8 +- 14 files changed, 1817 insertions(+), 573 deletions(-)
Signature · 1 line
2.21.0
PATCH v4 1/11 net/mlx5: initial design of non template to hws
Implement the frame and needed building
blocks for non template to hws API's.
Added validate, list_create and list_destroy to mlx5_flow_hw_drv_ops. Rename old list_create/list_destroy functions to legacy_* and added a call from verbs/dv ops to the legacy functions.
Updated rte_flow_hw as needed.
Added rte_flow_nt2hws structure for non-template rule data.
squash to net/mlx5: initial design of non template to hws
--- drivers/net/mlx5/linux/mlx5_os.c | 8 +- drivers/net/mlx5/mlx5.h | 9 + drivers/net/mlx5/mlx5_flow.c | 139 +++++--- drivers/net/mlx5/mlx5_flow.h | 74 ++++- drivers/net/mlx5/mlx5_flow_dv.c | 192 +++++++++--- drivers/net/mlx5/mlx5_flow_hw.c | 487 +++++++++++++++++++++++++++-- drivers/net/mlx5/mlx5_flow_verbs.c | 2 + drivers/net/mlx5/mlx5_trigger.c | 6 + drivers/net/mlx5/windows/mlx5_os.c | 8 +- 9 files changed, 808 insertions(+), 117 deletions(-)
drivers/net/mlx5/linux/mlx5_os.c +7 -1
@@ -69,7 +69,7 @@ static rte_spinlock_t mlx5_shared_data_lock = RTE_SPINLOCK_INITIALIZER;static struct mlx5_local_data mlx5_local_data;/* rte flow indexed pool configuration. */ -static struct mlx5_indexed_pool_config icfg[] = { +static const struct mlx5_indexed_pool_config default_icfg[] = { { .size =sizeof (struct rte_flow ), .trunk_size =64 ,
@@ -1068,7 +1068,9 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,struct mlx5_port_info vport_info = { .query_flags =0 };int nl_rdma;int i; +struct mlx5_indexed_pool_config icfg[RTE_DIM (default_icfg)]; +memcpy (icfg, default_icfg,sizeof (icfg));/* Determine if this port representor is supposed to be spawned. */ if (switch_info->representor && dpdk_dev->devargs && !mlx5_representor_match (spawn, eth_da))
@@ -1539,6 +1541,10 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, icfg[i].release_mem_en = !!sh->config.reclaim_mode;if (sh->config.reclaim_mode) icfg[i].per_core_cache =0 ; +#ifdef HAVE_MLX5_HWS_SUPPORT +if (priv->sh->config.dv_flow_en ==2 ) + icfg[i].size =sizeof (struct rte_flow_hw ) +sizeof (struct rte_flow_nt2hws ); +#endif priv->flows[i] =mlx5_ipool_create (&icfg[i]);if (!priv->flows[i]) goto error;
drivers/net/mlx5/mlx5.h +9 -0
@@ -2293,6 +2293,15 @@ int mlx5_flow_validate(struct rte_eth_dev *dev,const struct rte_flow_item items[], const struct rte_flow_action actions[], struct rte_flow_error *error); +uint32_t +mlx5_flow_list_create (struct rte_eth_dev *dev,enum mlx5_flow_type type, +const struct rte_flow_attr *attr, +const struct rte_flow_item items[], +const struct rte_flow_action actions[], +bool external,struct rte_flow_error *error); +void +mlx5_flow_list_destroy (struct rte_eth_dev *dev,enum mlx5_flow_type type, +uint32_t flow_idx); struct rte_flow *mlx5_flow_create(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, const struct rte_flow_item items[],
drivers/net/mlx5/mlx5_flow.c +96 -43
311 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow.h +65 -9
131 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_dv.c +157 -35
316 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_hw.c +459 -28
568 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_verbs.c +2 -0
@@ -2183,6 +2183,8 @@ flow_verbs_sync_domain(struct rte_eth_dev *dev, uint32_t domains, }const struct mlx5_flow_driver_ops mlx5_flow_verbs_drv_ops = { + .list_create = flow_legacy_list_create, + .list_destroy = flow_legacy_list_destroy, .validate = flow_verbs_validate, .prepare = flow_verbs_prepare, .translate = flow_verbs_translate,
drivers/net/mlx5/mlx5_trigger.c +6 -0
@@ -1158,6 +1158,12 @@ mlx5_dev_start(struct rte_eth_dev *dev)DRV_LOG (DEBUG ,"port %u starting device" , dev->data->port_id);#ifdef HAVE_MLX5_HWS_SUPPORT if (priv->sh->config.dv_flow_en ==2 ) { +/*If previous configuration does not exist. */ +if (!(priv->dr_ctx)) { + ret =flow_hw_init (dev,NULL ); +if (ret) +return ret; + }/* If there is no E-Switch, then there are no start/stop order limitations. */ if (!priv->sh->config.dv_esw_en) goto continue_dev_start;
drivers/net/mlx5/windows/mlx5_os.c +7 -1
@@ -35,7 +35,7 @@ static const char *MZ_MLX5_PMD_SHARED_DATA = "mlx5_pmd_shared_data";static rte_spinlock_t mlx5_shared_data_lock =RTE_SPINLOCK_INITIALIZER ;/* rte flow indexed pool configuration. */ -static struct mlx5_indexed_pool_config icfg[] = { +static const struct mlx5_indexed_pool_config default_icfg[] = { { .size =sizeof (struct rte_flow ), .trunk_size =64 ,
@@ -352,7 +352,9 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,int own_domain_id =0 ;uint16_t port_id;int i; +struct mlx5_indexed_pool_config icfg[RTE_DIM (default_icfg)]; +memcpy (icfg, default_icfg,sizeof (icfg));/* Build device name. */ strlcpy (name, dpdk_dev->name,sizeof (name));/* check if the device is already spawned */
@@ -538,6 +540,10 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, icfg[i].release_mem_en = !!sh->config.reclaim_mode;if (sh->config.reclaim_mode) icfg[i].per_core_cache =0 ; +#ifdef HAVE_MLX5_HWS_SUPPORT +if (priv->sh->config.dv_flow_en ==2 ) + icfg[i].size =sizeof (struct rte_flow_hw ) +sizeof (struct rte_flow_nt2hws ); +#endif priv->flows[i] =mlx5_ipool_create (&icfg[i]);if (!priv->flows[i]) goto error;
Signature · 1 line
2.21.0
PATCH v4 2/11 net/mlx5: add dummy last action
In reply to Maayan KashaniFrom: Bing Zhao <[email protected]>
The RTE_FLOW_ACTION_TYPE_END action needs to be translated into the MLX5DR_ACTION_TYP_LAST for the future usage. It is only needed in the hardware steering backward compatible API.
--- drivers/net/mlx5/mlx5.h | 1 + drivers/net/mlx5/mlx5_flow_hw.c | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+)
drivers/net/mlx5/mlx5.h +1 -0
@@ -1509,6 +1509,7 @@ struct mlx5_dev_ctx_shared {/* Direct Rules tables for FDB, NIC TX+RX */ void *dr_drop_action;/* Pointer to DR drop action, any domain. */ void *pop_vlan_action;/* Pointer to DR pop VLAN action. */ +void *hw_dummy_last;/* Pointer to the DR dummy end action, any domain. */ #if defined(HAVE_IBV_FLOW_DV_SUPPORT ) || !defined(HAVE_INFINIBAND_VERBS_H )struct mlx5_send_to_kernel_action send_to_kernel_action[MLX5DR_TABLE_TYPE_MAX ];#endif
drivers/net/mlx5/mlx5_flow_hw.c +19 -0
@@ -10639,6 +10639,17 @@ flow_hw_configure(struct rte_eth_dev *dev,if (ret) goto err; } +/* +* All domains will use the same dummy action, only used in the backward +* compatible API. Initialize it for only once. No order dependency. +*/ +if (!priv->sh->hw_dummy_last) { + priv->sh->hw_dummy_last =mlx5dr_action_create_last (priv->dr_ctx, +MLX5DR_ACTION_FLAG_HWS_RX ); +if (!priv->sh->hw_dummy_last) +/* Do not overwrite the rte_errno. */ + goto err; + }if (!priv->shared_host)flow_hw_create_send_to_kernel_actions (priv);if (port_attr->nb_conn_tracks || (host_priv && host_priv->hws_ctpool)) {
@@ -10717,6 +10728,10 @@ flow_hw_configure(struct rte_eth_dev *dev,flow_hw_ct_mng_destroy (dev, priv->ct_mng); priv->ct_mng =NULL ; } +if (priv->sh->hw_dummy_last) { +mlx5dr_action_destroy (priv->sh->hw_dummy_last); + priv->sh->hw_dummy_last =NULL ; + }flow_hw_destroy_send_to_kernel_action (priv);flow_hw_cleanup_ctrl_fdb_tables (dev);flow_hw_free_vport_actions (priv);
@@ -10832,6 +10847,10 @@ flow_hw_resource_release(struct rte_eth_dev *dev)mlx5dr_action_destroy (priv->hw_def_miss);flow_hw_destroy_nat64_actions (priv);flow_hw_destroy_vlan (dev); +if (priv->sh->hw_dummy_last) { +mlx5dr_action_destroy (priv->sh->hw_dummy_last); + priv->sh->hw_dummy_last =NULL ; + }flow_hw_destroy_send_to_kernel_action (priv);flow_hw_free_vport_actions (priv);if (priv->acts_ipool) {
Signature · 1 line
2.21.0
PATCH v4 3/11 net/mlx5: add basic actions support for non-template API
In reply to Maayan KashaniFrom: Bing Zhao <[email protected]>
Support JUMP / DROP / QUEUE / MARK / FLAG now.
--- drivers/net/mlx5/mlx5_flow_hw.c | 153 ++++++++++++++++++++++++++++---- 1 file changed, 135 insertions(+), 18 deletions(-)
drivers/net/mlx5/mlx5_flow_hw.c +135 -18
@@ -604,8 +604,7 @@ flow_hw_jump_release(struct rte_eth_dev *dev, struct mlx5_hw_jump_action *jump)struct mlx5_priv *priv = dev->data->dev_private;struct mlx5_flow_group *grp; - grp =container_of - (jump, struct mlx5_flow_group, jump); + grp = container_of(jump, struct mlx5_flow_group, jump);mlx5_hlist_unregister (priv->sh->flow_tbls, &grp->entry); }
@@ -705,17 +704,9 @@ flow_hw_template_destroy_mhdr_action(struct mlx5_hw_modify_header_action *mhdr)* Pointer to the template HW steering DR actions. */ static void -__flow_hw_action_template_destroy (struct rte_eth_dev *dev, -struct mlx5_hw_actions *acts) +__flow_hw_actions_release (struct rte_eth_dev *dev,struct mlx5_hw_actions *acts) {struct mlx5_priv *priv = dev->data->dev_private; -struct mlx5_action_construct_data *data; - -while (!LIST_EMPTY (&acts->act_list)) { - data =LIST_FIRST (&acts->act_list); -LIST_REMOVE (data, next); -mlx5_ipool_free (priv->acts_ipool, data->idx); - }if (acts->mark) if (!(rte_atomic_fetch_sub_explicit(&priv->hws_mark_refcnt, 1,
@@ -760,6 +751,32 @@ __flow_hw_action_template_destroy(struct rte_eth_dev *dev, } } +/** +* Destroy DR actions created by action template. +* +* For DR actions created during table creation's action translate. +* Need to destroy the DR action when destroying the table. +* +* @param[in] dev +* Pointer to the rte_eth_dev structure. +* @param[in] acts +* Pointer to the template HW steering DR actions. +*/ +static void +__flow_hw_action_template_destroy (struct rte_eth_dev *dev,struct mlx5_hw_actions *acts) +{ +struct mlx5_priv *priv = dev->data->dev_private; +struct mlx5_action_construct_data *data; + +while (!LIST_EMPTY (&acts->act_list)) { + data =LIST_FIRST (&acts->act_list); +LIST_REMOVE (data, next); +mlx5_ipool_free (priv->acts_ipool, data->idx); + } + +__flow_hw_actions_release (dev, acts); +} +/** * Append dynamic action to the dynamic action list. *
@@ -12098,14 +12115,113 @@ static int flow_hw_prepare(struct rte_eth_dev *dev,return 0 ; } -static int flow_hw_translate_actions(struct rte_eth_dev *dev __rte_unused, - const struct rte_flow_attr *attr __rte_unused, - const struct rte_flow_action actions[] __rte_unused, - struct rte_flow_hw *flow __rte_unused, - struct rte_flow_error *error __rte_unused) +static int +flow_hw_translate_actions (struct rte_eth_dev *dev, +const struct rte_flow_attr *attr, +const struct rte_flow_action actions[], +struct rte_flow_hw *flow, +struct mlx5_hw_actions *hw_acts, +bool external, +struct rte_flow_error *error) { -/* TODO implement */ +struct mlx5_priv *priv = dev->data->dev_private; +enum mlx5dr_table_type type; +enum mlx5_hw_action_flag_type flag_type; +bool actions_end = false; +uint64_t action_flags =0 ;/* to be used when needed */ +uint32_t actions_n =0 ; +uint32_t mark_id; +uint32_t jump_group; +bool is_mark; +struct mlx5_flow_template_table_cfg tbl_cfg; +enum mlx5_flow_fate_type fate_type =MLX5_FLOW_FATE_NONE ; + +if (attr->transfer) + type =MLX5DR_TABLE_TYPE_FDB ; +else if (attr->egress) + type =MLX5DR_TABLE_TYPE_NIC_TX ; +else + type =MLX5DR_TABLE_TYPE_NIC_RX ; +/* The group in the attribute translation was done in advance. */ + flag_type = (attr->group ==0 ) ?MLX5_HW_ACTION_FLAG_ROOT : +MLX5_HW_ACTION_FLAG_NONE_ROOT ; +for (; !actions_end; actions++) { +switch (actions->type) { +case RTE_FLOW_ACTION_TYPE_VOID : +break ; +case RTE_FLOW_ACTION_TYPE_DROP : + hw_acts->rule_acts[actions_n++].action = priv->hw_drop[flag_type]; + fate_type =MLX5_FLOW_FATE_DROP ; +break ; +case RTE_FLOW_ACTION_TYPE_FLAG : +case RTE_FLOW_ACTION_TYPE_MARK : + is_mark = actions->type ==RTE_FLOW_ACTION_TYPE_MARK ; + mark_id = is_mark ? + ((const struct rte_flow_action_mark *)(actions->conf))->id : +MLX5_FLOW_MARK_DEFAULT ; + hw_acts->rule_acts[actions_n].tag.value =mlx5_flow_mark_set (mark_id); + hw_acts->rule_acts[actions_n].action = priv->hw_tag[flag_type]; + actions_n++; + action_flags |= is_mark ?MLX5_FLOW_ACTION_MARK :MLX5_FLOW_ACTION_FLAG ; + hw_acts->mark = true; +rte_atomic_fetch_add_explicit (&priv->hws_mark_refcnt,1 , + rte_memory_order_relaxed); +flow_hw_rxq_flag_set (dev, true); +break ; +case RTE_FLOW_ACTION_TYPE_JUMP : + jump_group = ((const struct rte_flow_action_jump *)actions->conf)->group; + tbl_cfg.attr.flow_attr = *attr; + tbl_cfg.external = external; +/* The flow_hw_jump_action_register() can be refactored. */ + hw_acts->jump =flow_hw_jump_action_register (dev, &tbl_cfg, + jump_group, error); +if (hw_acts->jump ==NULL ) + goto clean_up; + hw_acts->rule_acts[actions_n++].action = + (flag_type ==MLX5_HW_ACTION_FLAG_NONE_ROOT ) ? + hw_acts->jump->hws_action : hw_acts->jump->root_action; + action_flags |=MLX5_FLOW_ACTION_JUMP ; + fate_type =MLX5_FLOW_FATE_JUMP ; +break ; +case RTE_FLOW_ACTION_TYPE_QUEUE : +/* Right now, only Rx supports the TIR, validation is needed. */ + hw_acts->tir =flow_hw_tir_action_register (dev, + mlx5_hw_act_flag[flag_type][type], actions); +if (hw_acts->tir ==NULL ) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION ,NULL , +"Failed to translate queue." ); + goto clean_up; + } + action_flags |=MLX5_FLOW_ACTION_QUEUE ; + fate_type =MLX5_FLOW_FATE_QUEUE ; +break ; +case RTE_FLOW_ACTION_TYPE_END : +/* +* Using NULL action right now, maybe a new API can be used +* to create a dummy action with type MLX5DR_ACTION_TYP_LAST. +*/ + hw_acts->rule_acts[actions_n++].action = priv->sh->hw_dummy_last; + actions_end = true; +break ; +default : +break ; + } + } +if (fate_type ==MLX5_FLOW_FATE_QUEUE ) { + hw_acts->rule_acts[actions_n++].action = hw_acts->tir->action; + flow->hrxq = hw_acts->tir; + }else { +if (fate_type ==MLX5_FLOW_FATE_JUMP ) + flow->jump = hw_acts->jump; + } +/* Total actions number should be validated before. */ +MLX5_ASSERT (actions_n <=MLX5_HW_MAX_ACTS );return 0 ; +clean_up: +/* Make sure that there is no garbage in the actions. */ +__flow_hw_actions_release (dev, hw_acts); +return -rte_errno; } static int flow_hw_register_matcher(struct rte_eth_dev *dev,
@@ -12299,7 +12415,8 @@ static int flow_hw_create_flow(struct rte_eth_dev *dev,if (ret) goto error; - ret =flow_hw_translate_actions (dev, attr, actions, *flow, error); +/* Note: the actions should be saved in the sub-flow rule itself for reference. */ + ret =flow_hw_translate_actions (dev, attr, actions, *flow, &hw_act, external, error);if (ret) goto error;
Signature · 1 line
2.21.0
PATCH v4 4/11 net/mlx5: add default miss action support in nt2hws mode
In reply to Maayan KashaniFrom: Bing Zhao <[email protected]>
The validation will be handled later.
Now it only supports the SEND_TO_KERNEL on non-root tables.
--- drivers/net/mlx5/mlx5_flow_hw.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-)
drivers/net/mlx5/mlx5_flow_hw.c +20 -3
@@ -12129,22 +12129,28 @@ flow_hw_translate_actions(struct rte_eth_dev *dev,enum mlx5_hw_action_flag_type flag_type;bool actions_end = false;uint64_t action_flags =0 ;/* to be used when needed */ +int ret;uint32_t actions_n =0 ;uint32_t mark_id;uint32_t jump_group; +uint32_t src_group =0 ;bool is_mark;struct mlx5_flow_template_table_cfg tbl_cfg;enum mlx5_flow_fate_type fate_type =MLX5_FLOW_FATE_NONE ; +RTE_SET_USED (action_flags); +/* The group in the attribute translation was done in advance. */ + ret =__translate_group (dev, attr, external, attr->group, &src_group, error); +if (ret) +return ret;if (attr->transfer) type =MLX5DR_TABLE_TYPE_FDB ;else if (attr->egress) type =MLX5DR_TABLE_TYPE_NIC_TX ;else type =MLX5DR_TABLE_TYPE_NIC_RX ; -/* The group in the attribute translation was done in advance. */ - flag_type = (attr->group ==0 ) ?MLX5_HW_ACTION_FLAG_ROOT : -MLX5_HW_ACTION_FLAG_NONE_ROOT ; + flag_type = (src_group ==0 ) ?MLX5_HW_ACTION_FLAG_ROOT : +MLX5_HW_ACTION_FLAG_NONE_ROOT ;for (; !actions_end; actions++) {switch (actions->type) {case RTE_FLOW_ACTION_TYPE_VOID :
@@ -12196,6 +12202,17 @@ flow_hw_translate_actions(struct rte_eth_dev *dev, action_flags |=MLX5_FLOW_ACTION_QUEUE ; fate_type =MLX5_FLOW_FATE_QUEUE ;break ; +case RTE_FLOW_ACTION_TYPE_SEND_TO_KERNEL : +if (src_group ==0 ) { +rte_flow_error_set (error,ENOTSUP , +RTE_FLOW_ERROR_TYPE_ACTION ,NULL , +"Send to kernel action on the root table is" +" not supported in HWS mode now." ); + goto clean_up; + } + hw_acts->rule_acts[actions_n++].action = priv->hw_send_to_kernel[type]; + action_flags |=MLX5_FLOW_ACTION_SEND_TO_KERNEL ; +break ;case RTE_FLOW_ACTION_TYPE_END :/* * Using NULL action right now, maybe a new API can be used
Signature · 1 line
2.21.0
PATCH v4 5/11 net/mlx5: add ASO actions support to non-template mode
In reply to Maayan KashaniThis patch adds counter, connection tracking, meter and age actions support to non-template mode.
For CT, counter and meter: if no previous allocation was handled by hw configure routine,
Half of the maximum supported number of objects will be allocated. For AGE action, if no counters were allocated,
allocate half of the maximum,
and then allocate same number of AGE objects.
Also extracted the shared host handling to the configure function. And align all ASO actions to have init function
for future code improvement.
This patch does not affect SW Steering flow engine.
--- drivers/net/mlx5/mlx5.h | 7 ++ drivers/net/mlx5/mlx5_flow_hw.c | 185 +++++++++++++++++++++++++++----- drivers/net/mlx5/mlx5_hws_cnt.c | 47 ++++---- drivers/net/mlx5/mlx5_hws_cnt.h | 10 +- 4 files changed, 190 insertions(+), 59 deletions(-)
drivers/net/mlx5/mlx5.h +7 -0
@@ -792,6 +792,13 @@ struct mlx5_dev_shared_port {/* Only yellow color valid. */ #define MLX5_MTR_POLICY_MODE_OY 3 +/* Max number of meters allocated in non template mode. */ +#define MLX5_MTR_NT_MAX (1 << 23)/*TODO verify number */ +/* Max number of connection tracking allocated in non template mode */ +#define MLX5_CT_NT_MAX (1 << 23)/*TODO verify number */ +/* Max number of counters allocated in non template mode */ +#define MLX5_CNT_MAX (1 << 23)/*TODO verify number */ +enum mlx5_meter_domain {MLX5_MTR_DOMAIN_INGRESS ,MLX5_MTR_DOMAIN_EGRESS ,
drivers/net/mlx5/mlx5_flow_hw.c +157 -28
280 lines not on this page · raw message
drivers/net/mlx5/mlx5_hws_cnt.c +20 -27
115 lines not on this page · raw message
drivers/net/mlx5/mlx5_hws_cnt.h +6 -4
@@ -712,9 +712,10 @@ mlx5_hws_cnt_service_thread_create(struct mlx5_dev_ctx_shared *sh);void mlx5_hws_cnt_service_thread_destroy (struct mlx5_dev_ctx_shared *sh); -struct mlx5_hws_cnt_pool * +int mlx5_hws_cnt_pool_create (struct rte_eth_dev *dev, -const struct rte_flow_port_attr *pattr,uint16_t nb_queue); +uint32_t nb_counters,uint16_t nb_queue, +struct mlx5_hws_cnt_pool *chost); void mlx5_hws_cnt_pool_destroy(struct mlx5_dev_ctx_shared *sh,
@@ -744,8 +745,9 @@ mlx5_hws_age_context_get(struct mlx5_priv *priv, uint32_t idx);int mlx5_hws_age_pool_init (struct rte_eth_dev *dev, -const struct rte_flow_port_attr *attr, -uint16_t nb_queues); +uint32_t nb_aging_objects, +uint16_t nb_queues, +bool strict_queue);void mlx5_hws_age_pool_destroy (struct mlx5_priv *priv);
Signature · 1 line
2.21.0
PATCH v4 6/11 net/mlx5: fix segfault on counter pool destroy
In reply to Maayan KashaniIf the counter pool was not added to list,
and an error state was reached,
on attempt to destroy the counter pool, segmentation fault was received during list remove action.
Added a check to verify the list is not empty before trying to remove the cpool from the list.
Invalid state, leading to segfault,
can also be reached in the following scenario:
1. mlx5_hws_cnt_pool_init() does a zmalloc and initializes most
of the fields of cpool, but does not initialize the next field.
2. mlx5_hws_cnt_pool_dcs_alloc() attempts to bulk allocate flow counters.
If this fails, we skip straight to 4.
In HW, this can fail simply if FW doesn't support bulk flow counter allocation.
3. Right before the goto error, we insert the cpool to the hws_cpool_list.
This is where the next field is initialized.
4. mlx5_hws_cnt_pool_destroy() assumes the cpool's next field
is initialized and SEGVs if not.
So, added a guard against cases where the entry was uninitialized (checking le_prev field is not NULL).
--- drivers/net/mlx5/mlx5_hws_cnt.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/mlx5/mlx5_hws_cnt.c +3 -1
@@ -718,7 +718,9 @@ mlx5_hws_cnt_pool_destroy(struct mlx5_dev_ctx_shared *sh,* Maybe blocked for at most 200ms here. */ rte_spinlock_lock (&sh->cpool_lock); -LIST_REMOVE (cpool, next); +/* Try to remove cpool before it was added to list caused segfault. */ +if (!LIST_EMPTY (&sh->hws_cpool_list) && cpool->next.le_prev) +LIST_REMOVE (cpool, next);rte_spinlock_unlock (&sh->cpool_lock);if (cpool->cfg.host_cpool ==NULL ) {if (--sh->cnt_svc->refcnt ==0 )
Signature · 1 line
2.21.0
PATCH v4 7/11 net/mlx5: abstract action handling and enable reconfigure
In reply to Maayan Kashanireuse HWS actions translation code in order to create the actions for lower layer.
All actions are handled as non masked. Therefore, will be translated in the rule construct phase shared with the template code
and not during the action template translate.
Currently there is no option to reconfigure in template API’s. To support non template API and template API simultaneously, There is a need to enable the user to reconfigure after default configuration was applied by the driver on port start.
Fix flow create ptr
In SWS the return flow pointer is the flow index, in HWS the return flow pointer is the flow data pointer. Currently the return value of non template code did not Enable destroy or quary.
--- drivers/net/mlx5/mlx5.h | 25 +- drivers/net/mlx5/mlx5_flow.c | 31 +- drivers/net/mlx5/mlx5_flow.h | 14 +- drivers/net/mlx5/mlx5_flow_dv.c | 18 +- drivers/net/mlx5/mlx5_flow_hw.c | 811 ++++++++++++++++---------------- 5 files changed, 463 insertions(+), 436 deletions(-)
drivers/net/mlx5/mlx5.h +13 -12
@@ -793,11 +793,11 @@ struct mlx5_dev_shared_port {#define MLX5_MTR_POLICY_MODE_OY 3/* Max number of meters allocated in non template mode. */ -#define MLX5_MTR_NT_MAX (1 << 23)/*TODO verify number */ +#define MLX5_MTR_NT_MAX (1 << 23)/* Max number of connection tracking allocated in non template mode */ -#define MLX5_CT_NT_MAX (1 << 23)/*TODO verify number */ +#define MLX5_CT_NT_MAX (1 << 23)/* Max number of counters allocated in non template mode */ -#define MLX5_CNT_MAX (1 << 23)/*TODO verify number */ +#define MLX5_CNT_MAX (1 << 23)enum mlx5_meter_domain {MLX5_MTR_DOMAIN_INGRESS ,
@@ -1516,7 +1516,6 @@ struct mlx5_dev_ctx_shared {/* Direct Rules tables for FDB, NIC TX+RX */ void *dr_drop_action;/* Pointer to DR drop action, any domain. */ void *pop_vlan_action;/* Pointer to DR pop VLAN action. */ -void *hw_dummy_last;/* Pointer to the DR dummy end action, any domain. */ #if defined(HAVE_IBV_FLOW_DV_SUPPORT ) || !defined(HAVE_INFINIBAND_VERBS_H )struct mlx5_send_to_kernel_action send_to_kernel_action[MLX5DR_TABLE_TYPE_MAX ];#endif
@@ -1797,6 +1796,14 @@ struct mlx5_hw_ctrl_flow {struct mlx5_hw_ctrl_flow_info info; }; +/* HW Steering port configuration passed to rte_flow_configure(). */ +struct mlx5_flow_hw_attr { +struct rte_flow_port_attr port_attr; +uint16_t nb_queue; +struct rte_flow_queue_attr *queue_attr; +bool nt_mode; +}; +/* * Flow rule structure for flow engine mode control, focus on group 0. * Apply to all supported domains.
@@ -1818,12 +1825,6 @@ struct rte_pmd_mlx5_flow_engine_mode_info {/* The list is maintained in insertion order. */ LIST_HEAD(hot_up_info, mlx5_dv_flow_info) hot_upgrade; }; -/* HW Steering port configuration passed to rte_flow_configure(). */ -struct mlx5_flow_hw_attr { -struct rte_flow_port_attr port_attr; -uint16_t nb_queue; -struct rte_flow_queue_attr *queue_attr; -};struct mlx5_flow_hw_ctrl_rx ;
@@ -2301,7 +2302,7 @@ int mlx5_flow_validate(struct rte_eth_dev *dev,const struct rte_flow_item items[], const struct rte_flow_action actions[], struct rte_flow_error *error); -uint32_t +uintptr_t mlx5_flow_list_create(struct rte_eth_dev *dev, enum mlx5_flow_type type, const struct rte_flow_attr *attr, const struct rte_flow_item items[],
@@ -2309,7 +2310,7 @@ mlx5_flow_list_create(struct rte_eth_dev *dev, enum mlx5_flow_type type, bool external, struct rte_flow_error *error);void mlx5_flow_list_destroy (struct rte_eth_dev *dev,enum mlx5_flow_type type, -uint32_t flow_idx); +uintptr_t flow_idx); struct rte_flow *mlx5_flow_create(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, const struct rte_flow_item items[],
drivers/net/mlx5/mlx5_flow.c +14 -17
@@ -4930,7 +4930,7 @@ flow_check_hairpin_split(struct rte_eth_dev *dev,/* Declare flow create/destroy prototype in advance. */ -static uint32_t +static uintptr_t flow_drv_list_create(struct rte_eth_dev *dev, enum mlx5_flow_type type, const struct rte_flow_attr *attr, const struct rte_flow_item items[],
@@ -4939,7 +4939,7 @@ flow_drv_list_create(struct rte_eth_dev *dev, enum mlx5_flow_type type,static void flow_drv_list_destroy (struct rte_eth_dev *dev,enum mlx5_flow_type type, -uint32_t flow_idx); +uintptr_t flow_idx); int flow_dv_mreg_match_cb(void *tool_ctx __rte_unused,
@@ -7243,7 +7243,7 @@ flow_tunnel_from_rule(const struct mlx5_flow *flow)* @return * A flow index on success, 0 otherwise and rte_errno is set. */ -uint32_t +uintptr_t flow_legacy_list_create(struct rte_eth_dev *dev, enum mlx5_flow_type type, const struct rte_flow_attr *attr, const struct rte_flow_item items[],
@@ -7918,7 +7918,7 @@ mlx5_flow_create(struct rte_eth_dev *dev,struct mlx5_priv *priv = dev->data->dev_private;struct rte_flow_attr *new_attr = (void *)(uintptr_t )attr;uint32_t prio = attr->priority; -uint32_t flow_idx; +uintptr_t flow_idx;/* * If the device is not started yet, it is not allowed to created a
@@ -7952,7 +7952,7 @@ mlx5_flow_create(struct rte_eth_dev *dev,return (void *)(uintptr_t )flow_idx; } -uint32_t +uintptr_t mlx5_flow_list_create(struct rte_eth_dev *dev, enum mlx5_flow_type type, const struct rte_flow_attr *attr, const struct rte_flow_item items[],
@@ -7963,7 +7963,7 @@ mlx5_flow_list_create(struct rte_eth_dev *dev, enum mlx5_flow_type type, error); } -uint32_t +uintptr_t flow_drv_list_create(struct rte_eth_dev *dev, enum mlx5_flow_type type, const struct rte_flow_attr *attr, const struct rte_flow_item items[],
@@ -7988,7 +7988,7 @@ flow_drv_list_create(struct rte_eth_dev *dev, enum mlx5_flow_type type,*/ void flow_legacy_list_destroy (struct rte_eth_dev *dev,enum mlx5_flow_type type, -uint32_t flow_idx) +uintptr_t flow_idx) {struct mlx5_priv *priv = dev->data->dev_private;struct rte_flow *flow =mlx5_ipool_get (priv->flows[type], (uint32_t )flow_idx);
@@ -8019,7 +8019,7 @@ flow_legacy_list_destroy(struct rte_eth_dev *dev, enum mlx5_flow_type type,static void flow_drv_list_destroy (struct rte_eth_dev *dev,enum mlx5_flow_type type, -uint32_t flow_idx) +uintptr_t flow_idx) {const struct mlx5_flow_driver_ops *fops;struct rte_flow_attr attr = { .transfer =0 };
@@ -8031,7 +8031,7 @@ flow_drv_list_destroy(struct rte_eth_dev *dev, enum mlx5_flow_type type,void mlx5_flow_list_destroy (struct rte_eth_dev *dev,enum mlx5_flow_type type, -uint32_t flow_idx) +uintptr_t flow_idx) {flow_drv_list_destroy (dev, type, flow_idx); }
@@ -8060,12 +8060,14 @@ mlx5_flow_list_flush(struct rte_eth_dev *dev, enum mlx5_flow_type type,if (priv->sh->config.dv_flow_en ==2 && type ==MLX5_FLOW_TYPE_GEN ) {flow_hw_q_flow_flush (dev,NULL ); -return ; }#endif - MLX5_IPOOL_FOREACH(priv->flows[type], fidx, flow) { -flow_drv_list_destroy (dev, type, fidx); +if (priv->sh->config.dv_flow_en ==2 ) { +flow_drv_list_destroy (dev, type, (uintptr_t )flow); + }else { +flow_drv_list_destroy (dev, type, fidx); + }if (unlikely (mlx5_need_cache_flow (priv,NULL ) && type ==MLX5_FLOW_TYPE_GEN )) { flow_info =LIST_FIRST (&mode_info->hot_upgrade);while (flow_info) {
@@ -8526,11 +8528,6 @@ mlx5_flow_destroy(struct rte_eth_dev *dev,struct rte_pmd_mlx5_flow_engine_mode_info *mode_info = &priv->mode_info;struct mlx5_dv_flow_info *flow_info; -if (priv->sh->config.dv_flow_en ==2 ) -return rte_flow_error_set (error,ENOTSUP , -RTE_FLOW_ERROR_TYPE_UNSPECIFIED , -NULL , -"Flow non-Q destruction not supported" );flow_drv_list_destroy (dev,MLX5_FLOW_TYPE_GEN , (uintptr_t )(void *)flow);if (unlikely (mlx5_need_cache_flow (priv,NULL ))) {
drivers/net/mlx5/mlx5_flow.h +9 -5
@@ -1315,6 +1315,8 @@ struct rte_flow_nt2hws {struct mlx5dr_bwc_rule *nt_rule;/** The matcher for non template api. */ struct mlx5_flow_dv_matcher *matcher; +/**< Auxiliary data stored per flow. */ +struct rte_flow_hw_aux *flow_aux; } __rte_packed;/** HWS flow struct. */
@@ -1349,12 +1351,14 @@ struct rte_flow_hw {struct mlx5_hrxq *hrxq; }; +/** Equals true if it is non template rule. */ +bool nt_rule;/** * Padding for alignment to 56 bytes. * Since mlx5dr rule is 72 bytes, whole flow is contained within 128 B (2 cache lines). * This space is reserved for future additions to flow struct. */ -uint8_t padding[10 ]; +uint8_t padding[9 ];/** HWS layer data struct. */ uint8_t rule[]; } __rte_packed;
@@ -2116,7 +2120,7 @@ int flow_hw_init(struct rte_eth_dev *dev, struct rte_flow_error *error); -typedef uint32_t (*mlx5_flow_list_create_t)(struct rte_eth_dev *dev, +typedef uintptr_t (*mlx5_flow_list_create_t)(struct rte_eth_dev *dev, enum mlx5_flow_type type, const struct rte_flow_attr *attr, const struct rte_flow_item items[],
@@ -2125,7 +2129,7 @@ typedef uint32_t (*mlx5_flow_list_create_t)(struct rte_eth_dev *dev, struct rte_flow_error *error);typedef void (*mlx5_flow_list_destroy_t )(struct rte_eth_dev *dev,enum mlx5_flow_type type, -uint32_t flow_idx); +uintptr_t flow_idx); typedef int (*mlx5_flow_validate_t)(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, const struct rte_flow_item items[],
@@ -3317,13 +3321,13 @@ int mlx5_flow_item_field_width(struct rte_eth_dev *dev, enum rte_flow_field_id field, int inherit, const struct rte_flow_attr *attr, struct rte_flow_error *error); -uint32_t flow_legacy_list_create (struct rte_eth_dev *dev,enum mlx5_flow_type type, +uintptr_t flow_legacy_list_create (struct rte_eth_dev *dev,enum mlx5_flow_type type,const struct rte_flow_attr *attr,const struct rte_flow_item items[],const struct rte_flow_action actions[],bool external,struct rte_flow_error *error);void flow_legacy_list_destroy (struct rte_eth_dev *dev,enum mlx5_flow_type type, -uint32_t flow_idx); +uintptr_t flow_idx); static __rte_always_inline int flow_hw_get_srh_flex_parser_byte_off_from_ctx(void *dr_ctx __rte_unused)
drivers/net/mlx5/mlx5_flow_dv.c +15 -3
@@ -11843,12 +11843,14 @@ flow_matcher_create_cb(void *tool_ctx, void *cb_ctx)struct mlx5_flow_cb_ctx *ctx = cb_ctx;struct mlx5_flow_dv_matcher *ref = ctx->data;struct mlx5_flow_dv_matcher *resource; +#ifdef HAVE_MLX5_HWS_SUPPORT +const struct rte_flow_item *items; +#endif struct mlx5dv_flow_matcher_attr dv_attr = { .type =IBV_FLOW_ATTR_NORMAL , .match_mask = (void *)&ref->mask, }; -struct mlx5_flow_tbl_data_entry *tbl =container_of (ref->tbl, -typeof (*tbl), tbl); +struct mlx5_flow_tbl_data_entry *tbl;int ret; resource = mlx5_malloc(MLX5_MEM_ZERO, sizeof(*resource), 0,
@@ -11859,9 +11861,9 @@ flow_matcher_create_cb(void *tool_ctx, void *cb_ctx) "cannot create matcher");return NULL ; } -/*Consider memcpy(resource, ref, sizeof(*resource));*/ *resource = *ref;if (sh->config.dv_flow_en !=2 ) { + tbl =container_of (ref->tbl,typeof (*tbl), tbl); dv_attr.match_criteria_enable =flow_dv_matcher_enable (resource->mask.buf); __flow_dv_adjust_buf_size(&ref->mask.size,
@@ -11879,6 +11881,16 @@ flow_matcher_create_cb(void *tool_ctx, void *cb_ctx) "cannot create matcher");return NULL ; } + }else { +#ifdef HAVE_MLX5_HWS_SUPPORT + items = *((const struct rte_flow_item **)(ctx->data2)); + resource->matcher_object =mlx5dr_bwc_matcher_create + (resource->group->tbl, resource->priority, items); +if (!(resource->matcher_object)) +return NULL ; +#else +return NULL ; +#endif }return &resource->entry; }
drivers/net/mlx5/mlx5_flow_hw.c +412 -399
1,332 lines not on this page · raw message
Signature · 1 line
2.21.0
PATCH v4 8/11 common/mlx5: read connection tracking attributes
In reply to Maayan KashaniNeed to read maximum connection tracking
objects from HCA attributes.
--- drivers/common/mlx5/mlx5_devx_cmds.c | 3 +++ drivers/common/mlx5/mlx5_devx_cmds.h | 1 + 2 files changed, 4 insertions(+)
drivers/common/mlx5/mlx5_devx_cmds.c +3 -0
@@ -1170,6 +1170,9 @@ mlx5_devx_cmd_query_hca_attr(void *ctx, (rc &MLX5_CROSS_VHCA_ALLOWED_OBJS_TIR ) && (rc &MLX5_CROSS_VHCA_ALLOWED_OBJS_FT ) && (rc &MLX5_CROSS_VHCA_ALLOWED_OBJS_RTC ); +if (attr->ct_offload) + attr->log_max_conn_track_offload =MLX5_GET (cmd_hca_cap_2, hcattr, + log_max_conn_track_offload); }if (attr->log_min_stride_wqe_sz ==0 ) attr->log_min_stride_wqe_sz =MLX5_MPRQ_LOG_MIN_STRIDE_WQE_SIZE ;
drivers/common/mlx5/mlx5_devx_cmds.h +1 -0
@@ -326,6 +326,7 @@ struct mlx5_hca_attr { uint32_t wqe_based_flow_table_sup:1;uint8_t max_header_modify_pattern_length;uint64_t system_image_guid; + uint32_t log_max_conn_track_offload:5; };/* LAG Context. */
Signature · 1 line
2.21.0
PATCH v4 9/11 net/mlx5: support bulk actions in non template mode
In reply to Maayan KashaniAdd support for encap/decap/modify header action for non template API.
Save 1 action per bulk according to action data. Reuse action if possible.
Store actions same as for SWS today, use same key structure.
--- drivers/net/mlx5/mlx5_flow.h | 44 ++++-- drivers/net/mlx5/mlx5_flow_dv.c | 268 ++++++++++++++++++++------------ drivers/net/mlx5/mlx5_flow_hw.c | 184 ++++++++++++++++++++-- 3 files changed, 368 insertions(+), 128 deletions(-)
drivers/net/mlx5/mlx5_flow.h +32 -12
@@ -666,6 +666,10 @@ struct mlx5_flow_dv_modify_hdr_resource {struct mlx5_list_entry entry;void *action;/**< Modify header action object. */ uint32_t idx; +#ifdef HAVE_MLX5_HWS_SUPPORT +void *mh_dr_pattern;/**< Modify header DR pattern(HWS only). */ +#endif +uint64_t flags;/**< Flags for RDMA API(HWS only). */ /* Key area for hash list matching: */ uint8_t ft_type;/**< Flow table type, Rx or Tx. */ uint8_t actions_num;/**< Number of modification actions. */
@@ -1317,7 +1321,11 @@ struct rte_flow_nt2hws {struct mlx5_flow_dv_matcher *matcher;/**< Auxiliary data stored per flow. */ struct rte_flow_hw_aux *flow_aux; -} __rte_packed; +/** Modify header pointer. */ +struct mlx5_flow_dv_modify_hdr_resource *modify_hdr; +/** Encap/decap index. */ +uint32_t rix_encap_decap; +};/** HWS flow struct. */ struct rte_flow_hw {
@@ -3079,14 +3087,14 @@ struct mlx5_list_entry *flow_dv_tag_clone_cb(void *tool_ctx, void *cb_ctx);void flow_dv_tag_clone_free_cb (void *tool_ctx,struct mlx5_list_entry *entry); -int flow_dv_modify_match_cb (void *tool_ctx,struct mlx5_list_entry *entry, +int flow_modify_match_cb (void *tool_ctx,struct mlx5_list_entry *entry,void *cb_ctx); -struct mlx5_list_entry *flow_dv_modify_create_cb (void *tool_ctx,void *ctx); -void flow_dv_modify_remove_cb (void *tool_ctx,struct mlx5_list_entry *entry); -struct mlx5_list_entry *flow_dv_modify_clone_cb (void *tool_ctx, +struct mlx5_list_entry *flow_modify_create_cb (void *tool_ctx,void *ctx); +void flow_modify_remove_cb (void *tool_ctx,struct mlx5_list_entry *entry); +struct mlx5_list_entry *flow_modify_clone_cb (void *tool_ctx,struct mlx5_list_entry *oentry,void *ctx); -void flow_dv_modify_clone_free_cb (void *tool_ctx, +void flow_modify_clone_free_cb (void *tool_ctx,struct mlx5_list_entry *entry);struct mlx5_list_entry *flow_dv_mreg_create_cb (void *tool_ctx,void *ctx);
@@ -3098,18 +3106,30 @@ struct mlx5_list_entry *flow_dv_mreg_clone_cb(void *tool_ctx, void *ctx);void flow_dv_mreg_clone_free_cb (void *tool_ctx,struct mlx5_list_entry *entry); -int flow_dv_encap_decap_match_cb (void *tool_ctx,struct mlx5_list_entry *entry, +int flow_encap_decap_match_cb (void *tool_ctx,struct mlx5_list_entry *entry,void *cb_ctx); -struct mlx5_list_entry *flow_dv_encap_decap_create_cb (void *tool_ctx, +struct mlx5_list_entry *flow_encap_decap_create_cb (void *tool_ctx,void *cb_ctx); -void flow_dv_encap_decap_remove_cb (void *tool_ctx, +void flow_encap_decap_remove_cb (void *tool_ctx,struct mlx5_list_entry *entry); -struct mlx5_list_entry *flow_dv_encap_decap_clone_cb (void *tool_ctx, +struct mlx5_list_entry *flow_encap_decap_clone_cb (void *tool_ctx,struct mlx5_list_entry *entry,void *cb_ctx); -void flow_dv_encap_decap_clone_free_cb (void *tool_ctx, +void flow_encap_decap_clone_free_cb (void *tool_ctx,struct mlx5_list_entry *entry); - +int __flow_encap_decap_resource_register + (struct rte_eth_dev *dev, +struct mlx5_flow_dv_encap_decap_resource *resource, +bool is_root, +struct mlx5_flow_dv_encap_decap_resource **encap_decap, +struct rte_flow_error *error); +int __flow_modify_hdr_resource_register + (struct rte_eth_dev *dev, +struct mlx5_flow_dv_modify_hdr_resource *resource, +struct mlx5_flow_dv_modify_hdr_resource **modify, +struct rte_flow_error *error); +int flow_encap_decap_resource_release (struct rte_eth_dev *dev, +uint32_t encap_decap_idx);int flow_matcher_match_cb (void *tool_ctx,struct mlx5_list_entry *entry,void *ctx);struct mlx5_list_entry *flow_matcher_create_cb (void *tool_ctx,void *ctx);
drivers/net/mlx5/mlx5_flow_dv.c +165 -103
459 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_hw.c +171 -13
299 lines not on this page · raw message
Signature · 1 line
2.21.0
PATCH v4 10/11 net/mlx5: use non const max number for ASO actions
In reply to Maayan KashaniFor ASO max allocations in non-template mode,
Read FW capabilities instead of using consts.
--- drivers/net/mlx5/mlx5.h | 17 ++++++++++++----- drivers/net/mlx5/mlx5_flow_hw.c | 13 +++++++++---- drivers/net/mlx5/mlx5_flow_meter.c | 25 +++++++++++++++++++++---- 3 files changed, 42 insertions(+), 13 deletions(-)
drivers/net/mlx5/mlx5.h +12 -5
@@ -792,12 +792,18 @@ struct mlx5_dev_shared_port {/* Only yellow color valid. */ #define MLX5_MTR_POLICY_MODE_OY 3 +/* Max number of meters. */ +#define MLX5_MTR_MAX (priv) (mlx5_flow_mtr_max_get(priv))/* Max number of meters allocated in non template mode. */ -#define MLX5_MTR_NT_MAX (1 << 23) -/* Max number of connection tracking allocated in non template mode */ -#define MLX5_CT_NT_MAX (1 << 23) -/* Max number of counters allocated in non template mode */ -#define MLX5_CNT_MAX (1 << 23) +#define MLX5_MTR_NT_MAX (priv) (MLX5_MTR_MAX(priv) >> 1) +/* Max number of connection tracking. */ +#define MLX5_CT_MAX (priv) (1 << (priv)->sh->cdev->config.hca_attr.log_max_conn_track_offload) +/* Max number of connection tracking allocated in non template mode. */ +#define MLX5_CT_NT_MAX (priv) (MLX5_CT_MAX(priv) >> 1) +/* Max number of counters. */ +#define MLX5_CNT_MAX (priv) ((priv)->sh->hws_max_nb_counters) +/* Max number of counters allocated in non template mode. */ +#define MLX5_CNT_NT_MAX (priv) (MLX5_CNT_MAX(priv) >> 1)enum mlx5_meter_domain {MLX5_MTR_DOMAIN_INGRESS ,
@@ -2423,6 +2429,7 @@ mlx5_flow_meter_hierarchy_get_final_policy(struct rte_eth_dev *dev,int mlx5_flow_meter_flush (struct rte_eth_dev *dev,struct rte_mtr_error *error);void mlx5_flow_meter_rxq_flush (struct rte_eth_dev *dev); +uint32_t mlx5_flow_mtr_max_get (struct mlx5_priv *priv);/* mlx5_os.c */
drivers/net/mlx5/mlx5_flow_hw.c +9 -4
@@ -12522,6 +12522,7 @@ static int flow_hw_ensure_action_pools_allocated(struct rte_eth_dev *dev,bool actions_end = false;struct mlx5_priv *priv = dev->data->dev_private;int ret; +uint obj_num;for (; !actions_end; actions++) {switch ((int )actions->type) {
@@ -12530,7 +12531,8 @@ static int flow_hw_ensure_action_pools_allocated(struct rte_eth_dev *dev,if (!priv->hws_age_req) {/* If no counters were previously allocated. */ if (!priv->hws_cpool) { - ret =mlx5_hws_cnt_pool_create (dev,MLX5_CNT_MAX , + obj_num =MLX5_CNT_NT_MAX (priv); + ret =mlx5_hws_cnt_pool_create (dev, obj_num, priv->nb_queue,NULL );if (ret) goto err;
@@ -12548,7 +12550,8 @@ static int flow_hw_ensure_action_pools_allocated(struct rte_eth_dev *dev,case RTE_FLOW_ACTION_TYPE_COUNT :/* If no counters were previously allocated. */ if (!priv->hws_cpool) { - ret =mlx5_hws_cnt_pool_create (dev,MLX5_CNT_MAX , + obj_num =MLX5_CNT_NT_MAX (priv); + ret =mlx5_hws_cnt_pool_create (dev, obj_num, priv->nb_queue,NULL );if (ret) goto err;
@@ -12557,7 +12560,8 @@ static int flow_hw_ensure_action_pools_allocated(struct rte_eth_dev *dev,case RTE_FLOW_ACTION_TYPE_CONNTRACK :/* If no CT were previously allocated. */ if (!priv->hws_ctpool) { - ret =mlx5_flow_ct_init (dev,MLX5_CT_NT_MAX , priv->nb_queue); + obj_num =MLX5_CT_NT_MAX (priv); + ret =mlx5_flow_ct_init (dev, obj_num, priv->nb_queue);if (ret) goto err; }
@@ -12565,7 +12569,8 @@ static int flow_hw_ensure_action_pools_allocated(struct rte_eth_dev *dev,case RTE_FLOW_ACTION_TYPE_METER_MARK :/* If no meters were previously allocated. */ if (!priv->hws_mpool) { - ret =mlx5_flow_meter_init (dev,MLX5_MTR_NT_MAX ,0 ,0 , + obj_num =MLX5_MTR_NT_MAX (priv); + ret =mlx5_flow_meter_init (dev, obj_num,0 ,0 , priv->nb_queue);if (ret) goto err;
drivers/net/mlx5/mlx5_flow_meter.c +21 -4
@@ -704,6 +704,26 @@ mlx5_flow_meter_param_fill(struct mlx5_flow_meter_profile *fmp,return 0 ; } +/** +* Callback to get MTR maximum objects number. +* +* @param[in] priv +* Pointer to Ethernet device. +* +* @return +* Max number of meters. +*/ +uint32_t +mlx5_flow_mtr_max_get (struct mlx5_priv *priv) +{ +struct mlx5_hca_qos_attr *qattr = &priv->sh->cdev->config.hca_attr.qos; + +/* Max number of meters. */ +return ((priv->sh->meter_aso_en) ? +1 << (qattr->log_max_num_meter_aso +1 ) : + qattr->log_max_flow_meter); +} +/** * Callback to get MTR capabilities. *
@@ -730,14 +750,11 @@ mlx5_flow_mtr_cap_get(struct rte_eth_dev *dev,RTE_MTR_ERROR_TYPE_UNSPECIFIED ,NULL , "Meter is not supported");memset (cap,0 ,sizeof (*cap)); + cap->n_max =mlx5_flow_mtr_max_get (priv);if (priv->sh->meter_aso_en) { -/* 2 meters per one ASO cache line. */ - cap->n_max =1 << (qattr->log_max_num_meter_aso +1 ); cap->srtcm_rfc2697_packet_mode_supported =1 ; cap->trtcm_rfc2698_packet_mode_supported =1 ; cap->trtcm_rfc4115_packet_mode_supported =1 ; - }else { - cap->n_max =1 << qattr->log_max_flow_meter; } cap->srtcm_rfc2697_byte_mode_supported =1 ; cap->trtcm_rfc2698_byte_mode_supported =1 ;
Signature · 1 line
2.21.0
PATCH v4 11/11 net/mlx5: initial design changes
In reply to Maayan KashaniChange flow_drv_list_create/destroy to mlx5_flow_list_create/destroy. Remove resource release function inlining.
Check number of queues in template mode in hw configure function. Use user priority to calculate matcher priority.
--- drivers/net/mlx5/mlx5_flow.c | 70 +++++++--------------- drivers/net/mlx5/mlx5_flow_hw.c | 100 +++++++++++++++----------------- 2 files changed, 68 insertions(+), 102 deletions(-)
drivers/net/mlx5/mlx5_flow.c +20 -50
@@ -4928,19 +4928,6 @@ flow_check_hairpin_split(struct rte_eth_dev *dev,return 0 ; } -/* Declare flow create/destroy prototype in advance. */ - -static uintptr_t -flow_drv_list_create (struct rte_eth_dev *dev,enum mlx5_flow_type type, -const struct rte_flow_attr *attr, -const struct rte_flow_item items[], -const struct rte_flow_action actions[], -bool external,struct rte_flow_error *error); - -static void -flow_drv_list_destroy (struct rte_eth_dev *dev,enum mlx5_flow_type type, -uintptr_t flow_idx); -int flow_dv_mreg_match_cb(void *tool_ctx __rte_unused,struct mlx5_list_entry *entry,void *cb_ctx)
@@ -5059,7 +5046,7 @@ flow_dv_mreg_create_cb(void *tool_ctx, void *cb_ctx)* be applied, removed, deleted in arbitrary order * by list traversing. */ - mcp_res->rix_flow =flow_drv_list_create (dev,MLX5_FLOW_TYPE_MCP , + mcp_res->rix_flow =mlx5_flow_list_create (dev,MLX5_FLOW_TYPE_MCP , &attr, items, actions, false, error);if (!mcp_res->rix_flow) {mlx5_ipool_free (priv->sh->ipool[MLX5_IPOOL_MCP ], idx);
@@ -5153,7 +5140,7 @@ flow_dv_mreg_remove_cb(void *tool_ctx, struct mlx5_list_entry *entry)struct mlx5_priv *priv = dev->data->dev_private;MLX5_ASSERT (mcp_res->rix_flow); -flow_drv_list_destroy (dev,MLX5_FLOW_TYPE_MCP , mcp_res->rix_flow); +mlx5_flow_list_destroy (dev,MLX5_FLOW_TYPE_MCP , mcp_res->rix_flow);mlx5_ipool_free (priv->sh->ipool[MLX5_IPOOL_MCP ], mcp_res->idx); }
@@ -7540,7 +7527,7 @@ mlx5_flow_create_esw_table_zero_flow(struct rte_eth_dev *dev) };struct rte_flow_error error; -return (void *)(uintptr_t )flow_drv_list_create (dev,MLX5_FLOW_TYPE_CTL , +return (void *)(uintptr_t )mlx5_flow_list_create (dev,MLX5_FLOW_TYPE_CTL , &attr, &pattern, actions, false, &error); }
@@ -7608,14 +7595,14 @@ mlx5_flow_create_devx_sq_miss_flow(struct rte_eth_dev *dev, uint32_t sq_num)* Creates group 0, highest priority jump flow. * Matches txq to bypass kernel packets. */ -if (flow_drv_list_create (dev,MLX5_FLOW_TYPE_CTL , &attr, pattern, actions, +if (mlx5_flow_list_create (dev,MLX5_FLOW_TYPE_CTL , &attr, pattern, actions, false, &error) ==0 )return 0 ;/* Create group 1, lowest priority redirect flow for txq. */ attr.group =1 ; actions[0 ].conf = &port; actions[0 ].type =RTE_FLOW_ACTION_TYPE_PORT_ID ; -return flow_drv_list_create (dev,MLX5_FLOW_TYPE_CTL , &attr, pattern, +return mlx5_flow_list_create (dev,MLX5_FLOW_TYPE_CTL , &attr, pattern, actions, false, &error); }
@@ -7771,7 +7758,7 @@ mlx5_flow_cache_flow_toggle(struct rte_eth_dev *dev, bool orig_prio) flow_info->flow_idx_low_prio);if (high && low) {RTE_SWAP (*low, *high); -flow_drv_list_destroy (dev,MLX5_FLOW_TYPE_GEN , +mlx5_flow_list_destroy (dev,MLX5_FLOW_TYPE_GEN , flow_info->flow_idx_low_prio); flow_info->flow_idx_high_prio =0 ; }
@@ -7785,7 +7772,7 @@ mlx5_flow_cache_flow_toggle(struct rte_eth_dev *dev, bool orig_prio)while (flow_info) {if (flow_info->orig_prio != flow_info->attr.priority) {if (flow_info->flow_idx_high_prio) -flow_drv_list_destroy (dev,MLX5_FLOW_TYPE_GEN , +mlx5_flow_list_destroy (dev,MLX5_FLOW_TYPE_GEN , flow_info->flow_idx_high_prio);else break ;
@@ -7940,12 +7927,13 @@ mlx5_flow_create(struct rte_eth_dev *dev, RTE_PMD_MLX5_FLOW_ENGINE_FLAG_STANDBY_DUP_INGRESS))) new_attr->priority += 1; } - flow_idx =flow_drv_list_create (dev,MLX5_FLOW_TYPE_GEN , attr, items, actions, true, error); + flow_idx =mlx5_flow_list_create (dev,MLX5_FLOW_TYPE_GEN , attr, items, actions, + true, error);if (!flow_idx)return NULL ;if (unlikely (mlx5_need_cache_flow (priv, attr))) {if (mlx5_flow_cache_flow_info (dev, attr, prio, items, actions, flow_idx)) { -flow_drv_list_destroy (dev,MLX5_FLOW_TYPE_GEN , flow_idx); +mlx5_flow_list_destroy (dev,MLX5_FLOW_TYPE_GEN , flow_idx); flow_idx =0 ; } }
@@ -7958,17 +7946,6 @@ mlx5_flow_list_create(struct rte_eth_dev *dev, enum mlx5_flow_type type,const struct rte_flow_item items[], const struct rte_flow_action actions[], bool external, struct rte_flow_error *error) -{ - return flow_drv_list_create(dev, type, attr, items, actions, external, -error ); -} - -uintptr_t -flow_drv_list_create (struct rte_eth_dev *dev,enum mlx5_flow_type type, -const struct rte_flow_attr *attr, -const struct rte_flow_item items[], -const struct rte_flow_action actions[], -bool external,struct rte_flow_error *error) { const struct mlx5_flow_driver_ops *fops;enum mlx5_flow_drv_type drv_type =flow_get_drv_type (dev, attr);
@@ -8017,8 +7994,8 @@ flow_legacy_list_destroy(struct rte_eth_dev *dev, enum mlx5_flow_type type,mlx5_ipool_free (priv->flows[type], flow_idx); } -static void -flow_drv_list_destroy (struct rte_eth_dev *dev,enum mlx5_flow_type type, +void +mlx5_flow_list_destroy (struct rte_eth_dev *dev,enum mlx5_flow_type type,uintptr_t flow_idx) {const struct mlx5_flow_driver_ops *fops;
@@ -8029,13 +8006,6 @@ flow_drv_list_destroy(struct rte_eth_dev *dev, enum mlx5_flow_type type, fops->list_destroy (dev, type, flow_idx); } -void -mlx5_flow_list_destroy (struct rte_eth_dev *dev,enum mlx5_flow_type type, -uintptr_t flow_idx) -{ -flow_drv_list_destroy (dev, type, flow_idx); -} -/** * Destroy all flows. *
@@ -8064,9 +8034,9 @@ mlx5_flow_list_flush(struct rte_eth_dev *dev, enum mlx5_flow_type type,#endif MLX5_IPOOL_FOREACH(priv->flows[type], fidx, flow) {if (priv->sh->config.dv_flow_en ==2 ) { -flow_drv_list_destroy (dev, type, (uintptr_t )flow); +mlx5_flow_list_destroy (dev, type, (uintptr_t )flow); }else { -flow_drv_list_destroy (dev, type, fidx); +mlx5_flow_list_destroy (dev, type, fidx); }if (unlikely (mlx5_need_cache_flow (priv,NULL ) && type ==MLX5_FLOW_TYPE_GEN )) { flow_info =LIST_FIRST (&mode_info->hot_upgrade);
@@ -8339,7 +8309,7 @@ mlx5_ctrl_flow_source_queue(struct rte_eth_dev *dev, actions[0 ].type =RTE_FLOW_ACTION_TYPE_JUMP ; actions[0 ].conf = &jump; actions[1 ].type =RTE_FLOW_ACTION_TYPE_END ; - flow_idx =flow_drv_list_create (dev,MLX5_FLOW_TYPE_CTL , + flow_idx =mlx5_flow_list_create (dev,MLX5_FLOW_TYPE_CTL , &attr, items, actions, false, &error);if (!flow_idx) { DRV_LOG(DEBUG,
@@ -8429,7 +8399,7 @@ mlx5_ctrl_flow_vlan(struct rte_eth_dev *dev, action_rss.types =0 ;for (i =0 ; i != priv->reta_idx_n; ++i) queue[i] = (*priv->reta_idx)[i]; - flow_idx =flow_drv_list_create (dev,MLX5_FLOW_TYPE_CTL , + flow_idx =mlx5_flow_list_create (dev,MLX5_FLOW_TYPE_CTL , &attr, items, actions, false, &error);if (!flow_idx)return -rte_errno;
@@ -8504,7 +8474,7 @@ mlx5_flow_lacp_miss(struct rte_eth_dev *dev) }, };struct rte_flow_error error; -uint32_t flow_idx =flow_drv_list_create (dev,MLX5_FLOW_TYPE_CTL , +uint32_t flow_idx =mlx5_flow_list_create (dev,MLX5_FLOW_TYPE_CTL , &attr, items, actions, false, &error);
@@ -8528,7 +8498,7 @@ mlx5_flow_destroy(struct rte_eth_dev *dev,struct rte_pmd_mlx5_flow_engine_mode_info *mode_info = &priv->mode_info;struct mlx5_dv_flow_info *flow_info; -flow_drv_list_destroy (dev,MLX5_FLOW_TYPE_GEN , +mlx5_flow_list_destroy (dev,MLX5_FLOW_TYPE_GEN , (uintptr_t )(void *)flow);if (unlikely (mlx5_need_cache_flow (priv,NULL ))) { flow_info =LIST_FIRST (&mode_info->hot_upgrade);
@@ -9840,14 +9810,14 @@ mlx5_flow_discover_mreg_c(struct rte_eth_dev *dev)if (!priv->sh->config.dv_flow_en)break ;/* Create internal flow, validation skips copy action. */ - flow_idx =flow_drv_list_create (dev,MLX5_FLOW_TYPE_GEN , &attr, + flow_idx =mlx5_flow_list_create (dev,MLX5_FLOW_TYPE_GEN , &attr, items, actions, false, &error); flow =mlx5_ipool_get (priv->flows[MLX5_FLOW_TYPE_GEN ], flow_idx);if (!flow)continue ; priv->sh->flow_mreg_c[n++] = idx; -flow_drv_list_destroy (dev,MLX5_FLOW_TYPE_GEN , flow_idx); +mlx5_flow_list_destroy (dev,MLX5_FLOW_TYPE_GEN , flow_idx); }for (; n <MLX5_MREG_C_NUM ; ++n) priv->sh->flow_mreg_c[n] =REG_NON ;
drivers/net/mlx5/mlx5_flow_hw.c +48 -52
190 lines not on this page · raw message
Signature · 1 line
2.21.0
PATCH v5 1/11 net/mlx5: initial design of non template to hws
In reply to Maayan KashaniImplement the frame and needed building
blocks for non template to hws API's.
Added validate, list_create and list_destroy to mlx5_flow_hw_drv_ops. Rename old list_create/list_destroy functions to legacy_* and added a call from verbs/dv ops to the legacy functions.
Updated rte_flow_hw as needed.
Added rte_flow_nt2hws structure for non-template rule data.
squash to net/mlx5: initial design of non template to hws
--- drivers/net/mlx5/linux/mlx5_os.c | 8 +- drivers/net/mlx5/mlx5.h | 9 + drivers/net/mlx5/mlx5_flow.c | 139 +++++--- drivers/net/mlx5/mlx5_flow.h | 74 ++++- drivers/net/mlx5/mlx5_flow_dv.c | 192 +++++++++--- drivers/net/mlx5/mlx5_flow_hw.c | 487 +++++++++++++++++++++++++++-- drivers/net/mlx5/mlx5_flow_verbs.c | 2 + drivers/net/mlx5/mlx5_trigger.c | 6 + drivers/net/mlx5/windows/mlx5_os.c | 8 +- 9 files changed, 808 insertions(+), 117 deletions(-)
drivers/net/mlx5/linux/mlx5_os.c +7 -1
@@ -69,7 +69,7 @@ static rte_spinlock_t mlx5_shared_data_lock = RTE_SPINLOCK_INITIALIZER;static struct mlx5_local_data mlx5_local_data;/* rte flow indexed pool configuration. */ -static struct mlx5_indexed_pool_config icfg[] = { +static const struct mlx5_indexed_pool_config default_icfg[] = { { .size =sizeof (struct rte_flow ), .trunk_size =64 ,
@@ -1080,7 +1080,9 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,struct mlx5_port_info vport_info = { .query_flags =0 };int nl_rdma;int i; +struct mlx5_indexed_pool_config icfg[RTE_DIM (default_icfg)]; +memcpy (icfg, default_icfg,sizeof (icfg));/* Determine if this port representor is supposed to be spawned. */ if (switch_info->representor && dpdk_dev->devargs && !mlx5_representor_match (spawn, eth_da))
@@ -1560,6 +1562,10 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, icfg[i].release_mem_en = !!sh->config.reclaim_mode;if (sh->config.reclaim_mode) icfg[i].per_core_cache =0 ; +#ifdef HAVE_MLX5_HWS_SUPPORT +if (priv->sh->config.dv_flow_en ==2 ) + icfg[i].size =sizeof (struct rte_flow_hw ) +sizeof (struct rte_flow_nt2hws ); +#endif priv->flows[i] =mlx5_ipool_create (&icfg[i]);if (!priv->flows[i]) goto error;
drivers/net/mlx5/mlx5.h +9 -0
@@ -2327,6 +2327,15 @@ int mlx5_flow_validate(struct rte_eth_dev *dev,const struct rte_flow_item items[], const struct rte_flow_action actions[], struct rte_flow_error *error); +uint32_t +mlx5_flow_list_create (struct rte_eth_dev *dev,enum mlx5_flow_type type, +const struct rte_flow_attr *attr, +const struct rte_flow_item items[], +const struct rte_flow_action actions[], +bool external,struct rte_flow_error *error); +void +mlx5_flow_list_destroy (struct rte_eth_dev *dev,enum mlx5_flow_type type, +uint32_t flow_idx); struct rte_flow *mlx5_flow_create(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, const struct rte_flow_item items[],
drivers/net/mlx5/mlx5_flow.c +96 -43
311 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow.h +65 -9
131 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_dv.c +157 -35
316 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_hw.c +459 -28
568 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_verbs.c +2 -0
@@ -2186,6 +2186,8 @@ flow_verbs_sync_domain(struct rte_eth_dev *dev, uint32_t domains, }const struct mlx5_flow_driver_ops mlx5_flow_verbs_drv_ops = { + .list_create = flow_legacy_list_create, + .list_destroy = flow_legacy_list_destroy, .validate = flow_verbs_validate, .prepare = flow_verbs_prepare, .translate = flow_verbs_translate,
drivers/net/mlx5/mlx5_trigger.c +6 -0
@@ -1158,6 +1158,12 @@ mlx5_dev_start(struct rte_eth_dev *dev)DRV_LOG (DEBUG ,"port %u starting device" , dev->data->port_id);#ifdef HAVE_MLX5_HWS_SUPPORT if (priv->sh->config.dv_flow_en ==2 ) { +/*If previous configuration does not exist. */ +if (!(priv->dr_ctx)) { + ret =flow_hw_init (dev,NULL ); +if (ret) +return ret; + }/* If there is no E-Switch, then there are no start/stop order limitations. */ if (!priv->sh->config.dv_esw_en) goto continue_dev_start;
drivers/net/mlx5/windows/mlx5_os.c +7 -1
@@ -35,7 +35,7 @@ static const char *MZ_MLX5_PMD_SHARED_DATA = "mlx5_pmd_shared_data";static rte_spinlock_t mlx5_shared_data_lock =RTE_SPINLOCK_INITIALIZER ;/* rte flow indexed pool configuration. */ -static struct mlx5_indexed_pool_config icfg[] = { +static const struct mlx5_indexed_pool_config default_icfg[] = { { .size =sizeof (struct rte_flow ), .trunk_size =64 ,
@@ -352,7 +352,9 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,int own_domain_id =0 ;uint16_t port_id;int i; +struct mlx5_indexed_pool_config icfg[RTE_DIM (default_icfg)]; +memcpy (icfg, default_icfg,sizeof (icfg));/* Build device name. */ strlcpy (name, dpdk_dev->name,sizeof (name));/* check if the device is already spawned */
@@ -538,6 +540,10 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, icfg[i].release_mem_en = !!sh->config.reclaim_mode;if (sh->config.reclaim_mode) icfg[i].per_core_cache =0 ; +#ifdef HAVE_MLX5_HWS_SUPPORT +if (priv->sh->config.dv_flow_en ==2 ) + icfg[i].size =sizeof (struct rte_flow_hw ) +sizeof (struct rte_flow_nt2hws ); +#endif priv->flows[i] =mlx5_ipool_create (&icfg[i]);if (!priv->flows[i]) goto error;
Signature · 1 line
2.21.0
PATCH v5 2/11 net/mlx5: add dummy last action
From: Bing Zhao <[email protected]>
The RTE_FLOW_ACTION_TYPE_END action needs to be translated into the MLX5DR_ACTION_TYP_LAST for the future usage. It is only needed in the hardware steering backward compatible API.
--- drivers/net/mlx5/mlx5.h | 1 + drivers/net/mlx5/mlx5_flow_hw.c | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+)
drivers/net/mlx5/mlx5.h +1 -0
@@ -1529,6 +1529,7 @@ struct mlx5_dev_ctx_shared {/* Direct Rules tables for FDB, NIC TX+RX */ void *dr_drop_action;/* Pointer to DR drop action, any domain. */ void *pop_vlan_action;/* Pointer to DR pop VLAN action. */ +void *hw_dummy_last;/* Pointer to the DR dummy end action, any domain. */ #if defined(HAVE_IBV_FLOW_DV_SUPPORT ) || !defined(HAVE_INFINIBAND_VERBS_H )struct mlx5_send_to_kernel_action send_to_kernel_action[MLX5DR_TABLE_TYPE_MAX ];#endif
drivers/net/mlx5/mlx5_flow_hw.c +19 -0
@@ -11219,6 +11219,17 @@ flow_hw_configure(struct rte_eth_dev *dev,if (ret) goto err; } +/* +* All domains will use the same dummy action, only used in the backward +* compatible API. Initialize it for only once. No order dependency. +*/ +if (!priv->sh->hw_dummy_last) { + priv->sh->hw_dummy_last =mlx5dr_action_create_last (priv->dr_ctx, +MLX5DR_ACTION_FLAG_HWS_RX ); +if (!priv->sh->hw_dummy_last) +/* Do not overwrite the rte_errno. */ + goto err; + }if (!priv->shared_host)flow_hw_create_send_to_kernel_actions (priv);if (port_attr->nb_conn_tracks || (host_priv && host_priv->hws_ctpool)) {
@@ -11297,6 +11308,10 @@ flow_hw_configure(struct rte_eth_dev *dev,flow_hw_ct_mng_destroy (dev, priv->ct_mng); priv->ct_mng =NULL ; } +if (priv->sh->hw_dummy_last) { +mlx5dr_action_destroy (priv->sh->hw_dummy_last); + priv->sh->hw_dummy_last =NULL ; + }flow_hw_destroy_send_to_kernel_action (priv);flow_hw_cleanup_ctrl_fdb_tables (dev);flow_hw_free_vport_actions (priv);
@@ -11422,6 +11437,10 @@ flow_hw_resource_release(struct rte_eth_dev *dev)mlx5dr_action_destroy (priv->hw_def_miss);flow_hw_destroy_nat64_actions (priv);flow_hw_destroy_vlan (dev); +if (priv->sh->hw_dummy_last) { +mlx5dr_action_destroy (priv->sh->hw_dummy_last); + priv->sh->hw_dummy_last =NULL ; + }flow_hw_destroy_send_to_kernel_action (priv);flow_hw_free_vport_actions (priv);if (priv->acts_ipool) {
Signature · 1 line
2.21.0
PATCH v5 3/11 net/mlx5: add basic actions support for non-template API
In reply to Maayan KashaniFrom: Bing Zhao <[email protected]>
Support JUMP / DROP / QUEUE / MARK / FLAG now.
--- drivers/net/mlx5/mlx5_flow_hw.c | 153 ++++++++++++++++++++++++++++---- 1 file changed, 135 insertions(+), 18 deletions(-)
drivers/net/mlx5/mlx5_flow_hw.c +135 -18
@@ -546,8 +546,7 @@ flow_hw_jump_release(struct rte_eth_dev *dev, struct mlx5_hw_jump_action *jump)struct mlx5_priv *priv = dev->data->dev_private;struct mlx5_flow_group *grp; - grp =container_of - (jump, struct mlx5_flow_group, jump); + grp = container_of(jump, struct mlx5_flow_group, jump);mlx5_hlist_unregister (priv->sh->flow_tbls, &grp->entry); }
@@ -647,17 +646,9 @@ flow_hw_template_destroy_mhdr_action(struct mlx5_hw_modify_header_action *mhdr)* Pointer to the template HW steering DR actions. */ static void -__flow_hw_action_template_destroy (struct rte_eth_dev *dev, -struct mlx5_hw_actions *acts) +__flow_hw_actions_release (struct rte_eth_dev *dev,struct mlx5_hw_actions *acts) {struct mlx5_priv *priv = dev->data->dev_private; -struct mlx5_action_construct_data *data; - -while (!LIST_EMPTY (&acts->act_list)) { - data =LIST_FIRST (&acts->act_list); -LIST_REMOVE (data, next); -mlx5_ipool_free (priv->acts_ipool, data->idx); - }if (acts->mark) if (!(rte_atomic_fetch_sub_explicit(&priv->hws_mark_refcnt, 1,
@@ -702,6 +693,32 @@ __flow_hw_action_template_destroy(struct rte_eth_dev *dev, } } +/** +* Destroy DR actions created by action template. +* +* For DR actions created during table creation's action translate. +* Need to destroy the DR action when destroying the table. +* +* @param[in] dev +* Pointer to the rte_eth_dev structure. +* @param[in] acts +* Pointer to the template HW steering DR actions. +*/ +static void +__flow_hw_action_template_destroy (struct rte_eth_dev *dev,struct mlx5_hw_actions *acts) +{ +struct mlx5_priv *priv = dev->data->dev_private; +struct mlx5_action_construct_data *data; + +while (!LIST_EMPTY (&acts->act_list)) { + data =LIST_FIRST (&acts->act_list); +LIST_REMOVE (data, next); +mlx5_ipool_free (priv->acts_ipool, data->idx); + } + +__flow_hw_actions_release (dev, acts); +} +/** * Append dynamic action to the dynamic action list. *
@@ -12690,14 +12707,113 @@ static int flow_hw_prepare(struct rte_eth_dev *dev,return 0 ; } -static int flow_hw_translate_actions(struct rte_eth_dev *dev __rte_unused, - const struct rte_flow_attr *attr __rte_unused, - const struct rte_flow_action actions[] __rte_unused, - struct rte_flow_hw *flow __rte_unused, - struct rte_flow_error *error __rte_unused) +static int +flow_hw_translate_actions (struct rte_eth_dev *dev, +const struct rte_flow_attr *attr, +const struct rte_flow_action actions[], +struct rte_flow_hw *flow, +struct mlx5_hw_actions *hw_acts, +bool external, +struct rte_flow_error *error) { -/* TODO implement */ +struct mlx5_priv *priv = dev->data->dev_private; +enum mlx5dr_table_type type; +enum mlx5_hw_action_flag_type flag_type; +bool actions_end = false; +uint64_t action_flags =0 ;/* to be used when needed */ +uint32_t actions_n =0 ; +uint32_t mark_id; +uint32_t jump_group; +bool is_mark; +struct mlx5_flow_template_table_cfg tbl_cfg; +enum mlx5_flow_fate_type fate_type =MLX5_FLOW_FATE_NONE ; + +if (attr->transfer) + type =MLX5DR_TABLE_TYPE_FDB ; +else if (attr->egress) + type =MLX5DR_TABLE_TYPE_NIC_TX ; +else + type =MLX5DR_TABLE_TYPE_NIC_RX ; +/* The group in the attribute translation was done in advance. */ + flag_type = (attr->group ==0 ) ?MLX5_HW_ACTION_FLAG_ROOT : +MLX5_HW_ACTION_FLAG_NONE_ROOT ; +for (; !actions_end; actions++) { +switch (actions->type) { +case RTE_FLOW_ACTION_TYPE_VOID : +break ; +case RTE_FLOW_ACTION_TYPE_DROP : + hw_acts->rule_acts[actions_n++].action = priv->hw_drop[flag_type]; + fate_type =MLX5_FLOW_FATE_DROP ; +break ; +case RTE_FLOW_ACTION_TYPE_FLAG : +case RTE_FLOW_ACTION_TYPE_MARK : + is_mark = actions->type ==RTE_FLOW_ACTION_TYPE_MARK ; + mark_id = is_mark ? + ((const struct rte_flow_action_mark *)(actions->conf))->id : +MLX5_FLOW_MARK_DEFAULT ; + hw_acts->rule_acts[actions_n].tag.value =mlx5_flow_mark_set (mark_id); + hw_acts->rule_acts[actions_n].action = priv->hw_tag[flag_type]; + actions_n++; + action_flags |= is_mark ?MLX5_FLOW_ACTION_MARK :MLX5_FLOW_ACTION_FLAG ; + hw_acts->mark = true; +rte_atomic_fetch_add_explicit (&priv->hws_mark_refcnt,1 , + rte_memory_order_relaxed); +flow_hw_rxq_flag_set (dev, true); +break ; +case RTE_FLOW_ACTION_TYPE_JUMP : + jump_group = ((const struct rte_flow_action_jump *)actions->conf)->group; + tbl_cfg.attr.flow_attr = *attr; + tbl_cfg.external = external; +/* The flow_hw_jump_action_register() can be refactored. */ + hw_acts->jump =flow_hw_jump_action_register (dev, &tbl_cfg, + jump_group, error); +if (hw_acts->jump ==NULL ) + goto clean_up; + hw_acts->rule_acts[actions_n++].action = + (flag_type ==MLX5_HW_ACTION_FLAG_NONE_ROOT ) ? + hw_acts->jump->hws_action : hw_acts->jump->root_action; + action_flags |=MLX5_FLOW_ACTION_JUMP ; + fate_type =MLX5_FLOW_FATE_JUMP ; +break ; +case RTE_FLOW_ACTION_TYPE_QUEUE : +/* Right now, only Rx supports the TIR, validation is needed. */ + hw_acts->tir =flow_hw_tir_action_register (dev, + mlx5_hw_act_flag[flag_type][type], actions); +if (hw_acts->tir ==NULL ) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION ,NULL , +"Failed to translate queue." ); + goto clean_up; + } + action_flags |=MLX5_FLOW_ACTION_QUEUE ; + fate_type =MLX5_FLOW_FATE_QUEUE ; +break ; +case RTE_FLOW_ACTION_TYPE_END : +/* +* Using NULL action right now, maybe a new API can be used +* to create a dummy action with type MLX5DR_ACTION_TYP_LAST. +*/ + hw_acts->rule_acts[actions_n++].action = priv->sh->hw_dummy_last; + actions_end = true; +break ; +default : +break ; + } + } +if (fate_type ==MLX5_FLOW_FATE_QUEUE ) { + hw_acts->rule_acts[actions_n++].action = hw_acts->tir->action; + flow->hrxq = hw_acts->tir; + }else { +if (fate_type ==MLX5_FLOW_FATE_JUMP ) + flow->jump = hw_acts->jump; + } +/* Total actions number should be validated before. */ +MLX5_ASSERT (actions_n <=MLX5_HW_MAX_ACTS );return 0 ; +clean_up: +/* Make sure that there is no garbage in the actions. */ +__flow_hw_actions_release (dev, hw_acts); +return -rte_errno; } static int flow_hw_register_matcher(struct rte_eth_dev *dev,
@@ -12891,7 +13007,8 @@ static int flow_hw_create_flow(struct rte_eth_dev *dev,if (ret) goto error; - ret =flow_hw_translate_actions (dev, attr, actions, *flow, error); +/* Note: the actions should be saved in the sub-flow rule itself for reference. */ + ret =flow_hw_translate_actions (dev, attr, actions, *flow, &hw_act, external, error);if (ret) goto error;
Signature · 1 line
2.21.0
PATCH v5 4/11 net/mlx5: add default miss action support in nt2hws mode
In reply to Maayan KashaniFrom: Bing Zhao <[email protected]>
The validation will be handled later.
Now it only supports the SEND_TO_KERNEL on non-root tables.
--- drivers/net/mlx5/mlx5_flow_hw.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-)
drivers/net/mlx5/mlx5_flow_hw.c +20 -3
@@ -12721,22 +12721,28 @@ flow_hw_translate_actions(struct rte_eth_dev *dev,enum mlx5_hw_action_flag_type flag_type;bool actions_end = false;uint64_t action_flags =0 ;/* to be used when needed */ +int ret;uint32_t actions_n =0 ;uint32_t mark_id;uint32_t jump_group; +uint32_t src_group =0 ;bool is_mark;struct mlx5_flow_template_table_cfg tbl_cfg;enum mlx5_flow_fate_type fate_type =MLX5_FLOW_FATE_NONE ; +RTE_SET_USED (action_flags); +/* The group in the attribute translation was done in advance. */ + ret =__translate_group (dev, attr, external, attr->group, &src_group, error); +if (ret) +return ret;if (attr->transfer) type =MLX5DR_TABLE_TYPE_FDB ;else if (attr->egress) type =MLX5DR_TABLE_TYPE_NIC_TX ;else type =MLX5DR_TABLE_TYPE_NIC_RX ; -/* The group in the attribute translation was done in advance. */ - flag_type = (attr->group ==0 ) ?MLX5_HW_ACTION_FLAG_ROOT : -MLX5_HW_ACTION_FLAG_NONE_ROOT ; + flag_type = (src_group ==0 ) ?MLX5_HW_ACTION_FLAG_ROOT : +MLX5_HW_ACTION_FLAG_NONE_ROOT ;for (; !actions_end; actions++) {switch (actions->type) {case RTE_FLOW_ACTION_TYPE_VOID :
@@ -12788,6 +12794,17 @@ flow_hw_translate_actions(struct rte_eth_dev *dev, action_flags |=MLX5_FLOW_ACTION_QUEUE ; fate_type =MLX5_FLOW_FATE_QUEUE ;break ; +case RTE_FLOW_ACTION_TYPE_SEND_TO_KERNEL : +if (src_group ==0 ) { +rte_flow_error_set (error,ENOTSUP , +RTE_FLOW_ERROR_TYPE_ACTION ,NULL , +"Send to kernel action on the root table is" +" not supported in HWS mode now." ); + goto clean_up; + } + hw_acts->rule_acts[actions_n++].action = priv->hw_send_to_kernel[type]; + action_flags |=MLX5_FLOW_ACTION_SEND_TO_KERNEL ; +break ;case RTE_FLOW_ACTION_TYPE_END :/* * Using NULL action right now, maybe a new API can be used
Signature · 1 line
2.21.0
PATCH v5 5/11 net/mlx5: add ASO actions support to non-template mode
In reply to Maayan KashaniThis patch adds counter, connection tracking, meter and age actions support to non-template mode.
For CT, counter and meter: if no previous allocation was handled by hw configure routine,
Half of the maximum supported number of objects will be allocated. For AGE action, if no counters were allocated,
allocate half of the maximum,
and then allocate same number of AGE objects.
Also extracted the shared host handling to the configure function. And align all ASO actions to have init function
for future code improvement.
This patch does not affect SW Steering flow engine.
--- drivers/net/mlx5/mlx5.h | 7 ++ drivers/net/mlx5/mlx5_flow_hw.c | 185 +++++++++++++++++++++++++++----- drivers/net/mlx5/mlx5_hws_cnt.c | 47 ++++---- drivers/net/mlx5/mlx5_hws_cnt.h | 10 +- 4 files changed, 190 insertions(+), 59 deletions(-)
drivers/net/mlx5/mlx5.h +7 -0
@@ -812,6 +812,13 @@ struct mlx5_dev_shared_port {/* Only yellow color valid. */ #define MLX5_MTR_POLICY_MODE_OY 3 +/* Max number of meters allocated in non template mode. */ +#define MLX5_MTR_NT_MAX (1 << 23)/*TODO verify number */ +/* Max number of connection tracking allocated in non template mode */ +#define MLX5_CT_NT_MAX (1 << 23)/*TODO verify number */ +/* Max number of counters allocated in non template mode */ +#define MLX5_CNT_MAX (1 << 23)/*TODO verify number */ +enum mlx5_meter_domain {MLX5_MTR_DOMAIN_INGRESS ,MLX5_MTR_DOMAIN_EGRESS ,
drivers/net/mlx5/mlx5_flow_hw.c +157 -28
280 lines not on this page · raw message
drivers/net/mlx5/mlx5_hws_cnt.c +20 -27
115 lines not on this page · raw message
drivers/net/mlx5/mlx5_hws_cnt.h +6 -4
@@ -712,9 +712,10 @@ mlx5_hws_cnt_service_thread_create(struct mlx5_dev_ctx_shared *sh);void mlx5_hws_cnt_service_thread_destroy (struct mlx5_dev_ctx_shared *sh); -struct mlx5_hws_cnt_pool * +int mlx5_hws_cnt_pool_create (struct rte_eth_dev *dev, -const struct rte_flow_port_attr *pattr,uint16_t nb_queue); +uint32_t nb_counters,uint16_t nb_queue, +struct mlx5_hws_cnt_pool *chost); void mlx5_hws_cnt_pool_destroy(struct mlx5_dev_ctx_shared *sh,
@@ -744,8 +745,9 @@ mlx5_hws_age_context_get(struct mlx5_priv *priv, uint32_t idx);int mlx5_hws_age_pool_init (struct rte_eth_dev *dev, -const struct rte_flow_port_attr *attr, -uint16_t nb_queues); +uint32_t nb_aging_objects, +uint16_t nb_queues, +bool strict_queue);void mlx5_hws_age_pool_destroy (struct mlx5_priv *priv);
Signature · 1 line
2.21.0
PATCH v5 6/11 net/mlx5: fix segfault on counter pool destroy
In reply to Maayan KashaniIf the counter pool was not added to list,
and an error state was reached,
on attempt to destroy the counter pool, segmentation fault was received during list remove action.
Added a check to verify the list is not empty before trying to remove the cpool from the list.
Invalid state, leading to segfault,
can also be reached in the following scenario:
1. mlx5_hws_cnt_pool_init() does a zmalloc and initializes most
of the fields of cpool, but does not initialize the next field.
2. mlx5_hws_cnt_pool_dcs_alloc() attempts to bulk allocate flow counters.
If this fails, we skip straight to 4.
In HW, this can fail simply if FW doesn't support bulk flow counter allocation.
3. Right before the goto error, we insert the cpool to the hws_cpool_list.
This is where the next field is initialized.
4. mlx5_hws_cnt_pool_destroy() assumes the cpool's next field
is initialized and SEGVs if not.
So, added a guard against cases where the entry was uninitialized (checking le_prev field is not NULL).
--- drivers/net/mlx5/mlx5_hws_cnt.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/mlx5/mlx5_hws_cnt.c +3 -1
@@ -718,7 +718,9 @@ mlx5_hws_cnt_pool_destroy(struct mlx5_dev_ctx_shared *sh,* Maybe blocked for at most 200ms here. */ rte_spinlock_lock (&sh->cpool_lock); -LIST_REMOVE (cpool, next); +/* Try to remove cpool before it was added to list caused segfault. */ +if (!LIST_EMPTY (&sh->hws_cpool_list) && cpool->next.le_prev) +LIST_REMOVE (cpool, next);rte_spinlock_unlock (&sh->cpool_lock);if (cpool->cfg.host_cpool ==NULL ) {if (--sh->cnt_svc->refcnt ==0 )
Signature · 1 line
2.21.0
PATCH v5 7/11 net/mlx5: abstract action handling and enable reconfigure
In reply to Maayan Kashanireuse HWS actions translation code in order to create the actions for lower layer.
All actions are handled as non masked. Therefore, will be translated in the rule construct phase shared with the template code
and not during the action template translate.
Currently there is no option to reconfigure in template API’s. To support non template API and template API simultaneously, There is a need to enable the user to reconfigure after default configuration was applied by the driver on port start.
Fix flow create ptr
In SWS the return flow pointer is the flow index, in HWS the return flow pointer is the flow data pointer. Currently the return value of non template code did not Enable destroy or quary.
--- drivers/net/mlx5/mlx5.h | 25 +- drivers/net/mlx5/mlx5_flow.c | 31 +- drivers/net/mlx5/mlx5_flow.h | 14 +- drivers/net/mlx5/mlx5_flow_dv.c | 18 +- drivers/net/mlx5/mlx5_flow_hw.c | 831 ++++++++++++++++---------------- 5 files changed, 473 insertions(+), 446 deletions(-)
drivers/net/mlx5/mlx5.h +13 -12
@@ -813,11 +813,11 @@ struct mlx5_dev_shared_port {#define MLX5_MTR_POLICY_MODE_OY 3/* Max number of meters allocated in non template mode. */ -#define MLX5_MTR_NT_MAX (1 << 23)/*TODO verify number */ +#define MLX5_MTR_NT_MAX (1 << 23)/* Max number of connection tracking allocated in non template mode */ -#define MLX5_CT_NT_MAX (1 << 23)/*TODO verify number */ +#define MLX5_CT_NT_MAX (1 << 23)/* Max number of counters allocated in non template mode */ -#define MLX5_CNT_MAX (1 << 23)/*TODO verify number */ +#define MLX5_CNT_MAX (1 << 23)enum mlx5_meter_domain {MLX5_MTR_DOMAIN_INGRESS ,
@@ -1536,7 +1536,6 @@ struct mlx5_dev_ctx_shared {/* Direct Rules tables for FDB, NIC TX+RX */ void *dr_drop_action;/* Pointer to DR drop action, any domain. */ void *pop_vlan_action;/* Pointer to DR pop VLAN action. */ -void *hw_dummy_last;/* Pointer to the DR dummy end action, any domain. */ #if defined(HAVE_IBV_FLOW_DV_SUPPORT ) || !defined(HAVE_INFINIBAND_VERBS_H )struct mlx5_send_to_kernel_action send_to_kernel_action[MLX5DR_TABLE_TYPE_MAX ];#endif
@@ -1817,6 +1816,14 @@ struct mlx5_hw_ctrl_flow {struct mlx5_hw_ctrl_flow_info info; }; +/* HW Steering port configuration passed to rte_flow_configure(). */ +struct mlx5_flow_hw_attr { +struct rte_flow_port_attr port_attr; +uint16_t nb_queue; +struct rte_flow_queue_attr *queue_attr; +bool nt_mode; +}; +/* * Flow rule structure for flow engine mode control, focus on group 0. * Apply to all supported domains.
@@ -1838,12 +1845,6 @@ struct rte_pmd_mlx5_flow_engine_mode_info {/* The list is maintained in insertion order. */ LIST_HEAD(hot_up_info, mlx5_dv_flow_info) hot_upgrade; }; -/* HW Steering port configuration passed to rte_flow_configure(). */ -struct mlx5_flow_hw_attr { -struct rte_flow_port_attr port_attr; -uint16_t nb_queue; -struct rte_flow_queue_attr *queue_attr; -};struct mlx5_flow_hw_ctrl_rx ;
@@ -2335,7 +2336,7 @@ int mlx5_flow_validate(struct rte_eth_dev *dev,const struct rte_flow_item items[], const struct rte_flow_action actions[], struct rte_flow_error *error); -uint32_t +uintptr_t mlx5_flow_list_create(struct rte_eth_dev *dev, enum mlx5_flow_type type, const struct rte_flow_attr *attr, const struct rte_flow_item items[],
@@ -2343,7 +2344,7 @@ mlx5_flow_list_create(struct rte_eth_dev *dev, enum mlx5_flow_type type, bool external, struct rte_flow_error *error);void mlx5_flow_list_destroy (struct rte_eth_dev *dev,enum mlx5_flow_type type, -uint32_t flow_idx); +uintptr_t flow_idx); struct rte_flow *mlx5_flow_create(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, const struct rte_flow_item items[],
drivers/net/mlx5/mlx5_flow.c +14 -17
@@ -4985,7 +4985,7 @@ flow_check_hairpin_split(struct rte_eth_dev *dev,/* Declare flow create/destroy prototype in advance. */ -static uint32_t +static uintptr_t flow_drv_list_create(struct rte_eth_dev *dev, enum mlx5_flow_type type, const struct rte_flow_attr *attr, const struct rte_flow_item items[],
@@ -4994,7 +4994,7 @@ flow_drv_list_create(struct rte_eth_dev *dev, enum mlx5_flow_type type,static void flow_drv_list_destroy (struct rte_eth_dev *dev,enum mlx5_flow_type type, -uint32_t flow_idx); +uintptr_t flow_idx); int flow_dv_mreg_match_cb(void *tool_ctx __rte_unused,
@@ -7298,7 +7298,7 @@ flow_tunnel_from_rule(const struct mlx5_flow *flow)* @return * A flow index on success, 0 otherwise and rte_errno is set. */ -uint32_t +uintptr_t flow_legacy_list_create(struct rte_eth_dev *dev, enum mlx5_flow_type type, const struct rte_flow_attr *attr, const struct rte_flow_item items[],
@@ -7973,7 +7973,7 @@ mlx5_flow_create(struct rte_eth_dev *dev,struct mlx5_priv *priv = dev->data->dev_private;struct rte_flow_attr *new_attr = (void *)(uintptr_t )attr;uint32_t prio = attr->priority; -uint32_t flow_idx; +uintptr_t flow_idx;/* * If the device is not started yet, it is not allowed to created a
@@ -8007,7 +8007,7 @@ mlx5_flow_create(struct rte_eth_dev *dev,return (void *)(uintptr_t )flow_idx; } -uint32_t +uintptr_t mlx5_flow_list_create(struct rte_eth_dev *dev, enum mlx5_flow_type type, const struct rte_flow_attr *attr, const struct rte_flow_item items[],
@@ -8018,7 +8018,7 @@ mlx5_flow_list_create(struct rte_eth_dev *dev, enum mlx5_flow_type type, error); } -uint32_t +uintptr_t flow_drv_list_create(struct rte_eth_dev *dev, enum mlx5_flow_type type, const struct rte_flow_attr *attr, const struct rte_flow_item items[],
@@ -8043,7 +8043,7 @@ flow_drv_list_create(struct rte_eth_dev *dev, enum mlx5_flow_type type,*/ void flow_legacy_list_destroy (struct rte_eth_dev *dev,enum mlx5_flow_type type, -uint32_t flow_idx) +uintptr_t flow_idx) {struct mlx5_priv *priv = dev->data->dev_private;struct rte_flow *flow =mlx5_ipool_get (priv->flows[type], (uint32_t )flow_idx);
@@ -8074,7 +8074,7 @@ flow_legacy_list_destroy(struct rte_eth_dev *dev, enum mlx5_flow_type type,static void flow_drv_list_destroy (struct rte_eth_dev *dev,enum mlx5_flow_type type, -uint32_t flow_idx) +uintptr_t flow_idx) {const struct mlx5_flow_driver_ops *fops;struct rte_flow_attr attr = { .transfer =0 };
@@ -8086,7 +8086,7 @@ flow_drv_list_destroy(struct rte_eth_dev *dev, enum mlx5_flow_type type,void mlx5_flow_list_destroy (struct rte_eth_dev *dev,enum mlx5_flow_type type, -uint32_t flow_idx) +uintptr_t flow_idx) {flow_drv_list_destroy (dev, type, flow_idx); }
@@ -8115,12 +8115,14 @@ mlx5_flow_list_flush(struct rte_eth_dev *dev, enum mlx5_flow_type type,if (priv->sh->config.dv_flow_en ==2 && type ==MLX5_FLOW_TYPE_GEN ) {flow_hw_q_flow_flush (dev,NULL ); -return ; }#endif - MLX5_IPOOL_FOREACH(priv->flows[type], fidx, flow) { -flow_drv_list_destroy (dev, type, fidx); +if (priv->sh->config.dv_flow_en ==2 ) { +flow_drv_list_destroy (dev, type, (uintptr_t )flow); + }else { +flow_drv_list_destroy (dev, type, fidx); + }if (unlikely (mlx5_need_cache_flow (priv,NULL ) && type ==MLX5_FLOW_TYPE_GEN )) { flow_info =LIST_FIRST (&mode_info->hot_upgrade);while (flow_info) {
@@ -8581,11 +8583,6 @@ mlx5_flow_destroy(struct rte_eth_dev *dev,struct rte_pmd_mlx5_flow_engine_mode_info *mode_info = &priv->mode_info;struct mlx5_dv_flow_info *flow_info; -if (priv->sh->config.dv_flow_en ==2 ) -return rte_flow_error_set (error,ENOTSUP , -RTE_FLOW_ERROR_TYPE_UNSPECIFIED , -NULL , -"Flow non-Q destruction not supported" );flow_drv_list_destroy (dev,MLX5_FLOW_TYPE_GEN , (uintptr_t )(void *)flow);if (unlikely (mlx5_need_cache_flow (priv,NULL ))) {
drivers/net/mlx5/mlx5_flow.h +9 -5
@@ -1320,6 +1320,8 @@ struct rte_flow_nt2hws {struct mlx5dr_bwc_rule *nt_rule;/** The matcher for non template api. */ struct mlx5_flow_dv_matcher *matcher; +/**< Auxiliary data stored per flow. */ +struct rte_flow_hw_aux *flow_aux; } __rte_packed;/** HWS flow struct. */
@@ -1354,12 +1356,14 @@ struct rte_flow_hw {struct mlx5_hrxq *hrxq; }; +/** Equals true if it is non template rule. */ +bool nt_rule;/** * Padding for alignment to 56 bytes. * Since mlx5dr rule is 72 bytes, whole flow is contained within 128 B (2 cache lines). * This space is reserved for future additions to flow struct. */ -uint8_t padding[10 ]; +uint8_t padding[9 ];/** HWS layer data struct. */ uint8_t rule[]; } __rte_packed;
@@ -2204,7 +2208,7 @@ int flow_hw_init(struct rte_eth_dev *dev, struct rte_flow_error *error); -typedef uint32_t (*mlx5_flow_list_create_t)(struct rte_eth_dev *dev, +typedef uintptr_t (*mlx5_flow_list_create_t)(struct rte_eth_dev *dev, enum mlx5_flow_type type, const struct rte_flow_attr *attr, const struct rte_flow_item items[],
@@ -2213,7 +2217,7 @@ typedef uint32_t (*mlx5_flow_list_create_t)(struct rte_eth_dev *dev, struct rte_flow_error *error);typedef void (*mlx5_flow_list_destroy_t )(struct rte_eth_dev *dev,enum mlx5_flow_type type, -uint32_t flow_idx); +uintptr_t flow_idx); typedef int (*mlx5_flow_validate_t)(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, const struct rte_flow_item items[],
@@ -3476,13 +3480,13 @@ int mlx5_flow_item_field_width(struct rte_eth_dev *dev, enum rte_flow_field_id field, int inherit, const struct rte_flow_attr *attr, struct rte_flow_error *error); -uint32_t flow_legacy_list_create (struct rte_eth_dev *dev,enum mlx5_flow_type type, +uintptr_t flow_legacy_list_create (struct rte_eth_dev *dev,enum mlx5_flow_type type,const struct rte_flow_attr *attr,const struct rte_flow_item items[],const struct rte_flow_action actions[],bool external,struct rte_flow_error *error);void flow_legacy_list_destroy (struct rte_eth_dev *dev,enum mlx5_flow_type type, -uint32_t flow_idx); +uintptr_t flow_idx); static __rte_always_inline int flow_hw_get_srh_flex_parser_byte_off_from_ctx(void *dr_ctx __rte_unused)
drivers/net/mlx5/mlx5_flow_dv.c +15 -3
@@ -11901,12 +11901,14 @@ flow_matcher_create_cb(void *tool_ctx, void *cb_ctx)struct mlx5_flow_cb_ctx *ctx = cb_ctx;struct mlx5_flow_dv_matcher *ref = ctx->data;struct mlx5_flow_dv_matcher *resource; +#ifdef HAVE_MLX5_HWS_SUPPORT +const struct rte_flow_item *items; +#endif struct mlx5dv_flow_matcher_attr dv_attr = { .type =IBV_FLOW_ATTR_NORMAL , .match_mask = (void *)&ref->mask, }; -struct mlx5_flow_tbl_data_entry *tbl =container_of (ref->tbl, -typeof (*tbl), tbl); +struct mlx5_flow_tbl_data_entry *tbl;int ret; resource = mlx5_malloc(MLX5_MEM_ZERO, sizeof(*resource), 0,
@@ -11917,9 +11919,9 @@ flow_matcher_create_cb(void *tool_ctx, void *cb_ctx) "cannot create matcher");return NULL ; } -/*Consider memcpy(resource, ref, sizeof(*resource));*/ *resource = *ref;if (sh->config.dv_flow_en !=2 ) { + tbl =container_of (ref->tbl,typeof (*tbl), tbl); dv_attr.match_criteria_enable =flow_dv_matcher_enable (resource->mask.buf); __flow_dv_adjust_buf_size(&ref->mask.size,
@@ -11937,6 +11939,16 @@ flow_matcher_create_cb(void *tool_ctx, void *cb_ctx) "cannot create matcher");return NULL ; } + }else { +#ifdef HAVE_MLX5_HWS_SUPPORT + items = *((const struct rte_flow_item **)(ctx->data2)); + resource->matcher_object =mlx5dr_bwc_matcher_create + (resource->group->tbl, resource->priority, items); +if (!(resource->matcher_object)) +return NULL ; +#else +return NULL ; +#endif }return &resource->entry; }
drivers/net/mlx5/mlx5_flow_hw.c +422 -409
1,352 lines not on this page · raw message
Signature · 1 line
2.21.0
PATCH v5 8/11 common/mlx5: read connection tracking attributes
In reply to Maayan KashaniNeed to read maximum connection tracking
objects from HCA attributes.
--- drivers/common/mlx5/mlx5_devx_cmds.c | 3 +++ drivers/common/mlx5/mlx5_devx_cmds.h | 1 + 2 files changed, 4 insertions(+)
drivers/common/mlx5/mlx5_devx_cmds.c +3 -0
@@ -1170,6 +1170,9 @@ mlx5_devx_cmd_query_hca_attr(void *ctx, (rc &MLX5_CROSS_VHCA_ALLOWED_OBJS_TIR ) && (rc &MLX5_CROSS_VHCA_ALLOWED_OBJS_FT ) && (rc &MLX5_CROSS_VHCA_ALLOWED_OBJS_RTC ); +if (attr->ct_offload) + attr->log_max_conn_track_offload =MLX5_GET (cmd_hca_cap_2, hcattr, + log_max_conn_track_offload); }if (attr->log_min_stride_wqe_sz ==0 ) attr->log_min_stride_wqe_sz =MLX5_MPRQ_LOG_MIN_STRIDE_WQE_SIZE ;
drivers/common/mlx5/mlx5_devx_cmds.h +1 -0
@@ -326,6 +326,7 @@ struct mlx5_hca_attr { uint32_t wqe_based_flow_table_sup:1;uint8_t max_header_modify_pattern_length;uint64_t system_image_guid; + uint32_t log_max_conn_track_offload:5; };/* LAG Context. */
Signature · 1 line
2.21.0
PATCH v5 9/11 net/mlx5: support bulk actions in non template mode
In reply to Maayan KashaniAdd support for encap/decap/modify header action for non template API.
Save 1 action per bulk according to action data. Reuse action if possible.
Store actions same as for SWS today, use same key structure.
--- drivers/net/mlx5/mlx5_flow.h | 44 ++++-- drivers/net/mlx5/mlx5_flow_dv.c | 268 ++++++++++++++++++++------------ drivers/net/mlx5/mlx5_flow_hw.c | 184 ++++++++++++++++++++-- 3 files changed, 368 insertions(+), 128 deletions(-)
drivers/net/mlx5/mlx5_flow.h +32 -12
@@ -671,6 +671,10 @@ struct mlx5_flow_dv_modify_hdr_resource {struct mlx5_list_entry entry;void *action;/**< Modify header action object. */ uint32_t idx; +#ifdef HAVE_MLX5_HWS_SUPPORT +void *mh_dr_pattern;/**< Modify header DR pattern(HWS only). */ +#endif +uint64_t flags;/**< Flags for RDMA API(HWS only). */ /* Key area for hash list matching: */ uint8_t ft_type;/**< Flow table type, Rx or Tx. */ uint8_t actions_num;/**< Number of modification actions. */
@@ -1322,7 +1326,11 @@ struct rte_flow_nt2hws {struct mlx5_flow_dv_matcher *matcher;/**< Auxiliary data stored per flow. */ struct rte_flow_hw_aux *flow_aux; -} __rte_packed; +/** Modify header pointer. */ +struct mlx5_flow_dv_modify_hdr_resource *modify_hdr; +/** Encap/decap index. */ +uint32_t rix_encap_decap; +};/** HWS flow struct. */ struct rte_flow_hw {
@@ -3238,14 +3246,14 @@ struct mlx5_list_entry *flow_dv_tag_clone_cb(void *tool_ctx, void *cb_ctx);void flow_dv_tag_clone_free_cb (void *tool_ctx,struct mlx5_list_entry *entry); -int flow_dv_modify_match_cb (void *tool_ctx,struct mlx5_list_entry *entry, +int flow_modify_match_cb (void *tool_ctx,struct mlx5_list_entry *entry,void *cb_ctx); -struct mlx5_list_entry *flow_dv_modify_create_cb (void *tool_ctx,void *ctx); -void flow_dv_modify_remove_cb (void *tool_ctx,struct mlx5_list_entry *entry); -struct mlx5_list_entry *flow_dv_modify_clone_cb (void *tool_ctx, +struct mlx5_list_entry *flow_modify_create_cb (void *tool_ctx,void *ctx); +void flow_modify_remove_cb (void *tool_ctx,struct mlx5_list_entry *entry); +struct mlx5_list_entry *flow_modify_clone_cb (void *tool_ctx,struct mlx5_list_entry *oentry,void *ctx); -void flow_dv_modify_clone_free_cb (void *tool_ctx, +void flow_modify_clone_free_cb (void *tool_ctx,struct mlx5_list_entry *entry);struct mlx5_list_entry *flow_dv_mreg_create_cb (void *tool_ctx,void *ctx);
@@ -3257,18 +3265,30 @@ struct mlx5_list_entry *flow_dv_mreg_clone_cb(void *tool_ctx, void *ctx);void flow_dv_mreg_clone_free_cb (void *tool_ctx,struct mlx5_list_entry *entry); -int flow_dv_encap_decap_match_cb (void *tool_ctx,struct mlx5_list_entry *entry, +int flow_encap_decap_match_cb (void *tool_ctx,struct mlx5_list_entry *entry,void *cb_ctx); -struct mlx5_list_entry *flow_dv_encap_decap_create_cb (void *tool_ctx, +struct mlx5_list_entry *flow_encap_decap_create_cb (void *tool_ctx,void *cb_ctx); -void flow_dv_encap_decap_remove_cb (void *tool_ctx, +void flow_encap_decap_remove_cb (void *tool_ctx,struct mlx5_list_entry *entry); -struct mlx5_list_entry *flow_dv_encap_decap_clone_cb (void *tool_ctx, +struct mlx5_list_entry *flow_encap_decap_clone_cb (void *tool_ctx,struct mlx5_list_entry *entry,void *cb_ctx); -void flow_dv_encap_decap_clone_free_cb (void *tool_ctx, +void flow_encap_decap_clone_free_cb (void *tool_ctx,struct mlx5_list_entry *entry); - +int __flow_encap_decap_resource_register + (struct rte_eth_dev *dev, +struct mlx5_flow_dv_encap_decap_resource *resource, +bool is_root, +struct mlx5_flow_dv_encap_decap_resource **encap_decap, +struct rte_flow_error *error); +int __flow_modify_hdr_resource_register + (struct rte_eth_dev *dev, +struct mlx5_flow_dv_modify_hdr_resource *resource, +struct mlx5_flow_dv_modify_hdr_resource **modify, +struct rte_flow_error *error); +int flow_encap_decap_resource_release (struct rte_eth_dev *dev, +uint32_t encap_decap_idx);int flow_matcher_match_cb (void *tool_ctx,struct mlx5_list_entry *entry,void *ctx);struct mlx5_list_entry *flow_matcher_create_cb (void *tool_ctx,void *ctx);
drivers/net/mlx5/mlx5_flow_dv.c +165 -103
459 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_hw.c +171 -13
299 lines not on this page · raw message
Signature · 1 line
2.21.0
PATCH v5 10/11 net/mlx5: use non const max number for ASO actions
In reply to Maayan KashaniFor ASO max allocations in non-template mode,
Read FW capabilities instead of using consts.
--- drivers/net/mlx5/mlx5.h | 17 ++++++++++++----- drivers/net/mlx5/mlx5_flow_hw.c | 13 +++++++++---- drivers/net/mlx5/mlx5_flow_meter.c | 25 +++++++++++++++++++++---- 3 files changed, 42 insertions(+), 13 deletions(-)
drivers/net/mlx5/mlx5.h +12 -5
@@ -812,12 +812,18 @@ struct mlx5_dev_shared_port {/* Only yellow color valid. */ #define MLX5_MTR_POLICY_MODE_OY 3 +/* Max number of meters. */ +#define MLX5_MTR_MAX (priv) (mlx5_flow_mtr_max_get(priv))/* Max number of meters allocated in non template mode. */ -#define MLX5_MTR_NT_MAX (1 << 23) -/* Max number of connection tracking allocated in non template mode */ -#define MLX5_CT_NT_MAX (1 << 23) -/* Max number of counters allocated in non template mode */ -#define MLX5_CNT_MAX (1 << 23) +#define MLX5_MTR_NT_MAX (priv) (MLX5_MTR_MAX(priv) >> 1) +/* Max number of connection tracking. */ +#define MLX5_CT_MAX (priv) (1 << (priv)->sh->cdev->config.hca_attr.log_max_conn_track_offload) +/* Max number of connection tracking allocated in non template mode. */ +#define MLX5_CT_NT_MAX (priv) (MLX5_CT_MAX(priv) >> 1) +/* Max number of counters. */ +#define MLX5_CNT_MAX (priv) ((priv)->sh->hws_max_nb_counters) +/* Max number of counters allocated in non template mode. */ +#define MLX5_CNT_NT_MAX (priv) (MLX5_CNT_MAX(priv) >> 1)enum mlx5_meter_domain {MLX5_MTR_DOMAIN_INGRESS ,
@@ -2457,6 +2463,7 @@ mlx5_flow_meter_hierarchy_get_final_policy(struct rte_eth_dev *dev,int mlx5_flow_meter_flush (struct rte_eth_dev *dev,struct rte_mtr_error *error);void mlx5_flow_meter_rxq_flush (struct rte_eth_dev *dev); +uint32_t mlx5_flow_mtr_max_get (struct mlx5_priv *priv);/* mlx5_os.c */
drivers/net/mlx5/mlx5_flow_hw.c +9 -4
@@ -13114,6 +13114,7 @@ static int flow_hw_ensure_action_pools_allocated(struct rte_eth_dev *dev,bool actions_end = false;struct mlx5_priv *priv = dev->data->dev_private;int ret; +uint obj_num;for (; !actions_end; actions++) {switch ((int )actions->type) {
@@ -13122,7 +13123,8 @@ static int flow_hw_ensure_action_pools_allocated(struct rte_eth_dev *dev,if (!priv->hws_age_req) {/* If no counters were previously allocated. */ if (!priv->hws_cpool) { - ret =mlx5_hws_cnt_pool_create (dev,MLX5_CNT_MAX , + obj_num =MLX5_CNT_NT_MAX (priv); + ret =mlx5_hws_cnt_pool_create (dev, obj_num, priv->nb_queue,NULL );if (ret) goto err;
@@ -13140,7 +13142,8 @@ static int flow_hw_ensure_action_pools_allocated(struct rte_eth_dev *dev,case RTE_FLOW_ACTION_TYPE_COUNT :/* If no counters were previously allocated. */ if (!priv->hws_cpool) { - ret =mlx5_hws_cnt_pool_create (dev,MLX5_CNT_MAX , + obj_num =MLX5_CNT_NT_MAX (priv); + ret =mlx5_hws_cnt_pool_create (dev, obj_num, priv->nb_queue,NULL );if (ret) goto err;
@@ -13149,7 +13152,8 @@ static int flow_hw_ensure_action_pools_allocated(struct rte_eth_dev *dev,case RTE_FLOW_ACTION_TYPE_CONNTRACK :/* If no CT were previously allocated. */ if (!priv->hws_ctpool) { - ret =mlx5_flow_ct_init (dev,MLX5_CT_NT_MAX , priv->nb_queue); + obj_num =MLX5_CT_NT_MAX (priv); + ret =mlx5_flow_ct_init (dev, obj_num, priv->nb_queue);if (ret) goto err; }
@@ -13157,7 +13161,8 @@ static int flow_hw_ensure_action_pools_allocated(struct rte_eth_dev *dev,case RTE_FLOW_ACTION_TYPE_METER_MARK :/* If no meters were previously allocated. */ if (!priv->hws_mpool) { - ret =mlx5_flow_meter_init (dev,MLX5_MTR_NT_MAX ,0 ,0 , + obj_num =MLX5_MTR_NT_MAX (priv); + ret =mlx5_flow_meter_init (dev, obj_num,0 ,0 , priv->nb_queue);if (ret) goto err;
drivers/net/mlx5/mlx5_flow_meter.c +21 -4
@@ -704,6 +704,26 @@ mlx5_flow_meter_param_fill(struct mlx5_flow_meter_profile *fmp,return 0 ; } +/** +* Callback to get MTR maximum objects number. +* +* @param[in] priv +* Pointer to Ethernet device. +* +* @return +* Max number of meters. +*/ +uint32_t +mlx5_flow_mtr_max_get (struct mlx5_priv *priv) +{ +struct mlx5_hca_qos_attr *qattr = &priv->sh->cdev->config.hca_attr.qos; + +/* Max number of meters. */ +return ((priv->sh->meter_aso_en) ? +1 << (qattr->log_max_num_meter_aso +1 ) : + qattr->log_max_flow_meter); +} +/** * Callback to get MTR capabilities. *
@@ -730,14 +750,11 @@ mlx5_flow_mtr_cap_get(struct rte_eth_dev *dev,RTE_MTR_ERROR_TYPE_UNSPECIFIED ,NULL , "Meter is not supported");memset (cap,0 ,sizeof (*cap)); + cap->n_max =mlx5_flow_mtr_max_get (priv);if (priv->sh->meter_aso_en) { -/* 2 meters per one ASO cache line. */ - cap->n_max =1 << (qattr->log_max_num_meter_aso +1 ); cap->srtcm_rfc2697_packet_mode_supported =1 ; cap->trtcm_rfc2698_packet_mode_supported =1 ; cap->trtcm_rfc4115_packet_mode_supported =1 ; - }else { - cap->n_max =1 << qattr->log_max_flow_meter; } cap->srtcm_rfc2697_byte_mode_supported =1 ; cap->trtcm_rfc2698_byte_mode_supported =1 ;
Signature · 1 line
2.21.0
PATCH v5 11/11 net/mlx5: initial design changes
In reply to Maayan KashaniChange flow_drv_list_create/destroy to mlx5_flow_list_create/destroy. Remove resource release function inlining.
Check number of queues in template mode in hw configure function. Use user priority to calculate matcher priority.
--- drivers/net/mlx5/mlx5_flow.c | 70 +++++++--------------- drivers/net/mlx5/mlx5_flow_hw.c | 100 +++++++++++++++----------------- 2 files changed, 68 insertions(+), 102 deletions(-)
drivers/net/mlx5/mlx5_flow.c +20 -50
@@ -4983,19 +4983,6 @@ flow_check_hairpin_split(struct rte_eth_dev *dev,return 0 ; } -/* Declare flow create/destroy prototype in advance. */ - -static uintptr_t -flow_drv_list_create (struct rte_eth_dev *dev,enum mlx5_flow_type type, -const struct rte_flow_attr *attr, -const struct rte_flow_item items[], -const struct rte_flow_action actions[], -bool external,struct rte_flow_error *error); - -static void -flow_drv_list_destroy (struct rte_eth_dev *dev,enum mlx5_flow_type type, -uintptr_t flow_idx); -int flow_dv_mreg_match_cb(void *tool_ctx __rte_unused,struct mlx5_list_entry *entry,void *cb_ctx)
@@ -5114,7 +5101,7 @@ flow_dv_mreg_create_cb(void *tool_ctx, void *cb_ctx)* be applied, removed, deleted in arbitrary order * by list traversing. */ - mcp_res->rix_flow =flow_drv_list_create (dev,MLX5_FLOW_TYPE_MCP , + mcp_res->rix_flow =mlx5_flow_list_create (dev,MLX5_FLOW_TYPE_MCP , &attr, items, actions, false, error);if (!mcp_res->rix_flow) {mlx5_ipool_free (priv->sh->ipool[MLX5_IPOOL_MCP ], idx);
@@ -5208,7 +5195,7 @@ flow_dv_mreg_remove_cb(void *tool_ctx, struct mlx5_list_entry *entry)struct mlx5_priv *priv = dev->data->dev_private;MLX5_ASSERT (mcp_res->rix_flow); -flow_drv_list_destroy (dev,MLX5_FLOW_TYPE_MCP , mcp_res->rix_flow); +mlx5_flow_list_destroy (dev,MLX5_FLOW_TYPE_MCP , mcp_res->rix_flow);mlx5_ipool_free (priv->sh->ipool[MLX5_IPOOL_MCP ], mcp_res->idx); }
@@ -7595,7 +7582,7 @@ mlx5_flow_create_esw_table_zero_flow(struct rte_eth_dev *dev) };struct rte_flow_error error; -return (void *)(uintptr_t )flow_drv_list_create (dev,MLX5_FLOW_TYPE_CTL , +return (void *)(uintptr_t )mlx5_flow_list_create (dev,MLX5_FLOW_TYPE_CTL , &attr, &pattern, actions, false, &error); }
@@ -7663,14 +7650,14 @@ mlx5_flow_create_devx_sq_miss_flow(struct rte_eth_dev *dev, uint32_t sq_num)* Creates group 0, highest priority jump flow. * Matches txq to bypass kernel packets. */ -if (flow_drv_list_create (dev,MLX5_FLOW_TYPE_CTL , &attr, pattern, actions, +if (mlx5_flow_list_create (dev,MLX5_FLOW_TYPE_CTL , &attr, pattern, actions, false, &error) ==0 )return 0 ;/* Create group 1, lowest priority redirect flow for txq. */ attr.group =1 ; actions[0 ].conf = &port; actions[0 ].type =RTE_FLOW_ACTION_TYPE_PORT_ID ; -return flow_drv_list_create (dev,MLX5_FLOW_TYPE_CTL , &attr, pattern, +return mlx5_flow_list_create (dev,MLX5_FLOW_TYPE_CTL , &attr, pattern, actions, false, &error); }
@@ -7826,7 +7813,7 @@ mlx5_flow_cache_flow_toggle(struct rte_eth_dev *dev, bool orig_prio) flow_info->flow_idx_low_prio);if (high && low) {RTE_SWAP (*low, *high); -flow_drv_list_destroy (dev,MLX5_FLOW_TYPE_GEN , +mlx5_flow_list_destroy (dev,MLX5_FLOW_TYPE_GEN , flow_info->flow_idx_low_prio); flow_info->flow_idx_high_prio =0 ; }
@@ -7840,7 +7827,7 @@ mlx5_flow_cache_flow_toggle(struct rte_eth_dev *dev, bool orig_prio)while (flow_info) {if (flow_info->orig_prio != flow_info->attr.priority) {if (flow_info->flow_idx_high_prio) -flow_drv_list_destroy (dev,MLX5_FLOW_TYPE_GEN , +mlx5_flow_list_destroy (dev,MLX5_FLOW_TYPE_GEN , flow_info->flow_idx_high_prio);else break ;
@@ -7995,12 +7982,13 @@ mlx5_flow_create(struct rte_eth_dev *dev, RTE_PMD_MLX5_FLOW_ENGINE_FLAG_STANDBY_DUP_INGRESS))) new_attr->priority += 1; } - flow_idx =flow_drv_list_create (dev,MLX5_FLOW_TYPE_GEN , attr, items, actions, true, error); + flow_idx =mlx5_flow_list_create (dev,MLX5_FLOW_TYPE_GEN , attr, items, actions, + true, error);if (!flow_idx)return NULL ;if (unlikely (mlx5_need_cache_flow (priv, attr))) {if (mlx5_flow_cache_flow_info (dev, attr, prio, items, actions, flow_idx)) { -flow_drv_list_destroy (dev,MLX5_FLOW_TYPE_GEN , flow_idx); +mlx5_flow_list_destroy (dev,MLX5_FLOW_TYPE_GEN , flow_idx); flow_idx =0 ; } }
@@ -8013,17 +8001,6 @@ mlx5_flow_list_create(struct rte_eth_dev *dev, enum mlx5_flow_type type,const struct rte_flow_item items[], const struct rte_flow_action actions[], bool external, struct rte_flow_error *error) -{ - return flow_drv_list_create(dev, type, attr, items, actions, external, -error ); -} - -uintptr_t -flow_drv_list_create (struct rte_eth_dev *dev,enum mlx5_flow_type type, -const struct rte_flow_attr *attr, -const struct rte_flow_item items[], -const struct rte_flow_action actions[], -bool external,struct rte_flow_error *error) { const struct mlx5_flow_driver_ops *fops;enum mlx5_flow_drv_type drv_type =flow_get_drv_type (dev, attr);
@@ -8072,8 +8049,8 @@ flow_legacy_list_destroy(struct rte_eth_dev *dev, enum mlx5_flow_type type,mlx5_ipool_free (priv->flows[type], flow_idx); } -static void -flow_drv_list_destroy (struct rte_eth_dev *dev,enum mlx5_flow_type type, +void +mlx5_flow_list_destroy (struct rte_eth_dev *dev,enum mlx5_flow_type type,uintptr_t flow_idx) {const struct mlx5_flow_driver_ops *fops;
@@ -8084,13 +8061,6 @@ flow_drv_list_destroy(struct rte_eth_dev *dev, enum mlx5_flow_type type, fops->list_destroy (dev, type, flow_idx); } -void -mlx5_flow_list_destroy (struct rte_eth_dev *dev,enum mlx5_flow_type type, -uintptr_t flow_idx) -{ -flow_drv_list_destroy (dev, type, flow_idx); -} -/** * Destroy all flows. *
@@ -8119,9 +8089,9 @@ mlx5_flow_list_flush(struct rte_eth_dev *dev, enum mlx5_flow_type type,#endif MLX5_IPOOL_FOREACH(priv->flows[type], fidx, flow) {if (priv->sh->config.dv_flow_en ==2 ) { -flow_drv_list_destroy (dev, type, (uintptr_t )flow); +mlx5_flow_list_destroy (dev, type, (uintptr_t )flow); }else { -flow_drv_list_destroy (dev, type, fidx); +mlx5_flow_list_destroy (dev, type, fidx); }if (unlikely (mlx5_need_cache_flow (priv,NULL ) && type ==MLX5_FLOW_TYPE_GEN )) { flow_info =LIST_FIRST (&mode_info->hot_upgrade);
@@ -8394,7 +8364,7 @@ mlx5_ctrl_flow_source_queue(struct rte_eth_dev *dev, actions[0 ].type =RTE_FLOW_ACTION_TYPE_JUMP ; actions[0 ].conf = &jump; actions[1 ].type =RTE_FLOW_ACTION_TYPE_END ; - flow_idx =flow_drv_list_create (dev,MLX5_FLOW_TYPE_CTL , + flow_idx =mlx5_flow_list_create (dev,MLX5_FLOW_TYPE_CTL , &attr, items, actions, false, &error);if (!flow_idx) { DRV_LOG(DEBUG,
@@ -8484,7 +8454,7 @@ mlx5_ctrl_flow_vlan(struct rte_eth_dev *dev, action_rss.types =0 ;for (i =0 ; i != priv->reta_idx_n; ++i) queue[i] = (*priv->reta_idx)[i]; - flow_idx =flow_drv_list_create (dev,MLX5_FLOW_TYPE_CTL , + flow_idx =mlx5_flow_list_create (dev,MLX5_FLOW_TYPE_CTL , &attr, items, actions, false, &error);if (!flow_idx)return -rte_errno;
@@ -8559,7 +8529,7 @@ mlx5_flow_lacp_miss(struct rte_eth_dev *dev) }, };struct rte_flow_error error; -uint32_t flow_idx =flow_drv_list_create (dev,MLX5_FLOW_TYPE_CTL , +uint32_t flow_idx =mlx5_flow_list_create (dev,MLX5_FLOW_TYPE_CTL , &attr, items, actions, false, &error);
@@ -8583,7 +8553,7 @@ mlx5_flow_destroy(struct rte_eth_dev *dev,struct rte_pmd_mlx5_flow_engine_mode_info *mode_info = &priv->mode_info;struct mlx5_dv_flow_info *flow_info; -flow_drv_list_destroy (dev,MLX5_FLOW_TYPE_GEN , +mlx5_flow_list_destroy (dev,MLX5_FLOW_TYPE_GEN , (uintptr_t )(void *)flow);if (unlikely (mlx5_need_cache_flow (priv,NULL ))) { flow_info =LIST_FIRST (&mode_info->hot_upgrade);
@@ -9896,14 +9866,14 @@ mlx5_flow_discover_mreg_c(struct rte_eth_dev *dev)if (!priv->sh->config.dv_flow_en)break ;/* Create internal flow, validation skips copy action. */ - flow_idx =flow_drv_list_create (dev,MLX5_FLOW_TYPE_GEN , &attr, + flow_idx =mlx5_flow_list_create (dev,MLX5_FLOW_TYPE_GEN , &attr, items, actions, false, &error); flow =mlx5_ipool_get (priv->flows[MLX5_FLOW_TYPE_GEN ], flow_idx);if (!flow)continue ; priv->sh->flow_mreg_c[n++] = idx; -flow_drv_list_destroy (dev,MLX5_FLOW_TYPE_GEN , flow_idx); +mlx5_flow_list_destroy (dev,MLX5_FLOW_TYPE_GEN , flow_idx); }for (; n <MLX5_MREG_C_NUM ; ++n) priv->sh->flow_mreg_c[n] =REG_NON ;
drivers/net/mlx5/mlx5_flow_hw.c +48 -52
190 lines not on this page · raw message
Signature · 1 line
2.21.0
PATCH v6 1/11 net/mlx5: initial design of non template to hws
In reply to Maayan KashaniImplement the frame and needed building
blocks for non template to hws API's.
Added validate, list_create and list_destroy to mlx5_flow_hw_drv_ops. Rename old list_create/list_destroy functions to legacy_* and added a call from verbs/dv ops to the legacy functions.
Updated rte_flow_hw as needed.
Added rte_flow_nt2hws structure for non-template rule data.
squash to net/mlx5: initial design of non template to hws
--- drivers/net/mlx5/linux/mlx5_os.c | 8 +- drivers/net/mlx5/mlx5.h | 9 + drivers/net/mlx5/mlx5_flow.c | 139 +++++--- drivers/net/mlx5/mlx5_flow.h | 74 ++++- drivers/net/mlx5/mlx5_flow_dv.c | 192 +++++++++--- drivers/net/mlx5/mlx5_flow_hw.c | 487 +++++++++++++++++++++++++++-- drivers/net/mlx5/mlx5_flow_verbs.c | 2 + drivers/net/mlx5/mlx5_trigger.c | 6 + drivers/net/mlx5/windows/mlx5_os.c | 8 +- 9 files changed, 808 insertions(+), 117 deletions(-)
drivers/net/mlx5/linux/mlx5_os.c +7 -1
@@ -69,7 +69,7 @@ static rte_spinlock_t mlx5_shared_data_lock = RTE_SPINLOCK_INITIALIZER;static struct mlx5_local_data mlx5_local_data;/* rte flow indexed pool configuration. */ -static struct mlx5_indexed_pool_config icfg[] = { +static const struct mlx5_indexed_pool_config default_icfg[] = { { .size =sizeof (struct rte_flow ), .trunk_size =64 ,
@@ -1080,7 +1080,9 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,struct mlx5_port_info vport_info = { .query_flags =0 };int nl_rdma;int i; +struct mlx5_indexed_pool_config icfg[RTE_DIM (default_icfg)]; +memcpy (icfg, default_icfg,sizeof (icfg));/* Determine if this port representor is supposed to be spawned. */ if (switch_info->representor && dpdk_dev->devargs && !mlx5_representor_match (spawn, eth_da))
@@ -1560,6 +1562,10 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, icfg[i].release_mem_en = !!sh->config.reclaim_mode;if (sh->config.reclaim_mode) icfg[i].per_core_cache =0 ; +#ifdef HAVE_MLX5_HWS_SUPPORT +if (priv->sh->config.dv_flow_en ==2 ) + icfg[i].size =sizeof (struct rte_flow_hw ) +sizeof (struct rte_flow_nt2hws ); +#endif priv->flows[i] =mlx5_ipool_create (&icfg[i]);if (!priv->flows[i]) goto error;
drivers/net/mlx5/mlx5.h +9 -0
@@ -2327,6 +2327,15 @@ int mlx5_flow_validate(struct rte_eth_dev *dev,const struct rte_flow_item items[], const struct rte_flow_action actions[], struct rte_flow_error *error); +uint32_t +mlx5_flow_list_create (struct rte_eth_dev *dev,enum mlx5_flow_type type, +const struct rte_flow_attr *attr, +const struct rte_flow_item items[], +const struct rte_flow_action actions[], +bool external,struct rte_flow_error *error); +void +mlx5_flow_list_destroy (struct rte_eth_dev *dev,enum mlx5_flow_type type, +uint32_t flow_idx); struct rte_flow *mlx5_flow_create(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, const struct rte_flow_item items[],
drivers/net/mlx5/mlx5_flow.c +96 -43
311 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow.h +65 -9
131 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_dv.c +157 -35
316 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_hw.c +459 -28
568 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_verbs.c +2 -0
@@ -2186,6 +2186,8 @@ flow_verbs_sync_domain(struct rte_eth_dev *dev, uint32_t domains, }const struct mlx5_flow_driver_ops mlx5_flow_verbs_drv_ops = { + .list_create = flow_legacy_list_create, + .list_destroy = flow_legacy_list_destroy, .validate = flow_verbs_validate, .prepare = flow_verbs_prepare, .translate = flow_verbs_translate,
drivers/net/mlx5/mlx5_trigger.c +6 -0
@@ -1158,6 +1158,12 @@ mlx5_dev_start(struct rte_eth_dev *dev)DRV_LOG (DEBUG ,"port %u starting device" , dev->data->port_id);#ifdef HAVE_MLX5_HWS_SUPPORT if (priv->sh->config.dv_flow_en ==2 ) { +/*If previous configuration does not exist. */ +if (!(priv->dr_ctx)) { + ret =flow_hw_init (dev,NULL ); +if (ret) +return ret; + }/* If there is no E-Switch, then there are no start/stop order limitations. */ if (!priv->sh->config.dv_esw_en) goto continue_dev_start;
drivers/net/mlx5/windows/mlx5_os.c +7 -1
@@ -35,7 +35,7 @@ static const char *MZ_MLX5_PMD_SHARED_DATA = "mlx5_pmd_shared_data";static rte_spinlock_t mlx5_shared_data_lock =RTE_SPINLOCK_INITIALIZER ;/* rte flow indexed pool configuration. */ -static struct mlx5_indexed_pool_config icfg[] = { +static const struct mlx5_indexed_pool_config default_icfg[] = { { .size =sizeof (struct rte_flow ), .trunk_size =64 ,
@@ -352,7 +352,9 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,int own_domain_id =0 ;uint16_t port_id;int i; +struct mlx5_indexed_pool_config icfg[RTE_DIM (default_icfg)]; +memcpy (icfg, default_icfg,sizeof (icfg));/* Build device name. */ strlcpy (name, dpdk_dev->name,sizeof (name));/* check if the device is already spawned */
@@ -538,6 +540,10 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, icfg[i].release_mem_en = !!sh->config.reclaim_mode;if (sh->config.reclaim_mode) icfg[i].per_core_cache =0 ; +#ifdef HAVE_MLX5_HWS_SUPPORT +if (priv->sh->config.dv_flow_en ==2 ) + icfg[i].size =sizeof (struct rte_flow_hw ) +sizeof (struct rte_flow_nt2hws ); +#endif priv->flows[i] =mlx5_ipool_create (&icfg[i]);if (!priv->flows[i]) goto error;
Signature · 1 line
2.21.0
PATCH v6 2/11 net/mlx5: add dummy last action
From: Bing Zhao <[email protected]>
The RTE_FLOW_ACTION_TYPE_END action needs to be translated into the MLX5DR_ACTION_TYP_LAST for the future usage. It is only needed in the hardware steering backward compatible API.
--- drivers/net/mlx5/mlx5.h | 1 + drivers/net/mlx5/mlx5_flow_hw.c | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+)
drivers/net/mlx5/mlx5.h +1 -0
@@ -1529,6 +1529,7 @@ struct mlx5_dev_ctx_shared {/* Direct Rules tables for FDB, NIC TX+RX */ void *dr_drop_action;/* Pointer to DR drop action, any domain. */ void *pop_vlan_action;/* Pointer to DR pop VLAN action. */ +void *hw_dummy_last;/* Pointer to the DR dummy end action, any domain. */ #if defined(HAVE_IBV_FLOW_DV_SUPPORT ) || !defined(HAVE_INFINIBAND_VERBS_H )struct mlx5_send_to_kernel_action send_to_kernel_action[MLX5DR_TABLE_TYPE_MAX ];#endif
drivers/net/mlx5/mlx5_flow_hw.c +19 -0
@@ -11219,6 +11219,17 @@ flow_hw_configure(struct rte_eth_dev *dev,if (ret) goto err; } +/* +* All domains will use the same dummy action, only used in the backward +* compatible API. Initialize it for only once. No order dependency. +*/ +if (!priv->sh->hw_dummy_last) { + priv->sh->hw_dummy_last =mlx5dr_action_create_last (priv->dr_ctx, +MLX5DR_ACTION_FLAG_HWS_RX ); +if (!priv->sh->hw_dummy_last) +/* Do not overwrite the rte_errno. */ + goto err; + }if (!priv->shared_host)flow_hw_create_send_to_kernel_actions (priv);if (port_attr->nb_conn_tracks || (host_priv && host_priv->hws_ctpool)) {
@@ -11297,6 +11308,10 @@ flow_hw_configure(struct rte_eth_dev *dev,flow_hw_ct_mng_destroy (dev, priv->ct_mng); priv->ct_mng =NULL ; } +if (priv->sh->hw_dummy_last) { +mlx5dr_action_destroy (priv->sh->hw_dummy_last); + priv->sh->hw_dummy_last =NULL ; + }flow_hw_destroy_send_to_kernel_action (priv);flow_hw_cleanup_ctrl_fdb_tables (dev);flow_hw_free_vport_actions (priv);
@@ -11422,6 +11437,10 @@ flow_hw_resource_release(struct rte_eth_dev *dev)mlx5dr_action_destroy (priv->hw_def_miss);flow_hw_destroy_nat64_actions (priv);flow_hw_destroy_vlan (dev); +if (priv->sh->hw_dummy_last) { +mlx5dr_action_destroy (priv->sh->hw_dummy_last); + priv->sh->hw_dummy_last =NULL ; + }flow_hw_destroy_send_to_kernel_action (priv);flow_hw_free_vport_actions (priv);if (priv->acts_ipool) {
Signature · 1 line
2.21.0
PATCH v6 3/11 net/mlx5: add basic actions support for non-template API
In reply to Maayan KashaniFrom: Bing Zhao <[email protected]>
Support JUMP / DROP / QUEUE / MARK / FLAG now.
--- drivers/net/mlx5/mlx5_flow_hw.c | 153 ++++++++++++++++++++++++++++---- 1 file changed, 135 insertions(+), 18 deletions(-)
drivers/net/mlx5/mlx5_flow_hw.c +135 -18
@@ -546,8 +546,7 @@ flow_hw_jump_release(struct rte_eth_dev *dev, struct mlx5_hw_jump_action *jump)struct mlx5_priv *priv = dev->data->dev_private;struct mlx5_flow_group *grp; - grp =container_of - (jump, struct mlx5_flow_group, jump); + grp = container_of(jump, struct mlx5_flow_group, jump);mlx5_hlist_unregister (priv->sh->flow_tbls, &grp->entry); }
@@ -647,17 +646,9 @@ flow_hw_template_destroy_mhdr_action(struct mlx5_hw_modify_header_action *mhdr)* Pointer to the template HW steering DR actions. */ static void -__flow_hw_action_template_destroy (struct rte_eth_dev *dev, -struct mlx5_hw_actions *acts) +__flow_hw_actions_release (struct rte_eth_dev *dev,struct mlx5_hw_actions *acts) {struct mlx5_priv *priv = dev->data->dev_private; -struct mlx5_action_construct_data *data; - -while (!LIST_EMPTY (&acts->act_list)) { - data =LIST_FIRST (&acts->act_list); -LIST_REMOVE (data, next); -mlx5_ipool_free (priv->acts_ipool, data->idx); - }if (acts->mark) if (!(rte_atomic_fetch_sub_explicit(&priv->hws_mark_refcnt, 1,
@@ -702,6 +693,32 @@ __flow_hw_action_template_destroy(struct rte_eth_dev *dev, } } +/** +* Destroy DR actions created by action template. +* +* For DR actions created during table creation's action translate. +* Need to destroy the DR action when destroying the table. +* +* @param[in] dev +* Pointer to the rte_eth_dev structure. +* @param[in] acts +* Pointer to the template HW steering DR actions. +*/ +static void +__flow_hw_action_template_destroy (struct rte_eth_dev *dev,struct mlx5_hw_actions *acts) +{ +struct mlx5_priv *priv = dev->data->dev_private; +struct mlx5_action_construct_data *data; + +while (!LIST_EMPTY (&acts->act_list)) { + data =LIST_FIRST (&acts->act_list); +LIST_REMOVE (data, next); +mlx5_ipool_free (priv->acts_ipool, data->idx); + } + +__flow_hw_actions_release (dev, acts); +} +/** * Append dynamic action to the dynamic action list. *
@@ -12690,14 +12707,113 @@ static int flow_hw_prepare(struct rte_eth_dev *dev,return 0 ; } -static int flow_hw_translate_actions(struct rte_eth_dev *dev __rte_unused, - const struct rte_flow_attr *attr __rte_unused, - const struct rte_flow_action actions[] __rte_unused, - struct rte_flow_hw *flow __rte_unused, - struct rte_flow_error *error __rte_unused) +static int +flow_hw_translate_actions (struct rte_eth_dev *dev, +const struct rte_flow_attr *attr, +const struct rte_flow_action actions[], +struct rte_flow_hw *flow, +struct mlx5_hw_actions *hw_acts, +bool external, +struct rte_flow_error *error) { -/* TODO implement */ +struct mlx5_priv *priv = dev->data->dev_private; +enum mlx5dr_table_type type; +enum mlx5_hw_action_flag_type flag_type; +bool actions_end = false; +uint64_t action_flags =0 ;/* to be used when needed */ +uint32_t actions_n =0 ; +uint32_t mark_id; +uint32_t jump_group; +bool is_mark; +struct mlx5_flow_template_table_cfg tbl_cfg; +enum mlx5_flow_fate_type fate_type =MLX5_FLOW_FATE_NONE ; + +if (attr->transfer) + type =MLX5DR_TABLE_TYPE_FDB ; +else if (attr->egress) + type =MLX5DR_TABLE_TYPE_NIC_TX ; +else + type =MLX5DR_TABLE_TYPE_NIC_RX ; +/* The group in the attribute translation was done in advance. */ + flag_type = (attr->group ==0 ) ?MLX5_HW_ACTION_FLAG_ROOT : +MLX5_HW_ACTION_FLAG_NONE_ROOT ; +for (; !actions_end; actions++) { +switch (actions->type) { +case RTE_FLOW_ACTION_TYPE_VOID : +break ; +case RTE_FLOW_ACTION_TYPE_DROP : + hw_acts->rule_acts[actions_n++].action = priv->hw_drop[flag_type]; + fate_type =MLX5_FLOW_FATE_DROP ; +break ; +case RTE_FLOW_ACTION_TYPE_FLAG : +case RTE_FLOW_ACTION_TYPE_MARK : + is_mark = actions->type ==RTE_FLOW_ACTION_TYPE_MARK ; + mark_id = is_mark ? + ((const struct rte_flow_action_mark *)(actions->conf))->id : +MLX5_FLOW_MARK_DEFAULT ; + hw_acts->rule_acts[actions_n].tag.value =mlx5_flow_mark_set (mark_id); + hw_acts->rule_acts[actions_n].action = priv->hw_tag[flag_type]; + actions_n++; + action_flags |= is_mark ?MLX5_FLOW_ACTION_MARK :MLX5_FLOW_ACTION_FLAG ; + hw_acts->mark = true; +rte_atomic_fetch_add_explicit (&priv->hws_mark_refcnt,1 , + rte_memory_order_relaxed); +flow_hw_rxq_flag_set (dev, true); +break ; +case RTE_FLOW_ACTION_TYPE_JUMP : + jump_group = ((const struct rte_flow_action_jump *)actions->conf)->group; + tbl_cfg.attr.flow_attr = *attr; + tbl_cfg.external = external; +/* The flow_hw_jump_action_register() can be refactored. */ + hw_acts->jump =flow_hw_jump_action_register (dev, &tbl_cfg, + jump_group, error); +if (hw_acts->jump ==NULL ) + goto clean_up; + hw_acts->rule_acts[actions_n++].action = + (flag_type ==MLX5_HW_ACTION_FLAG_NONE_ROOT ) ? + hw_acts->jump->hws_action : hw_acts->jump->root_action; + action_flags |=MLX5_FLOW_ACTION_JUMP ; + fate_type =MLX5_FLOW_FATE_JUMP ; +break ; +case RTE_FLOW_ACTION_TYPE_QUEUE : +/* Right now, only Rx supports the TIR, validation is needed. */ + hw_acts->tir =flow_hw_tir_action_register (dev, + mlx5_hw_act_flag[flag_type][type], actions); +if (hw_acts->tir ==NULL ) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION ,NULL , +"Failed to translate queue." ); + goto clean_up; + } + action_flags |=MLX5_FLOW_ACTION_QUEUE ; + fate_type =MLX5_FLOW_FATE_QUEUE ; +break ; +case RTE_FLOW_ACTION_TYPE_END : +/* +* Using NULL action right now, maybe a new API can be used +* to create a dummy action with type MLX5DR_ACTION_TYP_LAST. +*/ + hw_acts->rule_acts[actions_n++].action = priv->sh->hw_dummy_last; + actions_end = true; +break ; +default : +break ; + } + } +if (fate_type ==MLX5_FLOW_FATE_QUEUE ) { + hw_acts->rule_acts[actions_n++].action = hw_acts->tir->action; + flow->hrxq = hw_acts->tir; + }else { +if (fate_type ==MLX5_FLOW_FATE_JUMP ) + flow->jump = hw_acts->jump; + } +/* Total actions number should be validated before. */ +MLX5_ASSERT (actions_n <=MLX5_HW_MAX_ACTS );return 0 ; +clean_up: +/* Make sure that there is no garbage in the actions. */ +__flow_hw_actions_release (dev, hw_acts); +return -rte_errno; } static int flow_hw_register_matcher(struct rte_eth_dev *dev,
@@ -12891,7 +13007,8 @@ static int flow_hw_create_flow(struct rte_eth_dev *dev,if (ret) goto error; - ret =flow_hw_translate_actions (dev, attr, actions, *flow, error); +/* Note: the actions should be saved in the sub-flow rule itself for reference. */ + ret =flow_hw_translate_actions (dev, attr, actions, *flow, &hw_act, external, error);if (ret) goto error;
Signature · 1 line
2.21.0
PATCH v6 4/11 net/mlx5: add default miss action support in nt2hws mode
In reply to Maayan KashaniFrom: Bing Zhao <[email protected]>
The validation will be handled later.
Now it only supports the SEND_TO_KERNEL on non-root tables.
--- drivers/net/mlx5/mlx5_flow_hw.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-)
drivers/net/mlx5/mlx5_flow_hw.c +20 -3
@@ -12721,22 +12721,28 @@ flow_hw_translate_actions(struct rte_eth_dev *dev,enum mlx5_hw_action_flag_type flag_type;bool actions_end = false;uint64_t action_flags =0 ;/* to be used when needed */ +int ret;uint32_t actions_n =0 ;uint32_t mark_id;uint32_t jump_group; +uint32_t src_group =0 ;bool is_mark;struct mlx5_flow_template_table_cfg tbl_cfg;enum mlx5_flow_fate_type fate_type =MLX5_FLOW_FATE_NONE ; +RTE_SET_USED (action_flags); +/* The group in the attribute translation was done in advance. */ + ret =__translate_group (dev, attr, external, attr->group, &src_group, error); +if (ret) +return ret;if (attr->transfer) type =MLX5DR_TABLE_TYPE_FDB ;else if (attr->egress) type =MLX5DR_TABLE_TYPE_NIC_TX ;else type =MLX5DR_TABLE_TYPE_NIC_RX ; -/* The group in the attribute translation was done in advance. */ - flag_type = (attr->group ==0 ) ?MLX5_HW_ACTION_FLAG_ROOT : -MLX5_HW_ACTION_FLAG_NONE_ROOT ; + flag_type = (src_group ==0 ) ?MLX5_HW_ACTION_FLAG_ROOT : +MLX5_HW_ACTION_FLAG_NONE_ROOT ;for (; !actions_end; actions++) {switch (actions->type) {case RTE_FLOW_ACTION_TYPE_VOID :
@@ -12788,6 +12794,17 @@ flow_hw_translate_actions(struct rte_eth_dev *dev, action_flags |=MLX5_FLOW_ACTION_QUEUE ; fate_type =MLX5_FLOW_FATE_QUEUE ;break ; +case RTE_FLOW_ACTION_TYPE_SEND_TO_KERNEL : +if (src_group ==0 ) { +rte_flow_error_set (error,ENOTSUP , +RTE_FLOW_ERROR_TYPE_ACTION ,NULL , +"Send to kernel action on the root table is" +" not supported in HWS mode now." ); + goto clean_up; + } + hw_acts->rule_acts[actions_n++].action = priv->hw_send_to_kernel[type]; + action_flags |=MLX5_FLOW_ACTION_SEND_TO_KERNEL ; +break ;case RTE_FLOW_ACTION_TYPE_END :/* * Using NULL action right now, maybe a new API can be used
Signature · 1 line
2.21.0
PATCH v6 5/11 net/mlx5: add ASO actions support to non-template mode
In reply to Maayan KashaniThis patch adds counter, connection tracking, meter and age actions support to non-template mode.
For CT, counter and meter: if no previous allocation was handled by hw configure routine,
Half of the maximum supported number of objects will be allocated. For AGE action, if no counters were allocated,
allocate half of the maximum,
and then allocate same number of AGE objects.
Also extracted the shared host handling to the configure function. And align all ASO actions to have init function
for future code improvement.
This patch does not affect SW Steering flow engine.
--- drivers/net/mlx5/mlx5.h | 7 ++ drivers/net/mlx5/mlx5_flow_hw.c | 185 +++++++++++++++++++++++++++----- drivers/net/mlx5/mlx5_hws_cnt.c | 47 ++++---- drivers/net/mlx5/mlx5_hws_cnt.h | 10 +- 4 files changed, 190 insertions(+), 59 deletions(-)
drivers/net/mlx5/mlx5.h +7 -0
@@ -812,6 +812,13 @@ struct mlx5_dev_shared_port {/* Only yellow color valid. */ #define MLX5_MTR_POLICY_MODE_OY 3 +/* Max number of meters allocated in non template mode. */ +#define MLX5_MTR_NT_MAX (1 << 23)/*TODO verify number */ +/* Max number of connection tracking allocated in non template mode */ +#define MLX5_CT_NT_MAX (1 << 23)/*TODO verify number */ +/* Max number of counters allocated in non template mode */ +#define MLX5_CNT_MAX (1 << 23)/*TODO verify number */ +enum mlx5_meter_domain {MLX5_MTR_DOMAIN_INGRESS ,MLX5_MTR_DOMAIN_EGRESS ,
drivers/net/mlx5/mlx5_flow_hw.c +157 -28
280 lines not on this page · raw message
drivers/net/mlx5/mlx5_hws_cnt.c +20 -27
115 lines not on this page · raw message
drivers/net/mlx5/mlx5_hws_cnt.h +6 -4
@@ -712,9 +712,10 @@ mlx5_hws_cnt_service_thread_create(struct mlx5_dev_ctx_shared *sh);void mlx5_hws_cnt_service_thread_destroy (struct mlx5_dev_ctx_shared *sh); -struct mlx5_hws_cnt_pool * +int mlx5_hws_cnt_pool_create (struct rte_eth_dev *dev, -const struct rte_flow_port_attr *pattr,uint16_t nb_queue); +uint32_t nb_counters,uint16_t nb_queue, +struct mlx5_hws_cnt_pool *chost); void mlx5_hws_cnt_pool_destroy(struct mlx5_dev_ctx_shared *sh,
@@ -744,8 +745,9 @@ mlx5_hws_age_context_get(struct mlx5_priv *priv, uint32_t idx);int mlx5_hws_age_pool_init (struct rte_eth_dev *dev, -const struct rte_flow_port_attr *attr, -uint16_t nb_queues); +uint32_t nb_aging_objects, +uint16_t nb_queues, +bool strict_queue);void mlx5_hws_age_pool_destroy (struct mlx5_priv *priv);
Signature · 1 line
2.21.0
PATCH v6 6/11 net/mlx5: fix segfault on counter pool destroy
In reply to Maayan KashaniIf the counter pool was not added to list,
and an error state was reached,
on attempt to destroy the counter pool, segmentation fault was received during list remove action.
Added a check to verify the list is not empty before trying to remove the cpool from the list.
Invalid state, leading to segfault,
can also be reached in the following scenario:
1. mlx5_hws_cnt_pool_init() does a zmalloc and initializes most
of the fields of cpool, but does not initialize the next field.
2. mlx5_hws_cnt_pool_dcs_alloc() attempts to bulk allocate flow counters.
If this fails, we skip straight to 4.
In HW, this can fail simply if FW doesn't support bulk flow counter allocation.
3. Right before the goto error, we insert the cpool to the hws_cpool_list.
This is where the next field is initialized.
4. mlx5_hws_cnt_pool_destroy() assumes the cpool's next field
is initialized and SEGVs if not.
So, added a guard against cases where the entry was uninitialized (checking le_prev field is not NULL).
--- drivers/net/mlx5/mlx5_hws_cnt.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/mlx5/mlx5_hws_cnt.c +3 -1
@@ -718,7 +718,9 @@ mlx5_hws_cnt_pool_destroy(struct mlx5_dev_ctx_shared *sh,* Maybe blocked for at most 200ms here. */ rte_spinlock_lock (&sh->cpool_lock); -LIST_REMOVE (cpool, next); +/* Try to remove cpool before it was added to list caused segfault. */ +if (!LIST_EMPTY (&sh->hws_cpool_list) && cpool->next.le_prev) +LIST_REMOVE (cpool, next);rte_spinlock_unlock (&sh->cpool_lock);if (cpool->cfg.host_cpool ==NULL ) {if (--sh->cnt_svc->refcnt ==0 )
Signature · 1 line
2.21.0
PATCH v6 7/11 net/mlx5: abstract action handling and enable reconfigure
In reply to Maayan Kashanireuse HWS actions translation code in order to create the actions for lower layer.
All actions are handled as non masked. Therefore, will be translated in the rule construct phase shared with the template code
and not during the action template translate.
Currently there is no option to reconfigure in template API’s. To support non template API and template API simultaneously, There is a need to enable the user to reconfigure after default configuration was applied by the driver on port start.
Fix flow create ptr
In SWS the return flow pointer is the flow index, in HWS the return flow pointer is the flow data pointer. Currently the return value of non template code did not Enable destroy or quary.
--- drivers/net/mlx5/mlx5.h | 25 +- drivers/net/mlx5/mlx5_flow.c | 31 +- drivers/net/mlx5/mlx5_flow.h | 14 +- drivers/net/mlx5/mlx5_flow_dv.c | 18 +- drivers/net/mlx5/mlx5_flow_hw.c | 829 ++++++++++++++++---------------- 5 files changed, 472 insertions(+), 445 deletions(-)
drivers/net/mlx5/mlx5.h +13 -12
@@ -813,11 +813,11 @@ struct mlx5_dev_shared_port {#define MLX5_MTR_POLICY_MODE_OY 3/* Max number of meters allocated in non template mode. */ -#define MLX5_MTR_NT_MAX (1 << 23)/*TODO verify number */ +#define MLX5_MTR_NT_MAX (1 << 23)/* Max number of connection tracking allocated in non template mode */ -#define MLX5_CT_NT_MAX (1 << 23)/*TODO verify number */ +#define MLX5_CT_NT_MAX (1 << 23)/* Max number of counters allocated in non template mode */ -#define MLX5_CNT_MAX (1 << 23)/*TODO verify number */ +#define MLX5_CNT_MAX (1 << 23)enum mlx5_meter_domain {MLX5_MTR_DOMAIN_INGRESS ,
@@ -1536,7 +1536,6 @@ struct mlx5_dev_ctx_shared {/* Direct Rules tables for FDB, NIC TX+RX */ void *dr_drop_action;/* Pointer to DR drop action, any domain. */ void *pop_vlan_action;/* Pointer to DR pop VLAN action. */ -void *hw_dummy_last;/* Pointer to the DR dummy end action, any domain. */ #if defined(HAVE_IBV_FLOW_DV_SUPPORT ) || !defined(HAVE_INFINIBAND_VERBS_H )struct mlx5_send_to_kernel_action send_to_kernel_action[MLX5DR_TABLE_TYPE_MAX ];#endif
@@ -1817,6 +1816,14 @@ struct mlx5_hw_ctrl_flow {struct mlx5_hw_ctrl_flow_info info; }; +/* HW Steering port configuration passed to rte_flow_configure(). */ +struct mlx5_flow_hw_attr { +struct rte_flow_port_attr port_attr; +uint16_t nb_queue; +struct rte_flow_queue_attr *queue_attr; +bool nt_mode; +}; +/* * Flow rule structure for flow engine mode control, focus on group 0. * Apply to all supported domains.
@@ -1838,12 +1845,6 @@ struct rte_pmd_mlx5_flow_engine_mode_info {/* The list is maintained in insertion order. */ LIST_HEAD(hot_up_info, mlx5_dv_flow_info) hot_upgrade; }; -/* HW Steering port configuration passed to rte_flow_configure(). */ -struct mlx5_flow_hw_attr { -struct rte_flow_port_attr port_attr; -uint16_t nb_queue; -struct rte_flow_queue_attr *queue_attr; -};struct mlx5_flow_hw_ctrl_rx ;
@@ -2335,7 +2336,7 @@ int mlx5_flow_validate(struct rte_eth_dev *dev,const struct rte_flow_item items[], const struct rte_flow_action actions[], struct rte_flow_error *error); -uint32_t +uintptr_t mlx5_flow_list_create(struct rte_eth_dev *dev, enum mlx5_flow_type type, const struct rte_flow_attr *attr, const struct rte_flow_item items[],
@@ -2343,7 +2344,7 @@ mlx5_flow_list_create(struct rte_eth_dev *dev, enum mlx5_flow_type type, bool external, struct rte_flow_error *error);void mlx5_flow_list_destroy (struct rte_eth_dev *dev,enum mlx5_flow_type type, -uint32_t flow_idx); +uintptr_t flow_idx); struct rte_flow *mlx5_flow_create(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, const struct rte_flow_item items[],
drivers/net/mlx5/mlx5_flow.c +14 -17
@@ -4985,7 +4985,7 @@ flow_check_hairpin_split(struct rte_eth_dev *dev,/* Declare flow create/destroy prototype in advance. */ -static uint32_t +static uintptr_t flow_drv_list_create(struct rte_eth_dev *dev, enum mlx5_flow_type type, const struct rte_flow_attr *attr, const struct rte_flow_item items[],
@@ -4994,7 +4994,7 @@ flow_drv_list_create(struct rte_eth_dev *dev, enum mlx5_flow_type type,static void flow_drv_list_destroy (struct rte_eth_dev *dev,enum mlx5_flow_type type, -uint32_t flow_idx); +uintptr_t flow_idx); int flow_dv_mreg_match_cb(void *tool_ctx __rte_unused,
@@ -7298,7 +7298,7 @@ flow_tunnel_from_rule(const struct mlx5_flow *flow)* @return * A flow index on success, 0 otherwise and rte_errno is set. */ -uint32_t +uintptr_t flow_legacy_list_create(struct rte_eth_dev *dev, enum mlx5_flow_type type, const struct rte_flow_attr *attr, const struct rte_flow_item items[],
@@ -7973,7 +7973,7 @@ mlx5_flow_create(struct rte_eth_dev *dev,struct mlx5_priv *priv = dev->data->dev_private;struct rte_flow_attr *new_attr = (void *)(uintptr_t )attr;uint32_t prio = attr->priority; -uint32_t flow_idx; +uintptr_t flow_idx;/* * If the device is not started yet, it is not allowed to created a
@@ -8007,7 +8007,7 @@ mlx5_flow_create(struct rte_eth_dev *dev,return (void *)(uintptr_t )flow_idx; } -uint32_t +uintptr_t mlx5_flow_list_create(struct rte_eth_dev *dev, enum mlx5_flow_type type, const struct rte_flow_attr *attr, const struct rte_flow_item items[],
@@ -8018,7 +8018,7 @@ mlx5_flow_list_create(struct rte_eth_dev *dev, enum mlx5_flow_type type, error); } -uint32_t +uintptr_t flow_drv_list_create(struct rte_eth_dev *dev, enum mlx5_flow_type type, const struct rte_flow_attr *attr, const struct rte_flow_item items[],
@@ -8043,7 +8043,7 @@ flow_drv_list_create(struct rte_eth_dev *dev, enum mlx5_flow_type type,*/ void flow_legacy_list_destroy (struct rte_eth_dev *dev,enum mlx5_flow_type type, -uint32_t flow_idx) +uintptr_t flow_idx) {struct mlx5_priv *priv = dev->data->dev_private;struct rte_flow *flow =mlx5_ipool_get (priv->flows[type], (uint32_t )flow_idx);
@@ -8074,7 +8074,7 @@ flow_legacy_list_destroy(struct rte_eth_dev *dev, enum mlx5_flow_type type,static void flow_drv_list_destroy (struct rte_eth_dev *dev,enum mlx5_flow_type type, -uint32_t flow_idx) +uintptr_t flow_idx) {const struct mlx5_flow_driver_ops *fops;struct rte_flow_attr attr = { .transfer =0 };
@@ -8086,7 +8086,7 @@ flow_drv_list_destroy(struct rte_eth_dev *dev, enum mlx5_flow_type type,void mlx5_flow_list_destroy (struct rte_eth_dev *dev,enum mlx5_flow_type type, -uint32_t flow_idx) +uintptr_t flow_idx) {flow_drv_list_destroy (dev, type, flow_idx); }
@@ -8115,12 +8115,14 @@ mlx5_flow_list_flush(struct rte_eth_dev *dev, enum mlx5_flow_type type,if (priv->sh->config.dv_flow_en ==2 && type ==MLX5_FLOW_TYPE_GEN ) {flow_hw_q_flow_flush (dev,NULL ); -return ; }#endif - MLX5_IPOOL_FOREACH(priv->flows[type], fidx, flow) { -flow_drv_list_destroy (dev, type, fidx); +if (priv->sh->config.dv_flow_en ==2 ) { +flow_drv_list_destroy (dev, type, (uintptr_t )flow); + }else { +flow_drv_list_destroy (dev, type, fidx); + }if (unlikely (mlx5_need_cache_flow (priv,NULL ) && type ==MLX5_FLOW_TYPE_GEN )) { flow_info =LIST_FIRST (&mode_info->hot_upgrade);while (flow_info) {
@@ -8581,11 +8583,6 @@ mlx5_flow_destroy(struct rte_eth_dev *dev,struct rte_pmd_mlx5_flow_engine_mode_info *mode_info = &priv->mode_info;struct mlx5_dv_flow_info *flow_info; -if (priv->sh->config.dv_flow_en ==2 ) -return rte_flow_error_set (error,ENOTSUP , -RTE_FLOW_ERROR_TYPE_UNSPECIFIED , -NULL , -"Flow non-Q destruction not supported" );flow_drv_list_destroy (dev,MLX5_FLOW_TYPE_GEN , (uintptr_t )(void *)flow);if (unlikely (mlx5_need_cache_flow (priv,NULL ))) {
drivers/net/mlx5/mlx5_flow.h +9 -5
@@ -1320,6 +1320,8 @@ struct rte_flow_nt2hws {struct mlx5dr_bwc_rule *nt_rule;/** The matcher for non template api. */ struct mlx5_flow_dv_matcher *matcher; +/**< Auxiliary data stored per flow. */ +struct rte_flow_hw_aux *flow_aux; } __rte_packed;/** HWS flow struct. */
@@ -1354,12 +1356,14 @@ struct rte_flow_hw {struct mlx5_hrxq *hrxq; }; +/** Equals true if it is non template rule. */ +bool nt_rule;/** * Padding for alignment to 56 bytes. * Since mlx5dr rule is 72 bytes, whole flow is contained within 128 B (2 cache lines). * This space is reserved for future additions to flow struct. */ -uint8_t padding[10 ]; +uint8_t padding[9 ];/** HWS layer data struct. */ uint8_t rule[]; } __rte_packed;
@@ -2204,7 +2208,7 @@ int flow_hw_init(struct rte_eth_dev *dev, struct rte_flow_error *error); -typedef uint32_t (*mlx5_flow_list_create_t)(struct rte_eth_dev *dev, +typedef uintptr_t (*mlx5_flow_list_create_t)(struct rte_eth_dev *dev, enum mlx5_flow_type type, const struct rte_flow_attr *attr, const struct rte_flow_item items[],
@@ -2213,7 +2217,7 @@ typedef uint32_t (*mlx5_flow_list_create_t)(struct rte_eth_dev *dev, struct rte_flow_error *error);typedef void (*mlx5_flow_list_destroy_t )(struct rte_eth_dev *dev,enum mlx5_flow_type type, -uint32_t flow_idx); +uintptr_t flow_idx); typedef int (*mlx5_flow_validate_t)(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, const struct rte_flow_item items[],
@@ -3476,13 +3480,13 @@ int mlx5_flow_item_field_width(struct rte_eth_dev *dev, enum rte_flow_field_id field, int inherit, const struct rte_flow_attr *attr, struct rte_flow_error *error); -uint32_t flow_legacy_list_create (struct rte_eth_dev *dev,enum mlx5_flow_type type, +uintptr_t flow_legacy_list_create (struct rte_eth_dev *dev,enum mlx5_flow_type type,const struct rte_flow_attr *attr,const struct rte_flow_item items[],const struct rte_flow_action actions[],bool external,struct rte_flow_error *error);void flow_legacy_list_destroy (struct rte_eth_dev *dev,enum mlx5_flow_type type, -uint32_t flow_idx); +uintptr_t flow_idx); static __rte_always_inline int flow_hw_get_srh_flex_parser_byte_off_from_ctx(void *dr_ctx __rte_unused)
drivers/net/mlx5/mlx5_flow_dv.c +15 -3
@@ -11901,12 +11901,14 @@ flow_matcher_create_cb(void *tool_ctx, void *cb_ctx)struct mlx5_flow_cb_ctx *ctx = cb_ctx;struct mlx5_flow_dv_matcher *ref = ctx->data;struct mlx5_flow_dv_matcher *resource; +#ifdef HAVE_MLX5_HWS_SUPPORT +const struct rte_flow_item *items; +#endif struct mlx5dv_flow_matcher_attr dv_attr = { .type =IBV_FLOW_ATTR_NORMAL , .match_mask = (void *)&ref->mask, }; -struct mlx5_flow_tbl_data_entry *tbl =container_of (ref->tbl, -typeof (*tbl), tbl); +struct mlx5_flow_tbl_data_entry *tbl;int ret; resource = mlx5_malloc(MLX5_MEM_ZERO, sizeof(*resource), 0,
@@ -11917,9 +11919,9 @@ flow_matcher_create_cb(void *tool_ctx, void *cb_ctx) "cannot create matcher");return NULL ; } -/*Consider memcpy(resource, ref, sizeof(*resource));*/ *resource = *ref;if (sh->config.dv_flow_en !=2 ) { + tbl =container_of (ref->tbl,typeof (*tbl), tbl); dv_attr.match_criteria_enable =flow_dv_matcher_enable (resource->mask.buf); __flow_dv_adjust_buf_size(&ref->mask.size,
@@ -11937,6 +11939,16 @@ flow_matcher_create_cb(void *tool_ctx, void *cb_ctx) "cannot create matcher");return NULL ; } + }else { +#ifdef HAVE_MLX5_HWS_SUPPORT + items = *((const struct rte_flow_item **)(ctx->data2)); + resource->matcher_object =mlx5dr_bwc_matcher_create + (resource->group->tbl, resource->priority, items); +if (!(resource->matcher_object)) +return NULL ; +#else +return NULL ; +#endif }return &resource->entry; }
drivers/net/mlx5/mlx5_flow_hw.c +421 -408
1,349 lines not on this page · raw message
Signature · 1 line
2.21.0
PATCH v6 8/11 common/mlx5: read connection tracking attributes
In reply to Maayan KashaniNeed to read maximum connection tracking
objects from HCA attributes.
--- drivers/common/mlx5/mlx5_devx_cmds.c | 3 +++ drivers/common/mlx5/mlx5_devx_cmds.h | 1 + 2 files changed, 4 insertions(+)
drivers/common/mlx5/mlx5_devx_cmds.c +3 -0
@@ -1170,6 +1170,9 @@ mlx5_devx_cmd_query_hca_attr(void *ctx, (rc &MLX5_CROSS_VHCA_ALLOWED_OBJS_TIR ) && (rc &MLX5_CROSS_VHCA_ALLOWED_OBJS_FT ) && (rc &MLX5_CROSS_VHCA_ALLOWED_OBJS_RTC ); +if (attr->ct_offload) + attr->log_max_conn_track_offload =MLX5_GET (cmd_hca_cap_2, hcattr, + log_max_conn_track_offload); }if (attr->log_min_stride_wqe_sz ==0 ) attr->log_min_stride_wqe_sz =MLX5_MPRQ_LOG_MIN_STRIDE_WQE_SIZE ;
drivers/common/mlx5/mlx5_devx_cmds.h +1 -0
@@ -326,6 +326,7 @@ struct mlx5_hca_attr { uint32_t wqe_based_flow_table_sup:1;uint8_t max_header_modify_pattern_length;uint64_t system_image_guid; + uint32_t log_max_conn_track_offload:5; };/* LAG Context. */
Signature · 1 line
2.21.0
PATCH v6 9/11 net/mlx5: support bulk actions in non template mode
In reply to Maayan KashaniAdd support for encap/decap/modify header action for non template API.
Save 1 action per bulk according to action data. Reuse action if possible.
Store actions same as for SWS today, use same key structure.
--- drivers/net/mlx5/mlx5_flow.h | 44 ++++-- drivers/net/mlx5/mlx5_flow_dv.c | 268 ++++++++++++++++++++------------ drivers/net/mlx5/mlx5_flow_hw.c | 184 ++++++++++++++++++++-- 3 files changed, 368 insertions(+), 128 deletions(-)
drivers/net/mlx5/mlx5_flow.h +32 -12
@@ -671,6 +671,10 @@ struct mlx5_flow_dv_modify_hdr_resource {struct mlx5_list_entry entry;void *action;/**< Modify header action object. */ uint32_t idx; +#ifdef HAVE_MLX5_HWS_SUPPORT +void *mh_dr_pattern;/**< Modify header DR pattern(HWS only). */ +#endif +uint64_t flags;/**< Flags for RDMA API(HWS only). */ /* Key area for hash list matching: */ uint8_t ft_type;/**< Flow table type, Rx or Tx. */ uint8_t actions_num;/**< Number of modification actions. */
@@ -1322,7 +1326,11 @@ struct rte_flow_nt2hws {struct mlx5_flow_dv_matcher *matcher;/**< Auxiliary data stored per flow. */ struct rte_flow_hw_aux *flow_aux; -} __rte_packed; +/** Modify header pointer. */ +struct mlx5_flow_dv_modify_hdr_resource *modify_hdr; +/** Encap/decap index. */ +uint32_t rix_encap_decap; +};/** HWS flow struct. */ struct rte_flow_hw {
@@ -3238,14 +3246,14 @@ struct mlx5_list_entry *flow_dv_tag_clone_cb(void *tool_ctx, void *cb_ctx);void flow_dv_tag_clone_free_cb (void *tool_ctx,struct mlx5_list_entry *entry); -int flow_dv_modify_match_cb (void *tool_ctx,struct mlx5_list_entry *entry, +int flow_modify_match_cb (void *tool_ctx,struct mlx5_list_entry *entry,void *cb_ctx); -struct mlx5_list_entry *flow_dv_modify_create_cb (void *tool_ctx,void *ctx); -void flow_dv_modify_remove_cb (void *tool_ctx,struct mlx5_list_entry *entry); -struct mlx5_list_entry *flow_dv_modify_clone_cb (void *tool_ctx, +struct mlx5_list_entry *flow_modify_create_cb (void *tool_ctx,void *ctx); +void flow_modify_remove_cb (void *tool_ctx,struct mlx5_list_entry *entry); +struct mlx5_list_entry *flow_modify_clone_cb (void *tool_ctx,struct mlx5_list_entry *oentry,void *ctx); -void flow_dv_modify_clone_free_cb (void *tool_ctx, +void flow_modify_clone_free_cb (void *tool_ctx,struct mlx5_list_entry *entry);struct mlx5_list_entry *flow_dv_mreg_create_cb (void *tool_ctx,void *ctx);
@@ -3257,18 +3265,30 @@ struct mlx5_list_entry *flow_dv_mreg_clone_cb(void *tool_ctx, void *ctx);void flow_dv_mreg_clone_free_cb (void *tool_ctx,struct mlx5_list_entry *entry); -int flow_dv_encap_decap_match_cb (void *tool_ctx,struct mlx5_list_entry *entry, +int flow_encap_decap_match_cb (void *tool_ctx,struct mlx5_list_entry *entry,void *cb_ctx); -struct mlx5_list_entry *flow_dv_encap_decap_create_cb (void *tool_ctx, +struct mlx5_list_entry *flow_encap_decap_create_cb (void *tool_ctx,void *cb_ctx); -void flow_dv_encap_decap_remove_cb (void *tool_ctx, +void flow_encap_decap_remove_cb (void *tool_ctx,struct mlx5_list_entry *entry); -struct mlx5_list_entry *flow_dv_encap_decap_clone_cb (void *tool_ctx, +struct mlx5_list_entry *flow_encap_decap_clone_cb (void *tool_ctx,struct mlx5_list_entry *entry,void *cb_ctx); -void flow_dv_encap_decap_clone_free_cb (void *tool_ctx, +void flow_encap_decap_clone_free_cb (void *tool_ctx,struct mlx5_list_entry *entry); - +int __flow_encap_decap_resource_register + (struct rte_eth_dev *dev, +struct mlx5_flow_dv_encap_decap_resource *resource, +bool is_root, +struct mlx5_flow_dv_encap_decap_resource **encap_decap, +struct rte_flow_error *error); +int __flow_modify_hdr_resource_register + (struct rte_eth_dev *dev, +struct mlx5_flow_dv_modify_hdr_resource *resource, +struct mlx5_flow_dv_modify_hdr_resource **modify, +struct rte_flow_error *error); +int flow_encap_decap_resource_release (struct rte_eth_dev *dev, +uint32_t encap_decap_idx);int flow_matcher_match_cb (void *tool_ctx,struct mlx5_list_entry *entry,void *ctx);struct mlx5_list_entry *flow_matcher_create_cb (void *tool_ctx,void *ctx);
drivers/net/mlx5/mlx5_flow_dv.c +165 -103
459 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_hw.c +171 -13
299 lines not on this page · raw message
Signature · 1 line
2.21.0
PATCH v6 10/11 net/mlx5: use non const max number for ASO actions
In reply to Maayan KashaniFor ASO max allocations in non-template mode,
Read FW capabilities instead of using consts.
--- drivers/net/mlx5/mlx5.h | 17 ++++++++++++----- drivers/net/mlx5/mlx5_flow_hw.c | 13 +++++++++---- drivers/net/mlx5/mlx5_flow_meter.c | 25 +++++++++++++++++++++---- 3 files changed, 42 insertions(+), 13 deletions(-)
drivers/net/mlx5/mlx5.h +12 -5
@@ -812,12 +812,18 @@ struct mlx5_dev_shared_port {/* Only yellow color valid. */ #define MLX5_MTR_POLICY_MODE_OY 3 +/* Max number of meters. */ +#define MLX5_MTR_MAX (priv) (mlx5_flow_mtr_max_get(priv))/* Max number of meters allocated in non template mode. */ -#define MLX5_MTR_NT_MAX (1 << 23) -/* Max number of connection tracking allocated in non template mode */ -#define MLX5_CT_NT_MAX (1 << 23) -/* Max number of counters allocated in non template mode */ -#define MLX5_CNT_MAX (1 << 23) +#define MLX5_MTR_NT_MAX (priv) (MLX5_MTR_MAX(priv) >> 1) +/* Max number of connection tracking. */ +#define MLX5_CT_MAX (priv) (1 << (priv)->sh->cdev->config.hca_attr.log_max_conn_track_offload) +/* Max number of connection tracking allocated in non template mode. */ +#define MLX5_CT_NT_MAX (priv) (MLX5_CT_MAX(priv) >> 1) +/* Max number of counters. */ +#define MLX5_CNT_MAX (priv) ((priv)->sh->hws_max_nb_counters) +/* Max number of counters allocated in non template mode. */ +#define MLX5_CNT_NT_MAX (priv) (MLX5_CNT_MAX(priv) >> 1)enum mlx5_meter_domain {MLX5_MTR_DOMAIN_INGRESS ,
@@ -2457,6 +2463,7 @@ mlx5_flow_meter_hierarchy_get_final_policy(struct rte_eth_dev *dev,int mlx5_flow_meter_flush (struct rte_eth_dev *dev,struct rte_mtr_error *error);void mlx5_flow_meter_rxq_flush (struct rte_eth_dev *dev); +uint32_t mlx5_flow_mtr_max_get (struct mlx5_priv *priv);/* mlx5_os.c */
drivers/net/mlx5/mlx5_flow_hw.c +9 -4
@@ -13114,6 +13114,7 @@ static int flow_hw_ensure_action_pools_allocated(struct rte_eth_dev *dev,bool actions_end = false;struct mlx5_priv *priv = dev->data->dev_private;int ret; +uint obj_num;for (; !actions_end; actions++) {switch ((int )actions->type) {
@@ -13122,7 +13123,8 @@ static int flow_hw_ensure_action_pools_allocated(struct rte_eth_dev *dev,if (!priv->hws_age_req) {/* If no counters were previously allocated. */ if (!priv->hws_cpool) { - ret =mlx5_hws_cnt_pool_create (dev,MLX5_CNT_MAX , + obj_num =MLX5_CNT_NT_MAX (priv); + ret =mlx5_hws_cnt_pool_create (dev, obj_num, priv->nb_queue,NULL );if (ret) goto err;
@@ -13140,7 +13142,8 @@ static int flow_hw_ensure_action_pools_allocated(struct rte_eth_dev *dev,case RTE_FLOW_ACTION_TYPE_COUNT :/* If no counters were previously allocated. */ if (!priv->hws_cpool) { - ret =mlx5_hws_cnt_pool_create (dev,MLX5_CNT_MAX , + obj_num =MLX5_CNT_NT_MAX (priv); + ret =mlx5_hws_cnt_pool_create (dev, obj_num, priv->nb_queue,NULL );if (ret) goto err;
@@ -13149,7 +13152,8 @@ static int flow_hw_ensure_action_pools_allocated(struct rte_eth_dev *dev,case RTE_FLOW_ACTION_TYPE_CONNTRACK :/* If no CT were previously allocated. */ if (!priv->hws_ctpool) { - ret =mlx5_flow_ct_init (dev,MLX5_CT_NT_MAX , priv->nb_queue); + obj_num =MLX5_CT_NT_MAX (priv); + ret =mlx5_flow_ct_init (dev, obj_num, priv->nb_queue);if (ret) goto err; }
@@ -13157,7 +13161,8 @@ static int flow_hw_ensure_action_pools_allocated(struct rte_eth_dev *dev,case RTE_FLOW_ACTION_TYPE_METER_MARK :/* If no meters were previously allocated. */ if (!priv->hws_mpool) { - ret =mlx5_flow_meter_init (dev,MLX5_MTR_NT_MAX ,0 ,0 , + obj_num =MLX5_MTR_NT_MAX (priv); + ret =mlx5_flow_meter_init (dev, obj_num,0 ,0 , priv->nb_queue);if (ret) goto err;
drivers/net/mlx5/mlx5_flow_meter.c +21 -4
@@ -704,6 +704,26 @@ mlx5_flow_meter_param_fill(struct mlx5_flow_meter_profile *fmp,return 0 ; } +/** +* Callback to get MTR maximum objects number. +* +* @param[in] priv +* Pointer to Ethernet device. +* +* @return +* Max number of meters. +*/ +uint32_t +mlx5_flow_mtr_max_get (struct mlx5_priv *priv) +{ +struct mlx5_hca_qos_attr *qattr = &priv->sh->cdev->config.hca_attr.qos; + +/* Max number of meters. */ +return ((priv->sh->meter_aso_en) ? +1 << (qattr->log_max_num_meter_aso +1 ) : + qattr->log_max_flow_meter); +} +/** * Callback to get MTR capabilities. *
@@ -730,14 +750,11 @@ mlx5_flow_mtr_cap_get(struct rte_eth_dev *dev,RTE_MTR_ERROR_TYPE_UNSPECIFIED ,NULL , "Meter is not supported");memset (cap,0 ,sizeof (*cap)); + cap->n_max =mlx5_flow_mtr_max_get (priv);if (priv->sh->meter_aso_en) { -/* 2 meters per one ASO cache line. */ - cap->n_max =1 << (qattr->log_max_num_meter_aso +1 ); cap->srtcm_rfc2697_packet_mode_supported =1 ; cap->trtcm_rfc2698_packet_mode_supported =1 ; cap->trtcm_rfc4115_packet_mode_supported =1 ; - }else { - cap->n_max =1 << qattr->log_max_flow_meter; } cap->srtcm_rfc2697_byte_mode_supported =1 ; cap->trtcm_rfc2698_byte_mode_supported =1 ;
Signature · 1 line
2.21.0
PATCH v6 11/11 net/mlx5: initial design changes
In reply to Maayan KashaniChange flow_drv_list_create/destroy to mlx5_flow_list_create/destroy. Remove resource release function inlining.
Check number of queues in template mode in hw configure function. Use user priority to calculate matcher priority.
--- drivers/net/mlx5/mlx5_flow.c | 70 +++++++--------------- drivers/net/mlx5/mlx5_flow_hw.c | 100 +++++++++++++++----------------- 2 files changed, 68 insertions(+), 102 deletions(-)
drivers/net/mlx5/mlx5_flow.c +20 -50
@@ -4983,19 +4983,6 @@ flow_check_hairpin_split(struct rte_eth_dev *dev,return 0 ; } -/* Declare flow create/destroy prototype in advance. */ - -static uintptr_t -flow_drv_list_create (struct rte_eth_dev *dev,enum mlx5_flow_type type, -const struct rte_flow_attr *attr, -const struct rte_flow_item items[], -const struct rte_flow_action actions[], -bool external,struct rte_flow_error *error); - -static void -flow_drv_list_destroy (struct rte_eth_dev *dev,enum mlx5_flow_type type, -uintptr_t flow_idx); -int flow_dv_mreg_match_cb(void *tool_ctx __rte_unused,struct mlx5_list_entry *entry,void *cb_ctx)
@@ -5114,7 +5101,7 @@ flow_dv_mreg_create_cb(void *tool_ctx, void *cb_ctx)* be applied, removed, deleted in arbitrary order * by list traversing. */ - mcp_res->rix_flow =flow_drv_list_create (dev,MLX5_FLOW_TYPE_MCP , + mcp_res->rix_flow =mlx5_flow_list_create (dev,MLX5_FLOW_TYPE_MCP , &attr, items, actions, false, error);if (!mcp_res->rix_flow) {mlx5_ipool_free (priv->sh->ipool[MLX5_IPOOL_MCP ], idx);
@@ -5208,7 +5195,7 @@ flow_dv_mreg_remove_cb(void *tool_ctx, struct mlx5_list_entry *entry)struct mlx5_priv *priv = dev->data->dev_private;MLX5_ASSERT (mcp_res->rix_flow); -flow_drv_list_destroy (dev,MLX5_FLOW_TYPE_MCP , mcp_res->rix_flow); +mlx5_flow_list_destroy (dev,MLX5_FLOW_TYPE_MCP , mcp_res->rix_flow);mlx5_ipool_free (priv->sh->ipool[MLX5_IPOOL_MCP ], mcp_res->idx); }
@@ -7595,7 +7582,7 @@ mlx5_flow_create_esw_table_zero_flow(struct rte_eth_dev *dev) };struct rte_flow_error error; -return (void *)(uintptr_t )flow_drv_list_create (dev,MLX5_FLOW_TYPE_CTL , +return (void *)(uintptr_t )mlx5_flow_list_create (dev,MLX5_FLOW_TYPE_CTL , &attr, &pattern, actions, false, &error); }
@@ -7663,14 +7650,14 @@ mlx5_flow_create_devx_sq_miss_flow(struct rte_eth_dev *dev, uint32_t sq_num)* Creates group 0, highest priority jump flow. * Matches txq to bypass kernel packets. */ -if (flow_drv_list_create (dev,MLX5_FLOW_TYPE_CTL , &attr, pattern, actions, +if (mlx5_flow_list_create (dev,MLX5_FLOW_TYPE_CTL , &attr, pattern, actions, false, &error) ==0 )return 0 ;/* Create group 1, lowest priority redirect flow for txq. */ attr.group =1 ; actions[0 ].conf = &port; actions[0 ].type =RTE_FLOW_ACTION_TYPE_PORT_ID ; -return flow_drv_list_create (dev,MLX5_FLOW_TYPE_CTL , &attr, pattern, +return mlx5_flow_list_create (dev,MLX5_FLOW_TYPE_CTL , &attr, pattern, actions, false, &error); }
@@ -7826,7 +7813,7 @@ mlx5_flow_cache_flow_toggle(struct rte_eth_dev *dev, bool orig_prio) flow_info->flow_idx_low_prio);if (high && low) {RTE_SWAP (*low, *high); -flow_drv_list_destroy (dev,MLX5_FLOW_TYPE_GEN , +mlx5_flow_list_destroy (dev,MLX5_FLOW_TYPE_GEN , flow_info->flow_idx_low_prio); flow_info->flow_idx_high_prio =0 ; }
@@ -7840,7 +7827,7 @@ mlx5_flow_cache_flow_toggle(struct rte_eth_dev *dev, bool orig_prio)while (flow_info) {if (flow_info->orig_prio != flow_info->attr.priority) {if (flow_info->flow_idx_high_prio) -flow_drv_list_destroy (dev,MLX5_FLOW_TYPE_GEN , +mlx5_flow_list_destroy (dev,MLX5_FLOW_TYPE_GEN , flow_info->flow_idx_high_prio);else break ;
@@ -7995,12 +7982,13 @@ mlx5_flow_create(struct rte_eth_dev *dev, RTE_PMD_MLX5_FLOW_ENGINE_FLAG_STANDBY_DUP_INGRESS))) new_attr->priority += 1; } - flow_idx =flow_drv_list_create (dev,MLX5_FLOW_TYPE_GEN , attr, items, actions, true, error); + flow_idx =mlx5_flow_list_create (dev,MLX5_FLOW_TYPE_GEN , attr, items, actions, + true, error);if (!flow_idx)return NULL ;if (unlikely (mlx5_need_cache_flow (priv, attr))) {if (mlx5_flow_cache_flow_info (dev, attr, prio, items, actions, flow_idx)) { -flow_drv_list_destroy (dev,MLX5_FLOW_TYPE_GEN , flow_idx); +mlx5_flow_list_destroy (dev,MLX5_FLOW_TYPE_GEN , flow_idx); flow_idx =0 ; } }
@@ -8013,17 +8001,6 @@ mlx5_flow_list_create(struct rte_eth_dev *dev, enum mlx5_flow_type type,const struct rte_flow_item items[], const struct rte_flow_action actions[], bool external, struct rte_flow_error *error) -{ - return flow_drv_list_create(dev, type, attr, items, actions, external, -error ); -} - -uintptr_t -flow_drv_list_create (struct rte_eth_dev *dev,enum mlx5_flow_type type, -const struct rte_flow_attr *attr, -const struct rte_flow_item items[], -const struct rte_flow_action actions[], -bool external,struct rte_flow_error *error) { const struct mlx5_flow_driver_ops *fops;enum mlx5_flow_drv_type drv_type =flow_get_drv_type (dev, attr);
@@ -8072,8 +8049,8 @@ flow_legacy_list_destroy(struct rte_eth_dev *dev, enum mlx5_flow_type type,mlx5_ipool_free (priv->flows[type], flow_idx); } -static void -flow_drv_list_destroy (struct rte_eth_dev *dev,enum mlx5_flow_type type, +void +mlx5_flow_list_destroy (struct rte_eth_dev *dev,enum mlx5_flow_type type,uintptr_t flow_idx) {const struct mlx5_flow_driver_ops *fops;
@@ -8084,13 +8061,6 @@ flow_drv_list_destroy(struct rte_eth_dev *dev, enum mlx5_flow_type type, fops->list_destroy (dev, type, flow_idx); } -void -mlx5_flow_list_destroy (struct rte_eth_dev *dev,enum mlx5_flow_type type, -uintptr_t flow_idx) -{ -flow_drv_list_destroy (dev, type, flow_idx); -} -/** * Destroy all flows. *
@@ -8119,9 +8089,9 @@ mlx5_flow_list_flush(struct rte_eth_dev *dev, enum mlx5_flow_type type,#endif MLX5_IPOOL_FOREACH(priv->flows[type], fidx, flow) {if (priv->sh->config.dv_flow_en ==2 ) { -flow_drv_list_destroy (dev, type, (uintptr_t )flow); +mlx5_flow_list_destroy (dev, type, (uintptr_t )flow); }else { -flow_drv_list_destroy (dev, type, fidx); +mlx5_flow_list_destroy (dev, type, fidx); }if (unlikely (mlx5_need_cache_flow (priv,NULL ) && type ==MLX5_FLOW_TYPE_GEN )) { flow_info =LIST_FIRST (&mode_info->hot_upgrade);
@@ -8394,7 +8364,7 @@ mlx5_ctrl_flow_source_queue(struct rte_eth_dev *dev, actions[0 ].type =RTE_FLOW_ACTION_TYPE_JUMP ; actions[0 ].conf = &jump; actions[1 ].type =RTE_FLOW_ACTION_TYPE_END ; - flow_idx =flow_drv_list_create (dev,MLX5_FLOW_TYPE_CTL , + flow_idx =mlx5_flow_list_create (dev,MLX5_FLOW_TYPE_CTL , &attr, items, actions, false, &error);if (!flow_idx) { DRV_LOG(DEBUG,
@@ -8484,7 +8454,7 @@ mlx5_ctrl_flow_vlan(struct rte_eth_dev *dev, action_rss.types =0 ;for (i =0 ; i != priv->reta_idx_n; ++i) queue[i] = (*priv->reta_idx)[i]; - flow_idx =flow_drv_list_create (dev,MLX5_FLOW_TYPE_CTL , + flow_idx =mlx5_flow_list_create (dev,MLX5_FLOW_TYPE_CTL , &attr, items, actions, false, &error);if (!flow_idx)return -rte_errno;
@@ -8559,7 +8529,7 @@ mlx5_flow_lacp_miss(struct rte_eth_dev *dev) }, };struct rte_flow_error error; -uint32_t flow_idx =flow_drv_list_create (dev,MLX5_FLOW_TYPE_CTL , +uint32_t flow_idx =mlx5_flow_list_create (dev,MLX5_FLOW_TYPE_CTL , &attr, items, actions, false, &error);
@@ -8583,7 +8553,7 @@ mlx5_flow_destroy(struct rte_eth_dev *dev,struct rte_pmd_mlx5_flow_engine_mode_info *mode_info = &priv->mode_info;struct mlx5_dv_flow_info *flow_info; -flow_drv_list_destroy (dev,MLX5_FLOW_TYPE_GEN , +mlx5_flow_list_destroy (dev,MLX5_FLOW_TYPE_GEN , (uintptr_t )(void *)flow);if (unlikely (mlx5_need_cache_flow (priv,NULL ))) { flow_info =LIST_FIRST (&mode_info->hot_upgrade);
@@ -9896,14 +9866,14 @@ mlx5_flow_discover_mreg_c(struct rte_eth_dev *dev)if (!priv->sh->config.dv_flow_en)break ;/* Create internal flow, validation skips copy action. */ - flow_idx =flow_drv_list_create (dev,MLX5_FLOW_TYPE_GEN , &attr, + flow_idx =mlx5_flow_list_create (dev,MLX5_FLOW_TYPE_GEN , &attr, items, actions, false, &error); flow =mlx5_ipool_get (priv->flows[MLX5_FLOW_TYPE_GEN ], flow_idx);if (!flow)continue ; priv->sh->flow_mreg_c[n++] = idx; -flow_drv_list_destroy (dev,MLX5_FLOW_TYPE_GEN , flow_idx); +mlx5_flow_list_destroy (dev,MLX5_FLOW_TYPE_GEN , flow_idx); }for (; n <MLX5_MREG_C_NUM ; ++n) priv->sh->flow_mreg_c[n] =REG_NON ;
drivers/net/mlx5/mlx5_flow_hw.c +48 -52
190 lines not on this page · raw message
Signature · 1 line
2.21.0
PATCH v7 1/11 net/mlx5: initial design of non template to hws
In reply to Maayan KashaniImplement the frame and needed building
blocks for non template to hws API's.
Added validate, list_create and list_destroy to mlx5_flow_hw_drv_ops. Rename old list_create/list_destroy functions to legacy_* and added a call from verbs/dv ops to the legacy functions.
Updated rte_flow_hw as needed.
Added rte_flow_nt2hws structure for non-template rule data.
squash to net/mlx5: initial design of non template to hws
--- drivers/net/mlx5/linux/mlx5_os.c | 8 +- drivers/net/mlx5/mlx5.h | 9 + drivers/net/mlx5/mlx5_flow.c | 139 +++++--- drivers/net/mlx5/mlx5_flow.h | 74 ++++- drivers/net/mlx5/mlx5_flow_dv.c | 192 +++++++++--- drivers/net/mlx5/mlx5_flow_hw.c | 487 +++++++++++++++++++++++++++-- drivers/net/mlx5/mlx5_flow_verbs.c | 2 + drivers/net/mlx5/mlx5_trigger.c | 6 + drivers/net/mlx5/windows/mlx5_os.c | 8 +- 9 files changed, 808 insertions(+), 117 deletions(-)
drivers/net/mlx5/linux/mlx5_os.c +7 -1
@@ -69,7 +69,7 @@ static rte_spinlock_t mlx5_shared_data_lock = RTE_SPINLOCK_INITIALIZER;static struct mlx5_local_data mlx5_local_data;/* rte flow indexed pool configuration. */ -static struct mlx5_indexed_pool_config icfg[] = { +static const struct mlx5_indexed_pool_config default_icfg[] = { { .size =sizeof (struct rte_flow ), .trunk_size =64 ,
@@ -1080,7 +1080,9 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,struct mlx5_port_info vport_info = { .query_flags =0 };int nl_rdma;int i; +struct mlx5_indexed_pool_config icfg[RTE_DIM (default_icfg)]; +memcpy (icfg, default_icfg,sizeof (icfg));/* Determine if this port representor is supposed to be spawned. */ if (switch_info->representor && dpdk_dev->devargs && !mlx5_representor_match (spawn, eth_da))
@@ -1560,6 +1562,10 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, icfg[i].release_mem_en = !!sh->config.reclaim_mode;if (sh->config.reclaim_mode) icfg[i].per_core_cache =0 ; +#ifdef HAVE_MLX5_HWS_SUPPORT +if (priv->sh->config.dv_flow_en ==2 ) + icfg[i].size =sizeof (struct rte_flow_hw ) +sizeof (struct rte_flow_nt2hws ); +#endif priv->flows[i] =mlx5_ipool_create (&icfg[i]);if (!priv->flows[i]) goto error;
drivers/net/mlx5/mlx5.h +9 -0
@@ -2327,6 +2327,15 @@ int mlx5_flow_validate(struct rte_eth_dev *dev,const struct rte_flow_item items[], const struct rte_flow_action actions[], struct rte_flow_error *error); +uint32_t +mlx5_flow_list_create (struct rte_eth_dev *dev,enum mlx5_flow_type type, +const struct rte_flow_attr *attr, +const struct rte_flow_item items[], +const struct rte_flow_action actions[], +bool external,struct rte_flow_error *error); +void +mlx5_flow_list_destroy (struct rte_eth_dev *dev,enum mlx5_flow_type type, +uint32_t flow_idx); struct rte_flow *mlx5_flow_create(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, const struct rte_flow_item items[],
drivers/net/mlx5/mlx5_flow.c +96 -43
311 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow.h +65 -9
131 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_dv.c +157 -35
316 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_hw.c +459 -28
568 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_verbs.c +2 -0
@@ -2186,6 +2186,8 @@ flow_verbs_sync_domain(struct rte_eth_dev *dev, uint32_t domains, }const struct mlx5_flow_driver_ops mlx5_flow_verbs_drv_ops = { + .list_create = flow_legacy_list_create, + .list_destroy = flow_legacy_list_destroy, .validate = flow_verbs_validate, .prepare = flow_verbs_prepare, .translate = flow_verbs_translate,
drivers/net/mlx5/mlx5_trigger.c +6 -0
@@ -1158,6 +1158,12 @@ mlx5_dev_start(struct rte_eth_dev *dev)DRV_LOG (DEBUG ,"port %u starting device" , dev->data->port_id);#ifdef HAVE_MLX5_HWS_SUPPORT if (priv->sh->config.dv_flow_en ==2 ) { +/*If previous configuration does not exist. */ +if (!(priv->dr_ctx)) { + ret =flow_hw_init (dev,NULL ); +if (ret) +return ret; + }/* If there is no E-Switch, then there are no start/stop order limitations. */ if (!priv->sh->config.dv_esw_en) goto continue_dev_start;
drivers/net/mlx5/windows/mlx5_os.c +7 -1
@@ -35,7 +35,7 @@ static const char *MZ_MLX5_PMD_SHARED_DATA = "mlx5_pmd_shared_data";static rte_spinlock_t mlx5_shared_data_lock =RTE_SPINLOCK_INITIALIZER ;/* rte flow indexed pool configuration. */ -static struct mlx5_indexed_pool_config icfg[] = { +static const struct mlx5_indexed_pool_config default_icfg[] = { { .size =sizeof (struct rte_flow ), .trunk_size =64 ,
@@ -352,7 +352,9 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,int own_domain_id =0 ;uint16_t port_id;int i; +struct mlx5_indexed_pool_config icfg[RTE_DIM (default_icfg)]; +memcpy (icfg, default_icfg,sizeof (icfg));/* Build device name. */ strlcpy (name, dpdk_dev->name,sizeof (name));/* check if the device is already spawned */
@@ -538,6 +540,10 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, icfg[i].release_mem_en = !!sh->config.reclaim_mode;if (sh->config.reclaim_mode) icfg[i].per_core_cache =0 ; +#ifdef HAVE_MLX5_HWS_SUPPORT +if (priv->sh->config.dv_flow_en ==2 ) + icfg[i].size =sizeof (struct rte_flow_hw ) +sizeof (struct rte_flow_nt2hws ); +#endif priv->flows[i] =mlx5_ipool_create (&icfg[i]);if (!priv->flows[i]) goto error;
Signature · 1 line
2.21.0
PATCH v7 2/11 net/mlx5: add dummy last action
From: Bing Zhao <[email protected]>
The RTE_FLOW_ACTION_TYPE_END action needs to be translated into the MLX5DR_ACTION_TYP_LAST for the future usage. It is only needed in the hardware steering backward compatible API.
--- drivers/net/mlx5/mlx5.h | 1 + drivers/net/mlx5/mlx5_flow_hw.c | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+)
drivers/net/mlx5/mlx5.h +1 -0
@@ -1529,6 +1529,7 @@ struct mlx5_dev_ctx_shared {/* Direct Rules tables for FDB, NIC TX+RX */ void *dr_drop_action;/* Pointer to DR drop action, any domain. */ void *pop_vlan_action;/* Pointer to DR pop VLAN action. */ +void *hw_dummy_last;/* Pointer to the DR dummy end action, any domain. */ #if defined(HAVE_IBV_FLOW_DV_SUPPORT ) || !defined(HAVE_INFINIBAND_VERBS_H )struct mlx5_send_to_kernel_action send_to_kernel_action[MLX5DR_TABLE_TYPE_MAX ];#endif
drivers/net/mlx5/mlx5_flow_hw.c +19 -0
@@ -11219,6 +11219,17 @@ flow_hw_configure(struct rte_eth_dev *dev,if (ret) goto err; } +/* +* All domains will use the same dummy action, only used in the backward +* compatible API. Initialize it for only once. No order dependency. +*/ +if (!priv->sh->hw_dummy_last) { + priv->sh->hw_dummy_last =mlx5dr_action_create_last (priv->dr_ctx, +MLX5DR_ACTION_FLAG_HWS_RX ); +if (!priv->sh->hw_dummy_last) +/* Do not overwrite the rte_errno. */ + goto err; + }if (!priv->shared_host)flow_hw_create_send_to_kernel_actions (priv);if (port_attr->nb_conn_tracks || (host_priv && host_priv->hws_ctpool)) {
@@ -11297,6 +11308,10 @@ flow_hw_configure(struct rte_eth_dev *dev,flow_hw_ct_mng_destroy (dev, priv->ct_mng); priv->ct_mng =NULL ; } +if (priv->sh->hw_dummy_last) { +mlx5dr_action_destroy (priv->sh->hw_dummy_last); + priv->sh->hw_dummy_last =NULL ; + }flow_hw_destroy_send_to_kernel_action (priv);flow_hw_cleanup_ctrl_fdb_tables (dev);flow_hw_free_vport_actions (priv);
@@ -11422,6 +11437,10 @@ flow_hw_resource_release(struct rte_eth_dev *dev)mlx5dr_action_destroy (priv->hw_def_miss);flow_hw_destroy_nat64_actions (priv);flow_hw_destroy_vlan (dev); +if (priv->sh->hw_dummy_last) { +mlx5dr_action_destroy (priv->sh->hw_dummy_last); + priv->sh->hw_dummy_last =NULL ; + }flow_hw_destroy_send_to_kernel_action (priv);flow_hw_free_vport_actions (priv);if (priv->acts_ipool) {
Signature · 1 line
2.21.0
PATCH v7 3/11 net/mlx5: add basic actions support for non-template API
In reply to Maayan KashaniFrom: Bing Zhao <[email protected]>
Support JUMP / DROP / QUEUE / MARK / FLAG now.
--- drivers/net/mlx5/mlx5_flow_hw.c | 154 ++++++++++++++++++++++++++++---- 1 file changed, 136 insertions(+), 18 deletions(-)
drivers/net/mlx5/mlx5_flow_hw.c +136 -18
@@ -546,8 +546,7 @@ flow_hw_jump_release(struct rte_eth_dev *dev, struct mlx5_hw_jump_action *jump)struct mlx5_priv *priv = dev->data->dev_private;struct mlx5_flow_group *grp; - grp =container_of - (jump, struct mlx5_flow_group, jump); + grp = container_of(jump, struct mlx5_flow_group, jump);mlx5_hlist_unregister (priv->sh->flow_tbls, &grp->entry); }
@@ -647,17 +646,9 @@ flow_hw_template_destroy_mhdr_action(struct mlx5_hw_modify_header_action *mhdr)* Pointer to the template HW steering DR actions. */ static void -__flow_hw_action_template_destroy (struct rte_eth_dev *dev, -struct mlx5_hw_actions *acts) +__flow_hw_actions_release (struct rte_eth_dev *dev,struct mlx5_hw_actions *acts) {struct mlx5_priv *priv = dev->data->dev_private; -struct mlx5_action_construct_data *data; - -while (!LIST_EMPTY (&acts->act_list)) { - data =LIST_FIRST (&acts->act_list); -LIST_REMOVE (data, next); -mlx5_ipool_free (priv->acts_ipool, data->idx); - }if (acts->mark) if (!(rte_atomic_fetch_sub_explicit(&priv->hws_mark_refcnt, 1,
@@ -702,6 +693,32 @@ __flow_hw_action_template_destroy(struct rte_eth_dev *dev, } } +/** +* Destroy DR actions created by action template. +* +* For DR actions created during table creation's action translate. +* Need to destroy the DR action when destroying the table. +* +* @param[in] dev +* Pointer to the rte_eth_dev structure. +* @param[in] acts +* Pointer to the template HW steering DR actions. +*/ +static void +__flow_hw_action_template_destroy (struct rte_eth_dev *dev,struct mlx5_hw_actions *acts) +{ +struct mlx5_priv *priv = dev->data->dev_private; +struct mlx5_action_construct_data *data; + +while (!LIST_EMPTY (&acts->act_list)) { + data =LIST_FIRST (&acts->act_list); +LIST_REMOVE (data, next); +mlx5_ipool_free (priv->acts_ipool, data->idx); + } + +__flow_hw_actions_release (dev, acts); +} +/** * Append dynamic action to the dynamic action list. *
@@ -12690,14 +12707,114 @@ static int flow_hw_prepare(struct rte_eth_dev *dev,return 0 ; } -static int flow_hw_translate_actions(struct rte_eth_dev *dev __rte_unused, - const struct rte_flow_attr *attr __rte_unused, - const struct rte_flow_action actions[] __rte_unused, - struct rte_flow_hw *flow __rte_unused, - struct rte_flow_error *error __rte_unused) +static int +flow_hw_translate_actions (struct rte_eth_dev *dev, +const struct rte_flow_attr *attr, +const struct rte_flow_action actions[], +struct rte_flow_hw *flow, +struct mlx5_hw_actions *hw_acts, +bool external, +struct rte_flow_error *error) { -/* TODO implement */ +struct mlx5_priv *priv = dev->data->dev_private; +enum mlx5dr_table_type type; +enum mlx5_hw_action_flag_type flag_type; +bool actions_end = false; +uint64_t action_flags =0 ;/* to be used when needed */ +uint32_t actions_n =0 ; +uint32_t mark_id; +uint32_t jump_group; +bool is_mark; +struct mlx5_flow_template_table_cfg tbl_cfg; +enum mlx5_flow_fate_type fate_type =MLX5_FLOW_FATE_NONE ; + +RTE_SET_USED (action_flags); +if (attr->transfer) + type =MLX5DR_TABLE_TYPE_FDB ; +else if (attr->egress) + type =MLX5DR_TABLE_TYPE_NIC_TX ; +else + type =MLX5DR_TABLE_TYPE_NIC_RX ; +/* The group in the attribute translation was done in advance. */ + flag_type = (attr->group ==0 ) ?MLX5_HW_ACTION_FLAG_ROOT : +MLX5_HW_ACTION_FLAG_NONE_ROOT ; +for (; !actions_end; actions++) { +switch (actions->type) { +case RTE_FLOW_ACTION_TYPE_VOID : +break ; +case RTE_FLOW_ACTION_TYPE_DROP : + hw_acts->rule_acts[actions_n++].action = priv->hw_drop[flag_type]; + fate_type =MLX5_FLOW_FATE_DROP ; +break ; +case RTE_FLOW_ACTION_TYPE_FLAG : +case RTE_FLOW_ACTION_TYPE_MARK : + is_mark = actions->type ==RTE_FLOW_ACTION_TYPE_MARK ; + mark_id = is_mark ? + ((const struct rte_flow_action_mark *)(actions->conf))->id : +MLX5_FLOW_MARK_DEFAULT ; + hw_acts->rule_acts[actions_n].tag.value =mlx5_flow_mark_set (mark_id); + hw_acts->rule_acts[actions_n].action = priv->hw_tag[flag_type]; + actions_n++; + action_flags |= is_mark ?MLX5_FLOW_ACTION_MARK :MLX5_FLOW_ACTION_FLAG ; + hw_acts->mark = true; +rte_atomic_fetch_add_explicit (&priv->hws_mark_refcnt,1 , + rte_memory_order_relaxed); +flow_hw_rxq_flag_set (dev, true); +break ; +case RTE_FLOW_ACTION_TYPE_JUMP : + jump_group = ((const struct rte_flow_action_jump *)actions->conf)->group; + tbl_cfg.attr.flow_attr = *attr; + tbl_cfg.external = external; +/* The flow_hw_jump_action_register() can be refactored. */ + hw_acts->jump =flow_hw_jump_action_register (dev, &tbl_cfg, + jump_group, error); +if (hw_acts->jump ==NULL ) + goto clean_up; + hw_acts->rule_acts[actions_n++].action = + (flag_type ==MLX5_HW_ACTION_FLAG_NONE_ROOT ) ? + hw_acts->jump->hws_action : hw_acts->jump->root_action; + action_flags |=MLX5_FLOW_ACTION_JUMP ; + fate_type =MLX5_FLOW_FATE_JUMP ; +break ; +case RTE_FLOW_ACTION_TYPE_QUEUE : +/* Right now, only Rx supports the TIR, validation is needed. */ + hw_acts->tir =flow_hw_tir_action_register (dev, + mlx5_hw_act_flag[flag_type][type], actions); +if (hw_acts->tir ==NULL ) { +rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION ,NULL , +"Failed to translate queue." ); + goto clean_up; + } + action_flags |=MLX5_FLOW_ACTION_QUEUE ; + fate_type =MLX5_FLOW_FATE_QUEUE ; +break ; +case RTE_FLOW_ACTION_TYPE_END : +/* +* Using NULL action right now, maybe a new API can be used +* to create a dummy action with type MLX5DR_ACTION_TYP_LAST. +*/ + hw_acts->rule_acts[actions_n++].action = priv->sh->hw_dummy_last; + actions_end = true; +break ; +default : +break ; + } + } +if (fate_type ==MLX5_FLOW_FATE_QUEUE ) { + hw_acts->rule_acts[actions_n++].action = hw_acts->tir->action; + flow->hrxq = hw_acts->tir; + }else { +if (fate_type ==MLX5_FLOW_FATE_JUMP ) + flow->jump = hw_acts->jump; + } +/* Total actions number should be validated before. */ +MLX5_ASSERT (actions_n <=MLX5_HW_MAX_ACTS );return 0 ; +clean_up: +/* Make sure that there is no garbage in the actions. */ +__flow_hw_actions_release (dev, hw_acts); +return -rte_errno; } static int flow_hw_register_matcher(struct rte_eth_dev *dev,
@@ -12891,7 +13008,8 @@ static int flow_hw_create_flow(struct rte_eth_dev *dev,if (ret) goto error; - ret =flow_hw_translate_actions (dev, attr, actions, *flow, error); +/* Note: the actions should be saved in the sub-flow rule itself for reference. */ + ret =flow_hw_translate_actions (dev, attr, actions, *flow, &hw_act, external, error);if (ret) goto error;
Signature · 1 line
2.21.0
PATCH v7 4/11 net/mlx5: add default miss action support in nt2hws mode
In reply to Maayan KashaniFrom: Bing Zhao <[email protected]>
The validation will be handled later.
Now it only supports the SEND_TO_KERNEL on non-root tables.
--- drivers/net/mlx5/mlx5_flow_hw.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-)
drivers/net/mlx5/mlx5_flow_hw.c +19 -3
@@ -12721,23 +12721,28 @@ flow_hw_translate_actions(struct rte_eth_dev *dev,enum mlx5_hw_action_flag_type flag_type;bool actions_end = false;uint64_t action_flags =0 ;/* to be used when needed */ +int ret;uint32_t actions_n =0 ;uint32_t mark_id;uint32_t jump_group; +uint32_t src_group =0 ;bool is_mark;struct mlx5_flow_template_table_cfg tbl_cfg;enum mlx5_flow_fate_type fate_type =MLX5_FLOW_FATE_NONE ;RTE_SET_USED (action_flags); +/* The group in the attribute translation was done in advance. */ + ret =__translate_group (dev, attr, external, attr->group, &src_group, error); +if (ret) +return ret;if (attr->transfer) type =MLX5DR_TABLE_TYPE_FDB ;else if (attr->egress) type =MLX5DR_TABLE_TYPE_NIC_TX ;else type =MLX5DR_TABLE_TYPE_NIC_RX ; -/* The group in the attribute translation was done in advance. */ - flag_type = (attr->group ==0 ) ?MLX5_HW_ACTION_FLAG_ROOT : -MLX5_HW_ACTION_FLAG_NONE_ROOT ; + flag_type = (src_group ==0 ) ?MLX5_HW_ACTION_FLAG_ROOT : +MLX5_HW_ACTION_FLAG_NONE_ROOT ;for (; !actions_end; actions++) {switch (actions->type) {case RTE_FLOW_ACTION_TYPE_VOID :
@@ -12789,6 +12794,17 @@ flow_hw_translate_actions(struct rte_eth_dev *dev, action_flags |=MLX5_FLOW_ACTION_QUEUE ; fate_type =MLX5_FLOW_FATE_QUEUE ;break ; +case RTE_FLOW_ACTION_TYPE_SEND_TO_KERNEL : +if (src_group ==0 ) { +rte_flow_error_set (error,ENOTSUP , +RTE_FLOW_ERROR_TYPE_ACTION ,NULL , +"Send to kernel action on the root table is" +" not supported in HWS mode now." ); + goto clean_up; + } + hw_acts->rule_acts[actions_n++].action = priv->hw_send_to_kernel[type]; + action_flags |=MLX5_FLOW_ACTION_SEND_TO_KERNEL ; +break ;case RTE_FLOW_ACTION_TYPE_END :/* * Using NULL action right now, maybe a new API can be used
Signature · 1 line
2.21.0
PATCH v7 5/11 net/mlx5: add ASO actions support to non-template mode
In reply to Maayan KashaniThis patch adds counter, connection tracking, meter and age actions support to non-template mode.
For CT, counter and meter: if no previous allocation was handled by hw configure routine,
Half of the maximum supported number of objects will be allocated. For AGE action, if no counters were allocated,
allocate half of the maximum,
and then allocate same number of AGE objects.
Also extracted the shared host handling to the configure function. And align all ASO actions to have init function
for future code improvement.
This patch does not affect SW Steering flow engine.
--- drivers/net/mlx5/mlx5.h | 7 ++ drivers/net/mlx5/mlx5_flow_hw.c | 185 +++++++++++++++++++++++++++----- drivers/net/mlx5/mlx5_hws_cnt.c | 47 ++++---- drivers/net/mlx5/mlx5_hws_cnt.h | 10 +- 4 files changed, 190 insertions(+), 59 deletions(-)
drivers/net/mlx5/mlx5.h +7 -0
@@ -812,6 +812,13 @@ struct mlx5_dev_shared_port {/* Only yellow color valid. */ #define MLX5_MTR_POLICY_MODE_OY 3 +/* Max number of meters allocated in non template mode. */ +#define MLX5_MTR_NT_MAX (1 << 23)/*TODO verify number */ +/* Max number of connection tracking allocated in non template mode */ +#define MLX5_CT_NT_MAX (1 << 23)/*TODO verify number */ +/* Max number of counters allocated in non template mode */ +#define MLX5_CNT_MAX (1 << 23)/*TODO verify number */ +enum mlx5_meter_domain {MLX5_MTR_DOMAIN_INGRESS ,MLX5_MTR_DOMAIN_EGRESS ,
drivers/net/mlx5/mlx5_flow_hw.c +157 -28
280 lines not on this page · raw message
drivers/net/mlx5/mlx5_hws_cnt.c +20 -27
115 lines not on this page · raw message
drivers/net/mlx5/mlx5_hws_cnt.h +6 -4
@@ -712,9 +712,10 @@ mlx5_hws_cnt_service_thread_create(struct mlx5_dev_ctx_shared *sh);void mlx5_hws_cnt_service_thread_destroy (struct mlx5_dev_ctx_shared *sh); -struct mlx5_hws_cnt_pool * +int mlx5_hws_cnt_pool_create (struct rte_eth_dev *dev, -const struct rte_flow_port_attr *pattr,uint16_t nb_queue); +uint32_t nb_counters,uint16_t nb_queue, +struct mlx5_hws_cnt_pool *chost); void mlx5_hws_cnt_pool_destroy(struct mlx5_dev_ctx_shared *sh,
@@ -744,8 +745,9 @@ mlx5_hws_age_context_get(struct mlx5_priv *priv, uint32_t idx);int mlx5_hws_age_pool_init (struct rte_eth_dev *dev, -const struct rte_flow_port_attr *attr, -uint16_t nb_queues); +uint32_t nb_aging_objects, +uint16_t nb_queues, +bool strict_queue);void mlx5_hws_age_pool_destroy (struct mlx5_priv *priv);
Signature · 1 line
2.21.0
PATCH v7 6/11 net/mlx5: fix segfault on counter pool destroy
In reply to Maayan KashaniIf the counter pool was not added to list,
and an error state was reached,
on attempt to destroy the counter pool, segmentation fault was received during list remove action.
Added a check to verify the list is not empty before trying to remove the cpool from the list.
Invalid state, leading to segfault,
can also be reached in the following scenario:
1. mlx5_hws_cnt_pool_init() does a zmalloc and initializes most
of the fields of cpool, but does not initialize the next field.
2. mlx5_hws_cnt_pool_dcs_alloc() attempts to bulk allocate flow counters.
If this fails, we skip straight to 4.
In HW, this can fail simply if FW doesn't support bulk flow counter allocation.
3. Right before the goto error, we insert the cpool to the hws_cpool_list.
This is where the next field is initialized.
4. mlx5_hws_cnt_pool_destroy() assumes the cpool's next field
is initialized and SEGVs if not.
So, added a guard against cases where the entry was uninitialized (checking le_prev field is not NULL).
--- drivers/net/mlx5/mlx5_hws_cnt.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/mlx5/mlx5_hws_cnt.c +3 -1
@@ -718,7 +718,9 @@ mlx5_hws_cnt_pool_destroy(struct mlx5_dev_ctx_shared *sh,* Maybe blocked for at most 200ms here. */ rte_spinlock_lock (&sh->cpool_lock); -LIST_REMOVE (cpool, next); +/* Try to remove cpool before it was added to list caused segfault. */ +if (!LIST_EMPTY (&sh->hws_cpool_list) && cpool->next.le_prev) +LIST_REMOVE (cpool, next);rte_spinlock_unlock (&sh->cpool_lock);if (cpool->cfg.host_cpool ==NULL ) {if (--sh->cnt_svc->refcnt ==0 )
Signature · 1 line
2.21.0
PATCH v7 7/11 net/mlx5: abstract action handling and enable reconfigure
In reply to Maayan Kashanireuse HWS actions translation code in order to create the actions for lower layer.
All actions are handled as non masked. Therefore, will be translated in the rule construct phase shared with the template code
and not during the action template translate.
Currently there is no option to reconfigure in template API’s. To support non template API and template API simultaneously, There is a need to enable the user to reconfigure after default configuration was applied by the driver on port start.
Fix flow create ptr
In SWS the return flow pointer is the flow index, in HWS the return flow pointer is the flow data pointer. Currently the return value of non template code did not Enable destroy or quary.
--- drivers/net/mlx5/mlx5.h | 25 +- drivers/net/mlx5/mlx5_flow.c | 31 +- drivers/net/mlx5/mlx5_flow.h | 14 +- drivers/net/mlx5/mlx5_flow_dv.c | 18 +- drivers/net/mlx5/mlx5_flow_hw.c | 829 ++++++++++++++++---------------- 5 files changed, 472 insertions(+), 445 deletions(-)
drivers/net/mlx5/mlx5.h +13 -12
@@ -813,11 +813,11 @@ struct mlx5_dev_shared_port {#define MLX5_MTR_POLICY_MODE_OY 3/* Max number of meters allocated in non template mode. */ -#define MLX5_MTR_NT_MAX (1 << 23)/*TODO verify number */ +#define MLX5_MTR_NT_MAX (1 << 23)/* Max number of connection tracking allocated in non template mode */ -#define MLX5_CT_NT_MAX (1 << 23)/*TODO verify number */ +#define MLX5_CT_NT_MAX (1 << 23)/* Max number of counters allocated in non template mode */ -#define MLX5_CNT_MAX (1 << 23)/*TODO verify number */ +#define MLX5_CNT_MAX (1 << 23)enum mlx5_meter_domain {MLX5_MTR_DOMAIN_INGRESS ,
@@ -1536,7 +1536,6 @@ struct mlx5_dev_ctx_shared {/* Direct Rules tables for FDB, NIC TX+RX */ void *dr_drop_action;/* Pointer to DR drop action, any domain. */ void *pop_vlan_action;/* Pointer to DR pop VLAN action. */ -void *hw_dummy_last;/* Pointer to the DR dummy end action, any domain. */ #if defined(HAVE_IBV_FLOW_DV_SUPPORT ) || !defined(HAVE_INFINIBAND_VERBS_H )struct mlx5_send_to_kernel_action send_to_kernel_action[MLX5DR_TABLE_TYPE_MAX ];#endif
@@ -1817,6 +1816,14 @@ struct mlx5_hw_ctrl_flow {struct mlx5_hw_ctrl_flow_info info; }; +/* HW Steering port configuration passed to rte_flow_configure(). */ +struct mlx5_flow_hw_attr { +struct rte_flow_port_attr port_attr; +uint16_t nb_queue; +struct rte_flow_queue_attr *queue_attr; +bool nt_mode; +}; +/* * Flow rule structure for flow engine mode control, focus on group 0. * Apply to all supported domains.
@@ -1838,12 +1845,6 @@ struct rte_pmd_mlx5_flow_engine_mode_info {/* The list is maintained in insertion order. */ LIST_HEAD(hot_up_info, mlx5_dv_flow_info) hot_upgrade; }; -/* HW Steering port configuration passed to rte_flow_configure(). */ -struct mlx5_flow_hw_attr { -struct rte_flow_port_attr port_attr; -uint16_t nb_queue; -struct rte_flow_queue_attr *queue_attr; -};struct mlx5_flow_hw_ctrl_rx ;
@@ -2335,7 +2336,7 @@ int mlx5_flow_validate(struct rte_eth_dev *dev,const struct rte_flow_item items[], const struct rte_flow_action actions[], struct rte_flow_error *error); -uint32_t +uintptr_t mlx5_flow_list_create(struct rte_eth_dev *dev, enum mlx5_flow_type type, const struct rte_flow_attr *attr, const struct rte_flow_item items[],
@@ -2343,7 +2344,7 @@ mlx5_flow_list_create(struct rte_eth_dev *dev, enum mlx5_flow_type type, bool external, struct rte_flow_error *error);void mlx5_flow_list_destroy (struct rte_eth_dev *dev,enum mlx5_flow_type type, -uint32_t flow_idx); +uintptr_t flow_idx); struct rte_flow *mlx5_flow_create(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, const struct rte_flow_item items[],
drivers/net/mlx5/mlx5_flow.c +14 -17
@@ -4985,7 +4985,7 @@ flow_check_hairpin_split(struct rte_eth_dev *dev,/* Declare flow create/destroy prototype in advance. */ -static uint32_t +static uintptr_t flow_drv_list_create(struct rte_eth_dev *dev, enum mlx5_flow_type type, const struct rte_flow_attr *attr, const struct rte_flow_item items[],
@@ -4994,7 +4994,7 @@ flow_drv_list_create(struct rte_eth_dev *dev, enum mlx5_flow_type type,static void flow_drv_list_destroy (struct rte_eth_dev *dev,enum mlx5_flow_type type, -uint32_t flow_idx); +uintptr_t flow_idx); int flow_dv_mreg_match_cb(void *tool_ctx __rte_unused,
@@ -7298,7 +7298,7 @@ flow_tunnel_from_rule(const struct mlx5_flow *flow)* @return * A flow index on success, 0 otherwise and rte_errno is set. */ -uint32_t +uintptr_t flow_legacy_list_create(struct rte_eth_dev *dev, enum mlx5_flow_type type, const struct rte_flow_attr *attr, const struct rte_flow_item items[],
@@ -7973,7 +7973,7 @@ mlx5_flow_create(struct rte_eth_dev *dev,struct mlx5_priv *priv = dev->data->dev_private;struct rte_flow_attr *new_attr = (void *)(uintptr_t )attr;uint32_t prio = attr->priority; -uint32_t flow_idx; +uintptr_t flow_idx;/* * If the device is not started yet, it is not allowed to created a
@@ -8007,7 +8007,7 @@ mlx5_flow_create(struct rte_eth_dev *dev,return (void *)(uintptr_t )flow_idx; } -uint32_t +uintptr_t mlx5_flow_list_create(struct rte_eth_dev *dev, enum mlx5_flow_type type, const struct rte_flow_attr *attr, const struct rte_flow_item items[],
@@ -8018,7 +8018,7 @@ mlx5_flow_list_create(struct rte_eth_dev *dev, enum mlx5_flow_type type, error); } -uint32_t +uintptr_t flow_drv_list_create(struct rte_eth_dev *dev, enum mlx5_flow_type type, const struct rte_flow_attr *attr, const struct rte_flow_item items[],
@@ -8043,7 +8043,7 @@ flow_drv_list_create(struct rte_eth_dev *dev, enum mlx5_flow_type type,*/ void flow_legacy_list_destroy (struct rte_eth_dev *dev,enum mlx5_flow_type type, -uint32_t flow_idx) +uintptr_t flow_idx) {struct mlx5_priv *priv = dev->data->dev_private;struct rte_flow *flow =mlx5_ipool_get (priv->flows[type], (uint32_t )flow_idx);
@@ -8074,7 +8074,7 @@ flow_legacy_list_destroy(struct rte_eth_dev *dev, enum mlx5_flow_type type,static void flow_drv_list_destroy (struct rte_eth_dev *dev,enum mlx5_flow_type type, -uint32_t flow_idx) +uintptr_t flow_idx) {const struct mlx5_flow_driver_ops *fops;struct rte_flow_attr attr = { .transfer =0 };
@@ -8086,7 +8086,7 @@ flow_drv_list_destroy(struct rte_eth_dev *dev, enum mlx5_flow_type type,void mlx5_flow_list_destroy (struct rte_eth_dev *dev,enum mlx5_flow_type type, -uint32_t flow_idx) +uintptr_t flow_idx) {flow_drv_list_destroy (dev, type, flow_idx); }
@@ -8115,12 +8115,14 @@ mlx5_flow_list_flush(struct rte_eth_dev *dev, enum mlx5_flow_type type,if (priv->sh->config.dv_flow_en ==2 && type ==MLX5_FLOW_TYPE_GEN ) {flow_hw_q_flow_flush (dev,NULL ); -return ; }#endif - MLX5_IPOOL_FOREACH(priv->flows[type], fidx, flow) { -flow_drv_list_destroy (dev, type, fidx); +if (priv->sh->config.dv_flow_en ==2 ) { +flow_drv_list_destroy (dev, type, (uintptr_t )flow); + }else { +flow_drv_list_destroy (dev, type, fidx); + }if (unlikely (mlx5_need_cache_flow (priv,NULL ) && type ==MLX5_FLOW_TYPE_GEN )) { flow_info =LIST_FIRST (&mode_info->hot_upgrade);while (flow_info) {
@@ -8581,11 +8583,6 @@ mlx5_flow_destroy(struct rte_eth_dev *dev,struct rte_pmd_mlx5_flow_engine_mode_info *mode_info = &priv->mode_info;struct mlx5_dv_flow_info *flow_info; -if (priv->sh->config.dv_flow_en ==2 ) -return rte_flow_error_set (error,ENOTSUP , -RTE_FLOW_ERROR_TYPE_UNSPECIFIED , -NULL , -"Flow non-Q destruction not supported" );flow_drv_list_destroy (dev,MLX5_FLOW_TYPE_GEN , (uintptr_t )(void *)flow);if (unlikely (mlx5_need_cache_flow (priv,NULL ))) {
drivers/net/mlx5/mlx5_flow.h +9 -5
@@ -1320,6 +1320,8 @@ struct rte_flow_nt2hws {struct mlx5dr_bwc_rule *nt_rule;/** The matcher for non template api. */ struct mlx5_flow_dv_matcher *matcher; +/**< Auxiliary data stored per flow. */ +struct rte_flow_hw_aux *flow_aux; } __rte_packed;/** HWS flow struct. */
@@ -1354,12 +1356,14 @@ struct rte_flow_hw {struct mlx5_hrxq *hrxq; }; +/** Equals true if it is non template rule. */ +bool nt_rule;/** * Padding for alignment to 56 bytes. * Since mlx5dr rule is 72 bytes, whole flow is contained within 128 B (2 cache lines). * This space is reserved for future additions to flow struct. */ -uint8_t padding[10 ]; +uint8_t padding[9 ];/** HWS layer data struct. */ uint8_t rule[]; } __rte_packed;
@@ -2204,7 +2208,7 @@ int flow_hw_init(struct rte_eth_dev *dev, struct rte_flow_error *error); -typedef uint32_t (*mlx5_flow_list_create_t)(struct rte_eth_dev *dev, +typedef uintptr_t (*mlx5_flow_list_create_t)(struct rte_eth_dev *dev, enum mlx5_flow_type type, const struct rte_flow_attr *attr, const struct rte_flow_item items[],
@@ -2213,7 +2217,7 @@ typedef uint32_t (*mlx5_flow_list_create_t)(struct rte_eth_dev *dev, struct rte_flow_error *error);typedef void (*mlx5_flow_list_destroy_t )(struct rte_eth_dev *dev,enum mlx5_flow_type type, -uint32_t flow_idx); +uintptr_t flow_idx); typedef int (*mlx5_flow_validate_t)(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, const struct rte_flow_item items[],
@@ -3476,13 +3480,13 @@ int mlx5_flow_item_field_width(struct rte_eth_dev *dev, enum rte_flow_field_id field, int inherit, const struct rte_flow_attr *attr, struct rte_flow_error *error); -uint32_t flow_legacy_list_create (struct rte_eth_dev *dev,enum mlx5_flow_type type, +uintptr_t flow_legacy_list_create (struct rte_eth_dev *dev,enum mlx5_flow_type type,const struct rte_flow_attr *attr,const struct rte_flow_item items[],const struct rte_flow_action actions[],bool external,struct rte_flow_error *error);void flow_legacy_list_destroy (struct rte_eth_dev *dev,enum mlx5_flow_type type, -uint32_t flow_idx); +uintptr_t flow_idx); static __rte_always_inline int flow_hw_get_srh_flex_parser_byte_off_from_ctx(void *dr_ctx __rte_unused)
drivers/net/mlx5/mlx5_flow_dv.c +15 -3
@@ -11901,12 +11901,14 @@ flow_matcher_create_cb(void *tool_ctx, void *cb_ctx)struct mlx5_flow_cb_ctx *ctx = cb_ctx;struct mlx5_flow_dv_matcher *ref = ctx->data;struct mlx5_flow_dv_matcher *resource; +#ifdef HAVE_MLX5_HWS_SUPPORT +const struct rte_flow_item *items; +#endif struct mlx5dv_flow_matcher_attr dv_attr = { .type =IBV_FLOW_ATTR_NORMAL , .match_mask = (void *)&ref->mask, }; -struct mlx5_flow_tbl_data_entry *tbl =container_of (ref->tbl, -typeof (*tbl), tbl); +struct mlx5_flow_tbl_data_entry *tbl;int ret; resource = mlx5_malloc(MLX5_MEM_ZERO, sizeof(*resource), 0,
@@ -11917,9 +11919,9 @@ flow_matcher_create_cb(void *tool_ctx, void *cb_ctx) "cannot create matcher");return NULL ; } -/*Consider memcpy(resource, ref, sizeof(*resource));*/ *resource = *ref;if (sh->config.dv_flow_en !=2 ) { + tbl =container_of (ref->tbl,typeof (*tbl), tbl); dv_attr.match_criteria_enable =flow_dv_matcher_enable (resource->mask.buf); __flow_dv_adjust_buf_size(&ref->mask.size,
@@ -11937,6 +11939,16 @@ flow_matcher_create_cb(void *tool_ctx, void *cb_ctx) "cannot create matcher");return NULL ; } + }else { +#ifdef HAVE_MLX5_HWS_SUPPORT + items = *((const struct rte_flow_item **)(ctx->data2)); + resource->matcher_object =mlx5dr_bwc_matcher_create + (resource->group->tbl, resource->priority, items); +if (!(resource->matcher_object)) +return NULL ; +#else +return NULL ; +#endif }return &resource->entry; }
drivers/net/mlx5/mlx5_flow_hw.c +421 -408
1,349 lines not on this page · raw message
Signature · 1 line
2.21.0
PATCH v7 8/11 common/mlx5: read connection tracking attributes
In reply to Maayan KashaniNeed to read maximum connection tracking
objects from HCA attributes.
--- drivers/common/mlx5/mlx5_devx_cmds.c | 3 +++ drivers/common/mlx5/mlx5_devx_cmds.h | 1 + 2 files changed, 4 insertions(+)
drivers/common/mlx5/mlx5_devx_cmds.c +3 -0
@@ -1170,6 +1170,9 @@ mlx5_devx_cmd_query_hca_attr(void *ctx, (rc &MLX5_CROSS_VHCA_ALLOWED_OBJS_TIR ) && (rc &MLX5_CROSS_VHCA_ALLOWED_OBJS_FT ) && (rc &MLX5_CROSS_VHCA_ALLOWED_OBJS_RTC ); +if (attr->ct_offload) + attr->log_max_conn_track_offload =MLX5_GET (cmd_hca_cap_2, hcattr, + log_max_conn_track_offload); }if (attr->log_min_stride_wqe_sz ==0 ) attr->log_min_stride_wqe_sz =MLX5_MPRQ_LOG_MIN_STRIDE_WQE_SIZE ;
drivers/common/mlx5/mlx5_devx_cmds.h +1 -0
@@ -326,6 +326,7 @@ struct mlx5_hca_attr { uint32_t wqe_based_flow_table_sup:1;uint8_t max_header_modify_pattern_length;uint64_t system_image_guid; + uint32_t log_max_conn_track_offload:5; };/* LAG Context. */
Signature · 1 line
2.21.0
PATCH v7 9/11 net/mlx5: support bulk actions in non template mode
In reply to Maayan KashaniAdd support for encap/decap/modify header action for non template API.
Save 1 action per bulk according to action data. Reuse action if possible.
Store actions same as for SWS today, use same key structure.
--- drivers/net/mlx5/mlx5_flow.h | 44 ++++-- drivers/net/mlx5/mlx5_flow_dv.c | 268 ++++++++++++++++++++------------ drivers/net/mlx5/mlx5_flow_hw.c | 184 ++++++++++++++++++++-- 3 files changed, 368 insertions(+), 128 deletions(-)
drivers/net/mlx5/mlx5_flow.h +32 -12
@@ -671,6 +671,10 @@ struct mlx5_flow_dv_modify_hdr_resource {struct mlx5_list_entry entry;void *action;/**< Modify header action object. */ uint32_t idx; +#ifdef HAVE_MLX5_HWS_SUPPORT +void *mh_dr_pattern;/**< Modify header DR pattern(HWS only). */ +#endif +uint64_t flags;/**< Flags for RDMA API(HWS only). */ /* Key area for hash list matching: */ uint8_t ft_type;/**< Flow table type, Rx or Tx. */ uint8_t actions_num;/**< Number of modification actions. */
@@ -1322,7 +1326,11 @@ struct rte_flow_nt2hws {struct mlx5_flow_dv_matcher *matcher;/**< Auxiliary data stored per flow. */ struct rte_flow_hw_aux *flow_aux; -} __rte_packed; +/** Modify header pointer. */ +struct mlx5_flow_dv_modify_hdr_resource *modify_hdr; +/** Encap/decap index. */ +uint32_t rix_encap_decap; +};/** HWS flow struct. */ struct rte_flow_hw {
@@ -3238,14 +3246,14 @@ struct mlx5_list_entry *flow_dv_tag_clone_cb(void *tool_ctx, void *cb_ctx);void flow_dv_tag_clone_free_cb (void *tool_ctx,struct mlx5_list_entry *entry); -int flow_dv_modify_match_cb (void *tool_ctx,struct mlx5_list_entry *entry, +int flow_modify_match_cb (void *tool_ctx,struct mlx5_list_entry *entry,void *cb_ctx); -struct mlx5_list_entry *flow_dv_modify_create_cb (void *tool_ctx,void *ctx); -void flow_dv_modify_remove_cb (void *tool_ctx,struct mlx5_list_entry *entry); -struct mlx5_list_entry *flow_dv_modify_clone_cb (void *tool_ctx, +struct mlx5_list_entry *flow_modify_create_cb (void *tool_ctx,void *ctx); +void flow_modify_remove_cb (void *tool_ctx,struct mlx5_list_entry *entry); +struct mlx5_list_entry *flow_modify_clone_cb (void *tool_ctx,struct mlx5_list_entry *oentry,void *ctx); -void flow_dv_modify_clone_free_cb (void *tool_ctx, +void flow_modify_clone_free_cb (void *tool_ctx,struct mlx5_list_entry *entry);struct mlx5_list_entry *flow_dv_mreg_create_cb (void *tool_ctx,void *ctx);
@@ -3257,18 +3265,30 @@ struct mlx5_list_entry *flow_dv_mreg_clone_cb(void *tool_ctx, void *ctx);void flow_dv_mreg_clone_free_cb (void *tool_ctx,struct mlx5_list_entry *entry); -int flow_dv_encap_decap_match_cb (void *tool_ctx,struct mlx5_list_entry *entry, +int flow_encap_decap_match_cb (void *tool_ctx,struct mlx5_list_entry *entry,void *cb_ctx); -struct mlx5_list_entry *flow_dv_encap_decap_create_cb (void *tool_ctx, +struct mlx5_list_entry *flow_encap_decap_create_cb (void *tool_ctx,void *cb_ctx); -void flow_dv_encap_decap_remove_cb (void *tool_ctx, +void flow_encap_decap_remove_cb (void *tool_ctx,struct mlx5_list_entry *entry); -struct mlx5_list_entry *flow_dv_encap_decap_clone_cb (void *tool_ctx, +struct mlx5_list_entry *flow_encap_decap_clone_cb (void *tool_ctx,struct mlx5_list_entry *entry,void *cb_ctx); -void flow_dv_encap_decap_clone_free_cb (void *tool_ctx, +void flow_encap_decap_clone_free_cb (void *tool_ctx,struct mlx5_list_entry *entry); - +int __flow_encap_decap_resource_register + (struct rte_eth_dev *dev, +struct mlx5_flow_dv_encap_decap_resource *resource, +bool is_root, +struct mlx5_flow_dv_encap_decap_resource **encap_decap, +struct rte_flow_error *error); +int __flow_modify_hdr_resource_register + (struct rte_eth_dev *dev, +struct mlx5_flow_dv_modify_hdr_resource *resource, +struct mlx5_flow_dv_modify_hdr_resource **modify, +struct rte_flow_error *error); +int flow_encap_decap_resource_release (struct rte_eth_dev *dev, +uint32_t encap_decap_idx);int flow_matcher_match_cb (void *tool_ctx,struct mlx5_list_entry *entry,void *ctx);struct mlx5_list_entry *flow_matcher_create_cb (void *tool_ctx,void *ctx);
drivers/net/mlx5/mlx5_flow_dv.c +165 -103
459 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow_hw.c +171 -13
299 lines not on this page · raw message
Signature · 1 line
2.21.0
PATCH v7 10/11 net/mlx5: use non const max number for ASO actions
In reply to Maayan KashaniFor ASO max allocations in non-template mode,
Read FW capabilities instead of using consts.
--- drivers/net/mlx5/mlx5.h | 17 ++++++++++++----- drivers/net/mlx5/mlx5_flow_hw.c | 13 +++++++++---- drivers/net/mlx5/mlx5_flow_meter.c | 25 +++++++++++++++++++++---- 3 files changed, 42 insertions(+), 13 deletions(-)
drivers/net/mlx5/mlx5.h +12 -5
@@ -812,12 +812,18 @@ struct mlx5_dev_shared_port {/* Only yellow color valid. */ #define MLX5_MTR_POLICY_MODE_OY 3 +/* Max number of meters. */ +#define MLX5_MTR_MAX (priv) (mlx5_flow_mtr_max_get(priv))/* Max number of meters allocated in non template mode. */ -#define MLX5_MTR_NT_MAX (1 << 23) -/* Max number of connection tracking allocated in non template mode */ -#define MLX5_CT_NT_MAX (1 << 23) -/* Max number of counters allocated in non template mode */ -#define MLX5_CNT_MAX (1 << 23) +#define MLX5_MTR_NT_MAX (priv) (MLX5_MTR_MAX(priv) >> 1) +/* Max number of connection tracking. */ +#define MLX5_CT_MAX (priv) (1 << (priv)->sh->cdev->config.hca_attr.log_max_conn_track_offload) +/* Max number of connection tracking allocated in non template mode. */ +#define MLX5_CT_NT_MAX (priv) (MLX5_CT_MAX(priv) >> 1) +/* Max number of counters. */ +#define MLX5_CNT_MAX (priv) ((priv)->sh->hws_max_nb_counters) +/* Max number of counters allocated in non template mode. */ +#define MLX5_CNT_NT_MAX (priv) (MLX5_CNT_MAX(priv) >> 1)enum mlx5_meter_domain {MLX5_MTR_DOMAIN_INGRESS ,
@@ -2457,6 +2463,7 @@ mlx5_flow_meter_hierarchy_get_final_policy(struct rte_eth_dev *dev,int mlx5_flow_meter_flush (struct rte_eth_dev *dev,struct rte_mtr_error *error);void mlx5_flow_meter_rxq_flush (struct rte_eth_dev *dev); +uint32_t mlx5_flow_mtr_max_get (struct mlx5_priv *priv);/* mlx5_os.c */
drivers/net/mlx5/mlx5_flow_hw.c +9 -4
@@ -13114,6 +13114,7 @@ static int flow_hw_ensure_action_pools_allocated(struct rte_eth_dev *dev,bool actions_end = false;struct mlx5_priv *priv = dev->data->dev_private;int ret; +uint obj_num;for (; !actions_end; actions++) {switch ((int )actions->type) {
@@ -13122,7 +13123,8 @@ static int flow_hw_ensure_action_pools_allocated(struct rte_eth_dev *dev,if (!priv->hws_age_req) {/* If no counters were previously allocated. */ if (!priv->hws_cpool) { - ret =mlx5_hws_cnt_pool_create (dev,MLX5_CNT_MAX , + obj_num =MLX5_CNT_NT_MAX (priv); + ret =mlx5_hws_cnt_pool_create (dev, obj_num, priv->nb_queue,NULL );if (ret) goto err;
@@ -13140,7 +13142,8 @@ static int flow_hw_ensure_action_pools_allocated(struct rte_eth_dev *dev,case RTE_FLOW_ACTION_TYPE_COUNT :/* If no counters were previously allocated. */ if (!priv->hws_cpool) { - ret =mlx5_hws_cnt_pool_create (dev,MLX5_CNT_MAX , + obj_num =MLX5_CNT_NT_MAX (priv); + ret =mlx5_hws_cnt_pool_create (dev, obj_num, priv->nb_queue,NULL );if (ret) goto err;
@@ -13149,7 +13152,8 @@ static int flow_hw_ensure_action_pools_allocated(struct rte_eth_dev *dev,case RTE_FLOW_ACTION_TYPE_CONNTRACK :/* If no CT were previously allocated. */ if (!priv->hws_ctpool) { - ret =mlx5_flow_ct_init (dev,MLX5_CT_NT_MAX , priv->nb_queue); + obj_num =MLX5_CT_NT_MAX (priv); + ret =mlx5_flow_ct_init (dev, obj_num, priv->nb_queue);if (ret) goto err; }
@@ -13157,7 +13161,8 @@ static int flow_hw_ensure_action_pools_allocated(struct rte_eth_dev *dev,case RTE_FLOW_ACTION_TYPE_METER_MARK :/* If no meters were previously allocated. */ if (!priv->hws_mpool) { - ret =mlx5_flow_meter_init (dev,MLX5_MTR_NT_MAX ,0 ,0 , + obj_num =MLX5_MTR_NT_MAX (priv); + ret =mlx5_flow_meter_init (dev, obj_num,0 ,0 , priv->nb_queue);if (ret) goto err;
drivers/net/mlx5/mlx5_flow_meter.c +21 -4
@@ -704,6 +704,26 @@ mlx5_flow_meter_param_fill(struct mlx5_flow_meter_profile *fmp,return 0 ; } +/** +* Callback to get MTR maximum objects number. +* +* @param[in] priv +* Pointer to Ethernet device. +* +* @return +* Max number of meters. +*/ +uint32_t +mlx5_flow_mtr_max_get (struct mlx5_priv *priv) +{ +struct mlx5_hca_qos_attr *qattr = &priv->sh->cdev->config.hca_attr.qos; + +/* Max number of meters. */ +return ((priv->sh->meter_aso_en) ? +1 << (qattr->log_max_num_meter_aso +1 ) : + qattr->log_max_flow_meter); +} +/** * Callback to get MTR capabilities. *
@@ -730,14 +750,11 @@ mlx5_flow_mtr_cap_get(struct rte_eth_dev *dev,RTE_MTR_ERROR_TYPE_UNSPECIFIED ,NULL , "Meter is not supported");memset (cap,0 ,sizeof (*cap)); + cap->n_max =mlx5_flow_mtr_max_get (priv);if (priv->sh->meter_aso_en) { -/* 2 meters per one ASO cache line. */ - cap->n_max =1 << (qattr->log_max_num_meter_aso +1 ); cap->srtcm_rfc2697_packet_mode_supported =1 ; cap->trtcm_rfc2698_packet_mode_supported =1 ; cap->trtcm_rfc4115_packet_mode_supported =1 ; - }else { - cap->n_max =1 << qattr->log_max_flow_meter; } cap->srtcm_rfc2697_byte_mode_supported =1 ; cap->trtcm_rfc2698_byte_mode_supported =1 ;
Signature · 1 line
2.21.0
PATCH v7 11/11 net/mlx5: initial design changes
In reply to Maayan KashaniChange flow_drv_list_create/destroy to mlx5_flow_list_create/destroy. Remove resource release function inlining.
Check number of queues in template mode in hw configure function. Use user priority to calculate matcher priority.
--- drivers/net/mlx5/mlx5_flow.c | 70 +++++++--------------- drivers/net/mlx5/mlx5_flow_hw.c | 100 +++++++++++++++----------------- 2 files changed, 68 insertions(+), 102 deletions(-)
drivers/net/mlx5/mlx5_flow.c +20 -50
@@ -4983,19 +4983,6 @@ flow_check_hairpin_split(struct rte_eth_dev *dev,return 0 ; } -/* Declare flow create/destroy prototype in advance. */ - -static uintptr_t -flow_drv_list_create (struct rte_eth_dev *dev,enum mlx5_flow_type type, -const struct rte_flow_attr *attr, -const struct rte_flow_item items[], -const struct rte_flow_action actions[], -bool external,struct rte_flow_error *error); - -static void -flow_drv_list_destroy (struct rte_eth_dev *dev,enum mlx5_flow_type type, -uintptr_t flow_idx); -int flow_dv_mreg_match_cb(void *tool_ctx __rte_unused,struct mlx5_list_entry *entry,void *cb_ctx)
@@ -5114,7 +5101,7 @@ flow_dv_mreg_create_cb(void *tool_ctx, void *cb_ctx)* be applied, removed, deleted in arbitrary order * by list traversing. */ - mcp_res->rix_flow =flow_drv_list_create (dev,MLX5_FLOW_TYPE_MCP , + mcp_res->rix_flow =mlx5_flow_list_create (dev,MLX5_FLOW_TYPE_MCP , &attr, items, actions, false, error);if (!mcp_res->rix_flow) {mlx5_ipool_free (priv->sh->ipool[MLX5_IPOOL_MCP ], idx);
@@ -5208,7 +5195,7 @@ flow_dv_mreg_remove_cb(void *tool_ctx, struct mlx5_list_entry *entry)struct mlx5_priv *priv = dev->data->dev_private;MLX5_ASSERT (mcp_res->rix_flow); -flow_drv_list_destroy (dev,MLX5_FLOW_TYPE_MCP , mcp_res->rix_flow); +mlx5_flow_list_destroy (dev,MLX5_FLOW_TYPE_MCP , mcp_res->rix_flow);mlx5_ipool_free (priv->sh->ipool[MLX5_IPOOL_MCP ], mcp_res->idx); }
@@ -7595,7 +7582,7 @@ mlx5_flow_create_esw_table_zero_flow(struct rte_eth_dev *dev) };struct rte_flow_error error; -return (void *)(uintptr_t )flow_drv_list_create (dev,MLX5_FLOW_TYPE_CTL , +return (void *)(uintptr_t )mlx5_flow_list_create (dev,MLX5_FLOW_TYPE_CTL , &attr, &pattern, actions, false, &error); }
@@ -7663,14 +7650,14 @@ mlx5_flow_create_devx_sq_miss_flow(struct rte_eth_dev *dev, uint32_t sq_num)* Creates group 0, highest priority jump flow. * Matches txq to bypass kernel packets. */ -if (flow_drv_list_create (dev,MLX5_FLOW_TYPE_CTL , &attr, pattern, actions, +if (mlx5_flow_list_create (dev,MLX5_FLOW_TYPE_CTL , &attr, pattern, actions, false, &error) ==0 )return 0 ;/* Create group 1, lowest priority redirect flow for txq. */ attr.group =1 ; actions[0 ].conf = &port; actions[0 ].type =RTE_FLOW_ACTION_TYPE_PORT_ID ; -return flow_drv_list_create (dev,MLX5_FLOW_TYPE_CTL , &attr, pattern, +return mlx5_flow_list_create (dev,MLX5_FLOW_TYPE_CTL , &attr, pattern, actions, false, &error); }
@@ -7826,7 +7813,7 @@ mlx5_flow_cache_flow_toggle(struct rte_eth_dev *dev, bool orig_prio) flow_info->flow_idx_low_prio);if (high && low) {RTE_SWAP (*low, *high); -flow_drv_list_destroy (dev,MLX5_FLOW_TYPE_GEN , +mlx5_flow_list_destroy (dev,MLX5_FLOW_TYPE_GEN , flow_info->flow_idx_low_prio); flow_info->flow_idx_high_prio =0 ; }
@@ -7840,7 +7827,7 @@ mlx5_flow_cache_flow_toggle(struct rte_eth_dev *dev, bool orig_prio)while (flow_info) {if (flow_info->orig_prio != flow_info->attr.priority) {if (flow_info->flow_idx_high_prio) -flow_drv_list_destroy (dev,MLX5_FLOW_TYPE_GEN , +mlx5_flow_list_destroy (dev,MLX5_FLOW_TYPE_GEN , flow_info->flow_idx_high_prio);else break ;
@@ -7995,12 +7982,13 @@ mlx5_flow_create(struct rte_eth_dev *dev, RTE_PMD_MLX5_FLOW_ENGINE_FLAG_STANDBY_DUP_INGRESS))) new_attr->priority += 1; } - flow_idx =flow_drv_list_create (dev,MLX5_FLOW_TYPE_GEN , attr, items, actions, true, error); + flow_idx =mlx5_flow_list_create (dev,MLX5_FLOW_TYPE_GEN , attr, items, actions, + true, error);if (!flow_idx)return NULL ;if (unlikely (mlx5_need_cache_flow (priv, attr))) {if (mlx5_flow_cache_flow_info (dev, attr, prio, items, actions, flow_idx)) { -flow_drv_list_destroy (dev,MLX5_FLOW_TYPE_GEN , flow_idx); +mlx5_flow_list_destroy (dev,MLX5_FLOW_TYPE_GEN , flow_idx); flow_idx =0 ; } }
@@ -8013,17 +8001,6 @@ mlx5_flow_list_create(struct rte_eth_dev *dev, enum mlx5_flow_type type,const struct rte_flow_item items[], const struct rte_flow_action actions[], bool external, struct rte_flow_error *error) -{ - return flow_drv_list_create(dev, type, attr, items, actions, external, -error ); -} - -uintptr_t -flow_drv_list_create (struct rte_eth_dev *dev,enum mlx5_flow_type type, -const struct rte_flow_attr *attr, -const struct rte_flow_item items[], -const struct rte_flow_action actions[], -bool external,struct rte_flow_error *error) { const struct mlx5_flow_driver_ops *fops;enum mlx5_flow_drv_type drv_type =flow_get_drv_type (dev, attr);
@@ -8072,8 +8049,8 @@ flow_legacy_list_destroy(struct rte_eth_dev *dev, enum mlx5_flow_type type,mlx5_ipool_free (priv->flows[type], flow_idx); } -static void -flow_drv_list_destroy (struct rte_eth_dev *dev,enum mlx5_flow_type type, +void +mlx5_flow_list_destroy (struct rte_eth_dev *dev,enum mlx5_flow_type type,uintptr_t flow_idx) {const struct mlx5_flow_driver_ops *fops;
@@ -8084,13 +8061,6 @@ flow_drv_list_destroy(struct rte_eth_dev *dev, enum mlx5_flow_type type, fops->list_destroy (dev, type, flow_idx); } -void -mlx5_flow_list_destroy (struct rte_eth_dev *dev,enum mlx5_flow_type type, -uintptr_t flow_idx) -{ -flow_drv_list_destroy (dev, type, flow_idx); -} -/** * Destroy all flows. *
@@ -8119,9 +8089,9 @@ mlx5_flow_list_flush(struct rte_eth_dev *dev, enum mlx5_flow_type type,#endif MLX5_IPOOL_FOREACH(priv->flows[type], fidx, flow) {if (priv->sh->config.dv_flow_en ==2 ) { -flow_drv_list_destroy (dev, type, (uintptr_t )flow); +mlx5_flow_list_destroy (dev, type, (uintptr_t )flow); }else { -flow_drv_list_destroy (dev, type, fidx); +mlx5_flow_list_destroy (dev, type, fidx); }if (unlikely (mlx5_need_cache_flow (priv,NULL ) && type ==MLX5_FLOW_TYPE_GEN )) { flow_info =LIST_FIRST (&mode_info->hot_upgrade);
@@ -8394,7 +8364,7 @@ mlx5_ctrl_flow_source_queue(struct rte_eth_dev *dev, actions[0 ].type =RTE_FLOW_ACTION_TYPE_JUMP ; actions[0 ].conf = &jump; actions[1 ].type =RTE_FLOW_ACTION_TYPE_END ; - flow_idx =flow_drv_list_create (dev,MLX5_FLOW_TYPE_CTL , + flow_idx =mlx5_flow_list_create (dev,MLX5_FLOW_TYPE_CTL , &attr, items, actions, false, &error);if (!flow_idx) { DRV_LOG(DEBUG,
@@ -8484,7 +8454,7 @@ mlx5_ctrl_flow_vlan(struct rte_eth_dev *dev, action_rss.types =0 ;for (i =0 ; i != priv->reta_idx_n; ++i) queue[i] = (*priv->reta_idx)[i]; - flow_idx =flow_drv_list_create (dev,MLX5_FLOW_TYPE_CTL , + flow_idx =mlx5_flow_list_create (dev,MLX5_FLOW_TYPE_CTL , &attr, items, actions, false, &error);if (!flow_idx)return -rte_errno;
@@ -8559,7 +8529,7 @@ mlx5_flow_lacp_miss(struct rte_eth_dev *dev) }, };struct rte_flow_error error; -uint32_t flow_idx =flow_drv_list_create (dev,MLX5_FLOW_TYPE_CTL , +uint32_t flow_idx =mlx5_flow_list_create (dev,MLX5_FLOW_TYPE_CTL , &attr, items, actions, false, &error);
@@ -8583,7 +8553,7 @@ mlx5_flow_destroy(struct rte_eth_dev *dev,struct rte_pmd_mlx5_flow_engine_mode_info *mode_info = &priv->mode_info;struct mlx5_dv_flow_info *flow_info; -flow_drv_list_destroy (dev,MLX5_FLOW_TYPE_GEN , +mlx5_flow_list_destroy (dev,MLX5_FLOW_TYPE_GEN , (uintptr_t )(void *)flow);if (unlikely (mlx5_need_cache_flow (priv,NULL ))) { flow_info =LIST_FIRST (&mode_info->hot_upgrade);
@@ -9896,14 +9866,14 @@ mlx5_flow_discover_mreg_c(struct rte_eth_dev *dev)if (!priv->sh->config.dv_flow_en)break ;/* Create internal flow, validation skips copy action. */ - flow_idx =flow_drv_list_create (dev,MLX5_FLOW_TYPE_GEN , &attr, + flow_idx =mlx5_flow_list_create (dev,MLX5_FLOW_TYPE_GEN , &attr, items, actions, false, &error); flow =mlx5_ipool_get (priv->flows[MLX5_FLOW_TYPE_GEN ], flow_idx);if (!flow)continue ; priv->sh->flow_mreg_c[n++] = idx; -flow_drv_list_destroy (dev,MLX5_FLOW_TYPE_GEN , flow_idx); +mlx5_flow_list_destroy (dev,MLX5_FLOW_TYPE_GEN , flow_idx); }for (; n <MLX5_MREG_C_NUM ; ++n) priv->sh->flow_mreg_c[n] =REG_NON ;
drivers/net/mlx5/mlx5_flow_hw.c +48 -52
190 lines not on this page · raw message
Signature · 1 line
2.21.0
Hi,
From: Maayan Kashani <[email protected]>
Sent: Sunday, June 9, 2024 2:00 PM
To: [email protected]
Cc: Maayan Kashani; Dariusz Sosnowski; Raslan Darawsheh; Slava Ovsiienko; Ori Kam; Suanming Mou; Matan Azrad
Subject: [PATCH v7 01/11] net/mlx5: initial design of non template to hws
Implement the frame and needed building
blocks for non template to hws API's.
Added validate, list_create and list_destroy to mlx5_flow_hw_drv_ops. Rename old list_create/list_destroy functions to legacy_* and added a call from verbs/dv ops to the legacy functions.
Updated rte_flow_hw as needed.
Added rte_flow_nt2hws structure for non-template rule data.
squash to net/mlx5: initial design of non template to hws
Series applied to next-net-mlx,
Kindest regards,
Raslan Darawsheh