Add a memset_startat() macro which sets a pattern from a struct member
to the end of the struct. Needed by a wireless driver.
MFC after: 3 days
Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D37389
On Linux, the `kmalloc()` family of functions returns a special value if
the size of the allocation is zero. This macro verifies if the pointer
is NULL (the allocation failed) or the size is 0 (the allocation was not
performed AFAIU). This special value can be passed to `kfree()`.
On FreeBSD, our `malloc(9)` functions don't return a special value for
0-size allocations. Therefore we can simply compare the result against
NULL.
Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D37367
They are not really used in this header. However they are included in
Linux and at least the DRM drivers unfortunately rely on this namespace
pollution.
Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D37365
This is used by `i915_gem.c` in the i915 DRM driver to get access to
`wbinvd_on_all_cpus()`.
Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D36970
I took the implementation from OpenBSD, commit
d55ef580b1748517027c3eabdb715316ca5b1442.
The only difference is the addition of `dma_buf_map_is_equal()`.
Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D36963
It simply includes the same header in FreeBSD (which is located
elsewhere).
Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D36960
In FreeBSD, this is a wrapper on top of `realloc()`.
V2: Check if `n * size` would overflow and return `NULL` if that's the
case. Suggested by hselasky@ and emaste@.
Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D36959
In Linux, this affects how the value is formatted. In FreeBSD, this
remains an unsigned integer.
Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D36958
The previous `llnode` field is moved inside another field `node`.
This `node` field is a `struct __call_single_node` in Linux. Here, we
simply add an anonymous struct with the `llnode` field inside. That
field's new name is `llist` now.
V2: Use an anonymous union to keep the structure backward compatible
with drivers using the previous `llnode` field. This was suggested
by wufl@ and hselasky@. Thank you!
Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D36955
The system call returns the head of the robust futex list. The list head is stored
in the location pointed to by the head argument. When copying data between address
spaces use proper head storage size as it depends on an emulated ABI.
PR: 267616
MFC after: 3 days
Add virt_to_phys() as a define to vtophys().
This is used by a wireless driver for dma related work; sigh.
MFC after: 3 days
Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D37301
In addition to (*func) tasklet also seems to have a (*callback) with
a different argument. Add support for this and add tasklet_setup()
as well for support in more drivers.
The from_tasklet() definition is duplicated in the tree; hide it there
under #ifndef to avoid a re-definition. People should generally add
LinuxKPI bits to linuxkpi rather than private files if they also rely
on other LinuxKPI bits.
X-MFC: DO NOT MFC, space allocated by drivers not us.
Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D37216
Add a static set of cpumasks for all (possible) cpus with only the one
indexed cpu enabled in each set.
This is needed for cpumask_of(_cpuid) which returns a cpumask (cpuset)
with only cpu _cpuid enabled and is used by one wireless driver at least.
MFC after: 3 days
Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D37223
This is just a dummy enum and struct in order to make drivers compile
more happily as some parts are simply not hidden behind #ifdefs and
this avoids a longer-term maintenance problem.
MFC after: 3 days
Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D37215
Add devm_request_irq() needed by a driver. Turns out all we need
is a wrapper with the right arguments to lkpi_request_irq().
MFC after: 3 days
Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D37217
Add a memcpy variant which takes length of source and destination
buffers and a padding character in case there is free space in the
destination. This is used by a wireless driver.
MFC after: 3 days
Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D37226
Most of the WME code has been there disabled for months. One of the
reasons was that it lead to crashes early on. It is now understood
that the crashes are independent event and we can enable WME.
Update the code and deal with the calls from net80211 and adjust the
updates to when mac80211 drivers expect them, coherently put it under
LKPI_80211_WME and enable the define locally.
Sponsored by: The FreeBSD Foundation
MFC after: 3 days
With mac80211 operations (MO) tracing on we have seen some ill-ordered
executions of MO functions. In order to limit visibility of the mac80211
sta, pass the internal version into lkpi_80211_mo_sta_state() and only
there convert to the argument needed. This mostly eases tracing and
debugging.
Sposnored by: The FreeBSD Foundation
MFC after: 3 days
For some of these Clang produced a warning that "a function declaration
without a prototype is deprecated in all versions of C". In other cases
the function defintion used () which did not match the header
declaration, which used (void).
Sponsored by: The FreeBSD Foundation
Add __seq_open_private() and seq_release_private() needed by iwlwifi
debugfs support.
Sponsored by: The FreeBSD Foundation
MFC after: 3 days
Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D37089
Add a macro to each implemented mac80211 operation. This currently
turns into a printf if LINUXKPI_80211_DEBUG is defined but in the
future could become a different probe as well.
This is helpful for quick analysis and boot-time problem debugging
when DTrace and other frameworks may be harder to use.
Sponsored by: The FreeBSD Foundation
MFC after: 3 days
Add new fields (also have to move a struct up, no changes there)
in order to make iwlwifi debugfs support compile.
Sposnored by: The FreeBSD Foundation
MFC after: 3 days
Adds a few struct members and a function to get i915_runtime_pm_status()
to compile in drm-kmod.
Differential Revision: https://reviews.freebsd.org/D36749
Sponsored by: Google, Inc. (GSoC 2022)
Add the glue code to support netlink in Linuxolator.
linux_common(4) now depends on netlink(4).
All netlink protocol constants are consistent with the Linux version.
However, certain OS-specific constants such as AF_INET6, interface
flags or default routing table id, are different between FreeBSD and
Linux. Thus, it may be needed to rewrite some message parts or even
rewrite the whole message, adding or removing some TLVs. The core
netlink implementation code provides efficient rewriting callbacks
which Linuxolator now uses.
Reviewed by: dchagin
Differential Revision: https://reviews.freebsd.org/D36361
MFC after: 2 months
glibc-based interface.
Unfortunately, the glibc maintainers, despite knowing the existence
of the FreeBSD qsort_r(3) interface in 2004 and refused to add the
same interface to glibc based on grounds of the lack of standardization
and portability concerns, has decided it was a good idea to introduce
their own qsort_r(3) interface in 2007 as a GNU extension with a
slightly different and incompatible interface.
With the adoption of their interface as POSIX standard, let's switch
to the same prototype, there is no need to remain incompatible.
C++ and C applications written for the historical FreeBSD interface
get source level compatibility when building in C++ mode, or when
building with a C compiler with C11 generics support, provided that
the caller passes a fifth parameter of qsort_r() that exactly matches
the historical FreeBSD comparator function pointer type and does not
redefine the historical qsort_r(3) prototype in their source code.
Symbol versioning is used to keep old binaries working.
MFC: never
Relnotes: yes
Reviewed by: cem, imp, hps, pauamma
Differential revision: https://reviews.freebsd.org/D17083
Sysctl OIDs were internally stored in linked lists, triggering O(n^2)
behavior when userland iterates over many of them. The slowdown is
noticeable for MIBs that have > 100 children (for example, vm.uma). But
it's unignorable for kstat.zfs when a pool has > 1000 datasets.
Convert the linked lists into RB trees. This produces a ~25x speedup
for listing kstat.zfs with 4100 datasets, and no measurable penalty for
small dataset counts.
Bump __FreeBSD_version for the KPI change.
Sponsored by: Axcient
Reviewed by: mjg
Differential Revision: https://reviews.freebsd.org/D36500
While we deal with 0 returned, some drivers directly use and check for
DMA_MAPPING_ERROR. Add the case and check for both in dma_mapping_error().
MFC after: 1 week
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D36686
Add a structure definition as well as a dummy dmi_walk for now
which returns an error as not supported. Our current dmi implementation
is special but does not give access to all details but rather only
information from kenv which does not suffice all use cases.
MFC after: 1 week
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D36687
This matches the return type of pmap_mapdev/bios.
Reviewed by: kib, markj
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D36548