[v4,net-next,00/12] ethtool support for IEEE 802.3 MAC Merge layer

Message ID 20230119122705.73054-1-vladimir.oltean@nxp.com
Headers
Series ethtool support for IEEE 802.3 MAC Merge layer |

Message

Vladimir Oltean Jan. 19, 2023, 12:26 p.m. UTC
  Change log
----------

v3->v4:
- add missing opening bracket in ocelot_port_mm_irq()
- moved cfg.verify_time range checking so that it actually takes place
  for the updated rather than old value
v3 at:
https://patchwork.kernel.org/project/netdevbpf/cover/20230117085947.2176464-1-vladimir.oltean@nxp.com/

v2->v3:
- made get_mm return int instead of void
- deleted ETHTOOL_A_MM_SUPPORTED
- renamed ETHTOOL_A_MM_ADD_FRAG_SIZE to ETHTOOL_A_MM_TX_MIN_FRAG_SIZE
- introduced ETHTOOL_A_MM_RX_MIN_FRAG_SIZE
- cleaned up documentation
- rebased on top of PLCA changes
- renamed ETHTOOL_STATS_SRC_* to ETHTOOL_MAC_STATS_SRC_*
v2 at:
https://patchwork.kernel.org/project/netdevbpf/cover/20230111161706.1465242-1-vladimir.oltean@nxp.com/

v1->v2:
I've decided to focus just on the MAC Merge layer for now, which is why
I am able to submit this patch set as non-RFC.
v1 (RFC) at:
https://patchwork.kernel.org/project/netdevbpf/cover/20220816222920.1952936-1-vladimir.oltean@nxp.com/

What is being introduced
------------------------

TL;DR: a MAC Merge layer as defined by IEEE 802.3-2018, clause 99
(interspersing of express traffic). This is controlled through ethtool
netlink (ETHTOOL_MSG_MM_GET, ETHTOOL_MSG_MM_SET). The raw ethtool
commands are posted here:
https://patchwork.kernel.org/project/netdevbpf/cover/20230111153638.1454687-1-vladimir.oltean@nxp.com/

The MAC Merge layer has its own statistics counters
(ethtool --include-statistics --show-mm swp0) as well as two member
MACs, the statistics of which can be queried individually, through a new
ethtool netlink attribute, corresponding to:

$ ethtool -I --show-pause eno2 --src aggregate
$ ethtool -S eno2 --groups eth-mac eth-phy eth-ctrl rmon -- --src pmac

The core properties of the MAC Merge layer are described in great detail
in patches 02/12 and 03/12. They can be viewed in "make htmldocs" format.

Devices for which the API is supported
--------------------------------------

I decided to start with the Ethernet switch on NXP LS1028A (Felix)
because of the smaller patch set. I also have support for the ENETC
controller pending.

I would like to get confirmation that the UAPI being proposed here will
not restrict any use cases known by other hardware vendors.

Why is support for preemptible traffic classes not here?
--------------------------------------------------------

There is legitimate concern whether the 802.1Q portion of the standard
(which traffic classes go to the eMAC and which to the pMAC) should be
modeled in Linux using tc or using another UAPI. I think that is
stalling the entire series, but should be discussed separately instead.
Removing FP adminStatus support makes me confident enough to submit this
patch set without an RFC tag (meaning: I wouldn't mind if it was merged
as is).

What is submitted here is sufficient for an LLDP daemon to do its job.
I've patched openlldp to advertise and configure frame preemption:
https://github.com/vladimiroltean/openlldp/tree/frame-preemption-v3

In case someone wants to try it out, here are some commands I've used.

 # Configure the interfaces to receive and transmit LLDP Data Units
 lldptool -L -i eno0 adminStatus=rxtx
 lldptool -L -i swp0 adminStatus=rxtx
 # Enable the transmission of certain TLVs on switch's interface
 lldptool -T -i eno0 -V addEthCap enableTx=yes
 lldptool -T -i swp0 -V addEthCap enableTx=yes
 # Query LLDP statistics on switch's interface
 lldptool -S -i swp0
 # Query the received neighbor TLVs
 lldptool -i swp0 -t -n -V addEthCap
 Additional Ethernet Capabilities TLV
         Preemption capability supported
         Preemption capability enabled
         Preemption capability active
         Additional fragment size: 60 octets

So using this patch set, lldpad will be able to advertise and configure
frame preemption, but still, no data packet will be sent as preemptible
over the link, because there is no UAPI to control which traffic classes
are sent as preemptible and which as express.

Preemptable or preemptible?
---------------------------

IEEE 802.3 uses "preemptable" throughout. IEEE 802.1Q uses "preemptible"
throughout. Because the definition of "preemptible" falls under 802.1Q's
jurisdiction and 802.3 just references it, I went with the 802.1Q naming
even where supporting an 802.3 feature. Also, checkpatch agrees with this.

