Commit graph

1718 commits

Author SHA1 Message Date
Jason A. Harmening
64f4e2bdf5 Avoid waiting on physical allocations that can't possibly be satisfied
- Change vm_page_reclaim_contig[_domain] to return an errno instead
  of a boolean.  0 indicates a successful reclaim, ENOMEM indicates
  lack of available memory to reclaim, with any other error (currently
  only ERANGE) indicating that reclamation is impossible for the
  specified address range.  Change all callers to only follow
  up with vm_page_wait* in the ENOMEM case.

- Introduce vm_domainset_iter_ignore(), which marks the specified
  domain as unavailable for further use by the iterator.  Use this
  function to ignore domains that can't possibly satisfy a physical
  allocation request.  Since WAITOK allocations run the iterators
  repeatedly, this avoids the possibility of infinitely spinning
  in domain iteration if no available domain can satisfy the
  allocation request.

PR:		274252
Reported by:	kevans
Tested by:	kevans
Reviewed by:	markj
Differential Revision: https://reviews.freebsd.org/D42706

(cherry picked from commit 2619c5ccfe1f7889f0241916bd17d06340142b05)

MFCed as a prerequisite for further MFC of VM domainset changes.  Based
on analysis, it would not hurt, and I have been using it in productions
for months now.

Resolved the trivial conflict due to commit 718d1928f874 ("LinuxKPI:
make linux_alloc_pages() honor __GFP_NORETRY") having been MFCed before
this one.
2025-10-23 08:18:48 +02:00
Gordon Bergling
444c56a189 linuxkpi: Fix a typo in a source code comment
- s/__FreeBSD_verison/__FreeBSD_version/

(cherry picked from commit e0875bf019e11f93d5e23b9839e1a7f0c4317320)
2025-09-08 10:24:33 +02:00
Olivier Certner
88a7dd1118 LinuxKPI: Have kvzalloc() rely on kvmalloc(), not kmalloc()
Since commit 19df0c5abcb9d4e9 ("LinuxKPI: make __kmalloc() play by the
rules"), kmalloc() systematically allocates contiguous physical memory,
as it should.  However, kvzalloc() was left defined in terms of
kmalloc(), which makes it allocate contiguous physical memory too.  This
is a too stringent restriction, as kvzalloc() is supposed to be a simple
page-zeroing wrapper around kvmalloc().

According to Linux's documentation ("memory-allocation.rst"), kvmalloc()
first tries to allocate contiguous memory, falling back to
non-contiguous one if that fails.  Thus, callers are already supposed to
deal with the possibility of non-contiguous memory being returned.

Reviewed by:    bz
Fixes:          19df0c5abcb9 ("LinuxKPI: make __kmalloc() play by the rules")
MFC after:      10 days
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D51247

(cherry picked from commit 986edb19a49c7d7d3050c759d9b0826283492ebf)

Forgotten on commit to main/-CURRENT:
PR:             277476
2025-07-31 12:43:10 +02:00
Olivier Certner
fb1c847232 LinuxKPI: alloc_pages(): Don't reclaim on __GFP_NORETRY
Pass VM_ALLOC_NORECLAIM to vm_page_alloc_noobj_contig() so that it
avoids reclaiming (currently, calling vm_reserv_reclaim_contig()).

According to Linux's documentation, __GFP_NORETRY should not cause any
"disruptive reclaim".  alloc_pages() is called a lot from the amdgpu DRM
driver via ttm_pool_alloc(), which tries to allocate pages of the
highest order first and fallback to lower order pages (as allocating
contiguous physical pages is in fact not a requirement).  This process
relies on failing fast, as requested by __GFP_NORETRY.  See also related
commit 718d1928f874 ("LinuxKPI: make linux_alloc_pages() honor
__GFP_NORETRY").

Reviewed by:    jeffpc_josefsipek.net, bz
MFC after:      10 days
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D51246

(cherry picked from commit 4ca9190251bbd00c928a3cba54712c3ec25e9e26)

Forgotten on commit to main/-CURRENT:
PR:             277476
2025-07-31 12:42:44 +02:00
Ed Maste
9e24f4a6d8 linuxkpi: Remove incorrect + 1 from HWEIGHT* macros
Fixes: 4cc8a9da49 ("LinuxKPI: add HWEIGHT32()")
Reviewed by:	bz
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D51010

(cherry picked from commit cdbff1b2999660b31b2de076d04670722a555ed2)
2025-07-28 10:15:31 +02:00
Bjoern A. Zeeb
3a2604d7b5 LinuxKPI: 802.11: switch to m_get3()
Start using m_get3() instead of m_get2() as we may get up to 11K
frames and m_get2() only gives us up to MJUMPAGESIZE (8K).

Sponsored by:	The FreeBSD Foundation
Discovered by:	adrian with rtwn(4) [see D50049].

(cherry picked from commit 02382a0ac822b88e17d86643e27964eba18479e0)
2025-07-16 08:54:06 +02:00
Bjoern A. Zeeb
58ef216043 LinuxKPI: 802.11: add support for GCMP hw crypto offload
For iwlwifi, rtw88, and rtw89 we can treat GCMP the same way as we
treat CCMP which allows us to re-use the CCMP code for now.
Add the missing case statements and factor out some common code.

Allow IEEE80211_CRYPTO_AES_GCM_128 through our filter of supported
cipher suites to announce it to net80211.

Sponsored by;	The FreeBSD Foundation

(cherry picked from commit 29ddd583693aced69be48b545e1c7e7249bdfb9c)
2025-07-16 08:53:47 +02:00
Bjoern A. Zeeb
61d3d5de48 LinuxKPI: 802.11: improve queue locking
Introduce an internal lkpi_ieee80211_wake_queues_locked() function
that can be used from context holding the wiphy lock.
Make linuxkpi_ieee80211_wake_queues() a wrapper with locking around
this.

Equally apply the wiphy lock to linuxkpi_ieee80211_wake_queue().

In lkpi_ieee80211_wake_queues() only wakeup the driver if the queue
is not empty;  otherwise weird sideeffects can happen with some drivers.

Sponsored by:	The FreeBSD Foundation

(cherry picked from commit bc24342d96aa816b448bec4d32b1f5e4a5793886)
2025-07-16 08:53:19 +02:00
Bjoern A. Zeeb
d055cdba2b LinuxKPI: 802.11; update frag_threshold and rts_threshold
Update threshold values once we are associated.

Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 6e7a6a66b239180778bb31da9fa8544bbd977cde)
2025-07-16 08:52:59 +02:00
Bjoern A. Zeeb
ba7debc6a8 LinuxKPI: 802.11: cast jiffies to unsigned long
The joffoes changes are not (yet) merged if they will be.  In order to
not break a possible future MFC of them, cast jiffies to unsigned long
already.  They are only used in logging/debugging here.

Sponsored by:	The FreeBSD Foundation
Fixes:		dcc99bf830b2
2025-07-16 08:52:28 +02:00
Bjoern A. Zeeb
2e96fcb3dd LinuxKPI: 802.11: place lock asserts for key operation
Since b8dfc3ecf7031 we hold the wiphy lock over any key updates.
Assert that on function entry.

Given this invariant there is no need to recheck a kay under lock now,
as the first lookup already is under the lock, so simplify the code.

Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 284af342971d102702df950a2f1e5479eaabdf0b)
2025-07-16 08:52:08 +02:00
Bjoern A. Zeeb
1fe0c1c30a LinuxKPI: 802.11: WEP noise
While we decided that we will not provide WEP support for the LinuxKPI
802.11 compat code, some of it is in there already (also because drivers
still support it).  Put proper keylen checks in place as net80211 only
knows about WEP while LinuxKPI has WEP40 and WEP104.

Sponsored by:	The FreeBSD Foundation

(cherry picked from commit aaee0ed3d163a1d29ea74d7e4d2c3658a51cfb27)
2025-07-16 08:51:40 +02:00
Bjoern A. Zeeb
acb49e1b87 LinuxKPI: 802.11: adjust logging for key handling
Given there are still problems observed (at least in the Lab) adjust
crypto key handling routines and enhance logging with td_tid, jiffies.

Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 80386ed954aaa33b849877e8a86918de9365a087)
2025-07-16 08:51:20 +02:00
Bjoern A. Zeeb
3ed4883403 LinuxKPI: 802.11: move rx_nss check to be at least 1 into sync function
We set rx_nss to at least 1 and the sync functions for HT and VHT are
careful not to set it to 0.   Rather than relying on that and any
possible future call to lkpi_sta_sync_from_ni() migrate the MAX()
call into the sync function after each standard level went through
to make sure that at the end we at least have rx_nss set to 1.

Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 34c150cc5fdb3c599bb6ff14eb56afee00c45258)
2025-07-16 08:50:55 +02:00
Bjoern A. Zeeb
7ec85951a5 LinuxKPI: 802.11: ensure bandwidth <= channel bandwidth
While we could select our own channel width and station bandwidth
indepedent of net80211 that is not a good idea and will lead to
trouble.  Make sure the station bandwidth we select does not
exceed the bandwidth of the channel we are tuned into.

