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 Signed-off-by: Michael Savisko <michael...@nvidia.com> Acked-by: Matan Azrad <ma...@nvidia.com> --- 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(+) diff --git a/drivers/common/mlx5/linux/meson.build b/drivers/common/mlx5/linux/meson.build index e77b46d157..b044f95700 100644 --- a/drivers/common/mlx5/linux/meson.build +++ b/drivers/common/mlx5/linux/meson.build @@ -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 += [ diff --git a/drivers/common/mlx5/linux/mlx5_glue.c b/drivers/common/mlx5/linux/mlx5_glue.c index 450dd6a06a..b954df0784 100644 --- a/drivers/common/mlx5/linux/mlx5_glue.c +++ b/drivers/common/mlx5/linux/mlx5_glue.c @@ -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, }; diff --git a/drivers/common/mlx5/linux/mlx5_glue.h b/drivers/common/mlx5/linux/mlx5_glue.h index c4903a6dce..9616dfdd06 100644 --- a/drivers/common/mlx5/linux/mlx5_glue.h +++ b/drivers/common/mlx5/linux/mlx5_glue.h @@ -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; diff --git a/drivers/net/mlx5/linux/mlx5_flow_os.h b/drivers/net/mlx5/linux/mlx5_flow_os.h index bcb48b3e56..ed71289322 100644 --- a/drivers/net/mlx5/linux/mlx5_flow_os.h +++ b/drivers/net/mlx5/linux/mlx5_flow_os.h @@ -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 * diff --git a/drivers/net/mlx5/windows/mlx5_flow_os.h b/drivers/net/mlx5/windows/mlx5_flow_os.h index 347ec64580..1c1c17fc41 100644 --- a/drivers/net/mlx5/windows/mlx5_flow_os.h +++ b/drivers/net/mlx5/windows/mlx5_flow_os.h @@ -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 * -- 2.27.0