Vladimir Oltean (12):
  net: ethtool: netlink: introduce ethnl_update_bool()
  net: ethtool: add support for MAC Merge layer
  docs: ethtool-netlink: document interface for MAC Merge layer
  net: ethtool: netlink: retrieve stats from multiple sources (eMAC,
    pMAC)
  docs: ethtool: document ETHTOOL_A_STATS_SRC and
    ETHTOOL_A_PAUSE_STATS_SRC
  net: ethtool: add helpers for aggregate statistics
  net: ethtool: add helpers for MM fragment size translation
  net: dsa: add plumbing for changing and getting MAC merge layer state
  net: mscc: ocelot: allow ocelot_stat_layout elements with no name
  net: mscc: ocelot: hide access to ocelot_stats_layout behind a helper
  net: mscc: ocelot: export ethtool MAC Merge stats for Felix VSC9959
  net: mscc: ocelot: add MAC Merge layer support for VSC9959

 Documentation/networking/ethtool-netlink.rst | 107 ++++++
 Documentation/networking/statistics.rst      |   1 +
 drivers/net/dsa/ocelot/felix.c               |  28 ++
 drivers/net/dsa/ocelot/felix_vsc9959.c       |  57 +++-
 drivers/net/ethernet/mscc/Makefile           |   1 +
 drivers/net/ethernet/mscc/ocelot.c           |  18 +-
 drivers/net/ethernet/mscc/ocelot.h           |   2 +
 drivers/net/ethernet/mscc/ocelot_mm.c        | 214 ++++++++++++
 drivers/net/ethernet/mscc/ocelot_stats.c     | 331 +++++++++++++++++--
 include/linux/ethtool.h                      | 248 +++++++++++---
 include/net/dsa.h                            |  11 +
 include/soc/mscc/ocelot.h                    |  58 ++++
 include/soc/mscc/ocelot_dev.h                |  23 ++
 include/uapi/linux/ethtool.h                 |  43 +++
 include/uapi/linux/ethtool_netlink.h         |  50 +++
 net/dsa/slave.c                              |  37 +++
 net/ethtool/Makefile                         |   4 +-
 net/ethtool/common.h                         |   2 +
 net/ethtool/mm.c                             | 271 +++++++++++++++
 net/ethtool/netlink.c                        |  19 ++
 net/ethtool/netlink.h                        |  34 +-
 net/ethtool/pause.c                          |  48 +++
 net/ethtool/stats.c                          | 159 ++++++++-
 23 files changed, 1688 insertions(+), 78 deletions(-)
 create mode 100644 drivers/net/ethernet/mscc/ocelot_mm.c
 create mode 100644 net/ethtool/mm.c
  

Comments

Jakub Kicinski Jan. 21, 2023, 5:53 a.m. UTC | #1
On Thu, 19 Jan 2023 14:26:52 +0200 Vladimir Oltean wrote:
> TL;DR: a MAC Merge layer as defined by IEEE 802.3-2018, clause 99
> (interspersing of express traffic). This is controlled through ethtool
> netlink (ETHTOOL_MSG_MM_GET, ETHTOOL_MSG_MM_SET). The raw ethtool
> commands are posted here:

ethtool stuff LGTM FWIW.
  
patchwork-bot+netdevbpf@kernel.org Jan. 23, 2023, 11:20 a.m. UTC | #2
Hello:

This series was applied to netdev/net.git (master)
by David S. Miller <davem@davemloft.net>:

On Thu, 19 Jan 2023 14:26:52 +0200 you wrote:
> Change log
> ----------
> 
> v3->v4:
> - add missing opening bracket in ocelot_port_mm_irq()
> - moved cfg.verify_time range checking so that it actually takes place
>   for the updated rather than old value
> v3 at:
> https://patchwork.kernel.org/project/netdevbpf/cover/20230117085947.2176464-1-vladimir.oltean@nxp.com/
> 
> [...]

