2021-08-18 06:12:14

by Xiaoliang Yang

[permalink] [raw]
Subject: [RFC v2 net-next 0/8] net: dsa: felix: psfp support on vsc9959

VSC9959 hardware supports Per-Stream Filtering and Policing(PSFP).
This patch series add PSFP support on tc flower offload of ocelot
driver. Use chain 30000 to distinguish PSFP from VCAP blocks. Add gate
and police set to support PSFP in VSC9959 driver.

v1->v2 changes:
- Use tc flower offload of ocelot driver to support PSFP add and delete.
- Add PSFP tables add/del functions in felix_vsc9959.c.
- Use list_for_each_entry to simplify the code.
- Fix PSFP tables add/del issue.

Vladimir Oltean (1):
net: mscc: ocelot: add MAC table write and lookup operations

Xiaoliang Yang (7):
net: mscc: ocelot: export MAC table lookup and write
net: mscc: ocelot: set vcap IS2 chain to goto PSFP chain
net: mscc: ocelot: add gate and police action offload to PSFP
net: dsa: felix: support psfp filter on vsc9959
net: dsa: felix: add stream gate settings for psfp
net: mscc: ocelot: use index to set vcap policer
net: dsa: felix: use vcap policer to set flow meter for psfp

drivers/net/dsa/ocelot/felix.c | 2 +
drivers/net/dsa/ocelot/felix.h | 10 +
drivers/net/dsa/ocelot/felix_vsc9959.c | 692 ++++++++++++++++++++-
drivers/net/ethernet/mscc/ocelot.c | 53 +-
drivers/net/ethernet/mscc/ocelot.h | 13 -
drivers/net/ethernet/mscc/ocelot_flower.c | 74 ++-
drivers/net/ethernet/mscc/ocelot_vcap.c | 103 +--
drivers/net/ethernet/mscc/ocelot_vsc7514.c | 7 +
include/soc/mscc/ocelot.h | 39 +-
include/soc/mscc/ocelot_ana.h | 10 +
include/soc/mscc/ocelot_vcap.h | 1 +
11 files changed, 932 insertions(+), 72 deletions(-)

--
2.17.1


2021-08-18 06:12:50

by Xiaoliang Yang

[permalink] [raw]
Subject: [RFC v2 net-next 8/8] net: dsa: felix: use vcap policer to set flow meter for psfp

This patch add police action to set flow meter table which is defined
in IEEE802.1Qci. Flow metering is two rates two buckets and three color
marker to policing the frames, we only enable one rate one bucket in
this patch.

Flow metering shares a same policer pool with VCAP policers, so the PSFP
policer calls ocelot_vcap_policer_add() and ocelot_vcap_policer_del() to
set flow meter police.

Signed-off-by: Xiaoliang Yang <[email protected]>
---
drivers/net/dsa/ocelot/felix_vsc9959.c | 32 +++++++++++++++++++++++++-
1 file changed, 31 insertions(+), 1 deletion(-)

diff --git a/drivers/net/dsa/ocelot/felix_vsc9959.c b/drivers/net/dsa/ocelot/felix_vsc9959.c
index 08e2b5633aa5..3e8347f71e2e 100644
--- a/drivers/net/dsa/ocelot/felix_vsc9959.c
+++ b/drivers/net/dsa/ocelot/felix_vsc9959.c
@@ -1343,6 +1343,7 @@ static int vsc9959_port_setup_tc(struct dsa_switch *ds, int port,

#define VSC9959_PSFP_SFID_MAX 175
#define VSC9959_PSFP_GATE_ID_MAX 183
+#define VSC9959_PSFP_POLICER_BASE 63
#define VSC9959_PSFP_POLICER_MAX 383
#define VSC9959_PSFP_GATE_LIST_NUM 4
#define VSC9959_PSFP_GATE_CYCLETIME_MIN 5000
@@ -1845,7 +1846,10 @@ static int vsc9959_psfp_filter_add(struct ocelot *ocelot,
struct felix_stream stream = {0};
struct felix_stream_gate *sgi;
struct felix_psfp_list *psfp;
+ struct ocelot_policer pol;
int ret, i, size;
+ u64 rate, burst;
+ u32 index;

psfp = felix->info->psfp;

@@ -1864,13 +1868,33 @@ static int vsc9959_psfp_filter_add(struct ocelot *ocelot,
ret = vsc9959_psfp_sgi_table_add(ocelot, sgi);
if (ret) {
kfree(sgi);
- return ret;
+ goto err;
}
sfi.sg_valid = 1;
sfi.sgid = sgi->index;
kfree(sgi);
break;
case FLOW_ACTION_POLICE:
+ index = a->police.index + VSC9959_PSFP_POLICER_BASE;
+ if (index > VSC9959_PSFP_POLICER_MAX) {
+ ret = -EINVAL;
+ goto err;
+ }
+
+ rate = a->police.rate_bytes_ps;
+ burst = rate * PSCHED_NS2TICKS(a->police.burst);
+ pol = (struct ocelot_policer) {
+ .burst = div_u64(burst, PSCHED_TICKS_PER_SEC),
+ .rate = div_u64(rate, 1000) * 8,
+ };
+ ret = ocelot_vcap_policer_add(ocelot, index, &pol);
+ if (ret)
+ goto err;
+
+ sfi.fm_valid = 1;
+ sfi.fmid = index;
+ sfi.maxsdu = a->police.mtu;
+ break;
default:
return -EOPNOTSUPP;
}
@@ -1907,6 +1931,9 @@ static int vsc9959_psfp_filter_add(struct ocelot *ocelot,
if (sfi.sg_valid)
vsc9959_psfp_sgi_table_del(ocelot, sfi.sgid);

+ if (sfi.fm_valid)
+ ocelot_vcap_policer_del(ocelot, sfi.fmid);
+
return ret;
}

@@ -1931,6 +1958,9 @@ static int vsc9959_psfp_filter_del(struct ocelot *ocelot,
if (sfi->sg_valid)
vsc9959_psfp_sgi_table_del(ocelot, sfi->sgid);

+ if (sfi->fm_valid)
+ ocelot_vcap_policer_del(ocelot, sfi->fmid);
+
vsc9959_psfp_sfi_table_del(ocelot, stream->sfid);

stream->sfid_valid = 0;
--
2.17.1