qcacld-3.0: Remove work-queue mechanism for TDLS Discovery Req

prima to qcacld-3.0 propagation

This commit removes work-queue mechanism which is used to
trigger the TDLS Discovery request.

This eliminates concurrent TDLS data structures access.

Change-Id: Id6d6b38d2b17c4b1bab9b616b52e5a2d8c3475dc
Crs-Fixed: 798119
diff --git a/core/hdd/inc/wlan_hdd_tdls.h b/core/hdd/inc/wlan_hdd_tdls.h
index 907e42e..c9e9889 100644
--- a/core/hdd/inc/wlan_hdd_tdls.h
+++ b/core/hdd/inc/wlan_hdd_tdls.h
@@ -350,7 +350,6 @@
  * @discovery_sent_cnt: discovery sent count
  * @ap_rssi: ap rssi
  * @curr_candidate: current candidate
- * @implicit_setup: implicit setup work queue
  * @ct_peer_mac_table: linear mac address table for counting the packets
  * @valid_mac_entries: number of valid mac entry in @ct_peer_mac_table
  * @magic: magic
@@ -366,7 +365,6 @@
 	uint32_t discovery_sent_cnt;
 	int8_t ap_rssi;
 	struct _hddTdlsPeer_t *curr_candidate;
-	struct work_struct implicit_setup;
 	struct tdls_ct_mac_table ct_peer_mac_table[TDLS_CT_MAC_MAX_TABLE_SIZE];
 	uint8_t valid_mac_entries;
 	uint32_t magic;
@@ -591,8 +589,7 @@
 				     hddTdlsPeer_t *curr_peer,
 				     uint16_t reason);
 
-void wlan_hdd_tdls_pre_setup_init_work(tdlsCtx_t *pHddTdlsCtx,
-				       hddTdlsPeer_t *curr_candidate);
+void wlan_hdd_tdls_implicit_send_discovery_request(tdlsCtx_t *hdd_tdls_ctx);
 
 int wlan_hdd_tdls_set_extctrl_param(hdd_adapter_t *pAdapter,
 				    const uint8_t *mac,
diff --git a/core/hdd/src/wlan_hdd_assoc.c b/core/hdd/src/wlan_hdd_assoc.c
index b690dda..1f7a06e 100644
--- a/core/hdd/src/wlan_hdd_assoc.c
+++ b/core/hdd/src/wlan_hdd_assoc.c
@@ -3925,8 +3925,9 @@
 						curr_peer->isForcedPeer,
 						pRoamInfo->reasonCode);
 				}
-				wlan_hdd_tdls_pre_setup_init_work
-					(pHddTdlsCtx, curr_peer);
+				pHddTdlsCtx->curr_candidate = curr_peer;
+				wlan_hdd_tdls_implicit_send_discovery_request(
+								pHddTdlsCtx);
 			}
 			status = QDF_STATUS_SUCCESS;
 		}
diff --git a/core/hdd/src/wlan_hdd_tdls.c b/core/hdd/src/wlan_hdd_tdls.c
index e126b2e..f26b839 100644
--- a/core/hdd/src/wlan_hdd_tdls.c
+++ b/core/hdd/src/wlan_hdd_tdls.c
@@ -52,7 +52,6 @@
 							    pHddTdlsCtx);
 static void wlan_hdd_tdls_timers_destroy(tdlsCtx_t *pHddTdlsCtx);
 int wpa_tdls_is_allowed_force_peer(tdlsCtx_t *pHddTdlsCtx, u8 *mac);
-static void wlan_hdd_tdls_pre_setup(struct work_struct *work);
 static void wlan_hdd_tdls_ct_handler(void *user_data);
 
 /**
@@ -290,44 +289,7 @@
 
 
 /**
- * wlan_hdd_tdls_pre_setup_init_work() - schedule work for tdls pre-setup
- * @pHddTdlsCtx: HDD TDLS context
- * @curr_candidate: current candidate peer
- *
- * Return: None
- */
-void wlan_hdd_tdls_pre_setup_init_work(tdlsCtx_t *pHddTdlsCtx,
-				       hddTdlsPeer_t *curr_candidate)
-{
-	if (!pHddTdlsCtx || !curr_candidate) {
-		QDF_TRACE(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_ERROR,
-			  "%s: either pHddTdlsCtx or curr_candidate is null",
-			  __func__);
-		return;
-	}
-
-	if (TDLS_CTX_MAGIC != pHddTdlsCtx->magic) {
-		/* When TDLS discovery attempt for a peer reaches to max configured
-		 * threshold then tdls support for that peer would be disabled and
-		 * in that case, ignore discovery trigger from FW for that peer.
-		 */
-		if (eTDLS_CAP_NOT_SUPPORTED == curr_candidate->tdls_support) {
-			hdd_warn("tdls_support is marked disabled for peer: "
-				  MAC_ADDRESS_STR
-				  ", ignore pre_setup_init_work",
-				  MAC_ADDR_ARRAY(curr_candidate->peerMac));
-			return;
-		}
-
-		pHddTdlsCtx->curr_candidate = curr_candidate;
-		pHddTdlsCtx->magic = TDLS_CTX_MAGIC;
-
-		schedule_work(&pHddTdlsCtx->implicit_setup);
-	}
-}
-
-/**
- * wlan_hdd_tdls_pre_setup_init_work() - get value of discovery counter sent
+ * wlan_hdd_tdls_discovery_sent_cnt() - get value of discovery counter sent
  * @pHddCtx: HDD context
  *
  * Return: the value of the transmitted TDLS discovery counter
@@ -838,8 +800,6 @@
 		pHddCtx->tdls_mode = eTDLS_SUPPORT_ENABLED;
 	}
 
-	INIT_WORK(&pHddTdlsCtx->implicit_setup, wlan_hdd_tdls_pre_setup);
-
 	INIT_DELAYED_WORK(&pHddCtx->tdls_scan_ctxt.tdls_scan_work,
 			  wlan_hdd_tdls_schedule_scan);
 
@@ -887,7 +847,6 @@
 		goto done;
 	}
 
-	cds_flush_work(&pHddTdlsCtx->implicit_setup);
 	cds_flush_delayed_work(&pHddCtx->tdls_scan_ctxt.tdls_scan_work);
 
 	mutex_lock(&pHddCtx->tdls_lock);
@@ -2680,172 +2639,6 @@
 }
 
 /**
- * __wlan_hdd_tdls_pre_setup() - TDLS Pre implicit setup
- * @work: work_struct used to find the TDLS context
- *
- * Return: Void
- */
-static void __wlan_hdd_tdls_pre_setup(struct work_struct *work)
-{
-	tdlsCtx_t *pHddTdlsCtx = container_of(work, tdlsCtx_t, implicit_setup);
-	hdd_context_t *pHddCtx;
-	hddTdlsPeer_t *curr_peer;
-	hddTdlsPeer_t *temp_peer;
-	int status;
-	tSirMacAddr peer_mac;
-
-	ENTER();
-
-	if (NULL == pHddTdlsCtx) {
-		QDF_TRACE(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_ERROR,
-			  FL("pHddTdlsCtx is NULL"));
-		return;
-	}
-
-	if (unlikely(TDLS_CTX_MAGIC != pHddTdlsCtx->magic)) {
-		QDF_TRACE(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_ERROR,
-			  "%s: tdls magic number mis-match %u",
-			  __func__, pHddTdlsCtx->magic);
-		return;
-	}
-
-	pHddCtx = WLAN_HDD_GET_CTX(pHddTdlsCtx->pAdapter);
-
-	if (0 != (wlan_hdd_validate_context(pHddCtx)))
-		return;
-
-	mutex_lock(&pHddCtx->tdls_lock);
-
-	curr_peer = pHddTdlsCtx->curr_candidate;
-
-	if (NULL == curr_peer) {
-		QDF_TRACE(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_ERROR,
-			  FL("pHddCtx is not valid"));
-		goto done;
-	}
-
-	qdf_mem_copy(&peer_mac, curr_peer->peerMac, sizeof(peer_mac));
-
-	mutex_unlock(&pHddCtx->tdls_lock);
-
-	temp_peer = wlan_hdd_tdls_is_progress(pHddCtx, NULL, 0, true);
-
-	if (NULL != temp_peer) {
-		hdd_notice(MAC_ADDRESS_STR " ongoing. pre_setup ignored",
-			   MAC_ADDR_ARRAY(temp_peer->peerMac));
-		goto done;
-	}
-
-	if (eTDLS_CAP_UNKNOWN != curr_peer->tdls_support)
-		wlan_hdd_tdls_set_peer_link_status(curr_peer,
-						   eTDLS_LINK_DISCOVERING,
-						   eTDLS_LINK_SUCCESS,
-						   true);
-
-	mutex_lock(&pHddCtx->tdls_lock);
-
-	/* Ignore discovery attempt if External Control is enabled, that
-	 * is, peer is forced. In that case, continue discovery attempt
-	 * regardless attempt count
-	 */
-	if (false == curr_peer->isForcedPeer) {
-		if (curr_peer->discovery_attempt >=
-		    pHddTdlsCtx->threshold_config.discovery_tries_n) {
-			QDF_TRACE(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_ERROR,
-				  "%s: discovery attempt (%d) reached max (%d) for peer "
-				  MAC_ADDRESS_STR
-				  ", ignore discovery trigger from fw",
-				  __func__, curr_peer->discovery_attempt,
-				  pHddTdlsCtx->threshold_config.
-				  discovery_tries_n,
-				  MAC_ADDR_ARRAY(curr_peer->peerMac));
-			curr_peer->tdls_support = eTDLS_CAP_NOT_SUPPORTED;
-			/* Since TDLS discovery attempt reached the
-			 * maximum threshold, so we remove the peer
-			 * from the FW connection table.
-			 */
-			if (0 != wlan_hdd_tdls_update_peer_mac(pHddTdlsCtx->pAdapter,
-				curr_peer->peerMac, eSME_TDLS_PEER_REMOVE_MAC_ADDR))
-				hdd_err("TDLS Peer mac update Failed "
-					MAC_ADDRESS_STR,
-					MAC_ADDR_ARRAY(curr_peer->peerMac));
-			goto done;
-		}
-	}
-
-	mutex_unlock(&pHddCtx->tdls_lock);
-	wlan_hdd_tdls_set_peer_link_status(curr_peer,
-					   eTDLS_LINK_DISCOVERING,
-					   eTDLS_LINK_SUCCESS,
-					   true);
-
-	status =
-		wlan_hdd_cfg80211_send_tdls_discover_req(pHddTdlsCtx->pAdapter->
-							 wdev.wiphy,
-							 pHddTdlsCtx->pAdapter->dev,
-							 peer_mac);
-
-	mutex_lock(&pHddCtx->tdls_lock);
-
-	if (NULL == pHddTdlsCtx->curr_candidate) {
-		hdd_err("current candidate Not valid any more");
-		goto done;
-	}
-
-	curr_peer = pHddTdlsCtx->curr_candidate;
-
-	if (0 != status) {
-		hdd_err(MAC_ADDRESS_STR " discovery could not sent",
-			MAC_ADDR_ARRAY(curr_peer->peerMac));
-		if (eTDLS_CAP_UNKNOWN != curr_peer->tdls_support) {
-			mutex_unlock(&pHddCtx->tdls_lock);
-			wlan_hdd_tdls_set_peer_link_status(curr_peer,
-							   eTDLS_LINK_IDLE,
-							   eTDLS_LINK_UNSPECIFIED,
-							   true);
-			mutex_lock(&pHddCtx->tdls_lock);
-		}
-		goto done;
-	}
-
-	pHddTdlsCtx->discovery_sent_cnt++;
-
-	curr_peer->discovery_attempt++;
-
-	wlan_hdd_tdls_check_power_save_prohibited(pHddTdlsCtx->pAdapter);
-
-	hdd_notice("discovery count %u timeout %u msec",
-		   pHddTdlsCtx->discovery_sent_cnt,
-		   pHddTdlsCtx->threshold_config.tx_period_t -
-		   TDLS_DISCOVERY_TIMEOUT_BEFORE_UPDATE);
-
-	wlan_hdd_tdls_timer_restart(pHddTdlsCtx->pAdapter,
-				    &pHddTdlsCtx->peerDiscoveryTimeoutTimer,
-				    pHddTdlsCtx->threshold_config.tx_period_t -
-				    TDLS_DISCOVERY_TIMEOUT_BEFORE_UPDATE);
-
-done:
-	pHddTdlsCtx->curr_candidate = NULL;
-	pHddTdlsCtx->magic = 0;
-	mutex_unlock(&pHddCtx->tdls_lock);
-	EXIT();
-	return;
-}
-
-/**
- * wlan_hdd_tdls_pre_setup() - TDLS Pre implicit setup
- * @work: work_struct used to find the TDLS context
- *
- * Return: Void
- */
-void wlan_hdd_tdls_pre_setup(struct work_struct *work)
-{
-	cds_ssr_protect(__func__);
-	__wlan_hdd_tdls_pre_setup(work);
-	cds_ssr_unprotect(__func__);
-}
-
-/**
  * wlan_hdd_tdls_copy_scan_context() - Copy TDLS scan context
  * @pHddCtx: HDD context
  * @wiphy: wiphy pointer
@@ -5534,7 +5327,6 @@
  *
  * Return: None
  */
-static
 void wlan_hdd_tdls_implicit_send_discovery_request(tdlsCtx_t *hdd_tdls_ctx)
 {
 	hdd_context_t *hdd_ctx;