Now that VHT160 work we may locally disable it (-vht160) and the
AP may still support it but we would be on a 80Mhz channel.
Or we do support VHT160 but the AP does not.  Again we would be
on a 80Mhz channel and not support 160Mhz.

Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 9df0d1f3d1f3dd8823800210dd49e40170d5abd8)
2025-07-16 08:50:23 +02:00
Bjoern A. Zeeb
987223006e LinuxKPI: 802.11: make synching from HT more resilient
During testing I hit a case where htcap->mcs.rx_mask[0,1] were zero.
This should not happen as that would mean we are not supporting HT.
After adding extra caution for debugging I could no longer reproduce
the case.

So just to deal with the eventuality make synching from HT more
resilient by checking that we have nss > 0 or otherwise disable
HT operations.

Move setting the bandwidth below this check to not alter it in
case of the now early return.

Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 58dae28f665b32650f452730378693de40e96d68)
2025-07-16 08:50:02 +02:00
Bjoern A. Zeeb
7979bbe2af LinuxKPI: 802.11: fix lkpi_scan_ies_add() channel lookup
When looking up the channel we may not get a result if no flags are
passed in as net80211 channel list setup and lookup coding requires a
matching flag (band).  So pass in IEEE80211_CHAN_[AG] depending on band
to increase the chances of finding a base channel and from that derive
rates, etc.

