linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/3] cfg80211/mac80211: CSA notification
@ 2014-11-07 12:31 Luca Coelho
  2014-11-07 12:31 ` [PATCH v2 1/3] cfg80211/nl80211: add channel switch started notification Luca Coelho
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Luca Coelho @ 2014-11-07 12:31 UTC (permalink / raw)
  To: johannes; +Cc: linux-wireless, emmanuel.grumbach

From: Luciano Coelho <luciano.coelho@intel.com>

This is a rework of the channel switch started notification that I
sent a long time ago.  According to the review, I removed the failure
notification.  Additionally, some other small changes were made to fix
some things and adapt to the current code.

Please review.

--
Luca.

Luciano Coelho (3):
  cfg80211/nl80211: add channel switch started notification
  mac80211: send channel switch started notifications
  cfg80211/nl80211: allow any interface to send channel switch
    notifications

 include/net/cfg80211.h       | 14 ++++++++++++++
 include/uapi/linux/nl80211.h | 15 ++++++++++++++-
 net/mac80211/cfg.c           |  3 +++
 net/mac80211/mlme.c          |  5 +++++
 net/wireless/nl80211.c       | 34 +++++++++++++++++++++++++---------
 net/wireless/trace.h         | 16 ++++++++++++++++
 6 files changed, 77 insertions(+), 10 deletions(-)

-- 
2.1.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v2 1/3] cfg80211/nl80211: add channel switch started notification
  2014-11-07 12:31 [PATCH v2 0/3] cfg80211/mac80211: CSA notification Luca Coelho
@ 2014-11-07 12:31 ` Luca Coelho
  2014-11-07 12:31 ` [PATCH v2 2/3] mac80211: send channel switch started notifications Luca Coelho
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Luca Coelho @ 2014-11-07 12:31 UTC (permalink / raw)
  To: johannes; +Cc: linux-wireless, emmanuel.grumbach

From: Luciano Coelho <luciano.coelho@intel.com>

Add a new NL80211_CH_SWITCH_STARTED_NOTIFY message that can be sent to
the userspace when a channel switch process has started.  This allows
userspace to take action, for instance, by requesting other interfaces
to switch channel as necessary.

This patch introduces a function that allows the drivers to send this
notification.  It should be used when the driver starts processing a
channel switch initiated by a remote device (eg. when a STA receives a
CSA from the AP) and when it successfully starts a userspace-triggered
channel switch (eg. when hostapd triggers a channel swith in the AP).

Signed-off-by: Luciano Coelho <luciano.coelho@intel.com>
---
 include/net/cfg80211.h       | 14 ++++++++++++++
 include/uapi/linux/nl80211.h | 11 +++++++++++
 net/wireless/nl80211.c       | 28 +++++++++++++++++++++++++---
 net/wireless/trace.h         | 16 ++++++++++++++++
 4 files changed, 66 insertions(+), 3 deletions(-)

diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 5c3acd0..220d5f5 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -4719,6 +4719,20 @@ bool cfg80211_reg_can_beacon(struct wiphy *wiphy,
 void cfg80211_ch_switch_notify(struct net_device *dev,
 			       struct cfg80211_chan_def *chandef);
 
+/*
+ * cfg80211_ch_switch_started_notify - notify channel switch start
+ * @dev: the device on which the channel switch started
+ * @chandef: the future channel definition
+ * @count: the number of TBTTs until the channel switch happens
+ *
+ * Inform the userspace about the channel switch that has just
+ * started, so that it can take appropriate actions (eg. starting
+ * channel switch on other vifs), if necessary.
+ */
+void cfg80211_ch_switch_started_notify(struct net_device *dev,
+				       struct cfg80211_chan_def *chandef,
+				       u8 count);
+
 /**
  * ieee80211_operating_class_to_band - convert operating class to band
  *
diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
index 9b3025e..3541634 100644
--- a/include/uapi/linux/nl80211.h
+++ b/include/uapi/linux/nl80211.h
@@ -645,6 +645,15 @@
  *	%NL80211_ATTR_IFINDEX is now on %NL80211_ATTR_WIPHY_FREQ and the
  *	attributes determining channel width.
  *
+ * @NL80211_CMD_CH_SWITCH_STARTED_NOTIFY: Notify that a channel switch
+ *	has been started on an interface, regardless of the initiator
+ *	(ie. whether it was requested from a remote device or
+ *	initiated on our own).  It indicates that
+ *	%NL80211_ATTR_IFINDEX will be on %NL80211_ATTR_WIPHY_FREQ
+ *	after %NL80211_ATTR_CH_SWITCH_COUNT TBTT's.  The userspace may
+ *	decide to react to this indication by requesting other
+ *	interfaces to change channel as well.
+ *
  * @NL80211_CMD_START_P2P_DEVICE: Start the given P2P Device, identified by
  *	its %NL80211_ATTR_WDEV identifier. It must have been created with
  *	%NL80211_CMD_NEW_INTERFACE previously. After it has been started, the
@@ -930,6 +939,8 @@ enum nl80211_commands {
 	NL80211_CMD_JOIN_OCB,
 	NL80211_CMD_LEAVE_OCB,
 
+	NL80211_CMD_CH_SWITCH_STARTED_NOTIFY,
+
 	/* add new commands above here */
 
 	/* used to define NL80211_CMD_MAX below */
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 24549cb..24fd292 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -11653,7 +11653,9 @@ EXPORT_SYMBOL(cfg80211_pmksa_candidate_notify);
 static void nl80211_ch_switch_notify(struct cfg80211_registered_device *rdev,
 				     struct net_device *netdev,
 				     struct cfg80211_chan_def *chandef,
-				     gfp_t gfp)
+				     gfp_t gfp,
+				     enum nl80211_commands notif,
+				     u8 count)
 {
 	struct sk_buff *msg;
 	void *hdr;
@@ -11662,7 +11664,7 @@ static void nl80211_ch_switch_notify(struct cfg80211_registered_device *rdev,
 	if (!msg)
 		return;
 
-	hdr = nl80211hdr_put(msg, 0, 0, 0, NL80211_CMD_CH_SWITCH_NOTIFY);
+	hdr = nl80211hdr_put(msg, 0, 0, 0, notif);
 	if (!hdr) {
 		nlmsg_free(msg);
 		return;
@@ -11674,6 +11676,10 @@ static void nl80211_ch_switch_notify(struct cfg80211_registered_device *rdev,
 	if (nl80211_send_chandef(msg, chandef))
 		goto nla_put_failure;
 
+	if ((notif == NL80211_CMD_CH_SWITCH_STARTED_NOTIFY) &&
+	    (nla_put_u32(msg, NL80211_ATTR_CH_SWITCH_COUNT, count)))
+			goto nla_put_failure;
+
 	genlmsg_end(msg, hdr);
 
 	genlmsg_multicast_netns(&nl80211_fam, wiphy_net(&rdev->wiphy), msg, 0,
@@ -11704,10 +11710,26 @@ void cfg80211_ch_switch_notify(struct net_device *dev,
 
 	wdev->chandef = *chandef;
 	wdev->preset_chandef = *chandef;
-	nl80211_ch_switch_notify(rdev, dev, chandef, GFP_KERNEL);
+	nl80211_ch_switch_notify(rdev, dev, chandef, GFP_KERNEL,
+				 NL80211_CMD_CH_SWITCH_NOTIFY, 0);
 }
 EXPORT_SYMBOL(cfg80211_ch_switch_notify);
 
+void cfg80211_ch_switch_started_notify(struct net_device *dev,
+				       struct cfg80211_chan_def *chandef,
+				       u8 count)
+{
+	struct wireless_dev *wdev = dev->ieee80211_ptr;
+	struct wiphy *wiphy = wdev->wiphy;
+	struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy);
+
+	trace_cfg80211_ch_switch_started_notify(dev, chandef);
+
+	nl80211_ch_switch_notify(rdev, dev, chandef, GFP_KERNEL,
+				 NL80211_CMD_CH_SWITCH_STARTED_NOTIFY, count);
+}
+EXPORT_SYMBOL(cfg80211_ch_switch_started_notify);
+
 void cfg80211_cqm_txe_notify(struct net_device *dev,
 			     const u8 *peer, u32 num_packets,
 			     u32 rate, u32 intvl, gfp_t gfp)
diff --git a/net/wireless/trace.h b/net/wireless/trace.h
index 277a85d..6e25370 100644
--- a/net/wireless/trace.h
+++ b/net/wireless/trace.h
@@ -2355,6 +2355,22 @@ TRACE_EVENT(cfg80211_ch_switch_notify,
 		  NETDEV_PR_ARG, CHAN_DEF_PR_ARG)
 );
 
+TRACE_EVENT(cfg80211_ch_switch_started_notify,
+	TP_PROTO(struct net_device *netdev,
+		 struct cfg80211_chan_def *chandef),
+	TP_ARGS(netdev, chandef),
+	TP_STRUCT__entry(
+		NETDEV_ENTRY
+		CHAN_DEF_ENTRY
+	),
+	TP_fast_assign(
+		NETDEV_ASSIGN;
+		CHAN_DEF_ASSIGN(chandef);
+	),
+	TP_printk(NETDEV_PR_FMT ", " CHAN_DEF_PR_FMT,
+		  NETDEV_PR_ARG, CHAN_DEF_PR_ARG)
+);
+
 TRACE_EVENT(cfg80211_radar_event,
 	TP_PROTO(struct wiphy *wiphy, struct cfg80211_chan_def *chandef),
 	TP_ARGS(wiphy, chandef),
-- 
2.1.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v2 2/3] mac80211: send channel switch started notifications
  2014-11-07 12:31 [PATCH v2 0/3] cfg80211/mac80211: CSA notification Luca Coelho
  2014-11-07 12:31 ` [PATCH v2 1/3] cfg80211/nl80211: add channel switch started notification Luca Coelho
