The RX path marked TCP/UDP checksums hardware-verified unless
FM_FD_CMD_DCL4C was set, but that is a TX command bit: frames with bad
checksums could be accepted (IDS evasion). Claim CSUM_L4_VALID only with
FM_FD_STAT_L4CV in the frame status, as Linux's dpaa_eth does. Nothing
says the parser checked the IPv4 header checksum, so the stack verifies
it again.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- machdep.c: drop the socdev_va and hcr_el2 lines carried over from
26.1. Upstream 26.7 defines socdev_va itself and no longer uses
hcr_el2, which -Werror rejects as unused.
- fman_fdt.c: the clock header moved to dev/clk/clk.h.
- fm_ehash.c: cpu_dcache_wbinv_range() takes a pointer now.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Change GATEWAY kernel config from UFS root to ZFS root (pool0/ROOT/default).
ZFS is compiled into the kernel since booti direct boot has no FreeBSD loader
to load modules. Disable kern.geom.label.disk_ident.enable so GPT labels
work cleanly with ZFS.
Remove printf from fman chardev ioctl default cases. ZFS GEOM probes all
character devices with DIOCGMEDIASIZE (0x40086481) at boot, generating ~32
spurious "unknown ioctl" messages. ENOTTY is the correct response and the
printf serves no diagnostic purpose.
Move ~900 lines of SFP management code (GPIO polling, EEPROM reading,
RollBall I2C-MDIO PHY probing, auto-negotiation, link monitoring) from
the dtsec MAC driver into the sfp_fdt framework driver.
sfp_fdt now implements a full state machine (EMPTY → PROBE → PRESENT →
PHY_PROBE/WAIT_LOS → PHY_AN/DDM_POLL → LINK_UP) that handles module
detection, identification, and link management for any MAC driver with
SFP+ cages. MAC drivers register a callback table (sfp_upstream_ops)
via SFF_REGISTER_UPSTREAM() and receive module_insert, module_remove,
link_up, and link_down events.
dtsec is reduced to ~50 lines of callback implementations that update
interface link state and store module info for sysctl reporting.
Tested on hardware with both fiber (FLEXOPTIX DAC) and copper (FS.com
10GBASE-T with AQR113C PHY via RollBall) modules at 10 Gbps.
Add support for copper (RJ45) SFP+ modules with embedded PHYs.
These modules use Clause 45 MDIO registers accessed via an I2C-to-MDIO
bridge for PHY management, auto-negotiation, and link status polling.
Two bridge protocols are supported with automatic detection:
- RollBall (I2C addr 0x51, page 3, command-based)
- Standard I2C-MDIO (I2C addr 0x56, SFF-8472)
PHY probe runs on module insertion for RJ45 connectors, configures
auto-negotiation (10G/5G/2.5G/1G advertisement with Extended Next Page),
and polls PMA/PMD link status at 1Hz via taskqueue. Speed detection
uses AN 10GBT_STAT for multi-gig and PMA/PMD CTRL1 as fallback.
For copper modules without accessible PHY (autonomous operation),
falls back to DDM RX_LOS polling for link state detection.
Also fixes three GPIO issues that prevented copper modules from working:
- TX_DISABLE pin direction must be set to OUTPUT explicitly
- TX_DISABLE polarity inverted due to board hardware inverter
- Module PHY stays inactive until TX_DISABLE is properly deasserted
Verified at 10 Gbps (9.4 Gbps iperf3) with FS.com SFP-10G-T (AQR113C)
and Intel X550 link partner over Cat6e cable.
Use LINK_STATE_UNKNOWN for no-module state (instead of DOWN) so the
sfpled driver can distinguish "no module" from "module present, no
link". For copper PHY modules (RJ45 connector type 0x22), ignore
LOS GPIO — these modules deassert LOS when powered up regardless
of copper link negotiation status. Always report LINK_STATE_DOWN
for RJ45 modules until a PHY driver can negotiate.
Wire SFP infrastructure into dtsec so 10GbE ports detect module
insertion/removal via mod-def0 GPIO polling, read the SFP EEPROM
for identification, control TX enable/disable, and report accurate
link status via LOS GPIO instead of hardcoding link as always up.
Module presence is polled at 1Hz in the existing tick callout.
EEPROM reads are deferred to taskqueue_thread since I2C can sleep.
Insert task re-checks module presence under DTSEC_LOCK to handle
races with hot-removal during EEPROM read.
Adds dev.dtsec.N.sfp_info sysctl for module vendor and part number.
No DTS changes needed — sfp phandle, GPIOs, and i2c-bus are already
defined in mono-gateway-dk.dts.
Move the 5 fmlib ioctl ABI headers (fm_pcd_ioctls.h, fm_ioctls.h,
net_ioctls.h, ioctls.h, integration_ioctls.h) from the external
opnsense-deps repo into sys/contrib/ncsw/inc/ioctls/. This makes the
kernel buildable without depending on a sibling repository.
Merge FMCD_COMPILE_CMD into DPAA_COMPILE_CMD since it only added a
single -I path; fman_chardev.c now compiles with the same flags as all
other DPAA source files.
LAGG member ports are enabled via SIOCSIFFLAGS -> dtsec_if_enable_locked(),
not dtsec_if_init_locked(). The MII tick callout was only started in the
init path, so LAGG member ports never got periodic PHY polling. Without
the tick, link state changes (cable unplug/replug) were never detected
and RTM_IFINFO was never generated.
Start callout_reset in dtsec_if_enable_locked() so member ports get the
same periodic PHY polling as standalone ports. Also reprogram the hardware
MAC address via FM_MAC_ModifyMacAddr() since LAGG changes the stack MAC
via if_setlladdr() then cycles SIOCSIFFLAGS.
dpaa_oh: Add per-VAP distribution FQ registry so CDX can route WiFi
download frames to hash-distributed FQIDs. Add dist fallback callback
for frames with unrecognized BPIDs on OH dist FQs. Return EBUSY from
dpaa_oh_enqueue when EQCR ring is full so callers can retry. Free
dtsec buffers in error callback to prevent BMan pool drain.
if_dtsec: Export dtsec_rm_pool_rx_refill_bpid for external callers
(dpaa_wifi, dpaa_oh, CDX) that consume dtsec BMan pool buffers.
fm_ehash: Rewrite ModifyMissNextEngine to match Linux SDK two-phase
pattern (DROP→update→real action). Support KG (with CC_EN), PLCR
(shared profile), and DONE engines. Remove verify-retry loop and CC
tree copy propagation — single WRITE_UINT32 per word suffices with
the two-phase approach.
qman_portals: Add qman_portal_quiesce() to drain all per-CPU portal
poll taskqueues. Called after FQR retire to ensure no in-flight
QM_PORTAL_Poll references a stale callback from an unloading module.
if_dtsec_rm: Add dtsec_rm_pool_rx_refill_bpid() for external callers
(CDX dist FQ callback) to trigger BMan pool refill by BPID.
dpaa_oh: Add distribution FQ callback registry (register/unregister/
lookup by BPID) for OH port consumers (WiFi, IPsec) to receive
frames from CDX distribution FQs. Add MODULE_VERSION.
Add dtsec_rm_buf_free_external() for dpaa_wifi.ko to release BMan
buffers from dtsec RX pools back to the correct UMA zone. Route
M_PROTO1-tagged mbufs to if_transmit in QMan portal drain path.
Process gpio-hog child nodes during gpiobus attach to configure pins
at boot. Used on Mono Gateway for WiFi module enable (2R-enable),
3R-disable, and UART mux routing.
- qoriq_dw_pci: byte-swap CCSR register access for big-endian controller
- pci_dw: lane configuration support for proper link training
- DTS: enable PCIe3 for WiFi module (88W9098)
Firmware-based SGMII PHY used on the Mono Gateway (3x 1GbE ports).
Key differences from standard PHY drivers:
- No BMCR reset (kills firmware, darkens LEDs)
- SGMII auto-negotiation via MMD VEND1 register
- Status read from MIISTAT instead of BMSR
OH ports provide hardware packet processing pipelines for IPsec and
WiFi offload via CDX. Port assignment matches Linux SDK: cell-index 3
(IPsec), cell-index 4 (WiFi). Cell-index 2 reserved for Host Command.
Add the main DPAA1 Ethernet driver using the NCSW FM_MAC API for
mEMAC (LS1046A FManv3). Implements TX/RX via QMan frame queues and
BMan buffer pools with scatter-gather support.
Features: TX checksum offload (RPD+DTC), RX checksum validation with
PCD parser, 128-FQID RSS via FMan KeyGen, deferred RX delivery via
mbufq to prevent SMP hard lockups from nested NCSW_PLOCK, per-port
BMan buffer pool with consumption model and in-flight cap.
Includes mEMAC external MDIO controller for PHY management.
Add the FreeBSD bus driver wrappers that bridge NCSW to the kernel
device tree. BMan and QMan portal drivers handle multi-CPU
initialization with explicit CPU binding (sched_bind unavailable
during attach). FMan driver configures the frame manager hardware,
reserved-memory regions (PFDR/FQD/FBPR via no-map DT nodes), and
MURAM allocation.
Portal common infrastructure provides shared init and cache-inhibited
mapping for both BMan and QMan portals.
Add the MONO-GATEWAY kernel configuration for the NXP LS1046A-based
Mono Gateway Development Kit. Based on GENERIC with OPNsense standard
features, DPAA1 build infrastructure (empty file list for now), and
early printf via QorIQ ns16550.
Add the mono-gateway-dk.dts device tree covering the full SoC and board
peripherals (DPAA1 FMan/QMan/BMan, I2C mux tree, GPIO, UART, eMMC, QSPI,
SFP+ cages, and reserved memory regions).
Add ARM64 I/O stubs (pio.h) for NCSW compatibility, EARLY_PRINTF qoriq
type registration, CAAM RNG entropy source enum, and qoriq_therm build
fix (remove spurious pci dependency).
If the parent bridge's [secondary, subordinate] window already covers
the VF bus (e.g., programmed by BIOS or a prior PF), skip allocating
PCI_RES_BUS. This avoids a duplicate rman allocation in the multi-PF
case while still allocating when growth is actually needed.
Reviewed by: ssaxena
Differential Revision: https://reviews.freebsd.org/D52163
(cherry picked from commit feb0a7e19f3c2e4c7eb90668b1e3dc34b5bb6dd6)
Distinguish the two failure classes from the PR in a single log line
(ring indices, ISR/IMR, TXCFG, interrupt mode): lost interrupt vs
genuine DMA stall.
Bail out instead of re-initializing when the controller reads back
all-ones (fallen off the bus; reinit cannot help).
Re-assert the driver's existing ASPM-disabled policy before reinit,
since firmware/power transitions re-arming L0s/L1 is a documented
stall trigger.
Diagnostics-only on the recovered path; no fast-path change.
* Field diagnostics running on an RTL8168H production fleet; the log
format distinguishes lost-doorbell / DMA-stall / dead-controller
without a debug build.
Reviewed by: adrian
Differential Revision: https://reviews.freebsd.org/D58279
PR: kern/166724
(cherry picked from commit 42f3088bd980a469dbbc3e6b568edb7ce0ab2bc3)
A Tx completion that raises a status bit between the ISR ack at the top
of re_intr_msi() and the IMR re-enable at the bottom is never re-signalled:
these controllers do not re-assert MSI for an already-set status bit
(this is why hw.re.msi_disable is a known workaround in the PR).
Re-read ISR before re-enabling; if a Tx bit is pending, ack just that bit,
reap the ring and restart the queue. Rx bits are deliberately left set so
they re-arm the interrupt normally and Rx moderation state is untouched.
Also flush the posted IMR write. Mirrors what the INTx path already
achieves via the loop in re_intr().
* MSI interrupt mode on RTL8168H under load; "missed Tx interrupts"
watchdog recoveries no longer occur.
Reviewed by: adrian
Differential Revision: https://reviews.freebsd.org/D58278
PR: kern/166724
(cherry picked from commit d11f124e932bfa4fabdc6c5b67735181615a0630)
On PCIe parts a TxPoll request can be lost when packets are queued
in quick succession, leaving owned descriptors with no transfer in
progress until the watchdog fires. re_txeof() runs from the interrupt
handlers, re_tick() and re_watchdog(), so re-writing TXSTART whenever
the ring is still non-empty turns a potential 5-second stall into at
most one tick.
One register write on a path that already took an interrupt;
fast path untouched.
* Sustained bidirectional load on RTL8168H; no Tx stalls, no throughput
regression at 941 Mbps line rate.
Reviewed by: adrian
Differential Revision: https://reviews.freebsd.org/D58277
PR: kern/166724
(cherry picked from commit 4bff6b9f5cef13df8540fa6869bd6707f8e7575d)
The STOPREQ command written by re_stop() is not defined for
RTL8168G and later; issuing it can wedge the MAC.
Replace it on those parts with the vendor-documented sequence:
* settle delay
* bounded poll for Tx queue empty
* clear TE/RE
* then bounded poll of the MCU command register (0xD3) FIFO-empty bits.
Also reset the controller before the Rx/Tx buffer free: a controller that
has not quiesced keeps DMAing stale, still-owned descriptors pointing at
freed mbufs (use-after-free under INVARIANTS, cross-NIC mbuf corruption
reported in the PR).
Adds the RL_MCU_* register definitions.
All waits are bounded; error paths only.
* iperf3 --bidir at line rate against RTL8168H (XID 0x541);
previously wedged the controller until power cycle, with the
quiesce the reset path recovers.
* Deployed in production on an RTL8168H fleet since 2026-07-01.
Reviewed by: adrian
Differential Revision: https://reviews.freebsd.org/D58276
PR: kern/166724
(cherry picked from commit 38187938f52283143308dd219db35d889da55ea4)
HW generic stats provide information about PCIe transactions and
out-of-order doorbell writes, useful for debug. Allocate a DMA buffer
for them (disabling BNXT_FW_CAP_GENERIC_STATS if the allocation
fails), fetch them via HWRM_STAT_GENERIC_QSTATS once per admin-status
tick on P5+ chips, and expose them to userspace under
dev.bnxt.<unit>.hwstats.generic_stats.* via sysctl.
Reviewed by: gallatin
MFC after: 2 weeks
Sponsored by: Broadcom Inc.
Differential Revision: https://reviews.freebsd.org/D58614
(cherry picked from commit d1619865da1cd4c5b557158b4bbf666e0f7f040b)
Copying the STQM backing-store context to seed FTQM's also copied
STQM's pg_info pointer verbatim. On cold load STQM's pg_info is still
NULL so this is harmless, but on a firmware reset STQM's pg_info is
already non-NULL, making FTQM alias STQM's backing-store pages. The
allocator then skips FTQM since it looks already allocated, and FTQM
is later indexed as its own array, reading out of bounds into STQM's
buffer and dereferencing a bogus DMA address.
Clear ctxm->pg_info after the memcpy so FTQM always gets its own
backing store.
Reviewed by: gallatin
MFC after: 2 weeks
Sponsored by: Broadcom Inc.
Differential Revision: https://reviews.freebsd.org/D58615
(cherry picked from commit f2ce672ade231a1e19f1238922a2c3b6fe696e22)
Advertise IFLIB_I2C_PAGE_BANK and forward the requested page/bank to
firmware, so CMIS optics can be read correctly instead of falling
back to bogus legacy SFF-8472 decoding. Also fix bnxt_i2c_req() to
return positive errno values.
Signed-off-by: gallatin
Reviewed by: gallatin
MFC after: 2 weeks
Sponsored by: Broadcom Inc.
Differential Revision: https://reviews.freebsd.org/D59573
(cherry picked from commit fdab50f6f8107c9d825a7e6d92d7a6b89c417bbb)
bnxt_dcb_init() currently pushes all-zero ETS and PFC settings to
the firmware at every attach. This reserves bandwidth allocation
for RoCE traffic, which prevents L2 traffic from reaching line rate.
These settings should only be updated with valid values when the
RoCE driver is loaded. Therefore, we should stop programming them
during bnxt_dcb_init().
Signed-off-by: Andy Gospodarek <gospo@broadcom.com>
Reviewed by: chandrakanth.patil_broadcom.com, gallatin
MFC after: 2 weeks
Sponsored by: Broadcom Inc.
Differential Revision: https://reviews.freebsd.org/D60516
(cherry picked from commit 31cbd8f27d687ce9b10a22c858296532be400bb4)
An interrupt storm was observed on Thor2 because the Rx CQ consumer
index was always one less than it should be. Correct the Rx CQ
consumer index to fix the storm.
Reported by: gallatin
Reviewed by: gallatin
MFC after: 2 weeks
Sponsored by: Broadcom Inc.
Differential Revision: https://reviews.freebsd.org/D58602
(cherry picked from commit 8c69a5dc60b3630a4c5bca0bda714f791324afad)
Stop initialization when hardware setup, ring initialization/start, or
datapath start fails. Run the existing best-effort stop/cache/reset
cleanup and report the failure through iflib_init_failed(). Do not keep
configuring later rings or publish the interface as running.
Reviewed by: nprice
MFC after: 2 weeks
Sponsored by: BBOX.io
Differential Revision: https://reviews.freebsd.org/D59853
(cherry picked from commit 050683bb8e136981e4a1f66e845ab05c135630f4)
Atlantic controllers can retain receive descriptors and their data
addresses after their rings are disabled. Reusing or releasing those
mappings without invalidating the device cache has caused observed
IOMMU and SMMU faults in the referenced Linux reports (7a1bb49461b1,
ed4d81c4b3f2 and 7526183cfdbe).
Move global cache invalidation out of the per-ring stop routine. Disable
every ring first, toggle invalidation once, and wait for its completion
indication. Exclude Atlantic A0, as in the upstream workaround. Report
a completion timeout rather than silently discarding it.
Reviewed by: nprice
MFC after: 2 weeks
Sponsored by: BBOX.io
Differential Revision: https://reviews.freebsd.org/D59852
(cherry picked from commit 4993c1052f899b9a971815df5661ca241641ad8e)
Fetch the common RSS key independently of options RSS instead of
generating a private key in non-RSS kernels. Keep the existing
software-RSS or round-robin indirection policy and hardware key
serialization unchanged.
Reviewed by: gallatin
MFC after: 2 weeks
Sponsored by: BBOX.io
Differential Revision: https://reviews.freebsd.org/D59793
(cherry picked from commit 772994d7748287be70fe850ec9e1117d4e7b1747)
aq_fw2x_thermal_arm() reached for a copper PHY register that the fibre
parts do not implement, so arming failed on every init and printed a
warning for a capability the hardware cannot have. Return ENOTSUP when
the firmware does not advertise a temperature sensor, matching
aq_fw2x_get_temp(), and warn only for a genuine failure.
Signed-off-by: Nick Price <nprice@FreeBSD.org>
Accepted-by: adrian
Approved-by: adrian
(cherry picked from commit 6dbf809bafe1421fbf3cdd952748b15437b7c72a)
The D100 device ID was defined and handled by aq_hw_capabilities(), but
had no entry in aq_vendor_info_array[], so the driver never probed it and
the card was left unattached. Add the missing entry; the table lists the
fibre variant last within each group, so it follows D109 rather than
sorting numerically.
Signed-off-by: Nick Price <nprice@FreeBSD.org>
Accepted-by: adrian
Approved-by: adrian
(cherry picked from commit 1a78f5ae3917b770bd958010dae86574b15d97ff)
A link flap left nothing in the log to work from. Both the link up and
link down messages were gated on bootverbose while the message for a
speed change that keeps carrier was not, so a default kernel was silent
about a flap yet loud about a downshift -- the inverse of what an
operator wants. The generic message from if_link_state_change() carries
no speed, so gating the driver's own left the negotiated rate
unrecorded. Report both transitions unconditionally.
Say more than the rate. aq_hw_get_link_state() already negotiates flow
control and throws it away, and Atlantic 2 reports duplex and EEE in the
same link status word the rate comes from; decode them through a new
get_link_info firmware op and name all of it on the up transition. EEE
matters for a flap: low power idle transitions are a common source of
marginal link trouble on multi-gigabit copper, and whether it was active
is otherwise invisible.
Give the down transition a cause. The PHY global fault code was only
consulted from the thermal state machine, so an ordinary link loss
reported nothing at all. Read the fault code, the firmware link state
and the PHY temperature once per transition and append whatever is
available. The firmware raises a fault one poll after it drops the
link, so a thermal trip usually shows only its temperature here and
aq_thermal_poll() names it on the following poll; the temperature alone
is enough to separate a hot PHY from a cable event.
Warn before the PHY trips rather than only after. The Atlantic 2 health
monitor word carries a hot warning bit next to the ready and fault bits
that nothing decoded. Report both edges of it from the thermal poll, so
an adapter that is approaching its shutdown threshold says so while the
link is still up.
Expose the firmware's own link transition counters. The Atlantic 2 A0
statistics layout opens with link_up and link_down, which were read out
of the firmware on every statistics poll and discarded. Publish them as
dev.aq.N.fw_link_up and fw_link_down so a single flap can be told from a
link that has been flapping all night. The B0 layout has no equivalent,
so the op reports ENOTSUP there and the nodes are not created, matching
how the temperature node is handled.
Stop announcing a link state that was never read. The return value of
aq_hw_get_link_state() was discarded, so a failed read would have been
announced as link down. No firmware backend can fail that call today --
all three decode a register with no error path -- but the caller no
longer depends on that, and it says so once if it ever starts failing.
Report the hardware failures that were being discarded. The driver
already reports the errors it keeps, so what stayed quiet was the set of
calls whose result was never examined at all. None of these are
expected to fail, which is precisely why a failure needs to say so: each
one leaves the interface running but misconfigured in a way that
presents as a network problem rather than a driver problem. aq_if_init()
discarded aq_hw_start(), aq_hw_rss_hash_set(), aq_hw_rss_set() and
aq_hw_udp_rss_enable(), so a datapath that never started or an
indirection table that was never programmed showed up only as an
interface that passes no traffic or delivers every flow to one queue.
aq_mc_filter_apply() discarded aq_hw_mac_addr_set(), so a multicast
address the stack believes is programmed could silently not be; report
the address that failed and leave the filter slot for the next one
instead of burning it. aq_update_vlan_filters() reported only the last
of its three register writes. aq_if_stop() discarded both ring stop
calls and the MAC reset, and a MAC that did not reset can still be
mastering the bus. aq_if_detach() and aq_if_suspend() discarded
aq_hw_deinit(). The interrupt moderation update on a link speed change
was dropped as well; it runs only on a transition, so reporting it
cannot become noisy.
aq_if_attach_pre() discarded aq_hw_capabilities(), which is the only
behavioral change here: it now fails the attach rather than continuing
with an unset media type and an empty link speed mask, which would
attach an interface that can never negotiate a link. It returns an
error only for a device the probe table does not cover, so it is not
reachable in practice.
Document the resulting sysctls, along with the existing temperature and
tracing nodes, which had no manual page coverage.
Tested on an AQC113C (Atlantic 2 B0, firmware 1.5.38). Link up reports
"speed=10000, full-duplex, flowcontrol none, EEE off", and "speed=1000"
after a forced renegotiation, so the rate and duplex are read rather
than assumed. A cable pull reports "link DOWN, F/W link state 0, temp
59 C" with the PHY fault clause correctly absent, which is what
separates a cable event from a thermal trip. The B0 interface reports
ENOTSUP for the link counters, so those two nodes are correctly not
created. Traffic is unaffected: ten flows spread over all eight RX
queues with no errors and no drops.
Reviewed by: adrian
Differential Revision: https://reviews.freebsd.org/D58749
Signed-off-by: Nick Price <nprice@FreeBSD.org>
(cherry picked from commit af3f2dd124f07342c273dc017bc5e73639e446a5)
aq_if_init() programmed the address captured at attach, so an address set
with "ifconfig ether" or by lagg(4) enslavement was never written to
unicast filter slot 0: the interface transmitted with the new address but
the MAC still filtered on the old one, so it received nothing. Copy the
current if_getlladdr() the way the other iflib drivers do.
The link state could latch UP forever. aq_if_stop() cleared linkup
before calling aq_if_update_admin_status(), which suppressed the
LINK_STATE_DOWN transition the "link was UP" branch would have made.
Announce the down transition directly from aq_if_stop() instead, and do
not poll the admin status there at all: the MAC has just been reset, so a
stale link reading would re-announce the link as up.
The admin task itself had to stop reporting a link on a stopped
interface. iflib runs it while either IFF_DRV_RUNNING or IFF_DRV_OACTIVE
is set, and iflib_stop() sets OACTIVE, so the task kept polling after the
stop and re-announced LINK_STATE_UP behind the driver's back. Treat a
non-running interface as having no link. A lagg(4) parent otherwise
keeps hashing flows onto a port whose carrier is gone, because
LAGG_PORTACTIVE tests if_link_state together with IFF_UP. Stop the rest
of the task there as well: the PHY thermal poll and the initialization
retry both end in iflib_request_reset(), and _task_fn_admin() acts on
that with no test of its own, so either could re-initialize an interface
the operator had just taken down.
aq_if_update_admin_status() also only reacted to transitions in and out
of zero speed, so an autoneg downshift that kept the link up left
if_baudrate, ifmedia, RX pause and interrupt moderation programmed for
the old speed. Track the announced speed and re-run that work when it
changes.
aq_if_suspend() resets the MAC and stops the rings, but
iflib_device_suspend() only calls IFDI_SUSPEND and never stops the
interface, leaving IFF_DRV_RUNNING set over a suspended device. Clear it.
Signed-off-by: Nick Price <nick@spun.io>
Reviewed by: adrian
Differential Revision: https://reviews.freebsd.org/D58473
(cherry picked from commit c956cc0f033a4050fbca4e39fdace7276a588e15)
Fold the whole-driver-review correctness and hardening fixes for the
firmware and hardware layers.
Advance the firmware-mailbox address per word in aq_hw_fw_downld_dwords():
on B1 silicon each loop iteration waits for the mailbox address register
to differ from the expected address, but it was set once and never moved,
so after the first word every wait returned immediately and read stale
data. Advance it four bytes per word. B0 is unaffected (it polls the
busy bit). The same function also left err set to ETIMEDOUT after
successfully force-recovering the RAM CPU semaphore; the transfer loop is
guarded by "--cnt && !err", so it ran zero iterations and returned a
timeout with an untouched buffer, making the recovery path dead code.
aq_hw_get_mac_permanent() ignored the get_mac_addr() error and then
examined a buffer the firmware op never wrote on failure. A fresh softc
is zero, so the "invalid address" test fired, a random locally
administered MAC was substituted, and err was overwritten with 0 -- a
transient mailbox failure produced a card that attached with a different
MAC every boot. Fail instead; the random-address fallback still covers a
genuinely blank or multicast burned-in address. aq_fw1x_reset()
discarded the same download's return value and then read transaction_id
out of an uninitialized stack struct, so propagate that error too.
Encode RX-only flow control as PAUSE|ASYM_PAUSE rather than PAUSE alone:
firmware 2.x/3.x has no independent RX-only bit, so the old encoding
advertised symmetric pause when RX-only was requested. The MPI_INIT path
also never cleared the pause bits before OR-ing in the requested ones, so
flow control could be enabled and never disabled; clear them first, as
the Atlantic 2 and Linux implementations do.
Reject single-vector MSI in aq_if_attach_post() the same way legacy INTx
is rejected: ift_legacy_intr is NULL, so no driver filter would
acknowledge the not-clear-on-read, auto-masked device interrupt status;
every supported Atlantic device provides MSI-X.
Propagate firmware and MDIO errors instead of discarding them. The fw2x
MDIO primitive returned a data word with no way to report a controller
timeout; give aq_fw2x_mdio_op() a status return and a data out-parameter,
propagate it through phy_write/read/reset/thermal_arm, and stop advancing
the thermal recovery state machine when a PHY reset fails. Use that
error to end the PHY address scan early: aq_fw2x_init_phy_id() probed all
32 MDIO ports even when the controller itself was timing out, spending up
to ten seconds under fw_mtx and the iflib context lock. aq_fw2x_reset()
also drove the shared MIF mailbox without fw_mtx, unlike every other fw2x
mailbox user, so it could interleave with the temperature sysctl and load
the capability mask from the wrong window.
aq_hw_mpi_set() can return ETIMEDOUT when the Atlantic 2 shared firmware
buffer is not acknowledged; aq_hw_init() now aborts through its error
path rather than enabling rings with an unaccepted link state, and
aq_if_init() logs the later link-speed error.
Retry a failed initialization instead of leaving the link down. ifdi_init
has no return value, so iflib marks the interface running once aq_if_init()
returns; a propagated firmware-ack failure would otherwise leave it running
with no initialized hardware and no recovery. Record the failure and retry
from the admin task via iflib_request_reset(), paced by the once-per-second
timer, giving up after a bounded number of attempts. Ring and queue start
failures are deliberately left to the existing diagnostic, since they leave
the remaining queues usable.
Reviewed by: adrian
Differential Revision: https://reviews.freebsd.org/D58437
(cherry picked from commit b445000158d39a126f5fcd6e18bbc32248f0bc68)
Non-functional cleanup, no change in behavior.
device_printf() already prefixes each line with the device name, so the
inline "atlantic:" token in the status and error messages produced a
doubled prefix and diverged from the trace macros; remove it so all
output carries one uniform "aqN:" prefix. Compile the RX/TX descriptor
tracers only when AQ_CFG_DEBUG_LVL > 2 and make them no-op macros
otherwise, so the default build no longer pays a cross-TU call plus
argument evaluation per descriptor.
Drop enum aq_dev_state, struct aq_rx_filters, and struct aq_vlan_tag,
which have no remaining references now that VLAN state lives in a
bitstr_t. Replace the four identical aq_sysctl_print_{tx,rx}_{head,tail}
handlers, each carrying a dead write path on a read-only oid, with one
aq_sysctl_print_ring_ptr that selects the accessor from arg2. Reduce the
thermal and PHY-recovery comments to single terse lines that keep the
load-bearing register numbers and the A1-vs-A2 recovery difference.
Signed-off-by: Nick Price <nick@spun.io>
Reviewed by: adrian
Differential Revision: https://reviews.freebsd.org/D58436
(cherry picked from commit ae7e2c9170f6f7e39ab3132eb72c89f9f6e3a4d6)
Fold the thermal-protection work and the correctness fixes that landed
alongside it.
Report and auto-recover from PHY thermal shutdown. The Atlantic PHYs can
autonomously shut down on over-temperature, latching global fault 0x8007
and dropping the link; Atlantic 2 ships this armed, Atlantic 1 disabled.
Arm it on Atlantic 1 at interface init (1E.C478.A via the MAC's MDIO
controller), and recover from a trip automatically: the admin-status poll
detects the fault, logs the shutdown limit and measured temperature, and
holds the link down until the PHY cools, then restores it -- Atlantic 1
needs a PHY reset (1E.2681.0) with the MAC firmware running plus a full
re-init, Atlantic 2 recovers on the re-init alone. New firmware ops
get_phy_fault, phy_reset, thermal_arm, and get_thermal_limit back the
state machine in aq_if_update_admin_status().
Make that Atlantic 1 thermal MDIO path address-correct and fail-safe.
The direct-MDIO helpers hardcoded the Clause-45 port address to 0, but it
is strap-selectable: on a board whose PHY answers elsewhere every thermal
op targeted nothing, so arming silently no-oped and the post-trip reset
never cleared the latch. Discover the address by scanning ports 0..31
for a PMA/PMD identifier and form it as (phy_id << 5) | mmd, marking it
valid only when a PHY actually answers. aq_fw2x_phy_read also returned 0
on a semaphore timeout, indistinguishable from a real 1E.C478 == 0, so
thermal_arm could zero live provisioning bits; give the read an error
return and gate thermal_arm and get_thermal_limit on it.
Bound the multicast filter slot index. aq_mc_filter_apply() programmed
slot count + 1 and bailed only at count == AQ_HW_MAC_MAX (33), one
address too late, so a 33rd entry raced in between the if_llmaddr_count()
snapshot and the if_foreach_llmaddr() walk drove an out-of-bounds MMIO
write to slot 33. Fire the guard at AQ_HW_MAC_MAX - 1, and also reject
index >= AQ_HW_MAC_MAX in aq_hw_mac_addr_set() where the slot becomes an
RPF register offset.
Correctness and safety fixes: initialize the sysctl context in
attach_pre so the iflib fail-path detach cannot sysctl_ctx_free() an
uninitialized list (a page fault when MSI/MSI-X is denied); range-check
the Atlantic 2 action-resolver table index, taken verbatim from a
firmware-supplied base, before writing the ART registers; and accumulate
statistics deltas as unsigned, since AQ_SDELTA discarded a forward delta
of 2^31 or more at 10G across a stretched admin poll.
Signed-off-by: Nick Price <nick@spun.io>
Reviewed by: adrian
Differential Revision: https://reviews.freebsd.org/D58435
(cherry picked from commit b68f4667612ff8cde2fefc94f8b31377b128ea7e)
Fold the driver's observability and infrastructure work.
Make aq_device.h self-contained: it declares struct aq_dev in terms of
iflib, bitstring, socket, and ethernet types but included none of the
headers that define them, compiling only because every includer happened
to pull those first. Include what it uses. No functional change.
Make the debug controls per-instance. The debug and debug_categories
sysctls were registered per device but pointed at file-scope globals, so
writing dev.aq.1.debug also changed dev.aq.0.debug and a card could not
be traced in isolation. Move the level and category mask into struct
aq_dev, reach them through the aq_dev back-pointer in struct aq_hw (wired
up in attach_pre before the first firmware trace and guarded against a
NULL deref), emit through device_printf() so each line carries its unit,
and seed initial values from per-unit device hints so attach can be
traced.
Expose the PHY die temperature as dev.aq.N.temperature through a new
firmware get_temp op: Atlantic 1 v2 reads it through the mailbox MPI
control/state toggle, Atlantic 2 from the phy_health_monitor block in the
OUT window (located at 0x13620 and confirmed by its ready bit). Atlantic
1 v1 has no sensor and exposes no node. Because this is the first
firmware accessor iflib does not serialise, add a per-instance mutex in
struct aq_hw and take it across the v2 read-modify-write in set_mode(),
get_stats(), get_mode(), and get_temp(); the v1 and Atlantic 2 paths do
not need it and say so.
Trace the Atlantic 2 firmware path, which previously emitted nothing at
any debug level (aq2_fw.c did not even include aq_dbg.h): the boot
handshake, reset policy, MAC address, and link mode set/read, using the
existing dbg_init and dbg_fw categories, with the per-poll mode read at
detail level.
Scope the driver sysctls to a context freed at detach. They were
registered on the device newbus context, which newbus tears down only
after DEVICE_DETACH returns, yet iflib frees the rings and softc inside
DEVICE_DETACH -- a sysctl read racing detach could touch freed memory.
Give the driver its own sysctl_ctx_list and free it at the start of
aq_if_detach, draining in-flight readers first.
Signed-off-by: Nick Price <nick@spun.io>
Reviewed by: adrian
Differential Revision: https://reviews.freebsd.org/D58434
(cherry picked from commit 9e067f207dc2da57df49812809cc5034030f61d1)
Four Atlantic 2 register-access corrections found in bring-up.
B0 aggregate octet counters: the B0 firmware statistics interface reports
only aggregate rx/tx good octets, not the per-cast breakdown A0 and
Atlantic 1 provide, so every octet sysctl read a permanent zero while
frame counters advanced. Populate the aggregate octet fields from the B0
buffer; aq_update_hw_stats() accumulates them directly when the per-cast
octets are absent.
Drop the duplicate attach-time MCP reboot: aq_hw_mpi_create() already
reboots the A2 firmware to read its version and caps, then aq_hw_reset()
immediately rebooted it again -- a full MCP restart plus several
transaction-id-bracketed window reads, adding attach latency and a
duplicate banner. Give aq_hw_reset() a reboot flag and pass reboot=false
for A2 at attach; the load-bearing down/stop reboot (which resyncs A2 RX
DMA across ifconfig down/up) keeps reboot=true.
Skip Atlantic 1 register accesses on Atlantic 2: gate out the 0x7040
Atlantic 1 TPO write (which A2 lacks; already a no-op via the unset TPO2
feature, but Linux hw_atl2 omits it), and guard the
aq_hw_mpi_read_stats() direct reads of reg_rx_dma_stat_counter7 (dpc) and
the LRO counter (cprc) with !ATLANTIC2 -- those are Atlantic 1 codegen
offsets that on Atlantic 2 land on unrelated registers and can report
bogus input-drop / LRO counts.
HW-validated on AQC107 <-> AQC113C: A1 stats unchanged, A2 IQDROPS stays
0, attach consumes one MCP reboot instead of two, bidirectional iperf3
clean.
Reviewed by: adrian
Differential Revision: https://reviews.freebsd.org/D58143
(cherry picked from commit c325b4024d61fe20f8140d6891074ca7276c4d58)
Wire up the Atlantic 2 receive datapath: the action-resolver table (ART),
multiqueue RSS, QoS, and interrupt moderation.
RX action-resolver table: Atlantic 2 replaces Atlantic 1's discrete RX
filter registers with an ART -- hardware computes a per-packet
classification tag, then walks {tag, mask, action} rows to drop, assign a
queue, or assign a TC. aq_hw_art_filter_set() installs one row under the
ART semaphore; aq_hw_init_rx_path() enables the resolver, tags L2
unicast/broadcast, installs the unicast/all-multicast and VLAN drop rows,
and assigns every 802.1p priority to TC 0 (mirroring the Atlantic 1
user-priority map, since our RX side is a single 8-ring group in TC 0).
Tag every enabled VLAN filter in the per-filter resolver-tag field -- a
register the BSD ports never write -- because the VLAN drop row matches
resolver tag 0, so without it all tagged receive was dead under VLAN
filtering. Promiscuous mode disables the drop rows rather than toggling
the Atlantic 1 promiscuous bits; all ART callers surface a semaphore
timeout consistently. The Atlantic 1 RX_TCP_RSS_HASH and TPO2
programming is gated to Atlantic 1.
Multiqueue RSS and QoS: fill Atlantic 2's own per-TC redirection table
(AQ2_RPF_RSS_REDIR), skipping the Atlantic 1 table and its write-enable
handshake. Program Atlantic 2's smaller packet-buffer sizes, its wider
data-TC credit/weight fields, and its ring-to-TC map, using
aq_hw_active_tcs() for the TC loops.
RSS hash types: the Atlantic 2 resolver has per-protocol hash-type enables
in REDIR2, so build the mask from aq_rss_hashconfig() instead of
hardcoding every protocol -- UDP 4-tuple hashing now follows the kernel
policy (off by default) with no L3L4 flow-filter workaround, and
aq_hw_udp_rss_enable() is skipped on Atlantic 2. The kernel-to-hardware
hash-type mapping is a small static lookup table rather than a nine-branch
chain, since the two bit spaces do not share a simple shift.
Tx interrupt moderation: Atlantic 2's per-ring Tx moderation control
register lives at a different address, but its field layout matches the
value the driver already builds, so write that value straight to it; Rx
moderation is shared.
HW-validated on AQC107 <-> AQC113C: TCP RSS spreads across 7/8 RX queues
under 16 parallel flows, rx_err=0.
Reviewed by: adrian
Differential Revision: https://reviews.freebsd.org/D58142
(cherry picked from commit 418e7fd13b5aa201c0f9eb65ab2f9a0c1810ba23)
Add support for the Marvell Atlantic 2 (AQC113/114/115/116) controllers,
a new chip generation that is not register-compatible with the Atlantic 1
parts aq(4) supports today. Adapted from the OpenBSD/NetBSD if_aq driver.
Register and device definitions (aq2_hw.h): the firmware handshake
(MIF_BOOT / MCP_HOST_REQ_INT / MIF_HOST_FINISHED), the 0x12000/0x13000
firmware interface windows, and the action-resolver table (ART) that
replaces Atlantic 1's discrete RX filters, plus the Atlantic 2 PCI device
ids and the aq_is_atlantic2() helper. Reserve a chip-feature bit
(AQ_HW_CHIP_ATLANTIC2) and add the aq_hw fields the firmware fills at boot
(ART base index, statistics interface version A0/B0). The per-VLAN-filter
resolver-tag field comes from the Linux driver; the BSD sources never
write it.
Firmware operations (aq_fwa2.c): Atlantic 2 talks to the management CPU
through the 0x12000/0x13000 register windows plus the boot handshake,
rather than Atlantic 1's mailbox in shared RAM. Implement that as a third
aq_firmware_ops vtable (reset, set_mode, get_mode, get_mac_addr,
get_stats); aq_fwa2_reboot() boots the firmware, selects the A2 ops, and
reads the version and ART base index, failing fast on the
crash-init / boot-failed bits. fwa2_set_mode advertises full duplex only
(the media model exposes no half-duplex types) and writes and acks the
link options before raising ACTIVE mode, so a forced media change does not
begin negotiation with a stale rate mask. enum aq_fw_link_speed gains
aq_fw_10M, which Atlantic 2 supports and Atlantic 1 does not.
Probe and attach: list the device ids with their media types and link
speeds (all copper; AQC113* up to 10G, AQC116C to 1G), populate
hw->device_id, and tag the generation with AQ_HW_CHIP_ATLANTIC2 so
IS_CHIP_FEATURE() recognises it uniformly. Branch firmware bring-up and
reset on the generation: aq_hw_init_ucp() and aq_hw_reset() reboot the MCP
instead of the Atlantic 1 RBL/FLB reset -- without a real datapath reset
every stop/init cycle reprograms the rings on a live, desynced RX DMA
engine and the receive path stays dead. aq_hw_init() programs the
Atlantic 2 launch-time clock ratio in place of the Atlantic 1
MRRS / TX-DMA request-limit clamp. Add an AQ_LINK_10M capability bit
(Atlantic 2 links at 10M, Atlantic 1 cannot), offer 10baseT media, and map
IFM_10_T to aq_fw_10M.
With every supported media type now present, replace the per-speed switch
statements in aq_media.c with a single {link bit, fw rate, IFM_* subtype,
Mbit/s} table -- one source of truth for the supported link speeds.
With this an Atlantic 2 card probes, brings up its firmware, reads its
MAC, and negotiates link; the RX action-resolver datapath comes next.
Reviewed by: adrian
Differential Revision: https://reviews.freebsd.org/D58141
(cherry picked from commit dc5c0fc51cf47d6dfc737343e06805db294258e9)
Non-functional cleanup, with two diagnostic corrections.
Dead code: delete leftover commented-out AQ_DBG_ENTER/EXIT/PRINT calls
(aq_hw.c, aq_fw2x.c, aq_irq.c, aq_main.c), a commented-out aq_nic_cfg
local, the stale old-signature parameter blocks between the ring-init
declarations and their bodies (aq_ring.c), a trailing note on a live
statement, and the unused DumpHex() vendor debug helper (no callers; its
body only compiled under AQ_CFG_DEBUG_LVL > 3).
Register-write macros: parenthesize AQ_WRITE_REG_BIT's msk/shift/value
arguments so a compound argument cannot mis-bind, give AQ_HW_FLUSH() an
explicit hw parameter instead of capturing it from caller scope, and drop
the duplicate lowercase aq_hw_write_reg[_bit] aliases (converting the 43
call sites to the uppercase spelling) so there is a single form.
Diagnostics: the aq_log* family expanded through the base log macro, which
ignored its level and printed unconditionally, while the error traces
gated on a debug level that defaulted below LOG_ERR and so were suppressed
-- backwards. Gate the base log macro the way the trace one does and
default the level to lvl_error, so the once-per-event firmware reset /
capability errors are visible by default while the verbose info/dump
output stays opt-in.
Naming: rename identifiers carried verbatim from the vendor import that do
not match style -- names mixing an ALL-CAPS macro-style prefix with a
lowercase tail, and a trailing underscore the vendor used as a
"file-local" marker in place of static.
- dbg_level_ / dbg_categories_ -> aq_dbg_level / aq_dbg_categories: these
are real globals (the log/trace macros reference them from every
translation unit), so the trailing underscore was never a stand-in for
static; give them the aq_ namespace so the driver stops exporting
generically-named global symbols.
- log_base_ / trace_base_ -> aq_log_base / aq_trace_base: the internal
macros behind the aq_log*/trace* families.
- bootExitCode / flbStatus -> boot_exit_code / flb_status (aq_fw.c);
flb_status now matches the identically-purposed variable already spelled
that way in the sibling FLB-reset path.
Cosmetic: terminate the ring/HW-init, MSI-X admin-handler, and
media-change error messages with a newline so they are not garbled into
adjacent dmesg output, and label the per-queue rx_bytes sysctl "RX Octets"
(it was copy-pasted "TX Octets").
Reviewed by: adrian
Differential Revision: https://reviews.freebsd.org/D58140
(cherry picked from commit f1796e8781ca8a632ffa0861b2e09944d225c479)
Firmware-statistics accounting and interrupt-routing fixes.
Stats delta underflow: guard the MAC statistics delta accumulation
against counter wrap or a firmware counter reset, so a snapshot smaller
than the previous one does not underflow into a huge spurious delta.
Skip stats on a failed read: aq_update_hw_stats() ignored
aq_hw_mpi_read_stats()'s return and committed the on-stack mbox into
last_stats unconditionally. On a failed read that snapshot is garbage or
zero and poisons the delta baseline (a zeroed snapshot wipes last_stats,
so the next good read double-counts). Check the return and skip the
accumulation and the last_stats commit on failure.
Mailbox/stats separation: struct aq_hw_stats served both as the raw fw1x
MCP mailbox layout and as the driver's canonical stats snapshot, so any
field added to it would silently shift the fw1x mailbox read. Give the
fw1x mailbox its own raw layout in struct aq_hw_fw_mbox and let
aq_hw_stats become purely driver-owned; with the coupling gone, add
first-class aggregate octet fields (brc/btc) that Atlantic 2 B0 firmware
can populate directly. No A1 behavior change. The raw block is a named
struct (aq_fw1x_mbox_stats) with a _Static_assert tying its size to
aq_hw_stats' matching prefix, so the fw1x memcpy cannot silently misalign
if either field list drifts. Also drop the unused FW1X_MPI_STATE_ADR /
FW1X_MPI_CONTROL_ADR macros and the redundant fw1x_get_stats() dpc
assignment that the caller immediately overwrites.
Per-speed interrupt moderation: aq_hw_interrupt_moderation_set()
hardcoded speed_index = 0, so every link speed got the 10G timer pair and
the other rows were dead. Record the negotiated rate and index the
tables by ffs(speed) - 1, reordering the rows to match the
enum aq_fw_link_speed bit positions so the index cannot drift from the
enum. Rename the two per-speed timer tables (AQ_HW_NIC_timers_table_
{rx,tx}_ -> aq_itr_timers_{rx,tx}), function-local static arrays whose
SCREAMING_CASE vendor names read like macros.
Hardware error interrupts: route both hardware error causes (interrupt
map register 0) to the admin vector so they are actually delivered.
Reviewed by: adrian
Differential Revision: https://reviews.freebsd.org/D58139
(cherry picked from commit 65fd3b4165eff52f3447c70db8d10ef67875c022)