Sponsored by:	The FreeBSD Foundation

(cherry picked from commit f1a110f1f0f2ef83758f7d0a984b14f512ea00fd)
2025-07-16 08:49:23 +02:00
Bjoern A. Zeeb
857d924cd9 LinuxKPI: 802.11: stop queues during key updates
When beginning key updates do stop and afterwards re-enable the tx queues
to avoid packets being passed to the driver.  This is a theoretical
problem at this point but helps some cases.  These functions will likely
need refinement in the future.

Sponsored by:	The FreeBSD Foundation

(cherry picked from commit db480c29879cac1afba1d887d7b8871aa4eef6db)
2025-07-16 08:49:06 +02:00
Bjoern A. Zeeb
59ea420e71 LinuxKPI: dummy: add more dummy hreader files
These are needed for mt76.

Sponsored by:	The FreeBSD Foundation

(cherry picked from commit e8e2ed66f0978c439c7e93ff3d30a86ffad5bf56)
2025-07-16 08:48:15 +02:00
Bjoern A. Zeeb
45d0a75002 LinuxKPI: pci: fix two errors in lkpi_pci_get_device()
On any result we need to acquire a reference. pci_dev_get() deals with
a NULL argument so we can simply pass what we "found" at the end.
This will avoid reference count problems.

If the iteration on the linux list in lkpi_pci_get_device() does
not find a match pdev will still be defined at the end of the
loop but not pointing to a valid pdev.
Store the found entry in a 2nd variable which otherwise will be NULL.
This will avoid random panics, usually in sysfs_remove_dir() when
the reference gets released.

