2009-01-20 08:01:19

by Sujith

[permalink] [raw]
Subject: [PATCH] mac80211: Add capability to enable/disable beaconing

This patch adds a flag to notify drivers to start and
stop beaconing when needed, for example, during a scan run.

Signed-off-by: Sujith <[email protected]>
---
include/net/mac80211.h | 3 +++
net/mac80211/main.c | 10 ++++++++++
net/mac80211/scan.c | 3 +++
3 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index 9a5869e..a9f71b5 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -637,6 +637,8 @@ enum ieee80211_if_conf_change {
*
* @changed: parameters that have changed, see &enum ieee80211_if_conf_change.
* @bssid: BSSID of the network we are associated to/creating.
+ * @enable_beacon: Indicates whether beacons can be sent.
+ * This is valid only for AP/IBSS/MESH modes.
*
* This structure is passed to the config_interface() callback of
* &struct ieee80211_hw.
@@ -644,6 +646,7 @@ enum ieee80211_if_conf_change {
struct ieee80211_if_conf {
u32 changed;
u8 *bssid;
+ bool enable_beacon;
};

/**
diff --git a/net/mac80211/main.c b/net/mac80211/main.c
index c78304d..44585c7 100644
--- a/net/mac80211/main.c
+++ b/net/mac80211/main.c
@@ -183,6 +183,16 @@ int ieee80211_if_config(struct ieee80211_sub_if_data *sdata, u32 changed)
return -EINVAL;
}

+ if ((changed & IEEE80211_IFCC_BEACON) &&
+ (sdata->vif.type == NL80211_IFTYPE_AP ||
+ sdata->vif.type == NL80211_IFTYPE_ADHOC ||
+ sdata->vif.type == NL80211_IFTYPE_MESH_POINT)) {
+ if (local->sw_scanning || local->hw_scanning)
+ conf.enable_beacon = false;
+ else
+ conf.enable_beacon = true;
+ }
+
if (WARN_ON(!conf.bssid && (changed & IEEE80211_IFCC_BSSID)))
return -EINVAL;

diff --git a/net/mac80211/scan.c b/net/mac80211/scan.c
index a2caeed..c8be92d 100644
--- a/net/mac80211/scan.c
+++ b/net/mac80211/scan.c
@@ -459,6 +459,7 @@ void ieee80211_scan_completed(struct ieee80211_hw *hw)

local->sw_scanning = false;
ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_CHANNEL);
+ ieee80211_if_config(sdata, IEEE80211_IFCC_BEACON);

netif_tx_lock_bh(local->mdev);
netif_addr_lock(local->mdev);
@@ -655,6 +656,8 @@ int ieee80211_start_scan(struct ieee80211_sub_if_data *scan_sdata,
local->scan_band = IEEE80211_BAND_2GHZ;
local->scan_sdata = scan_sdata;

+ ieee80211_if_config(scan_sdata, IEEE80211_IFCC_BEACON);
+
netif_addr_lock_bh(local->mdev);
local->filter_flags |= FIF_BCN_PRBRESP_PROMISC;
local->ops->configure_filter(local_to_hw(local),
--
1.6.1



2009-01-22 03:32:08

by Sujith

[permalink] [raw]
Subject: Re: [PATCH] mac80211: Add capability to enable/disable beaconing

Johannes Berg wrote:
> On Wed, 2009-01-21 at 12:45 +0100, Johannes Berg wrote:
>
> > How about this? Untested still though.
>
> That ran into a bug, here's a version that's hopefully better. (second
> patch unchanged)

Tested in IBSS mode, works fine. Thanks a lot.

Sujith

2009-01-21 12:44:16

by Johannes Berg

[permalink] [raw]
Subject: Re: [PATCH] mac80211: Add capability to enable/disable beaconing

On Tue, 2009-01-20 at 21:30 +0530, Sujith wrote:
> Johannes Berg wrote:
> > cOn Tue, 2009-01-20 at 13:27 +0530, Sujith wrote:
> > > This patch adds a flag to notify drivers to start and
> > > stop beaconing when needed, for example, during a scan run.
> >
> >
> > > + if ((changed & IEEE80211_IFCC_BEACON) &&
> > > + (sdata->vif.type == NL80211_IFTYPE_AP ||
> > > + sdata->vif.type == NL80211_IFTYPE_ADHOC ||
> > > + sdata->vif.type == NL80211_IFTYPE_MESH_POINT)) {
> > > + if (local->sw_scanning || local->hw_scanning)
> > > + conf.enable_beacon = false;
> > > + else
> > > + conf.enable_beacon = true;
> > > + }
> > > +
> >
> > You really just want to do the minimal thing, right? :)
>
> Oh, absolutely :)

:)

> > That won't work when userspace disables the beacon by removing it, for
> > instance, right now drivers won't know when hostapd removed the beacon
> > except that ieee80211_beacon_get will start returning 0... Also, I think
> > a separate change flag would be appropriate, sometimes we might just
> > re-enable the beacon without having changed it, after scanning?
>
> Ok, how about this ?

How about this? Untested still though.

johannes


Attachments:
015-mac80211-add-iflock.patch (4.35 kB)
016-mac80211-beacon-endis.patch (7.27 kB)
signature.asc (836.00 B)
This is a digitally signed message part
Download all attachments

2009-01-20 16:02:22

by Sujith

[permalink] [raw]
Subject: Re: [PATCH] mac80211: Add capability to enable/disable beaconing

Johannes Berg wrote:
> cOn Tue, 2009-01-20 at 13:27 +0530, Sujith wrote:
> > This patch adds a flag to notify drivers to start and
> > stop beaconing when needed, for example, during a scan run.
>
>
> > + if ((changed & IEEE80211_IFCC_BEACON) &&
> > + (sdata->vif.type == NL80211_IFTYPE_AP ||
> > + sdata->vif.type == NL80211_IFTYPE_ADHOC ||
> > + sdata->vif.type == NL80211_IFTYPE_MESH_POINT)) {
> > + if (local->sw_scanning || local->hw_scanning)
> > + conf.enable_beacon = false;
> > + else
> > + conf.enable_beacon = true;
> > + }
> > +
>
> You really just want to do the minimal thing, right? :)

Oh, absolutely :)

> That won't work when userspace disables the beacon by removing it, for
> instance, right now drivers won't know when hostapd removed the beacon
> except that ieee80211_beacon_get will start returning 0... Also, I think
> a separate change flag would be appropriate, sometimes we might just
> re-enable the beacon without having changed it, after scanning?

Ok, how about this ?

diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index 9a5869e..72a3025 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -624,12 +624,18 @@ struct ieee80211_if_init_conf {
* enum ieee80211_if_conf_change - interface config change flags
*
* @IEEE80211_IFCC_BSSID: The BSSID changed.
- * @IEEE80211_IFCC_BEACON: The beacon for this interface changed
- * (currently AP and MESH only), use ieee80211_beacon_get().
+ * @IEEE80211_IFCC_CONFIGURE_BEACON: The beacon for this interface changed
+ * (currently AP,IBSS and MESH only), use ieee80211_beacon_get().
+ * @IEEE80211_IFCC_STOP_BEACON: Indicates that beaconing should be stopped
+ * by the driver.
+ * @IEEE80211_IFCC_RESUME_BEACON: Beaconing can be resumed by the driver,
+ * with the original template obtained from mac80211.
*/
enum ieee80211_if_conf_change {
- IEEE80211_IFCC_BSSID = BIT(0),
- IEEE80211_IFCC_BEACON = BIT(1),
+ IEEE80211_IFCC_BSSID = BIT(0),
+ IEEE80211_IFCC_CONFIGURE_BEACON = BIT(1),
+ IEEE80211_IFCC_STOP_BEACON = BIT(2),
+ IEEE80211_IFCC_RESUME_BEACON = BIT(3)
};

/**
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index d1ac3ab..b6d718c 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -523,7 +523,7 @@ static int ieee80211_config_beacon(struct ieee80211_sub_if_data *sdata,

kfree(old);

- return ieee80211_if_config(sdata, IEEE80211_IFCC_BEACON);
+ return ieee80211_if_config(sdata, IEEE80211_IFCC_CONFIGURE_BEACON);
}

static int ieee80211_add_beacon(struct wiphy *wiphy, struct net_device *dev,
@@ -583,7 +583,7 @@ static int ieee80211_del_beacon(struct wiphy *wiphy, struct net_device *dev)
synchronize_rcu();
kfree(old);

- return ieee80211_if_config(sdata, IEEE80211_IFCC_BEACON);
+ return ieee80211_if_config(sdata, IEEE80211_IFCC_STOP_BEACON);
}

/* Layer 2 Update frame (802.2 Type 1 LLC XID Update response) */
diff --git a/net/mac80211/mesh.c b/net/mac80211/mesh.c
index 82f568e..988827c 100644
--- a/net/mac80211/mesh.c
+++ b/net/mac80211/mesh.c
@@ -427,7 +427,7 @@ static void ieee80211_mesh_housekeeping(struct ieee80211_sub_if_data *sdata,

free_plinks = mesh_plink_availables(sdata);
if (free_plinks != sdata->u.mesh.accepting_plinks)
- ieee80211_if_config(sdata, IEEE80211_IFCC_BEACON);
+ ieee80211_if_config(sdata, IEEE80211_IFCC_CONFIGURE_BEACON);

ifmsh->housekeeping = false;
mod_timer(&ifmsh->housekeeping_timer,
@@ -442,7 +442,7 @@ void ieee80211_start_mesh(struct ieee80211_sub_if_data *sdata)

ifmsh->housekeeping = true;
queue_work(local->hw.workqueue, &ifmsh->work);
- ieee80211_if_config(sdata, IEEE80211_IFCC_BEACON);
+ ieee80211_if_config(sdata, IEEE80211_IFCC_CONFIGURE_BEACON);
}

void ieee80211_stop_mesh(struct ieee80211_sub_if_data *sdata)
diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c
index 81c5cff..59197bd 100644
--- a/net/mac80211/mlme.c
+++ b/net/mac80211/mlme.c
@@ -1598,7 +1598,7 @@ static int ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata,

ifsta->probe_resp = skb;

- ieee80211_if_config(sdata, IEEE80211_IFCC_BEACON);
+ ieee80211_if_config(sdata, IEEE80211_IFCC_CONFIGURE_BEACON);


rates = 0;
diff --git a/net/mac80211/scan.c b/net/mac80211/scan.c
index a2caeed..09f4839 100644
--- a/net/mac80211/scan.c
+++ b/net/mac80211/scan.c
@@ -459,6 +459,7 @@ void ieee80211_scan_completed(struct ieee80211_hw *hw)

local->sw_scanning = false;
ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_CHANNEL);
+ ieee80211_if_config(sdata, IEEE80211_IFCC_RESUME_BEACON);

netif_tx_lock_bh(local->mdev);
netif_addr_lock(local->mdev);
@@ -655,6 +656,8 @@ int ieee80211_start_scan(struct ieee80211_sub_if_data *scan_sdata,
local->scan_band = IEEE80211_BAND_2GHZ;
local->scan_sdata = scan_sdata;

+ ieee80211_if_config(scan_sdata, IEEE80211_IFCC_STOP_BEACON);
+
netif_addr_lock_bh(local->mdev);
local->filter_flags |= FIF_BCN_PRBRESP_PROMISC;
local->ops->configure_filter(local_to_hw(local),

2009-01-21 13:02:40

by Johannes Berg

[permalink] [raw]
Subject: Re: [PATCH] mac80211: Add capability to enable/disable beaconing

On Wed, 2009-01-21 at 12:45 +0100, Johannes Berg wrote:

> How about this? Untested still though.

That ran into a bug, here's a version that's hopefully better. (second
patch unchanged)

johannes


Attachments:
015-mac80211-add-iflock.patch (4.57 kB)
signature.asc (836.00 B)
This is a digitally signed message part
Download all attachments

2009-01-20 19:55:19

by Luis R. Rodriguez

[permalink] [raw]
Subject: Re: [PATCH] mac80211: Add capability to enable/disable beaconing

On Tue, Jan 20, 2009 at 08:00:08AM -0800, Sujith wrote:
> Johannes Berg wrote:
> > cOn Tue, 2009-01-20 at 13:27 +0530, Sujith wrote:
> > > This patch adds a flag to notify drivers to start and
> > > stop beaconing when needed, for example, during a scan run.
> >
> >
> > > + if ((changed & IEEE80211_IFCC_BEACON) &&
> > > + (sdata->vif.type == NL80211_IFTYPE_AP ||
> > > + sdata->vif.type == NL80211_IFTYPE_ADHOC ||
> > > + sdata->vif.type == NL80211_IFTYPE_MESH_POINT)) {
> > > + if (local->sw_scanning || local->hw_scanning)
> > > + conf.enable_beacon = false;
> > > + else
> > > + conf.enable_beacon = true;
> > > + }
> > > +
> >
> > You really just want to do the minimal thing, right? :)
>
> Oh, absolutely :)
>
> > That won't work when userspace disables the beacon by removing it, for
> > instance, right now drivers won't know when hostapd removed the beacon
> > except that ieee80211_beacon_get will start returning 0... Also, I think
> > a separate change flag would be appropriate, sometimes we might just
> > re-enable the beacon without having changed it, after scanning?
>
> Ok, how about this ?
>
> diff --git a/include/net/mac80211.h b/include/net/mac80211.h
> index 9a5869e..72a3025 100644
> --- a/include/net/mac80211.h
> +++ b/include/net/mac80211.h
> @@ -624,12 +624,18 @@ struct ieee80211_if_init_conf {
> * enum ieee80211_if_conf_change - interface config change flags
> *
> * @IEEE80211_IFCC_BSSID: The BSSID changed.
> - * @IEEE80211_IFCC_BEACON: The beacon for this interface changed
> - * (currently AP and MESH only), use ieee80211_beacon_get().
> + * @IEEE80211_IFCC_CONFIGURE_BEACON: The beacon for this interface changed
> + * (currently AP,IBSS and MESH only), use ieee80211_beacon_get().
> + * @IEEE80211_IFCC_STOP_BEACON: Indicates that beaconing should be stopped
> + * by the driver.
> + * @IEEE80211_IFCC_RESUME_BEACON: Beaconing can be resumed by the driver,
> + * with the original template obtained from mac80211.
> */
> enum ieee80211_if_conf_change {
> - IEEE80211_IFCC_BSSID = BIT(0),
> - IEEE80211_IFCC_BEACON = BIT(1),
> + IEEE80211_IFCC_BSSID = BIT(0),
> + IEEE80211_IFCC_CONFIGURE_BEACON = BIT(1),
> + IEEE80211_IFCC_STOP_BEACON = BIT(2),
> + IEEE80211_IFCC_RESUME_BEACON = BIT(3)

This would make grep'ing easier:

IEEE80211_IFCC_BEACON_CONFIGURE = BIT(1),
IEEE80211_IFCC_BEACON_STOP = BIT(2),
IEEE80211_IFCC_BEACON_RESUME = BIT(3)

Luis

2009-01-20 10:53:40

by Johannes Berg

[permalink] [raw]
Subject: Re: [PATCH] mac80211: Add capability to enable/disable beaconing

cOn Tue, 2009-01-20 at 13:27 +0530, Sujith wrote:
> This patch adds a flag to notify drivers to start and
> stop beaconing when needed, for example, during a scan run.


> + if ((changed & IEEE80211_IFCC_BEACON) &&
> + (sdata->vif.type == NL80211_IFTYPE_AP ||
> + sdata->vif.type == NL80211_IFTYPE_ADHOC ||
> + sdata->vif.type == NL80211_IFTYPE_MESH_POINT)) {
> + if (local->sw_scanning || local->hw_scanning)
> + conf.enable_beacon = false;
> + else
> + conf.enable_beacon = true;
> + }
> +

You really just want to do the minimal thing, right? :)

That won't work when userspace disables the beacon by removing it, for
instance, right now drivers won't know when hostapd removed the beacon
except that ieee80211_beacon_get will start returning 0... Also, I think
a separate change flag would be appropriate, sometimes we might just
re-enable the beacon without having changed it, after scanning?

johannes


Attachments:
signature.asc (836.00 B)
This is a digitally signed message part