Commit graph

673 commits

Author SHA1 Message Date
Hans Petter Selasky
d17c5a4f62 LinuxKPI: Add comment describing proper use of the on_each_cpu() function.
Sponsored by:		NVIDIA Networking

(cherry picked from commit c6cf874c7d)
2022-03-17 10:55:15 +01:00
Emmanuel Vadot
61b0043efb linuxkpi: Add mmap_lock.h
This contain mmap_read_lock, mmap_read_unlock and mmap_write_lock_killable
which are abstraction around down_read, up_read and down_write_killable.
Note that in Linux 5.8 mmap_sem was renamed to mmap_lock.
We might want to do the same at some point but some drivers still uses
the old mmap locking API.

Reviewed by:	bz
MFC after:	2 weeks
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D34297

(cherry picked from commit 995c3b88d4)
2022-03-05 12:12:44 +01:00
Emmanuel Vadot
db4c095026 linuxkpi: Add orderly_poweroff
This simply poweroff the system.
Needed by drm-kmod v5.8

Reviewed by:	bz
MFC after:	2 weeks
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D34287

(cherry picked from commit 8021ba6723)
2022-03-05 12:12:44 +01:00
Emmanuel Vadot
3d148ca784 linuxkpi: Add dev_emerg
Needed by drm-kmod v5.8

Reviewed by:	bz
MFC after:	2 weeks
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D34286

(cherry picked from commit e3f1af9b33)
2022-03-05 12:12:44 +01:00
Emmanuel Vadot
78281dd986 linuxkpi: Add backlight_device_set_brightness
This simply set the brightness of a backlight device.
Needed by drm-kmod v5.8

Reviewed by:	bz, emaste
MFC after:	2 weeks
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D34285

(cherry picked from commit 2cc3af6e1d)
2022-03-05 12:12:44 +01:00
Emmanuel Vadot
48df337c9e linuxkpi: Add list_rotate_to_front
This just calls list_move_tail.

Reviewed by:	hselasky, bz
Sponsored by:	Beckhoff Automation GmbH & Co. KG
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D34251

(cherry picked from commit bf7deecfe7)
2022-03-05 12:12:43 +01:00
Emmanuel Vadot
090eb6f388 linuxkpi: Add __var_waitqueue
This returns the wait queue based on the object but in LinuxKPI
we only have one waitqueue for this.

Reviewed by:	hselasky, bz
MFC after:	2 weeks
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D34250

(cherry picked from commit cb15ed7da2)
2022-03-05 12:12:43 +01:00
Bjoern A. Zeeb
e596e01cc9 LinuxKPI: update 802.11 headers
Add new defines, struct members, and (stub) functions needed for an
updated iwlwifi.  Most of the defines are for rfkill or HE.

Pull in a case statement from the upcoming iwlwifi update to
not break the build.

Sponsored by:	The FreeBSD Foundation

(cherry picked from commit d875aa1587)
(cherry picked from commit 9ad210c159)
2022-02-27 23:41:54 +00:00
Bjoern A. Zeeb
4605fd58a3 LinuxKPI: change DECLARE_FLEX_ARRAY()
DECLARE_FLEX_ARRAY can be used inside a structure.  On FreeBSD due to
-Wgnu-variable-sized-type-not-at-end this yields an error.  Use [0]
instead of [] to overcome this.

Sponsored by:	The FreeBSD Foundation
Reviewed by:	hselasky
Differential Revision: https://reviews.freebsd.org/D34350

(cherry picked from commit fab601c5b7)
2022-02-27 23:41:54 +00:00
Bjoern A. Zeeb
7d510d1398 LinuxKPI: add MODULE_IMPORT_NS()
Add dummy MODULE_IMPORT_NS() used by an updated iwlwifi.

Sponsored by:	The FreeBSD Foundation
Reviewed by:	hselasky
Differential Revision: https://reviews.freebsd.org/D34349

(cherry picked from commit f6fb9b524f)
2022-02-27 23:41:54 +00:00
Bjoern A. Zeeb
d3caff9be6 LinuxKPI: skbuff.h add skb_postpush_rcsum()
Add a stub for skb_postpush_rcsum() needed by an updated iwlwifi.

Sponsored by:	The FreeBSD Foundation

(cherry picked from commit a3e07b6ef3)
2022-02-27 23:41:54 +00:00
Bjoern A. Zeeb
ddcb65c526 LinuxKPI: implement dma_sync_single_for_*, apply to (un)map single/sg
Implement dma_sync_single_for_{cpu,device} translating the Linux
DMA_ flags to BUS_DMASYNC_ combinations.  Make map_single/unmap_single*
functions call the respective sync function.   Apply the same logic to
the scatter-gather list map/unmap functions.

Sponsored by:	The FreeBSD Foundation
Reviewed by:	hselasky
Differential Revision: https://reviews.freebsd.org/D32255

(cherry picked from commit 95edb10b47)
2022-02-20 16:26:01 +00:00
Bjoern A. Zeeb
6ddbe66d02 LinuxKPI: 802.11 header updates and add/adjust source dependencies.
This update is for more/newer versions of drivers:
- add and properly place more structs, enums, defines needed by drivers.
- correct types of struct fields.
- make various function arguments const.
- move REG_RULE() macro to its own file regulatory.h and
  use macros for calculations.
- add linuxkpi_ieee80211_get_channel() implementation.
- change linuxkpi_ieee80211_ifattach() to return int for error checking.

No intended functional changes for iwlwifi.

Sponsored by:	The FreeBSD Foundation (partially)

(cherry picked from commit 2e183d999c)
2022-02-20 16:25:43 +00:00
Bjoern A. Zeeb
5221620a8b LinuxKPI: skbuff updates
Various updates to skbuff for new/updated drivers and some housekeeping:
- update types and struct members, add new (stub) functions
- improve freeing of frags.
- fix an issue with sleeping during alloc for dev_alloc_skb().
- Adjust a KASSERT for skb_reserve() which apparently can be called
  multiple times if no data was put into the skb yet.
- move the sysctl from linux_8022.c (which may be in a different module)
  to linux_skbuff.c so in case we turn debugging on we do not run into
  unresolved symbols.  Rename the sysctl variable to be less conflicting
  and update debugging macros along with that; also add IMPROVE().
- add DDB support to show an skbuff.
- adjust comments/whitespace.

No functional changes intended for iwlwifi.

Sponsored by:	The FreeBSD Foundation (partially)

(cherry picked from commit 6baea3312d)
2022-02-20 16:25:37 +00:00
Bjoern A. Zeeb
0422c15541 LinuxKPI: pci.h add more defines
Add and sort in more defines needed by newer drivers.

Reviewed by:	hselasky
Differential Revision: https://reviews.freebsd.org/D34293

(cherry picked from commit c4f52f71de)
2022-02-20 16:25:13 +00:00
Bjoern A. Zeeb
a108252a71 LinuxKPI: lockdep add lockdep_assert_not_held()
Add lockdep_assert_not_held() asserting LA_UNLOCKED as needed by a
driver.

Reviewed by:	hselasky
Differential Revision: https://reviews.freebsd.org/D34232

(cherry picked from commit 064c110f4b)
2022-02-20 16:25:03 +00:00
Bjoern A. Zeeb
c3ffeddb47 LinuxKPI: add kstrtoint_from_user() and DECLARE_FLEX_ARRAY()
Add an implementation of kstrtoint_from_user() based on the other
implementations and an attempt at DECLARE_FLEX_ARRAY() which works
for the driver needing it.

Reviewed by:	hselasky
Differential Revision: https://reviews.freebsd.org/D34231

(cherry picked from commit c840d5cec2)
2022-02-20 16:24:51 +00:00
Bjoern A. Zeeb
715d53ecb9 LinuxKPI: add UUID_STRING_LEN and GUID_INIT to uuid.h
Add a definition for UUID_STRING_LEN to uuid.h as needed by a driver.
Also add GUID_INIT for drm-kmod [1].

Submitted by:	wulf [1]
Reviewed by:	hselasky (earlier), wulf
Differential Revision: https://reviews.freebsd.org/D34235

(cherry picked from commit 97009980c4)
2022-02-20 16:24:38 +00:00
Bjoern A. Zeeb
5b4f2e8162 LinuxKPI: add sizeof_field()
Add sizeof_field() to linux/compiler.h needed by a driver.

