Commit graph

662 commits

Author SHA1 Message Date
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
Bjoern A. Zeeb
2f6e37eded LinuxKPI: bitfields add more *replace_bits()
Add or extend the already existing *_replace_bits() implementations
using macros as we do for the other parts in the file for
le<n>p_replace_bits(), u<n>p_replace_bits(), and _u<n>_replace_bits().

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

(cherry picked from commit 2fb0569f1f)
2022-01-16 22:38:57 +00:00
Bjoern A. Zeeb
f88fcc52d8 LinuxKPI: add hex2bin()
Add a hex2bin() implementation needed by a driver's debugfs code.

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

(cherry picked from commit deb9bfbd5b)
2022-01-16 22:38:48 +00:00
Bjoern A. Zeeb
f8612fa7e0 LinuxKPI: add 802.11 compat code
Add 802.11 compat code for mac80211 and to a minimal degree cfg80211.
This allows us to compile and use basic functionality of wireless
drivers such as iwlwifi.

This is a constant work in progress but having it in the tree will
allow others to test and more easy to track changes and avoid having
snapshots no longer applying to branches.

Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 6b4cac814e)
2021-12-30 18:27:45 +00:00
Bjoern A. Zeeb
fb3c236a4b LinuxKPI: import beginning of a new version of netdevice.h
Import a netdevice update complementing the last remaining bits of
the old ifnet derived implementation.  Along add a (for now) task
based NAPI implementation.

This is the minimal set of chnages which are needed for the initial
support of wireless drivers.  The NAPI implementation has an option to
still switch to "direct dispatch" as it had been used by these drivers
before not relying on a deferred context along with some printf tracing.
This has been helpful in the last weeks for debugging and will be
cleaned once we have had broader testing and are sure this is fine as-is.
Should we need a more time-sensitive or load-sensitive response
in the future we can always switch to something more sophisticated.

Sponsored by:		The FreeBSD Foundation
X-Differential Revision: D33075 (abandoned without feedback a while ago)

(cherry picked from commit d105895844)
2021-12-30 18:27:31 +00:00
Bjoern A. Zeeb
508c4fb4c3 LinuxKPI: add a work-in-progress skbuff implementation
This is a work-in-progress implementation of sk_buff compat code
used for wireless drivers only currently.
Bring in this version of the code as it has proven to be good enough
to have packets going for a few months.

The current implementation has several drawbacks including the need
for us to copy data between sk_buffs and mbufs.
Do not rely on the internals of this implementation.  They are highly
likely to change as we will improve the integration to FreeBSD mbufs.

Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 49ed6e979c)
2021-12-30 18:27:19 +00:00
Bjoern A. Zeeb
a34668185b modules: increase MAXMODNAME and provide backward compat
With various firmware files used by graphics and wireless drivers
we are exceeding the current 32 character module name (file path
in kldxref) length.
In order to overcome this issue bump it to the maximum path length
for the next version.
To be able to MFC provide backward compat support for another version
of the struct as the offsets for the second half change due to the
array size increase.

MAXMODNAME being defined to MAXPATHLEN needs param.h to be
included first.  With only 7 modules (or LinuxKPI module.h) not
doing that adjust them rather than including param.h in module.h [1].

Reported by:	Greg V (greg unrelenting.technology)
Sponsored by:	The FreeBSD Foundation
Suggested by:	imp [1]
Reviewed by:	imp (and others to different level)
Differential Revision:	https://reviews.freebsd.org/D32383

(cherry picked from commit df38ada293)
2021-12-30 18:26:18 +00:00
Bjoern A. Zeeb
111619ff70 LinuxKPI: add bcd.h
Add bcd2bin() in bcd.h.

Libkern does provide a bcd2bin() which cannot be used cirectly leaving
us with a conflict (see comment in file).
Rather than having code to re-define bcd2bin() for the LinuxKPI
make sure libkern.h is always included before the LinuxKPI version.
Then only re-define our local LinuxKPI implementation.  [1]
From the argument truncating wrapper call the libkern version.
If we change our libkern implementation in the future we can save
us the remainder of the hassle. [2].

Suggested by:	Johannes Berg (johannes sipsolutions.net) [1]
Suggested by:	ian [2]
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 548ada00e5)
(cherry picked from commit ae2268efd5)
2021-11-21 18:15:58 +00:00
Bjoern A. Zeeb
9d2d8a27d0 LinuxKPI: add strreplace() to string.h
Add strreplace() needed by a driver.

(cherry picked from commit a5e2a27dca)
2021-11-19 00:01:26 +00:00
Bjoern A. Zeeb
4459c16279 LinuxKPI: add kstrtou8() and kstrtou8_from_user() to kernel.h
Analogous to the other sized version of kstrto[u]<type>() and
kstrtobool_from_user() add the "u8" versions needed by a driver.

(cherry picked from commit b382b78503)
2021-11-19 00:01:26 +00:00
Bjoern A. Zeeb
a6a1ab040f LinuxKPI: add simple_open() to fs.h
Add a dummy simple_open() to fs.h as we have for other
(unsupported) functions.
This is needed by a wireless driver.

(cherry picked from commit 41dee251ee)
2021-11-19 00:01:26 +00:00
Bjoern A. Zeeb
009e6b6e71 LinuxKPI: module.h add MODULE_SUPPORTED_DEVICE()
Add a dummy MODULE_SUPPORTED_DEVICE define as we do for other
MODULE_* macros.  This is needed by a wireless driver.

(cherry picked from commit c5eec7b57c)
2021-11-19 00:01:26 +00:00