Commit graph

151731 commits

Author SHA1 Message Date
Navdeep Parhar
cd93fdee5c cxgbe(4): Stop and restart the L2T allocator with the LLD.
L2T entries are used by both filters and TOE and the L2T is shared
between the base driver (LLD) and the TOM ULD.  Add a flag to indicate
that the L2T is stopped, which means:
* t4_alloc_l2e and t4_l2t_alloc_switching will not allocate new entries.
* t4_tom will ignore all ARP/NDP updates from the kernel.
* Previously allocated L2T entries can still be freed.

MFC after:      1 month
Sponsored by:   Chelsio Communications
2024-07-21 20:29:26 -07:00
Navdeep Parhar
fd3aca5b41 cxgbe(4): Stop and restart the atid allocator with the LLD.
atids are used by both filters and TOE and the atid table is in the base
driver (LLD).  New atids cannot be allocated when the allocator is
stopped but existing ones can still be freed.  It is expected that the
owners of outstanding atids will release them in their own stop
processing, before the adapter is restarted.

MFC after:	1 month
Sponsored by:	Chelsio Communications
2024-07-21 20:26:42 -07:00
Navdeep Parhar
5241b210a4 cxgbe(4): Basic infrastructure for ULDs to participate in adapter reset.
The suspend/resume/reset implementation in the base driver (LLD)
currently works when only stateless features are in use.  This commit
adds basic infrastructure for stateful upper layer drivers (ULDs) to
participate in suspend/resume/reset.

* Add a uld_restart to indicate that the adapter has been restarted
  after a stop and the ULD should resume operations.
* Move the existing functionality in t4_suspend/t4_resume to stop_lld and
  restart_lld.  Use these and the new uld restart routines everywhere the
  adapter has to be stopped abruptly and restarted, namely:
  1. PCIE bus suspend/resume/reset methods invoked by the kernel.
  2. Manual internal-reset using driver sysctl.
  3. Automatic internal-reset on a fatal error.
* Implement an alternate internal-reset for use in VMs and for testing.

Typical reset sequence is:
stop_adapter(sc);
stop_lld(sc);
stop_all_uld(sc);
set_adapter_hwstatus(sc, false);

/* hw reset takes place here. */

restart_adapter(sc);
restart_lld(sc);
  set_adapter_hwstatus(sc, true);
restart_all_uld(sc);

MFC after:	1 month
Sponsored by:	Chelsio Communications
2024-07-21 20:24:03 -07:00
Michael Tuexen
e0b080f850 tcp: mark TCP stacks which can serve as a default stack
Allow a TCP function block (tfb) to become the default stack only if
tfb->tfb_flags has the TCP_FUNC_DEFAULT_OK flags set. This allows a
TCP function block, that is not suitable as a default function block
to ensure that it is not set as the default via sysctl. In this case
sysctl would return EINVAL.

Reviewed by:		gallatin, Peter Lei
Sponsored by:		Netflix, Inc.
Differential Revision:	https://reviews.freebsd.org/D45419
2024-07-21 15:06:10 +02:00
Rick Macklem
026cdaa3b3 nfscl: Scan readdir reply filenames for invalid characters
The NFS RFCs are pretty loose with respect to what characters
can be in a filename returned by a Readdir.  However, FreeBSD,
as a POSIX system will not handle imbedded '/' or nul characters
in file names.  Also, for NFSv4, the file names "." and ".."
are handcrafted on the client and should not be returned by a
NFSv4 server.

This patch scans for the above in filenames returned by Readdir and
ignores any entry returned by Readdir which has them in it.
Because an imbedded nul would be a string terminator, it was
not possible to code this check efficiently using string(3)
functions.

Reported by:	Apple Security Engineering and Architecture (SEAR)
MFC after:	1 week
2024-07-21 15:56:16 -07:00
Michael Tuexen
baee801c92 tcp: simplify endpoint creation at the passive side
Use the intended TCP stack when creating a TCP endpoint instead of
creating it the endpoint the default stack first and after that
switching it to use the intended TCP stack.
Reviewed by:		Peter Lei, rrs and jtl (older version)
Sponsored by:		Netflix, Inc.
Differential Revision:	https://reviews.freebsd.org/D45411
2024-07-21 11:49:37 +02:00
Michael Tuexen
646c28ea80 tcp: improve SEG.ACK validation
Implement the improved SEG.ACK validation described in RFC 5961.
In addition to that, also detect ghost ACKs, which are ACKs for data
that has never been sent.
The additional checks are enabled by default, but can be disabled
by setting the sysctl-variable net.inet.tcp.insecure_ack to a
non-zero value.

PR:			250357
Reviewed by:		Peter Lei, rscheff (older version)
MFC after:		1 week
Sponsored by:		Netflix, Inc.
Differential Revision:	https://reviews.freebsd.org/D45894
2024-07-21 11:37:35 +02:00
Bojan Novković
1cbd613f33 db_pprint: Properly handle complex pointer types
The existing pretty-printing code fails to properly print complex
pointer types. This commit fixes this behaviour by traversing the
chain of CTF types until a base type is encountered.

Approved by: markj (mentor)
Fixes: c21bc6f3c2
2024-07-21 19:31:59 +02:00
Bojan Novković
82f5dfc121 db_pprint: Fix offset calculation for struct members
The struct pretty-printing code uses the ctm_offset field in
struct ctf_member_v3 to calculate the address of a struct member.
However, the code treats this as a byte offset rather than the
offset in bits, leading to wrong values being printed.
Fix this by diving with ctm_offset by NBBY.

Approved by: markj (mentor)
Fixes: c21bc6f3c2
2024-07-21 19:31:48 +02:00
Vladimir Kondratyev
24388fccd5 Bump __FreeBSD_version after LinuxKPI changes.
Sponsored by:   Serenity Cyber Security, LLC
2024-07-21 16:17:37 +03:00
Vladimir Kondratyev
14fc33ea3a LinuxKPI: Fix resource leak on pci_iounmap-ing of PCI BAR
If the resource was allocated with want_iomap_res flag set.

Sponsored by:	Serenity CyberSecurity, LLC
MFC after:	1 week
Reviewed by:	manu, bz
Differential Revision:	https://reviews.freebsd.org/D45905
2024-07-21 16:10:44 +03:00
Vladimir Kondratyev
fcc350c375 LinuxKPI: Add pci_iomap_range function
pci_iomap_range creates a virtual mapping cookie for a PCI BAR.
As compared with pci_iomap it got extra offset parameter.

Sponsored by:	Serenity CyberSecurity, LLC
MFC after:	1 week
Reviewed by:	manu, bz
Differential Revision:	https://reviews.freebsd.org/D45904
2024-07-21 16:10:25 +03:00
Vladimir Kondratyev
d42136e361 LinuxKPI: Remove vmas argument from get_user_pages on KBI layer
To chase Linux kernel 6.5

Sponsored by:	Serenity Cyber Security, LLC
Reviewed by:	manu
Differential Revision:	https://reviews.freebsd.org/D45850
2024-07-21 16:10:14 +03:00
Vladimir Kondratyev
1fe7cd0243 LinuxKPI: Remove owner argument from class_create function on KBI layer
To chase Linux 6.4

Sponsored by:   Serenity Cyber Security, LLC
Differential Revision:	https://reviews.freebsd.org/D45849
2024-07-21 16:09:58 +03:00
Vladimir Kondratyev
7774e08adf LinuxKPI: Add linux/eventfd.h and linux/memremap.h dummy headers
Sponsored by:	Serenity Cyber Security, LLC
MFC after:	1 week
Reviewed by:	manu
Differential Revision:	https://reviews.freebsd.org/D45848
2024-07-21 16:09:48 +03:00
Vladimir Kondratyev
3e90716331 LinuxKPI: Add acpi_dev_get_first_match_dev and acpi_device_handle
acpi_dev_get_first_match_dev returns the first match of ACPI device
and acpi_device_handle returns its ACPI handle.

Sponsored by:	Serenity Cyber Security, LLC
MFC after:	1 week
Reviewed by:	manu
Differential Revision:	https://reviews.freebsd.org/D45847
2024-07-21 16:09:37 +03:00
Vladimir Kondratyev
5b1171a0b7 LinuxKPI: Add pci_match_id to linux/pci.h
It finds out if a given PCI device matches a given pci_id table.

Sponsored by:	Serenity Cyber Security, LLC
MFC after:	1 week
Reviewed by:	manu
Differential Revision:	https://reviews.freebsd.org/D45846
2024-07-21 16:09:27 +03:00
Vladimir Kondratyev
a1181662d3 LinuxKPI: Add devm_device_add_group to linux/device.h
devm_device_add_group creates a managed attribute group for a device.

Sponsored by:	Serenity Cyber Security, LLC
MFC after:	1 week
Reviewed by:	manu
Differential Revision:	https://reviews.freebsd.org/D45845
2024-07-21 16:09:12 +03:00
Vladimir Kondratyev
80aa295a52 LinuxKPI: Add page_to_virt function
Sponsored by:	Serenity Cyber Security, LLC
MFC after:	1 week
Reviewed by:	manu
Differential Revision:	https://reviews.freebsd.org/D45843
2024-07-21 16:09:01 +03:00
Vladimir Kondratyev
742088d9fb LinuxKPI: Add __diag macros
__diag macros turn individual warnings and errors on and off locally,
depending on version of compiler. Add dummy implementation as drm-kmod
set warnings separately for each file.

Sponsored by:	Serenity Cyber Security, LLC
MFC after:	1 week
Reviewed by:	manu, emaste
Differential Revision:	https://reviews.freebsd.org/D45842
2024-07-21 16:08:48 +03:00
Vladimir Kondratyev
ab1a5d8e2a LinuxKPI: Add kmalloc_size_roundup function
kmalloc_size_roundup reports allocation bucket size for the given size.

Sponsored by:	Serenity CyberSecurity, LLC
MFC after:	1 week
Reviewed by:	manu, emaste
Differential Revision:	https://reviews.freebsd.org/D45841
2024-07-21 16:08:37 +03:00
Vladimir Kondratyev
ab6e116790 LinuxKPI: Add kvrealloc to linux/slab.h
Sponsored by:	Serenity Cyber Security, LLC
MFC after:	1 week
Reviewed by:	manu
Differential Revision:	https://reviews.freebsd.org/D45616
2024-07-21 16:08:28 +03:00
Vladimir Kondratyev
5d20075f8b LinuxKPI: Automatically enable drm support for devices named "drmn"
This allows replace linux_pci_(un)register_drm_driver calls with driver
renaming to FreeBSD name.

Sponsored by:	Serenity CyberSecurity, LLC
MFC after:	1 week
Reviewed by:	manu, bz
Differential Revision:	https://reviews.freebsd.org/D45906
2024-07-21 16:02:08 +03:00
Gordon Bergling
619c9488a3 axgbe: Fix two typos in source code comments
- s/specfied/specified/

MFC after:	3 days
2024-07-21 11:06:07 +02:00
Gordon Bergling
c90a206496 ipfilter(4): Fix typos in source code comments
- s/inconsistancy/inconsistency/

MFC after:	3 days
2024-07-21 11:02:31 +02:00
Gordon Bergling
58c99e0750 sctp(4): Fix typos in source code comments
- s/collasped/collapsed/
- s/defininitions/definitions/
- s/optionaly/optionally/

Obtained from:	NetBSD
MFC after:	3 days
2024-07-21 10:57:22 +02:00
Konstantin Belousov
9a7096ff54 ipsec_offload: hide SA/SP offload lifecycle prints under verbose sysctl
Reported and reviewed by:	kp
Discussed with:	np
Sponsored by:	NVIDIA networking
Differential revision:	https://reviews.freebsd.org/D46045
2024-07-21 11:53:19 +03:00
Konstantin Belousov
6023bd1d52 netipsec: move declaration of the sysctl net.inet{,6}.ipsec nodes to header
Reviewed by:	kp
Sponsored by:	NVIDIA networking
Differential revision:	https://reviews.freebsd.org/D46045
2024-07-21 11:53:19 +03:00
Konstantin Belousov
eb0fdc7753 netinet/ipsec.h: remove unneeded "extern"s
Reviewed by:	kp
Sponsored by:	NVIDIA networking
Differential revision:	https://reviews.freebsd.org/D46045
2024-07-21 11:53:19 +03:00
Warner Losh
d3795c1d72 cam/iosched: Use better malloc idiom
Allocate to a simple poiter, use that everywhere, then return it at the
end. The code looks cleaner.

