qcacld-3.0: Send disconnect event to upper layers upon disconnect
Indicate disconnect event to nl80211 and thereby to the supplicant
by invoking cfg80211_disconnect upon disconnect as kernel 3.11 onward
releases will not indicate the same to upper layers.
Call to cfg80211_disconnect also signifies whether disconnect is
triggered by the supplicant or received from the AP by setting the
"from_ap" flag accordingly.
qcacld-2.0 to qcacld-3.0 propagation
Change-Id: I55028533ebbf03910755da1b35c2fa57d97ce43b
CRs-Fixed: 1016872
diff --git a/core/hdd/src/wlan_hdd_assoc.c b/core/hdd/src/wlan_hdd_assoc.c
index ddf6059..28a98c5 100644
--- a/core/hdd/src/wlan_hdd_assoc.c
+++ b/core/hdd/src/wlan_hdd_assoc.c
@@ -1066,7 +1066,7 @@
/* HDD has initiated disconnect, do not send disconnect indication
* to kernel. Sending disconnected event to kernel for userspace
- * initiated disconnect will be handled by hdd_DisConnectHandler call
+ * initiated disconnect will be handled by disconnect handler call
* to cfg80211_disconnected.
*/
if ((eConnectionState_Disconnecting ==
@@ -1104,19 +1104,14 @@
if (pRoamInfo->reasonCode ==
eSIR_MAC_PEER_STA_REQ_LEAVING_BSS_REASON)
pr_info("wlan: disconnected due to poor signal, rssi is %d dB\n", pRoamInfo->rxRssi);
- cfg80211_disconnected(dev, pRoamInfo->
- reasonCode, NULL, 0,
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0)) || defined(WITH_BACKPORTS)
- true,
-#endif
- GFP_KERNEL);
+ wlan_hdd_cfg80211_indicate_disconnect(
+ dev, false,
+ pRoamInfo->reasonCode);
} else {
- cfg80211_disconnected(dev,
- WLAN_REASON_UNSPECIFIED, NULL, 0,
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0)) || defined(WITH_BACKPORTS)
- true,
-#endif
- GFP_KERNEL);
+ wlan_hdd_cfg80211_indicate_disconnect(
+ dev, false,
+ WLAN_REASON_UNSPECIFIED
+ );
}
hdd_info("sent disconnected event to nl80211, rssi: %d",
diff --git a/core/hdd/src/wlan_hdd_cfg80211.c b/core/hdd/src/wlan_hdd_cfg80211.c
index 9dd2324..366687c 100644
--- a/core/hdd/src/wlan_hdd_cfg80211.c
+++ b/core/hdd/src/wlan_hdd_cfg80211.c
@@ -9899,11 +9899,8 @@
* is handled by __cfg80211_disconnect call to __cfg80211_disconnected
*/
hddLog(LOG1, FL("Send disconnected event to userspace"));
- cfg80211_disconnected(pAdapter->dev, WLAN_REASON_UNSPECIFIED, NULL, 0,
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0)) || defined(WITH_BACKPORTS)
- false,
-#endif
- GFP_KERNEL);
+ wlan_hdd_cfg80211_indicate_disconnect(pAdapter->dev, true,
+ WLAN_REASON_UNSPECIFIED);
#endif
return result;
diff --git a/core/hdd/src/wlan_hdd_cfg80211.h b/core/hdd/src/wlan_hdd_cfg80211.h
index c91fa41..a3ab748 100644
--- a/core/hdd/src/wlan_hdd_cfg80211.h
+++ b/core/hdd/src/wlan_hdd_cfg80211.h
@@ -2551,4 +2551,23 @@
void hdd_get_bpf_offload_cb(void *hdd_context, struct sir_bpf_get_offload *);
void hdd_init_bpf_completion(void);
+
+#if defined(CFG80211_DISCONNECTED_V2) || \
+(LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0))
+static inline void wlan_hdd_cfg80211_indicate_disconnect(struct net_device *dev,
+ bool locally_generated,
+ int reason)
+{
+ cfg80211_disconnected(dev, reason, NULL, 0,
+ locally_generated, GFP_KERNEL);
+}
+#else
+static inline void wlan_hdd_cfg80211_indicate_disconnect(struct net_device *dev,
+ bool locally_generated,
+ int reason)
+{
+ cfg80211_disconnected(dev, reason, NULL, 0,
+ GFP_KERNEL);
+}
+#endif
#endif
diff --git a/core/hdd/src/wlan_hdd_main.c b/core/hdd/src/wlan_hdd_main.c
index 8cd1271..2fe155d 100644
--- a/core/hdd/src/wlan_hdd_main.c
+++ b/core/hdd/src/wlan_hdd_main.c
@@ -3262,13 +3262,9 @@
hdd_ReassocScenario = false;
/* indicate disconnected event to nl80211 */
- cfg80211_disconnected(adapter->dev,
- WLAN_REASON_UNSPECIFIED,
- NULL, 0,
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0)) || defined(WITH_BACKPORTS)
- true,
-#endif
- GFP_KERNEL);
+ wlan_hdd_cfg80211_indicate_disconnect(
+ adapter->dev, false,
+ WLAN_REASON_UNSPECIFIED);
} else if (eConnectionState_Connecting == connState) {
/*
* Indicate connect failure to supplicant if we were in the