Skip to contentSkip to conversation

wifi: ath6kl: add AR6006 hw1.1 (QCA6006) support

PATCH New Josef Schlehofer 1 participant 10 messages Nov 30

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover wifi: ath6kl: add AR6006 hw1.1 (QCA6006) support

This series adds the AR6006 hw1.1 (QCA6006, USB 0cf3:9372) to ath6kl. The chip is the third radio of the Xiaomi AIoT AC2350 router and its second 2.4 GHz radio. The router runs OpenWrt on a big-endian QCA9563.

It depends on the big-endian fixes sent earlier:
https://lore.kernel.org/r/[email protected]

The series ran on that router with OpenWrt 25.12, backported to its backports 6.18.55 tree. The MAC address and the 2.4 GHz limit came from the device tree, added at runtime to the existing node of the USB port. The firmware booted, station mode joined a WPA2 network and got a DHCP lease, and AP mode associated a WPA2 client with unicast data both ways. Further runs took the MAC address from an nvmem cell, went through a deferred probe and let the firmware connect on a channel outside the limit, which the driver rejected. I only had one ath6kl device available, so I could not test two devices at the same time. Suspend/resume and firmware recovery were not tested either.

Patch 4 gives every device its own band and channel copies, so the device tree limit in patch 8 does not touch other ath6kl devices. Patches 5, 6 and 8 add a device tree binding, the MAC address from the device tree and ieee80211-freq-limit. Patch 7 fixes an old NULL dereference for a connection on a frequency that has no channel, which a dropped band makes more likely. The USB ID comes last, so no bisect point binds the driver to the chip early.

HT is not advertised to cfg80211 because this firmware does not provide RSN-CAP-OVERRIDE. The firmware nevertheless selected HT rates in station mode, while the AP ran without HT. The vendor driver sets the RSN capabilities with a separate command, which could be added later.

The firmware is not in linux-firmware. I asked Qualcomm about it here:
https://lore.kernel.org/r/[email protected]

The binding passes dt_binding_check. All patches build without warnings with W=1 and sparse for big- and little-endian MIPS.

Josef Schlehofer (9):
wifi: ath6kl: add AR6006 hw1.1 support
wifi: ath6kl: handle the AR6006 WMI layout
wifi: ath6kl: ignore AR6006 regulatory domain events
wifi: ath6kl: use per-device band and channel copies
dt-bindings: net: wireless: add QCA6006 binding
wifi: ath6kl: take the AR6006 MAC address from DT
wifi: ath6kl: handle unsupported connection frequencies
wifi: ath6kl: honour ieee80211-freq-limit from DT
wifi: ath6kl: add QCA6006 USB ID

 .../bindings/net/wireless/qcom,qca6006.yaml   |  56 ++++++++
 MAINTAINERS                                   |   1 +
 drivers/net/wireless/ath/ath6kl/Kconfig       |   4 +-
 drivers/net/wireless/ath/ath6kl/bmi.h         |   1 +
 drivers/net/wireless/ath/ath6kl/cfg80211.c    | 102 +++++++++++---
 drivers/net/wireless/ath/ath6kl/core.c        |  13 ++
 drivers/net/wireless/ath/ath6kl/core.h        |  26 ++++
 drivers/net/wireless/ath/ath6kl/init.c        | 128 ++++++++++++++++--
 drivers/net/wireless/ath/ath6kl/main.c        |  39 +++++-
 drivers/net/wireless/ath/ath6kl/target.h      |   8 +-
 drivers/net/wireless/ath/ath6kl/usb.c         |   6 +-
 drivers/net/wireless/ath/ath6kl/wmi.c         |  88 ++++++++++--
 drivers/net/wireless/ath/ath6kl/wmi.h         |  51 +++++++
 13 files changed, 475 insertions(+), 48 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/net/wireless/qcom,qca6006.yaml

base-commit: 18d0bedbb5f0538396cb7f763ed9cd1dd69c5b23
prerequisite-patch-id: 89962941e5e2bec4646eadeb25f7429dec473b24
prerequisite-patch-id: 8ef8976331b491b95bde120d4e16f11bb2201feb
prerequisite-patch-id: fce0da8f0fbbba34b79af8437b3842d93af001b6

Signature · 1 line
2.54.0 (Apple Git-157)
#1 lore raw

PATCH 1/9 wifi: ath6kl: add AR6006 hw1.1 support

The AR6006 hw1.1 (version 0x31c80002, target type 6) is a USB chip, for example the QCA6006 in the Xiaomi AIoT AC2350 router. It is close to the AR6004 hw3.0, so most AR6004 branches apply to it as well.

Add a hw_list entry with its own host interest area at 0x00428800, board data at 0x46e400 and a 40 MHz reference clock. The values come from Qualcomm's ath6kl-3.5 driver. Like the AR6004 it needs no BMI_SET_APP_START and no write to the analog PLL register. ath6kl-3.5 skips both for the AR6004 and the AR6006.

The firmware does not use HTC credit flow control on USB. Add ATH6KL_HW_NO_HTC_CREDIT_FLOW and set HTC_CONN_FLGS_DISABLE_CRED_FLOW_CTRL on all service endpoints for it. The fw.ram.bin firmware (API 1) carries no capability list, so enable 64BIT_RATES, MAP_LP_ENDPOINT and NO_IP_CHECKSUM for it, as is done for older AR6004 firmware.

