Skip to contentSkip to conversation

mwifiex: improvements for 3.4

PATCH In review Bing Zhao 2 participants 9 messages Feb 28, 2012 1 message not in the archive Networking drivers (wireless)

lore
Share & tools
lore

Bing Zhao

author
#0 lore raw

cover mwifiex: improvements for 3.4

Hi John,

Please find the following patches in this submission. I've mixed V1 and V2 patches here as they have dependences.

[PATCH 1/6 V2] mwifiex: correct bitrates advertised to cfg80211

The V1 patch was submitted for 3.3. Now I'm submitting the V2 for 3.4
as it doesn't cause any real problem in 3.3 or ealier versions.

[PATCH 2/6 RESEND] mwifiex: remove unnecessary enum MWIFIEX_802_11_WEP_STATUS [PATCH 3/6 RESEND] mwifiex: handle auto authentication mode correctly

These two patches are included here just for your convenience. They depend on
"[PATCH 3.3] mwifiex: reset encryption mode flag before association" and "[PATCH 3.4] mwifiex: remove redundant scan operation"
submitted previously.

[PATCH 4/6] mwifiex: remove unnecessary struct mwifiex_802_11_ssid

This is a new cleanup patch for 3.4.

[PATCH 5/6 V2] mwifiex: fix bug in wildcard scan handling

The V1 patch was submitted for 3.3. Now I'm submitting the V2 for 3.4
because it depends on PATCH 4/6 which is intended for 3.4.

[PATCH 6/6] mwifiex: remove BSS entry before specific SSID scan

This is a new enhancement patch for specific scan, intended for 3.4.

Thanks,
Bing

---

Amitkumar Karwar (5):
mwifiex: remove unnecessary enum MWIFIEX_802_11_WEP_STATUS
mwifiex: handle auto authentication mode correctly
mwifiex: remove unnecessary struct mwifiex_802_11_ssid
mwifiex: fix bug in wildcard scan handling
mwifiex: remove BSS entry before specific SSID scan

Avinash Patil (1):
mwifiex: correct bitrates advertised to cfg80211

 drivers/net/wireless/mwifiex/cfg80211.c  |   32 ++++-----
 drivers/net/wireless/mwifiex/cmdevt.c    |    8 +--
 drivers/net/wireless/mwifiex/decl.h      |    5 --
 drivers/net/wireless/mwifiex/fw.h        |   15 +---
 drivers/net/wireless/mwifiex/init.c      |    2 +-
 drivers/net/wireless/mwifiex/ioctl.h     |    4 +-
 drivers/net/wireless/mwifiex/join.c      |   11 ++--
 drivers/net/wireless/mwifiex/main.h      |   18 +++---
 drivers/net/wireless/mwifiex/scan.c      |  111 ++++++++++++++++--------------
 drivers/net/wireless/mwifiex/sta_event.c |    2 +-
 drivers/net/wireless/mwifiex/sta_ioctl.c |   26 +++++--
 11 files changed, 116 insertions(+), 118 deletions(-)
author
#1 lore raw

PATCH v2 1/6 mwifiex: correct bitrates advertised to cfg80211

From: Avinash Patil <[email protected]>

1. Driver and firmware do not support 22Mbps and 72Mbps bitrates. Remove them from the rate table advertised to cfg80211.

2. First 4 rates from mwifiex_rates table are not valid for 5GHz/A band. Set correct bitrate array's index and no of rates for ieee80211_supported_band for 5GHz band.

---
V2: updated the commit description (Johanness Berg)

 drivers/net/wireless/mwifiex/cfg80211.c |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)
