Skip to content

Commit

Permalink
nl80211/cfg80211: add new scan configurations attributes (INTERNAL)
Browse files Browse the repository at this point in the history
To enhance scan abilities by being able to setup some low level
scan parameters dynamically during NL80211_CMD_TRIGGER_SCAN
command.

Exposing 3 new attributes:
  NL80211_ATTR_SCAN_MIN_DWELL: Minimum scan dwell time (in TUs), u32
	attribute to setup minimum time to wait on each channel, if received
	at least one probe response during this period will continue waiting
	%NL80211_ATTR_SCAN_MAX_DWELL, otherwise will move to next channel.
 	This is optional attribute, so if it's not set driver should
	use hardware default values.
  NL80211_ATTR_SCAN_MAX_DWELL: Maximum scan dwell time (in TUs), u32
	attribute to setup maximum time to wait on each channel.
	This is optional attribute, so if it's not set driver should
	use hardware default values.
  NL80211_ATTR_SCAN_NUM_PROBE:  Attribute (u8) to setup number of probe
 	requests to transmit on each active scan channel, used with
	NL80211_CMD_TRIGGER_SCAN command.

These attributes are also required for the beacon reports in the
802.11k standard.

Signed-off-by: Victor Goldenshtein <victorg@ti.com>
Signed-off-by: Luciano Coelho <coelho@ti.com>
  • Loading branch information
victorgld authored and Luciano Coelho committed Jul 18, 2012
1 parent ced3c5f commit 15f5e33
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 0 deletions.
20 changes: 20 additions & 0 deletions include/linux/nl80211.h
Expand Up @@ -1278,6 +1278,22 @@ enum nl80211_commands {
* strength of probe response/beacon (in dBm) is stronger than this
* negative value (usually: -20 dBm > X > -95 dBm).
*
* @%NL80211_ATTR_SCAN_MIN_DWELL: Minimum scan dwell time (in TUs), u32
* attribute to setup minimum time to wait on each channel, if received
* at least one probe response during this period will continue waiting
* %NL80211_ATTR_SCAN_MAX_DWELL, otherwise will move to next channel.
* Relevant only for active scan, used with %NL80211_CMD_TRIGGER_SCAN
* command. This is optional attribute, so if it's not set driver should
* use hardware default values.
* @%NL80211_ATTR_SCAN_MAX_DWELL: Maximum scan dwell time (in TUs), u32
* attribute to setup maximum time to wait on each channel.
* Relevant only for active scan, used with %NL80211_CMD_TRIGGER_SCAN
* command. This is optional attribute, so if it's not set driver should
* use hardware default values.
* @%NL80211_ATTR_SCAN_NUM_PROBE: Attribute (u8) to setup number of probe
* requests to transmit on each active scan channel, used with
* %NL80211_CMD_TRIGGER_SCAN command.
*
* @NL80211_ATTR_MAX: highest attribute number currently defined
* @__NL80211_ATTR_AFTER_LAST: internal use
*/
Expand Down Expand Up @@ -1536,6 +1552,10 @@ enum nl80211_attrs {
NL80211_ATTR_IM_SCAN_RESULT,
NL80211_ATTR_IM_SCAN_RESULT_MIN_RSSI,

NL80211_ATTR_SCAN_MIN_DWELL,
NL80211_ATTR_SCAN_MAX_DWELL,
NL80211_ATTR_SCAN_NUM_PROBE,

/* add attributes here, update the policy in nl80211.c */

__NL80211_ATTR_AFTER_LAST,
Expand Down
7 changes: 7 additions & 0 deletions include/net/cfg80211.h
Expand Up @@ -1001,6 +1001,9 @@ struct cfg80211_ssid {
* @wiphy: the wiphy this was for
* @wdev: the wireless device to scan for
* @aborted: (internal) scan request was notified as aborted
* @min_dwell: minimum time to wait on each channel for active scans
* @max_dwell: maximum time to wait on each channel for active scans
* @num_probe: number of probe requests to transmit on each active scan channel
* @no_cck: used to send probe requests at non CCK rate in 2GHz band
*/
struct cfg80211_scan_request {
Expand All @@ -1019,6 +1022,10 @@ struct cfg80211_scan_request {
bool aborted;
bool no_cck;

u32 min_dwell;
u32 max_dwell;
u8 num_probe;

/* keep last */
struct ieee80211_channel *channels[0];
};
Expand Down
3 changes: 3 additions & 0 deletions net/mac80211/scan.c
Expand Up @@ -462,6 +462,9 @@ static int __ieee80211_start_scan(struct ieee80211_sub_if_data *sdata,

local->hw_scan_req->ssids = req->ssids;
local->hw_scan_req->n_ssids = req->n_ssids;
local->hw_scan_req->max_dwell = req->max_dwell;
local->hw_scan_req->min_dwell = req->min_dwell;
local->hw_scan_req->num_probe = req->num_probe;
ies = (u8 *)local->hw_scan_req +
sizeof(*local->hw_scan_req) +
req->n_channels * sizeof(req->channels[0]);
Expand Down
18 changes: 18 additions & 0 deletions net/wireless/nl80211.c
Expand Up @@ -357,6 +357,9 @@ static const struct nla_policy nl80211_policy[NL80211_ATTR_MAX+1] = {
[NL80211_ATTR_USER_REG_HINT_TYPE] = { .type = NLA_U32 },
[NL80211_ATTR_IM_SCAN_RESULT] = { .type = NLA_FLAG },
[NL80211_ATTR_IM_SCAN_RESULT_MIN_RSSI] = { .type = NLA_U32 },
[NL80211_ATTR_SCAN_MIN_DWELL] = { .type = NLA_U32 },
[NL80211_ATTR_SCAN_MAX_DWELL] = { .type = NLA_U32 },
[NL80211_ATTR_SCAN_NUM_PROBE] = { .type = NLA_U8 },
};

/* policy for the key attributes */
Expand Down Expand Up @@ -4305,6 +4308,21 @@ static int nl80211_trigger_scan(struct sk_buff *skb, struct genl_info *info)
rdev->im_scan_result_snd_pid = 0;
}

if (info->attrs[NL80211_ATTR_SCAN_MIN_DWELL]) {
request->min_dwell =
nla_get_u32(info->attrs[NL80211_ATTR_SCAN_MIN_DWELL]);
}

if (info->attrs[NL80211_ATTR_SCAN_MAX_DWELL]) {
request->max_dwell =
nla_get_u32(info->attrs[NL80211_ATTR_SCAN_MAX_DWELL]);
}

if (info->attrs[NL80211_ATTR_SCAN_NUM_PROBE]) {
request->num_probe =
nla_get_u8(info->attrs[NL80211_ATTR_SCAN_NUM_PROBE]);
}

for (i = 0; i < IEEE80211_NUM_BANDS; i++)
if (wiphy->bands[i])
request->rates[i] =
Expand Down

0 comments on commit 15f5e33

Please sign in to comment.