Skip to contentSkip to conversation

mac80211: use nullfunc instead of probe request for connection monitoring

PATCH Superseded Felix Fietkau 2 participants 3 messages Nov 20, 2010 mac80211

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/2 mac80211: use nullfunc instead of probe request for connection monitoring

nullfunc frames are better for connection monitoring, because probe requests are answered even if the AP has already dropped the connection, whereas nullfunc frames from an unassociated station will trigger a disassoc/deauth frame from the AP (WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA), which allows the station to reconnect immediately instead of waiting until it attempts to transmit the next unicast frame.

This only works on hardware with reliable tx ACK reporting, any other hardware needs to fall back to the probe request method.

---
 net/mac80211/ieee80211_i.h |    2 +
 net/mac80211/mlme.c        |   88 +++++++++++++++++++++++++++++++------------
 net/mac80211/status.c      |    4 ++
 3 files changed, 69 insertions(+), 25 deletions(-)
net/mac80211/ieee80211_i.h +2 -0
index 3598abf..7bb9a62 100644
@@ -1264,6 +1264,8 @@ void ieee80211_send_nullfunc(struct ieee80211_local *local,
 			     int powersave);
 void ieee80211_sta_rx_notify(struct ieee80211_sub_if_data *sdata,
 			     struct ieee80211_hdr *hdr);
+void ieee80211_sta_tx_notify(struct ieee80211_sub_if_data *sdata,
+			     struct ieee80211_hdr *hdr);
 void ieee80211_beacon_connection_loss_work(struct work_struct *work);
 
 void ieee80211_wake_queues_by_reason(struct ieee80211_hw *hw,
net/mac80211/mlme.c +63 -25

112 lines not on this page · raw message

net/mac80211/status.c +4 -0
index 3153c19..8695cd1 100644
@@ -155,6 +155,10 @@ static void ieee80211_frame_acked(struct sta_info *sta, struct sk_buff *skb)
 
 		ieee80211_queue_work(&local->hw, &local->recalc_smps);
 	}
+
+	if ((sdata->vif.type == NL80211_IFTYPE_STATION) &&
+	    (local->hw.flags & IEEE80211_HW_REPORTS_TX_ACK_STATUS))
+		ieee80211_sta_tx_notify(sdata, (void *) skb->data);
 }
 
 void ieee80211_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb)
Signature · 1 line
1.7.3.2
#1 lore raw

PATCH v3 2/2 mac80211: reduce the number of retries for nullfunc probing

Since nullfunc frames are transmitted as unicast frames, they're more reliable than the broadcast probe requests, so we need fewer retries to figure out whether the AP is really gone.

---
 net/mac80211/mlme.c |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)
net/mac80211/mlme.c +8 -1
index 18c0e42..0c0f9fa 100644
@@ -28,6 +28,7 @@
 #include "rate.h"
 #include "led.h"
 
+#define IEEE80211_MAX_NULLFUNC_TRIES 2
 #define IEEE80211_MAX_PROBE_TRIES 5
 
 /*
@@ -1915,16 +1916,22 @@ void ieee80211_sta_work(struct ieee80211_sub_if_data *sdata)
 			    IEEE80211_STA_CONNECTION_POLL) &&
 	    ifmgd->associated) {
 		u8 bssid[ETH_ALEN];
+		int max_tries;
 
 		/* ACK received for nullfunc probing frame */
 		if (!ifmgd->probe_send_count)
 			ieee80211_reset_ap_probe(sdata);
 
+		if (local->hw.flags & IEEE80211_HW_REPORTS_TX_ACK_STATUS)
+			max_tries = IEEE80211_MAX_NULLFUNC_TRIES;
+		else
+			max_tries = IEEE80211_MAX_PROBE_TRIES;
+
 		memcpy(bssid, ifmgd->associated->bssid, ETH_ALEN);
 		if (time_is_after_jiffies(ifmgd->probe_timeout))
 			run_again(ifmgd, ifmgd->probe_timeout);
 
-		else if (ifmgd->probe_send_count < IEEE80211_MAX_PROBE_TRIES) {
+		else if (ifmgd->probe_send_count < max_tries) {
 #ifdef CONFIG_MAC80211_VERBOSE_DEBUG
 			wiphy_debug(local->hw.wiphy,
 				    "%s: No probe response from AP %pM"
Signature · 1 line
1.7.3.2
#2 lore raw
In reply to Felix Fietkau

A couple of issues here, I think.

Quoted 2 lines · Felix Fietkau
net/mac80211/mlme.c +0 -0

[...]

net/mac80211/mlme.c void ieee80211_sta_rx_notify(struct ieee80211_sub_if_data *sdata, · line 1067

Quoted 10 lines
net/mac80211/mlme.c +10 -0
+void ieee80211_sta_tx_notify(struct ieee80211_sub_if_data *sdata,
+                            struct ieee80211_hdr *hdr)
+{
+       if (!ieee80211_is_data(hdr->frame_control) &&
+           !ieee80211_is_nullfunc(hdr->frame_control))
+           return;
+
+       ieee80211_sta_reset_conn_monitor(sdata);
+
+       if (ieee80211_is_nullfunc(hdr->frame_control)) {

Could you also add a "&& sdata->u.mgd.probe_send_count = 0" condition here, or the BEACON/CONNECTION poll test to reduce the number of times we queue work here? Or should this work be done on every ACKed nullfunc?

Quoted 9 lines

+               sdata->u.mgd.probe_send_count = 0;
+               ieee80211_queue_work(&sdata->local->hw, &sdata->work);
+       }

net/mac80211/mlme.c +2 -0
+}
+

 static void ieee80211_mgd_probe_ap_send(struct ieee80211_sub_if_data *sdata) {
       struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;

net/mac80211/mlme.c void ieee80211_sta_work(struct ieee80211_sub_if_data *sdata) · line 1922

Quoted 7 lines
net/mac80211/mlme.c +4 -0
@@ -1882,6 +1916,10 @@ void ieee80211_sta_work(struct ieee80211_sub_if_data *sdata)
            ifmgd->associated) {
                u8 bssid[ETH_ALEN];
 
+               /* ACK received for nullfunc probing frame */
+               if (!ifmgd->probe_send_count)
+                       ieee80211_reset_ap_probe(sdata);
+

Yeah, but then it looks like we'd end up falling through to the "ifmgd->probe_send_count < IEEE80211_MAX_PROBE_TRIES" case later in this block, and send another probe! Not good.

net/mac80211/mlme.c void ieee80211_sta_work(struct ieee80211_sub_if_data *sdata) · line 1925

Quoted 3 lines
net/mac80211/mlme.c +0 -0
                memcpy(bssid, ifmgd->associated->bssid, ETH_ALEN);
                if (time_is_after_jiffies(ifmgd->probe_timeout))
                        run_again(ifmgd, ifmgd->probe_timeout);

--
Paul