qcacld-3.0: Add USB bus support (HDD)

Add HDD specific changes for USB bus support.

CRs-Fixed: 1023663
Change-Id: I572a78cd9de1f7e531f300ced69a7eb51f4a167f
diff --git a/core/hdd/inc/wlan_hdd_ipa.h b/core/hdd/inc/wlan_hdd_ipa.h
index a7e8d5f..f7221a6 100644
--- a/core/hdd/inc/wlan_hdd_ipa.h
+++ b/core/hdd/inc/wlan_hdd_ipa.h
@@ -35,7 +35,27 @@
  * Originally written by Qualcomm Atheros, Inc
  */
 
-#include <linux/ipa.h>
+/**
+ * enum hdd_ipa_wlan_event - HDD IPA events
+ * @HDD_IPA_CLIENT_CONNECT: Client Connects
+ * @HDD_IPA_CLIENT_DISCONNECT: Client Disconnects
+ * @HDD_IPA_AP_CONNECT: SoftAP is started
+ * @HDD_IPA_AP_DISCONNECT: SoftAP is stopped
+ * @HDD_IPA_STA_CONNECT: STA associates to AP
+ * @HDD_IPA_STA_DISCONNECT: STA dissociates from AP
+ * @HDD_IPA_CLIENT_CONNECT_EX: Peer associates/re-associates to softap
+ * @HDD_IPA_WLAN_EVENT_MAX: Max value for the enum
+ */
+enum hdd_ipa_wlan_event {
+	HDD_IPA_CLIENT_CONNECT,
+	HDD_IPA_CLIENT_DISCONNECT,
+	HDD_IPA_AP_CONNECT,
+	HDD_IPA_AP_DISCONNECT,
+	HDD_IPA_STA_CONNECT,
+	HDD_IPA_STA_DISCONNECT,
+	HDD_IPA_CLIENT_CONNECT_EX,
+	HDD_IPA_WLAN_EVENT_MAX
+};
 
 #ifdef IPA_OFFLOAD
 /* Include files */
@@ -57,7 +77,7 @@
 QDF_STATUS hdd_ipa_process_rxt(void *cds_context, qdf_nbuf_t rxBuf,
 	uint8_t sta_id);
 int hdd_ipa_wlan_evt(hdd_adapter_t *adapter, uint8_t sta_id,
-	enum ipa_wlan_event type, uint8_t *mac_addr);
+	enum hdd_ipa_wlan_event type, uint8_t *mac_addr);
 int hdd_ipa_set_perf_level(hdd_context_t *hdd_ctx, uint64_t tx_packets,
 	uint64_t rx_packets);
 int hdd_ipa_suspend(hdd_context_t *hdd_ctx);
@@ -92,7 +112,7 @@
 }
 
 static inline int hdd_ipa_wlan_evt(hdd_adapter_t *adapter, uint8_t sta_id,
-	enum ipa_wlan_event type, uint8_t *mac_addr)
+	enum hdd_ipa_wlan_event type, uint8_t *mac_addr)
 {
 	return 0;
 }
diff --git a/core/hdd/src/wlan_hdd_assoc.c b/core/hdd/src/wlan_hdd_assoc.c
index f6919bb..bed513c 100644
--- a/core/hdd/src/wlan_hdd_assoc.c
+++ b/core/hdd/src/wlan_hdd_assoc.c
@@ -1593,8 +1593,8 @@
 
 	if (hdd_ipa_is_enabled(pHddCtx))
 		hdd_ipa_wlan_evt(pAdapter, pHddStaCtx->conn_info.staId[0],
-				 WLAN_STA_DISCONNECT,
-				 pHddStaCtx->conn_info.bssId.bytes);
+				HDD_IPA_STA_DISCONNECT,
+				pHddStaCtx->conn_info.bssId.bytes);
 
 #ifdef FEATURE_WLAN_AUTO_SHUTDOWN
 	wlan_hdd_auto_shutdown_enable(pHddCtx, true);
