pf: fix crash on low memory
pfr_create_kentry() can return NULL. Don't dereference the pointer it
returns until after we've checked it.
Fixes: 08ed87a4a276 ("pf: convert DIOCRSETADDRS to netlink")
See also: https://redmine.netgate.com/issues/23622
Sponsored by: Rubicon Communications, LLC ("Netgate")
e1000: Serialize 82579 CSR writes with the Management Engine
The 82579 PCIm2PCI arbiter can acknowledge a host MAC CSR write while
the Management Engine is accessing another CSR. The host write can be
lost; subsequent target accesses may no longer be claimed by the MAC and
can hang the system.
For 82579 controllers with valid management firmware, wait for the ME
CSR access indication before every MAC CSR write. Keep the wait bounded
and use DELAY because writes occur in interrupt and datapath contexts.
Verify every transmit and receive tail write. If a tail does not hold
the requested value, disable its datapath direction and request a full
iflib reset.
Keep the ordinary register-write path as a direct MMIO write behind a
predicted per-device gate. Contain the wait and tail recovery in the
82579 slow path rather than adding tail-specific accessors and state to
the rest of the e1000 family.
[11 lines not shown]
ixgbe: Recognize production X550 PHY IDs
According to Linux 5f1c3589b0f0, the X550 PHY classifier still matches
an alpha silicon ID, while the shared definitions contain the two
production IDs. This can leave production hardware on the generic
probing path and issue unnecessary PHY queries.
(cherry picked from commit 392f0af6685a06e89fecdc38cc2e910d2b84d738)
lacp: Simplify lacp_compose_key()
lacp uses interface speed to separate lacp members into different
aggregation groups. It wants to use the lower 4 bits of the key
to represent the speed. This change fixes a few bugs around that:
1) Actually use the baud rate reported by the interface as the speed
(and fall back to use the baudrate associated with the media if
the interface somehow doesn't support if_baudrate)
2) Compressess the baud rates down to the 4 bits reserved for them.
Using things like FM_400G_FR8 does not fit in 4 bits (its value
is 0x1811) . In fact, interfaces faster than 1Gb/s don't fit in
4 bits using the old scheme
3) Emits a warning on the console once per boot if it encounters a
NIC with an unsupported speed to make it slightly more obvious
why LACP might not behave as expected.
[10 lines not shown]
ixgbe: Expose EEE LPI event counters
X550-family devices provide clear-on-read counters for transmit and
receive Low Power Idle events. Accumulate each register once in the
normal statistics poll and expose the monotonic totals below the eee
sysctl node. Document the counters together with the existing EEE
control.
Obtained from: Intel ix 3.4.39
(cherry picked from commit ff86fd4f36618dacf1628180034c312c70294276)
ixgbe: Add 10GBase-BX BiDi SFP+ module support
10G-BX optics use paired wavelengths to carry 10 Gb/s Ethernet over a
single strand of single-mode fiber. Their 10G compliance byte is
empty, so identify them from the SFF-8472 nominal signaling rate and
single-mode reach fields.
When an EEPROM also advertises 1G BASE-BX10, give the complete 10G
bitrate and reach signature precedence. Otherwise retain FreeBSD's
permissive 1G-BX identification rather than requiring a nominal
1.3 GBd rate.
Relnotes: yes
(cherry picked from commit f9ce33b0d8ef233063bd6c27bdba2580f97d9094)
ixv: Report multigigabit link speeds
The VF link-status path can receive 2.5 and 5 Gb/s speed bits from
X550-family PFs, but media reporting has no cases for them. The
bootverbose message also assumes every non-10-Gb/s link is 1 Gb/s.
Expose the corresponding ifmedia subtypes and derive the diagnostic
speed through the shared link-speed conversion helper.
(cherry picked from commit a884921abbaf52ff862a32ff6806bf071974faa6)
ixgbe: Preserve the full VF RSS domain in the shared RETA
The 82599 and X540 share the global RSS redirection table between the
PF and its VFs. Programming that table from the PF queue count
prevents a VF from using queue indices absent from the PF layout. A
one-queue PF consequently directs every flow for a two- or four-queue
VF to queue zero.
Program at least four queue indices while SR-IOV is active. Each pool
PSRTYPE.RQPL field masks the shared table to the queue subset available
to that function, so the PF can continue using fewer queues.
(cherry picked from commit 8b668bc7e7c8b0a1bcb018360a4aafa445ff554f)
net: Add ifmedia support for 10GBase-BX BiDi
10GBase-BX uses paired wavelengths to carry both directions over a
single strand of single-mode fiber. The optics must be paired so that
the transmit and receive wavelengths cross over.
MFC after: 2 weeks
(cherry picked from commit 4220b52453c9701922955dcc1c1e1554d6a9f3ae)
if_media: Claim 10BASE-T1S and 10BASE-T1L constants
These are two single-pair Ethernet (SPE) variants that run at 10 Mbps.
10BASE-T1S has automotive origins and supports multiple nodes on up to
25m of cable. 10BASE-T1L is intended for building and industrial
automation and supports long-distance point to point links of over 1km.
Reviewed by: kbowling
Differential Revision: https://reviews.freebsd.org/D56952
(cherry picked from commit a3036edd0292291a71fb74ba2bce355159ac6913)
ixgbe: Compare flow control against requested mode
The flow-control sysctl represents the configured policy, while
current_mode is the mode negotiated with the link partner. Comparing a
new request with current_mode can needlessly reprogram an unchanged
policy or skip a requested policy change that happens to match the
current negotiation result.
Compare with requested_mode before deciding that no update is needed.
(cherry picked from commit c410551b9feadf9b65f920fd25714fcda8299a56)
ixl: Track and recover MDD-blocked VFs
The hardware identifies each VF with TX and RX malicious-driver
status latches, but the driver combined all events into one counter
and reported only the last VF found.
Consume every PF and VF latch, keep per-direction VF counters, and
rate-limit per-VF diagnostics. Keep the software block until a
successful VF or PF reset reconstructs its resources.
Match Linux i40e policy by leaving a detected VF blocked by default.
Add an opt-in hw.ixl.mdd_auto_reset_vf tunable that notifies and
resets the VF for installations that prefer availability. DPDK
provides the register clear and per-VF attribution precedent; Linux
provides the recovery policy.
(cherry picked from commit 93f1065920d806400ace6b60b025faf91926bdaa)
ixl: Report PF initialization failures to iflib
ixl_if_init() returned early after AdminQ reconstruction, LAA, or
VSI initialization failures. Since IFDI_INIT has no return value,
iflib then marked the interface RUNNING and enabled its interrupts
and timers despite the incomplete hardware state.
Use iflib_init_failed() on each incomplete path. Also stop at the
first ring-enable error and tear down any partially enabled rings
before reporting failure. This keeps the interface stopped and
makes a later initialization attempt start from a bounded state.
(cherry picked from commit f008b582c9f1e1a636e88a5f330ff3a167094440)
ixgbe: Validate EEPROM checksum section bounds
The generic checksum walker trusts NVM section pointers and lengths and
iterates with a 16-bit index. A corrupt section that crosses the end of
the EEPROM can wrap the index and leave the driver in an effectively
unbounded read loop during attach.
Validate each non-empty section against the discovered EEPROM word size
before reading it, and use widened arithmetic for the inclusive end and
iterator.
(cherry picked from commit be3e1068ea8699fb719691453899ca20a601fe1d)
ixgbe: Restore missed packet accounting
missed_rx and total_missed_rx are never populated. As a result, the
GPRC erratum workaround does not remove missed packets and iqdrops
always remains zero. The rx_missed_packets sysctl and input-error total
also expose only MPC bank zero.
Read and accumulate all eight MPC banks. Use the interval total to
correct GPRC and the cumulative total for iqdrops, input errors, and the
aggregate sysctl. This matches DPDK's coverage of the hardware banks.
(cherry picked from commit 660099c985e8bfc931b01398715441c90cf0d4db)
ixl: Quiesce VF DMA before a PF reset
A PF reset has a warning interval before the hardware reset begins.
Cooperative VF drivers respond to the reset event by stopping and
releasing their receive buffers, but notifying VFs did not stop the
hardware queues. An active VF could therefore DMA through its old
rings into freed mbuf clusters during the warning interval.
Put every enabled VF in reset, drain its PCIe transactions, disable its
queues, wait for receive queue shutdown, and drain transactions again
before tearing down the PF HMC and AdminQ.
Hold VFs in reset again while rebuilding the firmware topology. Release
VF reset before programming the replacement VSI and queue mappings,
since VF reset clears those registers, and publish VFACTIVE only after
reconstruction succeeds. Leave a VF held in reset if rebuilding it
fails.
Fixes: 983e628a0c47 ("ixl: Rebuild VF resources after a PF reset")
[2 lines not shown]
iavf: Resume AdminQ processing after PF reset
A PF reset indication leaves IAVF_STATE_RESET_PENDING set while the
VF recreates its AdminQ and negotiates new resources. The ordinary
AdminQ task refuses to consume messages while that state is set.
Consequently, the first DISABLE_QUEUES reply after successful mailbox
rediscovery remains in the receive queue and initialization times out.
Later retries and manual interface restarts repeat the same cycle.
Clear the stale reset indication once VERSION and GET_VF_RESOURCES have
succeeded, before enabling interrupts and resuming normal virtchnl
requests.
(cherry picked from commit 02fbb1ce07f60fab82e21e5bbe2dae85f024bb55)
iavf: Do not publish link-up while stopped
A PF link event remains cached while a VF is administratively down.
Media status queries called iavf_update_link_status() and published
that cached state as link-up, while the stopped admin path immediately
published link-down. Consumers reacting to link events could turn
this into an unbounded notification loop and prevent interface detach
from draining its link-state task.
Keep the cached PF state, but only publish link-up after iflib has
marked the VF running. A subsequent admin pass publishes the cached
state after a successful initialization.
(cherry picked from commit 46241b7d6647dfc2fc557c02804d20b9f05af5c4)
ixgbe: Preserve VF jumbo frame size across PF resets
sc->max_frame_size represents the largest frame requested by the PF or
an active VF. The MTU callback replaces it with the PF frame size, so
a subsequent reinitialization can program MHADD below an active VF's
jumbo-frame request.
Recompute the aggregate before hardware initialization and use it when
programming MHADD. Recompute after each VF LPE request as well, so a
reduced request can lower the hardware limit when no other function
needs the previous value.
(cherry picked from commit 877f0ee40c2af801c5ca758a37b3ebddc560dad2)
ixl: Rebuild VF resources after a PF reset
A PF or EMP reset destroys the firmware switch topology, including
every VF VSI. The driver rebuilt only its PF VSI and left configured
VFs with stale switch element and VSI identifiers.
Notify VFs before a driver initiated reset, recreate the IOV VEB, and
rebuild each configured VF VSI and queue mapping after the PF switch
is restored. Keep a VF out of VFACTIVE if its reconstruction fails
so one failure cannot expose incomplete resources or prevent the PF
and other VFs from recovering.
Invalidate cached VF firmware identifiers and runtime state before
recreating the VEB. If VEB creation itself fails, teardown and mailbox
paths can no longer use pre-reset SEIDs or VSI data.
Factor the common VEB setup out of IOV initialization so initial
setup and post-reset reconstruction use the same topology and filter
sequence.
[2 lines not shown]
ixl: Enforce VF VLAN policy
Add access and trunk VLAN policy to the SR-IOV schema. Access VFs
use a hardware PVID and cannot alter their VLAN membership. Trunk VFs
may register up to 16 VLANs, while VLAN 0 remains implicitly admitted
for untagged and priority-tagged traffic.
Enable hardware VLAN anti-spoofing and maintain the MAC-by-VLAN filter
cross-product used by DPDK. Apply Linux's untrusted-VF limits of 18 MAC
addresses and 16 VLANs so one guest cannot consume the shared PF filter
table without bound.
Document the access and trunk policy in ixl(4).
(cherry picked from commit e2daa5c06c2febacf141f9fd3a6a18cf86df8fe1)
ixl: Fix build after VF reset changes
VF_FLAG_INITIALIZED belongs to the SR-IOV status-reporting interface,
which was not merged to stable/15. The VF reset MFCs accidentally kept
two status-only clears without the flag definition or the corresponding
set operation.
Remove the clears rather than pulling the unrelated reporting interface
into stable/15. They do not participate in hardware reset sequencing.
Fixes: d252dd2a841c ("ixl: Rebuild VF resources after a PF reset")
Fixes: 1319574637fb ("ixl: Quiesce VF DMA before a PF reset")
tcp: cleanup whitespaces
Use tabs consistently in #defines
No functional change intended.
Reported by: Hannes Elfert
MFC after: 1 week
MFC to: stable/15
pfsync: handle large MTU pfsync interfaces
pfsync packets were allocated with m_get2(), which can't return packets
larger than MJUMPAGESIZE. As a result 9k MTU pfsync interfaces simply didn't work.
Use m_get3(), which can allocate sufficiently large mbufs.
Extend the pfsync:bulk test case to provoke this problem.
PR: 297307
MFC after: 2 weeks
Sponsored by: Rubicon Communications, LLC ("Netgate")
(cherry picked from commit 7e2781fdcfdbe489cc07572d33dc36bca06a342d)
pfsync: handle large MTU pfsync interfaces
pfsync packets were allocated with m_get2(), which can't return packets
larger than MJUMPAGESIZE. As a result 9k MTU pfsync interfaces simply didn't work.
Use m_get3(), which can allocate sufficiently large mbufs.
Extend the pfsync:bulk test case to provoke this problem.
PR: 297307
MFC after: 2 weeks
Sponsored by: Rubicon Communications, LLC ("Netgate")
(cherry picked from commit 7e2781fdcfdbe489cc07572d33dc36bca06a342d)