Commit 8cc1d523 authored by Amitkumar Karwar's avatar Amitkumar Karwar Committed by John W. Linville

mwifiex: update cfg80211 with correct reason code when connection is lost

Driver gets LINK_LOST, DEAUTHENTICATED and DISASSOCIATED events
from firmware when connection is lost in different scenarios.
Currently we are using common code WLAN_REASON_DEAUTH_LEAVING
for these cases.

This patch adds support to parse an actual reason code from
firmware event body and send it to cfg80211.
WLAN_REASON_DEAUTH_LEAVING code is used if deauth is initiated
by our device.
Signed-off-by: default avatarAmitkumar Karwar <akarwar@marvell.com>
Signed-off-by: default avatarBing Zhao <bzhao@marvell.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 06975884
...@@ -1180,16 +1180,18 @@ int mwifiex_ret_802_11_ad_hoc(struct mwifiex_private *priv, ...@@ -1180,16 +1180,18 @@ int mwifiex_ret_802_11_ad_hoc(struct mwifiex_private *priv,
struct mwifiex_adapter *adapter = priv->adapter; struct mwifiex_adapter *adapter = priv->adapter;
struct host_cmd_ds_802_11_ad_hoc_result *adhoc_result; struct host_cmd_ds_802_11_ad_hoc_result *adhoc_result;
struct mwifiex_bssdescriptor *bss_desc; struct mwifiex_bssdescriptor *bss_desc;
u16 reason_code;
adhoc_result = &resp->params.adhoc_result; adhoc_result = &resp->params.adhoc_result;
bss_desc = priv->attempted_bss_desc; bss_desc = priv->attempted_bss_desc;
/* Join result code 0 --> SUCCESS */ /* Join result code 0 --> SUCCESS */
if (le16_to_cpu(resp->result)) { reason_code = le16_to_cpu(resp->result);
if (reason_code) {
dev_err(priv->adapter->dev, "ADHOC_RESP: failed\n"); dev_err(priv->adapter->dev, "ADHOC_RESP: failed\n");
if (priv->media_connected) if (priv->media_connected)
mwifiex_reset_connect_state(priv); mwifiex_reset_connect_state(priv, reason_code);
memset(&priv->curr_bss_params.bss_descriptor, memset(&priv->curr_bss_params.bss_descriptor,
0x00, sizeof(struct mwifiex_bssdescriptor)); 0x00, sizeof(struct mwifiex_bssdescriptor));
......
...@@ -847,7 +847,7 @@ int mwifiex_cmd_802_11_associate(struct mwifiex_private *priv, ...@@ -847,7 +847,7 @@ int mwifiex_cmd_802_11_associate(struct mwifiex_private *priv,
struct mwifiex_bssdescriptor *bss_desc); struct mwifiex_bssdescriptor *bss_desc);
int mwifiex_ret_802_11_associate(struct mwifiex_private *priv, int mwifiex_ret_802_11_associate(struct mwifiex_private *priv,
struct host_cmd_ds_command *resp); struct host_cmd_ds_command *resp);
void mwifiex_reset_connect_state(struct mwifiex_private *priv); void mwifiex_reset_connect_state(struct mwifiex_private *priv, u16 reason);
u8 mwifiex_band_to_radio_type(u8 band); u8 mwifiex_band_to_radio_type(u8 band);
int mwifiex_deauthenticate(struct mwifiex_private *priv, u8 *mac); int mwifiex_deauthenticate(struct mwifiex_private *priv, u8 *mac);
int mwifiex_adhoc_start(struct mwifiex_private *priv, int mwifiex_adhoc_start(struct mwifiex_private *priv,
......
...@@ -545,7 +545,7 @@ static int mwifiex_ret_802_11_deauthenticate(struct mwifiex_private *priv, ...@@ -545,7 +545,7 @@ static int mwifiex_ret_802_11_deauthenticate(struct mwifiex_private *priv,
if (!memcmp(resp->params.deauth.mac_addr, if (!memcmp(resp->params.deauth.mac_addr,
&priv->curr_bss_params.bss_descriptor.mac_address, &priv->curr_bss_params.bss_descriptor.mac_address,
sizeof(resp->params.deauth.mac_addr))) sizeof(resp->params.deauth.mac_addr)))
mwifiex_reset_connect_state(priv); mwifiex_reset_connect_state(priv, WLAN_REASON_DEAUTH_LEAVING);
return 0; return 0;
} }
...@@ -558,7 +558,7 @@ static int mwifiex_ret_802_11_deauthenticate(struct mwifiex_private *priv, ...@@ -558,7 +558,7 @@ static int mwifiex_ret_802_11_deauthenticate(struct mwifiex_private *priv,
static int mwifiex_ret_802_11_ad_hoc_stop(struct mwifiex_private *priv, static int mwifiex_ret_802_11_ad_hoc_stop(struct mwifiex_private *priv,
struct host_cmd_ds_command *resp) struct host_cmd_ds_command *resp)
{ {
mwifiex_reset_connect_state(priv); mwifiex_reset_connect_state(priv, WLAN_REASON_DEAUTH_LEAVING);
return 0; return 0;
} }
......
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
* - Sends a disconnect event to upper layers/applications. * - Sends a disconnect event to upper layers/applications.
*/ */
void void
mwifiex_reset_connect_state(struct mwifiex_private *priv) mwifiex_reset_connect_state(struct mwifiex_private *priv, u16 reason_code)
{ {
struct mwifiex_adapter *adapter = priv->adapter; struct mwifiex_adapter *adapter = priv->adapter;
...@@ -117,10 +117,10 @@ mwifiex_reset_connect_state(struct mwifiex_private *priv) ...@@ -117,10 +117,10 @@ mwifiex_reset_connect_state(struct mwifiex_private *priv)
priv->media_connected = false; priv->media_connected = false;
dev_dbg(adapter->dev, dev_dbg(adapter->dev,
"info: successfully disconnected from %pM: reason code %d\n", "info: successfully disconnected from %pM: reason code %d\n",
priv->cfg_bssid, WLAN_REASON_DEAUTH_LEAVING); priv->cfg_bssid, reason_code);
if (priv->bss_mode == NL80211_IFTYPE_STATION) { if (priv->bss_mode == NL80211_IFTYPE_STATION) {
cfg80211_disconnected(priv->netdev, WLAN_REASON_DEAUTH_LEAVING, cfg80211_disconnected(priv->netdev, reason_code, NULL, 0,
NULL, 0, GFP_KERNEL); GFP_KERNEL);
} }
memset(priv->cfg_bssid, 0, ETH_ALEN); memset(priv->cfg_bssid, 0, ETH_ALEN);
...@@ -186,7 +186,7 @@ int mwifiex_process_sta_event(struct mwifiex_private *priv) ...@@ -186,7 +186,7 @@ int mwifiex_process_sta_event(struct mwifiex_private *priv)
struct mwifiex_adapter *adapter = priv->adapter; struct mwifiex_adapter *adapter = priv->adapter;
int ret = 0; int ret = 0;
u32 eventcause = adapter->event_cause; u32 eventcause = adapter->event_cause;
u16 ctrl; u16 ctrl, reason_code;
switch (eventcause) { switch (eventcause) {
case EVENT_DUMMY_HOST_WAKEUP_SIGNAL: case EVENT_DUMMY_HOST_WAKEUP_SIGNAL:
...@@ -204,22 +204,31 @@ int mwifiex_process_sta_event(struct mwifiex_private *priv) ...@@ -204,22 +204,31 @@ int mwifiex_process_sta_event(struct mwifiex_private *priv)
case EVENT_DEAUTHENTICATED: case EVENT_DEAUTHENTICATED:
dev_dbg(adapter->dev, "event: Deauthenticated\n"); dev_dbg(adapter->dev, "event: Deauthenticated\n");
adapter->dbg.num_event_deauth++; adapter->dbg.num_event_deauth++;
if (priv->media_connected) if (priv->media_connected) {
mwifiex_reset_connect_state(priv); reason_code =
le16_to_cpu(*(__le16 *)adapter->event_body);
mwifiex_reset_connect_state(priv, reason_code);
}
break; break;
case EVENT_DISASSOCIATED: case EVENT_DISASSOCIATED:
dev_dbg(adapter->dev, "event: Disassociated\n"); dev_dbg(adapter->dev, "event: Disassociated\n");
adapter->dbg.num_event_disassoc++; adapter->dbg.num_event_disassoc++;
if (priv->media_connected) if (priv->media_connected) {
mwifiex_reset_connect_state(priv); reason_code =
le16_to_cpu(*(__le16 *)adapter->event_body);
mwifiex_reset_connect_state(priv, reason_code);
}
break; break;
case EVENT_LINK_LOST: case EVENT_LINK_LOST:
dev_dbg(adapter->dev, "event: Link lost\n"); dev_dbg(adapter->dev, "event: Link lost\n");
adapter->dbg.num_event_link_lost++; adapter->dbg.num_event_link_lost++;
if (priv->media_connected) if (priv->media_connected) {
mwifiex_reset_connect_state(priv); reason_code =
le16_to_cpu(*(__le16 *)adapter->event_body);
mwifiex_reset_connect_state(priv, reason_code);
}
break; break;
case EVENT_PS_SLEEP: case EVENT_PS_SLEEP:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment