Skip to contentSkip to conversation

cfg80211/mac80211: Add support to configure and monitor rssi threshold

PATCH In review Tamizh chelvam 2 participants 30 messages Jun 13, 2018 – Aug 28, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover cfg80211/mac80211: Add support to configure and monitor rssi threshold

This patchsets introduced new NL command and api to support configuring rssi for the connected stations and api to notify userspace application upon crossing the configured threshold. This will be useful for the application which requires station's current capability change information.

Tamizh chelvam (7):
wireless: Change single cqm_config to rssi config list
cfg80211: Add new NL command to configure peer specific rssi
threshold
mac80211: Add api to support configuring station specific rssi
threshold
cfg80211: Add support to notify station's rssi level crossing
mac80211: Implement functionality to monitor station's rssi cross
event
cfg80211: Accept multiple RSSI threholds for STA_MON command
mac80211: Add api to configure low and high RSSI threshold

 include/net/cfg80211.h       |   42 ++++-
 include/net/mac80211.h       |    6 +
 include/uapi/linux/nl80211.h |   60 +++++++
 net/mac80211/cfg.c           |   75 +++++++++
 net/mac80211/rx.c            |   65 +++++++-
 net/mac80211/sta_info.h      |   22 +++
 net/wireless/core.c          |   29 +++-
 net/wireless/core.h          |    6 +-
 net/wireless/nl80211.c       |  377 ++++++++++++++++++++++++++++++++++++------
 net/wireless/rdev-ops.h      |   31 ++++
 net/wireless/trace.h         |   73 ++++++++
 11 files changed, 723 insertions(+), 63 deletions(-)
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH 1/7 wireless: Change single cqm_config to rssi config list

This patch changes single cqm_config into mac address based rssi config list. This way the same structure can be utilized by AP mode as well.

---
 include/net/cfg80211.h |    8 ++++--
 net/wireless/core.c    |   29 +++++++++++++++----
 net/wireless/core.h    |    6 ++--
 net/wireless/nl80211.c |   74 ++++++++++++++++++++++++++++++++----------------
 4 files changed, 82 insertions(+), 35 deletions(-)
include/net/cfg80211.h +5 -3
index 5fbfe61..3e123a3 100644
@@ -4139,7 +4139,7 @@ static inline struct wiphy *wiphy_new(const struct cfg80211_ops *ops,
 struct cfg80211_conn;
 struct cfg80211_internal_bss;
 struct cfg80211_cached_keys;
-struct cfg80211_cqm_config;
+struct cfg80211_rssi_config;
 
 /**
  * struct wireless_dev - wireless device state
@@ -4204,7 +4204,8 @@ static inline struct wiphy *wiphy_new(const struct cfg80211_ops *ops,
  * @event_lock: (private) lock for event list
  * @owner_nlportid: (private) owner socket port ID
  * @nl_owner_dead: (private) owner socket went away
- * @cqm_config: (private) nl80211 RSSI monitor state
+ * @rssi_config: (private) nl80211 RSSI monitor state
+ * @rssi_config_list: (private) peer based list for rssi config
  */
 struct wireless_dev {
 	struct wiphy *wiphy;
@@ -4275,7 +4276,8 @@ struct wireless_dev {
 	} wext;
 #endif
 
-	struct cfg80211_cqm_config *cqm_config;
+	struct cfg80211_rssi_config *rssi_config;
+	struct list_head rssi_config_list;
 };
 
 static inline u8 *wdev_address(struct wireless_dev *wdev)
net/wireless/core.c +24 -5
index 5fe35aa..62e496e 100644
@@ -994,10 +994,28 @@ 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)
+void cfg80211_rssi_config_free(struct wireless_dev *wdev, const u8 *peer)
 {
-	kfree(wdev->cqm_config);
-	wdev->cqm_config = NULL;
+	struct cfg80211_rssi_config *rssi_config, *tmp;
+
+	if (list_empty(&wdev->rssi_config_list))
+		goto free;
+
+	list_for_each_entry_safe(rssi_config, tmp, &wdev->rssi_config_list,
+				 list) {
+		if (peer && memcmp(rssi_config->addr, peer, ETH_ALEN))
+			continue;
+
+		list_del(&rssi_config->list);
+		kfree(rssi_config);
+		if (list_empty(&wdev->rssi_config_list) || peer)
+			goto out;
+	}
+
+free:
+	kfree(wdev->rssi_config);
+out:
+	wdev->rssi_config = NULL;
 }
 
 void cfg80211_unregister_wdev(struct wireless_dev *wdev)
@@ -1027,7 +1045,7 @@ void cfg80211_unregister_wdev(struct wireless_dev *wdev)
 		break;
 	}
 
-	cfg80211_cqm_config_free(wdev);
+	cfg80211_rssi_config_free(wdev, NULL);
 }
 EXPORT_SYMBOL(cfg80211_unregister_wdev);
 
@@ -1163,6 +1181,7 @@ static int cfg80211_netdev_notifier_call(struct notifier_block *nb,
 		spin_lock_init(&wdev->event_lock);
 		INIT_LIST_HEAD(&wdev->mgmt_registrations);
 		spin_lock_init(&wdev->mgmt_registrations_lock);
+		INIT_LIST_HEAD(&wdev->rssi_config_list);
 
 		/*
 		 * We get here also when the interface changes network namespaces,
@@ -1292,7 +1311,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);
+			cfg80211_rssi_config_free(wdev, NULL);
 		}
 		/*
 		 * synchronise (so that we won't find this netdev
net/wireless/core.h +4 -2
index 63eb1b5..170a31b 100644
@@ -260,10 +260,12 @@ struct cfg80211_beacon_registration {
 	u32 nlportid;
 };
 
-struct cfg80211_cqm_config {
+struct cfg80211_rssi_config {
+	struct list_head list;
 	u32 rssi_hyst;
 	s32 last_rssi_event_value;
 	int n_rssi_thresholds;
+	u8 addr[ETH_ALEN];
 	s32 rssi_thresholds[0];
 };
 
@@ -514,6 +516,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);
+void cfg80211_rssi_config_free(struct wireless_dev *wdev, const u8 *peer);
 
 #endif /* __NET_WIRELESS_CORE_H */
net/wireless/nl80211.c +49 -25

136 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#7 lore raw

PATCH 2/7 cfg80211: Add new NL command to configure peer specific rssi threshold

In reply to Tamizh chelvam

This patch add support to configure peer specific rssi configuration to monitor station's signal strength variation.
New NL80211_CMD_SET_STA_MON introduced to configure rssi threshold and hysteresis info using NL80211_ATTR_STA_MON_RSSI_THOLD and NL80211_ATTR_STA_MON_RSSI_HYST along with NL80211_ATTR_MAC. Driver supporting this configuration should advertise NL80211_EXT_FEATURE_STA_MON_RSSI_CONFIG.
Monitoring station's signal strength variation will be useful for the application like steering.

---
 include/net/cfg80211.h       |    9 +++++
 include/uapi/linux/nl80211.h |   55 ++++++++++++++++++++++++++++++
 net/wireless/nl80211.c       |   77 ++++++++++++++++++++++++++++++++++++++++++
 net/wireless/rdev-ops.h      |   16 +++++++++
 net/wireless/trace.h         |   25 ++++++++++++++
 5 files changed, 182 insertions(+)
include/net/cfg80211.h +9 -0
index 3e123a3..584697b 100644
@@ -3024,6 +3024,11 @@ struct cfg80211_external_auth_params {
  *
  * @tx_control_port: TX a control port frame (EAPoL).  The noencrypt parameter
  *	tells the driver that the frame should not be encrypted.
+ * @set_sta_mon_rssi_config: Configure  RSSI threshold for a station.
+ *	After configuration, the driver should (soon) send an event indicating
+ *	the current level of a station is above/below the configured threshold;
+ *	this may need some care when the configuration is changed
+ *	(without first being disabled.)
  */
 struct cfg80211_ops {
 	int	(*suspend)(struct wiphy *wiphy, struct cfg80211_wowlan *wow);
@@ -3329,6 +3334,10 @@ struct cfg80211_ops {
 				   const u8 *buf, size_t len,
 				   const u8 *dest, const __be16 proto,
 				   const bool noencrypt);
+	int	(*set_sta_mon_rssi_config)(struct wiphy *wiphy,
+					   struct net_device *dev,
+					   const u8 *addr,
+					   s32 rssi_thold, u32 rssi_hyst);
 };
 
 /*
include/uapi/linux/nl80211.h +55 -0

97 lines not on this page · raw message

net/wireless/nl80211.c +77 -0

101 lines not on this page · raw message

net/wireless/rdev-ops.h +16 -0
index 364f5d6..faccfae 100644
@@ -1232,4 +1232,20 @@ static inline int rdev_del_pmk(struct cfg80211_registered_device *rdev,
 	return ret;
 }
 
+static inline int
+rdev_set_sta_mon_rssi_config(struct cfg80211_registered_device *rdev,
+			     struct net_device *dev, const u8 *peer,
+			     s32 rssi_thold, u32 rssi_hyst)
+
+{
+	int ret;
+
+	trace_rdev_set_sta_mon_rssi_config(&rdev->wiphy, dev, peer,
+					   rssi_thold, rssi_hyst);
+	ret = rdev->ops->set_sta_mon_rssi_config(&rdev->wiphy, dev, peer,
+						 rssi_thold, rssi_hyst);
+	trace_rdev_return_int(&rdev->wiphy, ret);
+	return ret;
+}
+
 #endif /* __CFG80211_RDEV_OPS */
net/wireless/trace.h +25 -0
index 2b417a2..361ec08 100644
@@ -3257,6 +3257,31 @@
 	),
 	TP_printk(WIPHY_PR_FMT ", " WDEV_PR_FMT, WIPHY_PR_ARG, WDEV_PR_ARG)
 );
