net/ieee_oui.h: clarify how `OUI_FREEBSD_BASE` is managed
Note that the FreeBSD Foundation manages the current value
associated with `OUI_FREEBSD_BASE`.
Trim trailing whitespace in comments in the change while here.
MFC after: 1 week
Pull Request: https://ron-dev.freebsd.org/FreeBSD/src/pulls/82
ufshci: report the SCSI status and sense to CAM
A CHECK CONDITION was reported to CAM as a transport error without
valid sense, so CAM retried blindly. After a reset the device answers
NOT READY, and those retries ran out and detached the disk.
Report the SCSI status and sense with CAM_AUTOSNS_VALID, and freeze the
device queue on a SCSI status error. A GOOD status with a failed
response is still an error. Stop logging every CHECK CONDITION.
Reviewed by: imp
Sponsored by: Samsung Electronics
Differential Revision: https://reviews.freebsd.org/D61122
ufshci: try the link startup more than once
A device that is still powering on may not answer the first
DME_LINKSTARTUP, and the driver gave up after one try.
Try up to three times. Both attach and reset use this path.
Reviewed by: imp
Sponsored by: Samsung Electronics
Differential Revision: https://reviews.freebsd.org/D61121
ufshci: tell CAM when the controller is gone for good
When the controller failed for good, CAM was not told, so its disks
stayed and every command to them failed.
Post AC_LOST_DEVICE from the failure path so CAM removes them.
Reviewed by: imp
Sponsored by: Samsung Electronics
Differential Revision: https://reviews.freebsd.org/D61120
ufshci: fail the controller when a polled command never completes
The reset task waits on its own polled bring-up commands. If one was
lost, nothing could complete it, and the poll panicked after ten
seconds.
Fail the controller instead. The failure path completes every
outstanding request, including the polled one, so the poll returns an
error to its caller. A polled command is only sent while the controller
is being brought up or by the passthrough ioctl, and a lost one means
the controller is not usable anyway.
Reviewed by: imp
Sponsored by: Samsung Electronics
Differential Revision: https://reviews.freebsd.org/D61119
ufshci: hold back I/O during a reset
The disable path only claims what is in flight at that moment. An I/O
submitted after a reset was requested rang a doorbell that the reset
then wiped, so it was lost. An I/O sent as soon as the queue was back
reached the device before the bring-up had initialized it, and the
device answered NOT READY.
Keep such an I/O on a list instead, without a slot, from the moment a
reset is requested until the bring-up has finished, and send the list
in order then. A request that a reset returned to CAM comes back while
the list is still held, so it waits there too. A completion sends the
next one when the slots have run out. If the controller fails first,
the failure path completes the list with an error. Admin and task
management requests still go out, because the reset task waits on its
own commands and the watchdog sends the aborts. This is how nvme(4)
holds requests while a queue is in recovery.
Reviewed by: imp
[2 lines not shown]
ufshci: requeue requests that a reset aborted
A request taken back by a reset was reported to CAM as an error, which
used up a retry. A few resets in a row failed the I/O even though the
device never saw it.
Pass the overall command status to the completion callback and requeue
aborted requests. The polled completion carries it too, so the
passthrough ioctl reports it instead of a placeholder zero. The abort
path now reports an invalid status instead of aborted, so a command
that never finishes still uses up its retries.
Reviewed by: imp
Sponsored by: Samsung Electronics
Differential Revision: https://reviews.freebsd.org/D61117
ufshci: reclaim in-flight requests across a reset in SDB mode
A reset wipes the controller's request list, so a request that was in
flight never completes. Its slot stayed scheduled, the watchdog timed
it out again, and the next reset went round the same way. CAM never
got the request back.
Claim in-flight requests when the queue is disabled and return them as
aborted once it is back. If the reset fails first, the failure path
completes them instead.
Reviewed by: imp
Sponsored by: Samsung Electronics
Differential Revision: https://reviews.freebsd.org/D61116
ufshci: keep a slot for admin requests
The slot reserve step handed any free slot to whoever asked first, so
I/O could fill the queue and leave no slot for the driver's own admin
commands, which a reset sends through the same queue. A full queue was
also reported to CAM as busy, and CAM used up its retries on that
within microseconds.
Keep the last slot for admin requests and give CAM one opening fewer,
since letting CAM fill every I/O slot cut the throughput sharply. On a
full queue, freeze the device queue and requeue the request. Remove the
unused reserve_admin_slot hook.
Reviewed by: imp
Sponsored by: Samsung Electronics
Differential Revision: https://reviews.freebsd.org/D61114
ufshci: tear down the controller in a safe order
Detach freed the request queues while the interrupt, the watchdog or a
running reset could still use them. It also left the controller
running, so a pending interrupt could hit the next attach before its
queues existed.
Tear down the interrupt, stop the watchdogs, free the task queue,
disable the controller, and only then destroy the queues. A stopped
watchdog stays stopped, so a reset still running cannot arm it again.
A reset requested after the task queue is freed is ignored.
Reviewed by: imp
Sponsored by: Samsung Electronics
Differential Revision: https://reviews.freebsd.org/D61115
ufshci: claim a slot before completing it
A request is completed with the queue lock dropped, because the
completion callback may submit the next request and take that lock
again. The completion scan checked a slot under the lock, dropped the
lock, and only then completed the request, with the slot still marked
scheduled. The failure path and the abort completion look for such
slots under the same lock, so one of them could pick the same slot in
that window. The request was then completed twice, freed twice, and
its CCB went back to CAM twice. After a reset every in-flight slot
reads as done at once, so the window was easy to hit.
No existing state could mark that window. FREE would hand the slot to
a new request while the old completion still reads it, RESERVED means
a submit in progress, and NEED_ERROR_HANDLING is about to mean a
request that a reset has claimed but nobody has completed yet.
Add a completing state. Every path that completes a slot sets it
under the lock before dropping the lock, and every path skips a slot
[6 lines not shown]
ufshci: add debug aids for driving the recovery path
The reset and recovery paths only run when the hardware fails, so they
never ran on an emulated controller. The failure path also took the
controller offline without logging anything.
Add the force_reset, drop_next_ios and drop_next_admins sysctls to
drive these paths, and log when the controller fails. The aborts the
watchdog sends must go out, so the task management queue is never
dropped.
Reviewed by: imp
Sponsored by: Samsung Electronics
Differential Revision: https://reviews.freebsd.org/D61112
ufshci: detect completions with the completion notification register
The single doorbell completion scan took a cleared doorbell bit as a
completion. A bit that was never set reads the same, so a slot whose
doorbell was not rung yet, or one that a reset wiped, looked complete
and was finished with a stale descriptor.
UFSHCI 3.0 added UTRLCNR, which the controller sets when it completes
a request and the driver already clears afterwards. Use it to find
completed slots on a 3.0 or later controller. Older controllers keep
the doorbell check, and the task management list has no such register.
Reviewed by: imp
Sponsored by: Samsung Electronics
Differential Revision: https://reviews.freebsd.org/D61111
mii: fix the LINT-NOVIMAGE build for LAN867X
`sys/kernel.h` must be included for all kernel drivers, per driver(9).
`sys/kernel.h` provides defines for `SI_*`, which
`EARLY_DRIVER_MODULE(..)` in `sys/bus.h` relies on and the latter header
is not "self-standing".
Found when running `make tinderbox`.
Fixes: 83d0eed50106 ("lan867xphy: New driver for Microchip ...")
usr.bin/diff/tests/diff_test: add SPDX ID
The SPDX ID makes the script's licensing more explicit.
MFC after: 1 week
Reviewed by: bapt
Differential Revision: https://reviews.freebsd.org/D60908
mqueuefs: set *a_eofflag in VOP_READDIR
mqfs_readdir() never reported end of directory. Since 77b273d8f5f4
VOP_READDIR_APV() asserts that a readdir which returns no entries also
sets *a_eofflag, so with INVARIANTS the final zero-length
getdirentries(2) that ls(1) issues on a mounted mqueuefs panics:
panic: VOP_READDIR: eofflag not set
Report end of directory when the child list was walked to its end;
leave the flag clear when the walk stopped because the buffer was full.
MFC after: 1 week
i2ctinyusb: do not list i2ctinyusb.c twice in SRCS
The module Makefile named its only source file in both the SRCS= line
and the SRCS+= line that follows. bsd.kmod.mk tolerates the duplicate
in a normal build, but when the kernel is built with -flto=thin the
linker sees the same bitcode object twice and refuses to link the
module ("Expected at most one ThinLTO module per bitcode file").
Fixes: 54e231b373ef
MFC after: 1 week
iavf: Honor negotiated VLAN offload capabilities
The driver advertised VLAN offload unconditionally, even when the PF
did not grant it, as observed with an E835 VF under Hyper-V. This
tells the stack to rely on hardware tag insertion and sends the PF
unsupported VLAN filter requests.
Advertise hardware VLAN tagging and filtering only when GET_VF_RESOURCES
grants the legacy VLAN capability. Do not allocate filter shadow entries
or send ADD_VLAN/DEL_VLAN requests without that capability. Retain VLAN
MTU and checksum/TSO support for software-tagged packets.
Keep advertised capabilities stable across resets, since existing VLAN
interfaces may already rely on them. If resource rediscovery removes
previously advertised VLAN offload, leave the VF stopped and require
reattachment rather than resume with a stale offload contract. A newly
granted capability is not exposed until reattach.
MFC after: 2 weeks
Sponsored by: BBOX.io
iavf: Reconcile VLAN filters with acknowledged requests
Track desired and acknowledged VLAN membership separately. Retain
pending deletions and uncertain state after failed requests instead of
losing the work when a message is submitted. Make repeated registration
idempotent.
Adapt DPDK's synchronous, single-VID virtchnl request shape and the
bounded desired-state reconciliation used by igbv and ixv. Serialize
VLAN requests under the existing virtchnl mutex, with filter-list
changes under the iflib context lock. Preserve an unresolved
transaction so a late reply cannot be mistaken for a newer operation,
including after the desired state changes.
Reconcile live membership changes without restarting healthy queues.
Limit each pass to 32 requests and a one-second reply deadline,
continuing live batches from the admin task. Down or recovering VFs
apply desired state at initialization; initialization batches continue
through the existing retry callout without rediscovering the mailbox or
[14 lines not shown]
libexpat: cath up with import of expat 2.10.0
Update expat_config.h and the libbsdxml(3) manpage to reflect the most
recent import.
MFC after: 3 days
MFC with: 765f30b9f3af
udp6: make udp6_ctlinput() same as IPv4 version
Processing an incoming ICMPv6 we need to find just the matching inpcb and
call udp_notify() on it.
The call to in6_pcbnotify() at the first glance seems like a notifying
sweep across the entire database, but it is not. It finds just the
matching inpcb, but does that in the most inefficient way! The added test
case proves that ICMPv6 processing stays the same before and after the
change. This weird use of in6_pcbnotify() can be tracked down all the way
to the initial KAME code.
Reviewed by: tuexen, gallatin
Differential Revision: https://reviews.freebsd.org/D60967
tests/sys/file: add tests for the lowest fd after fork
fdcopy() skips plain kqueues and close-on-fork descriptors when it
copies the table into the child. Check that dup(2) in the child still
returns the lowest unused descriptor, both when the skipped descriptor
is the lowest free slot and when it sits above an existing hole.
Test cases:
kqueue_no_hole a plain kqueue is the lowest descriptor; the
child's dup() reuses its slot
kqueue_two two adjacent plain kqueues; the child's dup()
returns the lower one
kqueue_above_hole a plain kqueue sits above a closed descriptor;
the child's dup() returns the hole
kqueue_cponfork a KQUEUE_CPONFORK kqueue is copied; the child's
dup() returns the next slot
clofork_no_hole an O_CLOFORK descriptor is the lowest one; the
child's dup() reuses its slot
[12 lines not shown]
bhyve/riscv: correctly handle empty masks and broadcast in SBI IPI/RFNC
Bhyve treats an empty cpu set as an error which triggers MPASS panic in
the guest. As per the SBI spec, empty masks should return SBI_SUCCESS,
and a base of -1UL specifies a broadcast to all harts. Fix both in
vmm_sbi.c, clear a1 on return, and skip the SBI ecall in
sbi_ipi_pic_ipi_send() if the mask is empty. Also add a NULL check in
riscv_send_ipi().
Signed-off-by: Doongar Singh <doonbsd at gmail.com>
Reviewed by: br
Differential Revision: https://reviews.freebsd.org/D61126
vtnet: Accept VIRTIO_NET_F_CTRL_RX_EXTRA
Although the driver does not issue the extra receive-mode commands
accepting the feature is harmless and some devices, notably Apple's
Virtualization.framework, offer their control-queue features as a
group and refuse FEATURES_OK unless the whole set is acknowledged.
Signed-off-by: Faraz Vahedi <kfv at kfv.io>
Reviewed by: adrian
Pull Request: https://github.com/freebsd/freebsd-src/pull/2322
(cherry picked from commit d4ddf8eaee9371d1d20bfb753237f25505d6afee)
vtnet: Implement VIRTIO_NET_F_GUEST_ANNOUNCE
When the device sets VIRTIO_NET_S_ANNOUNCE in the config status
field, for example after a VM migrates to a new host, announce
the interface's presence on the network so peers and switches
learn the new attachment point, then acknowledge the request
with the VIRTIO_NET_CTRL_ANNOUNCE_ACK control command, as per
VirtIO v1.3, 5.1.6.5.4.
The announcement raises iflladdr_event: the stack sends gratuitous
ARPs and unsolicited neighbor advertisements for the interface's
addresses, and stacked interfaces such as vlan(4) propagate the
event and announce theirs as well. The event handlers may sleep,
so the work is deferred from the config change interrupt to a task
on taskqueue_thread; that context also allows the acknowledgement
to be skipped safely if the interface was stopped in the meantime,
in which case the device keeps the bit set and the request is
re-delivered with the next config change interrupt.
[5 lines not shown]
netinet6: Use memcpy/memset/memcmp for consistency
Convert the remaining bzero()/bcopy()/bcmp() calls in the neighbor
discovery handlers to memset()/memcpy()/memcmp().
No functional change intended.
Reviewed by: glebius, pouria
Sponsored by: VersatusHPC
Differential Revision: https://reviews.freebsd.org/D58177
jail: return a new descriptor from jail_get(JAIL_USE_DESC | JAIL_GET_DESC)
Prior to this change, `jail_get` when called with `JAIL_USE|JAIL_GET_DESC`
would fail to return a valid descriptor in the positive case because the
`JAIL_USE_DESC` block jumped to `found_prison` before the descriptor was
allocated. This resulted in the returned jail descriptor always being -1,
despite the call being successful.
This change fixes the logic so `jfd_out` is properly initialized in the
aforementioned scenario.
MFC after: 3 days
Reviewed by: jamie, ngie, adrian
Differential Revision: https://reviews.freebsd.org/D60984
ena: Fix RSS sysctl panic when the RSS table is destroyed
ena_set_io_queue_count() destroys the ena-com RSS state but left
ENA_FLAG_RSS_ACTIVE set. The RSS sysctl handlers gate on that flag, so
they ran against state that was gone.
This causes 2 types of issues:
1. Kernel panic when reading dev.ena.0.rss.key or writing to
dev.ena.0.rss.indir_table
2. Returning a stale cached RSS table when reading
dev.ena.0.rss.indir_table, or a bogus 1 when reading
dev.ena.0.rss.indir_table_size
ena_set_io_queue_count() is called in 2 cases:
1. The io_queues_nb sysctl.
2. Device restore when the device comes back with fewer MSI-X vectors
than before.
Clear ENA_FLAG_RSS_ACTIVE when the RSS table is destroyed. The handlers
[12 lines not shown]