Found during mt76 bringup.

Sponsored by:	The FreeBSD Foundation
Fixes:		8f61992d7c
Reviewed by:	dumbbell
Differential Revision: https://reviews.freebsd.org/D50153

(cherry picked from commit 2c65f965146a7f822302715a439e17996d17453c)
2025-07-16 08:46:44 +02:00
Bjoern A. Zeeb
098d70f5ab LinuxKPI: pci: deal with kobject_add() being able to fail
lkpifill_pci_dev() uses a sequene of kobject_init/set_name/add.
The problem is that kobject_add could fail.

Move the entire logic to the beginning of the function,
switch to kobject_init_and_add() and check the return code.
Make lkpifill_pci_dev() return the error and deal in the callers
with a possible error accordingly.

Sponsored by:	The FreeBSD Foundation
Reviewed by:	dumbbell
Differential Revision: https://reviews.freebsd.org/D50154

(cherry picked from commit 96e86aa6faa6fde4ff75fd757db55afe9e4be132)
2025-07-16 08:46:32 +02:00
Bjoern A. Zeeb
25bbb6c554 LinuxKPI: style
Check results of non-bool to be != 0.

No functional changes intended.

Sponsored by:	The FreeBSD Foundation
Reviewed by:	emaste
Differential Revision: https://reviews.freebsd.org/D50158

(cherry picked from commit 76b66ac45ea804f23ffb35712b0ceaa98864c06f)
2025-07-16 08:45:48 +02:00
Bjoern A. Zeeb
55b4ef5444 LinuxKPI: skbuff: make csum_unfold return __wsum
Given the internal field now stores a __wsum csum (after we added
the type) also make sure csum_unfold() returns a __wsum.

Sponsored by:	The FreeBSD Foundation
Fixes:		59481c7db234

(cherry picked from commit 36ca21722c2700e00e41444a29aeabf246eea90d)
2025-07-16 08:45:25 +02:00
Bjoern A. Zeeb
1ca66ac330 LinuxKPI: skbuff: add dummy skb_copy_header()
There's one case which needs skb_copy_header();  add a dummy function
for now until we get to the code which uses it to test an implementation.

Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 84c5998ccb0b3e8a401d1f2b5a32649e88847d63)
2025-07-16 08:45:25 +02:00
Bjoern A. Zeeb
6e214c2140 LinuxKPI: add struct_group_tagged()
Restructure struct_group() into a wrapper around __struct_group().
Various callers have arguments annotated as /* no foo */ so try to
add all we can find.

Sponsored by:	The FreeBSD Foundation
Reviewed by:	dumbbell
Differential Revision: https://reviews.freebsd.org/D50157

(cherry picked from commit 54d0e1772fb6b83d72725764e0a5d3ead8337673)
2025-07-16 08:45:06 +02:00
Bjoern A. Zeeb
1a1a1ffd85 LinuxKPI: add ktime_get_boottime_seconds()
ktime_get_boottime_seconds() is needed by an updated iwlwifi driver.

Sposored by:	The FreeBSD Foundation
Reviewed by:	dumbbell
Differential Revision: https://reviews.freebsd.org/D50005

(cherry picked from commit 93b82146c43b8ecad4fd7694ec1daf6d79cca65c)
2025-07-16 08:44:48 +02:00
Bjoern A. Zeeb
2ca8d402df LinuxKPI: add is_unicast_ether_addr()
Needed by mediatek/mt76 wireless driver.

While here adjust the way is_multicast_ether_addr() is implemented
to not look weird. [1]

Sponsored by:	The FreeBSD Foundation
Suggested by:	emaste [1]
Reviewed by:	emaste
Differential Revision: https://reviews.freebsd.org/D50152

(cherry picked from commit a4618caa43c16e6e672c27dac1943fd833f8bd8f)
2025-07-16 08:43:58 +02:00
Bjoern A. Zeeb
ddb311ffab LinuxKPI: add _devcd_free_sgtable() to devcoredump.h
It may be that once we implement freeing of chained tables
_devcd_free_sgtable() will become our _lkpi_dev_coredumpsg_free()
but further investigations need to happen.  For now make an
updated iwlwifi driver happy which should not need more.

