Parcourir la source

qcacld-3.0: Replace legacy scan serialization with new one

Replace legacy scan serialization with new one serialization

CRs-Fixed: 2005532
Change-Id: I57d48d226d5092d8cfc834196acf28a7e5d48966
Krunal Soni il y a 8 ans
Parent
commit
81f068c8e3

+ 33 - 1
core/sme/inc/csr_internal.h

@@ -358,6 +358,7 @@ typedef struct tagScanCmd {
 	csr_scan_completeCallback callback;
 	void *pContext;
 	eCsrScanReason reason;
+	eCsrScanStatus status;
 	eCsrRoamState lastRoamState[CSR_ROAM_SESSION_MAX];
 	tCsrRoamProfile *pToRoamProfile;
 	/* this is the ID related to the pToRoamProfile */
@@ -1392,6 +1393,36 @@ QDF_STATUS csr_scan_process_single_bssdescr(tpAniSirGlobal pMac,
 		tSirBssDescription *pSirBssDescription,
 		uint32_t scan_id, uint32_t flags);
 
+void csr_scan_pending_ll_unlock(struct sAniSirGlobal *mac_ctx);
+void csr_scan_active_ll_unlock(struct sAniSirGlobal *mac_ctx);
+void csr_scan_pending_ll_lock(struct sAniSirGlobal *mac_ctx);
+void csr_scan_active_ll_lock(struct sAniSirGlobal *mac_ctx);
+uint32_t csr_scan_active_ll_count(struct sAniSirGlobal *mac_ctx);
+uint32_t csr_scan_pending_ll_count(struct sAniSirGlobal *mac_ctx);
+bool csr_scan_active_ll_is_list_empty(struct sAniSirGlobal *mac_ctx,
+				bool inter_locked);
+bool csr_scan_pending_ll_is_list_empty(struct sAniSirGlobal *mac_ctx,
+				bool inter_locked);
+bool csr_scan_active_ll_remove_entry(struct sAniSirGlobal *mac_ctx,
+		tListElem *entry, bool inter_locked);
+bool csr_scan_pending_ll_remove_entry(struct sAniSirGlobal *mac_ctx,
+		tListElem *entry, bool inter_locked);
+tListElem *csr_scan_active_ll_peek_head(struct sAniSirGlobal *mac_ctx,
+		bool inter_locked);
+tListElem *csr_scan_pending_ll_peek_head(struct sAniSirGlobal *mac_ctx,
+		bool inter_locked);
+tListElem *csr_scan_pending_ll_next(struct sAniSirGlobal *mac_ctx,
+		tListElem *entry, bool inter_locked);
+tListElem *csr_scan_active_ll_next(struct sAniSirGlobal *mac_ctx,
+		tListElem *entry, bool inter_locked);
+tListElem *csr_scan_active_ll_remove_head(struct sAniSirGlobal *mac_ctx,
+			bool fInterlocked);
+tListElem *csr_scan_pending_ll_remove_head(struct sAniSirGlobal *mac_ctx,
+			bool fInterlocked);
+tListElem *csr_scan_active_ll_remove_head(struct sAniSirGlobal *mac_ctx,
+			bool fInterlocked);
+tListElem *csr_scan_pending_ll_remove_head(struct sAniSirGlobal *mac_ctx,
+			bool fInterlocked);
 void csr_nonscan_pending_ll_unlock(struct sAniSirGlobal *mac_ctx);
 void csr_nonscan_active_ll_unlock(struct sAniSirGlobal *mac_ctx);
 void csr_nonscan_pending_ll_lock(struct sAniSirGlobal *mac_ctx);
@@ -1426,7 +1457,8 @@ void purge_sme_session_pending_cmd_list(struct sAniSirGlobal *mac_ctx,
 		uint32_t session_id);
 void purge_sme_session_active_cmd_list(struct sAniSirGlobal *mac_ctx,
 		uint32_t session_id);
-
+void purge_sme_session_pending_scan_cmd_list(struct sAniSirGlobal *mac_ctx,
+		uint32_t session_id);
 bool csr_wait_for_connection_update(tpAniSirGlobal mac,
 		bool do_release_reacquire_lock);
 enum tQDF_ADAPTER_MODE csr_get_session_persona(tpAniSirGlobal pmac,

+ 0 - 5
core/sme/inc/sme_inside.h

@@ -223,11 +223,7 @@ QDF_STATUS csr_set_serialization_params_to_cmd(tpAniSirGlobal mac_ctx,
 		tSmeCmd *sme_cmd, struct wlan_serialization_command *cmd,
 		uint8_t high_priority);
 tSmeCmd *sme_get_command_buffer(tpAniSirGlobal pMac);
-void sme_push_command(tpAniSirGlobal pMac, tSmeCmd *pCmd, bool fHighPriority);
-void sme_process_pending_queue(tpAniSirGlobal pMac);
 void sme_release_command(tpAniSirGlobal pMac, tSmeCmd *pCmd);
-void purge_sme_session_cmd_list(tpAniSirGlobal pMac, uint32_t sessionId,
-		tDblLinkList *pList);
 bool qos_process_command(tpAniSirGlobal pMac, tSmeCmd *pCommand);
 void qos_release_command(tpAniSirGlobal pMac, tSmeCmd *pCommand);
 QDF_STATUS csr_process_scan_command(tpAniSirGlobal pMac, tSmeCmd *pCommand);
@@ -240,7 +236,6 @@ void csr_reinit_set_key_cmd(tpAniSirGlobal pMac, tSmeCmd *pCommand);
 QDF_STATUS csr_roam_process_set_key_command(tpAniSirGlobal pMac,
 		tSmeCmd *pCommand);
 void csr_release_command_set_key(tpAniSirGlobal pMac, tSmeCmd *pCommand);
-void csr_abort_command(tpAniSirGlobal pMac, tSmeCmd *pCommand, bool fStopping);
 void csr_cancel_command(tpAniSirGlobal mac_ctx, tSmeCmd *sme_cmd);
 
 QDF_STATUS csr_is_valid_channel(tpAniSirGlobal pMac, uint8_t chnNum);

+ 11 - 428
core/sme/src/common/sme_api.c

@@ -372,65 +372,12 @@ void sme_release_command(tpAniSirGlobal mac_ctx, tSmeCmd *sme_cmd)
 				LL_ACCESS_LOCK);
 }
 
-static void sme_release_cmd_list(tpAniSirGlobal pMac, tDblLinkList *pList)
-{
-	tListElem *pEntry;
-	tSmeCmd *pCommand;
-
-	while ((pEntry = csr_ll_remove_head(pList, LL_ACCESS_LOCK)) != NULL) {
-		/* TODO: base on command type to call release functions */
-		/* reinitialize different command types so they can be reused */
-		pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
-		csr_abort_command(pMac, pCommand, true);
-	}
-}
-
 static void purge_sme_cmd_list(tpAniSirGlobal pMac)
 {
-	/* purge pending command list */
+	/* purge all command lists */
+	sms_log(pMac, LOG1, FL("Purging all queues"));
 	wlan_serialization_purge_cmd_list(pMac->psoc, NULL,
-			false, false, false, true, false);
-	/* purge active command list */
-	wlan_serialization_purge_cmd_list(pMac->psoc, NULL,
-			false, false, true, false, false);
-	sme_release_cmd_list(pMac, &pMac->sme.smeScanCmdPendingList);
-	sme_release_cmd_list(pMac, &pMac->sme.smeScanCmdActiveList);
-}
-
-void purge_sme_session_cmd_list(tpAniSirGlobal pMac, uint32_t sessionId,
-				tDblLinkList *pList)
-{
-	/* release any out standing commands back to free command list */
-	tListElem *pEntry, *pNext;
-	tSmeCmd *pCommand;
-	tDblLinkList localList;
-
-	qdf_mem_zero(&localList, sizeof(tDblLinkList));
-	if (!QDF_IS_STATUS_SUCCESS(csr_ll_open(pMac->hHdd, &localList))) {
-		sms_log(pMac, LOGE, FL(" failed to open list"));
-		return;
-	}
-
-	csr_ll_lock(pList);
-	pEntry = csr_ll_peek_head(pList, LL_ACCESS_NOLOCK);
-	while (pEntry != NULL) {
-		pNext = csr_ll_next(pList, pEntry, LL_ACCESS_NOLOCK);
-		pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
-		if (pCommand->sessionId == sessionId) {
-			if (csr_ll_remove_entry(pList, pEntry, LL_ACCESS_NOLOCK)) {
-				csr_ll_insert_tail(&localList, pEntry,
-						   LL_ACCESS_NOLOCK);
-			}
-		}
-		pEntry = pNext;
-	}
-	csr_ll_unlock(pList);
-
-	while ((pEntry = csr_ll_remove_head(&localList, LL_ACCESS_NOLOCK))) {
-		pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
-		csr_abort_command(pMac, pCommand, true);
-	}
-	csr_ll_close(&localList);
+			false, false, false, false, true);
 }
 
 static QDF_STATUS free_sme_cmd_list(tpAniSirGlobal pMac)
@@ -569,142 +516,6 @@ tSmeCmd *sme_get_command_buffer(tpAniSirGlobal pMac)
 	return pRetCmd;
 }
 
-void sme_push_command(tpAniSirGlobal pMac, tSmeCmd *pCmd, bool fHighPriority)
-{
-	if (!SME_IS_START(pMac)) {
-		sms_log(pMac, LOGE, FL("Sme in stop state"));
-		QDF_ASSERT(0);
-		return;
-	}
-
-	if (fHighPriority) {
-		csr_nonscan_pending_ll_insert_head(pMac, &pCmd->Link,
-				   LL_ACCESS_LOCK);
-	} else {
-		csr_nonscan_pending_ll_insert_tail(pMac, &pCmd->Link,
-				   LL_ACCESS_LOCK);
-	}
-
-	/* process the command queue... */
-	sme_process_pending_queue(pMac);
-
-	return;
-}
-
-static
-tListElem *csr_get_pending_cmd_to_process(tpAniSirGlobal pMac,
-				uint8_t sessionId, bool fInterlocked)
-{
-	tListElem *pCurEntry = NULL;
-	tSmeCmd *pCommand;
-
-	/* Go through the list and return the command whose session id is not
-	 * matching with the current ongoing scan cmd sessionId */
-	pCurEntry = csr_nonscan_pending_ll_peek_head(pMac, LL_ACCESS_LOCK);
-	while (pCurEntry) {
-		pCommand = GET_BASE_ADDR(pCurEntry, tSmeCmd, Link);
-		if (pCommand->sessionId != sessionId) {
-			sms_log(pMac, LOG1,
-				"selected the command with different sessionId");
-			return pCurEntry;
-		}
-
-		pCurEntry = csr_nonscan_pending_ll_next(pMac,
-					pCurEntry, fInterlocked);
-	}
-
-	sms_log(pMac, LOG1, "No command pending with different sessionId");
-	return NULL;
-}
-
-static bool sme_process_scan_queue(tpAniSirGlobal pMac)
-{
-	tListElem *pEntry;
-	tSmeCmd *pCommand;
-	tListElem *pSmeEntry = NULL;
-	tSmeCmd *pSmeCommand = NULL;
-	bool status = true;
-
-	if ((!csr_nonscan_active_ll_is_list_empty(pMac,
-				   LL_ACCESS_LOCK))) {
-		pSmeEntry = csr_nonscan_active_ll_peek_head(pMac,
-					LL_ACCESS_LOCK);
-		if (pSmeEntry)
-			pSmeCommand = GET_BASE_ADDR(pSmeEntry, tSmeCmd, Link);
-	}
-	csr_ll_lock(&pMac->sme.smeScanCmdActiveList);
-	if (csr_ll_is_list_empty(&pMac->sme.smeScanCmdPendingList,
-				 LL_ACCESS_LOCK))
-		goto end;
-	pEntry = csr_ll_peek_head(&pMac->sme.smeScanCmdPendingList,
-				  LL_ACCESS_LOCK);
-	if (!pEntry)
-		goto end;
-
-	sms_log(pMac, LOG1,
-		FL("scan_count in active scanlist %d "),
-		pMac->sme.smeScanCmdActiveList.Count);
-
-	pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
-	if (pSmeCommand != NULL) {
-		/*
-		 * if scan is running on one interface and SME receives
-		 * the next command on the same interface then
-		 * dont the allow the command to be queued to
-		 * smeCmdPendingList. If next scan is allowed on
-		 * the same interface the CSR state machine will
-		 * get screwed up.
-		 */
-		if (pSmeCommand->sessionId == pCommand->sessionId) {
-			status = false;
-			goto end;
-		}
-	}
-	/*
-	 * We cannot execute any command in wait-for-key state until setKey is
-	 * through.
-	 */
-	if (CSR_IS_WAIT_FOR_KEY(pMac, pCommand->sessionId)) {
-		if (!CSR_IS_SET_KEY_COMMAND(pCommand)) {
-			sms_log(pMac, LOGE,
-				FL("Can't process cmd(%d), waiting for key"),
-				pCommand->command);
-			status = false;
-			goto end;
-		}
-	}
-	if (csr_ll_remove_entry(&pMac->sme.smeScanCmdPendingList, pEntry,
-				LL_ACCESS_LOCK)) {
-		csr_ll_insert_head(&pMac->sme.smeScanCmdActiveList,
-				   &pCommand->Link, LL_ACCESS_NOLOCK);
-		switch (pCommand->command) {
-		case eSmeCommandScan:
-			sms_log(pMac, LOG1, FL("Processing scan offload cmd."));
-			qdf_mc_timer_start(&pCommand->u.scanCmd.csr_scan_timer,
-				CSR_ACTIVE_SCAN_LIST_CMD_TIMEOUT);
-			csr_process_scan_command(pMac, pCommand);
-			break;
-		case eSmeCommandRemainOnChannel:
-			sms_log(pMac, LOG1,
-				FL("Processing remain on channel offload cmd"));
-			p2p_process_remain_on_channel_cmd(pMac, pCommand);
-			break;
-		default:
-			sms_log(pMac, LOGE,
-				FL("Wrong cmd enqueued to ScanCmdPendingList"));
-			pEntry = csr_ll_remove_head(
-					&pMac->sme.smeScanCmdActiveList,
-					LL_ACCESS_NOLOCK);
-			pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
-			csr_release_command(pMac, pCommand);
-			break;
-		}
-	}
-end:
-	csr_ll_unlock(&pMac->sme.smeScanCmdActiveList);
-	return status;
-}
-
 /**
  * sme_ser_handle_active_cmd() - handle command activation callback from
  *					new serialization module
@@ -761,6 +572,12 @@ QDF_STATUS sme_ser_handle_active_cmd(struct wlan_serialization_command *cmd)
 	case eSmeCommandNdpDataEndInitiatorRequest:
 		status = csr_process_ndp_data_end_request(mac_ctx, sme_cmd);
 		break;
+	case eSmeCommandScan:
+		sms_log(mac_ctx, LOG1, FL("Processing scan offload cmd."));
+		qdf_mc_timer_start(&sme_cmd->u.scanCmd.csr_scan_timer,
+				CSR_ACTIVE_SCAN_LIST_CMD_TIMEOUT);
+		status = csr_process_scan_command(mac_ctx, sme_cmd);
+		break;
 	case eSmeCommandRemainOnChannel:
 		status = p2p_process_remain_on_channel_cmd(mac_ctx, sme_cmd);
 		break;
@@ -849,7 +666,6 @@ QDF_STATUS sme_ser_cmd_callback(void *buf,
 			FL("WLAN_SER_CB_CANCEL_CMD callback"));
 		sme_cmd = cmd->umac_cmd;
 		csr_cancel_command(mac_ctx, sme_cmd);
-		csr_release_command_buffer(mac_ctx, sme_cmd);
 		break;
 	case WLAN_SER_CB_RELEASE_MEM_CMD:
 		sms_log(mac_ctx, LOG1,
@@ -868,239 +684,6 @@ QDF_STATUS sme_ser_cmd_callback(void *buf,
 	return status;
 }
 
-/**
- * sme_process_command() - processes SME commnd
- * @mac_ctx:       mac global context
- *
- * This function is called by sme_process_pending_queue() in a while loop
- *
- * Return: true indicates that caller function can proceed to next cmd
- *         false otherwise.
- */
-static bool sme_process_command(tpAniSirGlobal pMac)
-{
-	bool fContinue = false;
-	QDF_STATUS status = QDF_STATUS_SUCCESS;
-	tListElem *pEntry;
-	tSmeCmd *pCommand;
-	tListElem *pSmeEntry;
-	tSmeCmd *pSmeCommand;
-
-	/*
-	 * if the ActiveList is empty, then nothing is active so we can process
-	 * a pending command...
-	 * alwasy lock active list before locking pending list
-	 */
-	csr_nonscan_active_ll_lock(pMac);
-	if (!csr_nonscan_active_ll_is_list_empty(pMac, LL_ACCESS_NOLOCK)) {
-		csr_nonscan_active_ll_unlock(pMac);
-		goto process_scan_q;
-	}
-
-	if (csr_nonscan_pending_ll_is_list_empty(pMac, LL_ACCESS_LOCK)) {
-		/* No command waiting */
-		csr_nonscan_active_ll_unlock(pMac);
-		goto process_scan_q;
-	}
-
-	/*
-	 * If scan command is pending in the smeScanCmdActive list then pick the
-	 * command from smeCmdPendingList which is not matching with the scan
-	 * command session id. At any point of time only one command will be
-	 * allowed on a single session.
-	 */
-	if (!csr_ll_is_list_empty(
-			&pMac->sme.smeScanCmdActiveList, LL_ACCESS_LOCK)) {
-		pSmeEntry = csr_ll_peek_head(&pMac->sme.smeScanCmdActiveList,
-					     LL_ACCESS_LOCK);
-		if (pSmeEntry) {
-			pSmeCommand = GET_BASE_ADDR(pSmeEntry, tSmeCmd, Link);
-			pEntry = csr_get_pending_cmd_to_process(pMac,
-					pSmeCommand->sessionId,
-					LL_ACCESS_LOCK);
-			goto sme_process_cmd;
-		}
-	}
-
-	/* Peek the command */
-	pEntry = csr_nonscan_pending_ll_peek_head(pMac, LL_ACCESS_LOCK);
-sme_process_cmd:
-	if (!pEntry) {
-		csr_nonscan_active_ll_unlock(pMac);
-		goto process_scan_q;
-	}
-	pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
-	/*
-	 * Allow only disconnect command in wait-for-key state until setKey is
-	 * through.
-	 */
-	if (CSR_IS_WAIT_FOR_KEY(pMac, pCommand->sessionId)
-	    && !CSR_IS_DISCONNECT_COMMAND(pCommand)
-	    && !CSR_IS_SET_KEY_COMMAND(pCommand)) {
-
-		csr_nonscan_active_ll_unlock(pMac);
-		sms_log(pMac, LOGE,
-			FL("SessionId %d: Can't process cmd(%d), waiting for key"),
-			pCommand->sessionId, pCommand->command);
-		fContinue = false;
-		goto process_scan_q;
-	}
-
-	if (!csr_nonscan_pending_ll_remove_entry(pMac, pEntry,
-				LL_ACCESS_LOCK)) {
-		/* This is odd. Some one else pull off the command. */
-		csr_nonscan_active_ll_unlock(pMac);
-		goto process_scan_q;
-	}
-	/* we can reuse the pCommand. Insert the command onto the ActiveList */
-	csr_nonscan_active_ll_insert_head(pMac, &pCommand->Link,
-				LL_ACCESS_NOLOCK);
-	/* .... and process the command. */
-	MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_COMMAND,
-			 pCommand->sessionId, pCommand->command));
-
-	switch (pCommand->command) {
-	case eSmeCommandScan:
-		csr_nonscan_active_ll_unlock(pMac);
-		status = csr_process_scan_command(pMac, pCommand);
-		break;
-	case eSmeCommandRoam:
-		csr_nonscan_active_ll_unlock(pMac);
-		status = csr_roam_process_command(pMac, pCommand);
-		if (!QDF_IS_STATUS_SUCCESS(status)
-		    && csr_nonscan_active_ll_remove_entry(pMac,
-				&pCommand->Link, LL_ACCESS_LOCK))
-			csr_release_command(pMac, pCommand);
-		break;
-	case eSmeCommandWmStatusChange:
-		csr_nonscan_active_ll_unlock(pMac);
-		csr_roam_process_wm_status_change_command(pMac, pCommand);
-		break;
-	case eSmeCommandSetKey:
-		csr_nonscan_active_ll_unlock(pMac);
-		status = csr_roam_process_set_key_command(pMac, pCommand);
-		if (!QDF_IS_STATUS_SUCCESS(status)
-		    && csr_nonscan_active_ll_remove_entry(pMac,
-				&pCommand->Link, LL_ACCESS_LOCK)) {
-			csr_release_command(pMac, pCommand);
-		}
-		break;
-	case eSmeCommandNdpInitiatorRequest:
-		csr_nonscan_active_ll_unlock(pMac);
-		if (csr_process_ndp_initiator_request(pMac, pCommand) !=
-			QDF_STATUS_SUCCESS)
-			if (csr_nonscan_active_ll_remove_entry(
-					pMac, &pCommand->Link, LL_ACCESS_LOCK))
-				csr_release_command(pMac, pCommand);
-		break;
-	case eSmeCommandNdpResponderRequest:
-		csr_nonscan_active_ll_unlock(pMac);
-		status = csr_process_ndp_responder_request(pMac, pCommand);
-		if (status != QDF_STATUS_SUCCESS) {
-			if (csr_nonscan_active_ll_remove_entry(pMac,
-					&pCommand->Link, LL_ACCESS_LOCK))
-				csr_release_command(pMac, pCommand);
-		}
-		break;
-	case eSmeCommandNdpDataEndInitiatorRequest:
-		csr_nonscan_active_ll_unlock(pMac);
-		status = csr_process_ndp_data_end_request(pMac, pCommand);
-		if (status != QDF_STATUS_SUCCESS) {
-			if (csr_nonscan_active_ll_remove_entry(pMac,
-					&pCommand->Link, LL_ACCESS_LOCK))
-				csr_release_command(pMac, pCommand);
-		}
-		break;
-	case eSmeCommandRemainOnChannel:
-		csr_nonscan_active_ll_unlock(pMac);
-		status = p2p_process_remain_on_channel_cmd(pMac, pCommand);
-		if (!QDF_IS_STATUS_SUCCESS(status)
-		    && csr_nonscan_active_ll_remove_entry(pMac,
-				&pCommand->Link, LL_ACCESS_LOCK))
-			csr_release_command(pMac, pCommand);
-		break;
-	/*
-	 * Treat standby differently here because caller may not be able
-	 * to handle the failure so we do our best here
-	 */
-	case eSmeCommandEnterStandby:
-		break;
-	case eSmeCommandAddTs:
-	case eSmeCommandDelTs:
-		csr_nonscan_active_ll_unlock(pMac);
-#ifndef WLAN_MDM_CODE_REDUCTION_OPT
-		fContinue = qos_process_command(pMac, pCommand);
-		if (fContinue && csr_nonscan_active_ll_remove_entry(
-			pMac, &pCommand->Link, LL_ACCESS_NOLOCK)) {
-			/* The command failed, remove it */
-			qos_release_command(pMac, pCommand);
-		}
-#endif
-		break;
-#ifdef FEATURE_WLAN_TDLS
-	case eSmeCommandTdlsSendMgmt:
-	case eSmeCommandTdlsAddPeer:
-	case eSmeCommandTdlsDelPeer:
-	case eSmeCommandTdlsLinkEstablish:
-		QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_INFO,
-			  FL("sending TDLS Command 0x%x to PE"),
-			  pCommand->command);
-		csr_nonscan_active_ll_unlock(pMac);
-		status = csr_tdls_process_cmd(pMac, pCommand);
-		if (!QDF_IS_STATUS_SUCCESS(status)) {
-			if (csr_nonscan_active_ll_remove_entry(
-					pMac, &pCommand->Link,
-						LL_ACCESS_LOCK)) {
-				qdf_mem_zero(&pCommand->u.tdlsCmd,
-					     sizeof(tTdlsCmd));
-				csr_release_command(pMac, pCommand);
-			}
-		}
-		break;
-#endif
-	case e_sme_command_set_hw_mode:
-		csr_nonscan_active_ll_unlock(pMac);
-		csr_process_set_hw_mode(pMac, pCommand);
-		break;
-	case e_sme_command_nss_update:
-		csr_nonscan_active_ll_unlock(pMac);
-		csr_process_nss_update_req(pMac, pCommand);
-		break;
-	case e_sme_command_set_dual_mac_config:
-		csr_nonscan_active_ll_unlock(pMac);
-		csr_process_set_dual_mac_config(pMac, pCommand);
-		break;
-	case e_sme_command_set_antenna_mode:
-		csr_nonscan_active_ll_unlock(pMac);
-		csr_process_set_antenna_mode(pMac, pCommand);
-		break;
-	default:
-		/* something is wrong */
-		/* remove it from the active list */
-		sms_log(pMac, LOGE, FL("unknown command %d"),
-			pCommand->command);
-		pEntry = csr_nonscan_active_ll_remove_head(pMac,
-					    LL_ACCESS_NOLOCK);
-		csr_nonscan_active_ll_unlock(pMac);
-		pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
-		csr_release_command(pMac, pCommand);
-		status = QDF_STATUS_E_FAILURE;
-		break;
-	}
-	if (!QDF_IS_STATUS_SUCCESS(status))
-		fContinue = true;
-process_scan_q:
-	if (!(sme_process_scan_queue(pMac)))
-		fContinue = false;
-	return fContinue;
-}
-
-void sme_process_pending_queue(tpAniSirGlobal pMac)
-{
-	while (sme_process_command(pMac))
-	;
-}
-
 /**
  * sme_get_sessionid_from_activelist() - gets session id
  * @mac: mac context
@@ -3424,7 +3007,7 @@ QDF_STATUS sme_scan_request(tHalHandle hal, uint8_t session_id,
 		return status;
 	}
 
-	scan_count = csr_ll_count(&mac_ctx->sme.smeScanCmdActiveList);
+	scan_count = csr_scan_active_ll_count(mac_ctx);
 	if (scan_count >= mac_ctx->scan.max_scan_count) {
 		sms_log(mac_ctx, LOGE, FL("Max scan reached"));
 		return QDF_STATUS_E_FAILURE;
@@ -6896,7 +6479,7 @@ QDF_STATUS sme_remain_on_channel(tHalHandle hHal, uint8_t session_id,
 	MTRACE(qdf_trace(QDF_MODULE_ID_SME,
 			 TRACE_CODE_SME_RX_HDD_REMAIN_ONCHAN, session_id, 0));
 
-	scan_count = csr_ll_count(&mac_ctx->sme.smeScanCmdActiveList);
+	scan_count = csr_scan_active_ll_count(mac_ctx);
 	if (scan_count >= mac_ctx->scan.max_scan_count) {
 		sms_log(mac_ctx, LOGE, FL("Max scan reached"));
 		return QDF_STATUS_E_FAILURE;

+ 51 - 43
core/sme/src/csr/csr_api_roam.c

@@ -1361,12 +1361,6 @@ void csr_cancel_command(tpAniSirGlobal mac_ctx, tSmeCmd *sme_cmd)
 	}
 }
 
-void csr_abort_command(tpAniSirGlobal pMac, tSmeCmd *pCommand, bool fStopping)
-{
-	csr_cancel_command(pMac, pCommand);
-	csr_release_command(pMac, pCommand);
-}
-
 void csr_roam_substate_change(tpAniSirGlobal pMac, eCsrRoamSubState NewSubstate,
 			      uint32_t sessionId)
 {
@@ -15587,9 +15581,7 @@ void csr_cleanup_session(tpAniSirGlobal pMac, uint32_t sessionId)
 		qdf_mc_timer_destroy(&pSession->hTimerJoinRetry);
 #endif
 		purge_sme_session_pending_cmd_list(pMac, sessionId);
-		purge_sme_session_cmd_list(pMac, sessionId,
-						   &pMac->sme.
-						   smeScanCmdPendingList);
+		purge_sme_session_pending_scan_cmd_list(pMac, sessionId);
 		csr_init_session(pMac, sessionId);
 	}
 }
@@ -15609,8 +15601,8 @@ QDF_STATUS csr_roam_close_session(tpAniSirGlobal pMac, uint32_t sessionId,
 		} else {
 			purge_sme_session_pending_cmd_list(pMac, sessionId);
 			purge_sme_session_active_cmd_list(pMac, sessionId);
-			purge_sme_session_cmd_list(pMac, sessionId,
-					   &pMac->sme.smeScanCmdPendingList);
+			purge_sme_session_pending_scan_cmd_list(pMac,
+								sessionId);
 			status = csr_issue_del_sta_for_session_req(pMac,
 						 sessionId,
 						 pSession->selfMacAddr.bytes,
@@ -18197,6 +18189,8 @@ static void csr_free_cmd_memory(tpAniSirGlobal pMac, tSmeCmd *pCommand)
 	}
 	switch (pCommand->command) {
 	case eSmeCommandScan:
+		csr_scan_call_callback(pMac, pCommand,
+				pCommand->u.scanCmd.status);
 		csr_release_command_scan(pMac, pCommand);
 		break;
 	case eSmeCommandRoam:
@@ -18249,30 +18243,36 @@ void csr_release_command(tpAniSirGlobal mac_ctx, tSmeCmd *sme_cmd)
 		sms_log(mac_ctx, LOGE, "sme_cmd is NULL");
 		return;
 	}
-	if (sme_cmd->command != eSmeCommandScan &&
-			sme_cmd->command != eSmeCommandRemainOnChannel) {
-		qdf_mem_zero(&cmd_info,
-			     sizeof(struct wlan_serialization_queued_cmd_info));
-		cmd_info.cmd_type = csr_get_cmd_type(sme_cmd);
-		cmd_info.vdev = wlan_objmgr_get_vdev_by_id_from_psoc(
-					mac_ctx->psoc, sme_cmd->sessionId,
-					WLAN_LEGACY_SME_ID);
-		if (wlan_serialization_is_cmd_present_in_active_queue(
-					mac_ctx->psoc, &cmd_info)) {
-			sms_log(mac_ctx, LOG1,
+	qdf_mem_zero(&cmd_info,
+			sizeof(struct wlan_serialization_queued_cmd_info));
+	if (sme_cmd->command == eSmeCommandScan ||
+			sme_cmd->command == eSmeCommandRemainOnChannel) {
+		sms_log(mac_ctx, LOG2, "filled cmd_id[%d]",
+			sme_cmd->u.scanCmd.scanID);
+		cmd_info.cmd_id = sme_cmd->u.scanCmd.scanID;
+		cmd_info.req_type = WLAN_SER_CANCEL_SINGLE_SCAN;
+	} else {
+		sms_log(mac_ctx, LOG2, "filled cmd_id = 0");
+		cmd_info.cmd_id = 0;
+		cmd_info.req_type = WLAN_SER_CANCEL_NON_SCAN_CMD;
+	}
+	cmd_info.cmd_type = csr_get_cmd_type(sme_cmd);
+	cmd_info.vdev = wlan_objmgr_get_vdev_by_id_from_psoc(
+			mac_ctx->psoc, sme_cmd->sessionId,
+			WLAN_LEGACY_SME_ID);
+	if (wlan_serialization_is_cmd_present_in_active_queue(
+				mac_ctx->psoc, &cmd_info)) {
+		sms_log(mac_ctx, LOG1,
 				FL("Releasing cmd from active queue"));
-			wlan_serialization_remove_cmd(&cmd_info);
-		} else if (wlan_serialization_is_cmd_present_in_pending_queue(
-					mac_ctx->psoc, &cmd_info)) {
-			sms_log(mac_ctx, LOG1,
+		wlan_serialization_remove_cmd(&cmd_info);
+	} else if (wlan_serialization_is_cmd_present_in_pending_queue(
+				mac_ctx->psoc, &cmd_info)) {
+		sms_log(mac_ctx, LOG1,
 				FL("Releasing cmd from pending queue"));
-			wlan_serialization_cancel_request(&cmd_info);
-		} else {
-			sms_log(mac_ctx, LOG1,
-				FL("Can't find in any queue, its ok"));
-		}
+		wlan_serialization_cancel_request(&cmd_info);
 	} else {
-		csr_release_command_buffer(mac_ctx, sme_cmd);
+		sms_log(mac_ctx, LOG1,
+				FL("Can't find in any queue, its ok"));
 	}
 }
 
@@ -18515,7 +18515,17 @@ QDF_STATUS csr_set_serialization_params_to_cmd(tpAniSirGlobal mac_ctx,
 	 * no need to fill command id for non-scan as they will be
 	 * zero always
 	 */
+	if (sme_cmd->command == eSmeCommandScan ||
+			sme_cmd->command == eSmeCommandRemainOnChannel) {
+		cmd->cmd_id = sme_cmd->u.scanCmd.scanID;
+		sms_log(mac_ctx, LOG2, "cmd_id[%d]", sme_cmd->u.scanCmd.scanID);
+	} else {
+		sms_log(mac_ctx, LOG2, "cmd_id = 0");
+		cmd->cmd_id = 0;
+	}
 	cmd->cmd_type = csr_get_cmd_type(sme_cmd);
+	sms_log(mac_ctx, LOG1, "filled cmd_type[%d] cmd_id[%d]",
+		cmd->cmd_type, cmd->cmd_id);
 	if (cmd->cmd_type == WLAN_SER_CMD_MAX) {
 		sms_log(mac_ctx, LOGE, FL("serialization enum not found"));
 		return status;
@@ -18547,18 +18557,16 @@ QDF_STATUS csr_queue_sme_command(tpAniSirGlobal mac_ctx, tSmeCmd *sme_cmd,
 		return QDF_STATUS_CSR_WRONG_STATE;
 	}
 
-	if ((sme_cmd->command == eSmeCommandScan)
-	    || (sme_cmd->command == eSmeCommandRemainOnChannel)) {
-		sms_log(mac_ctx, LOGW,
-		FL("scan pending list count %d scan_id %d"),
-			mac_ctx->sme.smeScanCmdPendingList.Count,
-			sme_cmd->u.scanCmd.scanID);
-		csr_ll_insert_tail(&mac_ctx->sme.smeScanCmdPendingList,
-				   &sme_cmd->Link, LL_ACCESS_LOCK);
-		/* process the command queue... */
-		sme_process_pending_queue(mac_ctx);
-		return QDF_STATUS_SUCCESS;
+	if (CSR_IS_WAIT_FOR_KEY(mac_ctx, sme_cmd->sessionId)) {
+		if (!CSR_IS_SET_KEY_COMMAND(sme_cmd) &&
+				!CSR_IS_DISCONNECT_COMMAND(sme_cmd)) {
+			sms_log(mac_ctx, LOGE,
+				FL("Can't process cmd(%d), waiting for key"),
+				sme_cmd->command);
+			return QDF_STATUS_CMD_NOT_QUEUED;
+		}
 	}
+
 	qdf_mem_zero(&cmd, sizeof(struct wlan_serialization_command));
 	if (QDF_STATUS_SUCCESS ==
 			csr_set_serialization_params_to_cmd(mac_ctx, sme_cmd,

+ 58 - 81
core/sme/src/csr/csr_api_scan.c

@@ -97,8 +97,6 @@ void csr_save_tx_power_to_cfg(tpAniSirGlobal pMac, tDblLinkList *pList,
 			      uint32_t cfgId);
 void csr_set_cfg_country_code(tpAniSirGlobal pMac, uint8_t *countryCode);
 void csr_purge_channel_power(tpAniSirGlobal pMac, tDblLinkList *pChannelList);
-void csr_release_scan_command(tpAniSirGlobal pMac, tSmeCmd *pCommand,
-			      eCsrScanStatus scanStatus);
 static bool csr_scan_validate_scan_result(tpAniSirGlobal pMac, uint8_t *pChannels,
 					  uint8_t numChn,
 					  tSirBssDescription *pBssDesc,
@@ -119,7 +117,7 @@ static void csr_release_scan_cmd_pending_list(tpAniSirGlobal pMac)
 					   LL_ACCESS_LOCK)) != NULL) {
 		pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
 		if (eSmeCsrCommandMask & pCommand->command) {
-			csr_abort_command(pMac, pCommand, true);
+			csr_release_command(pMac, pCommand);
 		} else {
 			sms_log(pMac, LOGE, FL("Error: Received command : %d"),
 				pCommand->command);
@@ -4188,17 +4186,18 @@ QDF_STATUS csr_get_active_scan_entry(tpAniSirGlobal mac_ctx,
 	tSmeCmd *cmd;
 	uint32_t cmd_scan_id = 0;
 
-	csr_ll_lock(&mac_ctx->sme.smeScanCmdActiveList);
+	sms_log(mac_ctx, LOGE, FL("Enter"));
+	csr_scan_active_ll_lock(mac_ctx);
 
-	if (csr_ll_is_list_empty(&mac_ctx->sme.smeScanCmdActiveList,
-			LL_ACCESS_NOLOCK)) {
+	if (csr_scan_active_ll_is_list_empty(mac_ctx, LL_ACCESS_NOLOCK)) {
 		sms_log(mac_ctx, LOGE,
 			FL(" Active list Empty scanId: %d"), scan_id);
-		csr_ll_unlock(&mac_ctx->sme.smeScanCmdActiveList);
+		csr_scan_active_ll_unlock(mac_ctx);
 		return QDF_STATUS_SUCCESS;
 	}
-	localentry = csr_ll_peek_head(&mac_ctx->sme.smeScanCmdActiveList,
+	localentry = csr_scan_active_ll_peek_head(mac_ctx,
 			LL_ACCESS_NOLOCK);
+	sms_log(mac_ctx, LOGE, FL("Entry %p outside while"), localentry);
 	 while (localentry) {
 		cmd = GET_BASE_ADDR(localentry, tSmeCmd, Link);
 		if (cmd->command == eSmeCommandScan)
@@ -4209,13 +4208,15 @@ QDF_STATUS csr_get_active_scan_entry(tpAniSirGlobal mac_ctx,
 			sms_log(mac_ctx, LOG1, FL(" scanId Matched %d"),
 					scan_id);
 			*entry = localentry;
-			csr_ll_unlock(&mac_ctx->sme.smeScanCmdActiveList);
+			csr_scan_active_ll_unlock(mac_ctx);
 			return QDF_STATUS_SUCCESS;
 		}
-		localentry = csr_ll_next(&mac_ctx->sme.smeScanCmdActiveList,
+		localentry = csr_scan_active_ll_next(mac_ctx,
 				localentry, LL_ACCESS_NOLOCK);
+		sms_log(mac_ctx, LOGE, FL("Entry %p inside while"), localentry);
 	}
-	csr_ll_unlock(&mac_ctx->sme.smeScanCmdActiveList);
+	csr_scan_active_ll_unlock(mac_ctx);
+	sms_log(mac_ctx, LOGE, FL("Exit"));
 	return status;
 }
 
@@ -4795,9 +4796,10 @@ QDF_STATUS csr_scan_sme_scan_response(tpAniSirGlobal pMac,
 		}
 		break;
 	}
-	if (fRemoveCommand)
-		csr_release_scan_command(pMac, pCommand, scanStatus);
-	sme_process_pending_queue(pMac);
+	if (fRemoveCommand) {
+		pCommand->u.scanCmd.status = scanStatus;
+		csr_release_command(pMac, pCommand);
+	}
 	return status;
 
 error_handling:
@@ -5365,9 +5367,8 @@ QDF_STATUS csr_process_scan_command(tpAniSirGlobal pMac, tSmeCmd *pCommand)
 		break;
 	}
 
-	if (!QDF_IS_STATUS_SUCCESS(status)) {
-		csr_release_scan_command(pMac, pCommand, eCSR_SCAN_FAILURE);
-	}
+	if (!QDF_IS_STATUS_SUCCESS(status))
+		pCommand->u.scanCmd.status = eCSR_SCAN_FAILURE;
 
 	return status;
 }
@@ -6032,7 +6033,6 @@ bool csr_scan_remove_fresh_scan_command(tpAniSirGlobal pMac, uint8_t sessionId)
 	tListElem *pEntry, *pEntryTmp;
 	tSmeCmd *pCommand;
 	tDblLinkList localList;
-	tDblLinkList *pCmdList;
 
 	qdf_mem_zero(&localList, sizeof(tDblLinkList));
 	if (!QDF_IS_STATUS_SUCCESS(csr_ll_open(pMac->hHdd, &localList))) {
@@ -6040,12 +6040,11 @@ bool csr_scan_remove_fresh_scan_command(tpAniSirGlobal pMac, uint8_t sessionId)
 		return fRet;
 	}
 
-	pCmdList = &pMac->sme.smeScanCmdPendingList;
-
-	csr_ll_lock(pCmdList);
-	pEntry = csr_ll_peek_head(pCmdList, LL_ACCESS_NOLOCK);
+	csr_scan_pending_ll_lock(pMac);
+	pEntry = csr_scan_pending_ll_peek_head(pMac, LL_ACCESS_NOLOCK);
 	while (pEntry) {
-		pEntryTmp = csr_ll_next(pCmdList, pEntry, LL_ACCESS_NOLOCK);
+		pEntryTmp = csr_scan_pending_ll_next(pMac, pEntry,
+						LL_ACCESS_NOLOCK);
 		pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
 		if (!((eSmeCommandScan == pCommand->command)
 		    && (sessionId == pCommand->sessionId))) {
@@ -6056,7 +6055,7 @@ bool csr_scan_remove_fresh_scan_command(tpAniSirGlobal pMac, uint8_t sessionId)
 			FL("-------- abort scan command reason = %d"),
 			pCommand->u.scanCmd.reason);
 		/* The rest are fresh scan requests */
-		if (csr_ll_remove_entry(pCmdList, pEntry,
+		if (csr_scan_pending_ll_remove_entry(pMac, pEntry,
 					LL_ACCESS_NOLOCK)) {
 			csr_ll_insert_tail(&localList, pEntry,
 					   LL_ACCESS_NOLOCK);
@@ -6065,7 +6064,7 @@ bool csr_scan_remove_fresh_scan_command(tpAniSirGlobal pMac, uint8_t sessionId)
 		pEntry = pEntryTmp;
 	}
 
-	csr_ll_unlock(pCmdList);
+	csr_scan_pending_ll_unlock(pMac);
 
 	while ((pEntry = csr_ll_remove_head(&localList, LL_ACCESS_NOLOCK))) {
 		pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
@@ -6085,28 +6084,6 @@ bool csr_scan_remove_fresh_scan_command(tpAniSirGlobal pMac, uint8_t sessionId)
 	return fRet;
 }
 
-void csr_release_scan_command(tpAniSirGlobal pMac, tSmeCmd *pCommand,
-			      eCsrScanStatus scanStatus)
-{
-	eCsrScanReason reason = pCommand->u.scanCmd.reason;
-	bool status;
-	tDblLinkList *cmd_list = NULL;
-
-	csr_scan_call_callback(pMac, pCommand, scanStatus);
-	sms_log(pMac, LOG1, FL("Remove Scan command reason = %d, scan_id %d"),
-		reason, pCommand->u.scanCmd.scanID);
-	cmd_list = &pMac->sme.smeScanCmdActiveList;
-	status = csr_ll_remove_entry(cmd_list, &pCommand->Link, LL_ACCESS_LOCK);
-	if (!status) {
-		sms_log(pMac, LOGE,
-			FL("cannot release command reason %d scan_id %d"),
-			pCommand->u.scanCmd.reason,
-			pCommand->u.scanCmd.scanID);
-		return;
-	}
-	csr_release_command(pMac, pCommand);
-}
-
 QDF_STATUS csr_scan_get_pmkid_candidate_list(tpAniSirGlobal pMac,
 					     uint32_t sessionId,
 					     tPmkidCandidateInfo *pPmkidList,
@@ -6720,10 +6697,8 @@ QDF_STATUS csr_scan_abort_all_scans(tpAniSirGlobal mac_ctx,
 			csr_remove_cmd_from_pending_list(
 				mac_ctx,
 				session_id, INVALID_SCAN_ID,
-				&mac_ctx->sme.smeScanCmdPendingList,
 				eSmeCommandScan);
 			csr_abort_scan_from_active_list(mac_ctx,
-				 &mac_ctx->sme.smeScanCmdActiveList,
 				 session_id, INVALID_SCAN_ID, eSmeCommandScan,
 				 reason);
 		}
@@ -6741,8 +6716,7 @@ QDF_STATUS csr_scan_abort_mac_scan(tpAniSirGlobal pMac, uint8_t sessionId,
 
 	pMac->scan.fDropScanCmd = true;
 	ret = csr_remove_cmd_from_pending_list(pMac,
-			sessionId, scan_id, &pMac->sme.smeScanCmdPendingList,
-			eSmeCommandScan);
+			sessionId, scan_id, eSmeCommandScan);
 	pMac->scan.fDropScanCmd = false;
 
 	/*
@@ -6753,8 +6727,8 @@ QDF_STATUS csr_scan_abort_mac_scan(tpAniSirGlobal pMac, uint8_t sessionId,
 	if (ret != QDF_STATUS_SUCCESS ||
 			sessionId != CSR_SESSION_ID_INVALID) {
 		status = csr_abort_scan_from_active_list(pMac,
-			&pMac->sme.smeScanCmdActiveList, sessionId, scan_id,
-			eSmeCommandScan, reason);
+				sessionId, scan_id,
+				eSmeCommandScan, reason);
 	}
 	return status;
 }
@@ -6806,7 +6780,7 @@ QDF_STATUS csr_remove_nonscan_cmd_from_pending_list(tpAniSirGlobal pMac,
 		sms_log(pMac, LOG1, FL("Sending abort for command ID %d"),
 			(commandType == eSmeCommandScan) ? pCommand->u.
 			scanCmd.scanID : sessionId);
-		csr_abort_command(pMac, pCommand, false);
+		csr_release_command(pMac, pCommand);
 	}
 
 	csr_ll_close(&localList);
@@ -6816,7 +6790,6 @@ QDF_STATUS csr_remove_nonscan_cmd_from_pending_list(tpAniSirGlobal pMac,
 QDF_STATUS csr_remove_cmd_from_pending_list(tpAniSirGlobal pMac,
 						uint8_t sessionId,
 						uint32_t scan_id,
-						tDblLinkList *pList,
 						eSmeCommandType commandType)
 {
 	tDblLinkList localList;
@@ -6831,8 +6804,8 @@ QDF_STATUS csr_remove_cmd_from_pending_list(tpAniSirGlobal pMac,
 		return status;
 	}
 
-	csr_ll_lock(pList);
-	pEntry = csr_ll_peek_head(pList, LL_ACCESS_NOLOCK);
+	csr_scan_pending_ll_lock(pMac);
+	pEntry = csr_scan_pending_ll_peek_head(pMac, LL_ACCESS_NOLOCK);
 
 	/*
 	 * Have to make sure we don't loop back to the head of the list,
@@ -6840,7 +6813,8 @@ QDF_STATUS csr_remove_cmd_from_pending_list(tpAniSirGlobal pMac,
 	 */
 	while (pEntry) {
 		pEntryToRemove = pEntry;
-		pEntry = csr_ll_next(pList, pEntry, LL_ACCESS_NOLOCK);
+		pEntry = csr_scan_pending_ll_next(pMac, pEntry,
+						LL_ACCESS_NOLOCK);
 		pCommand = GET_BASE_ADDR(pEntryToRemove, tSmeCmd, Link);
 
 		if ((pCommand->command == commandType) &&
@@ -6848,22 +6822,22 @@ QDF_STATUS csr_remove_cmd_from_pending_list(tpAniSirGlobal pMac,
 		    (pCommand->u.scanCmd.scanID == scan_id)) ||
 		    (pCommand->sessionId == sessionId))) {
 			/* Remove that entry only */
-			if (csr_ll_remove_entry(pList, pEntryToRemove,
-			    LL_ACCESS_NOLOCK)) {
+			if (csr_scan_pending_ll_remove_entry(pMac,
+					pEntryToRemove, LL_ACCESS_NOLOCK)) {
 				csr_ll_insert_tail(&localList, pEntryToRemove,
 						   LL_ACCESS_NOLOCK);
 				status = QDF_STATUS_SUCCESS;
 			}
 		}
 	}
-	csr_ll_unlock(pList);
+	csr_scan_pending_ll_unlock(pMac);
 
 	while ((pEntry = csr_ll_remove_head(&localList, LL_ACCESS_NOLOCK))) {
 		pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
 		sms_log(pMac, LOG1, FL("Sending abort for command ID %d"),
 			(commandType == eSmeCommandScan) ? pCommand->u.
 			scanCmd.scanID : sessionId);
-		csr_abort_command(pMac, pCommand, false);
+		csr_release_command(pMac, pCommand);
 	}
 
 	csr_ll_close(&localList);
@@ -6875,17 +6849,15 @@ QDF_STATUS csr_scan_abort_scan_for_ssid(tpAniSirGlobal pMac, uint32_t sessionId)
 	QDF_STATUS status = QDF_STATUS_SUCCESS;
 
 	pMac->scan.fDropScanCmd = true;
-	csr_remove_scan_for_ssid_from_pending_list(pMac,
-			&pMac->sme.smeScanCmdPendingList, sessionId);
+	csr_remove_scan_for_ssid_from_pending_list(pMac, sessionId);
 	pMac->scan.fDropScanCmd = false;
-	csr_abort_scan_from_active_list(pMac, &pMac->sme.smeScanCmdActiveList,
+	csr_abort_scan_from_active_list(pMac,
 			sessionId, INVALID_SCAN_ID, eSmeCommandScan,
 			eCSR_SCAN_ABORT_SSID_ONLY);
 	return status;
 }
 
 void csr_remove_scan_for_ssid_from_pending_list(tpAniSirGlobal pMac,
-						tDblLinkList *pList,
 						uint32_t sessionId)
 {
 	tDblLinkList localList;
@@ -6898,16 +6870,17 @@ void csr_remove_scan_for_ssid_from_pending_list(tpAniSirGlobal pMac,
 		sms_log(pMac, LOGE, FL(" failed to open list"));
 		return;
 	}
-	csr_ll_lock(pList);
-	if (!csr_ll_is_list_empty(pList, LL_ACCESS_NOLOCK)) {
-		pEntry = csr_ll_peek_head(pList, LL_ACCESS_NOLOCK);
+	csr_scan_pending_ll_lock(pMac);
+	if (!csr_scan_pending_ll_is_list_empty(pMac, LL_ACCESS_NOLOCK)) {
+		pEntry = csr_scan_pending_ll_peek_head(pMac, LL_ACCESS_NOLOCK);
 		/*
 		 * Have to make sure we don't loop back to the head of the list,
 		 * which will happen if the entry is NOT on the list...
 		 */
 		while (pEntry) {
 			pEntryToRemove = pEntry;
-			pEntry = csr_ll_next(pList, pEntry, LL_ACCESS_NOLOCK);
+			pEntry = csr_scan_pending_ll_next(pMac, pEntry,
+						LL_ACCESS_NOLOCK);
 			pCommand = GET_BASE_ADDR(pEntryToRemove, tSmeCmd, Link);
 
 			if (!((eSmeCommandScan == pCommand->command) &&
@@ -6916,17 +6889,17 @@ void csr_remove_scan_for_ssid_from_pending_list(tpAniSirGlobal pMac,
 			if (eCsrScanForSsid != pCommand->u.scanCmd.reason)
 				continue;
 			/* Remove that entry only */
-			if (csr_ll_remove_entry(pList, pEntryToRemove,
-						LL_ACCESS_NOLOCK)) {
+			if (csr_scan_pending_ll_remove_entry(pMac,
+					pEntryToRemove, LL_ACCESS_NOLOCK)) {
 				csr_ll_insert_tail(&localList, pEntryToRemove,
 						   LL_ACCESS_NOLOCK);
 			}
 		}
 	}
-	csr_ll_unlock(pList);
+	csr_scan_pending_ll_unlock(pMac);
 	while ((pEntry = csr_ll_remove_head(&localList, LL_ACCESS_NOLOCK))) {
 		pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
-		csr_abort_command(pMac, pCommand, false);
+		csr_release_command(pMac, pCommand);
 	}
 	csr_ll_close(&localList);
 }
@@ -6987,7 +6960,7 @@ static void csr_send_scan_abort(tpAniSirGlobal mac_ctx,
  * Return: Success - QDF_STATUS_SUCCESS, Failure - error number
  */
 QDF_STATUS csr_abort_scan_from_active_list(tpAniSirGlobal mac_ctx,
-		tDblLinkList *list, uint32_t session_id, uint32_t scan_id,
+		uint32_t session_id, uint32_t scan_id,
 		eSmeCommandType scan_cmd_type, eCsrAbortReason abort_reason)
 {
 	tListElem *entry;
@@ -6995,12 +6968,14 @@ QDF_STATUS csr_abort_scan_from_active_list(tpAniSirGlobal mac_ctx,
 	tListElem *entry_remove;
 	QDF_STATUS status = QDF_STATUS_SUCCESS;
 
-	csr_ll_lock(list);
-	if (!csr_ll_is_list_empty(list, LL_ACCESS_NOLOCK)) {
-		entry = csr_ll_peek_head(list, LL_ACCESS_NOLOCK);
+	sms_log(mac_ctx, LOGE, FL("Enter"));
+	csr_scan_active_ll_lock(mac_ctx);
+	if (!csr_scan_active_ll_is_list_empty(mac_ctx, LL_ACCESS_NOLOCK)) {
+		entry = csr_scan_active_ll_peek_head(mac_ctx, LL_ACCESS_NOLOCK);
 		while (entry) {
 			entry_remove = entry;
-			entry = csr_ll_next(list, entry, LL_ACCESS_NOLOCK);
+			entry = csr_scan_active_ll_next(mac_ctx, entry,
+						LL_ACCESS_NOLOCK);
 			cmd = GET_BASE_ADDR(entry_remove, tSmeCmd, Link);
 
 			/*skip if abort reason is for SSID*/
@@ -7025,7 +7000,8 @@ QDF_STATUS csr_abort_scan_from_active_list(tpAniSirGlobal mac_ctx,
 			}
 		}
 	}
-	csr_ll_unlock(list);
+	csr_scan_active_ll_unlock(mac_ctx);
+	sms_log(mac_ctx, LOGE, FL("Exit"));
 
 	return status;
 }
@@ -7546,6 +7522,7 @@ void csr_scan_active_list_timeout_handle(void *userData)
 	}
 	csr_save_scan_results(mac_ctx, scan_cmd->u.scanCmd.reason,
 		scan_cmd->sessionId);
-	csr_release_scan_command(mac_ctx, scan_cmd, eCSR_SCAN_FAILURE);
+	scan_cmd->u.scanCmd.status = eCSR_SCAN_FAILURE;
+	csr_release_command(mac_ctx, scan_cmd);
 	return;
 }

+ 3 - 8
core/sme/src/csr/csr_inside_api.h

@@ -281,21 +281,18 @@ QDF_STATUS csr_scan_abort_all_scans(tpAniSirGlobal mac_ctx,
  * for failure
  */
 QDF_STATUS csr_remove_cmd_from_pending_list(tpAniSirGlobal pMac,
-						      uint8_t sessionId,
-						      uint32_t scan_id,
-						      tDblLinkList *pList,
-						      eSmeCommandType commandType);
+			uint8_t sessionId, uint32_t scan_id,
+			eSmeCommandType commandType);
 QDF_STATUS csr_remove_nonscan_cmd_from_pending_list(tpAniSirGlobal pMac,
 			uint8_t sessionId, eSmeCommandType commandType);
 QDF_STATUS csr_scan_abort_mac_scan_not_for_connect(tpAniSirGlobal pMac,
 						   uint8_t sessionId);
 QDF_STATUS csr_scan_abort_scan_for_ssid(tpAniSirGlobal pMac, uint32_t sessionId);
 void csr_remove_scan_for_ssid_from_pending_list(tpAniSirGlobal pMac,
-						tDblLinkList *pList,
 						uint32_t sessionId);
 
 QDF_STATUS csr_abort_scan_from_active_list(tpAniSirGlobal pMac,
-		tDblLinkList *pList, uint32_t sessionId, uint32_t scan_id,
+		uint32_t sessionId, uint32_t scan_id,
 		eSmeCommandType scan_cmd_type, eCsrAbortReason abort_reason);
 
 /* To age out scan results base. tSmeGetScanChnRsp is a pointer returned by LIM that */
@@ -1056,8 +1053,6 @@ tpSirBssDescription csr_get_fst_bssdescr_ptr(tScanResultHandle result_handle);
 tSirBssDescription*
 csr_get_bssdescr_from_scan_handle(tScanResultHandle result_handle,
 				  tSirBssDescription *bss_descr);
-void csr_release_scan_command(tpAniSirGlobal pMac, tSmeCmd *pCommand,
-			      eCsrScanStatus scanStatus);
 bool is_disconnect_pending(tpAniSirGlobal mac_ctx,
 				   uint8_t sessionid);
 void csr_scan_active_list_timeout_handle(void *userData);

+ 239 - 13
core/sme/src/csr/csr_util.c

@@ -255,6 +255,15 @@ const char *get_e_csr_roam_result_str(eCsrRoamResult val)
 	}
 }
 
+void purge_sme_session_pending_scan_cmd_list(struct sAniSirGlobal *mac_ctx,
+				uint32_t session_id)
+{
+	uint8_t vdev_id = session_id;
+
+	wlan_serialization_purge_cmd_list(mac_ctx->psoc, &vdev_id,
+			false, true, false, false, false);
+}
+
 void purge_sme_session_pending_cmd_list(struct sAniSirGlobal *mac_ctx,
 				uint32_t session_id)
 {
@@ -287,6 +296,23 @@ void csr_nonscan_pending_ll_insert_tail(struct sAniSirGlobal *mac_ctx,
 		tListElem *entry, bool inter_locked)
 {
 }
+
+void csr_scan_pending_ll_unlock(struct sAniSirGlobal *mac_ctx)
+{
+}
+
+void csr_scan_active_ll_unlock(struct sAniSirGlobal *mac_ctx)
+{
+}
+
+void csr_scan_pending_ll_lock(struct sAniSirGlobal *mac_ctx)
+{
+}
+
+void csr_scan_active_ll_lock(struct sAniSirGlobal *mac_ctx)
+{
+}
+
 void csr_nonscan_pending_ll_unlock(struct sAniSirGlobal *mac_ctx)
 {
 }
@@ -302,6 +328,7 @@ void csr_nonscan_pending_ll_lock(struct sAniSirGlobal *mac_ctx)
 void csr_nonscan_active_ll_lock(struct sAniSirGlobal *mac_ctx)
 {
 }
+
 uint32_t csr_nonscan_active_ll_count(struct sAniSirGlobal *mac_ctx)
 {
 	return wlan_serialization_get_active_list_count(mac_ctx->psoc, false);
@@ -312,6 +339,28 @@ uint32_t csr_nonscan_pending_ll_count(struct sAniSirGlobal *mac_ctx)
 	return wlan_serialization_get_pending_list_count(mac_ctx->psoc, false);
 }
 
+uint32_t csr_scan_active_ll_count(struct sAniSirGlobal *mac_ctx)
+{
+	return wlan_serialization_get_active_list_count(mac_ctx->psoc, true);
+}
+
+uint32_t csr_scan_pending_ll_count(struct sAniSirGlobal *mac_ctx)
+{
+	return wlan_serialization_get_pending_list_count(mac_ctx->psoc, true);
+}
+
+bool csr_scan_active_ll_is_list_empty(struct sAniSirGlobal *mac_ctx,
+					bool inter_locked)
+{
+	return !wlan_serialization_get_active_list_count(mac_ctx->psoc, true);
+}
+
+bool csr_scan_pending_ll_is_list_empty(struct sAniSirGlobal *mac_ctx,
+					bool inter_locked)
+{
+	return !wlan_serialization_get_pending_list_count(mac_ctx->psoc, true);
+}
+
 bool csr_nonscan_active_ll_is_list_empty(struct sAniSirGlobal *mac_ctx,
 				bool inter_locked)
 {
@@ -328,7 +377,7 @@ tListElem *csr_nonscan_active_ll_peek_head(struct sAniSirGlobal *mac_ctx,
 	struct wlan_serialization_command *cmd;
 	tSmeCmd *sme_cmd;
 
-	sms_log(mac_ctx, LOGE, "Enter");
+	sms_log(mac_ctx, LOGE, FL("Enter"));
 	cmd = wlan_serialization_peek_head_active_cmd_using_psoc(mac_ctx->psoc,
 								 false);
 	if (!cmd) {
@@ -336,7 +385,7 @@ tListElem *csr_nonscan_active_ll_peek_head(struct sAniSirGlobal *mac_ctx,
 		return NULL;
 	}
 	sme_cmd = cmd->umac_cmd;
-	sms_log(mac_ctx, LOGE, "Exit");
+	sms_log(mac_ctx, LOGE, FL("Exit"));
 
 	return &sme_cmd->Link;
 }
@@ -346,7 +395,7 @@ tListElem *csr_nonscan_pending_ll_peek_head(struct sAniSirGlobal *mac_ctx,
 	struct wlan_serialization_command *cmd;
 	tSmeCmd *sme_cmd;
 
-	sms_log(mac_ctx, LOGE, "Enter");
+	sms_log(mac_ctx, LOGE, FL("Enter"));
 	cmd = wlan_serialization_peek_head_pending_cmd_using_psoc(mac_ctx->psoc,
 								  false);
 	if (!cmd) {
@@ -354,22 +403,61 @@ tListElem *csr_nonscan_pending_ll_peek_head(struct sAniSirGlobal *mac_ctx,
 		return NULL;
 	}
 	sme_cmd = cmd->umac_cmd;
-	sms_log(mac_ctx, LOGE, "Exit");
+	sms_log(mac_ctx, LOGE, FL("Exit"));
+
+	return &sme_cmd->Link;
+}
+
+tListElem *csr_scan_active_ll_peek_head(struct sAniSirGlobal *mac_ctx,
+		bool inter_locked)
+{
+	struct wlan_serialization_command *cmd;
+	tSmeCmd *sme_cmd;
+
+	sms_log(mac_ctx, LOGE, FL("Enter"));
+	cmd = wlan_serialization_peek_head_active_cmd_using_psoc(mac_ctx->psoc,
+			true);
+	if (!cmd) {
+		sms_log(mac_ctx, LOGE, "No cmd found");
+		return NULL;
+	}
+	sme_cmd = cmd->umac_cmd;
+	sms_log(mac_ctx, LOGE, FL("Exit"));
+
+	return &sme_cmd->Link;
+}
+
+tListElem *csr_scan_pending_ll_peek_head(struct sAniSirGlobal *mac_ctx,
+		bool inter_locked)
+{
+	struct wlan_serialization_command *cmd;
+	tSmeCmd *sme_cmd;
+
+	sms_log(mac_ctx, LOGE, FL("Enter"));
+	cmd = wlan_serialization_peek_head_pending_cmd_using_psoc(mac_ctx->psoc,
+			true);
+	if (!cmd) {
+		sms_log(mac_ctx, LOGE, "No cmd found");
+		return NULL;
+	}
+	sme_cmd = cmd->umac_cmd;
+	sms_log(mac_ctx, LOGE, FL("Exit"));
 
 	return &sme_cmd->Link;
 }
+
 bool csr_nonscan_active_ll_remove_entry(struct sAniSirGlobal *mac_ctx,
 		tListElem *entry, bool inter_locked)
 {
 	tListElem *head;
 
-	sms_log(mac_ctx, LOGE, "Enter");
+	sms_log(mac_ctx, LOGE, FL("Enter"));
 	head = csr_nonscan_active_ll_peek_head(mac_ctx, inter_locked);
 	if (head == entry) {
-		sms_log(mac_ctx, LOGE, "Exit");
+		sms_log(mac_ctx, LOGE, "found and Exit");
 		return true;
 	} else {
-		sms_log(mac_ctx, LOGE, "Exit");
+		sms_log(mac_ctx, LOGE, "not found and Exit");
 		return false;
 	}
 }
@@ -378,38 +466,176 @@ bool csr_nonscan_pending_ll_remove_entry(struct sAniSirGlobal *mac_ctx,
 {
 	tListElem *head;
 
-	sms_log(mac_ctx, LOGE, "Enter");
+	sms_log(mac_ctx, LOGE, FL("Enter"));
 	head = csr_nonscan_pending_ll_peek_head(mac_ctx, inter_locked);
 	if (head == entry) {
-		sms_log(mac_ctx, LOGE, "Exit");
+		sms_log(mac_ctx, LOGE, "found and Exit");
 		return true;
 	} else {
-		sms_log(mac_ctx, LOGE, "Exit");
+		sms_log(mac_ctx, LOGE, "not found and Exit");
 		return false;
 	}
 }
+
+bool csr_scan_active_ll_remove_entry(struct sAniSirGlobal *mac_ctx,
+		tListElem *entry, bool inter_locked)
+{
+	tListElem *found_sme_cmd;
+	tSmeCmd *sme_cmd;
+	struct wlan_serialization_command *cmd;
+
+	if (!entry) {
+		sms_log(mac_ctx, LOGE, "entry is null");
+		return false;
+	}
+	sms_log(mac_ctx, LOGE, FL("Enter"));
+	sme_cmd = GET_BASE_ADDR(entry, tSmeCmd, Link);
+	cmd = wlan_serialization_get_scan_cmd_using_scan_id(mac_ctx->psoc,
+				sme_cmd->sessionId, sme_cmd->u.scanCmd.scanID,
+				true);
+	if (!cmd) {
+		sms_log(mac_ctx, LOGE, "Can't find the entry");
+		return false;
+	}
+	sme_cmd = cmd->umac_cmd;
+	found_sme_cmd = &sme_cmd->Link;
+	if (found_sme_cmd == entry) {
+		sms_log(mac_ctx, LOGE, "found and Exit");
+		return true;
+	} else {
+		sms_log(mac_ctx, LOGE, "not found and Exit");
+		return false;
+	}
+}
+bool csr_scan_pending_ll_remove_entry(struct sAniSirGlobal *mac_ctx,
+		tListElem *entry, bool inter_locked)
+{
+	tListElem *found_sme_cmd;
+	tSmeCmd *sme_cmd;
+	struct wlan_serialization_command *cmd;
+
+	if (!entry) {
+		sms_log(mac_ctx, LOGE, "entry is null");
+		return false;
+	}
+	sms_log(mac_ctx, LOGE, FL("Enter"));
+	sme_cmd = GET_BASE_ADDR(entry, tSmeCmd, Link);
+	cmd = wlan_serialization_get_scan_cmd_using_scan_id(mac_ctx->psoc,
+				sme_cmd->sessionId, sme_cmd->u.scanCmd.scanID,
+				false);
+	if (!cmd) {
+		sms_log(mac_ctx, LOGE, "Can't find the entry");
+		return false;
+	}
+	sme_cmd = cmd->umac_cmd;
+	found_sme_cmd = &sme_cmd->Link;
+	if (found_sme_cmd == entry) {
+		sms_log(mac_ctx, LOGE, "found and Exit");
+		return true;
+	} else {
+		sms_log(mac_ctx, LOGE, "not found and Exit");
+		return false;
+	}
+}
+
+tListElem *csr_scan_active_ll_remove_head(struct sAniSirGlobal *mac_ctx,
+		bool inter_locked)
+{
+	return csr_scan_active_ll_peek_head(mac_ctx, inter_locked);
+}
+
+tListElem *csr_scan_pending_ll_remove_head(struct sAniSirGlobal *mac_ctx,
+		bool inter_locked)
+{
+	return csr_scan_pending_ll_peek_head(mac_ctx, inter_locked);
+}
+
+
 tListElem *csr_nonscan_active_ll_remove_head(struct sAniSirGlobal *mac_ctx,
 		bool inter_locked)
 {
 	return csr_nonscan_active_ll_peek_head(mac_ctx, inter_locked);
 }
+
 tListElem *csr_nonscan_pending_ll_remove_head(struct sAniSirGlobal *mac_ctx,
 		bool inter_locked)
 {
 	return csr_nonscan_pending_ll_peek_head(mac_ctx, inter_locked);
 }
 
+tListElem *csr_scan_active_ll_next(struct sAniSirGlobal *mac_ctx,
+				tListElem *entry, bool inter_locked)
+{
+	tSmeCmd *sme_cmd;
+	struct wlan_serialization_command cmd, *tcmd;
+
+	sms_log(mac_ctx, LOGE, FL("Enter"));
+	if (!entry)
+		return NULL;
+	sme_cmd = GET_BASE_ADDR(entry, tSmeCmd, Link);
+	if (sme_cmd->command == eSmeCommandScan ||
+			sme_cmd->command == eSmeCommandRemainOnChannel)
+		cmd.cmd_id = sme_cmd->u.scanCmd.scanID;
+	else
+		cmd.cmd_id = 0;
+	cmd.cmd_type = csr_get_cmd_type(sme_cmd);
+	cmd.vdev = wlan_objmgr_get_vdev_by_id_from_psoc(mac_ctx->psoc,
+				sme_cmd->sessionId, WLAN_LEGACY_SME_ID);
+	tcmd = wlan_serialization_get_active_list_next_node_using_psoc(
+				mac_ctx->psoc, &cmd, true);
+	if (!tcmd) {
+		sms_log(mac_ctx, LOGE, "No cmd found");
+		return NULL;
+	}
+	sme_cmd = tcmd->umac_cmd;
+	sms_log(mac_ctx, LOGE, FL("Exit"));
+	return &sme_cmd->Link;
+}
+
+tListElem *csr_scan_pending_ll_next(struct sAniSirGlobal *mac_ctx,
+				tListElem *entry, bool inter_locked)
+{
+	tSmeCmd *sme_cmd;
+	struct wlan_serialization_command cmd, *tcmd;
+
+	sms_log(mac_ctx, LOGE, FL("Enter"));
+	if (!entry)
+		return NULL;
+	sme_cmd = GET_BASE_ADDR(entry, tSmeCmd, Link);
+	if (sme_cmd->command == eSmeCommandScan ||
+			sme_cmd->command == eSmeCommandRemainOnChannel)
+		cmd.cmd_id = sme_cmd->u.scanCmd.scanID;
+	else
+		cmd.cmd_id = 0;
+	cmd.cmd_type = csr_get_cmd_type(sme_cmd);
+	cmd.vdev = wlan_objmgr_get_vdev_by_id_from_psoc(mac_ctx->psoc,
+				sme_cmd->sessionId, WLAN_LEGACY_SME_ID);
+	tcmd = wlan_serialization_get_pending_list_next_node_using_psoc(
+				mac_ctx->psoc, &cmd, true);
+	if (!tcmd) {
+		sms_log(mac_ctx, LOGE, FL("No cmd found"));
+		return NULL;
+	}
+	sme_cmd = tcmd->umac_cmd;
+	sms_log(mac_ctx, LOGE, FL("Exit"));
+	return &sme_cmd->Link;
+}
+
 tListElem *csr_nonscan_pending_ll_next(struct sAniSirGlobal *mac_ctx,
 				tListElem *entry, bool inter_locked)
 {
 	tSmeCmd *sme_cmd;
 	struct wlan_serialization_command cmd, *tcmd;
 
-	sms_log(mac_ctx, LOGE, "Enter");
+	sms_log(mac_ctx, LOGE, FL("Enter"));
 	if (!entry)
 		return NULL;
 	sme_cmd = GET_BASE_ADDR(entry, tSmeCmd, Link);
-	cmd.cmd_id = 0;
+	if (sme_cmd->command == eSmeCommandScan ||
+			sme_cmd->command == eSmeCommandRemainOnChannel)
+		cmd.cmd_id = sme_cmd->u.scanCmd.scanID;
+	else
+		cmd.cmd_id = 0;
 	cmd.cmd_type = csr_get_cmd_type(sme_cmd);
 	cmd.vdev = wlan_objmgr_get_vdev_by_id_from_psoc(mac_ctx->psoc,
 				sme_cmd->sessionId, WLAN_LEGACY_SME_ID);
@@ -420,7 +646,7 @@ tListElem *csr_nonscan_pending_ll_next(struct sAniSirGlobal *mac_ctx,
 		return NULL;
 	}
 	sme_cmd = tcmd->umac_cmd;
-	sms_log(mac_ctx, LOGE, "Exit");
+	sms_log(mac_ctx, LOGE, FL("Exit"));
 	return &sme_cmd->Link;
 }
 

+ 1 - 2
core/sme/src/p2p/p2p_api.c

@@ -123,13 +123,12 @@ QDF_STATUS sme_remain_on_chn_rsp(tpAniSirGlobal pMac, uint8_t *pMsg)
 		callback(pMac, pCommand->u.remainChlCmd.callbackCtx,
 			rsp->status, rsp->scan_id);
 
-	fFound = csr_ll_remove_entry(&pMac->sme.smeScanCmdActiveList, pEntry,
+	fFound = csr_scan_active_ll_remove_entry(pMac, pEntry,
 				     LL_ACCESS_LOCK);
 	if (fFound) {
 		/* Now put this command back on the avilable command list */
 		csr_release_command(pMac, pCommand);
 	}
-	sme_process_pending_queue(pMac);
 	return status;
 }