Commit graph

1326 commits

Author SHA1 Message Date
Bjoern A. Zeeb
c8a6676eb6 LinuxKPI: 802.11: crypto pn lengths
Define the last missing PN length and for consistency use them
in struct ieee80211_key_seq (even though a 6 is a 6 is a 6).

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2025-03-18 09:22:00 +00:00
Lutz Bichler
ef037a028a linuxkpi: Correct DIV_ROUND_DOWN_ULL
This fixes a black screen issue with the i915 DRM driver from Linux v6.8

Fixes: c4e0746e7d ("LinuxKPI: Add helper macros IS_ALIGNED and DIV_ROUND_DOWN_ULL.")
Pull request: https://github.com/freebsd/freebsd-src/pull/1612
2025-03-12 13:43:08 -04:00
Bjoern A. Zeeb
2ab4a41956 LinuxKPI: skbuff: add synchronization primitives and missing bits
Make a pass over skbuff.h:
- implement some missing bits,
- sprinkle some const,
- add locking and read/write_once calls as needed to provide
  synchronization as expected by Linux,
- fix some typos,
- remove return from void functions,
- adjust tracing macros.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
PR:		283903 (rtw88 skb leak)
Tested by:	Guillaume Outters (guillaume-freebsd outters.eu)
Differential Revision: https://reviews.freebsd.org/D49101
2025-02-23 23:25:32 +00:00
Bjoern A. Zeeb
72ee3d57f3 LinuxKPI: 802.11: add condition to TODO in ieee80211_sta_recalc_aggregates
ieee80211_sta_recalc_aggregates() shows up in TODO traces but there is
nothing we have to do there until we have active links (MLO support).
Make the TODO conditional for a time when we will get there.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2025-02-22 23:31:46 +00:00
Bjoern A. Zeeb
a6994e208c LinuxKPI: rather than manually defining a value use the net80211 define
Define cfg80211 IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_MASK to
net80211 IEEE80211_VHTCAP_SUPP_CHAN_WIDTH_MASK.

We should likely at some point make a sweep and replace all the
values with the defines from the comments for the matching net80211
version.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2025-02-22 23:25:35 +00:00
Bjoern A. Zeeb
11450726d3 LinuxKPI: 802.11: improve cfg80211_chandef_create()
Implement cfg80211_chandef_create() to work with HT.  Update enum
with HT channel types.  When calling the function from LinuxKPI 802.11
code, pass in NL80211_CHAN_HT20 if HT is supported rather than NO_HT.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2025-02-22 22:18:51 +00:00
Jean-Sébastien Pédron
05dfaadde4
linuxkpi: Add shrinker_alloc() and shrinker_free()
They are used by the DRM drivers in Linux 6.7.

Bump `FreeBSD_version` because external drivers that use `struct
shrinker` will have to be recompiled.

Reviewed by:	bz
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D48747
2025-02-19 21:39:46 +01:00
Jean-Sébastien Pédron
1396a7316f
linuxkpi: Print "TODO" if a driver call pci_wake_from_d3()
This helps developers working with linuxkpi find out a function is
already defined but is just a stub.

Reported by:	bz
Reviewed by:	bz, emaste
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D48862
2025-02-19 21:39:46 +01:00
Jean-Sébastien Pédron
dec2806f96
linuxkpi: Define PCI_IRQ_LEGACY for Linux < 6.10
Commit 03e39d3d42 decreased the Linux
version that exposes this constant to be Linux 6.7. It happens that the
constant is older.

However, it is removed in Linux 6.10. Let's change the version condition
to say that it is defined for any version before 6.10.

Reported by:	bz
Reviewed by:	bz
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D48861
2025-02-19 21:39:46 +01:00
Jean-Sébastien Pédron
585cdb74f4
linuxkpi: Defaults to get_file_rcu() version from Linux 6.7
To use the old version, one has to explicitly set `LINUXKPI_VERSION` to
the expected version of Linux KPI.