Sponsored by:		Netflix
Differential Revision:	https://reviews.freebsd.org/D46043
2024-07-20 13:59:18 -06:00
Warner Losh
403cc016c0 cam/iosched: Fix build
I was testing this in several trees, and this chunk was in the tree I
tested. I didn't detect the mismerge before the commit...

Fixes: 6f1dd6071a
Sponsored by: Netflix
2024-07-19 22:16:59 -06:00
Warner Losh
123e29068e nvme: widen nvme_qpair_manual_complete_request for better errors
Make nvme_qpair_manual_complete_request take dnr as well as a
print_on_error action. Make the status word computation common between
it and nvme_qpair_manual_complete_tracker. And print the error when
we are cancelling the I/O on failure, but not when we're filtering
the I/O after we've failed. Make it private again to nvme_qpair.c.

Sponsored by:		Netflix
Differential Revision:	https://reviews.freebsd.org/D46049
2024-07-19 20:56:04 -06:00
Warner Losh
9229b3105d nvme: Fail passthrough commands right away in failed state.
When the drive is failed, we can't send passthrough commands to the
card, so fail them right away. Rearrange the comments to reflect the
current failure paths in the driver.

Sponsored by:		Netflix
Differential Revision:	https://reviews.freebsd.org/D46048
2024-07-19 20:55:52 -06:00
Warner Losh
9cbf3d6182 cam/iosched: Make each periph driver provide schedule fnp
When we init the iosched instance, require clients to provide a schedule
function. We have almost, but not quite everything to know when it is
safe to schedule new I/O. The periph drivers, however, have all the
information, so make them do it when the I/O Scheduler needs to maybe
schedule I/O for rate limiting, etc. and use it to do that.

Sponsored by:		Netflix
Reviewed by:		jhb
Differential Revision:	https://reviews.freebsd.org/D46038
2024-07-19 20:53:37 -06:00
Warner Losh
dd6123ebf0 cam/iosched: Log outlier latency events
Log outlier latency events to devd. In addition to counting, this will
allow analysis of whether the problem is confined to a specific block
range, or if it's a more general problem.

Sponsored by:		Netflix
Reviewed by:		jhb
Differential Revision:	https://reviews.freebsd.org/D46036
2024-07-19 20:53:37 -06:00
Warner Losh
6f1dd6071a cam/iosched: Pass in the disk when initializing
The disk is nice to have at times, especially when you need the sector
size. At present, the only plans for this are related to logging.

Sponsored by:		Netflix
Reviewed by:		jhb
Differential Revision:	https://reviews.freebsd.org/D46035
2024-07-19 20:53:37 -06:00
Warner Losh
148c173485 cam/iosched: Pass the transaction down we're collecting stats for
Pass the struct bio * down to the stats collection routines. This allows
us to collect better stats and report more details.

Sponsored by:		Netflix
Reviewed by:		jhb
Differential Revision:	https://reviews.freebsd.org/D46034
2024-07-19 20:53:37 -06:00
Warner Losh
e82644e59e cam/iosched: Add a counter of I/Os that take too long
Add kern.cam.DEV.UNIT.iosched.too_long (to count I/Os taking too long)
and kern.cam.DEV.UNIT.bad_latency (to set this threshold, defaults to
500ms). Each class of I/O (read, write, trim) has its own counters and
thresholds.

Sponsored by:		Netflix
Reviewed by:		jhb
Differential Revision:	https://reviews.freebsd.org/D46033
2024-07-19 20:53:37 -06:00
John Baldwin
680f40f383 stdatomic: Only use clang atomics if __clang__ is defined
GCC 14 defines __has_extension(c_atomic) but does not support
__c11_atomic_*, so require __clang__ for the CLANG_ATOMICS case.

