Skip to contentSkip to conversation

cfg80211: Accept multiple RSSI thresholds for CQM

PATCH Applied Andrew Zaborowski 3 participants 5 messages Feb 10, 2017 – Feb 21, 2017 802.11 (including cfg80211/NL80211)

lore
Share & tools
lore
#0 lore raw

PATCH v6 1/3 cfg80211: Accept multiple RSSI thresholds for CQM

Change the SET CQM command's RSSI threshold attribute to accept any number of thresholds as a sorted array. The API should be backwards compatible so that if one s32 threshold value is passed, the old mechanism is enabled. The netlink event generated is the same in both cases.

cfg80211 handles an arbitrary number of RSSI thresholds but drivers have to provide a method (set_cqm_rssi_range_config) that configures a range set by a high and a low value. Drivers have to call back when the RSSI goes out of that range and there's no additional event for each time the range is reconfigured as there was with the current one-threshold API.

This method doesn't have a hysteresis parameter because there's no benefit to the cfg80211 code from having the hysteresis be handled by hardware/driver in terms of the number of wakeups. At the same time it would likely be less consistent between drivers if offloaded or done in the drivers.

---
changes in v3:
- define NL80211_EXT_FEATURE_CQM_RSSI_LIST which drivers need to set if they implement set_cqm_rssi_range_config (mac80211 is a special case)
- error check the kzalloc in nl80211_set_cqm_rssi
- add a rdev->ops->get_station check before calling get_station
changes in v4:
- simplify the case of disabling CQM in nl80211_set_cqm_rssi
changed in v5:
- drop unneeded NL80211_EXT_FEATURE_CQM_RSSI_LIST check
- change the way new low/high threshold is calculated in cfg80211_cqm_rssi_update to make sure it's "hyst" away from range border to further reduce number of events
- clarify NL80211_EXT_FEATURE_CQM_RSSI_LIST description in nl80211.h
changed in v6:
- always add hysteresis value to the low/high thresholds used

---
 include/net/cfg80211.h       |  13 ++++
 include/uapi/linux/nl80211.h |   9 ++-
 net/wireless/core.c          |   9 +++
 net/wireless/core.h          |   9 +++
 net/wireless/nl80211.c       | 138 +++++++++++++++++++++++++++++++++++++++----
 net/wireless/rdev-ops.h      |  12 ++++
 net/wireless/trace.h         |  22 +++++++
 7 files changed, 198 insertions(+), 14 deletions(-)