Reported by:	bz
Reviewed by:	bz
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D48860
2025-02-19 21:39:46 +01:00
Bjoern A. Zeeb
11db70b605 LinuxKPI: 802.11: hardware crypto offload improvements
Implement mac80211 functions ieee80211_iter_keys[_rcu](), and
ieee80211_get_key_rx_seq() (*).
Implement an internal function lkpi_sta_del_keys() to delete keys
when we are leaving RUN (AUTHORIZED) state.
Improve and make work (*) the net80211 vap function pointers
(*iv_key_set)(), (*iv_key_delete)() implementations.
Correct the logic in lkpi_80211_txq_tx_one() and factor most crypto
related bits out into lkpi_hw_crypto_prepare() (*).

(*) We are currently supporting CCMP only.  I would hope we will
not have to do full WEP/TKIP support anymore given both are deprecated.

The entire logic remains behind the LKPI_80211_HW_CRYPTO pre-processor
condition and with this commit in addition behind a tunable.
The code is compiled in by default now but the tunable remains off until
wider testing has shown no problems.
I have seen one net80211 triggered panic on shutdown related to deleting
keys which I cannot reproduce anymore and could have been fixed by
9763fec11b83; otherwise we will have to investigate as it shows again.
The dedicated hw crypto tracing option can help in that case with debug
kernels.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Fixes:		b35f6cd066
2025-02-18 02:54:33 +00:00
Bjoern A. Zeeb
408394185f LinuxKPI: 802.11: dump station_info using (*sta_statistics)() as sysctl
Implement the mac80211 (*sta_statistics) to obtain station statistics.
Fix up struct station_info for that.
Add supporting funtions to decode station_info and rate_info_bw fields
to make the output more usable to human beings.

Add a per-VIF (VAP) sysctl to export that information.  This is mostly
used for now to see what the driver/fw thinks about its TX rate.
We should later gather this information in different ways and pass it
to net80211 to export it to user space so we can finally have nice
station information (also for the non-AP side).

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2025-02-17 01:37:30 +00:00
Bjoern A. Zeeb
bcf1d8ee35 LinuxKPI: 802.11/skb: add extra information for skb alloc failures
rtw88 seems to have an skb leak still.

Add a WARN_ONCE to __skb_queue_purge() just to make sure there is no
glitch due to missing locking.

Also add a rolling error reporting for skb allocation failures in
LinuxKPI to gather some more information if possible about queue
states.

This is a corrected version of what was initially part of D48474.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2025-02-16 23:04:24 +00:00
Bjoern A. Zeeb
d2407a21bd LinuxKPI: 802.11: ieee80211_vif_usable_links()
ieee80211_vif_usable_links() shows up in TODO() tracking.
Turns out the return (1) is likely wrong and should be 0 given we do
not support MLD yet.  For now return the valid_links bitmap and leave
an IMPROVE as likely not all of the valid ones will be useable.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2025-02-16 22:45:33 +00:00
Bjoern A. Zeeb
a7c19b8a99 LinuxKPI; 802.11: start implementing cfg80211_calculate_bitrate()
For now we only return the legacy rate and have two TODOs for HT and
VHT which still need to be implemented as needed.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2025-02-16 22:33:03 +00:00
Bjoern A. Zeeb
470aaf42c3 LinuxKPI: 802.11: make struct ieee80211_tx_info a bit more packed
Given I was looking at the struct make it more packed at the beginning
at least.  In fact it did not shrink but the tx_time_est got expanded.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2025-02-16 22:24:53 +00:00
Bjoern A. Zeeb
49010ba706 LinuxKPI: 802.11: fill in a lot more RX status fields
Convert a lot more LinuxKPI rx_status fields to net80211 rx_stats
bits for as much as we can see fit.  Factor the entire logic out
into its own function as it got quite long.

