Skip to content

Commit 2a69cb9

Browse files
ogerlitzSaeed Mahameed
authored andcommitted
net/mlx5: Introduce modify header structures, commands and steering action definitions
Add the definitions related to creation/deletion of a modify header context and the modify header steering action which are used for HW packet header modify (re-write) as part of steering. Add as well the modify header id into two intermediate structs and set it to the FTE. Note that as the push/pop vlan steering actions are emulated by the ewitch management code, we're not breaking any compatibility while changing their values to make room for the modify header action which is not emulated and whose value is part of the FW API. The new bit values for the emulated actions are at the end of the possible range. Signed-off-by: Or Gerlitz <[email protected]> Reviewed-by: Hadar Hen Zion <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]>
1 parent a750276 commit 2a69cb9

File tree

6 files changed

+118
-5
lines changed

6 files changed

+118
-5
lines changed

drivers/net/ethernet/mellanox/mlx5/core/eswitch.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,8 +285,8 @@ enum {
285285
SET_VLAN_INSERT = BIT(1)
286286
};
287287

288-
#define MLX5_FLOW_CONTEXT_ACTION_VLAN_POP 0x40
289-
#define MLX5_FLOW_CONTEXT_ACTION_VLAN_PUSH 0x80
288+
#define MLX5_FLOW_CONTEXT_ACTION_VLAN_POP 0x4000
289+
#define MLX5_FLOW_CONTEXT_ACTION_VLAN_PUSH 0x8000
290290

