Commit Graph

4711 Commits

Author SHA1 Message Date
Dmitry Chagin
7ae0972c7b linsysfs(4): Reimplement listnics() using ifAPI
Handle if arrival/departure events and VNETs.

Differential Revision:	https://reviews.freebsd.org/D38901
MFC after:		1 month
XMFC with:		ifAPI, pseudofs
2023-04-03 11:22:16 +03:00
Bjoern A. Zeeb
cfccc7f30a LinuxKPI: 802.11: remove extra spaces
Remove two extra spaces.  No functional change.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2023-04-02 22:25:28 +00:00
Emmanuel Vadot
4fd9e20671 linuxkpi: hdmi: Remove wrong dependency on wlan
Copy-paste mistake.

Reported by:	Alastair Hogge <agh@riseup.net>
Fixes:	f1d7ae31d4 ("linuxkpi: Add hdmi helpers")
2023-04-02 16:56:23 +02:00
Bjoern A. Zeeb
8ac540d3b8 LinuxKPI: 802.11: adjust locking
Split up the lhw lock and the scan lock.  The latter is a mtx
while the former changes from mtx to sx as mac80211 downcalls may
sleep (and the ic lock is not usable in that case either and a larger
project to fix).
This will also enforce some lookups under lock (mostly scan) as well
as general protection for more compat code and avoid a possible
deadlock with one of the upcoming callbacks from driver into the
compat code.

Sponsored by:	The FreeBSD Foundation
MFC after:	7 days
2023-03-31 19:59:50 +00:00
John Baldwin
ad83dd2b2b LinuxKPI: Appease -Wunused-but-set-variable warnings from GCC.
- Mark assert dummy variables as __unused.

- Use a dummy (void) cast of the flags argument passed to
  spin_unlock_irqrestore so it gets treated as used.

Reviewed by:	manu, hselasky
Differential Revision:	https://reviews.freebsd.org/D39349
2023-03-31 10:56:33 -07:00
Dmitry Chagin
f94b5734bc Revert "linsysfs(4): Reimplement listnics() using ifAPI"
This reverts commit 0b56641cfc.

As it poorly interacts with vnet subsystem
2023-03-31 14:54:33 +03:00
Bjoern A. Zeeb
3f0083c4e3 LinuxKPI: 802.11: use ic_printf more consistently
Rather than printing ic_name ourselves (or not at all) use ic_printf()
as a common function from net80211 where possible.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2023-03-31 07:14:32 +00:00
Emmanuel Vadot
51d07956cf linuxkpi: Add alderlake defines in intel-family
Needed by drm-kmod.

Sponsored by:	Beckhoff Automation GmbH & Co. KG
2023-03-28 10:57:13 +02:00
Emmanuel Vadot
aaf6129c9d linuxkpi: Add devm_add_action and devm_add_action_or_reset
Those adds a new devres and will exectute some function on release.

Reviewed by:	bz
Differential Revision:	https://reviews.freebsd.org/D39142
Sponsored by:	Beckhoff Automation GmbH & Co. KG
2023-03-28 09:19:05 +02:00
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