Skip to content

Commit

Permalink
mwifiex: fix bug in wildcard scan handling
Browse files Browse the repository at this point in the history
Currently if valid SSID list is provided in scan request, driver
performs specific SSID scan otherwise wildcard scan is chosen.

When wpa_supplicant provides valid SSID list followed by
zero-length SSID for wildcard scan, only specific SSID scan is
performed by driver. Actually driver is expected to do both type
of scanning in this case. The patch fixes this issue.

Also, use SSID list pointer provided by stack directly, instead
of copying SSID's to local structure.

Signed-off-by: Amitkumar Karwar <akarwar@marvell.com>
Signed-off-by: Bing Zhao <bzhao@marvell.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
  • Loading branch information
Amitkumar Karwar authored and John W. Linville committed Mar 5, 2012
1 parent b9be5f3 commit be0b281
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 33 deletions.
10 changes: 4 additions & 6 deletions drivers/net/wireless/mwifiex/cfg80211.c
Original file line number Diff line number Diff line change
Expand Up @@ -1106,12 +1106,10 @@ mwifiex_cfg80211_scan(struct wiphy *wiphy, struct net_device *dev,
dev_err(priv->adapter->dev, "failed to alloc scan_req\n");
return -ENOMEM;
}
for (i = 0; i < request->n_ssids; i++) {
memcpy(priv->user_scan_cfg->ssid_list[i].ssid,
request->ssids[i].ssid, request->ssids[i].ssid_len);
priv->user_scan_cfg->ssid_list[i].max_len =
request->ssids[i].ssid_len;
}

priv->user_scan_cfg->num_ssids = request->n_ssids;
priv->user_scan_cfg->ssid_list = request->ssids;

for (i = 0; i < request->n_channels; i++) {
chan = request->channels[i];
priv->user_scan_cfg->chan_list[i].chan_number = chan->hw_value;
Expand Down
10 changes: 3 additions & 7 deletions drivers/net/wireless/mwifiex/fw.h
Original file line number Diff line number Diff line change
Expand Up @@ -852,11 +852,6 @@ struct mwifiex_user_scan_chan {
u32 scan_time;
} __packed;

struct mwifiex_user_scan_ssid {
u8 ssid[IEEE80211_MAX_SSID_LEN + 1];
u8 max_len;
} __packed;

struct mwifiex_user_scan_cfg {
/*
* BSS mode to be sent in the firmware command
Expand All @@ -867,8 +862,9 @@ struct mwifiex_user_scan_cfg {
u8 reserved;
/* BSSID filter sent in the firmware command to limit the results */
u8 specific_bssid[ETH_ALEN];
/* SSID filter list used in the to limit the scan results */
struct mwifiex_user_scan_ssid ssid_list[MWIFIEX_MAX_SSID_LIST_LENGTH];
/* SSID filter list used in the firmware to limit the scan results */
struct cfg80211_ssid *ssid_list;
u8 num_ssids;
/* Variable number (fixed maximum) of channels to scan up */
struct mwifiex_user_scan_chan chan_list[MWIFIEX_USER_SCAN_CHAN_MAX];
} __packed;
Expand Down
40 changes: 20 additions & 20 deletions drivers/net/wireless/mwifiex/scan.c
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,7 @@ mwifiex_scan_setup_scan_config(struct mwifiex_private *priv,
u16 scan_dur;
u8 channel;
u8 radio_type;
u32 ssid_idx;
int i;
u8 ssid_filter;
u8 rates[MWIFIEX_SUPPORTED_RATES];
u32 rates_size;
Expand Down Expand Up @@ -792,14 +792,8 @@ mwifiex_scan_setup_scan_config(struct mwifiex_private *priv,
user_scan_in->specific_bssid,
sizeof(scan_cfg_out->specific_bssid));

for (ssid_idx = 0;
((ssid_idx < ARRAY_SIZE(user_scan_in->ssid_list))
&& (*user_scan_in->ssid_list[ssid_idx].ssid
|| user_scan_in->ssid_list[ssid_idx].max_len));
ssid_idx++) {

ssid_len = strlen(user_scan_in->ssid_list[ssid_idx].
ssid) + 1;
for (i = 0; i < user_scan_in->num_ssids; i++) {
ssid_len = user_scan_in->ssid_list[i].ssid_len;

wildcard_ssid_tlv =
(struct mwifiex_ie_types_wildcard_ssid_params *)
Expand All @@ -810,19 +804,26 @@ mwifiex_scan_setup_scan_config(struct mwifiex_private *priv,
(u16) (ssid_len + sizeof(wildcard_ssid_tlv->
max_ssid_length)));

/* max_ssid_length = 0 tells firmware to perform
specific scan for the SSID filled */
wildcard_ssid_tlv->max_ssid_length = 0;
/*
* max_ssid_length = 0 tells firmware to perform
* specific scan for the SSID filled, whereas
* max_ssid_length = IEEE80211_MAX_SSID_LEN is for
* wildcard scan.
*/
if (ssid_len)
wildcard_ssid_tlv->max_ssid_length = 0;
else
wildcard_ssid_tlv->max_ssid_length =
IEEE80211_MAX_SSID_LEN;

memcpy(wildcard_ssid_tlv->ssid,
user_scan_in->ssid_list[ssid_idx].ssid,
ssid_len);
user_scan_in->ssid_list[i].ssid, ssid_len);

tlv_pos += (sizeof(wildcard_ssid_tlv->header)
+ le16_to_cpu(wildcard_ssid_tlv->header.len));

dev_dbg(adapter->dev, "info: scan: ssid_list[%d]: %s, %d\n",
ssid_idx, wildcard_ssid_tlv->ssid,
dev_dbg(adapter->dev, "info: scan: ssid[%d]: %s, %d\n",
i, wildcard_ssid_tlv->ssid,
wildcard_ssid_tlv->max_ssid_length);

/* Empty wildcard ssid with a maxlen will match many or
Expand All @@ -831,7 +832,6 @@ mwifiex_scan_setup_scan_config(struct mwifiex_private *priv,
filtered. */
if (!ssid_len && wildcard_ssid_tlv->max_ssid_length)
ssid_filter = false;

}

/*
Expand All @@ -840,7 +840,7 @@ mwifiex_scan_setup_scan_config(struct mwifiex_private *priv,
* truncate scan results. That is not an issue with an SSID
* or BSSID filter applied to the scan results in the firmware.
*/
if ((ssid_idx && ssid_filter)
if ((i && ssid_filter)
|| memcmp(scan_cfg_out->specific_bssid, &zero_mac,
sizeof(zero_mac)))
*filtered_scan = true;
Expand Down Expand Up @@ -1876,8 +1876,8 @@ static int mwifiex_scan_specific_ssid(struct mwifiex_private *priv,
return -ENOMEM;
}

memcpy(scan_cfg->ssid_list[0].ssid, req_ssid->ssid,
req_ssid->ssid_len);
scan_cfg->ssid_list = req_ssid;
scan_cfg->num_ssids = 1;

ret = mwifiex_scan_networks(priv, scan_cfg);

Expand Down

0 comments on commit be0b281

Please sign in to comment.