---
The series ran on OpenWrt 25.12 (backports 6.18.55) on a big-endian QCA9563 router. The firmware booted, station mode joined a WPA2 network and got a DHCP lease, and AP mode associated a WPA2 client with unicast data both ways.

 drivers/net/wireless/ath/ath6kl/bmi.h    |  1 +
 drivers/net/wireless/ath/ath6kl/core.c   |  8 ++++
 drivers/net/wireless/ath/ath6kl/core.h   | 11 ++++++
 drivers/net/wireless/ath/ath6kl/init.c   | 50 ++++++++++++++++++++----
 drivers/net/wireless/ath/ath6kl/target.h |  8 +++-
 5 files changed, 69 insertions(+), 9 deletions(-)
drivers/net/wireless/ath/ath6kl/bmi.h +1 -0
index 397a52f26..af2f464ee 100644
@@ -136,6 +136,7 @@
 #define TARGET_VERSION_SENTINAL 0xffffffff
 #define TARGET_TYPE_AR6003      3
 #define TARGET_TYPE_AR6004      5
+#define TARGET_TYPE_AR6006      6
 #define BMI_ROMPATCH_INSTALL               9
 /*
  * Semantics: Install a ROM Patch.
drivers/net/wireless/ath/ath6kl/core.c +8 -0
index 1ed773eca..9762de89e 100644
@@ -141,6 +141,14 @@ int ath6kl_core_init(struct ath6kl *ar, enum ath6kl_htc_type htc_type)
 				  ar->fw_capabilities);
 	}
 
+	/* AR6006 fw.ram.bin (API 1) carries no capability list */
+	if (ar->target_type == TARGET_TYPE_AR6006 && ar->fw_api == 1) {
+		__set_bit(ATH6KL_FW_CAPABILITY_64BIT_RATES, ar->fw_capabilities);
+		__set_bit(ATH6KL_FW_CAPABILITY_MAP_LP_ENDPOINT,
+			  ar->fw_capabilities);
+		__set_bit(ATH6KL_FW_CAPABILITY_NO_IP_CHECKSUM, ar->fw_capabilities);
+	}
+
 	/* Indicate that WMI is enabled (although not ready yet) */
 	set_bit(WMI_ENABLED, &ar->flag);
 	ar->wmi = ath6kl_wmi_init(ar);
