Commit graph

1137 commits

Author SHA1 Message Date
Lutz Bichler
872c817d52 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

(cherry picked from commit ef037a028af7cc331e36ca6c8e2eb5612cdb1130)
2025-03-18 09:27:37 -04:00
Bjoern A. Zeeb
e00588ed9c 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
PR:		283903 (rtw88 skb leak)
Tested by:	Guillaume Outters (guillaume-freebsd outters.eu)
Tested by:	oleg.nauman gmail.com
Differential Revision: https://reviews.freebsd.org/D49101

(cherry picked from commit 2ab4a41956159e7c974979693cb0b13cf552128e)
2025-02-26 02:39:41 +00:00
Bjoern A. Zeeb
c1895bd9c0 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

(cherry picked from commit 11450726d3cf8d76d2113d7cabe995f8ef31ec5a)
2025-02-26 02:39:13 +00:00
Bjoern A. Zeeb
a960f6e717 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

(cherry picked from commit 408394185fe9be0c158189b7671bde316ac14ac9)
2025-02-24 20:26:49 +00:00
Bjoern A. Zeeb
b2999f0227 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

(cherry picked from commit bcf1d8ee355213eef4a125c0b8518f1cb4f35df4)
(cherry picked from commit 1432e0f20ccde8eaa23d3d3e20fca2989cd344b6)
2025-02-24 20:26:49 +00:00
Bjoern A. Zeeb
75418cb419 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

(cherry picked from commit 470aaf42c3c0661821a8744ae7c29b096adb4aa3)
2025-02-24 20:26:48 +00:00
Bjoern A. Zeeb
6b244c7666 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

(cherry picked from commit 49010ba706d39fba0d8bc128d96e6122e65eb8ad)
2025-02-24 20:26:48 +00:00
Bjoern A. Zeeb
b3c037c2bc 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
Reviewed by:	adrian
Differential Revision: https://reviews.freebsd.org/D48975

(cherry picked from commit 75fb66d8241d0487baf482c975c1de3b55d9a315)
2025-02-24 20:26:47 +00:00
Bjoern A. Zeeb
c5978cd3e4 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.

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)
2025-02-10 14:52:08 +00:00
Doug Moore
6f309b9d56 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

(cherry picked from commit c8b0c33b03ac072413b27bed2bdae2ae27426f3a)
2025-02-10 04:29:23 -06:00
Doug Moore
4ed1837853 libkern: add ilog2 macro
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)
2025-02-10 04:27:12 -06:00
Olivier Certner
11dde2c8b7
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

(cherry picked from commit 9b7157c690723279d448fc7ea9c1f9374ad4511a)
2025-01-27 19:19:57 +01:00
Mark Johnston
48155c983c kern: Make fileops and filterops tables const where possible
No functional change intended.

MFC after:	1 week

(cherry picked from commit ef9ffb8594eee294334ced627755bf5b46b48f9f)
2024-12-03 01:03:42 +00:00
Austin Shafer
d95675349a linuxkpi: Provide a non-NULL value for THIS_MODULE
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)
2024-11-30 08:55:57 -05:00
Bjoern A. Zeeb
06733ceca6 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:		5c92f84bb607

(cherry picked from commit 9b2705121ba230bf71a1509cc928f0481dfbf31c)
2024-11-14 01:52:01 +00:00
Bjoern A. Zeeb
d964b9d8ed 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 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)
2024-10-31 14:33:57 +00:00
Bjoern A. Zeeb
8341284368 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
Reviewed by:	wulf
Differential Revision:  https://reviews.freebsd.org/D46842

(cherry picked from commit 5c92f84bb607c692ce4fa762a7a3c4b86a2fa281)
2024-10-31 14:33:57 +00:00
Bjoern A. Zeeb
1579a25f0a 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
Differential Revision: https://reviews.freebsd.org/D46822

(cherry picked from commit 157e93e0e8138fbaa6ab5d5b20b0c23f903667a6)
2024-10-31 14:33:56 +00:00
Bjoern A. Zeeb
0dee359c09 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
Differential Revision: https://reviews.freebsd.org/D46802

(cherry picked from commit 105331f658e2f14fb4daa64dcd076c7369505295)
2024-10-31 14:33:56 +00:00
Zhenlei Huang
5942658cf3 LinuxKPI: Remove stray semicolons
MFC after:	1 week

(cherry picked from commit b4856b8e9d872ca6ee0c4ef43e7047693ef7645b)
2024-10-31 12:40:17 +08:00
Evgenii Khramtsov
089664a8db 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:		ae38a1a1bfdf ("linuxkpi: spinlock: Simplify code")
MFC after:	?

(cherry picked from commit 84f46335ab5da086c74032579799c0a74aa27447)
2024-10-24 09:24:52 +02:00
Bjoern A. Zeeb
75ac24a7df 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
Reviewed by:	emaste
Differential Revision: https://reviews.freebsd.org/D46843

(cherry picked from commit fa81baa307da9a0055d7d08f6d141ea310f067ed)
2024-10-16 21:50:37 +00:00
Bjoern A. Zeeb
0804848403 LinuxKPI: add time_is_before_jiffies()
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)
2024-10-16 21:49:40 +00:00
Bjoern A. Zeeb
c8c12a517b 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

(cherry picked from commit 0b325167f60def621536632460caf68e2fab4fb8)
2024-10-09 19:18:58 +00:00
Bjoern A. Zeeb
70da94bb52 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

(cherry picked from commit c1c989588df67396392edceb0e7e7028abc06c49)
2024-09-28 10:35:15 +00:00
Bjoern A. Zeeb
5ea0b01301 LinuxKPI: some additions for mt76
Add changes required for later mt76 drivers.

Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 4b972f77a16f9a217c211c8c4f28a41eca98554e)
2024-09-28 10:35:15 +00:00
Bjoern A. Zeeb
f00e737be0 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

(cherry picked from commit 6ed447b51a9d6cf22aae2dfba6efce3922ae6d57)
2024-09-28 10:35:14 +00:00
Bjoern A. Zeeb
ea18ffdf6e LinuxKPI: add more fields to mhi.h
Add more fields required by updated wireless drivers to mhi.h.

Sponsored by:	The FreeBSD Foundation

(cherry picked from commit c12e3a05252ac9f43a6db379f88e4b4a07c06d46)
2024-09-28 10:35:14 +00:00
Bjoern A. Zeeb
286250daf5 LinuxKPI: add pci_err()
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)
2024-09-28 10:35:14 +00:00
Bjoern A. Zeeb
e138f36f64 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
Reviewed by:	manu
Differential Revision: https://reviews.freebsd.org/D46467

(cherry picked from commit f5c7feee7129dc88a2e5dc3ce0a075cb5e4f534a)
2024-09-28 10:35:14 +00:00
Bjoern A. Zeeb
cedae002cb 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
Reviewed by:	emaste
Differential Revision: https://reviews.freebsd.org/D46463

(cherry picked from commit 1847e63d63f440cfcb2f4ee2c2ee8990f0272d88)
2024-09-28 10:35:14 +00:00
Bjoern A. Zeeb
6dedd620cf LinuxKPI: add eth_hdr()
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)
2024-09-28 10:35:13 +00:00
Bjoern A. Zeeb
8e5f4f5f75 LinuxKPI: add ENAVAIL error code
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)
2024-09-28 10:35:13 +00:00
Bjoern A. Zeeb
d5025c4916 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
Reviewed by:	emaste
Differential Revision: https://reviews.freebsd.org/D46464

(cherry picked from commit f29e915bc0d216a87f222a208caeb2172c93e4ea)
2024-09-28 10:35:13 +00:00
Bjoern A. Zeeb
d506ab946d 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
Tested by:	jfree
Differential Revision: https://reviews.freebsd.org/D45755

(cherry picked from commit 5668c22a13c6befa9b8486387d38457c40ce7af4)
2024-09-28 10:35:12 +00:00
Bjoern A. Zeeb
af034dcbb2 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
Differential Revision: https://reviews.freebsd.org/D45820

(cherry picked from commit 59d262fe969af5a8a83f0ccd7586c9bd2c8fb1f3)
2024-09-28 10:35:12 +00:00
Bjoern A. Zeeb
f9edc5b3f6 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
Reviewed by:	emaste
Differential Revision: https://reviews.freebsd.org/D45815

(cherry picked from commit 1f7df757017404011732196e65981d9325f7a89f)
2024-09-28 10:35:12 +00:00
Ed Maste
6fb0634bc4 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

(cherry picked from commit a1295b24842d209e6bf93a4823193d56ad2db064)
2024-08-11 19:01:51 -04:00
Vladimir Kondratyev
59d36b8969 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

(cherry picked from commit c89d94ad5d95fd15e891b2723caae8a6104ee153)
2024-08-11 13:12:38 +03:00
Vladimir Kondratyev
7403f2c657 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

(cherry picked from commit fcc350c375f776318d0da8021109631492ab9261)
2024-08-02 00:16:23 +03:00
Vladimir Kondratyev
d23c4b1a55 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

(cherry picked from commit 3e90716331cdbdee7465213d389a33f90dad11cf)
2024-08-02 00:15:51 +03:00
Vladimir Kondratyev
ce2d721b9f 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

(cherry picked from commit 5b1171a0b75fc88bffb5a67b0b02d8d59eb8d5c4)
2024-08-02 00:15:44 +03:00
Vladimir Kondratyev
b71e429d54 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

(cherry picked from commit a1181662d3707d8165d7153a0aa5d76ea1ddc11a)
2024-08-02 00:15:28 +03:00
Vladimir Kondratyev
5a97344123 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

(cherry picked from commit 80aa295a5272d01b7f21eff6719dcd45e14e8e09)
2024-08-02 00:15:22 +03:00
Vladimir Kondratyev
0ab568c2ff 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

(cherry picked from commit 742088d9fb545296c8677119757a967141ba7d4a)
2024-08-02 00:15:11 +03:00
Vladimir Kondratyev
b5d03f42e9 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

(cherry picked from commit ab1a5d8e2ade8c706ff8cd7aa3d5c88a95633228)
2024-08-02 00:15:04 +03:00
Vladimir Kondratyev
d8394e282f 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

(cherry picked from commit ab6e1167909bf1e2792a2ba33000e13d33aaf551)
2024-08-02 00:14:10 +03:00
Vladimir Kondratyev
88ca9c8226 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

(cherry picked from commit 8c5c572125665e3fd8a033d1a8b0a370e5a43e24)
2024-08-02 00:09:41 +03:00
Vladimir Kondratyev
3eb0293692 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

(cherry picked from commit e1b0f431a109683ca7c232fb9282f3afabfdf12d)
2024-08-02 00:09:41 +03:00
Vladimir Kondratyev
f1f6228a66 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

(cherry picked from commit 889f74af66b82e4401fb69ed8af6b9b4f48ce53b)
2024-08-02 00:09:41 +03:00