linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCHv2 0/3] cfg80211/mac80211: cqm rssi config for AP mode
@ 2018-02-13  9:20 Tamizh chelvam
  2018-02-13  9:20 ` [PATCHv2 1/3] cfg80211: enable setting " Tamizh chelvam
  0 siblings, 1 reply; 4+ messages in thread
From: Tamizh chelvam @ 2018-02-13  9:20 UTC (permalink / raw)
  To: johannes; +Cc: linux-wireless, Tamizh chelvam

From: Tamizh chelvam <tamizhr@codeaurora.org>

Currently station mode has the support of rssi based cqm. This patchsets
extended the support for AP mode as well. Already netlink accepts mac
address in cqm notification event. We can use that to pass mac address of
the station to specify its rssi change event. This patchsets introduce
new api cfg80211_ap_sta_cqm_notify and multicast group to notify the event.

Pradeep Kumar Chitrapu (1):
  mac80211: enable setting cqm rssi c onfig for AP mode

Tamizh chelvam (2):
  cfg80211: enable setting cqm rssi config for AP mode
  mac80211: implement cqm rssi check using rx data signal

V2:
  * Removed changing existing ieee80211_cqm_rssi_notify api changes.
  * Introduced new ext feature bit and multicast group id to support this
    feature.

 include/net/cfg80211.h       |   15 ++++++++++
 include/net/mac80211.h       |    7 +++++
 include/uapi/linux/nl80211.h |    6 ++++
 net/mac80211/cfg.c           |   31 ++++++++++++-------
 net/mac80211/rx.c            |   46 +++++++++++++++++++++++++++-
 net/mac80211/sta_info.h      |    3 ++
 net/wireless/nl80211.c       |   68 +++++++++++++++++++++++++++++++++++-------
 7 files changed, 155 insertions(+), 21 deletions(-)

-- 
1.7.9.5

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

* [PATCHv2 1/3] cfg80211: enable setting cqm rssi config for AP mode
  2018-02-13  9:20 [PATCHv2 0/3] cfg80211/mac80211: cqm rssi config for AP mode Tamizh chelvam
@ 2018-02-13  9:20 ` Tamizh chelvam
  2018-02-19 13:14   ` Johannes Berg
  0 siblings, 1 reply; 4+ messages in thread
From: Tamizh chelvam @ 2018-02-13  9:20 UTC (permalink / raw)
  To: johannes; +Cc: linux-wireless, Tamizh chelvam

From: Tamizh chelvam <tamizhr@codeaurora.org>

This patch extend cqm rssi config and notifier feature to AP mode
by introducing NL80211_EXT_FEATURE_AP_STA_CQM_RSSI_CONFIG ext
feature bit. And this patch introduces NL80211_MCGRP_AP_STA_CQM
for notifying station's low/high rssi event to userspace application.

Signed-off-by: Tamizh chelvam <tamizhr@codeaurora.org>
---
 include/net/cfg80211.h       |   15 ++++++++++
 include/uapi/linux/nl80211.h |    6 ++++
 net/wireless/nl80211.c       |   68 +++++++++++++++++++++++++++++++++++-------
 3 files changed, 79 insertions(+), 10 deletions(-)

diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 7d49cd0..179904f 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -5704,6 +5704,21 @@ void cfg80211_cqm_rssi_notify(struct net_device *dev,
 			      s32 rssi_level, gfp_t gfp);
 
 /**
+ * cfg80211_ap_sta_cqm_rssi_notify - CQM rssi event for connected stations
+ * @dev: network device
+ * @mac: peer's MAC address
+ * @rssi_event: the triggered RSSI event
+ * @rssi_level: new RSSI level value or 0 if not available
+ * @gfp: context flags
+ *
+ * This function is called when a configured connection quality monitoring
+ * rssi threshold reached event occurs for a station.
+ */
+void cfg80211_ap_sta_cqm_rssi_notify(struct net_device *dev, const u8 *mac,
+		enum nl80211_cqm_rssi_threshold_event rssi_event,
+		s32 rssi_level, gfp_t gfp);
+
+/**
  * cfg80211_cqm_pktloss_notify - notify userspace about packetloss to peer
  * @dev: network device
  * @peer: peer's MAC address
diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
index ca3d5a6..9448bba 100644
--- a/include/uapi/linux/nl80211.h
+++ b/include/uapi/linux/nl80211.h
@@ -49,6 +49,7 @@
 #define NL80211_MULTICAST_GROUP_MLME		"mlme"
 #define NL80211_MULTICAST_GROUP_VENDOR		"vendor"
 #define NL80211_MULTICAST_GROUP_NAN		"nan"
+#define NL80211_MULTICAST_GROUP_AP_STA_CQM	"apstacqm"
 #define NL80211_MULTICAST_GROUP_TESTMODE	"testmode"
 
 /**
@@ -4996,6 +4997,10 @@ enum nl80211_feature_flags {
  * @NL80211_EXT_FEATURE_LOW_SPAN_SCAN: Driver supports low span scan.
  * @NL80211_EXT_FEATURE_LOW_POWER_SCAN: Driver supports low power scan.
  * @NL80211_EXT_FEATURE_HIGH_ACCURACY_SCAN: Driver supports high accuracy scan.
+ * @NL80211_EXT_FEATURE_AP_STA_CQM_RSSI_CONFIG: With this driver the
+ *	non P2P/STA interface accept %NL80211_ATTR_CQM_RSSI_THOLD  and
+ *	%NL80211_ATTR_CQM_RSSI_HYST attributes to monitor connected clients
+ *	rssi values.
  *
  * @NUM_NL80211_EXT_FEATURES: number of extended features.
  * @MAX_NL80211_EXT_FEATURES: highest extended feature index.
@@ -5026,6 +5031,7 @@ enum nl80211_ext_feature_index {
 	NL80211_EXT_FEATURE_LOW_SPAN_SCAN,
 	NL80211_EXT_FEATURE_LOW_POWER_SCAN,
 	NL80211_EXT_FEATURE_HIGH_ACCURACY_SCAN,
+	NL80211_EXT_FEATURE_AP_STA_CQM_RSSI_CONFIG,
 
 	/* add new features before the definition below */
 	NUM_NL80211_EXT_FEATURES,
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index cc6ec5b..68627a7 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -43,6 +43,7 @@ enum nl80211_multicast_groups {
 	NL80211_MCGRP_MLME,
 	NL80211_MCGRP_VENDOR,
 	NL80211_MCGRP_NAN,
+	NL80211_MCGRP_AP_STA_CQM,
 	NL80211_MCGRP_TESTMODE /* keep last - ifdef! */
 };
 
@@ -53,6 +54,8 @@ enum nl80211_multicast_groups {
 	[NL80211_MCGRP_MLME] = { .name = NL80211_MULTICAST_GROUP_MLME },
 	[NL80211_MCGRP_VENDOR] = { .name = NL80211_MULTICAST_GROUP_VENDOR },
 	[NL80211_MCGRP_NAN] = { .name = NL80211_MULTICAST_GROUP_NAN },
+	[NL80211_MCGRP_AP_STA_CQM] = {
+				.name = NL80211_MULTICAST_GROUP_AP_STA_CQM },
 #ifdef CONFIG_NL80211_TESTMODE
 	[NL80211_MCGRP_TESTMODE] = { .name = NL80211_MULTICAST_GROUP_TESTMODE }
 #endif
@@ -9903,8 +9906,10 @@ static int nl80211_set_cqm_rssi(struct genl_info *info,
 		prev = thresholds[i];
 	}
 
-	if (wdev->iftype != NL80211_IFTYPE_STATION &&
-	    wdev->iftype != NL80211_IFTYPE_P2P_CLIENT)
+	if ((wdev->iftype != NL80211_IFTYPE_STATION &&
+	     wdev->iftype != NL80211_IFTYPE_P2P_CLIENT &&
+	     !wiphy_ext_feature_isset(&rdev->wiphy,
+				NL80211_EXT_FEATURE_AP_STA_CQM_RSSI_CONFIG)))
 		return -EOPNOTSUPP;
 
 	wdev_lock(wdev);
@@ -14601,9 +14606,24 @@ static void cfg80211_send_cqm(struct sk_buff *msg, gfp_t gfp)
 				NL80211_MCGRP_MLME, gfp);
 }
 
-void cfg80211_cqm_rssi_notify(struct net_device *dev,
-			      enum nl80211_cqm_rssi_threshold_event rssi_event,
-			      s32 rssi_level, gfp_t gfp)
+static void cfg80211_send_ap_sta_cqm(struct sk_buff *msg, gfp_t gfp)
+{
+	void **cb = (void **)msg->cb;
+	struct cfg80211_registered_device *rdev = cb[2];
+
+	nla_nest_end(msg, cb[1]);
+	genlmsg_end(msg, cb[0]);
+
+	memset(msg->cb, 0, sizeof(msg->cb));
+
+	genlmsg_multicast_netns(&nl80211_fam, wiphy_net(&rdev->wiphy), msg, 0,
+				NL80211_MCGRP_AP_STA_CQM, gfp);
+}
+
+static struct sk_buff *cfg80211_cqm_rssi_prepare(struct net_device *dev,
+			const u8 *mac,
+			enum nl80211_cqm_rssi_threshold_event rssi_event,
+			s32 rssi_level, gfp_t gfp)
 {
 	struct sk_buff *msg;
 	struct wireless_dev *wdev = dev->ieee80211_ptr;
@@ -14613,7 +14633,7 @@ void cfg80211_cqm_rssi_notify(struct net_device *dev,
 
 	if (WARN_ON(rssi_event != NL80211_CQM_RSSI_THRESHOLD_EVENT_LOW &&
 		    rssi_event != NL80211_CQM_RSSI_THRESHOLD_EVENT_HIGH))
-		return;
+		return NULL;
 
 	if (wdev->cqm_config) {
 		wdev->cqm_config->last_rssi_event_value = rssi_level;
@@ -14626,7 +14646,7 @@ void cfg80211_cqm_rssi_notify(struct net_device *dev,
 
 	msg = cfg80211_prepare_cqm(dev, NULL, gfp);
 	if (!msg)
-		return;
+		return NULL;
 
 	if (nla_put_u32(msg, NL80211_ATTR_CQM_RSSI_THRESHOLD_EVENT,
 			rssi_event))
@@ -14636,15 +14656,43 @@ void cfg80211_cqm_rssi_notify(struct net_device *dev,
 				      rssi_level))
 		goto nla_put_failure;
 
-	cfg80211_send_cqm(msg, gfp);
-
-	return;
+	return msg;
 
  nla_put_failure:
 	nlmsg_free(msg);
+	return NULL;
+}
+
+void cfg80211_cqm_rssi_notify(struct net_device *dev,
+			      enum nl80211_cqm_rssi_threshold_event rssi_event,
+			      s32 rssi_level, gfp_t gfp)
+{
+	struct sk_buff *msg;
+
+	msg = cfg80211_cqm_rssi_prepare(dev, NULL, rssi_event, rssi_level,
+					gfp);
+	if (!msg)
+		return;
+	cfg80211_send_cqm(msg, gfp);
+
+	return;
 }
 EXPORT_SYMBOL(cfg80211_cqm_rssi_notify);
 
+void cfg80211_ap_sta_cqm_rssi_notify(struct net_device *dev, const u8 *mac,
+			  enum nl80211_cqm_rssi_threshold_event rssi_event,
+			  s32 rssi_level, gfp_t gfp)
+{
+	struct sk_buff *msg;
+
+	msg = cfg80211_cqm_rssi_prepare(dev, mac, rssi_event, rssi_level,
+					gfp);
+	if (!msg)
+		return;
+	cfg80211_send_ap_sta_cqm(msg, gfp);
+}
+EXPORT_SYMBOL(cfg80211_ap_sta_cqm_rssi_notify);
+
 void cfg80211_cqm_txe_notify(struct net_device *dev,
 			     const u8 *peer, u32 num_packets,
 			     u32 rate, u32 intvl, gfp_t gfp)
-- 
1.7.9.5

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

* Re: [PATCHv2 1/3] cfg80211: enable setting cqm rssi config for AP mode
  2018-02-13  9:20 ` [PATCHv2 1/3] cfg80211: enable setting " Tamizh chelvam