drivers/net/wireless/ath/ath6kl/core.h +11 -0
index a0b236eee..747ff2079 100644
@@ -165,6 +165,8 @@ struct ath6kl_fw_ie {
 
 enum ath6kl_hw_flags {
 	ATH6KL_HW_SDIO_CRC_ERROR_WAR	= BIT(3),
+	/* the target does not use HTC credit flow control (USB) */
+	ATH6KL_HW_NO_HTC_CREDIT_FLOW	= BIT(4),
 };
 
 #define ATH6KL_FW_API2_FILE "fw-2.bin"
@@ -244,6 +246,13 @@ enum ath6kl_hw_flags {
 #define AR6004_HW_3_0_BOARD_DATA_FILE	      AR6004_HW_3_0_FW_DIR "/bdata.bin"
 #define AR6004_HW_3_0_DEFAULT_BOARD_DATA_FILE AR6004_HW_3_0_FW_DIR "/bdata.bin"
 
+/* AR6006 1.1 definitions */
+#define AR6006_HW_1_1_VERSION			0x31c80002
+#define AR6006_HW_1_1_FW_DIR			"ath6k/AR6006/hw1.1"
+#define AR6006_HW_1_1_FIRMWARE_FILE		"fw.ram.bin"
+#define AR6006_HW_1_1_BOARD_DATA_FILE		AR6006_HW_1_1_FW_DIR "/bdata.bin"
+#define AR6006_HW_1_1_DEFAULT_BOARD_DATA_FILE	AR6006_HW_1_1_FW_DIR "/bdata.bin"
+
 /* Per STA data, used in AP mode */
 #define STA_PS_AWAKE		BIT(0)
 #define	STA_PS_SLEEP		BIT(1)
@@ -888,6 +897,8 @@ static inline u32 ath6kl_get_hi_item_addr(struct ath6kl *ar,
 		addr = ATH6KL_AR6003_HI_START_ADDR + item_offset;
 	else if (ar->target_type == TARGET_TYPE_AR6004)
 		addr = ATH6KL_AR6004_HI_START_ADDR + item_offset;
+	else if (ar->target_type == TARGET_TYPE_AR6006)
+		addr = ATH6KL_AR6006_HI_START_ADDR + item_offset;
 
 	return addr;
 }
drivers/net/wireless/ath/ath6kl/init.c +42 -8

105 lines not on this page · raw message

drivers/net/wireless/ath/ath6kl/target.h +7 -1
index d5eeeae77..83a8bf0b5 100644
@@ -25,6 +25,9 @@
 #define AR6004_BOARD_DATA_SZ     6144
 #define AR6004_BOARD_EXT_DATA_SZ 0
 
+#define AR6006_BOARD_DATA_SZ     6144
+#define AR6006_BOARD_EXT_DATA_SZ 0
+
 #define RESET_CONTROL_ADDRESS		0x00004000
 #define RESET_CONTROL_COLD_RST		0x00000100
 #define RESET_CONTROL_MBOX_RST		0x00000004
@@ -143,6 +146,7 @@
  */
 #define ATH6KL_AR6003_HI_START_ADDR           0x00540600
 #define ATH6KL_AR6004_HI_START_ADDR           0x00400800
+#define ATH6KL_AR6006_HI_START_ADDR           0x00428800
 
 /*
  * These are items that the Host may need to access
@@ -332,10 +336,12 @@ struct host_interest {
 /* Convert a Target virtual address into a Target physical address */
 #define AR6003_VTOP(vaddr) ((vaddr) & 0x001fffff)
 #define AR6004_VTOP(vaddr) (vaddr)
+#define AR6006_VTOP(vaddr) (vaddr)
 
 #define TARG_VTOP(target_type, vaddr) \
 	(((target_type) == TARGET_TYPE_AR6003) ? AR6003_VTOP(vaddr) : \
-	(((target_type) == TARGET_TYPE_AR6004) ? AR6004_VTOP(vaddr) : 0))
+	(((target_type) == TARGET_TYPE_AR6004) ? AR6004_VTOP(vaddr) : \
+	(((target_type) == TARGET_TYPE_AR6006) ? AR6006_VTOP(vaddr) : 0)))
 
 #define ATH6KL_FWLOG_PAYLOAD_SIZE		1500
 
Signature · 1 line
2.54.0 (Apple Git-157)
#2 lore raw

PATCH 2/9 wifi: ath6kl: handle the AR6006 WMI layout

In reply to Josef Schlehofer

The AR6006 hw1.1 firmware 5.x uses the WMI layout of Qualcomm's ath6kl-3.5 driver, not the one of mainline ath6kl. Most command and event IDs match, but a few payloads differ:

- WMI_CONNECT_CMDID and WMI_AP_CONFIG_COMMIT_CMDID take 52 bytes, without the trailing nw_subtype.
- WMI_SET_BEACON_INT_CMDID takes 16 bits and WMI_AP_SET_DTIM_CMDID 8 bits.
- The STA part of WMI_CONNECT_EVENTID has a 16-bit nw_type, followed by tx_scheduler_enabled and aid.
- The AP station part of WMI_CONNECT_EVENTID has phymode before aid.
- The AP per station statistics use a 43-byte record.

Add ATH6KL_HW_VENDOR_WMI and set it for the AR6006. Behind it, send the shorter payloads and read the vendor variants of the connect event and the statistics. Other chips are not affected.

WMI_AP_CONN_INACT_CMDID is shorter in this layout as well, but ath6kl only sends it with the INACTIVITY_TIMEOUT capability, which this firmware does not get. It is left alone.

---
The series ran on OpenWrt 25.12 (backports 6.18.55) on a big-endian QCA9563 router. Station mode joined a WPA2 network and got a DHCP lease, and AP mode associated a WPA2 client with unicast data both ways. The AP statistics are only read through debugfs and did not run.

 drivers/net/wireless/ath/ath6kl/core.h |  2 +
 drivers/net/wireless/ath/ath6kl/init.c |  3 +-
 drivers/net/wireless/ath/ath6kl/main.c | 23 +++++++-
 drivers/net/wireless/ath/ath6kl/wmi.c  | 78 +++++++++++++++++++++-----
 drivers/net/wireless/ath/ath6kl/wmi.h  | 51 +++++++++++++++++
 5 files changed, 141 insertions(+), 16 deletions(-)
drivers/net/wireless/ath/ath6kl/core.h +2 -0
index 747ff2079..31cd88d83 100644
@@ -167,6 +167,8 @@ enum ath6kl_hw_flags {
 	ATH6KL_HW_SDIO_CRC_ERROR_WAR	= BIT(3),
 	/* the target does not use HTC credit flow control (USB) */
 	ATH6KL_HW_NO_HTC_CREDIT_FLOW	= BIT(4),
+	/* firmware 5.x with the WMI layout of ath6kl-3.5 (AR6006) */
+	ATH6KL_HW_VENDOR_WMI		= BIT(5),
 };
 
 #define ATH6KL_FW_API2_FILE "fw-2.bin"
drivers/net/wireless/ath/ath6kl/init.c +2 -1
index 8d1a1aa8a..745c49fcd 100644
@@ -198,7 +198,8 @@ static const struct ath6kl_hw hw_list[] = {
 		.refclk_hz			= 40000000,
 		.testscript_addr		= 0,
 		.uarttx_pin			= 11,
-		.flags				= ATH6KL_HW_NO_HTC_CREDIT_FLOW,
+		.flags				= ATH6KL_HW_NO_HTC_CREDIT_FLOW |
+						  ATH6KL_HW_VENDOR_WMI,
 
 		.fw = {
 			.dir		= AR6006_HW_1_1_FW_DIR,
drivers/net/wireless/ath/ath6kl/main.c +22 -1
index 9c023d7ce..9dd39d79f 100644
@@ -827,7 +827,28 @@ void ath6kl_tgt_stats_event(struct ath6kl_vif *vif, u8 *ptr, u32 len)
 	struct wmi_per_sta_stat *st_ap, *st_p;
 	u8 ac;
 
-	if (vif->nw_type == AP_NETWORK) {
+	if (vif->nw_type == AP_NETWORK &&
+	    (ar->hw.flags & ATH6KL_HW_VENDOR_WMI)) {
+		struct wmi_ap_mode_stat_vendor *pv = (void *)ptr;
+		struct wmi_per_sta_stat_vendor *sv;
+
+		if (len < sizeof(*pv))
+			return;
+
+		for (ac = 0; ac < AP_MAX_NUM_STA; ac++) {
+			st_ap = &ap->sta[ac];
+			sv = &pv->sta[ac];
+
+			ath6kl_add_le32(&st_ap->tx_bytes, sv->tx_bytes);
+			ath6kl_add_le32(&st_ap->tx_pkts, sv->tx_pkts);
+			ath6kl_add_le32(&st_ap->tx_error, sv->tx_error);
+			ath6kl_add_le32(&st_ap->tx_discard, sv->tx_discard);
+			ath6kl_add_le32(&st_ap->rx_bytes, sv->rx_bytes);
+			ath6kl_add_le32(&st_ap->rx_pkts, sv->rx_pkts);
+			ath6kl_add_le32(&st_ap->rx_error, sv->rx_error);
+			ath6kl_add_le32(&st_ap->rx_discard, sv->rx_discard);
+		}
+	} else if (vif->nw_type == AP_NETWORK) {
 		if (len < sizeof(*p))
 			return;
 
drivers/net/wireless/ath/ath6kl/wmi.c +64 -14

151 lines not on this page · raw message

drivers/net/wireless/ath/ath6kl/wmi.h +51 -0

69 lines not on this page · raw message

Signature · 1 line
2.54.0 (Apple Git-157)
#3 lore raw

PATCH 3/9 wifi: ath6kl: ignore AR6006 regulatory domain events

In reply to Josef Schlehofer

The AR6006 hw1.1 firmware sends regdomain events with a country that varies. On one router it reported 0x4000006a (no country) at load, then about 0.6 s later 0x80000114 (DE) in one run and 0x800000cb (CZ) in another. Every time an AP started it reported 0x80000348 (US). Why the country varies is not known. A country taken from nearby beacons is one possibility.

ath6kl passes the country to regulatory_hint(). On a router with other radios this intersects the global regulatory domain with that country. In testing the global domain turned from CZ into "98". After an AP started it became "98" with DFS-UNSET and without channels 12 and 13.

The host cannot set the country in this firmware either. WMI_SET_REGDOMAIN_CMDID is 0xf0b0 in this WMI layout and 0xf08f in mainline, and ath6kl only sends it with the REGDOMAIN capability, which this firmware does not get.

Ignore the regdomain event for the AR6006 and leave the country to user space.

---
The series ran on OpenWrt 25.12 (backports 6.18.55) on a big-endian QCA9563 router with two other radios. The global regulatory domain stayed unchanged at load and after an AP started.

 drivers/net/wireless/ath/ath6kl/wmi.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
drivers/net/wireless/ath/ath6kl/wmi.c +10 -0
index 941612c68..238dbfcf3 100644
@@ -1054,6 +1054,16 @@ static void ath6kl_wmi_regdomain_event(struct wmi *wmi, u8 *datap, int len)
 	char alpha2[2];
 	u32 reg_code;
 
+	/*
+	 * The AR6006 firmware reports a varying country. Passing it on
+	 * changes the global regulatory domain for the other radios of the
+	 * system, so ignore it for this chip.
+	 */
+	if (wmi->parent_dev->target_type == TARGET_TYPE_AR6006) {
+		ath6kl_dbg(ATH6KL_DBG_WMI, "ignoring AR6006 regdomain event\n");
+		return;
+	}
+
 	ev = (struct ath6kl_wmi_regdomain *) datap;
 	reg_code = le32_to_cpu(ev->reg_code);
 
Signature · 1 line
2.54.0 (Apple Git-157)
#4 lore raw

PATCH 4/9 wifi: ath6kl: use per-device band and channel copies

In reply to Josef Schlehofer

ath6kl registers the same static band and channel structures for every device. ath6kl_cfg80211_init() already changes the HT capabilities of these shared structures to match the firmware of the device being probed, so a second device inherits them. A per-board channel limit from the device tree would have the same problem.

Copy the band and channel templates into struct ath6kl and register the copies. The HT adjustments and the one reader of the 2.4 GHz HT support now use the copies. The bitrate tables stay shared.

---
This touches every ath6kl chip. Only an AR6006 hw1.1 on USB was available for testing. It ran there with the rest of the series, but two ath6kl devices side by side did not run.

 drivers/net/wireless/ath/ath6kl/cfg80211.c | 50 ++++++++++++++--------
 drivers/net/wireless/ath/ath6kl/core.h     |  9 ++++
 2 files changed, 40 insertions(+), 19 deletions(-)
drivers/net/wireless/ath/ath6kl/cfg80211.c +31 -19
index c91560d55..6b03627e2 100644
@@ -85,7 +85,7 @@ static struct ieee80211_rate ath6kl_rates[] = {
 			IEEE80211_HT_CAP_SGI_20		 | \
 			IEEE80211_HT_CAP_SGI_40)
 
-static struct ieee80211_channel ath6kl_2ghz_channels[] = {
+static const struct ieee80211_channel ath6kl_2ghz_channels[] = {
 	CHAN2G(1, 2412, 0),
 	CHAN2G(2, 2417, 0),
 	CHAN2G(3, 2422, 0),
@@ -102,7 +102,7 @@ static struct ieee80211_channel ath6kl_2ghz_channels[] = {
 	CHAN2G(14, 2484, 0),
 };
 
-static struct ieee80211_channel ath6kl_5ghz_a_channels[] = {
+static const struct ieee80211_channel ath6kl_5ghz_a_channels[] = {
 	CHAN5G(36, 0), CHAN5G(40, 0),
 	CHAN5G(44, 0), CHAN5G(48, 0),
 	CHAN5G(52, 0), CHAN5G(56, 0),
@@ -122,18 +122,16 @@ static struct ieee80211_channel ath6kl_5ghz_a_channels[] = {
 	CHAN5G(216, 0),
 };
 
-static struct ieee80211_supported_band ath6kl_band_2ghz = {
+static const struct ieee80211_supported_band ath6kl_band_2ghz = {
 	.n_channels = ARRAY_SIZE(ath6kl_2ghz_channels),
-	.channels = ath6kl_2ghz_channels,
 	.n_bitrates = ath6kl_g_rates_size,
 	.bitrates = ath6kl_g_rates,
 	.ht_cap.cap = ath6kl_g_htcap,
 	.ht_cap.ht_supported = true,
 };
 
-static struct ieee80211_supported_band ath6kl_band_5ghz = {
+static const struct ieee80211_supported_band ath6kl_band_5ghz = {
 	.n_channels = ARRAY_SIZE(ath6kl_5ghz_a_channels),
-	.channels = ath6kl_5ghz_a_channels,
 	.n_bitrates = ath6kl_a_rates_size,
 	.bitrates = ath6kl_a_rates,
 	.ht_cap.cap = ath6kl_a_htcap,
@@ -1121,7 +1119,7 @@ void ath6kl_cfg80211_ch_switch_notify(struct ath6kl_vif *vif, int freq,
 	cfg80211_chandef_create(&chandef,
 				ieee80211_get_channel(vif->ar->wiphy, freq),
 				(mode == WMI_11G_HT20 &&
-				 ath6kl_band_2ghz.ht_cap.ht_supported) ?
+				 vif->ar->band_2ghz.ht_cap.ht_supported) ?
 					NL80211_CHAN_HT20 : NL80211_CHAN_NO_HT);
 
 	wiphy_lock(vif->ar->wiphy);
@@ -3931,6 +3929,20 @@ int ath6kl_cfg80211_init(struct ath6kl *ar)
 		return -EINVAL;
 	}
 
+	BUILD_BUG_ON(ARRAY_SIZE(ath6kl_2ghz_channels) !=
+		     ATH6KL_NUM_2GHZ_CHANNELS);
+	BUILD_BUG_ON(ARRAY_SIZE(ath6kl_5ghz_a_channels) !=
+		     ATH6KL_NUM_5GHZ_CHANNELS);
+
+	memcpy(ar->channels_2ghz, ath6kl_2ghz_channels,
+	       sizeof(ar->channels_2ghz));
+	memcpy(ar->channels_5ghz, ath6kl_5ghz_a_channels,
+	       sizeof(ar->channels_5ghz));
+	ar->band_2ghz = ath6kl_band_2ghz;
+	ar->band_2ghz.channels = ar->channels_2ghz;
+	ar->band_5ghz = ath6kl_band_5ghz;
+	ar->band_5ghz.channels = ar->channels_5ghz;
+
 	/*
 	 * Even if the fw has HT support, advertise HT cap only when
 	 * the firmware has support to override RSN capability, otherwise
@@ -3939,10 +3951,10 @@ int ath6kl_cfg80211_init(struct ath6kl *ar)
 	if (!(ht &&
 	      test_bit(ATH6KL_FW_CAPABILITY_RSN_CAP_OVERRIDE,
 		       ar->fw_capabilities))) {
-		ath6kl_band_2ghz.ht_cap.cap = 0;
-		ath6kl_band_2ghz.ht_cap.ht_supported = false;
-		ath6kl_band_5ghz.ht_cap.cap = 0;
-		ath6kl_band_5ghz.ht_cap.ht_supported = false;
+		ar->band_2ghz.ht_cap.cap = 0;
+		ar->band_2ghz.ht_cap.ht_supported = false;
+		ar->band_5ghz.ht_cap.cap = 0;
+		ar->band_5ghz.ht_cap.ht_supported = false;
 
 		if (ht)
 			ath6kl_err("Firmware lacks RSN-CAP-OVERRIDE, so HT (802.11n) is disabled.");
@@ -3950,15 +3962,15 @@ int ath6kl_cfg80211_init(struct ath6kl *ar)
 
 	if (test_bit(ATH6KL_FW_CAPABILITY_64BIT_RATES,
 		     ar->fw_capabilities)) {
-		ath6kl_band_2ghz.ht_cap.mcs.rx_mask[0] = 0xff;
-		ath6kl_band_5ghz.ht_cap.mcs.rx_mask[0] = 0xff;
-		ath6kl_band_2ghz.ht_cap.mcs.rx_mask[1] = 0xff;
-		ath6kl_band_5ghz.ht_cap.mcs.rx_mask[1] = 0xff;
+		ar->band_2ghz.ht_cap.mcs.rx_mask[0] = 0xff;
+		ar->band_5ghz.ht_cap.mcs.rx_mask[0] = 0xff;
+		ar->band_2ghz.ht_cap.mcs.rx_mask[1] = 0xff;
+		ar->band_5ghz.ht_cap.mcs.rx_mask[1] = 0xff;
 		ar->hw.tx_ant = 0x3; /* mask, 2 antenna */
 		ar->hw.rx_ant = 0x3;
 	} else {
-		ath6kl_band_2ghz.ht_cap.mcs.rx_mask[0] = 0xff;
-		ath6kl_band_5ghz.ht_cap.mcs.rx_mask[0] = 0xff;
+		ar->band_2ghz.ht_cap.mcs.rx_mask[0] = 0xff;
+		ar->band_5ghz.ht_cap.mcs.rx_mask[0] = 0xff;
 		ar->hw.tx_ant = 1;
 		ar->hw.rx_ant = 1;
 	}
@@ -3967,9 +3979,9 @@ int ath6kl_cfg80211_init(struct ath6kl *ar)
 	wiphy->available_antennas_rx = ar->hw.rx_ant;
 
 	if (band_2gig)
-		wiphy->bands[NL80211_BAND_2GHZ] = &ath6kl_band_2ghz;
+		wiphy->bands[NL80211_BAND_2GHZ] = &ar->band_2ghz;
 	if (band_5gig)
-		wiphy->bands[NL80211_BAND_5GHZ] = &ath6kl_band_5ghz;
+		wiphy->bands[NL80211_BAND_5GHZ] = &ar->band_5ghz;
 
 	wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM;
 
drivers/net/wireless/ath/ath6kl/core.h +9 -0
index 31cd88d83..da85c8dfb 100644
@@ -703,10 +703,19 @@ enum ath6kl_fw_err {
 	ATH6KL_FW_EP_FULL,
 };
 
+#define ATH6KL_NUM_2GHZ_CHANNELS	14
+#define ATH6KL_NUM_5GHZ_CHANNELS	33
+
 struct ath6kl {
 	struct device *dev;
 	struct wiphy *wiphy;
 
+	/* per device copies, a board may disable channels or change HT caps */
+	struct ieee80211_supported_band band_2ghz;
+	struct ieee80211_supported_band band_5ghz;
+	struct ieee80211_channel channels_2ghz[ATH6KL_NUM_2GHZ_CHANNELS];
+	struct ieee80211_channel channels_5ghz[ATH6KL_NUM_5GHZ_CHANNELS];
+
 	enum ath6kl_state state;
 	unsigned int testmode;
 
Signature · 1 line
2.54.0 (Apple Git-157)
#5 lore raw

PATCH 5/9 dt-bindings: net: wireless: add QCA6006 binding

In reply to Josef Schlehofer

Describe the QCA6006 (AR6006 hw1.1) USB wireless chip as a USB device node, so a board can give it a MAC address and an ieee80211-freq-limit. The Xiaomi AIoT AC2350 router needs both. Its QCA6006 has only a 2.4 GHz front end, and its board data carries the Atheros default MAC address.

The compatible follows usb-device.yaml, with VID and PID in lower case and leading zeroes suppressed. The common wireless properties come from wireless-controller.yaml.

---
 .../bindings/net/wireless/qcom,qca6006.yaml   | 56 +++++++++++++++++++
 MAINTAINERS                                   |  1 +
 2 files changed, 57 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/wireless/qcom,qca6006.yaml
Documentation/devicetree/bindings/net/wireless/qcom,qca6006.yaml new file +56 -0
new file mode 100644
index 000000000..3f727c368
@@ -0,0 +1,56 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/net/wireless/qcom,qca6006.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Qualcomm Atheros QCA6006 USB wireless chip
+
+maintainers:
+  - Josef Schlehofer <[email protected]>
+
+description:
+  The QCA6006 (AR6006 hw1.1) is a wireless chip connected over USB. The
+  node describes the USB device on the port of its hub.
+
+allOf:
+  - $ref: /schemas/usb/usb-device.yaml#
+  - $ref: wireless-controller.yaml#
+
+properties:
+  compatible:
+    const: usbcf3,9372  # QCA6006 (AR6006 hw1.1)
+
+  nvmem-cells:
+    maxItems: 1
+    description: Reference to an nvmem node for the MAC address
+
+  nvmem-cell-names:
+    items:
+      - const: mac-address
+
+required:
+  - compatible
+  - reg
+
+dependentRequired:
+  nvmem-cells: [nvmem-cell-names]
+  nvmem-cell-names: [nvmem-cells]
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    usb {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        wifi@1 {
+            compatible = "usbcf3,9372";
+            reg = <1>;
+            ieee80211-freq-limit = <2400000 2483000>;
+            local-mac-address = [02 00 00 00 00 01];
+        };
+    };
+
+...
MAINTAINERS +1 -0
index deb787820..7b9e18566 100644
@@ -4384,6 +4384,7 @@ ATHEROS ATH6KL WIRELESS DRIVER
 L:	[email protected]
 S:	Orphan
 W:	https://wireless.docs.kernel.org/en/latest/en/users/drivers/ath6kl.html
+F:	Documentation/devicetree/bindings/net/wireless/qcom,qca6006.yaml
 F:	drivers/net/wireless/ath/ath6kl/
 
 ATI_REMOTE2 DRIVER
Signature · 1 line
2.54.0 (Apple Git-157)
#6 lore raw

PATCH 6/9 wifi: ath6kl: take the AR6006 MAC address from DT

In reply to Josef Schlehofer

The AR6006 board data carries a default MAC address. On the Xiaomi AIoT AC2350 it is the Atheros default 00:03:7f:20:01:42, so the real address has to come from the board. Qualcomm's ath6kl-3.5 driver takes it from a module parameter and writes it into the board data.

Read the address once at probe with of_get_mac_address() from the node of the USB device, so mac-address, local-mac-address and nvmem cells work. This happens before any firmware is loaded, so a deferred probe frees everything on the existing error path. A missing node or property is not an error, and neither is a kernel without nvmem support. Other errors are logged and the board data default stays.

Write the address into the board data before the upload, also on resume and recovery. The MAC sits at offset 8. The checksum at offset 4 is the inverted XOR of all little-endian 16-bit words of the uploaded board data. Also set the option that keeps the firmware from taking the MAC from OTP, as the vendor driver does.

---
On the router the address came from local-mac-address in one run and from an nvmem cell in another, both added at runtime to the node of the USB port, and the firmware used it. With nvmem-cells pointing at a node that is no nvmem provider, the probe was deferred and left no netdev. After the node got local-mac-address again, reloading the driver probed the chip without a reset in between and booted the firmware. Resume and recovery did not run.

 drivers/net/wireless/ath/ath6kl/core.c |  5 ++
 drivers/net/wireless/ath/ath6kl/core.h |  4 ++
 drivers/net/wireless/ath/ath6kl/init.c | 77 ++++++++++++++++++++++++++
 drivers/net/wireless/ath/ath6kl/usb.c  |  3 +-
 4 files changed, 88 insertions(+), 1 deletion(-)
drivers/net/wireless/ath/ath6kl/core.c +5 -0
index 9762de89e..792a8b1f8 100644
@@ -110,6 +110,11 @@ int ath6kl_core_init(struct ath6kl *ar, enum ath6kl_htc_type htc_type)
 	if (ret)
 		goto err_power_off;
 
+	/* before any firmware is loaded, so a deferred probe leaks nothing */
+	ret = ath6kl_init_read_dt_mac(ar);
+	if (ret)
+		goto err_power_off;
+
 	ar->htc_target = ath6kl_htc_create(ar);
 
 	if (!ar->htc_target) {
drivers/net/wireless/ath/ath6kl/core.h +4 -0
index da85c8dfb..d9b12dacc 100644
@@ -716,6 +716,9 @@ struct ath6kl {
 	struct ieee80211_channel channels_2ghz[ATH6KL_NUM_2GHZ_CHANNELS];
 	struct ieee80211_channel channels_5ghz[ATH6KL_NUM_5GHZ_CHANNELS];
 
+	/* AR6006: MAC address from the device tree, zero if there is none */
+	u8 dt_mac[ETH_ALEN];
+
 	enum ath6kl_state state;
 	unsigned int testmode;
 
@@ -992,6 +995,7 @@ void ath6kl_cfg80211_vif_stop(struct ath6kl_vif *vif, bool wmi_ready);
 int ath6kl_init_hw_start(struct ath6kl *ar);
 int ath6kl_init_hw_stop(struct ath6kl *ar);
 int ath6kl_init_fetch_firmwares(struct ath6kl *ar);
+int ath6kl_init_read_dt_mac(struct ath6kl *ar);
 int ath6kl_init_hw_params(struct ath6kl *ar);
 
 void ath6kl_check_wow_status(struct ath6kl *ar);
drivers/net/wireless/ath/ath6kl/init.c +77 -0

97 lines not on this page · raw message

drivers/net/wireless/ath/ath6kl/usb.c +2 -1
index 945984c3d..2f08dba57 100644
@@ -1161,7 +1161,8 @@ static int ath6kl_usb_probe(struct usb_interface *interface,
 
 	ret = ath6kl_core_init(ar, ATH6KL_HTC_TYPE_PIPE);
 	if (ret) {
-		ath6kl_err("Failed to init ath6kl core: %d\n", ret);
+		dev_err_probe(&interface->dev, ret,
+			      "Failed to init ath6kl core\n");
 		goto err_core_free;
 	}
 
Signature · 1 line
2.54.0 (Apple Git-157)
#7 lore raw

PATCH 7/9 wifi: ath6kl: handle unsupported connection frequencies

In reply to Josef Schlehofer

The firmware picks the network on its own and reports the frequency in the connect event. ath6kl looks up the channel for it and passes the result to cfg80211. The channel tables of ath6kl do not cover every frequency. Channel 144 is missing, for example, and channels 184 to 196 sit at 5920 to 5980 MHz instead of 4920 to 4980 MHz. For a connection on such a frequency the lookup returns NULL. cfg80211_inform_bss() then dereferences it when ath6kl adds the BSS, and the channel switch notification for an AP passes it to cfg80211_chandef_create(), which warns and leaves the chandef uninitialised.

Reject such a connection. Send a disconnect and run the normal disconnect handling, so cfg80211 sees the connection fail or end and the link is not marked up. Skip the channel switch notification for such a frequency.

The next patch can drop a whole band for a board, which makes this case more likely.

---
On the test router the 2.4 GHz band was dropped through the device tree and wpa_supplicant left the choice of network to the firmware (ap_scan=2). The firmware connected on 2437 MHz, the connection was rejected, the AP saw the station leave and cfg80211 reported a failed connect. The channel switch check could not be triggered. An AP starts on the channel the host gives it, so that check only guards against firmware that reports a different one.

 drivers/net/wireless/ath/ath6kl/cfg80211.c | 11 +++++++++--
 drivers/net/wireless/ath/ath6kl/main.c     | 12 ++++++++++++
 2 files changed, 21 insertions(+), 2 deletions(-)
drivers/net/wireless/ath/ath6kl/cfg80211.c +9 -2
index 6b03627e2..7f1ffe4b7 100644
@@ -1110,14 +1110,21 @@ void ath6kl_cfg80211_scan_complete_event(struct ath6kl_vif *vif, bool aborted)
 void ath6kl_cfg80211_ch_switch_notify(struct ath6kl_vif *vif, int freq,
 				      enum wmi_phy_mode mode)
 {
+	struct ieee80211_channel *chan;
 	struct cfg80211_chan_def chandef;
 
 	ath6kl_dbg(ATH6KL_DBG_WLAN_CFG,
 		   "channel switch notify nw_type %d freq %d mode %d\n",
 		   vif->nw_type, freq, mode);
 
-	cfg80211_chandef_create(&chandef,
-				ieee80211_get_channel(vif->ar->wiphy, freq),
+	chan = ieee80211_get_channel(vif->ar->wiphy, freq);
+	if (!chan) {
+		ath6kl_err("channel switch to unsupported frequency %d MHz\n",
+			   freq);
+		return;
+	}
+
+	cfg80211_chandef_create(&chandef, chan,
 				(mode == WMI_11G_HT20 &&
 				 vif->ar->band_2ghz.ht_cap.ht_supported) ?
 					NL80211_CHAN_HT20 : NL80211_CHAN_NO_HT);
drivers/net/wireless/ath/ath6kl/main.c +12 -0
index 9dd39d79f..a062598ce 100644
@@ -633,6 +633,18 @@ void ath6kl_connect_event(struct ath6kl_vif *vif, u16 channel, u8 *bssid,
 {
 	struct ath6kl *ar = vif->ar;
 
+	/*
+	 * cfg80211 needs a channel for the BSS. Reject a connection on a
+	 * frequency that has no channel on this device.
+	 */
+	if (!ieee80211_get_channel(ar->wiphy, channel)) {
+		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,
+					WLAN_REASON_UNSPECIFIED);
+		return;
+	}
+
 	ath6kl_cfg80211_connect_event(vif, channel, bssid,
 				      listen_int, beacon_int,
 				      net_type, beacon_ie_len,
Signature · 1 line
2.54.0 (Apple Git-157)
#8 lore raw

PATCH 8/9 wifi: ath6kl: honour ieee80211-freq-limit from DT

In reply to Josef Schlehofer

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.

---
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(-)
drivers/net/wireless/ath/ath6kl/cfg80211.c +41 -0
index 7f1ffe4b7..97107510b 100644
@@ -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;
drivers/net/wireless/ath/ath6kl/main.c +6 -2
index a062598ce..20fa471a9 100644
@@ -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,
Signature · 1 line
2.54.0 (Apple Git-157)
#9 lore raw

PATCH 9/9 wifi: ath6kl: add QCA6006 USB ID

In reply to Josef Schlehofer

The QCA6006 is an AR6006 hw1.1 on USB with the ID 0cf3:9372. It is the third radio of the Xiaomi AIoT AC2350 router and its second 2.4 GHz radio. Qualcomm's ath6kl-3.5 driver lists the same ID. Also declare the AR6006 firmware and board data files and name the AR6006 in the Kconfig help.

It comes last in the series, so no bisect point binds the driver to the chip before the MAC address and band handling exist.

---
The series ran on OpenWrt 25.12 (backports 6.18.55) on that router. Station mode joined a WPA2 network and got a DHCP lease, and AP mode associated a WPA2 client with unicast data both ways.

 drivers/net/wireless/ath/ath6kl/Kconfig | 4 ++--
 drivers/net/wireless/ath/ath6kl/usb.c   | 3 +++
 2 files changed, 5 insertions(+), 2 deletions(-)
drivers/net/wireless/ath/ath6kl/Kconfig +2 -2
index cd96cf8d9..e68beb00f 100644
@@ -4,7 +4,7 @@ config ATH6KL
 	depends on CFG80211
 	help
 	  This module adds core support for wireless adapters based on
-	  Atheros AR6003 and AR6004 chipsets. You still need separate
+	  Atheros AR6003, AR6004 and AR6006 chipsets. You still need separate
 	  bus drivers for USB and SDIO to be able to use real devices.
 
 	  If you choose to build it as a module, it will be called
@@ -28,7 +28,7 @@ config ATH6KL_USB
 	depends on USB
 	help
 	  This module adds support for wireless adapters based on
-	  Atheros AR6004 chipset and chipsets based on it running over
+	  Atheros AR6004 and AR6006 chipsets running over
 	  USB. If you choose to build it as a module, it will be
 	  called ath6kl_usb.
 
drivers/net/wireless/ath/ath6kl/usb.c +3 -0
index 2f08dba57..7b6520985 100644
@@ -1217,6 +1217,7 @@ static int ath6kl_usb_pm_resume(struct usb_interface *interface)
 static const struct usb_device_id ath6kl_usb_ids[] = {
 	{USB_DEVICE(0x0cf3, 0x9375)},
 	{USB_DEVICE(0x0cf3, 0x9374)},
+	{USB_DEVICE(0x0cf3, 0x9372)},
 	{USB_DEVICE(0x04da, 0x390d)},
 	{ /* Terminating entry */ },
 };
@@ -1251,3 +1252,5 @@ MODULE_FIRMWARE(AR6004_HW_1_2_DEFAULT_BOARD_DATA_FILE);
 MODULE_FIRMWARE(AR6004_HW_1_3_FW_DIR "/" AR6004_HW_1_3_FIRMWARE_FILE);
 MODULE_FIRMWARE(AR6004_HW_1_3_BOARD_DATA_FILE);
 MODULE_FIRMWARE(AR6004_HW_1_3_DEFAULT_BOARD_DATA_FILE);
+MODULE_FIRMWARE(AR6006_HW_1_1_FW_DIR "/" AR6006_HW_1_1_FIRMWARE_FILE);
+MODULE_FIRMWARE(AR6006_HW_1_1_BOARD_DATA_FILE);
Signature · 1 line
2.54.0 (Apple Git-157)