Commit graph

1147 commits

Author SHA1 Message Date
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
Warner Losh
d5507f9e43 nvme: Separate total failures from I/O failures
When it's a I/O failure, we can still send admin commands. Separate out
the admin failures and flag them as such so that we can still send admin
commands on half-failed drives.

Fixes: 9229b3105d (nvme: Fail passthrough commands right away in failed state)
Sponsored by: Netflix
2024-08-15 20:22:18 -06:00
Ed Maste
a1295b2484 linuxkpi: use canonical tests for is_{zero,broadcast}_ether_addr
They are functionally equivalent, but the updated form mirrors the tests
in sys/net/ethernet.h and avoids confusion.

Reviewed by:	kib
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D21037
2024-08-08 12:39:14 -04:00
Vladimir Kondratyev
c89d94ad5d LinuxKPI: update linuxkpi_video to Linux 6.6
disable hdmi_audio_infoframe_pack_for_dp function for now as it depends
on not imported yet drm sources and is not used by drm-kmod.

Reviewed by:	manu
Sponsored by:	Serenity CyberSecurity, LLC
Differential Revision:	https://reviews.freebsd.org/D46224
2024-08-07 23:38:38 +03:00
Bjoern A. Zeeb
1f7df75701 LinuxKPI: move __kmalloc from slab.h to slab.c
In order to allow the allocator to change in the future move it into
the implementation file from being an inline function in the header.

While here factor out the size calculation and add a comment as-to why
this is done.  We will need the size (_s) in the future to make a
decision on how to allocate.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Reviewed by:	emaste
Differential Revision: https://reviews.freebsd.org/D45815
2024-07-26 11:51:04 +00:00
Bjoern A. Zeeb
5668c22a13 LinuxKPI/lindebugfs: stop panicing in lindebugfs, fix simple_read_from_buffer
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
MFC after:	2 weeks
Tested by:	jfree
Differential Revision: https://reviews.freebsd.org/D45755
2024-07-26 10:53:55 +00:00
Bjoern A. Zeeb
59d262fe96 LinuxKPI: 802.11 compile in debugging based on IEEE80211 debugging
If IEEE80211 debugging is turned on in kernel configs also turn on
LinuxKPI 802.11 and SKB debugging (sysctls) to have them available.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Differential Revision: https://reviews.freebsd.org/D45820
2024-07-25 15:06:46 +00: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
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
8c5c572125 LinuxKPI: Add DEFINE_DEBUGFS_ATTRIBUTE_SIGNED to linux/debugfs.h
Sponsored by:	Serenity CyberSecurity, LLC
MFC after:	1 week
Reviewed by:	manu
Differential Revision:	https://reviews.freebsd.org/D45615
2024-06-26 23:51:34 +03:00
Vladimir Kondratyev
e1b0f431a1 LinuxKPI: Remove vmas argument from get_user_pages on KPI layer
To chase Linux kernel 6.5

Sponsored by:	Serenity CyberSecurity, LLC
MFC after:	1 week
Reviewed by:	manu, emaste
Differential Revision:	https://reviews.freebsd.org/D45614
2024-06-26 23:51:04 +03:00
Vladimir Kondratyev
889f74af66 LinuxKPI: Add linux/nodemask.h
and dummy num_possible_nodes() implementation.
We do not fully support NUMA in LinuxKPI yet.

Sponsored by:	Serenity CyberSecurity, LLC
MFC after:	1 week
Reviewed by:	manu, bz
Differential Revision:	https://reviews.freebsd.org/D45613
2024-06-26 23:49:52 +03:00
Vladimir Kondratyev
256eb8d536 LinuxKPI: Remove linux/sched.h include from linux/kernel.h header
This include prevents usage of any kernel.h helpers in sched.h and
all of dependencies. Linux does not have it too.
Fix building of kernel and drm-kmod after than.

Sponsored by:	Serenity CyberSecurity, LLC
MFC after:	1 week
Reviewed by:	manu, bz
Differential Revision:	https://reviews.freebsd.org/D45692
2024-06-26 23:47:12 +03:00
Vladimir Kondratyev
d21316ff22 LinuxKPI: Add header polution to compile linux/numa.h
Sponsored by:	Serenity CyberSecurity, LLC
MFC after:	1 week
Reviewed by:	manu, bz, emaste
Differential Revision:	https://reviews.freebsd.org/D45612
2024-06-26 23:44:56 +03:00
Vladimir Kondratyev
460908ea55 LinuxKPI: Remove owner argument from class_create function on KPI layer
to chase Linux 6.4

Sponsored by:	Serenity Cyber Security, LLC
MFC after:	1 week
Reviewed by:	manu, emaste
Differential Revision:	https://reviews.freebsd.org/D45610
2024-06-26 23:44:12 +03:00
Vladimir Kondratyev
73f3589120 LinuxKPI: Add kmap_local_page function
kmap_local_page maps a page for temporary usage

Sponsored by:	Serenity CyberSecurity, LLC
MFC after:	1 week
Reviewed by:	manu
Differential Revision:	https://reviews.freebsd.org/D45609
2024-06-26 23:43:43 +03:00
Vladimir Kondratyev
a5cac2e672 LinuxKPI: Add rb_add_cached function
rb_add_cached inserts node into the leftmost cached tree

Sponsored by:	Serenity CyberSecurity, LLC
MFC after:	1 week
Reviewed by:	manu
Differential Revision:	https://reviews.freebsd.org/D45608
2024-06-26 23:43:16 +03:00
Doug Moore
c8b0c33b03 log2: move log2 functions from linuxkpi to libkern
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
2024-06-24 02:00:31 -05:00
Bjoern A. Zeeb
63a327b954 LinuxKPI: 802.11: use net80211 IEEE80211_HTCAP_* definitions
Rather than using the values and leaving net80211 names in a comment
define the LinuxKPI IEEE80211_HT_CAP_* to the net80211 IEEE80211_HTCAP_*
names.  That way errors like the one fixed in 3e0915b7b6 are less
likely to happen.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2024-06-07 23:57:04 +00:00