OSDN Git Service

net: dsa: sja1105: add broadcast and per-traffic class policers
authorVladimir Oltean <vladimir.oltean@nxp.com>
Sun, 29 Mar 2020 11:52:02 +0000 (14:52 +0300)
committerDavid S. Miller <davem@davemloft.net>
Mon, 30 Mar 2020 18:44:01 +0000 (11:44 -0700)
commita6af77637adc92aa0725ac14f71ad915c6000609
tree64ff849db1040e8425463ac993dc4b5214339c41
parenta7cc081cabdae395b1d2ae581a6fee61aec72317
net: dsa: sja1105: add broadcast and per-traffic class policers

This patch adds complete support for manipulating the L2 Policing Tables
from this switch. There are 45 table entries, one entry per each port
and traffic class, and one dedicated entry for broadcast traffic for
each ingress port.

Policing entries are shareable, and we use this functionality to support
shared block filters.

We are modeling broadcast policers as simple tc-flower matches on
dst_mac. As for the traffic class policers, the switch only deduces the
traffic class from the VLAN PCP field, so it makes sense to model this
as a tc-flower match on vlan_prio.

How to limit broadcast traffic coming from all front-panel ports to a
cumulated total of 10 Mbit/s:

tc qdisc add dev sw0p0 ingress_block 1 clsact
tc qdisc add dev sw0p1 ingress_block 1 clsact
tc qdisc add dev sw0p2 ingress_block 1 clsact
tc qdisc add dev sw0p3 ingress_block 1 clsact
tc filter add block 1 flower skip_sw dst_mac ff:ff:ff:ff:ff:ff \
action police rate 10mbit burst 64k

How to limit traffic with VLAN PCP 0 (also includes untagged traffic) to
100 Mbit/s on port 0 only:

tc filter add dev sw0p0 ingress protocol 802.1Q flower skip_sw \
vlan_prio 0 action police rate 100mbit burst 64k

The broadcast, VLAN PCP and port policers are compatible with one
another (can be installed at the same time on a port).

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/dsa/sja1105/Makefile
drivers/net/dsa/sja1105/sja1105.h
drivers/net/dsa/sja1105/sja1105_flower.c [new file with mode: 0644]
drivers/net/dsa/sja1105/sja1105_main.c