Here is the summary with links:
  - [v4,net-next,01/12] net: ethtool: netlink: introduce ethnl_update_bool()
    https://git.kernel.org/netdev/net/c/7c494a7749a7
  - [v4,net-next,02/12] net: ethtool: add support for MAC Merge layer
    (no matching commit)
  - [v4,net-next,03/12] docs: ethtool-netlink: document interface for MAC Merge layer
    (no matching commit)
  - [v4,net-next,04/12] net: ethtool: netlink: retrieve stats from multiple sources (eMAC, pMAC)
    (no matching commit)
  - [v4,net-next,05/12] docs: ethtool: document ETHTOOL_A_STATS_SRC and ETHTOOL_A_PAUSE_STATS_SRC
    (no matching commit)
  - [v4,net-next,06/12] net: ethtool: add helpers for aggregate statistics
    (no matching commit)
  - [v4,net-next,07/12] net: ethtool: add helpers for MM fragment size translation
    (no matching commit)
  - [v4,net-next,08/12] net: dsa: add plumbing for changing and getting MAC merge layer state
    (no matching commit)
  - [v4,net-next,09/12] net: mscc: ocelot: allow ocelot_stat_layout elements with no name
    (no matching commit)
  - [v4,net-next,10/12] net: mscc: ocelot: hide access to ocelot_stats_layout behind a helper
    (no matching commit)
  - [v4,net-next,11/12] net: mscc: ocelot: export ethtool MAC Merge stats for Felix VSC9959
    (no matching commit)
  - [v4,net-next,12/12] net: mscc: ocelot: add MAC Merge layer support for VSC9959
    (no matching commit)

You are awesome, thank you!
  
patchwork-bot+netdevbpf@kernel.org Jan. 23, 2023, 1 p.m. UTC | #3
Hello:

This series was applied to netdev/net-next.git (master)
by David S. Miller <davem@davemloft.net>:

On Thu, 19 Jan 2023 14:26:52 +0200 you wrote:
> Change log
> ----------
> 
> v3->v4:
> - add missing opening bracket in ocelot_port_mm_irq()
> - moved cfg.verify_time range checking so that it actually takes place
>   for the updated rather than old value
> v3 at:
> https://patchwork.kernel.org/project/netdevbpf/cover/20230117085947.2176464-1-vladimir.oltean@nxp.com/
> 
> [...]

Here is the summary with links:
  - [v4,net-next,01/12] net: ethtool: netlink: introduce ethnl_update_bool()
    (no matching commit)
  - [v4,net-next,02/12] net: ethtool: add support for MAC Merge layer
    https://git.kernel.org/netdev/net-next/c/2b30f8291a30
  - [v4,net-next,03/12] docs: ethtool-netlink: document interface for MAC Merge layer
    https://git.kernel.org/netdev/net-next/c/3700000479f0
  - [v4,net-next,04/12] net: ethtool: netlink: retrieve stats from multiple sources (eMAC, pMAC)
    https://git.kernel.org/netdev/net-next/c/04692c9020b7
  - [v4,net-next,05/12] docs: ethtool: document ETHTOOL_A_STATS_SRC and ETHTOOL_A_PAUSE_STATS_SRC
    https://git.kernel.org/netdev/net-next/c/c319df10a4c8
  - [v4,net-next,06/12] net: ethtool: add helpers for aggregate statistics
    https://git.kernel.org/netdev/net-next/c/449c5459641a
  - [v4,net-next,07/12] net: ethtool: add helpers for MM fragment size translation
    https://git.kernel.org/netdev/net-next/c/dd1c41645039
  - [v4,net-next,08/12] net: dsa: add plumbing for changing and getting MAC merge layer state
    https://git.kernel.org/netdev/net-next/c/5f6c2d498ad9
  - [v4,net-next,09/12] net: mscc: ocelot: allow ocelot_stat_layout elements with no name
    https://git.kernel.org/netdev/net-next/c/1a733bbddfad
  - [v4,net-next,10/12] net: mscc: ocelot: hide access to ocelot_stats_layout behind a helper
    https://git.kernel.org/netdev/net-next/c/497eea9f8ed5
  - [v4,net-next,11/12] net: mscc: ocelot: export ethtool MAC Merge stats for Felix VSC9959
    https://git.kernel.org/netdev/net-next/c/ab3f97a9610a
  - [v4,net-next,12/12] net: mscc: ocelot: add MAC Merge layer support for VSC9959
    https://git.kernel.org/netdev/net-next/c/6505b6805655

You are awesome, thank you!
  
Vladimir Oltean Jan. 25, 2023, 11:30 p.m. UTC | #4
On Thu, Jan 19, 2023 at 02:26:52PM +0200, Vladimir Oltean wrote:
> What is submitted here is sufficient for an LLDP daemon to do its job.
> I've patched openlldp to advertise and configure frame preemption:
> https://github.com/vladimiroltean/openlldp/tree/frame-preemption-v3
> 
> In case someone wants to try it out, here are some commands I've used.

Just a heads up, I've sent a patch set for ethtool user space:
https://patchwork.kernel.org/project/netdevbpf/cover/20230124142056.3778131-1-vladimir.oltean@nxp.com/
and a pull request for openlldp:
https://github.com/intel/openlldp/pull/91

Waiting for these to get merged before I submit selftests for the kernel.
Those who would like things to progress faster can help with some review
there.