Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net/mlx5: Add core support for vlan push/pop steering action

Newer NICs (ConnectX-5 and onward) can apply vlan pop or push as an
action taking place during flow steering. Add the core bits for that.

Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com>
Reviewed-by: Mark Bloch <markb@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>

authored by

Or Gerlitz and committed by
Saeed Mahameed
0c06897a aa24670e

+35 -7
+2
drivers/net/ethernet/mellanox/mlx5/core/diag/fs_tracepoint.h
··· 136 136 {MLX5_FLOW_CONTEXT_ACTION_ENCAP, "ENCAP"},\ 137 137 {MLX5_FLOW_CONTEXT_ACTION_DECAP, "DECAP"},\ 138 138 {MLX5_FLOW_CONTEXT_ACTION_MOD_HDR, "MOD_HDR"},\ 139 + {MLX5_FLOW_CONTEXT_ACTION_VLAN_PUSH, "VLAN_PUSH"},\ 140 + {MLX5_FLOW_CONTEXT_ACTION_VLAN_POP, "VLAN_POP"},\ 139 141 {MLX5_FLOW_CONTEXT_ACTION_FWD_NEXT_PRIO, "NEXT_PRIO"} 140 142 141 143 TRACE_EVENT(mlx5_fs_set_fte,
-3
drivers/net/ethernet/mellanox/mlx5/core/eswitch.h
··· 227 227 SET_VLAN_INSERT = BIT(1) 228 228 }; 229 229 230 - #define MLX5_FLOW_CONTEXT_ACTION_VLAN_POP 0x4000 231 - #define MLX5_FLOW_CONTEXT_ACTION_VLAN_PUSH 0x8000 232 - 233 230 struct mlx5_esw_flow_attr { 234 231 struct mlx5_eswitch_rep *in_rep; 235 232 struct mlx5_eswitch_rep *out_rep;
+9 -1
drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c
··· 317 317 fte->dests_size * MLX5_ST_SZ_BYTES(dest_format_struct); 318 318 u32 out[MLX5_ST_SZ_DW(set_fte_out)] = {0}; 319 319 struct mlx5_flow_rule *dst; 320 - void *in_flow_context; 320 + void *in_flow_context, *vlan; 321 321 void *in_match_value; 322 322 void *in_dests; 323 323 u32 *in; ··· 340 340 341 341 in_flow_context = MLX5_ADDR_OF(set_fte_in, in, flow_context); 342 342 MLX5_SET(flow_context, in_flow_context, group_id, group_id); 343 + 343 344 MLX5_SET(flow_context, in_flow_context, flow_tag, fte->action.flow_tag); 344 345 MLX5_SET(flow_context, in_flow_context, action, fte->action.action); 345 346 MLX5_SET(flow_context, in_flow_context, encap_id, fte->action.encap_id); 346 347 MLX5_SET(flow_context, in_flow_context, modify_header_id, 347 348 fte->action.modify_id); 349 + 350 + vlan = MLX5_ADDR_OF(flow_context, in_flow_context, push_vlan); 351 + 352 + MLX5_SET(vlan, vlan, ethtype, fte->action.vlan.ethtype); 353 + MLX5_SET(vlan, vlan, vid, fte->action.vlan.vid); 354 + MLX5_SET(vlan, vlan, prio, fte->action.vlan.prio); 355 + 348 356 in_match_value = MLX5_ADDR_OF(flow_context, in_flow_context, 349 357 match_value); 350 358 memcpy(in_match_value, &fte->val, sizeof(fte->val));
+3 -1
drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
··· 1439 1439 if (xored_actions & (MLX5_FLOW_CONTEXT_ACTION_DROP | 1440 1440 MLX5_FLOW_CONTEXT_ACTION_ENCAP | 1441 1441 MLX5_FLOW_CONTEXT_ACTION_DECAP | 1442 - MLX5_FLOW_CONTEXT_ACTION_MOD_HDR)) 1442 + MLX5_FLOW_CONTEXT_ACTION_MOD_HDR | 1443 + MLX5_FLOW_CONTEXT_ACTION_VLAN_POP | 1444 + MLX5_FLOW_CONTEXT_ACTION_VLAN_PUSH)) 1443 1445 return true; 1444 1446 1445 1447 return false;
+7
include/linux/mlx5/fs.h
··· 142 142 mlx5_create_flow_group(struct mlx5_flow_table *ft, u32 *in); 143 143 void mlx5_destroy_flow_group(struct mlx5_flow_group *fg); 144 144 145 + struct mlx5_fs_vlan { 146 + u16 ethtype; 147 + u16 vid; 148 + u8 prio; 149 + }; 150 + 145 151 struct mlx5_flow_act { 146 152 u32 action; 147 153 bool has_flow_tag; ··· 155 149 u32 encap_id; 156 150 u32 modify_id; 157 151 uintptr_t esp_id; 152 + struct mlx5_fs_vlan vlan; 158 153 }; 159 154 160 155 #define MLX5_DECLARE_FLOW_ACT(name) \
+14 -2
include/linux/mlx5/mlx5_ifc.h
··· 314 314 u8 flow_table_modify[0x1]; 315 315 u8 encap[0x1]; 316 316 u8 decap[0x1]; 317 - u8 reserved_at_9[0x17]; 317 + u8 reserved_at_9[0x1]; 318 + u8 pop_vlan[0x1]; 319 + u8 push_vlan[0x1]; 320 + u8 reserved_at_c[0x14]; 318 321 319 322 u8 reserved_at_20[0x2]; 320 323 u8 log_max_ft_size[0x6]; ··· 2314 2311 MLX5_FLOW_CONTEXT_ACTION_ENCAP = 0x10, 2315 2312 MLX5_FLOW_CONTEXT_ACTION_DECAP = 0x20, 2316 2313 MLX5_FLOW_CONTEXT_ACTION_MOD_HDR = 0x40, 2314 + MLX5_FLOW_CONTEXT_ACTION_VLAN_POP = 0x80, 2315 + MLX5_FLOW_CONTEXT_ACTION_VLAN_PUSH = 0x100, 2316 + }; 2317 + 2318 + struct mlx5_ifc_vlan_bits { 2319 + u8 ethtype[0x10]; 2320 + u8 prio[0x3]; 2321 + u8 cfi[0x1]; 2322 + u8 vid[0xc]; 2317 2323 }; 2318 2324 2319 2325 struct mlx5_ifc_flow_context_bits { 2320 - u8 reserved_at_0[0x20]; 2326 + struct mlx5_ifc_vlan_bits push_vlan; 2321 2327 2322 2328 u8 group_id[0x20]; 2323 2329