Now only net80211 needs to start using more of these values and
report them.

Also fix some related fields and struct definitions in LinuxKPI.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2025-02-16 22:09:00 +00:00
Bjoern A. Zeeb
5778cbdae7 LinuxKPI: 802.11: implement various VHT helper functions
Implement ieee80211_rate_set_vht(), ieee80211_rate_get_vht_{mcs,nss}(),
and ieee80211_get_vht_max_nss().

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2025-02-15 23:53:19 +00:00
Bjoern A. Zeeb
75fb66d824 net80211 / LinuxKPI 802.11: add 802.11-2016 VHT Extended NSS BW defines
Add the mask and shift for the VHT Extended NSS BW Support field.
Document them in net80211 and further related bitmasks in LinuxKPI.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Reviewed by:	adrian
Differential Revision: https://reviews.freebsd.org/D48975
2025-02-15 15:48:36 +00:00
Emmanuel Vadot
03704b89e7 linuxkpi: cc_platform: Add CC_ATTR_GUEST_MEM_ENCRYPT
Add this attribute which is a no-op for us but in linux represent that
the guest memory encryption is active.
drm ttm started to check this flag in > 6.1.92

Sponsored by:	Beckhoff Automation GmbH & Co. KG
2025-02-11 09:27:48 +01:00
Bjoern A. Zeeb
95ea57c856 LinnuxKPI: drm2: retire timespec_to_jiffies()
Linux has removed timespec_to_jiffies() half a decade ago [1].
I cannot find any use of it anymore in recent drm-kmod branches
or in the tree so retire it.

While here also retire it from drm2.

Reported by:	emaste (D48318) [1].
Sponsored by:	The freeBSD Foundation
MFC after:	2 weeks
Reviewed by:	emaste, dumbbell (tested all drm-kmod versions, thanks!)
Differential Revision: https://reviews.freebsd.org/D48379
2025-02-01 00:47:30 +00:00
Bjoern A. Zeeb
1b840f09b6 LinuxKPI: 802.11: remove rate_lowest_index()
rate_lowest_index() is no longer used anywhere in our code.
Garbage collect it.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2025-01-31 23:53:31 +00:00
Bjoern A. Zeeb
c75a558d07 LinuxKPI: 802.11: implement ieee80211_get_{he,eht}_iftype_cap{,_vif}
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
MFC after:	3 days
2025-01-31 23:53:30 +00:00
Jean-Sébastien Pédron
2ee1311820
lindebugfs: Add debugfs_lookup()
[Why]
This function is used by hhe DRM generic code starting with Linux 6.7.

Reviewed by:	manu
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D48761
2025-01-31 17:00:50 +01:00
Jean-Sébastien Pédron
f570760e5f
linuxkpi: Add several headers to reproduce namespace pollution
[Why]
The i915 DRM driver relies on this chain of includes to access the
definition of `struct tasklet_struct` in `<linux/interrupt.h>`.

Reviewed by:	imp, manu
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D48760
2025-01-31 17:00:49 +01:00
Jean-Sébastien Pédron
73281513fc
linuxkpi: Add pci_wake_from_d3()
[Why]
This is used by the amdgpu DRM driver starting with Linux 6.7.

[How]
The function just returns 0 for now.

Reviewed by:	manu
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D48759
2025-01-31 17:00:49 +01:00
Jean-Sébastien Pédron
8bdb76f202
linuxkpi: Add dev_is_removable()
[Why]
This is used by the amdgpy DRM driver starting from Linux 6.7.

[How]
The function always returns false, like `pci_is_thunderbolt_attached()`
because we don't have an API for this in FreeBSD yet.

Reviewed by:	manu
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D48758
2025-01-31 17:00:49 +01:00
Jean-Sébastien Pédron
e3cf2321b0
linuxkpi: Add get_file_active()
[Why]
This is used by the i915 DRM driver starting from Linux 6.7.