@ 2014-11-07 12:31 ` Luca Coelho
  2014-11-07 12:31 ` [PATCH v2 3/3] cfg80211/nl80211: allow any interface to send channel switch notifications Luca Coelho
  2014-11-10  9:20 ` [PATCH v2 0/3] cfg80211/mac80211: CSA notification Johannes Berg
  3 siblings, 0 replies; 5+ messages in thread
From: Luca Coelho @ 2014-11-07 12:31 UTC (permalink / raw)
  To: johannes; +Cc: linux-wireless, emmanuel.grumbach

From: Luciano Coelho <luciano.coelho@intel.com>

Send a channel switch notification to userspace when a channel switch
is requested or when we react to a remote CSA.

Signed-off-by: Luciano Coelho <luciano.coelho@intel.com>
---
 net/mac80211/cfg.c  | 3 +++
 net/mac80211/mlme.c | 3 +++
 2 files changed, 6 insertions(+)

diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index 0618594..c5be146 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -3195,6 +3195,9 @@ __ieee80211_channel_switch(struct wiphy *wiphy, struct net_device *dev,
 		ieee80211_stop_vif_queues(local, sdata,
 					  IEEE80211_QUEUE_STOP_REASON_CSA);
 
+	cfg80211_ch_switch_started_notify(sdata->dev, &sdata->csa_chandef,
+					  params->count);
+
 	if (changed) {
 		ieee80211_bss_info_change_notify(sdata, changed);
 		drv_channel_switch_beacon(sdata, &params->chandef);
diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c
index 0d166e7..e31299f 100644
--- a/net/mac80211/mlme.c
+++ b/net/mac80211/mlme.c
@@ -1205,6 +1205,9 @@ ieee80211_sta_process_chanswitch(struct ieee80211_sub_if_data *sdata,
 					  IEEE80211_QUEUE_STOP_REASON_CSA);
 	mutex_unlock(&local->mtx);
 
+	cfg80211_ch_switch_started_notify(sdata->dev, &csa_ie.chandef,
+					  csa_ie.count);
+
 	if (local->ops->channel_switch) {
 		/* use driver's channel switch callback */
 		drv_channel_switch(local, sdata, &ch_switch);
-- 
2.1.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v2 3/3] cfg80211/nl80211: allow any interface to send channel switch notifications
  2014-11-07 12:31 [PATCH v2 0/3] cfg80211/mac80211: CSA notification Luca Coelho
  2014-11-07 12:31 ` [PATCH v2 1/3] cfg80211/nl80211: add channel switch started notification Luca Coelho
  2014-11-07 12:31 ` [PATCH v2 2/3] mac80211: send channel switch started notifications Luca Coelho
@ 2014-11-07 12:31 ` Luca Coelho
  2014-11-10  9:20 ` [PATCH v2 0/3] cfg80211/mac80211: CSA notification Johannes Berg
  3 siblings, 0 replies; 5+ messages in thread
From: Luca Coelho @ 2014-11-07 12:31 UTC (permalink / raw)
  To: johannes; +Cc: linux-wireless, emmanuel.grumbach

From: Luciano Coelho <luciano.coelho@intel.com>

For multi-vif channel switches, we want to send
NL80211_CMD_CH_SWITCH_NOTIFY to the userspace to let it decide whether
other interfaces need to be moved as well.  This is needed when we
want a P2P GO interface to follow the channel of a station, for
example.

Modify the code so that all interfaces can send CSA notifications.
Additionally, send notifications for STA CSA as well.

Signed-off-by: Luciano Coelho <luciano.coelho@intel.com>
---
 include/uapi/linux/nl80211.h | 4 +++-
 net/mac80211/mlme.c          | 2 ++
 net/wireless/nl80211.c       | 6 ------
 3 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
index 3541634..a552736 100644
--- a/include/uapi/linux/nl80211.h
+++ b/include/uapi/linux/nl80211.h
@@ -643,7 +643,9 @@
  * @NL80211_CMD_CH_SWITCH_NOTIFY: An AP or GO may decide to switch channels
  *	independently of the userspace SME, send this event indicating
  *	%NL80211_ATTR_IFINDEX is now on %NL80211_ATTR_WIPHY_FREQ and the
- *	attributes determining channel width.
+ *	attributes determining channel width.  This indication may also be
+ *	sent when a remotely-initiated switch (e.g., when a STA receives a CSA
+ *	from the remote AP) is completed;
  *
  * @NL80211_CMD_CH_SWITCH_STARTED_NOTIFY: Notify that a channel switch
  *	has been started on an interface, regardless of the initiator
diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c
index e31299f..6c60bfb 100644
--- a/net/mac80211/mlme.c
+++ b/net/mac80211/mlme.c
@@ -1049,6 +1049,8 @@ static void ieee80211_chswitch_post_beacon(struct ieee80211_sub_if_data *sdata)
 		sdata->csa_block_tx = false;
 	}
 
+	cfg80211_ch_switch_notify(sdata->dev, &sdata->reserved_chandef);
+
 	sdata->vif.csa_active = false;
 	ifmgd->csa_waiting_bcn = false;
 
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 24fd292..d0a8361 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -11702,12 +11702,6 @@ void cfg80211_ch_switch_notify(struct net_device *dev,
 
 	trace_cfg80211_ch_switch_notify(dev, chandef);
 
-	if (WARN_ON(wdev->iftype != NL80211_IFTYPE_AP &&
-		    wdev->iftype != NL80211_IFTYPE_P2P_GO &&
-		    wdev->iftype != NL80211_IFTYPE_ADHOC &&
-		    wdev->iftype != NL80211_IFTYPE_MESH_POINT))
-		return;
-
 	wdev->chandef = *chandef;
 	wdev->preset_chandef = *chandef;
 	nl80211_ch_switch_notify(rdev, dev, chandef, GFP_KERNEL,
-- 
2.1.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v2 0/3] cfg80211/mac80211: CSA notification
  2014-11-07 12:31 [PATCH v2 0/3] cfg80211/mac80211: CSA notification Luca Coelho
                   ` (2 preceding siblings ...)
  2014-11-07 12:31 ` [PATCH v2 3/3] cfg80211/nl80211: allow any interface to send channel switch notifications Luca Coelho
@ 2014-11-10  9:20 ` Johannes Berg
  3 siblings, 0 replies; 5+ messages in thread
From: Johannes Berg @ 2014-11-10  9:20 UTC (permalink / raw)
  To: Luca Coelho; +Cc: linux-wireless, emmanuel.grumbach

On Fri, 2014-11-07 at 14:31 +0200, Luca Coelho wrote:
> From: Luciano Coelho <luciano.coelho@intel.com>
> 
> This is a rework of the channel switch started notification that I
> sent a long time ago.  According to the review, I removed the failure
> notification.  Additionally, some other small changes were made to fix
> some things and adapt to the current code.

Applied.

johannes


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-11-10  9:20 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-07 12:31 [PATCH v2 0/3] cfg80211/mac80211: CSA notification Luca Coelho
2014-11-07 12:31 ` [PATCH v2 1/3] cfg80211/nl80211: add channel switch started notification Luca Coelho
2014-11-07 12:31 ` [PATCH v2 2/3] mac80211: send channel switch started notifications Luca Coelho
2014-11-07 12:31 ` [PATCH v2 3/3] cfg80211/nl80211: allow any interface to send channel switch notifications Luca Coelho
2014-11-10  9:20 ` [PATCH v2 0/3] cfg80211/mac80211: CSA notification Johannes Berg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).