Add HWS mirroring support
cover Add HWS mirroring support
This patch series are to add the support of mirroring feature in HWS. The main idea is to create DevX Flow table and FTE in it. The FTE may have multiple different destinations of type Vport/TIR/Table. With this multi-destination FTE, NIC can duplicate packets and forward to all destinations.
Hamdan Igbaria (2):
net/mlx5/hws: add creation of packet reformat DevX obj net/mlx5/hws: add mlx5dr obj struct to mlx5dr action
Shun Hao (1):
net/mlx5/hws: add support for mirroring
drivers/common/mlx5/mlx5_prm.h | 62 +++++++++++- drivers/net/mlx5/hws/mlx5dr.h | 34 +++++++ drivers/net/mlx5/hws/mlx5dr_action.c | 134 ++++++++++++++++++++++++- drivers/net/mlx5/hws/mlx5dr_action.h | 6 ++ drivers/net/mlx5/hws/mlx5dr_cmd.c | 123 +++++++++++++++++++++-- drivers/net/mlx5/hws/mlx5dr_cmd.h | 30 +++++- drivers/net/mlx5/hws/mlx5dr_debug.c | 1 + drivers/net/mlx5/hws/mlx5dr_internal.h | 5 + drivers/net/mlx5/hws/mlx5dr_send.c | 5 - drivers/net/mlx5/hws/mlx5dr_table.c | 8 +- 10 files changed, 384 insertions(+), 24 deletions(-)
Signature · 1 line
2.20.0
PATCH 1/3 net/mlx5/hws: add creation of packet reformat DevX obj
From: Hamdan Igbaria <[email protected]>
Add support for creation of packet reformat object, via the ALLOC_PACKET_REFORMAT_CONTEXT command.
--- drivers/common/mlx5/mlx5_prm.h | 39 +++++++++++++++++ drivers/net/mlx5/hws/mlx5dr_cmd.c | 60 ++++++++++++++++++++++++++ drivers/net/mlx5/hws/mlx5dr_cmd.h | 11 +++++ drivers/net/mlx5/hws/mlx5dr_internal.h | 5 +++ drivers/net/mlx5/hws/mlx5dr_send.c | 5 --- 5 files changed, 115 insertions(+), 5 deletions(-)
drivers/common/mlx5/mlx5_prm.h +39 -0
@@ -1213,6 +1213,8 @@ enum {MLX5_CMD_OP_CREATE_FLOW_GROUP =0x933 ,MLX5_CMD_OP_SET_FLOW_TABLE_ENTRY =0x936 ,MLX5_CMD_OP_MODIFY_FLOW_TABLE =0x93c , +MLX5_CMD_OP_ALLOC_PACKET_REFORMAT_CONTEXT =0x93d , +MLX5_CMD_OP_DEALLOC_PACKET_REFORMAT_CONTEXT =0x93e ,MLX5_CMD_OP_ALLOC_FLOW_COUNTER =0x939 ,MLX5_CMD_OP_QUERY_FLOW_COUNTER =0x93b , MLX5_CMD_OP_CREATE_GENERAL_OBJECT = 0xa00,
@@ -5180,6 +5182,43 @@ struct mlx5_ifc_modify_flow_table_out_bits {u8 reserved_at_40[0x60 ]; }; +struct mlx5_ifc_packet_reformat_context_in_bits { +u8 reformat_type[0x8 ]; +u8 reserved_at_8[0x4 ]; +u8 reformat_param_0[0x4 ]; +u8 reserved_at_16[0x6 ]; +u8 reformat_data_size[0xa ]; + +u8 reformat_param_1[0x8 ]; +u8 reserved_at_40[0x8 ]; +u8 reformat_data[6 ][0x8 ]; + +u8 more_reformat_data[][0x8 ]; +}; + +struct mlx5_ifc_alloc_packet_reformat_context_in_bits { +u8 opcode[0x10 ]; +u8 uid[0x10 ]; + +u8 reserved_at_20[0x10 ]; +u8 op_mod[0x10 ]; + +u8 reserved_at_40[0xa0 ]; + +u8 packet_reformat_context[]; +}; + +struct mlx5_ifc_alloc_packet_reformat_out_bits { +u8 status[0x8 ]; +u8 reserved_at_8[0x18 ]; + +u8 syndrome[0x20 ]; + +u8 packet_reformat_id[0x20 ]; + +u8 reserved_at_60[0x20 ]; +}; +/* CQE format mask. */ #define MLX5E_CQE_FORMAT_MASK 0xc
drivers/net/mlx5/hws/mlx5dr_cmd.c +60 -0
66 lines not on this page · raw message
drivers/net/mlx5/hws/mlx5dr_cmd.h +11 -0
@@ -155,6 +155,13 @@ struct mlx5dr_cmd_allow_other_vhca_access_attr {uint8_t access_key[ACCESS_KEY_LEN ]; }; +struct mlx5dr_cmd_packet_reformat_create_attr { +uint8_t type; +size_t data_sz; +void *data; +uint8_t reformat_param_0; +}; +struct mlx5dr_cmd_query_ft_caps {uint8_t max_level;uint8_t reparse;
@@ -270,6 +277,10 @@ mlx5dr_cmd_header_modify_pattern_create(struct ibv_context *ctx,uint32_t pattern_length, uint8_t *actions); +struct mlx5dr_devx_obj * +mlx5dr_cmd_packet_reformat_create (struct ibv_context *ctx, +struct mlx5dr_cmd_packet_reformat_create_attr *attr); +struct mlx5dr_devx_obj * mlx5dr_cmd_set_fte(struct ibv_context *ctx, uint32_t table_type,
drivers/net/mlx5/hws/mlx5dr_internal.h +5 -0
@@ -91,4 +91,9 @@ static inline uint64_t roundup_pow_of_two(uint64_t n) return n == 1 ? 1 : 1ULL << log2above(n); } +static inline unsigned long align (unsigned long val,unsigned long align) +{ +return (val + align -1 ) & ~(align -1 ); +} +#endif /* MLX5DR_INTERNAL_H_ */
drivers/net/mlx5/hws/mlx5dr_send.c +0 -5
@@ -668,11 +668,6 @@ static int mlx5dr_send_ring_create_sq_obj(struct mlx5dr_context *ctx,return err; } -static inline unsigned long align (unsigned long val,unsigned long align) -{ -return (val + align -1 ) & ~(align -1 ); -} - static int mlx5dr_send_ring_open_sq(struct mlx5dr_context *ctx, struct mlx5dr_send_engine *queue, struct mlx5dr_send_ring_sq *sq,
Signature · 1 line
2.20.0
PATCH 2/3 net/mlx5/hws: add mlx5dr obj struct to mlx5dr action
In reply to Shun HaoFrom: Hamdan Igbaria <[email protected]>
Add mlx5dr_devx_obj struct to mlx5dr_action, so we could hold the FT obj in dest table action.
--- drivers/net/mlx5/hws/mlx5dr_action.c | 2 ++ drivers/net/mlx5/hws/mlx5dr_action.h | 3 +++ drivers/net/mlx5/hws/mlx5dr_table.c | 1 - 3 files changed, 5 insertions(+), 1 deletion(-)
drivers/net/mlx5/hws/mlx5dr_action.c +2 -0
@@ -785,6 +785,8 @@ mlx5dr_action_create_dest_table(struct mlx5dr_context *ctx, ret =mlx5dr_action_create_stcs (action, tbl->ft);if (ret) goto free_action; + + action->devx_dest.devx_obj = tbl->ft; }return action;
drivers/net/mlx5/hws/mlx5dr_action.h +3 -0
@@ -148,6 +148,9 @@ struct mlx5dr_action {struct {struct mlx5dv_steering_anchor *sa; } root_tbl; +struct { +struct mlx5dr_devx_obj *devx_obj; + } devx_dest; }; };
drivers/net/mlx5/hws/mlx5dr_table.c +0 -1
@@ -68,7 +68,6 @@ static void mlx5dr_table_down_default_fdb_miss_tbl(struct mlx5dr_table *tbl)return ;mlx5dr_cmd_forward_tbl_destroy (default_miss); - ctx->common_res[tbl_type].default_miss =NULL ; }
Signature · 1 line
2.20.0
PATCH 3/3 net/mlx5/hws: add support for mirroring
In reply to Shun HaoThis patch supports mirroring by adding an dest_array action. The action accecpts a list containing multiple destination actions, and can duplicate packet and forward to each destination in the list.
--- drivers/common/mlx5/mlx5_prm.h | 23 ++++- drivers/net/mlx5/hws/mlx5dr.h | 34 +++++++ drivers/net/mlx5/hws/mlx5dr_action.c | 132 ++++++++++++++++++++++++++- drivers/net/mlx5/hws/mlx5dr_action.h | 3 + drivers/net/mlx5/hws/mlx5dr_cmd.c | 63 +++++++++++-- drivers/net/mlx5/hws/mlx5dr_cmd.h | 19 +++- drivers/net/mlx5/hws/mlx5dr_debug.c | 1 + drivers/net/mlx5/hws/mlx5dr_table.c | 7 +- 8 files changed, 264 insertions(+), 18 deletions(-)
drivers/common/mlx5/mlx5_prm.h +20 -3
@@ -2310,7 +2310,11 @@ struct mlx5_ifc_cmd_hca_cap_2_bits { };struct mlx5_ifc_esw_cap_bits { -u8 reserved_at_0[0x60 ]; +u8 reserved_at_0[0x1d ]; +u8 merged_eswitch[0x1 ]; +u8 reserved_at_1e[0x2 ]; + +u8 reserved_at_20[0x40 ];u8 esw_manager_vport_number_valid[0x1 ];u8 reserved_at_61[0xf ];
@@ -5034,6 +5038,7 @@ 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 , +MLX5_FLOW_DESTINATION_TYPE_TIR =0x2 , };enum mlx5_flow_context_action {
@@ -5073,6 +5078,19 @@ union mlx5_ifc_dest_format_flow_counter_list_auto_bits {u8 reserved_at_0[0x40 ]; }; +struct mlx5_ifc_extended_dest_format_bits { +struct mlx5_ifc_dest_format_bits destination_entry; + +u8 packet_reformat_id[0x20 ]; + +u8 reserved_at_60[0x20 ]; +}; + +#define MLX5_IFC_MULTI_PATH_FT_MAX_LEVEL 64 + +#ifdef PEDANTIC +#pragma GCC diagnostic ignored "-Wpedantic" +#endif struct mlx5_ifc_flow_context_bits {u8 reserved_at_00[0x20 ];u8 group_id[0x20 ];
@@ -5091,8 +5109,7 @@ struct mlx5_ifc_flow_context_bits {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 ]; +union mlx5_ifc_dest_format_flow_counter_list_auto_bits destination[0 ]; };struct mlx5_ifc_set_fte_in_bits {
drivers/net/mlx5/hws/mlx5dr.h +34 -0
@@ -46,6 +46,7 @@ enum mlx5dr_action_type {MLX5DR_ACTION_TYP_ASO_METER ,MLX5DR_ACTION_TYP_ASO_CT ,MLX5DR_ACTION_TYP_DEST_ROOT , +MLX5DR_ACTION_TYP_DEST_ARRAY , MLX5DR_ACTION_TYP_MAX, };
@@ -213,6 +214,20 @@ struct mlx5dr_rule_action { }; }; +struct mlx5dr_action_dest_attr { +/* Required action combination */ +enum mlx5dr_action_type *action_type; + +/* Required destination action to forward the packet */ +struct mlx5dr_action *dest; + +/* Optional reformat data */ +struct { +size_t reformat_data_sz; +void *reformat_data; + } reformat; +}; +/* Open a context used for direct rule insertion using hardware steering. * Each context can contain multiple tables of different types. *
@@ -604,6 +619,25 @@ 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 a dest array action, this action can duplicate packets and forward to +* multiple destinations in the destination list. +* @param[in] ctx +* The context in which the new action will be created. +* @param[in] num_dest +* The number of dests attributes. +* @param[in] dests +* The destination array. Each contains a destination action and can have +* additional actions. +* @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_array (struct mlx5dr_context *ctx, +size_t num_dest, +struct mlx5dr_action_dest_attr *dests, +uint32_t flags); +/* Create dest root table, this action will jump to root table according * the given priority. * @param[in] ctx
drivers/net/mlx5/hws/mlx5dr_action.c +130 -2
174 lines not on this page · raw message
drivers/net/mlx5/hws/mlx5dr_action.h +3 -0
@@ -151,6 +151,9 @@ struct mlx5dr_action {struct {struct mlx5dr_devx_obj *devx_obj; } devx_dest; +struct { +struct mlx5dr_cmd_forward_tbl *fw_island; + } dest_array; }; };
drivers/net/mlx5/hws/mlx5dr_cmd.c +54 -9
107 lines not on this page · raw message
drivers/net/mlx5/hws/mlx5dr_cmd.h +17 -2
@@ -5,11 +5,25 @@#ifndef MLX5DR_CMD_H_ #define MLX5DR_CMD_H_ -struct mlx5dr_cmd_set_fte_attr { -uint32_t action_flags; +enum mlx5dr_cmd_ext_dest_flags { +MLX5DR_CMD_EXT_DEST_REFORMAT =1 <<0 , +MLX5DR_CMD_EXT_DEST_ESW_OWNER_VHCA_ID =1 <<1 , +}; + +struct mlx5dr_cmd_set_fte_dest {uint8_t destination_type;uint32_t destination_id; +enum mlx5dr_cmd_ext_dest_flags ext_flags; +uint16_t esw_owner_vhca_id; +}; + +struct mlx5dr_cmd_set_fte_attr { +uint32_t action_flags; +uint8_t ignore_flow_level;uint8_t flow_source; +uint32_t packet_reformat_id; +uint32_t dests_num; +struct mlx5dr_cmd_set_fte_dest *dests; }; struct mlx5dr_cmd_ft_create_attr {
@@ -210,6 +224,7 @@ struct mlx5dr_cmd_query_caps {struct mlx5dr_cmd_query_ft_caps nic_ft;struct mlx5dr_cmd_query_ft_caps fdb_ft;bool eswitch_manager; +uint8_t merged_eswitch;uint32_t eswitch_manager_vport_number;uint8_t log_header_modify_argument_granularity;uint8_t log_header_modify_argument_max_alloc;
drivers/net/mlx5/hws/mlx5dr_debug.c +1 -0
@@ -23,6 +23,7 @@ const char *mlx5dr_debug_action_type_str[] = { [MLX5DR_ACTION_TYP_ASO_METER] = "ASO_METER", [MLX5DR_ACTION_TYP_ASO_CT] = "ASO_CT", [MLX5DR_ACTION_TYP_DEST_ROOT] = "DEST_ROOT", + [MLX5DR_ACTION_TYP_DEST_ARRAY ] ="DEST_ARRAY" , }; static_assert(ARRAY_SIZE(mlx5dr_debug_action_type_str) == MLX5DR_ACTION_TYP_MAX,
drivers/net/mlx5/hws/mlx5dr_table.c +5 -2
@@ -22,6 +22,7 @@ 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_cmd_set_fte_dest dest = {0 };struct mlx5dr_context *ctx = tbl->ctx;uint8_t tbl_type = tbl->type;
@@ -37,9 +38,11 @@ mlx5dr_table_up_default_fdb_miss_tbl(struct mlx5dr_table *tbl) ft_attr.level = tbl->ctx->caps->fdb_ft.max_level;/* The last level */ ft_attr.rtc_valid = false; + dest.destination_type =MLX5_FLOW_DESTINATION_TYPE_VPORT ; + dest.destination_id = ctx->caps->eswitch_manager_vport_number; fte_attr.action_flags =MLX5_FLOW_CONTEXT_ACTION_FWD_DEST ; - fte_attr.destination_type =MLX5_FLOW_DESTINATION_TYPE_VPORT ; - fte_attr.destination_id = ctx->caps->eswitch_manager_vport_number; + fte_attr.dests_num =1 ; + fte_attr.dests = &dest; default_miss =mlx5dr_cmd_forward_tbl_create (mlx5dr_context_get_local_ibv (ctx), &ft_attr, &fte_attr);
Signature · 1 line
2.20.0