@@ -2453,7 +2453,7 @@
 
 		if (hdd_ipa_is_enabled(pHddCtx))
 			hdd_ipa_wlan_evt(pAdapter, pRoamInfo->staId,
-					 WLAN_STA_CONNECT,
+					 HDD_IPA_STA_CONNECT,
 					 pRoamInfo->bssid.bytes);
 
 #ifdef FEATURE_WLAN_AUTO_SHUTDOWN
diff --git a/core/hdd/src/wlan_hdd_cfg80211.c b/core/hdd/src/wlan_hdd_cfg80211.c
index b73d99c..b0c9328 100644
--- a/core/hdd/src/wlan_hdd_cfg80211.c
+++ b/core/hdd/src/wlan_hdd_cfg80211.c
@@ -12329,7 +12329,7 @@
 							pAdapter->
 								 aStaInfo[i].
 								 ucSTAId,
-							WLAN_CLIENT_DISCONNECT,
+							HDD_IPA_CLIENT_DISCONNECT,
 							mac);
 					}
 					hdd_notice("Delete STA with MAC::"
@@ -12373,7 +12373,7 @@
 
 			if (hdd_ipa_uc_is_enabled(pHddCtx)) {
 				hdd_ipa_wlan_evt(pAdapter, staId,
-						 WLAN_CLIENT_DISCONNECT, mac);
+					HDD_IPA_CLIENT_DISCONNECT, mac);
 			}
 
 			if (pAdapter->aStaInfo[staId].isDeauthInProgress ==
diff --git a/core/hdd/src/wlan_hdd_driver_ops.c b/core/hdd/src/wlan_hdd_driver_ops.c
index e4527bd..4470ca3 100644
--- a/core/hdd/src/wlan_hdd_driver_ops.c
+++ b/core/hdd/src/wlan_hdd_driver_ops.c
@@ -193,6 +193,8 @@
 		return QDF_BUS_TYPE_SNOC;
 	case PLD_BUS_TYPE_SDIO:
 		return QDF_BUS_TYPE_SDIO;
+	case PLD_BUS_TYPE_USB:
+		return QDF_BUS_TYPE_USB;
 	default:
 		return QDF_BUS_TYPE_NONE;
 	}
@@ -446,7 +448,7 @@
 
 	hdd_deinit();
 
