linux-2.6-microblaze.git
9 months agowifi: mac80211: move element parsing to a new file
Johannes Berg [Mon, 29 Jan 2024 19:19:34 +0000 (20:19 +0100)]
wifi: mac80211: move element parsing to a new file

This code got really big, move it to a new file.
Pure code move.

Link: https://msgid.link/20240129202041.7f27f7c895e4.I0adfc28bd656a4d44c2bf47966277eecf56cbaa0@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
9 months agowifi: mac80211: start building elements in SKBs
Johannes Berg [Mon, 29 Jan 2024 19:19:33 +0000 (20:19 +0100)]
wifi: mac80211: start building elements in SKBs

The building of elements is really mess, and really the only
reason we're not doing it in SKBs in the first place is that
the scan code in ieee80211_build_preq_ies() doesn't.

Convert ieee80211_build_preq_ies() to use an SKB internally
so that we can gradually convert other things to ..._put_*()
style interfaces.

Link: https://msgid.link/20240129202041.c3a8e3c2cc99.I9d9920858c30ae5154719783933de0d7bc2a2cb9@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
9 months agowifi: mac80211: simplify adding supported rates
Johannes Berg [Mon, 29 Jan 2024 19:19:32 +0000 (20:19 +0100)]
wifi: mac80211: simplify adding supported rates

Make this a new-style "put" function, and change the
parameters to pass more information directly, this
makes it usable also for the MLME code.

Link: https://msgid.link/20240129202041.f604a03bd728.I8c798ea45b8479ac9982e77d0378af11a09ccdaf@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
9 months agowifi: mac80211: tdls: use ieee80211_put_he_6ghz_cap()
Johannes Berg [Mon, 29 Jan 2024 19:19:31 +0000 (20:19 +0100)]
wifi: mac80211: tdls: use ieee80211_put_he_6ghz_cap()

We don't need to use the write function here since we already
have an SKB, so use ieee80211_put_he_6ghz_cap() with the SMPS
mode taken from the link we're using.

Link: https://msgid.link/20240129202041.6454ac78ff8c.I7152e3c27645105478c68d40ca493feb27cac6bf@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
9 months agowifi: mac80211: rename ieee80211_ie_build_he_6ghz_cap()
Johannes Berg [Mon, 29 Jan 2024 19:19:30 +0000 (20:19 +0100)]
wifi: mac80211: rename ieee80211_ie_build_he_6ghz_cap()

The term 'IE' isn't really in use in the spec, and I want
to rework all of this to use SKBs as the primary method
for building elements. Rename this one already.

Link: https://msgid.link/20240129202041.b8064a4e73b5.I8d2f4526562029107c6414c6cda378b300b1b0b0@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
9 months agowifi: mac80211: limit HE RU capabilities when limiting bandwidth
Johannes Berg [Mon, 29 Jan 2024 19:19:29 +0000 (20:19 +0100)]
wifi: mac80211: limit HE RU capabilities when limiting bandwidth

When limiting a station's supported bandwidth while connecting,
also limit various other HE capabilities according to the bandwidth
needed for them.

Link: https://msgid.link/20240129202041.34be99efca25.I02a695961bc6aadd37768b17c50fcdec4427d460@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
9 months agowifi: mac80211: adjust EHT capa when lowering bandwidth
Johannes Berg [Mon, 29 Jan 2024 19:19:28 +0000 (20:19 +0100)]
wifi: mac80211: adjust EHT capa when lowering bandwidth

If intending to associate with a lower bandwidth, remove capabilities
related to 320 MHz from the EHT capabilities element. Also change the
EHT MCS-NSS set accordingly: if just reducing 320->160 or similar the
format doesn't change, just cut off the last bytes. If changing from
higher bandwidth to 20 MHz only EHT STA, adjust the format.

Note that this also requires adjusting the caller in mlme.c since the
data written can now be shorter than it determined. We need to clean
all that up. Since the other callers pass NULL for the conn limit, we
don't need to change things there.

Link: https://msgid.link/20240129202041.b5f6df108c77.I0d8ea04079c61cb3744cc88625eeaf0d4776dc2b@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
9 months agowifi: mac80211: simplify HE/EHT element length functions
Johannes Berg [Mon, 29 Jan 2024 19:19:27 +0000 (20:19 +0100)]
wifi: mac80211: simplify HE/EHT element length functions

We don't need to pass the iftype there, we already have it
in the sdata. Simplify this code.

Link: https://msgid.link/20240129202041.5890eb1d4184.Ibce7e5abcc7887630da03ac2263d8004ec541418@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
9 months agowifi: mac80211: disallow basic multi-link element in per-STA profile
Johannes Berg [Mon, 29 Jan 2024 19:06:54 +0000 (20:06 +0100)]
wifi: mac80211: disallow basic multi-link element in per-STA profile

There really shouldn't be a basic multi-link element in any
per-STA profile in an association response, it's not clear
what that would really mean. Refuse connecting in this case
since the AP isn't following the spec.

Link: https://msgid.link/20240129200652.23f1e3b337f1.Idd2e43cdbfe3ba15b3e9b8aeb54c8115587177a0@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
9 months agowifi: mac80211: disambiguate element parsing errors
Johannes Berg [Mon, 29 Jan 2024 19:06:53 +0000 (20:06 +0100)]
wifi: mac80211: disambiguate element parsing errors

Let the element parsing function return what kind of error
was encountered, as a bitmap, even if nothing currently
checks for which specific error it was, we'll use it later.

Link: https://msgid.link/20240129200652.1a69f2a31ec7.I55b86561d64e7ef1504c73f6f2813c33030c8136@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
9 months agowifi: mac80211: implement MLO multicast deduplication
Johannes Berg [Mon, 29 Jan 2024 19:04:57 +0000 (20:04 +0100)]
wifi: mac80211: implement MLO multicast deduplication

If the vif is an MLD then it may receive multicast from
different links, and should drop those frames according
to the SN. Implement that.

Link: https://msgid.link/20240129200456.693b77d14b44.I491846f2bea0058c14eab6422962c10bfae9b675@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
9 months agowifi: mac80211: add/use ieee80211_get_sn()
Johannes Berg [Mon, 29 Jan 2024 19:04:56 +0000 (20:04 +0100)]
wifi: mac80211: add/use ieee80211_get_sn()

This will also be useful for MLO duplicate multicast
detection, but add it already here and use it in one
place that trivially converts.

Link: https://msgid.link/20240129200456.f0ff49c80006.I850d2785ab1640e56e262d3ad7343b87f6962552@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
9 months agowifi: cfg80211/mac80211: move puncturing into chandef
Johannes Berg [Mon, 29 Jan 2024 18:34:49 +0000 (19:34 +0100)]
wifi: cfg80211/mac80211: move puncturing into chandef

Aloka originally suggested that puncturing should be part of
the chandef, so that it's treated correctly. At the time, I
disagreed and it ended up not part of the chandef, but I've
now realized that this was wrong. Even for clients, the RX,
and perhaps more importantly, CCA configuration needs to take
puncturing into account.

Move puncturing into the chandef, and adjust all the code
accordingly. Also add a few tests for puncturing in chandef
compatibility checking.

Link: https://lore.kernel.org/linux-wireless/20220214223051.3610-1-quic_alokad@quicinc.com/
Suggested-by: Aloka Dixit <quic_alokad@quicinc.com>
Link: https://msgid.link/20240129194108.307183a5d2e5.I4d7fe2f126b2366c1312010e2900dfb2abffa0f6@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
9 months agowifi: mac80211: use cfg80211_chandef_primary_freq()
Johannes Berg [Mon, 29 Jan 2024 18:34:48 +0000 (19:34 +0100)]
wifi: mac80211: use cfg80211_chandef_primary_freq()

Instead of calculating the new primary 40/80/160 MHz
center frequency here, use the new helper function from
cfg80211.

Link: https://msgid.link/20240129194108.eb59d6433d18.I74b745f0d1a32e779fb25d50c56407be7c35b840@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
9 months agowifi: cfg80211: simplify cfg80211_chandef_compatible()
Johannes Berg [Mon, 29 Jan 2024 18:34:47 +0000 (19:34 +0100)]
wifi: cfg80211: simplify cfg80211_chandef_compatible()

Simplify cfg80211_chandef_compatible() a bit by switching
c1 and c2 around so that c1 is always the narrower one
(once they're not identical or narrow/S1G). Then we can
just check the various primary channels and exit with the
wider one (c2), or NULL.

Also refactor the primary 40/80/160 function to not have
all the calculations hard-coded, and use a wrapper around
it to check primary 40/80/160 compatibility.

While at it, add some kunit tests for this functionality.

Also expose the new cfg80211_chandef_primary_freq() to
drivers, mac80211 will use it.

Link: https://msgid.link/20240129194108.be3e6eccaba3.I8399c2ff1435d7378e5837794cb5aa6dd2ee1416@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
9 months agowifi: wireless: declare different S1G chandefs incompatible
Johannes Berg [Mon, 29 Jan 2024 18:34:46 +0000 (19:34 +0100)]
wifi: wireless: declare different S1G chandefs incompatible

It doesn't look like we can get into this code, but make it
more robust and declare two S1G chandefs to be incompatible
unless they're identical.

Link: https://msgid.link/20240129194108.b28fb0644a8c.I9297ada5cf1baf00dbbdf8fcffd1806883489fc9@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
9 months agowifi: mac80211: refactor puncturing bitmap extraction
Johannes Berg [Mon, 29 Jan 2024 18:34:45 +0000 (19:34 +0100)]
wifi: mac80211: refactor puncturing bitmap extraction

Add a new inline helper function to ieee80211.h to
extract the disabled subchannels bitmap from an EHT
operation element, and use that in mac80211 where
we do that.

Link: https://msgid.link/20240129194108.d9f50dcec8d0.I8b08cbc2490a734fafcce0fa0fc328211ba6f10b@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
9 months agowifi: cfg80211: move puncturing validation code
Johannes Berg [Mon, 29 Jan 2024 18:34:44 +0000 (19:34 +0100)]
wifi: cfg80211: move puncturing validation code

Upcoming patches will move the puncturing bitmap into the
chandef, so chandef validation will need to check for correct
puncturing. Purely move the code first so later changes are
easier to review.

Link: https://msgid.link/20240129194108.1ca184427c76.I077deb8d52c4648eac145b63f88b6c5a3b920ddc@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
9 months agowifi: mac80211: validate assoc response channel config
Johannes Berg [Mon, 29 Jan 2024 18:34:43 +0000 (19:34 +0100)]
wifi: mac80211: validate assoc response channel config

Due to the earlier restructuring we now mostly ignore
the channel configuration in the association response,
apart from the HT/VHT checks we had.

Don't do that, but parse it and update, also dropping the
association if the AP changed its mode in the response.

Link: https://msgid.link/20240129194108.b3efa5eae60c.I1b70c9fd56781b22cdfdca55d34d69f7d0733e31@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
9 months agowifi: mac80211: support wider bandwidth OFDMA config
Johannes Berg [Mon, 29 Jan 2024 18:34:42 +0000 (19:34 +0100)]
wifi: mac80211: support wider bandwidth OFDMA config

EHT requires that stations are able to participate in
wider bandwidth OFDMA, i.e. parse downlink OFDMA and
uplink OFDMA triggers when they're not capable of (or
not connected at) the (wider) bandwidth that the AP
is using. This requires hardware configuration, since
the entity responsible for parsing (possibly hardware)
needs to know the AP bandwidth.

To support this, change the channel request to have
the AP's bandwidth for clients, and track that in the
channel context in mac80211. This means that the same
chandef might need to be split up into two different
contexts, if the APs are different. Interfaces other
than client are not participating in OFDMA the same
way, so they don't request any AP setting.

Note that this doesn't introduce any API to split a
channel context, so that there are cases where this
might lead to a disconnect, e.g. if there are two
client interfaces using the same channel context, e.g.
both 160 MHz connected to different 320 MHz APs, and
one of the APs switches to 160 MHz.

Note also there are possible cases where this can be
optimised, e.g. when using the upper or lower 160 Mhz,
but I haven't been able to really fully understand the
spec and/or hardware limitations.

If, for some reason, there are no hardware limits on
this because the OFDMA (downlink/trigger) parsing is
done in firmware and can take the transmitter into
account, then drivers can set the new flag
IEEE80211_VIF_IGNORE_OFDMA_WIDER_BW on interfaces to
not have them request any AP bandwidth in the channel
context and ignore this issue entirely. The bss_conf
still contains the AP configuration (if any, i.e. EHT)
in the chanreq.

Link: https://msgid.link/20240129194108.d3d5b35dd783.I939d04674f4ff06f39934b1591c8d36a30ce74c2@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
9 months agowifi: mac80211: add and use a link iteration macro
Johannes Berg [Mon, 29 Jan 2024 18:34:41 +0000 (19:34 +0100)]
wifi: mac80211: add and use a link iteration macro

In the channel context code we have quite a few instances
of nested loops iterating the interfaces and then links.
Add a new for_each_sdata_link() macro and use it. Also,
since it's easier, convert all the loops and a few other
places away from RCU as we now hold the wiphy mutex
everywhere anyway.

This does cause a little bit more work (such as checking
interface types for each link of an interface rather than
not iterating links in some cases), but that's not a huge
issue and seems like an acceptable trade-off, readability
is important too.

Link: https://msgid.link/20240129194108.7240829bd96d.I5ccbb8dd019cbcb5326c85d76121359225d6541a@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
9 months agowifi: mac80211: introduce 'channel request'
Johannes Berg [Mon, 29 Jan 2024 18:34:40 +0000 (19:34 +0100)]
wifi: mac80211: introduce 'channel request'

For channel contexts, mac80211 currently uses the cfg80211
chandef struct (control channel, center freq(s), width) to
define towards drivers and internally how these behave. In
fact, there are _two_ such structs used, where the min_def
can reduce bandwidth according to the stations connected.

Unfortunately,  with EHT this is longer be sufficient,  at
least not for all hardware.  EHT requires that non-AP STAs
that are connected to an AP with a lower bandwidth than it
(the AP) advertises (e.g. 160 MHz STA connected to 320 MHz
AP) still be able to receive downlink OFDMA and respond to
trigger frames for uplink OFDMA  that specify the position
and bandwidth  for the non-AP STA  relative to the channel
the AP is using.  Therefore, they need to be aware of this,
and at least for some hardware (e.g. Intel) this awareness
is in the hardware. As a result, use of the "same" channel
may need to be split over  two channel contexts where they
differ by the AP being used.

As a first step,  introduce a concept of a channel request
('chanreq') for each interface,  to control the context it
requests.   This step does nothing but reorganise the code,
so that later the AP's chandef can be added to the request
in order to handle the EHT case described above.

Link: https://msgid.link/20240129194108.2e88e48bd2e9.I4256183debe975c5ed71621611206fdbb69ba330@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
9 months agowifi: mac80211: chan: chandef is non-NULL for reserved
Johannes Berg [Mon, 29 Jan 2024 18:34:39 +0000 (19:34 +0100)]
wifi: mac80211: chan: chandef is non-NULL for reserved

The last caller of this with a NULL argument was related to
the non-chanctx code, so we can now remove this odd logic.

Reviewed-by: Miriam Rachel Korenblit <miriam.rachel.korenblit@intel.com>
Link: https://msgid.link/20240129194108.bad8ec1e76c8.I12287452f42c54baf75821e75491cf6d021af20a@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
9 months agowifi: mac80211: simplify non-chanctx drivers
Johannes Berg [Mon, 29 Jan 2024 18:34:38 +0000 (19:34 +0100)]
wifi: mac80211: simplify non-chanctx drivers

There are still surprisingly many non-chanctx drivers, but in
mac80211 that code is a bit awkward. Simplify this by having
those drivers assign 'emulated' ops, so that the mac80211 code
can be more unified between non-chanctx/chanctx drivers. This
cuts the number of places caring about it by about 15, which
are scattered across - now they're fewer and no longer in the
channel context handling.

Link: https://msgid.link/20240129194108.6d0ead50f5cf.I60d093b2fc81ca1853925a4d0ac3a2337d5baa5b@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
9 months agowifi: mac80211: clean up HE 6 GHz and EHT chandef parsing
Johannes Berg [Mon, 29 Jan 2024 18:34:37 +0000 (19:34 +0100)]
wifi: mac80211: clean up HE 6 GHz and EHT chandef parsing

In the code we currently check for support 80+80, 160
and 320 channel widths, but really the way this should
be (and is otherwise) handled is that we compute the
highest channel bandwidth given there, and then cut it
down to what we support. This is also needed for wider
bandwidth OFDMA support.

Change the code to remove this limitation and always
parse the highest possible channel width.

Reviewed-by: Miriam Rachel Korenblit <miriam.rachel.korenblit@intel.com>
Link: https://msgid.link/20240129194108.d06f85082e29.I47e68ed3d97b0a2f4ee61e5d8abfcefc8a5b9c08@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
9 months agowifi: mac80211: clean up connection process
Johannes Berg [Mon, 29 Jan 2024 18:34:36 +0000 (19:34 +0100)]
wifi: mac80211: clean up connection process

