Skip to contentSkip to conversation

broadcast buffer / TIM map in mesh mode

RFC New Marco Porsch 2 participants 3 messages Oct 1, 2012 – Oct 2, 2012 mac80211

lore
Share & tools
lore
#0 lore raw

Hi,

I am working on a mesh powersave implementation. One requirement for that is to buffer broadcasts, set the TIM map and count powersave neighbors. All of these routines are currently bound to the AP-specific ieee80211_if_ap structure. Do you have any recommendations how to properly implement this for mesh interfaces?

a) allocate/free ieee80211_if_ap in iface.c:ieee80211_do_open/ieee80211_do_stop and bind to sdata->bss pointer?
b) include ieee80211_if_ap into ieee80211_if_mesh structure and use sdata->bss?
c) completely different?

Also, what is the purpose of the sdata->bss pointer? It seems to be used at times and not at others.

I have currently implemented a) here https://github.com/cozybit/open80211s/commit/66c40d36087c502f8c52b84861faad6f483ffeb8 as part of a series https://github.com/cozybit/open80211s/compare/38555f9d78...ft-powersave .

Regards,
Marco

maintainer
#1 lore raw

Hi Marco,

Quoted 7 lines

I am working on a mesh powersave implementation. One requirement for that is to buffer broadcasts, set the TIM map and count powersave neighbors. All of these routines are currently bound to the AP-specific ieee80211_if_ap structure.
Do you have any recommendations how to properly implement this for mesh interfaces?

Quoted 5 lines

a) allocate/free ieee80211_if_ap in iface.c:ieee80211_do_open/ieee80211_do_stop and bind to sdata->bss pointer?
b) include ieee80211_if_ap into ieee80211_if_mesh structure and use sdata->bss?
c) completely different?

I don't think a) or b) are appropriate since the if_ap structure contains a number of fields that you won't use or need. I would therefore suggest to split out the PS related fields of that structure into a substructure that you embed in both if_ap and if_mesh, and in the code you could then pass a pointer to that structure to the powersave handling functions.

Please do a separate patch to separate it out though, not just one huge patch to do both mesh & the splitting up :)

Quoted 2 lines

Also, what is the purpose of the sdata->bss pointer? It seems to be used at times and not at others.

The sdata->bss pointer should be used in *most* cases, it's a link to the "AP data" for the AP interface (where it just points to itself) and any AP_VLAN interface (where it points to the master AP interface)

#2 lore raw

RFC 1/1 mac80211: make powersave independent of interface type

This patch prepares mac80211 for a later implementation of mesh or ad-hoc powersave.
The structures related to powersave (buffer, TIM map, counters) are moved from the AP-specific interface structure to a generic structure that can be embedded into any interface type.
The functions related to powersave are prepared to allow easy extension with different interface types.

The patch compiles without warning but has not been tested yet.

---
 net/mac80211/debugfs_netdev.c |    6 +--
 net/mac80211/ieee80211_i.h    |   20 ++++----
 net/mac80211/iface.c          |    6 +--
 net/mac80211/rx.c             |   21 ++++++---
 net/mac80211/sta_info.c       |   45 +++++++++++++-----
 net/mac80211/tx.c             |  102 ++++++++++++++++++++++++-----------------
 6 files changed, 126 insertions(+), 74 deletions(-)
net/mac80211/debugfs_netdev.c +3 -3
index 6d5aec9..c83b8ca 100644
@@ -395,14 +395,14 @@ __IEEE80211_IF_FILE_W(uapsd_max_sp_len);
 
 /* AP attributes */
 IEEE80211_IF_FILE(num_mcast_sta, u.ap.num_mcast_sta, ATOMIC);
-IEEE80211_IF_FILE(num_sta_ps, u.ap.num_sta_ps, ATOMIC);
-IEEE80211_IF_FILE(dtim_count, u.ap.dtim_count, DEC);
+IEEE80211_IF_FILE(num_sta_ps, u.ap.ps.num_sta_ps, ATOMIC);
+IEEE80211_IF_FILE(dtim_count, u.ap.ps.dtim_count, DEC);
 
 static ssize_t ieee80211_if_fmt_num_buffered_multicast(
 	const struct ieee80211_sub_if_data *sdata, char *buf, int buflen)
 {
 	return scnprintf(buf, buflen, "%u\n",
-			 skb_queue_len(&sdata->u.ap.ps_bc_buf));
+			 skb_queue_len(&sdata->u.ap.ps.bc_buf));
 }
 __IEEE80211_IF_FILE(num_buffered_multicast, NULL);
 
net/mac80211/ieee80211_i.h +12 -8
index 8c80455..c430302 100644
@@ -280,23 +280,27 @@ struct probe_resp {
 	u8 data[0];
 };
 
-struct ieee80211_if_ap {
-	struct beacon_data __rcu *beacon;
-	struct probe_resp __rcu *probe_resp;
-
-	struct list_head vlans;
-
+struct ps_data {
 	/* yes, this looks ugly, but guarantees that we can later use
 	 * bitmap_empty :)
 	 * NB: don't touch this bitmap, use sta_info_{set,clear}_tim_bit */
 	u8 tim[sizeof(unsigned long) * BITS_TO_LONGS(IEEE80211_MAX_AID + 1)];
-	struct sk_buff_head ps_bc_buf;
+	struct sk_buff_head bc_buf;
 	atomic_t num_sta_ps; /* number of stations in PS mode */
-	atomic_t num_mcast_sta; /* number of stations receiving multicast */
 	int dtim_count;
 	bool dtim_bc_mc;
 };
 
+struct ieee80211_if_ap {
+	struct beacon_data __rcu *beacon;
+	struct probe_resp __rcu *probe_resp;
+
+	struct list_head vlans;
+
+	struct ps_data ps;
+	atomic_t num_mcast_sta; /* number of stations receiving multicast */
+};
+
 struct ieee80211_if_wds {
 	struct sta_info *sta;
 	u8 remote_addr[ETH_ALEN];
net/mac80211/iface.c +3 -3
index 6f8a73c..f41b5cf 100644
@@ -755,8 +755,8 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
 		WARN_ON(!list_empty(&sdata->u.ap.vlans));
 
 		/* free all potentially still buffered bcast frames */
-		local->total_ps_buffered -= skb_queue_len(&sdata->u.ap.ps_bc_buf);
-		skb_queue_purge(&sdata->u.ap.ps_bc_buf);
+		local->total_ps_buffered -= skb_queue_len(&sdata->u.ap.ps.bc_buf);
+		skb_queue_purge(&sdata->u.ap.ps.bc_buf);
 	} else if (sdata->vif.type == NL80211_IFTYPE_STATION) {
 		ieee80211_mgd_stop(sdata);
 	}
@@ -1157,7 +1157,7 @@ static void ieee80211_setup_sdata(struct ieee80211_sub_if_data *sdata,
 		sdata->vif.p2p = true;
 		/* fall through */
 	case NL80211_IFTYPE_AP:
-		skb_queue_head_init(&sdata->u.ap.ps_bc_buf);
+		skb_queue_head_init(&sdata->u.ap.ps.bc_buf);
 		INIT_LIST_HEAD(&sdata->u.ap.vlans);
 		break;
 	case NL80211_IFTYPE_P2P_CLIENT:
net/mac80211/rx.c +14 -7
index 61c621e..0573b1b 100644
@@ -1141,12 +1141,19 @@ ieee80211_rx_h_check_more_data(struct ieee80211_rx_data *rx)
 	return RX_CONTINUE;
 }
 
-static void ap_sta_ps_start(struct sta_info *sta)
+static void sta_ps_start(struct sta_info *sta)
 {
 	struct ieee80211_sub_if_data *sdata = sta->sdata;
 	struct ieee80211_local *local = sdata->local;
+	struct ps_data *ps;
 
-	atomic_inc(&sdata->bss->num_sta_ps);
+	if (sta->sdata->vif.type == NL80211_IFTYPE_AP ||
+	    sta->sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
+		ps = &sdata->bss->ps;
+	else
+		return;
+
+	atomic_inc(&ps->num_sta_ps);
 	set_sta_flag(sta, WLAN_STA_PS_STA);
 	if (!(local->hw.flags & IEEE80211_HW_AP_LINK_PS))
 		drv_sta_notify(local, sdata, STA_NOTIFY_SLEEP, &sta->sta);
@@ -1154,7 +1161,7 @@ static void ap_sta_ps_start(struct sta_info *sta)
 	       sta->sta.addr, sta->sta.aid);
 }
 
-static void ap_sta_ps_end(struct sta_info *sta)
+static void sta_ps_end(struct sta_info *sta)
 {
 	ps_dbg(sta->sdata, "STA %pM aid %d exits power save mode\n",
 	       sta->sta.addr, sta->sta.aid);
@@ -1181,9 +1188,9 @@ int ieee80211_sta_ps_transition(struct ieee80211_sta *sta, bool start)
 		return -EINVAL;
 
 	if (start)
-		ap_sta_ps_start(sta_inf);
+		sta_ps_start(sta_inf);
 	else
-		ap_sta_ps_end(sta_inf);
+		sta_ps_end(sta_inf);
 
 	return 0;
 }
@@ -1335,10 +1342,10 @@ ieee80211_rx_h_sta_process(struct ieee80211_rx_data *rx)
 			 */
 			if (ieee80211_is_data(hdr->frame_control) &&
 			    !ieee80211_has_pm(hdr->frame_control))
-				ap_sta_ps_end(sta);
+				sta_ps_end(sta);
 		} else {
 			if (ieee80211_has_pm(hdr->frame_control))
-				ap_sta_ps_start(sta);
+				sta_ps_start(sta);
 		}
 	}
 
net/mac80211/sta_info.c +34 -11

106 lines not on this page · raw message

net/mac80211/tx.c +60 -42

231 lines not on this page · raw message

Signature · 1 line
1.7.9.5