+
+TRACE_EVENT(rdev_set_sta_mon_rssi_config,
+	TP_PROTO(struct wiphy *wiphy,
+		 struct net_device *netdev, const u8 *peer,
+		 s32 rssi_thold, u32 rssi_hyst),
+	TP_ARGS(wiphy, netdev, peer, rssi_thold, rssi_hyst),
+	TP_STRUCT__entry(
+		WIPHY_ENTRY
+		NETDEV_ENTRY
+		MAC_ENTRY(peer)
+		__field(s32, rssi_thold)
+		__field(u32, rssi_hyst)
+	),
+	TP_fast_assign(
+		WIPHY_ASSIGN;
+		NETDEV_ASSIGN;
+		MAC_ASSIGN(peer, peer);
+		__entry->rssi_thold = rssi_thold;
+		__entry->rssi_hyst = rssi_hyst;
+	),
+	TP_printk(WIPHY_PR_FMT ", " NETDEV_PR_FMT ", " MAC_PR_FMT
+		  ", rssi_thold: %d, rssi_hyst: %u ",
+		  WIPHY_PR_ARG, NETDEV_PR_ARG, MAC_PR_ARG(peer),
+		  __entry->rssi_thold, __entry->rssi_hyst)
+);
 #endif /* !__RDEV_OPS_TRACE || TRACE_HEADER_MULTI_READ */
 
 #undef TRACE_INCLUDE_PATH
Signature · 1 line
1.7.9.5
#13 lore raw

PATCH 3/7 mac80211: Add api to support configuring station specific rssi threshold

In reply to Tamizh chelvam

This patch add set_sta_mon_rssi_config api to configure rssi and hysteresis threshold value for a connected station. This configuration will be applied only for the connected station.

---
 net/mac80211/cfg.c      |   35 +++++++++++++++++++++++++++++++++++
 net/mac80211/sta_info.h |   12 ++++++++++++
 2 files changed, 47 insertions(+)
net/mac80211/cfg.c +35 -0
index bdf6fa7..80ced50 100644
@@ -3803,6 +3803,40 @@ static int ieee80211_get_txq_stats(struct wiphy *wiphy,
 	return ret;
 }
 
