mbox series

[net-next,mlxsw,v3,00/10] mlxsw: Support DSCP prioritization and rewrite

Message ID cover.1532716714.git.petrm@mellanox.com (mailing list archive)
Headers show
Series mlxsw: Support DSCP prioritization and rewrite | expand

Message

Petr Machata July 27, 2018, 7:09 p.m. UTC
**Note:** The SPDX patch landed in combined queue since v2. I don't want
  to rebase this v3 on top of that, because that would cause useless
  back-and-forth as we update each other's patches to apply cleanly. The
  changes in this version v3 are however only in tests and thus won't
  conflict. So when applying this, just unroll the v2, apply v3, and
  reapply whatever was on top that, there won't be any conflicts.

On ingress, a network device such as a switch assigns to packets
priority based on various criteria. Common options include interpreting
PCP and DSCP fields according to user configuration. When a packet
egresses the switch, a reverse process may rewrite PCP and/or DSCP
headers according to packet priority.

So far, mlxsw has supported prioritization based on PCP (802.1p priority
tag). This patch set introduces support for prioritization based on
DSCP, and DSCP rewrite.

To configure the DSCP-to-priority maps, the user is expected to invoke
ieee_setapp and ieee_delapp DCBNL ops, e.g. by using lldptool:

# lldptool -T -i sw1p6 -V APP app=3,5,24 # (priority 3, DSCP, 24)

To decide whether or not to pay attention to DSCP values, the Spectrum
switch recognize a per-port configuration of trust level. Until the
first APP rule is added for a given port, this port's trust level stays
at PCP, meaning that PCP is used for packet prioritization. With the
first DSCP APP rule, the port is configured to trust DSCP instead, and
it stays there until all DSCP APP rules are removed again.

Besides the DSCP (value 5) selector, another selector that plays into
packet prioritization is Ethernet type (value 1) with PID of 0. Such APP
entries denote default priority[1]:

# lldptool -T -i sw1p6 -V APP app=3,1,0 # (default priority 3)

With this patch set, mlxsw uses these values to configure priority for
DSCP values not explicitly specified in DSCP APP map. In the future we
expect to also use this to configure default port priority for untagged
packets.

Access to DSCP-to-priority map, priority-to-DSCP map, and default
priority for a port is exposed through three new DCB helpers. Like the
already-existing dcb_ieee_getapp_mask() helper, these helpers operate in
terms of bitmaps, to support the arbitrary M:N mapping that the APP
rules allow. Such interface presents all the relevant information from
the APP database without necessitating exposition of iterators, locking
or other complex primitives. It is up to the driver to then digest the
mapping in a way that the device supports. In this patch set, mlxsw
resolves conflicts by favoring higher-numbered DSCP values and
priorities.

In this patchset:

- Patch #1 fixes a bug in DCB APP database management.
- Patch #2 adds the getters described above.
- Patches #3-#6 add Spectrum configuration registers.
- Patch #7 adds the mlxsw logic that configures the device according to
  APP rules.
- Patches #8-#10 add a library support and self-test. The test is added
  to the subdirectory drivers/net/mlxsw. Even though it's not
  particularly specific to mlxsw, it's not suitable for running on soft
  devices (which don't support the ieee_getapp et.al.), and thus isn't a
  good fit for the general net/forwarding directory.

[1] 802.1Q-2014, Table D-9

Changes from v2 to v3:
- Split patch #8 into patches #8-#10.
- In patch #10, fix two bugs: when indexing in bash associative array,
  the subscript is interpreted as string, not as a variable name to be
  expanded. And the key stored to t0s and t1s is not DSCP value, but
  key+base. Any one of these bugs would be noticed, but in combination
  they conspired to make the test just work, except it didn't really
  test anything.
- Add lldpad_wait_del even though it just sleeps. It will serve as a
  placeholder for the explanatory comment (which tweak to make it more
  understandable) and as a source code marker in case we'll come up with
  a better way to handle this.
- Support DSCP of 0 for dscp_capture_install et.al.

Changes from v1 to v2:
- In patches #2 and #7, use IEEE_8021QAZ_MAX_TCS instead of literal 8.
- In patch #2, check values of ifindex, selector, protocol, priority
  consistently in all helpers, and in this order.
- In patch #6, update commit message to describe when the rewrite is
  done.
- In patch #7, in mlxsw_sp_port_dcb_app_update():
  - Don't unnecessarily initialize have_dscp
  - Rewrite if(have_dscp){Y} if(!have_dscp){Z}
    to if(have_dscp){return Y} Z
- In patch #8:
  - Fix asymmetry between h1_create and h1_destroy, likewise for h2
  - Don't tolerate a couple stray extra packets.
  - Rename to qos_dscp_bridge.sh to recognize that this is the
    likely less common scenario that doesn't involve router.

Petr Machata (10):
  net: dcb: For wild-card lookups, use priority -1, not 0
  net: dcb: Add priority-to-DSCP map getters
  mlxsw: reg: Add QoS Port DSCP to Priority Mapping Register
  mlxsw: reg: Add QoS Priority Trust State Register
  mlxsw: reg: Add QoS ReWrite Enable Register
  mlxsw: reg: Add QoS Priority to DSCP Mapping Register
  mlxsw: spectrum: Support ieee_setapp, ieee_delapp
  selftests: forwarding: lib: Add DSCP capture
  selftests: forwarding: lib: Add lldpad waiting functions
  selftests: mlxsw: Add test for trust-DSCP

 drivers/net/ethernet/mellanox/mlxsw/reg.h          | 219 +++++++++++++++++
 drivers/net/ethernet/mellanox/mlxsw/spectrum.h     |   4 +-
 drivers/net/ethernet/mellanox/mlxsw/spectrum_dcb.c | 269 ++++++++++++++++++++-
 include/net/dcbnl.h                                |  13 +
 net/dcb/dcbnl.c                                    |  97 +++++++-
 .../selftests/drivers/net/mlxsw/qos_dscp_bridge.sh | 189 +++++++++++++++
 tools/testing/selftests/net/forwarding/lib.sh      |  63 +++++
 7 files changed, 848 insertions(+), 6 deletions(-)
 create mode 100755 tools/testing/selftests/drivers/net/mlxsw/qos_dscp_bridge.sh