Sponsored by:	The FreeBSD Foundation
Reviewed by:	dumbbell
Differential Revision: https://reviews.freebsd.org/D50006

(cherry picked from commit 71576ed24b56143429a3b6774a7862965c2dea88)
2025-07-16 08:43:07 +02:00
Bjoern A. Zeeb
bf1e748dfd LinuxKPI: netdev features style, annotate, and add %b decoding mask
Start to sort through the netdevice features to match them with
FreeBSD.  Annotate them a bit more verbose though the names are
pretty telling already.

While here adjust style(9) as well.

Lastly add the bit definitions for use with printf(9) %b as names
read easier than bitmasks.  We will use that in LinuxKPI 802.11.

No functional changes.

Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 4b6b9c1368b346f7093153d14e7931403ac3202d)
2025-07-16 08:42:44 +02:00
Bjoern A. Zeeb
5ddd593b7a LinuxKPI: netdev: add NETIF_F_HW_TC
Add a new flag needed by mt76.

Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 9c05d6320cc091ffb43002a149c04c122ccb798c)
2025-07-16 08:42:42 +02:00
Bjoern A. Zeeb
029e6b79e2 LinuxKPI: acpi: add acpi_evaluate_dsm()
Add a acpi_evaluate_dsm() wrapper around the native implementation
as needd by wireless drivers.

Sponsored by:	The FreeBSD Foundation
Reviewed by:	dumbbell
Differential Revision: https://reviews.freebsd.org/D50864

(cherry picked from commit ba6460df5607e572e9c868413c75ce9bc5ce9a00)
2025-07-16 08:34:33 +02:00
Bjoern A. Zeeb
1be17baf53 LinuxKPI: acpi: provide union [linuxkpi]_acpi_(object|buffer)
Provide union acpi_(object|buffer) as linuxkpi_ versions and in Linux
native lower case spelling so that driver code compiles unmodified.

Use the linuxkpi_ prefix to avoid name clashes with the native ACPI
implementation which uses CamelCase.

Use the linuxkpi_ names internally and redefine the linuxkpi_ unions
to their native names so they are avail as expected in drivers.

