mlxsw: Add support for buffer drops mirroring
Subsystems (9)
v2 cover mlxsw: Add support for buffer drops mirroring
This set offloads the recently introduced qevent infrastructure in TC and allows mlxsw to support mirroring of packets that were dropped due to buffer related reasons (e.g., early drops) during forwarding.
Up until now mlxsw only supported mirroring that was either triggered by per-port triggers (i.e., via matchall) or by the policy engine (i.e., via flower). Packets that are dropped due to buffer related reasons are mirrored using a third type of trigger, a global trigger.
Global triggers are bound once to a mirroring (SPAN) agent and enabled on a per-{port, TC} basis. This allows users, for example, to request that only packets that were early dropped on a specific netdev to be mirrored.
Patch set overview:
Patch #1 extends flow_block_offload and indirect offload structure to pass a scheduler instead of a netdevice. That is necessary, because binding type and netdevice are not a unique identifier of the block anymore.
Patches #2-#3 add the required registers to support above mentioned functionality.
Patches #4-#6 gradually add support for global mirroring triggers.
Patch #7 adds support for enablement of global mirroring triggers.
Patches #8-#11 are cleanups in the flow offload code and shuffle some code around to make the qevent offload easier.
Patch #12 implements offload of RED early_drop qevent.
Patch #13 extends the RED selftest for offloaded datapath to cover early_drop qevent.
v2:
- Patch #1:
- In struct flow_block_indr, track both sch and dev.
Amit Cohen (2):
mlxsw: reg: Add Monitoring Mirror Trigger Enable Register
mlxsw: reg: Add Monitoring Port Analyzer Global Register
Ido Schimmel (4):
mlxsw: spectrum_span: Move SPAN operations out of global file
mlxsw: spectrum_span: Prepare for global mirroring triggers
mlxsw: spectrum_span: Add support for global mirroring triggers
mlxsw: spectrum_span: Add APIs to enable / disable global mirroring
triggers
Petr Machata (7):
net: sched: Pass qdisc reference in struct flow_block_offload
mlxsw: spectrum_flow: Convert a goto to a return
mlxsw: spectrum_flow: Drop an unused field
mlxsw: spectrum_matchall: Publish matchall data structures
mlxsw: spectrum_flow: Promote binder-type dispatch to spectrum.c
mlxsw: spectrum_qdisc: Offload mirroring on RED qevent early_drop
selftests: mlxsw: RED: Test offload of mirror on RED early_drop qevent
drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c | 9 +- .../ethernet/mellanox/mlx5/core/en/rep/tc.c | 10 +- drivers/net/ethernet/mellanox/mlxsw/reg.h | 102 ++++ .../net/ethernet/mellanox/mlxsw/spectrum.c | 65 +-- .../net/ethernet/mellanox/mlxsw/spectrum.h | 33 +- .../ethernet/mellanox/mlxsw/spectrum_flow.c | 18 +- .../mellanox/mlxsw/spectrum_matchall.c | 23 - .../ethernet/mellanox/mlxsw/spectrum_qdisc.c | 472 ++++++++++++++++++ .../ethernet/mellanox/mlxsw/spectrum_span.c | 397 ++++++++++++++- .../ethernet/mellanox/mlxsw/spectrum_span.h | 16 + .../net/ethernet/netronome/nfp/flower/main.h | 2 +- .../ethernet/netronome/nfp/flower/offload.c | 8 +- include/net/flow_offload.h | 9 +- net/core/flow_offload.c | 12 +- net/netfilter/nf_flow_table_offload.c | 2 +- net/netfilter/nf_tables_offload.c | 2 +- net/sched/cls_api.c | 16 +- .../drivers/net/mlxsw/sch_red_core.sh | 106 +++- .../drivers/net/mlxsw/sch_red_ets.sh | 11 + .../drivers/net/mlxsw/sch_red_root.sh | 8 + 20 files changed, 1179 insertions(+), 142 deletions(-)
Signature · 1 line
2.20.1
PATCH v2 1/13 net: sched: Pass qdisc reference in struct flow_block_offload
Previously, shared blocks were only relevant for the pseudo-qdiscs ingress and clsact. Recently, a qevent facility was introduced, which allows to bind blocks to well-defined slots of a qdisc instance. RED in particular got two qevents: early_drop and mark. Drivers that wish to offload these blocks will be sent the usual notification, and need to know which qdisc it is related to.
To that end, extend flow_block_offload with a "sch" pointer, and initialize as appropriate. This prompts changes in the indirect block facility, which now tracks the scheduler in addition to the netdevice. Update signatures of several functions similarly.
---
Notes:
v2:
- In struct flow_block_indr, track both sch and dev.
drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c | 9 ++++----- .../net/ethernet/mellanox/mlx5/core/en/rep/tc.c | 10 +++++----- drivers/net/ethernet/netronome/nfp/flower/main.h | 2 +- .../net/ethernet/netronome/nfp/flower/offload.c | 8 ++++---- include/net/flow_offload.h | 9 ++++++--- net/core/flow_offload.c | 12 +++++++----- net/netfilter/nf_flow_table_offload.c | 2 +- net/netfilter/nf_tables_offload.c | 2 +- net/sched/cls_api.c | 16 +++++++++------- 9 files changed, 38 insertions(+), 32 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c +4 -5
@@ -1888,7 +1888,7 @@ static void bnxt_tc_setup_indr_rel(void *cb_priv)kfree (priv); } -static int bnxt_tc_setup_indr_block (struct net_device *netdev,struct bnxt *bp, +static int bnxt_tc_setup_indr_block (struct net_device *netdev,struct Qdisc *sch,struct bnxt *bp,struct flow_block_offload *f,void *data,void (*cleanup)(struct flow_block_cb *block_cb)) {
@@ -1911,7 +1911,7 @@ static int bnxt_tc_setup_indr_block(struct net_device *netdev, struct bnxt *bp, block_cb =flow_indr_block_cb_alloc (bnxt_tc_setup_indr_block_cb, cb_priv, cb_priv, bnxt_tc_setup_indr_rel, f, - netdev, data, bp, cleanup); + netdev, sch, data, bp, cleanup);if (IS_ERR (block_cb)) {list_del (&cb_priv->list);kfree (cb_priv);
@@ -1946,7 +1946,7 @@ static bool bnxt_is_netdev_indr_offload(struct net_device *netdev)return netif_is_vxlan (netdev); } -static int bnxt_tc_setup_indr_cb (struct net_device *netdev,void *cb_priv, +static int bnxt_tc_setup_indr_cb (struct net_device *netdev,struct Qdisc *sch,void *cb_priv,enum tc_setup_type type,void *type_data,void *data,void (*cleanup)(struct flow_block_cb *block_cb))
@@ -1956,8 +1956,7 @@ static int bnxt_tc_setup_indr_cb(struct net_device *netdev, void *cb_priv,switch (type) {case TC_SETUP_BLOCK : -return bnxt_tc_setup_indr_block (netdev, cb_priv, type_data, data, - cleanup); +return bnxt_tc_setup_indr_block (netdev, sch, cb_priv, type_data, data, cleanup);default :break ; }
drivers/net/ethernet/mellanox/mlx5/core/en/rep/tc.c +5 -5
@@ -404,7 +404,7 @@ static void mlx5e_rep_indr_block_unbind(void *cb_priv)static LIST_HEAD (mlx5e_block_cb_list); static int -mlx5e_rep_indr_setup_block(struct net_device *netdev, +mlx5e_rep_indr_setup_block(struct net_device *netdev, struct Qdisc *sch, struct mlx5e_rep_priv *rpriv, struct flow_block_offload *f, flow_setup_cb_t *setup_cb,
@@ -442,7 +442,7 @@ mlx5e_rep_indr_setup_block(struct net_device *netdev, block_cb =flow_indr_block_cb_alloc (setup_cb, indr_priv, indr_priv, mlx5e_rep_indr_block_unbind, - f, netdev, data, rpriv, + f, netdev, sch, data, rpriv, cleanup);if (IS_ERR (block_cb)) {list_del (&indr_priv->list);
@@ -472,18 +472,18 @@ mlx5e_rep_indr_setup_block(struct net_device *netdev, }static -int mlx5e_rep_indr_setup_cb (struct net_device *netdev,void *cb_priv, +int mlx5e_rep_indr_setup_cb (struct net_device *netdev,struct Qdisc *sch,void *cb_priv,enum tc_setup_type type,void *type_data,void *data,void (*cleanup)(struct flow_block_cb *block_cb)) {switch (type) {case TC_SETUP_BLOCK : -return mlx5e_rep_indr_setup_block (netdev, cb_priv, type_data, +return mlx5e_rep_indr_setup_block (netdev, sch, cb_priv, type_data, mlx5e_rep_indr_setup_tc_cb, data, cleanup);case TC_SETUP_FT : -return mlx5e_rep_indr_setup_block (netdev, cb_priv, type_data, +return mlx5e_rep_indr_setup_block (netdev, sch, cb_priv, type_data, mlx5e_rep_indr_setup_ft_cb, data, cleanup);default :
drivers/net/ethernet/netronome/nfp/flower/main.h +1 -1
@@ -458,7 +458,7 @@ void nfp_flower_qos_cleanup(struct nfp_app *app);int nfp_flower_setup_qos_offload (struct nfp_app *app,struct net_device *netdev,struct tc_cls_matchall_offload *flow);void nfp_flower_stats_rlim_reply (struct nfp_app *app,struct sk_buff *skb); -int nfp_flower_indr_setup_tc_cb (struct net_device *netdev,void *cb_priv, +int nfp_flower_indr_setup_tc_cb (struct net_device *netdev,struct Qdisc *sch,void *cb_priv,enum tc_setup_type type,void *type_data,void *data,void (*cleanup)(struct flow_block_cb *block_cb));
drivers/net/ethernet/netronome/nfp/flower/offload.c +4 -4
@@ -1646,7 +1646,7 @@ void nfp_flower_setup_indr_tc_release(void *cb_priv) }static int -nfp_flower_setup_indr_tc_block (struct net_device *netdev,struct nfp_app *app, +nfp_flower_setup_indr_tc_block (struct net_device *netdev,struct Qdisc *sch,struct nfp_app *app,struct flow_block_offload *f,void *data,void (*cleanup)(struct flow_block_cb *block_cb)) {
@@ -1680,7 +1680,7 @@ nfp_flower_setup_indr_tc_block(struct net_device *netdev, struct nfp_app *app, block_cb =flow_indr_block_cb_alloc (nfp_flower_setup_indr_block_cb, cb_priv, cb_priv, nfp_flower_setup_indr_tc_release, - f, netdev, data, app, cleanup); + f, netdev, sch, data, app, cleanup);if (IS_ERR (block_cb)) {list_del (&cb_priv->list);kfree (cb_priv);
@@ -1711,7 +1711,7 @@ nfp_flower_setup_indr_tc_block(struct net_device *netdev, struct nfp_app *app, }int -nfp_flower_indr_setup_tc_cb (struct net_device *netdev,void *cb_priv, +nfp_flower_indr_setup_tc_cb (struct net_device *netdev,struct Qdisc *sch,void *cb_priv,enum tc_setup_type type,void *type_data,void *data,void (*cleanup)(struct flow_block_cb *block_cb))
@@ -1721,7 +1721,7 @@ nfp_flower_indr_setup_tc_cb(struct net_device *netdev, void *cb_priv,switch (type) {case TC_SETUP_BLOCK : -return nfp_flower_setup_indr_tc_block (netdev, cb_priv, +return nfp_flower_setup_indr_tc_block (netdev, sch, cb_priv, type_data, data, cleanup);default :return -EOPNOTSUPP ;
include/net/flow_offload.h +6 -3
@@ -444,6 +444,7 @@ struct flow_block_offload {struct list_head cb_list;struct list_head *driver_block_list;struct netlink_ext_ack *extack; +struct Qdisc *sch; };enum tc_setup_type ;
@@ -455,6 +456,7 @@ struct flow_block_cb;struct flow_block_indr {struct list_head list;struct net_device *dev; +struct Qdisc *sch;enum flow_block_binder_type binder_type;void *data;void *cb_priv;
@@ -479,7 +481,8 @@ struct flow_block_cb *flow_indr_block_cb_alloc(flow_setup_cb_t *cb, void *cb_ident, void *cb_priv, void (*release)(void *cb_priv), struct flow_block_offload *bo, - struct net_device *dev, void *data, + struct net_device *dev, + struct Qdisc *sch, void *data, void *indr_cb_priv, void (*cleanup)(struct flow_block_cb *block_cb));void flow_block_cb_free (struct flow_block_cb *block_cb);
@@ -553,7 +556,7 @@ static inline void flow_block_init(struct flow_block *flow_block)INIT_LIST_HEAD (&flow_block->cb_list); } -typedef int flow_indr_block_bind_cb_t (struct net_device *dev,void *cb_priv, +typedef int flow_indr_block_bind_cb_t (struct net_device *dev,struct Qdisc *sch,void *cb_priv,enum tc_setup_type type,void *type_data,void *data,void (*cleanup)(struct flow_block_cb *block_cb));
@@ -561,7 +564,7 @@ typedef int flow_indr_block_bind_cb_t(struct net_device *dev, void *cb_priv,int flow_indr_dev_register (flow_indr_block_bind_cb_t *cb,void *cb_priv);void flow_indr_dev_unregister (flow_indr_block_bind_cb_t *cb,void *cb_priv,void (*release)(void *cb_priv)); -int flow_indr_dev_setup_offload (struct net_device *dev, +int flow_indr_dev_setup_offload (struct net_device *dev,struct Qdisc *sch,enum tc_setup_type type,void *data,struct flow_block_offload *bo,void (*cleanup)(struct flow_block_cb *block_cb));
net/core/flow_offload.c +7 -5
@@ -429,7 +429,7 @@ EXPORT_SYMBOL(flow_indr_dev_unregister);static void flow_block_indr_init (struct flow_block_cb *flow_block,struct flow_block_offload *bo, -struct net_device *dev,void *data, +struct net_device *dev,struct Qdisc *sch,void *data,void *cb_priv,void (*cleanup)(struct flow_block_cb *block_cb)) {
@@ -437,6 +437,7 @@ static void flow_block_indr_init(struct flow_block_cb *flow_block, flow_block->indr.data = data; flow_block->indr.cb_priv = cb_priv; flow_block->indr.dev = dev; + flow_block->indr.sch = sch; flow_block->indr.cleanup = cleanup; }
@@ -444,7 +445,8 @@ struct flow_block_cb *flow_indr_block_cb_alloc(flow_setup_cb_t *cb, void *cb_ident, void *cb_priv, void (*release)(void *cb_priv), struct flow_block_offload *bo, - struct net_device *dev, void *data, + struct net_device *dev, + struct Qdisc *sch, void *data, void *indr_cb_priv, void (*cleanup)(struct flow_block_cb *block_cb)) {
@@ -454,7 +456,7 @@ struct flow_block_cb *flow_indr_block_cb_alloc(flow_setup_cb_t *cb,if (IS_ERR (block_cb)) goto out; -flow_block_indr_init (block_cb, bo, dev, data, indr_cb_priv, cleanup); +flow_block_indr_init (block_cb, bo, dev, sch, data, indr_cb_priv, cleanup);list_add (&block_cb->indr.list, &flow_block_indr_list); out:
@@ -462,7 +464,7 @@ struct flow_block_cb *flow_indr_block_cb_alloc(flow_setup_cb_t *cb, }EXPORT_SYMBOL (flow_indr_block_cb_alloc); -int flow_indr_dev_setup_offload (struct net_device *dev, +int flow_indr_dev_setup_offload (struct net_device *dev,struct Qdisc *sch,enum tc_setup_type type,void *data,struct flow_block_offload *bo,void (*cleanup)(struct flow_block_cb *block_cb))
@@ -471,7 +473,7 @@ int flow_indr_dev_setup_offload(struct net_device *dev,mutex_lock (&flow_indr_block_lock);list_for_each_entry (this, &flow_block_indr_dev_list, list) - this->cb (dev, this->cb_priv, type, bo, data, cleanup); + this->cb (dev, sch, this->cb_priv, type, bo, data, cleanup);mutex_unlock (&flow_indr_block_lock);
net/netfilter/nf_flow_table_offload.c +1 -1
@@ -964,7 +964,7 @@ static int nf_flow_table_indr_offload_cmd(struct flow_block_offload *bo,nf_flow_table_block_offload_init (bo,dev_net (dev), cmd, flowtable, extack); -return flow_indr_dev_setup_offload (dev,TC_SETUP_FT , flowtable, bo, +return flow_indr_dev_setup_offload (dev,NULL ,TC_SETUP_FT , flowtable, bo, nf_flow_table_indr_cleanup); }
net/netfilter/nf_tables_offload.c +1 -1
@@ -312,7 +312,7 @@ static int nft_indr_block_offload_cmd(struct nft_base_chain *basechain,nft_flow_block_offload_init (&bo,dev_net (dev), cmd, basechain, &extack); - err =flow_indr_dev_setup_offload (dev,TC_SETUP_BLOCK , basechain, &bo, + err =flow_indr_dev_setup_offload (dev,NULL ,TC_SETUP_BLOCK , basechain, &bo, nft_indr_block_cleanup);if (err <0 )return err;
net/sched/cls_api.c +9 -7
@@ -622,7 +622,7 @@ static int tcf_block_setup(struct tcf_block *block, struct flow_block_offload *bo); static void tcf_block_offload_init(struct flow_block_offload *bo, - struct net_device *dev, + struct net_device *dev, struct Qdisc *sch, enum flow_block_command command, enum flow_block_binder_type binder_type, struct flow_block *flow_block,
@@ -634,6 +634,7 @@ static void tcf_block_offload_init(struct flow_block_offload *bo, bo->block = flow_block; bo->block_shared = shared; bo->extack = extack; + bo->sch = sch;INIT_LIST_HEAD (&bo->cb_list); }
@@ -644,10 +645,11 @@ static void tc_block_indr_cleanup(struct flow_block_cb *block_cb) {struct tcf_block *block = block_cb->indr.data;struct net_device *dev = block_cb->indr.dev; +struct Qdisc *sch = block_cb->indr.sch;struct netlink_ext_ack extack = {};struct flow_block_offload bo; -tcf_block_offload_init (&bo, dev,FLOW_BLOCK_UNBIND , +tcf_block_offload_init (&bo, dev, sch,FLOW_BLOCK_UNBIND , block_cb->indr.binder_type, &block->flow_block,tcf_block_shared (block), &extack);
@@ -666,14 +668,14 @@ static bool tcf_block_offload_in_use(struct tcf_block *block) }static int tcf_block_offload_cmd (struct tcf_block *block, -struct net_device *dev, +struct net_device *dev,struct Qdisc *sch,struct tcf_block_ext_info *ei,enum flow_block_command command,struct netlink_ext_ack *extack) {struct flow_block_offload bo = {}; -tcf_block_offload_init (&bo, dev, command, ei->binder_type, +tcf_block_offload_init (&bo, dev, sch, command, ei->binder_type, &block->flow_block,tcf_block_shared (block), extack);
@@ -690,7 +692,7 @@ static int tcf_block_offload_cmd(struct tcf_block *block,return tcf_block_setup (block, &bo); } -flow_indr_dev_setup_offload (dev,TC_SETUP_BLOCK , block, &bo, +flow_indr_dev_setup_offload (dev, sch,TC_SETUP_BLOCK , block, &bo, tc_block_indr_cleanup);tcf_block_setup (block, &bo);
@@ -717,7 +719,7 @@ static int tcf_block_offload_bind(struct tcf_block *block, struct Qdisc *q, goto err_unlock; } - err =tcf_block_offload_cmd (block, dev, ei,FLOW_BLOCK_BIND , extack); + err =tcf_block_offload_cmd (block, dev, q, ei,FLOW_BLOCK_BIND , extack);if (err == -EOPNOTSUPP ) goto no_offload_dev_inc;if (err)
@@ -744,7 +746,7 @@ static void tcf_block_offload_unbind(struct tcf_block *block, struct Qdisc *q,int err;down_write (&block->cb_lock); - err =tcf_block_offload_cmd (block, dev, ei,FLOW_BLOCK_UNBIND ,NULL ); + err =tcf_block_offload_cmd (block, dev, q, ei,FLOW_BLOCK_UNBIND ,NULL );if (err == -EOPNOTSUPP ) goto no_offload_dev_dec;up_write (&block->cb_lock);
Signature · 1 line
2.20.1
Jakub Kicinski
maintainerRe: [PATCH net-next v2 01/13] net: sched: Pass qdisc reference in struct flow_block_offload
Quoted 14 lines · On Sat, 11 Jul 2020 00:55:03 +0300 Petr Machata wrote:
drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c +1
-1@@ -1888,7 +1888,7 @@ static void bnxt_tc_setup_indr_rel(void *cb_priv)kfree (priv); } -static int bnxt_tc_setup_indr_block (struct net_device *netdev,struct bnxt *bp, +static int bnxt_tc_setup_indr_block (struct net_device *netdev,struct Qdisc *sch,struct bnxt *bp,struct flow_block_offload *f,void *data,void (*cleanup)(struct flow_block_cb *block_cb)) {
drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c static int bnxt_tc_setup_indr_block(struct net_device *netdev, struct bnxt *bp, · line 1914
Quoted 5 lines
drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c +1
-1@@ -1911,7 +1911,7 @@ static int bnxt_tc_setup_indr_block(struct net_device *netdev, struct bnxt *bp, block_cb =flow_indr_block_cb_alloc (bnxt_tc_setup_indr_block_cb, cb_priv, cb_priv, bnxt_tc_setup_indr_rel, f, - netdev, data, bp, cleanup); + netdev, sch, data, bp, cleanup);
nit: the number of arguments is getting out of hand here, perhaps it's
time to pass a structure in.
Quoted 22 lines
drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c +2
-3if (IS_ERR (block_cb)) {list_del (&cb_priv->list);kfree (cb_priv);@@ -1946,7 +1946,7 @@ static bool bnxt_is_netdev_indr_offload(struct net_device *netdev)return netif_is_vxlan (netdev); } -static int bnxt_tc_setup_indr_cb (struct net_device *netdev,void *cb_priv, +static int bnxt_tc_setup_indr_cb (struct net_device *netdev,struct Qdisc *sch,void *cb_priv,enum tc_setup_type type,void *type_data,void *data,void (*cleanup)(struct flow_block_cb *block_cb))@@ -1956,8 +1956,7 @@ static int bnxt_tc_setup_indr_cb(struct net_device *netdev, void *cb_priv,switch (type) {case TC_SETUP_BLOCK : -return bnxt_tc_setup_indr_block (netdev, cb_priv, type_data, data, - cleanup); +return bnxt_tc_setup_indr_block (netdev, sch, cb_priv, type_data, data, cleanup);default :break ; }
Re: [PATCH net-next v2 01/13] net: sched: Pass qdisc reference in struct flow_block_offload
Quoted 6 lines · Jakub Kicinski
Quoted 4 lines · On Sat, 11 Jul 2020 00:55:03 +0300 Petr Machata wrote:
drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c +0
-0
Quoted 9 lines
drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c static int bnxt_tc_setup_indr_block(struct net_device *netdev, struct bnxt *bp, · line 1914
Quoted 6 lines
drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c +1
-1@@ -1911,7 +1911,7 @@ static int bnxt_tc_setup_indr_block(struct net_device *netdev, struct bnxt *bp, block_cb =flow_indr_block_cb_alloc (bnxt_tc_setup_indr_block_cb, cb_priv, cb_priv, bnxt_tc_setup_indr_rel, f, - netdev, data, bp, cleanup); + netdev, sch, data, bp, cleanup);nit: the number of arguments is getting out of hand here, perhaps it's
time to pass a structure in.
I would say that adding a distinctly-typed and distinctly-named argument does not make the other arguments less clear, or increase the risk of mixing them up in a way that the compiler would not catch.
Taken from another angle, the argument list is not passed through layers of other functions, so the structure would be assembled in bnxt_tc_setup_indr_block() and then unpacked again in flow_indr_block_cb_alloc(). Nothing is saved in that regard either.
Also, flow_indr_block_cb_alloc() is a simple function. When a structure needs to be introduced to carry the arguments, it might be more straightforward to just open-code it.
Quoted 3 lines
Quoted 3 lines
drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c +0
-0if (IS_ERR (block_cb)) {list_del (&cb_priv->list);kfree (cb_priv);
PATCH v2 2/13 mlxsw: reg: Add Monitoring Mirror Trigger Enable Register
In reply to Petr MachataFrom: Amit Cohen <[email protected]>
This register is used to configure the mirror enable for different mirror reasons.
--- drivers/net/ethernet/mellanox/mlxsw/reg.h | 50 +++++++++++++++++++++++ 1 file changed, 50 insertions(+)
drivers/net/ethernet/mellanox/mlxsw/reg.h +50 -0
@@ -9502,6 +9502,55 @@ MLXSW_ITEM32(reg, mogcr, ptp_iftc, 0x00, 1, 1);*/ MLXSW_ITEM32 (reg, mogcr, ptp_eftc,0x00 ,0 ,1 ); +/* MOMTE - Monitoring Mirror Trigger Enable Register +* ------------------------------------------------- +* This register is used to configure the mirror enable for different mirror +* reasons. +*/ +#define MLXSW_REG_MOMTE_ID 0x908D +#define MLXSW_REG_MOMTE_LEN 0x10 + +MLXSW_REG_DEFINE (momte,MLXSW_REG_MOMTE_ID ,MLXSW_REG_MOMTE_LEN ); + +/* reg_momte_local_port +* Local port number. +* Access: Index +*/ +MLXSW_ITEM32 (reg, momte, local_port,0x00 ,16 ,8 ); + +enum mlxsw_reg_momte_type { +MLXSW_REG_MOMTE_TYPE_WRED =0x20 , +MLXSW_REG_MOMTE_TYPE_SHARED_BUFFER_TCLASS =0x31 , +MLXSW_REG_MOMTE_TYPE_SHARED_BUFFER_TCLASS_DESCRIPTORS =0x32 , +MLXSW_REG_MOMTE_TYPE_SHARED_BUFFER_EGRESS_PORT =0x33 , +MLXSW_REG_MOMTE_TYPE_ING_CONG =0x40 , +MLXSW_REG_MOMTE_TYPE_EGR_CONG =0x50 , +MLXSW_REG_MOMTE_TYPE_ECN =0x60 , +MLXSW_REG_MOMTE_TYPE_HIGH_LATENCY =0x70 , +}; + +/* reg_momte_type +* Type of mirroring. +* Access: Index +*/ +MLXSW_ITEM32 (reg, momte, type,0x04 ,0 ,8 ); + +/* reg_momte_tclass_en +* TClass/PG mirror enable. Each bit represents corresponding tclass. +* 0: disable (default) +* 1: enable +* Access: RW +*/ +MLXSW_ITEM_BIT_ARRAY (reg, momte, tclass_en,0x08 ,0x08 ,1 ); + +static inline void mlxsw_reg_momte_pack (char *payload,u8 local_port, +enum mlxsw_reg_momte_type type) +{ +MLXSW_REG_ZERO (momte, payload); +mlxsw_reg_momte_local_port_set (payload, local_port); +mlxsw_reg_momte_type_set (payload, type); +} +/* MTPPPC - Time Precision Packet Port Configuration * ------------------------------------------------- * This register serves for configuration of which PTP messages should be
@@ -10853,6 +10902,7 @@ static const struct mlxsw_reg_info *mlxsw_reg_infos[] = {MLXSW_REG (mgpc),MLXSW_REG (mprs),MLXSW_REG (mogcr), +MLXSW_REG (momte),MLXSW_REG (mtpppc),MLXSW_REG (mtpptr), MLXSW_REG(mtptpt),
Signature · 1 line
2.20.1
PATCH v2 3/13 mlxsw: reg: Add Monitoring Port Analyzer Global Register
In reply to Petr MachataFrom: Amit Cohen <[email protected]>
This register is used for global port analyzer configurations.
--- drivers/net/ethernet/mellanox/mlxsw/reg.h | 52 +++++++++++++++++++++++ 1 file changed, 52 insertions(+)
drivers/net/ethernet/mellanox/mlxsw/reg.h +52 -0
@@ -9502,6 +9502,57 @@ MLXSW_ITEM32(reg, mogcr, ptp_iftc, 0x00, 1, 1);*/ MLXSW_ITEM32 (reg, mogcr, ptp_eftc,0x00 ,0 ,1 ); +/* MPAGR - Monitoring Port Analyzer Global Register +* ------------------------------------------------ +* This register is used for global port analyzer configurations. +* Note: This register is not supported by current FW versions for Spectrum-1. +*/ +#define MLXSW_REG_MPAGR_ID 0x9089 +#define MLXSW_REG_MPAGR_LEN 0x0C + +MLXSW_REG_DEFINE (mpagr,MLXSW_REG_MPAGR_ID ,MLXSW_REG_MPAGR_LEN ); + +enum mlxsw_reg_mpagr_trigger { +MLXSW_REG_MPAGR_TRIGGER_EGRESS , +MLXSW_REG_MPAGR_TRIGGER_INGRESS , +MLXSW_REG_MPAGR_TRIGGER_INGRESS_WRED , +MLXSW_REG_MPAGR_TRIGGER_INGRESS_SHARED_BUFFER , +MLXSW_REG_MPAGR_TRIGGER_INGRESS_ING_CONG , +MLXSW_REG_MPAGR_TRIGGER_INGRESS_EGR_CONG , +MLXSW_REG_MPAGR_TRIGGER_EGRESS_ECN , +MLXSW_REG_MPAGR_TRIGGER_EGRESS_HIGH_LATENCY , +}; + +/* reg_mpagr_trigger +* Mirror trigger. +* Access: Index +*/ +MLXSW_ITEM32 (reg, mpagr, trigger,0x00 ,0 ,4 ); + +/* reg_mpagr_pa_id +* Port analyzer ID. +* Access: RW +*/ +MLXSW_ITEM32 (reg, mpagr, pa_id,0x04 ,0 ,4 ); + +/* reg_mpagr_probability_rate +* Sampling rate. +* Valid values are: 1 to 3.5*10^9 +* Value of 1 means "sample all". Default is 1. +* Access: RW +*/ +MLXSW_ITEM32 (reg, mpagr, probability_rate,0x08 ,0 ,32 ); + +static inline void mlxsw_reg_mpagr_pack (char *payload, +enum mlxsw_reg_mpagr_trigger trigger, +u8 pa_id,u32 probability_rate) +{ +MLXSW_REG_ZERO (mpagr, payload); +mlxsw_reg_mpagr_trigger_set (payload, trigger); +mlxsw_reg_mpagr_pa_id_set (payload, pa_id); +mlxsw_reg_mpagr_probability_rate_set (payload, probability_rate); +} +/* MOMTE - Monitoring Mirror Trigger Enable Register * ------------------------------------------------- * This register is used to configure the mirror enable for different mirror
@@ -10902,6 +10953,7 @@ static const struct mlxsw_reg_info *mlxsw_reg_infos[] = {MLXSW_REG (mgpc),MLXSW_REG (mprs),MLXSW_REG (mogcr), +MLXSW_REG (mpagr),MLXSW_REG (momte),MLXSW_REG (mtpppc), MLXSW_REG(mtpptr),
Signature · 1 line
2.20.1
PATCH v2 4/13 mlxsw: spectrum_span: Move SPAN operations out of global file
In reply to Petr MachataFrom: Ido Schimmel <[email protected]>
The per-ASIC SPAN operations are relevant to the SPAN module and therefore should be implemented there and not in the main driver file. Move them.
These operations will be extended later on.
--- .../net/ethernet/mellanox/mlxsw/spectrum.c | 50 ------------------- .../net/ethernet/mellanox/mlxsw/spectrum.h | 1 - .../ethernet/mellanox/mlxsw/spectrum_span.c | 47 +++++++++++++++++ .../ethernet/mellanox/mlxsw/spectrum_span.h | 8 +++ 4 files changed, 55 insertions(+), 51 deletions(-)
drivers/net/ethernet/mellanox/mlxsw/spectrum.c +0 -50
@@ -175,10 +175,6 @@ struct mlxsw_sp_mlxfw_dev {struct mlxsw_sp *mlxsw_sp; }; -struct mlxsw_sp_span_ops { -u32 (*buffsize_get)(int mtu,u32 speed); -}; -static int mlxsw_sp_component_query (struct mlxfw_dev *mlxfw_dev,u16 component_index,u32 *p_max_size,u8 *p_align_bits,u16 *p_max_write_size)
@@ -2812,52 +2808,6 @@ static const struct mlxsw_sp_ptp_ops mlxsw_sp2_ptp_ops = { .get_stats = mlxsw_sp2_get_stats, }; -static u32 mlxsw_sp1_span_buffsize_get (int mtu,u32 speed) -{ -return mtu *5 /2 ; -} - -static const struct mlxsw_sp_span_ops mlxsw_sp1_span_ops = { - .buffsize_get = mlxsw_sp1_span_buffsize_get, -}; - -#define MLXSW_SP2_SPAN_EG_MIRROR_BUFFER_FACTOR 38 -#define MLXSW_SP3_SPAN_EG_MIRROR_BUFFER_FACTOR 50 - -static u32 __mlxsw_sp_span_buffsize_get (int mtu,u32 speed,u32 buffer_factor) -{ -return 3 * mtu + buffer_factor * speed /1000 ; -} - -static u32 mlxsw_sp2_span_buffsize_get (int mtu,u32 speed) -{ -int factor =MLXSW_SP2_SPAN_EG_MIRROR_BUFFER_FACTOR ; - -return __mlxsw_sp_span_buffsize_get (mtu, speed, factor); -} - -static const struct mlxsw_sp_span_ops mlxsw_sp2_span_ops = { - .buffsize_get = mlxsw_sp2_span_buffsize_get, -}; - -static u32 mlxsw_sp3_span_buffsize_get (int mtu,u32 speed) -{ -int factor =MLXSW_SP3_SPAN_EG_MIRROR_BUFFER_FACTOR ; - -return __mlxsw_sp_span_buffsize_get (mtu, speed, factor); -} - -static const struct mlxsw_sp_span_ops mlxsw_sp3_span_ops = { - .buffsize_get = mlxsw_sp3_span_buffsize_get, -}; - -u32 mlxsw_sp_span_buffsize_get (struct mlxsw_sp *mlxsw_sp,int mtu,u32 speed) -{ -u32 buffsize = mlxsw_sp->span_ops->buffsize_get (speed, mtu); - -return mlxsw_sp_bytes_cells (mlxsw_sp, buffsize) +1 ; -} -static int mlxsw_sp_netdevice_event (struct notifier_block *unused,unsigned long event,void *ptr);
drivers/net/ethernet/mellanox/mlxsw/spectrum.h +0 -1
@@ -539,7 +539,6 @@ int mlxsw_sp_flow_counter_alloc(struct mlxsw_sp *mlxsw_sp, unsigned int *p_counter_index);void mlxsw_sp_flow_counter_free (struct mlxsw_sp *mlxsw_sp,unsigned int counter_index); -u32 mlxsw_sp_span_buffsize_get (struct mlxsw_sp *mlxsw_sp,int mtu,u32 speed);bool mlxsw_sp_port_dev_check (const struct net_device *dev);struct mlxsw_sp *mlxsw_sp_lower_get (struct net_device *dev);struct mlxsw_sp_port *mlxsw_sp_port_dev_lower_find (struct net_device *dev);
drivers/net/ethernet/mellanox/mlxsw/spectrum_span.c +47 -0
56 lines not on this page · raw message
drivers/net/ethernet/mellanox/mlxsw/spectrum_span.h +8 -0
@@ -34,6 +34,10 @@ struct mlxsw_sp_span_trigger_parms {struct mlxsw_sp_span_entry_ops ; +struct mlxsw_sp_span_ops { +u32 (*buffsize_get)(int mtu,u32 speed); +}; +struct mlxsw_sp_span_entry {const struct net_device *to_dev;const struct mlxsw_sp_span_entry_ops *ops;
@@ -82,4 +86,8 @@ mlxsw_sp_span_agent_unbind(struct mlxsw_sp *mlxsw_sp,struct mlxsw_sp_port *mlxsw_sp_port, const struct mlxsw_sp_span_trigger_parms *parms); +extern const struct mlxsw_sp_span_ops mlxsw_sp1_span_ops; +extern const struct mlxsw_sp_span_ops mlxsw_sp2_span_ops; +extern const struct mlxsw_sp_span_ops mlxsw_sp3_span_ops; +#endif
Signature · 1 line
2.20.1
PATCH v2 5/13 mlxsw: spectrum_span: Prepare for global mirroring triggers
In reply to Petr MachataFrom: Ido Schimmel <[email protected]>
Currently, a SPAN agent can only be bound to a per-port trigger where the trigger is either an incoming packet (INGRESS) or an outgoing packet (EGRESS) to / from the port.
The subsequent patch will introduce the concept of global mirroring triggers. The binding / unbinding of global triggers is different than that of per-port triggers. Such triggers also need to be enabled / disabled on a per-{port, TC} basis and are only supported from Spectrum-2 onwards.
Add trigger operations that allow us to abstract these differences. Only implement the operations for per-port triggers. Next patch will implement the operations for global triggers.
--- .../ethernet/mellanox/mlxsw/spectrum_span.c | 119 +++++++++++++++--- .../ethernet/mellanox/mlxsw/spectrum_span.h | 1 + 2 files changed, 103 insertions(+), 17 deletions(-)
drivers/net/ethernet/mellanox/mlxsw/spectrum_span.c +102 -17
@@ -21,6 +21,7 @@struct mlxsw_sp_span {struct work_struct work;struct mlxsw_sp *mlxsw_sp; +const struct mlxsw_sp_span_trigger_ops **span_trigger_ops_arr;struct list_head analyzed_ports_list;struct mutex analyzed_ports_lock;/* Protects analyzed_ports_list */ struct list_head trigger_entries_list;
@@ -38,12 +39,26 @@ struct mlxsw_sp_span_analyzed_port {struct mlxsw_sp_span_trigger_entry {struct list_head list;/* Member of trigger_entries_list */ +struct mlxsw_sp_span *span; +const struct mlxsw_sp_span_trigger_ops *ops;refcount_t ref_count;u8 local_port;enum mlxsw_sp_span_trigger trigger;struct mlxsw_sp_span_trigger_parms parms; }; +enum mlxsw_sp_span_trigger_type { +MLXSW_SP_SPAN_TRIGGER_TYPE_PORT , +}; + +struct mlxsw_sp_span_trigger_ops { +int (*bind)(struct mlxsw_sp_span_trigger_entry *trigger_entry); +void (*unbind)(struct mlxsw_sp_span_trigger_entry *trigger_entry); +bool (*matches)(struct mlxsw_sp_span_trigger_entry *trigger_entry, +enum mlxsw_sp_span_trigger trigger, +struct mlxsw_sp_port *mlxsw_sp_port); +}; +static void mlxsw_sp_span_respin_work (struct work_struct *work);static u64 mlxsw_sp_span_occ_get (void *priv)
@@ -57,7 +72,7 @@ int mlxsw_sp_span_init(struct mlxsw_sp *mlxsw_sp) {struct devlink *devlink =priv_to_devlink (mlxsw_sp->core);struct mlxsw_sp_span *span; -int i, entries_count; +int i, entries_count, err;if (!MLXSW_CORE_RES_VALID (mlxsw_sp->core,MAX_SPAN ))return -EIO ;
@@ -77,11 +92,20 @@ int mlxsw_sp_span_init(struct mlxsw_sp *mlxsw_sp)for (i =0 ; i < mlxsw_sp->span->entries_count; i++) mlxsw_sp->span->entries[i].id = i; + err = mlxsw_sp->span_ops->init (mlxsw_sp); +if (err) + goto err_init; +devlink_resource_occ_get_register (devlink,MLXSW_SP_RESOURCE_SPAN , mlxsw_sp_span_occ_get, mlxsw_sp);INIT_WORK (&span->work, mlxsw_sp_span_respin_work);return 0 ; + +err_init: +mutex_destroy (&mlxsw_sp->span->analyzed_ports_lock); +kfree (mlxsw_sp->span); +return err; }void mlxsw_sp_span_fini (struct mlxsw_sp *mlxsw_sp)
@@ -1059,9 +1083,9 @@ void mlxsw_sp_span_analyzed_port_put(struct mlxsw_sp_port *mlxsw_sp_port, }static int -__mlxsw_sp_span_trigger_entry_bind (struct mlxsw_sp_span *span, -struct mlxsw_sp_span_trigger_entry * - trigger_entry,bool enable) +__mlxsw_sp_span_trigger_port_bind (struct mlxsw_sp_span *span, +struct mlxsw_sp_span_trigger_entry * + trigger_entry,bool enable) {char mpar_pl[MLXSW_REG_MPAR_LEN ];enum mlxsw_reg_mpar_i_e i_e;
@@ -1084,19 +1108,60 @@ __mlxsw_sp_span_trigger_entry_bind(struct mlxsw_sp_span *span, }static int -mlxsw_sp_span_trigger_entry_bind (struct mlxsw_sp_span *span, -struct mlxsw_sp_span_trigger_entry * - trigger_entry) +mlxsw_sp_span_trigger_port_bind (struct mlxsw_sp_span_trigger_entry * + trigger_entry) { -return __mlxsw_sp_span_trigger_entry_bind (span, trigger_entry, true); +return __mlxsw_sp_span_trigger_port_bind (trigger_entry->span, + trigger_entry, true); }static void -mlxsw_sp_span_trigger_entry_unbind (struct mlxsw_sp_span *span, -struct mlxsw_sp_span_trigger_entry * - trigger_entry) +mlxsw_sp_span_trigger_port_unbind (struct mlxsw_sp_span_trigger_entry * + trigger_entry) { -__mlxsw_sp_span_trigger_entry_bind (span, trigger_entry, false); +__mlxsw_sp_span_trigger_port_bind (trigger_entry->span, trigger_entry, + false); +} + +static bool +mlxsw_sp_span_trigger_port_matches (struct mlxsw_sp_span_trigger_entry * + trigger_entry, +enum mlxsw_sp_span_trigger trigger, +struct mlxsw_sp_port *mlxsw_sp_port) +{ +return trigger_entry->trigger == trigger && + trigger_entry->local_port == mlxsw_sp_port->local_port; +} + +static const struct mlxsw_sp_span_trigger_ops +mlxsw_sp_span_trigger_port_ops = { + .bind = mlxsw_sp_span_trigger_port_bind, + .unbind = mlxsw_sp_span_trigger_port_unbind, + .matches = mlxsw_sp_span_trigger_port_matches, +}; + +static const struct mlxsw_sp_span_trigger_ops * +mlxsw_sp_span_trigger_ops_arr[] = { + [MLXSW_SP_SPAN_TRIGGER_TYPE_PORT ] = &mlxsw_sp_span_trigger_port_ops, +}; + +static void +mlxsw_sp_span_trigger_ops_set (struct mlxsw_sp_span_trigger_entry *trigger_entry) +{ +struct mlxsw_sp_span *span = trigger_entry->span; +enum mlxsw_sp_span_trigger_type type; + +switch (trigger_entry->trigger) { +case MLXSW_SP_SPAN_TRIGGER_INGRESS :/* fall-through */ +case MLXSW_SP_SPAN_TRIGGER_EGRESS : + type =MLXSW_SP_SPAN_TRIGGER_TYPE_PORT ; +break ; +default : +WARN_ON_ONCE (1 ); +return ; + } + + trigger_entry->ops = span->span_trigger_ops_arr[type]; } static struct mlxsw_sp_span_trigger_entry *
@@ -1114,12 +1179,15 @@ mlxsw_sp_span_trigger_entry_create(struct mlxsw_sp_span *span,return ERR_PTR (-ENOMEM );refcount_set (&trigger_entry->ref_count,1 ); - trigger_entry->local_port = mlxsw_sp_port->local_port; + trigger_entry->local_port = mlxsw_sp_port ? mlxsw_sp_port->local_port : +0 ; trigger_entry->trigger = trigger;memcpy (&trigger_entry->parms, parms,sizeof (trigger_entry->parms)); + trigger_entry->span = span; +mlxsw_sp_span_trigger_ops_set (trigger_entry);list_add_tail (&trigger_entry->list, &span->trigger_entries_list); - err =mlxsw_sp_span_trigger_entry_bind (span, trigger_entry); + err = trigger_entry->ops->bind (trigger_entry);if (err) goto err_trigger_entry_bind;
@@ -1136,7 +1204,7 @@ mlxsw_sp_span_trigger_entry_destroy(struct mlxsw_sp_span *span,struct mlxsw_sp_span_trigger_entry * trigger_entry) { -mlxsw_sp_span_trigger_entry_unbind (span, trigger_entry); + trigger_entry->ops->unbind (trigger_entry);list_del (&trigger_entry->list);kfree (trigger_entry); }
@@ -1149,8 +1217,8 @@ mlxsw_sp_span_trigger_entry_find(struct mlxsw_sp_span *span,struct mlxsw_sp_span_trigger_entry *trigger_entry;list_for_each_entry (trigger_entry, &span->trigger_entries_list, list) { -if (trigger_entry->trigger == trigger && - trigger_entry->local_port == mlxsw_sp_port->local_port) +if (trigger_entry->ops->matches (trigger_entry, trigger, + mlxsw_sp_port))return trigger_entry; }
@@ -1216,15 +1284,30 @@ void mlxsw_sp_span_agent_unbind(struct mlxsw_sp *mlxsw_sp,mlxsw_sp_span_trigger_entry_destroy (mlxsw_sp->span, trigger_entry); } +static int mlxsw_sp1_span_init (struct mlxsw_sp *mlxsw_sp) +{ + mlxsw_sp->span->span_trigger_ops_arr = mlxsw_sp_span_trigger_ops_arr; + +return 0 ; +} +static u32 mlxsw_sp1_span_buffsize_get (int mtu,u32 speed) {return mtu *5 /2 ; }const struct mlxsw_sp_span_ops mlxsw_sp1_span_ops = { + .init = mlxsw_sp1_span_init, .buffsize_get = mlxsw_sp1_span_buffsize_get, }; +static int mlxsw_sp2_span_init (struct mlxsw_sp *mlxsw_sp) +{ + mlxsw_sp->span->span_trigger_ops_arr = mlxsw_sp_span_trigger_ops_arr; + +return 0 ; +} +#define MLXSW_SP2_SPAN_EG_MIRROR_BUFFER_FACTOR 38#define MLXSW_SP3_SPAN_EG_MIRROR_BUFFER_FACTOR 50
@@ -1241,6 +1324,7 @@ static u32 mlxsw_sp2_span_buffsize_get(int mtu, u32 speed) }const struct mlxsw_sp_span_ops mlxsw_sp2_span_ops = { + .init = mlxsw_sp2_span_init, .buffsize_get = mlxsw_sp2_span_buffsize_get, };
@@ -1252,5 +1336,6 @@ static u32 mlxsw_sp3_span_buffsize_get(int mtu, u32 speed) }const struct mlxsw_sp_span_ops mlxsw_sp3_span_ops = { + .init = mlxsw_sp2_span_init, .buffsize_get = mlxsw_sp3_span_buffsize_get, };
drivers/net/ethernet/mellanox/mlxsw/spectrum_span.h +1 -0
@@ -35,6 +35,7 @@ struct mlxsw_sp_span_trigger_parms {struct mlxsw_sp_span_entry_ops ;struct mlxsw_sp_span_ops { +int (*init)(struct mlxsw_sp *mlxsw_sp);u32 (*buffsize_get)(int mtu,u32 speed); };
Signature · 1 line
2.20.1
PATCH v2 6/13 mlxsw: spectrum_span: Add support for global mirroring triggers
In reply to Petr MachataFrom: Ido Schimmel <[email protected]>
Global mirroring triggers are triggers that are only keyed by their trigger, as opposed to per-port triggers, which are keyed by their trigger and port.
Such triggers allow mirroring packets that were tail/early dropped or ECN marked to a SPAN agent.
Implement the previously added trigger operations for these global triggers. Since such triggers are only supported from Spectrum-2 onwards, have the Spectrum-1 operations return an error.
--- .../ethernet/mellanox/mlxsw/spectrum_span.c | 104 +++++++++++++++++- .../ethernet/mellanox/mlxsw/spectrum_span.h | 3 + 2 files changed, 104 insertions(+), 3 deletions(-)
drivers/net/ethernet/mellanox/mlxsw/spectrum_span.c +101 -3
@@ -49,6 +49,7 @@ struct mlxsw_sp_span_trigger_entry {enum mlxsw_sp_span_trigger_type {MLXSW_SP_SPAN_TRIGGER_TYPE_PORT , +MLXSW_SP_SPAN_TRIGGER_TYPE_GLOBAL , };struct mlxsw_sp_span_trigger_ops {
@@ -1140,9 +1141,101 @@ mlxsw_sp_span_trigger_port_ops = { .matches = mlxsw_sp_span_trigger_port_matches, }; +static int +mlxsw_sp1_span_trigger_global_bind (struct mlxsw_sp_span_trigger_entry * + trigger_entry) +{ +return -EOPNOTSUPP ; +} + +static void +mlxsw_sp1_span_trigger_global_unbind (struct mlxsw_sp_span_trigger_entry * + trigger_entry) +{ +} + +static bool +mlxsw_sp1_span_trigger_global_matches (struct mlxsw_sp_span_trigger_entry * + trigger_entry, +enum mlxsw_sp_span_trigger trigger, +struct mlxsw_sp_port *mlxsw_sp_port) +{ +WARN_ON_ONCE (1 ); +return false; +} + +static const struct mlxsw_sp_span_trigger_ops +mlxsw_sp1_span_trigger_global_ops = { + .bind = mlxsw_sp1_span_trigger_global_bind, + .unbind = mlxsw_sp1_span_trigger_global_unbind, + .matches = mlxsw_sp1_span_trigger_global_matches, +}; +static const struct mlxsw_sp_span_trigger_ops * -mlxsw_sp_span_trigger_ops_arr[] = { +mlxsw_sp1_span_trigger_ops_arr[] = { [MLXSW_SP_SPAN_TRIGGER_TYPE_PORT ] = &mlxsw_sp_span_trigger_port_ops, + [MLXSW_SP_SPAN_TRIGGER_TYPE_GLOBAL ] = + &mlxsw_sp1_span_trigger_global_ops, +}; + +static int +mlxsw_sp2_span_trigger_global_bind (struct mlxsw_sp_span_trigger_entry * + trigger_entry) +{ +struct mlxsw_sp *mlxsw_sp = trigger_entry->span->mlxsw_sp; +enum mlxsw_reg_mpagr_trigger trigger; +char mpagr_pl[MLXSW_REG_MPAGR_LEN ]; + +switch (trigger_entry->trigger) { +case MLXSW_SP_SPAN_TRIGGER_TAIL_DROP : + trigger =MLXSW_REG_MPAGR_TRIGGER_INGRESS_SHARED_BUFFER ; +break ; +case MLXSW_SP_SPAN_TRIGGER_EARLY_DROP : + trigger =MLXSW_REG_MPAGR_TRIGGER_INGRESS_WRED ; +break ; +case MLXSW_SP_SPAN_TRIGGER_ECN : + trigger =MLXSW_REG_MPAGR_TRIGGER_EGRESS_ECN ; +break ; +default : +WARN_ON_ONCE (1 ); +return -EINVAL ; + } + +mlxsw_reg_mpagr_pack (mpagr_pl, trigger, trigger_entry->parms.span_id, +1 ); +return mlxsw_reg_write (mlxsw_sp->core,MLXSW_REG (mpagr), mpagr_pl); +} + +static void +mlxsw_sp2_span_trigger_global_unbind (struct mlxsw_sp_span_trigger_entry * + trigger_entry) +{ +/* There is no unbinding for global triggers. The trigger should be +* disabled on all ports by now. +*/ +} + +static bool +mlxsw_sp2_span_trigger_global_matches (struct mlxsw_sp_span_trigger_entry * + trigger_entry, +enum mlxsw_sp_span_trigger trigger, +struct mlxsw_sp_port *mlxsw_sp_port) +{ +return trigger_entry->trigger == trigger; +} + +static const struct mlxsw_sp_span_trigger_ops +mlxsw_sp2_span_trigger_global_ops = { + .bind = mlxsw_sp2_span_trigger_global_bind, + .unbind = mlxsw_sp2_span_trigger_global_unbind, + .matches = mlxsw_sp2_span_trigger_global_matches, +}; + +static const struct mlxsw_sp_span_trigger_ops * +mlxsw_sp2_span_trigger_ops_arr[] = { + [MLXSW_SP_SPAN_TRIGGER_TYPE_PORT ] = &mlxsw_sp_span_trigger_port_ops, + [MLXSW_SP_SPAN_TRIGGER_TYPE_GLOBAL ] = + &mlxsw_sp2_span_trigger_global_ops, }; static void
@@ -1156,6 +1249,11 @@ mlxsw_sp_span_trigger_ops_set(struct mlxsw_sp_span_trigger_entry *trigger_entry)case MLXSW_SP_SPAN_TRIGGER_EGRESS : type =MLXSW_SP_SPAN_TRIGGER_TYPE_PORT ;break ; +case MLXSW_SP_SPAN_TRIGGER_TAIL_DROP :/* fall-through */ +case MLXSW_SP_SPAN_TRIGGER_EARLY_DROP :/* fall-through */ +case MLXSW_SP_SPAN_TRIGGER_ECN : + type =MLXSW_SP_SPAN_TRIGGER_TYPE_GLOBAL ; +break ;default :WARN_ON_ONCE (1 );return ;
@@ -1286,7 +1384,7 @@ void mlxsw_sp_span_agent_unbind(struct mlxsw_sp *mlxsw_sp,static int mlxsw_sp1_span_init (struct mlxsw_sp *mlxsw_sp) { - mlxsw_sp->span->span_trigger_ops_arr = mlxsw_sp_span_trigger_ops_arr; + mlxsw_sp->span->span_trigger_ops_arr = mlxsw_sp1_span_trigger_ops_arr;return 0 ; }
@@ -1303,7 +1401,7 @@ const struct mlxsw_sp_span_ops mlxsw_sp1_span_ops = {static int mlxsw_sp2_span_init (struct mlxsw_sp *mlxsw_sp) { - mlxsw_sp->span->span_trigger_ops_arr = mlxsw_sp_span_trigger_ops_arr; + mlxsw_sp->span->span_trigger_ops_arr = mlxsw_sp2_span_trigger_ops_arr;return 0 ; }
drivers/net/ethernet/mellanox/mlxsw/spectrum_span.h +3 -0
@@ -26,6 +26,9 @@ struct mlxsw_sp_span_parms {enum mlxsw_sp_span_trigger {MLXSW_SP_SPAN_TRIGGER_INGRESS ,MLXSW_SP_SPAN_TRIGGER_EGRESS , +MLXSW_SP_SPAN_TRIGGER_TAIL_DROP , +MLXSW_SP_SPAN_TRIGGER_EARLY_DROP , +MLXSW_SP_SPAN_TRIGGER_ECN , };struct mlxsw_sp_span_trigger_parms {
Signature · 1 line
2.20.1
PATCH v2 7/13 mlxsw: spectrum_span: Add APIs to enable / disable global mirroring triggers
In reply to Petr MachataFrom: Ido Schimmel <[email protected]>
While the binding of global mirroring triggers to a SPAN agent is global, packets are only mirrored if they belong to a port and TC on which the trigger was enabled. This allows, for example, to mirror packets that were tail-dropped on a specific netdev.
Implement the operations that allow to enable / disable a global mirroring trigger on a specific port and TC.
--- .../ethernet/mellanox/mlxsw/spectrum_span.c | 135 ++++++++++++++++++ .../ethernet/mellanox/mlxsw/spectrum_span.h | 4 + 2 files changed, 139 insertions(+)
drivers/net/ethernet/mellanox/mlxsw/spectrum_span.c +135 -0
@@ -58,6 +58,10 @@ struct mlxsw_sp_span_trigger_ops {bool (*matches)(struct mlxsw_sp_span_trigger_entry *trigger_entry,enum mlxsw_sp_span_trigger trigger,struct mlxsw_sp_port *mlxsw_sp_port); +int (*enable)(struct mlxsw_sp_span_trigger_entry *trigger_entry, +struct mlxsw_sp_port *mlxsw_sp_port,u8 tc); +void (*disable)(struct mlxsw_sp_span_trigger_entry *trigger_entry, +struct mlxsw_sp_port *mlxsw_sp_port,u8 tc); };static void mlxsw_sp_span_respin_work (struct work_struct *work);
@@ -1134,11 +1138,29 @@ mlxsw_sp_span_trigger_port_matches(struct mlxsw_sp_span_trigger_entry * trigger_entry->local_port == mlxsw_sp_port->local_port; } +static int +mlxsw_sp_span_trigger_port_enable (struct mlxsw_sp_span_trigger_entry * + trigger_entry, +struct mlxsw_sp_port *mlxsw_sp_port,u8 tc) +{ +/* Port trigger are enabled during binding. */ +return 0 ; +} + +static void +mlxsw_sp_span_trigger_port_disable (struct mlxsw_sp_span_trigger_entry * + trigger_entry, +struct mlxsw_sp_port *mlxsw_sp_port,u8 tc) +{ +} +static const struct mlxsw_sp_span_trigger_ops mlxsw_sp_span_trigger_port_ops = { .bind = mlxsw_sp_span_trigger_port_bind, .unbind = mlxsw_sp_span_trigger_port_unbind, .matches = mlxsw_sp_span_trigger_port_matches, + .enable = mlxsw_sp_span_trigger_port_enable, + .disable = mlxsw_sp_span_trigger_port_disable, }; static int
@@ -1164,11 +1186,30 @@ mlxsw_sp1_span_trigger_global_matches(struct mlxsw_sp_span_trigger_entry *return false; } +static int +mlxsw_sp1_span_trigger_global_enable (struct mlxsw_sp_span_trigger_entry * + trigger_entry, +struct mlxsw_sp_port *mlxsw_sp_port, +u8 tc) +{ +return -EOPNOTSUPP ; +} + +static void +mlxsw_sp1_span_trigger_global_disable (struct mlxsw_sp_span_trigger_entry * + trigger_entry, +struct mlxsw_sp_port *mlxsw_sp_port, +u8 tc) +{ +} +static const struct mlxsw_sp_span_trigger_ops mlxsw_sp1_span_trigger_global_ops = { .bind = mlxsw_sp1_span_trigger_global_bind, .unbind = mlxsw_sp1_span_trigger_global_unbind, .matches = mlxsw_sp1_span_trigger_global_matches, + .enable = mlxsw_sp1_span_trigger_global_enable, + .disable = mlxsw_sp1_span_trigger_global_disable, }; static const struct mlxsw_sp_span_trigger_ops *
@@ -1224,11 +1265,71 @@ mlxsw_sp2_span_trigger_global_matches(struct mlxsw_sp_span_trigger_entry *return trigger_entry->trigger == trigger; } +static int +__mlxsw_sp2_span_trigger_global_enable (struct mlxsw_sp_span_trigger_entry * + trigger_entry, +struct mlxsw_sp_port *mlxsw_sp_port, +u8 tc,bool enable) +{ +struct mlxsw_sp *mlxsw_sp = trigger_entry->span->mlxsw_sp; +char momte_pl[MLXSW_REG_MOMTE_LEN ]; +enum mlxsw_reg_momte_type type; +int err; + +switch (trigger_entry->trigger) { +case MLXSW_SP_SPAN_TRIGGER_TAIL_DROP : + type =MLXSW_REG_MOMTE_TYPE_SHARED_BUFFER_TCLASS ; +break ; +case MLXSW_SP_SPAN_TRIGGER_EARLY_DROP : + type =MLXSW_REG_MOMTE_TYPE_WRED ; +break ; +case MLXSW_SP_SPAN_TRIGGER_ECN : + type =MLXSW_REG_MOMTE_TYPE_ECN ; +break ; +default : +WARN_ON_ONCE (1 ); +return -EINVAL ; + } + +/* Query existing configuration in order to only change the state of +* the specified traffic class. +*/ +mlxsw_reg_momte_pack (momte_pl, mlxsw_sp_port->local_port, type); + err =mlxsw_reg_query (mlxsw_sp->core,MLXSW_REG (momte), momte_pl); +if (err) +return err; + +mlxsw_reg_momte_tclass_en_set (momte_pl, tc, enable); +return mlxsw_reg_write (mlxsw_sp->core,MLXSW_REG (momte), momte_pl); +} + +static int +mlxsw_sp2_span_trigger_global_enable (struct mlxsw_sp_span_trigger_entry * + trigger_entry, +struct mlxsw_sp_port *mlxsw_sp_port, +u8 tc) +{ +return __mlxsw_sp2_span_trigger_global_enable (trigger_entry, + mlxsw_sp_port, tc, true); +} + +static void +mlxsw_sp2_span_trigger_global_disable (struct mlxsw_sp_span_trigger_entry * + trigger_entry, +struct mlxsw_sp_port *mlxsw_sp_port, +u8 tc) +{ +__mlxsw_sp2_span_trigger_global_enable (trigger_entry, mlxsw_sp_port, tc, + false); +} +static const struct mlxsw_sp_span_trigger_ops mlxsw_sp2_span_trigger_global_ops = { .bind = mlxsw_sp2_span_trigger_global_bind, .unbind = mlxsw_sp2_span_trigger_global_unbind, .matches = mlxsw_sp2_span_trigger_global_matches, + .enable = mlxsw_sp2_span_trigger_global_enable, + .disable = mlxsw_sp2_span_trigger_global_disable, }; static const struct mlxsw_sp_span_trigger_ops *
@@ -1382,6 +1483,40 @@ void mlxsw_sp_span_agent_unbind(struct mlxsw_sp *mlxsw_sp,mlxsw_sp_span_trigger_entry_destroy (mlxsw_sp->span, trigger_entry); } +int mlxsw_sp_span_trigger_enable (struct mlxsw_sp_port *mlxsw_sp_port, +enum mlxsw_sp_span_trigger trigger,u8 tc) +{ +struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; +struct mlxsw_sp_span_trigger_entry *trigger_entry; + +ASSERT_RTNL (); + + trigger_entry =mlxsw_sp_span_trigger_entry_find (mlxsw_sp->span, + trigger, + mlxsw_sp_port); +if (WARN_ON_ONCE (!trigger_entry)) +return -EINVAL ; + +return trigger_entry->ops->enable (trigger_entry, mlxsw_sp_port, tc); +} + +void mlxsw_sp_span_trigger_disable (struct mlxsw_sp_port *mlxsw_sp_port, +enum mlxsw_sp_span_trigger trigger,u8 tc) +{ +struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; +struct mlxsw_sp_span_trigger_entry *trigger_entry; + +ASSERT_RTNL (); + + trigger_entry =mlxsw_sp_span_trigger_entry_find (mlxsw_sp->span, + trigger, + mlxsw_sp_port); +if (WARN_ON_ONCE (!trigger_entry)) +return ; + +return trigger_entry->ops->disable (trigger_entry, mlxsw_sp_port, tc); +} +static int mlxsw_sp1_span_init (struct mlxsw_sp *mlxsw_sp) { mlxsw_sp->span->span_trigger_ops_arr = mlxsw_sp1_span_trigger_ops_arr;
drivers/net/ethernet/mellanox/mlxsw/spectrum_span.h +4 -0
@@ -89,6 +89,10 @@ mlxsw_sp_span_agent_unbind(struct mlxsw_sp *mlxsw_sp,enum mlxsw_sp_span_trigger trigger, struct mlxsw_sp_port *mlxsw_sp_port, const struct mlxsw_sp_span_trigger_parms *parms); +int mlxsw_sp_span_trigger_enable (struct mlxsw_sp_port *mlxsw_sp_port, +enum mlxsw_sp_span_trigger trigger,u8 tc); +void mlxsw_sp_span_trigger_disable (struct mlxsw_sp_port *mlxsw_sp_port, +enum mlxsw_sp_span_trigger trigger,u8 tc);extern const struct mlxsw_sp_span_ops mlxsw_sp1_span_ops;extern const struct mlxsw_sp_span_ops mlxsw_sp2_span_ops;
Signature · 1 line
2.20.1
PATCH v2 8/13 mlxsw: spectrum_flow: Convert a goto to a return
In reply to Petr MachataNo clean-up is performed at the target label of this goto. Convert it to a direct return.
--- drivers/net/ethernet/mellanox/mlxsw/spectrum_flow.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/net/ethernet/mellanox/mlxsw/spectrum_flow.c +1 -3
@@ -219,8 +219,7 @@ static int mlxsw_sp_setup_tc_block_bind(struct mlxsw_sp_port *mlxsw_sp_port, mlxsw_sp_tc_block_release);if (IS_ERR (block_cb)) {mlxsw_sp_flow_block_destroy (flow_block); - err =PTR_ERR (block_cb); - goto err_cb_register; +return PTR_ERR (block_cb); } register_block = true; }else {
@@ -247,7 +246,6 @@ static int mlxsw_sp_setup_tc_block_bind(struct mlxsw_sp_port *mlxsw_sp_port, err_block_bind:if (!flow_block_cb_decref (block_cb))flow_block_cb_free (block_cb); -err_cb_register:return err; }
Signature · 1 line
2.20.1
PATCH v2 9/13 mlxsw: spectrum_flow: Drop an unused field
In reply to Petr MachataThe field "dev" in struct mlxsw_sp_flow_block_binding is not used. Drop it.
--- drivers/net/ethernet/mellanox/mlxsw/spectrum.h | 1 - 1 file changed, 1 deletion(-)
drivers/net/ethernet/mellanox/mlxsw/spectrum.h +0 -1
@@ -710,7 +710,6 @@ struct mlxsw_sp_flow_block {struct mlxsw_sp_flow_block_binding {struct list_head list; -struct net_device *dev;struct mlxsw_sp_port *mlxsw_sp_port;bool ingress; };
Signature · 1 line
2.20.1
PATCH v2 10/13 mlxsw: spectrum_matchall: Publish matchall data structures
In reply to Petr MachataA following patch introduces offloading of filters attached to blocks bound to the RED tail_drop qevent. The only classifier that mlxsw will permit in this role is matchall. mlxsw currently offloads matchall filters used with clsact qdisc. The data structures used for that offload will come handy for the qevent offload as well. Publish them in spectrum.h.
--- .../net/ethernet/mellanox/mlxsw/spectrum.h | 24 +++++++++++++++++++ .../mellanox/mlxsw/spectrum_matchall.c | 23 ------------------ 2 files changed, 24 insertions(+), 23 deletions(-)
drivers/net/ethernet/mellanox/mlxsw/spectrum.h +24 -0
@@ -960,6 +960,30 @@ extern const struct mlxsw_afk_ops mlxsw_sp1_afk_ops;extern const struct mlxsw_afk_ops mlxsw_sp2_afk_ops;/* spectrum_matchall.c */ +enum mlxsw_sp_mall_action_type { +MLXSW_SP_MALL_ACTION_TYPE_MIRROR , +MLXSW_SP_MALL_ACTION_TYPE_SAMPLE , +MLXSW_SP_MALL_ACTION_TYPE_TRAP , +}; + +struct mlxsw_sp_mall_mirror_entry { +const struct net_device *to_dev; +int span_id; +}; + +struct mlxsw_sp_mall_entry { +struct list_head list; +unsigned long cookie; +unsigned int priority; +enum mlxsw_sp_mall_action_type type; +bool ingress; +union { +struct mlxsw_sp_mall_mirror_entry mirror; +struct mlxsw_sp_port_sample sample; + }; +struct rcu_head rcu; +}; +int mlxsw_sp_mall_replace (struct mlxsw_sp *mlxsw_sp,struct mlxsw_sp_flow_block *block,struct tc_cls_matchall_offload *f);
drivers/net/ethernet/mellanox/mlxsw/spectrum_matchall.c +0 -23
@@ -10,29 +10,6 @@#include "spectrum_span.h" #include "reg.h" -enum mlxsw_sp_mall_action_type { -MLXSW_SP_MALL_ACTION_TYPE_MIRROR , -MLXSW_SP_MALL_ACTION_TYPE_SAMPLE , -}; - -struct mlxsw_sp_mall_mirror_entry { -const struct net_device *to_dev; -int span_id; -}; - -struct mlxsw_sp_mall_entry { -struct list_head list; -unsigned long cookie; -unsigned int priority; -enum mlxsw_sp_mall_action_type type; -bool ingress; -union { -struct mlxsw_sp_mall_mirror_entry mirror; -struct mlxsw_sp_port_sample sample; - }; -struct rcu_head rcu; -}; -static struct mlxsw_sp_mall_entry *mlxsw_sp_mall_entry_find (struct mlxsw_sp_flow_block *block,unsigned long cookie) {
Signature · 1 line
2.20.1
PATCH v2 11/13 mlxsw: spectrum_flow: Promote binder-type dispatch to spectrum.c
In reply to Petr MachataTwo RED qevents have been introduced recently. From the point of view of a driver, qevents are simply blocks with unusual binder types. However they need to be handled by different logic than ACL-like flows.
Thus rename mlxsw_sp_setup_tc_block() to mlxsw_sp_setup_tc_block_clsact() and move the binder-type dispatch from there to spectrum.c into a new function of the original name. The new dispatcher is easier to extend with new binder types.
--- drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 13 +++++++++++++ drivers/net/ethernet/mellanox/mlxsw/spectrum.h | 5 +++-- .../net/ethernet/mellanox/mlxsw/spectrum_flow.c | 14 +++----------- 3 files changed, 19 insertions(+), 13 deletions(-)
drivers/net/ethernet/mellanox/mlxsw/spectrum.c +13 -0
@@ -1329,6 +1329,19 @@ static int mlxsw_sp_port_kill_vid(struct net_device *dev,return 0 ; } +static int mlxsw_sp_setup_tc_block (struct mlxsw_sp_port *mlxsw_sp_port, +struct flow_block_offload *f) +{ +switch (f->binder_type) { +case FLOW_BLOCK_BINDER_TYPE_CLSACT_INGRESS : +return mlxsw_sp_setup_tc_block_clsact (mlxsw_sp_port, f, true); +case FLOW_BLOCK_BINDER_TYPE_CLSACT_EGRESS : +return mlxsw_sp_setup_tc_block_clsact (mlxsw_sp_port, f, false); +default : +return -EOPNOTSUPP ; + } +} +static int mlxsw_sp_setup_tc (struct net_device *dev,enum tc_setup_type type,void *type_data) {
drivers/net/ethernet/mellanox/mlxsw/spectrum.h +3 -2
@@ -767,8 +767,9 @@ mlxsw_sp_flow_block_is_mixed_bound(const struct mlxsw_sp_flow_block *block)struct mlxsw_sp_flow_block *mlxsw_sp_flow_block_create (struct mlxsw_sp *mlxsw_sp,struct net *net);void mlxsw_sp_flow_block_destroy (struct mlxsw_sp_flow_block *block); -int mlxsw_sp_setup_tc_block (struct mlxsw_sp_port *mlxsw_sp_port, -struct flow_block_offload *f); +int mlxsw_sp_setup_tc_block_clsact (struct mlxsw_sp_port *mlxsw_sp_port, +struct flow_block_offload *f, +bool ingress);/* spectrum_acl.c */ struct mlxsw_sp_acl_ruleset ;
drivers/net/ethernet/mellanox/mlxsw/spectrum_flow.c +3 -11
@@ -277,18 +277,10 @@ static void mlxsw_sp_setup_tc_block_unbind(struct mlxsw_sp_port *mlxsw_sp_port, } } -int mlxsw_sp_setup_tc_block (struct mlxsw_sp_port *mlxsw_sp_port, -struct flow_block_offload *f) +int mlxsw_sp_setup_tc_block_clsact (struct mlxsw_sp_port *mlxsw_sp_port, +struct flow_block_offload *f, +bool ingress) { -bool ingress; - -if (f->binder_type ==FLOW_BLOCK_BINDER_TYPE_CLSACT_INGRESS ) - ingress = true; -else if (f->binder_type ==FLOW_BLOCK_BINDER_TYPE_CLSACT_EGRESS ) - ingress = false; -else -return -EOPNOTSUPP ; - f->driver_block_list = &mlxsw_sp_block_cb_list;switch (f->command) {
Signature · 1 line
2.20.1
PATCH v2 12/13 mlxsw: spectrum_qdisc: Offload mirroring on RED qevent early_drop
In reply to Petr MachataThe RED qevents early_drop and mark can be offloaded under the following fairly strict conditions:
- At most one filter is configured at the qevent block
- The protocol is "any"
- The classifier is matchall
- The action is trap, sample, or mirror with the same conditions as with other SPAN offloads
- The hw_counters type is none
In this patchset, implement offload of mirror for early_drop qevent. The ECN trigger is currently not implemented in the FW and therefore the mark qevent is not supported.
The qevent notifications look exactly like regular block binding notifications with a binder type that identifies them as qevents. Therefore the details of processing this binding are fairly similar to the matchall offload.
struct flow_block_offload.sch points at the qdisc in question. Use it to figure out if the qdisc is offloaded at all and what TC it configures. Bounce bindings on not-offloaded qdiscs.
Individual bindings are kept in a list so that several qevents can share the same block and all binding points get configured as the configured filters change.
--- .../net/ethernet/mellanox/mlxsw/spectrum.c | 2 + .../net/ethernet/mellanox/mlxsw/spectrum.h | 2 + .../ethernet/mellanox/mlxsw/spectrum_qdisc.c | 472 ++++++++++++++++++ 3 files changed, 476 insertions(+)
drivers/net/ethernet/mellanox/mlxsw/spectrum.c +2 -0
@@ -1337,6 +1337,8 @@ static int mlxsw_sp_setup_tc_block(struct mlxsw_sp_port *mlxsw_sp_port,return mlxsw_sp_setup_tc_block_clsact (mlxsw_sp_port, f, true);case FLOW_BLOCK_BINDER_TYPE_CLSACT_EGRESS :return mlxsw_sp_setup_tc_block_clsact (mlxsw_sp_port, f, false); +case FLOW_BLOCK_BINDER_TYPE_RED_EARLY_DROP : +return mlxsw_sp_setup_tc_block_qevent_early_drop (mlxsw_sp_port, f);default :return -EOPNOTSUPP ; }
drivers/net/ethernet/mellanox/mlxsw/spectrum.h +2 -0
@@ -1031,6 +1031,8 @@ int mlxsw_sp_setup_tc_tbf(struct mlxsw_sp_port *mlxsw_sp_port, struct tc_tbf_qopt_offload *p);int mlxsw_sp_setup_tc_fifo (struct mlxsw_sp_port *mlxsw_sp_port,struct tc_fifo_qopt_offload *p); +int mlxsw_sp_setup_tc_block_qevent_early_drop (struct mlxsw_sp_port *mlxsw_sp_port, +struct flow_block_offload *f);/* spectrum_fid.c */ bool mlxsw_sp_fid_is_dummy (struct mlxsw_sp *mlxsw_sp,u16 fid_index);
drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c +472 -0
484 lines not on this page · raw message
Signature · 1 line
2.20.1
PATCH v2 13/13 selftests: mlxsw: RED: Test offload of mirror on RED early_drop qevent
In reply to Petr MachataAdd a selftest for offloading a mirror action attached to the block associated with RED early_drop qevent.
--- .../drivers/net/mlxsw/sch_red_core.sh | 106 +++++++++++++++++- .../drivers/net/mlxsw/sch_red_ets.sh | 11 ++ .../drivers/net/mlxsw/sch_red_root.sh | 8 ++ 3 files changed, 122 insertions(+), 3 deletions(-)
tools/testing/selftests/drivers/net/mlxsw/sch_red_core.sh +103 -3
@@ -121,6 +121,7 @@ h1_destroy() h2_create() { host_create $h2 2 + tc qdisc add dev $h2 clsact # Some of the tests in this suite use multicast traffic. As this traffic # enters BR2_10 resp. BR2_11, it is flooded to all other ports. Thus
@@ -141,6 +142,7 @@ h2_create() h2_destroy() { ethtool -s $h2 autoneg on + tc qdisc del dev $h2 clsact host_destroy $h2 }
@@ -336,6 +338,17 @@ get_qdisc_npackets() qdisc_stats_get $swp3 $(get_qdisc_handle $vlan) .packets } +send_packets() +{ + local vlan=$1; shift + local proto=$1; shift + local pkts=$1; shift + + $MZ $h2.$vlan -p 8000 -a own -b $h3_mac \ + -A $(ipaddr 2 $vlan) -B $(ipaddr 3 $vlan) \ + -t $proto -q -c $pkts "$@" +} + # This sends traffic in an attempt to build a backlog of $size. Returns 0 on # success. After 10 failed attempts it bails out and returns 1. It dumps the # backlog size to stdout.
@@ -364,9 +377,7 @@ build_backlog() return 1 fi - $MZ $h2.$vlan -p 8000 -a own -b $h3_mac \ - -A $(ipaddr 2 $vlan) -B $(ipaddr 3 $vlan) \ - -t $proto -q -c $pkts "$@" + send_packets $vlan $proto $pkts "$@" done }
@@ -531,3 +542,92 @@ do_mc_backlog_test() log_test "TC $((vlan - 10)): Qdisc reports MC backlog" } + +do_drop_test() +{ + local vlan=$1; shift + local limit=$1; shift + local trigger=$1; shift + local subtest=$1; shift + local fetch_counter=$1; shift + local backlog + local base + local now + local pct + + RET=0 + + start_traffic $h1.$vlan $(ipaddr 1 $vlan) $(ipaddr 3 $vlan) $h3_mac + + # Create a bit of a backlog and observe no mirroring due to drops. + qevent_rule_install_$subtest + base=$($fetch_counter) + + build_backlog $vlan $((2 * limit / 3)) udp >/dev/null + + busywait 1100 until_counter_is ">= $((base + 1))" $fetch_counter >/dev/null + check_fail $? "Spurious packets observed without buffer pressure" + + qevent_rule_uninstall_$subtest + + # Push to the queue until it's at the limit. The configured limit is + # rounded by the qdisc and then by the driver, so this is the best we + # can do to get to the real limit of the system. Do this with the rules + # uninstalled so that the inevitable drops don't get counted. + build_backlog $vlan $((3 * limit / 2)) udp >/dev/null + + qevent_rule_install_$subtest + base=$($fetch_counter) + + send_packets $vlan udp 11 + + now=$(busywait 1100 until_counter_is ">= $((base + 10))" $fetch_counter) + check_err $? "Dropped packets not observed: 11 expected, $((now - base)) seen" + + # When no extra traffic is injected, there should be no mirroring. + busywait 1100 until_counter_is ">= $((base + 20))" $fetch_counter >/dev/null + check_fail $? "Spurious packets observed" + + # When the rule is uninstalled, there should be no mirroring. + qevent_rule_uninstall_$subtest + send_packets $vlan udp 11 + busywait 1100 until_counter_is ">= $((base + 20))" $fetch_counter >/dev/null + check_fail $? "Spurious packets observed after uninstall" + + log_test "TC $((vlan - 10)): ${trigger}ped packets $subtest'd" + + stop_traffic + sleep 1 +} + +qevent_rule_install_mirror() +{ + tc filter add block 10 pref 1234 handle 102 matchall skip_sw \ + action mirred egress mirror dev $swp2 hw_stats disabled +} + +qevent_rule_uninstall_mirror() +{ + tc filter del block 10 pref 1234 handle 102 matchall +} + +qevent_counter_fetch_mirror() +{ + tc_rule_handle_stats_get "dev $h2 ingress" 101 +} + +do_drop_mirror_test() +{ + local vlan=$1; shift + local limit=$1; shift + local qevent_name=$1; shift + + tc filter add dev $h2 ingress pref 1 handle 101 prot ip \ + flower skip_sw ip_proto udp \ + action drop + + do_drop_test "$vlan" "$limit" "$qevent_name" mirror \ + qevent_counter_fetch_mirror + + tc filter del dev $h2 ingress pref 1 handle 101 flower +}
tools/testing/selftests/drivers/net/mlxsw/sch_red_ets.sh +11 -0
@@ -7,6 +7,7 @@ ALL_TESTS=" ecn_nodrop_test red_test mc_backlog_test + red_mirror_test " : ${QDISC:=ets} source sch_red_core.sh
@@ -83,6 +84,16 @@ mc_backlog_test() uninstall_qdisc } +red_mirror_test() +{ + install_qdisc qevent early_drop block 10 + + do_drop_mirror_test 10 $BACKLOG1 early_drop + do_drop_mirror_test 11 $BACKLOG2 early_drop + + uninstall_qdisc +} + trap cleanup EXIT setup_prepare
tools/testing/selftests/drivers/net/mlxsw/sch_red_root.sh +8 -0
@@ -7,6 +7,7 @@ ALL_TESTS=" ecn_nodrop_test red_test mc_backlog_test + red_mirror_test " source sch_red_core.sh
@@ -57,6 +58,13 @@ mc_backlog_test() uninstall_qdisc } +red_mirror_test() +{ + install_qdisc qevent early_drop block 10 + do_drop_mirror_test 10 $BACKLOG + uninstall_qdisc +} + trap cleanup EXIT setup_prepare
Signature · 1 line
2.20.1
David Miller
maintainerFrom: Petr Machata <[email protected]>
Date: Sat, 11 Jul 2020 00:55:02 +0300
Quoted 3 lines
This set offloads the recently introduced qevent infrastructure in TC and allows mlxsw to support mirroring of packets that were dropped due to buffer related reasons (e.g., early drops) during forwarding.
...
Series applied, thanks.