[PATCH net-next mlxsw v2 0/8] mlxsw: Support DSCP prioritization and rewrite

Petr Machata petrm at mellanox.com
Wed Jul 25 23:53:07 AEST 2018

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

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

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.
- Patch #8 adds a 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 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
- 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 (8):
  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: 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 | 248 +++++++++++++++++++
 6 files changed, 844 insertions(+), 6 deletions(-)
 create mode 100755 tools/testing/selftests/drivers/net/mlxsw/qos_dscp_bridge.sh


More information about the Linux-mlxsw mailing list