net/mlx5: implement send to kernel action
Subsystems (2)
cover net/mlx5: implement send to kernel action
This patchset provides mlx5 implementation of new rte_flow action RTE_FLOW_ACTION_TYPE_SEND_TO_KERNEL.
Depends-on: series=24713 ("ethdev: add send to kernel action")
Michael Savisko (10):
common/mlx5: update meson build file
net/mlx5: disable send to kernel action in HW streering common/mlx5: new glue callback for send to kernel action net/mlx5: add function to create send to kernel action net/mlx5: introduce new mlx5 action flag net/mlx5: introduce new mlx5 flow fate net/mlx5: get priority to send traffic to kernel net/mlx5: expose table resource release function net/mlx5: add send to kernel action resource holder net/mlx5: translation of rte flow send to kernel action
drivers/common/mlx5/linux/meson.build | 2 + drivers/common/mlx5/linux/mlx5_glue.c | 17 ++++++ drivers/common/mlx5/linux/mlx5_glue.h | 2 + drivers/net/mlx5/linux/mlx5_flow_os.h | 22 ++++++++ drivers/net/mlx5/linux/mlx5_os.c | 11 ++++ drivers/net/mlx5/mlx5.h | 6 ++ drivers/net/mlx5/mlx5_flow.c | 33 +++++++++++ drivers/net/mlx5/mlx5_flow.h | 10 +++- drivers/net/mlx5/mlx5_flow_dv.c | 79 +++++++++++++++++++++++++-- drivers/net/mlx5/mlx5_flow_hw.c | 3 + 10 files changed, 178 insertions(+), 7 deletions(-)
Signature · 1 line
2.27.0
PATCH 1/10 common/mlx5: update meson build file
Define HAVE_MLX5DV_DR_ACTION_CREATE_DEST_ROOT_TABLE macro if function mlx5dv_dr_action_create_dest_root_table exists in infiniband/mlx5dv.h
--- drivers/common/mlx5/linux/meson.build | 2 ++ 1 file changed, 2 insertions(+)
drivers/common/mlx5/linux/meson.build +2 -0
@@ -213,6 +213,8 @@ has_sym_args = [ 'ibv_reg_mr_iova' ], [ 'HAVE_MLX5_IBV_IMPORT_CTX_PD_AND_MR', 'infiniband/verbs.h', 'ibv_import_device' ], + [ 'HAVE_MLX5DV_DR_ACTION_CREATE_DEST_ROOT_TABLE', 'infiniband/mlx5dv.h', + 'mlx5dv_dr_action_create_dest_root_table' ], ] if libmtcr_ul_found has_sym_args += [
Signature · 1 line
2.27.0
PATCH 2/10 net/mlx5: disable send to kernel action in HW streering
In reply to Michael SaviskoFail translation of RTE_FLOW_ACTION_TYPE_SEND_TO_KERNEL action in HW steering.
--- drivers/net/mlx5/mlx5_flow_hw.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/mlx5/mlx5_flow_hw.c +3 -0
@@ -707,6 +707,9 @@ flow_hw_actions_translate(struct rte_eth_dev *dev, reformat_pos = i++; refmt_type =MLX5DR_ACTION_REFORMAT_TYPE_TNL_L2_TO_L2 ;break ; +case RTE_FLOW_ACTION_TYPE_SEND_TO_KERNEL : +DRV_LOG (ERR ,"send to kernel action is not supported in HW steering." ); + goto err;case RTE_FLOW_ACTION_TYPE_END : actions_end = true;break ;
Signature · 1 line
2.27.0
PATCH 3/10 common/mlx5: new glue callback for send to kernel action
In reply to Michael SaviskoAdd new glue callback dr_create_flow_action_send_to_kernel. Default callback invokes mlx5dv_dr_action_create_dest_root_table().
--- drivers/common/mlx5/linux/mlx5_glue.c | 17 +++++++++++++++++ drivers/common/mlx5/linux/mlx5_glue.h | 2 ++ 2 files changed, 19 insertions(+)
drivers/common/mlx5/linux/mlx5_glue.c +17 -0
@@ -1434,6 +1434,21 @@ mlx5_glue_dv_free_pp(struct mlx5dv_pp *pp)#endif } +static void * +mlx5_glue_dr_create_flow_action_send_to_kernel (void *tbl,uint16_t priority) +{ +#ifdef HAVE_MLX5DV_DR_ACTION_CREATE_DEST_ROOT_TABLE +struct mlx5dv_dr_table *table = (struct mlx5dv_dr_table *)tbl; + +return mlx5dv_dr_action_create_dest_root_table (table, priority); +#else +RTE_SET_USED (tbl); +RTE_SET_USED (priority); + errno =ENOTSUP ; +return NULL ; +#endif +} +__rte_cache_aligned const struct mlx5_glue *mlx5_glue = &(const struct mlx5_glue) { .version =MLX5_GLUE_VERSION ,
@@ -1561,4 +1576,6 @@ const struct mlx5_glue *mlx5_glue = &(const struct mlx5_glue) { .dv_free_var = mlx5_glue_dv_free_var, .dv_alloc_pp = mlx5_glue_dv_alloc_pp, .dv_free_pp = mlx5_glue_dv_free_pp, + .dr_create_flow_action_send_to_kernel = + mlx5_glue_dr_create_flow_action_send_to_kernel, };
drivers/common/mlx5/linux/mlx5_glue.h +2 -0
@@ -373,6 +373,8 @@ struct mlx5_glue {void *(*dv_create_flow_action_aso) (struct mlx5dv_dr_domain *domain,void *aso_obj,uint32_t offset,uint32_t flags,uint8_t return_reg_c); +void *(*dr_create_flow_action_send_to_kernel)(void *tbl, +uint16_t priority); };extern const struct mlx5_glue *mlx5_glue;
Signature · 1 line
2.27.0
PATCH 4/10 net/mlx5: add function to create send to kernel action
In reply to Michael SaviskoAdd static inline mlx5_flow_os_create_flow_action_send_to_kernel(), which calls dr_create_flow_action_send_to_kernel glue callback.
--- drivers/net/mlx5/linux/mlx5_flow_os.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)
drivers/net/mlx5/linux/mlx5_flow_os.h +22 -0
@@ -368,6 +368,28 @@ mlx5_flow_os_create_flow_action_default_miss(void **action)return (*action) ?0 :-1 ; } +/** +* Create flow action: send_to_kernel. +* +* @param[in] tbl +* Pointer to destination root table. +* @param[in] priority +* Priority to which traffic will arrive. +* @param[out] action +* Pointer to a valid action on success, NULL otherwise. +* +* @return +* 0 on success, or -1 on failure and errno is set. +*/ +static inline int +mlx5_flow_os_create_flow_action_send_to_kernel (void *tbl,uint16_t priority, +void **action) +{ + *action = mlx5_glue->dr_create_flow_action_send_to_kernel (tbl, + priority); +return (*action) ?0 :-1 ; +} +/** * Create flow action: dest_devx_tir *
Signature · 1 line
2.27.0
PATCH 5/10 net/mlx5: introduce new mlx5 action flag
In reply to Michael SaviskoAdd new mlx5 action flag MLX5_FLOW_ACTION_SEND_TO_KERNEL.
--- drivers/net/mlx5/mlx5_flow.h | 4 +++- drivers/net/mlx5/mlx5_flow_dv.c | 11 +++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-)
drivers/net/mlx5/mlx5_flow.h +3 -1
@@ -274,12 +274,14 @@ enum mlx5_feature_name {#define MLX5_FLOW_ACTION_MODIFY_FIELD (1ull << 39)#define MLX5_FLOW_ACTION_METER_WITH_TERMINATED_POLICY (1ull << 40)#define MLX5_FLOW_ACTION_CT (1ull << 41) +#define MLX5_FLOW_ACTION_SEND_TO_KERNEL (1ull << 42)#define MLX5_FLOW_FATE_ACTIONS \ (MLX5_FLOW_ACTION_DROP | MLX5_FLOW_ACTION_QUEUE | \ MLX5_FLOW_ACTION_RSS | MLX5_FLOW_ACTION_JUMP | \ MLX5_FLOW_ACTION_DEFAULT_MISS | \ - MLX5_FLOW_ACTION_METER_WITH_TERMINATED_POLICY) + MLX5_FLOW_ACTION_METER_WITH_TERMINATED_POLICY | \ + MLX5_FLOW_ACTION_SEND_TO_KERNEL)#define MLX5_FLOW_FATE_ESWITCH_ACTIONS \ (MLX5_FLOW_ACTION_DROP | MLX5_FLOW_ACTION_PORT_ID | \
drivers/net/mlx5/mlx5_flow_dv.c +11 -0
@@ -7953,6 +7953,12 @@ flow_dv_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr,* list it here as a supported type */ break ; +#ifdef HAVE_MLX5DV_DR_ACTION_CREATE_DEST_ROOT_TABLE +case RTE_FLOW_ACTION_TYPE_SEND_TO_KERNEL : + action_flags |=MLX5_FLOW_ACTION_SEND_TO_KERNEL ; + ++actions_n; +break ; +#endif default : return rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION,
@@ -13677,6 +13683,11 @@ flow_dv_translate(struct rte_eth_dev *dev, actions_n++; action_flags |=MLX5_FLOW_ACTION_CT ;break ; +case RTE_FLOW_ACTION_TYPE_SEND_TO_KERNEL : +return rte_flow_error_set (error,ENOTSUP , +RTE_FLOW_ERROR_TYPE_ACTION , +NULL ,"send to kernel action is not supported." ); +break ;case RTE_FLOW_ACTION_TYPE_END : actions_end = true;if (mhdr_res->actions_num) {
Signature · 1 line
2.27.0
PATCH 6/10 net/mlx5: introduce new mlx5 flow fate
In reply to Michael SaviskoAdd element MLX5_FLOW_FATE_SEND_TO_KERNEL in enum mlx5_flow_fate_type.
For that purpose field 'fate_action' in structure mlx5_flow_handle must be expanded from 3 bits to 4 bits.
--- drivers/net/mlx5/mlx5_flow.h | 3 ++- drivers/net/mlx5/mlx5_flow_dv.c | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-)
drivers/net/mlx5/mlx5_flow.h +2 -1
@@ -476,6 +476,7 @@ enum mlx5_flow_fate_type {MLX5_FLOW_FATE_DEFAULT_MISS ,MLX5_FLOW_FATE_SHARED_RSS ,MLX5_FLOW_FATE_MTR , +MLX5_FLOW_FATE_SEND_TO_KERNEL , MLX5_FLOW_FATE_MAX, };
@@ -708,7 +709,7 @@ struct mlx5_flow_handle {void *drv_flow;/**< pointer to driver flow object. */ uint32_t split_flow_id:27; /**< Sub flow unique match flow id. */ uint32_t is_meter_flow_id:1; /**< Indicate if flow_id is for meter. */ - uint32_t fate_action:3; /**< Fate action type. */ + uint32_t fate_action:4; /**< Fate action type. */union {uint32_t rix_hrxq;/**< Hash Rx queue object index. */ uint32_t rix_jump;/**< Index to the jump action resource. */
drivers/net/mlx5/mlx5_flow_dv.c +6 -0
@@ -14735,6 +14735,12 @@ flow_dv_fate_resource_release(struct rte_eth_dev *dev,flow_dv_port_id_action_resource_release (dev, handle->rix_port_id_action);break ; +case MLX5_FLOW_FATE_SEND_TO_KERNEL : +/* In case of send_to_kernel action the actual release of +* resource is done when all shared DR resources are released +* since this resource is created once and always reused. +*/ +break ;default :DRV_LOG (DEBUG ,"Incorrect fate action:%d" , handle->fate_action);break ;
Signature · 1 line
2.27.0
PATCH 7/10 net/mlx5: get priority to send traffic to kernel
In reply to Michael SaviskoIntroduce mlx5_get_send_to_kernel_priority() function which returns value of priority which must be used to jump back to table 0 in order to send traffic to kernel. This function returns lowest priority.
--- drivers/net/mlx5/mlx5_flow.c | 33 +++++++++++++++++++++++++++++++++ drivers/net/mlx5/mlx5_flow.h | 1 + 2 files changed, 34 insertions(+)
drivers/net/mlx5/mlx5_flow.c +33 -0
@@ -10968,6 +10968,39 @@ mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority,return res; } +/** +* Get the priority for sending traffic to kernel table. +* +* @param[in] dev +* Pointer to the Ethernet device structure. +* +* @return +* On success: the value of priority for sending traffic to kernel table +* On failure: -1 +*/ +uint32_t +mlx5_get_send_to_kernel_priority (struct rte_eth_dev *dev) +{ +struct mlx5_priv *priv = dev->data->dev_private; +uint32_t res; + +switch (priv->sh->flow_max_priority) { +case RTE_DIM (priority_map_5): + res =15 ; +break ; +case RTE_DIM (priority_map_3): + res =7 ; +break ; +default : +DRV_LOG (ERR , +"port %u maximum priority: %d expected 8/16" , + dev->data->port_id, priv->sh->flow_max_priority); + res = (uint32_t )-1 ; + } + +return res; +} +/** * Get the E-Switch Manager vport id. *
drivers/net/mlx5/mlx5_flow.h +1 -0
@@ -1750,6 +1750,7 @@ uint32_t mlx5_get_lowest_priority(struct rte_eth_dev *dev,uint16_t mlx5_get_matcher_priority (struct rte_eth_dev *dev,const struct rte_flow_attr *attr,uint32_t subpriority,bool external); +uint32_t mlx5_get_send_to_kernel_priority (struct rte_eth_dev *dev); int mlx5_flow_get_reg_id(struct rte_eth_dev *dev, enum mlx5_feature_name feature, uint32_t id,
Signature · 1 line
2.27.0
PATCH 8/10 net/mlx5: expose table resource release function
In reply to Michael SaviskoChange function flow_dv_tbl_resource_release() from static to external. Prestep for next commit.
--- drivers/net/mlx5/mlx5_flow.h | 2 ++ drivers/net/mlx5/mlx5_flow_dv.c | 6 +----- 2 files changed, 3 insertions(+), 5 deletions(-)
drivers/net/mlx5/mlx5_flow.h +2 -0
@@ -1916,6 +1916,8 @@ struct mlx5_flow_tbl_resource *flow_dv_tbl_resource_get(struct rte_eth_dev *dev, bool external, const struct mlx5_flow_tunnel *tunnel, uint32_t group_id, uint8_t dummy, uint32_t table_id, struct rte_flow_error *error); +int flow_dv_tbl_resource_release (struct mlx5_dev_ctx_shared *sh, +struct mlx5_flow_tbl_resource *tbl);struct mlx5_list_entry *flow_dv_tag_create_cb (void *tool_ctx,void *cb_ctx); int flow_dv_tag_match_cb(void *tool_ctx, struct mlx5_list_entry *entry,
drivers/net/mlx5/mlx5_flow_dv.c +1 -5
@@ -75,10 +75,6 @@ union flow_dv_attr {uint32_t attr; }; -static int -flow_dv_tbl_resource_release (struct mlx5_dev_ctx_shared *sh, -struct mlx5_flow_tbl_resource *tbl); -static int flow_dv_encap_decap_resource_release (struct rte_eth_dev *dev,uint32_t encap_decap_idx);
@@ -10911,7 +10907,7 @@ flow_dv_tbl_remove_cb(void *tool_ctx, struct mlx5_list_entry *entry)* @return * Returns 0 if table was released, else return 1; */ -static int +int flow_dv_tbl_resource_release (struct mlx5_dev_ctx_shared *sh,struct mlx5_flow_tbl_resource *tbl) {
Signature · 1 line
2.27.0
PATCH 9/10 net/mlx5: add send to kernel action resource holder
In reply to Michael SaviskoAdd new structure mlx5_send_to_kernel_action which will hold together allocated action resource and a reference to used table. A new structure member of this type added to struct mlx5_dev_ctx_shared. The member will be initialized upon first created send_to_kernel action and will be reused for all future actions of this type. Release of these resources will be done when all shared DR resources are being released in mlx5_os_free_shared_dr().
--- drivers/net/mlx5/linux/mlx5_os.c | 11 +++++++++++ drivers/net/mlx5/mlx5.h | 6 ++++++ 2 files changed, 17 insertions(+)
drivers/net/mlx5/linux/mlx5_os.c +11 -0
@@ -708,6 +708,17 @@ mlx5_os_free_shared_dr(struct mlx5_priv *priv) mlx5_glue->destroy_flow_action (sh->pop_vlan_action); sh->pop_vlan_action = NULL; } +if (sh->send_to_kernel_action.action) { +void *action = sh->send_to_kernel_action.action; + mlx5_glue->destroy_flow_action (action); + sh->send_to_kernel_action.action =NULL ; + } +if (sh->send_to_kernel_action.tbl) { +struct mlx5_flow_tbl_resource *tbl = + sh->send_to_kernel_action.tbl; +flow_dv_tbl_resource_release (sh, tbl); + sh->send_to_kernel_action.tbl =NULL ; + }#endif /* HAVE_MLX5DV_DR */ if (sh->default_miss_action) mlx5_glue->destroy_flow_action
drivers/net/mlx5/mlx5.h +6 -0
@@ -1178,6 +1178,11 @@ struct mlx5_flex_item {struct mlx5_flex_pattern_field map[MLX5_FLEX_ITEM_MAPPING_NUM ]; }; +struct mlx5_send_to_kernel_action { +void *action; +void *tbl; +}; +/* * Shared Infiniband device context for Master/Representors * which belong to same IB device with multiple IB ports.
@@ -1229,6 +1234,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. */ +struct mlx5_send_to_kernel_action send_to_kernel_action;struct mlx5_hlist *encaps_decaps;/* Encap/decap action hash list. */ struct mlx5_hlist *modify_cmds;struct mlx5_hlist *tag_table;
Signature · 1 line
2.27.0
PATCH 10/10 net/mlx5: translation of rte flow send to kernel action
In reply to Michael SaviskoAdd flow_dv_translate_action_send_to_kernel() function which will allocate rdma-core send_to_kernel action object. Called from flow_dv_translate().
--- drivers/net/mlx5/mlx5_flow_dv.c | 62 +++++++++++++++++++++++++++++++-- 1 file changed, 59 insertions(+), 3 deletions(-)
drivers/net/mlx5/mlx5_flow_dv.c +59 -3
@@ -12175,6 +12175,56 @@ flow_dv_translate_action_sample(struct rte_eth_dev *dev,return 0 ; } +static void * +flow_dv_translate_action_send_to_kernel (struct rte_eth_dev *dev, +struct rte_flow_error *error) +{ +struct mlx5_flow_tbl_resource *tbl; +struct mlx5_dev_ctx_shared *sh; +uint32_t priority; +void *action; +int ret; + + sh =MLX5_SH (dev); +if (sh->send_to_kernel_action.action) +return sh->send_to_kernel_action.action; + + priority =mlx5_get_send_to_kernel_priority (dev); +if (priority == (uint32_t )-1 ) { +rte_flow_error_set (error,ENOTSUP , +RTE_FLOW_ERROR_TYPE_UNSPECIFIED ,NULL , +"required priority is not available" ); +return NULL ; + } + + tbl =flow_dv_tbl_resource_get (dev,0 ,0 ,0 , false,NULL ,0 ,0 ,0 , + error); +if (!tbl) { +rte_flow_error_set (error,ENODATA , +RTE_FLOW_ERROR_TYPE_UNSPECIFIED ,NULL , +"cannot find destination root table" ); +return NULL ; + } + + ret =mlx5_flow_os_create_flow_action_send_to_kernel (tbl->obj, + priority, &action); +if (ret) { +rte_flow_error_set (error,ENOMEM , +RTE_FLOW_ERROR_TYPE_UNSPECIFIED ,NULL , +"cannot create action" ); + goto err; + } + +MLX5_ASSERT (action); + sh->send_to_kernel_action.action = action; + sh->send_to_kernel_action.tbl = tbl; +return action; + +err: +flow_dv_tbl_resource_release (sh, tbl); +return NULL ; +} +/** * Convert Sample action to DV specification. *
@@ -13680,9 +13730,15 @@ flow_dv_translate(struct rte_eth_dev *dev, action_flags |=MLX5_FLOW_ACTION_CT ;break ;case RTE_FLOW_ACTION_TYPE_SEND_TO_KERNEL : -return rte_flow_error_set (error,ENOTSUP , -RTE_FLOW_ERROR_TYPE_ACTION , -NULL ,"send to kernel action is not supported." ); + dev_flow->dv.actions[actions_n] = +flow_dv_translate_action_send_to_kernel (dev, + error); +if (!dev_flow->dv.actions[actions_n]) +return -rte_errno; + actions_n++; + action_flags |=MLX5_FLOW_ACTION_SEND_TO_KERNEL ; + dev_flow->handle->fate_action = +MLX5_FLOW_FATE_SEND_TO_KERNEL ;break ;case RTE_FLOW_ACTION_TYPE_END : actions_end = true;
Signature · 1 line
2.27.0