ufshci: build the ioctl file into the kernel
The passthrough ioctl went into the module build only. A kernel with
device ufshci then failed to link, because ufshci_ctrlr.c calls
ufshci_ioctl_construct() and ufshci_ioctl_destruct() and neither was
compiled in.
Add the file to sys/conf/files.
Fixes: 28fefc441e3b ("ufshci: add a control device node")
Sponsored by: Samsung Electronics
committers-ports.dot: Restore dteske from alumni
Move back to the current committers section and record fuz and jrm
as mentors.
Approved by: portmgr
Reviewed by: fuz (mentor), jrm (co-mentor)
Differential Revision: https://reviews.freebsd.org/D59500
ixv: Recover E610 Hyper-V carrier without the PCI link query
Current Windows PF drivers do not emulate the E610 link-status query at
PCI configuration offset 0x209. The installed Intel ixw 1.8.54.0 driver
returns zero even with the physical port connected, leaving the VF at
no carrier after an otherwise successful hn handoff.
When the query returns zero, use VFLINKS for carrier only. Its speed
field is not the negotiated E610 line rate: the tested 1 Gb/s port
reports the default 10 Gb/s encoding. Publish an unknown speed instead,
including in the verbose link-up diagnostic, and document this fallback.
Keep nonzero PCI results authoritative and reject all-ones reads. Other
Hyper-V families and the native E610 mailbox path are unchanged.
A zero result cannot distinguish an unsupported query from a down link;
in either case this fallback relies on the legacy carrier indication.
The connected and disconnected ports reported VFLINKS.UP set and clear,
respectively, while both returned zero from the PCI query.
[2 lines not shown]
ixv: Add Hyper-V virtual function support
Hyper-V does not expose the normal Intel PF/VF mailbox.
Import the Hyper-V operation overrides from DPDK and complete its reset
callback with the configuration-space mechanism submitted by Microsoft.
Route ixv operations through the operation table, use mailbox API 1.0,
and limit this environment to one queue pair.
Claim the 82599, X540, X550, X550EM-X, and X550EM-A Hyper-V device IDs
listed by DPDK. Select the same path for the E610 Hyper-V subdevice
identity defined there.
For E610/Linkville, read the emulated VFLINKS-format status from PCI
configuration space at offset 0x209. Older families retain the MMIO
VFLINKS path.
Treat receive-mode changes as host-owned no-ops and do not retry VLAN
operations that Hyper-V permanently rejects. Limit the Hyper-V 82599
[13 lines not shown]
hyperv: Configure IPv6 when setting up VF failover
The default VF-up script moves IPv4 configuration from the synthetic
interface to a failover lagg, but leaves IPv6 unconfigured on the lagg.
Adding the synthetic interface as a member can remove its IPv6 addresses,
so deleting the remaining member addresses is not sufficient.
Stop accepting router advertisements on the synthetic interface before
adding it to the lagg. Leave its link-local address and IPv6 enable state
in place for lagg's address, prefix and default-router cleanup, then disable
IPv6 and explicitly remove any remaining addresses. This also covers
members without a link-local address or with IPv6 already disabled.
Replay the synthetic interface's IPv6 rc.conf configuration on the lagg,
including aliases, prefix-derived addresses and legacy configuration names.
Remap the variables in a subshell and reuse network.subr's IPv6 helpers.
For SLAAC, solicit fresh router advertisements rather than copying learned
addresses as permanent ones. Configure IPv6 independently of the IPv4
DHCP/static choice, and leave existing laggs alone on repeated invocation.
[6 lines not shown]
hyperv: Bound IPv4 address removal when configuring VF failover
The VF-up script repeatedly deletes the first IPv4 address from hn until
ifconfig fails. Netlink-based ifconfig returns success when no address
remains, so the script can loop forever and block subsequent devd work.
Use ipv4_down() from the already-sourced network.subr to enumerate the
addresses and delete each explicitly. This also handles multiple
addresses without relying on the exit status of an empty deletion. The
behavior depends on ifconfig, not the VF hardware, so no device-specific
fallback is needed.
Fixes: c68595695679 ("hyperv: Add VF bringup scripts and devd rules.")
MFC after: 2 weeks
Sponsored by: BBOX.io
hn: Invoke the owned VF's transmit queue flush callback
The generic if_qflush() only clears if_snd. Calling it directly for a
transparent VF bypasses the driver's callback and its private software
transmit queues. Add if_getqflushfn(), matching the existing callback
accessors, and invoke the registered callback while hn_vf_lock protects
the VF pointer.
Flush an attached VF whenever transparent mode owns it, not only while
the VF datapath is enabled. Disabling transmit during handoff does not
discard packets already queued to the VF. This also covers the inactive
interval after fallback. Non-transparent VFs remain independently owned
and are not flushed by hn. Synthetic queue flushing is unchanged.
MFC after: 2 weeks
Sponsored by: BBOX.io
hn: Serialize VF link events with datapath handoff
Hold hn_vf_lock across the VF identity/state check and link publication.
Otherwise an event can observe an enabled VF, pause during fallback, then
overwrite the freshly reported synthetic carrier with stale VF state.
Ignore events while switching or after the association generation changes.
The link notification only queues further work, so the callback does not
need the sleepable hn lock.
Document that association serial numbers are currently diagnostic:
hn_ismyvf() matches the VF by MAC, while notifications gate availability.
MFC after: 2 weeks
Sponsored by: BBOX.io
hn: Track VF association and wait for datapath switch completion
Handle the host's VF association notifications instead of ignoring them.
Require an allocated association before switching to the MAC-matched VF,
and track notification generations so a withdrawal during initialization
cannot enable an obsolete handoff. Defer association and address-event
work to the VF taskqueue; the receive channel must remain available to
deliver switch completions.
Request and wait for the empty VMBus completion for SET_DATAPATH, checking
submission and channel-revocation failures. Enable transparent VF
transmit and select its link status only after the switch completes.
Use the existing transaction lifetime and revocation handling, without a
timeout that could leave a late completion referencing a freed request.
Restore synthetic capabilities, TSO limits and hardware-assist flags on
fallback, targeting hn rather than the departing VF. Block transparent
transmit during handoff and after association withdrawal. Separate the
attach delay from saved-setting readiness, permit delayed association to
[6 lines not shown]
hyperv: Stop bus relations handling from falling through to eject
The PCI_BUS_RELATIONS2 case lacks a break after queuing the reported
devices. It consequently processes the same packet as PCI_EJECT,
interpreting device_count as the slot number. If that value matches an
existing child, the callback schedules an unintended device eject.
End the relations case after processing the device list, matching the
original PCI_BUS_RELATIONS handling.
Fixes: ea11861e434a ("arm64: Hyper-V: vPCI: Enabling v-PCI in FreeBSD in ARM64 Hyper-V")
MFC after: 2 weeks
Sponsored by: BBOX.io
hn: Refresh VF offloads after bringing it up
VF readiness can precede its first initialization. In particular,
iflib populates if_hwassist during init, so copying it while the VF is
still down can leave hn advertising checksum and TSO capabilities with
no hardware-assist flags. The stack then uses software segmentation
until a capability ioctl happens to refresh the copied state.
Synchronize enabled capabilities and hardware-assist flags after the VF
up ioctl succeeds, before switching the datapath and enabling transparent
VF transmit. Use the existing helper in the common initialization path,
covering both normal bring-up and delayed VF initialization.
MFC after: 2 weeks
Sponsored by: BBOX.io
ufshci: install the ioctl header
The passthrough ioctl has a userland ABI header, but nothing installed
it. A program that wanted to use the ioctl had to copy the headers out
of the source tree by hand.
Install ufshci.h and ufshci_ioctl.h under /usr/include/dev/ufshci, the
way nvme installs nvme.h. The ioctl header pulls in ufshci.h, so both
go. Add the directory to the include mtree so installworld creates it.
Reviewed by: imp (mentor)
Sponsored by: Samsung Electronics
Differential Revision: https://reviews.freebsd.org/D59560
ufshci: add a control device node
The driver only exposed a CAM SIM. Userland had no way to reach the
device for anything that is not a SCSI command, so reading a descriptor
or an attribute was impossible.
Add /dev/ufshci%d as a root only node and the ioctl ABI header for it.
The node answers no ioctl yet. The header pulls in ufshci.h, which
declares bool only under _KERNEL, so include stdbool.h for userland the
way nvme.h already does.
Reviewed by: imp (mentor)
Sponsored by: Samsung Electronics
Differential Revision: https://reviews.freebsd.org/D59558
ufshci: add a passthrough ioctl
This ioctl is for a port of ufs-utils:
https://github.com/SanDisk-Open-Source/ufs-utils
The driver only exposed a CAM SIM. Reading a descriptor, an attribute
or a flag needs a query request, and a UniPro attribute needs a DME
command. The driver built both only for its own setup, so userland
could reach neither.
Add two ioctls on the control node. UFSHCI_PASSTHROUGH_CMD sends a
UPIU the caller built, sizes the request from its transaction code,
and copies the response UPIU back. UFSHCI_PASSTHROUGH_UIC carries the
four attribute commands and refuses the rest, which can drop the link
or power the device off. It keeps the raw argument2 so the caller can
read the result code the device reported, not just a failure.
Validate the input and bound it by what the controller can map. The
descriptor has no request length, so the controller reads it from the
[10 lines not shown]
ufshci: tell the controller how long the EHS is
The transfer request descriptor has a field for the total Extra Header
Segment length. The driver left it at zero. A request that carried an
EHS went out as the bare command UPIU, and the device answered a request
it had only seen part of.
Fill the field from the request UPIU header, which already carries the
same length. Every other path sets it to zero, so nothing else changes.
An EHS is the first thing that makes a request vary in size, so assert
that the request and the response still fit in the command descriptor.
Reviewed by: imp (mentor)
Sponsored by: Samsung Electronics
Differential Revision: https://reviews.freebsd.org/D59557
nfs_nfsdkrpc.c: Fix the "glue" for the nfsrdma.ko modules for NFSv3
Without this patch, nd_xprt is only set for NFSv4.1/4.2.
The nfsrdma.ko needs it to be set for all versions of NFS,
so this one line patch does that.
No semantics change for non-RDMA NFS service.
MFC after: 3 months
Fixes: 7144a1d58c5c ("nfsd: Add glue for the nfsrdma.ko module")
rtld: more caution when parsing in digest_notes()
Incorrect ELF might have PT_NOTE slightly larger than the needed to
contain all notes, and the PT_NOTE size could be larger than one page.
Then rtld mmaps just the notes bytes to parse. After the last note,
we iterate past the mapped region trying to read the Elf_Note header.
This was found in wild.
Require full elf note to fit into the [start_note, end_note) region to
continue the parsing. Check it in stages, first verifying the Elf_Note
header structure fits, to be able to read the name and data length.
After that, check the whole note against limit.
Reported and tested by: makc
Reviewed by: emaste
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D59635
iflib: Use a bounded buf_ring for simple_tx
Implement buf_ring/drbr deferred transmit in iflib. This is intended
to allow the new simpler code path to replace mp_ring. This patch
makes the simple_tx outperform mp_ring by a wide margin when CPU is
the bottleneck (eg, cannot fill the NIC). See graphs at:
https://people.freebsd.org/~gallatin/mpring_vs_simple_tx
Note that the buf ring is used for contention, not capacity. Eg,
it is used as a place for contending threads to put packets without
waiting for a mutex. It is not designed to act as a software ring
on top of the hardware descriptors provided by the underlying NIC
driver. "stranded packets" are exceedingly rare due to the fact that
if there is enough load to use the buf_ring, there will probably be
more load coming that can be a drainer. Not scheduling a gtask to
drain is intentional, and we really on the timer as a fallback.
One thing I noticed while developing this patch is that a simple mutex
with no deferral generally outperformed both mp_ring and drbr at high
[28 lines not shown]
vtnet: offer VIRTIO_NET_F_GUEST_CSUM
Always offer the VIRTIO_NET_F_GUEST_CSUM feature to the host, and not
only if RXCSUM is enabled on vtnet. Instead of using RXCSUM to control
whether this feature will be negotiated with the host, just use it to
control whether the VIRTIO_NET_HDR_F_DATA_VALID flag on an incoming
packet is processed (i.e., translated to the corresponding mbuf flag
only if RXCSUM is enabled on the vtnet interface).
This has two benefits:
1. Enabling/disabling RXCSUM on vtnet does not require feature
renegotiation.
2. The host is always allowed to send locally generated TCP or UDP
packets to the guest without computing a full checksum (by setting
the VIRTIO_NET_HDR_F_NEEDS_CSUM flag) and not only if the guest has
enabled RXCSUM on vtnet. Since locally generated packets do not
require a checksum, this saves otherwise unnecessarily wasted
computing power.
If a user of a FreeBSD guest really does not want to negotiate the
VIRTIO_NET_F_GUEST_CSUM feature with the host, it still can disable
[6 lines not shown]
linuxkpi: Add x86 CPU ID matching functions and macros
There are two parts that go together:
* `X86_MATCH_VFM()` to declare a matching pattern
* `x86_match_cpu()` to check if the current CPU matches one of the
patterns in an array.
The i915 DRM driver started to use this in Linux 6.14.
Reviewed by: kib
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D57700
UPDATING: bump __FreeBSD_version to 1600026 for LinuxKPI changes
The size of multiple embedded structs have changed and may lead to
problems (pci_error_handlers in pci_driver, dev_pm_info in struct device).
Allow these changes to be detected by bumping __FreeBSD_version.
MFC after: 3 days
Revert "linuxkpi: Add device under parent, not under class"
This reverts commit fc0a5ae094308609927e9c355928d08923278325.
This changed the sysctl node path and broke IB user space tools (ibv_*).
PR: 298485
Reported by: Ariel Ehrenberg (aehrenberg nvidia.com)
LinuxKPI: 802.11: Always lock around lkpi_80211_mo_{remove_interface,stop}()
Add the missing locking to another two MO driver downcalls, as drivers
always expect it (e.g. rtw89 by assertion).
Add the lock and might_sleep assertions to the respective lkpi_80211_mo_*
downcalls.
PR: 298417
Reviewed by: bz
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D59608
LinuxKPI: add can_wakeup option and accessor functions
We can implement device_set_wakeup_capable() in the !CONFIG_PM_SLEEP
case; we do not have the infrastructure in place for the CONFIG_PM_SLEEP
case so leave a pr_debug TODO.
Needed by an upcoming wireless driver.
MFC after: 3 days
Reviewed by: dumbbell
Differential Revision: https://reviews.freebsd.org/D58883
LinuxKPI: fix argument type to lkpi_pci_msi_desc_alloc()
lkpi_pci_msi_desc_alloc() takes an unsigned int, not an int.
While here make sure the prototype is visibile in interrupt.h as
well before use to avoid -Wimplicit-function-declaration errors.
Discovered while working on a wireless driver.
MFC after: 3 days
Reviewed by: dumbbell
Differential Revision: https://reviews.freebsd.org/D58879
LinuxKPI: implement dma_{alloc,free}_{noncoherent,attrs}
We use one to implement the other given direction stays unused.
This is needed by an upcoming wifi driver.
MFC after: 3 days
Reviewed by: dumbbell
Differential Revision: https://reviews.freebsd.org/D58880