Reviewed by:	hselasky
Differential Revision: https://reviews.freebsd.org/D34226

(cherry picked from commit e5b95b2201)
2022-02-20 16:24:22 +00:00
Bjoern A. Zeeb
9894111e34 LinuxKPI: add __ffs64()
Add __ffs64() to linux/bitops.h needed by a driver.

Reviewed by:	hselasky
Differential Revision: https://reviews.freebsd.org/D34225

(cherry picked from commit d17b78aa14)
2022-02-20 16:24:17 +00:00
Bjoern A. Zeeb
bc194dc41d LinuxKPI: add linux/pm_qos.h
Add a linux/pm_qos.h with three dummy functions and a struct as needed
by a driver and drm-kmod [1] in main with no intend to support this for
the moment.

Submitted by:	wulf (drm-kmod bits) [1]
Sponsored by:	The FreeBSD Foundation (drm-kmod requested updates)
Reviewed by:	hselasky (earlier version), wulf
Differential Revision: https://reviews.freebsd.org/D34234

(cherry picked from commit fa6d3522b5)
2022-02-20 16:23:32 +00:00
Bjoern A. Zeeb
f75b3614ba LinuxKPI: add NETIF_F_HW_CSUM to netdev_features.h
Add NETIF_F_HW_CSUM to netdev_features.h as needed by a driver.

Reviewed by:	hselasky
Differential Revision: https://reviews.freebsd.org/D34233

(cherry picked from commit 85d61bd872)
2022-02-20 16:23:27 +00:00
Bjoern A. Zeeb
ced43caa35 LinuxKPI: add more errno
Add ENOMEDIUM, ENOSR, and ELNRNG to linux/errno.h needed by drivers.

Reviewed by:	hselasky
Differential Revision: https://reviews.freebsd.org/D34227

(cherry picked from commit 8f33ad3cf5)
2022-02-20 16:23:16 +00:00
Bjoern A. Zeeb
0a856847c5 LinuxKPI: add eth_random_addr() and device_get_mac_address()
Add eth_random_addr() and a dummy of device_get_mac_address()
pending OF (FDT) support needed by drivers.

While here remove a white space in random_ether_addr().

Reviewed by:	hselasky
Differential Revision: https://reviews.freebsd.org/D34228

(cherry picked from commit 3cd6d6ff52)
2022-02-20 16:23:05 +00:00
Bjoern A. Zeeb
458eea38ec LinuxKPI: add an initial ethtool.h
Add an initial ethtool.h for a define and a dummy struct for now
needed by drivers.

Reviewed by:	hselasky
Differential Revision: https://reviews.freebsd.org/D34229

(cherry picked from commit 0c37ffda79)
2022-02-20 16:23:00 +00:00
Bjoern A. Zeeb
fa206965e6 LinuxKPI; add the beginning of a tracepoint.h implementation
Add a beginning of a tracepoint.h implementation to ease porting drivers
making use of this Linux facility.

Reviewed by:	hselasky
Differential Revision: https://reviews.freebsd.org/D34236

(cherry picked from commit a4529c46d4)
2022-02-20 16:22:41 +00:00
Vladimir Kondratyev
ba0f2d7807 LinuxKPI: Add sort() wrapper.
swap parameter is not supported as it is rarely used in Linux kernel
and its implementation will add some preprocessor spaghetti to qsort.

Required by drm-kmod.

MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D33675

(cherry picked from commit 7356f661e8)
2022-01-22 22:34:38 +03:00
Vladimir Kondratyev
ef743744f0 LinuxKPI: Use negative bit field size to trigger BUILD_BUG_ON_ZERO
compile time assertion on non-NULL pointers. Tests conducted show that
_Static_assert, negative array size method and current code does not
handle pointers well enough. Bit field method solves this problem.

This change is derrived from Linux implementation of BUILD_BUG_ON_ZERO.

MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D33674

(cherry picked from commit 64dab63f3b)
2022-01-22 22:34:38 +03:00
Vladimir Kondratyev
2d0694b953 LinuxKPI: Constantly use _LINUXKPI_ prefix in include guards
MFC after:	1 week
Reviewed by:	bz, emaste, hselasky, manu
Differential Revision:	https://reviews.freebsd.org/D33562

