aboutsummaryrefslogtreecommitdiff
path: root/sys/compat
Commit message (Collapse)AuthorAgeFilesLines
* LinuxKPI: netdevice: add structs net_device_path, net_device_path_ctxBjoern A. Zeeb14 hours1-0/+24
| | | | | | | | mt76(4) is using this along with a mac80211.h functiontion pointer to resolve a path in an offload case. Sponsored by: The FreeBSD Foundation MFC after: 3 days
* LinuxKPi: 802.11: add more definesBjoern A. Zeeb14 hours3-0/+4
| | | | | | | | Add more defines and a mac80211 op function pointer used by mt76(4) at Linux v6.19-rc6. Sponsored by: The FreeBSD Foundation MFC after: 3 days
* LinuxKPI: skbuff: implement skb_queue_splice()Bjoern A. Zeeb14 hours1-1/+8
| | | | | | | | | Add skb_queue_splice() and use it in skb_queue_splice_init() which already had that functionality (plus the init bit). The new function is used by rtw89(4). Sponosred by: The FreeBSD Foundation MFC after: 3 days
* LinuxKPI: 802.11: rename enum ieee80211_tx_rate_flags and move fileBjoern A. Zeeb14 hours2-14/+13
| | | | | | | | | | What we used to call enum ieee80211_tx_rate_flags is now used as enum mac80211_rate_control_flags for the ieee80211_tx_rate.flags in rtw89(4). Rename the enum and move it to mac80211 as it seems to belong there. Sponsonred by: The FreeBSD Foundation MFC after: 3 days
* LinuxKPI: 802.11: add new field to struct cfg80211_bitrate_maskBjoern A. Zeeb14 hours1-0/+3
| | | | | | | | rtw89(4) accesses eht_mcs[]. Add the field to struct cfg80211_bitrate_mask. Sponsored by: The FreeBSD Foundation MFC after: 3 days
* LinuxKPI: 802.11: Management MIC element can have 8 or 16 octets MICBjoern A. Zeeb14 hours1-3/+11
| | | | | | | | | Management MIC element (MME) can have 8 or 16 octets MIC. Add a second structure used by at least iwlwifi and update reference to latest standard version. Sponsored by: The FreeBSD Foundation MFC after: 3 days
* LinuxKPI: 802.11: fix build for non-debug kernelsBjoern A. Zeeb39 hours1-0/+2
| | | | | | | | | | | | | lkpi_nl80211_band_name() is only available under LINUXKPI_DEBUG_80211. IMPROVE in theory should be as well or defined to nothing but we cannot do that in cfg80211.h mac80211.h where we possibly (re-)define this. Put an #ifdef around the IMPROVE call for now (untested). Sponsored by: The FreeBSD Foundation MFC after: 3 days Fixes: 768332d61948 Reported by: CI
* LinuxKPI: 802.11: factor out rate logic for mandatory channelsBjoern A. Zeeb40 hours3-27/+100
| | | | | | | | | | | | | | | I was looking at rate work for another problem and found more flags in ath9k (which we will likely never need). The documentation then revealed the "mandatory" flags as well and with discussions about cfg80211 going on I decided to use the momentum and split our "supp_rates" setup between lkpi_lsta_alloc() and wiphy_register(). There should be no functional change. While there also initialize max_rc_amsdu_len. Sponsored by: The FreeBSD Foundation MFC after: 3 days
* sys/abi_compat.h: fix UB for bintime32 handlingKonstantin Belousov41 hours1-1/+1
| | | | | | | | | | | Do not cast and then access potentially unaligned uint64_t in the BT_CP() macro. Use freebsd32_uint64_t type and FU64_CP() for the frac member. Noted by: des Reviewed by: des, emaste Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D54663
* compat32: provide a type and a macro for (u)int64_t handling on non-x86 archesKonstantin Belousov41 hours1-1/+10
| | | | | | | | | | | | uint64_t is 4-byte aligned on i386, but is 8-bytes aligned on all other 32bit arches FreeBSD supports. Provide the freebsd32_uint64_t type and the FU64_CP() macro, which are intended to be used where 32bit ABI uses (u)int64_t type, and do proper layout and copying for the aggregate type. Reviewed by: des, emaste Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D54663
* linux: on vnet detach call clean_unrhdr(9) alwaysGleb Smirnoff6 days1-5/+6
| | | | | | | | The assumption was incorrect, and the current VIMAGE implementation leaves a possibility for some interfaces still exist in a jail that is going away. Fixes: 607f11055d2d421770963162a4d9a99cdd136152
* linuxkpi: Clean up linux_shmem_file_setup() a bitMark Johnston7 days1-4/+3
| | | | | | | | | | | - Free the pointer that was returned by the allocator, instead of the address of the first member. These will be equal in practice, but it's sketchy and won't work on CHERI with subobject bounds checking. - Use an anonymous struct, there's no need to name it. Reviewed by: bz, brooks, emaste MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D54673
* linuxkpi: Avoid a potential null pointer dereference in an error pathMark Johnston7 days1-1/+2
| | | | | | | Reported by: Kevin Day <kevin@your.org> Reviewed by: bz, emaste MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D54672
* linuxkpi: Fix an error path in linux_alloc_current()Mark Johnston7 days1-8/+2
| | | | | | | | | | | If the allocation fails we should free the task struct. While here get rid of a couple of unnecessary assertions. Reported by: Kevin Day <kevin@your.org> Reviewed by: emaste MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D54671
* LinuxKPI: pci: fix pcie_get_speed_cap()Bjoern A. Zeeb8 days1-9/+18
| | | | | | | | | | | | | pcie_get_speed_cap() has a hard coded skip of 3 devices at the beginning. It is either called on a pdev or on a result from pci_upstream_bridge(). In the latter case skipping another three devices might get us to acpi0 or nexus, neither of which is a PCI device still and pci_get_vendor() will panic() on that. Sponsored by: The FreeBSD Foundation (commit) GHI: https://github.com/freebsd/drm-kmod/issues/393 MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D53862
* LinuxKPI: include acpi headers for RISC-VBjoern A. Zeeb8 days1-1/+1
| | | | | | | | | | | | In order to compile iwlwifi(4), which is reported to work on RISC-V, include the ACPI headers to avoid adding further FreeBSD-specific #ifdefs to the driver. With this iwlwifi(4) just compiles on RISC-V (at least if ACPI support is turned off in the module Makefile). Sponsored by: The FreeBSD Foundation MFC after: 3 days Reviewed by: emaste Differential Revision: https://reviews.freebsd.org/D54692
* linux: add hidraw ioctl handlerAlex S12 days2-0/+70
| | | | | | | | | | First step towards getting the Linux version of SDL with HIDAPI gamepad drivers to work. Not quite complte as SDL expects to find some information in sysfs as well. Signed-off-by: Alex S <iwtcex@gmail.com> Reviewed by: imp Pull Request: https://github.com/freebsd/freebsd-src/pull/1938
* linux: support termios2 ioctlsmothcompute12 days2-1/+78
| | | | | | Signed-off-by: mothcompute <mothcompute@protonmail.com> Reviewed by: imp Pull Request: https://github.com/freebsd/freebsd-src/pull/1949
* linuxkpi: Add `rol32()`Jean-Sébastien Pédron2026-01-071-0/+6
| | | | | | | | | | | `rol64()` and `rol32()` are used by <linux/siphash.h>. The former was added previously, before <linux/siphash.h> was added. However the latter was not, and it broke the build on armv7. Reported by: adrian Reviewed by: adrian, rpokala Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D54588
* linuxkpi: Replicate the chain of #include in the `cec*.h` headersJean-Sébastien Pédron2026-01-075-0/+59
| | | | | | | | | | The i915 DRM driver depends on this namespace pollution to access `debugfs_*` functions, after several explicit #include of <linux/debugfs.h> were removed in Linux 6.10. Reviewed by: bz, christos Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D54494
* linuxkpi: Add WARN_RATELIMIT()Jean-Sébastien Pédron2026-01-071-0/+7
| | | | | | | | The i915 DRM driver started to use it in Linux 6.10. Reviewed by: bz, christos Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D54493
* linuxkpi: Add <linux/kmsg_dump.h>Jean-Sébastien Pédron2026-01-071-0/+51
| | | | | | | | | | | | | This header declares register/unregister functions to allow a piece of code to tell what function to call in case of a panic. Several panic handlers may be registered. The DRM generic code started to use it in Linux 6.10 as part of the panic handler. Reviewed by: bz, christos Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D54492
* linuxkpi: Add <linux/font.h>Jean-Sébastien Pédron2026-01-071-0/+33
| | | | | | | | | | | | | | | | The header defines the minimum to allow the DRM generic code to build. The only function used so far is `get_default_font()`, as part of a DRM-specific panic handler. We do not use this panic handler on FreeBSD. For now, it returns a NULL value. It should probably map to a vt(4) font. The DRM generic code started to use it in Linux 6.10 as part of the panic handler. Reviewed by: bz, christos Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D54491
* linuxkpi: Define `raw_spinlock_t` in <linux/spinlock.h>Jean-Sébastien Pédron2026-01-071-0/+20
| | | | | | | | | | | | | For now, it is synonymous to `spinlock_t`. The DRM generic code uses the `struct raw_spinlock` and not `raw_spinlock_t`, that's why the definition is a struct embedding a `struct mtx`, compared to `spinlock_t` which is a simpler typedef. The DRM generic code started to use it in Linux 6.10. Reviewed by: bz, christos Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D54489
* linuxkpi: Add `radix_tree_deref_slot()`Jean-Sébastien Pédron2026-01-051-0/+6
| | | | | | | | | | | We don't do reference counting, we only dereference the pointer and retunr the value. The amdgpu DRM driver started to use it in Linux 6.10. Reviewed by: bz Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D54502
* linuxkpi: Add <linux/siphash.h>Jean-Sébastien Pédron2026-01-052-0/+714
| | | | | | | | | | | The file is copied as is from Linux 6.10 as it dual-licensend under the GPLv2 and BSD 3-clause. The amdgpu DRM driver started to use it in Linux 6.10. Reviewed by: bz, emaste Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D54501
* linuxkpi: Add get_unaligned_le64()Jean-Sébastien Pédron2026-01-051-0/+7
| | | | | | | | | | | This function was the only one missing in the `get_unaligned_*()` family. This is going to be used by the imported `linux_siphash.c` in a future commit, which itself is used by DRM drivers starting from Linux 6.10. Reviewed by: bz Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D54500
* linuxkpi: Add `rol64()`Jean-Sébastien Pédron2026-01-051-0/+6
| | | | | | | | This is used by <linux/siphash.h> added in a separate future commit. Reviewed by: bz Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D54499
* linuxkpi: Add a dummy <linux/fpu.h>Jean-Sébastien Pédron2026-01-051-0/+0
| | | | | | | | | | The amdgpu DRM driver started to include in from Linux 6.10, but either it does not use any of it, or linuxkpi provides the necessary API from another header. Reviewed by: bz Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D54498
* linuxkpi: Add support for statically-allocated kfifoJean-Sébastien Pédron2026-01-051-2/+20
| | | | | | | | | | | | | | | | The main difference with the dynamically allocated version is that the structure is initialized with `DECLARE_KFIFO()` which takes the number of items as an additional argument compared to `DECLARE_KFIFO_PTR()`. The declared structure is then initialized with `INIT_KFIFO()` which sets all fields to 0, except `total` which is computed from the size of the array passed to `DECLARE_KFIFO()`. The amdgpu DRM driver started to used this in Linux 6.10. Reviewed by: bz Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D54497
* linuxkpi: Replicate Linux #includes between headersJean-Sébastien Pédron2026-01-058-0/+99
| | | | | | | | | | | | | | | | | | | | | | | | | | | The DRM drivers (and probably other parts of the Linux kernel) had a significant cleanup w.r.t. which source file includes what in Linux 6.10. Nonetheless, the DRM drivers still depend on implicit namespace pollution because some source files do not include all the headers they should. This cleanup broke the build with FreeBSD because we do not replicate the same `#include` directives everywhere. This commit adds the same `#include` directives in several headers in order to get the same namespace pollution. This fixes the build of the DRM drivers from Linux 6.10. An example is `drm_dp_tunnel.c` which needed `str_yes_no()` defined by <linux/string_helpers.h> (technically <linux/string_choices.h> in Linux). It gets it through: <linux/i2c.h> -> <linux/regulator/consumer.h> -> <linux/suspend.h> -> <linux/swap.h> -> <linux/memcontrol.h> -> <linux/cgroup.h> -> <linux/seq_file.h> -> <linux/string_helpers.h> Reviewed by: emaste Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D54496
* linuxkpi: Split <linux/compiler.h>Jean-Sébastien Pédron2026-01-053-46/+96
| | | | | | | | | | | | | | | | | | | | | | | | On Linux, they split the content into three headers: 1. <linux/compiler.h> 2. <linux/compiler_types.h> 3. <linux/compiler_attributes.h> The first includes the second, which includes the third. <linux/compiler_types.h> is also included on the compiler command line by default! I added that to the compilation flags of the DRM drivers. This allowed me to drop at least one: #ifdef __FreeBSD #include <linux/compiler.h> #endif Note that our copy of <linux/compiler.h> contains definitions which are not defined by Linux' <linux/compiler.h>. I left them alone. Reviewed by: emaste Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D54495
* linuxkpi: Add a dummy <linux/kdebug.h>Jean-Sébastien Pédron2026-01-051-0/+0
| | | | | | | | | The DRM generic code started to include it in Linux 6.10 but doesn't seem to use anything inside. Reviewed by: bz Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D54490
* linuxkpi: Define `PCI_POSSIBLE_ERROR()` macroJean-Sébastien Pédron2026-01-051-0/+14
| | | | | | | | | | | | | | | | | It comes with `PCI_ERROR_RESPONSE` and `PCI_SET_ERROR_RESPONSE()` but we don't use them so far. Therefore `PCI_POSSIBLE_ERROR()` will always reture false. As written in the comment, this macro is a bit weird given the Linux `pci_read_*() functions can return an error code separately from the read value. The `PCI_POSSIBLE_ERROR()` macro started to be used by the amdgpu DRM driver in Linux 6.10. Reviewed by: emaste Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D54487
* linuxkpi: Add hex_dump_to_buffer()Jean-Sébastien Pédron2026-01-042-0/+76
| | | | | | | | | | This function prints a single line of hex dump to the given line buffer. The implementation relies on `lkpi_hex_dump()` to format the string. Reviewed by: bz Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D51559
* linuxkpi: Add option to skip trailing newline in `lkpi_hex_dump()`Jean-Sébastien Pédron2026-01-043-7/+9
| | | | | | | | | This will be useful in the upcoming implementation of `hex_dump_to_buffer()` which doesn't add one. Reviewed by: bz, emaste Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D51844
* linuxkpi: Avoid trailing whitespaces in lkpi_hex_dump()Jean-Sébastien Pédron2026-01-041-13/+53
| | | | | | | | | | | | | | | We use the return value of the callback to track the number of bytes written. We use it to determine if a group of characters should be prepended with a whitespace. This way, we never add a trailing whitespace. We need to pay attention to the return value of the callback: if it is negative, it's an error and we return immediately. Otherwise, we would decrease the number of written bytes and possibly make it negative. Reviewed by: bz, christos Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D51558
* linuxkpi: Correct kstrtoboolDag-Erling Smørgrav2026-01-031-11/+5
| | | | | | | | | | | | | | | | | | Implement the exact same logic as in Linux: * Accept 'e', 't', 'y', '1', "on" for true. * Accept 'd', 'f', 'n', '0', "of" for false. * Disregard any characters beyond that. * Check that the string is not null, but don't check the result pointer. MFC after: 1 week Sponsored by: Klara, Inc. Sponsored by: NetApp, Inc. Reviewed by: bz, emaste Differential Revision: https://reviews.freebsd.org/D54451
* linuxkpi: Don't clobber result on failureDag-Erling Smørgrav2026-01-021-13/+30
| | | | | | | | | | | | In kstrto*(), don't assign to *res until we know the conversion is successful, and address issues that may result in warnings if code that uses <linux/kstrtox.h> is compiled at high warning levels. MFC after: 1 week Sponsored by: Klara, Inc. Sponsored by: NetApp, Inc. Reviewed by: bz, emaste Differential Revision: https://reviews.freebsd.org/D54440
* LinuxKPI: 802.11: fix rx_nss with VHTBjoern A. Zeeb2025-12-291-1/+2
| | | | | | | | | | | | | | | | | | | | When fixing single-stream chipsets, like iwlwifi(4) AX101, we started masking the announced with the hardware supported values. This would probably limit, e.g., rx_nss. During these works we fixed a loop checking from the highest nss=7 to lowest nss=0 (8..1) and would set rx_nss if the stream was supported. This left us with always setting rx_nss on nss=0 to nss + 1 = 1. Instead only update once when we hit the first supported MCS value (highest number of supported streams). Looking at the diff of the mentioned commit hash which gets fixed it looks like even the old code was not correct either. This only fixes the logic to calculate rx_nss. This does not yet help with modern drivers to actually update the value. Code for this will come in a later commit. Sponsored by: The FreeBSD Foundation MFC after: 3 days Fixes: adb4901ac9ae
* LinuxKPI: 802.11: reset hdr after crypto in lkpi_80211_txq_tx_one()Bjoern A. Zeeb2025-12-291-0/+2
| | | | | | | | | | | | | | | When lkpi_80211_txq_tx_one() calls into the crypto offloading parts to possibly make space in the headroom, the beginning of our frame moves. We have to reset hdr after that call as otherwise later classifications based on the hdr->frame_control will fail or cause wrong classificaiton of packets. This makes sure frames will either be directly sent using (*mo_tx)() or use the correct tid for the correct queue. This helps to get rtwx8 packets flowing after BA was negotiated. Sponsored by: The FreeBSD Foundation MFC after: 3 days Fixes: 11db70b6057e4
* LinuxKPI: 802.11: assign sequence numbers to framesBjoern A. Zeeb2025-12-291-0/+2
| | | | | | | | | | | | | | | | | | While all native drivers were converted to call ieee80211_output_seqno_assign() after changes to net80211 if needed, LinuxKPI 802.11 was not fixed. Add the missing call. Given we are currently only supporting STA mode, we can provide sequence numbers for all frames (mgmt/beacon would be a problem in AP mode). This greatly helps LinuxKPI based drivers other than iwlwifi(4). If drivers do their own sequence numbers, they will overwrite what we pre-set unless we would pass a txflag not to do so (beware the consequences). Sponsored by: The FreeBSD Foundation MFC after: 3 days Fixes: eabcd1773fa3, 785edcc2af5a
* LinuxKPI: 802.11: add compat.linuxkpi.80211.IF.dump_stas_queuesBjoern A. Zeeb2025-12-292-5/+77
| | | | | | | | | | Extend the normal compat.linuxkpi.80211.IF.dump_stas sysctl by queue information. This was helpful for debugging various issues, like selecting the outbound queue, stopping queues for BAR and helped finding multiple bugs. Sponsored by: The FreeBSD Foundation MFC after: 3 days
* compat: linux: use appropriate variables for copying out old timersKyle Evans2025-12-281-2/+2
| | | | | | | | | | | | We copyout &l_oval but do the conversions into &l_val, leaving us with stack garbage. A build with an LLVM21 cross-toolchain seems to catch this. Reported by: Florian Limberger <flo purplekraken com> Reviewed by: markj Fixes: a1fd2911ddb06 ("linux(4): Implement timer_settime64 syscall.") MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D52985
* net: add ifnet_rename_event EVENTHANDLER(9) for interface renamingGleb Smirnoff2025-12-221-1/+14
| | | | | | | | | | | | | | | | | and don't trigger ifnet_arrival_event and ifnet_departure_event for a rename, as the interface isn't being detached from any protocol. The consumers of the arrival/departure events are divided into a few categories: - which indeed need to do the same actions as if interface was fully detached and attached: routing socket and netlink notifications to userland and the Linux sysfs. All addressed by this commit. - which build their logic based on an interface name, but should actually update their database on rename: packet filters. This commit leaves them with the old behavior - emulate full detach & attach, but this should be improved. - which shouldn't do anything on rename, not touched by the commit. - ng_ether and if_tuntap, that are special and will be addressed by separate commits.
* LinuxKPI: bitcount fix builds with gcc and older llvmBjoern A. Zeeb2025-12-191-0/+8
| | | | | | | | | | | | | | | | LLVM before 19 and gcc before 14 do not support __builtin_popcountg(). Use __const_bitcount<n> from sys/bitcount.h as a replacement in these cases. This should still allow drm-kmod to build where the size needs to be known at compile-time. Remove the conditional for gcc around the iwlwifi modules build, which was collateral damage in all this. Sponsored by: The FreeBSD Foundation Fixes: 7cbc4d875971, 5e0a4859f28a MFC after: 3 days Reviewed by: brooks, emaste (without the sys/modules/Makefile change) Differential Revision: https://reviews.freebsd.org/D54297
* LinuxKPI: Implement vmap_pfnVladimir Kondratyev2025-12-172-0/+68
| | | | | | | | Required by i915kms to support recent discrete graphics cards. MFC after: 1 week Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D54225
* LinuxKPI: Move vmap-related code from linux_compat.c to linux_page.cVladimir Kondratyev2025-12-172-111/+125
| | | | | | | | | | Coming vmap_pfn() implementation requires is_vmalloc_addr() to be in the same file with other vmap-related code. Move code out from the overcrowded file. No functional changes intended. MFC after: 1 week Reviewed by: bz Differential Revision: https://reviews.freebsd.org/D54223
* LinuxKPI: 802.11: rework MC/configure_filterBjoern A. Zeeb2025-12-142-11/+2
| | | | | | | | | | | | | | | | | (*prepare_multicast)(), for the drivers we support, is iwlwifi(4)-specific. If it is not available do not let us stop from calling (*configure_filter)() at least as well. In addition to the interface setting mc_all_multi, if we have no way to prepare the multicast filter list this way, set FIF_ALLMULTI for now. This seems to help some with rtw89 but does not help me with other drivers yet to get IPv6 link-local (e.g., ff02::1%wlan0) going. This should also help in case we are scanning and are setting FIF_BCN_PRBRESP_PROMISC . We should go and review the full FIF_ list and start adding conditional support for the other options too. Sponsored by: The FreeBSD Foundation PR: 281982 MFC after: 3 days
* linux: Implement F_DUPFD_QUERY fcntl with kcmp(2) KCMP_FILERicardo Branco2025-12-112-0/+9
| | | | | | Signed-off-by: Ricardo Branco <rbranco@suse.de> Reviewed by: kib Pull Request: https://github.com/freebsd/freebsd-src/pull/1920