diff options
author | Or Gerlitz <ogerlitz@mellanox.com> | 2018-01-28 13:14:20 -0500 |
---|---|---|
committer | Saeed Mahameed <saeedm@mellanox.com> | 2018-03-26 16:47:13 -0400 |
commit | 0c06897a9ac7e2db9ad2df15bc6511e8ab88378f (patch) | |
tree | e5e660c913d41cfe1d1765ca6b89f10987071536 | |
parent | aa24670ef66cb38e667d7bb039f5ce29d926f2e0 (diff) |
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>
-rw-r--r-- | drivers/net/ethernet/mellanox/mlx5/core/diag/fs_tracepoint.h | 2 | ||||
-rw-r--r-- | drivers/net/ethernet/mellanox/mlx5/core/eswitch.h | 3 | ||||
-rw-r--r-- | drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c | 10 | ||||
-rw-r--r-- | drivers/net/ethernet/mellanox/mlx5/core/fs_core.c | 4 | ||||
-rw-r--r-- | include/linux/mlx5/fs.h | 7 | ||||
-rw-r--r-- | include/linux/mlx5/mlx5_ifc.h | 16 |
6 files changed, 35 insertions, 7 deletions
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/diag/fs_tracepoint.h b/drivers/net/ethernet/mellanox/mlx5/core/diag/fs_tracepoint.h index a6ba57fbb414..09f178a3fcab 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/diag/fs_tracepoint.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/diag/fs_tracepoint.h | |||
@@ -136,6 +136,8 @@ TRACE_EVENT(mlx5_fs_del_fg, | |||
136 | {MLX5_FLOW_CONTEXT_ACTION_ENCAP, "ENCAP"},\ | 136 | {MLX5_FLOW_CONTEXT_ACTION_ENCAP, "ENCAP"},\ |
137 | {MLX5_FLOW_CONTEXT_ACTION_DECAP, "DECAP"},\ | 137 | {MLX5_FLOW_CONTEXT_ACTION_DECAP, "DECAP"},\ |
138 | {MLX5_FLOW_CONTEXT_ACTION_MOD_HDR, "MOD_HDR"},\ | 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 | {MLX5_FLOW_CONTEXT_ACTION_FWD_NEXT_PRIO, "NEXT_PRIO"} | 141 | {MLX5_FLOW_CONTEXT_ACTION_FWD_NEXT_PRIO, "NEXT_PRIO"} |
140 | 142 | ||
141 | TRACE_EVENT(mlx5_fs_set_fte, | 143 | TRACE_EVENT(mlx5_fs_set_fte, |
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h index 98d2177d0806..a435eb7971c6 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h | |||
@@ -227,9 +227,6 @@ enum { | |||
227 | SET_VLAN_INSERT = BIT(1) | 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 | struct mlx5_esw_flow_attr { | 230 | struct mlx5_esw_flow_attr { |
234 | struct mlx5_eswitch_rep *in_rep; | 231 | struct mlx5_eswitch_rep *in_rep; |
235 | struct mlx5_eswitch_rep *out_rep; | 232 | struct mlx5_eswitch_rep *out_rep; |
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c b/drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c index 645f83cac34d..ef5afd7c9325 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c | |||
@@ -317,7 +317,7 @@ static int mlx5_cmd_set_fte(struct mlx5_core_dev *dev, | |||
317 | fte->dests_size * MLX5_ST_SZ_BYTES(dest_format_struct); | 317 | fte->dests_size * MLX5_ST_SZ_BYTES(dest_format_struct); |
318 | u32 out[MLX5_ST_SZ_DW(set_fte_out)] = {0}; | 318 | u32 out[MLX5_ST_SZ_DW(set_fte_out)] = {0}; |
319 | struct mlx5_flow_rule *dst; | 319 | struct mlx5_flow_rule *dst; |
320 | void *in_flow_context; | 320 | void *in_flow_context, *vlan; |
321 | void *in_match_value; | 321 | void *in_match_value; |
322 | void *in_dests; | 322 | void *in_dests; |
323 | u32 *in; | 323 | u32 *in; |
@@ -340,11 +340,19 @@ static int mlx5_cmd_set_fte(struct mlx5_core_dev *dev, | |||
340 | 340 | ||
341 | in_flow_context = MLX5_ADDR_OF(set_fte_in, in, flow_context); | 341 | in_flow_context = MLX5_ADDR_OF(set_fte_in, in, flow_context); |
342 | MLX5_SET(flow_context, in_flow_context, group_id, group_id); | 342 | MLX5_SET(flow_context, in_flow_context, group_id, group_id); |
343 | |||
343 | MLX5_SET(flow_context, in_flow_context, flow_tag, fte->action.flow_tag); | 344 | MLX5_SET(flow_context, in_flow_context, flow_tag, fte->action.flow_tag); |
344 | MLX5_SET(flow_context, in_flow_context, action, fte->action.action); | 345 | MLX5_SET(flow_context, in_flow_context, action, fte->action.action); |
345 | MLX5_SET(flow_context, in_flow_context, encap_id, fte->action.encap_id); | 346 | MLX5_SET(flow_context, in_flow_context, encap_id, fte->action.encap_id); |
346 | MLX5_SET(flow_context, in_flow_context, modify_header_id, | 347 | MLX5_SET(flow_context, in_flow_context, modify_header_id, |
347 | fte->action.modify_id); | 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 | in_match_value = MLX5_ADDR_OF(flow_context, in_flow_context, | 356 | in_match_value = MLX5_ADDR_OF(flow_context, in_flow_context, |
349 | match_value); | 357 | match_value); |
350 | memcpy(in_match_value, &fte->val, sizeof(fte->val)); | 358 | memcpy(in_match_value, &fte->val, sizeof(fte->val)); |
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c b/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c index 3ba07c7096ef..de51e7c39bc8 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c | |||
@@ -1439,7 +1439,9 @@ static bool check_conflicting_actions(u32 action1, u32 action2) | |||
1439 | if (xored_actions & (MLX5_FLOW_CONTEXT_ACTION_DROP | | 1439 | if (xored_actions & (MLX5_FLOW_CONTEXT_ACTION_DROP | |
1440 | MLX5_FLOW_CONTEXT_ACTION_ENCAP | | 1440 | MLX5_FLOW_CONTEXT_ACTION_ENCAP | |
1441 | MLX5_FLOW_CONTEXT_ACTION_DECAP | | 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 | return true; | 1445 | return true; |
1444 | 1446 | ||
1445 | return false; | 1447 | return false; |
diff --git a/include/linux/mlx5/fs.h b/include/linux/mlx5/fs.h index b957e52434f8..47aecc4fa8c2 100644 --- a/include/linux/mlx5/fs.h +++ b/include/linux/mlx5/fs.h | |||
@@ -142,6 +142,12 @@ struct mlx5_flow_group * | |||
142 | mlx5_create_flow_group(struct mlx5_flow_table *ft, u32 *in); | 142 | mlx5_create_flow_group(struct mlx5_flow_table *ft, u32 *in); |
143 | void mlx5_destroy_flow_group(struct mlx5_flow_group *fg); | 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 | struct mlx5_flow_act { | 151 | struct mlx5_flow_act { |
146 | u32 action; | 152 | u32 action; |
147 | bool has_flow_tag; | 153 | bool has_flow_tag; |
@@ -149,6 +155,7 @@ struct mlx5_flow_act { | |||
149 | u32 encap_id; | 155 | u32 encap_id; |
150 | u32 modify_id; | 156 | u32 modify_id; |
151 | uintptr_t esp_id; | 157 | uintptr_t esp_id; |
158 | struct mlx5_fs_vlan vlan; | ||
152 | }; | 159 | }; |
153 | 160 | ||
154 | #define MLX5_DECLARE_FLOW_ACT(name) \ | 161 | #define MLX5_DECLARE_FLOW_ACT(name) \ |
diff --git a/include/linux/mlx5/mlx5_ifc.h b/include/linux/mlx5/mlx5_ifc.h index 1f3483d40055..c19e611d2782 100644 --- a/include/linux/mlx5/mlx5_ifc.h +++ b/include/linux/mlx5/mlx5_ifc.h | |||
@@ -314,7 +314,10 @@ struct mlx5_ifc_flow_table_prop_layout_bits { | |||
314 | u8 flow_table_modify[0x1]; | 314 | u8 flow_table_modify[0x1]; |
315 | u8 encap[0x1]; | 315 | u8 encap[0x1]; |
316 | u8 decap[0x1]; | 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 | u8 reserved_at_20[0x2]; | 322 | u8 reserved_at_20[0x2]; |
320 | u8 log_max_ft_size[0x6]; | 323 | u8 log_max_ft_size[0x6]; |
@@ -2311,10 +2314,19 @@ enum { | |||
2311 | MLX5_FLOW_CONTEXT_ACTION_ENCAP = 0x10, | 2314 | MLX5_FLOW_CONTEXT_ACTION_ENCAP = 0x10, |
2312 | MLX5_FLOW_CONTEXT_ACTION_DECAP = 0x20, | 2315 | MLX5_FLOW_CONTEXT_ACTION_DECAP = 0x20, |
2313 | MLX5_FLOW_CONTEXT_ACTION_MOD_HDR = 0x40, | 2316 | MLX5_FLOW_CONTEXT_ACTION_MOD_HDR = 0x40, |
2317 | MLX5_FLOW_CONTEXT_ACTION_VLAN_POP = 0x80, | ||
2318 | MLX5_FLOW_CONTEXT_ACTION_VLAN_PUSH = 0x100, | ||
2319 | }; | ||
2320 | |||
2321 | struct mlx5_ifc_vlan_bits { | ||
2322 | u8 ethtype[0x10]; | ||
2323 | u8 prio[0x3]; | ||
2324 | u8 cfi[0x1]; | ||
2325 | u8 vid[0xc]; | ||
2314 | }; | 2326 | }; |
2315 | 2327 | ||
2316 | struct mlx5_ifc_flow_context_bits { | 2328 | struct mlx5_ifc_flow_context_bits { |
2317 | u8 reserved_at_0[0x20]; | 2329 | struct mlx5_ifc_vlan_bits push_vlan; |
2318 | 2330 | ||
2319 | u8 group_id[0x20]; | 2331 | u8 group_id[0x20]; |
2320 | 2332 | ||