Skip to content

Add support for qca8k mdio rw in Ethernet packet

Ansuel Smith lkml netdev 8 versions – Applied

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

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v8 Latest16 patches 2 repliesApplied 16/16
  2. v7 RFC16 patches 41 repliesSuperseded
  3. v6 RFC16 patches 15 repliesSuperseded
Earlier versions · 5
VersionPostedPatchesRepliesStatus
v5 RFC16 patches0 repliesSuperseded
v4 RFC15 patches10 repliesSuperseded
v3 RFC15 patches0 repliesSuperseded
v2 RFC8 patches8 repliesSuperseded
v1 RFC6 patches33 repliesSuperseded

Changes in v8 from the cover letter

- Reworked to rolling counter for the seq_num
- Reworked the hi/lo cache patch
- Fix multiple missing skb free and mutex lock errors
- Fix some spelling mistake
- Add macro build check for mgmt packet size
- Change some struct naming to make them more descriptive v7:
- Rebase on net-next changes
- Add bulk patches to speedup this even more

Patches in v8 All 16 applied

#Subject and filesSizeRepliesApplied
1/16net: dsa: provide switch operations for tracking the master stateinclude/net/dsa.h net/dsa/dsa2.c net/dsa/dsa_priv.h +2 more+123 -00 repliesApplied
2/16net: dsa: replay master state events in dsa_tree_{setup,teardown}_masternet/dsa/dsa2.c+24 -40 repliesApplied
3/16net: dsa: tag_qca: convert to FIELD macronet/dsa/tag_qca.c+15 -190 repliesApplied
4/16net: dsa: tag_qca: move define to include linux/dsainclude/linux/dsa/tag_qca.h net/dsa/tag_qca.c+22 -150 repliesApplied
5/16net: dsa: tag_qca: enable promisc_on_master flagnet/dsa/tag_qca.c+1 -00 repliesApplied
6/16net: dsa: tag_qca: add define for handling mgmt Ethernet packetinclude/linux/dsa/tag_qca.h net/dsa/tag_qca.c+56 -30 repliesApplied
7/16net: dsa: tag_qca: add define for handling MIB packetinclude/linux/dsa/tag_qca.h net/dsa/tag_qca.c+14 -01 replyApplied
8/16net: dsa: tag_qca: add support for handling mgmt and MIB Ethernet packetinclude/linux/dsa/tag_qca.h net/dsa/tag_qca.c+43 -30 repliesApplied
9/16net: dsa: qca8k: add tracking state of master portdrivers/net/dsa/qca8k.c drivers/net/dsa/qca8k.h+16 -00 repliesApplied
10/16net: dsa: qca8k: add support for mgmt read/write in Ethernet packetdrivers/net/dsa/qca8k.c drivers/net/dsa/qca8k.h+238 -00 repliesApplied
11/16net: dsa: qca8k: add support for mib autocast in Ethernet packetdrivers/net/dsa/qca8k.c drivers/net/dsa/qca8k.h+121 -20 repliesApplied
12/16net: dsa: qca8k: add support for phy read/write with mgmt Ethernetdrivers/net/dsa/qca8k.c drivers/net/dsa/qca8k.h+217 -00 repliesApplied
13/16net: dsa: qca8k: move page cache to driver privdrivers/net/dsa/qca8k.c drivers/net/dsa/qca8k.h+29 -221 replyApplied
14/16net: dsa: qca8k: cache lo and hi for mdio writedrivers/net/dsa/qca8k.c drivers/net/dsa/qca8k.h+54 -120 repliesApplied
15/16net: dsa: qca8k: add support for larger read/write size with mgmt Ethernetdrivers/net/dsa/qca8k.c+41 -200 repliesApplied
16/16net: dsa: qca8k: introduce qca8k_bulk_read/write functiondrivers/net/dsa/qca8k.c+43 -120 repliesApplied

Reviews trailers per patch

11 of 16 patches have a Reviewed-by or Acked-by.

PatchFlorian FainelliVladimir Oltean
1/16R-b
2/16R-b
3/16R-b R-b
4/16R-b R-b
5/16R-b R-b
6/16R-b
7/16R-b
8/16R-b R-b
9/16R-b
10/16
11/16
12/16
13/16R-b
14/16R-b
15/16
16/16

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

Read the v8 thread

Cover letter [net-next PATCH v8 00/16] Add support for qca8k mdio rw in Ethernet packet

Hi, this is ready but require some additional test on a wider userbase.

The main reason for this is that we notice some routing problem in the switch and it seems assisted learning is needed. Considering mdio is quite slow due to the indirect write using this Ethernet alternative way seems to be quicker.

The qca8k switch supports a special way to pass mdio read/write request using specially crafted Ethernet packet.
This works by putting some defined data in the Ethernet header where the mac source and dst should be placed. The Ethernet type header is set to qca header and is set to a mdio read/write type.
This is used to communicate to the switch that this is a special packet and should be parsed differently.