Reviewed by:	imp, emaste
Differential Revision:	https://reviews.freebsd.org/D46001
2024-07-19 13:05:52 -04:00
Navdeep Parhar
cf5e6370f1 cxgbe(4): Changes to ULD list management.
* Convert t4_uld_list to an array.  There will be at most 3 items in the
  list and it's simpler to track them in an array with a fixed slot for
  each ULD.
* There is no need to refcount ULDs so stop doing that.
* Add uld_ prefix to all members of uld_info.
* Rename async_event to uld_stop to match its actual purpose.  Call it
  for all ULDs and not just ULD_IWARP.

Reviewed by:	jhb
MFC after:	1 week
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D46029
2024-07-19 09:12:49 -07:00
Navdeep Parhar
cfcfd3c7bf cxgbe(4): Make no assumptions about the start and size of the L2T table.
Do not assume that the table starts at index 0 and is typically 4K in
size.  The only thing the driver needs to verify is that its use of
F_SYNC_WR doesn't collide with the L2T hwidx range.

Reviewed by:	jhb
MFC after:	1 week
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D46028
2024-07-19 09:12:46 -07:00
Navdeep Parhar
27479403a7 cxgbe/t4_tom: Free up hardware resources when the final CPL is received.
Final CPL means the tid is done in the hardware and other resources
associated with it can be freed right away.  There is no need to wait
for the kernel to detach the toepcb.

Reviewed by:	jhb
MFC after:	1 week
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D45991
2024-07-19 09:12:36 -07:00
Navdeep Parhar
bbc326241d cxgbe/t4_tom: Detach the toep from the tcpcb when entering TIME_WAIT.
The kernel used to call tod_pcb_detach when entering TIME_WAIT but that
seems to have changed, likely with the TIME_WAIT overhaul in the kernel
some time ago.  Catch up by having the driver perform the detach.

The hardware does not handle TIME_WAIT so it's important to detach and
let the kernel arm the 2MSL timer to deal with it.

Reported by:	Sony Arpita Das @ Chelsio
Reviewed by:	jhb
MFC after:	1 week
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D45990
2024-07-19 09:12:31 -07:00
Kristof Provost
fb05f761ac siftr: remove the shutdown_pre_sync event handler on unload
PR:		280351
MFC after:	2 weeks
2024-07-19 08:09:58 +02:00
Doug Moore
e82cee21ba axgbe: drop unused function
A recent change dropped the only use of fls64() in axgbe, so drop its
definition.

Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D46030
2024-07-18 17:21:45 -05:00
Doug Moore
a527b9cb72 axgbe: use standard rounddown_pow_of_two
Drop an implementation of __rounddown_pow_of_two, which triggers
Coverity warnings, and use the libkern implementation of
rounddown_pow_of_two instead.

Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D46022
2024-07-18 13:56:31 -05:00
Jessica Clarke
e1d442a6db Retire unused non-PCI_RES_BUS code
All architectures define PCI_RES_BUS unconditionally now that only
NEW_PCIB is supported, so we no longer need the legacy code.

Reviewed by:	jhb, andrew
Differential Revision:	https://reviews.freebsd.org/D32955
2024-07-18 18:55:33 +01:00
Jessica Clarke
8415a654d0 Retire non-NEW_PCIB code and remove config option
All architectures enable NEW_PCIB in DEFAULTS (arm being the most recent
to do so in 121be55599 (arm: Set NEW_PCIB in DEFAULTS rather than a
subset of kernel configs")), so it's time we removed the legacy code
that no longer sees much testing and has a significant maintenance
burden.

Reviewed by:	jhb, andrew, emaste
Differential Revision:	https://reviews.freebsd.org/D32954
2024-07-18 18:55:12 +01:00
John Baldwin
03248b3f50 NOTES: Correct swapped descriptions of virtio_scmi and virtio_scsi
Sponsored by:	Chelsio Communications
2024-07-18 13:28:57 -04:00
Mark Johnston
f029f62779 zdb: Fix printf formatting of a uint64_t
This fixes the build on 32-bit platforms.

Fixes:	dc91e74524 ("zdb: dump ZAP_FLAG_UINT64_KEY ZAPs properly (#16334)")
2024-07-18 10:52:52 -04:00