* [PATCH net-next v2 0/6] Add Northstar FA TCP/UDP NAT offload with a bridged LAN
@ 2026-12-01 18:22 Florian Fainelli
2026-12-01 18:22 ` [PATCH net-next v2 6/6] docs: net: document Northstar FA setup and NAT qualification Florian Fainelli
0 siblings, 1 reply; 2+ messages in thread
From: Florian Fainelli @ 2026-12-01 18:22 UTC (permalink / raw)
To: netdev
Cc: Florian Fainelli, andrew+netdev, andrew, bcm-kernel-feedback-list,
bridge, conor+dt, corbet, coreteam, davem, devicetree, edumazet,
fw, horms, idosch, jonas.gorski, krzk+dt, kuba, linux-doc,
linux-kernel, netfilter-devel, olteanv, pabeni, pablo, phil,
rafal, razor, rdunlap, robh, skhan, willemb
Add nftables flowtable offload for the original flow accelerator in
BCM4708/BCM5301X. The six patches provide bindings, B53/DSA metadata and
exception paths, cached-path validation and invalidation, the bgmac
backend, KUnit tests and a hardware qualification guide.
Support the usual router layout: a standalone WAN and an untagged LAN
bridge containing four wired LAN ports and software members such as a
PCIe WLAN interface. Wired IPv4 TCP/UDP SNAT or DNAT can use FA. Software
members retain software forwarding. Two standalone DSA router ports also
remain supported. Use distinct LAN/WAN router MACs, MTU 1500 and one
hardware flowtable in the initial network namespace. Include only the
physical wired DSA ports in the hardware flowtable.
Data travels through GMAC2 and switch port 8 (IMP0). B53 CFP redirects
TCP control, low-TTL, oversized and ingress-policy exceptions through
GMAC0 and switch port 5 (IMP1), outside inline FA. Both protocols require
this auxiliary connection. Router-domain and source-MAC guards preserve
ordinary LAN switching and force continued tuples from another physical
ingress through Linux learning. Table or classifier exhaustion retains
software forwarding. Existing board device trees must explicitly opt in.
Validate both actual cached routes, neighbours and bridge FDB paths.
FDB notifications invalidate bridge flowtable generations, including
software-only and hardware-capacity fallback owners after client moves.
Retirement is conservative across bridge paths in the same namespace and
across notified IPv4 route, rule and nexthop changes. Non-bridge caches
retain their existing automatic route-validation policy. Unnotified
DSCP-specific route aliases must not be used for accelerated traffic.
Changes in v2:
- Describe the GMAC3-hosted register window, restrict the GMAC2 consumer
schema and correct the auxiliary CPU port name to IMP1.
- Support the bridged-LAN router layout. Add shared source-MAC guards,
preserve ordinary LAN switching and clear the forwarding mark on
auxiliary redirects which may require software bridging.
- Validate cached routes and neighbours without allocating entries;
return the owner's reverse peer MAC for ingress guards. Resolve
untagged bridge paths and permit STP state reads under RCU.
- Notify caches around FDB changes and retire stale bridge generations
during construction, packet lookup, GC and hardware admission,
including software-only flows and hardware-capacity fallback.
- Recheck every installed next hop, serialize block bookkeeping,
reject non-initial namespaces and retire before ports can receive.
- Match TCP control in both directions using exact tuples, including
IP options, and close concurrent peer-installation races. Leave
unparseable and non-initial fragments on the software path.
- Handle guard failures, MAC-change vetoes, auxiliary VLAN membership
and notifier teardown. Retire on bridge state and security changes.
- Extend the combined KUnit suite to 37 cases and document bridge
configuration, software-member tests and FDB movement qualification.
- Fold intermediate fixes into their feature commits, wrap commit
messages and remove redundant nftables transport matches. Every
feature patch passes checkpatch.pl --strict without suppressions.
- Repeat qualification and complete a fresh bridged-LAN mixed soak
lasting 23 hours 58 minutes, including TCP/UDP capacity fallback.
v1: https://lore.kernel.org/all/20261116222519.1416501-1-florian.fainelli@broadcom.com/
Dependencies:
The base-commit trailer identifies the tested net-next snapshot. The five
prerequisite-patch-id trailers identify independent fixes supplied in a
separate prerequisite bundle, in this order:
net: ethernet: bgmac: validate RX length against the DMA packet capacity
netfilter: flowtable: do not forward frames not addressed to the host
netfilter: flowtable: retain offload ownership until deletion completes
net: dsa: tag_brcm: fix link-local detection with a prepended tag
net: ethernet: bgmac: update netdev MTU after changing the MAC
Validation on BCM953012ER / BCM53012:
- ARM W=1 built-in, module and disabled builds, including module link
and modpost; targeted DT schemas, examples and board DTBs.
- 37 combined QEMU KUnit cases, including bridge movement, cache
generation, source guards and the RCU STP accessor regression.
- Classic, software-flowtable and hardware TCP/UDP SNAT/DNAT controls
with payload, checksum, TTL and raw hardware-key checks.
- Prior boundary, ingress-policy, invalidation and read/insert/delete
completion-timeout qualification, with fallback and recovery.
- Software-to-wired continued-tuple movement, simultaneous wired HW
NAT and software-member NAT/L2 traffic, wrong-ingress trapping,
FDB updates and bridge/auxiliary-link control transitions.
- The new bridge soak completed 21 mixed-traffic phases and 20 cycles
each of UDP overflow, aging, recovery, TCP overflow, FIN drain and
TCP recovery. Its 132,404,736 wired echo exchanges and 1,538,648
exchanges on each software bridge stream had no loss or payload
errors. All 144 periodic independent audits were healthy. There
were no campaign restarts, host OOMs or unexpected kernel/FA errors.
The software bridge member was a veth; no actual WLAN radio was tested.
Traffic through every physical LAN port, BCM4708/BCM53011 hardware,
FA2/FA+, PPPoE and maximum throughput remain outside this qualification.
Earlier multicast-database diagnostics are tracked separately; the NAT
soak does not establish a fix for them. Register accessibility still
depends on the bootloader's GMAC3 state, as the binding and guide explain.
OpenAI Codex assistance covered implementation, tests, documentation,
changelogs, lab orchestration and submission preparation, using the
requested design, Broadcom documentation, the ISC downstream driver,
kernel sources and review feedback.
Florian Fainelli (6):
dt-bindings: net: describe the Northstar flow accelerator
net: dsa: add Broadcom FA metadata and IPv4 exception paths
net: flow_offload: allow drivers to validate and invalidate cached
paths
net: bgmac: add Northstar IPv4 TCP/UDP NAT flowtable offload
net: add KUnit coverage for FA and flowtable path validation
docs: net: document Northstar FA setup and NAT qualification
.../bindings/net/brcm,bcm4708-fa.yaml | 52 +
.../bindings/net/brcm,bcm5301x-gmac.yaml | 33 +
.../ethernet/broadcom/bcm-ns-fa.rst | 638 +++++
.../device_drivers/ethernet/index.rst | 1 +
MAINTAINERS | 7 +
drivers/net/dsa/b53/Kconfig | 12 +
drivers/net/dsa/b53/b53_common.c | 520 +++-
drivers/net/dsa/b53/b53_fa_test.c | 124 +
drivers/net/dsa/b53/b53_priv.h | 16 +
drivers/net/dsa/b53/b53_regs.h | 39 +
drivers/net/ethernet/broadcom/.kunitconfig | 24 +
drivers/net/ethernet/broadcom/Kconfig | 39 +
drivers/net/ethernet/broadcom/Makefile | 1 +
.../net/ethernet/broadcom/bcm-ns-fa-test.c | 795 ++++++
drivers/net/ethernet/broadcom/bcm-ns-fa.c | 2218 +++++++++++++++++
drivers/net/ethernet/broadcom/bcm-ns-fa.h | 30 +
drivers/net/ethernet/broadcom/bgmac-bcma.c | 5 +
drivers/net/ethernet/broadcom/bgmac.c | 30 +
drivers/net/ethernet/broadcom/bgmac.h | 2 +
include/linux/dsa/brcm.h | 34 +
include/net/dsa.h | 2 +
include/net/flow_offload.h | 14 +
include/net/netevent.h | 1 +
include/net/netfilter/nf_flow_table.h | 13 +-
include/net/netns/flow_table.h | 3 +
net/bridge/br_fdb.c | 26 +-
net/bridge/br_stp.c | 7 +-
net/dsa/Kconfig | 23 +
net/dsa/tag_brcm.c | 166 +-
net/dsa/tag_brcm_test.c | 200 ++
net/netfilter/Kconfig | 15 +-
net/netfilter/nf_flow_table_core.c | 57 +-
net/netfilter/nf_flow_table_core_test.c | 203 ++
net/netfilter/nf_flow_table_offload.c | 143 ++
net/netfilter/nf_flow_table_offload_test.c | 242 ++
net/netfilter/nf_flow_table_path.c | 8 +
net/netfilter/nft_flow_offload.c | 6 +-
37 files changed, 5712 insertions(+), 37 deletions(-)
create mode 100644 Documentation/devicetree/bindings/net/brcm,bcm4708-fa.yaml
create mode 100644 Documentation/devicetree/bindings/net/brcm,bcm5301x-gmac.yaml
create mode 100644 Documentation/networking/device_drivers/ethernet/broadcom/bcm-ns-fa.rst
create mode 100644 drivers/net/dsa/b53/b53_fa_test.c
create mode 100644 drivers/net/ethernet/broadcom/.kunitconfig
create mode 100644 drivers/net/ethernet/broadcom/bcm-ns-fa-test.c
create mode 100644 drivers/net/ethernet/broadcom/bcm-ns-fa.c
create mode 100644 drivers/net/ethernet/broadcom/bcm-ns-fa.h
create mode 100644 net/dsa/tag_brcm_test.c
create mode 100644 net/netfilter/nf_flow_table_offload_test.c
base-commit: d1f4b7c6b997c29de67ad7178ababac2328cb1b4
prerequisite-patch-id: cc5740b3c0df34f00a185bc49b48af0de0b4f246
prerequisite-patch-id: 4a2aa7a8f7a1670091364bf8856b1286bdd4e371
prerequisite-patch-id: 4dac987af9eb210ace8e99bf06ce4273995692bb
prerequisite-patch-id: d322079467996d4b88d7f928251d11869862b32a
prerequisite-patch-id: bfc2b85226ebd6baac17d44e5909873c908e821c
^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH net-next v2 6/6] docs: net: document Northstar FA setup and NAT qualification
2026-12-01 18:22 [PATCH net-next v2 0/6] Add Northstar FA TCP/UDP NAT offload with a bridged LAN Florian Fainelli
@ 2026-12-01 18:22 ` Florian Fainelli
0 siblings, 0 replies; 2+ messages in thread
From: Florian Fainelli @ 2026-12-01 18:22 UTC (permalink / raw)
To: netdev
Cc: Florian Fainelli, corbet, davem, edumazet, horms, kuba, linux-doc,
linux-kernel, pabeni, rdunlap, skhan, willemb
Describe the supported topology, GMAC2 data and GMAC0 exception wiring,
configuration, counters and software fallback. Provide classic/software/
hardware NAT controls and same-live-tuple TTL, MTU and ingress-policy
checks. Cover live route/neighbour changes, reachability probes and
read/insertion/deletion completion injection with reprobe recovery.
Explain that every notified IPv4 route, rule or nexthop event retires
all hardware owners, including unrelated and local-table updates.
Document the resulting offload-residency cost and distinguish actual
cached-path validation from the driver's incomplete FIB eligibility
probe. State the limits of FIB notifications and of the GMAC3-hosted
registers.
Describe a standalone WAN opposite a four-port LAN bridge with software
members, physical-only hardware flowtable devices, source-MAC guards,
FDB invalidation, software-to-wired movement and mixed NAT/L2 tests.
Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com>
---
Changes in v2:
- Document complete ingress guards, auxiliary VLAN membership, failed-
MAC-change recovery and exact TCP control retirement.
- Clarify GMAC3 register accessibility and bootloader dependencies, the
supported compatibles, and unnotified DSCP-specific route aliases which
must not be used with FA traffic.
- Include both TCP and UDP in the nftables example and run all combined
KUnit suites without the earlier name filter.
- Document bridge setup, wired-only hardware flowtable devices, software-
member NAT/L2 forwarding, FDB movement and mixed soak qualification.
Remove redundant transport protocol matches from the nftables example
so strict checkpatch is clean.
.../ethernet/broadcom/bcm-ns-fa.rst | 638 ++++++++++++++++++
.../device_drivers/ethernet/index.rst | 1 +
MAINTAINERS | 1 +
3 files changed, 640 insertions(+)
create mode 100644 Documentation/networking/device_drivers/ethernet/broadcom/bcm-ns-fa.rst
diff --git a/Documentation/networking/device_drivers/ethernet/broadcom/bcm-ns-fa.rst b/Documentation/networking/device_drivers/ethernet/broadcom/bcm-ns-fa.rst
new file mode 100644
index 0000000000000..a0bbddada2ed5
--- /dev/null
+++ b/Documentation/networking/device_drivers/ethernet/broadcom/bcm-ns-fa.rst
@@ -0,0 +1,638 @@
+.. SPDX-License-Identifier: GPL-2.0-only
+
+Broadcom Northstar flow accelerator
+===================================
+
+Status and scope
+----------------
+
+The driver supports BCM4708, BCM53011 and BCM53012. IPv4 TCP and UDP
+SNAT/DNAT have been validated on BCM953012ER (BCM53012), including normal
+and software-flowtable controls, external wire checks, hardware table
+pressure, software fallback, natural aging, teardown and recovery.
+
+BCM4708 and BCM53011 remain unvalidated. BCM53012 validation covers the
+limited topology below; maximum throughput has not been established.
+
+The driver accepts nftables flowtable offload through ``TC_SETUP_FT`` on
+bgmac. DSA forwards flowtable binds from its user ports to the GMAC2 conduit.
+The FA is inline on the UniMAC2 / switch IMP0 (port 8) path. GMAC0 and GMAC1
+are pass-through paths and cannot accelerate these flows.
+
+The initial supported configuration is deliberately limited:
+
+* IPv4 TCP/UDP with source NAT or destination NAT, including port translation.
+* Two untagged router interfaces in the initial network namespace: either
+ two standalone DSA ports, or a standalone WAN port and one LAN bridge.
+ The bridge may contain all four LAN switch ports and software ports such
+ as a PCIe WLAN interface. Accelerated ingress and egress must both be
+ DSA ports of the same switch, using GMAC2 as their conduit.
+* Distinct unicast MAC addresses on the LAN and WAN router interfaces.
+* MTU 1500 on both router interfaces and their physical ports, one hardware
+ flowtable, and no upper devices other than the untagged LAN bridge.
+
+IPv6, VLAN devices or VLAN-filtering bridges, PPPoE, tunnels, bonds, hairpin forwarding,
+plain routing, multipath/nexthop-object routes, and simultaneous source and
+destination NAT in one direction
+are rejected for hardware offload. They can still use software forwarding.
+Hardware admission requires a second, operational CPU connection from switch
+port 5 to GMAC0. B53 CFP redirects IPv4 exceptions through this connection,
+physically bypassing FA. This includes TCP SYN/FIN/RST, TTL 0/1, IP lengths
+above 1500, and packets that do not match the input port's router MAC. TCP
+also requires the flowtable FIN/RST exclusion mask. Boards without the
+auxiliary connection retain software forwarding for both protocols.
+
+The hardware has 1024 directional IPv4 entries, arranged in 256 four-way
+buckets, four router MAC entries, and 128 next-hop entries. Capacity exhaustion
+returns an error to the flowtable infrastructure, leaving traffic in software.
+One connection normally needs two directional entries. Next-hop entries are
+shared by destination MAC; router MACs are shared with an internal/external
+side attribute. The driver learns the tuple hash from opcode-2 miss tags,
+so it does not implement an assumed software equivalent of the hardware CRC.
+A finite RX hash cache can also cause an offload attempt to fall back to
+software under miss floods.
+
+The new ``brcm-fa`` DSA tag protocol carries the prepended FA miss descriptor.
+Its hash, bucket, and parser status fields differ from the ordinary switch
+tag. The bgmac receive hook observes the metadata for hash learning; the DSA
+tagger consumes it and selects the input port. Timestamp descriptors are not
+supported. The ordinary ``brcm`` and ``brcm-prepend`` taggers retain their
+opcode validation.
+
+Implementation notes
+--------------------
+
+Table operations use the documented indirect access sequence. DATA0 triggers
+the transfer; reads discard the initial DATA0 value and wait for the fetch
+before consuming DATA7 through DATA0. Every wait is bounded. The driver keeps
+clear-on-read disabled because clearing on a read gives unreliable hit counts.
+Instead it reads cumulative packet counts and computes wrapping deltas in
+software.
+
+The indirect read port is released after each access, including an access
+that times out. Leaving read mode armed prevents per-entry hit counters from
+updating and breaks the flowtable's activity accounting.
+
+Live packet lookups must not overlap software table transactions. On the
+tested BCM53012, that overlap can advance the indirect address more than
+once and persistently copy one flow's key into another slot. Before each
+transaction, the driver requests GMAC2 CPU flow control, waits for pause to
+assert and allows an in-flight frame to drain. It preserves automatic flow
+control and restores the previous MAC control on every exit path. The switch
+CPU port must honor pause, with matching internal link speeds at both ends.
+The FA stays in normal mode so packet and Broadcom-header processing retain
+their usual paths. Completion checks cover both the busy bit and the
+auto-incremented table address. Frequent statistics and debugfs reads also
+consume time on the internal link; include that work in performance tests.
+
+Router destination MAC validation is enabled before publishing a forwarding
+entry. With no installed entries, it is disabled to obtain hashes for the
+first unknown tuples. VLAN TPIDs are disabled in the FA parser so tagged
+packets cannot match an installed untagged tuple merely by sharing its inner
+five-tuple, including the TCP/UDP protocol bit. When both CPU connections
+are explicitly described, B53 CFP reserves rules for TCP SYN/FIN/RST, TTL
+0/1 and IPv4 total lengths above 1500. These redirect to port 5 with a
+classification and termination reason. Nine masked prefixes cover every
+length from 1501 through 65535. Router-MAC guards redirect packets using
+another router interface's destination MAC to port 5. All ports of the LAN
+bridge share its router MAC and routing domain. Other destination MACs
+cannot match the FA router-MAC pool; normal LAN switching and copies to
+software bridge members continue. MAC and bridge membership changes disable
+admission while updating these rules, and a MAC change which fails restores
+them. Both
+meter outcomes use the same action. Ordinary data uses port 8 only; unicast
+and multicast flooding to the auxiliary CPU is disabled. Redirected frames
+stay subject to VLAN filtering, so the auxiliary CPU port follows the VLAN
+membership of port 8. Standalone ports use basic EAP mode, with
+private VLAN membership restricting forwarding to the CPU connections.
+VLAN, EAP and STP filtering remain enabled. CFP classification is disabled
+on CPU ports. Router-domain guards cover every user port, including bridge
+members. FA cannot separate an additional active routing domain, so such a
+configuration is declined for hardware offload.
+
+Each accelerated LAN client also owns a classifier source-MAC guard. It
+redirects IPv4 packets from that MAC on any switch port other than the one
+recorded by the bridge FDB. This makes wired roaming observable even when
+the client continues an already accelerated tuple without ARP or TCP control
+traffic. The first packet reaches Linux bridge learning, which invalidates
+the old forwarding cache before a new hardware egress can be admitted.
+There are 128 shared client guards; exhaustion retains software forwarding.
+Classifier failures disable FA until reprobe. Redirected bridge frames are
+not marked as already forwarded by hardware, so Linux can forward them to
+other wired ports as well as WLAN.
+
+FA must ignore switch exception metadata to accelerate standalone data,
+which normally carries the switch flooding reason. Consequently, an inline
+SYN/FIN/RST trap through port 8 is insufficient: FA would accelerate those
+packets as well. The auxiliary GMAC0 path avoids that lookup entirely. It
+uses embedded Broadcom tags; the port 8 data path uses prepended FA metadata.
+The tagger dispatches control packets to FA before delivering them to Linux.
+The auxiliary conduit uses promiscuous mode to receive the router port MACs.
+Before disabling its CFP redirects, B53 disables hardware lookup, retires
+all entries and blocks admission. Re-enabling the path permits fresh
+connections to offload.
+
+On a valid TCP control packet, NAPI marks the matching direction as closing
+and immediately disables IPv4 lookup in the parser. Broadcom-tag relocation
+remains active so the control packet can traverse the software forwarding
+path. A worker removes both NAT directions before resuming lookups. Global
+bypass is unsuitable here because it also disables tag relocation. Control
+packets match either direction of an entry by their exact ports, including
+packets with IP options. Fragments other than the first, which carry no TCP
+header, are left to the slow path, as in the software flowtable. A direction
+installed while its peer is being retired is retired as well. RCU protects entry
+identity, and a generation check prevents an insertion learned before the
+control packet from racing past it. Closing rows retain their final packet
+delta for software accounting until the flowtable deletes their ownership.
+
+Hardware packet counters refresh flowtable last-used time and packet
+accounting. The hardware has no per-entry byte counter; reported byte totals
+therefore do not include accelerated traffic. Three-bit timestamps are not
+used for aging. Debugfs reads do not consume the driver's accounting deltas.
+
+Netdevice shutdown, address/MTU changes, new active switch ports, and upper
+interface changes flush entries. Bridge FDB updates, including software-only
+administrative moves, deletions and aging, retire all hardware owners. Bridge
+port state, security flags and VLAN changes also invalidate the cache. The
+retained bridge route is validated against its actual neighbour and current
+FDB-selected physical egress. A moved client retires the old software owner
+as well. Neighbor probes use the bridge L3 interface, rather than a member
+port. Accelerated packets do not refresh the software FDB; its normal aging
+may therefore cause retirement and relearning during a long connection.
+Every IPv4 FIB route, rule and nexthop event
+which the kernel notifies flushes all FA-owned flows, including unrelated
+prefixes and local-table entries. This is intentional: the rule does not carry
+enough routing-policy context to prove that an event cannot affect an
+installed path. The kernel only notifies the first alias of a prefix in a
+table, so a change to a route which is not first, such as a route with a
+non-zero DSCP (``tos``) next to the default one for the same prefix, is not
+seen, and neither are the route MTUs of such aliases. Do not use DSCP-specific
+routes for traffic which uses FA. Work is
+coalesced, but even unrelated routing churn can reduce offload residency.
+Redirects and next-hop MAC or validity changes also disable lookup and schedule
+entry retirement. The driver also notifies the flowtable owner to retire
+its cached software path; merely removing hardware rows would leave stale
+direct-transmit routes and destination MACs in use. Generation checks reject observations and publications
+that raced with invalidation. Before admitting a rule, the flowtable owner
+validates its actual cached routes and direct-path neighbours. Hardware
+flowtables retain validation-only route references, so this check preserves the mark,
+DSCP and output-interface context used when those paths were selected.
+These references do not enable automatic route checks for plain direct
+flows in other drivers or hardware-enabled flowtables. Existing direct
+tunnel, neighbour and XFRM route checks keep their previous behaviour.
+A proven stale cached route or neighbour retires the software owner too.
+The driver's separate FIB lookup is only a hardware eligibility probe:
+it lacks the complete policy context, so any mismatch declines hardware
+offload without tearing down a valid software owner. Unsupported route types,
+such as multipath, nexthop objects and lightweight tunnels, decline hardware
+admission without tearing down valid software flowtable forwarding.
+Valid neighbour aging transitions do not unnecessarily flush entries.
+Hardware counter activity drives Linux
+neighbour reachability probes, so an accelerated connection cannot leave a
+stale neighbour untested indefinitely.
+
+The flowtable classifier provides no per-route MTU. The driver therefore
+keeps all flows in software while any IPv4 route in the initial network
+namespace has an explicit MTU below 1500. The initial FIB notifier replay
+seeds a hash of low-MTU table/prefix pairs; route replacements and deletions
+update it incrementally without further FIB dumps. Ordinary routes use no
+tracking memory. If allocation fails or more than 1024 low-MTU prefixes
+need tracking, hardware admission remains disabled until reprobe; route
+updates and software forwarding continue. This conservative restriction also
+applies to unrelated routes. The CFP length trap handles packets exceeding
+the admitted interface MTU, including packets of an already installed tuple.
+
+A table timeout disables parser lookup
+and prevents further hardware insertion until reprobe. Tag relocation remains
+active for software fallback. Reconfiguration can
+leave an existing conntrack entry temporarily labelled HW_OFFLOAD after its
+hardware entries have been flushed. Use fresh connections after topology or
+ruleset changes; the label alone is never proof of forwarding by hardware.
+
+Device tree and kernel configuration
+------------------------------------
+
+Enable at least::
+
+ CONFIG_BGMAC_BCMA=y
+ CONFIG_BCM_NS_FA=y
+ CONFIG_NET_DSA=y
+ CONFIG_B53=y
+ CONFIG_B53_SRAB_DRIVER=y
+ CONFIG_NET_DSA_TAG_BRCM_FA=y
+ CONFIG_NF_CONNTRACK=y
+ CONFIG_NF_TABLES=y
+ CONFIG_NF_FLOW_TABLE=y
+ CONFIG_NF_FLOW_TABLE_INET=y
+ CONFIG_NFT_FLOW_OFFLOAD=y
+ CONFIG_NFT_NAT=y
+ CONFIG_NF_NAT=y
+ CONFIG_DEBUG_FS=y
+
+Modules are supported too. Use the board's existing ARM configuration and
+retain its PHY, switch, filesystem, and boot-device options.
+
+For a BCM53012 board, add the following node under the root address space
+(adjust the compatible to ``brcm,bcm53011-fa`` for BCM53011)::
+
+ / {
+ fa: flow-accelerator@18027c00 {
+ compatible = "brcm,bcm53012-fa";
+ reg = <0x18027c00 0xc0>;
+ };
+ };
+
+ &gmac2 {
+ brcm,flow-accelerator = <&fa>;
+ status = "okay";
+ };
+
+Both tested user ports must use switch port 8 and GMAC2. In the existing B53
+switch node, port 8 must have ``ethernet = <&gmac2>``. Also enable
+switch port 5 with ``ethernet = <&gmac0>``, ``phy-mode = "internal"`` and a
+1 Gbps full-duplex fixed link. Enable GMAC0 and bring its network interface
+up before testing either protocol; retain port 8 as the preferred conduit for
+user ports.
+Remove any other conflicting CPU assignments for this test. B53 selects ``brcm-fa``
+for a BCM5301x switch when the ethernet node of its port 8 has the phandle to
+an enabled accelerator node compatible with ``brcm,bcm4708-fa``,
+``brcm,bcm53011-fa`` or ``brcm,bcm53012-fa``. These are the compatibles which
+the backend accepts, so both agree on whether FA metadata is used. Another
+compatible on an enabled node fails the probe of GMAC2. The binding lists
+the supported SoCs: BCM4708, BCM53011 and BCM53012. Do not set
+``dsa-tag-protocol``: B53 does not implement the runtime protocol-change
+operation. No existing board is enabled automatically by this series.
+
+The FA registers are in the 4 KiB BCMA window of the GMAC3 core, outside the
+0x800 bytes of its own registers. They are managed by the GMAC2 consumer; they
+do not need a separate platform driver or character device. The driver neither
+enables nor resets the GMAC3 core. bgmac only probes GMAC3 when it has a MAC
+address, which would reset the core and the accelerator state: do not
+give GMAC3 one. Whether the registers can be accessed depends on the state in
+which the bootloader leaves that core, which has not been established for all
+boards. Leave the accelerator disabled or omit the GMAC2 phandle to retain the
+existing board configuration.
+
+Standalone WAN and bridged LAN
+------------------------------
+
+A common router configuration keeps the WAN separate and assigns the LAN
+IPv4 address to a bridge. For example, with ``lan1`` through ``lan4`` as
+switch ports, ``wan`` as the standalone WAN, and ``wlan0`` as the WLAN::
+
+ ip link add br-lan type bridge vlan_filtering 0
+ ip link set br-lan address 02:00:00:00:01:01
+ for dev in lan1 lan2 lan3 lan4 wlan0; do
+ ip link set "$dev" master br-lan
+ ip link set "$dev" up
+ done
+ ip address add 192.0.2.1/24 dev br-lan
+ ip link set br-lan up
+ ip link set wan address 02:00:00:00:03:01
+ ip address add 198.51.100.1/24 dev wan
+ ip link set wan up
+
+Remove the LAN IPv4 address from individual member ports before assigning
+it to the bridge. The LAN and WAN router MACs must be distinct. Keep the
+GMAC0 exception connection operational as for the standalone-port setup.
+Use bridge ports in the flowtable and the bridge name in routed firewall
+and NAT rules::
+
+ flowtable ft {
+ hook ingress priority 0;
+ devices = { lan1, lan2, lan3, lan4, wan };
+ flags offload;
+ counter;
+ }
+
+The hardware table can bind only devices which support flowtable offload.
+Keep WLAN devices out of this table: their connections use normal software
+forwarding, including the bridge FDB lookup. For the software-flowtable
+control test, omit ``flags offload`` and add ``wlan0`` to the device list.
+
+For the later test rules, replace LAN ``iifname`` and ``oifname`` matches
+with ``br-lan`` and retain ``wan`` for the WAN. Wired LAN-to-WAN connections
+can use FA in both directions. Connections using a WLAN or another software
+bridge port retain software forwarding; adding that member does not disable
+wired offload. VLAN filtering, stacked bridges, locked or isolated accelerated
+ports, and a second active LAN routing domain are not supported by this
+initial bridge implementation.
+
+Bridge FDB changes invalidate cached bridge paths in software as well as
+the FA entries. In particular, a software-only owner must not keep sending
+replies to a WLAN member after its client moves to a wired port. The next
+packet takes the normal forwarding path until the retired owner has been
+removed, then a fresh cache can resolve the new physical bridge port.
+
+Qualify both protocols and NAT initiation directions using classic,
+software-flowtable and hardware modes. While counters advance, exercise:
+
+* All four wired LAN members, including ordinary LAN-to-LAN switching,
+ unknown-unicast flooding and broadcast delivery to a software member.
+* The bridge MAC differing from every member MAC, and a failed MAC change.
+* Wired client movement while reusing a live tuple without ARP or TCP
+ SYN/FIN/RST, and movement between a wired port and WLAN.
+* FDB replacement, deletion and aging, including ``master dynamic`` entries
+ intentionally omitted from switchdev notifications.
+* Member removal/addition, STP blocking, auxiliary-link loss, and a VLAN
+ filtering toggle. Unsupported configurations must keep working in software.
+* Concurrent WLAN software forwarding and wired FA traffic, checking
+ duplicate delivery, wire NAT/checksum/TTL correctness and raw FA keys.
+* Client-guard and NAT-table exhaustion, teardown, recovery, and a mixed
+ TCP/UDP soak with bridge FDB aging left enabled.
+
+A veth bridge member can test software-member forwarding and movement in
+an automated lab. It does not qualify a real WLAN driver or association
+and roaming behavior; repeat those cases with the intended PCIe radio.
+
+Three-host hardware test
+------------------------
+
+Before any traffic test, read the accelerator control registers at 0x18027c00,
+for example with ``devmem``, after a cold boot, both with GMAC3 enabled and
+disabled in the device tree. A bus error or a timeout during probe means that
+the registers are not accessible in the state in which the bootloader leaves
+that core, and the board cannot use the accelerator.
+
+Use a dedicated test router with serial access and two external Linux hosts.
+Traffic generated on the router itself does not exercise the inline receive
+path. Keep all other switch user ports administratively down. Replace the
+interface names below with those on the board::
+
+ LAN host BCM5301X router WAN host
+ 192.0.2.2/24 -- lan1 192.0.2.1 198.51.100.1 wan -- 198.51.100.2/24
+ \ /
+ GMAC2 / FA
+
+Assign distinct router MACs before bringing up the interfaces::
+
+ ip link set lan1 down
+ ip link set wan down
+ ip link set lan1 address 02:00:00:00:01:01
+ ip link set wan address 02:00:00:00:02:01
+ ip addr add 192.0.2.1/24 dev lan1
+ ip addr add 198.51.100.1/24 dev wan
+ ip link set lan1 up
+ ip link set wan up
+ sysctl -w net.ipv4.ip_forward=1
+
+On the LAN host, assign 192.0.2.2/24 and a default route via 192.0.2.1.
+On the WAN host, assign 198.51.100.2/24 and a default route via 198.51.100.1.
+Do not put the router ports in a bridge or create VLAN uppers. Ensure that
+other firewall rules on this lab router permit the test packets.
+
+Mount debugfs if necessary and locate the FA status file::
+
+ mount -t debugfs none /sys/kernel/debug
+ find /sys/kernel/debug -name fa -type f
+ cat /sys/kernel/debug/<GMAC2-device-name>/fa
+
+The file contains ``failed``, global ``hits`` and ``misses``, error bits,
+and a row for every programmed directional entry. Each row identifies its
+slot, cookie, input/output interfaces, and raw hardware packet count. Save
+snapshots with timestamps before, during, and after every test.
+
+The adjacent ``fa_table`` file shows each software-owned tuple and the eight
+hardware words in DATA7 through DATA0 order. It uses the same lock and
+bounded indirect accesses as statistics collection. Save it when an entry
+stops counting to compare the hardware key against software ownership.
+
+Install a uniquely named test table; do not flush unrelated tables::
+
+ table inet fa_test {
+ flowtable ft {
+ hook ingress priority 0;
+ devices = { lan1, wan };
+ flags offload;
+ counter;
+ }
+ chain forward {
+ type filter hook forward priority 0; policy drop;
+ meta l4proto { tcp, udp } ct state established flow add @ft
+ ct state established,related counter accept
+ iifname "lan1" oifname "wan" meta l4proto { tcp, udp } th dport 5001 counter accept
+ iifname "wan" oifname "lan1" meta l4proto { tcp, udp } th dport 5001 ct status dnat counter accept
+ }
+ chain prerouting {
+ type nat hook prerouting priority dstnat; policy accept;
+ iifname "wan" udp dport 15001 dnat ip to 192.0.2.2:5001
+ iifname "wan" tcp dport 15001 dnat ip to 192.0.2.2:5001
+ }
+ chain postrouting {
+ type nat hook postrouting priority srcnat; policy accept;
+ iifname "lan1" oifname "wan" meta l4proto udp ip saddr 192.0.2.2 snat ip to 198.51.100.1:45000
+ iifname "lan1" oifname "wan" meta l4proto tcp ip saddr 192.0.2.2 snat ip to 198.51.100.1:45000
+ }
+ }
+
+Save this as a ruleset and load it with ``nft -f <file>``. For the two control
+runs described below, edit only this test table. Delete it between phases
+with ``nft delete table inet fa_test``. Delete matching conntrack entries
+between phases, for example::
+
+ conntrack -D -p udp --orig-src 192.0.2.2 --orig-dst 198.51.100.2 --dport 5001
+
+For SNAT, run a UDP or TCP echo server on the WAN host at
+198.51.100.2:5001. Run a client on the LAN host, bind its source to
+192.0.2.2:40000, and connect to that server. Verify the server observes
+the translated peer 198.51.100.1:45000. Include a sequence number in each
+payload and check every returned payload for loss or corruption.
+
+Run three phases with a fresh connection each time:
+
+1. **Normal forwarding:** omit the ``flow add @ft`` rule. Forward-chain
+ counters should grow throughout the test. FA entry counts and hit counts
+ should not grow for this traffic.
+2. **Software flowtable:** restore ``flow add @ft`` and omit ``flags offload``.
+ Expect OFFLOAD and no hardware entries/hit growth for this flow. Reduced
+ forward-chain counters in this phase demonstrate why those counters alone
+ cannot prove hardware offload.
+3. **Hardware flowtable:** restore ``flags offload``. Wait a few seconds for
+ asynchronous rule installation, then compare multiple debugfs snapshots.
+
+The hardware phase passes only when all of the following hold:
+
+* The WAN server sees the peer as 198.51.100.1:45000, proving address and
+ source-port translation. The client receives the original payloads.
+* ``conntrack -L -p udp -o extended`` identifies the expected original and
+ reply tuples and reports HW_OFFLOAD. OFFLOAD alone is insufficient.
+* There are two hardware entry rows for the connection and **both** packet
+ counters advance while the echo stream runs. The netfilter core can mark
+ HW_OFFLOAD when only one direction is accepted, so check each direction.
+* The global FA hit count advances with the transfer, ``failed`` remains 0,
+ and hardware error bits do not increase.
+* Captures on the external hosts show the expected rewritten IPv4/TCP or
+ IPv4/UDP tuples, valid checksums, unchanged payloads, and exactly one TTL
+ decrement.
+* Router CPU load and GMAC DMA packet growth are substantially below the
+ software phase at the same offered packet rate. A router-side capture
+ should see initial misses but few steady-state packets from this stream.
+ Compare external captures; packet-capture placement and GRO can affect
+ counts on the router.
+
+Use ``tcpdump -ni <host-interface> -vv -w <capture.pcap> udp`` on both external
+hosts. If host checksum offload obscures validation, temporarily disable the
+relevant offloads on the test hosts and restore them afterward. Capture from
+the receiving host or a wire tap when checking checksums.
+
+For DNAT, stop the WAN server and run the echo server on the LAN host at
+192.0.2.2:5001. Run the client on the WAN host, bind it to 198.51.100.2:40001,
+and connect it to 198.51.100.1:15001. Verify destination IP/port translation
+on the LAN capture and the source IP/port restoration on the WAN reply.
+Repeat all three phases and require hit growth in both directions.
+
+Stress, teardown, and negative tests
+------------------------------------
+
+* Change SNAT to a port range for parallel sessions. Exercise multiple
+ clients and next hops, hot buckets, more than 128 next-hop MACs, and over
+ 512 bidirectional sessions. Failures to allocate must fall back to software
+ without modifying a different connection's entry. Four-way collisions can
+ exhaust a bucket before the whole table is full.
+* Keep a densely occupied table active while repeatedly reading statistics.
+ Compare the software tuples with the raw entries in ``fa_table`` before
+ and after the test. Every valid hardware key must match its owning slot,
+ cookies must stay stable and every active direction's counter must grow.
+ Intact echoes and HW_OFFLOAD labels alone can conceal damaged entries
+ whose traffic has fallen back to software.
+* Stop the generator and wait longer than the configured UDP conntrack
+ timeout. Hardware rows must disappear. Run sustained traffic longer than
+ that timeout and verify that counter-based last-used refresh keeps the
+ connection alive. Check packet counter wrap handling during a long soak.
+* Delete the test flowtable during traffic. Entries must disappear and
+ forwarding must continue through the remaining firewall/NAT path. Delete
+ only the flow-add rule first if retaining the table is useful for this test.
+* Disable ``hw-tc-offload`` on the conduit with ethtool. Entries must be
+ flushed and new hardware insertions rejected. Re-enable it and use fresh
+ connections.
+* Test port down/up, a third port up, router MAC changes, MTU changes, a bridge
+ or VLAN upper being added, conduit down/up, module unload/reload, and
+ suspend/resume if supported. Require removal of stale entries and clean
+ resource reuse. Start fresh connections after each topology change.
+* Try IPv6, ICMP, GRE, PPPoE, VLAN and QinQ devices, double NAT, and
+ hairpin NAT. They must not create FA entries. Exercise tagged packets whose
+ inner tuple equals a live untagged offload; they must not hit that entry.
+* Send IPv4 fragments, IP options, bad IP checksums, runt/truncated headers,
+ and switch exception traffic. Require software handling or the normal
+ stack/switch drop behavior, never a stale or unrelated hardware hit.
+* Verify UDP zero-checksum packets, nonzero checksums, packets whose updated
+ checksum folds to zero, minimum-size frames, and maximum MTU packets.
+* Repeat SNAT, DNAT, table pressure, software fallback, aging and recovery
+ with TCP. Require the TCP bit in every owned raw table key and advancing
+ counters in both directions. Compare classic, software and hardware modes.
+* While hardware data counters advance, capture SYN/FIN/RST on the GMAC0
+ auxiliary conduit. Require embedded Broadcom tags and delivery to Linux.
+ Close with FIN and RST, reuse the same tuple, and change its NAT
+ mapping; require immediate removal of the old hardware directions, correct
+ new peers and intact framed payloads. Repeat with options and fragmented
+ control packets. An HW_OFFLOAD label alone does not qualify this test.
+ Bring GMAC0 down while TCP data flows. Require removal of its hardware
+ rows, intact software forwarding, and rejection of new TCP hardware
+ entries. Bring GMAC0 up and require fresh connections to offload again.
+* Run TCP and UDP with identical IP addresses and transport ports. Require
+ independent hashes, hardware protocol bits and correct payload delivery;
+ closing TCP must leave the UDP directions installed and advancing.
+* With a development fault-injection mechanism, force an indirect-port busy
+ timeout. Require bounded completion, ``failed 1``, no further insertions,
+ no reuse of uncertain table resources, and working software forwarding.
+ Reprobe before repeating. The driver provides no writable debugfs register
+ interface; do not poke live registers from userspace.
+
+Boundary and invalidation qualification
+---------------------------------------
+
+Run these tests with UDP and TCP, SNAT and DNAT, and classic, software
+flowtable and hardware forwarding. Install both hardware directions and
+verify their raw keys before injecting packets of that same live tuple:
+
+* TTL 0 and 1 must produce the software baseline's ICMP time-exceeded
+ response without forwarding a wrapped TTL. Ordinary traffic must decrement
+ TTL exactly once.
+* An IP length of 1500 must pass. At 1501, DF must produce ICMP fragmentation
+ needed with MTU 1500; without DF, Linux must fragment into packets no
+ larger than 1500. Check transport checksums after reassembly.
+* Inject the tuple on the opposite physical port, addressed both to the
+ original input MAC and the receiving port's MAC. Require the same ingress
+ firewall policy as the software baseline. Also test unrelated unicast,
+ broadcast and multicast destination MACs. These must not enter IPv4
+ forwarding merely because a five-tuple matches.
+
+While a hardware connection is live, replace its neighbour MAC and require
+all subsequently forwarded frames to use the new MAC. Set the neighbour to
+``NUD_FAILED`` while preventing ARP replies and require forwarding to stop.
+Restore reachability and require recovery. Force a valid neighbour to STALE
+while hardware counters advance and require a Linux ARP reachability probe.
+
+Install a blackhole host route and then a source-policy blackhole rule;
+require forwarding to stop after each netlink acknowledgment. Remove each
+change and check payload delivery and fresh hardware admission. Add an MTU
+1200 host route both during an existing connection and before a fresh one.
+Require zero hardware entries, intact small software-forwarded packets and
+ICMP fragmentation-needed with MTU 1200 for a 1280-byte DF probe. Remove
+that route and verify recovery. Keep the flowtable installed throughout;
+recreating it would conceal missing invalidation.
+
+Fault injection qualification
+-----------------------------
+
+A development kernel can enable ``CONFIG_FAULT_INJECTION``,
+``CONFIG_FAULT_INJECTION_DEBUG_FS`` and
+``CONFIG_BCM_NS_FA_FAULT_INJECTION``. The per-device ``fail_table`` directory
+uses the standard fault-injection attributes. The default probability is
+zero. Injection returns a timeout after an indirect transfer has completed,
+which deliberately makes completion uncertain to its caller. This tests
+software handling of uncertain reads and writes, including a write that may
+already have published an entry; it does not emulate a physical bus hang.
+The ordinary hardware busy/address waits remain bounded independently.
+
+For one injected failure, with the device name adjusted as needed::
+
+ D=/sys/kernel/debug/bcma0:5
+ echo 1 > $D/fail_table/times
+ echo 1 > $D/fail_table/interval
+ echo 0 > $D/fail_table/space
+ echo 100 > $D/fail_table/probability
+
+The next table access fails. To restrict injection to a table write, set
+``fail_table_write_only`` to ``Y`` before arming it, then insert a fresh
+connection or delete an installed one. Run read, insertion and deletion
+cases on separate clean probes. Verify ``failed 1`` and exactly one
+``fault_injections`` increment. Lookup must be disabled before the paused
+switch traffic resumes. Broadcom-tag relocation must remain active, and
+uncertain entries and MAC resources must not be reused until reprobe.
+
+Keep UDP and TCP SNAT/DNAT traffic active across each failure. Validate all
+eight wire directions for correct tuples, payloads, checksums and exactly
+one TTL decrement. Require a fresh connection to work in software and an
+ethtool feature toggle to leave the failed state latched. Stop the test,
+reprobe and require clean hardware admission again. Do not poke live
+registers from userspace; no writable register interface is provided.
+
+Automated validation
+--------------------
+
+Run the supplied KUnit configuration from a clean source tree::
+
+ ./tools/testing/kunit/kunit.py run --arch=x86_64 \
+ --kunitconfig=drivers/net/ethernet/broadcom/.kunitconfig \
+ --build_dir=/tmp/bcm-ns-fa-kunit
+
+The backend, switch and tagger provide KUnit suites named ``bcm-ns-fa``,
+``b53-fa-guards`` and ``brcm-fa-tag``. Enable ``CONFIG_BCM_NS_FA_KUNIT_TEST``,
+``CONFIG_NET_DSA_TAG_BRCM_FA_KUNIT_TEST`` and ``CONFIG_B53_FA_KUNIT_TEST``
+with KUnit and their parent drivers. ``CONFIG_NF_FLOW_TABLE_KUNIT_TEST``
+adds the ``nf-flow-lifetime`` and ``nf-flow-path`` suites for flowtable
+ownership and cached route validation, which the configuration also enables,
+so do not filter the suites by name. A few cases which access registers are
+skipped on UML, where MMIO is emulated.
+They cover cross-word field layout and endianness, NAT action rejection,
+miss-hash learning exclusions, opcode validation, source-port demultiplexing,
+consumption of the four-byte metadata tag, route-MTU admission and CFP UDF
+layout. The length-prefix test checks all 65536 possible IPv4 lengths.
+These tests do not simulate the FA.
+
+Build the bgmac, B53, and DSA objects with ``W=1`` for ARM, plus an x86
+COMPILE_TEST configuration; also check the FA-disabled configuration and
+built-in/module combinations. Run ``dt_binding_check`` for both new schemas,
+``checkpatch.pl``, and ``git diff --check``. The hardware matrix above remains
+mandatory even when all automated checks pass.
diff --git a/Documentation/networking/device_drivers/ethernet/index.rst b/Documentation/networking/device_drivers/ethernet/index.rst
index 403ae9c2b06a9..007e5c5c892ac 100644
--- a/Documentation/networking/device_drivers/ethernet/index.rst
+++ b/Documentation/networking/device_drivers/ethernet/index.rst
@@ -18,6 +18,7 @@ Contents:
amd/pds_vdpa
amd/pds_vfio_pci
aquantia/atlantic
+ broadcom/bcm-ns-fa
chelsio/cxgb
dlink/dl2k
davicom/dm9000
diff --git a/MAINTAINERS b/MAINTAINERS
index c05ac2258889e..7fbc78f9dd413 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -5672,6 +5672,7 @@ S: Maintained
F: Documentation/devicetree/bindings/net/brcm,amac.yaml
F: Documentation/devicetree/bindings/net/brcm,bcm4708-fa.yaml
F: Documentation/devicetree/bindings/net/brcm,bcm5301x-gmac.yaml
+F: Documentation/networking/device_drivers/ethernet/broadcom/bcm-ns-fa.rst
F: drivers/net/dsa/b53/b53_fa_test.c
F: drivers/net/ethernet/broadcom/.kunitconfig
F: drivers/net/ethernet/broadcom/bcm-ns-fa*
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-12-01 18:23 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-01 18:22 [PATCH net-next v2 0/6] Add Northstar FA TCP/UDP NAT offload with a bridged LAN Florian Fainelli
2026-12-01 18:22 ` [PATCH net-next v2 6/6] docs: net: document Northstar FA setup and NAT qualification Florian Fainelli
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox