wil6210: propagate disconnect reason
authorVladimir Kondratiev <qca_vkondrat@qca.qualcomm.com>
Mon, 1 Dec 2014 13:33:15 +0000 (15:33 +0200)
committerJohn W. Linville <linville@tuxdriver.com>
Mon, 1 Dec 2014 20:57:22 +0000 (15:57 -0500)
Propagate reason for the disconnect through the relevant call chains:
- report to cfg80211 reason as reported by the firmware
- provide to the firmware reason as requested by cfg80211

Signed-off-by: Vladimir Kondratiev <qca_vkondrat@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/ath/wil6210/cfg80211.c
drivers/net/wireless/ath/wil6210/main.c
drivers/net/wireless/ath/wil6210/wil6210.h
drivers/net/wireless/ath/wil6210/wmi.c

index 0fc0b9f8e605f0f51afb3e49e317b2e14cfcc9b4..38332a6dfb3a58d8ed246a8dac627ce18681212b 100644 (file)
@@ -798,7 +798,7 @@ static int wil_cfg80211_del_station(struct wiphy *wiphy,
        struct wil6210_priv *wil = wiphy_to_wil(wiphy);
 
        mutex_lock(&wil->mutex);
-       wil6210_disconnect(wil, params->mac, false);
+       wil6210_disconnect(wil, params->mac, params->reason_code, false);
        mutex_unlock(&wil->mutex);
 
        return 0;
index 6212983fede27d36ce520f78f40668531e7e96ff..151ff6bbce7c9272a3a57c87ad651827d97b6b17 100644 (file)
@@ -104,7 +104,7 @@ void wil_memcpy_toio_32(volatile void __iomem *dst, const void *src,
 }
 
 static void wil_disconnect_cid(struct wil6210_priv *wil, int cid,
-                              bool from_event)
+                              u16 reason_code, bool from_event)
 {
        uint i;
        struct net_device *ndev = wil_to_ndev(wil);
@@ -117,8 +117,7 @@ static void wil_disconnect_cid(struct wil6210_priv *wil, int cid,
        sta->data_port_open = false;
        if (sta->status != wil_sta_unused) {
                if (!from_event)
-                       wmi_disconnect_sta(wil, sta->addr,
-                                          WLAN_REASON_DEAUTH_LEAVING);
+                       wmi_disconnect_sta(wil, sta->addr, reason_code);
 
                switch (wdev->iftype) {
                case NL80211_IFTYPE_AP:
@@ -152,7 +151,7 @@ static void wil_disconnect_cid(struct wil6210_priv *wil, int cid,
 }
 
 static void _wil6210_disconnect(struct wil6210_priv *wil, const u8 *bssid,
-                               bool from_event)
+                               u16 reason_code, bool from_event)
 {
        int cid = -ENOENT;
        struct net_device *ndev = wil_to_ndev(wil);
@@ -167,10 +166,10 @@ static void _wil6210_disconnect(struct wil6210_priv *wil, const u8 *bssid,
        }
 
        if (cid >= 0) /* disconnect 1 peer */
-               wil_disconnect_cid(wil, cid, from_event);
+               wil_disconnect_cid(wil, cid, reason_code, from_event);
        else /* disconnect all */
                for (cid = 0; cid < WIL6210_MAX_CID; cid++)
-                       wil_disconnect_cid(wil, cid, from_event);
+                       wil_disconnect_cid(wil, cid, reason_code, from_event);
 
        /* link state */
        switch (wdev->iftype) {
@@ -179,8 +178,7 @@ static void _wil6210_disconnect(struct wil6210_priv *wil, const u8 *bssid,
                wil_link_off(wil);
                if (test_bit(wil_status_fwconnected, &wil->status)) {
                        clear_bit(wil_status_fwconnected, &wil->status);
-                       cfg80211_disconnected(ndev,
-                                             WLAN_STATUS_UNSPECIFIED_FAILURE,
+                       cfg80211_disconnected(ndev, reason_code,
                                              NULL, 0, GFP_KERNEL);
                } else if (test_bit(wil_status_fwconnecting, &wil->status)) {
                        cfg80211_connect_result(ndev, bssid, NULL, 0, NULL, 0,
@@ -200,7 +198,7 @@ static void wil_disconnect_worker(struct work_struct *work)
                        struct wil6210_priv, disconnect_worker);
 
        mutex_lock(&wil->mutex);
-       _wil6210_disconnect(wil, NULL, false);
+       _wil6210_disconnect(wil, NULL, WLAN_REASON_UNSPECIFIED, false);
        mutex_unlock(&wil->mutex);
 }
 
@@ -392,18 +390,19 @@ int wil_priv_init(struct wil6210_priv *wil)
  * wil6210_disconnect - disconnect one connection
  * @wil: driver context
  * @bssid: peer to disconnect, NULL to disconnect all
+ * @reason_code: Reason code for the Disassociation frame
  * @from_event: whether is invoked from FW event handler
  *
  * Disconnect and release associated resources. If invoked not from the
  * FW event handler, issue WMI command(s) to trigger MAC disconnect.
  */
 void wil6210_disconnect(struct wil6210_priv *wil, const u8 *bssid,
-                       bool from_event)
+                       u16 reason_code, bool from_event)
 {
        wil_dbg_misc(wil, "%s()\n", __func__);
 
        del_timer_sync(&wil->connect_timer);
-       _wil6210_disconnect(wil, bssid, from_event);
+       _wil6210_disconnect(wil, bssid, reason_code, from_event);
 }
 
 void wil_priv_deinit(struct wil6210_priv *wil)
@@ -415,7 +414,7 @@ void wil_priv_deinit(struct wil6210_priv *wil)
        cancel_work_sync(&wil->disconnect_worker);
        cancel_work_sync(&wil->fw_error_worker);
        mutex_lock(&wil->mutex);
-       wil6210_disconnect(wil, NULL, false);
+       wil6210_disconnect(wil, NULL, WLAN_REASON_DEAUTH_LEAVING, false);
        mutex_unlock(&wil->mutex);
        wmi_event_flush(wil);
        destroy_workqueue(wil->wmi_wq_conn);
@@ -600,7 +599,7 @@ int wil_reset(struct wil6210_priv *wil)
        WARN_ON(test_bit(wil_status_napi_en, &wil->status));
 
        cancel_work_sync(&wil->disconnect_worker);
-       wil6210_disconnect(wil, NULL, false);
+       wil6210_disconnect(wil, NULL, WLAN_REASON_DEAUTH_LEAVING, false);
 
        wil->status = 0; /* prevent NAPI from being scheduled */
 
index 95d3a062d35c57d9634dba7bf10a836891de9c50..18cff5340bdccf8b89512a0d3259fc65ec753b10 100644 (file)
@@ -586,7 +586,7 @@ int wmi_set_mac_address(struct wil6210_priv *wil, void *addr);
 int wmi_pcp_start(struct wil6210_priv *wil, int bi, u8 wmi_nettype, u8 chan);
 int wmi_pcp_stop(struct wil6210_priv *wil);
 void wil6210_disconnect(struct wil6210_priv *wil, const u8 *bssid,
-                       bool from_event);
+                       u16 reason_code, bool from_event);
 
 int wil_rx_init(struct wil6210_priv *wil);
 void wil_rx_fini(struct wil6210_priv *wil);
index bb1e066f756a88cd3920cbc62ccf251c5fa6aa4e..63476c86cd0e1b159be33fc85753583a1ca4cd34 100644 (file)
@@ -478,15 +478,15 @@ static void wmi_evt_disconnect(struct wil6210_priv *wil, int id,
                               void *d, int len)
 {
        struct wmi_disconnect_event *evt = d;
+       u16 reason_code = le16_to_cpu(evt->protocol_reason_status);
 
-       wil_dbg_wmi(wil, "Disconnect %pM reason %d proto %d wmi\n",
-                   evt->bssid,
-                   evt->protocol_reason_status, evt->disconnect_reason);
+       wil_dbg_wmi(wil, "Disconnect %pM reason [proto %d wmi %d]\n",
+                   evt->bssid, reason_code, evt->disconnect_reason);
 
        wil->sinfo_gen++;
 
        mutex_lock(&wil->mutex);
-       wil6210_disconnect(wil, evt->bssid, true);
+       wil6210_disconnect(wil, evt->bssid, reason_code, true);
        mutex_unlock(&wil->mutex);
 }