Skip to contentSkip to conversation

ath11k: Add probe response throttling logic

PATCH In review Sriram R 2 participants 4 messages Jun 27, 2019 – Jul 17, 2019 Qualcomm Atheros ATH11K wireless driver

lore
Share & tools
lore

Sriram R

author
#0 lore raw

PATCH 1/1 ath11k: Add probe response throttling logic

Drop probe response packets when the pending management tx count has reached a certain threshold, so as to prioritize other mgmt packets like auth and assoc to be sent on time for establishing successful connections.
This might be required in dense networks, multi-vap scenarios or due to emulated probe requests (DoS attack),
which could lead to association failures due to failure to send auth/assoc packets as high probe response traffic occupies the limited target mgmt transmit queue.
Currently the threshold is set to 3/4th of the target management tx queue.

---
 drivers/net/wireless/ath/ath11k/core.h |  6 ++++++
 drivers/net/wireless/ath/ath11k/mac.c  | 23 +++++++++++++++++++++--
 drivers/net/wireless/ath/ath11k/wmi.c  |  3 +++
 3 files changed, 30 insertions(+), 2 deletions(-)
drivers/net/wireless/ath/ath11k/core.h +6 -0
index af5c66f..9023367 100644
@@ -25,6 +25,11 @@
 
 #define ATH11K_TX_MGMT_NUM_PENDING_MAX	512
 
+#define ATH11K_TX_MGMT_TARGET_MAX_SUPPORT_WMI 64
+
+/* Pending management packets threshold for dropping probe responses */
+#define ATH11K_PRB_RSP_DROP_THRESHOLD ((ATH11K_TX_MGMT_TARGET_MAX_SUPPORT_WMI * 3) / 4)
+
 #define ATH11K_INVALID_HW_MAC_ID	0xFF
 
 enum ath11k_supported_bw {
@@ -485,6 +490,7 @@ struct ath11k {
 	struct idr txmgmt_idr;
 	/* protects txmgmt_idr data */
 	spinlock_t txmgmt_idr_lock;
+	atomic_t num_pending_mgmt_tx;
 
 	/* cycle count is reported twice for each visited channel during scan.
 	 * access protected by data_lock
drivers/net/wireless/ath/ath11k/mac.c +21 -2
index 1a4a333..b8035ec 100644
@@ -3392,17 +3392,32 @@ static void ath11k_mgmt_over_wmi_tx_work(struct work_struct *work)
 			ath11k_warn(ar->ab, "failed to transmit management frame %d\n",
 				    ret);
 			ieee80211_free_txskb(ar->hw, skb);
+		} else {
+			atomic_inc(&ar->num_pending_mgmt_tx);
 		}
 	}
 }
 
-static int ath11k_mac_mgmt_tx(struct ath11k *ar, struct sk_buff *skb)
+static int ath11k_mac_mgmt_tx(struct ath11k *ar, struct sk_buff *skb,
+			      bool is_prb_rsp)
 {
 	struct sk_buff_head *q = &ar->wmi_mgmt_tx_queue;
 
 	if (test_bit(ATH11K_FLAG_CRASH_FLUSH, &ar->ab->dev_flags))
 		return -ESHUTDOWN;
 
+	/* Drop probe response packets when the pending management tx
+	 * count has reached a certain threshold, so as to prioritize
+	 * other mgmt packets like auth and assoc to be sent on time
+	 * for establishing successful connections.
+	 */
+	if (is_prb_rsp &&
+	    atomic_read(&ar->num_pending_mgmt_tx) > ATH11K_PRB_RSP_DROP_THRESHOLD) {
+		ath11k_warn(ar->ab,
+			    "dropping probe response as pending queue is almost full\n");
+		return -ENOSPC;
+	}
+
 	if (skb_queue_len(q) == ATH11K_TX_MGMT_NUM_PENDING_MAX) {
 		ath11k_warn(ar->ab, "mgmt tx queue is full\n");
 		return -ENOSPC;
@@ -3423,10 +3438,12 @@ static void ath11k_mac_op_tx(struct ieee80211_hw *hw,
 	struct ieee80211_vif *vif = info->control.vif;
 	struct ath11k_vif *arvif = ath11k_vif_to_arvif(vif);
 	struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
+	bool is_prb_rsp;
 	int ret;
 
 	if (ieee80211_is_mgmt(hdr->frame_control)) {
-		ret = ath11k_mac_mgmt_tx(ar, skb);
+		is_prb_rsp = ieee80211_is_probe_resp(hdr->frame_control);
+		ret = ath11k_mac_mgmt_tx(ar, skb, is_prb_rsp);
 		if (ret) {
 			ath11k_warn(ar->ab, "failed to queue management frame %d\n",
 				    ret);
@@ -3601,6 +3618,8 @@ static void ath11k_mac_op_stop(struct ieee80211_hw *hw)
 	rcu_assign_pointer(ar->ab->pdevs_active[ar->pdev_idx], NULL);
 
 	synchronize_rcu();
+
+	atomic_set(&ar->num_pending_mgmt_tx, 0);
 }
 
 static void
drivers/net/wireless/ath/ath11k/wmi.c +3 -0
index 46a3e0f..6dad499 100644
@@ -3366,6 +3366,9 @@ static int wmi_process_mgmt_tx_comp(struct ath11k *ar, u32 desc_id,
 
 	ieee80211_tx_status_irqsafe(ar->hw, msdu);
 
+	WARN_ON(atomic_read(&ar->num_pending_mgmt_tx) == 0);
+	atomic_dec(&ar->num_pending_mgmt_tx);
+
 	return 0;
 }
 
Signature · 7 lines
2.7.4


_______________________________________________
ath11k mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/ath11k
#1 lore raw
Quoted 13 lines · Sriram R

Drop probe response packets when the pending management tx count has reached a certain threshold, so as to prioritize other mgmt packets like auth and assoc to be sent on time for establishing successful connections.
This might be required in dense networks, multi-vap scenarios or due to emulated probe requests (DoS attack),
which could lead to association failures due to failure to send auth/assoc packets as high probe response traffic occupies the limited target mgmt transmit queue.
Currently the threshold is set to 3/4th of the target management tx queue.

[...]

drivers/net/wireless/ath/ath11k/wmi.c static int wmi_process_mgmt_tx_comp(struct ath11k *ar, u32 desc_id, · line 3369

Quoted 7 lines
drivers/net/wireless/ath/ath11k/wmi.c +1 -0
@@ -3366,6 +3366,9 @@ static int wmi_process_mgmt_tx_comp(struct ath11k *ar, u32 desc_id,
 
 	ieee80211_tx_status_irqsafe(ar->hw, msdu);
 
+	WARN_ON(atomic_read(&ar->num_pending_mgmt_tx) == 0);

In the pending branch I changed this to WARN_ON_ONCE() so that we don't excessively spam the logs:

https://git.kernel.org/pub/scm/linux/kernel/git/kvalo/ath.git/commit/?h=pending-ath11k&id=02d5ce6ef5feff4bbc80afd800586bd15879b714

Signature · 6 lines
Kalle Valo

_______________________________________________
ath11k mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/ath11k
author
#2 lore raw
Quoted 23 lines · Kalle Valo
Quoted 13 lines · Sriram R

Drop probe response packets when the pending management tx count has reached a certain threshold, so as to prioritize other mgmt packets like auth and assoc to be sent on time for establishing successful connections.
This might be required in dense networks, multi-vap scenarios or due to emulated probe requests (DoS attack),
which could lead to association failures due to failure to send auth/assoc packets as high probe response traffic occupies the limited target mgmt transmit queue.
Currently the threshold is set to 3/4th of the target management tx queue.

[...]

Quoted 5 lines
drivers/net/wireless/ath/ath11k/wmi.c +0 -0
@@ -3366,6 +3366,9 @@ static int wmi_process_mgmt_tx_comp(struct 
 ath11k *ar, u32 desc_id,
 
Quoted 8 lines

drivers/net/wireless/ath/ath11k/wmi.c static int wmi_process_mgmt_tx_comp(struct ath11k *ar, u32 desc_id, · line 3369

Quoted 3 lines
drivers/net/wireless/ath/ath11k/wmi.c +1 -0
 	ieee80211_tx_status_irqsafe(ar->hw, msdu);
 
+	WARN_ON(atomic_read(&ar->num_pending_mgmt_tx) == 0);

In the pending branch I changed this to WARN_ON_ONCE() so that we don't excessively spam the logs:

https://git.kernel.org/pub/scm/linux/kernel/git/kvalo/ath.git/commit/?h=pending-ath11k&id=02d5ce6ef5feff4bbc80afd800586bd15879b714

Fine Kalle. Thanks for making this change.

Regards,
Sriram.R

_______________________________________________
ath11k mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/ath11k

#3 lore raw
In reply to Sriram R
Quoted 12 lines · Sriram R

Drop probe response packets when the pending management tx count has reached a certain threshold, so as to prioritize other mgmt packets like auth and assoc to be sent on time for establishing successful connections.
This might be required in dense networks, multi-vap scenarios or due to emulated probe requests (DoS attack),
which could lead to association failures due to failure to send auth/assoc packets as high probe response traffic occupies the limited target mgmt transmit queue.
Currently the threshold is set to 3/4th of the target management tx queue.

Quoted 2 lines

Patch applied to ath11k-bringup branch of ath.git, thanks.

1a50014ff2d3 ath11k: Add probe response throttling logic

Signature · 9 lines
https://patchwork.kernel.org/patch/11018825/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches


_______________________________________________
ath11k mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/ath11k