mlx5 updates 2021-12-14
From: Saeed Mahameed <[email protected]>
Hi Dave, Hi Jakub,
This series provides refactoring to the TC actions parsing code we have in the driver to help improving driver structure and extensibility for future actions support.
For more information please see tag log below.
Please pull and let me know if there is any problem.
Thanks,
Saeed.
The following changes since commit 6cf7a1ac0fedad8a70c050ade8a27a2071638500:
Merge branch 'net-dsa-hellcreek-fix-handling-of-mgmt-protocols' (2021-12-14 18:46:31 -0800)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux.git tags/mlx5-updates-2021-12-14
for you to fetch changes up to 35bb5242148fa16fd5b2f28b508e0c031e90c672:
net/mlx5e: Move goto action checks into tc_action goto post parse op (2021-12-14 21:29:46 -0800)
----------------------------------------------------------------
mlx5-updates-2021-12-14
Parsing Infrastructure for TC actions:
The series introduce a TC action infrastructure to help parsing TC actions in a generic way for both FDB and NIC rules.
To help maintain the parsing code of TC actions, we the parsing code to action parser per action TC type in separate files, instead of having one big switch case loop, duplicated between FDB and NIC parsers as before this patchset.
Each TC flow_action->id is represented by a dedicated mlx5e_tc_act handler which has callbacks to check if the specific action is offload supported and to parse the specific action.
We move each case (TC action) handling into the specific handler, which is responsible for parsing and determining if the action is supported.
----------------------------------------------------------------
Roi Dayan (16):
net/mlx5e: Add tc action infrastructure
net/mlx5e: Add goto to tc action infra
net/mlx5e: Add tunnel encap/decap to tc action infra net/mlx5e: Add csum to tc action infra
net/mlx5e: Add pedit to tc action infra
net/mlx5e: Add vlan push/pop/mangle to tc action infra net/mlx5e: Add mpls push/pop to tc action infra net/mlx5e: Add mirred/redirect to tc action infra net/mlx5e: Add ct to tc action infra
net/mlx5e: Add sample and ptype to tc_action infra net/mlx5e: Add redirect ingress to tc action infra net/mlx5e: TC action parsing loop
net/mlx5e: Move sample attr allocation to tc_action sample parse op net/mlx5e: Add post_parse() op to tc action infrastructure net/mlx5e: Move vlan action chunk into tc action vlan post parse op net/mlx5e: Move goto action checks into tc_action goto post parse op
drivers/net/ethernet/mellanox/mlx5/core/Makefile | 9 + .../ethernet/mellanox/mlx5/core/en/tc/act/accept.c | 31 + .../ethernet/mellanox/mlx5/core/en/tc/act/act.c | 103 ++ .../ethernet/mellanox/mlx5/core/en/tc/act/act.h | 75 ++ .../ethernet/mellanox/mlx5/core/en/tc/act/csum.c | 61 ++ .../net/ethernet/mellanox/mlx5/core/en/tc/act/ct.c | 50 + .../ethernet/mellanox/mlx5/core/en/tc/act/drop.c | 30 + .../ethernet/mellanox/mlx5/core/en/tc/act/goto.c | 122 +++ .../ethernet/mellanox/mlx5/core/en/tc/act/mark.c | 35 + .../ethernet/mellanox/mlx5/core/en/tc/act/mirred.c | 315 ++++++ .../mellanox/mlx5/core/en/tc/act/mirred_nic.c | 51 + .../ethernet/mellanox/mlx5/core/en/tc/act/mpls.c | 86 ++ .../ethernet/mellanox/mlx5/core/en/tc/act/pedit.c | 165 +++ .../ethernet/mellanox/mlx5/core/en/tc/act/pedit.h | 32 + .../ethernet/mellanox/mlx5/core/en/tc/act/ptype.c | 35 + .../mlx5/core/en/tc/act/redirect_ingress.c | 79 ++ .../ethernet/mellanox/mlx5/core/en/tc/act/sample.c | 51 + .../ethernet/mellanox/mlx5/core/en/tc/act/trap.c | 38 + .../ethernet/mellanox/mlx5/core/en/tc/act/tun.c | 61 ++ .../ethernet/mellanox/mlx5/core/en/tc/act/vlan.c | 218 ++++ .../ethernet/mellanox/mlx5/core/en/tc/act/vlan.h | 30 + .../mellanox/mlx5/core/en/tc/act/vlan_mangle.c | 87 ++ .../net/ethernet/mellanox/mlx5/core/en/tc_priv.h | 12 + drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 1073 ++------------------ drivers/net/ethernet/mellanox/mlx5/core/en_tc.h | 1 - 25 files changed, 1855 insertions(+), 995 deletions(-) create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/accept.c create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/act.c create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/act.h create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/csum.c create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/ct.c create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/drop.c create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/goto.c create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/mark.c create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/mirred.c create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/mirred_nic.c create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/mpls.c create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/pedit.c create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/pedit.h create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/ptype.c create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/redirect_ingress.c create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/sample.c create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/trap.c create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/tun.c create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/vlan.c create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/vlan.h create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/vlan_mangle.c
PATCH 1/16 net/mlx5e: Add tc action infrastructure
From: Roi Dayan <[email protected]>
Add an infrastructure to help parsing tc actions in a generic way.
Supporting an action parser means implementing struct mlx5e_tc_act for that action.
The infrastructure will give the possibility to be generic when parsing tc actions, i.e. parse_tc_nic_actions() and parse_tc_fdb_actions(). To parse tc actions a user needs to allocate a parse_state instance and pass it when iterating over the tc actions parsers.
If a parser doesn't exists then a user can treat it as unsupported.
To add an action parser a user needs to implement two callbacks. The can_offload() callback to quickly check if an action can be offloaded. The parse_action() callback to do actual parsing and prepare for offload.
Add implementation for drop, trap, mark and accept action parsers with this commit to act as examples and implement usage of the new infrastructure for those actions.
--- .../net/ethernet/mellanox/mlx5/core/Makefile | 4 + .../mellanox/mlx5/core/en/tc/act/accept.c | 31 +++++++ .../mellanox/mlx5/core/en/tc/act/act.c | 72 +++++++++++++++ .../mellanox/mlx5/core/en/tc/act/act.h | 45 ++++++++++ .../mellanox/mlx5/core/en/tc/act/drop.c | 30 +++++++ .../mellanox/mlx5/core/en/tc/act/mark.c | 35 ++++++++ .../mellanox/mlx5/core/en/tc/act/trap.c | 38 ++++++++ .../ethernet/mellanox/mlx5/core/en/tc_priv.h | 2 + .../net/ethernet/mellanox/mlx5/core/en_tc.c | 87 +++++++++---------- 9 files changed, 297 insertions(+), 47 deletions(-) create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/accept.c create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/act.c create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/act.h create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/drop.c create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/mark.c create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/trap.c
drivers/net/ethernet/mellanox/mlx5/core/Makefile +4 -0
@@ -46,6 +46,10 @@ mlx5_core-$(CONFIG_MLX5_CLS_ACT) += en_tc.o en/rep/tc.o en/rep/neigh.o \ en/tc_tun_vxlan.o en/tc_tun_gre.o en/tc_tun_geneve.o \ en/tc_tun_mplsoudp.o diag/en_tc_tracepoint.o \ en/tc/post_act.o en/tc/int_port.o + +mlx5_core-$(CONFIG_MLX5_CLS_ACT) += en/tc/act/act.o en/tc/act/drop.o en/tc/act/trap.o \ + en/tc/act/accept.o en/tc/act/mark.o + mlx5_core-$(CONFIG_MLX5_TC_CT) += en/tc_ct.o mlx5_core-$(CONFIG_MLX5_TC_SAMPLE) += en/tc/sample.o
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/accept.c new file +31 -0
@@ -0,0 +1,31 @@ +// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB +// Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + +#include "act.h" +#include "en/tc_priv.h" + +static bool +tc_act_can_offload_accept (struct mlx5e_tc_act_parse_state *parse_state, +const struct flow_action_entry *act, +int act_index) +{ +return true; +} + +static int +tc_act_parse_accept (struct mlx5e_tc_act_parse_state *parse_state, +const struct flow_action_entry *act, +struct mlx5e_priv *priv, +struct mlx5_flow_attr *attr) +{ + attr->action |=MLX5_FLOW_CONTEXT_ACTION_FWD_DEST | +MLX5_FLOW_CONTEXT_ACTION_COUNT ; + attr->flags |=MLX5_ESW_ATTR_FLAG_ACCEPT ; + +return 0 ; +} + +struct mlx5e_tc_act mlx5e_tc_act_accept = { + .can_offload = tc_act_can_offload_accept, + .parse_action = tc_act_parse_accept, +};
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/act.c new file +72 -0
72 lines not on this page · raw message
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/act.h new file +45 -0
45 lines not on this page · raw message
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/drop.c new file +30 -0
@@ -0,0 +1,30 @@ +// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB +// Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + +#include "act.h" +#include "en/tc_priv.h" + +static bool +tc_act_can_offload_drop (struct mlx5e_tc_act_parse_state *parse_state, +const struct flow_action_entry *act, +int act_index) +{ +return true; +} + +static int +tc_act_parse_drop (struct mlx5e_tc_act_parse_state *parse_state, +const struct flow_action_entry *act, +struct mlx5e_priv *priv, +struct mlx5_flow_attr *attr) +{ + attr->action |=MLX5_FLOW_CONTEXT_ACTION_DROP | +MLX5_FLOW_CONTEXT_ACTION_COUNT ; + +return 0 ; +} + +struct mlx5e_tc_act mlx5e_tc_act_drop = { + .can_offload = tc_act_can_offload_drop, + .parse_action = tc_act_parse_drop, +};
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/mark.c new file +35 -0
@@ -0,0 +1,35 @@ +// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB +// Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + +#include "act.h" +#include "en_tc.h" + +static bool +tc_act_can_offload_mark (struct mlx5e_tc_act_parse_state *parse_state, +const struct flow_action_entry *act, +int act_index) +{ +if (act->mark & ~MLX5E_TC_FLOW_ID_MASK ) { +NL_SET_ERR_MSG_MOD (parse_state->extack,"Bad flow mark, only 16 bit supported" ); +return false; + } + +return true; +} + +static int +tc_act_parse_mark (struct mlx5e_tc_act_parse_state *parse_state, +const struct flow_action_entry *act, +struct mlx5e_priv *priv, +struct mlx5_flow_attr *attr) +{ + attr->nic_attr->flow_tag = act->mark; + attr->action |=MLX5_FLOW_CONTEXT_ACTION_FWD_DEST ; + +return 0 ; +} + +struct mlx5e_tc_act mlx5e_tc_act_mark = { + .can_offload = tc_act_can_offload_mark, + .parse_action = tc_act_parse_mark, +};
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/trap.c new file +38 -0
@@ -0,0 +1,38 @@ +// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB +// Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + +#include "act.h" +#include "en/tc_priv.h" + +static bool +tc_act_can_offload_trap (struct mlx5e_tc_act_parse_state *parse_state, +const struct flow_action_entry *act, +int act_index) +{ +struct netlink_ext_ack *extack = parse_state->extack; + +if (parse_state->num_actions !=1 ) { +NL_SET_ERR_MSG_MOD (extack,"action trap is supported as a sole action only" ); +return false; + } + +return true; +} + +static int +tc_act_parse_trap (struct mlx5e_tc_act_parse_state *parse_state, +const struct flow_action_entry *act, +struct mlx5e_priv *priv, +struct mlx5_flow_attr *attr) +{ + attr->action |=MLX5_FLOW_CONTEXT_ACTION_FWD_DEST | +MLX5_FLOW_CONTEXT_ACTION_COUNT ; + attr->flags |=MLX5_ESW_ATTR_FLAG_SLOW_PATH ; + +return 0 ; +} + +struct mlx5e_tc_act mlx5e_tc_act_trap = { + .can_offload = tc_act_can_offload_trap, + .parse_action = tc_act_parse_trap, +};
drivers/net/ethernet/mellanox/mlx5/core/en/tc_priv.h +2 -0
@@ -5,6 +5,7 @@#define __MLX5_EN_TC_PRIV_H__#include "en_tc.h" +#include "en/tc/act/act.h" #define MLX5E_TC_FLOW_BASE (MLX5E_TC_FLAG_LAST_EXPORTED_BIT + 1)
@@ -37,6 +38,7 @@ struct mlx5e_tc_flow_parse_attr {struct mlx5e_tc_mod_hdr_acts mod_hdr_acts;int mirred_ifindex[MLX5_MAX_FLOW_FWD_VPORTS ];struct ethhdr eth; +struct mlx5e_tc_act_parse_state parse_state; };/* Helper struct for accessing a struct containing list_head array.
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +40 -47
165 lines not on this page · raw message
Signature · 1 line
2.31.1
PATCH 2/16 net/mlx5e: Add goto to tc action infra
In reply to Saeed MahameedFrom: Roi Dayan <[email protected]>
Add parsing support by implementing struct mlx5e_tc_act for this action.
--- .../net/ethernet/mellanox/mlx5/core/Makefile | 2 +- .../mellanox/mlx5/core/en/tc/act/act.c | 3 +- .../mellanox/mlx5/core/en/tc/act/act.h | 1 + .../mellanox/mlx5/core/en/tc/act/goto.c | 87 +++++++++++++++++++ .../ethernet/mellanox/mlx5/core/en/tc_priv.h | 4 + .../net/ethernet/mellanox/mlx5/core/en_tc.c | 77 +--------------- .../net/ethernet/mellanox/mlx5/core/en_tc.h | 1 - 7 files changed, 99 insertions(+), 76 deletions(-) create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/goto.c
drivers/net/ethernet/mellanox/mlx5/core/Makefile +1 -1
@@ -48,7 +48,7 @@ mlx5_core-$(CONFIG_MLX5_CLS_ACT) += en_tc.o en/rep/tc.o en/rep/neigh.o \ en/tc/post_act.o en/tc/int_port.o mlx5_core-$(CONFIG_MLX5_CLS_ACT) += en/tc/act/act.o en/tc/act/drop.o en/tc/act/trap.o \ - en/tc/act/accept.o en/tc/act/mark.o + en/tc/act/accept.o en/tc/act/mark.o en/tc/act/goto.o mlx5_core-$(CONFIG_MLX5_TC_CT) += en/tc_ct.o mlx5_core-$(CONFIG_MLX5_TC_SAMPLE) += en/tc/sample.o
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/act.c +2 -1
@@ -10,6 +10,7 @@ static struct mlx5e_tc_act *tc_acts_fdb[NUM_FLOW_ACTIONS] = { &mlx5e_tc_act_accept, &mlx5e_tc_act_drop, &mlx5e_tc_act_trap, + &mlx5e_tc_act_goto, };/* Must be aligned with enum flow_action_id. */
@@ -17,7 +18,7 @@ static struct mlx5e_tc_act *tc_acts_nic[NUM_FLOW_ACTIONS] = { &mlx5e_tc_act_accept, &mlx5e_tc_act_drop,NULL ,/* FLOW_ACTION_TRAP, */ -NULL ,/* FLOW_ACTION_GOTO, */ + &mlx5e_tc_act_goto,NULL ,/* FLOW_ACTION_REDIRECT, */ NULL ,/* FLOW_ACTION_MIRRED, */ NULL, /* FLOW_ACTION_REDIRECT_INGRESS, */
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/act.h +1 -0
@@ -31,6 +31,7 @@ extern struct mlx5e_tc_act mlx5e_tc_act_drop;extern struct mlx5e_tc_act mlx5e_tc_act_trap;extern struct mlx5e_tc_act mlx5e_tc_act_accept;extern struct mlx5e_tc_act mlx5e_tc_act_mark; +extern struct mlx5e_tc_act mlx5e_tc_act_goto;struct mlx5e_tc_act * mlx5e_tc_act_get(enum flow_action_id act_id,
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/goto.c new file +87 -0
87 lines not on this page · raw message
drivers/net/ethernet/mellanox/mlx5/core/en/tc_priv.h +4 -0
@@ -11,6 +11,8 @@#define MLX5E_TC_MAX_SPLITS 1 +#define mlx5e_nic_chains (priv) ((priv)->fs.tc.chains) +enum {MLX5E_TC_FLOW_FLAG_INGRESS =MLX5E_TC_FLAG_INGRESS_BIT ,MLX5E_TC_FLOW_FLAG_EGRESS =MLX5E_TC_FLAG_EGRESS_BIT ,
@@ -117,6 +119,8 @@ mlx5e_tc_offload_fdb_rules(struct mlx5_eswitch *esw,struct mlx5_flow_spec *spec, struct mlx5_flow_attr *attr); +bool mlx5e_is_eswitch_flow (struct mlx5e_tc_flow *flow); +bool mlx5e_is_ft_flow (struct mlx5e_tc_flow *flow);bool mlx5e_is_offloaded_flow (struct mlx5e_tc_flow *flow);static inline void __flow_flag_set (struct mlx5e_tc_flow *flow,unsigned long flag)
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +4 -73
125 lines not on this page · raw message
drivers/net/ethernet/mellanox/mlx5/core/en_tc.h +0 -1
@@ -151,7 +151,6 @@ enum {int mlx5e_tc_esw_init (struct rhashtable *tc_ht);void mlx5e_tc_esw_cleanup (struct rhashtable *tc_ht); -bool mlx5e_is_eswitch_flow (struct mlx5e_tc_flow *flow);int mlx5e_configure_flower (struct net_device *dev,struct mlx5e_priv *priv,struct flow_cls_offload *f,unsigned long flags);
Signature · 1 line
2.31.1
PATCH 4/16 net/mlx5e: Add csum to tc action infra
In reply to Saeed MahameedFrom: Roi Dayan <[email protected]>
Add parsing support by implementing struct mlx5e_tc_act for this action.
--- .../net/ethernet/mellanox/mlx5/core/Makefile | 2 +- .../mellanox/mlx5/core/en/tc/act/act.c | 5 +- .../mellanox/mlx5/core/en/tc/act/act.h | 1 + .../mellanox/mlx5/core/en/tc/act/csum.c | 61 +++++++++++++++++++ .../net/ethernet/mellanox/mlx5/core/en_tc.c | 43 ------------- 5 files changed, 67 insertions(+), 45 deletions(-) create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/csum.c
drivers/net/ethernet/mellanox/mlx5/core/Makefile +1 -1
@@ -49,7 +49,7 @@ mlx5_core-$(CONFIG_MLX5_CLS_ACT) += en_tc.o en/rep/tc.o en/rep/neigh.o \ mlx5_core-$(CONFIG_MLX5_CLS_ACT) += en/tc/act/act.o en/tc/act/drop.o en/tc/act/trap.o \ en/tc/act/accept.o en/tc/act/mark.o en/tc/act/goto.o \ - en/tc/act/tun.o + en/tc/act/tun.o en/tc/act/csum.o mlx5_core-$(CONFIG_MLX5_TC_CT) += en/tc_ct.o mlx5_core-$(CONFIG_MLX5_TC_SAMPLE) += en/tc/sample.o
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/act.c +4 -1
@@ -20,6 +20,9 @@ static struct mlx5e_tc_act *tc_acts_fdb[NUM_FLOW_ACTIONS] = {NULL ,/* FLOW_ACTION_VLAN_MANGLE, */ &mlx5e_tc_act_tun_encap, &mlx5e_tc_act_tun_decap, +NULL ,/* FLOW_ACTION_MANGLE, */ +NULL ,/* FLOW_ACTION_ADD, */ + &mlx5e_tc_act_csum, };/* Must be aligned with enum flow_action_id. */
@@ -39,7 +42,7 @@ static struct mlx5e_tc_act *tc_acts_nic[NUM_FLOW_ACTIONS] = {NULL ,/* FLOW_ACTION_TUNNEL_DECAP, */ NULL ,/* FLOW_ACTION_MANGLE, */ NULL ,/* FLOW_ACTION_ADD, */ -NULL ,/* FLOW_ACTION_CSUM, */ + &mlx5e_tc_act_csum, &mlx5e_tc_act_mark, };
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/act.h +1 -0
@@ -37,6 +37,7 @@ extern struct mlx5e_tc_act mlx5e_tc_act_mark;extern struct mlx5e_tc_act mlx5e_tc_act_goto;extern struct mlx5e_tc_act mlx5e_tc_act_tun_encap;extern struct mlx5e_tc_act mlx5e_tc_act_tun_decap; +extern struct mlx5e_tc_act mlx5e_tc_act_csum;struct mlx5e_tc_act * mlx5e_tc_act_get(enum flow_action_id act_id,
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/csum.c new file +61 -0
61 lines not on this page · raw message
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +0 -43
67 lines not on this page · raw message
Signature · 1 line
2.31.1
PATCH 3/16 net/mlx5e: Add tunnel encap/decap to tc action infra
In reply to Saeed MahameedFrom: Roi Dayan <[email protected]>
Add parsing support by implementing struct mlx5e_tc_act for this action.
--- .../net/ethernet/mellanox/mlx5/core/Makefile | 3 +- .../mellanox/mlx5/core/en/tc/act/act.c | 9 +++ .../mellanox/mlx5/core/en/tc/act/act.h | 5 ++ .../mellanox/mlx5/core/en/tc/act/tun.c | 61 +++++++++++++++++++ .../net/ethernet/mellanox/mlx5/core/en_tc.c | 24 ++------ 5 files changed, 81 insertions(+), 21 deletions(-) create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/tun.c
drivers/net/ethernet/mellanox/mlx5/core/Makefile +2 -1
@@ -48,7 +48,8 @@ mlx5_core-$(CONFIG_MLX5_CLS_ACT) += en_tc.o en/rep/tc.o en/rep/neigh.o \ en/tc/post_act.o en/tc/int_port.o mlx5_core-$(CONFIG_MLX5_CLS_ACT) += en/tc/act/act.o en/tc/act/drop.o en/tc/act/trap.o \ - en/tc/act/accept.o en/tc/act/mark.o en/tc/act/goto.o + en/tc/act/accept.o en/tc/act/mark.o en/tc/act/goto.o \ + en/tc/act/tun.o mlx5_core-$(CONFIG_MLX5_TC_CT) += en/tc_ct.o mlx5_core-$(CONFIG_MLX5_TC_SAMPLE) += en/tc/sample.o
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/act.c +9 -0
@@ -11,6 +11,15 @@ static struct mlx5e_tc_act *tc_acts_fdb[NUM_FLOW_ACTIONS] = { &mlx5e_tc_act_drop, &mlx5e_tc_act_trap, &mlx5e_tc_act_goto, +NULL ,/* FLOW_ACTION_REDIRECT, */ +NULL ,/* FLOW_ACTION_MIRRED, */ +NULL ,/* FLOW_ACTION_REDIRECT_INGRESS, */ +NULL ,/* FLOW_ACTION_MIRRED_INGRESS, */ +NULL ,/* FLOW_ACTION_VLAN_PUSH, */ +NULL ,/* FLOW_ACTION_VLAN_POP, */ +NULL ,/* FLOW_ACTION_VLAN_MANGLE, */ + &mlx5e_tc_act_tun_encap, + &mlx5e_tc_act_tun_decap, };/* Must be aligned with enum flow_action_id. */
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/act.h +5 -0
@@ -14,6 +14,9 @@ struct mlx5e_tc_act_parse_state {unsigned int num_actions;struct mlx5e_tc_flow *flow;struct netlink_ext_ack *extack; +bool encap; +bool decap; +const struct ip_tunnel_info *tun_info; };struct mlx5e_tc_act {
@@ -32,6 +35,8 @@ extern struct mlx5e_tc_act mlx5e_tc_act_trap;extern struct mlx5e_tc_act mlx5e_tc_act_accept;extern struct mlx5e_tc_act mlx5e_tc_act_mark;extern struct mlx5e_tc_act mlx5e_tc_act_goto; +extern struct mlx5e_tc_act mlx5e_tc_act_tun_encap; +extern struct mlx5e_tc_act mlx5e_tc_act_tun_decap;struct mlx5e_tc_act * mlx5e_tc_act_get(enum flow_action_id act_id,
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/tun.c new file +61 -0
61 lines not on this page · raw message
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +4 -20
@@ -3819,14 +3819,12 @@ static int parse_tc_fdb_actions(struct mlx5e_priv *priv,struct mlx5e_tc_flow_parse_attr *parse_attr;struct mlx5e_rep_priv *rpriv = priv->ppriv;struct mlx5e_sample_attr sample_attr = {}; -const struct ip_tunnel_info *info =NULL ;struct mlx5_flow_attr *attr = flow->attr;int ifindexes[MLX5_MAX_FLOW_FWD_VPORTS ];bool ft_flow =mlx5e_is_ft_flow (flow);enum mlx5_flow_namespace_type ns_type;const struct flow_action_entry *act;struct mlx5_esw_flow_attr *esw_attr; -bool encap = false, decap = false;struct mlx5e_tc_act *tc_act;int err, i, if_count =0 ;bool ptype_host = false;
@@ -3985,14 +3983,14 @@ static int parse_tc_fdb_actions(struct mlx5e_priv *priv, attr->action |=MLX5_FLOW_CONTEXT_ACTION_FWD_DEST |MLX5_FLOW_CONTEXT_ACTION_COUNT ; -if (encap) { +if (parse_state->encap) { parse_attr->mirred_ifindex[esw_attr->out_count] = out_dev->ifindex; parse_attr->tun_info[esw_attr->out_count] = -mlx5e_dup_tun_info (info); +mlx5e_dup_tun_info (parse_state->tun_info);if (!parse_attr->tun_info[esw_attr->out_count])return -ENOMEM ; - encap = false; + parse_state->encap = false; esw_attr->dests[esw_attr->out_count].flags |=MLX5_ESW_DEST_ENCAP ; esw_attr->out_count++;
@@ -4080,17 +4078,6 @@ static int parse_tc_fdb_actions(struct mlx5e_priv *priv,return -EOPNOTSUPP ; } } -break ; -case FLOW_ACTION_TUNNEL_ENCAP : - info = act->tunnel; -if (info) { - encap = true; - }else { -NL_SET_ERR_MSG_MOD (extack, -"Zero tunnel attributes is not supported" ); -return -EOPNOTSUPP ; - } -break ;case FLOW_ACTION_VLAN_PUSH :case FLOW_ACTION_VLAN_POP :
@@ -4121,9 +4108,6 @@ static int parse_tc_fdb_actions(struct mlx5e_priv *priv, esw_attr->split_count = esw_attr->out_count;break ; -case FLOW_ACTION_TUNNEL_DECAP : - decap = true; -break ;case FLOW_ACTION_CT :if (flow_flag_test (flow,SAMPLE )) {NL_SET_ERR_MSG_MOD (extack,"Sample action with connection tracking is not supported" );
@@ -4194,7 +4178,7 @@ static int parse_tc_fdb_actions(struct mlx5e_priv *priv,if (!actions_match_supported (priv, flow_action, parse_attr, flow, extack))return -EOPNOTSUPP ; -if (attr->dest_chain && decap) { +if (attr->dest_chain && parse_state->decap) {/* It can be supported if we'll create a mapping for * the tunnel device only (without tunnel), and set * this tunnel id with this decap flow.
Signature · 1 line
2.31.1
PATCH 7/16 net/mlx5e: Add mpls push/pop to tc action infra
In reply to Saeed MahameedFrom: Roi Dayan <[email protected]>
Add parsing support by implementing struct mlx5e_tc_act for this action.
--- .../net/ethernet/mellanox/mlx5/core/Makefile | 2 +- .../mellanox/mlx5/core/en/tc/act/act.c | 11 +++ .../mellanox/mlx5/core/en/tc/act/act.h | 3 + .../mellanox/mlx5/core/en/tc/act/mpls.c | 86 +++++++++++++++++++ .../net/ethernet/mellanox/mlx5/core/en_tc.c | 34 +------- 5 files changed, 102 insertions(+), 34 deletions(-) create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/mpls.c
drivers/net/ethernet/mellanox/mlx5/core/Makefile +1 -1
@@ -50,7 +50,7 @@ mlx5_core-$(CONFIG_MLX5_CLS_ACT) += en_tc.o en/rep/tc.o en/rep/neigh.o \ mlx5_core-$(CONFIG_MLX5_CLS_ACT) += en/tc/act/act.o en/tc/act/drop.o en/tc/act/trap.o \ en/tc/act/accept.o en/tc/act/mark.o en/tc/act/goto.o \ en/tc/act/tun.o en/tc/act/csum.o en/tc/act/pedit.o \ - en/tc/act/vlan.o en/tc/act/vlan_mangle.o + en/tc/act/vlan.o en/tc/act/vlan_mangle.o en/tc/act/mpls.o mlx5_core-$(CONFIG_MLX5_TC_CT) += en/tc_ct.o mlx5_core-$(CONFIG_MLX5_TC_SAMPLE) += en/tc/sample.o
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/act.c +11 -0
@@ -23,6 +23,17 @@ static struct mlx5e_tc_act *tc_acts_fdb[NUM_FLOW_ACTIONS] = { &mlx5e_tc_act_pedit, &mlx5e_tc_act_pedit, &mlx5e_tc_act_csum, +NULL ,/* FLOW_ACTION_MARK, */ +NULL ,/* FLOW_ACTION_PTYPE, */ +NULL ,/* FLOW_ACTION_PRIORITY, */ +NULL ,/* FLOW_ACTION_WAKE, */ +NULL ,/* FLOW_ACTION_QUEUE, */ +NULL ,/* FLOW_ACTION_SAMPLE, */ +NULL ,/* FLOW_ACTION_POLICE, */ +NULL ,/* FLOW_ACTION_CT, */ +NULL ,/* FLOW_ACTION_CT_METADATA, */ + &mlx5e_tc_act_mpls_push, + &mlx5e_tc_act_mpls_pop, };/* Must be aligned with enum flow_action_id. */
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/act.h +3 -0
@@ -18,6 +18,7 @@ struct mlx5e_tc_act_parse_state {struct netlink_ext_ack *extack;bool encap;bool decap; +bool mpls_push;const struct ip_tunnel_info *tun_info;struct pedit_headers_action hdrs[__PEDIT_CMD_MAX]; };
@@ -44,6 +45,8 @@ extern struct mlx5e_tc_act mlx5e_tc_act_csum;extern struct mlx5e_tc_act mlx5e_tc_act_pedit;extern struct mlx5e_tc_act mlx5e_tc_act_vlan;extern struct mlx5e_tc_act mlx5e_tc_act_vlan_mangle; +extern struct mlx5e_tc_act mlx5e_tc_act_mpls_push; +extern struct mlx5e_tc_act mlx5e_tc_act_mpls_pop;struct mlx5e_tc_act * mlx5e_tc_act_get(enum flow_action_id act_id,
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/mpls.c new file +86 -0
86 lines not on this page · raw message
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +1 -33
@@ -3481,7 +3481,6 @@ static int parse_tc_fdb_actions(struct mlx5e_priv *priv,struct mlx5e_tc_act *tc_act;int err, i, if_count =0 ;bool ptype_host = false; -bool mpls_push = false; err =flow_action_supported (flow_action, extack);if (err)
@@ -3505,37 +3504,6 @@ static int parse_tc_fdb_actions(struct mlx5e_priv *priv, ptype_host = true;break ; -case FLOW_ACTION_MPLS_PUSH : -if (!MLX5_CAP_ESW_FLOWTABLE_FDB (priv->mdev, - reformat_l2_to_l3_tunnel) || - act->mpls_push.proto !=htons (ETH_P_MPLS_UC )) { -NL_SET_ERR_MSG_MOD (extack, -"mpls push is supported only for mpls_uc protocol" ); -return -EOPNOTSUPP ; - } - mpls_push = true; -break ; -case FLOW_ACTION_MPLS_POP : -/* we only support mpls pop if it is the first action -* and the filter net device is bareudp. Subsequent -* actions can be pedit and the last can be mirred -* egress redirect. -*/ -if (i) { -NL_SET_ERR_MSG_MOD (extack, -"mpls pop supported only as first action" ); -return -EOPNOTSUPP ; - } -if (!netif_is_bareudp (parse_attr->filter_dev)) { -NL_SET_ERR_MSG_MOD (extack, -"mpls pop supported only on bareudp devices" ); -return -EOPNOTSUPP ; - } - - parse_attr->eth.h_proto = act->mpls_pop.proto; - attr->action |=MLX5_FLOW_CONTEXT_ACTION_PACKET_REFORMAT ; -flow_flag_set (flow,L3_TO_L2_DECAP ); -break ;case FLOW_ACTION_REDIRECT_INGRESS : {struct net_device *out_dev;
@@ -3594,7 +3562,7 @@ static int parse_tc_fdb_actions(struct mlx5e_priv *priv,return -EINVAL ; } -if (mpls_push && !netif_is_bareudp (out_dev)) { +if (parse_state->mpls_push && !netif_is_bareudp (out_dev)) {NL_SET_ERR_MSG_MOD (extack,"mpls is supported only through a bareudp device" );return -EOPNOTSUPP ;
Signature · 1 line
2.31.1
PATCH 6/16 net/mlx5e: Add vlan push/pop/mangle to tc action infra
In reply to Saeed MahameedFrom: Roi Dayan <[email protected]>
Add parsing support by implementing struct mlx5e_tc_act for this action.
--- .../net/ethernet/mellanox/mlx5/core/Makefile | 3 +- .../mellanox/mlx5/core/en/tc/act/act.c | 6 +- .../mellanox/mlx5/core/en/tc/act/act.h | 2 + .../mellanox/mlx5/core/en/tc/act/vlan.c | 167 +++++++++++++ .../mellanox/mlx5/core/en/tc/act/vlan.h | 30 +++ .../mlx5/core/en/tc/act/vlan_mangle.c | 87 +++++++ .../ethernet/mellanox/mlx5/core/en/tc_priv.h | 4 + .../net/ethernet/mellanox/mlx5/core/en_tc.c | 236 ++---------------- 8 files changed, 314 insertions(+), 221 deletions(-) create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/vlan.c create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/vlan.h create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/vlan_mangle.c
drivers/net/ethernet/mellanox/mlx5/core/Makefile +2 -1
@@ -49,7 +49,8 @@ mlx5_core-$(CONFIG_MLX5_CLS_ACT) += en_tc.o en/rep/tc.o en/rep/neigh.o \ mlx5_core-$(CONFIG_MLX5_CLS_ACT) += en/tc/act/act.o en/tc/act/drop.o en/tc/act/trap.o \ en/tc/act/accept.o en/tc/act/mark.o en/tc/act/goto.o \ - en/tc/act/tun.o en/tc/act/csum.o en/tc/act/pedit.o + en/tc/act/tun.o en/tc/act/csum.o en/tc/act/pedit.o \ + en/tc/act/vlan.o en/tc/act/vlan_mangle.o mlx5_core-$(CONFIG_MLX5_TC_CT) += en/tc_ct.o mlx5_core-$(CONFIG_MLX5_TC_SAMPLE) += en/tc/sample.o
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/act.c +3 -3
@@ -15,9 +15,9 @@ static struct mlx5e_tc_act *tc_acts_fdb[NUM_FLOW_ACTIONS] = {NULL ,/* FLOW_ACTION_MIRRED, */ NULL ,/* FLOW_ACTION_REDIRECT_INGRESS, */ NULL ,/* FLOW_ACTION_MIRRED_INGRESS, */ -NULL ,/* FLOW_ACTION_VLAN_PUSH, */ -NULL ,/* FLOW_ACTION_VLAN_POP, */ -NULL ,/* FLOW_ACTION_VLAN_MANGLE, */ + &mlx5e_tc_act_vlan, + &mlx5e_tc_act_vlan, + &mlx5e_tc_act_vlan_mangle, &mlx5e_tc_act_tun_encap, &mlx5e_tc_act_tun_decap, &mlx5e_tc_act_pedit,
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/act.h +2 -0
@@ -42,6 +42,8 @@ extern struct mlx5e_tc_act mlx5e_tc_act_tun_encap;extern struct mlx5e_tc_act mlx5e_tc_act_tun_decap;extern struct mlx5e_tc_act mlx5e_tc_act_csum;extern struct mlx5e_tc_act mlx5e_tc_act_pedit; +extern struct mlx5e_tc_act mlx5e_tc_act_vlan; +extern struct mlx5e_tc_act mlx5e_tc_act_vlan_mangle;struct mlx5e_tc_act * mlx5e_tc_act_get(enum flow_action_id act_id,
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/vlan.c new file +167 -0
167 lines not on this page · raw message
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/vlan.h new file +30 -0
@@ -0,0 +1,30 @@ +/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */ +/* Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved. */ + +#ifndef __MLX5_EN_TC_ACT_VLAN_H__ +#define __MLX5_EN_TC_ACT_VLAN_H__ + +#include <net/flow_offload.h> +#include "en/tc_priv.h" + +struct pedit_headers_action ; + +int +mlx5e_tc_act_vlan_add_push_action (struct mlx5e_priv *priv, +struct mlx5_flow_attr *attr, +struct net_device **out_dev, +struct netlink_ext_ack *extack); + +int +mlx5e_tc_act_vlan_add_pop_action (struct mlx5e_priv *priv, +struct mlx5_flow_attr *attr, +struct netlink_ext_ack *extack); + +int +mlx5e_tc_act_vlan_add_rewrite_action (struct mlx5e_priv *priv,int namespace, +const struct flow_action_entry *act, +struct mlx5e_tc_flow_parse_attr *parse_attr, +struct pedit_headers_action *hdrs, +u32 *action,struct netlink_ext_ack *extack); + +#endif /* __MLX5_EN_TC_ACT_VLAN_H__ */
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/vlan_mangle.c new file +87 -0
87 lines not on this page · raw message
drivers/net/ethernet/mellanox/mlx5/core/en/tc_priv.h +4 -0
@@ -183,4 +183,8 @@ struct mlx5_fc *mlx5e_tc_get_counter(struct mlx5e_tc_flow *flow);struct mlx5e_tc_int_port_priv *mlx5e_get_int_port_priv (struct mlx5e_priv *priv); + +void *mlx5e_get_match_headers_value (u32 flags,struct mlx5_flow_spec *spec); +void *mlx5e_get_match_headers_criteria (u32 flags,struct mlx5_flow_spec *spec); +#endif /* __MLX5_EN_TC_PRIV_H__ */
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +19 -217
318 lines not on this page · raw message
Signature · 1 line
2.31.1
PATCH 8/16 net/mlx5e: Add mirred/redirect to tc action infra
In reply to Saeed MahameedFrom: Roi Dayan <[email protected]>
Add parsing support by implementing struct mlx5e_tc_act for this action.
--- .../net/ethernet/mellanox/mlx5/core/Makefile | 3 +- .../mellanox/mlx5/core/en/tc/act/act.c | 6 +- .../mellanox/mlx5/core/en/tc/act/act.h | 4 + .../mellanox/mlx5/core/en/tc/act/mirred.c | 315 ++++++++++++++++++ .../mellanox/mlx5/core/en/tc/act/mirred_nic.c | 51 +++ .../ethernet/mellanox/mlx5/core/en/tc_priv.h | 1 + .../net/ethernet/mellanox/mlx5/core/en_tc.c | 263 +-------------- 7 files changed, 382 insertions(+), 261 deletions(-) create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/mirred.c create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/mirred_nic.c
drivers/net/ethernet/mellanox/mlx5/core/Makefile +2 -1
@@ -50,7 +50,8 @@ mlx5_core-$(CONFIG_MLX5_CLS_ACT) += en_tc.o en/rep/tc.o en/rep/neigh.o \ mlx5_core-$(CONFIG_MLX5_CLS_ACT) += en/tc/act/act.o en/tc/act/drop.o en/tc/act/trap.o \ en/tc/act/accept.o en/tc/act/mark.o en/tc/act/goto.o \ en/tc/act/tun.o en/tc/act/csum.o en/tc/act/pedit.o \ - en/tc/act/vlan.o en/tc/act/vlan_mangle.o en/tc/act/mpls.o + en/tc/act/vlan.o en/tc/act/vlan_mangle.o en/tc/act/mpls.o \ + en/tc/act/mirred.o en/tc/act/mirred_nic.o mlx5_core-$(CONFIG_MLX5_TC_CT) += en/tc_ct.o mlx5_core-$(CONFIG_MLX5_TC_SAMPLE) += en/tc/sample.o
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/act.c +3 -3
@@ -11,8 +11,8 @@ static struct mlx5e_tc_act *tc_acts_fdb[NUM_FLOW_ACTIONS] = { &mlx5e_tc_act_drop, &mlx5e_tc_act_trap, &mlx5e_tc_act_goto, -NULL ,/* FLOW_ACTION_REDIRECT, */ -NULL ,/* FLOW_ACTION_MIRRED, */ + &mlx5e_tc_act_mirred, + &mlx5e_tc_act_mirred,NULL ,/* FLOW_ACTION_REDIRECT_INGRESS, */ NULL ,/* FLOW_ACTION_MIRRED_INGRESS, */ &mlx5e_tc_act_vlan,
@@ -42,7 +42,7 @@ static struct mlx5e_tc_act *tc_acts_nic[NUM_FLOW_ACTIONS] = { &mlx5e_tc_act_drop,NULL ,/* FLOW_ACTION_TRAP, */ &mlx5e_tc_act_goto, -NULL ,/* FLOW_ACTION_REDIRECT, */ + &mlx5e_tc_act_mirred_nic,NULL ,/* FLOW_ACTION_MIRRED, */ NULL ,/* FLOW_ACTION_REDIRECT_INGRESS, */ NULL, /* FLOW_ACTION_MIRRED_INGRESS, */
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/act.h +4 -0
@@ -21,6 +21,8 @@ struct mlx5e_tc_act_parse_state {bool mpls_push;const struct ip_tunnel_info *tun_info;struct pedit_headers_action hdrs[__PEDIT_CMD_MAX]; +int ifindexes[MLX5_MAX_FLOW_FWD_VPORTS ]; +int if_count; };struct mlx5e_tc_act {
@@ -47,6 +49,8 @@ extern struct mlx5e_tc_act mlx5e_tc_act_vlan;extern struct mlx5e_tc_act mlx5e_tc_act_vlan_mangle;extern struct mlx5e_tc_act mlx5e_tc_act_mpls_push;extern struct mlx5e_tc_act mlx5e_tc_act_mpls_pop; +extern struct mlx5e_tc_act mlx5e_tc_act_mirred; +extern struct mlx5e_tc_act mlx5e_tc_act_mirred_nic;struct mlx5e_tc_act * mlx5e_tc_act_get(enum flow_action_id act_id,
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/mirred.c new file +315 -0
315 lines not on this page · raw message
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/mirred_nic.c new file +51 -0
51 lines not on this page · raw message
drivers/net/ethernet/mellanox/mlx5/core/en/tc_priv.h +1 -0
@@ -123,6 +123,7 @@ bool mlx5e_is_eswitch_flow(struct mlx5e_tc_flow *flow);bool mlx5e_is_ft_flow (struct mlx5e_tc_flow *flow);bool mlx5e_is_offloaded_flow (struct mlx5e_tc_flow *flow);int mlx5e_get_flow_namespace (struct mlx5e_tc_flow *flow); +bool mlx5e_same_hw_devs (struct mlx5e_priv *priv,struct mlx5e_priv *peer_priv);static inline void __flow_flag_set (struct mlx5e_tc_flow *flow,unsigned long flag) {
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +6 -257
343 lines not on this page · raw message
Signature · 1 line
2.31.1
PATCH 9/16 net/mlx5e: Add ct to tc action infra
In reply to Saeed MahameedFrom: Roi Dayan <[email protected]>
Add parsing support by implementing struct mlx5e_tc_act for this action.
--- .../net/ethernet/mellanox/mlx5/core/Makefile | 3 +- .../mellanox/mlx5/core/en/tc/act/act.c | 9 +++- .../mellanox/mlx5/core/en/tc/act/act.h | 2 + .../mellanox/mlx5/core/en/tc/act/ct.c | 50 +++++++++++++++++++ .../net/ethernet/mellanox/mlx5/core/en_tc.c | 30 +---------- 5 files changed, 64 insertions(+), 30 deletions(-) create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/ct.c
drivers/net/ethernet/mellanox/mlx5/core/Makefile +2 -1
@@ -51,7 +51,8 @@ mlx5_core-$(CONFIG_MLX5_CLS_ACT) += en/tc/act/act.o en/tc/act/drop.o en/tc/a en/tc/act/accept.o en/tc/act/mark.o en/tc/act/goto.o \ en/tc/act/tun.o en/tc/act/csum.o en/tc/act/pedit.o \ en/tc/act/vlan.o en/tc/act/vlan_mangle.o en/tc/act/mpls.o \ - en/tc/act/mirred.o en/tc/act/mirred_nic.o + en/tc/act/mirred.o en/tc/act/mirred_nic.o \ + en/tc/act/ct.o mlx5_core-$(CONFIG_MLX5_TC_CT) += en/tc_ct.o mlx5_core-$(CONFIG_MLX5_TC_SAMPLE) += en/tc/sample.o
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/act.c +8 -1
@@ -30,7 +30,7 @@ static struct mlx5e_tc_act *tc_acts_fdb[NUM_FLOW_ACTIONS] = {NULL ,/* FLOW_ACTION_QUEUE, */ NULL ,/* FLOW_ACTION_SAMPLE, */ NULL ,/* FLOW_ACTION_POLICE, */ -NULL ,/* FLOW_ACTION_CT, */ + &mlx5e_tc_act_ct,NULL ,/* FLOW_ACTION_CT_METADATA, */ &mlx5e_tc_act_mpls_push, &mlx5e_tc_act_mpls_pop,
@@ -55,6 +55,13 @@ static struct mlx5e_tc_act *tc_acts_nic[NUM_FLOW_ACTIONS] = { &mlx5e_tc_act_pedit, &mlx5e_tc_act_csum, &mlx5e_tc_act_mark, +NULL ,/* FLOW_ACTION_PTYPE, */ +NULL ,/* FLOW_ACTION_PRIORITY, */ +NULL ,/* FLOW_ACTION_WAKE, */ +NULL ,/* FLOW_ACTION_QUEUE, */ +NULL ,/* FLOW_ACTION_SAMPLE, */ +NULL ,/* FLOW_ACTION_POLICE, */ + &mlx5e_tc_act_ct, };/**
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/act.h +2 -0
@@ -23,6 +23,7 @@ struct mlx5e_tc_act_parse_state {struct pedit_headers_action hdrs[__PEDIT_CMD_MAX];int ifindexes[MLX5_MAX_FLOW_FWD_VPORTS ];int if_count; +struct mlx5_tc_ct_priv *ct_priv; };struct mlx5e_tc_act {
@@ -51,6 +52,7 @@ extern struct mlx5e_tc_act mlx5e_tc_act_mpls_push;extern struct mlx5e_tc_act mlx5e_tc_act_mpls_pop;extern struct mlx5e_tc_act mlx5e_tc_act_mirred;extern struct mlx5e_tc_act mlx5e_tc_act_mirred_nic; +extern struct mlx5e_tc_act mlx5e_tc_act_ct;struct mlx5e_tc_act * mlx5e_tc_act_get(enum flow_action_id act_id,
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/ct.c new file +50 -0
50 lines not on this page · raw message
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +2 -28
@@ -3219,24 +3219,11 @@ parse_tc_nic_actions(struct mlx5e_priv *priv, parse_attr = attr->parse_attr; parse_state = &parse_attr->parse_state;mlx5e_tc_act_init_parse_state (parse_state, flow, flow_action, extack); + parse_state->ct_priv =get_ct_priv (priv); ns_type =mlx5e_get_flow_namespace (flow); hdrs = parse_state->hdrs;flow_action_for_each (i, act, flow_action) { -switch (act->id) { -case FLOW_ACTION_CT : - err =mlx5_tc_ct_parse_action (get_ct_priv (priv), attr, - &parse_attr->mod_hdr_acts, - act, extack); -if (err) -return err; - -flow_flag_set (flow,CT ); -break ; -default : -break ; - } - tc_act =mlx5e_tc_act_get (act->id, ns_type);if (!tc_act) {NL_SET_ERR_MSG_MOD (extack,"Not implemented offload action" );
@@ -3377,6 +3364,7 @@ static int parse_tc_fdb_actions(struct mlx5e_priv *priv, parse_attr = attr->parse_attr; parse_state = &parse_attr->parse_state;mlx5e_tc_act_init_parse_state (parse_state, flow, flow_action, extack); + parse_state->ct_priv =get_ct_priv (priv); ns_type =mlx5e_get_flow_namespace (flow); hdrs = parse_state->hdrs;
@@ -3435,20 +3423,6 @@ static int parse_tc_fdb_actions(struct mlx5e_priv *priv,break ; } -case FLOW_ACTION_CT : -if (flow_flag_test (flow,SAMPLE )) { -NL_SET_ERR_MSG_MOD (extack,"Sample action with connection tracking is not supported" ); -return -EOPNOTSUPP ; - } - err =mlx5_tc_ct_parse_action (get_ct_priv (priv), attr, - &parse_attr->mod_hdr_acts, - act, extack); -if (err) -return err; - -flow_flag_set (flow,CT ); - esw_attr->split_count = esw_attr->out_count; -break ;case FLOW_ACTION_SAMPLE :if (flow_flag_test (flow,CT )) {NL_SET_ERR_MSG_MOD (extack,"Sample action with connection tracking is not supported" );
Signature · 1 line
2.31.1
PATCH 10/16 net/mlx5e: Add sample and ptype to tc_action infra
In reply to Saeed MahameedFrom: Roi Dayan <[email protected]>
Add parsing support by implementing struct mlx5e_tc_act for this action.
--- .../net/ethernet/mellanox/mlx5/core/Makefile | 2 +- .../mellanox/mlx5/core/en/tc/act/act.c | 4 +- .../mellanox/mlx5/core/en/tc/act/act.h | 4 ++ .../mellanox/mlx5/core/en/tc/act/ptype.c | 35 ++++++++++++++ .../mellanox/mlx5/core/en/tc/act/sample.c | 46 +++++++++++++++++++ .../net/ethernet/mellanox/mlx5/core/en_tc.c | 27 +---------- 6 files changed, 90 insertions(+), 28 deletions(-) create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/ptype.c create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/sample.c
drivers/net/ethernet/mellanox/mlx5/core/Makefile +1 -1
@@ -52,7 +52,7 @@ mlx5_core-$(CONFIG_MLX5_CLS_ACT) += en/tc/act/act.o en/tc/act/drop.o en/tc/a en/tc/act/tun.o en/tc/act/csum.o en/tc/act/pedit.o \ en/tc/act/vlan.o en/tc/act/vlan_mangle.o en/tc/act/mpls.o \ en/tc/act/mirred.o en/tc/act/mirred_nic.o \ - en/tc/act/ct.o + en/tc/act/ct.o en/tc/act/sample.o en/tc/act/ptype.o mlx5_core-$(CONFIG_MLX5_TC_CT) += en/tc_ct.o mlx5_core-$(CONFIG_MLX5_TC_SAMPLE) += en/tc/sample.o
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/act.c +2 -2
@@ -24,11 +24,11 @@ static struct mlx5e_tc_act *tc_acts_fdb[NUM_FLOW_ACTIONS] = { &mlx5e_tc_act_pedit, &mlx5e_tc_act_csum,NULL ,/* FLOW_ACTION_MARK, */ -NULL ,/* FLOW_ACTION_PTYPE, */ + &mlx5e_tc_act_ptype,NULL ,/* FLOW_ACTION_PRIORITY, */ NULL ,/* FLOW_ACTION_WAKE, */ NULL ,/* FLOW_ACTION_QUEUE, */ -NULL ,/* FLOW_ACTION_SAMPLE, */ + &mlx5e_tc_act_sample,NULL ,/* FLOW_ACTION_POLICE, */ &mlx5e_tc_act_ct, NULL, /* FLOW_ACTION_CT_METADATA, */
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/act.h +4 -0
@@ -19,11 +19,13 @@ struct mlx5e_tc_act_parse_state {bool encap;bool decap;bool mpls_push; +bool ptype_host;const struct ip_tunnel_info *tun_info;struct pedit_headers_action hdrs[__PEDIT_CMD_MAX];int ifindexes[MLX5_MAX_FLOW_FWD_VPORTS ];int if_count;struct mlx5_tc_ct_priv *ct_priv; +struct mlx5e_sample_attr sample_attr; };struct mlx5e_tc_act {
@@ -53,6 +55,8 @@ extern struct mlx5e_tc_act mlx5e_tc_act_mpls_pop;extern struct mlx5e_tc_act mlx5e_tc_act_mirred;extern struct mlx5e_tc_act mlx5e_tc_act_mirred_nic;extern struct mlx5e_tc_act mlx5e_tc_act_ct; +extern struct mlx5e_tc_act mlx5e_tc_act_sample; +extern struct mlx5e_tc_act mlx5e_tc_act_ptype;struct mlx5e_tc_act * mlx5e_tc_act_get(enum flow_action_id act_id,
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/ptype.c new file +35 -0
@@ -0,0 +1,35 @@ +// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB +// Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + +#include "act.h" +#include "en/tc_priv.h" + +static bool +tc_act_can_offload_ptype (struct mlx5e_tc_act_parse_state *parse_state, +const struct flow_action_entry *act, +int act_index) +{ +return true; +} + +static int +tc_act_parse_ptype (struct mlx5e_tc_act_parse_state *parse_state, +const struct flow_action_entry *act, +struct mlx5e_priv *priv, +struct mlx5_flow_attr *attr) +{ +struct netlink_ext_ack *extack = parse_state->extack; + +if (act->ptype !=PACKET_HOST ) { +NL_SET_ERR_MSG_MOD (extack,"skbedit ptype is only supported with type host" ); +return -EOPNOTSUPP ; + } + + parse_state->ptype_host = true; +return 0 ; +} + +struct mlx5e_tc_act mlx5e_tc_act_ptype = { + .can_offload = tc_act_can_offload_ptype, + .parse_action = tc_act_parse_ptype, +};
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/sample.c new file +46 -0
46 lines not on this page · raw message
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +2 -25
@@ -39,7 +39,6 @@#include <linux/rhashtable.h> #include <linux/refcount.h> #include <linux/completion.h> -#include <net/psample.h> #include <net/arp.h> #include <net/ipv6_stubs.h> #include <net/bareudp.h>
@@ -3346,14 +3345,12 @@ static int parse_tc_fdb_actions(struct mlx5e_priv *priv,struct mlx5_eswitch *esw = priv->mdev->priv.eswitch;struct mlx5e_tc_act_parse_state *parse_state;struct mlx5e_tc_flow_parse_attr *parse_attr; -struct mlx5e_sample_attr sample_attr = {};struct mlx5_flow_attr *attr = flow->attr;enum mlx5_flow_namespace_type ns_type;const struct flow_action_entry *act;struct mlx5_esw_flow_attr *esw_attr;struct pedit_headers_action *hdrs;struct mlx5e_tc_act *tc_act; -bool ptype_host = false;int err, i; err =flow_action_supported (flow_action, extack);
@@ -3370,15 +3367,6 @@ static int parse_tc_fdb_actions(struct mlx5e_priv *priv,flow_action_for_each (i, act, flow_action) {switch (act->id) { -case FLOW_ACTION_PTYPE : -if (act->ptype !=PACKET_HOST ) { -NL_SET_ERR_MSG_MOD (extack, -"skbedit ptype is only supported with type host" ); -return -EOPNOTSUPP ; - } - - ptype_host = true; -break ;case FLOW_ACTION_REDIRECT_INGRESS : {struct net_device *out_dev;
@@ -3398,7 +3386,7 @@ static int parse_tc_fdb_actions(struct mlx5e_priv *priv,return -EOPNOTSUPP ; } -if (!ptype_host) { +if (!parse_state->ptype_host) {NL_SET_ERR_MSG_MOD (extack,"redirect to int port ingress requires ptype=host action" );return -EOPNOTSUPP ;
@@ -3423,17 +3411,6 @@ static int parse_tc_fdb_actions(struct mlx5e_priv *priv,break ; } -case FLOW_ACTION_SAMPLE : -if (flow_flag_test (flow,CT )) { -NL_SET_ERR_MSG_MOD (extack,"Sample action with connection tracking is not supported" ); -return -EOPNOTSUPP ; - } - sample_attr.rate = act->sample.rate; - sample_attr.group_num = act->sample.psample_group->group_num; -if (act->sample.truncate) - sample_attr.trunc_size = act->sample.trunc_size; -flow_flag_set (flow,SAMPLE ); -break ;default :break ; }
@@ -3500,7 +3477,7 @@ static int parse_tc_fdb_actions(struct mlx5e_priv *priv, attr->sample_attr =kzalloc (sizeof (*attr->sample_attr),GFP_KERNEL );if (!attr->sample_attr)return -ENOMEM ; - *attr->sample_attr = sample_attr; + *attr->sample_attr = parse_state->sample_attr; }return 0 ;
Signature · 1 line
2.31.1
PATCH 5/16 net/mlx5e: Add pedit to tc action infra
In reply to Saeed MahameedFrom: Roi Dayan <[email protected]>
Add parsing support by implementing struct mlx5e_tc_act for this action.
--- .../net/ethernet/mellanox/mlx5/core/Makefile | 2 +- .../mellanox/mlx5/core/en/tc/act/act.c | 8 +- .../mellanox/mlx5/core/en/tc/act/act.h | 4 + .../mellanox/mlx5/core/en/tc/act/pedit.c | 165 ++++++++++++++++ .../mellanox/mlx5/core/en/tc/act/pedit.h | 32 ++++ .../ethernet/mellanox/mlx5/core/en/tc_priv.h | 1 + .../net/ethernet/mellanox/mlx5/core/en_tc.c | 179 ++---------------- 7 files changed, 222 insertions(+), 169 deletions(-) create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/pedit.c create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/pedit.h
drivers/net/ethernet/mellanox/mlx5/core/Makefile +1 -1
@@ -49,7 +49,7 @@ mlx5_core-$(CONFIG_MLX5_CLS_ACT) += en_tc.o en/rep/tc.o en/rep/neigh.o \ mlx5_core-$(CONFIG_MLX5_CLS_ACT) += en/tc/act/act.o en/tc/act/drop.o en/tc/act/trap.o \ en/tc/act/accept.o en/tc/act/mark.o en/tc/act/goto.o \ - en/tc/act/tun.o en/tc/act/csum.o + en/tc/act/tun.o en/tc/act/csum.o en/tc/act/pedit.o mlx5_core-$(CONFIG_MLX5_TC_CT) += en/tc_ct.o mlx5_core-$(CONFIG_MLX5_TC_SAMPLE) += en/tc/sample.o
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/act.c +4 -4
@@ -20,8 +20,8 @@ static struct mlx5e_tc_act *tc_acts_fdb[NUM_FLOW_ACTIONS] = {NULL ,/* FLOW_ACTION_VLAN_MANGLE, */ &mlx5e_tc_act_tun_encap, &mlx5e_tc_act_tun_decap, -NULL ,/* FLOW_ACTION_MANGLE, */ -NULL ,/* FLOW_ACTION_ADD, */ + &mlx5e_tc_act_pedit, + &mlx5e_tc_act_pedit, &mlx5e_tc_act_csum, };
@@ -40,8 +40,8 @@ static struct mlx5e_tc_act *tc_acts_nic[NUM_FLOW_ACTIONS] = {NULL ,/* FLOW_ACTION_VLAN_MANGLE, */ NULL ,/* FLOW_ACTION_TUNNEL_ENCAP, */ NULL ,/* FLOW_ACTION_TUNNEL_DECAP, */ -NULL ,/* FLOW_ACTION_MANGLE, */ -NULL ,/* FLOW_ACTION_ADD, */ + &mlx5e_tc_act_pedit, + &mlx5e_tc_act_pedit, &mlx5e_tc_act_csum, &mlx5e_tc_act_mark, };
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/act.h +4 -0
@@ -4,9 +4,11 @@#ifndef __MLX5_EN_TC_ACT_H__#define __MLX5_EN_TC_ACT_H__ +#include <net/tc_act/tc_pedit.h> #include <net/flow_offload.h> #include <linux/netlink.h> #include "eswitch.h" +#include "pedit.h" struct mlx5_flow_attr ;
@@ -17,6 +19,7 @@ struct mlx5e_tc_act_parse_state {bool encap;bool decap;const struct ip_tunnel_info *tun_info; +struct pedit_headers_action hdrs[__PEDIT_CMD_MAX]; };struct mlx5e_tc_act {
@@ -38,6 +41,7 @@ extern struct mlx5e_tc_act mlx5e_tc_act_goto;extern struct mlx5e_tc_act mlx5e_tc_act_tun_encap;extern struct mlx5e_tc_act mlx5e_tc_act_tun_decap;extern struct mlx5e_tc_act mlx5e_tc_act_csum; +extern struct mlx5e_tc_act mlx5e_tc_act_pedit;struct mlx5e_tc_act * mlx5e_tc_act_get(enum flow_action_id act_id,
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/pedit.c new file +165 -0
165 lines not on this page · raw message
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/pedit.h new file +32 -0
@@ -0,0 +1,32 @@ +/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */ +/* Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved. */ + +#ifndef __MLX5_EN_TC_ACT_PEDIT_H__ +#define __MLX5_EN_TC_ACT_PEDIT_H__ + +#include "en_tc.h" + +struct pedit_headers { +struct ethhdr eth; +struct vlan_hdr vlan; +struct iphdr ip4; +struct ipv6hdr ip6; +struct tcphdr tcp; +struct udphdr udp; +}; + +struct pedit_headers_action { +struct pedit_headers vals; +struct pedit_headers masks; +u32 pedits; +}; + +int +mlx5e_tc_act_pedit_parse_action (struct mlx5e_priv *priv, +const struct flow_action_entry *act,int namespace, +struct mlx5e_tc_flow_parse_attr *parse_attr, +struct pedit_headers_action *hdrs, +struct mlx5e_tc_flow *flow, +struct netlink_ext_ack *extack); + +#endif /* __MLX5_EN_TC_ACT_PEDIT_H__ */
drivers/net/ethernet/mellanox/mlx5/core/en/tc_priv.h +1 -0
@@ -122,6 +122,7 @@ mlx5e_tc_offload_fdb_rules(struct mlx5_eswitch *esw,bool mlx5e_is_eswitch_flow (struct mlx5e_tc_flow *flow);bool mlx5e_is_ft_flow (struct mlx5e_tc_flow *flow);bool mlx5e_is_offloaded_flow (struct mlx5e_tc_flow *flow); +int mlx5e_get_flow_namespace (struct mlx5e_tc_flow *flow);static inline void __flow_flag_set (struct mlx5e_tc_flow *flow,unsigned long flag) {
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +15 -164
286 lines not on this page · raw message
Signature · 1 line
2.31.1
PATCH 13/16 net/mlx5e: Move sample attr allocation to tc_action sample parse op
In reply to Saeed MahameedFrom: Roi Dayan <[email protected]>
There is no reason to wait with the kmalloc to after parsing all other actions. There could still be a failure later and before offloading the rule. So alloc the mem when parsing. The memory is being released on mlx5e_flow_put() which is called also on error flow.
--- .../net/ethernet/mellanox/mlx5/core/en/tc/act/act.h | 1 - .../net/ethernet/mellanox/mlx5/core/en/tc/act/sample.c | 7 ++++++- drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 10 ---------- 3 files changed, 6 insertions(+), 12 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/act.h +0 -1
@@ -25,7 +25,6 @@ struct mlx5e_tc_act_parse_state {int ifindexes[MLX5_MAX_FLOW_FWD_VPORTS ];int if_count;struct mlx5_tc_ct_priv *ct_priv; -struct mlx5e_sample_attr sample_attr; };struct mlx5e_tc_act {
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/sample.c +6 -1
@@ -27,7 +27,11 @@ tc_act_parse_sample(struct mlx5e_tc_act_parse_state *parse_state,struct mlx5e_priv *priv, struct mlx5_flow_attr *attr) { - struct mlx5e_sample_attr *sample_attr = &parse_state->sample_attr; + struct mlx5e_sample_attr *sample_attr; + + sample_attr =kzalloc (sizeof (*attr->sample_attr),GFP_KERNEL ); +if (!sample_attr) +return -ENOMEM ; sample_attr->rate = act->sample.rate; sample_attr->group_num = act->sample.psample_group->group_num;
@@ -35,6 +39,7 @@ tc_act_parse_sample(struct mlx5e_tc_act_parse_state *parse_state,if (act->sample.truncate) sample_attr->trunc_size = act->sample.trunc_size; + attr->sample_attr = sample_attr;flow_flag_set (parse_state->flow,SAMPLE );return 0 ;
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +0 -10
@@ -3425,16 +3425,6 @@ parse_tc_fdb_actions(struct mlx5e_priv *priv,return -EOPNOTSUPP ; } -/* Allocate sample attribute only when there is a sample action and -* no errors after parsing. -*/ -if (flow_flag_test (flow,SAMPLE )) { - attr->sample_attr =kzalloc (sizeof (*attr->sample_attr),GFP_KERNEL ); -if (!attr->sample_attr) -return -ENOMEM ; - *attr->sample_attr = parse_state->sample_attr; - } -return 0 ; }
Signature · 1 line
2.31.1
PATCH 11/16 net/mlx5e: Add redirect ingress to tc action infra
In reply to Saeed MahameedFrom: Roi Dayan <[email protected]>
Add parsing support by implementing struct mlx5e_tc_act for this action.
--- .../net/ethernet/mellanox/mlx5/core/Makefile | 3 +- .../mellanox/mlx5/core/en/tc/act/act.c | 2 +- .../mellanox/mlx5/core/en/tc/act/act.h | 1 + .../mlx5/core/en/tc/act/redirect_ingress.c | 79 +++++++++++++++++++ .../net/ethernet/mellanox/mlx5/core/en_tc.c | 49 ------------ 5 files changed, 83 insertions(+), 51 deletions(-) create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/redirect_ingress.c
drivers/net/ethernet/mellanox/mlx5/core/Makefile +2 -1
@@ -52,7 +52,8 @@ mlx5_core-$(CONFIG_MLX5_CLS_ACT) += en/tc/act/act.o en/tc/act/drop.o en/tc/a en/tc/act/tun.o en/tc/act/csum.o en/tc/act/pedit.o \ en/tc/act/vlan.o en/tc/act/vlan_mangle.o en/tc/act/mpls.o \ en/tc/act/mirred.o en/tc/act/mirred_nic.o \ - en/tc/act/ct.o en/tc/act/sample.o en/tc/act/ptype.o + en/tc/act/ct.o en/tc/act/sample.o en/tc/act/ptype.o \ + en/tc/act/redirect_ingress.o mlx5_core-$(CONFIG_MLX5_TC_CT) += en/tc_ct.o mlx5_core-$(CONFIG_MLX5_TC_SAMPLE) += en/tc/sample.o
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/act.c +1 -1
@@ -13,7 +13,7 @@ static struct mlx5e_tc_act *tc_acts_fdb[NUM_FLOW_ACTIONS] = { &mlx5e_tc_act_goto, &mlx5e_tc_act_mirred, &mlx5e_tc_act_mirred, -NULL ,/* FLOW_ACTION_REDIRECT_INGRESS, */ + &mlx5e_tc_act_redirect_ingress,NULL ,/* FLOW_ACTION_MIRRED_INGRESS, */ &mlx5e_tc_act_vlan, &mlx5e_tc_act_vlan,
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/act.h +1 -0
@@ -57,6 +57,7 @@ extern struct mlx5e_tc_act mlx5e_tc_act_mirred_nic;extern struct mlx5e_tc_act mlx5e_tc_act_ct;extern struct mlx5e_tc_act mlx5e_tc_act_sample;extern struct mlx5e_tc_act mlx5e_tc_act_ptype; +extern struct mlx5e_tc_act mlx5e_tc_act_redirect_ingress;struct mlx5e_tc_act * mlx5e_tc_act_get(enum flow_action_id act_id,
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/redirect_ingress.c new file +79 -0
79 lines not on this page · raw message
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +0 -49
55 lines not on this page · raw message
Signature · 1 line
2.31.1
PATCH 14/16 net/mlx5e: Add post_parse() op to tc action infrastructure
In reply to Saeed MahameedFrom: Roi Dayan <[email protected]>
The post_parse() op should be called after the parse op was called for all actions. It could be an action state is dependent on other actions. In the new op an action can fail the parse if the state is not valid anymore.
--- .../net/ethernet/mellanox/mlx5/core/en/tc/act/act.h | 4 ++++ drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 11 +++++++++++ 2 files changed, 15 insertions(+)
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/act.h +4 -0
@@ -36,6 +36,10 @@ struct mlx5e_tc_act {const struct flow_action_entry *act, struct mlx5e_priv *priv, struct mlx5_flow_attr *attr); + +int (*post_parse)(struct mlx5e_tc_act_parse_state *parse_state, +struct mlx5e_priv *priv, +struct mlx5_flow_attr *attr); };extern struct mlx5e_tc_act mlx5e_tc_act_drop;
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +11 -0
@@ -3168,6 +3168,17 @@ parse_tc_actions(struct mlx5e_tc_act_parse_state *parse_state,return err; } +flow_action_for_each (i, act, flow_action) { + tc_act =mlx5e_tc_act_get (act->id, ns_type); +if (!tc_act || !tc_act->post_parse || + !tc_act->can_offload (parse_state, act, i)) +continue ; + + err = tc_act->post_parse (parse_state, priv, attr); +if (err) +return err; + } +return 0 ; }
Signature · 1 line
2.31.1
PATCH 15/16 net/mlx5e: Move vlan action chunk into tc action vlan post parse op
In reply to Saeed MahameedFrom: Roi Dayan <[email protected]>
Move vlan prio tag rewrite handling into tc action infra vlan post parse op.
--- .../mellanox/mlx5/core/en/tc/act/vlan.c | 51 +++++++++++++++++++ .../net/ethernet/mellanox/mlx5/core/en_tc.c | 38 -------------- 2 files changed, 51 insertions(+), 38 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/vlan.c +51 -0
@@ -6,6 +6,30 @@#include "vlan.h" #include "en/tc_priv.h" +static int +add_vlan_prio_tag_rewrite_action (struct mlx5e_priv *priv, +struct mlx5e_tc_flow_parse_attr *parse_attr, +struct pedit_headers_action *hdrs, +u32 *action,struct netlink_ext_ack *extack) +{ +const struct flow_action_entry prio_tag_act = { + .vlan.vid =0 , + .vlan.prio = +MLX5_GET (fte_match_set_lyr_2_4, +mlx5e_get_match_headers_value (*action, + &parse_attr->spec), + first_prio) & +MLX5_GET (fte_match_set_lyr_2_4, +mlx5e_get_match_headers_criteria (*action, + &parse_attr->spec), + first_prio), + }; + +return mlx5e_tc_act_vlan_add_rewrite_action (priv,MLX5_FLOW_NAMESPACE_FDB , + &prio_tag_act, parse_attr, hdrs, action, + extack); +} + static int parse_tc_vlan_action(struct mlx5e_priv *priv, const struct flow_action_entry *act,
@@ -161,7 +185,34 @@ tc_act_parse_vlan(struct mlx5e_tc_act_parse_state *parse_state,return 0 ; } +static int +tc_act_post_parse_vlan (struct mlx5e_tc_act_parse_state *parse_state, +struct mlx5e_priv *priv, +struct mlx5_flow_attr *attr) +{ +struct mlx5e_tc_flow_parse_attr *parse_attr = attr->parse_attr; +struct pedit_headers_action *hdrs = parse_state->hdrs; +struct netlink_ext_ack *extack = parse_state->extack; +struct mlx5_eswitch *esw = priv->mdev->priv.eswitch; +int err; + +if (MLX5_CAP_GEN (esw->dev, prio_tag_required) && + attr->action &MLX5_FLOW_CONTEXT_ACTION_VLAN_POP ) { +/* For prio tag mode, replace vlan pop with rewrite vlan prio +* tag rewrite. +*/ + attr->action &= ~MLX5_FLOW_CONTEXT_ACTION_VLAN_POP ; + err =add_vlan_prio_tag_rewrite_action (priv, parse_attr, hdrs, + &attr->action, extack); +if (err) +return err; + } + +return 0 ; +} +struct mlx5e_tc_act mlx5e_tc_act_vlan = { .can_offload = tc_act_can_offload_vlan, .parse_action = tc_act_parse_vlan, + .post_parse = tc_act_post_parse_vlan, };
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +0 -38
@@ -59,7 +59,6 @@#include "en/tc_tun_encap.h" #include "en/tc/sample.h" #include "en/tc/act/act.h" -#include "en/tc/act/vlan.h" #include "lib/devcom.h" #include "lib/geneve.h" #include "lib/fs_chains.h"
@@ -3114,30 +3113,6 @@ bool mlx5e_same_hw_devs(struct mlx5e_priv *priv, struct mlx5e_priv *peer_priv)return (fsystem_guid == psystem_guid); } -static int -add_vlan_prio_tag_rewrite_action (struct mlx5e_priv *priv, -struct mlx5e_tc_flow_parse_attr *parse_attr, -struct pedit_headers_action *hdrs, -u32 *action,struct netlink_ext_ack *extack) -{ -const struct flow_action_entry prio_tag_act = { - .vlan.vid =0 , - .vlan.prio = -MLX5_GET (fte_match_set_lyr_2_4, -mlx5e_get_match_headers_value (*action, - &parse_attr->spec), - first_prio) & -MLX5_GET (fte_match_set_lyr_2_4, -mlx5e_get_match_headers_criteria (*action, - &parse_attr->spec), - first_prio), - }; - -return mlx5e_tc_act_vlan_add_rewrite_action (priv,MLX5_FLOW_NAMESPACE_FDB , - &prio_tag_act, parse_attr, hdrs, action, - extack); -} -static int parse_tc_actions (struct mlx5e_tc_act_parse_state *parse_state,struct flow_action *flow_action)
@@ -3372,7 +3347,6 @@ parse_tc_fdb_actions(struct mlx5e_priv *priv,struct mlx5e_tc_flow *flow, struct netlink_ext_ack *extack) { - struct mlx5_eswitch *esw = priv->mdev->priv.eswitch; struct mlx5e_tc_act_parse_state *parse_state;struct mlx5e_tc_flow_parse_attr *parse_attr;struct mlx5_flow_attr *attr = flow->attr;
@@ -3403,18 +3377,6 @@ parse_tc_fdb_actions(struct mlx5e_priv *priv,return -EOPNOTSUPP ; } -if (MLX5_CAP_GEN (esw->dev, prio_tag_required) && - attr->action &MLX5_FLOW_CONTEXT_ACTION_VLAN_POP ) { -/* For prio tag mode, replace vlan pop with rewrite vlan prio -* tag rewrite. -*/ - attr->action &= ~MLX5_FLOW_CONTEXT_ACTION_VLAN_POP ; - err =add_vlan_prio_tag_rewrite_action (priv, parse_attr, hdrs, - &attr->action, extack); -if (err) -return err; - } - err =actions_prepare_mod_hdr_actions (priv, flow, attr, hdrs, extack);if (err)return err;
Signature · 1 line
2.31.1
PATCH 12/16 net/mlx5e: TC action parsing loop
In reply to Saeed MahameedFrom: Roi Dayan <[email protected]>
Introduce a common function to implement the generic parsing loop. The same function can be used for parsing NIC and FDB (Switchdev mode) flows.
--- .../net/ethernet/mellanox/mlx5/core/en_tc.c | 88 ++++++++++--------- 1 file changed, 46 insertions(+), 42 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +46 -42
@@ -3138,6 +3138,39 @@ add_vlan_prio_tag_rewrite_action(struct mlx5e_priv *priv, extack); } +static int +parse_tc_actions (struct mlx5e_tc_act_parse_state *parse_state, +struct flow_action *flow_action) +{ +struct netlink_ext_ack *extack = parse_state->extack; +struct mlx5e_tc_flow *flow = parse_state->flow; +struct mlx5_flow_attr *attr = flow->attr; +enum mlx5_flow_namespace_type ns_type; +struct mlx5e_priv *priv = flow->priv; +const struct flow_action_entry *act; +struct mlx5e_tc_act *tc_act; +int err, i; + + ns_type =mlx5e_get_flow_namespace (flow); + +flow_action_for_each (i, act, flow_action) { + tc_act =mlx5e_tc_act_get (act->id, ns_type); +if (!tc_act) { +NL_SET_ERR_MSG_MOD (extack,"Not implemented offload action" ); +return -EOPNOTSUPP ; + } + +if (!tc_act->can_offload (parse_state, act, i)) +return -EOPNOTSUPP ; + + err = tc_act->parse_action (parse_state, act, priv, attr); +if (err) +return err; + } + +return 0 ; +} + static int actions_prepare_mod_hdr_actions(struct mlx5e_priv *priv, struct mlx5e_tc_flow *flow,
@@ -3204,11 +3237,8 @@ parse_tc_nic_actions(struct mlx5e_priv *priv,struct mlx5e_tc_act_parse_state *parse_state;struct mlx5e_tc_flow_parse_attr *parse_attr;struct mlx5_flow_attr *attr = flow->attr; -enum mlx5_flow_namespace_type ns_type; -const struct flow_action_entry *act;struct pedit_headers_action *hdrs; -struct mlx5e_tc_act *tc_act; -int err, i; +int err; err =flow_action_supported (flow_action, extack);if (err)
@@ -3219,23 +3249,11 @@ parse_tc_nic_actions(struct mlx5e_priv *priv, parse_state = &parse_attr->parse_state;mlx5e_tc_act_init_parse_state (parse_state, flow, flow_action, extack); parse_state->ct_priv =get_ct_priv (priv); - ns_type =mlx5e_get_flow_namespace (flow); hdrs = parse_state->hdrs; -flow_action_for_each (i, act, flow_action) { - tc_act =mlx5e_tc_act_get (act->id, ns_type); -if (!tc_act) { -NL_SET_ERR_MSG_MOD (extack,"Not implemented offload action" ); -return -EOPNOTSUPP ; - } - -if (!tc_act->can_offload (parse_state, act, i)) -return -EOPNOTSUPP ; - - err = tc_act->parse_action (parse_state, act, priv, attr); -if (err) -return err; - } + err =parse_tc_actions (parse_state, flow_action); +if (err) +return err;if (attr->dest_chain && parse_attr->mirred_ifindex[0 ]) {NL_SET_ERR_MSG (extack,"Mirroring goto chain rules isn't supported" );
@@ -3337,21 +3355,19 @@ int mlx5e_set_fwd_to_int_port_actions(struct mlx5e_priv *priv,return 0 ; } -static int parse_tc_fdb_actions (struct mlx5e_priv *priv, -struct flow_action *flow_action, -struct mlx5e_tc_flow *flow, -struct netlink_ext_ack *extack) +static int +parse_tc_fdb_actions (struct mlx5e_priv *priv, +struct flow_action *flow_action, +struct mlx5e_tc_flow *flow, +struct netlink_ext_ack *extack) {struct mlx5_eswitch *esw = priv->mdev->priv.eswitch;struct mlx5e_tc_act_parse_state *parse_state;struct mlx5e_tc_flow_parse_attr *parse_attr;struct mlx5_flow_attr *attr = flow->attr; -enum mlx5_flow_namespace_type ns_type; -const struct flow_action_entry *act;struct mlx5_esw_flow_attr *esw_attr;struct pedit_headers_action *hdrs; -struct mlx5e_tc_act *tc_act; -int err, i; +int err; err =flow_action_supported (flow_action, extack);if (err)
@@ -3362,23 +3378,11 @@ static int parse_tc_fdb_actions(struct mlx5e_priv *priv, parse_state = &parse_attr->parse_state;mlx5e_tc_act_init_parse_state (parse_state, flow, flow_action, extack); parse_state->ct_priv =get_ct_priv (priv); - ns_type =mlx5e_get_flow_namespace (flow); hdrs = parse_state->hdrs; -flow_action_for_each (i, act, flow_action) { - tc_act =mlx5e_tc_act_get (act->id, ns_type); -if (!tc_act) { -NL_SET_ERR_MSG_MOD (extack,"Not implemented offload action" ); -return -EOPNOTSUPP ; - } - -if (!tc_act->can_offload (parse_state, act, i)) -return -EOPNOTSUPP ; - - err = tc_act->parse_action (parse_state, act, priv, attr); -if (err) -return err; - } + err =parse_tc_actions (parse_state, flow_action); +if (err) +return err;/* Forward to/from internal port can only have 1 dest */ if ((netif_is_ovs_master(parse_attr->filter_dev) || esw_attr->dest_int_port) &&
Signature · 1 line
2.31.1
PATCH 16/16 net/mlx5e: Move goto action checks into tc_action goto post parse op
In reply to Saeed MahameedFrom: Roi Dayan <[email protected]>
Move goto action checks from parse nic/fdb funcs into the tc action infra goto post parse op.
While moving this part also use NL_SET_ERR_MSG_MOD() instead of NL_SET_ERR_MSG().
--- .../mellanox/mlx5/core/en/tc/act/goto.c | 35 +++++++++++++++++++ .../net/ethernet/mellanox/mlx5/core/en_tc.c | 19 ---------- 2 files changed, 35 insertions(+), 19 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/goto.c +35 -0
@@ -81,7 +81,42 @@ tc_act_parse_goto(struct mlx5e_tc_act_parse_state *parse_state,return 0 ; } +static int +tc_act_post_parse_goto (struct mlx5e_tc_act_parse_state *parse_state, +struct mlx5e_priv *priv, +struct mlx5_flow_attr *attr) +{ +struct mlx5e_tc_flow_parse_attr *parse_attr = attr->parse_attr; +struct netlink_ext_ack *extack = parse_state->extack; +struct mlx5e_tc_flow *flow = parse_state->flow; + +if (!attr->dest_chain) +return 0 ; + +if (parse_state->decap) { +/* It can be supported if we'll create a mapping for +* the tunnel device only (without tunnel), and set +* this tunnel id with this decap flow. +* +* On restore (miss), we'll just set this saved tunnel +* device. +*/ + +NL_SET_ERR_MSG_MOD (extack,"Decap with goto isn't supported" ); +netdev_warn (priv->netdev,"Decap with goto isn't supported" ); +return -EOPNOTSUPP ; + } + +if (!mlx5e_is_eswitch_flow (flow) && parse_attr->mirred_ifindex[0 ]) { +NL_SET_ERR_MSG_MOD (extack,"Mirroring goto chain rules isn't supported" ); +return -EOPNOTSUPP ; + } + +return 0 ; +} +struct mlx5e_tc_act mlx5e_tc_act_goto = { .can_offload = tc_act_can_offload_goto, .parse_action = tc_act_parse_goto, + .post_parse = tc_act_post_parse_goto, };
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +0 -19
@@ -3241,11 +3241,6 @@ parse_tc_nic_actions(struct mlx5e_priv *priv,if (err)return err; -if (attr->dest_chain && parse_attr->mirred_ifindex[0 ]) { -NL_SET_ERR_MSG (extack,"Mirroring goto chain rules isn't supported" ); -return -EOPNOTSUPP ; - } - err =actions_prepare_mod_hdr_actions (priv, flow, attr, hdrs, extack);if (err)return err;
@@ -3384,20 +3379,6 @@ parse_tc_fdb_actions(struct mlx5e_priv *priv,if (!actions_match_supported (priv, flow_action, parse_attr, flow, extack))return -EOPNOTSUPP ; -if (attr->dest_chain && parse_state->decap) { -/* It can be supported if we'll create a mapping for -* the tunnel device only (without tunnel), and set -* this tunnel id with this decap flow. -* -* On restore (miss), we'll just set this saved tunnel -* device. -*/ - -NL_SET_ERR_MSG (extack,"Decap with goto isn't supported" ); -netdev_warn (priv->netdev,"Decap with goto isn't supported" ); -return -EOPNOTSUPP ; - } -return 0 ; }
Signature · 1 line
2.31.1
Re: [net-next v0 01/16] net/mlx5e: Add tc action infrastructure
In reply to Saeed MahameedThis series was applied to netdev/net-next.git (master) by Saeed Mahameed <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (master) by Saeed Mahameed <[email protected]>:
Quoted 8 lines · On Tue, 14 Dec 2021 21:32:45 -0800 you wrote:
From: Roi Dayan <[email protected]>
Add an infrastructure to help parsing tc actions in a generic way.
Supporting an action parser means implementing struct
mlx5e_tc_actfor that action.[...]
Here is the summary with links:
- [net-next,v0,01/16] net/mlx5e: Add tc action infrastructure
https://git.kernel.org/netdev/net-next/c/fad547906980 - [net-next,v0,02/16] net/mlx5e: Add goto to tc action infra https://git.kernel.org/netdev/net-next/c/67d62ee7f46b - [net-next,v0,03/16] net/mlx5e: Add tunnel encap/decap to tc action infra https://git.kernel.org/netdev/net-next/c/c65686d79c95 - [net-next,v0,04/16] net/mlx5e: Add csum to tc action infra https://git.kernel.org/netdev/net-next/c/9ca1bb2cf69b - [net-next,v0,05/16] net/mlx5e: Add pedit to tc action infra https://git.kernel.org/netdev/net-next/c/e36db1ee7a88 - [net-next,v0,06/16] net/mlx5e: Add vlan push/pop/mangle to tc action infra https://git.kernel.org/netdev/net-next/c/8ee72638347c - [net-next,v0,07/16] net/mlx5e: Add mpls push/pop to tc action infra https://git.kernel.org/netdev/net-next/c/163b766f5662 - [net-next,v0,08/16] net/mlx5e: Add mirred/redirect to tc action infra https://git.kernel.org/netdev/net-next/c/ab3f3d5efffa - [net-next,v0,09/16] net/mlx5e: Add ct to tc action infra https://git.kernel.org/netdev/net-next/c/758bc1342277 - [net-next,v0,10/16] net/mlx5e: Add sample and ptype to tc_action infra https://git.kernel.org/netdev/net-next/c/3929ff583d8e - [net-next,v0,11/16] net/mlx5e: Add redirect ingress to tc action infra https://git.kernel.org/netdev/net-next/c/922d69ed9666 - [net-next,v0,12/16] net/mlx5e: TC action parsing loop https://git.kernel.org/netdev/net-next/c/8333d53e3f74 - [net-next,v0,13/16] net/mlx5e: Move sample attr allocation to tc_action sample parse op https://git.kernel.org/netdev/net-next/c/6bcba1bdeda5 - [net-next,v0,14/16] net/mlx5e: Add post_parse() op to tc action infrastructure https://git.kernel.org/netdev/net-next/c/dd5ab6d11565 - [net-next,v0,15/16] net/mlx5e: Move vlan action chunk into tc action vlan post parse op https://git.kernel.org/netdev/net-next/c/c22080352ecf - [net-next,v0,16/16] net/mlx5e: Move goto action checks into tc_action goto post parse op https://git.kernel.org/netdev/net-next/c/35bb5242148f
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html