Reviewed by:	manu
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D48757
2025-01-31 17:00:49 +01:00
Jean-Sébastien Pédron
1de8fcf419
linuxkpi: Add Linux 6.7 get_file_rcu() variant
[Why]
In Linux 6.7, the signature of `get_file_rcu()` changed significantly,
going from:

    bool get_file_rcu(struct linux_file *f);

... to:

    struct linux_file * get_file_rcu(struct linux_file **f);

I.e., both the argument and the return value changed in an incompatible
way.

This is used by the i915 DRM driver.

[How]
This patch introduces the variant and hide the new prototype behind
`LINUXKPI_VERSION >= 60700`.

Reviewed by:	manu
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D48756
2025-01-31 17:00:49 +01:00
Jean-Sébastien Pédron
be818f265e
linuxkpi: Use same field names in struct xarray as Linux
[Why]
The i915 DRM driver started to access the `xa_lock` field in Linux 6.7.

Reviewed by:	manu
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D48754
2025-01-31 17:00:48 +01:00
Jean-Sébastien Pédron
668fe90dc8
linuxkpi: Add xa_alloc_cyclic_irq()
[Why]
This function is used by the i915 DRM driver starting with Linux 6.7.

Reviewed by:	manu
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D48753
2025-01-31 17:00:48 +01:00
Jean-Sébastien Pédron
3fd7fd4974
linuxkpi: Add __assign_bit()
[Why]
This function is used by the i915 DRM driver in Linux 6.7.

Reviewed by:	manu
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D48752
2025-01-31 17:00:48 +01:00
Jean-Sébastien Pédron
2da778e62e
linuxkpi: Include <linux/{types,io}.h> from <video/vga.h>
[Why]
Some files in the i915 DRM driver in Linux 6.7 depend on these implicit
inclusions.

Reviewed by:	manu
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D48751
2025-01-31 17:00:48 +01:00
Jean-Sébastien Pédron
08c2f6cf46
linuxkpi: Unify definition of outb()
[Why]
It is already defined in <asm-generic/io.h> to use the FreeBSD versions.

Reviewed by:	manu
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D48750
2025-01-31 17:00:48 +01:00
Jean-Sébastien Pédron
d526b2115e
linuxkpi: Add num_online_nodes()
[Why]
This is used by the amdkfd DRM driver in Linux 6.7.

Reviewed by:	manu
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D48749
2025-01-31 17:00:47 +01:00
Jean-Sébastien Pédron
f4ffe67739
linuxkpi: Add private_data to struct shrinker
[Why]
This field is used by the i915 DRM driver in Linux 6.7.

Reviewed by:	manu
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D48748
2025-01-31 17:00:47 +01:00
Jean-Sébastien Pédron
479c61bd5f
linuxkpi: Add pci_get_base_class()
[Why]
This new API is used by the amdgpu DRM driver is Linux 6.7.

[How]
This is the same as `pci_get_class()` except that it searches a PCI
device matching the base class only; the subclass is ignored.

Reviewed by:	manu
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D48746
2025-01-31 17:00:47 +01:00
Jean-Sébastien Pédron
cd245b7941
linuxkpi: Add kstrtou32()
[Why]
This is used by the amdgpu DRM driver in Linux 6.7.

Reviewed by:	manu
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D48744
2025-01-31 17:00:47 +01:00
Jean-Sébastien Pédron
03e39d3d42
linuxkpi: Declare PCI_IRQ_LEGACY even for linuxkpi 6.7
[Why]
DRM drivers in Linux 6.7 already use this constant.

Reviewed by:	manu
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D48742
2025-01-31 17:00:46 +01:00
Jean-Sébastien Pédron
2cd5324153
linuxkpi: Add idr.h -> radix-tree.h -> rcupdate.h includes
[Why]
Some files in DRM rely on namespace pollution: they use the
<linux/rcupdate.h> API without including it explicitly.

