Handle multi chain hardware misses
Subsystems (7)
v3 cover Handle multi chain hardware misses
Hi David/Jakub/Saeed,
TC multi chain configuration can cause offloaded tc chains to miss in hardware after jumping to some chain. In such cases the software should continue from the chain that was missed in hardware, as the hardware may have manipulated the packet and updated some counters.
The first four patches enables tc classification to start from a specified chain by re-using the existing TC_SKB_EXT skb extension.
The next six patches are the Mellanox driver implementation of the miss path. The driver loads the last processed chain from HW register (reg_c0, then flow_tag) and stores it on the TC_SKB_EXT skb extension for continued processing in software.
The final six patches introduce the Mellanox driver implementation for handling tunnel restore when the packet was decapsulated on first chain hop. Early decapsulation creates two issues:
1. The outer headers will not be available in later chains
2. If the HW will miss on later chains, the packet will come up to software without the tunnel header. Therefore, sw matches on the tunnel info will miss.
Address these issues by mapping a unique id per tunnel info. The mapping is stored on hardware register (c1) when the packet is decapsulated. On miss, use the id to restore the tunnel info metadata on the skb.
Note that miss path handling of multi-chain rules is a required infrastructure for connection tracking hardware offload. The connection tracking offload series will follow this one.
Changelog:
v2-v3:
Split first patch to four
Paul Blakey (16):
net: sched: Introduce ingress classification function
net: sched: Pass ingress block to tcf_classify_ingress
net: sched: Change the block's chain list to an rcu list
net: sched: Support specifying a starting chain via tc skb ext net/mlx5: Introduce mapping infra for mapping unique ids to data net/mlx5: E-Switch, Move source port on reg_c0 to the upper 16 bits net/mlx5: E-Switch, Get reg_c0 value on CQE
net/mlx5: E-Switch, Mark miss packets with new chain id mapping net/mlx5e: Rx, Split rep rx mpwqe handler from nic net/mlx5: E-Switch, Restore chain id on miss
net/mlx5e: Allow re-allocating mod header actions net/mlx5e: Move tc tunnel parsing logic with the rest at tc_tun module net/mlx5e: Disallow inserting vxlan/vlan egress rules without
decap/pop
net/mlx5e: Support inner header rewrite with goto action net/mlx5: E-Switch, Get reg_c1 value on miss
net/mlx5e: Restore tunnel metadata on miss
drivers/infiniband/hw/mlx5/main.c | 3 +- drivers/net/ethernet/mellanox/mlx5/core/Makefile | 2 +- .../net/ethernet/mellanox/mlx5/core/en/mapping.c | 218 ++++++ .../net/ethernet/mellanox/mlx5/core/en/mapping.h | 27 + .../net/ethernet/mellanox/mlx5/core/en/tc_tun.c | 112 ++- .../net/ethernet/mellanox/mlx5/core/en/tc_tun.h | 3 +- drivers/net/ethernet/mellanox/mlx5/core/en_rep.c | 4 +- drivers/net/ethernet/mellanox/mlx5/core/en_rep.h | 7 + drivers/net/ethernet/mellanox/mlx5/core/en_rx.c | 66 ++ drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 818 ++++++++++++++++----- drivers/net/ethernet/mellanox/mlx5/core/en_tc.h | 45 ++ drivers/net/ethernet/mellanox/mlx5/core/eswitch.h | 15 + .../ethernet/mellanox/mlx5/core/eswitch_offloads.c | 240 +++++- .../mellanox/mlx5/core/eswitch_offloads_chains.c | 130 +++- .../mellanox/mlx5/core/eswitch_offloads_chains.h | 4 +- drivers/net/ethernet/mellanox/mlx5/core/fs_core.c | 4 +- include/linux/mlx5/eswitch.h | 31 +- include/net/pkt_cls.h | 13 + include/net/sch_generic.h | 3 + net/core/dev.c | 3 +- net/sched/cls_api.c | 98 ++- net/sched/sch_generic.c | 8 + net/sched/sch_ingress.c | 11 +- 23 files changed, 1619 insertions(+), 246 deletions(-) create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/en/mapping.c create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/en/mapping.h
Signature · 1 line
1.8.3.1
PATCH v3 1/16 net: sched: Introduce ingress classification function
TC multi chain configuration can cause offloaded tc chains to miss in hardware after jumping to some chain. In such cases the software should continue from the chain that missed in hardware, as the hardware may have manipulated the packet and updated some counters.
Currently a single tcf classification function serves both ingress and egress. However, multi chain miss processing (get tc skb extension on hw miss, set tc skb extension on tc miss) should happen only on ingress.
Refactor the code to use ingress classification function, and move setting the tc skb extension from general classification to it, as a prestep for supporting the hw miss scenario.
---
Changelog:
v2->v3
Split from v2 first patch
Defined tcf_classify_ingress so we only affect ingress classification Move setting the skb extension to ingress classification
include/net/pkt_cls.h | 10 +++++++++ net/core/dev.c | 3 ++- net/sched/cls_api.c | 58 ++++++++++++++++++++++++++++++++++++++------------- 3 files changed, 56 insertions(+), 15 deletions(-)
include/net/pkt_cls.h +10 -0
@@ -72,6 +72,8 @@ static inline struct Qdisc *tcf_block_q(struct tcf_block *block)int tcf_classify (struct sk_buff *skb,const struct tcf_proto *tp,struct tcf_result *res,bool compat_mode); +int tcf_classify_ingress (struct sk_buff *skb,const struct tcf_proto *tp, +struct tcf_result *res,bool compat_mode);#else static inline bool tcf_block_shared (struct tcf_block *block)
@@ -133,6 +135,14 @@ static inline int tcf_classify(struct sk_buff *skb, const struct tcf_proto *tp, {return TC_ACT_UNSPEC ; } + +static inline int tcf_classify_ingress (struct sk_buff *skb, +const struct tcf_proto *tp, +struct tcf_result *res,bool compat_mode) +{ +return TC_ACT_UNSPEC ; +} +#endif static inline unsigned long
net/core/dev.c +2 -1
@@ -4860,7 +4860,8 @@ static __latent_entropy void net_tx_action(struct softirq_action *h) skb->tc_at_ingress =1 ;mini_qdisc_bstats_cpu_update (miniq, skb); -switch (tcf_classify (skb, miniq->filter_list, &cl_res, false)) { +switch (tcf_classify_ingress (skb, miniq->filter_list, &cl_res, + false)) {case TC_ACT_OK :case TC_ACT_RECLASSIFY : skb->tc_index =TC_H_MIN (cl_res.classid);
net/sched/cls_api.c +44 -14
81 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH v3 2/16 net: sched: Pass ingress block to tcf_classify_ingress
In reply to Paul BlakeyOn ingress and cls_act qdiscs init, save the block on ingress mini_Qdisc and and pass it on to ingress classification, so it can be used for the looking up a specified chain index.
---
Changelog:
v2->v3
Split from v2 first patch
Init mini qdisc pairs' block on ingress/cls_act qdiscs init instead of head chain
include/net/pkt_cls.h | 7 +++++-- include/net/sch_generic.h | 3 +++ net/core/dev.c | 4 ++-- net/sched/cls_api.c | 4 +++- net/sched/sch_generic.c | 8 ++++++++ net/sched/sch_ingress.c | 11 ++++++++++- 6 files changed, 31 insertions(+), 6 deletions(-)
include/net/pkt_cls.h +5 -2
@@ -72,8 +72,10 @@ static inline struct Qdisc *tcf_block_q(struct tcf_block *block)int tcf_classify (struct sk_buff *skb,const struct tcf_proto *tp,struct tcf_result *res,bool compat_mode); -int tcf_classify_ingress (struct sk_buff *skb,const struct tcf_proto *tp, -struct tcf_result *res,bool compat_mode); +int tcf_classify_ingress (struct sk_buff *skb, +const struct tcf_block *ingress_block, +const struct tcf_proto *tp,struct tcf_result *res, +bool compat_mode);#else static inline bool tcf_block_shared (struct tcf_block *block)
@@ -137,6 +139,7 @@ static inline int tcf_classify(struct sk_buff *skb, const struct tcf_proto *tp, }static inline int tcf_classify_ingress (struct sk_buff *skb, +const struct tcf_block *ingress_block,const struct tcf_proto *tp,struct tcf_result *res,bool compat_mode) {
include/net/sch_generic.h +3 -0
@@ -1269,6 +1269,7 @@ static inline void psched_ratecfg_getrate(struct tc_ratespec *res,*/ struct mini_Qdisc {struct tcf_proto *filter_list; +struct tcf_block *block;struct gnet_stats_basic_cpu __percpu *cpu_bstats;struct gnet_stats_queue __percpu *cpu_qstats;struct rcu_head rcu;
@@ -1295,6 +1296,8 @@ void mini_qdisc_pair_swap(struct mini_Qdisc_pair *miniqp, struct tcf_proto *tp_head);void mini_qdisc_pair_init (struct mini_Qdisc_pair *miniqp,struct Qdisc *qdisc,struct mini_Qdisc __rcu **p_miniq); +void mini_qdisc_pair_block_init (struct mini_Qdisc_pair *miniqp, +struct tcf_block *block);static inline int skb_tc_reinsert (struct sk_buff *skb,struct tcf_result *res) {
net/core/dev.c +2 -2
@@ -4860,8 +4860,8 @@ static __latent_entropy void net_tx_action(struct softirq_action *h) skb->tc_at_ingress =1 ;mini_qdisc_bstats_cpu_update (miniq, skb); -switch (tcf_classify_ingress (skb, miniq->filter_list, &cl_res, - false)) { +switch (tcf_classify_ingress (skb, miniq->block, miniq->filter_list, + &cl_res, false)) {case TC_ACT_OK :case TC_ACT_RECLASSIFY : skb->tc_index =TC_H_MIN (cl_res.classid);
net/sched/cls_api.c +3 -1
@@ -1623,7 +1623,9 @@ int tcf_classify(struct sk_buff *skb, const struct tcf_proto *tp, }EXPORT_SYMBOL (tcf_classify); -int tcf_classify_ingress (struct sk_buff *skb,const struct tcf_proto *tp, +int tcf_classify_ingress (struct sk_buff *skb, +const struct tcf_block *ingress_block, +const struct tcf_proto *tp,struct tcf_result *res,bool compat_mode) {#if !IS_ENABLED (CONFIG_NET_TC_SKB_EXT )
net/sched/sch_generic.c +8 -0
@@ -1391,6 +1391,14 @@ void mini_qdisc_pair_swap(struct mini_Qdisc_pair *miniqp, }EXPORT_SYMBOL (mini_qdisc_pair_swap); +void mini_qdisc_pair_block_init (struct mini_Qdisc_pair *miniqp, +struct tcf_block *block) +{ + miniqp->miniq1.block = block; + miniqp->miniq2.block = block; +} +EXPORT_SYMBOL (mini_qdisc_pair_block_init); +void mini_qdisc_pair_init (struct mini_Qdisc_pair *miniqp,struct Qdisc *qdisc,struct mini_Qdisc __rcu **p_miniq) {
net/sched/sch_ingress.c +10 -1
@@ -78,6 +78,7 @@ static int ingress_init(struct Qdisc *sch, struct nlattr *opt, {struct ingress_sched_data *q =qdisc_priv (sch);struct net_device *dev =qdisc_dev (sch); +int err;net_inc_ingress_queue ();
@@ -87,7 +88,13 @@ static int ingress_init(struct Qdisc *sch, struct nlattr *opt, q->block_info.chain_head_change = clsact_chain_head_change; q->block_info.chain_head_change_priv = &q->miniqp; -return tcf_block_get_ext (&q->block, sch, &q->block_info, extack); + err =tcf_block_get_ext (&q->block, sch, &q->block_info, extack); +if (err) +return err; + +mini_qdisc_pair_block_init (&q->miniqp, q->block); + +return 0 ; }static void ingress_destroy (struct Qdisc *sch)
@@ -226,6 +233,8 @@ static int clsact_init(struct Qdisc *sch, struct nlattr *opt,if (err)return err; +mini_qdisc_pair_block_init (&q->miniqp_ingress, q->ingress_block); +mini_qdisc_pair_init (&q->miniqp_egress, sch, &dev->miniq_egress); q->egress_block_info.binder_type =FLOW_BLOCK_BINDER_TYPE_CLSACT_EGRESS ;
Signature · 1 line
1.8.3.1
PATCH v3 3/16 net: sched: Change the block's chain list to an rcu list
In reply to Paul BlakeyTo allow lookup of a block's chain under atomic context.
---
Changelog:
v2->v3
Split from v2 first patch
net/sched/cls_api.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
net/sched/cls_api.c +3 -2
@@ -22,6 +22,7 @@#include <linux/idr.h> #include <linux/rhashtable.h> #include <linux/jhash.h> +#include <linux/rculist.h> #include <net/net_namespace.h> #include <net/sock.h> #include <net/netlink.h>
@@ -354,7 +355,7 @@ static struct tcf_chain *tcf_chain_create(struct tcf_block *block, chain =kzalloc (sizeof (*chain),GFP_KERNEL );if (!chain)return NULL ; -list_add_tail (&chain->list, &block->chain_list); +list_add_tail_rcu (&chain->list, &block->chain_list);mutex_init (&chain->filter_chain_lock); chain->block = block; chain->index = chain_index;
@@ -394,7 +395,7 @@ static bool tcf_chain_detach(struct tcf_chain *chain)ASSERT_BLOCK_LOCKED (block); -list_del (&chain->list); +list_del_rcu (&chain->list);if (!chain->index) block->chain0.chain =NULL ;
Signature · 1 line
1.8.3.1
PATCH v3 4/16 net: sched: Support specifying a starting chain via tc skb ext
In reply to Paul BlakeySet the starting chain from the tc skb ext chain value. Once we read the tc skb ext, delete it, so cloned/redirect packets won't inherit it.
In order to lookup a chain by the chain index on the ingress block at ingress classification, provide a lookup function.
---
Changelog:
v2->v3
Split from v2 first patch
Do skb extension processing for ingress classification only Consume skb extension
net/sched/cls_api.c | 39 +++++++++++++++++++++++++++++++++++---- 1 file changed, 35 insertions(+), 4 deletions(-)
net/sched/cls_api.c +35 -4
@@ -454,6 +454,20 @@ static struct tcf_chain *tcf_chain_lookup(struct tcf_block *block,return NULL ; } +#if IS_ENABLED (CONFIG_NET_TC_SKB_EXT ) +static struct tcf_chain *tcf_chain_lookup_rcu (const struct tcf_block *block, +u32 chain_index) +{ +struct tcf_chain *chain; + +list_for_each_entry_rcu (chain, &block->chain_list, list) { +if (chain->index == chain_index) +return chain; + } +return NULL ; +} +#endif +static int tc_chain_notify (struct tcf_chain *chain,struct sk_buff *oskb,u32 seq,u16 flags,int event,bool unicast);
@@ -1562,13 +1576,13 @@ static int tcf_block_setup(struct tcf_block *block,*/ static inline int __tcf_classify (struct sk_buff *skb,const struct tcf_proto *tp, +const struct tcf_proto *orig_tp,struct tcf_result *res,bool compat_mode,u32 *last_executed_chain) {#ifdef CONFIG_NET_CLS_ACT const int max_reclassify_loop =4 ; -const struct tcf_proto *orig_tp = tp;const struct tcf_proto *first_tp;int limit =0 ;
@@ -1619,7 +1633,7 @@ int tcf_classify(struct sk_buff *skb, const struct tcf_proto *tp, {u32 last_executed_chain =0 ; -return __tcf_classify (skb, tp, res, compat_mode, +return __tcf_classify (skb, tp, tp, res, compat_mode, &last_executed_chain); }EXPORT_SYMBOL (tcf_classify);
@@ -1632,14 +1646,31 @@ int tcf_classify_ingress(struct sk_buff *skb,#if !IS_ENABLED (CONFIG_NET_TC_SKB_EXT )u32 last_executed_chain =0 ; -return __tcf_classify (skb, tp, res, compat_mode, +return __tcf_classify (skb, tp, tp, res, compat_mode, &last_executed_chain);#else u32 last_executed_chain = tp ? tp->chain->index :0 ; +const struct tcf_proto *orig_tp = tp;struct tc_skb_ext *ext;int ret; - ret =__tcf_classify (skb, tp, res, compat_mode, &last_executed_chain); + ext =skb_ext_find (skb,TC_SKB_EXT ); + +if (ext && ext->chain) { +struct tcf_chain *fchain; + + fchain =tcf_chain_lookup_rcu (ingress_block, ext->chain); +if (!fchain) +return TC_ACT_SHOT ; + +/* Consume, so cloned/redirect skbs won't inherit ext */ +skb_ext_del (skb,TC_SKB_EXT ); + + tp =rcu_dereference_bh (fchain->filter_chain); + } + + ret =__tcf_classify (skb, tp, orig_tp, res, compat_mode, + &last_executed_chain);/* If we missed on some chain */ if (ret ==TC_ACT_UNSPEC && last_executed_chain) {
Signature · 1 line
1.8.3.1
PATCH v3 5/16 net/mlx5: Introduce mapping infra for mapping unique ids to data
In reply to Paul BlakeyAdd a new interface for mapping data to a given id range (max_id), and back again. It uses xarray as the id allocator and for finding a given id. For locking it uses xa_lock (spin_lock) for add()/del(), and rcu_read_lock for find().
This mapping interface also supports delaying the mapping removal via a workqueue. This is for cases where we need the mapping to have some grace period in regards to finding it back again, for example for packets arriving from hardware that were marked with by a rule with an old mapping that no longer exists.
---
Changelog:
v2->v3
Scraped generic structure
Removed typeof()
Cleaner flush
Defined data[0] as data[] so comment isn't needed Changed from idr to xarray
use inline style definitions
Moved from lib to en
drivers/net/ethernet/mellanox/mlx5/core/Makefile | 2 +- .../net/ethernet/mellanox/mlx5/core/en/mapping.c | 218 +++++++++++++++++++++ .../net/ethernet/mellanox/mlx5/core/en/mapping.h | 27 +++ 3 files changed, 246 insertions(+), 1 deletion(-) create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/en/mapping.c create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/en/mapping.h
drivers/net/ethernet/mellanox/mlx5/core/Makefile +1 -1
@@ -34,7 +34,7 @@ mlx5_core-$(CONFIG_MLX5_EN_ARFS) += en_arfs.o mlx5_core-$(CONFIG_MLX5_EN_RXNFC) += en_fs_ethtool.o mlx5_core-$(CONFIG_MLX5_CORE_EN_DCB) += en_dcbnl.o en/port_buffer.o mlx5_core-$(CONFIG_MLX5_ESWITCH) += en_rep.o en_tc.o en/tc_tun.o lib/port_tun.o lag_mp.o \ - lib/geneve.o en/tc_tun_vxlan.o en/tc_tun_gre.o \ + lib/geneve.o en/mapping.o en/tc_tun_vxlan.o en/tc_tun_gre.o \ en/tc_tun_geneve.o diag/en_tc_tracepoint.o mlx5_core-$(CONFIG_PCI_HYPERV_INTERFACE) += en/hv_vhca_stats.o
drivers/net/ethernet/mellanox/mlx5/core/en/mapping.c new file +218 -0
218 lines not on this page · raw message
drivers/net/ethernet/mellanox/mlx5/core/en/mapping.h new file +27 -0
@@ -0,0 +1,27 @@ +/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */ +/* Copyright (c) 2019 Mellanox Technologies */ + +#ifndef __MLX5_MAPPING_H__ +#define __MLX5_MAPPING_H__ + +struct mapping_ctx ; + +int mapping_add (struct mapping_ctx *ctx,void *data,u32 *id); +int mapping_remove (struct mapping_ctx *ctx,u32 id); +int mapping_find (struct mapping_ctx *ctx,u32 id,void *data); + +/* mapping uses an xarray to map data to ids in add(), and for find(). +* For locking, it uses a internal xarray spin lock for add()/remove(), +* find() uses rcu_read_lock(). +* Choosing delayed_removal postpones the removal of a previously mapped +* id by MAPPING_GRACE_PERIOD milliseconds. +* This is to avoid races against hardware, where we mark the packet in +* hardware with a previous id, and quick remove() and add() reusing the same +* previous id. Then find() will get the new mapping instead of the old +* which was used to mark the packet. +*/ +struct mapping_ctx *mapping_create (size_t data_size,u32 max_id, +bool delayed_removal); +void mapping_destroy (struct mapping_ctx *ctx); + +#endif /* __MLX5_MAPPING_H__ */
Signature · 1 line
1.8.3.1
PATCH v3 6/16 net/mlx5: E-Switch, Move source port on reg_c0 to the upper 16 bits
In reply to Paul BlakeyMulti chain support requires the miss path to continue the processing from the last chain id, and for that we need to save the chain miss tag (a mapping for 32bit chain id) on reg_c0 which will come in a next patch.
Currently reg_c0 is exclusively used to store the source port metadata, giving it 32bit, it is created from 16bits of vcha_id, and 16bits of vport number.
We will move this source port metadata to upper 16bits, and leave the lower bits for the chain miss tag. We compress the reg_c0 source port metadata to 16bits by taking 8 bits from vhca_id, and 8bits from the vport number.
Since we compress the vport number to 8bits statically, and leave two top ids for special PF/ECPF numbers, we will only support a max of 254 vports with this strategy.
--- drivers/infiniband/hw/mlx5/main.c | 3 +- .../ethernet/mellanox/mlx5/core/eswitch_offloads.c | 64 ++++++++++++++++++---- include/linux/mlx5/eswitch.h | 29 +++++++++- 3 files changed, 83 insertions(+), 13 deletions(-)
drivers/infiniband/hw/mlx5/main.c +2 -1
@@ -3570,7 +3570,8 @@ static void mlx5_ib_set_rule_source_port(struct mlx5_ib_dev *dev, misc =MLX5_ADDR_OF (fte_match_param, spec->match_criteria, misc_parameters_2); -MLX5_SET_TO_ONES (fte_match_set_misc2, misc, metadata_reg_c_0); +MLX5_SET (fte_match_set_misc2, misc, metadata_reg_c_0, +mlx5_eswitch_get_vport_metadata_mask ()); }else { misc =MLX5_ADDR_OF (fte_match_param, spec->match_value, misc_parameters);
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +54 -10
103 lines not on this page · raw message
include/linux/mlx5/eswitch.h +27 -2
@@ -71,7 +71,26 @@ enum devlink_eswitch_encap_mode mlx5_eswitch_get_encap_mode(const struct mlx5_core_dev *dev);bool mlx5_eswitch_vport_match_metadata_enabled (const struct mlx5_eswitch *esw); -u32 mlx5_eswitch_get_vport_metadata_for_match (const struct mlx5_eswitch *esw, + +/* Reg C0 usage: +* Reg C0 = < ESW_VHCA_ID_BITS(8) | ESW_VPORT BITS(8) | ESW_CHAIN_TAG(16) > +* +* Highest 8 bits of the reg c0 is the vhca_id, next 8 bits is vport_num, +* the rest (lowest 16 bits) is left for tc chain tag restoration. +* VHCA_ID + VPORT comprise the SOURCE_PORT matching. +*/ +#define ESW_VHCA_ID_BITS 8 +#define ESW_VPORT_BITS 8 +#define ESW_SOURCE_PORT_METADATA_BITS (ESW_VHCA_ID_BITS + ESW_VPORT_BITS) +#define ESW_SOURCE_PORT_METADATA_OFFSET (32 - ESW_SOURCE_PORT_METADATA_BITS) +#define ESW_CHAIN_TAG_METADATA_BITS (32 - ESW_SOURCE_PORT_METADATA_BITS) + +static inline u32 mlx5_eswitch_get_vport_metadata_mask (void ) +{ +return GENMASK (31 ,32 -ESW_SOURCE_PORT_METADATA_BITS ); +} + +u32 mlx5_eswitch_get_vport_metadata_for_match (struct mlx5_eswitch *esw,u16 vport_num);u8 mlx5_eswitch_mode (struct mlx5_eswitch *esw);#else /* CONFIG_MLX5_ESWITCH */
@@ -94,11 +113,17 @@ static inline u8 mlx5_eswitch_mode(struct mlx5_eswitch *esw) };static inline u32 -mlx5_eswitch_get_vport_metadata_for_match (const struct mlx5_eswitch *esw, +mlx5_eswitch_get_vport_metadata_for_match (struct mlx5_eswitch *esw,int vport_num) {return 0 ; }; + +static inline u32 +mlx5_eswitch_get_vport_metadata_mask (void ) +{ +return 0 ; +}#endif /* CONFIG_MLX5_ESWITCH */ #endif
Signature · 1 line
1.8.3.1
PATCH v3 7/16 net/mlx5: E-Switch, Get reg_c0 value on CQE
In reply to Paul BlakeyOn RX side create a restore table in OFFLOADS namespace. This table will match on all values for reg_c0 we will use, and set it to the flow_tag. This flow tag can then be read on the CQE.
As there is no copy action from reg c0 to flow tag, instead we have to set the flow tag explictily. We add an API so callers can add all the used reg_c0 values (tags) and for each of those we add a restore rule.
This will be used in a following patch to save the miss chain mapping tag on reg_c0 and from it restore the tc chain on the skb.
--- drivers/net/ethernet/mellanox/mlx5/core/eswitch.h | 14 ++ .../ethernet/mellanox/mlx5/core/eswitch_offloads.c | 147 +++++++++++++++++++-- drivers/net/ethernet/mellanox/mlx5/core/fs_core.c | 4 +- include/linux/mlx5/eswitch.h | 2 + 4 files changed, 156 insertions(+), 11 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/eswitch.h +14 -0
@@ -189,6 +189,9 @@ struct mlx5_eswitch_fdb { };struct mlx5_esw_offload { +struct mlx5_flow_table *ft_offloads_restore; +struct mlx5_flow_group *restore_group; +struct mlx5_flow_table *ft_offloads;struct mlx5_flow_group *vport_rx_group;struct mlx5_eswitch_rep *vport_reps;
@@ -623,6 +626,11 @@ struct mlx5_vport *__must_check esw_vport_destroy_offloads_acl_tables(struct mlx5_eswitch *esw, struct mlx5_vport *vport); +struct mlx5_flow_handle * +esw_add_restore_rule (struct mlx5_eswitch *esw,u32 tag); +u32 +esw_get_max_restore_tag (struct mlx5_eswitch *esw); +#else /* CONFIG_MLX5_ESWITCH */ /* eswitch API stubs */ static inline int mlx5_eswitch_init (struct mlx5_core_dev *dev) {return 0 ; }
@@ -638,6 +646,12 @@ static inline const u32 *mlx5_esw_query_functions(struct mlx5_core_dev *dev)static inline void mlx5_eswitch_update_num_of_vfs (struct mlx5_eswitch *esw,const int num_vfs) {} +static struct mlx5_flow_handle * +esw_add_restore_rule (struct mlx5_eswitch *esw,u32 tag) +{ +return ERR_PTR (-EOPNOTSUPP ); +} +#endif /* CONFIG_MLX5_ESWITCH */ #endif /* __MLX5_ESWITCH_H__ */
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +138 -9
189 lines not on this page · raw message
drivers/net/ethernet/mellanox/mlx5/core/fs_core.c +2 -2
@@ -111,8 +111,8 @@#define ANCHOR_MIN_LEVEL (BY_PASS_MIN_LEVEL + 1)#define OFFLOADS_MAX_FT 1 -#define OFFLOADS_NUM_PRIOS 1 -#define OFFLOADS_MIN_LEVEL (ANCHOR_MIN_LEVEL + 1) +#define OFFLOADS_NUM_PRIOS 2 +#define OFFLOADS_MIN_LEVEL (ANCHOR_MIN_LEVEL + OFFLOADS_NUM_PRIOS)#define LAG_PRIO_NUM_LEVELS 1#define LAG_NUM_PRIOS 1
include/linux/mlx5/eswitch.h +2 -0
@@ -84,6 +84,8 @@ enum devlink_eswitch_encap_mode#define ESW_SOURCE_PORT_METADATA_BITS (ESW_VHCA_ID_BITS + ESW_VPORT_BITS)#define ESW_SOURCE_PORT_METADATA_OFFSET (32 - ESW_SOURCE_PORT_METADATA_BITS)#define ESW_CHAIN_TAG_METADATA_BITS (32 - ESW_SOURCE_PORT_METADATA_BITS) +#define ESW_CHAIN_TAG_METADATA_MASK GENMASK(ESW_CHAIN_TAG_METADATA_BITS - 1,\ + 0)static inline u32 mlx5_eswitch_get_vport_metadata_mask (void ) {
Signature · 1 line
1.8.3.1
PATCH 1/1 net/mlx5: Add missing inline to stub esw_add_restore_rule
When CONFIG_MLX5_ESWITCH is unset, clang warns:
In file included from drivers/net/ethernet/mellanox/mlx5/core/main.c:58:drivers/net/ethernet/mellanox/mlx5/core/eswitch.h:670:1: warning: unused function 'esw_add_restore_rule' [-Wunused-function] esw_add_restore_rule(struct mlx5_eswitch *esw, u32 tag)
^
1 warning generated.
This stub function is missing inline; add it to suppress the warning.
--- drivers/net/ethernet/mellanox/mlx5/core/eswitch.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/eswitch.h +1 -1
@@ -666,7 +666,7 @@ static inline const u32 *mlx5_esw_query_functions(struct mlx5_core_dev *dev)static inline void mlx5_eswitch_update_num_of_vfs (struct mlx5_eswitch *esw,const int num_vfs) {} -static struct mlx5_flow_handle * +static inline struct mlx5_flow_handle *esw_add_restore_rule (struct mlx5_eswitch *esw,u32 tag) {return ERR_PTR (-EOPNOTSUPP );
Signature · 1 line
2.26.0.rc1
Re: [PATCH -next] net/mlx5: Add missing inline to stub esw_add_restore_rule
Quoted 10 lines · Nathan Chancellor
When
CONFIG_MLX5_ESWITCHis unset, clang warns:In file included from
drivers/net/ethernet/mellanox/mlx5/core/main.c:58:drivers/net/ethernet/mellanox/mlx5/core/eswitch.h:670:1: warning: unused function 'esw_add_restore_rule' [-Wunused-function]esw_add_restore_rule(struct mlx5_eswitch *esw, u32 tag)
^
1 warning generated.
Quoted 4 lines
This stub function is missing inline; add it to suppress the warning.
Fixes 11b717d61526 ("net/mlx5: E-Switch, Get reg_c0 value on CQE")Signed-off-by Nathan Chancellor <[email protected]>
Yep, thanks for the patch!
Quoted 24 lines
--- drivers/net/ethernet/mellanox/mlx5/core/eswitch.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/ethernet/mellanox/mlx5/core/eswitch.h +1
-2@@ -666,7 +666,7 @@ static inline const u32 *mlx5_esw_query_functions(struct mlx5_core_dev *dev)static inline void mlx5_eswitch_update_num_of_vfs (struct mlx5_eswitch *esw,const int num_vfs) {} -static struct mlx5_flow_handle * +static inline struct mlx5_flow_handle *esw_add_restore_rule (struct mlx5_eswitch *esw,u32 tag) {return ERR_PTR (-EOPNOTSUPP ); --2.26.0.rc1
--
You received this message because you are subscribed to the Google Groups "Clang Built Linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/clang-built-linux/20200314034019.3374-1-natechancellor%40gmail.com.
Signature · 2 lines
Thanks, ~Nick Desaulniers
Saeed Mahameed
AppliedRe: [PATCH -next] net/mlx5: Add missing inline to stub esw_add_restore_rule
In reply to Nathan ChancellorQuoted 33 lines · Nathan Chancellor
When
CONFIG_MLX5_ESWITCHis unset, clang warns:In file included from
drivers/net/ethernet/mellanox/mlx5/core/main.c:58:drivers/net/ethernet/mellanox/mlx5/core/eswitch.h:670:1: warning:
unused
function 'esw_add_restore_rule' [-Wunused-function]esw_add_restore_rule(struct mlx5_eswitch *esw, u32 tag)^
1 warning generated.This stub function is missing inline; add it to suppress the warning.
Fixes 11b717d61526 ("net/mlx5: E-Switch, Get reg_c0 value on CQE")Signed-off-by Nathan Chancellor <[email protected]>--- drivers/net/ethernet/mellanox/mlx5/core/eswitch.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/ethernet/mellanox/mlx5/core/eswitch.h +1
-1@@ -666,7 +666,7 @@ static inline const u32 *mlx5_esw_query_functions(struct mlx5_core_dev *dev)static inline void mlx5_eswitch_update_num_of_vfs (struct mlx5_eswitch *esw,const int num_vfs) {} -static struct mlx5_flow_handle * +static inline struct mlx5_flow_handle *esw_add_restore_rule (struct mlx5_eswitch *esw,u32 tag)
Quoted 2 lines
{
returnERR_PTR(-EOPNOTSUPP);
Applied to net-next-mlx5
Thanks,
Saeed.
PATCH v3 8/16 net/mlx5: E-Switch, Mark miss packets with new chain id mapping
In reply to Paul BlakeyCurrently, if we miss in hardware after jumping to some chain, we continue in chain 0 in software. This is wrong, and with the new tc skb extension we can now restore the chain id on the skb, so tc can continue with in the correct chain.
To restore the chain id in software after a miss in hardware, we create a register mapping from 32bit chain ids to 16bit of reg_c0 (that survives loopback), to 32bit chain ids. We then mark packets that miss on some chain with the current chain id mapping on their reg_c0 field. Using this mapping, we will support up to 64K concurrent chains.
This register survives loopback and gets to the CQE on flow_tag via the eswitch restore rules.
In next commit, we will reverse the mapping we got on the CQE to a chain id and tell tc to continue in the sw chain where we left off via the tc skb extension.
--- drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 8 ++ drivers/net/ethernet/mellanox/mlx5/core/en_tc.h | 12 ++ .../mellanox/mlx5/core/eswitch_offloads_chains.c | 130 ++++++++++++++++++++- .../mellanox/mlx5/core/eswitch_offloads_chains.h | 4 +- 4 files changed, 150 insertions(+), 4 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +8 -0
@@ -153,6 +153,14 @@ struct mlx5e_tc_flow_parse_attr {#define MLX5E_TC_TABLE_NUM_GROUPS 4#define MLX5E_TC_TABLE_MAX_GROUP_SIZE BIT(16) +struct mlx5e_tc_attr_to_reg_mapping mlx5e_tc_attr_to_reg_mappings[] = { + [CHAIN_TO_REG ] = { + .mfield =MLX5_ACTION_IN_FIELD_METADATA_REG_C_0 , + .moffset =0 , + .mlen =2 , + }, +}; +struct mlx5e_hairpin {struct mlx5_hairpin *pair;
drivers/net/ethernet/mellanox/mlx5/core/en_tc.h +12 -0
@@ -91,6 +91,18 @@ void mlx5e_tc_encap_flows_del(struct mlx5e_priv *priv,void mlx5e_tc_reoffload_flows_work (struct work_struct *work); +enum mlx5e_tc_attr_to_reg { +CHAIN_TO_REG , +}; + +struct mlx5e_tc_attr_to_reg_mapping { +int mfield;/* rewrite field */ +int moffset;/* offset of mfield */ +int mlen;/* bytes to rewrite/match */ +}; + +extern struct mlx5e_tc_attr_to_reg_mapping mlx5e_tc_attr_to_reg_mappings[]; +bool mlx5e_is_valid_eswitch_fwd_dev (struct mlx5e_priv *priv,struct net_device *out_dev);
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads_chains.c +127 -3
235 lines not on this page · raw message
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads_chains.h +3 -1
@@ -26,5 +26,7 @@ struct mlx5_flow_table *int mlx5_esw_chains_create (struct mlx5_eswitch *esw);void mlx5_esw_chains_destroy (struct mlx5_eswitch *esw); -#endif /* __ML5_ESW_CHAINS_H__ */ +int +mlx5_eswitch_get_chain_for_tag (struct mlx5_eswitch *esw,u32 tag,u32 *chain); +#endif /* __ML5_ESW_CHAINS_H__ */
Signature · 1 line
1.8.3.1
PATCH v3 9/16 net/mlx5e: Rx, Split rep rx mpwqe handler from nic
In reply to Paul BlakeyCopy the current rep mpwqe rx handler which is also used by nic profile. In the next patch, we will add rep specific logic, just for the rep profile rx handler.
--- drivers/net/ethernet/mellanox/mlx5/core/en_rep.c | 4 +- drivers/net/ethernet/mellanox/mlx5/core/en_rep.h | 2 + drivers/net/ethernet/mellanox/mlx5/core/en_rx.c | 54 ++++++++++++++++++++++++ 3 files changed, 58 insertions(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c +2 -2
@@ -1921,7 +1921,7 @@ static unsigned int mlx5e_ul_rep_stats_grps_num(struct mlx5e_priv *priv) .update_rx = mlx5e_update_rep_rx, .update_stats = mlx5e_update_ndo_stats, .rx_handlers.handle_rx_cqe = mlx5e_handle_rx_cqe_rep, - .rx_handlers.handle_rx_cqe_mpwqe = mlx5e_handle_rx_cqe_mpwrq, + .rx_handlers.handle_rx_cqe_mpwqe = mlx5e_handle_rx_cqe_mpwrq_rep, .max_tc = 1, .rq_groups = MLX5E_NUM_RQ_GROUPS(REGULAR), .stats_grps = mlx5e_rep_stats_grps,
@@ -1941,7 +1941,7 @@ static unsigned int mlx5e_ul_rep_stats_grps_num(struct mlx5e_priv *priv) .update_stats = mlx5e_update_ndo_stats, .update_carrier = mlx5e_update_carrier, .rx_handlers.handle_rx_cqe = mlx5e_handle_rx_cqe_rep, - .rx_handlers.handle_rx_cqe_mpwqe = mlx5e_handle_rx_cqe_mpwrq, + .rx_handlers.handle_rx_cqe_mpwqe = mlx5e_handle_rx_cqe_mpwrq_rep, .max_tc = MLX5E_MAX_NUM_TC, .rq_groups = MLX5E_NUM_RQ_GROUPS(REGULAR), .stats_grps = mlx5e_ul_rep_stats_grps,
drivers/net/ethernet/mellanox/mlx5/core/en_rep.h +2 -0
@@ -191,6 +191,8 @@ struct mlx5e_rep_sq {void mlx5e_remove_sqs_fwd_rules (struct mlx5e_priv *priv);void mlx5e_handle_rx_cqe_rep (struct mlx5e_rq *rq,struct mlx5_cqe64 *cqe); +void mlx5e_handle_rx_cqe_mpwrq_rep (struct mlx5e_rq *rq, +struct mlx5_cqe64 *cqe);int mlx5e_rep_encap_entry_attach (struct mlx5e_priv *priv,struct mlx5e_encap_entry *e);
drivers/net/ethernet/mellanox/mlx5/core/en_rx.c +54 -0
60 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH v3 10/16 net/mlx5: E-Switch, Restore chain id on miss
In reply to Paul BlakeyChain ids are mapped to the lower part of reg C, and after loopback are copied to to CQE via a restore rule's flow_tag.
To let tc continue in the correct chain, we find the corresponding chain id in the eswitch chain id <-> reg C mapping, and set the SKB's tc extension chain to it.
That tells tc to continue processing from this set chain.
--- drivers/net/ethernet/mellanox/mlx5/core/en_rx.c | 6 ++++ drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 43 +++++++++++++++++++++++++ drivers/net/ethernet/mellanox/mlx5/core/en_tc.h | 2 ++ 3 files changed, 51 insertions(+)
drivers/net/ethernet/mellanox/mlx5/core/en_rx.c +6 -0
@@ -1225,6 +1225,9 @@ void mlx5e_handle_rx_cqe_rep(struct mlx5e_rq *rq, struct mlx5_cqe64 *cqe)if (rep->vlan &&skb_vlan_tag_present (skb))skb_vlan_pop (skb); +if (!mlx5e_tc_rep_update_skb (cqe, skb)) + goto free_wqe; +napi_gro_receive (rq->cq.napi, skb); free_wqe:
@@ -1275,6 +1278,9 @@ void mlx5e_handle_rx_cqe_mpwrq_rep(struct mlx5e_rq *rq,mlx5e_complete_rx_cqe (rq, cqe, cqe_bcnt, skb); +if (!mlx5e_tc_rep_update_skb (cqe, skb)) + goto mpwrq_cqe_out; +napi_gro_receive (rq->cq.napi, skb); mpwrq_cqe_out:
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +43 -0
46 lines not on this page · raw message
drivers/net/ethernet/mellanox/mlx5/core/en_tc.h +2 -0
@@ -106,6 +106,8 @@ struct mlx5e_tc_attr_to_reg_mapping {bool mlx5e_is_valid_eswitch_fwd_dev (struct mlx5e_priv *priv,struct net_device *out_dev); +bool mlx5e_tc_rep_update_skb (struct mlx5_cqe64 *cqe,struct sk_buff *skb); +#else /* CONFIG_MLX5_ESWITCH */ static inline int mlx5e_tc_nic_init (struct mlx5e_priv *priv) {return 0 ; }static inline void mlx5e_tc_nic_cleanup (struct mlx5e_priv *priv) {}
Signature · 1 line
1.8.3.1
PATCH v3 11/16 net/mlx5e: Allow re-allocating mod header actions
In reply to Paul BlakeyCurrently the size of the mod header actions array is deduced from the number of parsed TC header rewrite actions. However, mod header actions are also used for setting HW register values. Support the dynamic reallocation of the mod header array as a pre-step for adding HW registers mod actions.
--- drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 120 +++++++++++++----------- drivers/net/ethernet/mellanox/mlx5/core/en_tc.h | 11 +++ 2 files changed, 76 insertions(+), 55 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +65 -55
@@ -144,9 +144,7 @@ struct mlx5e_tc_flow_parse_attr {const struct ip_tunnel_info *tun_info[MLX5_MAX_FLOW_FWD_VPORTS ];struct net_device *filter_dev;struct mlx5_flow_spec spec; -int num_mod_hdr_actions; -int max_mod_hdr_actions; -void *mod_hdr_actions; +struct mlx5e_tc_mod_hdr_acts mod_hdr_acts;int mirred_ifindex[MLX5_MAX_FLOW_FWD_VPORTS ]; };
@@ -369,10 +367,10 @@ static int mlx5e_attach_mod_hdr(struct mlx5e_priv *priv,struct mod_hdr_key key;u32 hash_key; - num_actions = parse_attr->num_mod_hdr_actions; + num_actions = parse_attr->mod_hdr_acts.num_actions; actions_size =MLX5_MH_ACT_SZ * num_actions; - key.actions = parse_attr->mod_hdr_actions; + key.actions = parse_attr->mod_hdr_acts.actions; key.num_actions = num_actions; hash_key =hash_mod_hdr_info (&key);
@@ -962,7 +960,7 @@ static void mlx5e_hairpin_flow_del(struct mlx5e_priv *priv,if (attr->action &MLX5_FLOW_CONTEXT_ACTION_MOD_HDR ) { err =mlx5e_attach_mod_hdr (priv, flow, parse_attr); flow_act.modify_hdr = attr->modify_hdr; -kfree (parse_attr->mod_hdr_actions); +dealloc_mod_hdr_actions (&parse_attr->mod_hdr_acts);if (err)return err; }
@@ -1228,7 +1226,7 @@ static void remove_unready_flow(struct mlx5e_tc_flow *flow)if (attr->action &MLX5_FLOW_CONTEXT_ACTION_MOD_HDR ) { err =mlx5e_attach_mod_hdr (priv, flow, parse_attr); -kfree (parse_attr->mod_hdr_actions); +dealloc_mod_hdr_actions (&parse_attr->mod_hdr_acts);if (err)return err; }
@@ -2391,25 +2389,26 @@ static bool cmp_val_mask(void *valp, void *maskp, void *matchvalp, OFFLOAD(UDP_DPORT, 16, U16_MAX, udp.dest, 0, udp_dport), }; -/* On input attr->max_mod_hdr_actions tells how many HW actions can be parsed at -* max from the SW pedit action. On success, attr->num_mod_hdr_actions -* says how many HW actions were actually parsed. -*/ -static int offload_pedit_fields (struct pedit_headers_action *hdrs, +static int offload_pedit_fields (struct mlx5e_priv *priv, +int namespace, +struct pedit_headers_action *hdrs,struct mlx5e_tc_flow_parse_attr *parse_attr,u32 *action_flags,struct netlink_ext_ack *extack) {struct pedit_headers *set_masks, *add_masks, *set_vals, *add_vals; -int i, action_size, nactions, max_actions, first, last, next_z; +int i, action_size, first, last, next_z;void *headers_c, *headers_v, *action, *vals_p;u32 *s_masks_p, *a_masks_p, s_mask, a_mask; +struct mlx5e_tc_mod_hdr_acts *mod_acts;struct mlx5_fields *f;unsigned long mask;__be32 mask_be32;__be16 mask_be16; +int err;u8 cmd; + mod_acts = &parse_attr->mod_hdr_acts; headers_c =get_match_headers_criteria (*action_flags, &parse_attr->spec); headers_v =get_match_headers_value (*action_flags, &parse_attr->spec);
@@ -2419,11 +2418,6 @@ static int offload_pedit_fields(struct pedit_headers_action *hdrs, add_vals = &hdrs[1 ].vals; action_size =MLX5_UN_SZ_BYTES (set_action_in_add_action_in_auto); - action = parse_attr->mod_hdr_actions + - parse_attr->num_mod_hdr_actions * action_size; - - max_actions = parse_attr->max_mod_hdr_actions; - nactions = parse_attr->num_mod_hdr_actions;for (i =0 ; i <ARRAY_SIZE (fields); i++) {bool skip;
@@ -2449,13 +2443,6 @@ static int offload_pedit_fields(struct pedit_headers_action *hdrs,return -EOPNOTSUPP ; } -if (nactions == max_actions) { -NL_SET_ERR_MSG_MOD (extack, -"too many pedit actions, can't offload" ); -printk (KERN_WARNING "mlx5: parsed %d pedit actions, can't do more\n" , nactions); -return -EOPNOTSUPP ; - } - skip = false;if (s_mask) {void *match_mask = headers_c + f->match_offset;
@@ -2502,6 +2489,18 @@ static int offload_pedit_fields(struct pedit_headers_action *hdrs,return -EOPNOTSUPP ; } + err =alloc_mod_hdr_actions (priv->mdev, namespace, mod_acts); +if (err) { +NL_SET_ERR_MSG_MOD (extack, +"too many pedit actions, can't offload" ); +mlx5_core_warn (priv->mdev, +"mlx5: parsed %d pedit actions, can't do more\n" , + mod_acts->num_actions); +return err; + } + + action = mod_acts->actions + + (mod_acts->num_actions * action_size);MLX5_SET (set_action_in, action, action_type, cmd);MLX5_SET (set_action_in, action, field, f->field);
@@ -2524,11 +2523,9 @@ static int offload_pedit_fields(struct pedit_headers_action *hdrs,else if (f->field_bsize ==8 )MLX5_SET (set_action_in, action, data, *(u8 *)vals_p >> first); - action += action_size; - nactions++; + ++mod_acts->num_actions; } - parse_attr->num_mod_hdr_actions = nactions;return 0 ; }
@@ -2541,29 +2538,48 @@ static int mlx5e_flow_namespace_max_modify_action(struct mlx5_core_dev *mdev,return MLX5_CAP_FLOWTABLE_NIC_RX (mdev, max_modify_header_actions); } -static int alloc_mod_hdr_actions (struct mlx5e_priv *priv, -struct pedit_headers_action *hdrs, -int namespace, -struct mlx5e_tc_flow_parse_attr *parse_attr) +int alloc_mod_hdr_actions (struct mlx5_core_dev *mdev, +int namespace, +struct mlx5e_tc_mod_hdr_acts *mod_hdr_acts) { -int nkeys, action_size, max_actions; +int action_size, new_num_actions, max_hw_actions; +size_t new_sz, old_sz; +void *ret; - nkeys = hdrs[TCA_PEDIT_KEY_EX_CMD_SET ].pedits + - hdrs[TCA_PEDIT_KEY_EX_CMD_ADD ].pedits; - action_size =MLX5_UN_SZ_BYTES (set_action_in_add_action_in_auto); +if (mod_hdr_acts->num_actions < mod_hdr_acts->max_actions) +return 0 ; - max_actions =mlx5e_flow_namespace_max_modify_action (priv->mdev, namespace); -/* can get up to crazingly 16 HW actions in 32 bits pedit SW key */ - max_actions =min (max_actions, nkeys *16 ); + action_size =MLX5_UN_SZ_BYTES (set_action_in_add_action_in_auto); - parse_attr->mod_hdr_actions =kcalloc (max_actions, action_size,GFP_KERNEL ); -if (!parse_attr->mod_hdr_actions) + max_hw_actions =mlx5e_flow_namespace_max_modify_action (mdev, + namespace); + new_num_actions =min (max_hw_actions, + mod_hdr_acts->actions ? + mod_hdr_acts->max_actions *2 :1 ); +if (mod_hdr_acts->max_actions == new_num_actions) +return -ENOSPC ; + + new_sz = action_size * new_num_actions; + old_sz = mod_hdr_acts->max_actions * action_size; + ret =krealloc (mod_hdr_acts->actions, new_sz,GFP_KERNEL ); +if (!ret)return -ENOMEM ; - parse_attr->max_mod_hdr_actions = max_actions; +memset (ret + old_sz,0 , new_sz - old_sz); + mod_hdr_acts->actions = ret; + mod_hdr_acts->max_actions = new_num_actions; +return 0 ; } +void dealloc_mod_hdr_actions (struct mlx5e_tc_mod_hdr_acts *mod_hdr_acts) +{ +kfree (mod_hdr_acts->actions); + mod_hdr_acts->actions =NULL ; + mod_hdr_acts->num_actions =0 ; + mod_hdr_acts->max_actions =0 ; +} +static const struct pedit_headers zero_masks = {}; static int parse_tc_pedit_action(struct mlx5e_priv *priv,
@@ -2616,13 +2632,8 @@ static int alloc_tc_pedit_action(struct mlx5e_priv *priv, int namespace,int err;u8 cmd; -if (!parse_attr->mod_hdr_actions) { - err =alloc_mod_hdr_actions (priv, hdrs, namespace, parse_attr); -if (err) - goto out_err; - } - - err =offload_pedit_fields (hdrs, parse_attr, action_flags, extack); + err =offload_pedit_fields (priv, namespace, hdrs, parse_attr, + action_flags, extack);if (err <0 ) goto out_dealloc_parsed_actions;
@@ -2642,8 +2653,7 @@ static int alloc_tc_pedit_action(struct mlx5e_priv *priv, int namespace,return 0 ; out_dealloc_parsed_actions: -kfree (parse_attr->mod_hdr_actions); -out_err: +dealloc_mod_hdr_actions (&parse_attr->mod_hdr_acts);return err; }
@@ -2976,9 +2986,9 @@ static int parse_tc_nic_actions(struct mlx5e_priv *priv,/* in case all pedit actions are skipped, remove the MOD_HDR * flag. */ -if (parse_attr->num_mod_hdr_actions ==0 ) { +if (parse_attr->mod_hdr_acts.num_actions ==0 ) { action &= ~MLX5_FLOW_CONTEXT_ACTION_MOD_HDR ; -kfree (parse_attr->mod_hdr_actions); +dealloc_mod_hdr_actions (&parse_attr->mod_hdr_acts); } }
@@ -3564,9 +3574,9 @@ static int parse_tc_fdb_actions(struct mlx5e_priv *priv,* flag. we might have set split_count either by pedit or * pop/push. if there is no pop/push either, reset it too. */ -if (parse_attr->num_mod_hdr_actions ==0 ) { +if (parse_attr->mod_hdr_acts.num_actions ==0 ) { action &= ~MLX5_FLOW_CONTEXT_ACTION_MOD_HDR ; -kfree (parse_attr->mod_hdr_actions); +dealloc_mod_hdr_actions (&parse_attr->mod_hdr_acts);if (!((action &MLX5_FLOW_CONTEXT_ACTION_VLAN_POP ) || (action &MLX5_FLOW_CONTEXT_ACTION_VLAN_PUSH ))) attr->split_count =0 ;
drivers/net/ethernet/mellanox/mlx5/core/en_tc.h +11 -0
@@ -108,6 +108,17 @@ bool mlx5e_is_valid_eswitch_fwd_dev(struct mlx5e_priv *priv,bool mlx5e_tc_rep_update_skb (struct mlx5_cqe64 *cqe,struct sk_buff *skb); +struct mlx5e_tc_mod_hdr_acts { +int num_actions; +int max_actions; +void *actions; +}; + +int alloc_mod_hdr_actions (struct mlx5_core_dev *mdev, +int namespace, +struct mlx5e_tc_mod_hdr_acts *mod_hdr_acts); +void dealloc_mod_hdr_actions (struct mlx5e_tc_mod_hdr_acts *mod_hdr_acts); +#else /* CONFIG_MLX5_ESWITCH */ static inline int mlx5e_tc_nic_init (struct mlx5e_priv *priv) {return 0 ; }static inline void mlx5e_tc_nic_cleanup (struct mlx5e_priv *priv) {}
Signature · 1 line
1.8.3.1
PATCH v3 12/16 net/mlx5e: Move tc tunnel parsing logic with the rest at tc_tun module
In reply to Paul BlakeyCurrently, tunnel parsing is split between en_tc and tc_tun. The next patch will replace the tunnel fields matching with a register match, and will not need this parsing.
Move the tunnel parsing logic to tc_tun as a pre-step for skipping it in the next patch.
--- .../net/ethernet/mellanox/mlx5/core/en/tc_tun.c | 112 ++++++++++++++++++++- .../net/ethernet/mellanox/mlx5/core/en/tc_tun.h | 3 +- drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 109 +------------------- 3 files changed, 112 insertions(+), 112 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.c +110 -2
@@ -469,10 +469,15 @@ int mlx5e_tc_tun_parse(struct net_device *filter_dev,struct mlx5e_priv *priv, struct mlx5_flow_spec *spec, struct flow_cls_offload *f, - void *headers_c, - void *headers_v, u8 *match_level) + u8 *match_level) { struct mlx5e_tc_tunnel *tunnel = mlx5e_get_tc_tun(filter_dev); +struct flow_rule *rule =flow_cls_offload_flow_rule (f); +void *headers_c =MLX5_ADDR_OF (fte_match_param, spec->match_criteria, + outer_headers); +void *headers_v =MLX5_ADDR_OF (fte_match_param, spec->match_value, + outer_headers); +struct netlink_ext_ack *extack = f->common.extack;int err =0 ;if (!tunnel) {
@@ -499,6 +504,109 @@ int mlx5e_tc_tun_parse(struct net_device *filter_dev, goto out; } +if (flow_rule_match_key (rule,FLOW_DISSECTOR_KEY_ENC_CONTROL )) { +struct flow_match_control match; +u16 addr_type; + +flow_rule_match_enc_control (rule, &match); + addr_type = match.key->addr_type; + +/* For tunnel addr_type used same key id`s as for non-tunnel */ +if (addr_type ==FLOW_DISSECTOR_KEY_IPV4_ADDRS ) { +struct flow_match_ipv4_addrs match; + +flow_rule_match_enc_ipv4_addrs (rule, &match); +MLX5_SET (fte_match_set_lyr_2_4, headers_c, + src_ipv4_src_ipv6.ipv4_layout.ipv4, +ntohl (match.mask->src)); +MLX5_SET (fte_match_set_lyr_2_4, headers_v, + src_ipv4_src_ipv6.ipv4_layout.ipv4, +ntohl (match.key->src)); + +MLX5_SET (fte_match_set_lyr_2_4, headers_c, + dst_ipv4_dst_ipv6.ipv4_layout.ipv4, +ntohl (match.mask->dst)); +MLX5_SET (fte_match_set_lyr_2_4, headers_v, + dst_ipv4_dst_ipv6.ipv4_layout.ipv4, +ntohl (match.key->dst)); + +MLX5_SET_TO_ONES (fte_match_set_lyr_2_4, headers_c, + ethertype); +MLX5_SET (fte_match_set_lyr_2_4, headers_v, ethertype, +ETH_P_IP ); + }else if (addr_type ==FLOW_DISSECTOR_KEY_IPV6_ADDRS ) { +struct flow_match_ipv6_addrs match; + +flow_rule_match_enc_ipv6_addrs (rule, &match); +memcpy (MLX5_ADDR_OF (fte_match_set_lyr_2_4, headers_c, + src_ipv4_src_ipv6.ipv6_layout.ipv6), + &match.mask->src,MLX5_FLD_SZ_BYTES (ipv6_layout, + ipv6)); +memcpy (MLX5_ADDR_OF (fte_match_set_lyr_2_4, headers_v, + src_ipv4_src_ipv6.ipv6_layout.ipv6), + &match.key->src,MLX5_FLD_SZ_BYTES (ipv6_layout, + ipv6)); + +memcpy (MLX5_ADDR_OF (fte_match_set_lyr_2_4, headers_c, + dst_ipv4_dst_ipv6.ipv6_layout.ipv6), + &match.mask->dst,MLX5_FLD_SZ_BYTES (ipv6_layout, + ipv6)); +memcpy (MLX5_ADDR_OF (fte_match_set_lyr_2_4, headers_v, + dst_ipv4_dst_ipv6.ipv6_layout.ipv6), + &match.key->dst,MLX5_FLD_SZ_BYTES (ipv6_layout, + ipv6)); + +MLX5_SET_TO_ONES (fte_match_set_lyr_2_4, headers_c, + ethertype); +MLX5_SET (fte_match_set_lyr_2_4, headers_v, ethertype, +ETH_P_IPV6 ); + } + } + +if (flow_rule_match_key (rule,FLOW_DISSECTOR_KEY_ENC_IP )) { +struct flow_match_ip match; + +flow_rule_match_enc_ip (rule, &match); +MLX5_SET (fte_match_set_lyr_2_4, headers_c, ip_ecn, + match.mask->tos &0x3 ); +MLX5_SET (fte_match_set_lyr_2_4, headers_v, ip_ecn, + match.key->tos &0x3 ); + +MLX5_SET (fte_match_set_lyr_2_4, headers_c, ip_dscp, + match.mask->tos >>2 ); +MLX5_SET (fte_match_set_lyr_2_4, headers_v, ip_dscp, + match.key->tos >>2 ); + +MLX5_SET (fte_match_set_lyr_2_4, headers_c, ttl_hoplimit, + match.mask->ttl); +MLX5_SET (fte_match_set_lyr_2_4, headers_v, ttl_hoplimit, + match.key->ttl); + +if (match.mask->ttl && + !MLX5_CAP_ESW_FLOWTABLE_FDB + (priv->mdev, + ft_field_support.outer_ipv4_ttl)) { +NL_SET_ERR_MSG_MOD (extack, +"Matching on TTL is not supported" ); + err = -EOPNOTSUPP ; + goto out; + } + } + +/* Enforce DMAC when offloading incoming tunneled flows. +* Flow counters require a match on the DMAC. +*/ +MLX5_SET_TO_ONES (fte_match_set_lyr_2_4, headers_c, dmac_47_16); +MLX5_SET_TO_ONES (fte_match_set_lyr_2_4, headers_c, dmac_15_0); +ether_addr_copy (MLX5_ADDR_OF (fte_match_set_lyr_2_4, headers_v, + dmac_47_16), priv->netdev->dev_addr); + +/* let software handle IP fragments */ +MLX5_SET (fte_match_set_lyr_2_4, headers_c, frag,1 ); +MLX5_SET (fte_match_set_lyr_2_4, headers_v, frag,0 ); + +return 0 ; + out:return err; }
drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.h +1 -2
@@ -76,8 +76,7 @@ int mlx5e_tc_tun_parse(struct net_device *filter_dev,struct mlx5e_priv *priv, struct mlx5_flow_spec *spec, struct flow_cls_offload *f, - void *headers_c, - void *headers_v, u8 *match_level); + u8 *match_level); int mlx5e_tc_tun_parse_udp_ports(struct mlx5e_priv *priv, struct mlx5_flow_spec *spec,
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +1 -108
123 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH v3 13/16 net/mlx5e: Disallow inserting vxlan/vlan egress rules without decap/pop
In reply to Paul BlakeyCurrently, rules on tunnel devices can be offloaded without decap action when a vlan pop action exists. Similarly, the driver will offload rules on vlan interfaces with no pop action when a decap action exists.
Disallow the faulty behavior by checking that vlan egress rules do pop or drop and vxlan egress rules do decap, as intended.
--- drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +15 -5
@@ -2675,6 +2675,8 @@ static bool actions_match_supported(struct mlx5e_priv *priv,struct mlx5e_tc_flow *flow, struct netlink_ext_ack *extack) { + struct net_device *filter_dev = parse_attr->filter_dev; +bool drop_action, decap_action, pop_action;u32 actions;if (mlx5e_is_eswitch_flow (flow))
@@ -2682,11 +2684,19 @@ static bool actions_match_supported(struct mlx5e_priv *priv,else actions = flow->nic_attr->action; -if (flow_flag_test (flow,EGRESS ) && - !((actions &MLX5_FLOW_CONTEXT_ACTION_DECAP ) || - (actions &MLX5_FLOW_CONTEXT_ACTION_VLAN_POP ) || - (actions &MLX5_FLOW_CONTEXT_ACTION_DROP ))) -return false; + drop_action = actions &MLX5_FLOW_CONTEXT_ACTION_DROP ; + decap_action = actions &MLX5_FLOW_CONTEXT_ACTION_DECAP ; + pop_action = actions &MLX5_FLOW_CONTEXT_ACTION_VLAN_POP ; + +if (flow_flag_test (flow,EGRESS ) && !drop_action) { +/* If no drop, we must decap (vxlan) or pop (vlan) */ +if (mlx5e_get_tc_tun (filter_dev) && !decap_action) +return false; +else if (is_vlan_dev (filter_dev) && !pop_action) +return false; +else +return false;/* Sanity */ + }if (actions &MLX5_FLOW_CONTEXT_ACTION_MOD_HDR ) return modify_header_match_supported(&parse_attr->spec,
Signature · 1 line
1.8.3.1
PATCH v3 14/16 net/mlx5e: Support inner header rewrite with goto action
In reply to Paul BlakeyThe hardware supports header rewrite of outer headers only. To perform header rewrite on inner headers, we must first decapsulate the packet.
Currently, the hardware decap action is explicitly set by the tc tunnel_key unset action. However, with goto action the user won't use the tunnel_key unset action. In addition, header rewrites actions will not apply to the inner header as done by the software model.
To support this, we will map each tunnel matches seen on a tc rule to a unique tunnel id, implicity add a decap action on tc chain 0 flows, and mark the packets with this unique tunnel id. Tunnel matches on the decapsulated tunnel on later chains will match on this unique id instead of the actual packet.
We will also use this mapping to restore the tunnel info metadata on miss.
--- drivers/net/ethernet/mellanox/mlx5/core/en_rep.h | 5 + drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 472 ++++++++++++++++++++--- drivers/net/ethernet/mellanox/mlx5/core/en_tc.h | 13 + 3 files changed, 445 insertions(+), 45 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_rep.h +5 -0
@@ -81,6 +81,11 @@ struct mlx5_rep_uplink_priv {struct mutex unready_flows_lock;struct list_head unready_flows;struct work_struct reoffload_flows_work; + +/* maps tun_info to a unique id*/ +struct mapping_ctx *tunnel_mapping; +/* maps tun_enc_opts to a unique id*/ +struct mapping_ctx *tunnel_enc_opts_mapping; };struct mlx5e_rep_priv {
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +427 -45
604 lines not on this page · raw message
drivers/net/ethernet/mellanox/mlx5/core/en_tc.h +13 -0
@@ -93,12 +93,15 @@ void mlx5e_tc_encap_flows_del(struct mlx5e_priv *priv,enum mlx5e_tc_attr_to_reg {CHAIN_TO_REG , +TUNNEL_TO_REG , };struct mlx5e_tc_attr_to_reg_mapping {int mfield;/* rewrite field */ int moffset;/* offset of mfield */ int mlen;/* bytes to rewrite/match */ + +int soffset;/* offset of spec for match */ };extern struct mlx5e_tc_attr_to_reg_mapping mlx5e_tc_attr_to_reg_mappings[];
@@ -114,6 +117,16 @@ struct mlx5e_tc_mod_hdr_acts {void *actions; }; +int mlx5e_tc_match_to_reg_set (struct mlx5_core_dev *mdev, +struct mlx5e_tc_mod_hdr_acts *mod_hdr_acts, +enum mlx5e_tc_attr_to_reg type, +u32 data); + +void mlx5e_tc_match_to_reg_match (struct mlx5_flow_spec *spec, +enum mlx5e_tc_attr_to_reg type, +u32 data, +u32 mask); +int alloc_mod_hdr_actions (struct mlx5_core_dev *mdev,int namespace,struct mlx5e_tc_mod_hdr_acts *mod_hdr_acts);
Signature · 1 line
1.8.3.1
PATCH v3 15/16 net/mlx5: E-Switch, Get reg_c1 value on miss
In reply to Paul BlakeyThe HW model implicitly decapsulates tunnels on chain 0 and sets reg_c1 with the mapped tunnel id. On miss, the packet does not have the outer header and the driver restores the tunnel information from the tunnel id.
Getting reg_c1 value in software requires enabling reg_c1 loopback and copying reg_c1 to reg_b. reg_b comes up on CQE as cqe->imm_inval_pkey.
Use the reg_c0 restoration rules to also copy reg_c1 to reg_B.
--- drivers/net/ethernet/mellanox/mlx5/core/eswitch.h | 1 + .../ethernet/mellanox/mlx5/core/eswitch_offloads.c | 31 +++++++++++++++++++--- 2 files changed, 29 insertions(+), 3 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/eswitch.h +1 -0
@@ -191,6 +191,7 @@ struct mlx5_eswitch_fdb {struct mlx5_esw_offload {struct mlx5_flow_table *ft_offloads_restore;struct mlx5_flow_group *restore_group; +struct mlx5_modify_hdr *restore_copy_hdr_id;struct mlx5_flow_table *ft_offloads;struct mlx5_flow_group *vport_rx_group;
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +28 -3
@@ -598,9 +598,11 @@ static int esw_set_passing_vport_metadata(struct mlx5_eswitch *esw, bool enable) esw_vport_context.fdb_to_vport_reg_c_id);if (enable) - fdb_to_vport_reg_c_id |=MLX5_FDB_TO_VPORT_REG_C_0 ; + fdb_to_vport_reg_c_id |=MLX5_FDB_TO_VPORT_REG_C_0 | +MLX5_FDB_TO_VPORT_REG_C_1 ;else - fdb_to_vport_reg_c_id &= ~MLX5_FDB_TO_VPORT_REG_C_0 ; + fdb_to_vport_reg_c_id &= ~(MLX5_FDB_TO_VPORT_REG_C_0 | +MLX5_FDB_TO_VPORT_REG_C_1 );MLX5_SET (modify_esw_vport_context_in, in, esw_vport_context.fdb_to_vport_reg_c_id, fdb_to_vport_reg_c_id);
@@ -861,7 +863,9 @@ struct mlx5_flow_handle * misc_parameters_2);MLX5_SET (fte_match_set_misc2, misc, metadata_reg_c_0, tag); spec->match_criteria_enable =MLX5_MATCH_MISC_PARAMETERS_2 ; - flow_act.action =MLX5_FLOW_CONTEXT_ACTION_FWD_DEST ; + flow_act.action =MLX5_FLOW_CONTEXT_ACTION_FWD_DEST | +MLX5_FLOW_CONTEXT_ACTION_MOD_HDR ; + flow_act.modify_hdr = esw->offloads.restore_copy_hdr_id; flow_context = &spec->flow_context; flow_context->flags |=FLOW_CONTEXT_HAS_TAG ;
@@ -1217,16 +1221,19 @@ static void esw_destroy_restore_table(struct mlx5_eswitch *esw) {struct mlx5_esw_offload *offloads = &esw->offloads; +mlx5_modify_header_dealloc (esw->dev, offloads->restore_copy_hdr_id);mlx5_destroy_flow_group (offloads->restore_group);mlx5_destroy_flow_table (offloads->ft_offloads_restore); }static int esw_create_restore_table (struct mlx5_eswitch *esw) { +u8 modact[MLX5_UN_SZ_BYTES (set_action_in_add_action_in_auto)] = {};int inlen =MLX5_ST_SZ_BYTES (create_flow_group_in);struct mlx5_flow_table_attr ft_attr = {};struct mlx5_core_dev *dev = esw->dev;struct mlx5_flow_namespace *ns; +struct mlx5_modify_hdr *mod_hdr;void *match_criteria, *misc;struct mlx5_flow_table *ft;struct mlx5_flow_group *g;
@@ -1275,11 +1282,29 @@ static int esw_create_restore_table(struct mlx5_eswitch *esw) goto err_group; } +MLX5_SET (copy_action_in, modact, action_type,MLX5_ACTION_TYPE_COPY ); +MLX5_SET (copy_action_in, modact, src_field, +MLX5_ACTION_IN_FIELD_METADATA_REG_C_1 ); +MLX5_SET (copy_action_in, modact, dst_field, +MLX5_ACTION_IN_FIELD_METADATA_REG_B ); + mod_hdr =mlx5_modify_header_alloc (esw->dev, +MLX5_FLOW_NAMESPACE_KERNEL ,1 , + modact); +if (IS_ERR (mod_hdr)) { +esw_warn (dev,"Failed to create restore mod header, err: %d\n" , + err); + err =PTR_ERR (mod_hdr); + goto err_mod_hdr; + } + esw->offloads.ft_offloads_restore = ft; esw->offloads.restore_group = g; + esw->offloads.restore_copy_hdr_id = mod_hdr;return 0 ; +err_mod_hdr: +mlx5_destroy_flow_group (g); err_group:mlx5_destroy_flow_table (ft); out_free:
Signature · 1 line
1.8.3.1
PATCH v3 16/16 net/mlx5e: Restore tunnel metadata on miss
In reply to Paul BlakeyIn tunnel and chains setup, we decapsulate the packets on first chain hop, if we miss on later chains, the packet will comes up without tunnel header, so it won't be taken by the tunnel device automatically, which fills the tunnel metadata, and further tc tunnel matches won't work.
On miss, we get the tunnel mapping id, which was set on the chain 0 rule that decapsulated the packet. This rule matched the tunnel outer headers. From the tunnel mapping id, we get to this tunnel matches and restore the equivalent tunnel info metadata dst on the skb. We also set the skb->dev to the relevant device (tunnel device). Now further tc processing can be done on the relevant device.
--- drivers/net/ethernet/mellanox/mlx5/core/en_rx.c | 10 ++- drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 110 ++++++++++++++++++++++-- drivers/net/ethernet/mellanox/mlx5/core/en_tc.h | 9 +- 3 files changed, 117 insertions(+), 12 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_rx.c +8 -2
@@ -1193,6 +1193,7 @@ void mlx5e_handle_rx_cqe_rep(struct mlx5e_rq *rq, struct mlx5_cqe64 *cqe)struct mlx5e_priv *priv =netdev_priv (netdev);struct mlx5e_rep_priv *rpriv = priv->ppriv;struct mlx5_eswitch_rep *rep = rpriv->rep; +struct mlx5e_tc_update_priv tc_priv = {};struct mlx5_wq_cyc *wq = &rq->wqe.wq;struct mlx5e_wqe_frag_info *wi;struct sk_buff *skb;
@@ -1225,11 +1226,13 @@ void mlx5e_handle_rx_cqe_rep(struct mlx5e_rq *rq, struct mlx5_cqe64 *cqe)if (rep->vlan &&skb_vlan_tag_present (skb))skb_vlan_pop (skb); -if (!mlx5e_tc_rep_update_skb (cqe, skb)) +if (!mlx5e_tc_rep_update_skb (cqe, skb, &tc_priv)) goto free_wqe;napi_gro_receive (rq->cq.napi, skb); +mlx5_tc_rep_post_napi_receive (&tc_priv); + free_wqe:mlx5e_free_rx_wqe (rq, wi, true); wq_cyc_pop:
@@ -1246,6 +1249,7 @@ void mlx5e_handle_rx_cqe_mpwrq_rep(struct mlx5e_rq *rq,u32 wqe_offset = stride_ix << rq->mpwqe.log_stride_sz;u32 head_offset = wqe_offset & (PAGE_SIZE -1 );u32 page_idx = wqe_offset >>PAGE_SHIFT ; +struct mlx5e_tc_update_priv tc_priv = {};struct mlx5e_rx_wqe_ll *wqe;struct mlx5_wq_ll *wq;struct sk_buff *skb;
@@ -1278,11 +1282,13 @@ void mlx5e_handle_rx_cqe_mpwrq_rep(struct mlx5e_rq *rq,mlx5e_complete_rx_cqe (rq, cqe, cqe_bcnt, skb); -if (!mlx5e_tc_rep_update_skb (cqe, skb)) +if (!mlx5e_tc_rep_update_skb (cqe, skb, &tc_priv)) goto mpwrq_cqe_out;napi_gro_receive (rq->cq.napi, skb); +mlx5_tc_rep_post_napi_receive (&tc_priv); + mpwrq_cqe_out:if (likely (wi->consumed_strides < rq->mpwqe.num_strides))return ;
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +101 -9
137 lines not on this page · raw message
drivers/net/ethernet/mellanox/mlx5/core/en_tc.h +8 -1
@@ -109,7 +109,14 @@ struct mlx5e_tc_attr_to_reg_mapping {bool mlx5e_is_valid_eswitch_fwd_dev (struct mlx5e_priv *priv,struct net_device *out_dev); -bool mlx5e_tc_rep_update_skb (struct mlx5_cqe64 *cqe,struct sk_buff *skb); +struct mlx5e_tc_update_priv { +struct net_device *tun_dev; +}; + +bool mlx5e_tc_rep_update_skb (struct mlx5_cqe64 *cqe,struct sk_buff *skb, +struct mlx5e_tc_update_priv *tc_priv); + +void mlx5_tc_rep_post_napi_receive (struct mlx5e_tc_update_priv *tc_priv);struct mlx5e_tc_mod_hdr_acts {int num_actions;
Signature · 1 line
1.8.3.1
Quoted 9 lines · Paul Blakey
Hi David/Jakub/Saeed,
TC multi chain configuration can cause offloaded tc chains to miss in hardware after jumping to some chain. In such cases the software should
continue from the chain that was missed in hardware, as the hardware may have
manipulated the packet and updated some counters.
[...]
Quoted 6 lines
Note that miss path handling of multi-chain rules is a required infrastructure
for connection tracking hardware offload. The connection tracking offload
series will follow this one.
Hi Dave,
As was agreed, i will apply this series and the two to follow to a side branch until all the connection tracking offloads patchsets are posted by Paul and reviewed/acked.
in case of no objection i will apply this patchset to allow Paul to move forward with the other two connection tracking patchsets.
Thanks,
Saeed.
David Miller
maintainerFrom: Saeed Mahameed <[email protected]>
Date: Wed, 19 Feb 2020 02:43:08 +0000
Quoted 20 lines · Paul Blakey
Quoted 9 lines
Hi David/Jakub/Saeed,
TC multi chain configuration can cause offloaded tc chains to miss in hardware after jumping to some chain. In such cases the software should
continue from the chain that was missed in hardware, as the hardware may have
manipulated the packet and updated some counters.[...]
Quoted 6 lines
Note that miss path handling of multi-chain rules is a required infrastructure
for connection tracking hardware offload. The connection tracking offload
series will follow this one.
Quoted 8 lines
Hi Dave,
As was agreed, i will apply this series and the two to follow to a side branch until all the connection tracking offloads patchsets are posted by Paul and reviewed/acked.
in case of no objection i will apply this patchset to allow Paul to move forward with the other two connection tracking patchsets.
I have no objection to this series, can you setup a pull request with this series in it that I can pull from into net-next?
Thanks.
Quoted 31 lines · David Miller
From: Saeed Mahameed <[email protected]>
Date: Wed, 19 Feb 2020 02:43:08 +0000Quoted 4 lines · Paul Blakey
Quoted 3 lines
Hi David/Jakub/Saeed,
TC multi chain configuration can cause offloaded tc chains to miss
in
Quoted 3 lines
Quoted 3 lines
hardware after jumping to some chain. In such cases the software should
continue from the chain that was missed in hardware, as thehardware
Quoted 13 lines
Quoted 3 lines
may have
manipulated the packet and updated some counters.[...]
Quoted 6 lines
Note that miss path handling of multi-chain rules is a required infrastructure
for connection tracking hardware offload. The connection tracking offload
series will follow this one.Quoted 3 lines
Hi Dave,
As was agreed, i will apply this series and the two to follow to a
side
Quoted 1 line
branch until all the connection tracking offloads patchsets are
posted
Quoted 9 lines
Quoted 4 lines
by Paul and reviewed/acked.
in case of no objection i will apply this patchset to allow Paul to move forward with the other two connection tracking patchsets.
I have no objection to this series, can you setup a pull request with this
series in it that I can pull from into net-next?
Great, Yes i will setup the pull request.
Series applied to ct-offload branch:
https://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux.git/log/?h=ct-offload
I will send the pull request once all connection tracking offload patches are posted and reviewed in net-next.
Thanks.