Skip to contentSkip to conversation

mac80211: add pre- and post-scan hooks

PATCH In review Dan Williams 3 participants 12 messages Jun 22, 2008 – Sep 11, 2008 mac80211

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mac80211: add pre- and post-scan hooks

mrv8k has commands that get called before and after the scan has been done to save and restore hardware state. Add optional callbacks to mac80211 to enable low-level drivers to know when the stack is about to start scanning, and when it's done.

include/net/mac80211.h +6 -0
index 7ab4ff6..b84e8ac 100644
@@ -1139,6 +1139,10 @@ enum ieee80211_ampdu_mlme_action {
  * 	ieee80211_ampdu_mlme_action. Starting sequence number (@ssn)
  * 	is the first frame we expect to perform the action on. notice
  * 	that TX/RX_STOP can pass NULL for this parameter.
+ *
+ * @prescan: Notifies low level driver that a software scan is about to happen.
+ *
+ * @postscan: Notifies low level driver that software scanning is done.
  */
 struct ieee80211_ops {
 	int (*tx)(struct ieee80211_hw *hw, struct sk_buff *skb);
@@ -1190,6 +1194,8 @@ struct ieee80211_ops {
 	int (*ampdu_action)(struct ieee80211_hw *hw,
 			    enum ieee80211_ampdu_mlme_action action,
 			    const u8 *addr, u16 tid, u16 *ssn);
+	int (*prescan)(struct ieee80211_hw *hw);
+	int (*postscan)(struct ieee80211_hw *hw);
 };
 
 /**
net/mac80211/mlme.c +8 -0
index 55659a7..4bee2a7 100644
@@ -3850,6 +3850,10 @@ void ieee80211_scan_completed(struct ieee80211_hw *hw)
 
 	netif_tx_unlock_bh(local->mdev);
 
+	/* call postscan outside locks because drivers may need to sleep */
+	if (local->ops->postscan)
+		local->ops->postscan(local_to_hw(local));
+
 	rcu_read_lock();
 	list_for_each_entry_rcu(sdata, &local->interfaces, list) {
 
@@ -4045,6 +4048,10 @@ static int ieee80211_sta_start_scan(struct net_device *dev,
 	local->scan_band = IEEE80211_BAND_2GHZ;
 	local->scan_dev = dev;
 
+	/* call prescan outside locks because drivers may need to sleep */
+	if (local->ops->prescan)
+		local->ops->prescan(local_to_hw(local));
+
 	netif_tx_lock_bh(local->mdev);
 	local->filter_flags |= FIF_BCN_PRBRESP_PROMISC;
 	local->ops->configure_filter(local_to_hw(local),
maintainer
#1 lore raw
Quoted 4 lines · Dan Williams

mrv8k has commands that get called before and after the scan has been done to save and restore hardware state. Add optional callbacks to mac80211 to enable low-level drivers to know when the stack is about to start scanning, and when it's done.

I'm not entirely against this, but does it mean the driver will not work with the userspace MLME that does scanning itself in userspace too?

johannes

#2 lore raw
Quoted 8 lines · Johannes Berg
Quoted 4 lines · Dan Williams

mrv8k has commands that get called before and after the scan has been done to save and restore hardware state. Add optional callbacks to mac80211 to enable low-level drivers to know when the stack is about to start scanning, and when it's done.

I'm not entirely against this, but does it mean the driver will not work with the userspace MLME that does scanning itself in userspace too?

Probably not? Both TopDog (linville's marvell.git and your marvell.tar.bz2) both do this. It's too early to tell whether we can get along without it since the driver isn't functional enough yet.

BTW, where'd you get marvell.tar.bz2 from?

Dan

maintainer
#3 lore raw
Quoted 7 lines · Dan Williams
Quoted 6 lines · Johannes Berg
Quoted 4 lines · Dan Williams

mrv8k has commands that get called before and after the scan has been done to save and restore hardware state. Add optional callbacks to mac80211 to enable low-level drivers to know when the stack is about to start scanning, and when it's done.

Quoted 6 lines
Quoted 2 lines

I'm not entirely against this, but does it mean the driver will not work with the userspace MLME that does scanning itself in userspace too?

Probably not? Both TopDog (linville's marvell.git and your marvell.tar.bz2) both do this. It's too early to tell whether we can get along without it since the driver isn't functional enough yet.

Hm. Could we leave it out of mac80211 for now then until you know?

Quoted 1 line

BTW, where'd you get marvell.tar.bz2 from?

No idea, I don't remember, I could probably dig it up in my email but didn't find it quickly right now.

johannes

#4 lore raw
Quoted 8 lines · Johannes Berg
Quoted 7 lines · Dan Williams
Quoted 6 lines · Johannes Berg
Quoted 4 lines · Dan Williams

mrv8k has commands that get called before and after the scan has been done to save and restore hardware state. Add optional callbacks to mac80211 to enable low-level drivers to know when the stack is about to start scanning, and when it's done.

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

I'm not entirely against this, but does it mean the driver will not work with the userspace MLME that does scanning itself in userspace too?

Probably not? Both TopDog (linville's marvell.git and your marvell.tar.bz2) both do this. It's too early to tell whether we can get along without it since the driver isn't functional enough yet.

Hm. Could we leave it out of mac80211 for now then until you know?

Fair enough.

Quoted 4 lines
Quoted 1 line

BTW, where'd you get marvell.tar.bz2 from?

No idea, I don't remember, I could probably dig it up in my email but didn't find it quickly right now.

If it's not too much trouble, would be nice to know.

Thanks!
Dan

maintainer
#5 lore raw
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

BTW, where'd you get marvell.tar.bz2 from?

No idea, I don't remember, I could probably dig it up in my email but didn't find it quickly right now.

If it's not too much trouble, would be nice to know.

I dug a little deeper and realised that I posted to linux-wireless when I found the code. It's from some router GPL code-drop tarball, possibly linksys, but I don't really remember, sorry.

johannes

maintainer
#6 lore raw
In reply to Dan Williams
Quoted 4 lines · Dan Williams

mrv8k has commands that get called before and after the scan has been done to save and restore hardware state. Add optional callbacks to mac80211 to enable low-level drivers to know when the stack is about to start scanning, and when it's done.

Was just talking to Sujith about something on IRC and realised that maybe this is required to turn off IBSS beaconing when leaving the channel for a scan?

johannes

#7 lore raw
Quoted 9 lines · Johannes Berg
Quoted 4 lines · Dan Williams

mrv8k has commands that get called before and after the scan has been done to save and restore hardware state. Add optional callbacks to mac80211 to enable low-level drivers to know when the stack is about to start scanning, and when it's done.

Was just talking to Sujith about something on IRC and realised that maybe this is required to turn off IBSS beaconing when leaving the channel for a scan?

Most cards to the beaconing in hardware/firmware with a given template, right? If so this sounds quite plausible. Does beaconing not get paused now?

Dan

maintainer
#8 lore raw
Quoted 7 lines · Dan Williams
Quoted 6 lines · Johannes Berg
Quoted 4 lines · Dan Williams

mrv8k has commands that get called before and after the scan has been done to save and restore hardware state. Add optional callbacks to mac80211 to enable low-level drivers to know when the stack is about to start scanning, and when it's done.

Quoted 6 lines
Quoted 3 lines

Was just talking to Sujith about something on IRC and realised that maybe this is required to turn off IBSS beaconing when leaving the channel for a scan?

Most cards to the beaconing in hardware/firmware with a given template, right?

Yes, many do.

Quoted 2 lines

If so this sounds quite plausible. Does beaconing not get paused now?

I'd guess not, but I haven't actually tested.

johannes

maintainer
#9 lore raw
In reply to Johannes Berg
Quoted 9 lines · Johannes Berg
Quoted 4 lines · Dan Williams

mrv8k has commands that get called before and after the scan has been done to save and restore hardware state. Add optional callbacks to mac80211 to enable low-level drivers to know when the stack is about to start scanning, and when it's done.

Was just talking to Sujith about something on IRC and realised that maybe this is required to turn off IBSS beaconing when leaving the channel for a scan?

On the other hand, we should add API to turn off beaconing anyway, which userspace might actually request. And when we do that, we can use it to turn off IBSS beaconing.

The beaconing API in total is a bit strange, we tell the driver when the beacon changes and it can then request one, but we never tell it when to start/stop beaconing, which means that currently your driver has to figure to start out beaconing on the first beacon change, and then cannot possibly stop again... We can return NULL from the beacon get function but that could be an error condition too...

I think we just need to add start/stop beacon bits, and then we can use them around a scan too, thoughts?

johannes

#10 lore raw
Quoted 6 lines · Johannes Berg

The beaconing API in total is a bit strange, we tell the driver when the beacon changes and it can then request one, but we never tell it when to start/stop beaconing, which means that currently your driver has to figure to start out beaconing on the first beacon change, and then cannot possibly stop again... We can return NULL from the beacon get function but that could be an error condition too...

The original design was for AP mode only and the assumption was that Beacon transmission is enabled pretty much all the time. Returning NULL was used if ever needed to stop Beacon transmission for some period of time.

Quoted 2 lines

I think we just need to add start/stop beacon bits, and then we can use them around a scan too, thoughts?

That sounds reasonable.

- Jouni

maintainer
#11 lore raw
Quoted 8 lines · Jouni Malinen
Quoted 6 lines · Johannes Berg

The beaconing API in total is a bit strange, we tell the driver when the beacon changes and it can then request one, but we never tell it when to start/stop beaconing, which means that currently your driver has to figure to start out beaconing on the first beacon change, and then cannot possibly stop again... We can return NULL from the beacon get function but that could be an error condition too...

Quoted 4 lines

The original design was for AP mode only and the assumption was that Beacon transmission is enabled pretty much all the time. Returning NULL was used if ever needed to stop Beacon transmission for some period of time.

That can only work with some hardware though, if the hardware doesn't beacon from a template.

Quoted 4 lines
Quoted 2 lines

I think we just need to add start/stop beacon bits, and then we can use them around a scan too, thoughts?

That sounds reasonable.

I'll take a look sometime.

johannes