Add Xilinx TSN Endpoint Ethernet MAC driver
Subsystems (5)
v4 cover Add Xilinx TSN Endpoint Ethernet MAC driver
Introduce a new network driver for the AMD LogiCORE 100M/1G TSN Subsystem IP, also known as the TSN Endpoint Ethernet MAC IP, which implements IEEE 802.1 Time-Sensitive Networking (TSN) features for deterministic and low-latency Ethernet communication in real-time and industrial automation use cases.
The v1 posting sent all 20 patches (wrapper, endpoint and the DSA switch) as one series. Following the review feedback to split it, this series sends only the wrapper and endpoint side (patches 1-8). The DSA switch driver, tag protocol, MDIO, phylink, PTP and bridge offloads will follow as a separate series once this base lands.
IP Core Overview:
The AMD LogiCORE 100M/1G TSN Subsystem IP solution (named as TSN Endpoint Ethernet MAC IP in the IP catalog) implements IEEE 802.1 Time Sensitive Networking (TSN) Standards and provides a low latency Bridged Endpoint or Endpoint only solutions. The bridged endpoint solution consists of a 3-port switch that connects to an endpoint including Linux software drivers. For Bridged Endpoint (Switch Endpoint), two ports connects to the network and one port connects to an internal Endpoint. It supports the use of GMII/RGMII interfaces connecting to a physical-side interface (PHY) chip with full duplex 100 Mb/s and 1 Gb/s operations.
Features:
- IP Customizable to generate TSN Endpoint or Bridged Endpoint solution
- Supports interface to network software stack
- Designed to comply with the following IEEE standards
- 802.1AS : Precision Time Protocol (PTP) synchronization
- 802.1Qav : Credit-Based Shaper for traffic shaping
- 802.1Qbv : Time-Aware Shaper for scheduled traffic
- 802.1Qbu : Frame Preemption for ultra-low latency
- 802.1CB : Frame Replication and Elimination for redundancy
- 802.1Qcc : Stream Reservation Protocol (SRP)
- IP is customizable to enable various TSN feature-sets
- Supports 2 to 8 priority queues for scheduled, reserved (IEEE 802.1 Qav Credit Based Shaper) and best effort traffic classes
- Provides feature rich Ethernet Switch that caters to various network needs
* 3-port Switch (2-external, 1-internal)
* Programmable cut-through and store-forward operations
* 4-port Switch (2-external, 2-internal) extension through 'Endpoint Extension' and 'Endpoint Packet Switching' features
- Solution validated on ZCU102 & ZC702 AMD Evaluation boards.
Sample hardware architecture diagram for Bridge End Point like below:
+------------------+
| MCDMA |
+---------+--------+
Q0---Q7
|
+------------------------------------------------------------ +
| | TSN sub system(Bridge End Point) |
| | |
| +------+----+ Port 0 +-----------------------+ |
| | EndPoint |<--------->| TSN Switch | |
| | (EP) | +----+-------------+----+ |
| +-----------+ | | |
| | | |
| Port 1 Port 2 |
| | | |
| +-----------+ +-----------+ |
| | MAC-1 | | MAC-2 | |
| | (ETH1) | | (ETH2) | |
| +-----+-----+ +-----+-----+ |
| | | |
| | | |
+-------------------------------------------------------------+
| |
RGMII RGMII
| |
+-----------+ +-----------+
| PHY1 | | PHY2 |
| (Port 0) | | (Port 2) |
+-----------+ +-----------+The endpoint is capable of Qbv scheduling and is connected to hardware that implements time-triggered per-stream scheduling as specified in IEEE 802.1Qcc-2018 Annex U.1.3.
Software Driver Overview:
This series adds the wrapper and endpoint side of the IP. The switch-facing part is exposed through the Distributed Switch Architecture (DSA) framework in a follow-up series, so that MAC1 and MAC2 show up to Linux as switch ports with the endpoint acting as the CPU/conduit port. The endpoint frames are already classified by source-port id and tagged with DSA port metadata here, so the switch series can consume them without further endpoint change.
Since the endpoint must be exposed to users for Qbv and time-triggered per-stream schedule configuration, it requires a user-facing netdev, which also aligns well with the DSA model. In addition, the hardware lacks a destination-port selector and does not provide an independent per-port forwarding mask. As a result, standalone port isolation is achieved using a private VLAN that contains only the selected port and the endpoint. The DSA framework enables reuse of the tag_8021q helpers to manage these VLANs, insert the destination-port VLAN tag (which is stripped by the hardware before egress on the wire), and seamlessly handle transitions between standalone and bridged operation.
Wrapper driver:
- Binds the top-level IP node, acquires and enables the IP-block clocks.
- Spawns the endpoint (and, later, switch) blocks as child platform devices via devm_of_platform_populate() and carries no netdev or register access of its own.
Endpoint driver:
- Implements the conduit net_device that Linux DMA traffic flows through on its way to and from the switch fabric.
- Manages multi-queue TX and RX descriptor rings using the dmaengine framework for high-performance packet transfer.
- Classifies each received frame by the source-port id carried in the RX descriptor sideband metadata and attaches DSA port metadata so the DSA core can demux it to the right user port netdev.
Changes in v4:
- Rebase onto net-next, which now carries the AXI MCDMA dmaengine changes merged for v7.4-rc1. Commit 5b585cc87781 ("dmaengine: xilinx_dma: Move descriptors to done list based on completion bit") keeps RX buffers
owned by the engine until their descriptor completes, and
commit 5f677afc9567 ("dmaengine: xilinx_dma: Extend metadata handling
for AXI DMA and MCDMA") provides the RX sideband metadata the endpoint reads. The series no longer has an external dependency.
- binding: bound the queueN children from above as well as below, so a
device tree with more queues than xlnx,num-priorities is rejected, and
state that each priority queue must use a distinct TX channel. Add the optional xlnx,max-learning-entries switch property.
- Kconfig: drop the reference to the companion DSA driver, which is not
part of this series.
- endpoint MAC: use alloc_etherdev() so the eth%d name is registered with NET_NAME_ENUM.
- endpoint DMA parse: use alloc_etherdev_mqs() for the multi-queue
netdev, and reject xlnx,num-priorities outside the 2..8 range the
binding allows.
- endpoint MCDMA bring-up: describe @dma_address as a DMA address in the kernel-doc.
- endpoint RX: report the ring as armed when the refill submitted at least
one descriptor, so ndo_open no longer fails when a buffer completes
before the ring is tested.
- endpoint TX: call skb_tx_timestamp() before dmaengine_submit(), add .get_ts_info so ethtool reports software TX timestamps, and terminate
the TX channels before netif_tx_disable() in ndo_stop so a completion
cannot wake a queue while the channels are freed. Extend the @closing kernel-doc to the TX completion.
- Link to v3: https://patch.msgid.link/[email protected]
Changes in v3:
- cover letter: explain why the switch-facing part is implemented as DSA,
what the endpoint netdev provides beyond being the conduit, and how RX demultiplexing and TX port selection map onto the hardware.
- binding: rename ports to ethernet-ports and [email protected] to
[email protected], the preferred names for a new binding. Require reg
on the CPU ethernet-port@0 and pin reg to the unit address on the
external ports (literal ethernet-port@1 reg=1 and ethernet-port@2 reg=2 instead of a shared enum). Require queue0 in tx-queues-config, and add contains rules so dma-names must carry at least one tx_chan and one
rx_chan.
- endpoint MAC: register the netdev with the standard eth%d name (NET_NAME_UNKNOWN) instead of a custom "ep%d".
- endpoint DMA parse: state the queueN to TX channel mapping in the commit body rather than only in the changelog. Rename the counting helper to ep_count_dma_channels() and the RX map to rx_dma_chan_map, keep the RX
map in a probe local, and document the TSN_DMA_CH_INVALID sentinel in
the tx_dma_chan_map kernel-doc.
- endpoint MCDMA bring-up: acquire every TX and RX channel at probe and
hold them until remove, so ndo_open only builds the rings and no
deferral can reach userspace. Reset the controller through the first
held channel. Move the closing flag and the circ_buf.h and spinlock.h includes to the RX patch that first uses them, and drop the unused io.h include.
- endpoint RX: check the dmaengine_submit() cookie before advancing
ring_head, and free the buffer if the submit fails. Use scoped_guard() rather than guard() for the rx_lock, per the netdev cleanup.h guidance. Introduce the closing flag here, alongside its first reader.
- endpoint TX: free a DMA-error frame with dev_kfree_skb_any() and a
completed one with dev_consume_skb_any(). Add skb_tx_timestamp() at the hardware handoff. Skip the queue wake while closing, using __netif_txq_completed_wake() with the closing flag.
- endpoint RX to DSA: reword the commit message to describe the metadata
this patch adds, and drop the claim that RX frames already reach the
swpN netdevs.
- Link to v2: https://patch.msgid.link/[email protected]
- This series has a dependency on the MCDMA patches, which are currently
not present in net-next:
https://lore.kernel.org/all/[email protected]
Changes in v2:
- Split the original 20-patch series. This v2 carries only the wrapper and endpoint (patches 1-8). The DSA switch driver, tag protocol and offloads will be posted as a separate follow-up series.
- binding: describe only the Bridged Endpoint configuration, drop reg from the wrapper node (it has none of its own, ranges covers the child windows), rename ep-mac@ to ethernet@ and mdio-mac1/2 to mdio-1/2, cap the DMA channels at 8 (dma-names maxItems 16, tx_chan/rx_chan [0-7], dma-channel-num max 7), use a ports/ethernet-ports container and require port@0, port@1 and port@2, add reg (enum [1, 2]) and require reg, phy-mode and phy-handle on the external ports (gmii/rgmii/rgmii-id), and add minItems on the switch interrupts.
- Kconfig: depend on OF_ADDRESS instead of OF && HAS_IOMEM, point the help text at the companion DSA driver rather than a symbol that does not exist yet, and drop the mod_devicetable.h include (platform_device.h pulls it in).
- endpoint: name the netdev ep%d instead of a fixed "ep", drop the mapped but unused register window, use dev_kfree_skb_any() on the drop path, and drop the mod_devicetable.h include.
- endpoint DMA: check xlnx,dma-channel-num against the channels dma-names lists, require one queue per tx_chan and num-priorities equal to the TX channel count, cap TX/RX at 8, error out on an unknown dma-names entry, and drop the unreachable count guards.
- endpoint MCDMA bring-up: request a channel at probe time so -EPROBE_DEFER stays in the probe path and never reaches ndo_open, and request channels by their real dma-names index instead of a dense 0..N-1 sequence.
- endpoint RX: serialise the refill against teardown under a per-channel lock, recover a drained ring with a refill timer instead of stalling, fail ndo_open if a channel cannot arm any descriptor, take the ring size from the channel, shut the refill timer down with timer_shutdown_sync() at teardown, and return true from the refill helper when it arms a descriptor.
- endpoint TX: take the scatterlist count from skb_to_sgvec(), check dmaengine_submit() before advancing the ring and charging BQL, publish the ring head and tail with WRITE_ONCE(), move tx_lock into the per-channel struct so independent TX queues do not share one lock, use the spinlock_bh guard class in the completion callback, and use dmaengine_prep_slave_sg().
- endpoint RX to DSA: attach the port metadata only when the netdev is a DSA conduit, take a counted dst reference (dst_hold() + skb_dst_set()) so the dst survives the __netif_rx() backlog handoff without skb_dst_force() in softirq, and release it with dst_release() at teardown.
Previous versions:
v1 (full 20-patch series, now split):
https://lore.kernel.org/lkml/[email protected]/
Test information:
- Validated these changes on the net-next branch with the MCDMA metadata patches cherry-picked from linux-next, along with the series listed below
https://lore.kernel.org/all/[email protected]/
- The endpoint RX path depends on AXI MCDMA metadata support in the dmaengine driver. On plain net-next, xilinx_mcdma_prep_slave_sg() does not attach metadata_ops and desc_metadata_modes stays 0 for XDMA_TYPE_AXIMCDMA, so dmaengine_desc_get_metadata_ptr() returns -ENOTSUPP and ep_dma_rx_cb() would drop every received frame. The series therefore depends on the MCDMA metadata support that extends metadata_ops to XDMA_TYPE_AXIMCDMA and returns the descriptor status word (index 0 is status, index 1 is the sideband word carrying TID/TDEST/TUSER, index 2 onward is the app words). That dmaengine work is a prerequisite for RX to function and the TSN patches touch no dmaengine code. It will be posted to the dmaengine tree and this series carries a Depends-on note plus a lore link once it is on-list.
- Performed ping, iperf3 and multi-queue TX/RX tests on the ZynqMP ZCU102 platform, with the endpoint conduit up and both external MACs cabled to peer NICs. Also ran teardown and probe-defer stress under KASAN and lockdep with no use-after-free or locking splats.
---
Nagadheeraj Rottela (1):
net: xilinx: tsn: deliver endpoint RX frames to DSA user ports
Srinivas Neeli (7):
dt-bindings: net: add Xilinx TSN Endpoint Ethernet MAC
net: xilinx: tsn: add TSN endpoint wrapper driver
net: xilinx: tsn: add endpoint MAC driver skeleton
net: xilinx: tsn: parse endpoint DMA channel configuration
net: xilinx: tsn: bring up the endpoint MCDMA channels
net: xilinx: tsn: add the endpoint RX data path
net: xilinx: tsn: add the endpoint TX data path
.../net/xlnx,tsn-endpoint-ethernet-mac.yaml | 536 ++++++++++ MAINTAINERS | 8 + drivers/net/ethernet/xilinx/Kconfig | 1 + drivers/net/ethernet/xilinx/Makefile | 1 + drivers/net/ethernet/xilinx/tsn/Kconfig | 15 + drivers/net/ethernet/xilinx/tsn/Makefile | 2 + drivers/net/ethernet/xilinx/tsn/xilinx_tsn.h | 15 + drivers/net/ethernet/xilinx/tsn/xilinx_tsn_ep.c | 1094 ++++++++++++++++++++ drivers/net/ethernet/xilinx/tsn/xilinx_tsn_main.c | 107 ++ 9 files changed, 1779 insertions(+)
---
base-commit: 6584acd42820478910a771efb28a355a707e9cb0
change-id: 20260831-patches_v2_external-36421e557430
Best regards,
Signature · 1 line
Srinivas Neeli <[email protected]>
PATCH v4 1/8 dt-bindings: net: add Xilinx TSN Endpoint Ethernet MAC
Add a binding for the Xilinx TSN Endpoint Ethernet MAC IP. The top-level node describes the IP wrapper, which owns the six shared IP clocks and the xlnx,num-priorities parameter, and has two children:
- xlnx,tsn-ep-mac: the endpoint MAC, owning the host-side DMA channels (dmas / dma-names / tx-queues-config).
- xlnx,tsn-switch: the three-port Ethernet switch covering the switch fabric and the two per-MAC register windows. The MDIO controllers and PTP register blocks sit at fixed offsets inside the per-MAC windows, accessed through the mdio-1 / mdio-2 children and per-MAC interrupt-names entries. Each external port@N references its PHY through a phy-handle in the matching mdio-<N> child.
---
Changes in v4:
- Bound the queueN children from above as well as below. Each xlnx,num-priorities branch now narrows patternProperties to "^queue[0-N-1]$" and sets additionalProperties: false, so a device tree that describes more queues than the IP has priorities is rejected at dt_binding_check and the offending nodes are named. The driver keeps its own check, since a device tree is not required to have been validated.
- Clarify that each priority queue must use a distinct TX channel listed in dma-names. The driver rejects two queues mapped to the same channel.
- Add the optional xlnx,max-learning-entries switch property for the per-port MAX_LEARNING_ENTRIES IP parameter (256 to 1920, default 1920).
Changes in v3:
- Rename ports to ethernet-ports and [email protected] to [email protected], the preferred names for a new binding.
- Require reg on the CPU ethernet-port@0. dsa_switch_parse_ports_of() reads reg from every port before classifying it, so a DT that omits reg on the CPU port passes dt_binding_check but fails switch registration.
- Pin reg to the unit address on the external ports. Replace the shared
^port@[1-2]$ subschema with literal ethernet-port@1 (reg const 1) and ethernet-port@2 (reg const 2), so the node name and reg value can no longer disagree and each MAC/MDIO binds to the intended port. - Require queue0 in tx-queues-config. An empty node, or one without queue0, is now rejected at dt_binding_check. The logical queue index is dense from 0, so queue0 is always present. The driver validates the full queue set. - Add contains rules to dma-names so a TX-only or RX-only list no longer validates. At least one tx_chan and one rx_chan are required. - Tie the queueN children to xlnx,num-priorities. tx-queues-config now requires queue0 and queue1, which hold for every allowed value, and for each value 3 to 8 the schema requires queue0 through queueN-1. A device tree with fewer queues than the IP has priorities is rejected at dt_binding_check.
Changes in v2:
- Describe only the Bridged Endpoint configuration. The IP has so far been simulated only as a bridged endpoint, so the binding and driver describe that configuration alone. Support for an Endpoint-only design will be added once that IP variant is simulated.
- Rename ep-mac@ to ethernet@ and mdio-mac1/mdio-mac2 to mdio-1/mdio-2, and anchor the node names (^ethernet@[0-9a-f]+$, ^switch@[0-9a-f]+$), per ethernet-controller.yaml and mdio.yaml.
- Cap TX at 8 and RX at 8 channels. The IP exposes 8 priorities, so it drives at most 8 TX and 8 RX MCDMA channels. dma-names lists both directions, so its combined maxItems is 16 (8 TX + 8 RX). V1 allowed up to 16 per direction, which the hardware cannot use.
- Set additionalProperties: false on tx-queues-config and its queue nodes.
- Drop reg from the wrapper node. It has no registers of its own, ranges already describes the child windows.
- Add minItems: 7 to the switch interrupts to match interrupt-names.
- Use a ^(ethernet-)?ports$ container with additionalProperties: false and its own #address-cells/#size-cells, and require either ports or ethernet-ports.
- Require ethernet on the CPU port@0.
- Add reg (enum [1, 2]) on the external port@[1-2] ports and require reg, phy-mode and phy-handle. MAC1 and MAC2 use gmii/rgmii/rgmii-id.
- Require port@0, port@1 and port@2. The IP is a fixed three-port bridged design (port@0 CPU, port@1 MAC1, port@2 MAC2), so a device tree missing any of them cannot describe working hardware.
- Add #address-cells and #size-cells (both const 1) on the wrapper node, which the child ethernet@/switch@ windows need now that reg is dropped, and set unevaluatedProperties: false on the endpoint node.
--- .../net/xlnx,tsn-endpoint-ethernet-mac.yaml | 536 +++++++++++++++++++++ MAINTAINERS | 7 + 2 files changed, 543 insertions(+)
Documentation/devicetree/bindings/net/xlnx,tsn-endpoint-ethernet-mac.yaml new file +536 -0
@@ -0,0 +1,536 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/net/xlnx,tsn-endpoint-ethernet-mac.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Xilinx TSN Endpoint Ethernet MAC + +description: + TSN Endpoint Ethernet MAC IP implements IEEE 802.1 Time-Sensitive + Networking (TSN) standards and provides low-latency network connectivity + in the Bridged Endpoint configuration. The IP integrates a three-port + switch, with two ports connected to the external network and one port + connected to an internal endpoint. It also supports GMII/RGMII interfaces + for connection to an external PHY, enabling full-duplex operation at + 100 Mb/s and 1 Gb/s speeds. + +maintainers: + - Srinivas Neeli <[email protected]> + - Nagadheeraj Rottela <[email protected]> + +properties: + compatible: + const: xlnx,tsn-endpoint-ethernet-mac-3.0 + + clocks: + items: + - description: GTX clock for transmitter logic and RTC + - description: GTX 90-degree phase shifted clock for RGMII + - description: Host RX FIFO clock + - description: Host TX FIFO clock + - description: Reference clock for IDELAY control + - description: AXI-Lite register interface clock + + clock-names: + items: + - const: gtx + - const: gtx90 + - const: host_rxfifo + - const: host_txfifo + - const: ref + - const: s_axi + + ranges: true + + '#address-cells': + const: 1 + + '#size-cells': + const: 1 + + xlnx,num-priorities: + $ref: /schemas/types.yaml#/definitions/uint32 + minimum: 2 + maximum: 8 + description: + Number of traffic classes (priorities) configured in the IP. + This is an IP configuration parameter that determines the number of + priority queues available for QoS scheduling. Traffic classes map to + IEEE 802.1Q priority levels (0-7). + +patternProperties: + "^ethernet@[0-9a-f]+$": + type: object + $ref: /schemas/net/ethernet-controller.yaml# + unevaluatedProperties: false + description: + Endpoint MAC sub-node. Provides the host-side data path through the + DMA channels described by its dmas / dma-names. + properties: + compatible: + const: xlnx,tsn-ep-mac + + reg: + maxItems: 1 + + dmas: + minItems: 2 + maxItems: 16 + + dma-names: + minItems: 2 + maxItems: 16 + items: + pattern: "^(tx|rx)_chan[0-7]$" + allOf: + - contains: + pattern: "^tx_chan[0-7]$" + - contains: + pattern: "^rx_chan[0-7]$" + description: | + Names matching the entries in 'dmas', one per DMA channel and in + the same order. TX channel names use "tx_chan<N>" and RX channel + names use "rx_chan<N>", where N is 0..7. At least one TX and one RX + channel are required. Example: "tx_chan0", "tx_chan1", ..., + "rx_chan0", "rx_chan1", .... + + tx-queues-config: + type: object + additionalProperties: false + description: + TX queue configuration node that maps IP priority queues to + DMA TX channels. The TSN IP supports multiple priority queues for + QoS scheduling. Each priority queue must be described exactly + once and map to a distinct TX channel listed in dma-names. Two + queues must not use the same TX channel. The mapping need not + follow the channel numbering. For example, queue0 with + xlnx,dma-channel-num set to 5 means priority queue 0 uses tx_chan5 + for data transfer. + + patternProperties: + "^queue[0-7]$": + type: object + additionalProperties: false + + description: + Each subnode represents a priority queue. The + xlnx,dma-channel-num property specifies which DMA TX channel + (tx_chan0 to tx_chan7) is connected to this queue for + transmitting packets. + properties: + xlnx,dma-channel-num: + $ref: /schemas/types.yaml#/definitions/uint32 + description: + DMA channel that transmits this priority queue, given as + the N of the tx_chanN entry in dma-names. + minimum: 0 + maximum: 7 + + required: + - xlnx,dma-channel-num + + required: + - queue0 + - queue1 + + required: + - compatible + - reg + - dmas + - dma-names + - tx-queues-config + + "^switch@[0-9a-f]+$": + type: object + $ref: /schemas/net/dsa/dsa.yaml#/$defs/ethernet-ports + description: + Three-port Ethernet switch sub-node. Contains the switch fabric + register window and the two per-MAC register windows. Each per-MAC + window houses an MDIO controller and a PTP register block at fixed + offsets. The IP's per-MAC and PTP-timer interrupts are exposed here. + + properties: + compatible: + const: xlnx,tsn-switch + + reg: + items: + - description: Switch fabric register window + - description: MAC1 register window (includes MDIO and PTP) + - description: MAC2 register window (includes MDIO and PTP) + + reg-names: + items: + - const: switch + - const: mac1 + - const: mac2 + + interrupts: + minItems: 7 + maxItems: 7 + + interrupt-names: + items: + - const: ptp_rx_mac1 + - const: ptp_tx_mac1 + - const: mac_irq_mac1 + - const: ptp_timer + - const: ptp_rx_mac2 + - const: ptp_tx_mac2 + - const: mac_irq_mac2 + + xlnx,max-learning-entries: + $ref: /schemas/types.yaml#/definitions/uint32 + minimum: 256 + maximum: 1920 + default: 1920 + description: + Maximum number of addresses the hardware address learning engine + can learn on each network port (MAC1 and MAC2). This is the + MAX_LEARNING_ENTRIES IP configuration parameter, and no register + reports it. The endpoint port does not take part in hardware + address learning. + + mdio-1: + $ref: /schemas/net/mdio.yaml# + description: + MDIO bus controller for MAC1. Registers reside inside the mac1 + reg-names window. + unevaluatedProperties: false + + mdio-2: + $ref: /schemas/net/mdio.yaml# + description: + MDIO bus controller for MAC2. Registers reside inside the mac2 + reg-names window. + unevaluatedProperties: false + + ethernet-ports: + type: object + additionalProperties: false + + properties: + '#address-cells': + const: 1 + + '#size-cells': + const: 0 + + ethernet-port@0: + type: object + unevaluatedProperties: true + description: + CPU port. Wired internally to the endpoint MAC sibling. + + properties: + reg: + const: 0 + + phy-mode: + const: internal + + required: + - reg + - ethernet + + ethernet-port@1: + type: object + unevaluatedProperties: true + description: + External Ethernet port wired to MAC1, reached through the + mdio-1 bus. + + properties: + reg: + const: 1 + + phy-mode: + enum: + - gmii + - rgmii + - rgmii-id + + required: + - reg + - phy-mode + - phy-handle + + ethernet-port@2: + type: object + unevaluatedProperties: true + description: + External Ethernet port wired to MAC2, reached through the + mdio-2 bus. + + properties: + reg: + const: 2 + + phy-mode: + enum: + - gmii + - rgmii + - rgmii-id + + required: + - reg + - phy-mode + - phy-handle + + required: + - ethernet-port@0 + - ethernet-port@1 + - ethernet-port@2 + + required: + - compatible + - reg + - reg-names + - interrupts + - interrupt-names + - ethernet-ports + + unevaluatedProperties: false + +additionalProperties: false + +required: + - compatible + - clocks + - clock-names + - xlnx,num-priorities + - ranges + - '#address-cells' + - '#size-cells' + +allOf: + - if: + properties: + xlnx,num-priorities: + const: 2 + then: + patternProperties: + "^ethernet@[0-9a-f]+$": + properties: + tx-queues-config: + patternProperties: + "^queue[0-1]$": {} + additionalProperties: false + + - if: + properties: + xlnx,num-priorities: + const: 3 + then: + patternProperties: + "^ethernet@[0-9a-f]+$": + properties: + tx-queues-config: + required: + - queue0 + - queue1 + - queue2 + patternProperties: + "^queue[0-2]$": {} + additionalProperties: false + + - if: + properties: + xlnx,num-priorities: + const: 4 + then: + patternProperties: + "^ethernet@[0-9a-f]+$": + properties: + tx-queues-config: + required: + - queue0 + - queue1 + - queue2 + - queue3 + patternProperties: + "^queue[0-3]$": {} + additionalProperties: false + + - if: + properties: + xlnx,num-priorities: + const: 5 + then: + patternProperties: + "^ethernet@[0-9a-f]+$": + properties: + tx-queues-config: + required: + - queue0 + - queue1 + - queue2 + - queue3 + - queue4 + patternProperties: + "^queue[0-4]$": {} + additionalProperties: false + + - if: + properties: + xlnx,num-priorities: + const: 6 + then: + patternProperties: + "^ethernet@[0-9a-f]+$": + properties: + tx-queues-config: + required: + - queue0 + - queue1 + - queue2 + - queue3 + - queue4 + - queue5 + patternProperties: + "^queue[0-5]$": {} + additionalProperties: false + + - if: + properties: + xlnx,num-priorities: + const: 7 + then: + patternProperties: + "^ethernet@[0-9a-f]+$": + properties: + tx-queues-config: + required: + - queue0 + - queue1 + - queue2 + - queue3 + - queue4 + - queue5 + - queue6 + patternProperties: + "^queue[0-6]$": {} + additionalProperties: false + + - if: + properties: + xlnx,num-priorities: + const: 8 + then: + patternProperties: + "^ethernet@[0-9a-f]+$": + properties: + tx-queues-config: + required: + - queue0 + - queue1 + - queue2 + - queue3 + - queue4 + - queue5 + - queue6 + - queue7 + patternProperties: + "^queue[0-7]$": {} + additionalProperties: false + +examples: + - | + tsn@80040000 { + compatible = "xlnx,tsn-endpoint-ethernet-mac-3.0"; + clocks = <&misc_clk_2>, <&misc_clk_2>, <&misc_clk_1>, <&misc_clk_1>, + <&misc_clk_3>, <&misc_clk_0>; + clock-names = "gtx", "gtx90", "host_rxfifo", "host_txfifo", + "ref", "s_axi"; + xlnx,num-priorities = <8>; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0x80040000 0x40000>; + + ep_mac: ethernet@16000 { + compatible = "xlnx,tsn-ep-mac"; + reg = <0x16000 0xa000>; + dmas = <&axi_mcdma_0 0>, <&axi_mcdma_0 1>, <&axi_mcdma_0 2>, + <&axi_mcdma_0 3>, <&axi_mcdma_0 4>, <&axi_mcdma_0 5>, + <&axi_mcdma_0 6>, <&axi_mcdma_0 7>, <&axi_mcdma_0 16>, + <&axi_mcdma_0 17>, <&axi_mcdma_0 18>, <&axi_mcdma_0 19>, + <&axi_mcdma_0 20>, <&axi_mcdma_0 21>, <&axi_mcdma_0 22>, + <&axi_mcdma_0 23>; + dma-names = "tx_chan0", "tx_chan1", "tx_chan2", "tx_chan3", + "tx_chan4", "tx_chan5", "tx_chan6", "tx_chan7", + "rx_chan0", "rx_chan1", "rx_chan2", "rx_chan3", + "rx_chan4", "rx_chan5", "rx_chan6", "rx_chan7"; + tx-queues-config { + queue0 { xlnx,dma-channel-num = <0x7>; }; + queue1 { xlnx,dma-channel-num = <0x6>; }; + queue2 { xlnx,dma-channel-num = <0x5>; }; + queue3 { xlnx,dma-channel-num = <0x4>; }; + queue4 { xlnx,dma-channel-num = <0x3>; }; + queue5 { xlnx,dma-channel-num = <0x2>; }; + queue6 { xlnx,dma-channel-num = <0x1>; }; + queue7 { xlnx,dma-channel-num = <0x0>; }; + }; + }; + + switch@38000 { + compatible = "xlnx,tsn-switch"; + reg = <0x38000 0x8000>, + <0x00000 0x14000>, + <0x20000 0x14000>; + reg-names = "switch", "mac1", "mac2"; + + interrupt-parent = <&intc>; + interrupts = <0 2>, <2 2>, <4 2>, <6 2>, + <1 2>, <3 2>, <5 2>; + interrupt-names = "ptp_rx_mac1", "ptp_tx_mac1", + "mac_irq_mac1", "ptp_timer", + "ptp_rx_mac2", "ptp_tx_mac2", + "mac_irq_mac2"; + xlnx,max-learning-entries = <1920>; + + mdio-1 { + #address-cells = <1>; + #size-cells = <0>; + phy0: ethernet-phy@0 { + reg = <0>; + }; + }; + + mdio-2 { + #address-cells = <1>; + #size-cells = <0>; + phy1: ethernet-phy@1 { + reg = <1>; + }; + }; + + ethernet-ports { + #address-cells = <1>; + #size-cells = <0>; + + ethernet-port@0 { + reg = <0>; + ethernet = <&ep_mac>; + phy-mode = "internal"; + + fixed-link { + speed = <1000>; + full-duplex; + }; + }; + + ethernet-port@1 { + reg = <1>; + phy-handle = <&phy0>; + phy-mode = "rgmii-id"; + }; + + ethernet-port@2 { + reg = <2>; + phy-handle = <&phy1>; + phy-mode = "rgmii-id"; + }; + }; + }; + };
MAINTAINERS +7 -0
@@ -30742,6 +30742,13 @@ M: Harsh Jain <[email protected]> S: Maintained F: drivers/char/hw_random/xilinx-trng.c +XILINX TSN ENDPOINT ETHERNET MAC DRIVER +M: Nagadheeraj Rottela <[email protected]> +M: Srinivas Neeli <[email protected]> +L: [email protected] +S: Maintained +F: Documentation/devicetree/bindings/net/xlnx,tsn-endpoint-ethernet-mac.yaml + XILINX UARTLITE SERIAL DRIVER M: Peter Korsgaard <[email protected]> L: [email protected]
Signature · 1 line
2.43.0
Re: [PATCH net-next v4 1/8] dt-bindings: net: add Xilinx TSN Endpoint Ethernet MAC
Documentation/devicetree/bindings/net/xlnx,tsn-endpoint-ethernet-mac.yaml line 193
Quoted 11 lines
Documentation/devicetree/bindings/net/xlnx,tsn-endpoint-ethernet-mac.yaml new file +11
-0+ xlnx,max-learning-entries: + $ref: /schemas/types.yaml#/definitions/uint32 + minimum: 256 + maximum: 1920 + default: 1920 + description: + Maximum number of addresses the hardware address learning engine + can learn on each network port (MAC1 and MAC2). This is the + MAX_LEARNING_ENTRIES IP configuration parameter, and no register + reports it. The endpoint port does not take part in hardware + address learning.
Is this a synthesis parameter? No other switch that i know of has it in DT. The driver hard codes the value based on the compatible. Why does that not work for you?
Documentation/devicetree/bindings/net/xlnx,tsn-endpoint-ethernet-mac.yaml line 207
Quoted 13 lines
Documentation/devicetree/bindings/net/xlnx,tsn-endpoint-ethernet-mac.yaml new file +13
-0+ mdio-1: + $ref: /schemas/net/mdio.yaml# + description: + MDIO bus controller for MAC1. Registers reside inside the mac1 + reg-names window. + unevaluatedProperties: false + + mdio-2: + $ref: /schemas/net/mdio.yaml# + description: + MDIO bus controller for MAC2. Registers reside inside the mac2 + reg-names window. + unevaluatedProperties: false
How hard coded into the design is the number of ports? The way the DT is structured, it does not seem easy to add another port. It is more normal to put all port properties within one node, so you just need to cookie cutter that node, not add new nodes all other the place.
Quoted 12 lines
Documentation/devicetree/bindings/net/xlnx,tsn-endpoint-ethernet-mac.yaml new file +11
-0+ switch@38000 { + compatible = "xlnx,tsn-switch"; + reg = <0x38000 0x8000>, + <0x00000 0x14000>, + <0x20000 0x14000>; + reg-names = "switch", "mac1", "mac2"; + mdio-1 { + #address-cells = <1>; + #size-cells = <0>; + phy0: ethernet-phy@0 { + reg = <0>;
Documentation/devicetree/bindings/net/xlnx,tsn-endpoint-ethernet-mac.yaml line 506
Quoted 10 lines
Documentation/devicetree/bindings/net/xlnx,tsn-endpoint-ethernet-mac.yaml new file +10
-0+ }; + }; + + mdio-2 { + #address-cells = <1>; + #size-cells = <0>; + phy1: ethernet-phy@1 { + reg = <1>; + }; + };
Interesting that this is address 1, where as the other is address 0. Just to be sure, there are two fully independent MDIO bus masters?
This
Quoted 16 lines
Documentation/devicetree/bindings/net/xlnx,tsn-endpoint-ethernet-mac.yaml new file +16
-0+ + ethernet-ports { + #address-cells = <1>; + #size-cells = <0>; + + ethernet-port@0 { + reg = <0>; + ethernet = <&ep_mac>; + phy-mode = "internal"; + + fixed-link { + speed = <1000>; + full-duplex; + }; + }; +
Documentation/devicetree/bindings/net/xlnx,tsn-endpoint-ethernet-mac.yaml line 532
Quoted 10 lines
Documentation/devicetree/bindings/net/xlnx,tsn-endpoint-ethernet-mac.yaml new file +10
-0+ ethernet-port@1 { + reg = <1>; + phy-handle = <&phy0>; + phy-mode = "rgmii-id"; + }; + + ethernet-port@2 { + reg = <2>; + phy-handle = <&phy1>; + phy-mode = "rgmii-id";
Are these two PHY internal or external? Using rgmii internally is O.K, but odd. Normally 'GMII' or 'internal' would be used.
Andrew
Re: [PATCH net-next v4 1/8] dt-bindings: net: add Xilinx TSN Endpoint Ethernet MAC
Hi Andrew,
Quoted 11 lines · Andrew Lunn
Documentation/devicetree/bindings/net/xlnx,tsn-endpoint-ethernet-mac.yaml line 193
Quoted 11 lines
Documentation/devicetree/bindings/net/xlnx,tsn-endpoint-ethernet-mac.yaml new file +11
-0+ xlnx,max-learning-entries: + $ref: /schemas/types.yaml#/definitions/uint32 + minimum: 256 + maximum: 1920 + default: 1920 + description: + Maximum number of addresses the hardware address learning engine + can learn on each network port (MAC1 and MAC2). This is the + MAX_LEARNING_ENTRIES IP configuration parameter, and no register + reports it. The endpoint port does not take part in hardware + address learning.
Quoted 3 lines
Is this a synthesis parameter? No other switch that i know of has it in DT. The driver hard codes the value based on the compatible. Why does that not work for you?
Yes, MAX_LEARNING_ENTRIES is a Vivado synthesis parameter of the IP (256 to 1920), and no register reports it, so one compatible can carry different values. The endpoint driver in this series does not use it. It will be used by the DSA switch driver.
Quoted 13 lines
Documentation/devicetree/bindings/net/xlnx,tsn-endpoint-ethernet-mac.yaml line 207
Quoted 13 lines
Documentation/devicetree/bindings/net/xlnx,tsn-endpoint-ethernet-mac.yaml new file +13
-0+ mdio-1: + $ref: /schemas/net/mdio.yaml# + description: + MDIO bus controller for MAC1. Registers reside inside the mac1 + reg-names window. + unevaluatedProperties: false + + mdio-2: + $ref: /schemas/net/mdio.yaml# + description: + MDIO bus controller for MAC2. Registers reside inside the mac2 + reg-names window. + unevaluatedProperties: false
Quoted 4 lines
How hard coded into the design is the number of ports? The way the DT is structured, it does not seem easy to add another port. It is more normal to put all port properties within one node, so you just need to cookie cutter that node, not add new nodes all other the place.
The number of ports is fixed by the IP. The switch always has two external MAC ports and one internal endpoint port, and no configuration has more external MACs, so the binding never needs to grow another port.
The switch node follows the IP's register map. The switch fabric and the two MAC blocks are separate register windows of the switch IP, and each MAC window also holds that MAC's MDIO controller and PTP block. The PTP timer interrupt is shared by the whole switch, not owned by one port.
For these reasons I would prefer to keep the per-MAC resources on the switch node
Quoted 22 lines
Quoted 12 lines
Documentation/devicetree/bindings/net/xlnx,tsn-endpoint-ethernet-mac.yaml new file +11
-0+ switch@38000 { + compatible = "xlnx,tsn-switch"; + reg = <0x38000 0x8000>, + <0x00000 0x14000>, + <0x20000 0x14000>; + reg-names = "switch", "mac1", "mac2"; + mdio-1 { + #address-cells = <1>; + #size-cells = <0>; + phy0: ethernet-phy@0 { + reg = <0>;Documentation/devicetree/bindings/net/xlnx,tsn-endpoint-ethernet-mac.yaml line 506
Quoted 10 lines
Documentation/devicetree/bindings/net/xlnx,tsn-endpoint-ethernet-mac.yaml new file +10
-0+ }; + }; + + mdio-2 { + #address-cells = <1>; + #size-cells = <0>; + phy1: ethernet-phy@1 { + reg = <1>; + }; + };
Quoted 4 lines
Interesting that this is address 1, where as the other is address 0. Just to be sure, there are two fully independent MDIO bus masters?
This
Yes. Each MAC has its own independent MDIO controller, with its own MDC/MDIO pins and its registers inside that MAC's register window.
Thanks
Srinivas Neeli
Quoted 31 lines
Quoted 17 lines
Documentation/devicetree/bindings/net/xlnx,tsn-endpoint-ethernet-mac.yaml new file +16
-0+ + ethernet-ports { + #address-cells = <1>; + #size-cells = <0>; + + ethernet-port@0 { + reg = <0>; + ethernet = <&ep_mac>; + phy-mode = "internal"; + + fixed-link { + speed = <1000>; + full-duplex; + }; + }; +Documentation/devicetree/bindings/net/xlnx,tsn-endpoint-ethernet-mac.yaml line 532
Quoted 10 lines
Documentation/devicetree/bindings/net/xlnx,tsn-endpoint-ethernet-mac.yaml new file +10
-0+ ethernet-port@1 { + reg = <1>; + phy-handle = <&phy0>; + phy-mode = "rgmii-id"; + }; + + ethernet-port@2 { + reg = <2>; + phy-handle = <&phy1>; + phy-mode = "rgmii-id";Are these two PHY internal or external? Using rgmii internally is O.K, but odd. Normally 'GMII' or 'internal' would be used.
Andrew
Re: [PATCH net-next v4 1/8] dt-bindings: net: add Xilinx TSN Endpoint Ethernet MAC
Quoted 6 lines
Quoted 3 lines
Is this a synthesis parameter? No other switch that i know of has it in DT. The driver hard codes the value based on the compatible. Why does that not work for you?
Yes,
MAX_LEARNING_ENTRIESis a Vivado synthesis parameter of the IP (256 to 1920), and no register reports it
I assume that will be fixed in the next version of the IP?
Are there many other synthesis parameter which are not exported in registers? I just want to get an idea if this is a one off, or you are going to add lots of DT parameters in the next set of patches.
Quoted 3 lines
The number of ports is fixed by the IP. The switch always has two external MAC ports and one internal endpoint port, and no configuration has more external MACs, so the binding never needs to grow another port.
And that is signed off by top management? The next switch you design will be a fresh design, no reuse of the existing IP and will require a whole new DSA driver?
Quoted 5 lines
The switch node follows the IP's register map. The switch fabric and the two MAC blocks are separate register windows of the switch IP, and each MAC window also holds that MAC's MDIO controller and PTP block. The PTP timer interrupt is shared by the whole switch, not owned by one port.
Quoted 10 lines
For these reasons I would prefer to keep the per-MAC resources on the switch node
Quoted 7 lines
Quoted 7 lines
Documentation/devicetree/bindings/net/xlnx,tsn-endpoint-ethernet-mac.yaml new file +6
-0+ switch@38000 { + compatible = "xlnx,tsn-switch"; + reg = <0x38000 0x8000>, + <0x00000 0x14000>, + <0x20000 0x14000>; + reg-names = "switch", "mac1", "mac2";
I ask, because it would not be too hard to swap this address map around, put the switch registers first, and then the port registers, and you could have as many ports as you want.
Quoted 2 lines · Back to what you just
each
MAC window also holds that MAC's MDIO controller and PTP block.
So the MDIO controller and the PTP block are MAC properties, so should be inside the MAC node.
Quoted 2 lines
The PTP
timer interrupt is shared by the whole switch
So that should be at the switch level.
Andrew
Re: [PATCH net-next v4 1/8] dt-bindings: net: add Xilinx TSN Endpoint Ethernet MAC
Hi Andrew,
Quoted 6 lines · Andrew Lunn
Quoted 5 lines
Quoted 3 lines
Is this a synthesis parameter? No other switch that i know of has it in DT. The driver hard codes the value based on the compatible. Why does that not work for you?
Yes,
MAX_LEARNING_ENTRIESis a Vivado synthesis parameter of the IP (256 to 1920), and no register reports itI assume that will be fixed in the next version of the IP?
Exposing synthesis parameters is standard behavior for FPGA IPs, and not all of these are exposed through registers. Hence, I am afraid there is no plan to change this in the IP.
For Xilinx/AMD FPGA IPs, these values can vary depending on the Vivado configuration,
so the same compatible may have different values for the same property depending on the design.
We have similar cases in the AXI Ethernet driver, for example, xlnx,rxcsum and xlnx,txcsum, which are based on synthesis parameters.
Quoted 4 lines
Are there many other synthesis parameter which are not exported in registers? I just want to get an idea if this is a one off, or you are going to add lots of DT parameters in the next set of patches.
Yes, there are a few additional parameters that we plan to expose through DT properties in the upcoming series.
The TSN subsystem has several configurable parameters, and I understand that DT should describe the hardware irrespective of its usage by software. But given the volume of such parameters, we are considering adding DT properties in an incremental fashion, as and when there are consumers.
Quoted 30 lines
Quoted 4 lines
The number of ports is fixed by the IP. The switch always has two external MAC ports and one internal endpoint port, and no configuration has more external MACs, so the binding never needs to grow another port.
And that is signed off by top management? The next switch you design will be a fresh design, no reuse of the existing IP and will require a whole new DSA driver?
Quoted 5 lines
The switch node follows the IP's register map. The switch fabric and the two MAC blocks are separate register windows of the switch IP, and each MAC window also holds that MAC's MDIO controller and PTP block. The PTP timer interrupt is shared by the whole switch, not owned by one port.
Quoted 9 lines
For these reasons I would prefer to keep the per-MAC resources on the switch node
Quoted 6 lines
Quoted 6 lines
Documentation/devicetree/bindings/net/xlnx,tsn-endpoint-ethernet-mac.yaml new file +6
-0+ switch@38000 { + compatible = "xlnx,tsn-switch"; + reg = <0x38000 0x8000>, + <0x00000 0x14000>, + <0x20000 0x14000>; + reg-names = "switch", "mac1", "mac2";I ask, because it would not be too hard to swap this address map around, put the switch registers first, and then the port registers, and you could have as many ports as you want.
Quoted 2 lines · Back to what you just
each
MAC window also holds that MAC's MDIO controller and PTP block.
Quoted 8 lines
So the MDIO controller and the PTP block are MAC properties, so should be inside the MAC node.
Quoted 2 lines
The PTP
timer interrupt is shared by the whole switchSo that should be at the switch level.
Andrew
Yes, I agree with your suggestion. I will move the MAC and MDIO properties under ethernet-ports in the next series.
Thanks
Srinivas Neeli
Re: [PATCH net-next v4 1/8] dt-bindings: net: add Xilinx TSN Endpoint Ethernet MAC
In reply to Srinivas NeeliDocumentation/devicetree/bindings/net/xlnx,tsn-endpoint-ethernet-mac.yaml line 16
Quoted 8 lines
Documentation/devicetree/bindings/net/xlnx,tsn-endpoint-ethernet-mac.yaml new file +8
-0+description: + TSN Endpoint Ethernet MAC IP implements IEEE 802.1 Time-Sensitive + Networking (TSN) standards and provides low-latency network connectivity + in the Bridged Endpoint configuration. The IP integrates a three-port + switch, with two ports connected to the external network and one port + connected to an internal endpoint. It also supports GMII/RGMII interfaces + for connection to an external PHY, enabling full-duplex operation at + 100 Mb/s and 1 Gb/s speeds.
Sorry, after reading that again, i realised i asked a wrong question. All PHYs are external.
Andrew
[email protected]
AI reviewRe: [PATCH net-next v4 1/8] dt-bindings: net: add Xilinx TSN Endpoint Ethernet MAC
In reply to Srinivas NeeliThank you for your contribution! Sashiko AI review found more severe issue(s) in other patches of this series. This mail is only an FYI, in case you want to address the nit picks below when you…
Thank you for your contribution! Sashiko AI review found more severe issue(s) in other patches of this series. This mail is only an FYI, in case you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] The top-level schema never requires the '^ethernet@[0-9a-f]+$' (xlnx,tsn-ep-mac) child or the '^switch@[0-9a-f]+$' (xlnx,tsn-switch)…
- [Low] The per-xlnx,num-priorities allOf branches force tx-queues-config to hold exactly queue0..queue(N-1).
- [Low] The wrapper compatible is IP-version-specific ('xlnx,tsn- endpoint-ethernet-mac-3.0').
- [Low] The commit message says 'Each external port@N references its PHY through a phy-handle in the matching mdio-<N> child.' Since v3, the…
- [Low] ethernet-port@1 and ethernet-port@2 restrict phy-mode to gmii, rgmii and rgmii-id, which excludes rgmii-txid and rgmii-rxid.
- [Low] clocks/clock-names is a fixed list of six required entries (gtx, gtx90, host_rxfifo, host_txfifo, ref, s_axi), with no conditional on…
--
dt-bindings: net: add Xilinx TSN Endpoint Ethernet MAC
This adds a YAML binding for the Xilinx TSN Endpoint Ethernet MAC IP in its Bridged Endpoint configuration. The top-level wrapper node owns the shared clocks and xlnx,num-priorities. It has an xlnx,tsn-ep-mac child for the host-side DMA channels and an xlnx,tsn-switch child for the three-port switch, its MDIO buses and its ports.
Quoted 3 lines
children and per-MAC interrupt-names entries. Each external port@N references its PHY through a phy-handle in the matching mdio-<N> child.
[Severity: Low]
Is this sentence still accurate after the v3 rename? The binding now only accepts ethernet-port@1 and ethernet-port@2 inside the ethernet-ports container. That container has additionalProperties: false, so the schema would reject a node named port@1.
Should this say ethernet-port@N instead?
Quoted 6 lines
Documentation/devicetree/bindings/net/xlnx,tsn-endpoint-ethernet-mac.yaml new file +0
-0@@ -0,0 +1,536 @@
[ ... ]
Quoted 11 lines
Documentation/devicetree/bindings/net/xlnx,tsn-endpoint-ethernet-mac.yaml new file +11
-0+properties: + compatible: + const: xlnx,tsn-endpoint-ethernet-mac-3.0 + + clocks: + items: + - description: GTX clock for transmitter logic and RTC + - description: GTX 90-degree phase shifted clock for RGMII + - description: Host RX FIFO clock + - description: Host TX FIFO clock + - description: Reference clock for IDELAY control
Documentation/devicetree/bindings/net/xlnx,tsn-endpoint-ethernet-mac.yaml line 42
Quoted 10 lines
Documentation/devicetree/bindings/net/xlnx,tsn-endpoint-ethernet-mac.yaml new file +10
-0+ - description: AXI-Lite register interface clock + + clock-names: + items: + - const: gtx + - const: gtx90 + - const: host_rxfifo + - const: host_txfifo + - const: ref + - const: s_axi
[Severity: Low]
Does the IP still have all six clock inputs when both external ports are GMII? The description says gtx90 is the phase shifted clock for RGMII. The list does not depend on the ports' phy-mode, so a GMII-only design still has to supply gtx90.
The example already feeds the same clock to both gtx and gtx90:
clocks = <&misc_clk_2>, <&misc_clk_2>, <&misc_clk_1>, <&misc_clk_1>,
Later in the series, tsn_ip_probe() in xilinx_tsn_main.c requests all six clocks as mandatory:
ret = devm_clk_bulk_get(dev, TSN_NUM_CLOCKS, w->clks);
A DT without gtx90 would therefore fail to probe. The binding does not say which clock inputs exist in the GMII configuration. The ref (IDELAYCTRL) clock may still be needed for GMII.
If the GMII configuration has no gtx90 input, should that clock depend on the ports' phy-mode?
Quoted 2 lines
Documentation/devicetree/bindings/net/xlnx,tsn-endpoint-ethernet-mac.yaml new file +2
-0+ + ranges: true
[ ... ]
Documentation/devicetree/bindings/net/xlnx,tsn-endpoint-ethernet-mac.yaml line 72
Quoted 11 lines
Documentation/devicetree/bindings/net/xlnx,tsn-endpoint-ethernet-mac.yaml new file +11
-0+patternProperties: + "^ethernet@[0-9a-f]+$": + type: object + $ref: /schemas/net/ethernet-controller.yaml# + unevaluatedProperties: false + description: + Endpoint MAC sub-node. Provides the host-side data path through the + DMA channels described by its dmas / dma-names. + properties: + compatible: + const: xlnx,tsn-ep-mac
[Severity: Low]
The wrapper compatible is versioned (xlnx,tsn-endpoint-ethernet-mac-3.0). This child and the switch child (xlnx,tsn-switch) use unversioned names that cover the whole family.
Documentation/devicetree/bindings/writing-bindings.rst asks for specific compatibles and says not to use device-family names. For sub-blocks of a bigger device, it prefers a compatible derived from the parent device.
The MDIO and PTP blocks sit at fixed offsets in the per-MAC windows of this IP version. How would these child compatibles distinguish a later TSN IP revision with a different sub-block layout?
Should the child compatibles follow the parent IP version too? If not, could the commit message explain why they are generic?
[ ... ]
Quoted 10 lines
Documentation/devicetree/bindings/net/xlnx,tsn-endpoint-ethernet-mac.yaml new file +10
-0+ dma-names: + minItems: 2 + maxItems: 16 + items: + pattern: "^(tx|rx)_chan[0-7]$" + allOf: + - contains: + pattern: "^tx_chan[0-7]$" + - contains: + pattern: "^rx_chan[0-7]$"
[ ... ]
Documentation/devicetree/bindings/net/xlnx,tsn-endpoint-ethernet-mac.yaml line 109
Quoted 12 lines
Documentation/devicetree/bindings/net/xlnx,tsn-endpoint-ethernet-mac.yaml new file +12
-0+ tx-queues-config: + type: object + additionalProperties: false + description: + TX queue configuration node that maps IP priority queues to + DMA TX channels. The TSN IP supports multiple priority queues for + QoS scheduling. Each priority queue must be described exactly + once and map to a distinct TX channel listed in dma-names. Two + queues must not use the same TX channel. The mapping need not + follow the channel numbering. For example, queue0 with + xlnx,dma-channel-num set to 5 means priority queue 0 uses tx_chan5 + for data transfer.
[Severity: Low]
Should dma-names be tied to xlnx,num-priorities in the same way as the queueN children?
The per-N allOf branches force tx-queues-config to hold exactly queue0 to queue(N-1). dma-names only needs one tx_chan entry and one rx_chan entry, and it has no uniqueItems. As far as I can tell, this would validate:
xlnx,num-priorities = <8>;
dma-names = "tx_chan0", "rx_chan0";
tx-queues-config {
queue0 { xlnx,dma-channel-num = <0>; };
...
queue7 { xlnx,dma-channel-num = <0>; };
};That contradicts the description above, which says each queue maps to a distinct TX channel listed in dma-names.
The driver added later in the series ("net: xilinx: tsn: parse endpoint DMA channel configuration") also requires an exact match in xlnx_tsn_ep_probe():
if (num_tx_dma_channels != num_prio)
return dev_err_probe(dev, -EINVAL,
"TX channel count %u must equal num-priorities %u\n",
The binding does not document this rule. A DT with more tx_chan entries than priorities passes dt_binding_check but fails probe. The driver rejects all of these cases at probe time with an error message.
Could each per-N if/then block also limit the tx_chan entries to exactly N (contains with minContains/maxContains), and could dma-names get
uniqueItems: true?
The MAINTAINERS entry here lists only the binding file. The driver directory is added to it later in the series.
[ ... ]
Quoted 6 lines
Documentation/devicetree/bindings/net/xlnx,tsn-endpoint-ethernet-mac.yaml new file +6
-0+ ethernet-port@1: + type: object + unevaluatedProperties: true + description: + External Ethernet port wired to MAC1, reached through the + mdio-1 bus.
Documentation/devicetree/bindings/net/xlnx,tsn-endpoint-ethernet-mac.yaml line 252
Quoted 10 lines
Documentation/devicetree/bindings/net/xlnx,tsn-endpoint-ethernet-mac.yaml new file +10
-0+ + properties: + reg: + const: 1 + + phy-mode: + enum: + - gmii + - rgmii + - rgmii-id
[Severity: Low]
Why are rgmii-txid and rgmii-rxid left out here and on ethernet-port@2?
phy-mode describes which RGMII delays the board does not provide. A board whose PCB adds only one of the two delays needs one of those modes. With this enum, the board author has to choose rgmii (one delay missing) or rgmii-id (one delay applied twice).
The gtx90 clock is described as "GTX 90-degree phase shifted clock for RGMII", which suggests the MAC may shift TXC itself. Does the MAC add the TX delay? If it does, and the PHY also adds the TX delay for rgmii-id, the delay would be applied twice.
Should the binding say whether the MAC applies this delay, or describe it with a property such as tx-internal-delay-ps?
[ ... ]
Documentation/devicetree/bindings/net/xlnx,tsn-endpoint-ethernet-mac.yaml line 305
Quoted 10 lines
Documentation/devicetree/bindings/net/xlnx,tsn-endpoint-ethernet-mac.yaml new file +10
-0+additionalProperties: false + +required: + - compatible + - clocks + - clock-names + - xlnx,num-priorities + - ranges + - '#address-cells' + - '#size-cells'
[Severity: Low]
Should the ethernet@ and switch@ children be required here?
The description and changelog say the binding covers only the fixed Bridged Endpoint configuration. ethernet-port@0/1/2 are required because a DT missing any of them "cannot describe working hardware". Even so, a wrapper with no switch@ child, or with no children at all, still passes dt_binding_check.
A node with only an ethernet@ child already validates under xlnx,tsn-endpoint-ethernet-mac-3.0. That is the Endpoint-only layout the changelog says is not supported yet.
If the two configurations are told apart later by which children are present, shouldn't this schema state that requirement now?
[ ... ]
Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261113-patches_v2_external-v4-0-56bb26f042a4%40amd.com
PATCH v4 2/8 net: xilinx: tsn: add TSN endpoint wrapper driver
In reply to Srinivas NeeliThe TSN Endpoint Ethernet MAC IP groups several sub-nodes under one IP node with a set of IP-wide clocks. Each sub-node needs its own driver, and the shared clocks must be running before any of them probe.
Add a thin wrapper platform driver for the IP node. Enable the IP-wide clocks from the device tree and bind each sub-node to its own driver.
---
Changes in v4:
- Drop the Kconfig reference to a companion DSA driver that is not in this series.
Changes in v2:
- Depend on OF_ADDRESS instead of OF && HAS_IOMEM.
- Point the Kconfig help text at the companion DSA driver, not a symbol that does not exist yet at this patch.
- Drop the mod_devicetable.h include, platform_device.h already pulls it in.
--- MAINTAINERS | 1 + drivers/net/ethernet/xilinx/Kconfig | 1 + drivers/net/ethernet/xilinx/Makefile | 1 + drivers/net/ethernet/xilinx/tsn/Kconfig | 14 +++ drivers/net/ethernet/xilinx/tsn/Makefile | 2 + drivers/net/ethernet/xilinx/tsn/xilinx_tsn_main.c | 104 ++++++++++++++++++++++ 6 files changed, 123 insertions(+)
MAINTAINERS +1 -0
@@ -30748,6 +30748,7 @@ M: Srinivas Neeli <[email protected]> L: [email protected] S: Maintained F: Documentation/devicetree/bindings/net/xlnx,tsn-endpoint-ethernet-mac.yaml +F: drivers/net/ethernet/xilinx/tsn/ XILINX UARTLITE SERIAL DRIVER M: Peter Korsgaard <[email protected]>
drivers/net/ethernet/xilinx/Kconfig +1 -0
@@ -41,4 +41,5 @@ config XILINX_LL_TEMAC This driver supports the Xilinx 10/100/1000 LocalLink TEMAC core used in Xilinx Spartan and Virtex FPGAs +source "drivers/net/ethernet/xilinx/tsn/Kconfig" endif # NET_VENDOR_XILINX
drivers/net/ethernet/xilinx/Makefile +1 -0
@@ -8,3 +8,4 @@ obj-$(CONFIG_XILINX_LL_TEMAC) += ll_temac.o obj-$(CONFIG_XILINX_EMACLITE) += xilinx_emaclite.o xilinx_emac-objs := xilinx_axienet_main.o xilinx_axienet_mdio.o obj-$(CONFIG_XILINX_AXI_EMAC) += xilinx_emac.o +obj-$(CONFIG_XILINX_TSN) += tsn/
drivers/net/ethernet/xilinx/tsn/Kconfig new file +14 -0
@@ -0,0 +1,14 @@ +# SPDX-License-Identifier: GPL-2.0-only +# +# Xilinx TSN device configuration +# + +config XILINX_TSN + tristate "Xilinx TSN Ethernet driver" + depends on OF_ADDRESS + help + This driver supports the AMD/Xilinx Time-Sensitive Networking + (TSN) Endpoint Ethernet MAC IP. It provides the wrapper device + and the endpoint MAC that connects the IP to the host CPU. + + If unsure, say N.
drivers/net/ethernet/xilinx/tsn/Makefile new file +2 -0
@@ -0,0 +1,2 @@ +obj-$(CONFIG_XILINX_TSN) += xilinx_tsn.o +xilinx_tsn-y := xilinx_tsn_main.o
drivers/net/ethernet/xilinx/tsn/xilinx_tsn_main.c new file +104 -0
104 lines not on this page · raw message
Signature · 1 line
2.43.0
[email protected]
AI reviewRe: [PATCH net-next v4 2/8] net: xilinx: tsn: add TSN endpoint wrapper driver
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Low] net: xilinx: tsn: use devm_clk_bulk_get_enable() in tsn_ip_probe() --
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider:
- [Low] net: xilinx: tsn: use devm_clk_bulk_get_enable() in tsn_ip_probe()
--
commit 9fffc2486144ec3dd4b7c4d984f898729124f771
Author: Srinivas Neeli <[email protected]>
net: xilinx: tsn: add TSN endpoint wrapper driver
This commit adds a platform driver for the AMD/Xilinx TSN Endpoint Ethernet MAC IP wrapper node that enables the IP-wide clocks and populates its child sub-nodes.
Quoted 5 lines
drivers/net/ethernet/xilinx/tsn/xilinx_tsn_main.c new file +0
-0
[ ... ]
Quoted 21 lines
drivers/net/ethernet/xilinx/tsn/xilinx_tsn_main.c new file +21
-0+static void tsn_clk_bulk_disable (void *data) +{ +struct xlnx_tsn_ip *w = data; + +clk_bulk_disable_unprepare (TSN_NUM_CLOCKS , w->clks); +} + +static int tsn_ip_probe (struct platform_device *pdev) +{ +struct device *dev = &pdev->dev; +struct xlnx_tsn_ip *w; +int ret; + + w =devm_kzalloc (dev,sizeof (*w),GFP_KERNEL ); +if (!w) +return -ENOMEM ; + +for (int i =0 ; i <TSN_NUM_CLOCKS ; i++) + w->clks[i].id = tsn_clk_names[i]; + + ret =devm_clk_bulk_get (dev,TSN_NUM_CLOCKS , w->clks);
drivers/net/ethernet/xilinx/tsn/xilinx_tsn_main.c line 67
Quoted 10 lines
drivers/net/ethernet/xilinx/tsn/xilinx_tsn_main.c new file +10
-0+if (ret) +return dev_err_probe (dev, ret,"failed to get clocks\n" ); + + ret =clk_bulk_prepare_enable (TSN_NUM_CLOCKS , w->clks); +if (ret) +return dev_err_probe (dev, ret,"failed to enable clocks\n" ); + + ret =devm_add_action_or_reset (dev, tsn_clk_bulk_disable, w); +if (ret) +return ret;
[Severity: Low]
Could tsn_ip_probe() use devm_clk_bulk_get_enable() instead of calling devm_clk_bulk_get(), clk_bulk_prepare_enable() and devm_add_action_or_reset() with tsn_clk_bulk_disable()?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
[email protected]
AI reviewRe: [PATCH net-next v4 2/8] net: xilinx: tsn: add TSN endpoint wrapper driver
In reply to Srinivas NeeliThank you for your contribution! Sashiko AI review found more severe issue(s) in other patches of this series. This mail is only an FYI, in case you want to address the nit picks below when you…
Thank you for your contribution! Sashiko AI review found more severe issue(s) in other patches of this series. This mail is only an FYI, in case you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] net: xilinx: tsn: use devm_clk_bulk_get_enable() in tsn_ip_probe()
--
Quoted 99 lines
drivers/net/ethernet/xilinx/tsn/xilinx_tsn_main.c new file +94
-0@@ -0,0 +1,104 @@ +// SPDX-License-Identifier: GPL-2.0 + +/* +* Time Sensitive Networking (TSN) Ethernet MAC wrapper driver. +* +* Copyright (C) 2026 Advanced Micro Devices, Inc. +*/ + +#include <linux/clk.h> +#include <linux/device.h> +#include <linux/module.h> +#include <linux/of.h> +#include <linux/of_platform.h> +#include <linux/platform_device.h> +#include <linux/slab.h> +#include <linux/types.h> + +#define TSN_NUM_CLOCKS 6 + +/** +* struct xlnx_tsn_ip - wrapper-private IP state +* @clks: bulk-managed IP clocks +*/ +struct xlnx_tsn_ip { +struct clk_bulk_data clks[TSN_NUM_CLOCKS ]; +}; + +static const char *const tsn_clk_names[TSN_NUM_CLOCKS ] = { +"gtx" , +"gtx90" , +"host_rxfifo" , +"host_txfifo" , +"ref" , +"s_axi" , +}; + +static void tsn_clk_bulk_disable (void *data) +{ +struct xlnx_tsn_ip *w = data; + +clk_bulk_disable_unprepare (TSN_NUM_CLOCKS , w->clks); +} + +static int tsn_ip_probe (struct platform_device *pdev) +{ +struct device *dev = &pdev->dev; +struct xlnx_tsn_ip *w; +int ret; + + w =devm_kzalloc (dev,sizeof (*w),GFP_KERNEL ); +if (!w) +return -ENOMEM ; + +for (int i =0 ; i <TSN_NUM_CLOCKS ; i++) + w->clks[i].id = tsn_clk_names[i]; + + ret =devm_clk_bulk_get (dev,TSN_NUM_CLOCKS , w->clks); +if (ret) +return dev_err_probe (dev, ret,"failed to get clocks\n" ); + + ret =clk_bulk_prepare_enable (TSN_NUM_CLOCKS , w->clks); +if (ret) +return dev_err_probe (dev, ret,"failed to enable clocks\n" ); + + ret =devm_add_action_or_reset (dev, tsn_clk_bulk_disable, w); +if (ret) +return ret; + +return devm_of_platform_populate (dev); +} + +static const struct of_device_id tsn_of_match[] = { + { .compatible ="xlnx,tsn-endpoint-ethernet-mac-3.0" }, + { } +}; +MODULE_DEVICE_TABLE (of, tsn_of_match); + +static struct platform_driver tsn_driver = { + .probe = tsn_ip_probe, + .driver = { + .name ="xilinx-tsn" , + .of_match_table = tsn_of_match, + }, +}; + +static struct platform_driver *const tsn_drivers[] = { + &tsn_driver, +}; + +static int __init xlnx_tsn_init (void ) +{ +return platform_register_drivers (tsn_drivers,ARRAY_SIZE (tsn_drivers)); +} +module_init (xlnx_tsn_init);
drivers/net/ethernet/xilinx/tsn/xilinx_tsn_main.c line 104
Quoted 10 lines
drivers/net/ethernet/xilinx/tsn/xilinx_tsn_main.c new file +10
-0+ +static void __exit xlnx_tsn_exit(void) +{ +platform_unregister_drivers (tsn_drivers,ARRAY_SIZE (tsn_drivers)); +} +module_exit (xlnx_tsn_exit); + +MODULE_AUTHOR ("Srinivas Neeli <[email protected]>" ); +MODULE_DESCRIPTION ("AMD/Xilinx TSN Endpoint Ethernet MAC wrapper driver" ); +MODULE_LICENSE ("GPL" );
[Severity: Low]
This open-codes what devm_clk_bulk_get_enable() already provides. That helper in drivers/clk/clk-devres.c gets the bulk clocks, prepares and enables them, and registers a devres release that disables, unprepares and puts them on probe failure or unbind.
That means three steps can collapse into a single devm_clk_bulk_get_enable(dev, TSN_NUM_CLOCKS, w->clks) call followed by one dev_err_probe():
- devm_clk_bulk_get()
- clk_bulk_prepare_enable()
- devm_add_action_or_reset()
The tsn_clk_bulk_disable() callback can then be dropped entirely.
The current code is not functionally wrong. It is just extra boilerplate in tsn_ip_probe() that the clk framework already handles. Is there a reason the get and enable steps need to stay split here, e.g. something planned between them in a later patch?
Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261113-patches_v2_external-v4-0-56bb26f042a4%40amd.com
PATCH v4 3/8 net: xilinx: tsn: add endpoint MAC driver skeleton
In reply to Srinivas NeeliThe TSN Endpoint MAC owns the IP's host-side MCDMA data path and is the netdev physically wired to the CPU. The DSA switch needs this netdev to exist as its conduit.
Add a platform driver (compatible "xlnx,tsn-ep-mac") for the endpoint. Register the netdev with the standard eth%d name, set its MAC address, and provide minimal netdev and ethtool ops. ndo_open starts the queues and ndo_start_xmit drops frames.
---
Changes in v4:
- Use alloc_etherdev() so the standard eth%d name is registered with NET_NAME_ENUM.
Changes in v3:
- Register the netdev with the standard eth%d name (NET_NAME_UNKNOWN) instead of a custom "ep%d".
Changes in v2:
- Name the netdev ep%d with NET_NAME_ENUM instead of a fixed "ep", so a second IP instance does not clash on register_netdev(). The %d enumeration is what NET_NAME_ENUM describes, and it matches the eth%d naming in net/dsa/user.c.
- Drop the mapped but unused register window (ep->regs and its ioremap). It was intended for QBV support, which is not part of this series, so the endpoint driver does not use it. The mapping will be re-added when QBV support lands.
- Use dev_kfree_skb_any() on the drop path, not dev_kfree_skb().
- Drop the mod_devicetable.h include, platform_device.h already pulls it in.
--- drivers/net/ethernet/xilinx/tsn/Makefile | 2 +- drivers/net/ethernet/xilinx/tsn/xilinx_tsn.h | 15 +++ drivers/net/ethernet/xilinx/tsn/xilinx_tsn_ep.c | 143 ++++++++++++++++++++++ drivers/net/ethernet/xilinx/tsn/xilinx_tsn_main.c | 3 + 4 files changed, 162 insertions(+), 1 deletion(-)
drivers/net/ethernet/xilinx/tsn/Makefile +1 -1
@@ -1,2 +1,2 @@ obj-$(CONFIG_XILINX_TSN) += xilinx_tsn.o -xilinx_tsn-y := xilinx_tsn_main.o +xilinx_tsn-y := xilinx_tsn_main.o xilinx_tsn_ep.o
drivers/net/ethernet/xilinx/tsn/xilinx_tsn.h new file +15 -0
@@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* AMD/Xilinx TSN Endpoint Ethernet MAC driver, shared definitions. +* +* Copyright (C) 2026 Advanced Micro Devices, Inc. +*/ + +#ifndef _XILINX_TSN_H +#define _XILINX_TSN_H + +#include <linux/platform_device.h> + +extern struct platform_driver xlnx_tsn_ep_driver; + +#endif /* _XILINX_TSN_H */
drivers/net/ethernet/xilinx/tsn/xilinx_tsn_ep.c new file +143 -0
143 lines not on this page · raw message
drivers/net/ethernet/xilinx/tsn/xilinx_tsn_main.c +3 -0
@@ -15,6 +15,8 @@#include <linux/slab.h> #include <linux/types.h> +#include "xilinx_tsn.h" +#define TSN_NUM_CLOCKS 6/**
@@ -85,6 +87,7 @@ static struct platform_driver tsn_driver = {static struct platform_driver *const tsn_drivers[] = { &tsn_driver, + &xlnx_tsn_ep_driver, };static int __init xlnx_tsn_init (void )
Signature · 1 line
2.43.0
PATCH v4 4/8 net: xilinx: tsn: parse endpoint DMA channel configuration
In reply to Srinivas NeeliThe endpoint has one MCDMA channel per TX queue and per RX queue, and the device tree lists them in "dma-names". The transmit path needs to know which channel backs each logical TX queue.
Count the TX and RX channels in "dma-names" and allocate the conduit netdev with that many hardware queues. Parse the "tx-queues-config" child node to map each logical TX queue to its channel.
The device tree describes one "queueN" child per TX channel under "tx-queues-config". Each child names its channel with "xlnx,dma-channel-num", given as the N of the tx_chanN entry in "dma-names". Every logical TX queue must be described exactly once and name a distinct channel that "dma-names" lists, and the TX channel count must equal "xlnx,num-priorities" on the parent IP node. Probe fails with dev_err_probe() when any of that does not hold.
---
Changes in v4:
- Use alloc_etherdev_mqs() so the standard eth%d name is registered with NET_NAME_ENUM while preserving the TX and RX queue counts.
- Reject xlnx,num-priorities outside the 2..8 range the binding allows. A value of 1 used to probe with a single TX queue.
Changes in v3:
- State the device tree requirements in the commit body. One "queueN" child per TX channel naming its channel with "xlnx,dma-channel-num", every TX queue described exactly once, and the TX channel count equal to "xlnx,num-priorities". They were only in the v2 changelog before.
- Correct the kernel-doc for tx_dma_chan_map. It holds the N of a tx_chanN entry in "dma-names", not a hardware channel number.
- Name the counting helper ep_count_dma_channels() and its probe results num_tx_dma_channels and num_rx_dma_channels. Both count MCDMA channels listed in "dma-names", which "queues" did not convey.
- Call the RX map rx_dma_chan_map, matching tx_dma_chan_map. Both hold the N of a chanN entry in "dma-names", so one concept now has one name.
- Keep the RX map in a probe local rather than copying it into the private struct. Nothing outside probe reads it.
Changes in v2:
- Check xlnx,dma-channel-num against the channels that dma-names actually lists, using a presence bitmask. Reject duplicates and out-of-range channels, and index the channel arrays by logical queue.
- Require one queue node per tx_chan and num-priorities equal to the TX channel count. This also gives xlnx,num-priorities a consumer.
- Cap TX and RX at 8 to match the binding.
- Error out on an unknown dma-names entry instead of skipping it.
- Drop the unreachable TX and RX count guards. The in-loop index and duplicate checks already bound the count, so the channel arrays cannot be over-indexed.
--- drivers/net/ethernet/xilinx/tsn/xilinx_tsn_ep.c | 203 +++++++++++++++++++++++- 1 file changed, 202 insertions(+), 1 deletion(-)
drivers/net/ethernet/xilinx/tsn/xilinx_tsn_ep.c +202 -1
@@ -5,9 +5,11 @@* Copyright (C) 2026 Advanced Micro Devices, Inc. */ +#include <linux/bitops.h> #include <linux/etherdevice.h> #include <linux/ethtool.h> #include <linux/if_ether.h> +#include <linux/if_vlan.h> #include <linux/kernel.h> #include <linux/module.h> #include <linux/netdevice.h>
@@ -21,14 +23,31 @@#define DRIVER_NAME "xilinx_tsn_ep" +#define TSN_DMA_CH_INVALID 0xFFU +#define TSN_MIN_PRIORITIES 2 +#define TSN_MAX_TX_QUEUE 8 +#define TSN_MAX_RX_QUEUE 8 + +#define TSN_MAX_VLAN_FRAME_SIZE (ETH_DATA_LEN + VLAN_ETH_HLEN + \ + ETH_FCS_LEN) +/** * struct xlnx_tsn_ep - EP MAC private data, embedded in net_device priv area * @ndev: the conduit netdev * @dev: backing device +* @num_tx_queues: number of TX DMA channels (one per priority) +* @num_rx_queues: number of RX DMA channels +* @tx_dma_chan_map: TX queue to tx_chanN map, or TSN_DMA_CH_INVALID when +* the queue has no channel +* @max_frm_size: maximum frame size accepted on RX */ struct xlnx_tsn_ep {struct net_device *ndev;struct device *dev; +u32 num_tx_queues; +u32 num_rx_queues; +u32 tx_dma_chan_map[TSN_MAX_TX_QUEUE ]; +u32 max_frm_size; };static netdev_tx_t ep_start_xmit (struct sk_buff *skb,struct net_device *ndev)
@@ -69,15 +88,180 @@ static const struct ethtool_ops ep_ethtool_ops = { .get_drvinfo = ep_get_drvinfo, }; +/* +* Parse the "tx-queues-config" child of the EP node. The logical queue +* index is taken from the "queue<N>" node name, so the mapping does not +* depend on the order the child nodes appear in the device tree. +*/ +static int ep_parse_tx_queue_config (struct xlnx_tsn_ep *ep, +struct device_node *txcfg_np,u16 tx_present) +{ + DECLARE_BITMAP(queue_seen, TSN_MAX_TX_QUEUE) = {}; + DECLARE_BITMAP(chan_seen, TSN_MAX_TX_QUEUE) = {}; +unsigned int count =0 ; +int ret; + +for_each_child_of_node_scoped (txcfg_np, qnode) { +u32 chan, queue; + +if (!str_has_prefix (qnode->name,"queue" ) || +kstrtou32 (qnode->name +strlen ("queue" ),10 , &queue) || + queue >= ep->num_tx_queues) +return dev_err_probe (ep->dev, -EINVAL , +"tx-config: invalid queue node %pOFn (have %u queues)\n" , + qnode, ep->num_tx_queues); + +if (test_and_set_bit (queue, queue_seen)) +return dev_err_probe (ep->dev, -EINVAL , +"tx-config: queue %u described twice\n" , + queue); + + ret =of_property_read_u32 (qnode,"xlnx,dma-channel-num" , &chan); +if (ret) +return dev_err_probe (ep->dev, ret, +"tx-config: queue %u missing xlnx,dma-channel-num\n" , + queue); + +if (chan >=TSN_MAX_TX_QUEUE || !(tx_present &BIT (chan))) +return dev_err_probe (ep->dev, -EINVAL , +"tx-config: queue %u maps to channel %u not present in dma-names\n" , + queue, chan); + +if (test_and_set_bit (chan, chan_seen)) +return dev_err_probe (ep->dev, -EINVAL , +"tx-config: channel %u already assigned to another queue\n" , + chan); + + ep->tx_dma_chan_map[queue] = chan; + count++; + } + +if (count != ep->num_tx_queues) +return dev_err_probe (ep->dev, -EINVAL , +"tx-config: described %u queues but expected %u\n" , + count, ep->num_tx_queues); + +return 0 ; +} + +static int ep_count_dma_channels (struct device *dev,u32 *out_tx,u32 *out_rx, +u16 *tx_present,u32 *rx_dma_chan_map) +{ +u32 tx =0 , rx =0 ; +u16 rx_present =0 ; +int n, i, ret; + + n =of_property_count_strings (dev->of_node,"dma-names" ); +if (n <0 ) +return dev_err_probe (dev, n,"failed to read dma-names\n" ); + +for (i =0 ; i < n; i++) { +const char *name; +size_t plen; +u32 idx; + + ret =of_property_read_string_index (dev->of_node,"dma-names" , + i, &name); +if (ret) +return dev_err_probe (dev, ret, +"failed to read dma-names[%d]\n" , i); + + plen =str_has_prefix (name,"tx_chan" ); +if (plen) { +if (kstrtou32 (name + plen,10 , &idx) || + idx >=TSN_MAX_TX_QUEUE ) +return dev_err_probe (dev, -EINVAL , +"invalid TX channel name %s\n" , + name); + +if (*tx_present &BIT (idx)) +return dev_err_probe (dev, -EINVAL , +"duplicate TX channel %s\n" , + name); + + *tx_present |=BIT (idx); + tx++; +continue ; + } + + plen =str_has_prefix (name,"rx_chan" ); +if (plen) { +if (kstrtou32 (name + plen,10 , &idx) || + idx >=TSN_MAX_RX_QUEUE ) +return dev_err_probe (dev, -EINVAL , +"invalid RX channel name %s\n" , + name); + +if (rx_present &BIT (idx)) +return dev_err_probe (dev, -EINVAL , +"duplicate RX channel %s\n" , + name); + + rx_present |=BIT (idx); + rx_dma_chan_map[rx] = idx; + rx++; +continue ; + } + +return dev_err_probe (dev, -EINVAL , +"unrecognised dma-names entry %s\n" , name); + } + +if (!tx) +return dev_err_probe (dev, -EINVAL , +"no TX channels in dma-names\n" ); + +if (!rx) +return dev_err_probe (dev, -EINVAL , +"no RX channels in dma-names\n" ); + + *out_tx = tx; + *out_rx = rx; + +return 0 ; +} +static int xlnx_tsn_ep_probe (struct platform_device *pdev) { +u32 num_tx_dma_channels, num_rx_dma_channels, num_prio; +u32 rx_dma_chan_map[TSN_MAX_RX_QUEUE ];struct device *dev = &pdev->dev; +struct device_node *txcfg_np; +struct device_node *ip_np;struct net_device *ndev;struct xlnx_tsn_ep *ep;u8 mac_addr[ETH_ALEN ]; +u16 tx_present =0 ;int ret; +int i; + + ret =ep_count_dma_channels (dev, &num_tx_dma_channels, + &num_rx_dma_channels, &tx_present, + rx_dma_chan_map); +if (ret) +return ret; + + ip_np =of_get_parent (dev->of_node); +if (!ip_np) +return dev_err_probe (dev, -EINVAL ,"missing parent IP node\n" ); + + ret =of_property_read_u32 (ip_np,"xlnx,num-priorities" , &num_prio); +of_node_put (ip_np); +if (ret) +return dev_err_probe (dev, ret,"missing xlnx,num-priorities\n" ); + +if (num_prio <TSN_MIN_PRIORITIES || num_prio >TSN_MAX_TX_QUEUE ) +return dev_err_probe (dev, -EINVAL , +"invalid xlnx,num-priorities %u\n" , + num_prio); - ndev =alloc_etherdev (sizeof (*ep)); +if (num_tx_dma_channels != num_prio) +return dev_err_probe (dev, -EINVAL , +"TX channel count %u must equal num-priorities %u\n" , + num_tx_dma_channels, num_prio); + + ndev =alloc_etherdev_mqs (sizeof (*ep), num_tx_dma_channels, + num_rx_dma_channels);if (!ndev)return -ENOMEM ;
@@ -89,6 +273,23 @@ static int xlnx_tsn_ep_probe(struct platform_device *pdev) ep =netdev_priv (ndev); ep->ndev = ndev; ep->dev = dev; + ep->num_tx_queues = num_tx_dma_channels; + ep->num_rx_queues = num_rx_dma_channels; + ep->max_frm_size =TSN_MAX_VLAN_FRAME_SIZE ; + +for (i =0 ; i <TSN_MAX_TX_QUEUE ; i++) + ep->tx_dma_chan_map[i] =TSN_DMA_CH_INVALID ; + + txcfg_np =of_get_child_by_name (dev->of_node,"tx-queues-config" ); +if (!txcfg_np) { + ret =dev_err_probe (dev, -EINVAL , +"missing tx-queues-config node\n" ); + goto err_free_ndev; + } + ret =ep_parse_tx_queue_config (ep, txcfg_np, tx_present); +of_node_put (txcfg_np); +if (ret) + goto err_free_ndev; ret =of_get_mac_address (dev->of_node, mac_addr);if (ret == -EPROBE_DEFER ) {
Signature · 1 line
2.43.0
[email protected]
AI reviewRe: [PATCH net-next v4 4/8] net: xilinx: tsn: parse endpoint DMA channel configuration
Thank you for your contribution! Sashiko AI review found more severe issue(s) in other patches of this series. This mail is only an FYI, in case you want to address the nit picks below when you…
Thank you for your contribution! Sashiko AI review found more severe issue(s) in other patches of this series. This mail is only an FYI, in case you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] The driver requires the number of tx_chanN entries in "dma-names" to equal "xlnx,num-priorities", but the DT binding does not encode or…
--
net: xilinx: tsn: parse endpoint DMA channel configuration
This patch counts the tx_chanN and rx_chanN entries in dma-names and allocates the conduit netdev with that many TX and RX queues. It parses the tx-queues-config child node to map each logical TX queue to a TX DMA channel. Probe also requires the TX channel count to equal xlnx,num-priorities on the parent IP node.
Quoted 4 lines
drivers/net/ethernet/xilinx/tsn/xilinx_tsn_ep.c +0
-0
[ ... ]
Quoted 1 line
drivers/net/ethernet/xilinx/tsn/xilinx_tsn_ep.c +0
-0@@ -69,15 +88,180 @@ static const struct ethtool_ops ep_ethtool_ops = {
[ ... ]
Quoted 2 lines
static int
xlnx_tsn_ep_probe(struct platform_device *pdev){
[ ... ]
Quoted 5 lines
drivers/net/ethernet/xilinx/tsn/xilinx_tsn_ep.c +5
-0+ ret =of_property_read_u32 (ip_np,"xlnx,num-priorities" , &num_prio); +of_node_put (ip_np); +if (ret) +return dev_err_probe (dev, ret,"missing xlnx,num-priorities\n" ); +
drivers/net/ethernet/xilinx/tsn/xilinx_tsn_ep.c static const struct ethtool_ops ep_ethtool_ops = { · line 261
Quoted 10 lines
drivers/net/ethernet/xilinx/tsn/xilinx_tsn_ep.c +8
-1+if (num_prio <TSN_MIN_PRIORITIES || num_prio >TSN_MAX_TX_QUEUE ) +return dev_err_probe (dev, -EINVAL , +"invalid xlnx,num-priorities %u\n" , + num_prio); - ndev =alloc_etherdev (sizeof (*ep)); +if (num_tx_dma_channels != num_prio) +return dev_err_probe (dev, -EINVAL , +"TX channel count %u must equal num-priorities %u\n" , + num_tx_dma_channels, num_prio);
[Severity: Low]
Is this equality check stricter than what the binding in xlnx,tsn-endpoint-ethernet-mac.yaml allows?
The binding says the following and nothing more:
- each dma-names item matches "^(tx|rx)_chan[0-7]$"
- there are 2..16 items, with at least one TX and one RX entry
- each queueN under tx-queues-config maps to a distinct TX channel listed in dma-names
Taken together, these rules only require the TX channel count to be at least xlnx,num-priorities. They don't require it to be equal.
For example, this DT looks valid against the schema:
xlnx,num-priorities = <2>;
...
dma-names = "tx_chan0", "tx_chan1", "tx_chan2", "rx_chan0";
tx-queues-config {
queue0 { xlnx,dma-channel-num = <0>; };
queue1 { xlnx,dma-channel-num = <1>; };
};But xlnx_tsn_ep_probe()->ep_count_dma_channels() counts three TX channels, and probe then fails with:
TX channel count 3 must equal num-priorities 2
The commit message says equality is the intended rule. Should the binding state or enforce that in the xlnx,num-priorities or dma-names descriptions? Or should the driver accept extra TX channels that no queue uses?
Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261113-patches_v2_external-v4-0-56bb26f042a4%40amd.com
PATCH v4 5/8 net: xilinx: tsn: bring up the endpoint MCDMA channels
In reply to Srinivas NeeliBefore the endpoint can move frames, each MCDMA channel needs a ring of buffers and a live dmaengine channel.
Request every TX and RX channel named in the device tree at probe and hold them for the lifetime of the device. dma_request_chan() returns -EPROBE_DEFER until the MCDMA provider is bound, and probe is the only context the driver core retries, so acquiring the channels here keeps the deferral where it can be handled. Holding them also pins the provider, so the channels cannot go away while the interface is down.
Reset the controller once at probe through the first held TX channel. An MCDMA soft reset resets the whole core, so any channel of the instance reaches it.
Give each channel a ring of preallocated SKB descriptor slots when the interface opens, and tear the rings down on stop, where dmaengine_terminate_sync() returns each channel to a clean state. Add the XILINX_DMA dependency for the dmaengine and Xilinx DMA APIs.
---
Changes in v4:
- Describe @dma_address as the DMA address of the first sgl entry. It holds a dma_addr_t from the DMA mapping, not a physical address.
Changes in v3:
- Acquire every TX and RX channel in probe and hold them until remove. ndo_open now only builds the rings. dma_request_chan() is the call that can return -EPROBE_DEFER and probe is the only context the driver core retries, so the deferral no longer has to be translated in ndo_open. Holding the channels also pins the MCDMA provider, so it cannot go away while the interface is down.
- Reset the controller through the first held TX channel instead of requesting and releasing a channel for the reset alone.
- Move the closing flag (field, kernel-doc and its ndo_open/ndo_stop writes) to the RX data path patch, where it is first read. Drop the unused io.h include and move circ_buf.h and spinlock.h to the RX patch that first uses CIRC_SPACE() and spinlock_t.
- Reword the commit description for the probe-time channel acquisition.
Changes in v2:
- Request a channel at probe time so -EPROBE_DEFER stays in the probe path and ndo_open never hands a deferral back to userspace.
- Request the channels by their real dma-names index, not a dense 0..N-1 sequence.
- Reword the commit message so the reset reads as probe-time through the first mapped TX channel, not on open.
--- drivers/net/ethernet/xilinx/tsn/Kconfig | 1 + drivers/net/ethernet/xilinx/tsn/xilinx_tsn_ep.c | 316 +++++++++++++++++++++++- 2 files changed, 315 insertions(+), 2 deletions(-)
drivers/net/ethernet/xilinx/tsn/Kconfig +1 -0
@@ -6,6 +6,7 @@ config XILINX_TSN tristate "Xilinx TSN Ethernet driver" depends on OF_ADDRESS + depends on XILINX_DMA help This driver supports the AMD/Xilinx Time-Sensitive Networking (TSN) Endpoint Ethernet MAC IP. It provides the wrapper device
drivers/net/ethernet/xilinx/tsn/xilinx_tsn_ep.c +314 -2
393 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH v4 6/8 net: xilinx: tsn: add the endpoint RX data path
In reply to Srinivas NeeliWith the RX channels armed, the endpoint can start receiving frames.
Post RX buffers to every RX channel on open and reap them from the completion callback. Each inbound frame carries a TUSER port_id in the descriptor sideband. Accept frames from MAC1 (port_id 1) and MAC2 (port_id 2) and pass them up the stack. Drop any other port_id, since the bridged-only model never produces it. Drop and count frames with bad descriptor status, an invalid length or no metadata pointer.
Refill each slot from the completion callback unless the interface is closing, which keeps the ring full without a separate refill worker.
Serialise the RX refill against teardown. The completion callback re-arms the ring, so ndo_stop() sets a closing flag before teardown and the refill tests it under the per-channel lock. ep_free_dma_chan() then takes that lock as a barrier, so any refill already past the closing test finishes and no later one submits or arms the timer before the channel is terminated. No descriptor is submitted once teardown has begun, so a single dmaengine_terminate_sync() is enough to quiesce the channel.
The RX path uses __netif_rx() from the dmaengine completion callback rather than NAPI. dmaengine owns the RX interrupt and ring and delivers one descriptor per callback, so there is no poll context to run NAPI or GRO, and the per-packet counters use the dev->stats atomics.
---
Changes in v4:
- Return true from ep_rx_refill() when this call submitted at least one descriptor. The completion callback advances ring_tail without rx_lock, so a descriptor could complete before the ring_head != ring_tail test and make ndo_open() fail with -ENOMEM.
- Use dev_dbg_ratelimited() for the unexpected port_id message, so it does not consume the shared net_ratelimit() budget, and replace the redundant CHECKSUM_NONE store with skb_checksum_none_assert().
Changes in v3:
- Check the dmaengine_submit() cookie in ep_rx_submit_desc(). Store the skb and submit, then advance ring_head only once dma_submit_error() is clear. On a submit failure clear the slot, unmap and free the buffer and return the error, so a failed descriptor can no longer pin its buffer or be read back by a later completion.
- Use scoped_guard() instead of guard() in ep_rx_refill() for the rx_lock, per the netdev cleanup.h guidance (guard() is discouraged in functions longer than 20 lines).
- Introduce the closing flag here (field, kernel-doc and the ndo_open/ndo_stop writes), together with its first reader in the RX refill path. It was added in the MCDMA bring-up patch before it had a consumer. Add the circ_buf.h and spinlock.h includes here, where CIRC_SPACE() and spinlock_t are first used.
- Reword the commit message to describe how the closing flag is published and tested, rather than stating that ndo_stop() sets it under the per-channel lock.
Changes in v2:
- Serialise the RX refill against teardown under a per-channel rx_lock. The completion callback re-arms the ring, so ndo_stop() sets a closing flag under the same lock and ep_free_dma_chan() takes it as a barrier before terminating.
- Recover a drained ring with a refill timer instead of leaving RX dead after an allocation failure.
- Fail ndo_open if a channel cannot arm any RX descriptor.
- Set the closing flag on the ndo_open error path too, before tearing the channels down.
- Take the ring size from the channel instead of a compile-time constant.
- Note in the commit message why RX is not NAPI based. dmaengine owns the RX interrupt and ring and delivers one descriptor per callback, so there is no poll context for NAPI or GRO, and the counters use the dev->stats atomics.
- Shut the refill timer down with timer_shutdown_sync() at teardown rather than relying on timer_delete_sync() plus the closing flag.
- Return true from ep_rx_refill() when at least one descriptor is armed, false otherwise, following the usual bool convention.
- Init the refill timer and rx_lock only for RX channels.
--- drivers/net/ethernet/xilinx/tsn/xilinx_tsn_ep.c | 230 +++++++++++++++++++++++- 1 file changed, 229 insertions(+), 1 deletion(-)
drivers/net/ethernet/xilinx/tsn/xilinx_tsn_ep.c +229 -1
@@ -5,7 +5,9 @@* Copyright (C) 2026 Advanced Micro Devices, Inc. */ +#include <linux/bitfield.h> #include <linux/bitops.h> +#include <linux/circ_buf.h> #include <linux/dma/xilinx_dma.h> #include <linux/dma-mapping.h> #include <linux/dmaengine.h>
@@ -21,7 +23,9 @@#include <linux/platform_device.h> #include <linux/scatterlist.h> #include <linux/slab.h> +#include <linux/spinlock.h> #include <linux/string.h> +#include <linux/timer.h> #include <linux/types.h> #include "xilinx_tsn.h"
@@ -39,6 +43,19 @@#define TX_BD_NUM_DEFAULT 64#define RX_BD_NUM_DEFAULT 128 +#define EP_RX_REFILL_RETRY msecs_to_jiffies(10) + +/* +* The DMA descriptor sideband status word packs TID/TDEST/TUSER together; +* TUSER occupies the low byte, TID/TDEST sit in the upper bits. +*/ +#define TSN_TUSER_MASK GENMASK(7, 0) +/* TUSER Input Port ID field (bits [5:4] of the TUSER field) */ +#define TSN_TUSER_PORT_ID_MASK GENMASK(5, 4) +#define TSN_TUSER_PORT_EP 0x0 +#define TSN_TUSER_PORT_MAC1 0x1 +#define TSN_TUSER_PORT_MAC2 0x2 +/** * struct skbuf_dma_descriptor - skb container for each in-flight DMA descriptor * @sgl: scatter-gather list backing the DMA mapping
@@ -64,6 +81,8 @@ struct skbuf_dma_descriptor {* @ring_head: producer index * @ring_tail: consumer index * @ring_size: number of slots in @skb_ring +* @rx_lock: serialises @ring_head between the RX callback and the refill timer +* @rx_refill_timer: retries RX refill after an allocation failure * @is_tx: true for TX channels, false for RX */ struct xlnx_tsn_ep_dma_chan {
@@ -74,6 +93,8 @@ struct xlnx_tsn_ep_dma_chan {u32 ring_head;u32 ring_tail;u32 ring_size; +spinlock_t rx_lock;/* serialises @ring_head */ +struct timer_list rx_refill_timer;bool is_tx; };
@@ -90,6 +111,7 @@ struct xlnx_tsn_ep_dma_chan {* @rx_dma: dmaengine RX channels, held from probe until remove * @tx_chans: array of TX channels (size @num_tx_queues) * @rx_chans: array of RX channels (size @num_rx_queues) +* @closing: set in ndo_stop so the RX completion callback stops re-arming */ struct xlnx_tsn_ep {struct net_device *ndev;
@@ -105,6 +127,7 @@ struct xlnx_tsn_ep {struct xlnx_tsn_ep_dma_chan **tx_chans;struct xlnx_tsn_ep_dma_chan **rx_chans; +bool closing; }; static inline struct skbuf_dma_descriptor *
@@ -113,6 +136,181 @@ ep_get_desc(struct xlnx_tsn_ep_dma_chan *xchan, int idx)return xchan->skb_ring[idx]; } +static void ep_dma_rx_cb (void *data,const struct dmaengine_result *result); + +static int ep_rx_submit_desc (struct xlnx_tsn_ep_dma_chan *xchan) +{ +struct dma_async_tx_descriptor *dma_rx_desc; +struct skbuf_dma_descriptor *skbuf_dma; +struct xlnx_tsn_ep *ep = xchan->ep; +struct sk_buff *skb; +dma_cookie_t cookie; +dma_addr_t addr; + + skbuf_dma =ep_get_desc (xchan, xchan->ring_head & (xchan->ring_size -1 )); +if (!skbuf_dma) +return -ENOSPC ; + + skb =dev_alloc_skb (ep->max_frm_size); +if (!skb) +return -ENOMEM ; + +sg_init_table (skbuf_dma->sgl,1 ); + addr =dma_map_single (xchan->dma_dev, skb->data, ep->max_frm_size, +DMA_FROM_DEVICE ); +if (unlikely (dma_mapping_error (xchan->dma_dev, addr))) { +if (net_ratelimit ()) +dev_warn (ep->dev,"DMA mapping error on RX submit\n" ); + + goto err_free_skb; + } +sg_dma_address (skbuf_dma->sgl) = addr; +sg_dma_len (skbuf_dma->sgl) = ep->max_frm_size; + dma_rx_desc =dmaengine_prep_slave_sg (xchan->chan, skbuf_dma->sgl, +1 ,DMA_DEV_TO_MEM , +DMA_PREP_INTERRUPT ); +if (!dma_rx_desc) + goto err_unmap_skb; + + skbuf_dma->dma_address =sg_dma_address (skbuf_dma->sgl); + skbuf_dma->desc = dma_rx_desc; + dma_rx_desc->callback_param = xchan; + dma_rx_desc->callback_result = ep_dma_rx_cb; + + skbuf_dma->skb = skb; + cookie =dmaengine_submit (dma_rx_desc); +if (dma_submit_error (cookie)) { + skbuf_dma->skb =NULL ; + goto err_unmap_skb; + } + xchan->ring_head++; + +return 0 ; + +err_unmap_skb: +dma_unmap_single (xchan->dma_dev, addr, ep->max_frm_size,DMA_FROM_DEVICE ); +err_free_skb: +dev_kfree_skb (skb); +return -ENOMEM ; +} + +static bool ep_rx_refill (struct xlnx_tsn_ep_dma_chan *xchan,bool arm_timer) +{ +int avail, i; + + scoped_guard(spinlock_bh, &xchan->rx_lock) { +if (READ_ONCE (xchan->ep->closing)) +return false; + + avail =CIRC_SPACE (xchan->ring_head,READ_ONCE (xchan->ring_tail), + xchan->ring_size); +for (i =0 ; i < avail; i++) { +if (ep_rx_submit_desc (xchan)) +break ; + } +dma_async_issue_pending (xchan->chan); + +if (i >0 || xchan->ring_head !=READ_ONCE (xchan->ring_tail)) +return true; + +if (arm_timer) +mod_timer (&xchan->rx_refill_timer, + jiffies +EP_RX_REFILL_RETRY ); + } + +return false; +} + +static void ep_rx_refill_timer (struct timer_list *t) +{ +struct xlnx_tsn_ep_dma_chan *xchan =timer_container_of (xchan, t, + rx_refill_timer); + +ep_rx_refill (xchan, true); +} + +static void ep_dma_rx_cb (void *data,const struct dmaengine_result *result) +{ +struct xlnx_tsn_ep_dma_chan *xchan = data; +struct skbuf_dma_descriptor *skbuf_dma; +size_t meta_len, meta_max_len, rx_len; +struct xlnx_tsn_ep *ep = xchan->ep; +struct net_device *ndev = ep->ndev; +struct sk_buff *skb; +u32 port_id, tuser; +u32 *metadata; + + skbuf_dma =ep_get_desc (xchan, xchan->ring_tail & (xchan->ring_size -1 )); +WRITE_ONCE (xchan->ring_tail, xchan->ring_tail +1 ); + skb = skbuf_dma->skb; + skbuf_dma->skb =NULL ; + +dma_unmap_single (xchan->dma_dev, skbuf_dma->dma_address, + ep->max_frm_size,DMA_FROM_DEVICE ); + +if (result->result !=DMA_TRANS_NOERROR ) { +if (net_ratelimit ()) +dev_warn (ep->dev,"RX DMA transfer error %d\n" , + result->result); + +dev_kfree_skb_any (skb); +DEV_STATS_INC (ndev, rx_dropped); +DEV_STATS_INC (ndev, rx_errors); + goto submit_new; + } + + metadata =dmaengine_desc_get_metadata_ptr (skbuf_dma->desc, + &meta_len, + &meta_max_len); +if (IS_ERR_OR_NULL (metadata)) { +if (net_ratelimit ()) +dev_warn (ep->dev,"Failed to get RX metadata pointer\n" ); + +dev_kfree_skb_any (skb); +DEV_STATS_INC (ndev, rx_dropped); +DEV_STATS_INC (ndev, rx_errors); + goto submit_new; + } + +/* MCDMA metadata: [0] = status, [1] = sideband (TID/TDEST/TUSER), [2..] = app */ + tuser = metadata[1 ] &TSN_TUSER_MASK ; + rx_len = ep->max_frm_size - result->residue; + +if (rx_len > ep->max_frm_size || rx_len <ETH_HLEN ) { +if (net_ratelimit ()) +dev_warn (ep->dev,"Invalid RX length %zu (max=%u, min=%u)\n" , + rx_len, ep->max_frm_size,ETH_HLEN ); + +dev_kfree_skb_any (skb); +DEV_STATS_INC (ndev, rx_dropped); +DEV_STATS_INC (ndev, rx_errors); + goto submit_new; + } + + port_id =FIELD_GET (TSN_TUSER_PORT_ID_MASK , tuser); +if (port_id !=TSN_TUSER_PORT_MAC1 && port_id !=TSN_TUSER_PORT_MAC2 ) { +dev_dbg_ratelimited (ep->dev, +"RX dropping unexpected TUSER port_id=%u\n" , + port_id); + +dev_kfree_skb_any (skb); +DEV_STATS_INC (ndev, rx_dropped); + goto submit_new; + } + +skb_put (skb, rx_len); + skb->dev = ndev; + skb->protocol =eth_type_trans (skb, ndev); +skb_checksum_none_assert (skb); +__netif_rx (skb); + +DEV_STATS_INC (ndev, rx_packets); +DEV_STATS_ADD (ndev, rx_bytes, rx_len); + +submit_new: +ep_rx_refill (xchan, true); +} +static netdev_tx_t ep_start_xmit (struct sk_buff *skb,struct net_device *ndev) {dev_kfree_skb_any (skb);
@@ -128,6 +326,8 @@ static int ep_open(struct net_device *ndev)struct xlnx_tsn_ep *ep =netdev_priv (ndev);int ret; +WRITE_ONCE (ep->closing, false); + ret =ep_init_dmaengine (ep);if (ret) {netdev_err (ndev,"failed to initialize DMA engine\n" );
@@ -145,6 +345,7 @@ static int ep_stop(struct net_device *ndev)struct xlnx_tsn_ep *ep =netdev_priv (ndev);netif_tx_disable (ndev); +WRITE_ONCE (ep->closing, true);ep_exit_dmaengine (ep);return 0 ;
@@ -201,6 +402,10 @@ ep_alloc_dma_chan(struct xlnx_tsn_ep *ep, struct dma_chan *dma_chan, chan->ep = ep; chan->ring_size = ring_size; chan->dma_dev =dmaengine_get_dma_device (chan->chan); +if (!is_tx) { +spin_lock_init (&chan->rx_lock); +timer_setup (&chan->rx_refill_timer, ep_rx_refill_timer,0 ); + }return chan; }
@@ -212,8 +417,21 @@ static void ep_free_dma_chan(struct xlnx_tsn_ep_dma_chan *chan)if (!chan)return ; -if (chan->chan) +if (chan->chan) { +if (!chan->is_tx) { +/* ep_stop() sets closing before teardown. Take rx_lock +* so any refill that already passed the closing check +* finishes and no later one submits or arms the timer, +* then shut down the timer so it cannot be rearmed +* before the channel is freed. +*/ +spin_lock_bh (&chan->rx_lock); +spin_unlock_bh (&chan->rx_lock); +timer_shutdown_sync (&chan->rx_refill_timer); + } +dmaengine_terminate_sync (chan->chan); + }if (chan->is_tx) {while (chan->ring_tail != chan->ring_head) {
@@ -306,9 +524,19 @@ static int ep_init_dmaengine(struct xlnx_tsn_ep *ep) rx_allocated++; } +for (i =0 ; i < ep->num_rx_queues; i++) { +if (!ep_rx_refill (ep->rx_chans[i], false)) { +dev_err (ep->dev,"RX channel %d: no descriptors armed\n" , + i); + ret = -ENOMEM ; + goto err_free_chans; + } + } +return 0 ; err_free_chans: +WRITE_ONCE (ep->closing, true);while (--rx_allocated >=0 )ep_free_dma_chan (ep->rx_chans[rx_allocated]);while (--tx_allocated >=0 )
Signature · 1 line
2.43.0
[email protected]
AI reviewRe: [PATCH net-next v4 6/8] net: xilinx: tsn: add the endpoint RX data path
Thank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [Medium] net: xilinx: tsn: RX stall from MCDMA IRQ coalescing in ep_rx_refill() - [Medium] net: xilinx…
Thank you for your contribution! Sashiko AI review found 2 potential issues to consider:
- [Medium] net: xilinx: tsn: RX stall from MCDMA IRQ coalescing in ep_rx_refill()
- [Medium] net: xilinx: tsn: permanent RX stall after MCDMA error interrupt
--
commit 8a8c3c55f7d1afb981a05d0249b531e8e8eb911c
Author: Srinivas Neeli <[email protected]>
net: xilinx: tsn: add the endpoint RX data path
This commit adds the endpoint RX data path, posting RX buffers to the MCDMA channels, handling completion callbacks with TUSER port_id filtering, and refilling the RX ring under a per-channel lock.
Quoted 4 lines
drivers/net/ethernet/xilinx/tsn/xilinx_tsn_ep.c +0
-0
[ ... ]
Quoted 1 line
drivers/net/ethernet/xilinx/tsn/xilinx_tsn_ep.c +0
-0@@ -113,6 +136,181 @@ ep_get_desc(struct xlnx_tsn_ep_dma_chan *xchan, int idx)
[ ... ]
Quoted 5 lines
drivers/net/ethernet/xilinx/tsn/xilinx_tsn_ep.c +5
-0+static bool ep_rx_refill (struct xlnx_tsn_ep_dma_chan *xchan,bool arm_timer) +{ +int avail, i; + + scoped_guard(spinlock_bh, &xchan->rx_lock) {
drivers/net/ethernet/xilinx/tsn/xilinx_tsn_ep.c ep_get_desc(struct xlnx_tsn_ep_dma_chan *xchan, int idx) · line 211
Quoted 10 lines
drivers/net/ethernet/xilinx/tsn/xilinx_tsn_ep.c +10
-0+if (READ_ONCE (xchan->ep->closing)) +return false; + + avail =CIRC_SPACE (xchan->ring_head,READ_ONCE (xchan->ring_tail), + xchan->ring_size); +for (i =0 ; i < avail; i++) { +if (ep_rx_submit_desc (xchan)) +break ; + } +dma_async_issue_pending (xchan->chan);
[Severity: Medium]
Can calling dma_async_issue_pending() once after submitting a batch of 2 to 24 descriptors stall RX under sparse traffic?
Each ep_rx_submit_desc() increments chan->desc_pendingcount in the MCDMA driver, and dma_async_issue_pending() then programs the channel's hardware interrupt coalescing threshold from that batch count:
drivers/dma/xilinx/xilinx_dma.c:xilinx_mcdma_start_transfer() {
...
if (chan->desc_pendingcount <= XILINX_MCDMA_COALESCE_MAX) {
reg &= ~XILINX_MCDMA_COALESCE_MASK;
reg |= chan->desc_pendingcount <<
XILINX_MCDMA_COALESCE_SHIFT;
}
reg |= XILINX_MCDMA_IRQ_ALL_MASK;
dma_ctrl_write(chan, XILINX_MCDMA_CHAN_CR_OFFSET(chan->tdest), reg);
...
}If ep_rx_refill() submits between 2 and 24 descriptors (for example when multiple descriptors complete before refill runs, or when an allocation fails partway through filling the ring), the hardware waits for that many frames before raising XILINX_MCDMA_IRQ_IOC_MASK, and later batches larger than 24 leave that threshold programmed. Because xilinx_mcdma_irq_handler() does not complete descriptors on XILINX_MCDMA_IRQ_DELAY_MASK, received frames fewer than the coalescing threshold sit in the ring without a completion callback until more traffic arrives.
drivers/net/ethernet/xilinx/tsn/xilinx_tsn_ep.c ep_get_desc(struct xlnx_tsn_ep_dma_chan *xchan, int idx) · line 218
Quoted 7 lines
drivers/net/ethernet/xilinx/tsn/xilinx_tsn_ep.c +7
-0+ +if (i >0 || xchan->ring_head !=READ_ONCE (xchan->ring_tail)) +return true; + +if (arm_timer) +mod_timer (&xchan->rx_refill_timer, + jiffies +EP_RX_REFILL_RETRY );
[Severity: Medium]
Does an MCDMA channel error interrupt wedge the RX queue until the interface is cycled down and up?
When xilinx_mcdma_irq_handler() sees XILINX_MCDMA_IRQ_ERR_MASK without a completed descriptor (XILINX_DMA_BD_COMP_MASK), it sets chan->err = true and leaves the active descriptors on chan->active_list rather than moving them to chan->done_list:
drivers/dma/xilinx/xilinx_dma.c:xilinx_mcdma_irq_handler() {
...
if (status & XILINX_MCDMA_IRQ_ERR_MASK) {
...
chan->err = true;
}
...
if (status & XILINX_MCDMA_IRQ_IOC_MASK) {
spin_lock(&chan->lock);
xilinx_dma_complete_descriptor(chan);
...
}Because nothing lands on chan->done_list, ep_dma_rx_cb() is never called for the in-flight descriptors, xchan->ring_head != xchan->ring_tail remains true, and rx_refill_timer is not armed. No further ep_rx_submit_desc() call runs to trigger xilinx_dma_chan_reset() in xilinx_dma_tx_submit(), leaving RX on that channel halted while the netdev stays up.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=6
[email protected]
AI reviewRe: [PATCH net-next v4 6/8] net: xilinx: tsn: add the endpoint RX data path
In reply to Srinivas NeeliThank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider.
Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider.
Critical: 0 · High: 0 · Medium: 2 · Low: 2
If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough).
- [Medium] In drivers/net/ethernet/xilinx/tsn/xilinx_tsn_ep.c, ep_dma_rx_cb() gets the MCDMA S2MM metadata block (metadata[0] = S2MM…
- [Medium] net: xilinx: tsn: RX stall from MCDMA IRQ coalescing in ep_rx_refill()
- [Low] The RX path needs the dmaengine provider to support DESC_METADATA_ENGINE, and nothing checks for it.
- [Low] The commit message says that refilling from the completion callback "keeps the ring full without a separate refill worker".
--
net: xilinx: tsn: add the endpoint RX data path
This commit adds the RX data path for the Xilinx TSN endpoint driver. RX buffers are posted to every MCDMA RX channel on open and reaped from the dmaengine completion callback, which passes MAC1/MAC2 frames up the stack with __netif_rx() and refills the ring. A per-channel lock and a closing flag keep the refill from racing with teardown.
Quoted 2 lines
Refill each slot from the completion callback unless the interface is closing, which keeps the ring full without a separate refill worker.
[Severity: Low]
Is this description accurate? The patch also adds rx_refill_timer. ep_rx_refill() arms it with mod_timer() when a refill leaves the ring empty. ep_rx_refill_timer() then submits descriptors from timer softirq context.
The commit body never introduces the timer or says when it is armed. The teardown paragraph mentions "the timer" as if it had already been described.
The timer is only explained in the v2 changelog below the '---', which is dropped when the patch is applied. Could the commit message describe the timer-based retry after an allocation failure?
Quoted 4 lines
drivers/net/ethernet/xilinx/tsn/xilinx_tsn_ep.c +0
-0
[ ... ]
Quoted 1 line
drivers/net/ethernet/xilinx/tsn/xilinx_tsn_ep.c +0
-0@@ -113,6 +136,181 @@ ep_get_desc(struct xlnx_tsn_ep_dma_chan *xchan, int idx)
[ ... ]
Quoted 2 lines
drivers/net/ethernet/xilinx/tsn/xilinx_tsn_ep.c +2
-0+static void ep_dma_rx_cb (void *data,const struct dmaengine_result *result) +{
[ ... ]
drivers/net/ethernet/xilinx/tsn/xilinx_tsn_ep.c ep_get_desc(struct xlnx_tsn_ep_dma_chan *xchan, int idx) · line 277
Quoted 3 lines
drivers/net/ethernet/xilinx/tsn/xilinx_tsn_ep.c +3
-0+/* MCDMA metadata: [0] = status, [1] = sideband (TID/TDEST/TUSER), [2..] = app */ + tuser = metadata[1 ] &TSN_TUSER_MASK ; + rx_len = ep->max_frm_size - result->residue;
[Severity: Medium]
Should metadata[0] be checked here too? The comment says it holds the S2MM BD status. Only the sideband word in metadata[1] is read, so the RXSOF/RXEOF bits are never checked.
ep_rx_submit_desc() posts each RX slot as a single buffer of ep->max_frm_size (TSN_MAX_VLAN_FRAME_SIZE, 1522) bytes:
sg_dma_len(skbuf_dma->sgl) = ep->max_frm_size;
If a frame longer than that reaches the S2MM channel, the MCDMA continues it into the next BD. That BD completes as a separate dmaengine descriptor.
On the provider side, xilinx_dma_complete_descriptor() only tests the Cmplt bit and copies the channel-wide chan->err into desc->err. So result->result is DMA_TRANS_NOERROR for both parts. That gives two cases:
- The head BD has residue 0, so rx_len is 1522. It passes the length check and goes up the stack truncated.
- The tail BD starts mid-payload. If rx_len >= ETH_HLEN and its sideband carries port_id 1 or 2, eth_type_trans() reads sender-controlled payload bytes as the MAC header, and then __netif_rx() delivers it.
Could a remote sender use this to inject an L2 frame built from the payload of an oversized outer frame? That frame would be credited to the port_id of a BD that is not the start of the packet.
The driver has no ndo_change_mtu, and nothing in the tree sets the MAC/switch maximum frame size. So what stops a frame over 1522 bytes (QinQ, or an 802.1CB R-TAG plus VLAN) from reaching the DMA? This depends on hardware behaviour that can't be confirmed from the tree.
The commit message also says:
Drop and count frames with bad descriptor status, an invalid length or no metadata pointer.
However, the only status check is result->result. That is the channel-level error, not the per-BD status word.
The later patch "net: xilinx: tsn: deliver endpoint RX frames to DSA user ports" uses this same port_id to pick the DSA user port. So the issue is still there at the end of the series.
[ ... ]
Quoted 4 lines
drivers/net/ethernet/xilinx/tsn/xilinx_tsn_ep.c +0
-0@@ -306,9 +524,19 @@ static int ep_init_dmaengine(struct xlnx_tsn_ep *ep) rx_allocated++; }
drivers/net/ethernet/xilinx/tsn/xilinx_tsn_ep.c static int ep_init_dmaengine(struct xlnx_tsn_ep *ep) · line 536
Quoted 10 lines
drivers/net/ethernet/xilinx/tsn/xilinx_tsn_ep.c +9
-0+for (i =0 ; i < ep->num_rx_queues; i++) { +if (!ep_rx_refill (ep->rx_chans[i], false)) { +dev_err (ep->dev,"RX channel %d: no descriptors armed\n" , + i); + ret = -ENOMEM ; + goto err_free_chans; + } + } +return 0 ;
[Severity: Low]
Should ep_init_dmaengine() check that the RX channels support DESC_METADATA_ENGINE before arming them?
xilinx_dma_probe() only sets DESC_METADATA_ENGINE when the DMA node has the optional xlnx,axistream-connected property:
if (xdev->has_axistream_connected)
xdev->common.desc_metadata_modes = DESC_METADATA_ENGINE;Without that property, desc_check_and_set_metadata_mode() returns -ENOTSUPP. Then dmaengine_desc_get_metadata_ptr() in ep_dma_rx_cb() fails for every descriptor, so every frame is dropped and counted in rx_errors.
ep_rx_refill() still returns true in this case, so ndo_open() succeeds. The only sign of the problem is a rate-limited "Failed to get RX metadata pointer" warning.
Would it be worth adding a dmaengine_is_metadata_mode_supported() check at open or probe time? The new xlnx,tsn-endpoint-ethernet-mac.yaml binding also doesn't say that the MCDMA node needs this property.
[ ... ]
Quoted 172 lines
drivers/net/ethernet/xilinx/tsn/xilinx_tsn_ep.c +168
-0@@ -113,6 +136,181 @@ ep_get_desc(struct xlnx_tsn_ep_dma_chan *xchan, int idx)return xchan->skb_ring[idx]; } +static void ep_dma_rx_cb (void *data,const struct dmaengine_result *result); + +static int ep_rx_submit_desc (struct xlnx_tsn_ep_dma_chan *xchan) +{ +struct dma_async_tx_descriptor *dma_rx_desc; +struct skbuf_dma_descriptor *skbuf_dma; +struct xlnx_tsn_ep *ep = xchan->ep; +struct sk_buff *skb; +dma_cookie_t cookie; +dma_addr_t addr; + + skbuf_dma =ep_get_desc (xchan, xchan->ring_head & (xchan->ring_size -1 )); +if (!skbuf_dma) +return -ENOSPC ; + + skb =dev_alloc_skb (ep->max_frm_size); +if (!skb) +return -ENOMEM ; + +sg_init_table (skbuf_dma->sgl,1 ); + addr =dma_map_single (xchan->dma_dev, skb->data, ep->max_frm_size, +DMA_FROM_DEVICE ); +if (unlikely (dma_mapping_error (xchan->dma_dev, addr))) { +if (net_ratelimit ()) +dev_warn (ep->dev,"DMA mapping error on RX submit\n" ); + + goto err_free_skb; + } +sg_dma_address (skbuf_dma->sgl) = addr; +sg_dma_len (skbuf_dma->sgl) = ep->max_frm_size; + dma_rx_desc =dmaengine_prep_slave_sg (xchan->chan, skbuf_dma->sgl, +1 ,DMA_DEV_TO_MEM , +DMA_PREP_INTERRUPT ); +if (!dma_rx_desc) + goto err_unmap_skb; + + skbuf_dma->dma_address =sg_dma_address (skbuf_dma->sgl); + skbuf_dma->desc = dma_rx_desc; + dma_rx_desc->callback_param = xchan; + dma_rx_desc->callback_result = ep_dma_rx_cb; + + skbuf_dma->skb = skb; + cookie =dmaengine_submit (dma_rx_desc); +if (dma_submit_error (cookie)) { + skbuf_dma->skb =NULL ; + goto err_unmap_skb; + } + xchan->ring_head++; + +return 0 ; + +err_unmap_skb: +dma_unmap_single (xchan->dma_dev, addr, ep->max_frm_size,DMA_FROM_DEVICE ); +err_free_skb: +dev_kfree_skb (skb); +return -ENOMEM ; +} + +static bool ep_rx_refill (struct xlnx_tsn_ep_dma_chan *xchan,bool arm_timer) +{ +int avail, i; + + scoped_guard(spinlock_bh, &xchan->rx_lock) { +if (READ_ONCE (xchan->ep->closing)) +return false; + + avail =CIRC_SPACE (xchan->ring_head,READ_ONCE (xchan->ring_tail), + xchan->ring_size); +for (i =0 ; i < avail; i++) { +if (ep_rx_submit_desc (xchan)) +break ; + } +dma_async_issue_pending (xchan->chan); + +if (i >0 || xchan->ring_head !=READ_ONCE (xchan->ring_tail)) +return true; + +if (arm_timer) +mod_timer (&xchan->rx_refill_timer, + jiffies +EP_RX_REFILL_RETRY ); + } + +return false; +} + +static void ep_rx_refill_timer (struct timer_list *t) +{ +struct xlnx_tsn_ep_dma_chan *xchan =timer_container_of (xchan, t, + rx_refill_timer); + +ep_rx_refill (xchan, true); +} + +static void ep_dma_rx_cb (void *data,const struct dmaengine_result *result) +{ +struct xlnx_tsn_ep_dma_chan *xchan = data; +struct skbuf_dma_descriptor *skbuf_dma; +size_t meta_len, meta_max_len, rx_len; +struct xlnx_tsn_ep *ep = xchan->ep; +struct net_device *ndev = ep->ndev; +struct sk_buff *skb; +u32 port_id, tuser; +u32 *metadata; + + skbuf_dma =ep_get_desc (xchan, xchan->ring_tail & (xchan->ring_size -1 )); +WRITE_ONCE (xchan->ring_tail, xchan->ring_tail +1 ); + skb = skbuf_dma->skb; + skbuf_dma->skb =NULL ; + +dma_unmap_single (xchan->dma_dev, skbuf_dma->dma_address, + ep->max_frm_size,DMA_FROM_DEVICE ); + +if (result->result !=DMA_TRANS_NOERROR ) { +if (net_ratelimit ()) +dev_warn (ep->dev,"RX DMA transfer error %d\n" , + result->result); + +dev_kfree_skb_any (skb); +DEV_STATS_INC (ndev, rx_dropped); +DEV_STATS_INC (ndev, rx_errors); + goto submit_new; + } + + metadata =dmaengine_desc_get_metadata_ptr (skbuf_dma->desc, + &meta_len, + &meta_max_len); +if (IS_ERR_OR_NULL (metadata)) { +if (net_ratelimit ()) +dev_warn (ep->dev,"Failed to get RX metadata pointer\n" ); + +dev_kfree_skb_any (skb); +DEV_STATS_INC (ndev, rx_dropped); +DEV_STATS_INC (ndev, rx_errors); + goto submit_new; + } + +/* MCDMA metadata: [0] = status, [1] = sideband (TID/TDEST/TUSER), [2..] = app */ + tuser = metadata[1 ] &TSN_TUSER_MASK ; + rx_len = ep->max_frm_size - result->residue; + +if (rx_len > ep->max_frm_size || rx_len <ETH_HLEN ) { +if (net_ratelimit ()) +dev_warn (ep->dev,"Invalid RX length %zu (max=%u, min=%u)\n" , + rx_len, ep->max_frm_size,ETH_HLEN ); + +dev_kfree_skb_any (skb); +DEV_STATS_INC (ndev, rx_dropped); +DEV_STATS_INC (ndev, rx_errors); + goto submit_new; + } + + port_id =FIELD_GET (TSN_TUSER_PORT_ID_MASK , tuser); +if (port_id !=TSN_TUSER_PORT_MAC1 && port_id !=TSN_TUSER_PORT_MAC2 ) { +dev_dbg_ratelimited (ep->dev, +"RX dropping unexpected TUSER port_id=%u\n" , + port_id); + +dev_kfree_skb_any (skb); +DEV_STATS_INC (ndev, rx_dropped); + goto submit_new; + } + +skb_put (skb, rx_len); + skb->dev = ndev; + skb->protocol =eth_type_trans (skb, ndev); +skb_checksum_none_assert (skb); +__netif_rx (skb); +
drivers/net/ethernet/xilinx/tsn/xilinx_tsn_ep.c ep_get_desc(struct xlnx_tsn_ep_dma_chan *xchan, int idx) · line 316
Quoted 10 lines
drivers/net/ethernet/xilinx/tsn/xilinx_tsn_ep.c +7
-0+DEV_STATS_INC (ndev, rx_packets); +DEV_STATS_ADD (ndev, rx_bytes, rx_len); + +submit_new: +ep_rx_refill (xchan, true); +} +static netdev_tx_t ep_start_xmit (struct sk_buff *skb,struct net_device *ndev) {dev_kfree_skb_any (skb);
[Severity: Medium]
Can this leave received frames stranded when RX traffic is sparse?
ep_rx_refill() queues up to avail descriptors with ep_rx_submit_desc() and then calls dma_async_issue_pending() once for the whole batch. On the provider side, xilinx_mcdma_start_transfer() sets the channel IRQ coalescing threshold in XILINX_MCDMA_CHAN_CR_OFFSET(chan->tdest) to chan->desc_pendingcount whenever that count is at most XILINX_MCDMA_COALESCE_MAX (24).
A refill that queues between 2 and 24 descriptors therefore sets the threshold to that batch size. That happens when several RX completions are reaped before the next refill runs. It also happens when dev_alloc_skb() or dmaengine_prep_slave_sg() fails partway through a batch and a later refill tops up the rest.
Batches larger than 24 skip the reprogramming. The initial fill of a 128-entry ring is one example. In that case a threshold left over from an earlier small batch stays in the control register.
With a threshold of N > 1, the MCDMA only raises the IOC interrupt after N frames have completed. xilinx_mcdma_irq_handler() only logs XILINX_MCDMA_IRQ_DELAY_MASK and does not call xilinx_dma_complete_descriptor(). No delay timeout appears to be programmed either.
If fewer than N frames arrive, they sit in the RX buffers and ep_dma_rx_cb() does not run for them until enough further traffic arrives.
The refill timer does not cover this case. ep_rx_refill() returns true because descriptors are still outstanding, so rx_refill_timer is never armed.
Much of the traffic on a TSN endpoint is low rate: ARP, PTP and other control frames. That can mean unbounded RX latency or a queue that looks stalled.
Should ep_rx_refill() issue pending after each submitted descriptor? Or does the fix belong in xilinx_dma, for example by completing descriptors on the delay interrupt or programming the coalesce delay timer? This depends on how the MCDMA coalescing behaves, so could you confirm what the hardware does here?
Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261113-patches_v2_external-v4-0-56bb26f042a4%40amd.com
PATCH v4 7/8 net: xilinx: tsn: add the endpoint TX data path
In reply to Srinivas NeeliAdd the transmit path so the endpoint can send frames.
Select the TX channel by indexing tx_chans[] with the frame's logical queue. ep_init_dmaengine() fills that array in logical-queue order, so the index maps to the channel that queue's descriptors were set up on. The driver consults tx_dma_chan_map[] only to reject a queue with no mapping. Map the frame and submit it to that channel. Stop the queue when the ring runs out of space, and wake it from the completion callback once a slot opens.
---
Changes in v4:
- Call skb_tx_timestamp() before dmaengine_submit(). The provider can start a pending descriptor from the IRQ of an earlier transfer, so the completion callback could free the skb before the timestamp was taken.
- Add .get_ts_info with ethtool_op_get_ts_info() so ethtool reports the software TX timestamps the driver now generates.
- Terminate the TX channels in ndo_stop() before netif_tx_disable(). A completion that read the closing flag as false then finishes before the queues are stopped and can no longer wake one while the channels are freed.
- Extend the @closing kernel-doc to the TX completion callback, which tests it before waking a stopped queue.
Changes in v3:
- Free a DMA-error TX frame with dev_kfree_skb_any() and a completed one with dev_consume_skb_any(), so dropped frames are not reported as delivered.
- Add skb_tx_timestamp() at the hardware handoff for software TX timestamps.
- Skip the queue wake in the completion callback while closing. Use __netif_txq_completed_wake() with the closing flag, and set ep->closing before netif_tx_disable().
- Reword the body to state that tx_chans[] is indexed by logical queue, and drop the description of a runtime channel lookup that no longer exists.
Changes in v2:
- Take the scatterlist entry count from skb_to_sgvec() instead of assuming nr_frags + 1, so dma_map_sg() cannot walk past the end of the list.
- Check dmaengine_submit() with dma_submit_error() before advancing the ring head and charging BQL, and drop the frame if the submit fails.
- Publish the ring head with WRITE_ONCE(), paired with the READ_ONCE() on the completion side.
- Take the ring size from the channel instead of the compile-time constant.
- Use dmaengine_prep_slave_sg() instead of calling the ops member directly.
- Move tx_lock into the per-channel struct, mirroring rx_lock, so independent TX queues do not serialise on one device-wide lock.
- Narrow the tx_lock kernel-doc to what it actually protects.
- Mark the ring_tail store in the completion callback with WRITE_ONCE() to match the READ_ONCE() readers.
- Use the spinlock_bh guard class in the completion callback so it matches the spin_lock_bh() in the xmit path.
- Index tx_chans directly by logical queue in ep_start_xmit() and drop the phys_chan/dma_dev locals, so the transmit path no longer re-derives the channel through tx_dma_chan_map.
--- drivers/net/ethernet/xilinx/tsn/xilinx_tsn_ep.c | 161 +++++++++++++++++++++++- 1 file changed, 159 insertions(+), 2 deletions(-)
drivers/net/ethernet/xilinx/tsn/xilinx_tsn_ep.c +159 -2
@@ -28,6 +28,8 @@#include <linux/timer.h> #include <linux/types.h> +#include <net/netdev_queues.h> +#include "xilinx_tsn.h" #define DRIVER_NAME "xilinx_tsn_ep"
@@ -82,6 +84,7 @@ struct skbuf_dma_descriptor {* @ring_tail: consumer index * @ring_size: number of slots in @skb_ring * @rx_lock: serialises @ring_head between the RX callback and the refill timer +* @tx_lock: serialises @ring_head and @ring_tail between xmit and TX completion * @rx_refill_timer: retries RX refill after an allocation failure * @is_tx: true for TX channels, false for RX */
@@ -94,6 +97,7 @@ struct xlnx_tsn_ep_dma_chan {u32 ring_tail;u32 ring_size;spinlock_t rx_lock;/* serialises @ring_head */ +spinlock_t tx_lock;/* serialises @ring_head and @ring_tail */ struct timer_list rx_refill_timer;bool is_tx; };
@@ -112,6 +116,7 @@ struct xlnx_tsn_ep_dma_chan {* @tx_chans: array of TX channels (size @num_tx_queues) * @rx_chans: array of RX channels (size @num_rx_queues) * @closing: set in ndo_stop so the RX completion callback stops re-arming +* and the TX completion callback stops waking a stopped queue */ struct xlnx_tsn_ep {struct net_device *ndev;
@@ -311,8 +316,151 @@ static void ep_dma_rx_cb(void *data, const struct dmaengine_result *result)ep_rx_refill (xchan, true); } +static void ep_dma_tx_cb (void *data,const struct dmaengine_result *result) +{ +struct xlnx_tsn_ep_dma_chan *xchan = data; +struct skbuf_dma_descriptor *skbuf_dma; +struct netdev_queue *txq; +struct net_device *ndev; +struct scatterlist *sgl; +struct sk_buff *skb; +int sg_len; +int len; + + scoped_guard(spinlock_bh, &xchan->tx_lock) { + skbuf_dma =ep_get_desc (xchan, + xchan->ring_tail & (xchan->ring_size -1 )); +if (!skbuf_dma || !skbuf_dma->skb) +return ; + + skb = skbuf_dma->skb; + sgl = skbuf_dma->sgl; + sg_len = skbuf_dma->sg_len; + +dma_unmap_sg (xchan->dma_dev, sgl, sg_len,DMA_TO_DEVICE ); + + skbuf_dma->skb =NULL ; +WRITE_ONCE (xchan->ring_tail, xchan->ring_tail +1 ); + } + + ndev = skb->dev; + txq =netdev_get_tx_queue (ndev,skb_get_queue_mapping (skb)); + len = skb->len; + +if (unlikely (result->result !=DMA_TRANS_NOERROR )) { +DEV_STATS_INC (ndev, tx_errors); +dev_kfree_skb_any (skb); + }else { +DEV_STATS_INC (ndev, tx_packets); +DEV_STATS_ADD (ndev, tx_bytes, len); +dev_consume_skb_any (skb); + } + +__netif_txq_completed_wake (txq,1 , len, +CIRC_SPACE (READ_ONCE (xchan->ring_head), +READ_ONCE (xchan->ring_tail), + xchan->ring_size),2 , +READ_ONCE (xchan->ep->closing)); +} +static netdev_tx_t ep_start_xmit (struct sk_buff *skb,struct net_device *ndev) { +struct dma_async_tx_descriptor *dma_tx_desc; +struct xlnx_tsn_ep *ep =netdev_priv (ndev); +struct skbuf_dma_descriptor *skbuf_dma; +int queue =skb_get_queue_mapping (skb); +struct xlnx_tsn_ep_dma_chan *xchan; +struct netdev_queue *txq; +int sg_len, nents, ret; +dma_cookie_t cookie; + +if (unlikely (queue >= ep->num_tx_queues)) { +if (net_ratelimit ()) +netdev_warn (ndev,"Invalid TX queue %d (max %u)\n" , + queue, ep->num_tx_queues); + goto err_drop_skb; + } + +if (ep->tx_dma_chan_map[queue] ==TSN_DMA_CH_INVALID ) { +if (net_ratelimit ()) +netdev_warn (ndev,"Logical TX queue %d has invalid DMA mapping\n" , + queue); + goto err_drop_skb; + } + + xchan = ep->tx_chans[queue]; + + sg_len =skb_shinfo (skb)->nr_frags +1 ; + txq =netdev_get_tx_queue (ndev, queue); + +spin_lock_bh (&xchan->tx_lock); +if (CIRC_SPACE (xchan->ring_head,READ_ONCE (xchan->ring_tail), + xchan->ring_size) <=1 ) { +netif_txq_try_stop (txq, +CIRC_SPACE (xchan->ring_head, +READ_ONCE (xchan->ring_tail), + xchan->ring_size), +2 ); +spin_unlock_bh (&xchan->tx_lock); +if (net_ratelimit ()) +netdev_warn (ndev,"TSN TX ring full\n" ); + +return NETDEV_TX_BUSY ; + } + + skbuf_dma =ep_get_desc (xchan, xchan->ring_head & (xchan->ring_size -1 )); +if (!skbuf_dma) { +spin_unlock_bh (&xchan->tx_lock); + goto err_drop_skb; + } +spin_unlock_bh (&xchan->tx_lock); + +sg_init_table (skbuf_dma->sgl, sg_len); + ret =skb_to_sgvec (skb, skbuf_dma->sgl,0 , skb->len); +if (ret <0 ) + goto err_drop_skb; + sg_len = ret; + + nents =dma_map_sg (xchan->dma_dev, skbuf_dma->sgl, sg_len,DMA_TO_DEVICE ); +if (!nents) + goto err_drop_skb; + + dma_tx_desc =dmaengine_prep_slave_sg (xchan->chan, skbuf_dma->sgl, + nents,DMA_MEM_TO_DEV , +DMA_PREP_INTERRUPT ); +if (!dma_tx_desc) + goto err_unmap_sg; + + skbuf_dma->skb = skb; + skbuf_dma->sg_len = sg_len; + dma_tx_desc->callback_param = xchan; + dma_tx_desc->callback_result = ep_dma_tx_cb; + +skb_tx_timestamp (skb); + +spin_lock_bh (&xchan->tx_lock); + cookie =dmaengine_submit (dma_tx_desc); +if (dma_submit_error (cookie)) { +spin_unlock_bh (&xchan->tx_lock); + skbuf_dma->skb =NULL ; + goto err_unmap_sg; + } +WRITE_ONCE (xchan->ring_head, xchan->ring_head +1 ); +netdev_tx_sent_queue (txq, skb->len); +netif_txq_maybe_stop (txq, +CIRC_SPACE (xchan->ring_head, +READ_ONCE (xchan->ring_tail), + xchan->ring_size), +2 ,2 ); +spin_unlock_bh (&xchan->tx_lock); + +dma_async_issue_pending (xchan->chan); + +return NETDEV_TX_OK ; + +err_unmap_sg: +dma_unmap_sg (xchan->dma_dev, skbuf_dma->sgl, sg_len,DMA_TO_DEVICE ); +err_drop_skb:dev_kfree_skb_any (skb);DEV_STATS_INC (ndev, tx_dropped);return NETDEV_TX_OK ;
@@ -343,10 +491,16 @@ static int ep_open(struct net_device *ndev)static int ep_stop (struct net_device *ndev) {struct xlnx_tsn_ep *ep =netdev_priv (ndev); +unsigned int i; -netif_tx_disable (ndev);WRITE_ONCE (ep->closing, true); +for (i =0 ; i < ep->num_tx_queues; i++) +dmaengine_terminate_sync (ep->tx_chans[i]->chan); + +netif_tx_disable (ndev);ep_exit_dmaengine (ep); +for (i =0 ; i < ndev->num_tx_queues; i++) +netdev_tx_reset_subqueue (ndev, i);return 0 ; }
@@ -366,6 +520,7 @@ static const struct net_device_ops ep_netdev_ops = {static const struct ethtool_ops ep_ethtool_ops = { .get_drvinfo = ep_get_drvinfo, + .get_ts_info = ethtool_op_get_ts_info, }; static struct xlnx_tsn_ep_dma_chan *
@@ -402,7 +557,9 @@ ep_alloc_dma_chan(struct xlnx_tsn_ep *ep, struct dma_chan *dma_chan, chan->ep = ep; chan->ring_size = ring_size; chan->dma_dev =dmaengine_get_dma_device (chan->chan); -if (!is_tx) { +if (is_tx) { +spin_lock_init (&chan->tx_lock); + }else {spin_lock_init (&chan->rx_lock);timer_setup (&chan->rx_refill_timer, ep_rx_refill_timer,0 ); }
Signature · 1 line
2.43.0
[email protected]
AI reviewRe: [PATCH net-next v4 7/8] net: xilinx: tsn: add the endpoint TX data path
Thank you for your contribution! Sashiko AI review found 3 potential issues to consider: - [High] net: xilinx: tsn: ep_stop() terminates TX DMA before netif_tx_disable() - [Medium] net: xilinx: tsn…
Thank you for your contribution! Sashiko AI review found 3 potential issues to consider:
- [High] net: xilinx: tsn: ep_stop() terminates TX DMA before netif_tx_disable()
- [Medium] net: xilinx: tsn: missing TX DMA error recovery in ep_start_xmit()
- [Medium] net: xilinx: tsn: ep_start_xmit() TX flow control ignores DMA segment limit
--
commit a8a4f14fcbe22e1b33cd5c8b571aab05e71576de
Author: Srinivas Neeli <[email protected]>
net: xilinx: tsn: add the endpoint TX data path
This commit adds the transmit path and TX DMA completion handling for the Xilinx TSN endpoint driver.
Quoted 4 lines
drivers/net/ethernet/xilinx/tsn/xilinx_tsn_ep.c +0
-0
[ ... ]
Quoted 40 lines
drivers/net/ethernet/xilinx/tsn/xilinx_tsn_ep.c +36
-0@@ -311,8 +316,151 @@ static void ep_dma_rx_cb(void *data, const struct dmaengine_result *result)ep_rx_refill (xchan, true); } +static void ep_dma_tx_cb (void *data,const struct dmaengine_result *result) +{ +struct xlnx_tsn_ep_dma_chan *xchan = data; +struct skbuf_dma_descriptor *skbuf_dma; +struct netdev_queue *txq; +struct net_device *ndev; +struct scatterlist *sgl; +struct sk_buff *skb; +int sg_len; +int len; + + scoped_guard(spinlock_bh, &xchan->tx_lock) { + skbuf_dma =ep_get_desc (xchan, + xchan->ring_tail & (xchan->ring_size -1 )); +if (!skbuf_dma || !skbuf_dma->skb) +return ; + + skb = skbuf_dma->skb; + sgl = skbuf_dma->sgl; + sg_len = skbuf_dma->sg_len; + +dma_unmap_sg (xchan->dma_dev, sgl, sg_len,DMA_TO_DEVICE ); + + skbuf_dma->skb =NULL ; +WRITE_ONCE (xchan->ring_tail, xchan->ring_tail +1 ); + } + + ndev = skb->dev; + txq =netdev_get_tx_queue (ndev,skb_get_queue_mapping (skb)); + len = skb->len; + +if (unlikely (result->result !=DMA_TRANS_NOERROR )) { +DEV_STATS_INC (ndev, tx_errors); +dev_kfree_skb_any (skb); + }else { +DEV_STATS_INC (ndev, tx_packets);
drivers/net/ethernet/xilinx/tsn/xilinx_tsn_ep.c static void ep_dma_rx_cb(void *data, const struct dmaengine_result *result) · line 364
Quoted 10 lines
drivers/net/ethernet/xilinx/tsn/xilinx_tsn_ep.c +10
-0+DEV_STATS_ADD (ndev, tx_bytes, len); +dev_consume_skb_any (skb); + } + +__netif_txq_completed_wake (txq,1 , len, +CIRC_SPACE (READ_ONCE (xchan->ring_head), +READ_ONCE (xchan->ring_tail), + xchan->ring_size),2 , +READ_ONCE (xchan->ep->closing)); +}
[Severity: Medium]
Can an AXI MCDMA channel error leave a stopped TX queue permanently wedged?
When xilinx_mcdma_irq_handler() handles XILINX_MCDMA_IRQ_ERR_MASK, it sets chan->err = true, and xilinx_dma_complete_descriptor() only moves descriptors to done_list when XILINX_DMA_BD_COMP_MASK is set. In-flight descriptors that do not complete never invoke ep_dma_tx_cb(), so xchan->ring_tail does not advance and __netif_txq_completed_wake() is never called. If the subqueue was stopped by netif_txq_maybe_stop() or BQL, ep_start_xmit() will not run again to reset the channel via xilinx_dma_tx_submit(), and ep_netdev_ops defines no ndo_tx_timeout callback to recover the channel and drain xchan->skb_ring.
Quoted 58 lines
drivers/net/ethernet/xilinx/tsn/xilinx_tsn_ep.c +58
-0+ +static netdev_tx_t ep_start_xmit (struct sk_buff *skb,struct net_device *ndev) +{ +struct dma_async_tx_descriptor *dma_tx_desc; +struct xlnx_tsn_ep *ep =netdev_priv (ndev); +struct skbuf_dma_descriptor *skbuf_dma; +int queue =skb_get_queue_mapping (skb); +struct xlnx_tsn_ep_dma_chan *xchan; +struct netdev_queue *txq; +int sg_len, nents, ret; +dma_cookie_t cookie; + +if (unlikely (queue >= ep->num_tx_queues)) { +if (net_ratelimit ()) +netdev_warn (ndev,"Invalid TX queue %d (max %u)\n" , + queue, ep->num_tx_queues); + goto err_drop_skb; + } + +if (ep->tx_dma_chan_map[queue] ==TSN_DMA_CH_INVALID ) { +if (net_ratelimit ()) +netdev_warn (ndev,"Logical TX queue %d has invalid DMA mapping\n" , + queue); + goto err_drop_skb; + } + + xchan = ep->tx_chans[queue]; + + sg_len =skb_shinfo (skb)->nr_frags +1 ; + txq =netdev_get_tx_queue (ndev, queue); + +spin_lock_bh (&xchan->tx_lock); +if (CIRC_SPACE (xchan->ring_head,READ_ONCE (xchan->ring_tail), + xchan->ring_size) <=1 ) { +netif_txq_try_stop (txq, +CIRC_SPACE (xchan->ring_head, +READ_ONCE (xchan->ring_tail), + xchan->ring_size), +2 ); +spin_unlock_bh (&xchan->tx_lock); +if (net_ratelimit ()) +netdev_warn (ndev,"TSN TX ring full\n" ); + +return NETDEV_TX_BUSY ; + } + + skbuf_dma =ep_get_desc (xchan, xchan->ring_head & (xchan->ring_size -1 )); +if (!skbuf_dma) { +spin_unlock_bh (&xchan->tx_lock); + goto err_drop_skb; + } +spin_unlock_bh (&xchan->tx_lock); + +sg_init_table (skbuf_dma->sgl, sg_len); + ret =skb_to_sgvec (skb, skbuf_dma->sgl,0 , skb->len); +if (ret <0 ) + goto err_drop_skb; + sg_len = ret;
drivers/net/ethernet/xilinx/tsn/xilinx_tsn_ep.c static void ep_dma_rx_cb(void *data, const struct dmaengine_result *result) · line 432
Quoted 10 lines
drivers/net/ethernet/xilinx/tsn/xilinx_tsn_ep.c +10
-0+ + nents =dma_map_sg (xchan->dma_dev, skbuf_dma->sgl, sg_len,DMA_TO_DEVICE ); +if (!nents) + goto err_drop_skb; + + dma_tx_desc =dmaengine_prep_slave_sg (xchan->chan, skbuf_dma->sgl, + nents,DMA_MEM_TO_DEV , +DMA_PREP_INTERRUPT ); +if (!dma_tx_desc) + goto err_unmap_sg;
[Severity: Medium]
Can dmaengine_prep_slave_sg() exhaust the MCDMA channel's segment pool and drop frames while the software ring still has space?
The driver advertises NETIF_F_SG and allows up to MAX_SKB_FRAGS + 1 (18) scatterlist entries per frame, while queue flow control only checks CIRC_SPACE() on the 64-frame software ring (up to 62 frames in flight). In drivers/dma/xilinx/xilinx_dma.c, each MCDMA channel has a pool of XILINX_DMA_NUM_DESCS (512) segments in chan->free_seg_list. When multi-fragment frames in flight consume all 512 segments before 62 frames are queued, dmaengine_prep_slave_sg() returns NULL and ep_start_xmit() drops the packet instead of stopping the TX queue.
[ ... ]
Quoted 8 lines
drivers/net/ethernet/xilinx/tsn/xilinx_tsn_ep.c +1
-1@@ -343,10 +491,16 @@ static int ep_open(struct net_device *ndev)static int ep_stop (struct net_device *ndev) {struct xlnx_tsn_ep *ep =netdev_priv (ndev); +unsigned int i; -netif_tx_disable (ndev);WRITE_ONCE (ep->closing, true);
drivers/net/ethernet/xilinx/tsn/xilinx_tsn_ep.c static int ep_open(struct net_device *ndev) · line 506
Quoted 10 lines
drivers/net/ethernet/xilinx/tsn/xilinx_tsn_ep.c +6
-0+for (i =0 ; i < ep->num_tx_queues; i++) +dmaengine_terminate_sync (ep->tx_chans[i]->chan); + +netif_tx_disable (ndev);ep_exit_dmaengine (ep); +for (i =0 ; i < ndev->num_tx_queues; i++) +netdev_tx_reset_subqueue (ndev, i);return 0 ; }
[Severity: High]
Can ep_start_xmit() race with dmaengine_terminate_sync() when ep_stop() terminates the TX channels before calling netif_tx_disable()?
Until netif_tx_disable() acquires HARD_TX_LOCK and sets __QUEUE_STATE_DRV_XOFF, transmit paths that bypass qdisc deactivation (such as AF_PACKET with PACKET_QDISC_BYPASS via __dev_direct_xmit(), or a queue using noqueue) can still enter ep_start_xmit(), which does not check ep->closing:
CPU0 CPU1ep_stop() __dev_direct_xmit()
WRITE_ONCE(ep->closing, true) ep_start_xmit()
dmaengine_terminate_sync()
xilinx_dma_terminate_all()
xilinx_dma_chan_reset()
chan->terminating = true
xilinx_dma_free_descriptors()
dmaengine_prep_slave_sg()
dmaengine_submit()
xilinx_dma_tx_submit()
chan->terminating = false
WRITE_ONCE(xchan->ring_head, ...)
dma_async_issue_pending() netif_tx_disable()
Calling dma_async_issue_pending() concurrently with dmaengine_terminate_sync() violates the dmaengine_synchronize() API contract and races with the unlocked channel reset and descriptor freeing in xilinx_dma_terminate_all(). In addition, because xilinx_dma_terminate_all() discards earlier in-flight descriptors without running ep_dma_tx_cb(), their SKBs remain at xchan->ring_tail; if the newly issued transfer completes before ep_exit_dmaengine() frees the channel, ep_dma_tx_cb() pops the stale slot at ring_tail, unmapping and freeing the wrong skb and passing its length to __netif_txq_completed_wake().
Calling netif_tx_disable(ndev) after WRITE_ONCE(ep->closing, true) and before the dmaengine_terminate_sync() loop would serialize against ep_start_xmit() while still preventing any concurrent ep_dma_tx_cb() from waking a stopped queue.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=7
[email protected]
AI reviewRe: [PATCH net-next v4 7/8] net: xilinx: tsn: add the endpoint TX data path
In reply to Srinivas NeeliThank you for your contribution! Sashiko AI review found 6 potential issue(s) to consider.
Thank you for your contribution! Sashiko AI review found 6 potential issue(s) to consider.
Critical: 0 · High: 1 · Medium: 3 · Low: 2
If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough).
- [High] ep_start_xmit() takes and releases xchan->tx_lock with spin_lock_bh()/spin_unlock_bh() at lines 396/404/413/416 and…
- [Medium] The TX path assumes every submitted MCDMA descriptor comes back through exactly one in-order completion callback, with a per-…
- [Medium] ep_stop() sets ep->closing and calls dmaengine_terminate_sync() on every TX channel (line 498) before…
- [Medium] net: xilinx: tsn: ep_start_xmit() TX flow control ignores DMA segment limit
- [Low] The commit body covers only TX channel selection, map/submit and queue stop/wake.
- [Low] Several hot-path checks in ep_start_xmit() can never fire, and the commit message ('The driver consults tx_dma_chan_map[] only to…
--
net: xilinx: tsn: add the endpoint TX data path
This commit adds the transmit path for the Xilinx TSN endpoint driver. Frames are mapped into a scatterlist and submitted to the MCDMA TX channel for their logical queue, and BQL drives queue stop/wake from the completion callback. It also adds software TX timestamping and reorders ep_stop() so the TX channels are terminated before the queues are disabled.
Quoted 9 lines
Add the transmit path so the endpoint can send frames.
Select the TX channel by indexing tx_chans[] with the frame's logical queue.
ep_init_dmaengine()fills that array in logical-queue order, so the index maps to the channel that queue's descriptors were set up on. The driver consults tx_dma_chan_map[] only to reject a queue with no mapping. Map the frame and submit it to that channel. Stop the queue when the ring runs out of space, and wake it from the completion callback once a slot opens.
[Severity: Low]
This isn't a bug, but the commit message only covers channel selection, map/submit and queue stop/wake. Should it also mention these other changes in the patch?
- software TX timestamping through skb_tx_timestamp(), plus the new .get_ts_info = ethtool_op_get_ts_info, which changes ethtool -T output
- BQL accounting through netdev_tx_sent_queue(), __netif_txq_completed_wake() and netdev_tx_reset_subqueue()
- the reordered ep_stop(), where dmaengine_terminate_sync() now runs on each TX channel before netif_tx_disable()
The reasons for the ep_stop() ordering and for the timestamping are only in the v3/v4 changelog below the --- line. That text does not end up in the git history.
Quoted 4 lines
drivers/net/ethernet/xilinx/tsn/xilinx_tsn_ep.c +0
-0
[ ... ]
Quoted 6 lines
drivers/net/ethernet/xilinx/tsn/xilinx_tsn_ep.c +2
-0@@ -311,8 +316,151 @@ static void ep_dma_rx_cb(void *data, const struct dmaengine_result *result)ep_rx_refill (xchan, true); } +static void ep_dma_tx_cb (void *data,const struct dmaengine_result *result) +{
[ ... ]
Quoted 5 lines
drivers/net/ethernet/xilinx/tsn/xilinx_tsn_ep.c +5
-0+ scoped_guard(spinlock_bh, &xchan->tx_lock) { + skbuf_dma =ep_get_desc (xchan, + xchan->ring_tail & (xchan->ring_size -1 )); +if (!skbuf_dma || !skbuf_dma->skb) +return ;
[ ... ]
drivers/net/ethernet/xilinx/tsn/xilinx_tsn_ep.c static void ep_dma_rx_cb(void *data, const struct dmaengine_result *result) · line 353
Quoted 4 lines
drivers/net/ethernet/xilinx/tsn/xilinx_tsn_ep.c +4
-0+if (unlikely (result->result !=DMA_TRANS_NOERROR )) { +DEV_STATS_INC (ndev, tx_errors); +dev_kfree_skb_any (skb); + }else {
[Severity: Medium]
What happens to the TX ring after an MM2S DMA error?
In the xilinx_dma provider, xilinx_mcdma_irq_handler() only sets chan->err when it sees XILINX_MCDMA_IRQ_ERR_MASK. Descriptors only complete when IOC is set. xilinx_dma_complete_descriptor() stops at the first descriptor whose last segment lacks XILINX_DMA_BD_COMP_MASK.
So the descriptors that did complete in that IRQ are the ones reported with an error result. An error IRQ without IOC produces no callbacks at all.
ep_start_xmit() sets callback_param to xchan rather than to the per-slot skbuf_dma, so this callback always consumes the ring_tail slot. If one callback never arrives, does every later completion land on the wrong slot? That would unmap and free the wrong skb, and report the wrong length to BQL and tx_bytes.
Also, xilinx_mcdma_start_transfer() returns early while chan->err is set, so the channel stays halted. It only recovers when the next xilinx_dma_tx_submit() calls xilinx_dma_chan_reset(). That reset is controller-wide, so it can disturb the RX channels too, and stale entries are left on active_list.
Nothing in the driver terminates or resyncs the channel after an error. ep_netdev_ops has no .ndo_tx_timeout, so the TX watchdog is never armed.
Once the ring fills, can this queue stay stopped until the interface is taken down and up again?
[ ... ]
Quoted 2 lines
static
netdev_tx_tep_start_xmit(struct sk_buff *skb, struct net_device *ndev){
[ ... ]
drivers/net/ethernet/xilinx/tsn/xilinx_tsn_ep.c static void ep_dma_rx_cb(void *data, const struct dmaengine_result *result) · line 389
Quoted 6 lines
drivers/net/ethernet/xilinx/tsn/xilinx_tsn_ep.c +6
-0+if (ep->tx_dma_chan_map[queue] ==TSN_DMA_CH_INVALID ) { +if (net_ratelimit ()) +netdev_warn (ndev,"Logical TX queue %d has invalid DMA mapping\n" , + queue); + goto err_drop_skb; + }
[Severity: Low]
This isn't a bug, but can this check ever fire?
ep_parse_tx_queue_config() does all of the following:
- rejects queue indices >= num_tx_queues
- rejects duplicate queues through queue_seen
- requires each node to name a valid channel listed in dma-names
- requires count == num_tx_queues
So either every logical queue in [0, num_tx_queues) gets a valid mapping, or probe fails.
The queue >= ep->num_tx_queues check above looks unreachable too. The netdev has one TX queue per TX DMA channel, and the core caps queue_mapping.
The !skbuf_dma branch below looks dead as well. ep_alloc_dma_chan() either allocates every skb_ring[] entry or fails.
The commit message says:
The driver consults tx_dma_chan_map[] only to reject a queue with no mapping.
That wording suggests an unmapped queue can show up at runtime. Should these checks be dropped, or the commit message reworded?
drivers/net/ethernet/xilinx/tsn/xilinx_tsn_ep.c static void ep_dma_rx_cb(void *data, const struct dmaengine_result *result) · line 396
Quoted 7 lines
drivers/net/ethernet/xilinx/tsn/xilinx_tsn_ep.c +7
-0+ + xchan = ep->tx_chans[queue]; + + sg_len =skb_shinfo (skb)->nr_frags +1 ; + txq =netdev_get_tx_queue (ndev, queue); + +spin_lock_bh (&xchan->tx_lock);
[Severity: High]
Is spin_lock_bh() safe in ndo_start_xmit here?
Documentation/networking/netdevices.rst says ndo_start_xmit may be called with interrupts disabled by netconsole:
netpoll_send_skb()
local_irq_save(flags);
__netpoll_send_skb()
HARD_TX_TRYLOCK()
netpoll_start_xmit()
ep_start_xmit()
spin_unlock_bh(&xchan->tx_lock)
__local_bh_enable_ip()
lockdep_assert_irqs_enabled();The driver does not set IFF_DISABLE_NETPOLL, so netconsole can bind to this netdev directly. It can also get here through a DSA user port, because dsa_user_netpoll_setup() sets up netpoll on the conduit, and a later patch in the series makes this device a conduit.
With lockdep enabled, this splats on every netconsole transmit.
Without lockdep, a pending softirq is still a problem. spin_unlock_bh() can then call do_softirq(), which runs softirq handlers with interrupts re-enabled. That happens inside netpoll's irq-off section, while this CPU still holds the txq _xmit_lock.
If NET_TX then runs qdisc_run()->sch_direct_xmit() on the same txq, wouldn't HARD_TX_LOCK spin on a lock its own CPU already holds?
The normal xmit path already runs with BH disabled, and the TX completion runs from the DMA tasklet. Would plain spin_lock() (or spin_lock_irqsave()) be enough here? The same question applies to the second spin_lock_bh() section around dmaengine_submit().
[ ... ]
drivers/net/ethernet/xilinx/tsn/xilinx_tsn_ep.c static int ep_open(struct net_device *ndev) · line 500
Quoted 12 lines
drivers/net/ethernet/xilinx/tsn/xilinx_tsn_ep.c +5
-1@@ -343,10 +491,16 @@ static int ep_open(struct net_device *ndev)static int ep_stop (struct net_device *ndev) {struct xlnx_tsn_ep *ep =netdev_priv (ndev); +unsigned int i; -netif_tx_disable (ndev);WRITE_ONCE (ep->closing, true); +for (i =0 ; i < ep->num_tx_queues; i++) +dmaengine_terminate_sync (ep->tx_chans[i]->chan); + +netif_tx_disable (ndev);
[Severity: Medium]
Can ep_start_xmit() still run while this loop terminates the TX channels?
The TX queues are still enabled at this point. __dev_close_many() has called dev_deactivate_many(), but that only quiesces the qdisc paths.
__dev_direct_xmit() is used by PACKET_QDISC_BYPASS and by AF_XDP generic xmit. It checks netif_running() before taking HARD_TX_LOCK. After that it only checks netif_xmit_frozen_or_drv_stopped(txq).
So a sender that passed the running check can reach ep_start_xmit() and call dmaengine_submit() and dma_async_issue_pending() on a channel that is being terminated. Documentation/driver-api/dmaengine/client.rst calls that undefined. Also, xilinx_dma_terminate_all() resets the channel and sets chan->idle without holding chan->lock.
xilinx_dma_free_descriptors() drops the queued descriptors for the [ring_tail, ring_head) slots without running callbacks, so ring_tail does not move.
When the newly submitted frame completes, ep_dma_tx_cb() would consume the oldest terminated slot. It would unmap and consume the wrong skb, and charge tx_packets, tx_bytes and BQL with that frame's length.
Moving netif_tx_disable() back to the front would reopen the race from the v4 changelog: a callback that read closing as false could wake the queue after netif_tx_disable(). Would it work to check closing and do the wake both under tx_lock, or to disable the queues both before and after the terminate loop?
Quoted 6 lines
drivers/net/ethernet/xilinx/tsn/xilinx_tsn_ep.c +2
-0ep_exit_dmaengine (ep); +for (i =0 ; i < ndev->num_tx_queues; i++) +netdev_tx_reset_subqueue (ndev, i);return 0 ; }
[ ... ]
Quoted 142 lines
drivers/net/ethernet/xilinx/tsn/xilinx_tsn_ep.c +136
-0@@ -311,8 +316,151 @@ static void ep_dma_rx_cb(void *data, const struct dmaengine_result *result)ep_rx_refill (xchan, true); } +static void ep_dma_tx_cb (void *data,const struct dmaengine_result *result) +{ +struct xlnx_tsn_ep_dma_chan *xchan = data; +struct skbuf_dma_descriptor *skbuf_dma; +struct netdev_queue *txq; +struct net_device *ndev; +struct scatterlist *sgl; +struct sk_buff *skb; +int sg_len; +int len; + + scoped_guard(spinlock_bh, &xchan->tx_lock) { + skbuf_dma =ep_get_desc (xchan, + xchan->ring_tail & (xchan->ring_size -1 )); +if (!skbuf_dma || !skbuf_dma->skb) +return ; + + skb = skbuf_dma->skb; + sgl = skbuf_dma->sgl; + sg_len = skbuf_dma->sg_len; + +dma_unmap_sg (xchan->dma_dev, sgl, sg_len,DMA_TO_DEVICE ); + + skbuf_dma->skb =NULL ; +WRITE_ONCE (xchan->ring_tail, xchan->ring_tail +1 ); + } + + ndev = skb->dev; + txq =netdev_get_tx_queue (ndev,skb_get_queue_mapping (skb)); + len = skb->len; + +if (unlikely (result->result !=DMA_TRANS_NOERROR )) { +DEV_STATS_INC (ndev, tx_errors); +dev_kfree_skb_any (skb); + }else { +DEV_STATS_INC (ndev, tx_packets); +DEV_STATS_ADD (ndev, tx_bytes, len); +dev_consume_skb_any (skb); + } + +__netif_txq_completed_wake (txq,1 , len, +CIRC_SPACE (READ_ONCE (xchan->ring_head), +READ_ONCE (xchan->ring_tail), + xchan->ring_size),2 , +READ_ONCE (xchan->ep->closing)); +} +static netdev_tx_t ep_start_xmit (struct sk_buff *skb,struct net_device *ndev) { +struct dma_async_tx_descriptor *dma_tx_desc; +struct xlnx_tsn_ep *ep =netdev_priv (ndev); +struct skbuf_dma_descriptor *skbuf_dma; +int queue =skb_get_queue_mapping (skb); +struct xlnx_tsn_ep_dma_chan *xchan; +struct netdev_queue *txq; +int sg_len, nents, ret; +dma_cookie_t cookie; + +if (unlikely (queue >= ep->num_tx_queues)) { +if (net_ratelimit ()) +netdev_warn (ndev,"Invalid TX queue %d (max %u)\n" , + queue, ep->num_tx_queues); + goto err_drop_skb; + } + +if (ep->tx_dma_chan_map[queue] ==TSN_DMA_CH_INVALID ) { +if (net_ratelimit ()) +netdev_warn (ndev,"Logical TX queue %d has invalid DMA mapping\n" , + queue); + goto err_drop_skb; + } + + xchan = ep->tx_chans[queue]; + + sg_len =skb_shinfo (skb)->nr_frags +1 ; + txq =netdev_get_tx_queue (ndev, queue); + +spin_lock_bh (&xchan->tx_lock); +if (CIRC_SPACE (xchan->ring_head,READ_ONCE (xchan->ring_tail), + xchan->ring_size) <=1 ) { +netif_txq_try_stop (txq, +CIRC_SPACE (xchan->ring_head, +READ_ONCE (xchan->ring_tail), + xchan->ring_size), +2 ); +spin_unlock_bh (&xchan->tx_lock); +if (net_ratelimit ()) +netdev_warn (ndev,"TSN TX ring full\n" ); + +return NETDEV_TX_BUSY ; + } + + skbuf_dma =ep_get_desc (xchan, xchan->ring_head & (xchan->ring_size -1 )); +if (!skbuf_dma) { +spin_unlock_bh (&xchan->tx_lock); + goto err_drop_skb; + } +spin_unlock_bh (&xchan->tx_lock); + +sg_init_table (skbuf_dma->sgl, sg_len); + ret =skb_to_sgvec (skb, skbuf_dma->sgl,0 , skb->len); +if (ret <0 ) + goto err_drop_skb; + sg_len = ret; + + nents =dma_map_sg (xchan->dma_dev, skbuf_dma->sgl, sg_len,DMA_TO_DEVICE ); +if (!nents) + goto err_drop_skb; + + dma_tx_desc =dmaengine_prep_slave_sg (xchan->chan, skbuf_dma->sgl, + nents,DMA_MEM_TO_DEV , +DMA_PREP_INTERRUPT ); +if (!dma_tx_desc) + goto err_unmap_sg; + + skbuf_dma->skb = skb; + skbuf_dma->sg_len = sg_len; + dma_tx_desc->callback_param = xchan; + dma_tx_desc->callback_result = ep_dma_tx_cb; + +skb_tx_timestamp (skb); + +spin_lock_bh (&xchan->tx_lock); + cookie =dmaengine_submit (dma_tx_desc); +if (dma_submit_error (cookie)) { +spin_unlock_bh (&xchan->tx_lock); + skbuf_dma->skb =NULL ; + goto err_unmap_sg; + } +WRITE_ONCE (xchan->ring_head, xchan->ring_head +1 ); +netdev_tx_sent_queue (txq, skb->len); +netif_txq_maybe_stop (txq, +CIRC_SPACE (xchan->ring_head, +READ_ONCE (xchan->ring_tail), + xchan->ring_size), +2 ,2 ); +spin_unlock_bh (&xchan->tx_lock); +
drivers/net/ethernet/xilinx/tsn/xilinx_tsn_ep.c static void ep_dma_rx_cb(void *data, const struct dmaengine_result *result) · line 466
Quoted 10 lines
drivers/net/ethernet/xilinx/tsn/xilinx_tsn_ep.c +7
-0+dma_async_issue_pending (xchan->chan); + +return NETDEV_TX_OK ; + +err_unmap_sg: +dma_unmap_sg (xchan->dma_dev, skbuf_dma->sgl, sg_len,DMA_TO_DEVICE ); +err_drop_skb:dev_kfree_skb_any (skb);DEV_STATS_INC (ndev, tx_dropped);return NETDEV_TX_OK ;
[Severity: Medium]
What happens when the MCDMA segment pool runs out before this ring does?
The driver sets NETIF_F_SG, and skbuf_dma->sgl has room for MAX_SKB_FRAGS + 1 entries. But the stop and wake decisions in ep_start_xmit() and ep_dma_tx_cb() only look at CIRC_SPACE() on the TX_BD_NUM_DEFAULT (64) slot frame ring. That allows up to 62 frames in flight per channel, however many segments each one uses.
In the xilinx_dma provider, each channel has a fixed pool of XILINX_DMA_NUM_DESCS (512) segments on chan->free_seg_list. xilinx_mcdma_prep_slave_sg() takes at least one segment per scatterlist entry. With fully fragmented skbs at 18 entries each, 28 frames in flight leave too few segments for the next one. At that point the frame ring is still less than half full.
dmaengine_prep_slave_sg() then returns NULL. The frame is unmapped and freed through err_unmap_sg and err_drop_skb, and it is counted as tx_dropped. The queue is never stopped, so the stack keeps handing over frames that fail the same way until completions return segments to the pool.
Nothing leaks and the queue does not stall. But sustained SG traffic, such as zerocopy senders or forwarded paged skbs, sees packet loss where it should see backpressure.
Should the flow control account for segments as well as frames? For example, the TX ring could be sized so that ring_size * (MAX_SKB_FRAGS + 1) fits in the provider's pool. Or the stop threshold could reserve the worst-case segment count per frame.
Alternatively, should a prep failure with frames still in flight stop the queue and return NETDEV_TX_BUSY, and rely on ep_dma_tx_cb() to wake it?
Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261113-patches_v2_external-v4-0-56bb26f042a4%40amd.com
PATCH v4 8/8 net: xilinx: tsn: deliver endpoint RX frames to DSA user ports
In reply to Srinivas NeeliFrom: Nagadheeraj Rottela <[email protected]>
The endpoint MAC is the DSA conduit for the three-port TSN switch. DSA selects an RX frame's user port from the port metadata on the skb, so a frame from either MAC needs that metadata to reach its swpN netdev.
Allocate a METADATA_HW_PORT_MUX entry per MAC port at probe and attach it to each RX frame by its TUSER port_id (1 for MAC1, 2 for MAC2), guarded by netdev_uses_dsa() so it runs only while a switch is bound as the conduit.
The RX callback runs in softirq and hands the frame to __netif_rx(), which queues it on the backlog, so the attached dst must be a counted reference (dst_hold() + skb_dst_set()) to survive the handoff.
--- drivers/net/ethernet/xilinx/tsn/xilinx_tsn_ep.c | 55 ++++++++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-)
drivers/net/ethernet/xilinx/tsn/xilinx_tsn_ep.c +54 -1
@@ -28,6 +28,8 @@#include <linux/timer.h> #include <linux/types.h> +#include <net/dsa.h> +#include <net/dst_metadata.h> #include <net/netdev_queues.h> #include "xilinx_tsn.h"
@@ -58,6 +60,9 @@#define TSN_TUSER_PORT_MAC1 0x1#define TSN_TUSER_PORT_MAC2 0x2 +/* Sized to index port_md[] by TUSER port_id (1 or 2, slot 0 unused) */ +#define XLNX_TSN_EP_PORT_MD_SLOTS (TSN_TUSER_PORT_MAC2 + 1) +/** * struct skbuf_dma_descriptor - skb container for each in-flight DMA descriptor * @sgl: scatter-gather list backing the DMA mapping
@@ -117,6 +122,8 @@ struct xlnx_tsn_ep_dma_chan {* @rx_chans: array of RX channels (size @num_rx_queues) * @closing: set in ndo_stop so the RX completion callback stops re-arming * and the TX completion callback stops waking a stopped queue +* @port_md: per-TUSER-port METADATA_HW_PORT_MUX entries attached on RX, +* indexed by port_id (1 for MAC1, 2 for MAC2) */ struct xlnx_tsn_ep {struct net_device *ndev;
@@ -133,6 +140,8 @@ struct xlnx_tsn_ep {struct xlnx_tsn_ep_dma_chan **rx_chans;bool closing; + +struct metadata_dst *port_md[XLNX_TSN_EP_PORT_MD_SLOTS ]; }; static inline struct skbuf_dma_descriptor *
@@ -304,6 +313,10 @@ static void ep_dma_rx_cb(void *data, const struct dmaengine_result *result) }skb_put (skb, rx_len); +if (netdev_uses_dsa (ndev)) { +dst_hold (&ep->port_md[port_id]->dst); +skb_dst_set (skb, &ep->port_md[port_id]->dst); + } skb->dev = ndev; skb->protocol =eth_type_trans (skb, ndev);skb_checksum_none_assert (skb);
@@ -907,6 +920,37 @@ static int ep_count_dma_channels(struct device *dev, u32 *out_tx, u32 *out_rx,return 0 ; } +static void ep_free_port_md (struct xlnx_tsn_ep *ep) +{ +int i; + +for (i =0 ; i <XLNX_TSN_EP_PORT_MD_SLOTS ; i++) { +if (ep->port_md[i]) { +dst_release (&ep->port_md[i]->dst); + ep->port_md[i] =NULL ; + } + } +} + +static int ep_alloc_port_md (struct xlnx_tsn_ep *ep) +{ +int i; + +for (i =TSN_TUSER_PORT_MAC1 ; i <=TSN_TUSER_PORT_MAC2 ; i++) { +struct metadata_dst *md; + + md =metadata_dst_alloc (0 ,METADATA_HW_PORT_MUX ,GFP_KERNEL ); +if (!md) { +ep_free_port_md (ep); +return -ENOMEM ; + } + md->u.port_info.port_id = i; + ep->port_md[i] = md; + } + +return 0 ; +} +static int xlnx_tsn_ep_probe (struct platform_device *pdev) {u32 num_tx_dma_channels, num_rx_dma_channels, num_prio;
@@ -996,16 +1040,24 @@ static int xlnx_tsn_ep_probe(struct platform_device *pdev) ndev->dev_addr); } + ret =ep_alloc_port_md (ep); +if (ret) { +dev_err_probe (dev, ret,"failed to allocate per-port metadata\n" ); + goto err_release_chans; + } +platform_set_drvdata (pdev, ep); ret =register_netdev (ndev);if (ret) {dev_err_probe (dev, ret,"failed to register net device\n" ); - goto err_release_chans; + goto err_free_md; }return 0 ; +err_free_md: +ep_free_port_md (ep); err_release_chans:ep_release_dma_chans (ep); err_free_ndev:
@@ -1021,6 +1073,7 @@ static void xlnx_tsn_ep_remove(struct platform_device *pdev)return ;unregister_netdev (ep->ndev); +ep_free_port_md (ep);ep_release_dma_chans (ep);free_netdev (ep->ndev); }
Signature · 1 line
2.43.0