291291
struct mlx5_encap_entry {
292292
struct hlist_node encap_hlist;

drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ static int mlx5_cmd_set_fte(struct mlx5_core_dev *dev,
249249
MLX5_SET(flow_context, in_flow_context, flow_tag, fte->flow_tag);
250250
MLX5_SET(flow_context, in_flow_context, action, fte->action);
251251
MLX5_SET(flow_context, in_flow_context, encap_id, fte->encap_id);
252+
MLX5_SET(flow_context, in_flow_context, modify_header_id, fte->modify_id);
252253
in_match_value = MLX5_ADDR_OF(flow_context, in_flow_context,
253254
match_value);
254255
memcpy(in_match_value, &fte->val, MLX5_ST_SZ_BYTES(fte_match_param));

drivers/net/ethernet/mellanox/mlx5/core/fs_core.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,7 @@ static struct fs_fte *alloc_fte(struct mlx5_flow_act *flow_act,
476476
fte->index = index;
477477
fte->action = flow_act->action;
478478
fte->encap_id = flow_act->encap_id;
479+
fte->modify_id = flow_act->modify_id;
479480

480481
return fte;
481482
}

drivers/net/ethernet/mellanox/mlx5/core/fs_core.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ struct fs_fte {
152152
u32 index;
153153
u32 action;
154154
u32 encap_id;
155+
u32 modify_id;
155156
enum fs_fte_status status;
156157
struct mlx5_fc *counter;
157158
};

include/linux/mlx5/fs.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,12 @@ struct mlx5_flow_act {
134134
u32 action;
135135
u32 flow_tag;
136136
u32 encap_id;
137+
u32 modify_id;
137138
};
138139

139140
#define MLX5_DECLARE_FLOW_ACT(name) \
140141
struct mlx5_flow_act name = {MLX5_FLOW_CONTEXT_ACTION_FWD_DEST,\
141-
MLX5_FS_DEFAULT_FLOW_TAG, 0}
142+
MLX5_FS_DEFAULT_FLOW_TAG, 0, 0}
142143

143144
/* Single destination per rule.
144145
* Group ID is implied by the match criteria.

include/linux/mlx5/mlx5_ifc.h

Lines changed: 111 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,8 @@ enum {
227227
MLX5_CMD_OP_MODIFY_FLOW_TABLE = 0x93c,
228228
MLX5_CMD_OP_ALLOC_ENCAP_HEADER = 0x93d,
229229
MLX5_CMD_OP_DEALLOC_ENCAP_HEADER = 0x93e,
230+
MLX5_CMD_OP_ALLOC_MODIFY_HEADER_CONTEXT = 0x940,
231+
MLX5_CMD_OP_DEALLOC_MODIFY_HEADER_CONTEXT = 0x941,
230232
MLX5_CMD_OP_MAX
231233
};
232234

@@ -302,7 +304,8 @@ struct mlx5_ifc_flow_table_prop_layout_bits {
302304

303305
u8 reserved_at_20[0x2];
304306
u8 log_max_ft_size[0x6];
305-
u8 reserved_at_28[0x10];
307+
u8 log_max_modify_header_context[0x8];
308+
u8 max_modify_header_actions[0x8];
306309
u8 max_ft_level[0x8];
307310

308311
u8 reserved_at_40[0x20];
@@ -2190,6 +2193,7 @@ enum {
21902193
MLX5_FLOW_CONTEXT_ACTION_COUNT = 0x8,
21912194
MLX5_FLOW_CONTEXT_ACTION_ENCAP = 0x10,
21922195
MLX5_FLOW_CONTEXT_ACTION_DECAP = 0x20,
2196+
MLX5_FLOW_CONTEXT_ACTION_MOD_HDR = 0x40,
21932197
};
21942198

21952199
struct mlx5_ifc_flow_context_bits {
@@ -2211,7 +2215,9 @@ struct mlx5_ifc_flow_context_bits {
22112215

22122216
u8 encap_id[0x20];
22132217

2214-
u8 reserved_at_e0[0x120];
2218+
u8 modify_header_id[0x20];
2219+
2220+
u8 reserved_at_100[0x100];
22152221

22162222
struct mlx5_ifc_fte_match_param_bits match_value;
22172223

@@ -4534,6 +4540,109 @@ struct mlx5_ifc_dealloc_encap_header_in_bits {
45344540
u8 reserved_60[0x20];
45354541
};
45364542

4543+
struct mlx5_ifc_set_action_in_bits {
4544+
u8 action_type[0x4];
4545+
u8 field[0xc];
4546+
u8 reserved_at_10[0x3];
4547+
u8 offset[0x5];
4548+
u8 reserved_at_18[0x3];
4549+
u8 length[0x5];
4550+
4551+
u8 data[0x20];
4552+
};
4553+
4554+
struct mlx5_ifc_add_action_in_bits {
4555+
u8 action_type[0x4];
4556+
u8 field[0xc];
4557+
u8 reserved_at_10[0x10];
4558+
4559+
u8 data[0x20];
4560+
};
4561+
4562+
union mlx5_ifc_set_action_in_add_action_in_auto_bits {
4563+
struct mlx5_ifc_set_action_in_bits set_action_in;
4564+
struct mlx5_ifc_add_action_in_bits add_action_in;
4565+
u8 reserved_at_0[0x40];
4566+
};
4567+
4568+
enum {
4569+
MLX5_ACTION_TYPE_SET = 0x1,
4570+
MLX5_ACTION_TYPE_ADD = 0x2,
4571+
};
4572+
4573+
enum {
4574+
MLX5_ACTION_IN_FIELD_OUT_SMAC_47_16 = 0x1,
4575+
MLX5_ACTION_IN_FIELD_OUT_SMAC_15_0 = 0x2,
4576+
MLX5_ACTION_IN_FIELD_OUT_ETHERTYPE = 0x3,
4577+
MLX5_ACTION_IN_FIELD_OUT_DMAC_47_16 = 0x4,
4578+
MLX5_ACTION_IN_FIELD_OUT_DMAC_15_0 = 0x5,
4579+
MLX5_ACTION_IN_FIELD_OUT_IP_DSCP = 0x6,
4580+
MLX5_ACTION_IN_FIELD_OUT_TCP_FLAGS = 0x7,
4581+
MLX5_ACTION_IN_FIELD_OUT_TCP_SPORT = 0x8,
4582+
MLX5_ACTION_IN_FIELD_OUT_TCP_DPORT = 0x9,
4583+
MLX5_ACTION_IN_FIELD_OUT_IP_TTL = 0xa,
4584+
MLX5_ACTION_IN_FIELD_OUT_UDP_SPORT = 0xb,
4585+
MLX5_ACTION_IN_FIELD_OUT_UDP_DPORT = 0xc,
4586+
MLX5_ACTION_IN_FIELD_OUT_SIPV6_127_96 = 0xd,
4587+
MLX5_ACTION_IN_FIELD_OUT_SIPV6_95_64 = 0xe,
4588+
MLX5_ACTION_IN_FIELD_OUT_SIPV6_63_32 = 0xf,
4589+
MLX5_ACTION_IN_FIELD_OUT_SIPV6_31_0 = 0x10,
4590+
MLX5_ACTION_IN_FIELD_OUT_DIPV6_127_96 = 0x11,
4591+
MLX5_ACTION_IN_FIELD_OUT_DIPV6_95_64 = 0x12,
4592+
MLX5_ACTION_IN_FIELD_OUT_DIPV6_63_32 = 0x13,
4593+
MLX5_ACTION_IN_FIELD_OUT_DIPV6_31_0 = 0x14,
4594+
MLX5_ACTION_IN_FIELD_OUT_SIPV4 = 0x15,
4595+
MLX5_ACTION_IN_FIELD_OUT_DIPV4 = 0x16,
4596+
};
4597+
4598+
struct mlx5_ifc_alloc_modify_header_context_out_bits {
4599+
u8 status[0x8];
4600+
u8 reserved_at_8[0x18];
4601+
4602+
u8 syndrome[0x20];
4603+
4604+
u8 modify_header_id[0x20];
4605+
4606+
u8 reserved_at_60[0x20];
4607+
};
4608+
4609+
struct mlx5_ifc_alloc_modify_header_context_in_bits {
4610+
u8 opcode[0x10];
4611+
u8 reserved_at_10[0x10];
4612+
4613+
u8 reserved_at_20[0x10];
4614+
u8 op_mod[0x10];
4615+
4616+
u8 reserved_at_40[0x20];
4617+
4618+
u8 table_type[0x8];
4619+
u8 reserved_at_68[0x10];
4620+
u8 num_of_actions[0x8];
4621+
4622+
union mlx5_ifc_set_action_in_add_action_in_auto_bits actions[0];
4623+
};
4624+
4625+
struct mlx5_ifc_dealloc_modify_header_context_out_bits {
4626+
u8 status[0x8];
4627+
u8 reserved_at_8[0x18];
4628+
4629+
u8 syndrome[0x20];
4630+
4631+
u8 reserved_at_40[0x40];
4632+
};
4633+
4634+
struct mlx5_ifc_dealloc_modify_header_context_in_bits {
4635+
u8 opcode[0x10];
4636+
u8 reserved_at_10[0x10];
4637+
4638+
u8 reserved_at_20[0x10];
4639+
u8 op_mod[0x10];
4640+
4641+
u8 modify_header_id[0x20];
4642+
4643+
u8 reserved_at_60[0x20];
4644+
};
4645+
45374646
struct mlx5_ifc_query_dct_out_bits {
45384647
u8 status[0x8];
45394648
u8 reserved_at_8[0x18];

0 commit comments

Comments
 (0)