Skip to content

PTP for DSA tag_ocelot_8021q

Vladimir Oltean netdev 2 versions Applied

Status from this message: This series was applied to netdev/net-next.git (refs/heads/master):

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest12 patches 11 repliesApplied 12/12
  2. v112 patches 5 repliesSuperseded

Changes in v2 from the cover letter

Add stub definition for ocelot_port_inject_frame when switch driver is not compiled in.

Patches in v2 All 12 applied

#Subject and filesSizeRepliesApplied
1/12net: mscc: ocelot: stop returning IRQ_NONE in ocelot_xtr_irq_handlerdrivers/net/ethernet/mscc/ocelot_vsc7514.c+2 -50 repliesApplied
2/12net: mscc: ocelot: only drain extraction queue on errordrivers/net/ethernet/mscc/ocelot_vsc7514.c+1 -11 replyApplied
3/12net: mscc: ocelot: better error handling in ocelot_xtr_irq_handlerdrivers/net/ethernet/mscc/ocelot_vsc7514.c+12 -101 replyApplied
4/12net: mscc: ocelot: use DIV_ROUND_UP helper in ocelot_port_inject_framedrivers/net/ethernet/mscc/ocelot_net.c+1 -11 replyApplied
5/12net: mscc: ocelot: refactor ocelot_port_inject_frame out of ocelot_port_xmitdrivers/net/ethernet/mscc/ocelot.c drivers/net/ethernet/mscc/ocelot_net.c include/soc/mscc/ocelot.h+109 -741 replyApplied
6/12net: dsa: tag_ocelot: avoid accessing ds->priv in ocelot_rcvnet/dsa/tag_ocelot.c+3 -41 replyApplied
7/12net: mscc: ocelot: use common tag parsing code with DSAdrivers/net/dsa/ocelot/felix.c drivers/net/dsa/ocelot/felix_vsc9959.c drivers/net/dsa/ocelot/seville_vsc9953.c +6 more+246 -2271 replyApplied
8/12net: dsa: tag_ocelot: single out PTP-related transmit tag processingnet/dsa/tag_ocelot.c+21 -111 replyApplied
9/12net: dsa: tag_ocelot: create separate tagger for Sevilledrivers/net/dsa/ocelot/felix.c drivers/net/dsa/ocelot/felix.h drivers/net/dsa/ocelot/felix_vsc9959.c +4 more+70 -831 replyApplied
10/12net: mscc: ocelot: refactor ocelot_xtr_irq_handler into ocelot_xtr_polldrivers/net/ethernet/mscc/ocelot.c drivers/net/ethernet/mscc/ocelot_vsc7514.c include/soc/mscc/ocelot.h+163 -1351 replyApplied
11/12net: dsa: felix: setup MMIO filtering rules for PTP when using tag_8021qdrivers/net/dsa/ocelot/felix.c drivers/net/dsa/ocelot/felix.h drivers/net/dsa/ocelot/felix_vsc9959.c +1 more+143 -31 replyApplied
12/12net: dsa: tag_ocelot_8021q: add support for PTP timestampingdrivers/net/dsa/ocelot/felix.c drivers/net/ethernet/mscc/ocelot.c drivers/net/ethernet/mscc/ocelot_vsc7514.c +2 more+115 -21 replyApplied

Reviews trailers per patch

All 12 patches have a Reviewed-by or Acked-by.

PatchFlorian Fainelli
1/12R-b
2/12R-b
3/12R-b
4/12R-b
5/12R-b
6/12R-b
7/12R-b
8/12R-b
9/12R-b
10/12R-b
11/12R-b
12/12R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [PATCH v2 net-next 00/12] PTP for DSA tag_ocelot_8021q

From: Vladimir Oltean <[email protected]>

Changes in v2:
Add stub definition for ocelot_port_inject_frame when switch driver is not compiled in.

This is part two of the errata workaround begun here:
https://patchwork.kernel.org/project/netdevbpf/cover/[email protected]/

Now that we have basic traffic support when we operate the Ocelot DSA switches without an NPI port, it would be nice to regain some of the features lost due to the lack of the NPI port functionality. An important one is PTP timestamping, which is intimately tied to the DSA frame header added by the NPI port: on TX, we put a "timestamp request ID" in the Injection Frame Header, while on RX, the Extraction Frame Header contains a partial 32-bit PTP timestamp. Get rid of the NPI port and replace it with a VLAN-based tagger, and you lose PTP, right?