@ 2018-02-19 13:14   ` Johannes Berg
  2018-02-21 13:57     ` Tamizh chelvam
  0 siblings, 1 reply; 4+ messages in thread
From: Johannes Berg @ 2018-02-19 13:14 UTC (permalink / raw)
  To: Tamizh chelvam; +Cc: linux-wireless

On Tue, 2018-02-13 at 14:50 +0530, Tamizh chelvam wrote:
> 
> @@ -9903,8 +9906,10 @@ static int nl80211_set_cqm_rssi(struct genl_info *info,
>  		prev = thresholds[i];
>  	}
>  
> -	if (wdev->iftype != NL80211_IFTYPE_STATION &&
> -	    wdev->iftype != NL80211_IFTYPE_P2P_CLIENT)
> +	if ((wdev->iftype != NL80211_IFTYPE_STATION &&
> +	     wdev->iftype != NL80211_IFTYPE_P2P_CLIENT &&
> +	     !wiphy_ext_feature_isset(&rdev->wiphy,
> +				NL80211_EXT_FEATURE_AP_STA_CQM_RSSI_CONFIG)))
>  		return -EOPNOTSUPP;

This enables for everything though - not sure we want that?

johannes

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

* Re: [PATCHv2 1/3] cfg80211: enable setting cqm rssi config for AP mode
  2018-02-19 13:14   ` Johannes Berg
@ 2018-02-21 13:57     ` Tamizh chelvam
  0 siblings, 0 replies; 4+ messages in thread
From: Tamizh chelvam @ 2018-02-21 13:57 UTC (permalink / raw)
  To: Johannes Berg; +Cc: linux-wireless

On 2018-02-19 18:44, Johannes Berg wrote:
> On Tue, 2018-02-13 at 14:50 +0530, Tamizh chelvam wrote:
>> 
>> @@ -9903,8 +9906,10 @@ static int nl80211_set_cqm_rssi(struct 
>> genl_info *info,
>>  		prev = thresholds[i];
>>  	}
>> 
>> -	if (wdev->iftype != NL80211_IFTYPE_STATION &&
>> -	    wdev->iftype != NL80211_IFTYPE_P2P_CLIENT)
>> +	if ((wdev->iftype != NL80211_IFTYPE_STATION &&
>> +	     wdev->iftype != NL80211_IFTYPE_P2P_CLIENT &&
>> +	     !wiphy_ext_feature_isset(&rdev->wiphy,
>> +				NL80211_EXT_FEATURE_AP_STA_CQM_RSSI_CONFIG)))
>>  		return -EOPNOTSUPP;
> 
> This enables for everything though - not sure we want that?

I'll add vif type(AP, AP_VLAN and P2P_GO) check in the next version to 
avoid enable this for all.

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

end of thread, other threads:[~2018-02-21 13:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-02-13  9:20 [PATCHv2 0/3] cfg80211/mac80211: cqm rssi config for AP mode Tamizh chelvam
2018-02-13  9:20 ` [PATCHv2 1/3] cfg80211: enable setting " Tamizh chelvam
2018-02-19 13:14   ` Johannes Berg
2018-02-21 13:57     ` Tamizh chelvam

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).