Commit graph

1173 commits

Author SHA1 Message Date
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
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
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
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
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
Bjoern A. Zeeb
9b2705121b LinuxKPI: lockdep fix #includes
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:		5c92f84bb6
MFC after:	3 days
2024-11-02 01:24:42 +00:00
Bjoern A. Zeeb
ac1d519c01 LinuxKPI: 802.11: adjustments for v6.11 iwlwifi, rtw88 and rtw89
Bring ing the LinuxKPI 802.11 compat bits which are not altering
the mac80211 ops KPI.

* Add various functions for drvier 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
MFC after:	3 days
2024-10-28 12:05:06 +00:00
Zhenlei Huang
b4856b8e9d LinuxKPI: Remove stray semicolons
MFC after:	1 week
2024-10-24 23:04:48 +08:00
Bjoern A. Zeeb
5c92f84bb6 LinuxKPI: update rcu_dereference_*() and lockdep_is_held()
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
MFC after:	3 days
Reviewed by:	wulf
Differential Revision:  https://reviews.freebsd.org/D46842
2024-10-23 01:43:09 +00:00
Bjoern A. Zeeb
157e93e0e8 LinuxKPI: pci: rename PCI_IRQ_LEGACY to PCI_IRQ_INTX
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
MFC after:	3 days
Differential Revision: https://reviews.freebsd.org/D46822
2024-10-17 13:27:05 +00:00
Bjoern A. Zeeb
105331f658 LinuxKPI: netdevice: add alloc_netdev_dummy()
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
MFC after:	3 days
Differential Revision: https://reviews.freebsd.org/D46802
2024-10-17 13:27:05 +00:00
Warner Losh
16672453f1 cdefs: Add __deprecated
Add __deprecated decorator. This is for a deprecated interface. copystr
is tagged with this today in copy(9), but don't actually provide it or
use it. copystr is a #define so adding it will have to wait.

LinuxKPI was defining this away completely in compiler.h. Since this is
shared between Linux KPI consumers and OpenZFS, if it's already defined,
use the FreeBSD sys/cdefs.h version, otherwise define it away. For
OpenZFS this will retain it, while for Linux KPI it will tend to drop it
(I think always, but I didn't look at everything).

Sponsored by:		Netflix
Reviewed by:		jhb, emaste
Differential Revision:	https://reviews.freebsd.org/D46137
2024-10-15 15:05:49 -06:00
Bjoern A. Zeeb
fa81baa307 LinuxKPI: add cleanup.h for guard DEFINE_GUARD/guard.
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
MFC after:	3 days
Reviewed by:	emaste
Differential Revision: https://reviews.freebsd.org/D46843
2024-10-14 17:45:42 +00:00
Bjoern A. Zeeb
8f9567628c LinuxKPI: add time_is_before_jiffies()
Add time_is_before_jiffies() as needed by iwlwifi from v6.11.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Reviewed by:	emaste
Differential Revision: https://reviews.freebsd.org/D46841
2024-10-11 20:48:58 +00:00
Bjoern A. Zeeb
0b325167f6 LinuxKPI: 802.11: move functions between header files
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
MFC after:	3 days
2024-09-27 17:54:16 +00:00
Bjoern A. Zeeb
c1c989588d LinuxKPI: 802.11: add futher defines to ieee80211.h and nl80211.h
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
MFC after:	3 days
2024-09-13 00:26:26 +00:00
Bjoern A. Zeeb
4b972f77a1 LinuxKPI: some additions for mt76
Add changes required for later mt76 drivers.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2024-09-13 00:25:31 +00:00
Bjoern A. Zeeb
6ed447b51a LinuxKPI; add more defintions to netdevice.h
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
MFC after:	3 days
2024-09-13 00:24:48 +00:00
Bjoern A. Zeeb
c12e3a0525 LinuxKPI: add more fields to mhi.h
Add more fields required by updated wireless drivers to mhi.h.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2024-09-13 00:23:35 +00:00
Bjoern A. Zeeb
01e1131e4a LinuxKPI: add pci_err()
Add pci_err() as a wrapper to dev_err() as needed by an updated driver.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Reviewed by:	emaste
Differential Revision: https://reviews.freebsd.org/D46660
2024-09-13 00:20:53 +00:00
Bjoern A. Zeeb
f5c7feee71 LinuxKPI: add general module_driver(), use it for module_pci_driver()
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
MFC after:	3 days
Reviewed by:	manu
Differential Revision: https://reviews.freebsd.org/D46467
2024-09-05 12:46:21 +00:00
Bjoern A. Zeeb
1847e63d63 LinuxKPI: add no_printk
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
MFC after:	3 days
Reviewed by:	emaste
Differential Revision: https://reviews.freebsd.org/D46463
2024-08-31 21:36:01 +00:00
Bjoern A. Zeeb
273cf7d363 LinuxKPI: add eth_hdr()
Add an implementation of eth_hdr() needed by a wireless driver.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Reviewed by:	emaste
Differential Revision: https://reviews.freebsd.org/D46462
2024-08-31 21:35:02 +00:00
Bjoern A. Zeeb
8adb745dc9 LinuxKPI: add ENAVAIL error code
Used by an updated wireless driver.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Reviewed by:	emaste
Differential Revision: https://reviews.freebsd.org/D46461
2024-08-31 21:34:01 +00:00
Bjoern A. Zeeb
f29e915bc0 LinuxKPI: add get_random_u8()
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
MFC after:	3 days
Reviewed by:	emaste
Differential Revision: https://reviews.freebsd.org/D46464
2024-08-31 21:32:11 +00:00
Evgenii Khramtsov
84f46335ab linuxkpi: chase spinlock_t in DECLARE_WAIT_QUEUE_HEAD
Remove member m to unbreak consumers, e.g. drm-kmod 5.10-lts branch.

[...]
/tmp/drm-kmod/drivers/gpu/drm/ttm/ttm_module.c:38:8: error: no member named 'm' in 'struct mtx'
   38 | static DECLARE_WAIT_QUEUE_HEAD(exit_q);
      |        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/tmp/src/sys/compat/linuxkpi/common/include/linux/wait.h:113:33: note: expanded from macro 'DECLARE_WAIT_QUEUE_HEAD'
  113 |         MTX_SYSINIT(name, &(name).lock.m, spin_lock_name("wqhead"), MTX_DEF)
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/tmp/src/sys/sys/mutex.h:528:4: note: expanded from macro 'MTX_SYSINIT'
  528 |                 (mtx),                                                  \
      |                  ^~~
/tmp/drm-kmod/drivers/gpu/drm/ttm/ttm_module.c:38:8: error: no member named 'm' in 'struct mtx'
   38 | static DECLARE_WAIT_QUEUE_HEAD(exit_q);
      |        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/tmp/src/sys/compat/linuxkpi/common/include/linux/wait.h:113:33: note: expanded from macro 'DECLARE_WAIT_QUEUE_HEAD'
  113 |         MTX_SYSINIT(name, &(name).lock.m, spin_lock_name("wqhead"), MTX_DEF)
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[...]

Fixes:		ae38a1a1bf ("linuxkpi: spinlock: Simplify code")
MFC after:	?
2024-08-28 09:29:40 +02:00
Warner Losh
ce7fac64ba Revert "nvme: Separate total failures from I/O failures"
All kinds of crazy stuff was mixed into this commit. Revert
it and do it again.

This reverts commit d5507f9e43.

Sponsored by:		Netflix
2024-08-15 21:29:53 -06:00