Commit Graph

4087 Commits

Author SHA1 Message Date
Bjoern A. Zeeb
bec766282f 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
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
2022-01-10 22:29:23 +00:00
Vladimir Kondratyev
7356f661e8 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
2022-01-10 22:49:38 +03:00
Vladimir Kondratyev
64dab63f3b 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
2022-01-10 22:49:38 +03:00
Vladimir Kondratyev
307f78f3ed 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
2022-01-10 22:49:38 +03:00
Vladimir Kondratyev
98b129783c 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
2022-01-10 22:49:38 +03:00
Vladimir Kondratyev
1456816425 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
2022-01-10 22:49:38 +03:00
Vladimir Kondratyev
f9c8b5880d 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
2022-01-10 22:49:38 +03:00
Vladimir Kondratyev
2e194c20c1 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
2022-01-10 22:49:38 +03:00
Vladimir Kondratyev
f3ddb82d9a 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
2022-01-10 22:49:38 +03:00
Vladimir Kondratyev
89bb7f9bda 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
2022-01-10 22:49:38 +03:00
Vladimir Kondratyev
882f8d059c LinuxKPI: Import linux/jump_label.h
Required by drm-kmod

Obtained from:	DragonflyBSD
Differential Revision:	https://reviews.freebsd.org/D33299
2022-01-10 22:49:38 +03:00
Vladimir Kondratyev
0b1244bd79 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
2022-01-10 22:49:37 +03:00
Vladimir Kondratyev
35235d5ff6 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
2022-01-10 22:49:37 +03:00
Vladimir Kondratyev
f1a7639a16 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
2022-01-10 22:49:37 +03:00
Vladimir Kondratyev
2fb5be7978 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
2022-01-10 22:49:37 +03:00
Vladimir Kondratyev
68fcdba38b 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
2022-01-10 22:49:37 +03:00
Vladimir Kondratyev
7ec6cbf1d2 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
2022-01-10 22:49:37 +03:00
Vladimir Kondratyev
e705066cd8 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
2022-01-10 22:49:37 +03:00
Vladimir Kondratyev
04d42cb453 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
2022-01-10 22:49:37 +03:00
Vladimir Kondratyev
c427456fd5 LinuxKPI: Implement kstrtoull
Required by drm-kmod 5.7

MFC after:	1 week
Reviewed by:	hselasky, manu
Differential Revision:	https://reviews.freebsd.org/D33291
2022-01-10 22:49:37 +03:00
Vladimir Kondratyev
bc923d93df 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
2022-01-10 22:49:37 +03:00
Vladimir Kondratyev
db562aeff7 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
2022-01-10 22:49:36 +03:00
Vladimir Kondratyev
9a79e08ae7 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
2022-01-10 22:49:36 +03:00
Vladimir Kondratyev
dbc920bd9a LinuxKPI: Implement interval_tree
Required by drm-kmod

MFC after:	1 week
Reviewed by:	hselasky, manu
Differential Revision: https://reviews.freebsd.org/D32869
2022-01-10 22:49:36 +03:00
Vladimir Kondratyev
dd52763387 LinuxKPI: Import some linux/rbtree.h functions from OpenBSD
Required by drm-kmod

Obtained from:	OpenBSD
MFC after:	1 week
2022-01-10 22:49:36 +03:00
Ruslan Makhmatkhanov
312ba38a9b LinuxKPI: 802.11 correctly spell queues
PR:		261078
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
2022-01-10 18:08:17 +00:00
Edward Tomasz Napierala
1866c766d2 linux: Improve debugging by recognizing TIOCGPTPEER
Sponsored By:	EPSRC
2022-01-10 15:36:11 +00:00
Bjoern A. Zeeb
51b461b3db 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.

MFC after:	3 days
2022-01-09 18:08:47 +00:00
Bjoern A. Zeeb
2fb0569f1f 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().

