Skip to contentSkip to conversation

wifi: ath11k: beacon protection and firmware airtime fairness

PATCH New Andrei-Alexandru Bleortu 1 participant 5 messages Oct 3

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

cover wifi: ath11k: beacon protection and firmware airtime fairness

Firmware features ath11k does not use yet, found while bringing up a Ubiquiti UniFi U6 Enterprise (IPQ5018 with two QCN9074) with the data path offloaded to NSS: a debugfs view of the firmware's services, beacon protection and firmware airtime fairness, plus the mac80211 change the last one needs.

Patch 1 lists the firmware's WMI service bits in debugfs, as ath10k
does: whether a feature exists is usually a service bit, and ath11k only logs part of the map at debug level.

Patch 2 is beacon protection, following ath12k's implementation: the firmware signs beacons with the BIGTK. Checked over the air on both
chips: every beacon in a monitor capture carried a Management MIC element whose BIP-CMAC-128 MIC verifies against the BIGTK hostapd installed (624 of 624; none with another radio's key), and a wpa_supplicant client verified the SSID from a protected beacon.

Patch 3 is Felix Fietkau's mac80211 change from OpenWrt, which gives drivers the station airtime weight (sta_set_airtime_weight). Patch 4 needs it; it is included unchanged, with his authorship.

Patch 4 is firmware airtime fairness: per-station airtime shares the firmware schedules by, derived from the stations' airtime weights. With the data path offloaded, mac80211's own airtime scheduler never sees the frames, so the firmware is the only place fairness can happen there. A station capped at 10% under strict scheduling drops from 885 to 122 Mbit/s and recovers when uncapped; at its normal fair share throughput is unchanged (900 Mbit/s on 5 GHz HE80). The firmware needs its ATF group defined before it accepts shares, which the commit message details.

Patch 3 is for mac80211; the others go through the ath tree, and patch 4 depends on patch 3.

The patches were written with an AI coding assistant (Claude Code), which also drafted the changelogs; the testing above was done on the device.

Andrei-Alexandru Bleortu (3):
wifi: ath11k: add a debugfs file listing the firmware WMI services
wifi: ath11k: support beacon protection
wifi: ath11k: support firmware airtime fairness

Felix Fietkau (1):
wifi: mac80211: notify driver on airtime weight changes

 drivers/net/wireless/ath/ath11k/core.h    |   2 +
 drivers/net/wireless/ath/ath11k/debugfs.c |  15 ++
 drivers/net/wireless/ath/ath11k/mac.c     | 166 +++++++++++++++++++++-
 drivers/net/wireless/ath/ath11k/wmi.c     |  99 +++++++++++++
 drivers/net/wireless/ath/ath11k/wmi.h     |  58 +++++++-
 include/net/mac80211.h                    |   5 +
 net/mac80211/cfg.c                        |   6 +-
 net/mac80211/driver-ops.c                 |   4 +
 net/mac80211/driver-ops.h                 |  19 +++
 net/mac80211/sta_info.c                   |   7 +-
 net/mac80211/trace.h                      |  27 ++++
 11 files changed, 400 insertions(+), 8 deletions(-)

base-commit: f0406245cb9855e6318335a8a223551354291a46

#1 lore raw

PATCH 1/4 wifi: ath11k: add a debugfs file listing the firmware WMI services

Whether a feature is available often comes down to a WMI service bit the firmware reports at boot, and ath11k only logs the ext services, at debug level. List every set bit of the service map in <soc>/wmi_services, as ath10k's file of the same name does, so the capabilities of a given firmware build can be read directly.

Tested-on: QCN9074 hw1.0 PCI WLAN.HK.2.9.0.1-02146-QCAHKSWPL_SILICONZ-1
Tested-on: IPQ5018 hw1.0 AHB WLAN.HK.2.7.0.1-01744-QCAHKSWPL_SILICONZ-1

---
 drivers/net/wireless/ath/ath11k/debugfs.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
drivers/net/wireless/ath/ath11k/debugfs.c +15 -0
index 70922612d..75d2e81c7 100644
@@ -851,6 +851,18 @@ static const struct file_operations fops_sram_dump = {
 	.llseek = default_llseek,
 };
 
+static int ath11k_wmi_services_show(struct seq_file *m, void *v)
+{
+	struct ath11k_base *ab = m->private;
+	unsigned int i;
+
+	for_each_set_bit(i, ab->wmi_ab.svc_map, WMI_MAX_EXT2_SERVICE)
+		seq_printf(m, "%u\n", i);
+
+	return 0;
+}
+DEFINE_SHOW_ATTRIBUTE(ath11k_wmi_services);
+
 int ath11k_debugfs_pdev_create(struct ath11k_base *ab)
 {
 	if (test_bit(ATH11K_FLAG_REGISTERED, &ab->dev_flags))
@@ -862,6 +874,9 @@ int ath11k_debugfs_pdev_create(struct ath11k_base *ab)
 	debugfs_create_file("soc_dp_stats", 0400, ab->debugfs_soc, ab,
 			    &fops_soc_dp_stats);
 
+	debugfs_create_file("wmi_services", 0400, ab->debugfs_soc, ab,
+			    &ath11k_wmi_services_fops);
+
 	if (ab->hw_params.sram_dump.start != 0)
 		debugfs_create_file("sram", 0400, ab->debugfs_soc, ab,
 				    &fops_sram_dump);
#2 lore raw

PATCH 2/4 wifi: ath11k: support beacon protection

In reply to Andrei-Alexandru Bleortu

Firmware with WMI_TLV_SERVICE_BEACON_PROTECTION_SUPPORT protects the beacons it transmits with the BIGTK. Advertise NL80211_EXT_FEATURE_BEACON_PROTECTION when the service is present, install the BIGTK (key index 6/7) in hardware with the BIP ciphers, and set the beacon protection bit of the beacon template command when the beacon's Extended Capabilities, or those of a nontransmitted BSSID profile in it, enable it. The IGTK (index 4/5) stays in software, which protects the management frames mac80211 sends.

This follows the ath12k change that added the same support, commit "wifi: ath12k: allow beacon protection keys to be installed in hardware".

Tested-on: QCN9074 hw1.0 PCI WLAN.HK.2.9.0.1-02146-QCAHKSWPL_SILICONZ-1
Tested-on: IPQ5018 hw1.0 AHB WLAN.HK.2.7.0.1-01744-QCAHKSWPL_SILICONZ-1

---
 drivers/net/wireless/ath/ath11k/core.h |  1 +
 drivers/net/wireless/ath/ath11k/mac.c  | 61 +++++++++++++++++++++++---
 drivers/net/wireless/ath/ath11k/wmi.c  |  2 +
 drivers/net/wireless/ath/ath11k/wmi.h  |  5 ++-
 4 files changed, 63 insertions(+), 6 deletions(-)
drivers/net/wireless/ath/ath11k/core.h +1 -0
index a0d725923..31eee25c0 100644
@@ -408,6 +408,7 @@ struct ath11k_vif {
 	int txpower;
 	bool rsnie_present;
 	bool wpaie_present;
+	bool beacon_prot;
 	bool bcca_zero_sent;
 	bool do_not_send_tmpl;
 	struct ath11k_arp_ns_offload arp_ns_offload;
drivers/net/wireless/ath/ath11k/mac.c +56 -5

97 lines not on this page · raw message

drivers/net/wireless/ath/ath11k/wmi.c +2 -0
index 08fd6795e..2c3e14a65 100644
@@ -1811,6 +1811,8 @@ int ath11k_wmi_bcn_tmpl(struct ath11k *ar, u32 vdev_id,
 	cmd->buf_len = bcn->len;
 	cmd->mbssid_ie_offset = offs->mbssid_off;
 	cmd->ema_params = ema_params;
+	if (arvif->beacon_prot)
+		cmd->feature_enable_bitmap |= WMI_BCN_TMPL_BEACON_PROTECTION_EN;
 
 	ptr = skb->data + sizeof(*cmd);
 
drivers/net/wireless/ath/ath11k/wmi.h +4 -1
index b2dade051..ae8b4cc08 100644
@@ -2128,6 +2128,7 @@ enum wmi_tlv_service {
 	WMI_TLV_SERVICE_PER_PEER_HTT_STATS_RESET = 213,
 	WMI_TLV_SERVICE_FREQINFO_IN_METADATA = 219,
 	WMI_TLV_SERVICE_EXT2_MSG = 220,
+	WMI_TLV_SERVICE_BEACON_PROTECTION_SUPPORT = 244,
 	WMI_TLV_SERVICE_PEER_POWER_SAVE_DURATION_SUPPORT = 246,
 	WMI_TLV_SERVICE_SRG_SRP_SPATIAL_REUSE_SUPPORT = 249,
 	WMI_TLV_SERVICE_MBSS_PARAM_IN_VDEV_START_SUPPORT = 253,
@@ -3628,6 +3629,8 @@ struct ath11k_wmi_p2p_noa_info {
 #define WMI_EMA_FIRST_TMPL_SHIFT          16
 #define WMI_EMA_LAST_TMPL_SHIFT           24
 
+#define WMI_BCN_TMPL_BEACON_PROTECTION_EN BIT(0)
+
 struct wmi_bcn_tmpl_cmd {
 	u32 tlv_header;
 	u32 vdev_id;
@@ -5237,7 +5240,7 @@ enum wmi_ap_ps_peer_param {
 
 #define DISABLE_SIFS_RESPONSE_TRIGGER 0
 
-#define WMI_MAX_KEY_INDEX   3
+#define WMI_MAX_KEY_INDEX   7
 #define WMI_MAX_KEY_LEN     32
 
 #define WMI_KEY_PAIRWISE 0x00
#3 lore raw

PATCH 3/4 wifi: mac80211: notify driver on airtime weight changes

In reply to Andrei-Alexandru Bleortu

From: Felix Fietkau <[email protected]>

Add a new sta_set_airtime_weight driver op so drivers can program the airtime fairness weight into hardware. The op is called when the weight is updated via sta_apply_parameters, and on station upload if a non-default weight is already set.

---
 include/net/mac80211.h    |  5 +++++
 net/mac80211/cfg.c        |  6 +++++-
 net/mac80211/driver-ops.c |  4 ++++
 net/mac80211/driver-ops.h | 19 +++++++++++++++++++
 net/mac80211/sta_info.c   |  7 ++++++-
 net/mac80211/trace.h      | 27 +++++++++++++++++++++++++++
 6 files changed, 66 insertions(+), 2 deletions(-)
include/net/mac80211.h +5 -0
index cb9f8e14b..aab98d92e 100644
@@ -4694,6 +4694,8 @@ struct ieee80211_prep_tx_info {
  * @set_sar_specs: Update the SAR (TX power) settings.
  * @sta_set_decap_offload: Called to notify the driver when a station is allowed
  *	to use rx decapsulation offload
+ * @sta_set_airtime_weight: Called to notify the driver of a change to a
+ *	station's airtime fairness weight, so it can be programmed in hardware.
  * @add_twt_setup: Update hw with TWT agreement parameters received from the peer.
  *	This callback allows the hw to check if requested parameters
  *	are supported and if there is enough room for a new agreement.
@@ -5108,6 +5110,9 @@ struct ieee80211_ops {
 	void (*sta_set_decap_offload)(struct ieee80211_hw *hw,
 				      struct ieee80211_vif *vif,
 				      struct ieee80211_sta *sta, bool enabled);
+	void (*sta_set_airtime_weight)(struct ieee80211_hw *hw,
+				       struct ieee80211_vif *vif,
+				       struct ieee80211_sta *sta, u16 weight);
 	void (*add_twt_setup)(struct ieee80211_hw *hw,
 			      struct ieee80211_sta *sta,
 			      struct ieee80211_twt_setup *twt);
net/mac80211/cfg.c +5 -1
index bd1a857c8..28f99a8f8 100644
@@ -2616,8 +2616,12 @@ static int sta_apply_parameters(struct ieee80211_local *local,
 	if (ieee80211_vif_is_mesh(&sdata->vif))
 		sta_apply_mesh_params(local, sta, params);
 
-	if (params->airtime_weight)
+	if (params->airtime_weight) {
 		sta->airtime_weight = params->airtime_weight;
+		if (sta->uploaded)
+			drv_sta_set_airtime_weight(local, sdata, &sta->sta,
+						   sta->airtime_weight);
+	}
 
 	if (params->nmi_mac) {
 		struct ieee80211_sub_if_data *nmi =
net/mac80211/driver-ops.c +4 -0
index 49753b73a..083c26517 100644
@@ -157,6 +157,10 @@ int drv_sta_state(struct ieee80211_local *local,
 			sta->uploaded = true;
 			if (rcu_access_pointer(sta->sta.rates))
 				drv_sta_rate_tbl_update(local, sdata, &sta->sta);
+			if (sta->airtime_weight != IEEE80211_DEFAULT_AIRTIME_WEIGHT)
+				drv_sta_set_airtime_weight(local, sdata,
+							   &sta->sta,
+							   sta->airtime_weight);
 		}
 	} else if (old_state == IEEE80211_STA_ASSOC &&
 		   new_state == IEEE80211_STA_AUTH) {
net/mac80211/driver-ops.h +19 -0
index f1c0b87fd..bd5c9d1ed 100644
@@ -1633,6 +1633,25 @@ static inline void drv_sta_set_decap_offload(struct ieee80211_local *local,
 	trace_drv_return_void(local);
 }
 
+static inline void drv_sta_set_airtime_weight(struct ieee80211_local *local,
+					      struct ieee80211_sub_if_data *sdata,
+					      struct ieee80211_sta *sta,
+					      u16 weight)
+{
+	sdata = get_bss_sdata(sdata);
+
+	might_sleep();
+	lockdep_assert_wiphy(local->hw.wiphy);
+	if (!check_sdata_in_driver(sdata))
+		return;
+
+	trace_drv_sta_set_airtime_weight(local, sdata, sta, weight);
+	if (local->ops->sta_set_airtime_weight)
+		local->ops->sta_set_airtime_weight(&local->hw, &sdata->vif, sta,
+						   weight);
+	trace_drv_return_void(local);
+}
+
 static inline void drv_add_twt_setup(struct ieee80211_local *local,
 				     struct ieee80211_sub_if_data *sdata,
 				     struct ieee80211_sta *sta,
net/mac80211/sta_info.c +6 -1
index e81cd1551..2ce3ef905 100644
@@ -872,8 +872,13 @@ static int sta_info_insert_drv_state(struct ieee80211_local *local,
 		 * Drivers using legacy sta_add/sta_remove callbacks only
 		 * get uploaded set to true after sta_add is called.
 		 */
-		if (!local->ops->sta_add)
+		if (!local->ops->sta_add) {
 			sta->uploaded = true;
+			if (sta->airtime_weight != IEEE80211_DEFAULT_AIRTIME_WEIGHT)
+				drv_sta_set_airtime_weight(local, sdata,
+							   &sta->sta,
+							   sta->airtime_weight);
+		}
 		return 0;
 	}
 
net/mac80211/trace.h +27 -0
index 562a4964a..3ae7e78de 100644
@@ -2462,6 +2462,33 @@ DEFINE_EVENT(sta_flag_evt, drv_sta_set_decap_offload,
 	TP_ARGS(local, sdata, sta, enabled)
 );
 
+TRACE_EVENT(drv_sta_set_airtime_weight,
+	TP_PROTO(struct ieee80211_local *local,
+		 struct ieee80211_sub_if_data *sdata,
+		 struct ieee80211_sta *sta, u16 weight),
+
+	TP_ARGS(local, sdata, sta, weight),
+
+	TP_STRUCT__entry(
+		LOCAL_ENTRY
+		VIF_ENTRY
+		STA_ENTRY
+		__field(u16, weight)
+	),
+
+	TP_fast_assign(
+		LOCAL_ASSIGN;
+		VIF_ASSIGN;
+		STA_ASSIGN;
+		__entry->weight = weight;
+	),
+
+	TP_printk(
+		LOCAL_PR_FMT  VIF_PR_FMT  STA_PR_FMT " weight:%u",
+		LOCAL_PR_ARG, VIF_PR_ARG, STA_PR_ARG, __entry->weight
+	)
+);
+
 TRACE_EVENT(drv_add_twt_setup,
 	TP_PROTO(struct ieee80211_local *local,
 		 struct ieee80211_sta *sta,
#4 lore raw

PATCH 4/4 wifi: ath11k: support firmware airtime fairness

In reply to Andrei-Alexandru Bleortu

Firmware with WMI_TLV_SERVICE_ATF schedules airtime between stations itself, in proportion to per-station shares the host gives it in parts per thousand. Enable it at init (resource config flag) and on each radio, advertise NL80211_EXT_FEATURE_AIRTIME_FAIRNESS, and send the shares of all AP stations of the radio, derived from their airtime weights (sta_set_airtime_weight), whenever a station associates or leaves or user space changes a weight.

The firmware schedules a station only within the share of its ATF group, so group 0, which every station belongs to, first gets the whole radio (WMI_ATF_SSID_GROUPING_REQUEST_CMDID, fair policy). Without the group, the firmware passes no data at all to a station that has a share.

Both are needed: without the resource config flag the firmware takes the shares but does not enforce them. With them, a station capped at 100/1000 under strict scheduling falls from 885 to 122 Mbit/s downlink and recovers once uncapped, and at its full fair share it runs at full rate.

This matters most where the data path does not pass mac80211's queues, such as NSS offload, where mac80211's own airtime scheduler never sees the frames.

Tested-on: QCN9074 hw1.0 PCI WLAN.HK.2.9.0.1-02146-QCAHKSWPL_SILICONZ-1

---
 drivers/net/wireless/ath/ath11k/core.h |   1 +
 drivers/net/wireless/ath/ath11k/mac.c  | 105 +++++++++++++++++++++++++
 drivers/net/wireless/ath/ath11k/wmi.c  |  97 +++++++++++++++++++++++
 drivers/net/wireless/ath/ath11k/wmi.h  |  53 +++++++++++++
 4 files changed, 256 insertions(+)
drivers/net/wireless/ath/ath11k/core.h +1 -0
index 31eee25c0..bb5f730c8 100644
@@ -542,6 +542,7 @@ struct ath11k_per_peer_cfr_capture {
 
 struct ath11k_sta {
 	struct ath11k_vif *arvif;
+	u16 airtime_weight;
 
 	/* the following are protected by ar->data_lock */
 	u32 changed; /* IEEE80211_RC_* */
drivers/net/wireless/ath/ath11k/mac.c +105 -0

147 lines not on this page · raw message

drivers/net/wireless/ath/ath11k/wmi.c +97 -0

109 lines not on this page · raw message

drivers/net/wireless/ath/ath11k/wmi.h +53 -0

77 lines not on this page · raw message