Rewrite the station-side connection handling. The connection
flags (IEEE80211_DISABLE_*) are rather confusing, and they're
not always maintained well. Additionally, for wider-bandwidth
OFDMA support we need to know the precise bandwidth of the AP,
which is currently somewhat difficult.

Rewrite this to have a 'mode' (S1G/legacy/HT/...) and a limit
on the bandwidth. This is not entirely clean because some of
those modes aren't completely sequenced (as this assumes in
some places), e.g. VHT doesn't exist on 2.4 GHz, but HE does.
However, it still simplifies things and gives us a good idea
what we're operating as, so we can parse elements accordingly
etc.

This leaves a FIXME for puncturing, this is addressed in a
later patch.

Reviewed-by: Ilan Peer <ilan.peer@intel.com>
Reviewed-by: Miriam Rachel Korenblit <miriam.rachel.korenblit@intel.com>
Link: https://msgid.link/20240129194108.9451722c0110.I3e61f4cfe9da89008e1854160093c76a1e69dc2a@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
9 months agowifi: mac80211: clean up band switch in duration
Johannes Berg [Mon, 29 Jan 2024 18:34:35 +0000 (19:34 +0100)]
wifi: mac80211: clean up band switch in duration

Most devices now do duration calculations, so we don't hit
this code at all any more. Clearly the approach of warning
at compile time here when new bands are added didn't work,
the new bands were just added with "TODO". Clean it up, it
won't matter for new bands since they'll just not have any
need to calculate durations in software.

While at it, also clean up and unify the code a bit.

Link: https://msgid.link/20240129194108.70a97bd69265.Icdd8b0ac60a382244466510090eb0f5868151f39@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
9 months agowifi: mac80211: remove extra shadowing variable
Johannes Berg [Wed, 31 Jan 2024 15:49:04 +0000 (16:49 +0100)]
wifi: mac80211: remove extra shadowing variable

Not sure how this happened or how nothing complained, but
this variable already exists in the outer function scope
with the same value (and the SKB isn't changed either.)
Remove the extra one.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
9 months agowifi: mac80211: remove unused MAX_MSG_LEN define
Johannes Berg [Wed, 31 Jan 2024 15:49:07 +0000 (16:49 +0100)]
wifi: mac80211: remove unused MAX_MSG_LEN define

This got unused when the tracing was converted to dynamic
strings, so the define can be removed.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
9 months agoMerge wireless into wireless-next
Johannes Berg [Thu, 8 Feb 2024 08:57:43 +0000 (09:57 +0100)]
Merge wireless into wireless-next

There are some changes coming to wireless-next that will
otherwise cause conflicts, pull wireless in first to be
able to resolve that when applying the individual changes
rather than having to do merge resolution later.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
9 months agowifi: rtl8xxxu: update rate mask per sta
Martin Kaistra [Mon, 5 Feb 2024 09:30:40 +0000 (10:30 +0100)]
wifi: rtl8xxxu: update rate mask per sta

Until now, rtl8xxxu_watchdog_callback() only fetches RSSI and updates
the rate mask in station mode. This means, in AP mode only the default
rate mask is used.

In order to have the rate mask reflect the actual connection quality,
extend rtl8xxxu_watchdog_callback() to iterate over every sta. Like in
the rtw88 driver, add a function to collect all currently present stas
and then iterate over a list of copies to ensure no RCU lock problems
for register access via USB. Remove the existing RCU lock in
rtl8xxxu_refresh_rate_mask().

Since the currently used ieee80211_ave_rssi() is only for 'vif', add
driver-level tracking of RSSI per sta.

Signed-off-by: Martin Kaistra <martin.kaistra@linutronix.de>
Reviewed-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://msgid.link/20240205093040.1941140-1-martin.kaistra@linutronix.de
9 months agobcma: make bcma_bus_type const
Ricardo B. Marliere [Sun, 4 Feb 2024 20:57:23 +0000 (17:57 -0300)]
bcma: make bcma_bus_type const

Now that the driver core can properly handle constant struct bus_type,
move the bcma_bus_type variable to be a constant structure as well,
placing it into read-only memory which can not be modified at runtime.

Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Ricardo B. Marliere <ricardo@marliere.net>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://msgid.link/20240204-bus_cleanup-bcma-v1-1-0d881c793190@marliere.net
9 months agossb: make ssb_bustype const
Ricardo B. Marliere [Sun, 4 Feb 2024 20:44:21 +0000 (17:44 -0300)]
ssb: make ssb_bustype const

Now that the driver core can properly handle constant struct bus_type,
move the ssb_bustype variable to be a constant structure as well,
placing it into read-only memory which can not be modified at runtime.

Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Ricardo B. Marliere <ricardo@marliere.net>
Acked-by: Michael Büsch <m@bues.ch>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://msgid.link/20240204-bus_cleanup-ssb-v1-1-511026cd5f3c@marliere.net
9 months agowifi: wfx: fix memory leak when starting AP
Jérôme Pouiller [Fri, 2 Feb 2024 16:42:13 +0000 (17:42 +0100)]
wifi: wfx: fix memory leak when starting AP

Kmemleak reported this error:

    unreferenced object 0xd73d1180 (size 184):
      comm "wpa_supplicant", pid 1559, jiffies 13006305 (age 964.245s)
      hex dump (first 32 bytes):
        00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
        00 00 00 00 00 00 00 00 1e 00 01 00 00 00 00 00  ................
      backtrace:
        [<5ca11420>] kmem_cache_alloc+0x20c/0x5ac
        [<127bdd74>] __alloc_skb+0x144/0x170
        [<fb8a5e38>] __netdev_alloc_skb+0x50/0x180
        [<0f9fa1d5>] __ieee80211_beacon_get+0x290/0x4d4 [mac80211]
        [<7accd02d>] ieee80211_beacon_get_tim+0x54/0x18c [mac80211]
        [<41e25cc3>] wfx_start_ap+0xc8/0x234 [wfx]
        [<93a70356>] ieee80211_start_ap+0x404/0x6b4 [mac80211]
        [<a4a661cd>] nl80211_start_ap+0x76c/0x9e0 [cfg80211]
        [<47bd8b68>] genl_rcv_msg+0x198/0x378
        [<453ef796>] netlink_rcv_skb+0xd0/0x130
        [<6b7c977a>] genl_rcv+0x34/0x44
        [<66b2d04d>] netlink_unicast+0x1b4/0x258
        [<f965b9b6>] netlink_sendmsg+0x1e8/0x428
        [<aadb8231>] ____sys_sendmsg+0x1e0/0x274
        [<d2b5212d>] ___sys_sendmsg+0x80/0xb4
        [<69954f45>] __sys_sendmsg+0x64/0xa8
    unreferenced object 0xce087000 (size 1024):
      comm "wpa_supplicant", pid 1559, jiffies 13006305 (age 964.246s)
      hex dump (first 32 bytes):
        00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
        10 00 07 40 00 00 00 00 00 00 00 00 00 00 00 00  ...@............
      backtrace:
        [<9a993714>] __kmalloc_track_caller+0x230/0x600
        [<f83ea192>] kmalloc_reserve.constprop.0+0x30/0x74
        [<a2c61343>] __alloc_skb+0xa0/0x170
        [<fb8a5e38>] __netdev_alloc_skb+0x50/0x180
        [<0f9fa1d5>] __ieee80211_beacon_get+0x290/0x4d4 [mac80211]
        [<7accd02d>] ieee80211_beacon_get_tim+0x54/0x18c [mac80211]
        [<41e25cc3>] wfx_start_ap+0xc8/0x234 [wfx]
        [<93a70356>] ieee80211_start_ap+0x404/0x6b4 [mac80211]
        [<a4a661cd>] nl80211_start_ap+0x76c/0x9e0 [cfg80211]
        [<47bd8b68>] genl_rcv_msg+0x198/0x378
        [<453ef796>] netlink_rcv_skb+0xd0/0x130
        [<6b7c977a>] genl_rcv+0x34/0x44
        [<66b2d04d>] netlink_unicast+0x1b4/0x258
        [<f965b9b6>] netlink_sendmsg+0x1e8/0x428
        [<aadb8231>] ____sys_sendmsg+0x1e0/0x274
        [<d2b5212d>] ___sys_sendmsg+0x80/0xb4

However, since the kernel is build optimized, it seems the stack is not
accurate. It appears the issue is related to wfx_set_mfp_ap(). The issue
is obvious in this function: memory allocated by ieee80211_beacon_get()
is never released. Fixing this leak makes kmemleak happy.

Reported-by: Ulrich Mohr <u.mohr@semex-engcon.com>
Co-developed-by: Ulrich Mohr <u.mohr@semex-engcon.com>
Signed-off-by: Ulrich Mohr <u.mohr@semex-engcon.com>
Fixes: 268bceec1684 ("staging: wfx: fix BA when device is AP and MFP is enabled")
Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://msgid.link/20240202164213.1606145-1-jerome.pouiller@silabs.com
9 months agowifi: rtw89: fw: download firmware with key data for secure boot
Ping-Ke Shih [Sun, 4 Feb 2024 01:26:27 +0000 (09:26 +0800)]
wifi: rtw89: fw: download firmware with key data for secure boot

Since firmware header contains multiple secure sections, we need to trim
ignored sections, and then download firmware header with single one secure
section.

For secure boot, when downloading secure section, copy security key data
from MSS poll by key_idx read from efuse. If non-secure boot, no need this
extra copy.

           +---------------------------+ -\
           |      firmware header      |  |
           |                           |  |
           | +-----------------------+ |  | only preserve single one secure
           | | section type/size * N | |  | section
           | | ...                   | |  |
           | +-----------------------+ |  |
           +---------------------------+ -/
           :                           :
           +---------------------------+ -\
           | secure section type (ID:9)|  |
           |                           |  |
      +----|-> [ security key data ]   |  |
      |    +---------------------------+ -/
      |    |MSS Pool for above section |
      |    |  [ security key data 0 ]  |
      +----|- [ security key data 1 ]  |
by key_idx |  [ security key data 2 ]  |
           |  ...                      |
           +---------------------------+

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://msgid.link/20240204012627.9647-5-pkshih@realtek.com
9 months agowifi: rtw89: fw: parse secure section from firmware file
Ping-Ke Shih [Sun, 4 Feb 2024 01:26:26 +0000 (09:26 +0800)]
wifi: rtw89: fw: parse secure section from firmware file

A firmware file can contains more than one section with secure type, so
use secure information from efuse to choose the one with matched
cryptography method. Then choose key data from MSS poll (multiple security
section pool; see below picture) according to key_index from efuse.

Note that the size of MSS pool isn't included in section size defined
in firmware header, so we also need to parse header of MSS pool to get
its size as shift to parse next section.

If secure boot isn't supported by current hardware, the first secure
section will be adopted, and no need additional process to key data.

  +---------------------------+
  |      firmware header      |
  |                           |
  | +-----------------------+ |
  | | section type/size * N-|-|-------+
  | | ...                   | |       |
  | +-----------------------+ |       |
  +---------------------------+       |
  :                           :       |
  +---------------------------+ -\    |
  | secure section type (ID:9)|  |    |
  |                           |  | <--+
  |                           |  |
  +---------------------------+ -/
  |MSS Pool for above section |
  |                           |
  |                           |
  +---------------------------+

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://msgid.link/20240204012627.9647-4-pkshih@realtek.com
9 months agowifi: rtw89: fw: read firmware secure information from efuse
Ping-Ke Shih [Sun, 4 Feb 2024 01:26:25 +0000 (09:26 +0800)]
wifi: rtw89: fw: read firmware secure information from efuse

To support firmware secure boot, read secure information from efuse to
know if current hardware module can support secure boot with certain
cryptography method.

This information should be prepared before downloading firmware, so read
efuse right after power on at probe stage. The secure information includes
secure cryptography method and secure key index that are used to choose
proper key material when downloading firmware.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://msgid.link/20240204012627.9647-3-pkshih@realtek.com
9 months agowifi: rtw89: fw: consider checksum length of security data
Ping-Ke Shih [Sun, 4 Feb 2024 01:26:24 +0000 (09:26 +0800)]
wifi: rtw89: fw: consider checksum length of security data

The newer firmware file provides security data with checksum, so we need to
consider the length. Otherwise it will fail to validate total firmware
length resulting in failed to probe.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://msgid.link/20240204012627.9647-2-pkshih@realtek.com
9 months agowifi: rtw89: 8922a: add chip_ops::rfk_hw_init
Ping-Ke Shih [Fri, 2 Feb 2024 03:06:42 +0000 (11:06 +0800)]
wifi: rtw89: 8922a: add chip_ops::rfk_hw_init

Add a chip_ops for WiFi 7 chips to set additional RF configurations
including MLO and PLL settings.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://msgid.link/20240202030642.108385-12-pkshih@realtek.com
9 months agowifi: rtw89: 8922a: add chip_ops::rfk_init_late to do initial RF calibrations later
Ping-Ke Shih [Fri, 2 Feb 2024 03:06:41 +0000 (11:06 +0800)]
wifi: rtw89: 8922a: add chip_ops::rfk_init_late to do initial RF calibrations later

The RF calibrations are moved into firmware, so we trigger calibrations by
H2C commands and wait for C2H completion events. However, these events
can be received only after HCI (i.e. PCI for now) starts, so we should
do initial RF calibrations after that.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://msgid.link/20240202030642.108385-11-pkshih@realtek.com
9 months agowifi: rtw89: 8922a: rfk: implement chip_ops to call RF calibrations
Ping-Ke Shih [Fri, 2 Feb 2024 03:06:40 +0000 (11:06 +0800)]
wifi: rtw89: 8922a: rfk: implement chip_ops to call RF calibrations

Calling RF calibrations when interface up, connection, switching bands and
going to scan.

For 8922AE, RF calibrations are moved to firmware, so use H2C commands to
trigger RF calibrations and wait for a C2H event to indicate completion.
Then, do next RF calibration.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://msgid.link/20240202030642.108385-10-pkshih@realtek.com
9 months agowifi: rtw89: rfk: add H2C command to trigger TSSI
Ping-Ke Shih [Fri, 2 Feb 2024 03:06:39 +0000 (11:06 +0800)]
wifi: rtw89: rfk: add H2C command to trigger TSSI

TSSI is short for transmitter signal strength indication, which is a
close-loop hardware circuit to feedback actual transmitting power as a
reference to adjust power for next transmission.

When connecting and switching bands or channels, do TSSI calibration and
reset hardware status to output expected power.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://msgid.link/20240202030642.108385-9-pkshih@realtek.com
9 months agowifi: rtw89: rfk: add H2C command to trigger TXGAPK
Ping-Ke Shih [Fri, 2 Feb 2024 03:06:38 +0000 (11:06 +0800)]
wifi: rtw89: rfk: add H2C command to trigger TXGAPK

TXGAPK stands for TX power gap calibration. Use this calibration to
compensate TX power gap to output expected power.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://msgid.link/20240202030642.108385-8-pkshih@realtek.com
9 months agowifi: rtw89: rfk: add H2C command to trigger DACK
Ping-Ke Shih [Fri, 2 Feb 2024 03:06:37 +0000 (11:06 +0800)]
wifi: rtw89: rfk: add H2C command to trigger DACK

DACK (digital-to-analog converters calibration) is used to calibrate DAC
to output signals with expected quality.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://msgid.link/20240202030642.108385-7-pkshih@realtek.com
9 months agowifi: rtw89: rfk: add H2C command to trigger DPK
Ping-Ke Shih [Fri, 2 Feb 2024 03:06:36 +0000 (11:06 +0800)]
wifi: rtw89: rfk: add H2C command to trigger DPK

DPK is short for digital pre-distortion calibration. It can adjusts digital
waveform according to PA linear characteristics dynamically to enhance
TX EVM.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://msgid.link/20240202030642.108385-6-pkshih@realtek.com
9 months agowifi: rtw89: rfk: add H2C command to trigger RX DCK
Ping-Ke Shih [Fri, 2 Feb 2024 03:06:35 +0000 (11:06 +0800)]
wifi: rtw89: rfk: add H2C command to trigger RX DCK

RX DCK is receiver DC calibration. This will calibrate DC offset to
reflect correct received signal strength indicator, so mechanisms like CCA
can have normalized values.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://msgid.link/20240202030642.108385-5-pkshih@realtek.com
9 months agowifi: rtw89: rfk: add H2C command to trigger IQK
Ping-Ke Shih [Fri, 2 Feb 2024 03:06:34 +0000 (11:06 +0800)]
wifi: rtw89: rfk: add H2C command to trigger IQK

IQ signal calibration is a basic and important calibration to yield good RF
performance. Do this calibration on AP channel if we are going to connect.
During scanning phase, it transmits with low data rate, so without IQK
RF performance is still acceptable.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://msgid.link/20240202030642.108385-4-pkshih@realtek.com
9 months agowifi: rtw89: rfk: send channel information to firmware for RF calibrations
Ping-Ke Shih [Fri, 2 Feb 2024 03:06:33 +0000 (11:06 +0800)]
wifi: rtw89: rfk: send channel information to firmware for RF calibrations

We are going to do RF calibrations in firmware, so driver needs to provide
channel information for calibrations, which can do the same things as
they did in driver.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://msgid.link/20240202030642.108385-3-pkshih@realtek.com
9 months agowifi: rtw89: rfk: add a completion to wait RF calibration report from C2H event
Ping-Ke Shih [Fri, 2 Feb 2024 03:06:32 +0000 (11:06 +0800)]
wifi: rtw89: rfk: add a completion to wait RF calibration report from C2H event

The RF calibrations should be executed one by one, so add a completion
to ensure one is finish before next. The report from C2H event contains
state and optional version, and we only check the state for now. We also
care about the time a RF calibration takes, so record start time before
asking firmware to do calibration and get the delta time when receiving
report.

Consider SER recovery, we can't receive C2H event, use half of argument
'ms' as fixed delay that is 2 times of measured maximum time of
calibrations.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://msgid.link/20240202030642.108385-2-pkshih@realtek.com
9 months agowifi: wilc1000: remove setting msg.spi
David Lechner [Thu, 1 Feb 2024 20:12:47 +0000 (14:12 -0600)]
wifi: wilc1000: remove setting msg.spi

Calling spi_sync() unconditionally sets the spi field of struct
spi_message. Therefore setting msg.spi = spi before calling spi_sync()
has no effect and can be removed.

(spi_message_add_tail() does not access this field.)

Signed-off-by: David Lechner <dlechner@baylibre.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://msgid.link/20240201201248.2334798-2-dlechner@baylibre.com
9 months agowifi: cw1200: Convert to GPIO descriptors
Linus Walleij [Wed, 31 Jan 2024 22:37:25 +0000 (23:37 +0100)]
wifi: cw1200: Convert to GPIO descriptors

The CW1200 uses two GPIOs to control the powerup and reset
pins, get these from GPIO descriptors instead of being passed
as platform data from boardfiles.

The RESET line will need to be marked as active low as we will
let gpiolib handle the polarity inversion.

The SDIO case is a bit special since the "card" need to be
powered up before it gets detected on the SDIO bus and
properly probed. Fix this by using board-specific GPIOs
assigned to device "NULL".

There are currently no in-tree users.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://msgid.link/20240131-descriptors-wireless-v1-6-e1c7c5d68746@linaro.org
9 months agowifi: plfxlc: Drop unused include
Linus Walleij [Wed, 31 Jan 2024 22:37:24 +0000 (23:37 +0100)]
wifi: plfxlc: Drop unused include

The driver includes the legacy GPIO header <linux/gpio.h>
but does not use any symbols from it. Drop the include.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://msgid.link/20240131-descriptors-wireless-v1-5-e1c7c5d68746@linaro.org
9 months agowifi: mwifiex: Drop unused headers
Linus Walleij [Wed, 31 Jan 2024 22:37:23 +0000 (23:37 +0100)]
wifi: mwifiex: Drop unused headers

The mwifiex driver include two legacy GPIO headers but does
not use symbols from any of them.

The driver does contain some "gpio" handling code, but this
is some custom GPIO interface, not the Linux GPIO.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://msgid.link/20240131-descriptors-wireless-v1-4-e1c7c5d68746@linaro.org
9 months agowifi: brcmsmac: Drop legacy header
Linus Walleij [Wed, 31 Jan 2024 22:37:22 +0000 (23:37 +0100)]
wifi: brcmsmac: Drop legacy header

The driver is using all the modern abstractions to obtain and use
GPIOs and the legacy <linux/gpio.h> header is unused, so drop it.

Fixes: a8e59744e16b ("gpiolib: split linux/gpio/driver.h out of linux/gpio.h")
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://msgid.link/20240131-descriptors-wireless-v1-3-e1c7c5d68746@linaro.org
9 months agowifi: ti: wlcore: sdio: Drop unused include
Linus Walleij [Wed, 31 Jan 2024 22:37:21 +0000 (23:37 +0100)]
wifi: ti: wlcore: sdio: Drop unused include

The file is including the legacy GPIO header <linux/gpio.h> but
is not using any symbols from it, drop the header.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://msgid.link/20240131-descriptors-wireless-v1-2-e1c7c5d68746@linaro.org
9 months agowifi: cw1200: fix __le16 sparse warnings
Kalle Valo [Tue, 30 Jan 2024 15:15:55 +0000 (17:15 +0200)]
wifi: cw1200: fix __le16 sparse warnings

Sparse warns:

drivers/net/wireless/st/cw1200/cw1200_spi.c:83:17:    got restricted __le16 [usertype]
drivers/net/wireless/st/cw1200/cw1200_spi.c:148:17: warning: incorrect type in assignment (different base types)
drivers/net/wireless/st/cw1200/cw1200_spi.c:148:17:    expected unsigned short [addressable] [assigned] [usertype] regaddr
drivers/net/wireless/st/cw1200/cw1200_spi.c:148:17:    got restricted __le16 [usertype]

These cpu_to_le16() calls are not really making any sense to me. On a big
endian system we first convert regaddr from big to little using cpu_to_le16()
but immediately after we convert them back to big endian? So just remove them.

Compile tested only.

Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://msgid.link/20240130151556.2315951-4-kvalo@kernel.org
9 months agowifi: rsi: fix restricted __le32 degrades to integer sparse warnings
Kalle Valo [Tue, 30 Jan 2024 15:15:54 +0000 (17:15 +0200)]
wifi: rsi: fix restricted __le32 degrades to integer sparse warnings

drivers/net/wireless/rsi/rsi_91x_usb.c:235:27: warning: restricted __le32 degrades to integer
drivers/net/wireless/rsi/rsi_91x_usb.c:236:27: warning: restricted __le32 degrades to integer
drivers/net/wireless/rsi/rsi_91x_usb.c:237:27: warning: restricted __le32 degrades to integer
drivers/net/wireless/rsi/rsi_91x_usb.c:238:27: warning: restricted __le32 degrades to integer
drivers/net/wireless/rsi/rsi_91x_usb.c:244:36: warning: restricted __le32 degrades to integer
drivers/net/wireless/rsi/rsi_91x_usb.c:245:35: warning: restricted __le32 degrades to integer

These cpu_to_le32() are not making sense. With usb_reg_buf we handle the values
byte at a time to make sure usb_reg_buf is in little endian so no need to
convert anything. And usb_control_msg() expects to have the values in native
endian anyway. So just remove these so they are not spamming our logs.

Compile tested only.

Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://msgid.link/20240130151556.2315951-3-kvalo@kernel.org
9 months agowifi: zd1211rw: remove __nocast from zd_addr_t
Kalle Valo [Tue, 30 Jan 2024 15:15:53 +0000 (17:15 +0200)]
wifi: zd1211rw: remove __nocast from zd_addr_t

Sparse warns:

drivers/net/wireless/zydas/zd1211rw/zd_usb.c:383:24: warning: implicit cast from nocast type
drivers/net/wireless/zydas/zd1211rw/zd_usb.c:419:24: warning: implicit cast from nocast type

This is an ancient driver which has not have any meaningfuli changes for a long
time and hopefully removed soon. So just remove the __nocast to get rid of the
sparse warnings.

Compile tested only.

Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://msgid.link/20240130151556.2315951-2-kvalo@kernel.org
9 months agowifi: rtl8xxxu: Add TP-Link TL-WN823N V2
Chun Qiu [Mon, 29 Jan 2024 05:30:30 +0000 (13:30 +0800)]
wifi: rtl8xxxu: Add TP-Link TL-WN823N V2

TP-Link TL-WN823N V2 (2357:0135) is based on rtl8192fu and has been
tested to work with the rtl8xxxu driver.

Signed-off-by: Chun Qiu <cqca@cock.lu>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://msgid.link/20240129053030.16369-1-cqca@cock.lu
9 months agowifi: libertas: fix some memleaks in lbs_allocate_cmd_buffer()
Zhipeng Lu [Fri, 26 Jan 2024 07:53:34 +0000 (15:53 +0800)]
wifi: libertas: fix some memleaks in lbs_allocate_cmd_buffer()

In the for statement of lbs_allocate_cmd_buffer(), if the allocation of
cmdarray[i].cmdbuf fails, both cmdarray and cmdarray[i].cmdbuf needs to
be freed. Otherwise, there will be memleaks in lbs_allocate_cmd_buffer().

Fixes: 876c9d3aeb98 ("[PATCH] Marvell Libertas 8388 802.11b/g USB driver")
Signed-off-by: Zhipeng Lu <alexious@zju.edu.cn>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://msgid.link/20240126075336.2825608-1-alexious@zju.edu.cn
9 months agowifi: mt76: mt7996: fix fortify warning
Felix Fietkau [Sat, 3 Feb 2024 13:24:46 +0000 (14:24 +0100)]
wifi: mt76: mt7996: fix fortify warning

Copy cck and ofdm separately in order to avoid __read_overflow2_field
warning.

Fixes: f75e4779d215 ("wifi: mt76: mt7996: add txpower setting support")
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://msgid.link/20240203132446.54790-1-nbd@nbd.name
9 months agowifi: cfg80211: fix kunit exports
Johannes Berg [Sun, 4 Feb 2024 10:03:39 +0000 (11:03 +0100)]
wifi: cfg80211: fix kunit exports

These can only be exported if cfg80211's kunit is enabled,
since they're otherwise static. kunit itself can be enabled
even if cfg80211's kunit isn't. Fix that by using the right
macro.

Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202402040534.6AEKtZ7Y-lkp@intel.com/
Fixes: 45d43937a44c ("wifi: cfg80211: add a kunit test for 6 GHz colocated AP parsing")
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
9 months agowifi: iwlwifi: mvm: fix warnings from dmi_get_system_info()
Johannes Berg [Sun, 4 Feb 2024 09:56:27 +0000 (10:56 +0100)]
wifi: iwlwifi: mvm: fix warnings from dmi_get_system_info()

dmi_get_system_info() will statically return NULL when the
kernel is compiled without CONFIG_DMI, leading to compiler
warnings. Fix that by printing "<unknown>" in that case.

Fixes: c3f40c3e0273 ("iwlwifi: mvm: add US/CA to TAS block list if OEM isn't allowed")
Fixes: 9457077df49e ("wifi: iwlwifi: mvm: Add debugfs to get TAS status")
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
9 months agowifi: iwlwifi: fw: fix compiler warning for NULL string print
Johannes Berg [Sun, 4 Feb 2024 09:53:18 +0000 (10:53 +0100)]
wifi: iwlwifi: fw: fix compiler warning for NULL string print

When the system is compiled without CONFIG_DMI, the function
here statically returns NULL, leading to a compiler warning.
Catch that and print "<unknown>" in that case.

While at it, fix some indentation in the function.

Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202402030641.zUTuACYV-lkp@intel.com/
Fixes: 09059c6764a8 ("wifi: iwlwifi: prepare for reading PPAG table from UEFI")
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
9 months agowifi: iwlwifi: fw: fix compile w/o CONFIG_ACPI
Johannes Berg [Sun, 4 Feb 2024 09:48:18 +0000 (10:48 +0100)]
wifi: iwlwifi: fw: fix compile w/o CONFIG_ACPI

The user of this function passes a pointer to a value that
doesn't exist when compiled w/o CONFIG_ACPI. Since we don't
need the value then, make the non-ACPI version a macro to
allow it to still build.

Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202402031454.syX4cSGN-lkp@intel.com/
Fixes: c4c954547755 ("wifi: iwlwifi: implement WPFC ACPI table loading")
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
9 months agowifi: brcmfmac: Adjust n_channels usage for __counted_by
Kees Cook [Fri, 26 Jan 2024 22:31:53 +0000 (14:31 -0800)]
wifi: brcmfmac: Adjust n_channels usage for __counted_by

After commit e3eac9f32ec0 ("wifi: cfg80211: Annotate struct
cfg80211_scan_request with __counted_by"), the compiler may enforce
dynamic array indexing of req->channels to stay below n_channels. As a
result, n_channels needs to be increased _before_ accessing the newly
added array index. Increment it first, then use "i" for the prior index.
Solves this warning in the coming GCC that has __counted_by support:

../drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c: In function 'brcmf_internal_escan_add_info':
../drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c:3783:46: warning: operation on 'req->
n_channels' may be undefined [-Wsequence-point]
 3783 |                 req->channels[req->n_channels++] = chan;
      |                               ~~~~~~~~~~~~~~~^~

Fixes: e3eac9f32ec0 ("wifi: cfg80211: Annotate struct cfg80211_scan_request with __counted_by")
Cc: Arend van Spriel <aspriel@gmail.com>
Cc: Franky Lin <franky.lin@broadcom.com>
Cc: Hante Meuleman <hante.meuleman@broadcom.com>
Cc: Kalle Valo <kvalo@kernel.org>
Cc: Chi-hsien Lin <chi-hsien.lin@infineon.com>
Cc: Ian Lin <ian.lin@infineon.com>
Cc: Johannes Berg <johannes.berg@intel.com>
Cc: Wright Feng <wright.feng@cypress.com>
Cc: Hector Martin <marcan@marcan.st>
Cc: linux-wireless@vger.kernel.org
Cc: brcm80211-dev-list.pdl@broadcom.com
Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://msgid.link/20240126223150.work.548-kees@kernel.org
9 months agowifi: iwlwifi: mvm: make functions public
Shaul Triebitz [Thu, 1 Feb 2024 14:17:41 +0000 (16:17 +0200)]
wifi: iwlwifi: mvm: make functions public

In the following patch, iwl_mvm_roc_duration_and_delay and
iwl_mvm_roc_add_cmd will be called also from time-event.c.
Move then there (where they more belong) and make then
public.

Signed-off-by: Shaul Triebitz <shaul.triebitz@intel.com>
Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Link: https://msgid.link/20240201155157.3edafc4d59aa.Ic68e90758bcad9ae00e0aa602101842dac60e1a1@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
9 months agowifi: iwlwifi: bump FW API to 88 for AX/BZ/SC devices
Miri Korenblit [Thu, 1 Feb 2024 14:17:40 +0000 (16:17 +0200)]
wifi: iwlwifi: bump FW API to 88 for AX/BZ/SC devices

Start supporting API version 88 for new devices.

Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Reviewed-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://msgid.link/20240201155157.e35556d3f956.I6543857041a33e2b35e67eecf648c9cc6972e60a@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
9 months agowifi: iwlwifi: mvm: don't send BT_COEX_CI command on new devices
Emmanuel Grumbach [Thu, 1 Feb 2024 14:17:38 +0000 (16:17 +0200)]
wifi: iwlwifi: mvm: don't send BT_COEX_CI command on new devices

AX210 and above have this logic offloaded in the firmware and it just
ignores the command coming from the driver.
Stop sending it.

Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Link: https://msgid.link/20240201155157.4e3e0b52f98b.I7e9481050921d95c38f5a21ccc47112b3698e859@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
9 months agowifi: iwlwifi: read DSM functions from UEFI
Miri Korenblit [Thu, 1 Feb 2024 14:17:37 +0000 (16:17 +0200)]
wifi: iwlwifi: read DSM functions from UEFI

For each DSM function, try to first read it from the UEFI.
If the UEFI WIFI GUID is unclocked, or the DSM function in
UEFI is invalid/unavailable - read it from ACPI.

Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Reviewed-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://msgid.link/20240201155157.27dd626ce2bd.Ib90bab74a9d56deb2362edb712294360e4ddae5b@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
9 months agowifi: iwlwifi: prepare for reading DSM from UEFI
Miri Korenblit [Thu, 1 Feb 2024 14:17:36 +0000 (16:17 +0200)]
wifi: iwlwifi: prepare for reading DSM from UEFI

Move all the common items (functions, enumerations and mcaros)
to regulatory.h/c files, and rename it to a common name.

Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Reviewed-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://msgid.link/20240201155157.eae9bcbc0023.If1175f3143d6369076669ddd5d6ad4df0ee00659@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
9 months agowifi: iwlwifi: simplify getting DSM from ACPI
Miri Korenblit [Thu, 1 Feb 2024 14:17:35 +0000 (16:17 +0200)]
wifi: iwlwifi: simplify getting DSM from ACPI

As DSMs are going to be read from UEFI too, we need a unified API
to get DSMs for both ACPI and UEFI.

The difference in getting DSM in each one of these methods (ACPI, UEFI)
is in the GUID, revision (0 for ACPI, 4 for UEFI), and size of the DSM
values (8 or 32 for ACPI, 32 for UEFI).

Therefore, change the iwl_acpi_get_dsm_x() to iwl_acpi_get_dsm() which
determines the GUID, revision (these two are the same for all WiFi DSMs),
and size (based on a func-to-size mapping) internally.

While at it, fix DSM_FUNC_RFI_CONFIG to expect a 32-bit value
(as defined in Intel BIOS spec) and not a 8-bit one.

Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Reviewed-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://msgid.link/20240201155157.1bcd7072a7a5.I344ee0a11abbc27da0c693187d1b8bee653aaeef@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
9 months agowifi: iwlwifi: take send-DSM-to-FW flows out of ACPI ifdef
Miri Korenblit [Thu, 1 Feb 2024 14:17:34 +0000 (16:17 +0200)]
wifi: iwlwifi: take send-DSM-to-FW flows out of ACPI ifdef

These functions shouldn't be ACPI_CONFIG dependent, as they don't
access the ACPI. The functions that really access ACPI -
already handle the case that CONFIG_ACPI is not set.

Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Reviewed-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://msgid.link/20240201155157.1412e6d561f8.I84f67478d01b576457e1bf489fbcb044adfda6fe@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
9 months agowifi: iwlwifi: rfi: use a single DSM function for all RFI configurations
Miri Korenblit [Thu, 1 Feb 2024 14:17:33 +0000 (16:17 +0200)]
wifi: iwlwifi: rfi: use a single DSM function for all RFI configurations

RFI configuration moved from internal guid to the wifi guid, DSM
function 11. Update reading RFI configuration from BIOS.

Signed-off-by: Anjaneyulu <pagadala.yesu.anjaneyulu@intel.com>
Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Reviewed-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://msgid.link/20240201155157.f4e62435310d.I4f9b6860dd8e3c7ae1f816be5ff8b5967eee266f@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
9 months agowifi: iwlwifi: read ECKV table from UEFI
Miri Korenblit [Thu, 1 Feb 2024 14:17:32 +0000 (16:17 +0200)]
wifi: iwlwifi: read ECKV table from UEFI

Try to read the ECKV table from UEFI first,
and if the WIFI UEFI tables are unlocked or the
table doesn't exist - try to read it from ACPI.

Change iwl_acpi_get_eckv() to receive fwrt as argument so
it will be the same as all iwl_acpi_get_x() functions,
so it could  be generated by the macro.

While at it - move the reading of ECKV to INIT stage. There is no
reason to read it each time we load the FW.

Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Reviewed-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://msgid.link/20240201155157.d4937cc00727.I36e5fc7f7850229b9b377c80b5203aa47137c97c@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
9 months agowifi: iwlwifi: read WRDD table from UEFI
Miri Korenblit [Thu, 1 Feb 2024 14:17:31 +0000 (16:17 +0200)]
wifi: iwlwifi: read WRDD table from UEFI

Try to read the WRDD table from UEFI first,
and if the WIFI UEFI tables are unlocked or the
table doesn't exist - try to read it from ACPI.

Change iwl_acpi_get_mcc() to receive fwrt as argument so
it will be the same as all iwl_acpi_get_x() functions,
so it could be generated by the macro.

Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Reviewed-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://msgid.link/20240201155157.5d52eeb109f7.I4d81700a7ae7fe2dfee14e363de358be59de7823@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
9 months agowifi: iwlwifi: support link command version 2
Shaul Triebitz [Thu, 1 Feb 2024 14:17:29 +0000 (16:17 +0200)]
wifi: iwlwifi: support link command version 2

In version 2, listen_lmac becomes reserved.

Signed-off-by: Shaul Triebitz <shaul.triebitz@intel.com>
Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Link: https://msgid.link/20240201155157.df1890aba2fd.Icad9ba10f8bab770adc6a559b2c7bff5cccbffe9@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
9 months agowifi: iwlwifi: mvm: use fast balance scan in case of an active P2P GO
Ayala Beker [Thu, 1 Feb 2024 14:17:28 +0000 (16:17 +0200)]
wifi: iwlwifi: mvm: use fast balance scan in case of an active P2P GO

Set fast balance scan in case of active P2P GO, regardless of the
BSS DTIM interval.
This will increase the chances of scheduler to successfully schedule
out-of-channel events.

Signed-off-by: Ayala Beker <ayala.beker@intel.com>
Reviewed-by: Ilan Peer <ilan.peer@intel.com>
Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Link: https://msgid.link/20240201155157.310a00388e11.Ib136140dffa8704e68ff14e8fb69d35b97057171@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
9 months agowifi: iwlwifi: mvm: don't send NDPs for new tx devices
Emmanuel Grumbach [Thu, 1 Feb 2024 14:17:27 +0000 (16:17 +0200)]
wifi: iwlwifi: mvm: don't send NDPs for new tx devices

New tx devices may have issues sending NDPs from the host.
Send a CQM event instead. If the AP is really gone, we will get a beacon
loss and disconnect.

Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Reviewed-by: Gregory Greenman <gregory.greenman@intel.com>
Reviewed-by: Berg, Johannes <johannes.berg@intel.com>
Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Link: https://msgid.link/20240201155157.e95d53448e94.I0ec92f1ca56a62cd8c13390b9fe60e9a7e9411c7@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
9 months agowifi: iwlwifi: read SPLC from UEFI
Miri Korenblit [Thu, 1 Feb 2024 14:17:26 +0000 (16:17 +0200)]
wifi: iwlwifi: read SPLC from UEFI

Try to read the SPLC table from UEFI first,
and if the WIFI UEFI tables are unlocked or the
table doesn't exist - try to read it from ACPI

Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Reviewed-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://msgid.link/20240201155157.3d9d835b6edb.I7ea262df9431ced787b77c87149c6d7bddb7e7d6@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
9 months agowifi: iwlwifi: prepare for reading SPLC from UEFI
Miri Korenblit [Thu, 1 Feb 2024 14:17:25 +0000 (16:17 +0200)]
wifi: iwlwifi: prepare for reading SPLC from UEFI

As the iwl_bios_get_x() functions are now generated using a macro,
and this macro requires the all iwl_acpi_get_x() to have the same
prototype, change iwl_acpi_get_pwr_limit() to return a int
and the actuall power limit will be filled in a pointer function
parameter.

Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Reviewed-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://msgid.link/20240201155157.4cce81198afe.Ice8b1b97a68da9ec7b5a4799ddb668642198e1af@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
9 months agowifi: iwlwifi: do not announce EPCS support
Benjamin Berg [Thu, 1 Feb 2024 14:17:30 +0000 (16:17 +0200)]
wifi: iwlwifi: do not announce EPCS support

mac80211 does not have proper support for EPCS currently as that would
require changing the ECDA parameters if EPCS (Emergency Preparedness
Communications Service) is in use. As such, do not announce support for
it in the capabilities.

Signed-off-by: Benjamin Berg <benjamin.berg@intel.com>
Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Link: https://msgid.link/20240201155157.59d71656addc.Idde91b3018239c49fc6ed231b411d05354fb9fb1@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
9 months agowifi: iwlwifi: exit eSR only after the FW does
Miri Korenblit [Thu, 1 Feb 2024 14:17:39 +0000 (16:17 +0200)]
wifi: iwlwifi: exit eSR only after the FW does

Currently the driver exits eSR by calling
iwl_mvm_esr_mode_inactive() before updating the FW
(by deactivating one of the links), and therefore before
sending the EML frame notifying that we are no longer in eSR.

This is wrong for several reasons:
1. The driver sends SMPS activation frames when we are still in eSR
   and SMPS should be disabled when in eSR
2. The driver restores RLC configuration as it was before eSR
   entering, and RLC command shouldn't be sent in eSR

Fix this by calling iwl_mvm_esr_mode_inactive() after FW update

Fixes: 12bacfc2c065 ("wifi: iwlwifi: handle eSR transitions")
Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Reviewed-by: Ilan Peer <ilan.peer@intel.com>
Reviewed-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://msgid.link/20240201155157.d8d9dc277d4e.Ib5aee0fd05e35b1da7f18753eb3c8fa0a3f872f3@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
9 months agowifi: iwlwifi: api: clean up some kernel-doc/typos
Johannes Berg [Wed, 31 Jan 2024 21:02:27 +0000 (22:02 +0100)]
wifi: iwlwifi: api: clean up some kernel-doc/typos

Add some kernel-doc for a union, and fix a couple of typos
I noticed looking through this.

Link: https://msgid.link/20240131220227.7fd507f09bb1.I278edc9a3d5de7fddcd84009a93c494c42686b68@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
9 months agowifi: iwlwifi: remove unused function prototype
Johannes Berg [Wed, 31 Jan 2024 21:00:39 +0000 (22:00 +0100)]
wifi: iwlwifi: remove unused function prototype

Saw this while going through the code, this function
hasn't existed for a while now; remove it.

Link: https://msgid.link/20240131220039.6fdb8cbf4814.I6c46065b836cafd93df676dd88c99a626a25bf46@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
9 months agoiwlwifi: fw: fix more kernel-doc warnings
Emmanuel Grumbach [Wed, 31 Jan 2024 20:38:16 +0000 (21:38 +0100)]
iwlwifi: fw: fix more kernel-doc warnings

Fix some more kernel-doc warnings in FW API definitions.

Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Link: https://msgid.link/20240131213817.9f30c6529216.I69e98612c6c81cf1b7bd480d8041b5d3e25610d3@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
9 months agowifi: mac80211: don't allow deactivation of all links
Miri Korenblit [Mon, 29 Jan 2024 19:00:53 +0000 (20:00 +0100)]
wifi: mac80211: don't allow deactivation of all links

The set_active_links API is intended for link switching, so switching
to no links at all is not supported.
Add a warning to check that.

Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Link: https://msgid.link/20240129200054.e3c113f94508.Ia35f927f914bf98dd8f9350dd4f78b1d901b1c1d@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
9 months agowifi: mac80211_hwsim: enable all links only in MLO
Miri Korenblit [Mon, 29 Jan 2024 19:00:52 +0000 (20:00 +0100)]
wifi: mac80211_hwsim: enable all links only in MLO

The existing code is enabling all usable links when moving to
authorized state, but this should happen only for MLO connections.
Fix this.

Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Link: https://msgid.link/20240129200054.f5459f6c29c8.I397814449e17950fcf882ef44a1e790a71aa1dce@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
9 months agowifi: nl80211: move WPA version validation to policy
Johannes Berg [Mon, 29 Jan 2024 18:54:21 +0000 (19:54 +0100)]
wifi: nl80211: move WPA version validation to policy

For a contiguous mask (starting with bit 0) of allowed values
in a bitmap, it's equivalent to check "!(val & ~mask)" and
"val ∈ [0, mask]". Use that to move the WPA versions check to
the policy, for better error reporting.

Reviewed-by: Jeff Johnson <quic_jjohnson@quicinc.com>
Link: https://msgid.link/20240129195421.e8cae9866ccb.I2539b395e3476307d702c6867e51a937e52e57a0@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
9 months agowifi: mac80211: clean up FILS discovery change flags handling
Johannes Berg [Mon, 29 Jan 2024 18:57:39 +0000 (19:57 +0100)]
wifi: mac80211: clean up FILS discovery change flags handling

It doesn't make sense to return BSS change flags in an int, as
they're a bigger type. For this particular function it still
works OK, but clean it up to avoid future errors (or copying
this code in a broken way.)

Reviewed-by: Jeff Johnson <quic_jjohnson@quicinc.com>
Link: https://msgid.link/20240129195739.e340a7d5e7c6.I1dfcca32d43dce903494a2c474844491682671b4@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
9 months agowifi: mac80211: trace SMPS requests from driver
Johannes Berg [Mon, 29 Jan 2024 18:54:35 +0000 (19:54 +0100)]
wifi: mac80211: trace SMPS requests from driver

Even if there are a lot of possible ways drivers might
call this, at least knowing when they do and with what
settings can be useful. Add tracing for it.

Link: https://msgid.link/20240129195435.b20d2ead2013.I8213e65c274451d523a3397519ac578c3ed2df4d@changeid
[removed link-id contortions as suggested by Jeff]
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
9 months agowifi: mac80211_hwsim: add control to skip beacons
Johannes Berg [Mon, 29 Jan 2024 19:00:02 +0000 (20:00 +0100)]
wifi: mac80211_hwsim: add control to skip beacons

To test certain beacon loss scenarios it can be useful to
simply not send a couple of beacons. Add a simple debugfs
file (per vif) to skip sending the beacons. They're still
fully prepared etc. so their DTIM count etc. will appear
as if they were simply corrupt over the air or otherwise
not received.

Reviewed-by: Jeff Johnson <quic_jjohnson@quicinc.com>
Link: https://msgid.link/20240129200001.a267383709e6.I36f427d17c3478a7df46e205716f5ebc9b35a918@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
9 months agowifi: iwlwifi: read WTAS table from UEFI
Miri Korenblit [Wed, 31 Jan 2024 08:24:47 +0000 (10:24 +0200)]
wifi: iwlwifi: read WTAS table from UEFI

Try to read the WTAS table from UEFI first,
and if the WIFI UEFI tables are unlocked or the
table doesn't exist - try to read it from ACPI.

Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Reviewed-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://msgid.link/20240131091413.45e6ff7b5063.Id3aec70887e14533b10d564f32c0cf5f2a14b792@changeid
[move uefi_tables_lock_status outside ifdef to fix build errors]
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
9 months agowifi: iwlwifi: separate TAS 'read-from-BIOS' and 'send-to-FW' flows
Miri Korenblit [Wed, 31 Jan 2024 08:24:46 +0000 (10:24 +0200)]
wifi: iwlwifi: separate TAS 'read-from-BIOS' and 'send-to-FW' flows

Currently the TAS 'read-from-BIOS' flow receives the command struct
and the version of it as read from FW TLVs, and fills the command
accordingly.
This seems wrong, we should have the 'read-from-BIOS' flow
(iwl_acpi_get_tas in iwlwifi) reading/parsing/validating the table from
BIOS, and the 'send-to-FW' flow (iwl_mvm_tas_init) doing
all the FW versioning checks and cmd filling.
Move the cmd filling to the 'send-to-fw' flow.

Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Reviewed-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://msgid.link/20240131091413.24df27772a71.I57b702af4feb3f38dc21d52593c25de4b1999e4b@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
9 months agowifi: iwlwifi: prepare for reading TAS table from UEFI
Miri Korenblit [Wed, 31 Jan 2024 08:24:45 +0000 (10:24 +0200)]
wifi: iwlwifi: prepare for reading TAS table from UEFI

We are going to support reading BIOS tables from UEFI
too, Refactor the TAS table flow:

1. Rename and move the common code to the regulatory.h/c files.
2. Remove the IWL_TAS_BLOCK_LIST_MAX, as we can use IWL_WTAS_BLACK_LIST_MAX
   instead.

Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Reviewed-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://msgid.link/20240131091413.0c2197cf1feb.Ib0e83d5bd3f4d5cfa9c3d2925317ba49377d257f@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
9 months agowifi: iwlwifi: don't check TAS block list size twice
Miri Korenblit [Wed, 31 Jan 2024 08:24:44 +0000 (10:24 +0200)]
wifi: iwlwifi: don't check TAS block list size twice

Currenltly we check the validity of this variable twice.
Remove the second check.

Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Reviewed-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://msgid.link/20240131091413.2234490624c4.I6399b652a3c83afff1b0b5f114604d15892ee01e@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
9 months agowifi: iwlwifi: read PPAG table from UEFI
Miri Korenblit [Wed, 31 Jan 2024 08:24:43 +0000 (10:24 +0200)]
wifi: iwlwifi: read PPAG table from UEFI

Try to read the PPAG table from UEFI first,
and if the WIFI UEFI tables are unlocked or the
table doesn't exist - try to read it from ACPI

Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Reviewed-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://msgid.link/20240131091413.6516da09aec1.I0dcaf0b6d8857417ba1318467a28da5d0d7d7f27@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
9 months agowifi: iwlwifi: validate PPAG table when sent to FW
Miri Korenblit [Wed, 31 Jan 2024 08:24:42 +0000 (10:24 +0200)]
wifi: iwlwifi: validate PPAG table when sent to FW

We used to check enablement/validity of the PPAG table while reading
it from BIOS.
For newer FWs this checks were offloaded, and the driver needs
to send the PPAG table anyway.
The desicion whether the table needs to be validated before sending it
is FW related and shouln't be in 'read-from-bios' flow.
Move it to 'send-to-fw' flow instead.
This will also help to avoid code duplication of checking validity in
both ACPI and UEFI caes.

Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Reviewed-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://msgid.link/20240131091413.7043b4087dda.I5a189f9a349556b84a79597fe1e46ffa93664df9@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
9 months agowifi: iwlwifi: prepare for reading PPAG table from UEFI
Miri Korenblit [Wed, 31 Jan 2024 08:24:41 +0000 (10:24 +0200)]
wifi: iwlwifi: prepare for reading PPAG table from UEFI

As PPAG table is going to be read from UEFI, there are some
cleanups required:
Move functions/definitions that are common to both UEFI and ACPI to
regulatory.h/c.
In addition, rename the functions/macros names so it will be clear which
one is ACPI specific, and which is common for ACPI and UEFI.

Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Reviewed-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://msgid.link/20240131091413.25623670b422.I8132af7517e4faf0ea8cbeb2efe9651edd319b98@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
9 months agowifi: iwlwifi: small cleanups in PPAG table flows
Miri Korenblit [Wed, 31 Jan 2024 08:24:40 +0000 (10:24 +0200)]
wifi: iwlwifi: small cleanups in PPAG table flows

1. The name of iwl_read_ppag_table is misleading, as this function only
   fills the command structure from the previously read table. Rename it.
2. Don't initialize fwrt::ppag_flags to 0 as the entire fwrt is zeroed
   in the INIT stage anyway.
3. Don't filter out the reserved bits from fwrt::ppag_flags when printing
   it, as it is already done in 'read-from-bios' flow.

Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Reviewed-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://msgid.link/20240131091413.48acf340e817.I810e457b80015c1931d96d3e13c849f0339723c3@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>