[How]
Reproduce the Linux chain of includes even if it means nothing on
FreeBSD. This allows consumers of <linux/idr.h> to "inherit"
<linux/rcupdate.h> API.

Reviewed by:	manu
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D48741
2025-01-31 17:00:46 +01:00
Jean-Sébastien Pédron
9136a44a2d
linuxkpi: Add <linux/cec.h>
Reviewed by:	manu
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D48740
2025-01-31 17:00:42 +01:00
Ahmad Khalifa
b72ae900d4 sys: make the kernel metadata pointer global
The way we got the kernel metadata pointer was by calling
preload_search_by_type with one of the following three: "elf kernel",
"elf32 kernel" and "elf64 kernel". Which one(s) we used wasn't
consistent though. Sometimes we would only try "elf kernel", and other
times we would try one of the latter two if the first failed. However,
the loader only ever sets "elf kernel" as the kernel type.

Now, the kmdp is a global, preload_kmdp, and it's initialized using
preload_initkmdp in machdep.c (or machdep_boot.c on arm/64).
preload_initkmdp takes a single boolean argument that tells us whether
not finding the kmdp is fatal or not.

Reviewed by: imp, kib
Pull Request: https://github.com/freebsd/freebsd-src/pull/1394
2025-01-24 14:25:51 -07:00
Olivier Certner
62af5b9dc6
atomics: Constify loads: Remove now superfluous uses of DECONST()
No functional change (intended).

Reviewed by:    kib
MFC after:      4 days
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D48497
2025-01-20 16:49:52 +01:00
Bjoern A. Zeeb
2bb0efbb7b Revert: LinuxKPI: switch jiffies and timer->expire to unsigned long
There are possible problems when jiffies (ticks) which still are int
wrap around.  Also given this did not touch every single place some
checks may be broken now.

Reported by:	markj
This reverts commit fd27f86dd7.
2025-01-08 08:30:14 +00:00
Bjoern A. Zeeb
fd27f86dd7 LinuxKPI: switch jiffies and timer->expire to unsigned long
It seems these functions work with unsigned long and not int in Linux.
Start simply replacing the int where I came across it while debugging
a wireless driver timer modification.  Also sprinkle in some "const".

Sponsored by:	The FreeBSD Foundation
MFC after:	2 weeks
Reviewed by:	emaste
Differential Revision: https://reviews.freebsd.org/D48318
2025-01-07 20:00:20 +00:00
Bjoern A. Zeeb
07f6575585 LinuxKPI: 802.11: turn on debugfs for iwlwifi and rtw88
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
MFC after:	10 days
2025-01-07 18:07:09 +00:00
Bjoern A. Zeeb
f1aeb5d850 LinuxKPI: 802.11: add a print mask for ieee80211_rx_status_flags bits
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
MFC after:	3 days
2025-01-07 14:51:03 +00:00
Bjoern A. Zeeb
95a7aa8009 LinuxKPI: 802.11: implement wiphy_{,un}lock()
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
MFC after:	3 days
2025-01-04 14:00:13 +00:00
Bjoern A. Zeeb
ca389486a9 net80211 / LinuxKPI 802.11: use enum ieee80211_sta_rx_bw for ni_chw
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
and add a print mask for debug output.  While designed as bitmask it
is not supposed to be used as such;  the bitmask is only used to be
able to use %b with a print mask.

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 three more channel
widths without breaking the KBI (if we were not to use %b with a
print_mask but use a lookup function for the string we could extend
it for a long time).

Sponsored by:	The FreeBSD Foundation
MFC after:	14 days
Reviewed by:	adrian
Differential Revision: https://reviews.freebsd.org/D47891
2024-12-08 20:57:53 +00:00
Mark Johnston
ef9ffb8594 kern: Make fileops and filterops tables const where possible
No functional change intended.

MFC after:	1 week
2024-11-26 21:04:21 +00:00