Well, not quite, this is what this patch series is about. The NPI port is basically a regular Ethernet port configured to service the packets in and out of the switch's CPU port module (which has other non-DSA I/O mechanisms too, such as register-based MMIO and DMA). If we disable the NPI port, we can in theory still access the packets delivered to the CPU port module by doing exactly what the ocelot switchdev driver does:
extracting Ethernet packets through registers (yes, it is as icky as it sounds).

However, there's a catch. The Felix switch was integrated into NXP LS1028A with the idea in mind that it will operate as DSA, i.e. using the CPU port module connected to the NPI port, not having I/O over register-based MMIO which is painfully slow and CPU intensive. So register-based packet I/O not supposed to work - those registers aren't even documented in the hardware reference manual for Felix. However they kinda do, with the exception of the fact that an RX interrupt was really not wired to the CPU cores - so we don't know when the CPU port module receives a new packet. But we can hack even around that, by replicating every packet that goes to the CPU port module and making it also go to a plain internal Ethernet port. Then drop the Ethernet packet and read the other copy of it from the CPU port module, this time annotated with the much-wanted RX timestamp.

This is all fine and it works, but it does raise some questions about what DSA even is anymore, if we start having switches that inject some of their packets over Ethernet and some through registers, where do we draw the line. In principle I believe these concerns are founded, but at the same time, the way that the Felix driver uses register MMIO based packet I/O is fundamentally the same as any other DSA driver capable of PTP makes use of a side-channel for timestamps like a FIFO (just that this one is a lot more complicated, and comes with the entire actual packet, not just the timestamp).

Nonetheless, I tried to keep the extra pressure added by this ERR workaround upon the DSA subsystem as small as possible, so some of the patches are just a revisit of some of Andrew's complaints w.r.t. the fact that tag_ocelot already violates any driver <-> tagger boundary, and as a consequence, is not able to be used on testbeds such as dsa_loop (which it now can). So now, the tag_ocelot and tag_ocelot_8021q drivers should be dsa_loop-clean, and have the ERR workarounds as self-contained as possible, using all the designated features for PTP timestamping and nothing more.

Comments appreciated.

Vladimir Oltean (12):
net: mscc: ocelot: stop returning IRQ_NONE in ocelot_xtr_irq_handler
net: mscc: ocelot: only drain extraction queue on error
net: mscc: ocelot: better error handling in ocelot_xtr_irq_handler
net: mscc: ocelot: use DIV_ROUND_UP helper in ocelot_port_inject_frame
net: mscc: ocelot: refactor ocelot_port_inject_frame out of
ocelot_port_xmit
net: dsa: tag_ocelot: avoid accessing ds->priv in ocelot_rcv
net: mscc: ocelot: use common tag parsing code with DSA
net: dsa: tag_ocelot: single out PTP-related transmit tag processing
net: dsa: tag_ocelot: create separate tagger for Seville
net: mscc: ocelot: refactor ocelot_xtr_irq_handler into
ocelot_xtr_poll
net: dsa: felix: setup MMIO filtering rules for PTP when using

    tag_8021q

net: dsa: tag_ocelot_8021q: add support for PTP timestamping

 drivers/net/dsa/ocelot/felix.c             | 224 +++++++++++++++++--
 drivers/net/dsa/ocelot/felix.h             |  14 +-
 drivers/net/dsa/ocelot/felix_vsc9959.c     |  29 +--
 drivers/net/dsa/ocelot/seville_vsc9953.c   |  30 +--
 drivers/net/ethernet/mscc/ocelot.c         | 216 ++++++++++++++++++
 drivers/net/ethernet/mscc/ocelot.h         |   9 -
 drivers/net/ethernet/mscc/ocelot_net.c     |  81 +------
 drivers/net/ethernet/mscc/ocelot_vsc7514.c | 178 +--------------
 include/linux/dsa/ocelot.h                 | 218 ++++++++++++++++++
 include/net/dsa.h                          |   2 +
 include/soc/mscc/ocelot.h                  |  41 +++-
 net/dsa/tag_ocelot.c                       | 244 +++++++--------------
 net/dsa/tag_ocelot_8021q.c                 |  34 +++
 13 files changed, 825 insertions(+), 495 deletions(-)
 create mode 100644 include/linux/dsa/ocelot.h
Signature · 1 line
2.25.1