+static int ieee80211_set_sta_mon_rssi_config(struct wiphy *wiphy,
+					     struct net_device *dev,
+					     const u8 *peer, s32 rssi_thold,
+					     u32 rssi_hyst)
+{
+	struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
+	struct sta_info *sta;
+
+	if (sdata->vif.type == NL80211_IFTYPE_AP &&
+	    (!sdata->vif.bss_conf.enable_beacon ||
+	     !wiphy_ext_feature_isset(sdata->local->hw.wiphy,
+				 NL80211_EXT_FEATURE_STA_MON_RSSI_CONFIG)))
+		return -EOPNOTSUPP;
+
+	mutex_lock(&sdata->local->sta_mtx);
+
+	sta = sta_info_get_bss(sdata, peer);
+	if (!sta) {
+		mutex_unlock(&sdata->local->sta_mtx);
+		return -ENOENT;
+	}
+
+	if (sta->rssi_thold == rssi_thold &&
+	    sta->rssi_hyst == rssi_hyst)
+		goto unlock;
+
+	sta->rssi_thold = rssi_thold;
+	sta->rssi_hyst = rssi_hyst;
+	sta->last_sta_mon_event_signal = 0;
+unlock:
+	mutex_unlock(&sdata->local->sta_mtx);
+	return 0;
+}
+
 const struct cfg80211_ops mac80211_config_ops = {
 	.add_virtual_intf = ieee80211_add_iface,
 	.del_virtual_intf = ieee80211_del_iface,
@@ -3897,4 +3931,5 @@ static int ieee80211_get_txq_stats(struct wiphy *wiphy,
 	.set_multicast_to_unicast = ieee80211_set_multicast_to_unicast,
 	.tx_control_port = ieee80211_tx_control_port,
 	.get_txq_stats = ieee80211_get_txq_stats,
+	.set_sta_mon_rssi_config = ieee80211_set_sta_mon_rssi_config,
 };
net/mac80211/sta_info.h +12 -0
index 81b35f6..8c459a7 100644
@@ -482,6 +482,14 @@ struct ieee80211_sta_rx_stats {
  * @pcpu_rx_stats: per-CPU RX statistics, assigned only if the driver needs
  *	this (by advertising the USES_RSS hw flag)
  * @status_stats: TX status statistics
+ * @rssi_thold: RSSI threshold to monitor station's signal strength, a zero
+ *	value implies disabled. As with the cfg80211 callback, a change here
+ *	should cause an event to be sent indicating where the current value
+ *	is in relation to the newly configured threshold
+ * @rssi_hyst: Station's RSSI hysteresis
+ * @last_sta_mon_event_signal: Last signal strength average for a station
+ *	that triggered a sta_mon event. 0 indicates that no event has been
+ *	generated for the current association
  */
 struct sta_info {
 	/* General information, mostly static */
@@ -583,6 +591,10 @@ struct sta_info {
 
 	struct cfg80211_chan_def tdls_chandef;
 
+	s32 rssi_thold;
+	u32 rssi_hyst;
+	int last_sta_mon_event_signal;
+
 	/* keep last! */
 	struct ieee80211_sta sta;
 };
Signature · 1 line
1.7.9.5
#16 lore raw

PATCH 4/7 cfg80211: Add support to notify station's rssi level crossing

In reply to Tamizh chelvam

Add cfg80211_sta_mon_rssi_notify api to update user space upon crossing the configured rssi threshold of a station. NL80211_CMD_NOTIFY_STA_MON introduced to send this event to userspace along with NL80211_ATTR_STA_MON_RSSI_THRESHOLD_EVENT, NL80211_ATTR_MAC and NL80211_ATTR_STA_MON_RSSI_LEVEL info. Userspace application can make a decision depends on this notification.

---
 include/net/cfg80211.h       |   16 +++++++
 include/uapi/linux/nl80211.h |    1 +
 net/wireless/nl80211.c       |   98 ++++++++++++++++++++++++++++++++++++++++++
 net/wireless/trace.h         |   22 ++++++++++
 4 files changed, 137 insertions(+)
include/net/cfg80211.h +16 -0
index 584697b..7dcf9b9 100644
@@ -5916,6 +5916,22 @@ void cfg80211_cqm_txe_notify(struct net_device *dev, const u8 *peer,
 void cfg80211_cqm_beacon_loss_notify(struct net_device *dev, gfp_t gfp);
 
 /**
+ * cfg80211_sta_mon_rssi_notify - Station's rssi out of range event
+ * @dev: network device
+ * @peer: Station'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 rssi threshold reached event
+ * occurs for a station.
+ */
+void
+cfg80211_sta_mon_rssi_notify(struct net_device *dev, const u8 *peer,
+		enum nl80211_sta_mon_rssi_threshold_event rssi_event,
+		s32 rssi_level, gfp_t gfp);
+
+/**
  * cfg80211_radar_event - radar detection event
  * @wiphy: the wiphy
  * @chandef: chandef for the current channel
include/uapi/linux/nl80211.h +1 -0
index f13ad07..9d47ee6 100644
@@ -1249,6 +1249,7 @@ enum nl80211_commands {
 	NL80211_CMD_CONTROL_PORT_FRAME,
 
 	NL80211_CMD_SET_STA_MON,
+	NL80211_CMD_NOTIFY_STA_MON,
 
 	/* add new commands above here */
 
net/wireless/nl80211.c +98 -0

104 lines not on this page · raw message

net/wireless/trace.h +22 -0
index 361ec08..5454c57 100644
@@ -3282,6 +3282,28 @@
 		  WIPHY_PR_ARG, NETDEV_PR_ARG, MAC_PR_ARG(peer),
 		  __entry->rssi_thold, __entry->rssi_hyst)
 );
+TRACE_EVENT(cfg80211_sta_mon_rssi_notify,
+	TP_PROTO(struct net_device *netdev, const u8 *peer,
+		 enum nl80211_sta_mon_rssi_threshold_event rssi_event,
+		 s32 rssi_level),
+	TP_ARGS(netdev, peer, rssi_event, rssi_level),
+	TP_STRUCT__entry(
+		NETDEV_ENTRY
+		MAC_ENTRY(peer)
+		__field(enum nl80211_sta_mon_rssi_threshold_event, rssi_event)
+		__field(s32, rssi_level)
+	),
+	TP_fast_assign(
+		NETDEV_ASSIGN;
+		MAC_ASSIGN(peer, peer);
+		__entry->rssi_event = rssi_event;
+		__entry->rssi_level = rssi_level;
+	),
+	TP_printk(NETDEV_PR_FMT ", peer: " MAC_PR_FMT
+		  ", rssi event: %d, rssi : %d",
+		  NETDEV_PR_ARG, MAC_PR_ARG(peer),
+		  __entry->rssi_event, __entry->rssi_level)
+);
 #endif /* !__RDEV_OPS_TRACE || TRACE_HEADER_MULTI_READ */
 
 #undef TRACE_INCLUDE_PATH
Signature · 1 line
1.7.9.5
#21 lore raw

PATCH 5/7 mac80211: Implement functionality to monitor station's rssi cross event

In reply to Tamizh chelvam

Triggers cfg80211_sta_mon_rssi_notify with the corresponding event when station signal goes out of configured threshold. It uses rx data signal to check against rssi threshold configured by the user.
This event will be useful for the application like steering to take decision on any station depends on its current capability.

---
 include/net/mac80211.h  |    6 ++++++
 net/mac80211/rx.c       |   42 +++++++++++++++++++++++++++++++++++++++++-
 net/mac80211/sta_info.h |    4 ++++
 3 files changed, 51 insertions(+), 1 deletion(-)
include/net/mac80211.h +6 -0
index 851a5e1..96fb9a8 100644
@@ -802,6 +802,12 @@ enum mac80211_rate_control_flags {
 	IEEE80211_TX_RC_160_MHZ_WIDTH		= BIT(10),
 };
 
+/*
+ * How many frames need to have been used in average station's
+ * signal strength before checking against the threshold
+ */
+#define IEEE80211_STA_SIGNAL_AVE_MIN_COUNT	4
+
 
 /* there are 40 bytes if you don't need the rateset to be kept */
 #define IEEE80211_TX_INFO_DRIVER_DATA_SIZE 40
net/mac80211/rx.c +41 -1

62 lines not on this page · raw message

net/mac80211/sta_info.h +4 -0
index 8c459a7..e130f6d 100644
@@ -490,6 +490,9 @@ struct ieee80211_sta_rx_stats {
  * @last_sta_mon_event_signal: Last signal strength average for a station
  *	that triggered a sta_mon event. 0 indicates that no event has been
  *	generated for the current association
+ * @count_rx_signal: Number of data frames used in averaging station signal.
+ *	This can be used to avoid generating less reliable station rssi cross
+ *	events that would be based only on couple of received frames
  */
 struct sta_info {
 	/* General information, mostly static */
@@ -594,6 +597,7 @@ struct sta_info {
 	s32 rssi_thold;
 	u32 rssi_hyst;
 	int last_sta_mon_event_signal;
+	unsigned int count_rx_signal;
 
 	/* keep last! */
 	struct ieee80211_sta sta;
Signature · 1 line
1.7.9.5
#24 lore raw

PATCH 6/7 cfg80211: Accept multiple RSSI threholds for STA_MON command

In reply to Tamizh chelvam

Change the NL80211_CMD_STA_MON RSSI threshold attribut to accept any number of thresholds as a sorted array. If user send the configuration with single RSSI threshold then the old mechanism is enabled. Same netlink event will be generated in both cases. This patch introduced set_sta_mon_rssi_range_config to configure high and low value.
Driver supporting this feature should advertise NL80211_EXT_FEATURE_STA_MON_RSSI_LIST.

---
 include/net/cfg80211.h       |   10 +++
 include/uapi/linux/nl80211.h |    4 +
 net/wireless/nl80211.c       |  176 ++++++++++++++++++++++++++++++------------
 net/wireless/rdev-ops.h      |   15 ++++
 net/wireless/trace.h         |   26 +++++++
 5 files changed, 180 insertions(+), 51 deletions(-)
include/net/cfg80211.h +10 -0
index 7dcf9b9..4c49cc5 100644
@@ -3029,6 +3029,12 @@ struct cfg80211_external_auth_params {
  *	the current level of a station is above/below the configured threshold;
  *	this may need some care when the configuration is changed
  *	(without first being disabled.)
+ * @set_sta_mon_rssi_range_config: Configure two RSSI thresholds in the
+ *	station's rssi monitor.  An event is to be sent only when the
+ *	signal level of a station is found to be outside the two values.
+ *	The driver should advertise %NL80211_EXT_FEATURE_STA_MON_RSSI_LIST if
+ *	this method is implemented. If it is provided then there's no point
+ *	providing @set_sta_mon_rssi_config
  */
 struct cfg80211_ops {
 	int	(*suspend)(struct wiphy *wiphy, struct cfg80211_wowlan *wow);
@@ -3338,6 +3344,10 @@ struct cfg80211_ops {
 					   struct net_device *dev,
 					   const u8 *addr,
 					   s32 rssi_thold, u32 rssi_hyst);
+	int	(*set_sta_mon_rssi_range_config)(struct wiphy *wiphy,
+						 struct net_device *dev,
+						 const u8 *addr,
+						 s32 rssi_low, s32 rssi_high);
 };
 
 /*
include/uapi/linux/nl80211.h +4 -0
index 9d47ee6..8e2a84b 100644
@@ -5188,6 +5188,9 @@ enum nl80211_feature_flags {
  * @NL80211_EXT_FEATURE_STA_MON_RSSI_CONFIG: With this driver can set
  *	rssi threshold using %NL80211_ATTR_STA_MON_RSSI_THOLD attribute
  *	for a connected station.
+ * @NL80211_EXT_FEATURE_STA_MON_RSSI_LIST: With this driver the
+ *	%NL80211_ATTR_STA_MON_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.
@@ -5223,6 +5226,7 @@ enum nl80211_ext_feature_index {
 	NL80211_EXT_FEATURE_DATA_ACK_SIGNAL_SUPPORT,
 	NL80211_EXT_FEATURE_TXQS,
 	NL80211_EXT_FEATURE_STA_MON_RSSI_CONFIG,
+	NL80211_EXT_FEATURE_STA_MON_RSSI_LIST,
 
 	/* add new features before the definition below */
 	NUM_NL80211_EXT_FEATURES,
net/wireless/nl80211.c +125 -51

261 lines not on this page · raw message

net/wireless/rdev-ops.h +15 -0
index faccfae..1184e4a 100644
@@ -1248,4 +1248,19 @@ static inline int rdev_del_pmk(struct cfg80211_registered_device *rdev,
 	return ret;
 }
 
+static inline int
+rdev_set_sta_mon_rssi_range_config(struct cfg80211_registered_device *rdev,
+				   struct net_device *dev, const u8 *peer,
+				   s32 low, s32 high)
+{
+	int ret;
+
+	trace_rdev_set_sta_mon_rssi_range_config(&rdev->wiphy, dev, peer,
+						 low, high);
+	ret = rdev->ops->set_sta_mon_rssi_range_config(&rdev->wiphy, dev, peer,
+						       low, high);
+	trace_rdev_return_int(&rdev->wiphy, ret);
+	return ret;
+}
+
 #endif /* __CFG80211_RDEV_OPS */
net/wireless/trace.h +26 -0
index 5454c57..76c422c 100644
@@ -3282,6 +3282,32 @@
 		  WIPHY_PR_ARG, NETDEV_PR_ARG, MAC_PR_ARG(peer),
 		  __entry->rssi_thold, __entry->rssi_hyst)
 );
+
+TRACE_EVENT(rdev_set_sta_mon_rssi_range_config,
+	TP_PROTO(struct wiphy *wiphy,
+		 struct net_device *netdev, const u8 *peer,
+		 s32 low, s32 high),
+	TP_ARGS(wiphy, netdev, peer, low, high),
+	TP_STRUCT__entry(
+		WIPHY_ENTRY
+		NETDEV_ENTRY
+		MAC_ENTRY(peer)
+		__field(s32, rssi_low)
+		__field(s32, rssi_high)
+	),
+	TP_fast_assign(
+		WIPHY_ASSIGN;
+		NETDEV_ASSIGN;
+		MAC_ASSIGN(peer, peer);
+		__entry->rssi_low = low;
+		__entry->rssi_high = high;
+	),
+	TP_printk(WIPHY_PR_FMT ", " NETDEV_PR_FMT ", " MAC_PR_FMT
+		  ", range: %d - %d ",
+		  WIPHY_PR_ARG, NETDEV_PR_ARG, MAC_PR_ARG(peer),
+		  __entry->rssi_low, __entry->rssi_high)
+);
+
 TRACE_EVENT(cfg80211_sta_mon_rssi_notify,
 	TP_PROTO(struct net_device *netdev, const u8 *peer,
 		 enum nl80211_sta_mon_rssi_threshold_event rssi_event,
Signature · 1 line
1.7.9.5
#28 lore raw

PATCH 7/7 mac80211: Add api to configure low and high RSSI threshold

In reply to Tamizh chelvam

Add set_sta_mon_rssi_range_config api to support configuring low and high RSSI threshold values for a connected station. And trigger an event if a station's signal strength goes out of configured range.

---
 net/mac80211/cfg.c      |   40 ++++++++++++++++++++++++++++++++++++++++
 net/mac80211/rx.c       |   23 +++++++++++++++++++++++
 net/mac80211/sta_info.h |    6 ++++++
 3 files changed, 69 insertions(+)
net/mac80211/cfg.c +40 -0
index 80ced50..5cdd8a3 100644
@@ -3831,12 +3831,51 @@ static int ieee80211_set_sta_mon_rssi_config(struct wiphy *wiphy,
 
 	sta->rssi_thold = rssi_thold;
 	sta->rssi_hyst = rssi_hyst;
+	sta->rssi_low = 0;
+	sta->rssi_high = 0;
 	sta->last_sta_mon_event_signal = 0;
 unlock:
 	mutex_unlock(&sdata->local->sta_mtx);
 	return 0;
 }
 
+static int ieee80211_set_sta_mon_rssi_range_cfg(struct wiphy *wiphy,
+						struct net_device *dev,
+						const u8 *peer,
+						s32 rssi_low, s32 rssi_high)
+{
+	struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
+	struct sta_info *sta;
+
+	if (sdata->vif.type == NL80211_IFTYPE_AP &&
+	    (!sdata->vif.bss_conf.enable_beacon ||
+	    !wiphy_ext_feature_isset(sdata->local->hw.wiphy,
+				     NL80211_EXT_FEATURE_STA_MON_RSSI_LIST)))
+		return -EOPNOTSUPP;
+
+	mutex_lock(&sdata->local->sta_mtx);
+
+	sta = sta_info_get_bss(sdata, peer);
+	if (!sta) {
+		mutex_unlock(&sdata->local->sta_mtx);
+		return -ENOENT;
+	}
+
+	if (sta->rssi_low == rssi_low &&
+	    sta->rssi_high == rssi_high)
+		goto unlock;
+
+	sta->rssi_thold = 0;
+	sta->rssi_hyst = 0;
+	sta->rssi_low = rssi_low;
+	sta->rssi_high = rssi_high;
+	sta->last_sta_mon_event_signal = 0;
+
+unlock:
+	mutex_unlock(&sdata->local->sta_mtx);
+	return 0;
+}
+
 const struct cfg80211_ops mac80211_config_ops = {
 	.add_virtual_intf = ieee80211_add_iface,
 	.del_virtual_intf = ieee80211_del_iface,
@@ -3932,4 +3971,5 @@ static int ieee80211_set_sta_mon_rssi_config(struct wiphy *wiphy,
 	.tx_control_port = ieee80211_tx_control_port,
 	.get_txq_stats = ieee80211_get_txq_stats,
 	.set_sta_mon_rssi_config = ieee80211_set_sta_mon_rssi_config,
+	.set_sta_mon_rssi_range_config = ieee80211_set_sta_mon_rssi_range_cfg,
 };
net/mac80211/rx.c +23 -0
index 06a6111..fddb5c6 100644
@@ -1569,6 +1569,29 @@ static void ieee80211_sta_rx_signal_thold_check(struct ieee80211_rx_data *rx)
 				sig, GFP_ATOMIC);
 		}
 	}
+
+	if (sta->rssi_low) {
+		int last_event = sta->last_sta_mon_event_signal;
+		int sig = -ewma_signal_read(&sta->rx_stats_avg.signal);
+		int low = sta->rssi_low;
+		int high = sta->rssi_high;
+
+		if (sig < low &&
+		    (last_event == 0 || last_event >= low)) {
+			sta->last_sta_mon_event_signal = sig;
+			cfg80211_sta_mon_rssi_notify(
+				rx->sdata->dev, sta->addr,
+				NL80211_STA_MON_RSSI_THRESHOLD_EVENT_LOW,
+				sig, GFP_ATOMIC);
+		} else if (sig > high &&
+			   (last_event == 0 || last_event <= high)) {
+			sta->last_sta_mon_event_signal = sig;
+			cfg80211_sta_mon_rssi_notify(
+				rx->sdata->dev, sta->addr,
+				NL80211_STA_MON_RSSI_THRESHOLD_EVENT_HIGH,
+				sig, GFP_ATOMIC);
+		}
+	}
 }
 
 static ieee80211_rx_result debug_noinline
net/mac80211/sta_info.h +6 -0
index e130f6d..05d68f8 100644
@@ -487,6 +487,10 @@ struct ieee80211_sta_rx_stats {
  *	should cause an event to be sent indicating where the current value
  *	is in relation to the newly configured threshold
  * @rssi_hyst: Station's RSSI hysteresis
+ * @rssi_low: RSSI lower threshold to monitor station's signal strength, a zero
+ *	value implies disabled.  This is an alternative mechanism to the single
+ *	threshold event and can't be enabled simultaneously with it
+ * @rssi_high: RSSI upper threshold for station
  * @last_sta_mon_event_signal: Last signal strength average for a station
  *	that triggered a sta_mon event. 0 indicates that no event has been
  *	generated for the current association
@@ -596,6 +600,8 @@ struct sta_info {
 
 	s32 rssi_thold;
 	u32 rssi_hyst;
+	s32 rssi_low;
+	s32 rssi_high;
 	int last_sta_mon_event_signal;
 	unsigned int count_rx_signal;
 
Signature · 1 line
1.7.9.5
maintainer
#2 lore raw

Re: [PATCH 1/7] wireless: Change single cqm_config to rssi config list

In reply to Tamizh chelvam

include/net/cfg80211.h static inline struct wiphy *wiphy_new(const struct cfg80211_ops *ops, · line 4142

Quoted 11 lines · Tamizh chelvam
include/net/cfg80211.h +1 -1
index 5fbfe61..3e123a3 100644
@@ -4139,7 +4139,7 @@ static inline struct wiphy *wiphy_new(const struct cfg80211_ops *ops,
 struct cfg80211_conn;
 struct cfg80211_internal_bss;
 struct cfg80211_cached_keys;
-struct cfg80211_cqm_config;
+struct cfg80211_rssi_config;

I think something like rssi_mon_config would be better? Just _rssi_ could be interpreted in many ways.

include/net/cfg80211.h struct wireless_dev { · line 4280

Quoted 3 lines
include/net/cfg80211.h +2 -1
-	struct cfg80211_cqm_config *cqm_config;
+	struct cfg80211_rssi_config *rssi_config;
+	struct list_head rssi_config_list;

Why do you need both now? Perhaps instead you should allow a NULL/all- ones MAC address for where you have the direct pointer now, and remove that? You anyway need to pass something to the peer argument in

include/net/cfg80211.h static inline struct wiphy *wiphy_new(const struct cfg80211_ops *ops, · line 4145

Quoted 2 lines
include/net/cfg80211.h +1 -1
-void cfg80211_cqm_config_free(struct wireless_dev *wdev)
+void cfg80211_rssi_config_free(struct wireless_dev *wdev, const u8 *peer)

even when the pointer is used.

Quoted 7 lines
include/net/cfg80211.h +5 -2
-	kfree(wdev->cqm_config);
-	wdev->cqm_config = NULL;
+	struct cfg80211_rssi_config *rssi_config, *tmp;
+
+	if (list_empty(&wdev->rssi_config_list))
+		goto free;
+

include/net/cfg80211.h static inline struct wiphy *wiphy_new(const struct cfg80211_ops *ops,

Quoted 10 lines
include/net/cfg80211.h +10 -0
+	list_for_each_entry_safe(rssi_config, tmp, &wdev->rssi_config_list,
+				 list) {
+		if (peer && memcmp(rssi_config->addr, peer, ETH_ALEN))
+			continue;
+
+		list_del(&rssi_config->list);
+		kfree(rssi_config);
+		if (list_empty(&wdev->rssi_config_list) || peer)
+			goto out;
+	}

That logic could use some comments if we even decide to keep it this way.

NULL means "free all"?

What's the locking scheme for this? It's way more complex now so perhaps stick ASSERT_RTNL() in there or so?

include/net/cfg80211.h static int cfg80211_cqm_rssi_update(struct cfg80211_registered_device *rdev, · line 10145

Quoted 7 lines
include/net/cfg80211.h +1 -1
@@ -10140,7 +10141,7 @@ static int cfg80211_cqm_rssi_update(struct cfg80211_registered_device *rdev,
 	int err;
 
 	/* RSSI reporting disabled? */
-	if (!wdev->cqm_config)
+	if (!wdev->rssi_config)
 		return rdev_set_cqm_rssi_range_config(rdev, dev, 0, 0);

So I guess the wdev->rssi_config is used for the case of "always use this config for any AP you're connected to" or so - but maybe it'd be better to track the AP as a station? Then again, I guess we can't force userspace to change that.

Quoted 11 lines
include/net/cfg80211.h +11 -0
+static struct cfg80211_rssi_config *
+cfg80211_get_rssi_config(struct wireless_dev *wdev, const s32 *thresholds,
+			 int n_thresholds, u32 hysteresis, const u8 *peer)
+{
+	struct cfg80211_rssi_config *rssi_config;
+
+	if (!peer)
+		return NULL;
+
+	if (list_empty(&wdev->rssi_config_list))
+		goto new;

include/net/cfg80211.h static int cfg80211_cqm_rssi_update(struct cfg80211_registered_device *rdev,

Quoted 10 lines
include/net/cfg80211.h +10 -0
+
+	list_for_each_entry(rssi_config, &wdev->rssi_config_list, list) {
+		if (!memcmp(rssi_config->addr, peer, ETH_ALEN))
+			goto found;
+	}
+
+new:
+	rssi_config = kzalloc(sizeof(struct cfg80211_rssi_config) +
+			      n_thresholds * sizeof(s32), GFP_KERNEL);
+	list_add(&rssi_config->list, &wdev->rssi_config_list);

Why does "get" always imply "create"?

include/net/cfg80211.h

Quoted 11 lines
include/net/cfg80211.h +4 -5
 	wdev_lock(wdev);
 	if (n_thresholds) {
-		struct cfg80211_cqm_config *cqm_config;
-
-		cqm_config = kzalloc(sizeof(struct cfg80211_cqm_config) +
-				     n_thresholds * sizeof(s32), GFP_KERNEL);
-		if (!cqm_config) {
+		wdev->rssi_config = cfg80211_get_rssi_config(
+						wdev, thresholds,
+						n_thresholds, hysteresis,
+						wdev->current_bss->pub.bssid);

Here you link it to the BSSID anyway, but do we always have a current_bss at this point?

johannes

maintainer
#8 lore raw

Re: [PATCH 2/7] cfg80211: Add new NL command to configure peer specific rssi threshold

In reply to Tamizh chelvam
Quoted 3 lines · Tamizh chelvam

+ * @NL80211_ATTR_STA_MON: Station's connection monitor configuration in a
+ * nested attribute with %NL80211_ATTR_STA_MON_* sub-attributes.

Can't we reuse the existing attributes in this nesting?

include/uapi/linux/nl80211.h enum nl80211_ps_state { · line 4326

Quoted 11 lines
include/uapi/linux/nl80211.h +11 -0
+/**
+ * enum nl80211_sta_mon_rssi_threshold_event - RSSI threshold event
+ * @NL80211_STA_MON_RSSI_THRESHOLD_EVENT_LOW: The RSSI level is lower than the
+ *	configured threshold
+ * @NL80211_STA_MON_RSSI_THRESHOLD_EVENT_HIGH: The RSSI is higher than the
+ *	configured threshold
+ */
+enum nl80211_sta_mon_rssi_threshold_event {
+	NL80211_STA_MON_RSSI_THRESHOLD_EVENT_LOW,
+	NL80211_STA_MON_RSSI_THRESHOLD_EVENT_HIGH,
+};

It seems like this should already exist also for the CQM? Can we not reuse it?

Quoted 17 lines
net/wireless/nl80211.c +17 -0
+static int nl80211_set_sta_mon_rssi(struct genl_info *info,
+				    const u8 *peer, s32 threshold,
+				    u32 hysteresis)
+{
+	struct cfg80211_registered_device *rdev = info->user_ptr[0];
+	struct net_device *dev = info->user_ptr[1];
+	struct wireless_dev *wdev = dev->ieee80211_ptr;
+
+	if (threshold > 0)
+		return -EINVAL;
+
+	if (threshold == 0)
+		hysteresis = 0;
+
+	if (!rdev->ops->set_sta_mon_rssi_config)
+		return -EOPNOTSUPP;
+

net/wireless/nl80211.c static int nl80211_tx_control_port(struct sk_buff *skb, struct genl_info *info) · line 12950

Quoted 10 lines
net/wireless/nl80211.c +10 -0
+	if ((wdev->iftype != NL80211_IFTYPE_AP &&
+	     wdev->iftype != NL80211_IFTYPE_P2P_GO &&
+	     wdev->iftype != NL80211_IFTYPE_AP_VLAN) ||
+	    !wiphy_ext_feature_isset(&rdev->wiphy,
+				NL80211_EXT_FEATURE_STA_MON_RSSI_CONFIG))
+		return -EOPNOTSUPP;
+
+	return rdev_set_sta_mon_rssi_config(rdev, dev, peer,
+					    threshold, hysteresis);
+}

Wait, you went to all this effort in the first patch and now you don't add this to the list?

johannes

maintainer
#14 lore raw

Re: [PATCH 3/7] mac80211: Add api to support configuring station specific rssi threshold

In reply to Tamizh chelvam

The subjects are a bit confusing - I think you should align the cfg80211 and mac80211 ones so it's clearer that this one is implementing the previous one's API. Peer vs. station, and mac80211 doesn't add API but implements it.

This patch doesn't really do anything though, so I guess you need to combine it with patch 5.

johannes

maintainer
#17 lore raw

Re: [PATCH 4/7] cfg80211: Add support to notify station's rssi level crossing

In reply to Tamizh chelvam
Quoted 7 lines · Tamizh chelvam

Add cfg80211_sta_mon_rssi_notify api to update user space upon crossing the configured rssi threshold of a station. NL80211_CMD_NOTIFY_STA_MON introduced to send this event to userspace along with NL80211_ATTR_STA_MON_RSSI_THRESHOLD_EVENT, NL80211_ATTR_MAC and NL80211_ATTR_STA_MON_RSSI_LEVEL info. Userspace application can make a decision depends on this notification.

I guess you should also combine this with patch 2, it's a bit weird to only have one side and not be able to use it in one patch, and both aren't all that big.

include/uapi/linux/nl80211.h enum nl80211_commands { · line 1252

Quoted 7 lines
include/uapi/linux/nl80211.h +1 -0
@@ -1249,6 +1249,7 @@ enum nl80211_commands {
 	NL80211_CMD_CONTROL_PORT_FRAME,
 
 	NL80211_CMD_SET_STA_MON,
+	NL80211_CMD_NOTIFY_STA_MON,

Missing documentation - but again, why not unify it with the existing event? Or can't we because that might confuse older applications? Perhaps anyway we should unicast these notifications? Not sure though, perhaps one app could set them up and the other might care?

include/uapi/linux/nl80211.h enum nl80211_commands {

Quoted 12 lines
include/uapi/linux/nl80211.h +12 -0
+static struct sk_buff *cfg80211_prepare_sta_mon(struct net_device *dev,
+						const char *mac, gfp_t gfp)
+{
+	struct wireless_dev *wdev = dev->ieee80211_ptr;
+	struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
+	struct sk_buff *msg = nlmsg_new(NLMSG_DEFAULT_SIZE, gfp);
+	void **cb;
+
+	if (!msg)
+		return NULL;
+
+	cb = (void **)msg->cb;

Uh, what's that? Please use a structure.

Quoted 2 lines
include/uapi/linux/nl80211.h +1 -0
+	cb[0] = nl80211hdr_put(msg, 0, 0, 0, NL80211_CMD_NOTIFY_STA_MON);

[...]

include/uapi/linux/nl80211.h

Quoted 6 lines
include/uapi/linux/nl80211.h +6 -0
+
+	cb[1] = nla_nest_start(msg, NL80211_ATTR_STA_MON);
+	if (!cb[1])
+		goto nla_put_failure;
+
+	cb[2] = rdev;

Yeah, definitely use a struct instead of three magic array indices.

Quoted 4 lines
include/uapi/linux/nl80211.h +4 -0
+
+	msg = cfg80211_prepare_sta_mon(dev, peer, gfp);
+	if (!msg)
+		return;

include/uapi/linux/nl80211.h

Quoted 10 lines
include/uapi/linux/nl80211.h +10 -0
+
+	if (nla_put_u32(msg, NL80211_ATTR_STA_MON_RSSI_THRESHOLD_EVENT,
+			rssi_event))
+		goto nla_put_failure;
+
+	if (rssi_level && nla_put_s32(msg, NL80211_ATTR_STA_MON_RSSI_LEVEL,
+				      rssi_level))
+		goto nla_put_failure;
+
+	cfg80211_send_sta_mon(msg, gfp);

In fact, perhaps better to have something like

struct nl80211_sta_mon_prep {
	struct sk_buff *skb;
	....
};

struct nl80211_sta_mon_prep prep;

if (cfg80211_prepare_sta_mon(&prep))

	return;

...
cfg80211_send_sta_mon(&prep, gfp);

or so?

johannes

maintainer
#22 lore raw

Re: [PATCH 5/7] mac80211: Implement functionality to monitor station's rssi cross event

In reply to Tamizh chelvam
Quoted 13 lines · Tamizh chelvam
net/mac80211/rx.c +12 -0
+	if (sta->rssi_thold && bss_conf->enable_beacon) {
+		int last_event = sta->last_sta_mon_event_signal;
+		int thold = sta->rssi_thold;
+		int hyst = sta->rssi_hyst;
+		int sig = -ewma_signal_read(&sta->rx_stats_avg.signal);
+
+		if (sig < thold &&
+		    (last_event == 0 || sig < last_event - hyst)) {
+			sta->last_sta_mon_event_signal = sig;
+			cfg80211_sta_mon_rssi_notify(
+				rx->sdata->dev, sta->addr,
+				NL80211_STA_MON_RSSI_THRESHOLD_EVENT_LOW,

net/mac80211/rx.c void ieee80211_sta_uapsd_trigger(struct ieee80211_sta *pubsta, u8 tid) · line 1571

Quoted 10 lines
net/mac80211/rx.c +10 -0
+				sig, GFP_ATOMIC);
+		} else if (sig > thold &&
+			   (last_event == 0 || sig > last_event + hyst)) {
+			sta->last_sta_mon_event_signal = sig;
+			cfg80211_sta_mon_rssi_notify(
+				rx->sdata->dev, sta->addr,
+				NL80211_STA_MON_RSSI_THRESHOLD_EVENT_HIGH,
+				sig, GFP_ATOMIC);
+		}
+	}

This seems really familiar - perhaps if you unify the cfg80211 API for sta_mon and "normal" CQM (distinguish based on the peer address?) you can unify this block of code too?

johannes

maintainer
#25 lore raw

Re: [PATCH 6/7] cfg80211: Accept multiple RSSI threholds for STA_MON command

In reply to Tamizh chelvam
Quoted 1 line · Tamizh chelvam

Change the NL80211_CMD_STA_MON RSSI threshold attribut to

This seems weird - you just introduced it a few patches back, and now you change it and even worry about compatibility and have both cfg80211 callbacks etc. Just remove set_sta_mon_rssi_config() and ask that drivers/mac80211 implement set_sta_mon_rssi_range_config?

Quoted 6 lines

* @NL80211_EXT_FEATURE_STA_MON_RSSI_CONFIG: With this driver can set
* rssi threshold using %NL80211_ATTR_STA_MON_RSSI_THOLD attribute
* for a connected station.
+ * @NL80211_EXT_FEATURE_STA_MON_RSSI_LIST: With this driver the
+ * %NL80211_ATTR_STA_MON_RSSI_THOLD attribute accepts a list of zero or
+ * more RSSI threshold values to monitor rather than exactly one threshold.

And maybe not have two bits here either?

Or do you expect somebody to actually really need the single threshold in the near future? It seems you're implementing it for mac80211 only, which doesn't care.

johannes

maintainer
#29 lore raw

Re: [PATCH 7/7] mac80211: Add api to configure low and high RSSI threshold

In reply to Tamizh chelvam
Quoted 5 lines · Tamizh chelvam

Add set_sta_mon_rssi_range_config api to support configuring low and high RSSI threshold values for a connected station. And trigger an event if a station's signal strength goes out of configured range.

Same here, let's not worry about the "single threshold" thing - it simplifies the code.

johannes

#15 lore raw

Re: [PATCH 3/7] mac80211: Add api to support configuring station specific rssi threshold

In reply to Johannes Berg
Quoted 8 lines · Johannes Berg

The subjects are a bit confusing - I think you should align the cfg80211 and mac80211 ones so it's clearer that this one is implementing the previous one's API. Peer vs. station, and mac80211 doesn't add API but implements it.

This patch doesn't really do anything though, so I guess you need to combine it with patch 5.

Okay sure

#9 lore raw

Re: [PATCH 2/7] cfg80211: Add new NL command to configure peer specific rssi threshold

In reply to Johannes Berg
Quoted 7 lines · Johannes Berg
Quoted 4 lines · Tamizh chelvam

+ * @NL80211_ATTR_STA_MON: Station's connection monitor configuration in a
+ * nested attribute with %NL80211_ATTR_STA_MON_* sub-attributes.

Can't we reuse the existing attributes in this nesting?

This new attributes introduced as per the previous discussion.
https://patchwork.kernel.org/patch/10240697/
Is my understanding correct ?

Quoted 40 lines
Quoted 10 lines

+/**
+ * enum nl80211_sta_mon_rssi_threshold_event - RSSI threshold event
+ * @NL80211_STA_MON_RSSI_THRESHOLD_EVENT_LOW: The RSSI level is lower than the
+ * configured threshold
+ * @NL80211_STA_MON_RSSI_THRESHOLD_EVENT_HIGH: The RSSI is higher than the
+ * configured threshold
+ */

include/uapi/linux/nl80211.h enum nl80211_ps_state { · line 4326

Quoted 4 lines
include/uapi/linux/nl80211.h +4 -0
+enum nl80211_sta_mon_rssi_threshold_event {
+	NL80211_STA_MON_RSSI_THRESHOLD_EVENT_LOW,
+	NL80211_STA_MON_RSSI_THRESHOLD_EVENT_HIGH,
+};

It seems like this should already exist also for the CQM? Can we not reuse it?

Quoted 22 lines
net/wireless/nl80211.c +22 -0
+static int nl80211_set_sta_mon_rssi(struct genl_info *info,
+				    const u8 *peer, s32 threshold,
+				    u32 hysteresis)
+{
+	struct cfg80211_registered_device *rdev = info->user_ptr[0];
+	struct net_device *dev = info->user_ptr[1];
+	struct wireless_dev *wdev = dev->ieee80211_ptr;
+
+	if (threshold > 0)
+		return -EINVAL;
+
+	if (threshold == 0)
+		hysteresis = 0;
+
+	if (!rdev->ops->set_sta_mon_rssi_config)
+		return -EOPNOTSUPP;
+
+	if ((wdev->iftype != NL80211_IFTYPE_AP &&
+	     wdev->iftype != NL80211_IFTYPE_P2P_GO &&
+	     wdev->iftype != NL80211_IFTYPE_AP_VLAN) ||
+	    !wiphy_ext_feature_isset(&rdev->wiphy,
+				NL80211_EXT_FEATURE_STA_MON_RSSI_CONFIG))
Quoted 9 lines

net/wireless/nl80211.c static int nl80211_tx_control_port(struct sk_buff *skb, struct genl_info *info) · line 12950

Quoted 5 lines
net/wireless/nl80211.c +5 -0
+		return -EOPNOTSUPP;
+
+	return rdev_set_sta_mon_rssi_config(rdev, dev, peer,
+					    threshold, hysteresis);
+}

Wait, you went to all this effort in the first patch and now you don't add this to the list?

No, the list and the rssi_config structure is for multi threshold value and not for single threshold.

Thanks,
Tamizh.

#18 lore raw

Re: [PATCH 4/7] cfg80211: Add support to notify station's rssi level crossing

In reply to Johannes Berg
Quoted 9 lines · Johannes Berg
Quoted 7 lines · Tamizh chelvam

Add cfg80211_sta_mon_rssi_notify api to update user space upon crossing the configured rssi threshold of a station. NL80211_CMD_NOTIFY_STA_MON introduced to send this event to userspace along with NL80211_ATTR_STA_MON_RSSI_THRESHOLD_EVENT, NL80211_ATTR_MAC and NL80211_ATTR_STA_MON_RSSI_LEVEL info. Userspace application can make a decision depends on this notification.

Quoted 3 lines

I guess you should also combine this with patch 2, it's a bit weird to only have one side and not be able to use it in one patch, and both aren't all that big.

Sure

Quoted 7 lines
Quoted 7 lines
include/uapi/linux/nl80211.h +0 -0
@@ -1249,6 +1249,7 @@ enum nl80211_commands {
 	NL80211_CMD_CONTROL_PORT_FRAME,
 
Quoted 8 lines

include/uapi/linux/nl80211.h enum nl80211_commands { · line 1252

Quoted 2 lines
include/uapi/linux/nl80211.h +1 -0
 	NL80211_CMD_SET_STA_MON,
+	NL80211_CMD_NOTIFY_STA_MON,

Missing documentation - but again, why not unify it with the existing event? Or can't we because that might confuse older applications? Perhaps anyway we should unicast these notifications? Not sure though, perhaps one app could set them up and the other might care?

This new command introduced as per the previous discussion
https://patchwork.kernel.org/patch/10168685/
https://patchwork.kernel.org/patch/10240697/

Is my understanding correct ?

Quoted 8 lines
Quoted 8 lines
include/uapi/linux/nl80211.h +5 -0
+static struct sk_buff *cfg80211_prepare_sta_mon(struct net_device 
 *dev,
+						const char *mac, gfp_t gfp)
+{
+	struct wireless_dev *wdev = dev->ieee80211_ptr;
+	struct cfg80211_registered_device *rdev = 

wiphy_to_rdev(wdev->wiphy);

include/uapi/linux/nl80211.h +1 -0
+	struct sk_buff *msg = nlmsg_new(NLMSG_DEFAULT_SIZE, gfp);
Quoted 8 lines

include/uapi/linux/nl80211.h

Quoted 6 lines
include/uapi/linux/nl80211.h +6 -0
+	void **cb;
+
+	if (!msg)
+		return NULL;
+
+	cb = (void **)msg->cb;

Uh, what's that? Please use a structure.

I just referred this code from cfg80211_prepare_cqm. Do you want me to change this to struct based?

Quoted 35 lines
Quoted 3 lines
include/uapi/linux/nl80211.h +1 -0
+	cb[0] = nl80211hdr_put(msg, 0, 0, 0, NL80211_CMD_NOTIFY_STA_MON);

[...]

include/uapi/linux/nl80211.h

Quoted 6 lines
include/uapi/linux/nl80211.h +6 -0
+
+	cb[1] = nla_nest_start(msg, NL80211_ATTR_STA_MON);
+	if (!cb[1])
+		goto nla_put_failure;
+
+	cb[2] = rdev;

Yeah, definitely use a struct instead of three magic array indices.

Quoted 4 lines
include/uapi/linux/nl80211.h +4 -0
+
+	msg = cfg80211_prepare_sta_mon(dev, peer, gfp);
+	if (!msg)
+		return;

include/uapi/linux/nl80211.h

Quoted 10 lines
include/uapi/linux/nl80211.h +10 -0
+
+	if (nla_put_u32(msg, NL80211_ATTR_STA_MON_RSSI_THRESHOLD_EVENT,
+			rssi_event))
+		goto nla_put_failure;
+
+	if (rssi_level && nla_put_s32(msg, NL80211_ATTR_STA_MON_RSSI_LEVEL,
+				      rssi_level))
+		goto nla_put_failure;
+
+	cfg80211_send_sta_mon(msg, gfp);

In fact, perhaps better to have something like

struct nl80211_sta_mon_prep {
	struct sk_buff *skb;
	....
};
Quoted 8 lines

struct nl80211_sta_mon_prep prep;

if (cfg80211_prepare_sta_mon(&prep))

	return;

...
cfg80211_send_sta_mon(&prep, gfp);

or so?

Tamizh.

#23 lore raw

Re: [PATCH 5/7] mac80211: Implement functionality to monitor station's rssi cross event

In reply to Johannes Berg
Quoted 20 lines · Johannes Berg
Quoted 19 lines · Tamizh chelvam
net/mac80211/rx.c +18 -0
+	if (sta->rssi_thold && bss_conf->enable_beacon) {
+		int last_event = sta->last_sta_mon_event_signal;
+		int thold = sta->rssi_thold;
+		int hyst = sta->rssi_hyst;
+		int sig = -ewma_signal_read(&sta->rx_stats_avg.signal);
+
+		if (sig < thold &&
+		    (last_event == 0 || sig < last_event - hyst)) {
+			sta->last_sta_mon_event_signal = sig;
+			cfg80211_sta_mon_rssi_notify(
+				rx->sdata->dev, sta->addr,
+				NL80211_STA_MON_RSSI_THRESHOLD_EVENT_LOW,
+				sig, GFP_ATOMIC);
+		} else if (sig > thold &&
+			   (last_event == 0 || sig > last_event + hyst)) {
+			sta->last_sta_mon_event_signal = sig;
+			cfg80211_sta_mon_rssi_notify(
+				rx->sdata->dev, sta->addr,
Quoted 9 lines

net/mac80211/rx.c void ieee80211_sta_uapsd_trigger(struct ieee80211_sta *pubsta, u8 tid) · line 1571

Quoted 4 lines
net/mac80211/rx.c +4 -0
+				NL80211_STA_MON_RSSI_THRESHOLD_EVENT_HIGH,
+				sig, GFP_ATOMIC);
+		}
+	}

This seems really familiar - perhaps if you unify the cfg80211 API for sta_mon and "normal" CQM (distinguish based on the peer address?) you can unify this block of code too?

Sure I'll check and update it in the next version of the patch.

#3 lore raw

Re: [PATCH 1/7] wireless: Change single cqm_config to rssi config list

In reply to Johannes Berg
Quoted 17 lines · Johannes Berg

include/net/cfg80211.h static inline struct wiphy *wiphy_new(const · line 4143

Quoted 12 lines · Tamizh chelvam
include/net/cfg80211.h +1 -1
index 5fbfe61..3e123a3 100644
@@ -4139,7 +4139,7 @@ static inline struct wiphy *wiphy_new(const 
 struct cfg80211_ops *ops,
 struct cfg80211_conn;
 struct cfg80211_internal_bss;
 struct cfg80211_cached_keys;
-struct cfg80211_cqm_config;
+struct cfg80211_rssi_config;

I think something like rssi_mon_config would be better? Just _rssi_ could be interpreted in many ways.

Okay sure

Quoted 8 lines

include/net/cfg80211.h struct wireless_dev { · line 4280

Quoted 3 lines
include/net/cfg80211.h +2 -1
-	struct cfg80211_cqm_config *cqm_config;
+	struct cfg80211_rssi_config *rssi_config;
+	struct list_head rssi_config_list;

Why do you need both now? Perhaps instead you should allow a NULL/all- ones MAC address for where you have the direct pointer now, and remove that? You anyway need to pass something to the peer argument in

In the current cqm/sta_mon implementation the range_config will be updated before notify event posted to userspace.
To update the range config for a specific station we need to have this peer addr based configuration list which holds the thresholds info
to choose the next rssi range.
Or do you want me to handle and store the rssi_config structure in mac80211 and update it in mac80211 itself ? And simply pass the notification event to userspace application ?

Quoted 27 lines
Quoted 3 lines
include/net/cfg80211.h +1 -1
-void cfg80211_cqm_config_free(struct wireless_dev *wdev)
+void cfg80211_rssi_config_free(struct wireless_dev *wdev, const u8 

*peer)

even when the pointer is used.

Quoted 7 lines
include/net/cfg80211.h +5 -2
-	kfree(wdev->cqm_config);
-	wdev->cqm_config = NULL;
+	struct cfg80211_rssi_config *rssi_config, *tmp;
+
+	if (list_empty(&wdev->rssi_config_list))
+		goto free;
+

include/net/cfg80211.h

Quoted 10 lines
include/net/cfg80211.h +10 -0
+	list_for_each_entry_safe(rssi_config, tmp, &wdev->rssi_config_list,
+				 list) {
+		if (peer && memcmp(rssi_config->addr, peer, ETH_ALEN))
+			continue;
+
+		list_del(&rssi_config->list);
+		kfree(rssi_config);
+		if (list_empty(&wdev->rssi_config_list) || peer)
+			goto out;
+	}

That logic could use some comments if we even decide to keep it this way.

Quoted 2 lines

NULL means "free all"?

Yes.

Quoted 3 lines

What's the locking scheme for this? It's way more complex now so perhaps stick ASSERT_RTNL() in there or so?

Isn't wdev_lock enough ?

Quoted 4 lines
Quoted 4 lines
include/net/cfg80211.h +0 -0
@@ -10140,7 +10141,7 @@ static int cfg80211_cqm_rssi_update(struct 
 cfg80211_registered_device *rdev,
 	int err;
 
Quoted 11 lines

include/net/cfg80211.h static int cfg80211_cqm_rssi_update(struct · line 10146

Quoted 4 lines
include/net/cfg80211.h +1 -1
 	/* RSSI reporting disabled? */
-	if (!wdev->cqm_config)
+	if (!wdev->rssi_config)
 		return rdev_set_cqm_rssi_range_config(rdev, dev, 0, 0);

So I guess the wdev->rssi_config is used for the case of "always use this config for any AP you're connected to" or so - but maybe it'd be better to track the AP as a station? Then again, I guess we can't force userspace to change that.

Sorry I didn't get your point:( I didn't change anything in the station mode. Functionality remains same for the station mode.

Quoted 16 lines
Quoted 16 lines
include/net/cfg80211.h +2 -0
+static struct cfg80211_rssi_config *
+cfg80211_get_rssi_config(struct wireless_dev *wdev, const s32 

*thresholds,

include/net/cfg80211.h +13 -0
+			 int n_thresholds, u32 hysteresis, const u8 *peer)
+{
+	struct cfg80211_rssi_config *rssi_config;
+
+	if (!peer)
+		return NULL;
+
+	if (list_empty(&wdev->rssi_config_list))
+		goto new;
+
+	list_for_each_entry(rssi_config, &wdev->rssi_config_list, list) {
+		if (!memcmp(rssi_config->addr, peer, ETH_ALEN))
+			goto found;
Quoted 9 lines

include/net/cfg80211.h

Quoted 6 lines
include/net/cfg80211.h +6 -0
+	}
+
+new:
+	rssi_config = kzalloc(sizeof(struct cfg80211_rssi_config) +
+			      n_thresholds * sizeof(s32), GFP_KERNEL);
+	list_add(&rssi_config->list, &wdev->rssi_config_list);

Why does "get" always imply "create"?

I'll rename the function.

Quoted 6 lines
Quoted 6 lines
include/net/cfg80211.h +0 -4
 	wdev_lock(wdev);
 	if (n_thresholds) {
-		struct cfg80211_cqm_config *cqm_config;
-
-		cqm_config = kzalloc(sizeof(struct cfg80211_cqm_config) +
-				     n_thresholds * sizeof(s32), GFP_KERNEL);
Quoted 9 lines

include/net/cfg80211.h

Quoted 5 lines
include/net/cfg80211.h +4 -1
-		if (!cqm_config) {
+		wdev->rssi_config = cfg80211_get_rssi_config(
+						wdev, thresholds,
+						n_thresholds, hysteresis,
+						wdev->current_bss->pub.bssid);

Here you link it to the BSSID anyway, but do we always have a current_bss at this point?

Oops! I didn't think about that condition. I'll fix that in the next version.

#26 lore raw

Re: [PATCH 6/7] cfg80211: Accept multiple RSSI threholds for STA_MON command

In reply to Johannes Berg
Quoted 8 lines · Johannes Berg
Quoted 1 line · Tamizh chelvam

Change the NL80211_CMD_STA_MON RSSI threshold attribut to

This seems weird - you just introduced it a few patches back, and now you change it and even worry about compatibility and have both cfg80211 callbacks etc. Just remove set_sta_mon_rssi_config() and ask that drivers/mac80211 implement set_sta_mon_rssi_range_config?

First I've done patch to have single threshold value for AP mode and as per the previous discussion extended to multiple thresholds also. Here the intention is to accept one or more than one RSSI thresholds to monitor. Any thought ?

Quoted 9 lines
Quoted 8 lines

* @NL80211_EXT_FEATURE_STA_MON_RSSI_CONFIG: With this driver can set
* rssi threshold using %NL80211_ATTR_STA_MON_RSSI_THOLD attribute
* for a connected station.
+ * @NL80211_EXT_FEATURE_STA_MON_RSSI_LIST: With this driver the
+ * %NL80211_ATTR_STA_MON_RSSI_THOLD attribute accepts a list of zero
or
+ * more RSSI threshold values to monitor rather than exactly one
threshold.

Quoted 6 lines

And maybe not have two bits here either?

Or do you expect somebody to actually really need the single threshold in the near future? It seems you're implementing it for mac80211 only, which doesn't care.

Thanks,
Tamizh.

maintainer
#27 lore raw

Re: [PATCH 6/7] cfg80211: Accept multiple RSSI threholds for STA_MON command

Quoted 4 lines · Tamizh chelvam

First I've done patch to have single threshold value for AP mode and as per the previous discussion extended to multiple thresholds also. Here the intention is to accept one or more than one RSSI thresholds to monitor. Any thought ?

Is there any point in even offering the API for a single one though? I mean - we only implement it in mac80211 now, and there we clearly implement multiple, so single would never be used.

Quoted 2 lines · Like I
Quoted 2 lines

Or do you expect somebody to actually really need the single threshold in the near future?

johannes

maintainer
#19 lore raw

Re: [PATCH 4/7] cfg80211: Add support to notify station's rssi level crossing

In reply to Tamizh chelvam
Quoted 14 lines · Tamizh chelvam
Quoted 5 lines
Quoted 5 lines
include/uapi/linux/nl80211.h +0 -0
@@ -1249,6 +1249,7 @@ enum nl80211_commands {
 	NL80211_CMD_CONTROL_PORT_FRAME,
 
Quoted 8 lines

include/uapi/linux/nl80211.h enum nl80211_commands { · line 1252

Quoted 2 lines
include/uapi/linux/nl80211.h +1 -0
 	NL80211_CMD_SET_STA_MON,
+	NL80211_CMD_NOTIFY_STA_MON,

Missing documentation - but again, why not unify it with the existing event? Or can't we because that might confuse older applications? Perhaps anyway we should unicast these notifications? Not sure though, perhaps one app could set them up and the other might care?

Quoted 5 lines

This new command introduced as per the previous discussion
https://patchwork.kernel.org/patch/10168685/
https://patchwork.kernel.org/patch/10240697/

Is my understanding correct ?

I guess you're right. To my defense, this was like almost half a year ago :)

Quoted 2 lines

I just referred this code from cfg80211_prepare_cqm. Do you want me to change this to struct based?

Please, I guess we can fix up cqm too later.

johannes

maintainer
#10 lore raw

Re: [PATCH 2/7] cfg80211: Add new NL command to configure peer specific rssi threshold

In reply to Tamizh chelvam
Quoted 7 lines · Tamizh chelvam
Quoted 6 lines · Johannes Berg
Quoted 4 lines · Tamizh chelvam

+ * @NL80211_ATTR_STA_MON: Station's connection monitor configuration in a
+ * nested attribute with %NL80211_ATTR_STA_MON_* sub-attributes.

Quoted 5 lines
Quoted 1 line

Can't we reuse the existing attributes in this nesting?

This new attributes introduced as per the previous discussion.
https://patchwork.kernel.org/patch/10240697/
Is my understanding correct ?

Yeah ok ... I'm thinking perhaps we could share some part of it, but it's not really worth making it more complex due to that.

Quoted 5 lines
Quoted 3 lines

Wait, you went to all this effort in the first patch and now you don't add this to the list?

No, the list and the rssi_config structure is for multi threshold value and not for single threshold.

Yeah, though I'm still not sure why we need the single threshold thing at all. List should always be a superset.

johannes

maintainer
#4 lore raw

Re: [PATCH 1/7] wireless: Change single cqm_config to rssi config list

In reply to Tamizh chelvam
Quoted 9 lines · Tamizh chelvam
Quoted 8 lines

include/net/cfg80211.h struct wireless_dev { · line 4280

Quoted 3 lines
include/net/cfg80211.h +2 -1
-	struct cfg80211_cqm_config *cqm_config;
+	struct cfg80211_rssi_config *rssi_config;
+	struct list_head rssi_config_list;

Why do you need both now? Perhaps instead you should allow a NULL/all- ones MAC address for where you have the direct pointer now, and remove that? You anyway need to pass something to the peer argument in

Quoted 8 lines

In the current cqm/sta_mon implementation the range_config will be updated before notify event posted to userspace.
To update the range config for a specific station we need to have this peer addr based configuration list which holds the thresholds info to choose the next rssi range.
Or do you want me to handle and store the rssi_config structure in mac80211 and update it in mac80211 itself ? And simply pass the notification event to userspace application ?

I don't have any issues with storing it in mac80211 - could attach it to the station entry there?

Come to think of it, that might also clarify the lifetime rules. As it is now, what if the station is removed? What are the lifetime rules for a per-station configuration?

It would almost look like it stays here (or maybe I missed when you remove it from the list when a station is removed), but that doesn't seem like a good idea.

Please document the lifetime rules also in the API, and make sure you implement them properly.

Quoted 5 lines
Quoted 3 lines

What's the locking scheme for this? It's way more complex now so perhaps stick ASSERT_RTNL() in there or so?

Isn't wdev_lock enough ?

I guess it should be :-) Maybe assert on that, also to document the locking rules.

Quoted 11 lines
Quoted 10 lines

net/wireless/nl80211.c static int cfg80211_cqm_rssi_update(struct cfg80211_registered_device *rdev, · line 10145

Quoted 4 lines
net/wireless/nl80211.c +1 -1
 	/* RSSI reporting disabled? */
-	if (!wdev->cqm_config)
+	if (!wdev->rssi_config)
 		return rdev_set_cqm_rssi_range_config(rdev, dev, 0, 0);

So I guess the wdev->rssi_config is used for the case of "always use this config for any AP you're connected to" or so - but maybe it'd be better to track the AP as a station? Then again, I guess we can't force userspace to change that.

Quoted 2 lines

Sorry I didn't get your point:( I didn't change anything in the station mode. Functionality remains same for the station mode.

Right, that sort of goes back to my thoughts about lifetime rules too. The rule for stations would be to have it deleted when the station is deleted, but I guess the rule for client-mode is to keep the config active even when roaming?

I was just thinking that you don't need to *store* it like that, you could still - in client mode - store the configuration treating the AP as a (peer) station, perhaps with an ff:ff:ff:ff:ff:ff MAC address or something (instead of using the BSSID, to get lifetime rules adjusted right).

But now that I'm thinking about how the lifetime rules differ ... that's probably not worth it.

Quoted 16 lines
Quoted 6 lines
Quoted 6 lines
net/wireless/nl80211.c +0 -4
 	wdev_lock(wdev);
 	if (n_thresholds) {
-		struct cfg80211_cqm_config *cqm_config;
-
-		cqm_config = kzalloc(sizeof(struct cfg80211_cqm_config) +
-				     n_thresholds * sizeof(s32), GFP_KERNEL);
Quoted 9 lines

net/wireless/nl80211.c static int nl80211_set_cqm_rssi(struct genl_info *info, · line 10261

Quoted 5 lines
net/wireless/nl80211.c +4 -1
-		if (!cqm_config) {
+		wdev->rssi_config = cfg80211_get_rssi_config(
+						wdev, thresholds,
+						n_thresholds, hysteresis,
+						wdev->current_bss->pub.bssid);

Here you link it to the BSSID anyway, but do we always have a current_bss at this point?

Quoted 2 lines

Oops! I didn't think about that condition. I'll fix that in the next version.

Again though - see above. I'm not sure it's even correct to link it to the BSSID since until now, I think the configuration would remain across roaming?

johannes

#20 lore raw

Re: [PATCH 4/7] cfg80211: Add support to notify station's rssi level crossing

In reply to Johannes Berg
Quoted 16 lines · Johannes Berg
Quoted 14 lines · Tamizh chelvam
Quoted 13 lines

include/uapi/linux/nl80211.h enum nl80211_commands { · line 1252

Quoted 7 lines
include/uapi/linux/nl80211.h +1 -0
@@ -1249,6 +1249,7 @@ enum nl80211_commands {
 	NL80211_CMD_CONTROL_PORT_FRAME,
 
 	NL80211_CMD_SET_STA_MON,
+	NL80211_CMD_NOTIFY_STA_MON,

Missing documentation - but again, why not unify it with the existing event? Or can't we because that might confuse older applications? Perhaps anyway we should unicast these notifications? Not sure though, perhaps one app could set them up and the other might care?

Quoted 8 lines
Quoted 5 lines

This new command introduced as per the previous discussion
https://patchwork.kernel.org/patch/10168685/
https://patchwork.kernel.org/patch/10240697/

Is my understanding correct ?

I guess you're right. To my defense, this was like almost half a year ago :)

Yeah;)

Quoted 6 lines
Quoted 3 lines

I just referred this code from cfg80211_prepare_cqm. Do you want me to change this to struct based?

Please, I guess we can fix up cqm too later.

Sure, I'll fix it in the next version.

Thanks,
Tamizh.

#5 lore raw

Re: [PATCH 1/7] wireless: Change single cqm_config to rssi config list

In reply to Johannes Berg
Quoted 20 lines · Johannes Berg
Quoted 9 lines · Tamizh chelvam
Quoted 8 lines

include/net/cfg80211.h struct wireless_dev { · line 4280

Quoted 3 lines
include/net/cfg80211.h +2 -1
-	struct cfg80211_cqm_config *cqm_config;
+	struct cfg80211_rssi_config *rssi_config;
+	struct list_head rssi_config_list;

Why do you need both now? Perhaps instead you should allow a NULL/all- ones MAC address for where you have the direct pointer now, and remove that? You anyway need to pass something to the peer argument in

Quoted 8 lines

In the current cqm/sta_mon implementation the range_config will be updated before notify event posted to userspace.
To update the range config for a specific station we need to have this peer addr based configuration list which holds the thresholds info to choose the next rssi range.
Or do you want me to handle and store the rssi_config structure in mac80211 and update it in mac80211 itself ? And simply pass the notification event to userspace application ?

Quoted 2 lines

I don't have any issues with storing it in mac80211 - could attach it to the station entry there?

yes.

Quoted 4 lines

Come to think of it, that might also clarify the lifetime rules. As it is now, what if the station is removed? What are the lifetime rules for a per-station configuration?

If we go with mac80211 based approach then the lifetime of the configuration would be for the current connection.

Quoted 7 lines

It would almost look like it stays here (or maybe I missed when you remove it from the list when a station is removed), but that doesn't seem like a good idea.

Please document the lifetime rules also in the API, and make sure you implement them properly.

In AP mode, the lifetime would be for the station's current connection. It will be removed in case of roaming/disconnected.

Quoted 9 lines
Quoted 6 lines
Quoted 4 lines

What's the locking scheme for this? It's way more complex now so perhaps stick ASSERT_RTNL() in there or so?

Isn't wdev_lock enough ?

I guess it should be :-) Maybe assert on that, also to document the locking rules.

Sure

Quoted 20 lines
Quoted 12 lines
Quoted 11 lines

net/wireless/nl80211.c static int cfg80211_cqm_rssi_update(struct cfg80211_registered_device *rdev, · line 10145

Quoted 5 lines
net/wireless/nl80211.c +1 -1
 	/* RSSI reporting disabled? */
-	if (!wdev->cqm_config)
+	if (!wdev->rssi_config)
 		return rdev_set_cqm_rssi_range_config(rdev, dev, 0, 0);

So I guess the wdev->rssi_config is used for the case of "always use this config for any AP you're connected to" or so - but maybe it'd be better to track the AP as a station? Then again, I guess we can't force userspace to change that.

Quoted 2 lines

Sorry I didn't get your point:( I didn't change anything in the station mode. Functionality remains same for the station mode.

Right, that sort of goes back to my thoughts about lifetime rules too. The rule for stations would be to have it deleted when the station is deleted, but I guess the rule for client-mode is to keep the config active even when roaming?

Quoted 6 lines

I was just thinking that you don't need to *store* it like that, you could still - in client mode - store the configuration treating the AP as a (peer) station, perhaps with an ff:ff:ff:ff:ff:ff MAC address or something (instead of using the BSSID, to get lifetime rules adjusted right).

Going with mac80211 based storing configuration will remove these list implementation in the cfg80211. So, there won't be any MAC address stored for client-mode in cqm_config structure.

Quoted 19 lines

But now that I'm thinking about how the lifetime rules differ ... that's probably not worth it.

Quoted 16 lines
Quoted 15 lines

net/wireless/nl80211.c static int nl80211_set_cqm_rssi(struct genl_info *info, · line 10261

Quoted 11 lines
net/wireless/nl80211.c +4 -5
 	wdev_lock(wdev);
 	if (n_thresholds) {
-		struct cfg80211_cqm_config *cqm_config;
-
-		cqm_config = kzalloc(sizeof(struct cfg80211_cqm_config) +
-				     n_thresholds * sizeof(s32), GFP_KERNEL);
-		if (!cqm_config) {
+		wdev->rssi_config = cfg80211_get_rssi_config(
+						wdev, thresholds,
+						n_thresholds, hysteresis,
+						wdev->current_bss->pub.bssid);

Here you link it to the BSSID anyway, but do we always have a current_bss at this point?

Quoted 7 lines
Quoted 2 lines

Oops! I didn't think about that condition. I'll fix that in the next version.

Again though - see above. I'm not sure it's even correct to link it to the BSSID since until now, I think the configuration would remain across roaming?

As mentioned above storing configuration parameters in mac80211 will avoid this list implementation here. So, no need of worrying about those roaming scenario know ?

Thanks,
Tamizh.

#11 lore raw

Re: [PATCH 2/7] cfg80211: Add new NL command to configure peer specific rssi threshold

In reply to Johannes Berg
Quoted 8 lines · Johannes Berg
Quoted 7 lines · Tamizh chelvam
Quoted 6 lines · Johannes Berg
Quoted 4 lines · Tamizh chelvam

+ * @NL80211_ATTR_STA_MON: Station's connection monitor configuration in a
+ * nested attribute with %NL80211_ATTR_STA_MON_* sub-attributes.

Quoted 9 lines
Quoted 5 lines
Quoted 1 line

Can't we reuse the existing attributes in this nesting?

This new attributes introduced as per the previous discussion.
https://patchwork.kernel.org/patch/10240697/
Is my understanding correct ?

Yeah ok ... I'm thinking perhaps we could share some part of it, but it's not really worth making it more complex due to that.

Sure, i'll reuse those cqm attributes and event notification enum as well.

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

Wait, you went to all this effort in the first patch and now you don't add this to the list?

No, the list and the rssi_config structure is for multi threshold value and not for single threshold.

Yeah, though I'm still not sure why we need the single threshold thing at all.

For taking steering kind of decision single threshold value can be used to monitor the station's rssi.

Quoted 2 lines

List should always be a superset.

I believe superset you meant will accept a signle threshold configuration also from user ? If so, we can remove the single threshold api implementation.

Thanks,
Tamizh.

maintainer
#12 lore raw

Re: [PATCH 2/7] cfg80211: Add new NL command to configure peer specific rssi threshold

Quoted 2 lines · Tamizh chelvam

I believe superset you meant will accept a signle threshold configuration also from user ?

Yes.

Quoted 1 line

If so, we can remove the single threshold api implementation.

I think here we can remove the single threshold API - we have it in the old only because some drivers still implement only a single threshold (AFAICT), but for a new API I think we can reasonably require multiple to be implemented.

johannes

maintainer
#6 lore raw

Re: [PATCH 1/7] wireless: Change single cqm_config to rssi config list

In reply to Tamizh chelvam
Quoted 10 lines · Tamizh chelvam
Quoted 6 lines

Again though - see above. I'm not sure it's even correct to link it to the BSSID since until now, I think the configuration would remain across
roaming?

As mentioned above storing configuration parameters in mac80211 will avoid this list implementation here.
So, no need of worrying about those roaming scenario know ?

I think we should tie it to the station lifetime and have it reconfigured on roaming etc., and if that means it's easier by storing in mac80211 I have no objection.

johannes