cfg80211: return channel noise via survey API
PATCH 1/1 cfg80211: return channel noise via survey API
This patch implements the NL80211_CMD_GET_SURVEY command and an get_survey() ops that a driver can implement. The goal of this command is to allow a drivers to report channel survey data (e.g. channel noise, channel occupation).
For now, only the mechanism to report back channel noise has been implemented.
In future, there will either be a survey-trigger command --- or the existing scan-trigger command will be enhanced. This will allow user-space to request survey for arbitrary channels.
Note: any driver that cannot report channel noise should not report any value at all, e.g. made-up -92 dBm.
---
v2: * channel is mandatory (by way of callback-parameter)
* switched to .dump operation, e.g. nl80211_dump_survey() is now similar to nl80211_dump_stations() and nl80211_send_survey() is similar to nl80211_send_station().
* this also means that the cfg80211_ops dump_survey() now caries an idx.
v3: * own name-space for survey parameters
* added sample to mac80211_hwsim
v4: * added missing cb->args[0] = ifidx
* changed noise from u32/mDm to u8/dBm (just like the signal in the station info).
* NL80211_SURVEY_FREQUENCY -> NL80211_SURVEY_INFO_FREQUENCY
* changed from RFC to PATCH
* changes some "return -1" into error values
* used "diff -p"
include/linux/nl80211.h +34 -0
@@ -160,6 +160,11 @@* @NL80211_CMD_SCAN_ABORTED: scan was aborted, for unspecified reasons, * partial scan results may be available * +* @NL80211_CMD_GET_SURVEY: get survey resuls, e.g. channel occupation +* or noise level +* @NL80211_CMD_NEW_SURVEY_RESULTS: survey data notification (as a reply to +* NL80211_CMD_GET_SURVEY and on the "scan" multicast group) +* * @NL80211_CMD_REG_CHANGE: indicates to userspace the regulatory domain * has been changed and provides details of the request information * that caused the change such as who initiated the regulatory request
@@ -341,6 +346,9 @@ enum nl80211_commands {NL80211_CMD_SET_WIPHY_NETNS , +NL80211_CMD_GET_SURVEY , + NL80211_CMD_NEW_SURVEY_RESULTS, +/* add new commands above here */ /* used to define NL80211_CMD_MAX below */
@@ -586,6 +594,10 @@ enum nl80211_commands {* * @NL80211_ATTR_4ADDR: Use 4-address frames on a virtual interface * +* @NL80211_ATTR_SURVEY_INFO: survey information about a channel, part of +* the survey response for %NL80211_CMD_GET_SURVEY, nested attribute +* containing info as possible, see &enum survey_info. +* * @NL80211_ATTR_MAX: highest attribute number currently defined * @__NL80211_ATTR_AFTER_LAST: internal use */
@@ -718,6 +730,8 @@ enum nl80211_attrs {NL80211_ATTR_4ADDR , +NL80211_ATTR_SURVEY_INFO , +/* add attributes here, update the policy in nl80211.c */ __NL80211_ATTR_AFTER_LAST,
@@ -1121,6 +1135,26 @@ enum nl80211_reg_rule_flags { };/** +* enum nl80211_survey_info - survey information +* +* These attribute types are used with %NL80211_ATTR_SURVEY_INFO +* when getting information about a survey. +* +* @__NL80211_SURVEY_INFO_INVALID: attribute number 0 is reserved +* @NL80211_SURVEY_INFO_FREQUENCY: center frequency of channel +* @NL80211_SURVEY_INFO_NOISE: noise level of channel (u8, dBm) +*/ +enum nl80211_survey_info { + __NL80211_SURVEY_INFO_INVALID, +NL80211_SURVEY_INFO_FREQUENCY , +NL80211_SURVEY_INFO_NOISE , + +/* keep last */ + __NL80211_SURVEY_INFO_AFTER_LAST, +NL80211_SURVEY_INFO_MAX = __NL80211_SURVEY_INFO_AFTER_LAST -1 +}; + +/** * enum nl80211_mntr_flags - monitor configuration flags * * Monitor configuration flags.
include/net/cfg80211.h +34 -0
@@ -235,6 +235,35 @@ struct key_params { };/** +* enum survey_info_flags - survey information flags +* +* Used by the driver to indicate which info in &struct survey_info +* it has filled in during the get_survey(). +*/ +enum survey_info_flags { +SURVEY_INFO_NOISE_DBM =1 <<0 , +}; + +/** +* struct survey_info - channel survey response +* +* Used by dump_survey() to report back per-channel survey information. +* +* @channel: the channel this survey record reports, mandatory +* @filled: bitflag of flags from &enum survey_info_flags +* @noise: channel noise in dBm. This and all following fields are +* optional +* +* This structure can later be expanded with things like +* channel duty cycle etc. +*/ +struct survey_info { +struct ieee80211_channel *channel; +u32 filled; +s8 noise; +}; + +/** * struct beacon_parameters - beacon parameters * * Used to configure the beacon for an interface.
@@ -943,6 +972,8 @@ struct cfg80211_bitrate_mask {* @rfkill_poll: polls the hw rfkill line, use cfg80211 reporting * functions to adjust rfkill hw state * +* @dump_survey: get site survey information. +* * @testmode_cmd: run a test mode command */ struct cfg80211_ops {
@@ -1062,6 +1093,9 @@ struct cfg80211_ops {const u8 *peer, const struct cfg80211_bitrate_mask *mask); +int (*dump_survey)(struct wiphy *wiphy,struct net_device *netdev, +int idx,struct survey_info *info); +/* some temporary stuff to finish wext */ int (*set_power_mgmt)(struct wiphy *wiphy,struct net_device *dev,bool enabled,int timeout);
net/wireless/nl80211.c +105 -0
117 lines not on this page · raw message
Signature · 1 line
http://www.holgerschurig.de