drivers/net/wireless/mwifiex/cfg80211.c +2 -4
index 7b98ce0..2a1fc32 100644
@@ -613,7 +613,6 @@ static struct ieee80211_rate mwifiex_rates[] = {
 	{.bitrate = 20, .hw_value = 4, },
 	{.bitrate = 55, .hw_value = 11, },
 	{.bitrate = 110, .hw_value = 22, },
-	{.bitrate = 220, .hw_value = 44, },
 	{.bitrate = 60, .hw_value = 12, },
 	{.bitrate = 90, .hw_value = 18, },
 	{.bitrate = 120, .hw_value = 24, },
@@ -622,7 +621,6 @@ static struct ieee80211_rate mwifiex_rates[] = {
 	{.bitrate = 360, .hw_value = 72, },
 	{.bitrate = 480, .hw_value = 96, },
 	{.bitrate = 540, .hw_value = 108, },
-	{.bitrate = 720, .hw_value = 144, },
 };
 
 /* Channel definitions to be advertised to cfg80211 */
@@ -688,8 +686,8 @@ static struct ieee80211_channel mwifiex_channels_5ghz[] = {
 static struct ieee80211_supported_band mwifiex_band_5ghz = {
 	.channels = mwifiex_channels_5ghz,
 	.n_channels = ARRAY_SIZE(mwifiex_channels_5ghz),
-	.bitrates = mwifiex_rates - 4,
-	.n_bitrates = ARRAY_SIZE(mwifiex_rates) + 4,
+	.bitrates = mwifiex_rates + 4,
+	.n_bitrates = ARRAY_SIZE(mwifiex_rates) - 4,
 };
 
 
Signature · 1 line
1.7.0.2
author
#2 lore raw

PATCH RESEND 2/6 mwifiex: remove unnecessary enum MWIFIEX_802_11_WEP_STATUS

In reply to Bing Zhao

From: Amitkumar Karwar <[email protected]>

Instead of defining an 'enum', we can simply use 'u8' flag for WEP status. Rename 'wep_status' to 'wep_enabled' to match with 'wpa_enabled' and 'wpa2_enabled'.

---
 drivers/net/wireless/mwifiex/cfg80211.c  |    2 +-
 drivers/net/wireless/mwifiex/fw.h        |    5 ---
 drivers/net/wireless/mwifiex/init.c      |    2 +-
 drivers/net/wireless/mwifiex/join.c      |    5 +--
 drivers/net/wireless/mwifiex/main.h      |    2 +-
 drivers/net/wireless/mwifiex/scan.c      |   47 ++++++++++++------------------
 drivers/net/wireless/mwifiex/sta_ioctl.c |   10 +++---
 7 files changed, 29 insertions(+), 44 deletions(-)
drivers/net/wireless/mwifiex/cfg80211.c +1 -1
index 2a1fc32..9f3d8aa 100644
@@ -146,7 +146,7 @@ mwifiex_cfg80211_set_default_key(struct wiphy *wiphy, struct net_device *netdev,
 	struct mwifiex_private *priv = mwifiex_netdev_get_priv(netdev);
 
 	/* Return if WEP key not configured */
-	if (priv->sec_info.wep_status == MWIFIEX_802_11_WEP_DISABLED)
+	if (!priv->sec_info.wep_enabled)
 		return 0;
 
 	if (mwifiex_set_encode(priv, NULL, 0, key_index, 0)) {
drivers/net/wireless/mwifiex/fw.h +0 -5
index 51c5417..c826200 100644
@@ -86,11 +86,6 @@ enum MWIFIEX_802_11_PRIVACY_FILTER {
 	MWIFIEX_802_11_PRIV_FILTER_8021X_WEP
 };
 
-enum MWIFIEX_802_11_WEP_STATUS {
-	MWIFIEX_802_11_WEP_ENABLED,
-	MWIFIEX_802_11_WEP_DISABLED,
-};
-
 #define CAL_SNR(RSSI, NF)		((s16)((s16)(RSSI)-(s16)(NF)))
 
 #define PROPRIETARY_TLV_BASE_ID                 0x0100
drivers/net/wireless/mwifiex/init.c +1 -1
index ca59cc0..e81bf6e 100644
@@ -82,7 +82,7 @@ static int mwifiex_init_priv(struct mwifiex_private *priv)
 	priv->bcn_avg_factor = DEFAULT_BCN_AVG_FACTOR;
 	priv->data_avg_factor = DEFAULT_DATA_AVG_FACTOR;
 
-	priv->sec_info.wep_status = MWIFIEX_802_11_WEP_DISABLED;
+	priv->sec_info.wep_enabled = 0;
 	priv->sec_info.authentication_mode = NL80211_AUTHTYPE_OPEN_SYSTEM;
 	priv->sec_info.encryption_mode = 0;
 	for (i = 0; i < ARRAY_SIZE(priv->wep_key); i++)
drivers/net/wireless/mwifiex/join.c +2 -3
index 0b0eb5e..ee439fc 100644
@@ -417,7 +417,7 @@ int mwifiex_cmd_802_11_associate(struct mwifiex_private *priv,
 	auth_tlv = (struct mwifiex_ie_types_auth_type *) pos;
 	auth_tlv->header.type = cpu_to_le16(TLV_TYPE_AUTH_TYPE);
 	auth_tlv->header.len = cpu_to_le16(sizeof(auth_tlv->auth_type));
-	if (priv->sec_info.wep_status == MWIFIEX_802_11_WEP_ENABLED)
+	if (priv->sec_info.wep_enabled)
 		auth_tlv->auth_type = cpu_to_le16(
 				(u16) priv->sec_info.authentication_mode);
 	else
@@ -1069,8 +1069,7 @@ mwifiex_cmd_802_11_ad_hoc_join(struct mwifiex_private *priv,
 	priv->curr_bss_params.bss_descriptor.channel = bss_desc->channel;
 	priv->curr_bss_params.band = (u8) bss_desc->bss_band;
 
-	if (priv->sec_info.wep_status == MWIFIEX_802_11_WEP_ENABLED
-	    || priv->sec_info.wpa_enabled)
+	if (priv->sec_info.wep_enabled || priv->sec_info.wpa_enabled)
 		tmp_cap |= WLAN_CAPABILITY_PRIVACY;
 
 	if (IS_SUPPORT_MULTI_BANDS(priv->adapter)) {
drivers/net/wireless/mwifiex/main.h +1 -1
index 52810b1..4c86217 100644
@@ -217,7 +217,7 @@ struct mwifiex_802_11_security {
 	u8 wpa2_enabled;
 	u8 wapi_enabled;
 	u8 wapi_key_on;
-	enum MWIFIEX_802_11_WEP_STATUS wep_status;
+	u8 wep_enabled;
 	u32 authentication_mode;
 	u32 encryption_mode;
 };
drivers/net/wireless/mwifiex/scan.c +19 -28

101 lines not on this page · raw message

drivers/net/wireless/mwifiex/sta_ioctl.c +5 -5
index b0fbf5d..866026e 100644
@@ -471,7 +471,7 @@ int mwifiex_get_bss_info(struct mwifiex_private *priv,
 
 	info->bcn_nf_last = priv->bcn_nf_last;
 
-	if (priv->sec_info.wep_status == MWIFIEX_802_11_WEP_ENABLED)
+	if (priv->sec_info.wep_enabled)
 		info->wep_status = true;
 	else
 		info->wep_status = false;
@@ -1020,7 +1020,7 @@ static int mwifiex_sec_ioctl_set_wep_key(struct mwifiex_private *priv,
 	wep_key = &priv->wep_key[priv->wep_key_curr_index];
 	index = encrypt_key->key_index;
 	if (encrypt_key->key_disable) {
-		priv->sec_info.wep_status = MWIFIEX_802_11_WEP_DISABLED;
+		priv->sec_info.wep_enabled = 0;
 	} else if (!encrypt_key->key_len) {
 		/* Copy the required key as the current key */
 		wep_key = &priv->wep_key[index];
@@ -1030,7 +1030,7 @@ static int mwifiex_sec_ioctl_set_wep_key(struct mwifiex_private *priv,
 			return -1;
 		}
 		priv->wep_key_curr_index = (u16) index;
-		priv->sec_info.wep_status = MWIFIEX_802_11_WEP_ENABLED;
+		priv->sec_info.wep_enabled = 1;
 	} else {
 		wep_key = &priv->wep_key[index];
 		memset(wep_key, 0, sizeof(struct mwifiex_wep_key));
@@ -1040,7 +1040,7 @@ static int mwifiex_sec_ioctl_set_wep_key(struct mwifiex_private *priv,
 		       encrypt_key->key_len);
 		wep_key->key_index = index;
 		wep_key->key_length = encrypt_key->key_len;
-		priv->sec_info.wep_status = MWIFIEX_802_11_WEP_ENABLED;
+		priv->sec_info.wep_enabled = 1;
 	}
 	if (wep_key->key_length) {
 		/* Send request to firmware */
@@ -1050,7 +1050,7 @@ static int mwifiex_sec_ioctl_set_wep_key(struct mwifiex_private *priv,
 		if (ret)
 			return ret;
 	}
-	if (priv->sec_info.wep_status == MWIFIEX_802_11_WEP_ENABLED)
+	if (priv->sec_info.wep_enabled)
 		priv->curr_pkt_filter |= HostCmd_ACT_MAC_WEP_ENABLE;
 	else
 		priv->curr_pkt_filter &= ~HostCmd_ACT_MAC_WEP_ENABLE;
Signature · 1 line
1.7.0.2
author
#3 lore raw

PATCH RESEND 3/6 mwifiex: handle auto authentication mode correctly

In reply to Bing Zhao

From: Amitkumar Karwar <[email protected]>

When authentication type is configured to NL80211_AUTHTYPE_AUTOMATIC, driver tries to connect using open mode. The association is failed if AP is configured in shared mode.

This patch adds code to try association using shared mode as well if open mode association fails.

Now since we returned exact error code in association response handler (instead of -1), corresponding changes are done in mwifiex_process_cmdresp().

---
 drivers/net/wireless/mwifiex/cfg80211.c  |   10 ++++++----
 drivers/net/wireless/mwifiex/cmdevt.c    |    8 +++-----
 drivers/net/wireless/mwifiex/join.c      |    2 +-
 drivers/net/wireless/mwifiex/main.h      |    1 +
 drivers/net/wireless/mwifiex/sta_ioctl.c |   11 +++++++++++
 5 files changed, 22 insertions(+), 10 deletions(-)
drivers/net/wireless/mwifiex/cfg80211.c +6 -4
index 9f3d8aa..55293a3 100644
@@ -871,6 +871,7 @@ mwifiex_cfg80211_assoc(struct mwifiex_private *priv, size_t ssid_len, u8 *ssid,
 	priv->sec_info.wpa2_enabled = false;
 	priv->wep_key_curr_index = 0;
 	priv->sec_info.encryption_mode = 0;
+	priv->sec_info.is_authtype_auto = 0;
 	ret = mwifiex_set_encode(priv, NULL, 0, 0, 1);
 
 	if (mode == NL80211_IFTYPE_ADHOC) {
@@ -892,11 +893,12 @@ mwifiex_cfg80211_assoc(struct mwifiex_private *priv, size_t ssid_len, u8 *ssid,
 	}
 
 	/* Now handle infra mode. "sme" is valid for infra mode only */
-	if (sme->auth_type == NL80211_AUTHTYPE_AUTOMATIC
-			|| sme->auth_type == NL80211_AUTHTYPE_OPEN_SYSTEM)
+	if (sme->auth_type == NL80211_AUTHTYPE_AUTOMATIC) {
 		auth_type = NL80211_AUTHTYPE_OPEN_SYSTEM;
-	else if (sme->auth_type == NL80211_AUTHTYPE_SHARED_KEY)
-		auth_type = NL80211_AUTHTYPE_SHARED_KEY;
+		priv->sec_info.is_authtype_auto = 1;
+	} else {
+		auth_type = sme->auth_type;
+	}
 
 	if (sme->crypto.n_ciphers_pairwise) {
 		priv->sec_info.encryption_mode =
drivers/net/wireless/mwifiex/cmdevt.c +3 -5
index 6623db6..c82eb7f 100644
@@ -771,7 +771,7 @@ int mwifiex_process_cmdresp(struct mwifiex_adapter *adapter)
 
 	/* Check init command response */
 	if (adapter->hw_status == MWIFIEX_HW_STATUS_INITIALIZING) {
-		if (ret == -1) {
+		if (ret) {
 			dev_err(adapter->dev, "%s: cmd %#x failed during "
 				"initialization\n", __func__, cmdresp_no);
 			mwifiex_init_fw_complete(adapter);
@@ -781,10 +781,8 @@ int mwifiex_process_cmdresp(struct mwifiex_adapter *adapter)
 	}
 
 	if (adapter->curr_cmd) {
-		if (adapter->curr_cmd->wait_q_enabled && (!ret))
-			adapter->cmd_wait_q.status = 0;
-		else if (adapter->curr_cmd->wait_q_enabled && (ret == -1))
-			adapter->cmd_wait_q.status = -1;
+		if (adapter->curr_cmd->wait_q_enabled)
+			adapter->cmd_wait_q.status = ret;
 
 		/* Clean up and put current command back to cmd_free_q */
 		mwifiex_insert_cmd_to_free_q(adapter, adapter->curr_cmd);
drivers/net/wireless/mwifiex/join.c +1 -1
index ee439fc..5c95e48 100644
@@ -585,7 +585,7 @@ int mwifiex_ret_802_11_associate(struct mwifiex_private *priv,
 		       le16_to_cpu(assoc_rsp->cap_info_bitmap),
 		       le16_to_cpu(assoc_rsp->a_id));
 
-		ret = -1;
+		ret = le16_to_cpu(assoc_rsp->status_code);
 		goto done;
 	}
 
drivers/net/wireless/mwifiex/main.h +1 -0
index 4c86217..dddb556 100644
@@ -219,6 +219,7 @@ struct mwifiex_802_11_security {
 	u8 wapi_key_on;
 	u8 wep_enabled;
 	u32 authentication_mode;
+	u8 is_authtype_auto;
 	u32 encryption_mode;
 };
 
drivers/net/wireless/mwifiex/sta_ioctl.c +11 -0
index 866026e..e10161f 100644
@@ -249,6 +249,17 @@ int mwifiex_bss_start(struct mwifiex_private *priv, struct cfg80211_bss *bss,
 		 * application retrieval */
 		priv->assoc_rsp_size = 0;
 		ret = mwifiex_associate(priv, bss_desc);
+
+		/* If auth type is auto and association fails using open mode,
+		 * try to connect using shared mode */
+		if (ret == WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG &&
+		    priv->sec_info.is_authtype_auto &&
+		    priv->sec_info.wep_enabled) {
+			priv->sec_info.authentication_mode =
+						NL80211_AUTHTYPE_SHARED_KEY;
+			ret = mwifiex_associate(priv, bss_desc);
+		}
+
 		if (bss)
 			cfg80211_put_bss(bss);
 	} else {
Signature · 1 line
1.7.0.2
author
#4 lore raw

PATCH 4/6 mwifiex: remove unnecessary struct mwifiex_802_11_ssid

In reply to Bing Zhao

From: Amitkumar Karwar <[email protected]>

Use struct cfg80211_ssid available in include/net/cfg80211.h instead of having similar definition in driver.

---
 drivers/net/wireless/mwifiex/cfg80211.c  |    4 ++--
 drivers/net/wireless/mwifiex/decl.h      |    5 -----
 drivers/net/wireless/mwifiex/ioctl.h     |    4 ++--
 drivers/net/wireless/mwifiex/join.c      |    4 ++--
 drivers/net/wireless/mwifiex/main.h      |   15 +++++++--------
 drivers/net/wireless/mwifiex/scan.c      |    7 +++----
 drivers/net/wireless/mwifiex/sta_event.c |    2 +-
 drivers/net/wireless/mwifiex/sta_ioctl.c |    5 ++---
 8 files changed, 19 insertions(+), 27 deletions(-)
drivers/net/wireless/mwifiex/cfg80211.c +2 -2
index 55293a3..6a91c2f 100644
@@ -839,12 +839,12 @@ mwifiex_cfg80211_assoc(struct mwifiex_private *priv, size_t ssid_len, u8 *ssid,
 		       u8 *bssid, int mode, struct ieee80211_channel *channel,
 		       struct cfg80211_connect_params *sme, bool privacy)
 {
-	struct mwifiex_802_11_ssid req_ssid;
+	struct cfg80211_ssid req_ssid;
 	int ret, auth_type = 0;
 	struct cfg80211_bss *bss = NULL;
 	u8 is_scanning_required = 0;
 
-	memset(&req_ssid, 0, sizeof(struct mwifiex_802_11_ssid));
+	memset(&req_ssid, 0, sizeof(struct cfg80211_ssid));
 
 	req_ssid.ssid_len = ssid_len;
 	if (ssid_len > IEEE80211_MAX_SSID_LEN) {
drivers/net/wireless/mwifiex/decl.h +0 -5
index 3735c77..be5fd16 100644
@@ -91,11 +91,6 @@ struct mwifiex_fw_image {
 	u32 fw_len;
 };
 
-struct mwifiex_802_11_ssid {
-	u32 ssid_len;
-	u8 ssid[IEEE80211_MAX_SSID_LEN];
-};
-
 struct mwifiex_wait_queue {
 	wait_queue_head_t wait;
 	int status;
drivers/net/wireless/mwifiex/ioctl.h +2 -2
index d5d81f1..7ca4e82 100644
@@ -50,7 +50,7 @@ struct mwifiex_chan_freq {
 };
 
 struct mwifiex_ssid_bssid {
-	struct mwifiex_802_11_ssid ssid;
+	struct cfg80211_ssid ssid;
 	u8 bssid[ETH_ALEN];
 };
 
@@ -122,7 +122,7 @@ struct mwifiex_ver_ext {
 
 struct mwifiex_bss_info {
 	u32 bss_mode;
-	struct mwifiex_802_11_ssid ssid;
+	struct cfg80211_ssid ssid;
 	u32 bss_chan;
 	u32 region_code;
 	u32 media_connected;
drivers/net/wireless/mwifiex/join.c +2 -2
index 5c95e48..bce9991 100644
@@ -714,7 +714,7 @@ done:
 int
 mwifiex_cmd_802_11_ad_hoc_start(struct mwifiex_private *priv,
 				struct host_cmd_ds_command *cmd,
-				struct mwifiex_802_11_ssid *req_ssid)
+				struct cfg80211_ssid *req_ssid)
 {
 	int rsn_ie_len = 0;
 	struct mwifiex_adapter *adapter = priv->adapter;
@@ -1245,7 +1245,7 @@ int mwifiex_associate(struct mwifiex_private *priv,
  */
 int
 mwifiex_adhoc_start(struct mwifiex_private *priv,
-		    struct mwifiex_802_11_ssid *adhoc_ssid)
+		    struct cfg80211_ssid *adhoc_ssid)
 {
 	dev_dbg(priv->adapter->dev, "info: Adhoc Channel = %d\n",
 		priv->adhoc_channel);
drivers/net/wireless/mwifiex/main.h +7 -8
index dddb556..a0bd4eb 100644
@@ -244,7 +244,7 @@ struct ieee_types_generic {
 
 struct mwifiex_bssdescriptor {
 	u8 mac_address[ETH_ALEN];
-	struct mwifiex_802_11_ssid ssid;
+	struct cfg80211_ssid ssid;
 	u32 privacy;
 	s32 rssi;
 	u32 channel;
@@ -388,7 +388,7 @@ struct mwifiex_private {
 	s16 bcn_rssi_avg;
 	s16 bcn_nf_avg;
 	struct mwifiex_bssdescriptor *attempted_bss_desc;
-	struct mwifiex_802_11_ssid prev_ssid;
+	struct cfg80211_ssid prev_ssid;
 	u8 prev_bssid[ETH_ALEN];
 	struct mwifiex_current_bss_params curr_bss_params;
 	u16 beacon_period;
@@ -747,8 +747,7 @@ void mwifiex_queue_scan_cmd(struct mwifiex_private *priv,
 			    struct cmd_ctrl_node *cmd_node);
 int mwifiex_ret_802_11_scan(struct mwifiex_private *priv,
 			    struct host_cmd_ds_command *resp);
-s32 mwifiex_ssid_cmp(struct mwifiex_802_11_ssid *ssid1,
-		       struct mwifiex_802_11_ssid *ssid2);
+s32 mwifiex_ssid_cmp(struct cfg80211_ssid *ssid1, struct cfg80211_ssid *ssid2);
 int mwifiex_associate(struct mwifiex_private *priv,
 		      struct mwifiex_bssdescriptor *bss_desc);
 int mwifiex_cmd_802_11_associate(struct mwifiex_private *priv,
@@ -760,12 +759,12 @@ void mwifiex_reset_connect_state(struct mwifiex_private *priv);
 u8 mwifiex_band_to_radio_type(u8 band);
 int mwifiex_deauthenticate(struct mwifiex_private *priv, u8 *mac);
 int mwifiex_adhoc_start(struct mwifiex_private *priv,
-			struct mwifiex_802_11_ssid *adhoc_ssid);
+			struct cfg80211_ssid *adhoc_ssid);
 int mwifiex_adhoc_join(struct mwifiex_private *priv,
 		       struct mwifiex_bssdescriptor *bss_desc);
 int mwifiex_cmd_802_11_ad_hoc_start(struct mwifiex_private *priv,
 				    struct host_cmd_ds_command *cmd,
-				    struct mwifiex_802_11_ssid *req_ssid);
+				    struct cfg80211_ssid *req_ssid);
 int mwifiex_cmd_802_11_ad_hoc_join(struct mwifiex_private *priv,
 				   struct host_cmd_ds_command *cmd,
 				   struct mwifiex_bssdescriptor *bss_desc);
@@ -898,7 +897,7 @@ int mwifiex_copy_mcast_addr(struct mwifiex_multicast_list *mlist,
 			    struct net_device *dev);
 int mwifiex_wait_queue_complete(struct mwifiex_adapter *adapter);
 int mwifiex_bss_start(struct mwifiex_private *priv, struct cfg80211_bss *bss,
-		      struct mwifiex_802_11_ssid *req_ssid);
+		      struct cfg80211_ssid *req_ssid);
 int mwifiex_cancel_hs(struct mwifiex_private *priv, int cmd_type);
 int mwifiex_enable_hs(struct mwifiex_adapter *adapter);
 int mwifiex_disable_auto_ds(struct mwifiex_private *priv);
@@ -907,7 +906,7 @@ int mwifiex_get_signal_info(struct mwifiex_private *priv,
 int mwifiex_drv_get_data_rate(struct mwifiex_private *priv,
 			      struct mwifiex_rate_cfg *rate);
 int mwifiex_request_scan(struct mwifiex_private *priv,
-			 struct mwifiex_802_11_ssid *req_ssid);
+			 struct cfg80211_ssid *req_ssid);
 int mwifiex_set_user_scan_ioctl(struct mwifiex_private *priv,
 				struct mwifiex_user_scan_cfg *scan_req);
 int mwifiex_change_adhoc_chan(struct mwifiex_private *priv, int channel);
drivers/net/wireless/mwifiex/scan.c +3 -4
index 8f10038..67422f6 100644
@@ -163,8 +163,7 @@ mwifiex_is_wpa_oui_present(struct mwifiex_bssdescriptor *bss_desc, u32 cipher)
  * This function compares two SSIDs and checks if they match.
  */
 s32
-mwifiex_ssid_cmp(struct mwifiex_802_11_ssid *ssid1,
-		 struct mwifiex_802_11_ssid *ssid2)
+mwifiex_ssid_cmp(struct cfg80211_ssid *ssid1, struct cfg80211_ssid *ssid2)
 {
 	if (!ssid1 || !ssid2 || (ssid1->ssid_len != ssid2->ssid_len))
 		return -1;
@@ -1851,7 +1850,7 @@ mwifiex_queue_scan_cmd(struct mwifiex_private *priv,
  * firmware, filtered on a specific SSID.
  */
 static int mwifiex_scan_specific_ssid(struct mwifiex_private *priv,
-				      struct mwifiex_802_11_ssid *req_ssid)
+				      struct cfg80211_ssid *req_ssid)
 {
 	struct mwifiex_adapter *adapter = priv->adapter;
 	int ret = 0;
@@ -1896,7 +1895,7 @@ static int mwifiex_scan_specific_ssid(struct mwifiex_private *priv,
  * scan, depending upon whether an SSID is provided or not.
  */
 int mwifiex_request_scan(struct mwifiex_private *priv,
-			 struct mwifiex_802_11_ssid *req_ssid)
+			 struct cfg80211_ssid *req_ssid)
 {
 	int ret;
 
drivers/net/wireless/mwifiex/sta_event.c +1 -1
index d7aa21d..b9b59db 100644
@@ -101,7 +101,7 @@ mwifiex_reset_connect_state(struct mwifiex_private *priv)
 
 	memcpy(&priv->prev_ssid,
 	       &priv->curr_bss_params.bss_descriptor.ssid,
-	       sizeof(struct mwifiex_802_11_ssid));
+	       sizeof(struct cfg80211_ssid));
 
 	memcpy(priv->prev_bssid,
 	       priv->curr_bss_params.bss_descriptor.mac_address, ETH_ALEN);
drivers/net/wireless/mwifiex/sta_ioctl.c +2 -3
index e10161f..593d285 100644
@@ -192,7 +192,7 @@ int mwifiex_fill_new_bss_desc(struct mwifiex_private *priv,
  * first.
  */
 int mwifiex_bss_start(struct mwifiex_private *priv, struct cfg80211_bss *bss,
-		      struct mwifiex_802_11_ssid *req_ssid)
+		      struct cfg80211_ssid *req_ssid)
 {
 	int ret;
 	struct mwifiex_adapter *adapter = priv->adapter;
@@ -464,8 +464,7 @@ int mwifiex_get_bss_info(struct mwifiex_private *priv,
 
 	info->bss_mode = priv->bss_mode;
 
-	memcpy(&info->ssid, &bss_desc->ssid,
-	       sizeof(struct mwifiex_802_11_ssid));
+	memcpy(&info->ssid, &bss_desc->ssid, sizeof(struct cfg80211_ssid));
 
 	memcpy(&info->bssid, &bss_desc->mac_address, ETH_ALEN);
 
Signature · 1 line
1.7.0.2
author
#5 lore raw

PATCH v2 5/6 mwifiex: fix bug in wildcard scan handling

In reply to Bing Zhao

From: Amitkumar Karwar <[email protected]>

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.

---
V2: Do not use strlen() on an SSID (Johanness Berg)

 drivers/net/wireless/mwifiex/cfg80211.c |   10 +++----
 drivers/net/wireless/mwifiex/fw.h       |   10 ++-----
 drivers/net/wireless/mwifiex/scan.c     |   40 +++++++++++++++---------------
 3 files changed, 27 insertions(+), 33 deletions(-)
drivers/net/wireless/mwifiex/cfg80211.c +4 -6
index 6a91c2f..b4890a0 100644
@@ -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;
drivers/net/wireless/mwifiex/fw.h +3 -7
index c826200..fc4ffee 100644
@@ -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
@@ -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;
drivers/net/wireless/mwifiex/scan.c +20 -20
index 67422f6..fd0302f 100644
@@ -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;
@@ -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 *)
@@ -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
@@ -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;
-
 		}
 
 		/*
@@ -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;
@@ -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);
 
Signature · 1 line
1.7.0.2
author
#6 lore raw

PATCH 6/6 mwifiex: remove BSS entry before specific SSID scan

In reply to Bing Zhao

From: Amitkumar Karwar <[email protected]>

Driver performs specific SSID scan operation when "iw dev <devname> scan ssid <ssid>" command is fired.
Sometimes even if driver could not find the AP with requested SSID in scanning, it is displayed in scan results based on history, because scan table entries are valid in cfg80211 stack for 15 seconds.

This patch adds code to remove respective scan table entry before performing specific SSID scan to make sure that correct scan results are displayed to user.

---
 drivers/net/wireless/mwifiex/scan.c |   23 ++++++++++++++++++++---
 1 files changed, 20 insertions(+), 3 deletions(-)
drivers/net/wireless/mwifiex/scan.c +20 -3
index fd0302f..bb3b3ee 100644
@@ -742,6 +742,7 @@ mwifiex_scan_setup_scan_config(struct mwifiex_private *priv,
 	u8 rates[MWIFIEX_SUPPORTED_RATES];
 	u32 rates_size;
 	struct mwifiex_ie_types_htcap *ht_cap;
+	struct wiphy *wiphy = priv->wdev->wiphy;
 
 	/* The tlv_buf_len is calculated for each scan command.  The TLVs added
 	   in this routine will be preserved since the routine that sends the
@@ -793,7 +794,24 @@ mwifiex_scan_setup_scan_config(struct mwifiex_private *priv,
 		       sizeof(scan_cfg_out->specific_bssid));
 
 		for (i = 0; i < user_scan_in->num_ssids; i++) {
-			ssid_len = user_scan_in->ssid_list[i].ssid_len;
+			struct cfg80211_bss *bss;
+			const struct cfg80211_ssid *ssid =
+					&user_scan_in->ssid_list[i];
+
+			ssid_len = ssid->ssid_len;
+
+			/* Delete an entry for given SSID in scan table */
+			if (ssid_len) {
+				u32 capa =
+				    (priv->bss_mode == NL80211_IFTYPE_STATION) ?
+				    WLAN_CAPABILITY_ESS : WLAN_CAPABILITY_IBSS;
+
+				bss = cfg80211_get_bss(wiphy, NULL, NULL,
+						       ssid->ssid, ssid_len,
+						       capa, capa);
+				if (bss)
+					cfg80211_unlink_bss(wiphy, bss);
+			}
 
 			wildcard_ssid_tlv =
 				(struct mwifiex_ie_types_wildcard_ssid_params *)
@@ -816,8 +834,7 @@ mwifiex_scan_setup_scan_config(struct mwifiex_private *priv,
 				wildcard_ssid_tlv->max_ssid_length =
 							IEEE80211_MAX_SSID_LEN;
 
-			memcpy(wildcard_ssid_tlv->ssid,
-			       user_scan_in->ssid_list[i].ssid, ssid_len);
+			memcpy(wildcard_ssid_tlv->ssid, ssid->ssid, ssid_len);
 
 			tlv_pos += (sizeof(wildcard_ssid_tlv->header)
 				+ le16_to_cpu(wildcard_ssid_tlv->header.len));
Signature · 1 line
1.7.0.2
maintainer
#7 lore raw

Re: [PATCH 6/6] mwifiex: remove BSS entry before specific SSID scan

Quoted 11 lines · Bing Zhao

From: Amitkumar Karwar <[email protected]>

Driver performs specific SSID scan operation when "iw dev <devname> scan ssid <ssid>" command is fired.
Sometimes even if driver could not find the AP with requested SSID in scanning, it is displayed in scan results based on history, because scan table entries are valid in cfg80211 stack for 15 seconds.

This patch adds code to remove respective scan table entry before performing specific SSID scan to make sure that correct scan results are displayed to user.

NACK. This isn't the intended behaviour here. If any such behaviour is desired it should probably be implemented in wpa_s, or maybe in cfg80211, but certainly not in the driver where all it does is make different drivers behave differently.

johannes

author
#9 lore raw

RE: [PATCH 6/6] mwifiex: remove BSS entry before specific SSID scan

In reply to a message not in the archive
Quoted 9 lines
Quoted 9 lines

Driver performs specific SSID scan operation when "iw dev <devname> scan ssid <ssid>" command is fired.
Sometimes even if driver could not find the AP with requested SSID in scanning, it is displayed in scan results based on history, because scan table entries are valid in cfg80211 stack for 15 seconds.

This patch adds code to remove respective scan table entry before performing specific SSID scan to make sure that correct scan results are displayed to user.

Quoted 8 lines

NACK. This isn't the intended behaviour here. If any such behaviour is desired it should probably be implemented in wpa_s, or maybe in cfg80211, but certainly not in the driver where all it does is make different drivers behave differently.

We've talked about passing a flag in w/ the scan request that says "flush your bss cache first". Seems like that'd do what's desired here (and could be used by wpa_supplicant to replace manually flushing stale entries).

Hi Sam,

Is there a patch available for testing?

Thanks,
Bing