flow_offload: add tc vlan push_eth and pop_eth actions
Subsystems (4)
cover flow_offload: add tc vlan push_eth and pop_eth actions
Offloading vlan push_eth and pop_eth actions is needed in order to correctly offload MPLSoUDP encap and decap flows, this series extends the flow offload API to support these actions and updates mlx5 to parse them.
Maor Dickman (3):
net/sched: add vlan push_eth and pop_eth action to the hardware IR net/mlx5e: MPLSoUDP decap, use vlan push_eth instead of pedit net/mlx5e: MPLSoUDP encap, support action vlan pop_eth explicitly
.../mellanox/mlx5/core/en/tc/act/act.c | 7 +++ .../mellanox/mlx5/core/en/tc/act/act.h | 2 + .../mellanox/mlx5/core/en/tc/act/mirred.c | 10 ++++ .../mellanox/mlx5/core/en/tc/act/mpls.c | 7 ++- .../mellanox/mlx5/core/en/tc/act/pedit.c | 59 +++---------------- .../mellanox/mlx5/core/en/tc/act/pedit.h | 3 +- .../mellanox/mlx5/core/en/tc/act/vlan.c | 19 ++++-- .../mlx5/core/en/tc/act/vlan_mangle.c | 4 +- .../ethernet/mellanox/mlx5/core/en/tc_priv.h | 1 - .../mellanox/mlx5/core/en/tc_tun_encap.c | 10 ++-- .../net/ethernet/mellanox/mlx5/core/eswitch.h | 1 + include/net/flow_offload.h | 4 ++ include/net/tc_act/tc_vlan.h | 14 +++++ net/sched/act_vlan.c | 14 +++++ 14 files changed, 85 insertions(+), 70 deletions(-)
Signature · 1 line
2.34.1
PATCH 1/3 net/sched: add vlan push_eth and pop_eth action to the hardware IR
From: Maor Dickman <[email protected]>
Add vlan push_eth and pop_eth action to the hardware intermediate representation model which would subsequently allow it to be used by drivers for offload.
--- include/net/flow_offload.h | 4 ++++ include/net/tc_act/tc_vlan.h | 14 ++++++++++++++ net/sched/act_vlan.c | 14 ++++++++++++++ 3 files changed, 32 insertions(+)
include/net/flow_offload.h +4 -0
@@ -150,6 +150,8 @@ enum flow_action_id {FLOW_ACTION_PPPOE_PUSH ,FLOW_ACTION_JUMP ,FLOW_ACTION_PIPE , +FLOW_ACTION_VLAN_PUSH_ETH , +FLOW_ACTION_VLAN_POP_ETH , NUM_FLOW_ACTIONS, };
@@ -211,6 +213,8 @@ struct flow_action_entry {__be16 proto;u8 prio; } vlan; +unsigned char vlan_push_eth_dst[ETH_ALEN ]; +unsigned char vlan_push_eth_src[ETH_ALEN ];struct {/* FLOW_ACTION_MANGLE */ /* FLOW_ACTION_ADD */ enum flow_action_mangle_base htype;
include/net/tc_act/tc_vlan.h +14 -0
@@ -78,4 +78,18 @@ static inline u8 tcf_vlan_push_prio(const struct tc_action *a) return tcfv_push_prio; } + +static inline void tcf_vlan_push_dst (unsigned char *dest,const struct tc_action *a) +{ +rcu_read_lock (); +memcpy (dest,rcu_dereference (to_vlan (a)->vlan_p)->tcfv_push_dst,ETH_ALEN ); +rcu_read_unlock (); +} + +static inline void tcf_vlan_push_src (unsigned char *dest,const struct tc_action *a) +{ +rcu_read_lock (); +memcpy (dest,rcu_dereference (to_vlan (a)->vlan_p)->tcfv_push_src,ETH_ALEN ); +rcu_read_unlock (); +}#endif /* __NET_TC_VLAN_H */
net/sched/act_vlan.c +14 -0
@@ -390,6 +390,14 @@ static int tcf_vlan_offload_act_setup(struct tc_action *act, void *entry_data, entry->vlan.proto =tcf_vlan_push_proto (act); entry->vlan.prio =tcf_vlan_push_prio (act);break ; +case TCA_VLAN_ACT_POP_ETH : + entry->id =FLOW_ACTION_VLAN_POP_ETH ; +break ; +case TCA_VLAN_ACT_PUSH_ETH : + entry->id =FLOW_ACTION_VLAN_PUSH_ETH ; +tcf_vlan_push_dst (entry->vlan_push_eth_dst, act); +tcf_vlan_push_src (entry->vlan_push_eth_src, act); +break ;default :return -EOPNOTSUPP ; }
@@ -407,6 +415,12 @@ static int tcf_vlan_offload_act_setup(struct tc_action *act, void *entry_data,case TCA_VLAN_ACT_MODIFY : fl_action->id =FLOW_ACTION_VLAN_MANGLE ;break ; +case TCA_VLAN_ACT_POP_ETH : + fl_action->id =FLOW_ACTION_VLAN_POP_ETH ; +break ; +case TCA_VLAN_ACT_PUSH_ETH : + fl_action->id =FLOW_ACTION_VLAN_PUSH_ETH ; +break ;default :return -EOPNOTSUPP ; }
Signature · 1 line
2.34.1
Jakub Kicinski
maintainerRe: [PATCH net-next 1/3] net/sched: add vlan push_eth and pop_eth action to the hardware IR
Sorry for the late review.
include/net/flow_offload.h struct flow_action_entry { · line 217
Quoted 6 lines · On Wed, 9 Mar 2022 15:02:54 +0200 Roi Dayan wrote:
include/net/flow_offload.h +2
-0@@ -211,6 +213,8 @@ struct flow_action_entry {__be16 proto;u8 prio; } vlan; +unsigned char vlan_push_eth_dst[ETH_ALEN ]; +unsigned char vlan_push_eth_src[ETH_ALEN ];
Let's wrap these two in a struct, like all other members here, and add the customary comment indicating which action its for.
Quoted 15 lines
include/net/flow_offload.h +0
-0struct {/* FLOW_ACTION_MANGLE */ /* FLOW_ACTION_ADD */ enum flow_action_mangle_base htype;include/net/tc_act/tc_vlan.h +4
-0@@ -78,4 +78,18 @@ static inline u8 tcf_vlan_push_prio(const struct tc_action *a)return tcfv_push_prio; } + +static inline void tcf_vlan_push_dst (unsigned char *dest,const struct tc_action *a) +{ +rcu_read_lock ();
include/net/tc_act/tc_vlan.h static inline u8 tcf_vlan_push_prio(const struct tc_action *a) · line 94
Quoted 10 lines
include/net/tc_act/tc_vlan.h +10
-0+memcpy (dest,rcu_dereference (to_vlan (a)->vlan_p)->tcfv_push_dst,ETH_ALEN ); +rcu_read_unlock (); +} + +static inline void tcf_vlan_push_src (unsigned char *dest,const struct tc_action *a) +{ +rcu_read_lock (); +memcpy (dest,rcu_dereference (to_vlan (a)->vlan_p)->tcfv_push_src,ETH_ALEN ); +rcu_read_unlock (); +}
The use of these two helpers separately makes no sense, we can't push half a header. It should be one helper populating both src and dst, IMO.
Re: [PATCH net-next 1/3] net/sched: add vlan push_eth and pop_eth action to the hardware IR
Quoted 13 lines · Jakub Kicinski
Sorry for the late review.
include/net/flow_offload.h struct flow_action_entry { · line 217
Quoted 6 lines · On Wed, 9 Mar 2022 15:02:54 +0200 Roi Dayan wrote:
include/net/flow_offload.h +2
-0@@ -211,6 +213,8 @@ struct flow_action_entry {__be16 proto;u8 prio; } vlan; +unsigned char vlan_push_eth_dst[ETH_ALEN ]; +unsigned char vlan_push_eth_src[ETH_ALEN ];Let's wrap these two in a struct, like all other members here, and add the customary comment indicating which action its for.
ok.
Quoted 20 lines
Quoted 20 lines
include/net/flow_offload.h +0
-0struct {/* FLOW_ACTION_MANGLE */ /* FLOW_ACTION_ADD */ enum flow_action_mangle_base htype;include/net/tc_act/tc_vlan.h +9
-0@@ -78,4 +78,18 @@ static inline u8 tcf_vlan_push_prio(const struct tc_action *a)return tcfv_push_prio; } + +static inline void tcf_vlan_push_dst (unsigned char *dest,const struct tc_action *a) +{ +rcu_read_lock (); +memcpy (dest,rcu_dereference (to_vlan (a)->vlan_p)->tcfv_push_dst,ETH_ALEN ); +rcu_read_unlock (); +} + +static inline void tcf_vlan_push_src (unsigned char *dest,const struct tc_action *a)
Quoted 8 lines
include/net/tc_act/tc_vlan.h static inline u8 tcf_vlan_push_prio(const struct tc_action *a) · line 94
Quoted 5 lines
include/net/tc_act/tc_vlan.h +5
-0+{ +rcu_read_lock (); +memcpy (dest,rcu_dereference (to_vlan (a)->vlan_p)->tcfv_push_src,ETH_ALEN ); +rcu_read_unlock (); +}The use of these two helpers separately makes no sense, we can't push half a header. It should be one helper populating both src and dst, IMO.
ok.
PATCH 2/3 net/mlx5e: MPLSoUDP decap, use vlan push_eth instead of pedit
In reply to Roi DayanFrom: Maor Dickman <[email protected]>
Currently action pedit of source and destination MACs is used to fill the MACs in L2 push step in MPLSoUDP decap offload, this isn't aligned to tc SW which use vlan eth_push action to do this.
To fix that, offload support for vlan veth_push action is added together with mpls pop action, and deprecate the use of pedit of MACs.
Flow example:
filter protocol mpls_uc pref 1 flower chain 0 filter protocol mpls_uc pref 1 flower chain 0 handle 0x1
eth_type 8847
mpls_label 555
enc_dst_port 6635
in_hw in_hw_count 1
action order 1: tunnel_key unset pipe
index 2 ref 1 bind 1
used_hw_stats delayed
action order 2: mpls pop protocol ip pipe
index 2 ref 1 bind 1
used_hw_stats delayed
action order 3: vlan push_eth dst_mac de:a2:ec:d6:69:c8 src_mac de:a2:ec:d6:69:c8 pipe
index 2 ref 1 bind 1
used_hw_stats delayed
action order 4: mirred (Egress Redirect to device enp8s0f0_0) stolen index 2 ref 1 bind 1
used_hw_stats delayed
--- .../mellanox/mlx5/core/en/tc/act/act.c | 6 ++ .../mellanox/mlx5/core/en/tc/act/act.h | 1 + .../mellanox/mlx5/core/en/tc/act/mirred.c | 5 ++ .../mellanox/mlx5/core/en/tc/act/mpls.c | 7 ++- .../mellanox/mlx5/core/en/tc/act/pedit.c | 59 +++---------------- .../mellanox/mlx5/core/en/tc/act/pedit.h | 3 +- .../mellanox/mlx5/core/en/tc/act/vlan.c | 16 +++-- .../mlx5/core/en/tc/act/vlan_mangle.c | 4 +- .../ethernet/mellanox/mlx5/core/en/tc_priv.h | 1 - .../mellanox/mlx5/core/en/tc_tun_encap.c | 10 ++-- .../net/ethernet/mellanox/mlx5/core/eswitch.h | 1 + 11 files changed, 43 insertions(+), 70 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/act.c +6 -0
@@ -35,6 +35,12 @@ static struct mlx5e_tc_act *tc_acts_fdb[NUM_FLOW_ACTIONS] = {NULL ,/* FLOW_ACTION_CT_METADATA, */ &mlx5e_tc_act_mpls_push, &mlx5e_tc_act_mpls_pop, +NULL ,/* FLOW_ACTION_MPLS_MANGLE, */ +NULL ,/* FLOW_ACTION_GATE, */ +NULL ,/* FLOW_ACTION_PPPOE_PUSH, */ +NULL ,/* FLOW_ACTION_JUMP, */ +NULL ,/* FLOW_ACTION_PIPE, */ + &mlx5e_tc_act_vlan, };/* Must be aligned with enum flow_action_id. */
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/act.h +1 -0
@@ -22,6 +22,7 @@ struct mlx5e_tc_act_parse_state {bool encap;bool decap;bool mpls_push; +bool eth_push;bool ptype_host;const struct ip_tunnel_info *tun_info;struct mlx5e_mpls_info mpls_info;
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/mirred.c +5 -0
@@ -125,6 +125,11 @@ tc_act_can_offload_mirred(struct mlx5e_tc_act_parse_state *parse_state,return false; } +if (flow_flag_test (parse_state->flow,L3_TO_L2_DECAP ) && !parse_state->eth_push) { +NL_SET_ERR_MSG_MOD (extack,"mpls pop is only supported with vlan eth push" ); +return false; + } +if (mlx5e_is_ft_flow (flow) && out_dev == priv->netdev) {/* Ignore forward to self rules generated * by adding both mlx5 devs to the flow table
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/mpls.c +4 -3
@@ -57,12 +57,13 @@ tc_act_can_offload_mpls_pop(struct mlx5e_tc_act_parse_state *parse_state, filter_dev = attr->parse_attr->filter_dev;/* we only support mpls pop if it is the first action +* or it is second action after tunnel key unset * and the filter net device is bareudp. Subsequent * actions can be pedit and the last can be mirred * egress redirect. */ -if (act_index) { -NL_SET_ERR_MSG_MOD (extack,"mpls pop supported only as first action" ); +if ((act_index ==1 && !parse_state->decap) || act_index >1 ) { +NL_SET_ERR_MSG_MOD (extack,"mpls pop supported only as first action or with decap" );return false; }
@@ -80,7 +81,7 @@ tc_act_parse_mpls_pop(struct mlx5e_tc_act_parse_state *parse_state,struct mlx5e_priv *priv, struct mlx5_flow_attr *attr) { - attr->parse_attr->eth.h_proto = act->mpls_pop.proto; + attr->esw_attr->eth.h_proto = act->mpls_pop.proto; attr->action |=MLX5_FLOW_CONTEXT_ACTION_PACKET_REFORMAT ;flow_flag_set (parse_state->flow,L3_TO_L2_DECAP );
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/pedit.c +7 -52
86 lines not on this page · raw message
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/pedit.h +1 -2
@@ -24,8 +24,7 @@ struct pedit_headers_action {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 mlx5e_tc_flow *flow, +struct pedit_headers_action *hdrs,struct netlink_ext_ack *extack);#endif /* __MLX5_EN_TC_ACT_PEDIT_H__ */
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/vlan.c +12 -4
@@ -34,7 +34,8 @@ parse_tc_vlan_action(struct mlx5e_priv *priv,const struct flow_action_entry *act, struct mlx5_esw_flow_attr *attr, u32 *action, - struct netlink_ext_ack *extack) + struct netlink_ext_ack *extack, + struct mlx5e_tc_act_parse_state *parse_state) { u8 vlan_idx = attr->total_vlan;
@@ -84,6 +85,13 @@ parse_tc_vlan_action(struct mlx5e_priv *priv, *action |=MLX5_FLOW_CONTEXT_ACTION_VLAN_PUSH ; }break ; +case FLOW_ACTION_VLAN_PUSH_ETH : +if (!flow_flag_test (parse_state->flow,L3_TO_L2_DECAP )) +return -EOPNOTSUPP ; + parse_state->eth_push = true; +memcpy (attr->eth.h_dest, act->vlan_push_eth_dst,ETH_ALEN ); +memcpy (attr->eth.h_source, act->vlan_push_eth_src,ETH_ALEN ); +break ;default :NL_SET_ERR_MSG_MOD (extack,"Unexpected action id for VLAN" );return -EINVAL ;
@@ -109,7 +117,7 @@ mlx5e_tc_act_vlan_add_push_action(struct mlx5e_priv *priv, };int err; - err =parse_tc_vlan_action (priv, &vlan_act, attr->esw_attr, &attr->action, extack); + err =parse_tc_vlan_action (priv, &vlan_act, attr->esw_attr, &attr->action, extack,NULL );if (err)return err;
@@ -139,7 +147,7 @@ mlx5e_tc_act_vlan_add_pop_action(struct mlx5e_priv *priv, priv->netdev->lower_level;while (nest_level--) { err =parse_tc_vlan_action (priv, &vlan_act, attr->esw_attr, &attr->action, - extack); + extack,NULL );if (err)return err; }
@@ -174,7 +182,7 @@ tc_act_parse_vlan(struct mlx5e_tc_act_parse_state *parse_state, parse_state->extack); }else { err =parse_tc_vlan_action (priv, act, esw_attr, &attr->action, - parse_state->extack); + parse_state->extack, parse_state); }if (err)
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/vlan_mangle.c +2 -2
@@ -43,8 +43,8 @@ mlx5e_tc_act_vlan_add_rewrite_action(struct mlx5e_priv *priv, int namespace,return -EOPNOTSUPP ; } - err =mlx5e_tc_act_pedit_parse_action (priv, &pedit_act, namespace, parse_attr, -NULL , extack); + err =mlx5e_tc_act_pedit_parse_action (priv, &pedit_act, namespace, parse_attr->hdrs, + extack); *action |=MLX5_FLOW_CONTEXT_ACTION_MOD_HDR ;return err;
drivers/net/ethernet/mellanox/mlx5/core/en/tc_priv.h +0 -1
@@ -41,7 +41,6 @@ struct mlx5e_tc_flow_parse_attr {struct pedit_headers_action hdrs[__PEDIT_CMD_MAX];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; };
drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_encap.c +4 -6
@@ -906,20 +906,18 @@ int mlx5e_attach_decap(struct mlx5e_priv *priv,struct mlx5_eswitch *esw = priv->mdev->priv.eswitch;struct mlx5_esw_flow_attr *attr = flow->attr->esw_attr;struct mlx5_pkt_reformat_params reformat_params; -struct mlx5e_tc_flow_parse_attr *parse_attr;struct mlx5e_decap_entry *d;struct mlx5e_decap_key key;uintptr_t hash_key;int err =0 ; - parse_attr = flow->attr->parse_attr; -if (sizeof (parse_attr->eth) >MLX5_CAP_ESW (priv->mdev, max_encap_header_size)) { +if (sizeof (attr->eth) >MLX5_CAP_ESW (priv->mdev, max_encap_header_size)) {NL_SET_ERR_MSG_MOD (extack,"encap header larger than max supported" );return -EOPNOTSUPP ; } - key.key = parse_attr->eth; + key.key = attr->eth; hash_key =hash_decap_info (&key);mutex_lock (&esw->offloads.decap_tbl_lock); d =mlx5e_decap_get (priv, &key, hash_key);
@@ -949,8 +947,8 @@ int mlx5e_attach_decap(struct mlx5e_priv *priv,memset (&reformat_params,0 ,sizeof (reformat_params)); reformat_params.type =MLX5_REFORMAT_TYPE_L3_TUNNEL_TO_L2 ; - reformat_params.size =sizeof (parse_attr->eth); - reformat_params.data = &parse_attr->eth; + reformat_params.size =sizeof (attr->eth); + reformat_params.data = &attr->eth; d->pkt_reformat =mlx5_packet_reformat_alloc (priv->mdev, &reformat_params,MLX5_FLOW_NAMESPACE_FDB );
drivers/net/ethernet/mellanox/mlx5/core/eswitch.h +1 -0
@@ -474,6 +474,7 @@ struct mlx5_esw_flow_attr {int src_port_rewrite_act_id; } dests[MLX5_MAX_FLOW_FWD_VPORTS ];struct mlx5_rx_tun_attr *rx_tun_attr; +struct ethhdr eth;struct mlx5_pkt_reformat *decap_pkt_reformat; };
Signature · 1 line
2.34.1
Jakub Kicinski
maintainerRe: [PATCH net-next 2/3] net/mlx5e: MPLSoUDP decap, use vlan push_eth instead of pedit
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/vlan.c parse_tc_vlan_action(struct mlx5e_priv *priv, · line 94
Quoted 7 lines · On Wed, 9 Mar 2022 15:02:55 +0200 Roi Dayan wrote:
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/vlan.c +7
-0+case FLOW_ACTION_VLAN_PUSH_ETH : +if (!flow_flag_test (parse_state->flow,L3_TO_L2_DECAP )) +return -EOPNOTSUPP ; + parse_state->eth_push = true; +memcpy (attr->eth.h_dest, act->vlan_push_eth_dst,ETH_ALEN ); +memcpy (attr->eth.h_source, act->vlan_push_eth_src,ETH_ALEN ); +break ;
How does the device know the proto? I kind of expected this code will require some form of a match on proto.
Re: [PATCH net-next 2/3] net/mlx5e: MPLSoUDP decap, use vlan push_eth instead of pedit
Quoted 11 lines · Jakub Kicinski
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/vlan.c parse_tc_vlan_action(struct mlx5e_priv *priv, · line 94
Quoted 7 lines · On Wed, 9 Mar 2022 15:02:55 +0200 Roi Dayan wrote:
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/vlan.c +7
-0+case FLOW_ACTION_VLAN_PUSH_ETH : +if (!flow_flag_test (parse_state->flow,L3_TO_L2_DECAP )) +return -EOPNOTSUPP ; + parse_state->eth_push = true; +memcpy (attr->eth.h_dest, act->vlan_push_eth_dst,ETH_ALEN ); +memcpy (attr->eth.h_source, act->vlan_push_eth_src,ETH_ALEN ); +break ;How does the device know the proto? I kind of expected this code will require some form of a match on proto.
Vlan push_eth doesn't handle the protocol, it only push src/dst mac.
From tc-vlan man page:
PUSH_ETH := push_eth dst_mac LLADDR src_mac LLADDR
In the case of MPLSoUDP the protocol is set by mpls pop action, prior to the vlan push_eth action.
Example:
action order 2: mpls pop protocol ip pipe
index 2 ref 1 bind 1
used_hw_stats delayed
action order 3: vlan push_eth dst_mac de:a2:ec:d6:69:c8src_mac de:a2:ec:d6:69:c8 pipe
index 2 ref 1 bind 1
used_hw_stats delayed
Jakub Kicinski
maintainerRe: [PATCH net-next 2/3] net/mlx5e: MPLSoUDP decap, use vlan push_eth instead of pedit
Quoted 13 lines · On Tue, 15 Mar 2022 11:50:46 +0200 Roi Dayan wrote:
Quoted 11 lines · Jakub Kicinski
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/vlan.c parse_tc_vlan_action(struct mlx5e_priv *priv, · line 94
Quoted 7 lines · On Wed, 9 Mar 2022 15:02:55 +0200 Roi Dayan wrote:
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/vlan.c +7
-0+case FLOW_ACTION_VLAN_PUSH_ETH : +if (!flow_flag_test (parse_state->flow,L3_TO_L2_DECAP )) +return -EOPNOTSUPP ; + parse_state->eth_push = true; +memcpy (attr->eth.h_dest, act->vlan_push_eth_dst,ETH_ALEN ); +memcpy (attr->eth.h_source, act->vlan_push_eth_src,ETH_ALEN ); +break ;How does the device know the proto? I kind of expected this code will require some form of a match on proto.
Quoted 4 lines
Vlan
push_ethdoesn't handle the protocol, it only push src/dst mac.From tc-vlan man page:
PUSH_ETH:=push_ethdst_macLLADDRsrc_macLLADDR
It uses the protocol from skb.
Quoted 8 lines
In the case of MPLSoUDP the protocol is set by mpls pop action, prior to the vlan
push_ethaction.Example:
action order 2: mpls pop protocol ip pipe
index 2 ref 1 bind 1
used_hw_statsdelayed
Quoted 4 lines
action order 3: vlan
push_ethdst_macde:a2:ec:d6:69:c8src_macde:a2:ec:d6:69:c8 pipe
index 2 ref 1 bind 1
used_hw_statsdelayed
Ack, I was basically asking how the existence of an earlier mpls pop gets enforced by the driver.
PATCH 3/3 net/mlx5e: MPLSoUDP encap, support action vlan pop_eth explicitly
In reply to Roi DayanFrom: Maor Dickman <[email protected]>
Currently the MPLSoUDP encap offload does the L2 pop implicitly while adding such action explicitly (vlan eth_push) will cause the rule to not be offloaded.
Solve it by adding offload support for vlan eth_push in case of MPLSoUDP decap case.
Flow example:
filter root protocol ip pref 1 flower chain 0 filter root protocol ip pref 1 flower chain 0 handle 0x1
eth_type ipv4
dst_ip 2.2.2.22
src_ip 2.2.2.21
in_hw in_hw_count 1
action order 1: vlan pop_eth pipe
index 1 ref 1 bind 1
used_hw_stats delayed
action order 2: mpls push protocol mpls_uc label 555 tc 3 ttl 255 pipe
index 1 ref 1 bind 1
used_hw_stats delayed
action order 3: tunnel_key set
src_ip 8.8.8.21
dst_ip 8.8.8.22
dst_port 6635
csum
tos 0x4
ttl 6 pipe
index 1 ref 1 bind 1
used_hw_stats delayed
action order 4: mirred (Egress Redirect to device bareudp0) stolen index 1 ref 1 bind 1
used_hw_stats delayed
--- drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/act.c | 1 + drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/act.h | 1 + drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/mirred.c | 5 +++++ drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/vlan.c | 3 +++ 4 files changed, 10 insertions(+)
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/act.c +1 -0
@@ -41,6 +41,7 @@ static struct mlx5e_tc_act *tc_acts_fdb[NUM_FLOW_ACTIONS] = {NULL ,/* FLOW_ACTION_JUMP, */ NULL ,/* FLOW_ACTION_PIPE, */ &mlx5e_tc_act_vlan, + &mlx5e_tc_act_vlan, };/* Must be aligned with enum flow_action_id. */
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/act.h +1 -0
@@ -23,6 +23,7 @@ struct mlx5e_tc_act_parse_state {bool decap;bool mpls_push;bool eth_push; +bool eth_pop;bool ptype_host;const struct ip_tunnel_info *tun_info;struct mlx5e_mpls_info mpls_info;
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/mirred.c +5 -0
@@ -125,6 +125,11 @@ tc_act_can_offload_mirred(struct mlx5e_tc_act_parse_state *parse_state,return false; } +if (parse_state->eth_pop && !parse_state->mpls_push) { +NL_SET_ERR_MSG_MOD (extack,"vlan pop eth is supported only with mpls push" ); +return false; + } +if (flow_flag_test (parse_state->flow,L3_TO_L2_DECAP ) && !parse_state->eth_push) {NL_SET_ERR_MSG_MOD (extack,"mpls pop is only supported with vlan eth push" );return false;
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/vlan.c +3 -0
@@ -85,6 +85,9 @@ parse_tc_vlan_action(struct mlx5e_priv *priv, *action |=MLX5_FLOW_CONTEXT_ACTION_VLAN_PUSH ; }break ; +case FLOW_ACTION_VLAN_POP_ETH : + parse_state->eth_pop = true; +break ;case FLOW_ACTION_VLAN_PUSH_ETH :if (!flow_flag_test (parse_state->flow,L3_TO_L2_DECAP ))return -EOPNOTSUPP ;
Signature · 1 line
2.34.1