-	pr_info("%s: Driver Removed\n", WLAN_MODULE_NAME);
+	pr_info("%s: Driver De-initialized\n", WLAN_MODULE_NAME);
 }
 
 /**
@@ -658,6 +660,25 @@
 	return ret;
 }
 
+/**
+ * wlan_hdd_bus_reset_resume() - resume wlan bus after reset
+ *
+ * This function is called to tell the driver that the device has been resumed
+ * and it has also been reset. The driver should redo any necessary
+ * initialization. It is mainly used by the USB bus
+ *
+ * Return: int 0 for success, non zero for failure
+ */
+static int wlan_hdd_bus_reset_resume(void)
+{
+	int ret;
+
+	cds_ssr_protect(__func__);
+	ret = hif_bus_reset_resume(cds_get_context(QDF_MODULE_ID_HIF));
+	cds_ssr_unprotect(__func__);
+	return ret;
+}
+
 #ifdef FEATURE_RUNTIME_PM
 /**
  * __wlan_hdd_runtime_suspend() - suspend the wlan bus without apps suspend
@@ -902,6 +923,19 @@
 }
 
 /**
+ * wlan_hdd_pld_reset_resume() - reset resume function registered to PLD
+ * @dev: device
+ * @pld_bus_type: PLD bus type
+ *
+ * Return: 0 on success
+ */
+static int wlan_hdd_pld_reset_resume(struct device *dev,
+		    enum pld_bus_type bus_type)
+{
+	return wlan_hdd_bus_reset_resume();
+}
+
+/**
  * wlan_hdd_pld_notify_handler() - notify_handler function registered to PLD
  * @dev: device
  * @pld_bus_type: PLD bus type
@@ -952,6 +986,7 @@
 	.crash_shutdown = wlan_hdd_pld_crash_shutdown,
 	.suspend    = wlan_hdd_pld_suspend,
 	.resume     = wlan_hdd_pld_resume,
+	.reset_resume = wlan_hdd_pld_reset_resume,
 	.modem_status = wlan_hdd_pld_notify_handler,
 #ifdef FEATURE_RUNTIME_PM
 	.runtime_suspend = wlan_hdd_pld_runtime_suspend,
diff --git a/core/hdd/src/wlan_hdd_ftm.c b/core/hdd/src/wlan_hdd_ftm.c
index 83d4cdd..b3e88a2 100644
--- a/core/hdd/src/wlan_hdd_ftm.c
+++ b/core/hdd/src/wlan_hdd_ftm.c
@@ -76,6 +76,7 @@
 } qcmbr_queue_t;
 LIST_HEAD(qcmbr_queue_head);
 DEFINE_SPINLOCK(qcmbr_queue_lock);
+static void wlanqcmbr_mc_process_msg(void *message);
 #endif
 #endif
 
diff --git a/core/hdd/src/wlan_hdd_hostapd.c b/core/hdd/src/wlan_hdd_hostapd.c
index d7c8aa3..235c050 100644
--- a/core/hdd/src/wlan_hdd_hostapd.c
+++ b/core/hdd/src/wlan_hdd_hostapd.c
@@ -1078,7 +1078,7 @@
 		if (hdd_ipa_is_enabled(pHddCtx)) {
 			status = hdd_ipa_wlan_evt(pHostapdAdapter,
 					pHddApCtx->uBCStaId,
-					WLAN_AP_CONNECT,
+					HDD_IPA_AP_CONNECT,
 					pHostapdAdapter->dev->dev_addr);
 			if (status) {
 				hdd_err("WLAN_AP_CONNECT event failed!!");
@@ -1234,7 +1234,7 @@
 		if (hdd_ipa_is_enabled(pHddCtx)) {
 			status = hdd_ipa_wlan_evt(pHostapdAdapter,
 					pHddApCtx->uBCStaId,
-					WLAN_AP_DISCONNECT,
+					HDD_IPA_AP_DISCONNECT,
 					pHostapdAdapter->dev->dev_addr);
 			if (status) {
 				hdd_err("WLAN_AP_DISCONNECT event failed!!");
@@ -1473,7 +1473,7 @@
 			status = hdd_ipa_wlan_evt(pHostapdAdapter,
 					pSapEvent->sapevt.
 					sapStationAssocReassocCompleteEvent.
-					staId, WLAN_CLIENT_CONNECT_EX,
+					staId, HDD_IPA_CLIENT_CONNECT_EX,
 					pSapEvent->sapevt.
 					sapStationAssocReassocCompleteEvent.
 					staMac.bytes);
@@ -1608,7 +1608,7 @@
 #ifdef IPA_OFFLOAD
 		if (hdd_ipa_is_enabled(pHddCtx)) {
 			status = hdd_ipa_wlan_evt(pHostapdAdapter, staId,
-					WLAN_CLIENT_DISCONNECT,
+					HDD_IPA_CLIENT_DISCONNECT,
 					pSapEvent->sapevt.
 					sapStationDisassocCompleteEvent.
 					staMac.bytes);
diff --git a/core/hdd/src/wlan_hdd_ipa.c b/core/hdd/src/wlan_hdd_ipa.c
index 87ae722..1377b92 100644
--- a/core/hdd/src/wlan_hdd_ipa.c
+++ b/core/hdd/src/wlan_hdd_ipa.c
@@ -35,6 +35,7 @@
 #ifdef IPA_OFFLOAD
 
 /* Include Files */