As a transition to not break drm-kmod which has in-place (no #ifdef)
changes from Linux spelling ot FreeBSD spelling, introduce
LINUXKPI_WANT_LINUX_ACPI so we have the Linux spelling as an opt-in.
That way the transition can happen gracefully and once "top-of-trees"
are all sorted we can remove the #ifdefs here again.

Bump __FreeBSD_version to be able to detect this change.

Sponsored by:	The FreeBSD Foundation
Reviewed by:	wulf (previous version), dumbbell
Differential Revision: https://reviews.freebsd.org/D50863

(cherry picked from commit 2ddfcc013c251f13c8c9b24970b8134ddd49afea)
2025-07-16 08:34:33 +02:00
Bjoern A. Zeeb
743d465e86 LinuxKPI: MODULE_DEVICE_TABLE() factor out the bus specific MODULE_PNP_INFO()
In order to be able to use MODULE_DEVICE_TABLE() with multiple bus
attachments, factor out the bus-specfic MODULE_PNP_INFO() and place
it next to the structure defining the table.

As it turns out bnxt(4) has been using the MODULE_DEVICE_TABLE() with
PCI attachments for the "auxillary" bus so far.  That makes little sense.
Define the MODULE_PNP_INFO() to nothing for that.  We may consider
pulling these LinucKPI bits in semi-native drivers into LinuxKPI
one day as that route is not really sustainabke.

Sponsored by:	The FreeBSD Foundation
Reviewed by:	imp, dumbbell
Differential Revision: https://reviews.freebsd.org/D51049

(cherry picked from commit 2f5666c1727c949491f73e6c3277b7b542131714)
2025-07-16 08:34:33 +02:00
Bjoern A. Zeeb
9860e47f49 LinuxKPI: MODULE_DEVICE_TABLE() remove hard coded pci
While we currently only use MODULE_DEVICE_TABLE() for pci (or so I
thought [*]), this may soon change.  Remove a hard coded "pci" for
the bus and use the bus name passed in as _bus.

[*] see follow-up change

Sponsored by:	The FreeBSD Foundation
Reviewed by:	imp, dumbbell
Differential Revision: https://reviews.freebsd.org/D51048

(cherry picked from commit f58e032410c93d67c83d6bce8a3e6711f377a4be)
2025-07-16 08:34:33 +02:00
Bjoern A. Zeeb
bc1acdbcb8 LinuxKPI: Implement dma_map_resource/dma_unmap_resource functions
dma_map_resource() and dma_unmap_resource() functions are used to map
and unmap of memory-mapped IO resources so they can be accessed by
the device.

Required by drm-kmod v5.5 to be built.

While for drm-kmod 6.6-lts only amdgpu uses these in one place and
the code apparently has not been exercised a lot it has been around
like this for years.  With changing the underlying implementations
bring it into the tree; should we find errors with it they can also
be fixed here.

Bump __FreeBSD version to be able to detect this change.

Obtained from:	D30933 (by wulf)
Sponsored by:	The FreeBSD Foundation
Reviewed by:	dumbbell
Differential Revision: https://reviews.freebsd.org/D49625

(cherry picked from commit a02180cf60a6a0102669b678e9c81ad9f1aa4d91)
2025-07-16 08:34:33 +02:00
Bjoern A. Zeeb
bef3edfe61 LinuxKPI: add missing bus_dmamap_sync() calls or exclude them
Rename linux_dma_unmap() to lkpi_dma_unmap(), and linux_dma_map_phys()
to lkpi_dma_map_phys() so that we get the full set of function
arguments (direction and attributes were missing).
Leave the old functions as wrappers as they are called from drm-kmod
linuxkpi/bsd still, and leaving them also allows us to MFC this
change.

Add missing bus_dmamap_sync() calls.  Rather than inlining them
in each inline function push them down to the actual implementation.
From there do not inline them either but call the appropriate
function dealing with the sync so that we do not have the same
code splattered in many places.

Adhere to the DMA_ATTR_SKIP_CPU_SYNC attribute and skip synching
when requested.

A previous, less complete version of this change already allowed
me to load firmware on arm64 for iwlwifi (again).

There are four more places which are not currently done as the
functions which came with an OFED sync a long time ago seem to be
unused these days.  Leaving a pr_debug("TODO") call there.

Also dma_[un]map_resource() when brought in from drm-kmod/linuxkpi/bsd
(D30933) should be adjusted to pass the full arguments as the amdgpu
callers are requesting to skip synching.

Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D45294

(cherry picked from commit f99d393f7f787ff080c12b92243adcc310ac7c58)
2025-07-16 08:34:33 +02:00
Bjoern A. Zeeb
0e285f4524 net80211: fix VHT160 and VHT80P80 selection and enable in LinuxKPI 802.11
Between 802.11ac-2013 and 802.11-2020 some fields were deprecated and the
way VHT160 and VHT80P80 are selected has changed.
In order to get onto VHT160 with modern APs adopt and support both the
deprecated as well as the new logic.

For simplicity of blocks we pull out the non-HT40 handling early on,
followed by the "use HT", followed by the deprectaed options and then
the 80Mhz channel width.

In all cases keep checking (a) what is locally supported, (b) what the
user has locally allowed (FVHT flags, [-]vht160 [-]vht80p80 [-]vht80
[-]vht40), as well as (c) what is announced.  Provide possible fallbacks
to lower channel widths in all cases (but VHT20, which means VHT is
disabled).

With this enable VHT160 and VHT80P80 in the LinuxKPI 802.11 driver
compat code as well.

Sponsored by:	The FreeBSD Foundation
Reviewed by:	thj
Differential Revision: https://reviews.freebsd.org/D49773

(cherry picked from commit 4bf049bfeefd988fed93149138c422b05d38251b)
2025-07-09 10:05:46 +02:00
Bjoern A. Zeeb
d4537584c5 LinuxKPI: 802.11: add ieee80211_purge_tx_queue()
Add ieee80211_purge_tx_queue() dummy function needed by rtw88 SDIO.

Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 9cac7351868d0e896a648ffe354b001ced55acfa)
2025-07-09 10:05:45 +02:00
Bjoern A. Zeeb
6cdd444452 net80211: LinuxKPI: migrate HE defines to net80211, put correct values
Migrate most LinuxKPI 802.11 definitions for HE IEs to net80211.
During that process also properly define them as most of them only
had dummy values.  Some of the definitions are sparse;  that is, only
the bits used by drivers so far were listed and annotated with the
standards section.

