cfg80211/mac80211: Add support to configure and monitor station's rssi threshold
Subsystems (2)
v3 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 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 (2):
cfg80211: Add support to configure station specific RSSI threshold
for AP mode
mac80211: Implement API to configure station specific rssi threshold
v3:
* Addressed Johannes comments
v2:
* Combined patchset 2 and 3 as single patch and addressed Johannes comments.
include/net/cfg80211.h | 39 +++++++++ include/net/mac80211.h | 7 ++ include/uapi/linux/nl80211.h | 21 +++++ net/mac80211/cfg.c | 108 +++++++++++++++++++++++++ net/mac80211/rx.c | 56 ++++++++++++- net/mac80211/sta_info.c | 1 + net/mac80211/sta_info.h | 31 ++++++++ net/wireless/nl80211.c | 179 ++++++++++++++++++++++++++++++++++++------ net/wireless/rdev-ops.h | 13 +++ net/wireless/trace.h | 21 +++++ 10 files changed, 449 insertions(+), 27 deletions(-)
Signature · 1 line
1.7.9.5
PATCH v3 1/2 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_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(not modifying the low and high threshold upon crossing the threshold) or moving(modifying low and high threshold upon crossing the threshold) 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 | 39 +++++++++ include/uapi/linux/nl80211.h | 21 +++++ net/wireless/nl80211.c | 179 ++++++++++++++++++++++++++++++++++++------ net/wireless/rdev-ops.h | 13 +++ net/wireless/trace.h | 21 +++++ 5 files changed, 247 insertions(+), 26 deletions(-)
include/net/cfg80211.h +39 -0
@@ -3161,6 +3161,20 @@ struct cfg80211_update_owe_info { };/** +* struct cfg80211_sta_mon - Configure station monitor parameters +* @rssi_tholds - array of RSSI thresholds for the station +* @rssi_hyst - RSSI hysterisis +* @n_tholds - Number of configuration thresholds +* @fixed_thold - Fixed thresholds limit used for the station +*/ +struct cfg80211_sta_mon { +s32 *rssi_tholds; +u32 rssi_hyst; +int n_tholds; +u8 fixed_thold; +}; + +/** * struct cfg80211_ops - backend description for wireless configuration * * This struct is registered by fullmac card drivers and/or wireless stacks
@@ -3501,6 +3515,12 @@ struct cfg80211_update_owe_info {* @update_owe_info: Provide updated OWE info to driver. Driver implementing SME * but offloading OWE processing to the user space will get the updated * DH IE through this interface. +* +* @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);
@@ -3817,6 +3837,9 @@ struct cfg80211_ops { struct cfg80211_pmsr_request *request);int (*update_owe_info)(struct wiphy *wiphy,struct net_device *dev,struct cfg80211_update_owe_info *owe_info); +int (*set_sta_mon_rssi_config)(struct wiphy *wiphy, +struct net_device *dev,const u8 *addr, +const struct cfg80211_sta_mon *sta_mon_cfg); };/*
@@ -6620,6 +6643,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 +21 -0
@@ -1070,6 +1070,12 @@* OWE AKM by the host drivers that implement SME but rely * on the user space for the cryptographic/DH IE processing in AP mode. * +* @NL80211_CMD_SET_STA_MON: This command is used to configure station's +* connection monitoring notification trigger levels. This uses nested +* attribute %NL80211_ATTR_CQM with %NL80211_ATTR_CQM_* sub-attributes. +* @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 */
@@ -1292,6 +1298,9 @@ enum nl80211_commands {NL80211_CMD_UPDATE_OWE_INFO , +NL80211_CMD_SET_STA_MON , + NL80211_CMD_NOTIFY_STA_MON, +/* add new commands above here */ /* used to define NL80211_CMD_MAX below */
@@ -2324,6 +2333,12 @@ enum nl80211_commands {* should be picking up the lowest tx power, either tx power per-interface * or per-station. * +* @NL80211_ATTR_STA_MON_FIXED_THOLD: This u8 attribute is used with +* %NL80211_CMD_SET_STA_MON to indicate driver that the monitoring +* threshold is fixed(not modifying the low and high threshold upon +* crossing the threshold) or moving(modifying low and high threshold +* upon crossing the threshold) thresholds. +* * @NUM_NL80211_ATTR: total number of nl80211_attrs available * @NL80211_ATTR_MAX: highest attribute number currently defined * @__NL80211_ATTR_AFTER_LAST: internal use
@@ -2777,6 +2792,8 @@ enum nl80211_attrs {NL80211_ATTR_STA_TX_POWER_SETTING ,NL80211_ATTR_STA_TX_POWER , +NL80211_ATTR_STA_MON_FIXED_THOLD , +/* add attributes here, update the policy in nl80211.c */ __NL80211_ATTR_AFTER_LAST,
@@ -5405,6 +5422,9 @@ enum nl80211_feature_flags {* @NL80211_EXT_FEATURE_STA_TX_PWR: This driver supports controlling tx power * to a station. * +* @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. */
@@ -5449,6 +5469,7 @@ enum nl80211_ext_feature_index {NL80211_EXT_FEATURE_SCHED_SCAN_BAND_SPECIFIC_RSSI_THOLD ,NL80211_EXT_FEATURE_EXT_KEY_ID ,NL80211_EXT_FEATURE_STA_TX_PWR , +NL80211_EXT_FEATURE_STA_MON_RSSI_CONFIG ,/* add new features before the definition below */ NUM_NL80211_EXT_FEATURES,
net/wireless/nl80211.c +153 -26
276 lines not on this page · raw message
net/wireless/rdev-ops.h +13 -0
@@ -1286,4 +1286,17 @@ static inline int rdev_update_owe_info(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 struct cfg80211_sta_mon *sta_mon_config) +{ +int ret = -EOPNOTSUPP ; + + ret = rdev->ops->set_sta_mon_rssi_config (&rdev->wiphy, dev, + addr, sta_mon_config); +trace_rdev_return_int (&rdev->wiphy, ret); +return ret; +} +#endif /* __CFG80211_RDEV_OPS */
net/wireless/trace.h +21 -0
@@ -3421,6 +3421,27 @@ WIPHY_PR_ARG, NETDEV_PR_ARG, MAC_PR_ARG(peer)) ); +TRACE_EVENT (cfg80211_sta_mon_rssi_notify, + TP_PROTO(struct net_device *netdev, const u8 *addr, + enum nl80211_cqm_rssi_threshold_event rssi_event, + s32 rssi_level), +TP_ARGS (netdev, addr, rssi_event, rssi_level), +TP_STRUCT__entry ( + NETDEV_ENTRY + MAC_ENTRY(addr) + __field(enum nl80211_cqm_rssi_threshold_event, rssi_event) +__field (s32, rssi_level) + ), +TP_fast_assign ( + NETDEV_ASSIGN; + MAC_ASSIGN(addr, addr); + __entry->rssi_event = rssi_event; + __entry->rssi_level = rssi_level; + ), +TP_printk (NETDEV_PR_FMT ", station mac: " MAC_PR_FMT +", rssi event: %d, level: %d" ,NETDEV_PR_ARG , +MAC_PR_ARG (addr), __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
PATCH v3 2/2 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. RSSI low and high threshold values will be calculated as per the station's current signal strength, if the configuration needs to be a fixed threshold then the user given value will be chosen as low and high threshold.
And this patch 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. 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 | 108 +++++++++++++++++++++++++++++++++++++++++++++++ net/mac80211/rx.c | 56 +++++++++++++++++++++++- net/mac80211/sta_info.c | 1 + net/mac80211/sta_info.h | 31 ++++++++++++++ 5 files changed, 202 insertions(+), 1 deletion(-)
include/net/mac80211.h +7 -0
@@ -873,6 +873,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 +108 -0
118 lines not on this page · raw message
net/mac80211/rx.c +55 -1
76 lines not on this page · raw message
net/mac80211/sta_info.c +1 -0
@@ -1029,6 +1029,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 +31 -0
@@ -427,6 +427,33 @@ struct ieee80211_sta_rx_stats {u64 msdu[IEEE80211_NUM_TIDS +1 ]; }; +/** +* struct sta_mon_rssi_config - Monitor station's signal strength +* @rcu_head: rcu head for freeing structure +* @n_rssi_tholds: Number of thresholds passed by user +* @low: RSSI lower threshold for this station, a zero value implies +* disabled +* @high: RSSI upper threshold for this station +* @hyst: RSSI hysteresis for this station +* @last_value: Last RSSI value for this station triggered the +* RSSI cross event +* @fixed_thold - Indicate whether to use fixed thresholds limit or not +* @threholds: RSSI threshold limit passed by the user +* @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_mon_rssi_config { +struct rcu_head rcu_head; +int n_thresholds; +s32 low, high; +u32 hyst; +s32 last_value; +u8 fixed_thold; +unsigned int count_rx_signal; +s32 thresholds[0 ]; +}; +/* * The bandwidth threshold below which the per-station CoDel parameters will be * scaled to be more lenient (to prevent starvation of slow stations). This
@@ -496,6 +523,7 @@ struct ieee80211_sta_rx_stats {* @fast_rx: RX fastpath information * @tdls_chandef: a TDLS peer can have a wider chandef that is compatible to * the BSS one. +* @rssi_config: RSSI threshold config parameters for this station * @tx_stats: TX statistics * @tx_stats.packets: # of packets transmitted * @tx_stats.bytes: # of bytes in all packets transmitted
@@ -623,6 +651,7 @@ struct sta_info {struct cfg80211_chan_def tdls_chandef; +struct sta_mon_rssi_config *rssi_config;/* keep last! */ struct ieee80211_sta sta; };
@@ -760,6 +789,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);
@@ -792,6 +822,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
kbuild test robot
build botRe: [PATCHv3 2/2] mac80211: Implement API to configure station specific rssi threshold
Thank you for the patch! Perhaps something to improve:
Hi Tamizh,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on mac80211-next/master]
[also build test WARNING on next-20190412]
[cannot apply to v5.1-rc4]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Tamizh-chelvam/cfg80211-Add-support-to-configure-station-specific-RSSI-threshold-for-AP-mode/20190412-225220 base: https://git.kernel.org/pub/scm/linux/kernel/git/jberg/mac80211-next.git master reproduce: # apt-get install sparse make ARCH=x86_64 allmodconfig make C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__'
sparse warnings: (new ones prefixed by >>)
>> net/mac80211/cfg.c:3947:17: sparse: incompatible types in comparison expression (different address spaces) -- >> net/mac80211/rx.c:1735:13: sparse: context imbalance in 'ieee80211_sta_rx_signal_thold_check' - wrong count at exit
vim +3947 net/mac80211/cfg.c
3940
3941 void sta_mon_rssi_config_free(struct sta_info *sta)
3942 {
3943 struct sta_mon_rssi_config *old_rssi_config;
3944
3945 if (sta->rssi_config) {
3946 old_rssi_config = sta->rssi_config;
> 3947 RCU_INIT_POINTER(sta->rssi_config, NULL);
3948 kfree_rcu(old_rssi_config, rcu_head);
3949 }
3950 }
3951
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
Johannes Berg
maintainerRe: [PATCHv3 2/2] mac80211: Implement API to configure station specific rssi threshold
In reply to Tamizh chelvamnet/mac80211/cfg.c static int ieee80211_get_txq_stats(struct wiphy *wiphy, · line 3947
Quoted 4 lines
net/mac80211/cfg.c +3
-0+if (sta->rssi_config) { + old_rssi_config = sta->rssi_config; +RCU_INIT_POINTER (sta->rssi_config,NULL );
Looks like you need an __rcu annotation somewhere to make this compile sparse-warnings-free.
johannes