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
Fixes: 11db70b605
(cherry picked from commit f0395993e1)
(cherry picked from commit 4d255abe99)
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
(cherry picked from commit 32ea820982)
(cherry picked from commit 6b9c0ac008)
Add a version of __const_bitcount<n> which can be used to get the
numbers at compile-time when __builtin_popcountg() is not available
(see sys/compat/linuxkpi/common/include/linux/bitops.h for LLVM before
19 and gcc before 14).
Obtained from: https://reviews.freebsd.org/D50995#1174884 by obiwac
Sponsored by: The FreeBSD Foundation
Reviewed by: brooks, emaste
Differential Revision: https://reviews.freebsd.org/D54301
(cherry picked from commit 27aa23cee8)
(cherry picked from commit 605389e40b)
For consistency rename the "scheduled_txqs" tailq to
"txq_scheduled" and add a lock per txq ("txq_scheduled_lock[]").
We use the "_bh" locking as this called from the device driver.
This fixes panics due to concurrent access to the tailq, especially
in between "first" and "remove" on the out-direction and between
"insert" and "elem_init" on the in-direction.
This was easily reproducible just running iperf3 at basic rates for
a few seconds to minutes with multiple chipsets, not only rtw89.
Sponsored by: The FreeBSD Foundation
PR: 290636
Reported by: arved, and others before
(cherry picked from commit 567a097c8a)
(cherry picked from commit 2e1156f758)
Always set CONFIG_ARCH_DMA_ADDR_T_64BIT as it is true for all
architectures we support. Add an option for CONFIG_NET_MEDIATEK_SOC_WED,
which we currently do not yet support.
Sponsored by: The FreeBSD Foundation
(cherry picked from commit 87aa494dfc)
(cherry picked from commit e2ebe56c50)
If CONFIG_NET_MEDIATEK_SOC_WED is not set then be silent; if
CONFIG_NET_MEDIATEK_SOC_WED is set we will enable logic or rather te
pr_debug("TODO") calls for now.
Spsonsored by: The FreeBSD Foundation
(cherry picked from commit 51c73fc5f5)
(cherry picked from commit 7ed3a99f35)
Move the enum and leave a comment on the struct member for the vif
about the type.
No functional changes.
Sponsored by: The FreeBSD Foundation
(cherry picked from commit b10ff7ed37)
(cherry picked from commit a714641fa5)
The logic in device_release_driver() got disabled in 93b14194ac
and since left alone. Add a pr_debug() call so we have a chance to
notice if that code is actually still in need to be fixed and re-enabled.
Sponsored by: The FreeBSD Foundation
(cherry picked from commit fc9666d0fc)
(cherry picked from commit 0f496780de)
We are ways away from implementing "airtime fairness" in LinuxKPI
(or rather net80211). For now make it an 'improve' rather than a
'todo' to get the logging away. Everything will work without it.
Sponsored by: The FreeBSD Foundation
(cherry picked from commit 86bfe5b4d5)
(cherry picked from commit c55874da4c)
cfg80211_chandef_create() gets passed a pointer to a cfg80211_chan_def.
It seems that several users are passing in an uninitialized variable
from the stack and expect cfg80211_chandef_create() to initialize it.
Run memset() on the struct, which for all callers currently seems to do
the right thing, to avoid later accesses to uninitialized struct members
like "punctured".
Reported by: CI (gcc build)
Sponsonred by: The FreeBSD Foundation
(cherry picked from commit 640205bc22)
(cherry picked from commit d389d1ac16)
This includes some type cleanups as well as some shuffling of structs
and functions to sort dependencies out. Few new functions and defines
as well as new struct members. Minor fixes to style and debug logging.
This is the majority of changes. None of these should conflict with
current in-tree drivers. The final bit of changes will come along with
the driver updates adding an extra argument to function pointers.
(cherry picked from commit 0567484734)
(cherry picked from commit f2b2d6c18a)
For the moment add skeleton functions for netif_device_attach/detach()
needed by rtw8[89] v6.17.
(cherry picked from commit 5ea941a4fb)
(cherry picked from commit 4bdd0e51d7)
This likely belongs in socket code which we do not have in LinuxKPI.
Needed by a wirless driver at v6.17.
(cherry picked from commit 88dbf83345)
(cherry picked from commit 3ad05fa24a)
We do not support Wireless Ethernet Dispatch (wed) on the mt76 (yet).
Add pr_debug calls with TODO in case we run into the calls anyway so
we could deal with them.
(cherry picked from commit 224ac9d2a0)
(cherry picked from commit b9b571e614)
page_pool headers were not used yet; they were created for mt76 but
are without functionality. Upstream has migrated them for v6.17 and
split them up into multiple files. Also add netmem.h which the little
needed is directly related to page pools.
(cherry picked from commit 7c31cdfa40)
(cherry picked from commit d388ff8016)
Given we do not yet support "wake" bits in device there is little need
doing it in PCI if we cannot check if we are supposed to do the
operation in first place. Once we would implement this, we would need
to also do the appropriate PCI (pme) checks before enabling (disabling)
it.
Reviewed by: dumbbell
Differential Revision: https://reviews.freebsd.org/D53208
(cherry picked from commit 885e8f272f)
(cherry picked from commit be52a81be0)
We do not currently aim to support crypto FIPS compliance in LinuxKPI
so keep this turned off.
Reviewed by: emaste, dumbbell
Differential Revision: https://reviews.freebsd.org/D53207
(cherry picked from commit 98609f4fec)
(cherry picked from commit 3aaaba2078)
The return type now is void; I believe no one ever used this
so we can just chnage it. The only active platform_driver_register()
calls seems to be in ath1[01]k and mt76 and there in unsupported code.
Reviewed by: dumbbell, emaste
Differential Revision: https://reviews.freebsd.org/D53205
(cherry picked from commit 0ae4998423)
(cherry picked from commit 5434a1635e)
We will see how much we will need them and how to fill them at that
point. They are left with a pr_debug("TODO") for now.
Differential Revision: https://reviews.freebsd.org/D53204
(cherry picked from commit cc792250ac)
(cherry picked from commit 805038b70a)
The former is needed by a wireless driver at v6.17.
Reviewed by: dumbbell, emaste
Differential Revision: https://reviews.freebsd.org/D53203
(cherry picked from commit 0a4b11ddb2)
(cherry picked from commit 0e30cab0f3)
igc(4) seems to work fine on arm64 for as much as I could test with
a 2.5Gbit/s interface on a mPCIe card.
Enable the module build so it is available.
(cherry picked from commit 51fbeadac4)
(cherry picked from commit 2c345e94ae)
As found on RTEMS the argument to if_foreach_llmaddr() was wrong
causing crashes.
Fixes: 51e8082055
PR: 290314
(cherry picked from commit 33afdf0e35)
(cherry picked from commit 10c71151ad)
The port is called wifi-firmware-mt76-kmod not "mediatek" in the
moddle.
Reported by: Lars Tunkrans (drsnx60 gmail.com)
Reviewed by: emaste, jrm, imp
Differential Revision: https://reviews.freebsd.org/D53067
(cherry picked from commit 10d88a7aa6)
(cherry picked from commit e048748627)
MediaTek mt76 WiFi cards are advertising FLR support but after issuing
a FLR the chipset is gone. Add a quirk so we can disable FLR. The
current reset code will automatically fall back to a power reset.
This makes the card show up under bhyve where before it would just not
be discovered at all. That should make wifibox work for it and will help
development for a LinuxKPI based mt76 driver as found in framework laptops
as no dedicated machine and constant reboots are needed anymore.
We will likely need to add more PCI vendor/device IDs once we can test
the other device IDs.
After a lot of help from: jhb
Really implemented by: jhb (I just typed and tested)
GH issue: github.com/pgj/freebsd-wifibox/issues/73
Reviewed by: imp, emaste
Differential Revision: https://reviews.freebsd.org/D52728
(cherry picked from commit 4c0e53aced)
(cherry picked from commit 3bd015a1a9)
Like lkpi_pci_get_domain_bus_and_slot() implement lkpi_pci_get_slot()
using pci_find_bsf() instead of pci_find_dbsf() (no domain).
This is needed for a wireless driver.
Unfortunately the name [pci_get_slot()] collides with the native PCI
function. Add a guard around it and disable the use when the native
version is required (in lkpifill_pci_dev() and in bnxt/bnxt_en; if the
latter gets fixed we can probably also fix work around it in the former;
further conflicts in drm-kmod 6.1-lts, 6.6-lts, and master were resolved).
Sponsored by: The FreeBSD Foundation (initially)
Reviewed by: dumbbell
Differential Revision: https://reviews.freebsd.org/D52065
(cherry picked from commit 4179e6b782)
(cherry picked from commit 62c3b77d1d)
In linux_pci_attach_device() allocate a LinuxKPI pci_dev for each device in
the hierarchy up to the root port[1] as we cannot do that later on demand
as we may be in a context where we may not sleep.
Take special care of DRM as there is a non-PCI device in the chain which
needs to be skipped.
iwlwifi(4) can hit this case called from a callout.
While here leave a comment as the cleanup order of
linux_pci_attach_device() needs correction seperately.
Sponsored by: The FreeBSD Foundation (initially)
PR: 283027
PR: 289647
Suggested by: jhb [1]
Reviewed by: dumbbell
Differential Revision: https://reviews.freebsd.org/D52069
(cherry picked from commit bbeeb58531)
(cherry picked from commit 3860afe99e)
(cherry picked from commit 123c2dc6e1)
(cherry picked from commit d8972ad2f6)
When freeing the last reference of the net80211 node the net80211
node_free() code may directly call into the crypto code to delete
the keys. While we still holding the wiphy lock this would lead to
a recursion on the non-recursive wiphy lock. Defer freeing the
reference until we are back under the net80211 com lock.
Reported by: Mark Phillips (mark freebsdfoundation.org) on 15.0-ALPHA1
(cherry picked from commit 3c38dce87e)
(cherry picked from commit b0469fa7f1)
dem_kfree() is called from all over the place and should actually
do something; contrary to lkpi_devm_kmalloc_release() it can also
take a const void *. We have to __DECONST() that though as the
entire devres framework does otherwise not take a const argument.
This was discovered during the rtw89 update to 6.16.
Sponsored by: The FreeBSD Foundation (initially)
Reviewed by: dumbbell
Differential Revision: https://reviews.freebsd.org/D52082
(cherry picked from commit 4ab64e3491)
(cherry picked from commit f20a09e161)
Needed by a wifi driver update.
Sponsored by: The FreeBSD Foundation (initially)
Reviewed by: dumbbell
Differential Revision: https://reviews.freebsd.org/D52080
(cherry picked from commit 2a44e10edb)
(cherry picked from commit 88122c8eb7)
These came up during a wifi driver update.
Sponsored by: The FreeBSD Foundation (initially)
Reviewed by: dumbbell
Differential Revision: https://reviews.freebsd.org/D52079
(cherry picked from commit 7c47393362)
(cherry picked from commit 3753913c9e)
It seems overflow.h wsa imported directly from Linux in 3208d4ad2b.
Update the file to the newer version as needed for wireless driver updates.
Sponsored by: The FreeBSD Foundation (initially)
Obtained from: git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
038d61fd642278 (tag: v6.16)
Reviewed by: dumbbell
Differential Revision: https://reviews.freebsd.org/D52078
(cherry picked from commit 70c508e691)
(cherry picked from commit cd2bd8bf67)
Use __builtin_object_size() by default.
If __builtin_dynamic_object_size() is available use that instead.
I would hope that in a future version we can remove the conditional
checks but in order to be able to MFC this without checking all
compiler versions simply keep it this way for now.
Sponsored by: The FreeBSD Foundation (initially)
Reviewed by: dumbbell
Differential Revision: https://reviews.freebsd.org/D52077
(cherry picked from commit ff5bcb7428)
(cherry picked from commit 310885b40a)
This adds guard support for non-real-types like rcu locking meaning
that we need to keep the lock state separately ourselves. _T is still
special and needs to be updated. Given it may not be used it needs
an __unused attribute (we are using the LinuxKPI __maybe_unused which
indeed is more expressive in this case).
Sponsored by: The FreeBSD Foundation (initially)
Reviewed by: dumbbell
Differential Revision: https://reviews.freebsd.org/D52076
(cherry picked from commit 3f48a0fe53)
(cherry picked from commit 4d5a78c5f4)
del_timer() got renamed to timer_delete() approximately in Linux 6.2
(similar for *_sync and likely others).
Keep the old functions as compat; unclear when we can gc them.
We should also re-define them with a linuxkpi_ prefix to avoid possible
conflicts in the future if we do a full pass over this at some point.
Sponsored by: The FreeBSD Foundation (intiially)
Reviewed by: dumbbell
Differential Revision: https://reviews.freebsd.org/D52074
(cherry picked from commit 5cb64a1d3f)
(cherry picked from commit 88198564db)
With Linux 6.16 from_timer() got renamed to timer_container_of(); add
the LINUXKPI_VERSION check with a default to the current version.
Update all in-tree consumers (apart from wireless drivers managed
otherwise).
Sponsored by: The FreeBSD Foundation (initially)
Reviewed by: dumbbell
Differential Revision: https://reviews.freebsd.org/D52073
(cherry picked from commit 81cb7c4c8e)
(cherry picked from commit 352be5b48b)
The code introduced abs_diff() as migrated from drm to standard
linux headers. The LINUXKPI_VERSION check did not allow this to
be visible by default in-tree. Make sure the v6.6 check is optional.
drm-kmod always defines LINUXKPI_VERSION so this should be fine.
Sponsored by: The FreeBSD Foundation (initially)
Fixes: afc450fac9
Reviewed by: dumbbell
Differential Revision: https://reviews.freebsd.org/D52071
(cherry picked from commit 736b16e88d)
(cherry picked from commit ab45c85937)
This will be used for hooking suspend/resume in for LinuxKPI 802.11
based drivers.
Sponsored by: The FreeBSD Foundation (initially)
Reviewed by: dumbbell
Differential Revision: https://reviews.freebsd.org/D52070
(cherry picked from commit 627234627b)
(cherry picked from commit 8fca57469f)
Factor out the pci_request_region() implementation into an internal
function and make pci_request_region() a simple wrapperaround it.
Likewise implement pcim_request_all_regions() as a loop calling
pci_request_region() for each entry.
In two cases which we returned an error before (bar index is valid but
bar is not (no len), and neither IO nor MEM) we now reutrn success
(nothing to do for us). Otherwise callers, especially
pcim_request_all_regions() would error out for the wrong reasons.
This seems to also match the expected behaviour of pci_request_region().
Sponsored by: The FreeBSD Foundation (intially)
Reviewed by: dumbbell
Differential Revision: https://reviews.freebsd.org/D52068
LinuxKPI: pci: undo the pci_resource_len() check in lkpi_pci_request_region()
Creating non-passthru SR-IOV interfaces on a mlx5en(4) failed.
The problem lies in the pci_resource_len() call but not that the BAR length
is tmeporary 0 but in that we call lkpi_pci_get_bar() with a true argument
which will create the BAR resource for us and report the approriate length
back. However, the later call to bus_alloc_resource_any() will then fail
given the resource already exists.
Restore the previous behaviour and let bus_alloc_resource_any() do the
work. Adjust the return values from -ENODEV to -EBUSY to match callers
expectations.
In linuxkpi_pcim_request_all_regions(), like in linuxkpi_pci_request_regions(),
filter out the -EBUSY errors as "not an error" and try the next bar.
This also seems to be consistent with the expectations of the callers.
PR: 290793
Reported by: David BOYER (jcduss13 gmail.com)
Tested on: mlx5en, iwlwifi, mt7921
Reviewed by: kib
Fixes: 7e21158d44 "implement [linuxkpi_]pcim_request_all_regions()"
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D53902
(cherry picked from commit 7e21158d44)
(cherry picked from commit ff31767e53)
(cherry picked from commit ed29ffd396)
(cherry picked from commit 2032abb31c)
Like pci_iomap() add the devres version pcim_iomap() using the former
to get the resource.
Add a helper function to validate that the bar is within a valid range
and sprinkle that check also to other related functions.
Sponsored by: The FreeBSD Foundation (intially)
Reviewed by: dumbbell
Differential Revision: https://reviews.freebsd.org/D52067
(cherry picked from commit 2f9064a5d2)
(cherry picked from commit cfb8f4bf2c)
Implement for_each_pci_dev() needed by a wireless driver update.
For that also improve pci_get_device() and add the functionality to
support the odev argument to start searching from that.
Sponsored by: The FreeBSD Foundation (intially)
Reviewed by: dumbbell
Differential Revision: https://reviews.freebsd.org/D52066
(cherry picked from commit 910cf345d0)
(cherry picked from commit 68f8fa4ada)
A port using linux(kpi) header files but not using skbuffs is hitting
the case that it cannot find opt_wlan.h. Give up to the idea that
skbuff.h is only used by wireless drivers (or in-tree) and that
IEEE80211_DEBUG (via opt_lwan.h) could autmatically compile in debug
support.
It is likely time to add a LINUXKPI_DEBUG knob in the near future
(also for linuxkpi_debug or linuxkpi_debug_rcu).
PR: 289268
(cherry picked from commit bc222e96d1)
- one duplcate entry: 0x664*|0x664*) -> 0x664*|0x665*)
- one unneeded glob: 0x98e4*) -> 0x98e4)
- 0x15e7|0x1636|0x1638|0x164c) half of these are green-sardine; split
- a missing entry for skillfish2 : + 0x143f
Reviewed by: imp, manu
Differential Revision: https://reviews.freebsd.org/D52312
(cherry picked from commit 1d12658755)
During startup hccontrol reset needs to be run multiple times
for iwbt to work more reliably. Add a loop trying up to
three times.
Tested by: various (original version; I changed test to -eq)
Differential Revision: https://reviews.freebsd.org/D44861
Fix a redirect of stderr to stdout which is going to /dev/null.
A '&' got missing in the original rewrite from the review that
I took and committed. Seems no one had noticed during testing
or review. People may have ended up with a "/1" file in their
root file system.
Fixes: 40652f86b5
Reported by: Vladyslav Movchan (vladislav.movchan gmail.com)
(cherry picked from commit 40652f86b5)
(cherry picked from commit 78807c196c)
Given the checksum offloading flags are mutually exclusive and are
not a bit mask, we can compress them into 2 bit for the four possible
values. Change the define but leave the type at uint8_t for now with
a comment. We can possible combine them with another sub-octet field
in the future.
Sponsored by: The FreeBSD Foundation
(cherry picked from commit 343f8f71af)
While we are still associated we cannot delete the keys as packets
may still go out and if the firmware has no more keys it will raise
and exception.
This can happen given net80211 has its own mind when to do this and
we, in various places, unlock and re-lock the com lock, so are open
to races.
Sponsored by: The FreeBSD Foundation
(cherry picked from commit 86a0941db7)
In bc24342d96 we added lower wake_queue locking. There are paths,
such as in rtw89 from a (*hw_scan_cancel)() that we can get to there and
then would recursively acquire the wiphy lock which is not allowed.
Adjust locking to a spin lock to match Linux driver expectations.
Sponsored by: The FreeBSD Foundation
Fixes: bc24342d96
(cherry picked from commit fc36de571f)
These structs as part of the union are used to handle raw packet data
so mark them all __packed.
Sponsored by: The FreeBSD Foundation
(cherry picked from commit d1df103190)