There seems to be little point to mangle the names and have two copies
of all these bit field definitions.  We can add "_S" (shift/mask)
variants to those we need in net80211 (if we do).

Sponsored by:	The FreeBSD Foundation
Reviewed by:	adrian
Differential Revision: https://reviews.freebsd.org/D50677

(cherry picked from commit 2ab7cbdc346e2a174a7bee4ce44c4f78b1ca093b)
2025-07-09 10:05:45 +02:00
Bjoern A. Zeeb
2942bbeaa1 net80211: LinuxKPI: migrate HE IE structs from LinuxKPI to net80211
Take the HE IE structures as they are used by drivers and put them
into net80211 rather than LinuxKPI.  There is little need to
re-invent the wheel on those.  They settled for long enough.

Do not export them by default to user space as some also overlap with
wpa and we still do not have a clear distinction for what is available
only in kernel and what to user space.   In our case ifconfig(8)
is a consumer of these structs which it can setting WANT_NET80211 like
we have done for some VHT bits before.

Add struct net80211_he_cap which holds the IE fields but also a bool
and is meant to be put into ic/vap/ni.  The bool will give us the same
naming for all layers rather than having individual flags in each part
which was highly confusing.  In theory this struct should be in
ieee80211_var.h but that would pull things apart.

Extend struct ieee80211_mu_edca_param_set by a union as it will help
ifconfig(8) parsing the bk/be/vi/vo parts.

Sponsored by:	The FreeBSD Foundation
Reviewed by:	adrian
Differential Revision: https://reviews.freebsd.org/D50676

(cherry picked from commit 8be200cf968f0c7f72f75c8a73d7b2bee43f935d)
2025-07-09 10:05:45 +02:00
Bjoern A. Zeeb
ec4ef92fd8 LinuxKPI: 802.11: update HE structures
Update strutures needed for 11ax (HE) to be correct.  Add references
to the standard.

Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 71f854e5a01a347174d09d594b3d490f806cf850)
2025-07-09 10:05:45 +02:00
Bjoern A. Zeeb
5bdc7c4962 LinuxKPI: 802.11: use macros for locking
Rather than using inline functions use macros so we know where we are
taking the lock in the code rather than only recording the inline
function location.

Sponsored by:	The FreeBSD Foundation

(cherry picked from commit d87ee937ed852cd22eac808bc8fcf7b0e34c9ec1)
2025-07-09 10:05:45 +02:00
Bjoern A. Zeeb
4d66e0f884 LinuxKPI: 802.11: mark struct ieee80211_ht_cap __packed
In lkpi_sta_sync_ht_from_ni() we are casting the information element (IE)
data to this struct as net80211 does not save the mcs/rx_mask.
Not marking the structs packed results in the mcs information not being
copied correctly and rx_nss calculations possibly being off.  Even worse,
at a later stage iwlwifi mvm/rs.c would extract the mcs values from the
same field to pass to the firmware which will than crash in an assert
as we would want to do HT with an empty MCS set.

Sponsored by:	The FreeBSD Foundation
Discovered:	while testing other features on arm64.
Approved by:	re (cperciva)