Currently we use Ethernet packet for
- MIB counter
- mdio read/write configuration
- phy read/write for each port

Current implementation of this use completion API to wait for the packet to be processed by the tagger and has a timeout that fallback to the legacy mdio way and mutex to enforce one transaction at time.

We now have connect()/disconnect() ops for the tagger. They are used to allocate priv data in the dsa priv. The header still has to be put in global include to make it usable by a dsa driver.
They are called when the tag is connect to the dst and the data is freed using discconect on tagger change.

(if someone wonder why the bind function is put at in the general setup function it's because tag is set in the cpu port where the notifier is still not available and we require the notifier to sen the tag_proto_connect() event.

We now have a tag_proto_connect() for the dsa driver used to put additional data in the tagger priv (that is actually the dsa priv). This is called using a switch event DSA_NOTIFIER_TAG_PROTO_CONNECT. Current use for this is adding handler for the Ethernet packet to keep the tagger code as dumb as possible.

The tagger priv implement only the handler for the special packet. All the other stuff is placed in the qca8k_priv and the tagger has to access it under lock.

We use the new API from Vladimir to track if the master port is operational or not. We had to track many thing to reach a usable state. Checking if the port is UP is not enough and tracking a NETDEV_CHANGE is also not enough since it use also for other task. The correct way was both track for interface UP and if a qdisc was assigned to the interface. That tells us the port (and the tagger indirectly) is ready to accept and process packet.

I tested this with multicpu port and with port6 set as the unique port and it's sad.
It seems they implemented this feature in a bad way and this is only supported with cpu port0. When cpu port6 is the unique port, the switch doesn't send ack packet. With multicpu port, packet ack are not duplicated and only cpu port0 sends them. This is the same for the MIB counter. For this reason this feature is enabled only when cpu port0 is enabled and operational.

v8:
- Reworked to rolling counter for the seq_num
- Reworked the hi/lo cache patch
- Fix multiple missing skb free and mutex lock errors
- Fix some spelling mistake
- Add macro build check for mgmt packet size
- Change some struct naming to make them more descriptive v7:
- Rebase on net-next changes
- Add bulk patches to speedup this even more
v6:
- Fix some error in ethtool handler caused by rebase/cleanup v5:
- Adapt to new API fixes
- Fix a wrong logic for noop
- Add additional lock for master_state change
- Limit mdio Ethernet to cpu port0 (switch limitation)
- Add priority to these special packet
- Move mdio cache to qca8k_priv
v4:
- Remove duplicate patch sent by mistake.
v3:
- Include MIB with Ethernet packet.
- Include phy read/write with Ethernet packet.
- Reorganize code with new API.
- Introuce master tracking by Vladimir
v2:
- Address all suggestion from Vladimir.
Try to generilize this with connect/disconnect function from the tagger and tag_proto_connect for the driver.

Ansuel Smith (14):
net: dsa: tag_qca: convert to FIELD macro
net: dsa: tag_qca: move define to include linux/dsa
net: dsa: tag_qca: enable promisc_on_master flag
net: dsa: tag_qca: add define for handling mgmt Ethernet packet
net: dsa: tag_qca: add define for handling MIB packet
net: dsa: tag_qca: add support for handling mgmt and MIB Ethernet
packet
net: dsa: qca8k: add tracking state of master port
net: dsa: qca8k: add support for mgmt read/write in Ethernet packet
net: dsa: qca8k: add support for mib autocast in Ethernet packet
net: dsa: qca8k: add support for phy read/write with mgmt Ethernet
net: dsa: qca8k: move page cache to driver priv
net: dsa: qca8k: cache lo and hi for mdio write
net: dsa: qca8k: add support for larger read/write size with mgmt
Ethernet
net: dsa: qca8k: introduce qca8k_bulk_read/write function

Vladimir Oltean (2):
net: dsa: provide switch operations for tracking the master state
net: dsa: replay master state events in
dsa_tree_{setup,teardown}_master

 drivers/net/dsa/qca8k.c     | 741 +++++++++++++++++++++++++++++++++---
 drivers/net/dsa/qca8k.h     |  46 ++-
 include/linux/dsa/tag_qca.h |  82 ++++
 include/net/dsa.h           |  17 +
 net/dsa/dsa2.c              |  74 +++-
 net/dsa/dsa_priv.h          |  13 +
 net/dsa/slave.c             |  32 ++
 net/dsa/switch.c            |  15 +
 net/dsa/tag_qca.c           |  85 +++--
 9 files changed, 1025 insertions(+), 80 deletions(-)
 create mode 100644 include/linux/dsa/tag_qca.h
Signature · 1 line
2.33.1