Make iwlwifi compile with debugfs after the last updates and turn it on
for both iwlwifi and rtw88 in order to be able to get at least some
useful information on driver/firwmare state.
Sponsored by: The FreeBSD Foundation
(cherry picked from commit 07f6575585bf69ae48dffe87c4578057ae4782d8)
rate_lowest_index() is no longer used anywhere in our code.
Garbage collect it.
Sponsored by: The FreeBSD Foundation
(cherry picked from commit 1b840f09b6b379c0aae5a558ba5a4ed6bb571a85)
Given the channel struct has an extra bool we cannot assign the
information 1:1 to net80211. While the caps where assigned the
suppoerted mcs sets were not. Fix that.
Sponsored by: The FreeBSD Foundation
(cherry picked from commit ecb2e5f9c30a8c0ae491d07b2300e37eb599c298)
Implement the combination of all four functions, the *_vif versions
from mac80211.h as a wrapper to the non-*_vif ones in cfg80211.h.
Put the function pairs next to each other and in the right files
and harmonize argument naming, etc.
Both of them have shown up too often in the todo-tracing to bother
enough to implement them now for a time in the future when we will
support HE/EHT.
Sponsored by: The FreeBSD Foundation
(cherry picked from commit c75a558d0729da87ee3c016b57cc8f5ac4fc65d0)
Let the macro take a format string and arguments and
add __func__, __LINE__ to the output.
Sponsored by: The FreeBSD Foundation
(cherry picked from commit a4cdb785bbd7e26cc3f2ed0bb4e5cf7ea83c400b)
Add a print mask for use with %b to aid debugging. It is a lot easier
to read names than numbers.
Sponsored by: The FreeBSD Foundation
(cherry picked from commit f1aeb5d850cf26418fb70a16d1304b92c45b5f1d)
This will help us to get minimally better lock coverage in iwlwifi
though not yet against the LinuxKPI implementation which will likely
switch to this in the future. At least the TODO() logging noise is
out of the way.
Sponsored by: The FreeBSD Foundation
(cherry picked from commit 95a7aa8009877ca95d81967f9af568ef832bb565)
Bring in changes missed during the last driver updates to make HT
compile when enabled.
Sponsored by: The FreeBSD Foundation
Fixes: 7b43f4d064195
(cherry picked from commit 943a19c666d67424cdde6cbcd096f28359b2d314)
net80211 node ni_chw currently encodes the channel width as Mhz number.
LinuxKPI 802.11 uses enum ieee80211_sta_rx_bw for the same.
Rather than keeping the "20" and "40" throughout the code (eventually
expanded to 80/160/320) switch them over to use the enum throughout.
Once we get to 320Mhz channel widths we would otherwise also need to
extend the uint8_t in struct ieee80211_node; making
enum ieee80211_sta_rx_bw __packed allows us for lots more channel
widths without breaking the KBI.
Sponsored by: The FreeBSD Foundation
Reviewed by: adrian
Differential Revision: https://reviews.freebsd.org/D47891
(cherry picked from commit ca389486a9599768e0ba69dca13c208020623083)
(cherry picked from commit 2c8b0d6205f6f98855773e3a82640b50abb2f2f6)
Given we have the support in main and stable/14 to load plain firmware
files from /boot/firmware/ make use of that. Switch the order to
try the original unmangled filename and path first before trying any
replacements.
This reduces time and console noise (especially under bootverbose).
Sponsored by: The FreeBSD Foundation
Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D47682
(cherry picked from commit 30d2f84ef2cba12c67c62a9fe4e1d8e22cf27bf9)
Bring in the LinuxKPI 802.11 compat bits which are altering
the mac80211 KPI.
* In struct ieee80211_bss_conf chandef -> chanreq.
* Various struct ieee80211_ops gained a link_id arguemnt,
stop gained a suspend flag.
* Various functions gained a link_id argument.
* ieee80211_tx_status() was renamed to ieee80211_tx_status_skb()
Sponsored by: The FreeBSD Foundation
(cherry picked from commit 7b43f4d064195bcf66816cb9fe350a1392fe24ce)
Linux has a header file that defines an ilog2 function and some simple
functions/macros that use it: roundup_pow_of_two, is_power_of_2,
rounddown_pow_of_two, and order_base_2. This change moves three of
those simple functions (all but is_power_of_2) from linuxkpi to
libkern. It also deletes a few implementations of these functions
that have previously been copied into code for various device drivers,
so that they can use the libkern version. The is_power_of_2 macro was
not moved because powerof2 in param.h provides almost the same service
already (except that they disagree about whether 0 is a power of two).
Since the linux definitions of these functions were copied into
FreeBSD 11 years ago, linux has improved them, and this change
provides those improvements. In particular, a giant table of log
values for evaluating ilog2 for constant values is no longer
necessary.
Reviewed by: alc, markj (previous version)
Differential Revision: https://reviews.freebsd.org/D45536
(cherry picked from commit c8b0c33b03ac072413b27bed2bdae2ae27426f3a)
The kernel source contains several definitions of an ilog2 function;
some are slower than necessary, and one of them is incorrect.
Elimininate them all and define an ilog2 macro in libkern to replace
them, in a way that is fast, correct for all argument types, and, in a
GENERIC kernel, includes a check for an invalid zero parameter.
Folks at Microsoft have verified that having a correct ilog2
definition for their MANA driver doesn't break it.
Reviewed by: alc, markj, mhorne (older version), jhibbits (older version)
Differential Revision: https://reviews.freebsd.org/D45170
Differential Revision: https://reviews.freebsd.org/D45235
(cherry picked from commit b0056b31e90029553894d17c441cbb2c06d31412)
In 886653492945f we added checks for packets to only go out if the
station is known to the firmware (amongst others) as there are
implications in drivers.
Unfortunately rtw88 does not support the mac80211 (*sta_state)() KPI
but only the fallback (*sta_add/remove)() in which case the station is
only added to firmware when going from AUTH to ASSOC. That means we
had no chance to get authenticated anymore.
PR: 283142, 274382
Fixes: 886653492945f (make sure we can send DISASSOC or DEAUTH frames)
Tested by: imb protected-networks.net, oleg.nauman gmail.com
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D48161
(cherry picked from commit 2372f8cc640c2f4ab82831e6ac0e27ab6c18321a)
No functional change (intended).
Reviewed by: kib
MFC after: 4 days
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D48497
(cherry picked from commit 9b7157c690723279d448fc7ea9c1f9374ad4511a)
Bump the vnode use count, not its hold count. This fixes a panic triggered
by fstatat(..., AT_EMPTY_PATH) on DRM device nodes, which happens to be
what glxinfo(1) from Ubuntu Jammy is doing.
PR: kern/274538
Reviewed By: kib (earlier version), olce
Differential Revision: https://reviews.freebsd.org/D47391
(cherry picked from commit fc595a6b76642dfdfdb8e6f9b9bbc734e95fb59c)
THIS_MODULE is used to differentiate modules on Linux. We currently
completely stub out any Linux struct module usage, but THIS_MODULE
is still used to populate the "owner" fields of various drivers.
Even though we don't actually dereference these "owner" fields they
are still used by drivers to check if devices/dmabufs/etc come
from different modules. For example, during DRM GEM import some
drivers check if the dmabuf's owner matches the dev's owner. If
they match because they are both NULL drivers may incorrectly think
two resources come from the same module.
This adds a general purpose __this_linker_file which will point to
the linker file of the module that uses it. We can then use that
pointer to have a valid value for THIS_MODULE.
Reviewed by: bz, jhb
Differential Revision: https://reviews.freebsd.org/D44306
(cherry picked from commit 28a59100b54ff245a45fbd328266266f1c14eb8c)
Annotate lkpi_ic_recv_action(), lkpi_ic_send_action(), and
lkpi_ic_ampdu_enable() with HT specifc debug logging as we only hook
them up currently for debug tracing but later should not need them
anymore.
Start the implementation for lkpi_ic_addba_request(),
lkpi_ic_addba_response(), and lkpi_ic_addba_stop().
Improve the implementation of lkpi_ic_ampdu_rx_start() and
lkpi_ic_ampdu_rx_stop().
Sponsored by: The FreeBSD Foundation (commit)
(cherry picked from commit 310743c4ccc545d58401cb9fb7761432e12a9fb5)
If a LinuxkPI base wireless driver does not support the (*ampdu_action)()
ieee80211_ops function for offloading parts to firmware there is no
reason for us to hook into the net80211 callbacks either but simply
to let software (net80211) handle this.
Sponsored by: The FreeBSD Foundation (commit)
(cherry picked from commit 86bc7259d3d558495511a0a23d137b4a6cd030f3)
The changes from 4aff4048 were based on net80211 which is still using
if_private.h details. Adjust the code to no longer depend on internal
details of ifnet. We also switch the "check"-functionn from if_init to
if_transmit which we can query. Given we do have a per-vif eventhandler
we could do without that check but would still need to check
if_getflags() for IFF_UP.
Sponsored by: The FreeBSD Foundation
Reported by: jhibbits
Fixes: 4aff4048
Reviewed by: jhibbits
Differential Revision: https://reviews.freebsd.org/D47490
(cherry picked from commit edab5a280e0b4a53d0f3e34957075c7efe048e8d)
Add sys/sytm.h for __diagused which unbreaks compilation of
drm-kmod 5.10-lts on main.
Sponsored by: The FreeBSD Foundation
Reported by: Evgenii Khramtsov
PR: 282479
Fixes: 5c92f84bb607
(cherry picked from commit 9b2705121ba230bf71a1509cc928f0481dfbf31c)
Bring ing the LinuxKPI 802.11 compat bits which are not altering
the mac80211 ops KPI.
* Add various functions for driver updates.
* Add functions (some compat code to I assume cleanup some
mac80211 ops) emulating chanctx changes doing (*config) updates.
* Adjust structs and defines.
* Deal with an enum growing more than 32 bits in printf.
* Add a mtx to struct wiphy which is exposed to the drivers.
Handle initialization and destruction for now.
* Implementation of wiphy_work and wiphy_delayed_work.
* Set was_assoc for deassoc/deauth in prep_tx_info.
Sponsored by: The FreeBSD Foundation
(cherry picked from commit ac1d519c01ca8beb59f27962c7052d09a03f72c8)
Update rcu_dereference_{check,protected}() to call the check and log
once if it fails and if the RCU debug sysctl is turned on.
Also add proper checks for conditions passed in to these functions.
For that implement linux_rcu_read_lock_held() (lots of help from wulf).
(While here also remove extraneous extern for function prototypes).
Update lockdep_is_held() to always be an inline function with argument
annotation so that we do no longer have unused variables
in callers which only call lockdep_is_held().
Sponsored by: The FreeBSD Foundation
Reviewed by: wulf
Differential Revision: https://reviews.freebsd.org/D46842
(cherry picked from commit 5c92f84bb607c692ce4fa762a7a3c4b86a2fa281)
PCI_IRQ_LEGACY was added in 366d68f283 (likely) for rtw88 only.
The define now got renamed and I cannot find any other use but
rtw88 and rtw89.
We keep the old name as comapt while driver updates are in
progress enabling it defining LINUXKPI_VERSION for the two drivers.
Sponsored by; The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D46822
(cherry picked from commit 157e93e0e8138fbaa6ab5d5b20b0c23f903667a6)
Add alloc_netdev_dummy() which is needed by an updated rtw88 driver.
Given we already call linuxkpi_init_dummy_netdev() ourselves allow the
setup function to be NULL to not initialize and start a tasq td twice.
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D46802
(cherry picked from commit 105331f658e2f14fb4daa64dcd076c7369505295)
iwlwifi v6.11 started to use guard(). _T in the implementation needs
to be exposed to the driver which uses it in DEFINE_GUARD().
Given this is the first instance of attribute(cleanup) in the tree:
- gcc has support for it since at least 2003-06-04
(0bfa5f65bfb186f10d43304946fd7fcd69988732)
- llvm gained support on 2009-01-31
(d277d790e0f6f23043397ba919619b5c3e157ff3, llvm-svn 63462).
Sponsored by: The FreeBSD Foundation
Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D46843
(cherry picked from commit fa81baa307da9a0055d7d08f6d141ea310f067ed)
Those files are required by updated wireless drivers.
Sponsored by: The FreeBSD Foundation
(cherry picked from commit 6621842ccfb4dd01470e9085697b553d10634eb0)
Add time_is_before_jiffies() as needed by iwlwifi from v6.11.
Sponsored by: The FreeBSD Foundation
Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D46841
(cherry picked from commit 8f9567628cb2ccb335640c4bb044df2ebf45d83a)
rtw89 TX path was faulting in linuxkpi_ieee80211_next_txq() due to a
"double scheduling" check in linuxkpI_ieee80211_schedule_txq() being
incorrect:
the next pointer may be NULL there if the element is the last in the
tailq, so correctly check tqe_prev. Without the fix we may have queued
the same element to the tailq twice, and because it was the last element
and had a NULL tqe_next, that NULL value would get propogated into
another node's tqe_prev on removal, and other such nastiness.
With this rtw89 no longer panics.
Reviewed by: bz
Differential Revision: https://reviews.freebsd.org/D47006
(cherry picked from commit 41b746e05231b44c87f3a3087a7fe29966af6d0f)
Native Linux implementation sets this as a maximum between 1 and
ht/vht/eht rx SS'es, FreeBSD does the same, but uses 0 as a minimum,
which leads setting it to 0 if we're not in ht/vht case.
This 0 was breaking rtw89 driver, when it was trying to determine
SS number by subtracting 1 from rx_nss and passing the value to the
hardware.
After this patch rtw89 association and simple ping work reliably,
but more work is needed to make the driver robust with heavy traffic
(iperf3) and being long idle.
Reviewed by: bz
Sponsored by: Future Crew LLC
Differential Revision: https://reviews.freebsd.org/D46528
(cherry picked from commit f5a58c2da23930ee4870f2eb54788f4669b9aa33)
Move some ieee8022_{is,has,get}_... functions working on header fields
from mac80211.h to ieee80211.h to avoid problems with #includes.
No functional changes.
Sponsored by: The FreeBSD Foundation
(cherry picked from commit 0b325167f60def621536632460caf68e2fab4fb8)
As a consequence lkpi_ieee80211_ifalloc() now does not fail. Remove
unneeded NULL check.
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D45852
(cherry picked from commit 7bcb1228558b4325fab39616e2e3b2573a9e7da6)
Upstream new defines, enum values, etc. for coming driver updates which
are non-conflicting with the current state.
The only notable change is the rename of the enum ieee80211_ap_reg_power
but the enum name had not been used so far by any driver in the tree
(only in mac80211.h) but an updated version of ath11k does use it so we
need to correct our initial naming.
Sponsored by: The FreeBSD Foundation
(cherry picked from commit c1c989588df67396392edceb0e7e7028abc06c49)
Add new enums to netdevice.h (including one which is referenced but
no value of it is used in a driver so we have to add a "dummy" value
to avoid an empty enum).
Sponsored by: The FreeBSD Foundation
(cherry picked from commit 6ed447b51a9d6cf22aae2dfba6efce3922ae6d57)
Add more fields required by updated wireless drivers to mhi.h.
Sponsored by: The FreeBSD Foundation
(cherry picked from commit c12e3a05252ac9f43a6db379f88e4b4a07c06d46)
Add pci_err() as a wrapper to dev_err() as needed by an updated driver.
Sponsored by: The FreeBSD Foundation
Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D46660
(cherry picked from commit 01e1131e4a20ea377d580ecce210aa86726e71c6)
Factor out module_pci_driver() from 366d68f283 into a general
module_driver() so other bus attachments can also use the same kind
of macro without duplicating all the lines.
Redefine module_pci_driver() using the new general macro.
No functional changes intended.
Sponsored by: The FreeBSD Foundation
Reviewed by: manu
Differential Revision: https://reviews.freebsd.org/D46467
(cherry picked from commit f5c7feee7129dc88a2e5dc3ce0a075cb5e4f534a)
Add a version of no_printk(), which seems to be there to have format
string checking while never calling the printk. It seems a very weird
thing and it needs a return code and for some reason my initial
while (0) { } version hadn't worked while porting over new code but
could have been further downstream format string problems.
if (0) seems to do the job though I would have expected that to more
likely simply get optimised out without any futher format checking.
Sponsored by: The FreeBSD Foundation
Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D46463
(cherry picked from commit 1847e63d63f440cfcb2f4ee2c2ee8990f0272d88)
Add an implementation of eth_hdr() needed by a wireless driver.
Sponsored by: The FreeBSD Foundation
Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D46462
(cherry picked from commit 273cf7d36336eeed5fc2ad42e5e12a36e36650a0)
Used by an updated wireless driver.
Sponsored by: The FreeBSD Foundation
Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D46461
(cherry picked from commit 8adb745dc9716e769ef0f7e993cea8a07735d5d8)
Add a get_random_u8() implementation following the u36 and u64 versions.
We'll likely want to macro-ify them in the future and add all the types
which makes sense just to be done.
Sponsored by: The FreeBSD Foundation
Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D46464
(cherry picked from commit f29e915bc0d216a87f222a208caeb2172c93e4ea)
Allow a user to change the "ether" address by ifconfig while a VAP is
not UP. Compared to net80211 (given we have no callback) we register
an eventhandler per-vif (a global one would force us to use hacks to
derive if a vap is indeed also a lkpi_80211 vif).
Sponsored by: The FreeBSD Foundation
PR: 277356
Tested by: lwhsu
Differential Revision: https://reviews.freebsd.org/D46121
(cherry picked from commit 4aff4048f5b1b6ab0b905726853ba6083e37cc37)
Implement ieee80211_sn_*() using the equivalent net80211 macros.
We need those implemented for at least 11n.
While here also sort all the BA functions together next to the
"sn" functions.
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D45819
(cherry picked from commit db8b3578627b5be93eba019ab2bbe3c03f7366f4)
We have TRACE in one place and TRACE-RX in another. Spell it
"TRACE-RX: %s: ..." everywhere. Helps with pattern matching.
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D45818
(cherry picked from commit bd206a6f4a87214ae8c1b32f1051b07362080361)
Trying to use lindebugfs for debugging wirless drivers two issues
became apparent:
(a) a panic in lindebugfs calling a hard coded release function if the
caller had not provided one. This seems to be based on assumptions
that no longer hold up. Remove the hard coded release function to
prevent panics.
(b) In LinuxKPI simple_read_from_buffer() would call copy_to_user() but
buffers weren't setup for this (lindebugfs copies data from its
own buffer) and then pseudofs will do another copyout to the user
on this; remove the copy_to_user() and simply copy the data over
to the provided buffer; this works for as long as the only consumers
remain debugfs callers (which currently seems to be the case).
[the only out-of-tree consumers I am aware off are two drm-kmod
drivers/gpu/drm/amd/pm/* debugfs functions I cannot test].
Sponsored by: The FreeBSD Foundation
Tested by: jfree
Differential Revision: https://reviews.freebsd.org/D45755
(cherry picked from commit 5668c22a13c6befa9b8486387d38457c40ce7af4)