(cherry picked from commit 6cbf8a04b1864d933506301cabe213a9c918d968)
(cherry picked from commit 9ccf7aeaa5dc5ceb3bf896d84ee50294b841043b)
2025-05-27 22:44:20 +00:00
Bjoern A. Zeeb
36174c38f9 LinuxKPI: 802.11: make sure AUTH frames are not being sent if BSS changed
iwlwifi keeps logging 'Invalid TXQ id' even after previous changes to
catch the BSS changed.  The reason for this is that we do not error in
the SCAN -> AUTH path as otherwise we would not have the state machine
get us back to SCAN to clear up firmware state before auth/assoc to the
new BSS.

If we are not in synch as net80211 just swapped the iv_bss from under us,
disable the TX queue for the (old) lsta to prevent the AUTH frame sent
from sta_newstate() reaching the driver.  After all we are not trying to
authenticate to that node (sta) anymore.

Sponsored by:	The FreeBSD Foundation
PR:		274382
Approved by:	re (cperciva)

(cherry picked from commit 16d987fe781780100a31df30b9edd79ebb54f957)
(cherry picked from commit e0692e7bb6e8abcc55a2510dceea5f83e823a827)
2025-05-15 19:13:58 +00:00
Bjoern A. Zeeb
873c0ea648 LinuxKPI: 802.11: header updates for mt76
Add more structs, fields, flags, defines.

Sponsored by:	The FreeBSD Foundation
Approved by:	re (cperciva)

(cherry picked from commit 675e6b1c68ba71af1853952f7df4d84399340009)
(cherry picked from commit 6a0dbc0a1246c9825f0892bb6dd957f5d081057a)
2025-05-08 21:22:53 +00:00
Bjoern A. Zeeb
71946313d4 LinuxKPI: 802.11: fix wiphy_info[_once]
The dev field in wiphy is a pointer already; no need for &.

Sponsored by:	The FreeBSD Foundation
Fixes:		ac1d519c01ca8
Approved by:	re (cperciva)

(cherry picked from commit 845b81cf908002b14ac08ce8c42246720a5b30d9)
(cherry picked from commit a21addc7a0137c5938414df322dbf5f929729834)
2025-05-08 21:22:35 +00:00
Bjoern A. Zeeb
62c010b651 LinuxKPI: define time64_t
Define time64_t to int64_t for all supported architectures
unconditionally.

Sponsored by:	The FreeBSD Foundation
Reviewed by:	imp, markj, emaste
Differential Revision: https://reviews.freebsd.org/D50004

(cherry picked from commit 8b51cd07f69e9a5052f660d96a8feb7af4b387c1)
2025-04-29 10:49:34 +00:00
Bjoern A. Zeeb
89473d9a1b LinuxKPI: add dummy header file linux/unaligned.h
Long-term asm/unaligned.h is likely to migrate to this file?

Sponsored by:	The FreeBSD Foundation
Reviewed by:	emaste
Differential Revision: https://reviews.freebsd.org/D50003

(cherry picked from commit 28efbf9d2f67ce0bb24ad83462c99a1c2771e602)
2025-04-29 10:49:34 +00:00
Bjoern A. Zeeb
85bd58055f LinuxKPI: sysfs: implement sysfs_match_string()
Use a macro to automatically gather the length of the array while
we can.

Sponsored by:	The FreeBSD Foundation
Reviewed by:	emaste
Differential Revision: https://reviews.freebsd.org/D50007

(cherry picked from commit f94d7319540b9b2256be60c2c666efe0b6e635ef)
2025-04-29 10:49:33 +00:00
Bjoern A. Zeeb
6510caf356 LinuxKPI: pci: add pci_info()
Add pci_info() needed for a driver update.  While here prefix
__VA_ARGS__ with ## for pci_err and pci_info in case we are only
passed a string without format arguments.

Sponsored by:	The FreeBSD Foundation
Reviewed by:	emaste
Differential Revision: https://reviews.freebsd.org/D50009

(cherry picked from commit e29d72ac3ddd9b97d945c5c64bc817e501bb113c)
2025-04-29 10:49:33 +00:00