net/mlx5/hws: support dest root table action
Subsystems (2)
PATCH 1/3 net/mlx5/hws: support dest root table action
Add support for dest root table action creation. This support will allow to redirect the packets to the kernel from non root tables.
--- drivers/common/mlx5/linux/meson.build | 2 + drivers/common/mlx5/linux/mlx5_glue.c | 28 +++++++++ drivers/common/mlx5/linux/mlx5_glue.h | 16 +++++ drivers/net/mlx5/hws/mlx5dr.h | 19 ++++++ drivers/net/mlx5/hws/mlx5dr_action.c | 84 +++++++++++++++++++++++++-- drivers/net/mlx5/hws/mlx5dr_action.h | 3 + drivers/net/mlx5/hws/mlx5dr_debug.c | 1 + 7 files changed, 147 insertions(+), 6 deletions(-)
drivers/common/mlx5/linux/meson.build +2 -0
@@ -219,6 +219,8 @@ has_sym_args = [ 'ibv_import_device' ], [ 'HAVE_MLX5DV_DR_ACTION_CREATE_DEST_ROOT_TABLE', 'infiniband/mlx5dv.h', 'mlx5dv_dr_action_create_dest_root_table' ], + [ 'HAVE_MLX5DV_CREATE_STEERING_ANCHOR', 'infiniband/mlx5dv.h', + 'mlx5dv_create_steering_anchor'], ] if libmtcr_ul_found has_sym_args += [
drivers/common/mlx5/linux/mlx5_glue.c +28 -0
@@ -1548,6 +1548,32 @@ mlx5_glue_dr_create_flow_action_send_to_kernel(void *tbl, uint16_t priority)#endif } +static struct mlx5dv_steering_anchor * +mlx5_glue_dv_create_steering_anchor (struct ibv_context *context, +struct mlx5dv_steering_anchor_attr *attr) +{ +#ifdef HAVE_MLX5DV_CREATE_STEERING_ANCHOR +return mlx5dv_create_steering_anchor (context, attr); +#else + (void )context; + (void )attr; + errno =ENOTSUP ; +return NULL ; +#endif +} + +static int +mlx5_glue_dv_destroy_steering_anchor (struct mlx5dv_steering_anchor *sa) +{ +#ifdef HAVE_MLX5DV_CREATE_STEERING_ANCHOR +return mlx5dv_destroy_steering_anchor (sa); +#else + (void )sa; + errno =ENOTSUP ; +return -ENOTSUP ; +#endif +} +__rte_cache_aligned const struct mlx5_glue *mlx5_glue = &(const struct mlx5_glue) { .version =MLX5_GLUE_VERSION ,
@@ -1685,4 +1711,6 @@ const struct mlx5_glue *mlx5_glue = &(const struct mlx5_glue) { .dv_free_pp = mlx5_glue_dv_free_pp, .dr_create_flow_action_send_to_kernel = mlx5_glue_dr_create_flow_action_send_to_kernel, + .create_steering_anchor = mlx5_glue_dv_create_steering_anchor, + .destroy_steering_anchor = mlx5_glue_dv_destroy_steering_anchor, };
drivers/common/mlx5/linux/mlx5_glue.h +16 -0
@@ -148,6 +148,18 @@ struct mlx5dv_var { uint32_t page_id; uint32_t length; off_t mmap_off;#define IBV_ACCESS_RELAXED_ORDERING 0#endif +#ifndef HAVE_MLX5DV_CREATE_STEERING_ANCHOR +struct mlx5dv_steering_anchor_attr { +uint32_t ft_type; +uint16_t priority; +uint64_t comp_mask; +}; + +struct mlx5dv_steering_anchor { +uint32_t id; +}; +#endif +struct mlx5_glue {const char *version;int (*fork_init)(void );
@@ -392,6 +404,10 @@ struct mlx5_glue { uint32_t offset, uint32_t flags, uint8_t return_reg_c);void *(*dr_create_flow_action_send_to_kernel)(void *tbl,uint16_t priority); +struct mlx5dv_steering_anchor *(*create_steering_anchor) + (struct ibv_context *context, +struct mlx5dv_steering_anchor_attr *attr); +int (*destroy_steering_anchor)(struct mlx5dv_steering_anchor *sa); };extern const struct mlx5_glue *mlx5_glue;
drivers/net/mlx5/hws/mlx5dr.h +19 -0
@@ -45,6 +45,7 @@ enum mlx5dr_action_type {MLX5DR_ACTION_TYP_PUSH_VLAN ,MLX5DR_ACTION_TYP_ASO_METER ,MLX5DR_ACTION_TYP_ASO_CT , +MLX5DR_ACTION_TYP_DEST_ROOT_TABLE , MLX5DR_ACTION_TYP_MAX, };
@@ -565,6 +566,24 @@ mlx5dr_action_create_pop_vlan(struct mlx5dr_context *ctx, uint32_t flags);struct mlx5dr_action *mlx5dr_action_create_push_vlan (struct mlx5dr_context *ctx,uint32_t flags); +/* Create dest root table, this action will jump to root table according +* the given priority. +* @param[in] ctx +* The context in which the new action will be created. +* @param[in] tbl +* The root table to jump to. +* @param[in] priority +* The priority of matcher in the root table to jump to. +* @param[in] flags +* Action creation flags. (enum mlx5dr_action_flags). +* @return pointer to mlx5dr_action on success NULL otherwise. +*/ +struct mlx5dr_action * +mlx5dr_action_create_dest_root_table (struct mlx5dr_context *ctx, +struct mlx5dr_table *tbl, +uint16_t priority, +uint32_t flags); +/* Destroy direct rule action. * * @param[in] action
drivers/net/mlx5/hws/mlx5dr_action.c +78 -6
135 lines not on this page · raw message
drivers/net/mlx5/hws/mlx5dr_action.h +3 -0
@@ -141,6 +141,9 @@ struct mlx5dr_action {struct {struct mlx5dr_devx_obj *devx_obj; } alias; +struct { +struct mlx5dv_steering_anchor *sa; + } root_tbl; }; };
drivers/net/mlx5/hws/mlx5dr_debug.c +1 -0
@@ -22,6 +22,7 @@ const char *mlx5dr_debug_action_type_str[] = { [MLX5DR_ACTION_TYP_PUSH_VLAN] = "PUSH_VLAN", [MLX5DR_ACTION_TYP_ASO_METER] = "ASO_METER", [MLX5DR_ACTION_TYP_ASO_CT] = "ASO_CT", + [MLX5DR_ACTION_TYP_DEST_ROOT_TABLE ] ="DEST_ROOT_TABLE" , }; static_assert(ARRAY_SIZE(mlx5dr_debug_action_type_str) == MLX5DR_ACTION_TYP_MAX,
Signature · 1 line
2.26.3
PATCH 2/3 net/mlx5/hws: dump FT icm addresses
Add the support for query FT command.
Use the query FT command to dump the ICM addresses of table start anchor and matcher end anchor.
--- drivers/common/mlx5/mlx5_prm.h | 50 ++++++++++++++++++++--- drivers/net/mlx5/hws/mlx5dr_cmd.c | 28 +++++++++++++ drivers/net/mlx5/hws/mlx5dr_cmd.h | 9 +++++ drivers/net/mlx5/hws/mlx5dr_debug.c | 62 ++++++++++++++++++++++++++--- drivers/net/mlx5/hws/mlx5dr_debug.h | 6 +++ 5 files changed, 144 insertions(+), 11 deletions(-)
drivers/common/mlx5/mlx5_prm.h +45 -5
@@ -1156,6 +1156,7 @@ enum {MLX5_CMD_OP_CREATE_RQT =0x916 ,MLX5_CMD_OP_MODIFY_RQT =0x917 ,MLX5_CMD_OP_CREATE_FLOW_TABLE =0x930 , +MLX5_CMD_OP_QUERY_FLOW_TABLE =0x932 ,MLX5_CMD_OP_CREATE_FLOW_GROUP =0x933 ,MLX5_CMD_OP_SET_FLOW_TABLE_ENTRY =0x936 , MLX5_CMD_OP_MODIFY_FLOW_TABLE = 0x93c,
@@ -4872,11 +4873,17 @@ struct mlx5_ifc_flow_table_context_bits {u8 reserved_at_60[0x60 ]; -u8 rtc_id_0[0x20 ]; - -u8 rtc_id_1[0x20 ]; - -u8 reserved_at_100[0x40 ]; +union { +struct { +u8 rtc_id_0[0x20 ]; +u8 rtc_id_1[0x20 ]; +u8 reserved_at_100[0x40 ]; + }; +struct { +u8 sw_owner_icm_root_1[0x40 ]; +u8 sw_owner_icm_root_0[0x40 ]; + }; + }; };struct mlx5_ifc_create_flow_table_in_bits {
@@ -4909,6 +4916,39 @@ struct mlx5_ifc_create_flow_table_out_bits {u8 icm_address_31_0[0x20 ]; }; +struct mlx5_ifc_query_flow_table_in_bits { +u8 opcode[0x10 ]; +u8 uid[0x10 ]; + +u8 vhca_tunnel_id[0x10 ]; +u8 op_mod[0x10 ]; + +u8 other_vport[0x1 ]; +u8 reserved_at_41[0xf ]; +u8 vport_number[0x10 ]; + +u8 reserved_at_60[0x20 ]; + +u8 table_type[0x8 ]; +u8 reserved_at_88[0x18 ]; + +u8 reserved_at_a0[0x8 ]; +u8 table_id[0x18 ]; + +u8 reserved_at_c0[0x140 ]; +}; + +struct mlx5_ifc_query_flow_table_out_bits { +u8 status[0x8 ]; +u8 reserved_at_8[0x18 ]; + +u8 syndrome[0x20 ]; + +u8 reserved_at_40[0x80 ]; + +struct mlx5_ifc_flow_table_context_bits flow_table_context; +}; +enum mlx5_flow_destination_type {MLX5_FLOW_DESTINATION_TYPE_VPORT =0x0 , };
drivers/net/mlx5/hws/mlx5dr_cmd.c +28 -0
@@ -80,6 +80,34 @@ mlx5dr_cmd_flow_table_modify(struct mlx5dr_devx_obj *devx_obj,return ret; } +int +mlx5dr_cmd_flow_table_query (struct mlx5dr_devx_obj *devx_obj, +struct mlx5dr_cmd_ft_query_attr *ft_attr, +uint64_t *icm_addr_0,uint64_t *icm_addr_1) +{ +uint32_t out[MLX5_ST_SZ_DW (query_flow_table_out)] = {0 }; +uint32_t in[MLX5_ST_SZ_DW (query_flow_table_in)] = {0 }; +void *ft_ctx; +int ret; + +MLX5_SET (query_flow_table_in, in, opcode,MLX5_CMD_OP_QUERY_FLOW_TABLE ); +MLX5_SET (query_flow_table_in, in, table_type, ft_attr->type); +MLX5_SET (query_flow_table_in, in, table_id, devx_obj->id); + + ret = mlx5_glue->devx_obj_query (devx_obj->obj, in,sizeof (in), out,sizeof (out)); +if (ret) { +DR_LOG (ERR ,"Failed to query FT" ); + rte_errno = errno; +return ret; + } + + ft_ctx =MLX5_ADDR_OF (query_flow_table_out, out, flow_table_context); + *icm_addr_0 =MLX5_GET64 (flow_table_context, ft_ctx, sw_owner_icm_root_0); + *icm_addr_1 =MLX5_GET64 (flow_table_context, ft_ctx, sw_owner_icm_root_1); + +return ret; +} +static struct mlx5dr_devx_obj *mlx5dr_cmd_flow_group_create (struct ibv_context *ctx,struct mlx5dr_cmd_fg_attr *fg_attr)
drivers/net/mlx5/hws/mlx5dr_cmd.h +9 -0
@@ -22,6 +22,10 @@ struct mlx5dr_cmd_ft_modify_attr {uint64_t modify_fs; }; +struct mlx5dr_cmd_ft_query_attr { +uint8_t type; +}; +struct mlx5dr_cmd_fg_attr {uint32_t table_id;uint32_t table_type;
@@ -215,6 +219,11 @@ int mlx5dr_cmd_flow_table_modify(struct mlx5dr_devx_obj *devx_obj, struct mlx5dr_cmd_ft_modify_attr *ft_attr); +int +mlx5dr_cmd_flow_table_query (struct mlx5dr_devx_obj *devx_obj, +struct mlx5dr_cmd_ft_query_attr *ft_attr, +uint64_t *icm_addr_0,uint64_t *icm_addr_1); +struct mlx5dr_devx_obj *mlx5dr_cmd_rtc_create (struct ibv_context *ctx,struct mlx5dr_cmd_rtc_create_attr *rtc_attr);
drivers/net/mlx5/hws/mlx5dr_debug.c +56 -6
105 lines not on this page · raw message
drivers/net/mlx5/hws/mlx5dr_debug.h +6 -0
@@ -26,6 +26,12 @@ enum mlx5dr_debug_res_type { MLX5DR_DEBUG_RES_TYPE_MATCHER_TEMPLATE_RANGE_DEFINER = 4206, }; +static inline uint64_t +mlx5dr_debug_icm_to_idx (uint64_t icm_addr) +{ +return (icm_addr >>6 ) &0xffffffff ; +} +const char *mlx5dr_debug_action_type_to_str (enum mlx5dr_action_type action_type);#endif /* MLX5DR_DEBUG_H_ */
Signature · 1 line
2.26.3
PATCH 3/3 net/mlx5/hws: Enhance forward table and FTE creation
In reply to Hamdan IgbariaChanged FW FT and FTE creation to allow dynamic creation. Till now only FTE with vport destination action was supported. Also enhanced forward table creation to be generic.
--- drivers/common/mlx5/mlx5_prm.h | 20 +++++++-- drivers/net/mlx5/hws/mlx5dr_cmd.c | 66 +++++++++++++++++------------ drivers/net/mlx5/hws/mlx5dr_cmd.h | 28 +++++++++--- drivers/net/mlx5/hws/mlx5dr_table.c | 12 ++++-- 4 files changed, 83 insertions(+), 43 deletions(-)
drivers/common/mlx5/mlx5_prm.h +16 -4
@@ -4951,10 +4951,17 @@ struct mlx5_ifc_query_flow_table_out_bits {enum mlx5_flow_destination_type {MLX5_FLOW_DESTINATION_TYPE_VPORT =0x0 , +MLX5_FLOW_DESTINATION_TYPE_FLOW_TABLE =0x1 , }; -enum { -MLX5_FLOW_CONTEXT_ACTION_FWD_DEST =0x4 , +enum mlx5_flow_context_action { +MLX5_FLOW_CONTEXT_ACTION_FWD_DEST =1 <<2 , +}; + +enum mlx5_flow_context_flow_source { +MLX5_FLOW_CONTEXT_FLOW_SOURCE_ANY_VPORT =0x0 , +MLX5_FLOW_CONTEXT_FLOW_SOURCE_UPLINK =0x1 , +MLX5_FLOW_CONTEXT_FLOW_SOURCE_LOCAL_VPORT =0x2 , };struct mlx5_ifc_set_fte_out_bits {
@@ -4992,11 +4999,16 @@ struct mlx5_ifc_flow_context_bits {u8 reserved_at_60[0x10 ];u8 action[0x10 ];u8 extended_destination[0x1 ]; -u8 reserved_at_81[0x7 ]; +u8 reserved_at_81[0x1 ]; +u8 flow_source[0x2 ]; +u8 encrypt_decrypt_type[0x4 ];u8 destination_list_size[0x18 ];u8 reserved_at_a0[0x8 ];u8 flow_counter_list_size[0x18 ]; -u8 reserved_at_c0[0x1740 ]; +u8 packet_reformat_id[0x20 ]; +u8 reserved_at_e0[0x40 ]; +u8 encrypt_decrypt_obj_id[0x20 ]; +u8 reserved_at_140[0x16c0 ];/* Currently only one destnation */ union mlx5_ifc_dest_format_flow_counter_list_auto_bits destination[1 ]; };
drivers/net/mlx5/hws/mlx5dr_cmd.c +38 -28
124 lines not on this page · raw message
drivers/net/mlx5/hws/mlx5dr_cmd.h +21 -7
@@ -5,6 +5,13 @@ #ifndef MLX5DR_CMD_H_ #define MLX5DR_CMD_H_ +struct mlx5dr_cmd_set_fte_attr { + uint32_t action_flags; + uint8_t destination_type; + uint32_t destination_id; + uint8_t flow_source; +}; + struct mlx5dr_cmd_ft_create_attr { uint8_t type; uint8_t level;
@@ -263,6 +270,20 @@ mlx5dr_cmd_header_modify_pattern_create(struct ibv_context *ctx,uint32_t pattern_length, uint8_t *actions); +struct mlx5dr_devx_obj * +mlx5dr_cmd_set_fte (struct ibv_context *ctx, +uint32_t table_type, +uint32_t table_id, +uint32_t group_id, +struct mlx5dr_cmd_set_fte_attr *fte_attr); + +struct mlx5dr_cmd_forward_tbl * +mlx5dr_cmd_forward_tbl_create (struct ibv_context *ctx, +struct mlx5dr_cmd_ft_create_attr *ft_attr, +struct mlx5dr_cmd_set_fte_attr *fte_attr); + +void mlx5dr_cmd_forward_tbl_destroy (struct mlx5dr_cmd_forward_tbl *tbl); +struct mlx5dr_devx_obj *mlx5dr_cmd_alias_obj_create (struct ibv_context *ctx,struct mlx5dr_cmd_alias_obj_create_attr *alias_attr);
@@ -275,13 +296,6 @@ int mlx5dr_cmd_query_ib_port(struct ibv_context *ctx,int mlx5dr_cmd_query_caps (struct ibv_context *ctx,struct mlx5dr_cmd_query_caps *caps); -void mlx5dr_cmd_miss_ft_destroy (struct mlx5dr_cmd_forward_tbl *tbl); - -struct mlx5dr_cmd_forward_tbl * -mlx5dr_cmd_miss_ft_create (struct ibv_context *ctx, -struct mlx5dr_cmd_ft_create_attr *ft_attr, -uint32_t vport); - void mlx5dr_cmd_set_attr_connect_miss_tbl(struct mlx5dr_context *ctx, uint32_t fw_ft_type, enum mlx5dr_table_type type,
drivers/net/mlx5/hws/mlx5dr_table.c +8 -4
@@ -20,6 +20,7 @@ static int mlx5dr_table_up_default_fdb_miss_tbl(struct mlx5dr_table *tbl) {struct mlx5dr_cmd_ft_create_attr ft_attr = {0 }; +struct mlx5dr_cmd_set_fte_attr fte_attr = {0 };struct mlx5dr_cmd_forward_tbl *default_miss;struct mlx5dr_context *ctx = tbl->ctx;uint8_t tbl_type = tbl->type;
@@ -40,8 +41,12 @@ mlx5dr_table_up_default_fdb_miss_tbl(struct mlx5dr_table *tbl)assert (ctx->caps->eswitch_manager); vport = ctx->caps->eswitch_manager_vport_number; - default_miss =mlx5dr_cmd_miss_ft_create (mlx5dr_context_get_local_ibv (ctx), - &ft_attr, vport); + fte_attr.action_flags =MLX5_FLOW_CONTEXT_ACTION_FWD_DEST ; + fte_attr.destination_type =MLX5_FLOW_DESTINATION_TYPE_VPORT ; + fte_attr.destination_id = vport; + + default_miss =mlx5dr_cmd_forward_tbl_create (mlx5dr_context_get_local_ibv (ctx), + &ft_attr, &fte_attr);if (!default_miss) {DR_LOG (ERR ,"Failed to default miss table type: 0x%x" , tbl_type);return rte_errno;
@@ -66,9 +71,8 @@ static void mlx5dr_table_down_default_fdb_miss_tbl(struct mlx5dr_table *tbl)if (--default_miss->refcount)return ; -mlx5dr_cmd_miss_ft_destroy (default_miss); +mlx5dr_cmd_forward_tbl_destroy (default_miss); -simple_free (default_miss); ctx->common_res[tbl_type].default_miss =NULL ; }
Signature · 1 line
2.26.3
From: Hamdan Igbaria
Quoted 6 lines
Add support for dest root table action creation.
This support will allow to redirect the packets to the kernel from non root tables.Signed-off-by Hamdan Igbaria <[email protected]>Reviewed-by Alex Vesker <[email protected]>
Hi,
Quoted 11 lines
-----Original Message-----
From: Hamdan Igbaria <[email protected]>
Sent: Monday, March 20, 2023 4:12 PM
To: Hamdan Igbaria <[email protected]>; Slava Ovsiienko <[email protected]>; NBU-Contact-Thomas Monjalon (EXTERNAL) <[email protected]>; Suanming Mou <[email protected]>; Matan Azrad <[email protected]>
Cc: [email protected]; Ori Kam <[email protected]>; Alex Vesker <[email protected]>
Subject: [v1 1/3]net/mlx5/hws: support dest root table action
Quoted 6 lines
Add support for dest root table action creation.
This support will allow to redirect the packets to the kernel from non root tables.Signed-off-by Hamdan Igbaria <[email protected]>Reviewed-by Alex Vesker <[email protected]>
Series applied to next-net-mlx,
Kindest regards,
Raslan Darawsheh