include/net/cfg80211.h +13 -0
index c92dc03..86c12f8 100644
@@ -2712,6 +2712,11 @@ struct cfg80211_nan_func {
  *	the current level is above/below the configured threshold; this may
  *	need some care when the configuration is changed (without first being
  *	disabled.)
+ * @set_cqm_rssi_range_config: Configure two RSSI thresholds in the
+ *	connection quality monitor.  An event is to be sent only when the
+ *	signal level is found to be outside the two values.  The driver should
+ *	set %NL80211_EXT_FEATURE_CQM_RSSI_LIST if this method is implemented.
+ *	If it is provided then there's no point providing @set_cqm_rssi_config.
  * @set_cqm_txe_config: Configure connection quality monitor TX error
  *	thresholds.
  * @sched_scan_start: Tell the driver to start a scheduled scan.
@@ -3001,6 +3006,10 @@ struct cfg80211_ops {
 				       struct net_device *dev,
 				       s32 rssi_thold, u32 rssi_hyst);
 
+	int	(*set_cqm_rssi_range_config)(struct wiphy *wiphy,
+					     struct net_device *dev,
+					     s32 rssi_low, s32 rssi_high);
+
 	int	(*set_cqm_txe_config)(struct wiphy *wiphy,
 				      struct net_device *dev,
 				      u32 rate, u32 pkts, u32 intvl);
@@ -3871,6 +3880,7 @@ void wiphy_free(struct wiphy *wiphy);
 struct cfg80211_conn;
 struct cfg80211_internal_bss;
 struct cfg80211_cached_keys;
+struct cfg80211_cqm_config;
 
 /**
  * struct wireless_dev - wireless device state
@@ -3934,6 +3944,7 @@ struct cfg80211_cached_keys;
  * @event_list: (private) list for internal event processing
  * @event_lock: (private) lock for event list
  * @owner_nlportid: (private) owner socket port ID
+ * @cqm_config: (private) nl80211 RSSI monitor state
  */
 struct wireless_dev {
 	struct wiphy *wiphy;
@@ -4002,6 +4013,8 @@ struct wireless_dev {
 		bool prev_bssid_valid;
 	} wext;
 #endif
+
+	struct cfg80211_cqm_config *cqm_config;
 };
 
 static inline u8 *wdev_address(struct wireless_dev *wdev)
include/uapi/linux/nl80211.h +8 -1
index 5ed257c..9a499b1 100644
@@ -3942,7 +3942,10 @@ enum nl80211_ps_state {
  * @__NL80211_ATTR_CQM_INVALID: invalid
  * @NL80211_ATTR_CQM_RSSI_THOLD: RSSI threshold in dBm. This value specifies
  *	the threshold for the RSSI level at which an event will be sent. Zero
- *	to disable.
+ *	to disable.  Alternatively, if %NL80211_EXT_FEATURE_CQM_RSSI_LIST is
+ *	set, multiple values can be supplied as a low-to-high sorted array of
+ *	threshold values in dBm.  Events will be sent when the RSSI value
+ *	crosses any of the thresholds.
  * @NL80211_ATTR_CQM_RSSI_HYST: RSSI hysteresis in dBm. This value specifies
  *	the minimum amount the RSSI level must change after an event before a
  *	new event may be issued (to reduce effects of RSSI oscillation).
@@ -4753,6 +4756,9 @@ enum nl80211_feature_flags {
  * @NL80211_EXT_FEATURE_SCHED_SCAN_RELATIVE_RSSI: The driver supports sched_scan
  *	for reporting BSSs with better RSSI than the current connected BSS
  *	(%NL80211_ATTR_SCHED_SCAN_RELATIVE_RSSI).
+ * @NL80211_EXT_FEATURE_CQM_RSSI_LIST: With this driver the
+ *	%NL80211_ATTR_CQM_RSSI_THOLD attribute accepts a list of zero or more
+ *	RSSI threshold values to monitor rather than exactly one threshold.
  *
  * @NUM_NL80211_EXT_FEATURES: number of extended features.
  * @MAX_NL80211_EXT_FEATURES: highest extended feature index.
@@ -4771,6 +4777,7 @@ enum nl80211_ext_feature_index {
 	NL80211_EXT_FEATURE_MGMT_TX_RANDOM_TA,
 	NL80211_EXT_FEATURE_MGMT_TX_RANDOM_TA_CONNECTED,
 	NL80211_EXT_FEATURE_SCHED_SCAN_RELATIVE_RSSI,
+	NL80211_EXT_FEATURE_CQM_RSSI_LIST,
 
 	/* add new features before the definition below */
 	NUM_NL80211_EXT_FEATURES,
net/wireless/core.c +9 -0
index e55e05b..04143df 100644
@@ -954,6 +954,12 @@ void wiphy_rfkill_set_hw_state(struct wiphy *wiphy, bool blocked)
 }
 EXPORT_SYMBOL(wiphy_rfkill_set_hw_state);
 
+void cfg80211_cqm_config_free(struct wireless_dev *wdev)
+{
+	kfree(wdev->cqm_config);
+	wdev->cqm_config = NULL;
+}
+
 void cfg80211_unregister_wdev(struct wireless_dev *wdev)
 {
 	struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
@@ -980,6 +986,8 @@ void cfg80211_unregister_wdev(struct wireless_dev *wdev)
 		WARN_ON_ONCE(1);
 		break;
 	}
+
+	cfg80211_cqm_config_free(wdev);
 }
 EXPORT_SYMBOL(cfg80211_unregister_wdev);
 
@@ -1234,6 +1242,7 @@ static int cfg80211_netdev_notifier_call(struct notifier_block *nb,
 			kzfree(wdev->wext.keys);
 #endif
 			flush_work(&wdev->disconnect_wk);
+			cfg80211_cqm_config_free(wdev);
 		}
 		/*
 		 * synchronise (so that we won't find this netdev
net/wireless/core.h +9 -0
index 58ca206..efa690a 100644
@@ -272,6 +272,13 @@ struct cfg80211_iface_destroy {
 	u32 nlportid;
 };
 
+struct cfg80211_cqm_config {
+	u32 rssi_hyst;
+	s32 last_rssi_event_value;
+	int n_rssi_thresholds;
+	s32 rssi_thresholds[0];
+};
+
 void cfg80211_destroy_ifaces(struct cfg80211_registered_device *rdev);
 
 /* free object */
@@ -512,4 +519,6 @@ void cfg80211_stop_nan(struct cfg80211_registered_device *rdev,
 #define CFG80211_DEV_WARN_ON(cond)	({bool __r = (cond); __r; })
 #endif
 
+void cfg80211_cqm_config_free(struct wireless_dev *wdev);
+
 #endif /* __NET_WIRELESS_CORE_H */
net/wireless/nl80211.c +125 -13

182 lines not on this page · raw message

net/wireless/rdev-ops.h +12 -0
index 2f42507..f2baf59 100644
@@ -750,6 +750,18 @@ rdev_set_cqm_rssi_config(struct cfg80211_registered_device *rdev,
 }
 
 static inline int
+rdev_set_cqm_rssi_range_config(struct cfg80211_registered_device *rdev,
+			       struct net_device *dev, s32 low, s32 high)
+{
+	int ret;
+	trace_rdev_set_cqm_rssi_range_config(&rdev->wiphy, dev, low, high);
+	ret = rdev->ops->set_cqm_rssi_range_config(&rdev->wiphy, dev,
+						   low, high);
+	trace_rdev_return_int(&rdev->wiphy, ret);
+	return ret;
+}
+
+static inline int
 rdev_set_cqm_txe_config(struct cfg80211_registered_device *rdev,
 			struct net_device *dev, u32 rate, u32 pkts, u32 intvl)
 {
net/wireless/trace.h +22 -0
index 776e80c..fd55786 100644
@@ -1322,6 +1322,28 @@ TRACE_EVENT(rdev_set_cqm_rssi_config,
 		 __entry->rssi_thold, __entry->rssi_hyst)
 );
 
+TRACE_EVENT(rdev_set_cqm_rssi_range_config,
+	TP_PROTO(struct wiphy *wiphy,
+		 struct net_device *netdev, s32 low, s32 high),
+	TP_ARGS(wiphy, netdev, low, high),
+	TP_STRUCT__entry(
+		WIPHY_ENTRY
+		NETDEV_ENTRY
+		__field(s32, rssi_low)
+		__field(s32, rssi_high)
+	),
+	TP_fast_assign(
+		WIPHY_ASSIGN;
+		NETDEV_ASSIGN;
+		__entry->rssi_low = low;
+		__entry->rssi_high = high;
+	),
+	TP_printk(WIPHY_PR_FMT ", " NETDEV_PR_FMT
+		  ", range: %d - %d ",
+		  WIPHY_PR_ARG, NETDEV_PR_ARG,
+		  __entry->rssi_low, __entry->rssi_high)
+);
+
 TRACE_EVENT(rdev_set_cqm_txe_config,
 	TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, u32 rate,
 		 u32 pkts, u32 intvl),
Signature · 1 line
2.9.3
maintainer Applied
#1 lore raw
Quoted 5 lines · Andrew Zaborowski

Change the SET CQM command's RSSI threshold attribute to accept any number of thresholds as a sorted array.  The API should be backwards compatible so that if one s32 threshold value is passed, the old mechanism is enabled.  The netlink event generated is the same in both cases.

I've applied this now, thanks for your patience :)

I got a bit confused - and then fixed it up - patchwork has giving your name as "Andrzej Zaborowski" which apparently you didn't really want (any more). I've fixed it for these patches to be as the patches you sent, but no guarantees I've done this before or will remember to do that in the future - if you can somehow change your name in patchwork (patchwork.kernel.org) that would be good.

johannes

#2 lore raw
Quoted 3 lines · Johannes Berg
Quoted 2 lines · Andrew Zaborowski

Change the SET CQM command's RSSI threshold attribute to accept any number of thresholds as a sorted array.=C2=A0=C2=A0The API should be bac=

kwards

Quoted 2 lines
Quoted 2 lines

compatible so that if one s32 threshold value is passed, the old mechanism is enabled.=C2=A0=C2=A0The netlink event generated is the same=

in

Quoted 10 lines
Quoted 1 line

both cases.

I've applied this now, thanks for your patience :)

I got a bit confused - and then fixed it up - patchwork has giving your name as "Andrzej Zaborowski" which apparently you didn't really want (any more). I've fixed it for these patches to be as the patches you sent, but no guarantees I've done this before or will remember to do that in the future - if you can somehow change your name in patchwork (patchwork.kernel.org) that would be good.

IIRC if you haven't registered to patchwork.kernel.org it's possible to change the name easily. But after registration the user needs to contact helpdesk to change the name.

Please let me know if there's an easier way to change the name. This is not the first time this comes up.

--=20
Kalle Valo

#3 lore raw

Hi,

Quoted 8 lines · Kalle Valo
Quoted 7 lines · Johannes Berg
Quoted 5 lines · Andrew Zaborowski

Change the SET CQM command's RSSI threshold attribute to accept any number of thresholds as a sorted array. The API should be backwards compatible so that if one s32 threshold value is passed, the old mechanism is enabled. The netlink event generated is the same in both cases.

Quoted 8 lines
Quoted 8 lines

I've applied this now, thanks for your patience :)

I got a bit confused - and then fixed it up - patchwork has giving your name as "Andrzej Zaborowski" which apparently you didn't really want (any more). I've fixed it for these patches to be as the patches you sent, but no guarantees I've done this before or will remember to do that in the future - if you can somehow change your name in patchwork (patchwork.kernel.org) that would be good.

Thanks, changed it for consistency now.

Quoted 4 lines

IIRC if you haven't registered to patchwork.kernel.org it's possible to change the name easily. But after registration the user needs to contact helpdesk to change the name.

Indeed I was able to set name on registration today but can see no way
to modify it. The project's mailing list has a thread about a patch
that's about to be backported to the patchwork.kernel.org version
though, https://github.com/getpatchwork/patchwork/commit/d365402fb98dfb2c4aea4b58346096f85bdfa0c3

Best regards

#4 lore raw
Quoted 27 lines · Andrew Zaborowski

Hi,

Quoted 8 lines · Kalle Valo
Quoted 7 lines · Johannes Berg
Quoted 5 lines · Andrew Zaborowski

Change the SET CQM command's RSSI threshold attribute to accept any number of thresholds as a sorted array. The API should be backwards compatible so that if one s32 threshold value is passed, the old mechanism is enabled. The netlink event generated is the same in both cases.

Quoted 8 lines
Quoted 8 lines

I've applied this now, thanks for your patience :)

I got a bit confused - and then fixed it up - patchwork has giving your name as "Andrzej Zaborowski" which apparently you didn't really want (any more). I've fixed it for these patches to be as the patches you sent, but no guarantees I've done this before or will remember to do that in the future - if you can somehow change your name in patchwork (patchwork.kernel.org) that would be good.

Thanks, changed it for consistency now.

Quoted 4 lines

IIRC if you haven't registered to patchwork.kernel.org it's possible to change the name easily. But after registration the user needs to contact helpdesk to change the name.

Quoted 5 lines

Indeed I was able to set name on registration today but can see no way to modify it. The project's mailing list has a thread about a patch that's about to be backported to the patchwork.kernel.org version though,
https://github.com/getpatchwork/patchwork/commit/d365402fb98dfb2c4aea4b58346096f85bdfa0c3

Great, that's exactly the right way to fix this. Thanks for letting us now.

Signature · 1 line
Kalle Valo