Commit graph

3871 commits

Author SHA1 Message Date
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
b42bc4d602 LinuxKPI: Add static_cpu_has() implementation
static_cpu_has returns true if CPU supports requested feature.

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

(cherry picked from commit f3ddb82d9a)
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
6fda5ef279 LinuxKPI: Add stdarg.h proxy header
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 35235d5ff6)
2022-01-22 22:34:36 +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
bb53dafe14 LinuxKPI: 802.11 correct enum ieee80211_channel_flags
enum ieee80211_channel_flags are used as bit fields and not as 1..n.
Correct the values using BIT(n).

This is also hoped to fix problems with 7260 cards which come up and
panic due to an empty channel list as all channels are set disabled [1][2].
It will hopefully also fix the one or other oddity.

Reported by:	ambrisko, Mike Tancsa (mike sentex.net) [1]
Confirmed to fix by: ambrisko, Mike Tancsa (mike sentex.net) [2]
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit d7ce88aafc)
2022-01-20 14:05:37 +00:00
Bjoern A. Zeeb
f27c46a850 LinuxKPI: 802.11 Refine/add DTIM/TSF handling
Correct data types related to delivery traffic indication map (DTIM)/
timing synchronization function (TSF) and implement/refine their
handling.  This information is used/needed by iwlwifi to set a station
as associated.  This will hopefully avoid more "no beacon heard"
time event failures.

The recording of the Linux specific sync_device_ts is done in the
receive path for now in case we do have the right information
available.  I need to investigate as to how-much it may make sense
to also migrate it into net80211 in the future depending on the
usage in other drivers (or how we did handle this in the past in
natively ported versions, e.g. iwm).

Sponsored by:	The FreeBSD Foundation

(cherry picked from commit c8dafefaee)
2022-01-20 14:05:26 +00:00
Bjoern A. Zeeb
ccda5ec945 LinuxKPI: 802.11 handle connection loss differently
Rather than just bouncing back to SCAN bounce to INIT on connection
loss.  This is should be refined in the future as the comment already
indicates but we need to tie two different worlds together.

Sponsored by:	The FreeBSD Foundation

(cherry picked from commit f3229b62a1)
2022-01-20 14:05:17 +00:00
Ruslan Makhmatkhanov
a22fd09343 LinuxKPI: 802.11 correctly spell queues
PR:		261078
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 312ba38a9b)
2022-01-16 22:39:37 +00:00
Bjoern A. Zeeb
82a6a8c294 LinuxKPI: 802.11 fix locking in lkpi_stop_hw_scan()
In lkpi_stop_hw_scan() we have to unlock around cancelling the
hardware scan and an msleep to wait for the confirmation that the
scan ended.  Otherwise we are sleeping with the non-sleepable
net80211 com lock held.  At the same time we need to hold the lhw
lock for the msleep().
This lock change got lost in the refactoring of lkpi_iv_newstate().

Reported by:	ambrisko, delphij
PR:		261075
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit bec766282f)
2022-01-16 22:39:28 +00: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
cb6bb87184 LinuxKPI / iwlwifi: fix spelling of constants
Fix the spelling of IEEE80211_HE_PHY_CAP9_NOMINAL_PKT_PADDING_*
(was "NOMIMAL").  The original version came from iwlwifi
in iwlwifi-next.  Other drivers (from wireless-testing) already
use the correct spelling and need this change in LinuxKPI.

Sponsored by:	The FreeBSD Foundation

(cherry picked from commit e200809190)
2022-01-16 22:39:16 +00:00
Bjoern A. Zeeb
b7277a762c LinuxKPI: 802.11 handle IEEE80211_CONF_IDLE better
We never initialized hw->conf.flags for IEEE80211_CONF_IDLE but
on set_channel we would clear it and announce a change.
This lead to a problem that drivers may do some work every time
which was not needed and may lead to unexpected behaviour (for no
better driver code).

Properly initialize conf.flags with IEEE80211_CONF_IDLE.
Factor out the toggling into a function and clear IDLE while
sw scanning and when associated and set again when scan ends
or we are bouncing out of assoc.

(cherry picked from commit 086be6a809)
2022-01-16 22:39:10 +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
Konstantin Belousov
6e676b5550 Regen 2022-01-14 18:17:30 +02:00
Konstantin Belousov
a48d9f1900 Add sched_getcpu()
(cherry picked from commit 77b2c2f814)
2022-01-14 18:17:29 +02:00
Mark Johnston
1562fe492a exec: Simplify sv_copyout_strings implementations a bit
Simplify control flow around handling of the execpath length and signal
trampoline.  Cache the sysentvec pointer in a local variable.

No functional change intended.

Reviewed by:	kib
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit f04a096049)
2022-01-14 08:50:06 -05:00
Bjoern A. Zeeb
50a078f852 LinuxKPI: 802.11 fix queue wait
We are using a bandaid to wait for queues after station creation
looping and pausing.
The abort condition was looping in the wrong direction so we were
potentially waiting forever if queues never became ready.
From initial user test data we also found that the wait time was
too low in some cases so increase the length.

Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 500be2e803)
2022-01-09 02:37:01 +00:00
Konstantin Belousov
9cbd1c32b1 amd64 ia32 vdso: add unwind annotations to the signal trampoline
(cherry picked from commit 8a4bd7f818)
2022-01-02 18:43:01 +02:00
Konstantin Belousov
e85becdf19 vdso for ia32 on amd64
(cherry picked from commit 98c8b62524)
2022-01-02 18:43:01 +02:00
Konstantin Belousov
203bcad731 amd64: wrap 64bit sigtramp into vdso
(cherry picked from commit ab4524b3d7)
2022-01-02 18:43:01 +02: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
2c6ebb7834 LinuxKPI: USB return possible error from suspend/resume
USB suspend/resume cannot fail so we never returned the error which
resulted in a -Wunused-but-set-variable warning.
Initialize the return variable and return a possible error possibly
triggering a printf upstream to at least have a trace of the problem.
This also fixes the warning.

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

(cherry picked from commit 943df073a3)
2021-12-30 18:25:28 +00:00
Bjoern A. Zeeb
e17d7f3d86 LinuxKPI: fix -Wunused-but-set-variable warnings
Handle write-only variables by removing the unused return value from void
functions or removing the unused variables entirely.

Sponsored by:	The FreeBSD Foundation
Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D33107

(cherry picked from commit 7043359ce3)
2021-12-30 18:25:15 +00:00
Konstantin Belousov
bafbbd46ca Regen 2021-12-20 02:29:11 +02:00
Konstantin Belousov
1791debf4a swapoff: add one more variant of the syscall
For MFC, COMPAT_FREEBSD13 braces were removed.

(cherry picked from commit 5346570276)
2021-12-20 02:29:11 +02:00