MFC after:	3 days
Reviewed by:	hselasky
Differential Revision: https://reviews.freebsd.org/D33799
2022-01-09 14:39:19 +00:00
Bjoern A. Zeeb
deb9bfbd5b LinuxKPI: add hex2bin()
Add a hex2bin() implementation needed by a driver's debugfs code.

MFC after:	3 days
Reviewed by:	hselasky
Differential Revision: https://reviews.freebsd.org/D33798
2022-01-09 14:36:28 +00:00
Bjoern A. Zeeb
e200809190 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
MFC after:	3 days
2022-01-09 02:21:05 +00:00
Bjoern A. Zeeb
086be6a809 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.

MFC after:	3 days
2022-01-09 00:59:50 +00:00
Bjoern A. Zeeb
4ddc0079ea 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.

MFC after:	3 days
2022-01-09 00:57:13 +00:00
Mark Johnston
f04a096049 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
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D33703
2021-12-31 12:50:15 -05:00
Bjoern A. Zeeb
500be2e803 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
MFC after:	3 days
2021-12-31 11:47:14 +00:00
John Baldwin
cc5aa0a496 sys/compat: Use C99 fixed-width integer types.
No functional change.

Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D33632
2021-12-28 09:41:33 -08:00
Bjoern A. Zeeb
6b4cac814e 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
MFC after:	3 days
2021-12-27 18:47:25 +00:00
Bjoern A. Zeeb
d105895844 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
MFC after:		3 days
X-Differential Revision: D33075 (abandoned without feedback a while ago)
2021-12-27 18:47:25 +00:00
Bjoern A. Zeeb
49ed6e979c 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
MFC after:	3 days
2021-12-27 18:47:25 +00:00
Alexander Motin
27ac2b2d49 LinuxKPI: Replace missed Giant with bus_topo_lock. 2021-12-25 22:02:07 -05:00
Mateusz Guzik
0c8d7eebfd linux: plug set-but-not-used vars
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2021-12-18 13:12:15 +00:00
Warner Losh
c6df6f5322 Create wrapper for Giant taken for newbus
Create a wrapper for newbus to take giant and for busses to take it too.
bus_topo_lock() should be called before interacting with newbus routines
and unlocked with bus_topo_unlock(). If you need the topology lock for
some reason, bus_topo_mtx() will provide that.

Sponsored by:		Netflix
Reviewed by:		mav
Differential Revision:	https://reviews.freebsd.org/D31831
2021-12-09 17:04:45 -07:00
Bjoern A. Zeeb
df38ada293 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]
MFC after:	10 days
Reviewed by:	imp (and others to different level)
Differential Revision:	https://reviews.freebsd.org/D32383
2021-12-09 18:09:53 +00:00
Konstantin Belousov
b7c55487ff Regen 2021-12-09 02:49:10 +02:00
Konstantin Belousov
794d3e8e63 fcntl(2): add F_KINFO operation
that returns struct kinfo_file for the given file descriptor.  Among
other data, it also returns kf_path, if file op was able to restore file
path.

Reviewed by:	jhb, markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D33277
2021-12-06 22:18:09 +02:00
Konstantin Belousov
8a4bd7f818 amd64 ia32 vdso: add unwind annotations to the signal trampoline
Reviewed by:	emaste
Discussed with:	jhb, jrtc27
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	1 month
Differential revision:	https://reviews.freebsd.org/D32960
2021-12-06 20:47:24 +02:00
Konstantin Belousov
98c8b62524 vdso for ia32 on amd64
Reviewed by:	emaste
Discussed with:	jrtc27
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	1 month
Differential revision:	https://reviews.freebsd.org/D32960
2021-12-06 20:46:49 +02:00
Brooks Davis
0e765d9b08 syscalls: regen 2021-11-29 22:04:58 +00:00
Brooks Davis
401eec3635 syscalls: regen 2021-11-29 22:04:44 +00:00
Brooks Davis
5c1835b1d4 syscalls: regen 2021-11-29 22:04:43 +00:00