This fixes an instapanic when restarting wpa_supplicant on my laptop's
iwlwifi device. After this change, iwlwifi enters a nonfunctional
state if wpa_supplicant is restarted, but "service netif restart wlan0"
is enough to get it working again.
releng/13.2 candidate.
Reviewed by: bz
MFC after: 3 days
For further use in linux_ioctl_socket add bsd_to_linux_ifflags() which
accepts FreeBSD interface flags and translate it to Linux if flags.
Reviewed by: melifaro
Differential Revision: https://reviews.freebsd.org/D38873
Split the linux_ioctl_socket() function on two counterparts, where
the linux_ioctl_socket_ifreq() intended to use in a code path which
requires the struct ifreq manipulation, i.e., translating in/out
values of the struct, while the linux_ioctl_socket() function is left
as is, it calls sys_ioctl() without touching in/out values.
Due to structures ifreq, sockaddr difference between FreeBSD and Linux
the linux_ioctl_socket_ifreq() calls kern_ioctl() directly, converting
in and out values to FreeBSD and to Linux accordingly.
Finally, modify the ifname_linux_to_bsd() to return error code, not
an unstable reference to the interface.
Reviewed by: melifaro
Differential Revision: https://reviews.freebsd.org/D38794
For now we are using mixed names to access struct ifreq members, some
of Linux (ifr_name, ifr_ifindex), others of FreeBSD. To avoid conflicts
switch to use FreeBSD names.
Reviewed by: jhibbits
Differential Revision: https://reviews.freebsd.org/D38792
Enter the net epoch when traversing a list of interfaces. For that
split the ifname_linux_to_bsd() function on two counterparts, where
the ifname_linux_to_ifp() intended to use in epoch, while the
ifname_linux_to_bsd() intended to be a self-contained.
Until the linux_ioctl_coket() function is refactored, the
ifname_linux_to_bsd() temporarily returns interface outside
of the net epoch.
Reviewed by: melifaro
Differential Revision: https://reviews.freebsd.org/D38790
Migrate linux and linprocfs to use the IfAPI interfaces instead of
direct ifnet accesses.
The code initially writed by jhibbits@, and adapted by me to 3ab3c9c2.
Reviewed by: jhibbits
Differential Revision: https://reviews.freebsd.org/D38735
According to the Linux sources the kernel exposes a proces virtual
memory size via proc filesystem into the three files - stat, status
and statm. This is the struct mm->total_vm value adjusted to the
corresponding units - bytes, kilobytes and pages.
The fix is based on a fernape@ analysis.
PR: 265937
Reported by: Ray Bellis
MFC after: 3 days
Netlink should translate a FreeBSD interface name to a Linux
interface name.
Reviewed by: melifaro
Differential Revision: https://reviews.freebsd.org/D38715
MFC after: 3 days
We have some amount of interface names translation functions which are
differs by bugs implementation. Consolidates it in a one place.
Fixup loopback interface names translation and use ifnet methods and
accessors, where possible.
Reviewed by: melifaro
Differential Revision: https://reviews.freebsd.org/D38714
MFC after: 3 days
X-MFC with: 32fdc75fe7
It's the same as `strscpy()` except that it fills the rest of the
destination buffer with zeroes if the source buffer is shorter.
Reviewed by: manu
Approved by: manu
The header is included in <linux/xarray.h> like it is on Linux. Some DRM
code depends on this header "pollution".
Reviewed by: bz
Approved by: bz
Differential Revision: https://reviews.freebsd.org/D38567
It gains new `struct ww_acquire_ctx *` argument we don't use currently.
Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38568
It takes the lock and release it immediately to make sure no shrinkers
are running in parallel.
Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38565
It returns `physmem`.
`__FreeBSD_version` is bumped to 1400080. We need that to remove a copy
of this function in the i915 DRM driver, maintained outside of base.
Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38531
Linux' XArray allows to store a NULL pointer as a value. `xa_load()`
would return NULL for both an unused index and an index set to NULL. But
it impacts `xa_alloc()` which needs to find the next available index.
However, our implementation relies on a radix tree (see `linux_radix.c`)
which does not accept NULL pointers as values. I'm not sure if this is a
limitation or a feature, so to work around this, a NULL value is
replaced by `NULL_VALUE`, an unlikely address, when we pass it to
linux_radix.
Reviewed by: emaste, manu
Approved by: emaste, manu
Differential Revision: https://reviews.freebsd.org/D38543
To avoid confusing people, rename linux_timer.h to linux_time.h,
as linux_timer.c is the implementation of timer syscalls only,
while linux_time.c contains implementation of all stuff declared
in linux_time.h.
MFC after: 2 weeks
MI linux.[c|h] are the module independent in terms of the Linux emulation
layer (ie, intended for both ISA - 32 & 64 bit), analogue of MD linux.h.
There must be a code here that cannot be placed into the corresponding by
common sense MI source and header files, i.e., code is machine independent,
but ISA dependent.
For the use_real_names knob, the code must be placed into the
linux_socket.[c|h], however linux_socket is ISA dependent.
MFC after: 2 weeks
This obsolete system call is not supported by glibc. In ancient libc
versions (before glibc 2.0), uselib() was used to load the shared
libraries with names found in an array of names in the binary.
On Linux, since 3.15, this system call is available only when
the kernel is configured with the CONFIG_USELIB option.
It doesn't look like anyone needs this syscall for others Linuxulators,
so move it to the corresponding MD Linuxulator.
MFC after: 2 weeks
Include sys/sysent.h directly where it needed. The linux_util.h included
in a most source files of the Linuxulator, avoid collecting a rarely used
includes here.
MFC after: 2 weeks
Include vm headers directly where they needed. The linux_util.h included
in a most source files of the Linuxulator, avoid collecting a rarely used
includes here.
MFC after: 2 weeks
`cpu_data(cpu)` evaluates to a `struct cpuinfo_x86` filled with
attributes of the given CPU number. The CPU number is an index in the
`__cpu_data[]` array with MAXCPU entries. On FreeBSD, we simply
initialize all of them like we do with `boot_cpu_data`.
While here, we add the `x86_model` field to the `struct cpuinfo_x86`. We
use `CPUID_TO_MODEL()` to set it.
At the same time, we fix the value of `x86` which should have been set
to the CPU family. It was using the same implementation as
`CPUID_TO_MODEL()` before. It now uses `CPUID_TO_FAMILY()`.
Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38542
`xa_is_err()` is synonymous to `IS_ERR()`.
Other introduced functions call their equivalent without the `irq*`
suffix.
Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38534
For `vga_client_register()`, the API is modified twice in a row. To keep
the API compatible with all commits in the DRM driver, we introduce two
`LINUXKPI_VERSION` version bumps.
Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38533
This is not used by the DRM driver yet because we comment out the code
calling them, but they are easy to implement.
Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38530
Following 5a9a0d7803 initialize the
queue values explicitly and deal with a stopped queue in
ieee80211_tx_dequeue().
Sponsored by: The FreeBSD Foundation
MFC after: 3 days
amdgpu's virtual display feature uses pci_name() to match a module parameter
string, and the documentation shows an example of `0000:26:00.0` for the name.
In our case the name was just `drmn`, which is not actually unique across
devices.
The other consumers are wireless drivers, which will benefit from this
change.
Generate the expected string for pci_name() to return.
Related to: https://github.com/freebsd/drm-kmod/issues/134
Sponsored by: https://www.patreon.com/valpackett
Reviewed by: bz, hselasky, manu (earlier)
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D34248
Following e9715b1c44 and
4b56afaf7b, implement support
for up-to 32 MSI vectors. This is used by wireless drivers.
This also switches msi_desc to an array in order to store
per-vector information.
Sponsored by: The FreeBSD Foundation
Discussed with: grehan (in Dec)
MFC after: 3 days
Reviewed by: jhb
Differential Revision: https://reviews.freebsd.org/D38222
irq_set_affinity_hint() takes a const mask argument and some drivers
pass it in as such where earlier implementations were more lenient.
Deal with it and __DECONST() the argument when passed to intr_setaffinity().
Sponsored by: The FreeBSD Foundation
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D38242
Add a dummy irq_set_status_flags() along with #defines passed by the driver.
Add disable_irq_nosync() as another wrapper to lkpi_disable_irq().
Those are used by wireless drivers.
Sponsored by: The FreeBSD Foundation
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D38241
Add a dummy implementation of pm_wakeup_event() which is used to notify
the power management system about a wakeup (which we currently do not
implement yet).
Sponsored by: The FreeBSD Foundation
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D38239
Add a dummy device_set_wakeup_enable() which is used for WoWLAN which we
do not (yet) support and device_wakeup_enable() which is a wrapper to the
former with the enable argument being true.
Sponsored by: The FreeBSD Foundation
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D38238
Add more empty header files wireless drivers try to include but
we do not (yet) need for any implementation.
Sponsored by: The FreeBSD Foundation
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D38271
Remove former dummy/ files which now have an actual implementation
in common/ .
Sponsored by: The FreeBSD Foundation
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D38269
Add a dummy pci_assign_resource() and an implementation of
pci_irq_vector() returning the irq for MSI-X, MSI, and legacy interrupt.
Both are needed by wirless drivers.
Sponsored by: The FreeBSD Foundation
MFC after: 3 days
Reviewed by: jhb
Differential Revision: https://reviews.freebsd.org/D38237
Summary:
Migrate linprocfs to use the IfAPI interfaces instead of direct ifnet
accesses.
Reviewed by: dchagin
Sponsored by: Juniper Networks, Inc.
Differential Revision: https://reviews.freebsd.org/D38358
COMPAT_LINUX32 option is defined for case when building 32-bit Linuxulator
for the 64-bit host. Usage of __ELF_WORD_SIZE is wrong here as it is equal to 32
on i386 too.
MFC after: 1 week
Add code (currently disabled by #ifdef) for HT and VHT to
lkpi_scan_ies_add(). Switch to a local variable for ic given
the new code also needs the value.
Sponsored by: The FreeBSD Foundation
MFC after: 3 days
This change breaks the API of `list_sort()`. `LINUXKPI_VERSION >= 51300`
is used to keep the header compatible with both versions of the
prototype.
Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38082
Implement ieee80211_is_pspoll() and move it up to the set of implemented
ieee80211_is_*() functions.
There are no further changes (git diff just looks weird).
Sponsored by: The FreeBSD Foundation
MFC after: 3 days
Very basic implementations of ieee80211_{wake,stop}_queue[s],
as well as ieee80211_txq_schedule_start(), ieee80211_next_txq(),
and ieee80211_schedule_txq().
Various combinations of these are used by different wireless
drivers, incl. iwlwifi.
Sponsored by: The FreeBSD Foundation (parts of this work)
MFC after: 3 days
Add an implementation of ieee80211_tx_status_ext() extending the
internal linuxkpi_ieee80211_tx_status() implementation.
Sponsored by: The FreeBSD Foundation
MFC after: 3 days
Extend linuxkpi_ieee80211_rx() by another argument for
the ieee80211_rx_list() implementation (even though the argument
is currently ignored).
Sponsored by: The FreeBSD Foundation
MFC after: 3 days
Correct struct member types, fix whitespace, and remove superfluous
return statements in void functions.
No functional changes.
Sponsored by: The FreeBSD Foundation
MFC after: 3 days
I'm sure I got it wrong but at least the DRM drivers compile.
Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38157
`io_mapping_map_local_wc()` is synonymous to `io_mapping_map_atomic_wc()`.
Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38156
They are synonymous to `kmap_atomic_prot()` and `kunmap_atomic()`
respectively.
While here, fix several style(9) issues.
Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38155
For now, it's empty. It is included by the DRM drivers but nothing is
missing otherwise. Perhaps something we already defined should be in
`pgtable.h` instead of another header.
Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38153
For now, it's empty. It is included by the DRM drivers but nothing is
missing otherwise. Perhaps something we already defined should be in
`limits.h` instead of another header.
Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38147
The struct layout is modified with this commit because new fields are
added in the middle, keeping original Linux order.
Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D37932
Rework the routines to convert a native statfs structure (with fixed-size 64-bit
counters) to a Linux statfs structure (with long-sized counters) for 32-bit apps.
Instead of following Linux and return an EOVERFLOW error from statfs() family of
syscalls when actual fs stat value(s) are large enough to not fit into 32 bits,
apply scale logics used by FreeBSD to convert a 5.x statfs structure to a 4.x
statfs structure.
For more details see cc479dda.
Tested by: glebius
MFC after: 1 week