net/mlx5: implement send to kernel action
Subsystems (2)
v2 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: patch-6838dd4bf976 ("ethdev: add send to kernel action")
---
v2:
- updated after code review
v1:
https://patches.dpdk.org/project/dpdk/list/?series=24734
---
Michael Savisko (4):
common/mlx5: new glue callback for send to kernel action net/mlx5: introduce new mlx5 action flag net/mlx5: add send to kernel action resource holder net/mlx5: translation of rte flow send to kernel action
doc/guides/nics/features/default.ini | 1 + doc/guides/nics/features/mlx5.ini | 1 + 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 | 13 +++++ drivers/net/mlx5/mlx5.h | 6 ++ drivers/net/mlx5/mlx5_flow.c | 32 +++++++++++ drivers/net/mlx5/mlx5_flow.h | 10 +++- drivers/net/mlx5/mlx5_flow_dv.c | 74 +++++++++++++++++++++++-- drivers/net/mlx5/mlx5_flow_hw.c | 3 + drivers/net/mlx5/windows/mlx5_flow_os.h | 24 ++++++++ 13 files changed, 200 insertions(+), 7 deletions(-)
Signature · 1 line
2.27.0
PATCH v2 1/4 common/mlx5: new glue callback for send to kernel action
Add new glue callback dr_create_flow_action_send_to_kernel. Default callback invokes mlx5dv_dr_action_create_dest_root_table().
Add static inline mlx5_flow_os_create_flow_action_send_to_kernel(), which calls dr_create_flow_action_send_to_kernel glue callback.
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 ++ 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/windows/mlx5_flow_os.h | 24 ++++++++++++++++++++++++ 5 files changed, 67 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 += [
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;
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 *
drivers/net/mlx5/windows/mlx5_flow_os.h +24 -0
@@ -326,6 +326,30 @@ mlx5_flow_os_create_flow_action_default_miss(void **action)return 0 ; } +/** +* 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) +{ +RTE_SET_USED (tbl); +RTE_SET_USED (priority); + *action =NULL ; + rte_errno =ENOTSUP ; +return -rte_errno; +} +/** * Create flow action: sampler *
Signature · 1 line
2.27.0
PATCH v2 2/4 net/mlx5: introduce new mlx5 action flag
In reply to Michael SaviskoAdd new mlx5 action flag MLX5_FLOW_ACTION_SEND_TO_KERNEL.
Add 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 | 7 +++++-- drivers/net/mlx5/mlx5_flow_dv.c | 17 +++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-)
drivers/net/mlx5/mlx5_flow.h +5 -2
@@ -277,12 +277,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 | \
@@ -477,6 +479,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, };
@@ -709,7 +712,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 +17 -0
@@ -7970,6 +7970,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,
@@ -13694,6 +13700,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) {
@@ -14742,6 +14753,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
RE: [PATCH v2 2/4] net/mlx5: introduce new mlx5 action flag
Hi,
Quoted 16 lines
-----Original Message-----
From: Michael Savisko <[email protected]>
Sent: Wednesday, October 19, 2022 9:40 PM
To: [email protected]
Cc: Michael Savisko <[email protected]>; Ori Kam <[email protected]>; Slava Ovsiienko <[email protected]>; Asaf Penso <[email protected]>; Matan Azrad <[email protected]>
Subject: [PATCH v2 2/4] net/mlx5: introduce new mlx5 action flagAdd new mlx5 action flag
MLX5_FLOW_ACTION_SEND_TO_KERNEL.Add element
MLX5_FLOW_FATE_SEND_TO_KERNELin enummlx5_flow_fate_type.
For that purpose field 'fate_action' in structuremlx5_flow_handlemust be expanded from 3 bits to 4 bits.
Quoted 5 lines
Signed-off-by Michael Savisko <[email protected]>Acked-by Matan Azrad <[email protected]>--- drivers/net/mlx5/mlx5_flow.h | 7 +++++-- drivers/net/mlx5/mlx5_flow_dv.c | 17 +++++++++++++++++
Missing doc update for features list, I'll handle during integration
Kindest regards,
Raslan Darawsheh
PATCH v2 3/4 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().
Change function flow_dv_tbl_resource_release() from static to external.
--- drivers/net/mlx5/linux/mlx5_os.c | 13 +++++++++++++ drivers/net/mlx5/mlx5.h | 6 ++++++ drivers/net/mlx5/mlx5_flow.h | 2 ++ drivers/net/mlx5/mlx5_flow_dv.c | 6 +----- 4 files changed, 22 insertions(+), 5 deletions(-)
drivers/net/mlx5/linux/mlx5_os.c +13 -0
@@ -700,6 +700,19 @@ 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
@@ -1180,6 +1180,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.
@@ -1231,6 +1236,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;
drivers/net/mlx5/mlx5_flow.h +2 -0
@@ -1918,6 +1918,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);
@@ -10928,7 +10924,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 v2 4/4 net/mlx5: translation of rte flow send to kernel action
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.
Add flow_dv_translate_action_send_to_kernel() function which will allocate rdma-core send_to_kernel action object. Called from flow_dv_translate().
Fail translation of RTE_FLOW_ACTION_TYPE_SEND_TO_KERNEL action in HW steering.
--- doc/guides/nics/features/default.ini | 1 + doc/guides/nics/features/mlx5.ini | 1 + drivers/net/mlx5/mlx5_flow.c | 32 ++++++++++++++++ drivers/net/mlx5/mlx5_flow.h | 1 + drivers/net/mlx5/mlx5_flow_dv.c | 57 ++++++++++++++++++++++++++-- drivers/net/mlx5/mlx5_flow_hw.c | 3 ++ 6 files changed, 92 insertions(+), 3 deletions(-)
doc/guides/nics/features/default.ini +1 -0
@@ -198,3 +198,4 @@ set_ttl = vf = vxlan_decap = vxlan_encap = +send_to_kernel =
doc/guides/nics/features/mlx5.ini +1 -0
@@ -128,3 +128,4 @@ set_tp_src = Y set_ttl = Y vxlan_decap = Y vxlan_encap = Y +send_to_kernel = Y
drivers/net/mlx5/mlx5_flow.c +32 -0
@@ -10967,6 +10967,38 @@ 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
@@ -1753,6 +1753,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,
drivers/net/mlx5/mlx5_flow_dv.c +54 -3
69 lines not on this page · raw message
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
Hi,
Quoted 45 lines
-----Original Message-----
From: Michael Savisko <[email protected]>
Sent: Wednesday, October 19, 2022 9:40 PM
To: [email protected]
Cc: Michael Savisko <[email protected]>; Ori Kam <[email protected]>; Slava Ovsiienko <[email protected]>; Asaf Penso <[email protected]>; Matan Azrad <[email protected]>
Subject: [PATCH v2 0/4] net/mlx5: implement send to kernel actionThis patchset provides mlx5 implementation of new
rte_flowactionRTE_FLOW_ACTION_TYPE_SEND_TO_KERNEL.Depends-on: patch-6838dd4bf976 ("ethdev: add send to kernel action")
Signed-off-by Michael Savisko <[email protected]>Acked-by Matan Azrad <[email protected]>---
v2:
- updated after code reviewv1:
https://patches.dpdk.org/project/dpdk/list/?series=24734---
Michael Savisko (4):
common/mlx5: new glue callback for send to kernel action net/mlx5: introduce new mlx5 action flag net/mlx5: add send to kernel action resource holder net/mlx5: translation of rte flow send to kernel actiondoc/guides/nics/features/default.ini | 1 + doc/guides/nics/features/mlx5.ini | 1 + 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 | 13 +++++ drivers/net/mlx5/mlx5.h | 6 ++ drivers/net/mlx5/mlx5_flow.c | 32 +++++++++++ drivers/net/mlx5/mlx5_flow.h | 10 +++- drivers/net/mlx5/mlx5_flow_dv.c | 74 +++++++++++++++++++++++-- drivers/net/mlx5/mlx5_flow_hw.c | 3 + drivers/net/mlx5/windows/mlx5_flow_os.h | 24 ++++++++ 13 files changed, 200 insertions(+), 7 deletions(-)
Quoted 2 lines
--
2.27.0
Series applied to next-net-mlx,
With a small fix for the missing doc on the features list,
Kindest regards,
Raslan Darawsheh