Commit Graph

4752 Commits

Author SHA1 Message Date
Emmanuel Vadot
f1d7ae31d4 linuxkpi: Add hdmi helpers
This is a direct port of the Linux code as the licence allows it, so
style(9) isn't respected to allow applying directly the upstream commits.
Do not add it to linuxkpi directly but add a new linuxkpi_hdmi module
that drm modules will require later, no need to bloat linuxkpi more.

Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D39122
2023-03-28 09:11:06 +02:00
Konstantin Belousov
6a0a634590 Regen 2023-03-28 02:39:26 +03:00
Alexander V. Chernikov
b894193501 netlink: fix linux module build w/ netlink.
Reported by:	Marek Zarychta <zarychtam@plan-b.pwste.edu.pl>
MFC after:	2 weeks
2023-03-27 18:21:26 +00:00
Vico Chen
1f0c8bfd65 linsysfs(4): Keep Linux compatible sysfs the same as Ubuntu
By checking Ubuntu, there is no `/sys/subsystem' in sysfs. To compatible
with Ubuntu, delete the 'subsystem' creation in Linux compatible module.

On the other hand, the sysfs `/sys/subsystem' cause failure for some
Linux udev cases. In Linux udev source code, there is a function named
`scan_devices_all', and it will scan `/sys/subsystem' if it is existed,
but now there are nothing in /sys/subsystem `, and it returns empty
to cause some use cases failed.

Reviewed by:		dchagin
Differential Revision:	https://reviews.freebsd.org/D38885
MFC after:		1 month
XMFC with:		ifAPI
2023-03-25 13:41:04 +03:00
Dmitry Chagin
0b56641cfc linsysfs(4): Reimplement listnics() using ifAPI
Handle if arrival/departure events.

Reviewed by:		melifaro (early version)
Differential Revision:	https://reviews.freebsd.org/D38901
MFC after:		1 month
XMFC with:		ifAPI
2023-03-25 13:40:41 +03:00
Bjoern A. Zeeb
59559d1354 LinuxKPI: remove now implemented dummy headers.
Both iommu.h and kconfig.h now exist in the common code.
There is no need for the duplicate (empty) headers anymore.
2023-03-23 01:15:53 +00:00
Jean-Sébastien Pédron
83df72e5fb
linuxkpi: Define pat_enabled()
This new <asm/memtype.h> header is included from <linux/pci.h> because
that's how it is included in Linux too. DRM drivers depend on this.

Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D39052
2023-03-21 23:36:40 +01:00
Jean-Sébastien Pédron
5fbfe9517b
linuxkpi: Define seq_has_overflowed() and single_open_size()
This required non-trivial changes to `linux_seq_file.c` to manage a new
`(struct seq_file)->size` field. This field is read directly by DRM
drivers, so we can't alias it to a call to sbuf_len(9).

`single_open_size()` also depended on the ability to allocate the sbuf
with a specified size instead of relying on `sbuf_new_auto()`.

Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D39056
2023-03-20 21:47:36 +01:00
Jean-Sébastien Pédron
1b4e08b483
linuxkpi: Support non-NULL zero-size pointers
DRM drivers set some pointers to `ZERO_SIZE_PTR` directly (without
allocating anything), to treat pointers which were "initialized" (set to
`ZERO_SIZE_PTR`) with no memory allocation like really allocated
pointers. NULL isn't used because it represents a third state.

Reviewed by:	emaste, manu
Approved by:	emaste, manu
Differential Revision:	https://reviews.freebsd.org/D39055
2023-03-20 21:47:36 +01:00
Jean-Sébastien Pédron
eef905a859
linuxkpi: Add <linux/iommu.h>
It defines a small part of the IOMMU API of Linux. We don't implement
that yet.

Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D39054
2023-03-20 21:47:36 +01:00
Jean-Sébastien Pédron
af19988f6c
linuxkpi: Define pcie_aspm_enabled()
This is not the same as querying the PCIE ASPM capability. The function
should return if the feature is actually enabled or not. It always
return false on FreeBSD.

Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D39053
2023-03-20 21:47:36 +01:00
Jean-Sébastien Pédron
19a355436e
linuxkpi: Add default_groups field to struct kobj_type
We don't use it, but it is set by the DRM drivers.

Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D39051
2023-03-20 21:47:35 +01:00
Jean-Sébastien Pédron
e91f5814b8
linuxkpi: Define device_iommu_mapped()
For now, it always return false.

Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D39050
2023-03-20 21:47:35 +01:00
Jean-Sébastien Pédron
0777b000f1
linuxkpi: Define dev_WARN() and dev_WARN_ONCE()
Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D39049
2023-03-20 21:47:28 +01:00
Justin Hibbits
56928500ec linux: Use the if_name() accessor to get loopback name
Avoid directly accessing the if_xname ifnet member. and use the
designated accessor function instead.

Sponsored by:	Juniper Networks, Inc.
2023-03-07 09:47:01 -05:00
Colin Percival
3689f8aeab linux_80211: Don't dequeue lsta if not queued
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
2023-03-05 12:16:22 -08:00
Dmitry Chagin
8243e17463 linux(4): Fixup 5c32488de0 mis-merge 2023-03-04 12:42:04 +03:00
Dmitry Chagin
5c32488de0 linux(4): Add a counterpart to linux_ifflags
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
2023-03-04 12:26:48 +03:00
Dmitry Chagin
945a7f0d21 linux(4): Assert that the FreeBSD size of struct sockaddr is equal to Linux
Our code depends on the fact that the size of struct sockaddr and
the size of sa_data is equal between FreeBSD and Linux.
2023-03-04 12:11:39 +03:00
Dmitry Chagin
9883961ed5 linux(4): Drop excess assert that Linux IFNAMSIZ is equal to FreeBSD
While here use _Static_assert() instead of the older CTASSERT().
2023-03-04 12:11:39 +03:00
Dmitry Chagin
d447088d99 linux(4): Improve linux_ifconf readability
Initialize max_len and full variables in a code block where
they are used.
2023-03-04 12:11:39 +03:00
Dmitry Chagin
96a8c6aa37 linux(4): Fixup of the pointer cast when comparing to an integer 2023-03-04 12:11:39 +03:00
Dmitry Chagin
8d6dd96d50 linux(4): Add net epoch assert to the linux_ifhwaddr, linux_ifflags
Now this functions are intended to use in the net epoch.

Reviewed by:		emaste, melifaro
Differential Revision:	https://reviews.freebsd.org/D38795
2023-03-04 12:11:38 +03:00
Dmitry Chagin
f9b0675b01 linux(4): Refactor socket ioctl path to avoid referencing an unstable interfaces
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
2023-03-04 12:11:38 +03:00
Dmitry Chagin
a927409ce8 linux(4): Rename struct l_ifreq members names to avoid conflicts with FreeBSD
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
2023-03-04 12:11:38 +03:00
Dmitry Chagin
cabbfb60d0 linux(4): Reduce code duplication between MD files
Move struct ifnet definitions under compat/linux.

Reviewed by:		emaste
Differential Revision:	https://reviews.freebsd.org/D38791
2023-03-04 12:11:38 +03:00
Dmitry Chagin
5d5b633dde linsysfs(4): Refactor to avoid referencing an unstable interfaces
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
2023-03-04 12:11:38 +03:00
Dmitry Chagin
130383f2f1 linux(4): Make linux_ifflags return a value
To simplify the use of the function in the printf-like statements.

Differential Revision:	https://reviews.freebsd.org/D38830
2023-03-04 12:11:38 +03:00
Dmitry Chagin
6c5786fd37 linux(4): Migrate to IfAPI
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
2023-03-04 12:11:38 +03:00
Dmitry Chagin
a55b5a9aed linprocfs(4): Fixup process size in the /proc/pid/stat file
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
2023-02-26 16:42:22 +03:00
Dmitry Chagin
e55e4a6ba3 linux(4): Fixup the interface name translation in netlink
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
2023-02-23 11:01:18 +03:00
Dmitry Chagin
3ab3c9c29c linux(4): Consolidate a FreeBSD interface names translation code
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
2023-02-23 11:00:29 +03:00
Dmitry Chagin
200fe6e3a0 linux(4): Use predefined constant instead of hardcoded value
Reviewed by:		melifaro
Differential Revision:	https://reviews.freebsd.org/D38713
MFC after:		3 days
2023-02-23 10:59:34 +03:00
Justin Hibbits
19850ee073 Revert "linprocfs: Migrate to IfAPI"
This reverts commit 5243598927.

Requested by:	dchagin
2023-02-21 18:17:26 -05:00
Justin Hibbits
e9e637bf24 Revert "Port Linuxulator to IfAPI"
Revert pending netlink fixes, and further fixes to this.

This reverts commit 52d984831d.

Requested by:	dchagin
2023-02-21 12:20:24 -05:00
Emmanuel Vadot
a0fdaf9a7b linuxkpi: Add more suspend defines
Needed by drm 5.15-lts

Sponsored by:	Beckhoff Automation GmbH & Co. KG
2023-02-17 14:50:58 +01:00
Jean-Sébastien Pédron
b1a9e570fe
linuxkpi: Add strscpy_pad() to <linux/string.h>
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
2023-02-15 23:19:41 +01:00
Jean-Sébastien Pédron
4dac88cd15
linuxkpi: Define debugfs_initialized()
It always return true on FreeBSD, at least for now, because all DRM
drivers using it depend on lindebugfs.

Reviewed by:	manu
Approved by:	manu
2023-02-15 23:19:41 +01:00
Jean-Sébastien Pédron
4b0552d5f4
linuxkpi: Move IS_ENABLED() and friends to <linux/kconfig.h>
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
2023-02-15 00:06:32 +01:00
Jean-Sébastien Pédron
96e16cf368
linuxkpi: Add <linux/cc_platform.h>
It defines the `cc_platform_has()` function.

Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D38596
2023-02-14 23:07:19 +01:00
Jean-Sébastien Pédron
e6f7fe74a9
linuxkpi: Update ww_mutex_trylock() API for Linux 5.16
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
2023-02-14 23:01:07 +01:00
Jean-Sébastien Pédron
7d03acf065
linuxkpi: Declare struct fwnode_handle in <linux/fwnode.h>
Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D38566
2023-02-14 23:01:06 +01:00
Jean-Sébastien Pédron
8363672729
linuxkpi: Add synchronize_shrinkers()
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
2023-02-14 23:01:06 +01:00
Jean-Sébastien Pédron
53da54b936
linuxkpi: Define totalram_pages()
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
2023-02-14 23:01:06 +01:00
Jean-Sébastien Pédron
3102ea3b15
linuxkpi: Accept NULL as a value in linux_xarray
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
2023-02-14 23:01:02 +01:00
Justin Hibbits
52d984831d Port Linuxulator to IfAPI
Reviewed by:	dchagin
Sponsored by:	Juniper Networks, Inc.
Differential Revision: https://reviews.freebsd.org/D38349
2023-02-14 10:28:44 -05:00
Dmitry Chagin
c8a79231a5 linux(4): Rename linux_timer.h to linux_time.h
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
2023-02-14 17:46:33 +03:00
Dmitry Chagin
d8e53d94fa linux(4): Cleanup includes under compat/linux
Cleanup unneeded includes, sort the rest according to style(9).
No functional changes.

MFC after:		2 weeks
2023-02-14 17:46:32 +03:00
Dmitry Chagin
e2028292e5 linux(4): Cleanup sys/sysctl.h from linux_misc.h
Leftover after c5156c77 (r374538).

MFC after:		2 weeks
2023-02-14 17:46:32 +03:00
Dmitry Chagin
77f66834b0 linux(4): Fix brackets of local include opt_inet6
MFC after:		2 weeks
2023-02-14 17:46:32 +03:00
Dmitry Chagin
32fdc75fe7 linux(4): Move use_real_names knob to the linux.c
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
2023-02-14 17:46:32 +03:00
Dmitry Chagin
acbbd5c039 linux(4): Cleanup sys/uio.h where linux_uitl.h is included
MFC after:		2 weeks
2023-02-14 17:46:31 +03:00
Dmitry Chagin
50c85a32d9 linux(4): Move uselib() to i386
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
2023-02-14 17:46:31 +03:00
Dmitry Chagin
86f9efef2c linux(4): Cleanup abi_compat.h include from linux_timer.h
Leftover after timespec copyin/copyout routines was implemented.

MFC after:		2 weeks
2023-02-14 17:46:31 +03:00
Dmitry Chagin
007986714c linux(4): Cleanup sys/queue.h from linux.h
Leftover after converting futexes to the umtx API.

NFC after:		2 weeks
2023-02-14 17:46:31 +03:00
Dmitry Chagin
513eb69edf linux(4): Cleanup sys/sysent.h from linux_util
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
2023-02-14 17:46:31 +03:00
Dmitry Chagin
31e938c531 linux(4): Cleanup vm includes from linux_util.h
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
2023-02-14 17:46:30 +03:00
Dmitry Chagin
81e7a80055 linux(4): Cleanup unneeded includes from linux_util.h
MFC after:		2 weeks
2023-02-14 17:46:30 +03:00
Jean-Sébastien Pédron
a27902c183
linuxkpi: Define cpu_data(cpu)
`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
2023-02-13 22:09:32 +01:00
Jean-Sébastien Pédron
f3490083b7
linuxkpi: Add sg_alloc_table_from_pages_segment()
Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D38541
2023-02-13 22:09:32 +01:00
Jean-Sébastien Pédron
d91cf06020
linuxkpi: Add <linux/stdarg.h> + include it from <linux/string.h>
The <stdarg.h> header was moved in Linux 5.15.

Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D38540
2023-02-13 22:09:32 +01:00
Jean-Sébastien Pédron
210e756d4b
linuxkpi: Define IRQ_NOTCONNECTED
Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D38539
2023-02-13 22:09:32 +01:00
Jean-Sébastien Pédron
b82bcfb66f
linuxkpi: Define lockdep_assert{,_once}()
Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D38538
2023-02-13 22:09:32 +01:00
Jean-Sébastien Pédron
54606590df
linuxkpi: Move definition of struct list_head to <linux/types.h>
This is the case on Linux.

Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D38537
2023-02-13 22:09:31 +01:00
Jean-Sébastien Pédron
bf6f665081
linuxkpi: Define FIELD_FIT()
Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D38536
2023-02-13 22:09:31 +01:00
Jean-Sébastien Pédron
83276e1f95
linuxkpi: Add i2c_adapter_quirks support
While here, also declare `I2C_CLASS_HWMON`.

Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D38535
2023-02-13 22:09:31 +01:00
Jean-Sébastien Pédron
5542309ec6
linuxkpi: Define xa_is_err(), xa_{store,erase}_irq() and xa_{,un}lock_irq*()
`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
2023-02-13 22:09:31 +01:00
Jean-Sébastien Pédron
1c6d8146fd
linuxkpi: Update vga_client_register() and add vga_client_unregister()
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
2023-02-13 22:09:31 +01:00
Jean-Sébastien Pédron
cf54169086
linuxkpi: Declare missing DMI_* enum entries
Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D38532
2023-02-13 22:09:30 +01:00
Jean-Sébastien Pédron
a82a8a5e19
linuxkpi: Define backlight_get_brightness() and backlight_is_blank()
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
2023-02-13 22:09:26 +01:00
Dmitry Chagin
10d16789a3 linux(4): Get rid of the opt_compat.h include.
Since e013e369 COMPAT_LINUX, COMPAT_LINUX32 build options are removed,
so include of opt_compat.h is no more needed.

MFC after:		2 weeks
2023-02-12 20:24:32 +03:00
Bjoern A. Zeeb
0cbcfa1964 LinuxKPI: 802.11: deal with stopped queues
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
2023-02-07 20:20:33 +00:00
Val Packett
393b0ba25f LinuxKPI: return an address string in pci_name()
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
2023-02-06 21:56:39 +00:00
Bjoern A. Zeeb
b15491b477 LinuxKPI: PCI: implement support for more than 1 MSI vector
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
2023-02-05 20:49:06 +00:00
Bjoern A. Zeeb
4c72d075a5 LinuxKPI: const argument to irq_set_affinity_hint()
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
2023-02-05 20:46:59 +00:00
Bjoern A. Zeeb
bc81a2b788 LinuxKPI: interrupt.h: add disable_irq_nosync(), irq_set_status_flags()
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
2023-02-05 20:45:28 +00:00
Bjoern A. Zeeb
934cb7a331 LinuxKPI: pm.h: add dummy pm_wakeup_event()
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
2023-02-05 20:43:46 +00:00
Bjoern A. Zeeb
ffdf10fb9c LinuxKPI: device: add device_set_wakeup_enable()
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
2023-02-05 20:36:54 +00:00
Bjoern A. Zeeb
52c28b9903 LinuxKPI: add more dummy header files
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
2023-02-05 20:34:57 +00:00
Bjoern A. Zeeb
78cab57ac6 LinuxKPI: dummy: remove files which have implementation
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
2023-02-05 20:33:30 +00:00
Bjoern A. Zeeb
fd1a2f3dfc LinuxKPI: pci: add more functions
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
2023-02-05 20:31:40 +00:00
Bjoern A. Zeeb
70b97048a0 LinuxKPI: mm.h: implement virt_to_head_page()
Implement virt_to_head_page().

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Reviewed by:	markj
Differential Revision: https://reviews.freebsd.org/D38240
2023-02-05 20:29:56 +00:00
Dmitry Chagin
edfc7d6e5b linux(4): Add the forgotten in the 6f8439db opt_compat include.
MFC after:		1 week
2023-02-05 18:25:10 +03:00
Dmitry Chagin
eb08932156 linux(4): Microoptimize linux_ipc code to unindent else blocks.
No functional change.

MFC after:		1 week
2023-02-03 19:17:34 +03:00
Dmitry Chagin
3e0c56a717 linux(4): Use designated initializers.
MFC after:		1 week
2023-02-03 19:17:15 +03:00
Justin Hibbits
c50f70b5a9 linsysfs: Use IfAPI accessors
Replace the only two ifnet member accesses with IfAPI accessor calls.

Sponsored by:	Juniper Networks, Inc.
2023-02-03 09:38:03 -05:00
Justin Hibbits
5243598927 linprocfs: Migrate to IfAPI
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
2023-02-03 09:38:03 -05:00
Dmitry Chagin
95b8603427 linux(4): Deduplicate linux_trans_osrel().
MFC after:		1 week
2023-02-02 17:58:07 +03:00
Dmitry Chagin
6039e966ff linux(4): Deduplicate linux_copyout_strings().
It is still present in the 32-bit Linuxulator on amd64.

MFC after:		1 week
2023-02-02 17:58:07 +03:00
Dmitry Chagin
6f8439db24 linux(4): Use COMPAT_LINUX32 enstead of __ELF_WORD_SIZE.
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
2023-02-02 17:58:06 +03:00
Dmitry Chagin
7446514533 linux(4): Microoptimize linux_elf.h for future use.
In order to reduce code duplication move coredump support definitions
into the appropriate header and hide private definitions.

MFC after:		1 week
2023-02-02 17:58:06 +03:00
Dmitry Chagin
575e48f1c4 linux(4): Deduplicate MI futex structures.
MFC after:	1 week
2023-02-01 21:57:04 +03:00
Bjoern A. Zeeb
b0ddb44fd4 LinuxKPI: 802.11: fix indent in lkpi_wake_tx_queues()
Fix indentation in lkpi_wake_tx_queues().
No functional changes.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2023-01-31 23:12:30 +00:00
Bjoern A. Zeeb
3dd980267f LinuxKPI: 802.11: enhance lkpi_scan_ies_add() for HT and VHT
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
2023-01-31 23:00:28 +00:00
Jean-Sébastien Pédron
a83b3ec719
linuxkpi: list_sort()'s callback now takes list arguments
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
2023-01-31 23:36:33 +01:00
Bjoern A. Zeeb
2336248a8b LinuxKPI: 802.11: fix ff76cbc81d (pspoll)
Add the lost "inline".

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
X-MFC with:	ff76cbc81d
2023-01-31 16:41:41 +00:00
Bjoern A. Zeeb
ff76cbc81d LinuxKPI: 802.11: implement ieee80211_is_pspoll()
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
2023-01-31 16:36:24 +00:00
Bjoern A. Zeeb
5a9a0d7803 LinuxKPI: 802.11: basic implementation of *queue(s)/*txq*
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
2023-01-31 16:17:14 +00:00
Bjoern A. Zeeb
a839757109 LinuxKPI: 802.11: implement ieee80211_tx_status_ext()
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
2023-01-31 15:35:59 +00:00
Bjoern A. Zeeb
e30e05d3ab LinuxKPI: 802.11: extend linuxkpi_ieee80211_rx()
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
2023-01-31 15:05:30 +00:00