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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)