cfg80211/mac80211: Add support to configure and monitor station's rssi threshold
Subsystems (2)
cover cfg80211/mac80211: Add support to configure and monitor station's rssi threshold
This patchsets introduced new NL command and api to support configuring rssi threshold 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 signal strength change information. Monitoring station's signal strength through station dump command will unnecessarily increase the system overhead. This event based mechanism will reduce the system overhead and helps application to take a decision for the station for which event received.
Tamizh chelvam (3):
cfg80211: Add support to configure station specific RSSI threshold
for AP mode
mac80211: Implement API to configure station specific rssi threshold
mac80211: Implement functionality to monitor station's signal
stregnth
include/net/cfg80211.h | 28 +++++++++ include/net/mac80211.h | 7 +++ include/uapi/linux/nl80211.h | 18 ++++++ net/mac80211/cfg.c | 91 +++++++++++++++++++++++++++++ net/mac80211/rx.c | 51 +++++++++++++++- net/mac80211/sta_info.c | 1 + net/mac80211/sta_info.h | 24 ++++++++ net/wireless/nl80211.c | 131 +++++++++++++++++++++++++++++++++++++----- net/wireless/rdev-ops.h | 18 ++++++ 9 files changed, 354 insertions(+), 15 deletions(-)
Signature · 1 line
1.7.9.5
PATCH 1/3 cfg80211: Add support to configure station specific RSSI threshold for AP mode
Add infrastructure to configure station specific RSSI threshold configuration to monitor station's signal strength variation. This configuration will be useful for the application like steering which requires change in the station's current signal strength.
New NL80211_CMD_SET_STA_MON introduced to configure the RSSI threshold using NL80211_ATTR_CQM nested attributes. The MAC address of
a station is passed in NL80211_ATTR_MAC. And NL80211_ATTR_STA_MON_FIXED_THOLD introduced to have this RSSI threshold as a fixed limit or moving range thresholds. Depends on the application's use case user can have either fixed or moving RSSI range thresholds.
cfg80211_sta_mon_rssi_notify introduced to notify change in the station's signal stregnth cross event using NL80211_CMD_NOTIFY_STA_MON. Driver supporting this feature should advertise NL80211_EXT_FEATURE_STA_MON_RSSI_CONFIG feature flag.
--- include/net/cfg80211.h | 28 +++++++++ include/uapi/linux/nl80211.h | 18 ++++++ net/wireless/nl80211.c | 131 +++++++++++++++++++++++++++++++++++++----- net/wireless/rdev-ops.h | 18 ++++++ 4 files changed, 181 insertions(+), 14 deletions(-)
include/net/cfg80211.h +28 -0
@@ -3183,6 +3183,12 @@ struct cfg80211_ftm_responder_stats {* * @get_ftm_responder_stats: Retrieve FTM responder statistics, if available. * Statistics should be cumulative, currently no way to reset is provided. +* +* @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);
@@ -3492,6 +3498,12 @@ struct cfg80211_ops {int (*get_ftm_responder_stats)(struct wiphy *wiphy,struct net_device *dev,struct cfg80211_ftm_responder_stats *ftm_stats); +int (*set_sta_mon_rssi_config)(struct wiphy *wiphy, +struct net_device *dev, +const u8 *addr, +const s32 *rssi_tholds, +u32 rssi_hyst,int rssi_n_tholds, +bool fixed_thold); };/*
@@ -6024,6 +6036,22 @@ bool cfg80211_rx_control_port(struct net_device *dev, struct sk_buff *skb, bool unencrypted);/** +* 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_cqm_rssi_threshold_event rssi_event, +s32 rssi_level,gfp_t gfp); + +/** * cfg80211_cqm_rssi_notify - connection quality monitoring rssi event * @dev: network device * @rssi_event: the triggered RSSI event
include/uapi/linux/nl80211.h +18 -0
@@ -1036,6 +1036,11 @@* @NL80211_CMD_GET_FTM_RESPONDER_STATS: Retrieve FTM responder statistics, in * the %NL80211_ATTR_FTM_RESPONDER_STATS attribute. * +* @NL80211_CMD_SET_STA_MON: This command is used to configure station's +* connection monitoring notification trigger levels. +* @NL80211_CMD_NOTIFY_STA_MON: This is used as an event to notify +* the user space that a trigger level was reached for a station. +* * @NL80211_CMD_MAX: highest used command number * @__NL80211_CMD_AFTER_LAST: internal use */
@@ -1250,6 +1255,9 @@ enum nl80211_commands {NL80211_CMD_GET_FTM_RESPONDER_STATS , +NL80211_CMD_SET_STA_MON , + NL80211_CMD_NOTIFY_STA_MON, +/* add new commands above here */ /* used to define NL80211_CMD_MAX below */
@@ -2254,6 +2262,10 @@ enum nl80211_commands {* @NL80211_ATTR_FTM_RESPONDER_STATS: Nested attribute with FTM responder * statistics, see &enum nl80211_ftm_responder_stats. * +* @NL80211_ATTR_STA_MON_FIXED_THOLD: Flag attribute is used with +* %NL80211_CMD_SET_STA_MON to indicate driver that the monitoring +* configuration is fixed limit or a moving range threshold. +* * @NUM_NL80211_ATTR: total number of nl80211_attrs available * @NL80211_ATTR_MAX: highest attribute number currently defined * @__NL80211_ATTR_AFTER_LAST: internal use
@@ -2699,6 +2711,8 @@ enum nl80211_attrs {NL80211_ATTR_FTM_RESPONDER_STATS , +NL80211_ATTR_STA_MON_FIXED_THOLD , +/* add attributes here, update the policy in nl80211.c */ __NL80211_ATTR_AFTER_LAST,
@@ -5258,6 +5272,9 @@ enum nl80211_feature_flags {* if this flag is not set. Ignoring this can leak clear text packets and/or * freeze the connection. * +* @NL80211_EXT_FEATURE_STA_MON_RSSI_CONFIG: Driver supports monitoring +* station's RSSI threshold value should adveritise this flag. +* * @NUM_NL80211_EXT_FEATURES: number of extended features. * @MAX_NL80211_EXT_FEATURES: highest extended feature index. */
@@ -5297,6 +5314,7 @@ enum nl80211_ext_feature_index {NL80211_EXT_FEATURE_SCAN_MIN_PREQ_CONTENT ,NL80211_EXT_FEATURE_CAN_REPLACE_PTK0 ,NL80211_EXT_FEATURE_ENABLE_FTM_RESPONDER , +NL80211_EXT_FEATURE_STA_MON_RSSI_CONFIG ,/* add new features before the definition below */ NUM_NL80211_EXT_FEATURES,
net/wireless/nl80211.c +117 -14
206 lines not on this page · raw message
net/wireless/rdev-ops.h +18 -0
@@ -1247,4 +1247,22 @@ 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 *addr, +const s32 *rssi_tholds,u32 rssi_hyst, +int n_rssi_tholds,bool fixed_thold) +{ +int ret = -EOPNOTSUPP ; + +if (rdev->ops->set_sta_mon_rssi_config) + ret = rdev->ops->set_sta_mon_rssi_config (&rdev->wiphy, dev, + addr, rssi_tholds, + rssi_hyst, + n_rssi_tholds, + fixed_thold); +trace_rdev_return_int (&rdev->wiphy, ret); +return ret; +} +#endif /* __CFG80211_RDEV_OPS */
Signature · 1 line
1.7.9.5
Re: [PATCH 1/3] cfg80211: Add support to configure station specific RSSI threshold for AP mode
Quoted 7 lines
Signed-off-by Tamizh chelvam <[email protected]>--- include/net/cfg80211.h | 28 +++++++++ include/uapi/linux/nl80211.h | 18 ++++++ net/wireless/nl80211.c | 131 +++++++++++++++++++++++++++++++++++++----- net/wireless/rdev-ops.h | 18 ++++++ 4 files changed, 181 insertions(+), 14 deletions(-)
...
Quoted 38 lines
net/wireless/nl80211.c +38
-0+static int nl80211_set_sta_mon (struct sk_buff *skb,struct genl_info *info) +{ +struct cfg80211_registered_device *rdev = info->user_ptr[0 ]; +struct net_device *dev = info->user_ptr[1 ]; +struct nlattr *attrs[NL80211_ATTR_CQM_MAX +1 ]; +bool fixed_thold = false; +struct nlattr *sta_mon; +u8 *addr =NULL ; +int err; + +if (!wiphy_ext_feature_isset (&rdev->wiphy, +NL80211_EXT_FEATURE_STA_MON_RSSI_CONFIG )) +return -EOPNOTSUPP ; + + sta_mon = info->attrs[NL80211_ATTR_CQM ]; +if (!sta_mon || !(info->attrs[NL80211_ATTR_MAC ])) +return -EINVAL ; + + err =nla_parse_nested (attrs,NL80211_ATTR_CQM_MAX , sta_mon, + nl80211_attr_cqm_policy, info->extack); +if (err) +return err; + + addr =nla_data (info->attrs[NL80211_ATTR_MAC ]); + fixed_thold = +nla_get_flag (info->attrs[NL80211_ATTR_STA_MON_FIXED_THOLD ]); + +if (attrs[NL80211_ATTR_CQM_RSSI_THOLD ] && + attrs[NL80211_ATTR_CQM_RSSI_HYST ]) { +const s32 *thresholds = +nla_data (attrs[NL80211_ATTR_CQM_RSSI_THOLD ]); +int len =nla_len (attrs[NL80211_ATTR_CQM_RSSI_THOLD ]); +u32 hysteresis =nla_get_u32 (attrs[NL80211_ATTR_CQM_RSSI_HYST ]); + +if (len %4 ) +return -EINVAL ; + + err =nl80211_validate_rssi_tholds (thresholds, len /4 );
net/wireless/nl80211.c static int nl80211_get_ftm_responder_stats(struct sk_buff *skb, · line 13041
Quoted 10 lines
net/wireless/nl80211.c +10
-0+if (err) +return err; + +return rdev_set_sta_mon_rssi_config (rdev, dev, addr, thresholds, + hysteresis, len /4 , + fixed_thold); + } + +return -EINVAL ; +}
IIUC there is a noticeable overlap between this new command and existing nl80211_set_cqm_rssi command. Is there any reason why nl80211_set_cqm_rss can not be adapted for AP case ?
If there is a reason to handle AP case separately, then it looks like it makes sense to add explicit check for supported iftype in this new command. Besides, it looks like there is no generic way to handle disabling of RSSI monitoring in the new command. As a result, we may end up in multiple driver
specific implementations.
Regards,
Sergey
RE: [EXTERNAL] Re: [PATCH 1/3] cfg80211: Add support to configure station specific RSSI threshold for AP mode
Quoted 44 lines
Quoted 44 lines
net/wireless/nl80211.c +44
-0+static int nl80211_set_sta_mon (struct sk_buff *skb,struct genl_info +*info) { +struct cfg80211_registered_device *rdev = info->user_ptr[0 ]; +struct net_device *dev = info->user_ptr[1 ]; +struct nlattr *attrs[NL80211_ATTR_CQM_MAX +1 ]; +bool fixed_thold = false; +struct nlattr *sta_mon; +u8 *addr =NULL ; +int err; + +if (!wiphy_ext_feature_isset (&rdev->wiphy, +NL80211_EXT_FEATURE_STA_MON_RSSI_CONFIG )) +return -EOPNOTSUPP ; + + sta_mon = info->attrs[NL80211_ATTR_CQM ]; +if (!sta_mon || !(info->attrs[NL80211_ATTR_MAC ])) +return -EINVAL ; + + err =nla_parse_nested (attrs,NL80211_ATTR_CQM_MAX , sta_mon, + nl80211_attr_cqm_policy, info->extack); +if (err) +return err; + + addr =nla_data (info->attrs[NL80211_ATTR_MAC ]); + fixed_thold = + +nla_get_flag (info->attrs[NL80211_ATTR_STA_MON_FIXED_THOLD ]); + +if (attrs[NL80211_ATTR_CQM_RSSI_THOLD ] && + attrs[NL80211_ATTR_CQM_RSSI_HYST ]) { +const s32 *thresholds = +nla_data (attrs[NL80211_ATTR_CQM_RSSI_THOLD ]); +int len =nla_len (attrs[NL80211_ATTR_CQM_RSSI_THOLD ]); +u32 hysteresis = +nla_get_u32 (attrs[NL80211_ATTR_CQM_RSSI_HYST ]); + +if (len %4 ) +return -EINVAL ; + + err =nl80211_validate_rssi_tholds (thresholds, len /4 ); +if (err) +return err; + + return rdev_set_sta_mon_rssi_config(rdev, dev, addr, thresholds,
Quoted 8 lines
net/wireless/nl80211.c static int nl80211_get_ftm_responder_stats(struct sk_buff *skb, · line 13041
Quoted 6 lines
net/wireless/nl80211.c +6
-0+ hysteresis, len /4 , + fixed_thold); + } + +return -EINVAL ; +}IIUC there is a noticeable overlap between this new command and existing
nl80211_set_cqm_rssicommand. Is there any reason why >nl80211_set_cqm_rss can not be adapted for AP case ?
[Tamizh] This new command for AP mode introduced as per the previous discussion.
Quoted 2 lines
If there is a reason to handle AP case separately, then it looks like it makes sense to add explicit check for supported iftype in this new command. >Besides, it looks like there is no generic way to handle disabling of RSSI monitoring in the new command. As a result, we may end up in multiple driver specific implementations.
[Tamizh] thanks for pointing me out. I'll add the ifmode check in the next patchset version.
Thanks,
Tamizh.
Johannes Berg
maintainerRe: [PATCH 1/3] cfg80211: Add support to configure station specific RSSI threshold for AP mode
In reply to Tamizh chelvamHi,
Sorry for the delay in reviewing this.
include/net/cfg80211.h struct cfg80211_ops { · line 3507
Quoted 7 lines
include/net/cfg80211.h +6
-0+int (*set_sta_mon_rssi_config)(struct wiphy *wiphy, +struct net_device *dev, +const u8 *addr, +const s32 *rssi_tholds, +u32 rssi_hyst,int rssi_n_tholds, +bool fixed_thold); };
I think it might be better to pass all the last 4 arguments (rssi related ones) as a struct? That's a pattern we typically have elsewhere too, and it makes things easier to extend and also easier to pass around.
Quoted 4 lines
+ * @NL80211_CMD_SET_STA_MON: This command is used to configure station's
+ * connection monitoring notification trigger levels.
+ * @NL80211_CMD_NOTIFY_STA_MON: This is used as an event to notify
+ * the user space that a trigger level was reached for a station.
Please describe the attributes to use with this.
Quoted 3 lines
+ * @NL80211_ATTR_STA_MON_FIXED_THOLD: Flag attribute is used with
+ * %NL80211_CMD_SET_STA_MON to indicate driver that the monitoring
+ * configuration is fixed limit or a moving range threshold.
This isn't really clear to me, what does it mean?
net/wireless/nl80211.c static int nl80211_get_ftm_responder_stats(struct sk_buff *skb, · line 13009
Quoted 1 line
net/wireless/nl80211.c +1
-0+if (!sta_mon || !(info->attrs[NL80211_ATTR_MAC ]))
Don't really need the parentheses in !(info->...)
net/wireless/nl80211.c static int nl80211_get_ftm_responder_stats(struct sk_buff *skb, · line 13013
Quoted 2 lines
net/wireless/nl80211.c +2
-0+ err =nla_parse_nested (attrs,NL80211_ATTR_CQM_MAX , sta_mon, + nl80211_attr_cqm_policy, info->extack);
I *think* I made that a proper nested policy, check and then you can remove passing it here.
net/wireless/nl80211.c void cfg80211_cqm_rssi_notify(struct net_device *dev, · line 15268
Quoted 9 lines
net/wireless/nl80211.c +9
-0+void +cfg80211_sta_mon_rssi_notify (struct net_device *dev,const u8 *peer, +enum nl80211_cqm_rssi_threshold_event rssi_event, +s32 rssi_level,gfp_t gfp) +{ +struct sk_buff *msg; + +if (WARN_ON (!peer)) +return ;
Tracing for this might be nice too?
johannes
Re: [PATCH 1/3] cfg80211: Add support to configure station specific RSSI threshold for AP mode
Quoted 14 lines
include/net/cfg80211.h struct cfg80211_ops { · line 3507
Quoted 8 lines
include/net/cfg80211.h +6
-0+int (*set_sta_mon_rssi_config)(struct wiphy *wiphy, +struct net_device *dev, +const u8 *addr, +const s32 *rssi_tholds, +u32 rssi_hyst,int rssi_n_tholds, +bool fixed_thold); };I think it might be better to pass all the last 4 arguments (rssi related ones) as a struct? That's a pattern we typically have elsewhere too, and it makes things easier to extend and also easier to pass around.
Sure.
Quoted 8 lines
Quoted 5 lines
+ * @NL80211_CMD_SET_STA_MON: This command is used to configure station's
+ * connection monitoring notification trigger levels.
+ * @NL80211_CMD_NOTIFY_STA_MON: This is used as an event to notify
+ * the user space that a trigger level was reached for a station.Please describe the attributes to use with this.
I'll add that in the next version of patchset
Quoted 7 lines
Quoted 4 lines
+ * @NL80211_ATTR_STA_MON_FIXED_THOLD: Flag attribute is used with
+ * %NL80211_CMD_SET_STA_MON to indicate driver that the monitoring
+ * configuration is fixed limit or a moving range threshold.This isn't really clear to me, what does it mean?
Sorry for not clear. This flag introduced to mention the driver that if this flag set then don't change the rssi_low and rssi_high limit upon the station's rssi crossing the configured limit. Keep the rssi_low and rssi_high as a fixed limit.
Quoted 4 lines
net/wireless/nl80211.c static int nl80211_get_ftm_responder_stats(struct sk_buff *skb, · line 13009
Quoted 1 line
net/wireless/nl80211.c +1
-0+if (!sta_mon || !(info->attrs[NL80211_ATTR_MAC ]))Don't really need the parentheses in !(info->...)
Yes, I'll remove it.
Quoted 6 lines
net/wireless/nl80211.c static int nl80211_get_ftm_responder_stats(struct sk_buff *skb, · line 13013
Quoted 2 lines
net/wireless/nl80211.c +2
-0+ err =nla_parse_nested (attrs,NL80211_ATTR_CQM_MAX , sta_mon, + nl80211_attr_cqm_policy, info->extack);I *think* I made that a proper nested policy, check and then you can remove passing it here.
Sure. I'll modify it in the next patchset version.
Quoted 12 lines
net/wireless/nl80211.c void cfg80211_cqm_rssi_notify(struct net_device *dev, · line 15268
Quoted 9 lines
net/wireless/nl80211.c +9
-0+void +cfg80211_sta_mon_rssi_notify (struct net_device *dev,const u8 *peer, +enum nl80211_cqm_rssi_threshold_event rssi_event, +s32 rssi_level,gfp_t gfp) +{ +struct sk_buff *msg; + +if (WARN_ON (!peer)) +return ;Tracing for this might be nice too?
Sure.
Thanks,
Tamizh.
PATCH 2/3 mac80211: Implement API to configure station specific rssi threshold
In reply to Tamizh chelvamImplement set_sta_mon_rssi_config API to configure station specific rssi threshold value to monitor change in connected station's signal strength.
--- net/mac80211/cfg.c | 91 +++++++++++++++++++++++++++++++++++++++++++++++ net/mac80211/sta_info.c | 1 + net/mac80211/sta_info.h | 19 ++++++++++ 3 files changed, 111 insertions(+)
net/mac80211/cfg.c +91 -0
@@ -3849,6 +3849,96 @@ static int ieee80211_get_txq_stats(struct wiphy *wiphy,return drv_get_ftm_responder_stats (local, sdata, ftm_stats); } +void sta_mon_rssi_config_free (struct sta_info *sta) +{ +kfree (sta->rssi_tholds); + sta->rssi_tholds =NULL ; + sta->n_rssi_tholds =0 ; +} + +static void ieee80211_update_rssi_config (struct sta_info *sta) +{ +s32 last; +u32 hyst; +int i, n; + +if (!sta->n_rssi_tholds) +return ; + +if (!sta->last_rssi_event_value) + sta->last_rssi_event_value = + -ewma_signal_read (&sta->rx_stats_avg.signal); + + last = sta->last_rssi_event_value; + hyst = sta->rssi_hyst; + n = sta->n_rssi_tholds; + +for (i =0 ; i < n; i++) +if (last < sta->rssi_tholds[i]) +break ; + + sta->rssi_low = i >0 ? (sta->rssi_tholds[i -1 ] - hyst) :S32_MIN ; + sta->rssi_high = i < n ? (sta->rssi_tholds[i] + hyst -1 ) :S32_MAX ; +} + +static int ieee80211_set_sta_mon_rssi_config (struct wiphy *wiphy, +struct net_device *dev, +const u8 *mac_addr, +const s32 *rssi_tholds, +u32 rssi_hyst,int n_rssi_tholds, +bool fixed_thold) +{ +struct ieee80211_sub_if_data *sdata =IEEE80211_DEV_TO_SUB_IF (dev); +struct ieee80211_local *local = sdata->local; +struct sta_info *sta; +int ret =0 ; + +mutex_lock (&local->sta_mtx); + +if (mac_addr) { + sta =sta_info_get_bss (sdata, mac_addr); +if (!sta) { + ret = -ENOENT ; + goto out; + } + +sta_mon_rssi_config_free (sta); + sta->rssi_hyst = rssi_hyst; +if (fixed_thold) { +if (n_rssi_tholds >2 ) { + ret = -EINVAL ; + goto out; + } + +if (n_rssi_tholds ==1 ) { + sta->rssi_low = rssi_tholds[0 ]; + sta->rssi_high = rssi_tholds[0 ]; + }else { + sta->rssi_low = rssi_tholds[0 ]; + sta->rssi_high = rssi_tholds[1 ]; + } + }else { +const s32 *rssi_tholds; + + rssi_tholds =kmemdup (rssi_tholds, + n_rssi_tholds *sizeof (s32), +GFP_KERNEL ); +if (!rssi_tholds) { + ret = -ENOMEM ; + goto out; + } + + sta->rssi_tholds = rssi_tholds; + sta->n_rssi_tholds = n_rssi_tholds; +ieee80211_update_rssi_config (sta); + } + } + +out: +mutex_unlock (&local->sta_mtx); +return ret; +} +const struct cfg80211_ops mac80211_config_ops = { .add_virtual_intf = ieee80211_add_iface, .del_virtual_intf = ieee80211_del_iface,
@@ -3944,4 +4034,5 @@ static int ieee80211_get_txq_stats(struct wiphy *wiphy, .tx_control_port = ieee80211_tx_control_port, .get_txq_stats = ieee80211_get_txq_stats, .get_ftm_responder_stats = ieee80211_get_ftm_responder_stats, + .set_sta_mon_rssi_config = ieee80211_set_sta_mon_rssi_config, };
net/mac80211/sta_info.c +1 -0
@@ -1020,6 +1020,7 @@ static void __sta_info_destroy_part2(struct sta_info *sta)rate_control_remove_sta_debugfs (sta);ieee80211_sta_debugfs_remove (sta); +sta_mon_rssi_config_free (sta);cleanup_single_sta (sta); }
net/mac80211/sta_info.h +19 -0
@@ -411,6 +411,9 @@ struct ieee80211_sta_rx_stats {u64 msdu[IEEE80211_NUM_TIDS +1 ]; }; +struct sta_mon_rssi_config { +}; +/* * The bandwidth threshold below which the per-station CoDel parameters will be * scaled to be more lenient (to prevent starvation of slow stations). This
@@ -482,6 +485,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 +* @n_rssi_tholds: Number of thresholds passed by user +* @rssi_tholds: RSSI threshold limit passed by the user +* @rssi_low: RSSI lower threshold for this station, a zero value implies +* disabled +* @rssi_high: RSSI upper threshold for this station +* @rssi_hyst: RSSI hysteresis for this station +* @last_rssi_event_value: Last RSSI value for this station triggered the +* RSSI cross event. */ struct sta_info {/* General information, mostly static */
@@ -583,6 +594,13 @@ struct sta_info {struct cfg80211_chan_def tdls_chandef; +int n_rssi_tholds; +const s32 *rssi_tholds; +s32 rssi_low; +s32 rssi_high; +u32 rssi_hyst; +s32 last_rssi_event_value; +/* keep last! */ struct ieee80211_sta sta; };
@@ -720,6 +738,7 @@ int sta_info_destroy_addr(struct ieee80211_sub_if_data *sdata, const u8 *addr);int sta_info_destroy_addr_bss (struct ieee80211_sub_if_data *sdata,const u8 *addr); +void sta_mon_rssi_config_free (struct sta_info *sta);void sta_info_recalc_tim (struct sta_info *sta);
Signature · 1 line
1.7.9.5
Johannes Berg
maintainerRe: [PATCH 2/3] mac80211: Implement API to configure station specific rssi threshold
net/mac80211/cfg.c static int ieee80211_get_txq_stats(struct wiphy *wiphy, · line 3911
Quoted 8 lines · Tamizh chelvam
net/mac80211/cfg.c +7
-0+sta_mon_rssi_config_free (sta); + sta->rssi_hyst = rssi_hyst; +if (fixed_thold) { +if (n_rssi_tholds >2 ) { + ret = -EINVAL ; + goto out; + }
This might be slightly wrong, you free and then can still return an error.
Quoted 7 lines
net/mac80211/cfg.c +7
-0+if (n_rssi_tholds ==1 ) { + sta->rssi_low = rssi_tholds[0 ]; + sta->rssi_high = rssi_tholds[0 ]; + }else { + sta->rssi_low = rssi_tholds[0 ]; + sta->rssi_high = rssi_tholds[1 ]; + }
net/mac80211/cfg.c static int ieee80211_get_txq_stats(struct wiphy *wiphy, · line 3929
Quoted 10 lines
net/mac80211/cfg.c +10
-0+ }else { +const s32 *rssi_tholds; + + rssi_tholds =kmemdup (rssi_tholds, + n_rssi_tholds *sizeof (s32), +GFP_KERNEL ); +if (!rssi_tholds) { + ret = -ENOMEM ; + goto out; + }
Similarly here, I guess you should do the allocation (and other error checking) before freeing.
Review
Quoted 8 lines
(quoted diff) +5
-0+ sta->rssi_tholds = rssi_tholds; + sta->n_rssi_tholds = n_rssi_tholds; + ieee80211_update_rssi_config(sta); +struct sta_mon_rssi_config { +};
Huh?
The commit log also makes it sounds like mac80211 actually *supports* this, but clearly that's not the case. However you don't give any data to the driver either, did you lose a patch along the way? Previously you had patch 5 ("mac80211: Implement functionality to monitor station's rssi cross event") and if I remember correctly I said you should squash some, but now that's not here?
johannes
Re: [PATCH 2/3] mac80211: Implement API to configure station specific rssi threshold
Quoted 13 lines · Johannes Berg
net/mac80211/cfg.c static int ieee80211_get_txq_stats(struct wiphy *wiphy, · line 3911
Quoted 8 lines · Tamizh chelvam
net/mac80211/cfg.c +7
-0+sta_mon_rssi_config_free (sta); + sta->rssi_hyst = rssi_hyst; +if (fixed_thold) { +if (n_rssi_tholds >2 ) { + ret = -EINVAL ; + goto out; + }This might be slightly wrong, you free and then can still return an error.
Sure. I'll move the free part after the validation check.
Quoted 12 lines
Quoted 12 lines
net/mac80211/cfg.c +12
-0+if (n_rssi_tholds ==1 ) { + sta->rssi_low = rssi_tholds[0 ]; + sta->rssi_high = rssi_tholds[0 ]; + }else { + sta->rssi_low = rssi_tholds[0 ]; + sta->rssi_high = rssi_tholds[1 ]; + } + }else { +const s32 *rssi_tholds; + + rssi_tholds = kmemdup(rssi_tholds, + n_rssi_tholds * sizeof(s32),
Quoted 9 lines
net/mac80211/cfg.c static int ieee80211_get_txq_stats(struct wiphy *wiphy, · line 3929
Quoted 5 lines
net/mac80211/cfg.c +5
-0+ GFP_KERNEL); +if (!rssi_tholds) { + ret = -ENOMEM ; + goto out; + }Similarly here, I guess you should do the allocation (and other error checking) before freeing.
ditto, Sure. I'll move the free part after the validation check.
Quoted 11 lines
Review
Quoted 8 lines
(quoted diff) +5
-0+ sta->rssi_tholds = rssi_tholds; + sta->n_rssi_tholds = n_rssi_tholds; + ieee80211_update_rssi_config(sta); +struct sta_mon_rssi_config { +};Huh?
oops:( I have kept all configuring parameters in sta_info itself, mistakenly didn't remove this struct:(
Quoted 8 lines
The commit log also makes it sounds like mac80211 actually *supports* this, but clearly that's not the case. However you don't give any data to the driver either, did you lose a patch along the way? Previously you had patch 5 ("mac80211: Implement functionality to monitor station's rssi cross event") and if I remember correctly I said you should squash some, but now that's not here?
Thanks,
Tamizh.
PATCH 3/3 mac80211: Implement functionality to monitor station's signal stregnth
In reply to Tamizh chelvamTriggers 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. And update the lower and upper RSSI threshold for the station if it is not configured as a fixed threshold.
This event will be useful for the application like steering to take decision on any station depends on its current link quality.
--- include/net/mac80211.h | 7 +++++++ net/mac80211/cfg.c | 2 +- net/mac80211/rx.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++- net/mac80211/sta_info.h | 5 +++++ 4 files changed, 63 insertions(+), 2 deletions(-)
include/net/mac80211.h +7 -0
@@ -849,6 +849,13 @@ enum mac80211_rate_control_flags { }; +/* +* 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/cfg.c +1 -1
@@ -3856,7 +3856,7 @@ void sta_mon_rssi_config_free(struct sta_info *sta) sta->n_rssi_tholds =0 ; } -static void ieee80211_update_rssi_config (struct sta_info *sta) +void ieee80211_update_rssi_config (struct sta_info *sta) {s32 last;u32 hyst;
net/mac80211/rx.c +50 -1
71 lines not on this page · raw message
net/mac80211/sta_info.h +5 -0
@@ -493,6 +493,9 @@ struct sta_mon_rssi_config {* @rssi_hyst: RSSI hysteresis for this station * @last_rssi_event_value: Last RSSI value for this station triggered the * RSSI cross event. +* @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 */
@@ -600,6 +603,7 @@ struct sta_info {s32 rssi_high;u32 rssi_hyst;s32 last_rssi_event_value; +unsigned int count_rx_signal;/* keep last! */ struct ieee80211_sta sta;
@@ -771,6 +775,7 @@ void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo,void ieee80211_sta_expire (struct ieee80211_sub_if_data *sdata,unsigned long exp_time);u8 sta_info_tx_streams (struct sta_info *sta); +void ieee80211_update_rssi_config (struct sta_info *sta);void ieee80211_sta_ps_deliver_wakeup (struct sta_info *sta);void ieee80211_sta_ps_deliver_poll_response (struct sta_info *sta);
Signature · 1 line
1.7.9.5
Re: [PATCH 3/3] mac80211: Implement functionality to monitor station's signal stregnth
Quoted 9 lines
include/net/mac80211.h +7
-0+/* +* 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 void ieee80211_sta_uapsd_trigger(struct ieee80211_sta *pubsta, u8 tid) · line 1696
Quoted 13 lines
net/mac80211/rx.c +13
-0+static void ieee80211_sta_rx_signal_thold_check (struct ieee80211_rx_data *rx) +{ +struct sta_info *sta = rx->sta; +struct ieee80211_bss_conf *bss_conf = &rx->sdata->vif.bss_conf; +bool rssi_cross = false; + +if (!wiphy_ext_feature_isset (rx->local->hw.wiphy, +NL80211_EXT_FEATURE_STA_MON_RSSI_CONFIG )) +return ; + + sta->count_rx_signal++; +if (sta->count_rx_signal <IEEE80211_STA_SIGNAL_AVE_MIN_COUNT ) +return ;
Could you please clarify count_rx_signal processing and averaging approach ? I couldn't find where this counter is reset or modified in any other way.
Regards,
Sergey
Johannes Berg
maintainerRe: [PATCH 3/3] mac80211: Implement functionality to monitor station's signal stregnth
In reply to Tamizh chelvamOh, umm, that patch is still here ...
I guess we can combine 2 and 3 too.
net/mac80211/rx.c void ieee80211_sta_uapsd_trigger(struct ieee80211_sta *pubsta, u8 tid) · line 1703
Quoted 6 lines
net/mac80211/rx.c +6
-0+if (sta->rssi_low && bss_conf->enable_beacon) { +int last_event = + sta->last_rssi_event_value; +int sig = -ewma_signal_read (&sta->rx_stats_avg.signal); +int low = sta->rssi_low; +int high = sta->rssi_high;
This doesn't really support a list, like in patch 2 where you store sta_info::rssi_tholds?
Quoted 14 lines
net/mac80211/rx.c +14
-0+if (sig < low && + (last_event ==0 || last_event >= low)) { + sta->last_rssi_event_value = sig; +cfg80211_sta_mon_rssi_notify ( + rx->sdata->dev, sta->addr, +NL80211_CQM_RSSI_THRESHOLD_EVENT_LOW , + sig,GFP_ATOMIC ); + rssi_cross = true; + }else if (sig > high && + (last_event ==0 || last_event <= high)) { + sta->last_rssi_event_value = sig; + cfg80211_sta_mon_rssi_notify( + rx->sdata->dev, sta->addr, + NL80211_CQM_RSSI_THRESHOLD_EVENT_HIGH,
net/mac80211/rx.c void ieee80211_sta_uapsd_trigger(struct ieee80211_sta *pubsta, u8 tid) · line 1728
Quoted 10 lines
net/mac80211/rx.c +10
-0+ sig, GFP_ATOMIC); + rssi_cross = true; + } + } + +if (rssi_cross) { +ieee80211_update_rssi_config (sta); + rssi_cross = false; + } +}
Ah, but it does, just hard to understand.
However, this does mean what I suspected on the other patch is true - you're calling ieee80211_update_rssi_config() here, and that uses the sta->rssi_tholds array without any protection, while a concurrent change of configuration can free the data.
You need to sort that out. I would suggest to stick all the sta->rssi_* fields you add into a new struct (you even had an empty one), and protect that struct using RCU. That also saves the memory in case it's not assigned at all. Something like
struct sta_mon_rssi_config {
struct rcu_head rcu_head;
int n_thresholds;
s32 low, high;
u32 hyst;
s32 last_value;
s32 thresholds[];
};then you can kfree_rcu() it, and just do a single allocation using struct_size() for however many entries you need.
net/mac80211/sta_info.h struct sta_info { · line 606
Quoted 11 lines
+ * @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.
*/
structsta_info{net/mac80211/sta_info.h +1
-0/* General information, mostly static */ @@ -600,6 +603,7 @@ struct sta_info {s32 rssi_high;u32 rssi_hyst;s32 last_rssi_event_value; +unsigned int count_rx_signal;
I guess that would also move into the new struct.
johannes
Re: [PATCH 3/3] mac80211: Implement functionality to monitor station's signal stregnth
Quoted 5 lines · Johannes Berg
Oh, umm, that patch is still here ...
I guess we can combine 2 and 3 too.
Sure.
Quoted 10 lines
net/mac80211/rx.c void ieee80211_sta_uapsd_trigger(struct ieee80211_sta *pubsta, u8 tid) · line 1703
Quoted 6 lines
net/mac80211/rx.c +6
-0+if (sta->rssi_low && bss_conf->enable_beacon) { +int last_event = + sta->last_rssi_event_value; +int sig = -ewma_signal_read (&sta->rx_stats_avg.signal); +int low = sta->rssi_low; +int high = sta->rssi_high;This doesn't really support a list, like in patch 2 where you store
sta_info::rssi_tholds?
rssi_low and rssi_high will have a configured value or zero know ? Configured value has been stored in the previous patch.
Quoted 27 lines
Quoted 14 lines
net/mac80211/rx.c +14
-0+if (sig < low && + (last_event ==0 || last_event >= low)) { + sta->last_rssi_event_value = sig; +cfg80211_sta_mon_rssi_notify ( + rx->sdata->dev, sta->addr, +NL80211_CQM_RSSI_THRESHOLD_EVENT_LOW , + sig,GFP_ATOMIC ); + rssi_cross = true; + }else if (sig > high && + (last_event ==0 || last_event <= high)) { + sta->last_rssi_event_value = sig; + cfg80211_sta_mon_rssi_notify( + rx->sdata->dev, sta->addr, + NL80211_CQM_RSSI_THRESHOLD_EVENT_HIGH,net/mac80211/rx.c void ieee80211_sta_uapsd_trigger(struct ieee80211_sta *pubsta, u8 tid) · line 1728
Quoted 10 lines
net/mac80211/rx.c +10
-0+ sig, GFP_ATOMIC); + rssi_cross = true; + } + } + +if (rssi_cross) { +ieee80211_update_rssi_config (sta); + rssi_cross = false; + } +}Ah, but it does, just hard to understand.
Quoted 5 lines
However, this does mean what I suspected on the other patch is true - you're calling
ieee80211_update_rssi_config()here, and that uses thesta->rssi_tholdsarray without any protection, while a concurrent change of configuration can free the data.
yes, I'll add a protection mechanism.
Quoted 14 lines
You need to sort that out. I would suggest to stick all the sta->rssi_* fields you add into a new struct (you even had an empty one), and protect that struct using RCU. That also saves the memory in case it's not assigned at all. Something like
struct sta_mon_rssi_config { struct rcu_head rcu_head; int n_thresholds; s32 low, high; u32 hyst; s32 last_value; s32 thresholds[]; };
Quoted 3 lines
then you can
kfree_rcu()it, and just do a single allocation usingstruct_size()for however many entries you need.
Yes correct. I'll change it.
Quoted 7 lines
Quoted 7 lines
+ * @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.
*/
structsta_info{
Quoted 9 lines
net/mac80211/sta_info.h struct sta_info { · line 606
Quoted 6 lines
net/mac80211/sta_info.h +1
-0/* General information, mostly static */ @@ -600,6 +603,7 @@ struct sta_info {s32 rssi_high;u32 rssi_hyst;s32 last_rssi_event_value; +unsigned int count_rx_signal;I guess that would also move into the new struct.
Okay.
Thanks,
Tamizh.