Since commit 19df0c5abcb9d4e9 ("LinuxKPI: make __kmalloc() play by the
rules"), kmalloc() systematically allocates contiguous physical memory,
as it should. However, kvzalloc() was left defined in terms of
kmalloc(), which makes it allocate contiguous physical memory too. This
is a too stringent restriction, as kvzalloc() is supposed to be a simple
page-zeroing wrapper around kvmalloc().
According to Linux's documentation ("memory-allocation.rst"), kvmalloc()
first tries to allocate contiguous memory, falling back to
non-contiguous one if that fails. Thus, callers are already supposed to
deal with the possibility of non-contiguous memory being returned.
Reviewed by: bz
Fixes: 19df0c5abcb9 ("LinuxKPI: make __kmalloc() play by the rules")
MFC after: 10 days
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D51247
(cherry picked from commit 986edb19a49c7d7d3050c759d9b0826283492ebf)
Forgotten on commit to main/-CURRENT:
PR: 277476
Given the internal field now stores a __wsum csum (after we added
the type) also make sure csum_unfold() returns a __wsum.
Sponsored by: The FreeBSD Foundation
Fixes: 59481c7db234
(cherry picked from commit 36ca21722c2700e00e41444a29aeabf246eea90d)
There's one case which needs skb_copy_header(); add a dummy function
for now until we get to the code which uses it to test an implementation.
Sponsored by: The FreeBSD Foundation
(cherry picked from commit 84c5998ccb0b3e8a401d1f2b5a32649e88847d63)
Restructure struct_group() into a wrapper around __struct_group().
Various callers have arguments annotated as /* no foo */ so try to
add all we can find.
Sponsored by: The FreeBSD Foundation
Reviewed by: dumbbell
Differential Revision: https://reviews.freebsd.org/D50157
(cherry picked from commit 54d0e1772fb6b83d72725764e0a5d3ead8337673)
ktime_get_boottime_seconds() is needed by an updated iwlwifi driver.
Sposored by: The FreeBSD Foundation
Reviewed by: dumbbell
Differential Revision: https://reviews.freebsd.org/D50005
(cherry picked from commit 93b82146c43b8ecad4fd7694ec1daf6d79cca65c)
Needed by mediatek/mt76 wireless driver.
While here adjust the way is_multicast_ether_addr() is implemented
to not look weird. [1]
Sponsored by: The FreeBSD Foundation
Suggested by: emaste [1]
Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D50152
(cherry picked from commit a4618caa43c16e6e672c27dac1943fd833f8bd8f)
It may be that once we implement freeing of chained tables
_devcd_free_sgtable() will become our _lkpi_dev_coredumpsg_free()
but further investigations need to happen. For now make an
updated iwlwifi driver happy which should not need more.
Sponsored by: The FreeBSD Foundation
Reviewed by: dumbbell
Differential Revision: https://reviews.freebsd.org/D50006
(cherry picked from commit 71576ed24b56143429a3b6774a7862965c2dea88)
Start to sort through the netdevice features to match them with
FreeBSD. Annotate them a bit more verbose though the names are
pretty telling already.
While here adjust style(9) as well.
Lastly add the bit definitions for use with printf(9) %b as names
read easier than bitmasks. We will use that in LinuxKPI 802.11.
No functional changes.
Sponsored by: The FreeBSD Foundation
(cherry picked from commit 4b6b9c1368b346f7093153d14e7931403ac3202d)
Add a acpi_evaluate_dsm() wrapper around the native implementation
as needd by wireless drivers.
Sponsored by: The FreeBSD Foundation
Reviewed by: dumbbell
Differential Revision: https://reviews.freebsd.org/D50864
(cherry picked from commit ba6460df5607e572e9c868413c75ce9bc5ce9a00)
Provide union acpi_(object|buffer) as linuxkpi_ versions and in Linux
native lower case spelling so that driver code compiles unmodified.
Use the linuxkpi_ prefix to avoid name clashes with the native ACPI
implementation which uses CamelCase.
Use the linuxkpi_ names internally and redefine the linuxkpi_ unions
to their native names so they are avail as expected in drivers.
As a transition to not break drm-kmod which has in-place (no #ifdef)
changes from Linux spelling ot FreeBSD spelling, introduce
LINUXKPI_WANT_LINUX_ACPI so we have the Linux spelling as an opt-in.
That way the transition can happen gracefully and once "top-of-trees"
are all sorted we can remove the #ifdefs here again.
Bump __FreeBSD_version to be able to detect this change.
Sponsored by: The FreeBSD Foundation
Reviewed by: wulf (previous version), dumbbell
Differential Revision: https://reviews.freebsd.org/D50863
(cherry picked from commit 2ddfcc013c251f13c8c9b24970b8134ddd49afea)
In order to be able to use MODULE_DEVICE_TABLE() with multiple bus
attachments, factor out the bus-specfic MODULE_PNP_INFO() and place
it next to the structure defining the table.
As it turns out bnxt(4) has been using the MODULE_DEVICE_TABLE() with
PCI attachments for the "auxillary" bus so far. That makes little sense.
Define the MODULE_PNP_INFO() to nothing for that. We may consider
pulling these LinucKPI bits in semi-native drivers into LinuxKPI
one day as that route is not really sustainabke.
Sponsored by: The FreeBSD Foundation
Reviewed by: imp, dumbbell
Differential Revision: https://reviews.freebsd.org/D51049
(cherry picked from commit 2f5666c1727c949491f73e6c3277b7b542131714)
While we currently only use MODULE_DEVICE_TABLE() for pci (or so I
thought [*]), this may soon change. Remove a hard coded "pci" for
the bus and use the bus name passed in as _bus.
[*] see follow-up change
Sponsored by: The FreeBSD Foundation
Reviewed by: imp, dumbbell
Differential Revision: https://reviews.freebsd.org/D51048
(cherry picked from commit f58e032410c93d67c83d6bce8a3e6711f377a4be)
dma_map_resource() and dma_unmap_resource() functions are used to map
and unmap of memory-mapped IO resources so they can be accessed by
the device.
Required by drm-kmod v5.5 to be built.
While for drm-kmod 6.6-lts only amdgpu uses these in one place and
the code apparently has not been exercised a lot it has been around
like this for years. With changing the underlying implementations
bring it into the tree; should we find errors with it they can also
be fixed here.
Bump __FreeBSD version to be able to detect this change.
Obtained from: D30933 (by wulf)
Sponsored by: The FreeBSD Foundation
Reviewed by: dumbbell
Differential Revision: https://reviews.freebsd.org/D49625
(cherry picked from commit a02180cf60a6a0102669b678e9c81ad9f1aa4d91)
Rename linux_dma_unmap() to lkpi_dma_unmap(), and linux_dma_map_phys()
to lkpi_dma_map_phys() so that we get the full set of function
arguments (direction and attributes were missing).
Leave the old functions as wrappers as they are called from drm-kmod
linuxkpi/bsd still, and leaving them also allows us to MFC this
change.
Add missing bus_dmamap_sync() calls. Rather than inlining them
in each inline function push them down to the actual implementation.
From there do not inline them either but call the appropriate
function dealing with the sync so that we do not have the same
code splattered in many places.
Adhere to the DMA_ATTR_SKIP_CPU_SYNC attribute and skip synching
when requested.
A previous, less complete version of this change already allowed
me to load firmware on arm64 for iwlwifi (again).
There are four more places which are not currently done as the
functions which came with an OFED sync a long time ago seem to be
unused these days. Leaving a pr_debug("TODO") call there.
Also dma_[un]map_resource() when brought in from drm-kmod/linuxkpi/bsd
(D30933) should be adjusted to pass the full arguments as the amdgpu
callers are requesting to skip synching.
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D45294
(cherry picked from commit f99d393f7f787ff080c12b92243adcc310ac7c58)
Add ieee80211_purge_tx_queue() dummy function needed by rtw88 SDIO.
Sponsored by: The FreeBSD Foundation
(cherry picked from commit 9cac7351868d0e896a648ffe354b001ced55acfa)
Migrate most LinuxKPI 802.11 definitions for HE IEs to net80211.
During that process also properly define them as most of them only
had dummy values. Some of the definitions are sparse; that is, only
the bits used by drivers so far were listed and annotated with the
standards section.
There seems to be little point to mangle the names and have two copies
of all these bit field definitions. We can add "_S" (shift/mask)
variants to those we need in net80211 (if we do).
Sponsored by: The FreeBSD Foundation
Reviewed by: adrian
Differential Revision: https://reviews.freebsd.org/D50677
(cherry picked from commit 2ab7cbdc346e2a174a7bee4ce44c4f78b1ca093b)
Take the HE IE structures as they are used by drivers and put them
into net80211 rather than LinuxKPI. There is little need to
re-invent the wheel on those. They settled for long enough.
Do not export them by default to user space as some also overlap with
wpa and we still do not have a clear distinction for what is available
only in kernel and what to user space. In our case ifconfig(8)
is a consumer of these structs which it can setting WANT_NET80211 like
we have done for some VHT bits before.
Add struct net80211_he_cap which holds the IE fields but also a bool
and is meant to be put into ic/vap/ni. The bool will give us the same
naming for all layers rather than having individual flags in each part
which was highly confusing. In theory this struct should be in
ieee80211_var.h but that would pull things apart.
Extend struct ieee80211_mu_edca_param_set by a union as it will help
ifconfig(8) parsing the bk/be/vi/vo parts.
Sponsored by: The FreeBSD Foundation
Reviewed by: adrian
Differential Revision: https://reviews.freebsd.org/D50676
(cherry picked from commit 8be200cf968f0c7f72f75c8a73d7b2bee43f935d)
Update strutures needed for 11ax (HE) to be correct. Add references
to the standard.
Sponsored by: The FreeBSD Foundation
(cherry picked from commit 71f854e5a01a347174d09d594b3d490f806cf850)
Rather than using inline functions use macros so we know where we are
taking the lock in the code rather than only recording the inline
function location.
Sponsored by: The FreeBSD Foundation
(cherry picked from commit d87ee937ed852cd22eac808bc8fcf7b0e34c9ec1)
In lkpi_sta_sync_ht_from_ni() we are casting the information element (IE)
data to this struct as net80211 does not save the mcs/rx_mask.
Not marking the structs packed results in the mcs information not being
copied correctly and rx_nss calculations possibly being off. Even worse,
at a later stage iwlwifi mvm/rs.c would extract the mcs values from the
same field to pass to the firmware which will than crash in an assert
as we would want to do HT with an empty MCS set.
Sponsored by: The FreeBSD Foundation
Discovered: while testing other features on arm64.
Approved by: re (cperciva)
(cherry picked from commit 6cbf8a04b1864d933506301cabe213a9c918d968)
(cherry picked from commit 9ccf7aeaa5dc5ceb3bf896d84ee50294b841043b)
Add more structs, fields, flags, defines.
Sponsored by: The FreeBSD Foundation
Approved by: re (cperciva)
(cherry picked from commit 675e6b1c68ba71af1853952f7df4d84399340009)
(cherry picked from commit 6a0dbc0a1246c9825f0892bb6dd957f5d081057a)
The dev field in wiphy is a pointer already; no need for &.
Sponsored by: The FreeBSD Foundation
Fixes: ac1d519c01ca8
Approved by: re (cperciva)
(cherry picked from commit 845b81cf908002b14ac08ce8c42246720a5b30d9)
(cherry picked from commit a21addc7a0137c5938414df322dbf5f929729834)
Define time64_t to int64_t for all supported architectures
unconditionally.
Sponsored by: The FreeBSD Foundation
Reviewed by: imp, markj, emaste
Differential Revision: https://reviews.freebsd.org/D50004
(cherry picked from commit 8b51cd07f69e9a5052f660d96a8feb7af4b387c1)
Use a macro to automatically gather the length of the array while
we can.
Sponsored by: The FreeBSD Foundation
Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D50007
(cherry picked from commit f94d7319540b9b2256be60c2c666efe0b6e635ef)
Add pci_info() needed for a driver update. While here prefix
__VA_ARGS__ with ## for pci_err and pci_info in case we are only
passed a string without format arguments.
Sponsored by: The FreeBSD Foundation
Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D50009
(cherry picked from commit e29d72ac3ddd9b97d945c5c64bc817e501bb113c)
An updated rtw88 driver requires minimal changes to leds.h. On
the positive side we can now remove the __DUMMY from the enum as we
actually have a valid field name.
Sponsored by: The FreeBSD Foundation
Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D50002
(cherry picked from commit 69880fede78fc769ad417e5a984fb9fee7815d8b)
Some code relies on header pollution (or self-sustainability).
Add cleanup.h to mutex.h as that is one case it seems to be used with.
Sponsored by: The FreeBSD Foundation
Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D50001
(cherry picked from commit 059136a95aca2e550b62ef40ab25a184d8141124)
This is needed for rtw89 updates.
Sponsored by: The FreeBSD Foundation
Reviewed by: emaste, zarychtam_plan-b.pwste.edu.pl
Differential Revision: https://reviews.freebsd.org/D50000
(cherry picked from commit c8e2458de590d7427ef3311412b8ddbc326cd3b5)
Move some structs into the appropriate header to be visible.
Add new fields to structs and enums.
Remove arguments from two functions (one function currently unused
by drivers in the tree, for the other the argument was unused).
Adjust the iwlwifi accordingly. This is in preparation for new
driver versions to allow a smooth transition.
Sponsored by: The FreeBSD Foundation
(cherry picked from commit e6010da63903cc6d9aac0077ab861cfd6bae2aa7)
Driver updates introduce a new field "mlo" to the sta.
Add the field to the struct and initialize it in the 802.11 compat
code along with a IMPROVE so once we get to 11be we can deal with it.
Sponsored by: The FreeBSD Foundation
(cherry picked from commit 71034267d861c183297bb209770004751f0e30c5)
TKIP has a special key buffer. While keylen only identifies the
key length, the two MIC are appended. The LinuxKPI offsets for
these were unfortunately never set correct which lead to constant
Micheal counter measures as the MIC never was correct when calculations
were offloaded to firmware. This is the first half of the fix.
Sponsored by: The FreeBSD Foundation
(cherry picked from commit a23908728efce08cfd10b13ed34de1361d0a980f)
In addition to CCMP add TKIP and GCMP support. The others are still
TODO() until we do suport them natively.
Also refine checks for tid and narrow them down (also don't assert but
gratiously fail).
Sponsored by: The FreeBSD Foundation
(cherry picked from commit a7131a748483adf783ff7ac2a8ab71d5c17eb925)
Add IEEE80211_KEY_FLAG_BITS to be used with %b for debugging
ieee802111_key_flag bit flags. Names are a lot easier to deal
with than just numbers.
Sponsored by: The FreeBSD Foundation
(cherry picked from commit 52e39daeef8804d134e1aa76149d47c026663a61)
Fix the types of a few remaining fields.
Shuffle the fields around so the important ones align to 64byte on a
64bit platform.
Sponsored by: The FreeBSD Foundation
(cherry picked from commit 59481c7db2340c9e64f9d3d9d05dafc2d72c157e)
Initially we saved the exact allocation length for contigfree(9).
contigfree can now be replaced by free(9) so there is no need to
remember that value anymore. Removing it also simplifies the
linuxkpi_kfree_skb() code.
Sponsored by: The FreeBSD Foundation
(cherry picked from commit 73e3969fd435eea296b44f3bd40ff76c042c9a36)
Seems this is the correct type for the csum field in an sk_buff.
Add it as uint32_t __bitwise__.
Sponsored by; The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D49831
(cherry picked from commit c925e0a77606d07e4d93204a1d35530176c4b344)
csa_active, color_change_active, mu_mimo_owner also moved from
vif to bss_conf; we already have the fields in bss_conf (adjust type
for one) so all we have to do is remove the old relics in vif.
Sponsored by: The FreeBSD Foundation
Tested by: Oleksandr Kryvulia (shuriku shurik.kiev.ua)
Tested by: Oleg Nauman (oleg.nauman gmail.com) [rtw88]
Differential Revision: https://reviews.freebsd.org/D49734
(cherry picked from commit 5321cf2b15d7bff1b01182cfc4897ac978c63fe7)
In preparations for MLD support chanctx_conf was moved from vif to
the bss_conf as it will be per-link later. Follow accordingly.
Sponsored by: The FreeBSD Foundation
PR: 280546
Tested by: Oleksandr Kryvulia (shuriku shurik.kiev.ua)
Tested by: Oleg Nauman (oleg.nauman gmail.com) [rtw88]
Differential Revision: https://reviews.freebsd.org/D49734
(cherry picked from commit 11604b2a1659fd6da9bbfdc6acf9758884cb2b36)
We have the same code three times, so factor it out into its own
function to make it easier to maintain.
Sponsored by: The FreeBSD Foundation
PR: 280546
Tested by: Oleksandr Kryvulia (shuriku shurik.kiev.ua)
Tested by: Oleg Nauman (oleg.nauman gmail.com) [rtw88]
Differential Revision: https://reviews.freebsd.org/D49734
(cherry picked from commit 50d826be664ef35065e8c4c4966252f2dfde9cb9)
Sort out some (though not yet all) changes needed for CONFIG_PM_SLEEP
and respectively WoWLAN support (so we can compile it in). This is
just one further step towards proper suspend/resume support.
Sponsored by: The FreeBSD Foundation
(cherry picked from commit b42c339c59fd00f2d97f6854b17b54b340019d0c)
Define the last missing PN length and for consistency use them
in struct ieee80211_key_seq (even though a 6 is a 6 is a 6).
Sponsored by: The FreeBSD Foundation
(cherry picked from commit c8a6676eb652b59fee545dc3e24ffec21bd0cd8d)
iwlwifi was the only driver we care about which "used" cipher_scheme
and it was removed from there too. Remove given it is no longer
used anywhere.
Sponsored by: The FreeBSD Foundation
(cherry picked from commit cdef9a9f91e2eee00e8f6f1ed743a8d8bd0bdc14)
Move the implementation of print_hex_dump() into linux_compat.c as
lkpi_hex_dump() taking an extra function pointer and argument.
Add two internal wrappers for printf and sbuf_printf to get a common
function definition (sbuf_printf takes the extra argument).
Use these to implement print_hex_dump() and the newly added
seq_hex_dump().
This allows us to re-use the same implementation of print_hex_dump()
for both functions without duplicating the code.
Initial implementation: D49381 by dumbbell
Sponsored by: The FreeBSD Foundation
Reviewed by: dumbbell
Differential Revision: https://reviews.freebsd.org/D49637
(cherry picked from commit 4359672e656af5e6758d0aae147212e58f445f5b)
Move kfree() into slab.c as an implementation and hide the private
function linux_kfree_async() entirely.
Remove a ; at the end of a define and sort some defines into place.
Remove extern from function declarations and move the closer to where
they belong.
Sort the functions into "base allocator/free" functions--these have
an implementation in slab.c and are ensuring contiguous physical
memory allocations.
Followed by inline functions using these base allocators to implement
their functionality; vmalloc/kvalloc, and misc functions.
Sponsored by: The FreeBSD Foundation
Reviewed by: dumbbell
Differential Revision: https://reviews.freebsd.org/D49572
(cherry picked from commit a3e6f97bf57c1d323487d07369aec66542f995ce)
Implement krealloc_array() using krealloc(). Implement krealloc()
doing the various size checks ourselves and use realloc() or kmalloc()
depending on old and new allocation sizes.
This way we can ensure that allocated memory stays physically contiguous.
Sponsored by: The FreeBSD Foundation
Suggested by: jhb (see D46657)
Reviewed by: jhb, markj
Differential Revision: https://reviews.freebsd.org/D49571
(cherry picked from commit 1c95d401ebe5075ebb38b57638830713a496f107)