(cherry picked from commit 307f78f3ed)
2022-01-22 22:34:38 +03:00
Vladimir Kondratyev
2d90567415 LinuxKPI: Import MTRR support functions from drm-kmod
They are superseded by PAT and mostly useless nowadays but still can be
used on Pentium III/IV era processors. Unlike drm-kmod version, this one
ignores MTRR if PAT is available that fixes confusing "Failed to add WC
MTRR for [0xXXXX-0xYYYY]: 22; performance may suffer" message often
appearing during drm-kmod initialization process.

MFC after:	1 week
Reviewed by:	hselasky, manu
Differential Revision:	https://reviews.freebsd.org/D33561

(cherry picked from commit 98b129783c)
2022-01-22 22:34:37 +03:00
Vladimir Kondratyev
2db63c396d LinuxKPI: Import linux/ratelimit.h
Required by drm-kmod.

Obtained from:	OpenBSD
MFC after:	1 week
Reviewed by:	manu
Differential Revision:	https://reviews.freebsd.org/D33560

(cherry picked from commit 1456816425)
2022-01-22 22:34:37 +03:00
Vladimir Kondratyev
64a0cd9aae LinuxKPI: Add linux/capability.h header
Required by drm-kmod.

Obtained from:	DragonflyBSD
MFC after:	1 week
Reviewed by:	hselasky, manu

Differential Revision:	https://reviews.freebsd.org/D33559

(cherry picked from commit f9c8b5880d)
2022-01-22 22:34:37 +03:00
Vladimir Kondratyev
272f8b9c28 LinuxKPI: Add readx_poll_timeout wrapper
Required by drm-kmod 5.7

MFC after:	1 week
Reviewed by:	hselasky
Differential Revision:	https://reviews.freebsd.org/D33307

(cherry picked from commit 2e194c20c1)
2022-01-22 22:34:37 +03:00
Vladimir Kondratyev
0576a1c277 LinuxKPI: Implement efi_enabled(EFI_BOOT)
efi_enabled(EFI_BOOT) returns true if machine was booted from EFI
Used by drm-kmod and some unported drm drivers like hyperv

MFC after:	1 week
Reviewed by:	hselasky, manu
Differential Revision:	https://reviews.freebsd.org/D33300

(cherry picked from commit 89bb7f9bda)
2022-01-22 22:34:37 +03:00
Vladimir Kondratyev
1e467a609a LinuxKPI: Import linux/jump_label.h
Required by drm-kmod

Obtained from:	DragonflyBSD
Differential Revision:	https://reviews.freebsd.org/D33299

(cherry picked from commit 882f8d059c)
2022-01-22 22:34:37 +03:00
Vladimir Kondratyev
a692caea30 LinuxKPI: Move kfree_async() functionality in to kfree()
Obsolete it usage but keep for a while for drm-kmod 5.4 compatibility

MFC after:	1 week
Reviewed by:	hselasky, manu
Differential Revision:	https://reviews.freebsd.org/D33298

(cherry picked from commit 0b1244bd79)
2022-01-22 22:34:37 +03:00
Vladimir Kondratyev
df10d8c667 LinuxKPI: Add some typical header pollution
To reduce amount of drm-kmod patching

MFC after:	1 week
Reviewed by:	hselasky, manu
Differential Revision:	https://reviews.freebsd.org/D33297

(cherry picked from commit f1a7639a16)
2022-01-22 22:34:36 +03:00
Vladimir Kondratyev
b4f5d92c88 LinuxKPI: Implement smp_*mb barriers with atomic_thread_fence_*
for x86 and move them to asm/barrier.h

MFC after:	1 week
Reviewed by:	bz, hselasky, manu
Differential Revision:	https://reviews.freebsd.org/D33296

(cherry picked from commit 2fb5be7978)
2022-01-22 22:34:36 +03:00
Vladimir Kondratyev
1cf90ce241 LinuxKPI: Make lockdep*_pin_lock macros useable for drm-kmod
Summary:
- Add dummy struct pin_cookie definition;
- Convert lockdep_pin_lock macro to function;
- Fix 'unused variable' compile-time errors;