+#include <linux/ipa.h>
 #include <wlan_hdd_includes.h>
 #include <wlan_hdd_ipa.h>
 
@@ -593,6 +594,7 @@
 			   unsigned long data);
 
 static void hdd_ipa_cleanup_iface(struct hdd_ipa_iface_context *iface_context);
+static void hdd_ipa_uc_proc_pending_event (struct hdd_ipa_priv *hdd_ipa);
 
 /**
  * hdd_ipa_is_enabled() - Is IPA enabled?
@@ -1290,40 +1292,6 @@
 }
 
 /**
- * hdd_ipa_uc_proc_pending_event() - Process IPA uC pending events
- * @hdd_ipa: Global HDD IPA context
- *
- * Return: None
- */
-static void hdd_ipa_uc_proc_pending_event(struct hdd_ipa_priv *hdd_ipa)
-{
-	unsigned int pending_event_count;
-	struct ipa_uc_pending_event *pending_event = NULL;
-
-	pending_event_count = qdf_list_size(&hdd_ipa->pending_event);
-	HDD_IPA_LOG(QDF_TRACE_LEVEL_INFO,
-		"%s, Pending Event Count %d", __func__, pending_event_count);
-	if (!pending_event_count) {
-		HDD_IPA_LOG(QDF_TRACE_LEVEL_INFO,
-			"%s, No Pending Event", __func__);
-		return;
-	}
-
-	qdf_list_remove_front(&hdd_ipa->pending_event,
-			(qdf_list_node_t **)&pending_event);
-	while (pending_event != NULL) {
-		hdd_ipa_wlan_evt(pending_event->adapter,
-			pending_event->type,
-			pending_event->sta_id,
-			pending_event->mac_addr);
-		qdf_mem_free(pending_event);
-		pending_event = NULL;
-		qdf_list_remove_front(&hdd_ipa->pending_event,
-			(qdf_list_node_t **)&pending_event);
-	}
-}
-
-/**
  * hdd_ipa_uc_op_cb() - IPA uC operation callback
  * @op_msg: operation message received from firmware
  * @usr_ctxt: user context registered with TL (we register the HDD Global
@@ -3582,15 +3550,59 @@
 }
 
 /**
- * hdd_ipa_wlan_evt() - IPA event handler
+ * hdd_to_ipa_wlan_event() - convert hdd_ipa_wlan_event to ipa_wlan_event
+ * @hdd_ipa_event_type: HDD IPA WLAN event to be converted to an ipa_wlan_event
+ *
+ * Return: ipa_wlan_event representing the hdd_ipa_wlan_event
+ */
+static enum ipa_wlan_event
+hdd_to_ipa_wlan_event(enum hdd_ipa_wlan_event hdd_ipa_event_type)
+{
+	enum ipa_wlan_event ipa_event;
+
+	switch (hdd_ipa_event_type) {
+	case HDD_IPA_CLIENT_CONNECT:
+		ipa_event = WLAN_CLIENT_CONNECT;
+		break;
+	case HDD_IPA_CLIENT_DISCONNECT:
+		ipa_event = WLAN_CLIENT_DISCONNECT;
+		break;
+	case HDD_IPA_AP_CONNECT:
+		ipa_event = WLAN_AP_CONNECT;
+		break;
+	case HDD_IPA_AP_DISCONNECT:
+		ipa_event = WLAN_AP_DISCONNECT;
+		break;
+	case HDD_IPA_STA_CONNECT:
+		ipa_event = WLAN_STA_CONNECT;
+		break;
+	case HDD_IPA_STA_DISCONNECT:
+		ipa_event = WLAN_STA_DISCONNECT;
+		break;
+	case HDD_IPA_CLIENT_CONNECT_EX:
+		ipa_event = WLAN_CLIENT_CONNECT_EX;
+		break;
+	case HDD_IPA_WLAN_EVENT_MAX:
+	default:
+		ipa_event = IPA_WLAN_EVENT_MAX;
+		break;
+	}
+	return ipa_event;
+
+}
+
+/**
+ * __hdd_ipa_wlan_evt() - IPA event handler
  * @adapter: adapter upon which the event was received
  * @sta_id: station id for the event
- * @type: the event type
+ * @type: event enum of type ipa_wlan_event
  * @mac_address: MAC address associated with the event
  *
+ * This function is meant to be called from within wlan_hdd_ipa.c
+ *
  * Return: 0 on success, negative errno value on error
  */
-int hdd_ipa_wlan_evt(hdd_adapter_t *adapter, uint8_t sta_id,
+static int __hdd_ipa_wlan_evt(hdd_adapter_t *adapter, uint8_t sta_id,
 		     enum ipa_wlan_event type, uint8_t *mac_addr)
 {
 	struct hdd_ipa_priv *hdd_ipa = ghdd_ipa;
@@ -3958,6 +3970,60 @@
 }
 
 /**
+ * hdd_ipa_wlan_evt() - IPA event handler
+ * @adapter: adapter upon which the event was received
+ * @sta_id: station id for the event
+ * @hdd_event_type: event enum of type hdd_ipa_wlan_event
+ * @mac_address: MAC address associated with the event
+ *
+ * This function is meant to be called from outside of wlan_hdd_ipa.c.
+ *
+ * Return: 0 on success, negative errno value on error
+ */
+int hdd_ipa_wlan_evt(hdd_adapter_t *adapter, uint8_t sta_id,
+	enum hdd_ipa_wlan_event hdd_event_type, uint8_t *mac_addr)
+{
+	enum ipa_wlan_event type = hdd_to_ipa_wlan_event(hdd_event_type);
+
+	return __hdd_ipa_wlan_evt(adapter, sta_id, type, mac_addr);
+}
+
+/**
+ * hdd_ipa_uc_proc_pending_event() - Process IPA uC pending events
+ * @hdd_ipa: Global HDD IPA context
+ *
+ * Return: None
+ */
+static void
+hdd_ipa_uc_proc_pending_event(struct hdd_ipa_priv *hdd_ipa)
+{
+	unsigned int pending_event_count;
+	struct ipa_uc_pending_event *pending_event = NULL;
+
+	pending_event_count = qdf_list_size(&hdd_ipa->pending_event);
+	HDD_IPA_LOG(QDF_TRACE_LEVEL_INFO,
+		"%s, Pending Event Count %d", __func__, pending_event_count);
+	if (!pending_event_count) {
+		HDD_IPA_LOG(QDF_TRACE_LEVEL_INFO,
+			"%s, No Pending Event", __func__);
+		return;
+	}
+
+	qdf_list_remove_front(&hdd_ipa->pending_event,
+			(qdf_list_node_t **)&pending_event);
+	while (pending_event != NULL) {
+		__hdd_ipa_wlan_evt(pending_event->adapter,
+			pending_event->type,
+			pending_event->sta_id,
+			pending_event->mac_addr);
+		qdf_mem_free(pending_event);
+		pending_event = NULL;
+		qdf_list_remove_front(&hdd_ipa->pending_event,
+			(qdf_list_node_t **)&pending_event);
+	}
+}
+
+/**
  * hdd_ipa_rm_state_to_str() - Convert IPA RM state to string
  * @state: IPA RM state value
  *
diff --git a/core/hdd/src/wlan_hdd_main.c b/core/hdd/src/wlan_hdd_main.c
index 0090d0b..b2699bc 100644
--- a/core/hdd/src/wlan_hdd_main.c
+++ b/core/hdd/src/wlan_hdd_main.c
@@ -8506,7 +8506,8 @@
 
 	ret = wlan_hdd_register_driver();
 	if (ret) {
-		pr_err("%s: driver load failure\n", WLAN_MODULE_NAME);
+		pr_err("%s: driver load failure, err %d\n", WLAN_MODULE_NAME,
+			ret);
 		goto out;
 	}