Commit Graph

4752 Commits

Author SHA1 Message Date
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
Bjoern A. Zeeb
a3baca22d0 LinuxKPI: 802.11: fix types and whitespace
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
2023-01-31 13:39:04 +00:00
Jean-Sébastien Pédron
b9ef068943
linuxkpi: Define dev_is_platform() and to_platform_device()
The former returns false and the latter returns NULL.

Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D38163
2023-01-30 23:10:03 +01:00
Jean-Sébastien Pédron
11aaefc9ca
linuxkpi: Try to solve headers dependencies
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
2023-01-30 23:09:52 +01:00
Jean-Sébastien Pédron
29d0c85c86
linuxkpi: Add io_mapping_map_local_wc() and io_mapping_unmap_local()
`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
2023-01-30 23:09:38 +01:00
Jean-Sébastien Pédron
9dafbd0c69
linuxkpi: Add kmap_local_page_prot() and kunmap_local()
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
2023-01-30 23:09:22 +01:00
Jean-Sébastien Pédron
7649b89cc1
linuxkpi: Add <linux/pgtable.h>
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
2023-01-30 23:09:13 +01:00
Jean-Sébastien Pédron
25faccaaca
linuxkpi: Add <linux/limits.h>
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
2023-01-30 23:08:59 +01:00
Jean-Sébastien Pédron
19be627cfd
linuxkpi: Define might_alloc()
... as a no-op.

Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D38146
2023-01-30 23:08:45 +01:00
Jean-Sébastien Pédron
e400b69599
linuxkpi: Add freeram and freehigh to struct sysinfo
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
2023-01-30 23:08:32 +01:00
Bjoern A. Zeeb
dbbf46ebba LinuxKPI: skbuff: implement skb_free_frag()
Using the work from 55038a6306 implement
skb_free_frag() calling page_frag_free().

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2023-01-28 15:33:12 +00:00
Dmitry Chagin
9922bccbc9 linux(4): Convert mount exported flags for statfs system calls.
MFC after:		1 week
2023-01-28 13:20:27 +03:00
Dmitry Chagin
953688e823 linux(4): Rework statfs conversion routine.
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
2023-01-28 13:19:41 +03:00
John Baldwin
4d77927e2a linuxkpi: Use a proper declaration for pm_suspend_via_firmware.
Reported by:	GCC -Wstrict-prototypes
2023-01-27 19:41:35 -08:00
Jean-Sébastien Pédron
3d751b7a71
linuxkpi: Add pin_user_pages*() functions
They were defined in the i915 DRM driver. I move the code in linuxkpi so
it can benefit other drivers.

Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D38078
2023-01-27 21:54:39 +01:00
Jean-Sébastien Pédron
3e0856b63f
linuxkpi: Fix sg_alloc_table_from_pages() to have the same API as Linux
It now returns a `struct scatterlist *` pointer instead of an error
code only.

The implementation is incomplete because it doesn't use the `prv`
argument.

Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D38077
2023-01-27 21:53:59 +01:00
Jean-Sébastien Pédron
8c46bd9f86
linuxkpi: Include linux/sched/mm.h from linux/sched.h
At least one file in the DRM drivers benefits from some namespace
pollution to use `fs_reclaim_acquire()`/`fs_reclaim_release()`. They are
defined in `linux/sched/mm.h` and this header must be included
indirectly into the DRM drivers' source file.

I couldn't find how it was included. Therefore this commit includes
`linux/sched/mm.h` from `linux/sched.h`. This is not the case in Linux
but fixes the issue with the DRM drivers.

Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D37912
2023-01-27 21:53:44 +01:00
Bjoern A. Zeeb
68b1d16250 LinuxKPI: linux_pci.c: fix whitespace
Properly indent a line.  No functional change.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2023-01-27 15:27:42 +00:00
Bjoern A. Zeeb
0d0ca120a7 LinuxKPI: pci.h move function declaration to top of file.
No functional changes.

X-MFC-with:	49b6d5ed14
Sponsored by:	The FreeBSD Foundation
2023-01-26 14:33:31 +00:00
Jean-Sébastien Pédron
a04aa80e77
lindebugfs: Add debugfs_create_file_size()
This is the same as `debugfs_create_file()` but takes the initial size
of the file. In FreeBSD, the given size is ignored and
`debugfs_create_file()` is called.

Reviewed by:	emaste, manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D37914
2023-01-25 23:23:16 +01:00
Jean-Sébastien Pédron
66cc55a041
linuxkpi: Define PCI_STD_NUM_BARS in <linux/pci.h>
Reviewed by:	emaste, manu
Approved by:	emaste, manu
Differential Revision:	https://reviews.freebsd.org/D38162
2023-01-25 22:57:32 +01:00
Jean-Sébastien Pédron
ccd31b4645
linuxkpi: Define pm_suspend_target_state in <linux/suspend.h>
It is set to `PM_SUSPEND_ON`.

Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D38161
2023-01-25 22:57:21 +01:00
Jean-Sébastien Pédron
4152ce2139
linuxkpi: Add msix_cap to struct pci_dev
At the same time, define `PCI_MSIX_FLAGS`and `PCI_MSIX_FLAGS_ENABLE`.

Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D38160
2023-01-25 22:57:08 +01:00
Jean-Sébastien Pédron
e64afbc215
linuxkpi: Add sysfs_emit_at() in <linux/sysfs.h>
Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D38159
2023-01-25 22:56:56 +01:00
Jean-Sébastien Pédron
47877d61af
linuxkpi: Define is_cow_mapping(flags) as false
Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D38158
2023-01-25 22:56:40 +01:00
Jean-Sébastien Pédron
3d47e3bf7b
linuxkpi: Include <linux/vmalloc.h> from <linux/pagemap.h>
I'm not sure this is correct, but it gives access to the definition of
`PAGE_KERNEL` in `ttm_tt.c` in the DRM drivers.

Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D38154
2023-01-25 22:50:52 +01:00
Jean-Sébastien Pédron
b34cd67243
linuxkpi: Add seqcount_ww_mutex_t in <linux/seqlock.h>
It is defined as a synonymous to `seqcount_mutex_t`.

Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D38152
2023-01-25 22:50:38 +01:00
Jean-Sébastien Pédron
d9f1cb6774
linuxkpi: Define DEFINE_WD_CLASS(name) in <linux/ww_mutex.h>
It is defined as a synonymous to `DEFINE_WW_CLASS(name)`.

Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D38151
2023-01-25 22:50:27 +01:00
Jean-Sébastien Pédron
04cbeeb597
linuxkpi: Adds more SZ_* macros
`SZ_2K` and `SZ_1G` were defined in irdma. They are removed from this
driver.

Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D38150
2023-01-25 22:50:07 +01:00
Jean-Sébastien Pédron
f27b1399d6
linuxkpi: Define ENOKEY to 126.
This is the same error code as Linux. This value is unused on FreeBSD.

Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D38149
2023-01-25 22:49:53 +01:00
Jean-Sébastien Pédron
49b6d5ed14
linuxkpi: Add pci_device_is_present()
This calls bus_child_present(9) internally.

Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D38148
2023-01-25 22:49:38 +01:00
Jean-Sébastien Pédron
bbff0400c1
linuxkpi: Define dev_dbg_ratelimited()
Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D38145
2023-01-25 22:48:32 +01:00
Jean-Sébastien Pédron
9491ea7c68
linuxkpi: Fix atomic_long_sub() overflow
By (ab)using `atomic_long_add_return()`, `atomic_long_sub()` was making
the atomic long overflow. Indeed the underlying FreeBSD atomic is based
on an unsigned long.

Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D38090
2023-01-25 22:26:54 +01:00
Jean-Sébastien Pédron
b99bc86232
linuxkpi: Add io_mapping_map_user() and remap_pfn_range()
The code comes from the i915 DRM driver.

In Linux commits b739f125e4ebd73d10ed30a856574e13649119ed and
b12d691ea5e01db42ccf3b4207e57cb3ce7cfe91 (Linux 5.13), the i915 DRM
driver dropped specific implementations to use Linux generic functions.
Therefore I moved the FreeBSD code from that i915 driver to linuxkpi.

However, these commits were later reverted (also in Linux 5.13) so the
i915 driver doesn't use these functions. But perhaps it will help in the
future.

To sum up, the code comes from the i915 DRM driver but it doesn't use it
(i.e. it continues to use its internal implementation).

Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D38088
2023-01-25 22:26:54 +01:00
Jean-Sébastien Pédron
4fee6659c4
linuxkpi: Add sysfs_emit()
Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D38086
2023-01-25 22:26:54 +01:00
Jean-Sébastien Pédron
0d4d9ee6f0
linuxkpi: Add complete field to struct dev_pm_ops
This change breaks the KBI.

Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D38085
2023-01-25 22:26:54 +01:00
Jean-Sébastien Pédron
270a133480
linuxkpi: Add pm_suspend_via_firmware()
Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D38084
2023-01-25 22:26:53 +01:00
Jean-Sébastien Pédron
710c6084d1
linuxkpi: Add pm_runtime_suspended()
Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D38083
2023-01-25 22:26:53 +01:00
Jean-Sébastien Pédron
2272ccaa68
linuxkpi: Define tasklet_unlock_spin_wait() as tasklet_unlock_wait()
Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D38080
2023-01-25 22:26:53 +01:00
Jean-Sébastien Pédron
a609ed7959
linuxkpi: Define synchronize_hardirq()
It currently does the same as `synchronize_irq()`.

Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D38079
2023-01-25 22:26:53 +01:00
Jean-Sébastien Pédron
976aa07a88
lindebugfs: Add missing debugfs_create_u*() and debugfs_create_x*()
The `debugfs_create_x*()` variants are the same as their
`debugfs_create_u*()` equivalent, but they work with lowercase
hexadecimal.

While here, fix a few style(9) issues.

Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D38087
2023-01-25 22:26:52 +01:00
Jean-Sébastien Pédron
f2044a3030
lindebugfs: Add debugfs_create_atomic_t()
Reviewed by:	jfree
Approved by:	jfree
Differential Revision:	https://reviews.freebsd.org/D37915
2023-01-25 22:26:32 +01:00
Jean-Sébastien Pédron
bb651c77f5
linuxkpi: Define hrtimer_try_to_cancel()
It is the same as callout_stop(9) but the return values are different.

Reviewed by:	hselasky
Approved by:	hselasky
Differential Revision:	https://reviews.freebsd.org/D38081
2023-01-18 23:02:24 +01:00
Jean-Sébastien Pédron
e8ce32bea3
linuxkpi: Define EBADSLT to 57
This is the same error code as Linux.

As emaste@ noted in the review, FreeBSD defines the following errno
values in `sys/errno.h`:
* 56 is `EISCONN`
* 57 is `ENOTCONN`

Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D37935
2023-01-16 19:27:21 +01:00
Jean-Sébastien Pédron
cf8f392260
linuxkpi: Add memalloc_noreclaim_save() and memalloc_noreclaim_restore()
They are no-ops.

Reviewed by:	emaste, manu
Approved by:	emaste, manu
Differential Revision:	https://reviews.freebsd.org/D37933
2023-01-16 19:27:16 +01:00
Jean-Sébastien Pédron
ed53e350d7
linuxkpi: Define ioremap_cache()
It uses the `VM_MEMATTR_WRITE_BACK` flag on FreeBSD.

It replaces `ioremap_wb()` which doesn't exist in Linux. Perhaps it
existed in the past and was removed.

Reviewed by:	emaste, manu
Approved by:	emaste, manu
Differential Revision:	https://reviews.freebsd.org/D37916
2023-01-16 19:11:58 +01:00
Jean-Sébastien Pédron
3aa335d00a
linuxkpi: Add gfp_mask field to struct shrink_control
bz@ asked if the KBI breakage is a concern here. My answer was that this
is the first time in the DRM drivers in Linux 5.13 (the version I'm
working on) that this structure is initialized (as a variable local to
the function in this case), so it shouldn't be a problem for the DRM
drivers.

However, I can't speak for other drivers maintained outside of the src
tree.

Reviewed by:	emaste, manu
Approved by:	emaste, manu
Differential Revision:	https://reviews.freebsd.org/D37913
2023-01-16 19:11:58 +01:00
Jean-Sébastien Pédron
c0c1c599c0
linuxkpi: Define GFP_NOFS in linux/gfp.h
Reviewed by:	emaste, manu
Approved by:	emaste, manu
Differential Revision:	https://reviews.freebsd.org/D37910
2023-01-16 19:11:52 +01:00
Bjoern A. Zeeb
4b56afaf7b LinuxKPI: implement irq_get_msi_desc()
Add irq_get_msi_desc() as a wrapper around a PCI function which will
allocate a single cached value (see comment on struct) for the
msi_desc requested if it doesn't exist yet and handle freeing it
when the PCI device goes away.  We take the values from the ivars of
the native (FreeBSD) device.

While changing struct pci_dev also add the msi_cap field requested by
a wireless driver.

Bump __FreeBSD_version so these changes can be detected.

MFC after:	3 days
X-MFC: move fields to end of struct (alloc happens in linux_pci.c)
Reviewed by:	hselasky (earlier version)
Differential Revision: https://reviews.freebsd.org/D37523
2023-01-13 00:43:23 +00:00
Bjoern A. Zeeb
8f61992d7c LinuxKPI: pci: add [linuxkpi_]pci_get_device()
Add a version of pci_get_device() as linuxkpi_pci_get_device()
not (yet) supporting the last argument.
Due to conflicts we cannot redefine it as we would normally do
in LinuxKPI so drivers have to be adjusted.

MFC after:	3 days
Differential Revision: https://reviews.freebsd.org/D37593
2023-01-13 00:40:57 +00:00
Bjoern A. Zeeb
e9715b1c44 LinuxKPI: fix pci_alloc_irq_vectors() for MSI
pci_alloc_irq_vectors() is given a min and max vector value.
pci_enable_msi() will always succeed independent of these arguments as
it does not know about them.  Further it will only ever allocate
1 "vector" not supporting any other amount.
So upfront check that (a) the available pci_msi_count() can satisfy the
requested minv and (b) given the pci_enable_msi() hard coded limit check
that minv is not larger than 1.
If we cannot satisfy either requirement return an error.

This fixes problems with drivers which check that the returned value
of allocated "vectors" will match their requests and only otherwise try
to fall back to ask for 1 or deal otherwise.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Reviewed by:	hselasky (earlier version)
Differential Revision: https://reviews.freebsd.org/D37522
2023-01-13 00:39:24 +00:00
Bjoern A. Zeeb
75388b9ca5 LinuxKPI: add (skeleton) functions to make drivers compile
Add more functions to netdevice.h (netif_napi_add_tx() being the only
one implemented) and add platform_device.h and netlink.h in order to
make driver code compile.
The skeleton functions are used only in very limited scope and not at
all in our usage so far but add (invasive) #ifdef if removed.
Add pr_debug() calls to each of them in order to log a TODO (if DEBUG
compiled in) and someone should hit them in the future.

MFC after:	3 days
Commented on by: hselasky (earlier version)
Differential Revision: https://reviews.freebsd.org/D37599
2023-01-13 00:38:11 +00:00
Bjoern A. Zeeb
f82cf28b31 LinuxKPI: add kstrtou32_from_user() and mac_pton()
While here:
- fix an argument of kstrtouint_from_user() to correct signedness.
- make kstrtou32() call kstrtouint() to avoid duplication (keep inline
  function)

Add kstrtou32_from_user() based on other examples in the file
making it a copy of the now fixed kstrtouint_from_user().

Also add a rudimentarily hacked up version of mac_pton() which is
leanient accepting non-well-formed input but so far only with ':'
separators.  It does not seem to obviously belong to any networking
header file so add it here.

Both new functions are needed for debugfs support for iwlwifi hence
coming together in one commit.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Commented on by:	emaste
Differential Revision: https://reviews.freebsd.org/D37088
2023-01-13 00:34:32 +00:00
Bjoern A. Zeeb
51e94a4658 LinuxKPI: fix possible NULL dereference in linuxkpi_page_frag_alloc()
Fix a possible NULL pointer deref in case alloc_pages() fails.
This is theoretical so far as up to now no code in the tree uses
linuxkpi_page_frag_alloc().

Reported by:	Coverity via emaste
Coverity ID:	1502345
Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
X-MFC-with:	55038a6306
2023-01-11 23:40:05 +00:00
Val Packett
0b4531511e copyright: chase my name and email change
Reviewed by:	imp, emaste
Differential Revision:	https://reviews.freebsd.org/D37945
2023-01-06 15:28:42 -05:00
Jean-Sébastien Pédron
17f2b12a38
linuxkpi: Define lockdep_assert_none_held_once()
This is defined as a no-op even when INVARIANTS is defined. I admit I
don't know how to implement that in FreeBSD and didn't search
thoroughly.

Reviewed by:	bz
Approved by:	bz
Differential Revision:	https://reviews.freebsd.org/D37911
2023-01-02 22:07:31 +01:00
Jean-Sébastien Pédron
8dfb5571c4
linuxkpi: Include errno.h from acpi/video.h
This defines `ENODEV` used in this header. This fixes a build failure in
the DRM drivers.

Reviewed by:	bz
Approved by:	bz
Differential Revision:	https://reviews.freebsd.org/D37909
2023-01-02 22:05:27 +01:00
Bjoern A. Zeeb
4052b0e4b2 LinuxKPI: pm.h add pm_sleep_ptr and DEFINE_SIMPLE_DEV_PM_OPS
Extend pm.h by pm_sleep_ptr and DEFINE_SIMPLE_DEV_PM_OPS().
For the moment this duplicates some parts (as can be seen in the earlier
review I tried to simplify bits but given our implementation this
was easier in the end).

While here and cleanup the SIMPLE_DEV_PM_OPS() bits (white-space only).

MFC after:	3 days
Reviewed by:	hselasky
Differential Revision: https://reviews.freebsd.org/D37527
2022-12-31 02:51:09 +00:00
Bjoern A. Zeeb
55038a6306 LinuxKPI: add simplified vesion of page_frag_cache
For the moment and the currently only consumer (mt76) add a simplified
version of the page_frag_cache.  We will only accept fragement sizes up
to 1 PAGE_SIZE (KASSERT) and we will always return a full page.
Should we add more consumers or small (or large) objects would become a
problem we can always add a more elaborate version.

Discussed with:	markj
Reviewed by:	markj (,hselasky commented as well)
MFC after:	3 days
Differential Revision: https://reviews.freebsd.org/D37595
2022-12-31 02:45:44 +00:00
Bjoern A. Zeeb
4b0af11437 LinuxKPI: 802.11: move ieee80211_{unregister,restart}_hw out of header
Migrate the two functions from the header into the implementation file
in order to have access to more facilities and not to run into possible
allocation/locking/... problems in the future.

Sponsored by:	The FreeBSD Foundation
MFC after:	10 days
2022-12-31 02:24:23 +00:00
Bjoern A. Zeeb
c990500bf1 LinuxKPI; 802.11: update mac80211.h structures and fields
Cleanup some fields and structures and add new ones.

Sponsored by:	The FreeBSD Foundation
MFC after:	10 days
2022-12-31 02:15:28 +00:00
Bjoern A. Zeeb
3391199496 LinuxKPI: 802.11: implement ieee80211_get_hdrlen_from_skb()
Implement ieee80211_get_hdrlen_from_skb() doing basic sanity checks
on lengths (minimal length or skb data length vs. header length).

Sponsored by:	The FreeBSD Foundation
MFC after:	10 days
2022-12-31 02:02:01 +00:00
Bjoern A. Zeeb
13d87d92e4 LinuxKPI: 802.11: implement cfg80211_get_ies_channel_number()
Using the previous changes implement cfg80211_get_ies_channel_number()
either based on DSPARMS (or for the future HTINFO).

Sponsored by:	The FreeBSD Foundation
MFC after:	10 days
2022-12-31 01:59:20 +00:00
Bjoern A. Zeeb
5db817d864 LinuxKPI: 802.11: implement some *eleme/ie* lookup functions
Implement cfg80211_find_elem(), ieee80211_bss_get_elem(),
ieee80211_bss_get_ie(), and cfg80211_find_vendor_ie() with the last
one having a short cut always also checking oui_type in the pattern.

Sponsored by:	The FreeBSD Foundation
MFC after:	10 days
2022-12-31 01:33:28 +00:00
Bjoern A. Zeeb
5edde07c2a LinuxKPI: 802.11: implement cfg80211_{get,put}_bss
Implement cfg80211_{get,put}_bss currently doing malloc/free bits,
so hopefully the drivers get the calls right.

cfg80211_get_bss() sets up a lookup structure which may also take a
result (first hit wins) and calls ieee80211_scan_iterate() comparing
the various values in the iterator funcion.  Some of the checks are
partially pointless (as it seems the drivers are not interested in
these parts [ANY] but we keep them for documentation purposes should
futher values arise in the future).

We currently only iterate over the first VAP which will do for now.

Sponsored by:	The FreeBSD Foundation
MFC after:	10 days
2022-12-31 01:18:16 +00:00
Bjoern A. Zeeb
b6b352e4c7 LinuxKPI: 802.11: set sta supported legacy rates
When initializing the sta set the per-band supported legacy rates
as some drivers take the information from there.

Sponsored by:	The FreeBSD Foundation
MFC after:	10 days
2022-12-31 00:33:34 +00:00
Vladimir Kondratyev
68f08e26e2 LinuxKPI: linux/seqlock.h: Fix write_seqcount_(begin|end)
in seqcount_mutex_t case with removal of extraneous mutex lock/unlock
calls and addition of missing critical section.
While here strip one inline wrap layer to reduce code size.

Fixes startup lockup of i915kms after update to drm-kmod v5.12

Reviewed by:	hselasky, bz
MFC after:	1week
Differential Revision:	https://reviews.freebsd.org/D37699
2022-12-24 12:01:20 +03:00
Konstantin Belousov
140ceb5d95 ptrace(2): add PT_SC_REMOTE remote syscall request
Reviewed by:	markj
Discussed with:	jhb
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D37590
2022-12-22 23:11:35 +02:00
Konstantin Belousov
f081a291a1 compat32: move struct ptrace_sc_ret32 definition from .c to .h
Reviewed by:	markj
Sponsoreed by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D37590
2022-12-22 23:11:35 +02:00
Emmanuel Vadot
ccd8c4488a linuxkpi: seq_read: Fix off by one error
strscpy needs the buffer length not the string length (so including
the '\0').

Reviewed by:	bz
Fixes:	f697b9432d ("linuxkpi: drm-kmod debugfs support")
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D37771
2022-12-21 21:11:31 +01:00
Mateusz Guzik
e6bc24b038 kref: switch internal type to atomic_t and bring back const to kref_read
This unbreak drm-kmod build.

the const is part of Linux API

Unfortunately drm-kmod uses hand-rolled refcount* calls on a kref
object. For now go the easy route of keeping it operational by casting
stuff internally.

The general goal here is to make FreeBSD refcount API use an opaque
type, hence the ongoing removal of hand-rolled accesses.

Reported by:	emaste
2022-12-13 20:46:58 +00:00
Mateusz Guzik
67e628b7a6 kref: replace hand-rolled atomic ops with refcount API
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D37608
2022-12-13 09:24:57 +00:00
Emmanuel Vadot
72621b543e linuxkpi: Fix style for dma_map_sgtable
Reported by:	bz
Sponsored by:	Beckhoff Automation GmbH & Co. KG
2022-12-06 16:52:16 +01:00
Austin Shafer
4085bde9fa linuxkpi: Fix return value of dma_map_sgtable
dma_map_sgtable internally uses the dma_map_sg_attrs helper. The problem is
that dma_map_sg_attrs returns the number of entries mapped, whereas
dma_map_sgtable returns nonzero on failure. This leads to dma_map_sgtable
returning non-zero-but-positive values which tricks other areas of the stack
into thinking nents is a valid pointer.

This checks if nents is valid and returns zero if so, updating the nents field
in sgt. This fixes PRIME render offload with nvidia-drm.

Fixes:	9202c95f47 ("linuxkpi: Add dma_{un,}map_sgtable")
2022-12-06 16:25:53 +01:00
Jean-Sébastien Pédron
e101c1c2c9 linuxkpi: Introduce module_param() of type bint
In Linux, this limits the accepted value to -1, 0 and 1.
In FreeBSD, this remains a signed integer with no specific constraints.

This change is a requirement to update our DRM drivers to Linux 5.12.

Differential Revision:	https://reviews.freebsd.org/D37364
2022-12-01 15:03:00 +01:00
Jean-Sébastien Pédron
0adc02a979 linuxkpi: Add PCIE_SPEED_{32,64}_0GT PCI-E bus speed constants
This change is a requirement to update our DRM drivers to Linux 5.12.

Differential Revision:	https://reviews.freebsd.org/D37363
2022-12-01 15:02:27 +01:00
Jean-Sébastien Pédron
e79a57d4ec linuxkpi: Add cmpxchg64() in <asm/atomic.h>
Differential Revision:	https://reviews.freebsd.org/D36966
2022-12-01 14:59:16 +01:00
Jean-Sébastien Pédron
18e4112337 linuxkpi: Add seqcount_mutex_t support in <linux/seqlock.h>
To achieve that, the header uses the C11 type generic selection keyboard
_Generic() because the macros are supposed to work with seqcount_t
and seqcount_mutex_t.

Differential Revision:	https://reviews.freebsd.org/D36965
2022-12-01 14:58:27 +01:00
Bjoern A. Zeeb
69cc163001 LinuxKPI: 802.11: minor header updates
- add comments for enum values constantly looked up, and another one to
  a net80211 equivalent (should possibly re-define those in the future?)
- add another nl80211_sta_info flag
- add enum environment_cap used in cfg80211.h in the future.

MFC after:	3 days
2022-11-28 21:21:06 +00:00
Bjoern A. Zeeb
5504bd59a3 LinuxKPI: SKB update
- skb_reset_tail_pointer(): we do not do offsets so do a plain reset
- skb_add_rx_frag(): adjust data_len to keep track of the frag
- based on that implement skb_is_nonlinear() and skb_linearize()
- implement build_skb() and adjust linuxkpi_kfree_skb() and ddb macro.

Sponsored by:	The FreeBSD Foundation (partially)
MFC after:	3 days
2022-11-28 20:54:57 +00:00
Bjoern A. Zeeb
ce9f36610e LinuxKPI: SKB: implement skb_peek()
Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2022-11-28 18:47:08 +00:00
Bjoern A. Zeeb
23c73dbae7 LinuxKPI: iwlwifi: rtw88: rtw89: remove budget argument from netif_napi_add()
In preparation for future updates remove the budget argument from the
netif_napi_add() in drivers and update LinuxKPI to reflect that it is
gone and only set it internally.  This required changes to the currently
committed wireless drivers based on LinuxKPI (iwlwifi, rtw88, rtw89).

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2022-11-28 17:30:40 +00:00
Bjoern A. Zeeb
1b91eba37b LinuxKPI: ethtool.h add more definitions
While we do not currently use ethtool, add the definitions to avoid
other longer-term maintenance problems with drivers.

Also migrate ETH_GSTRING_LEN into here from if_ether.h as it seems this
is where it belongs.

MFC after:	3 days
Differential Revision: https://reviews.freebsd.org/D37214
2022-11-28 17:25:58 +00:00
Bjoern A. Zeeb
0fce2dc157 LinuxKPI,lindebugfs: add u8 base type and blob support
Add debugfs_create_u8() based on other already present implementations.
Add a read-only implementation for debugfs_create_blob().

Both are needed for iwlwifi debugfs support.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
OKed by:	jfree (earlier version)
Differential Revision: https://reviews.freebsd.org/D37090
2022-11-28 17:21:50 +00:00
Bjoern A. Zeeb
af393426b3 LinuxKPI: add a no-op generic_file_llseek()
This is needed for debugfs implementations in drivers.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
OKed by:	jfree
Differential Revision: https://reviews.freebsd.org/D37092
2022-11-28 17:14:10 +00:00
Bjoern A. Zeeb
5f2f582ccc LinuxKPI: pci.h add more MSI related constanst and pci_is_enabled()
Add more MSI related constansts defined to our native defines and
pci_is_enabled().  All are needed for another wireless driver.

MFC after:	3 days
Differential Revision: https://reviews.freebsd.org/D37225
2022-11-28 17:11:47 +00:00
Ed Maste
eafafebe47 compat32: retire now-unused MIPS support
This reverts commit a6d20bbaa2.
2022-11-23 09:33:43 -05:00
Bjoern A. Zeeb
325ba12055 LinuxKPI: in efi.h include queue.h
sys/linker.h needs sys/queue.h;  this gets another wireless driver
closer to compiling on main.

MFC after:	3 days
2022-11-15 23:08:05 +00:00
Bjoern A. Zeeb
5d310ea8c5 LinuxKPI: add memset_startat macro
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
2022-11-15 12:52:10 +00:00
Jean-Sébastien Pédron
208d02fd5d
linuxkpi: Define ZERO_OR_NULL_PTR() in <linux/slab.h>
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
2022-11-11 21:03:25 +01:00
Jean-Sébastien Pédron
86a1c5d129
linuxkpi: Define pci_reset_function() in <linux/pci.h>
Currently, it always returns an error on FreeBSD.

Reviewed by:	bz manu
Approved by:	bz manu
Differential Revision:	https://reviews.freebsd.org/D37366
2022-11-11 21:00:36 +01:00
Jean-Sébastien Pédron
42bb586116
linuxkpi: Include <linux/list.h> and <linux/kernel.h> from <linux/mutex.h>
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
2022-11-11 20:59:40 +01:00
Jean-Sébastien Pédron
24c7853f39
linuxkpi: Add <linux/mman.h> which includes <linux/smp.h>
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
2022-11-11 20:57:46 +01:00
Jean-Sébastien Pédron
708a570255
linuxkpi: Add <linux/page-flags.h>
It just provides a `PageHighMem()` macro stub.

Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D36961
2022-11-11 20:56:42 +01:00
Jean-Sébastien Pédron
58cf3a69a5
linuxkpi: Define boot_cpu_data.x86_max_cores
Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D36971
2022-11-11 18:43:07 +01:00
Jean-Sébastien Pédron
c4163160e4
linuxkpi: Add dev_warn_once() in <linux/device.h>
Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D36968
2022-11-11 18:42:31 +01:00
Jean-Sébastien Pédron
23ebeac87f
linuxkpi: Add list_for_each_entry_from_rcu() in <linux/rculist.h>
Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D36967
2022-11-11 18:42:10 +01:00
Jean-Sébastien Pédron
d3584f9283
linuxkpi: Define typeof_member() in <linux/kernel.h>
Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D36964
2022-11-11 18:41:36 +01:00
Jean-Sébastien Pédron
0e5569a08c
linuxkpi: Add <linux/dma-buf-map.h>
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
2022-11-11 18:40:57 +01:00
Jean-Sébastien Pédron
c9c1255012
linuxkpi: Add <linux/mmzone.h>
It provides the `MAX_ORDER` constant.

Reviewed by:	emaste manu
Approved by:	emaste manu
Differential Revision:	https://reviews.freebsd.org/D36962
2022-11-11 18:39:48 +01:00
Jean-Sébastien Pédron
1676c97d5d
linuxkpi: Add <acpi/actbl.h>
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
2022-11-11 18:38:06 +01:00