From: Josef Schlehofer <pepe.schlehofer@gmail.com>
To: Jeff Johnson <jjohnson@kernel.org>
Cc: linux-wireless@vger.kernel.org
Subject: [PATCH ath-next 8/9] wifi: ath6kl: honour ieee80211-freq-limit from DT
Date: Mon, 30 Nov 2026 10:50:41 +0100 [thread overview]
Message-ID: <20261130095042.41330-9-pepe.schlehofer@gmail.com> (raw)
In-Reply-To: <20261130095042.41330-1-pepe.schlehofer@gmail.com>
The AR6006 firmware in the Xiaomi AIoT AC2350 reports a dual band phy
in its ready event, but the board only has a 2.4 GHz front end. A scan
on that router saw no 5 GHz network at all, not even the router's own.
Call wiphy_read_of_freq_limits() before the wiphy is registered, so a
board can describe the limit with ieee80211-freq-limit on the node of
the USB device. It works on the per-device channel copies, so other
ath6kl devices are not affected. A band that has no enabled channel
left is dropped from the wiphy, so user space does not see a band
full of disabled channels. A limit that leaves no channel at all only
gets a warning. The ath6kl loops over wiphy->bands already skip a
missing band, and the previous patch handles a connection on a
frequency that has no channel.
ath6kl does not pass the limit to the firmware, which picks the
network on its own. Reject a connection on a channel that the limit
disabled, as the previous patch does for a frequency without a
channel. The check uses orig_flags, as brcmfmac does, so a channel
that only the regulatory domain disables is not affected.
Signed-off-by: Josef Schlehofer <pepe.schlehofer@gmail.com>
---
On the router, ieee80211-freq-limit = <2400000 2483000> on the node of
the USB port, added at runtime, left only the 2.4 GHz band in iw phy,
and station and AP mode worked. With <2400000 2430000> only channels 1
and 2 stayed enabled, and connections the firmware made on channel 6
were rejected.
drivers/net/wireless/ath/ath6kl/cfg80211.c | 41 ++++++++++++++++++++++
drivers/net/wireless/ath/ath6kl/main.c | 8 +++--
2 files changed, 47 insertions(+), 2 deletions(-)
diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c
index 7f1ffe4b7..97107510b 100644
--- a/drivers/net/wireless/ath/ath6kl/cfg80211.c
+++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c
@@ -3875,6 +3875,39 @@ static const struct wiphy_wowlan_support ath6kl_wowlan_support = {
};
#endif
+static bool
+ath6kl_band_has_channel(const struct ieee80211_supported_band *sband)
+{
+ int i;
+
+ for (i = 0; i < sband->n_channels; i++)
+ if (!(sband->channels[i].flags & IEEE80211_CHAN_DISABLED))
+ return true;
+
+ return false;
+}
+
+/* drop bands without an enabled channel, unless no band would be left */
+static void ath6kl_drop_empty_bands(struct wiphy *wiphy)
+{
+ int band, left = 0;
+
+ for (band = 0; band < NUM_NL80211_BANDS; band++)
+ if (wiphy->bands[band] &&
+ ath6kl_band_has_channel(wiphy->bands[band]))
+ left++;
+
+ if (!left) {
+ ath6kl_warn("ieee80211-freq-limit leaves no channel\n");
+ return;
+ }
+
+ for (band = 0; band < NUM_NL80211_BANDS; band++)
+ if (wiphy->bands[band] &&
+ !ath6kl_band_has_channel(wiphy->bands[band]))
+ wiphy->bands[band] = NULL;
+}
+
int ath6kl_cfg80211_init(struct ath6kl *ar)
{
struct wiphy *wiphy = ar->wiphy;
@@ -3990,6 +4023,14 @@ int ath6kl_cfg80211_init(struct ath6kl *ar)
if (band_5gig)
wiphy->bands[NL80211_BAND_5GHZ] = &ar->band_5ghz;
+ /*
+ * Some boards only have a front end for one band although the
+ * firmware reports a dual band phy. Let the device tree limit the
+ * channels and drop a band that has none left.
+ */
+ wiphy_read_of_freq_limits(wiphy);
+ ath6kl_drop_empty_bands(wiphy);
+
wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM;
wiphy->cipher_suites = cipher_suites;
diff --git a/drivers/net/wireless/ath/ath6kl/main.c b/drivers/net/wireless/ath/ath6kl/main.c
index a062598ce..20fa471a9 100644
--- a/drivers/net/wireless/ath/ath6kl/main.c
+++ b/drivers/net/wireless/ath/ath6kl/main.c
@@ -632,12 +632,16 @@ void ath6kl_connect_event(struct ath6kl_vif *vif, u16 channel, u8 *bssid,
u8 *assoc_info)
{
struct ath6kl *ar = vif->ar;
+ struct ieee80211_channel *chan;
/*
* cfg80211 needs a channel for the BSS. Reject a connection on a
- * frequency that has no channel on this device.
+ * frequency without a channel here, or on a channel disabled before
+ * wiphy_register() (orig_flags), as ieee80211-freq-limit does. Later
+ * regulatory updates only change flags.
*/
- if (!ieee80211_get_channel(ar->wiphy, channel)) {
+ chan = ieee80211_get_channel(ar->wiphy, channel);
+ if (!chan || (chan->orig_flags & IEEE80211_CHAN_DISABLED)) {
ath6kl_err("connected on unsupported frequency %u MHz\n", channel);
ath6kl_wmi_disconnect_cmd(ar->wmi, vif->fw_vif_idx);
ath6kl_disconnect_event(vif, DISCONNECT_CMD, bssid, 0, NULL,
--
2.54.0 (Apple Git-157)
next prev parent reply other threads:[~2026-11-30 9:50 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-30 9:50 [PATCH ath-next 0/9] wifi: ath6kl: add AR6006 hw1.1 (QCA6006) support Josef Schlehofer
2026-11-30 9:50 ` [PATCH ath-next 1/9] wifi: ath6kl: add AR6006 hw1.1 support Josef Schlehofer
2026-11-30 9:50 ` [PATCH ath-next 2/9] wifi: ath6kl: handle the AR6006 WMI layout Josef Schlehofer
2026-11-30 9:50 ` [PATCH ath-next 3/9] wifi: ath6kl: ignore AR6006 regulatory domain events Josef Schlehofer
2026-11-30 9:50 ` [PATCH ath-next 4/9] wifi: ath6kl: use per-device band and channel copies Josef Schlehofer
2026-11-30 9:50 ` [PATCH ath-next 5/9] dt-bindings: net: wireless: add QCA6006 binding Josef Schlehofer
2026-11-30 9:50 ` [PATCH ath-next 6/9] wifi: ath6kl: take the AR6006 MAC address from DT Josef Schlehofer
2026-11-30 9:50 ` [PATCH ath-next 7/9] wifi: ath6kl: handle unsupported connection frequencies Josef Schlehofer
2026-11-30 9:50 ` Josef Schlehofer [this message]
2026-11-30 9:50 ` [PATCH ath-next 9/9] wifi: ath6kl: add QCA6006 USB ID Josef Schlehofer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261130095042.41330-9-pepe.schlehofer@gmail.com \
--to=pepe.schlehofer@gmail.com \
--cc=jjohnson@kernel.org \
--cc=linux-wireless@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox