cfg80211/mac80211: Add support to configure and monitor rssi threshold
Subsystems (2)
v3 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
v3:
* splitted single and multiple RSSI threshold changes as different patches
v2:
* fixed kbuild warnings
* updated commit log
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.9.1
RFC v3 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 | 7 +++-- net/wireless/core.c | 29 ++++++++++++++++---- net/wireless/core.h | 6 ++-- net/wireless/nl80211.c | 74 +++++++++++++++++++++++++++++++++----------------- 4 files changed, 81 insertions(+), 35 deletions(-)
include/net/cfg80211.h +4 -3
@@ -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,7 @@ 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 */ struct wireless_dev {struct wiphy *wiphy;
@@ -4275,7 +4275,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
@@ -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
@@ -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.9.1
RFC v3 2/7 cfg80211: Add new NL command to configure peer specific rssi threshold
In reply to Tamizh chelvamThis 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
@@ -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
@@ -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
@@ -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.9.1
RFC v3 3/7 mac80211: Add api to support configuring station specific rssi threshold
In reply to Tamizh chelvamThis 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
@@ -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
@@ -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.9.1
RFC v3 4/7 cfg80211: Add support to notify station's rssi level crossing
In reply to Tamizh chelvamAdd 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
@@ -5915,6 +5915,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
@@ -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
@@ -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.9.1
RFC v3 5/7 mac80211: Implement functionality to monitor station's rssi cross event
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.
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
@@ -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
@@ -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.9.1
RFC v3 6/7 cfg80211: Accept multiple RSSI threholds for STA_MON command
In reply to Tamizh chelvamChange 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
@@ -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
@@ -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
@@ -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
@@ -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.9.1
RFC v3 7/7 mac80211: Add api to configure low and high RSSI threshold
In reply to Tamizh chelvamAdd 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
@@ -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
@@ -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
@@ -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.9.1