MFC after:	1 week
Reviewers:	hselasky, manu
Differential Revision:	https://reviews.freebsd.org/D33295

(cherry picked from commit 68fcdba38b)
2022-01-22 22:34:36 +03:00
Vladimir Kondratyev
d93c8a4d5a LinuxKPI: Convert schedule() to inlined function
to prevent name clashing with drm-kmod

MFC after:	1 week
Reviewed by:	hselasky, manu
Differential Revision:	https://reviews.freebsd.org/D33294

(cherry picked from commit 7ec6cbf1d2)
2022-01-22 22:34:36 +03:00
Vladimir Kondratyev
8dc3f129c4 LinuxKPI: Add support for XA_FLAGS_ALLOC1 xarray flag
XA_FLAGS_ALLOC1 causes allocation of xarray entries starting at 1

Required by drm-kmod 5.7

MFC after:	1 week
Reviewed by:	hselasky, manu
Differential Revision:	https://reviews.freebsd.org/D33293

(cherry picked from commit e705066cd8)
2022-01-22 22:34:36 +03:00
Vladimir Kondratyev
9e736b8b8a LinuxKPI: Implement default sysfs kobject attribute operations
Required by drm-kmod 5.7

MFC after:	1 week
Reviewed by:	hselasky
Differential Revision:	https://reviews.freebsd.org/D33292

(cherry picked from commit 04d42cb453)
2022-01-22 22:34:36 +03:00
Vladimir Kondratyev
b30c794854 LinuxKPI: Implement kstrtoull
Required by drm-kmod 5.7

MFC after:	1 week
Reviewed by:	hselasky, manu
Differential Revision:	https://reviews.freebsd.org/D33291

(cherry picked from commit c427456fd5)
2022-01-22 22:34:36 +03:00
Vladimir Kondratyev
bc3e9499ca LinuxKPI: Implement dev_driver_string()
Required by drm-kmod 5.7

MFC after:	1 week
Reviewed by:	bz, hselasky, manu
Differential Revision:	https://reviews.freebsd.org/D33290

(cherry picked from commit bc923d93df)
2022-01-22 22:34:36 +03:00
Vladimir Kondratyev
b3407b54d3 LinuxKPI: Implement clflush_cache_range()
Required by drm-kmod 5.7

MFC after:	1 week
Reviewed by:	hselasky, manu
Differential Revision:	https://reviews.freebsd.org/D33289

(cherry picked from commit db562aeff7)
2022-01-22 22:34:36 +03:00
Vladimir Kondratyev
e2cc6a467f LinuxKPI: Add clflush argument type conversion wrapper
to reduce amount of source patching in drm-kmod.

MFC after:	1 week
Reviewed by:	manu
Differential Revision:	https://reviews.freebsd.org/D33288

(cherry picked from commit 9a79e08ae7)
2022-01-22 22:34:35 +03:00
Vladimir Kondratyev
10cb54117e LinuxKPI: Implement interval_tree
Required by drm-kmod

MFC after:	1 week
Reviewed by:	hselasky, manu
Differential Revision: https://reviews.freebsd.org/D32869

(cherry picked from commit dbc920bd9a)
2022-01-22 22:34:35 +03:00
Vladimir Kondratyev
c8ddc214cf LinuxKPI: Import some linux/rbtree.h functions from OpenBSD
Required by drm-kmod

Obtained from:	OpenBSD
MFC after:	1 week

(cherry picked from commit dd52763387)
2022-01-22 22:34:35 +03:00
Bjoern A. Zeeb
d12ea01e39 LinuxKPI: 802.11 update compat code for driver updates
Add more (dummy in case of HE) defines, structs, functions and another
mac80211 function pointer needed to update and support recent drivers.

(cherry picked from commit 51b461b3db)
2022-01-16 22:39:23 +00:00
Bjoern A. Zeeb
ed802474d4 LinuxKPI: ip.h add #include
Also include netinet/in.h so that in_addr in known for ip.h.
Found by compiling a new piece of code which complained.

(cherry picked from commit 4ddc0079ea)
2022-01-16 22:39:04 +00:00