Эх сурвалжийг харах

qcacld-3.0: Replace legacy SME serialization with new serialization

Legacy SME module is using old serialization mechanism, enable new
serialization mechanism.
Provide ifdef switch to fallback to old serialization in-case if it
is required to move to old serialization.

CRs-Fixed: 2005532
Change-Id: I4801dbab53e451206e2ff0904d102676fd7336e2
Krunal Soni 8 жил өмнө
parent
commit
a8270f5401

+ 14 - 15
core/sme/inc/csr_internal.h

@@ -975,7 +975,6 @@ typedef struct tagCsrRoamSession {
 
 typedef struct tagCsrRoamStruct {
 	uint32_t nextRoamId;
-	tDblLinkList roamCmdPendingList;
 	tDblLinkList channelList5G;
 	tDblLinkList channelList24;
 	tCsrConfig configParam;
@@ -1398,31 +1397,31 @@ void csr_nonscan_active_ll_unlock(struct sAniSirGlobal *mac_ctx);
 void csr_nonscan_pending_ll_lock(struct sAniSirGlobal *mac_ctx);
 void csr_nonscan_active_ll_lock(struct sAniSirGlobal *mac_ctx);
 bool csr_nonscan_active_ll_is_list_empty(struct sAniSirGlobal *mac_ctx,
-			bool fInterlocked);
+			bool inter_locked);
 bool csr_nonscan_pending_ll_is_list_empty(struct sAniSirGlobal *mac_ctx,
-			bool fInterlocked);
+			bool inter_locked);
 bool csr_nonscan_active_ll_remove_entry(struct sAniSirGlobal *mac_ctx,
-			tListElem *pEntryToRemove, bool fInterlocked);
+			tListElem *pEntryToRemove, bool inter_locked);
 bool csr_nonscan_pending_ll_remove_entry(struct sAniSirGlobal *mac_ctx,
-			tListElem *pEntryToRemove, bool fInterlocked);
-tListElem *csr_nonscan_active_ll_peak_head(struct sAniSirGlobal *mac_ctx,
-			bool fInterlocked);
-tListElem *csr_nonscan_pending_ll_peak_head(struct sAniSirGlobal *mac_ctx,
-			bool fInterlocked);
+			tListElem *pEntryToRemove, bool inter_locked);
+tListElem *csr_nonscan_active_ll_peek_head(struct sAniSirGlobal *mac_ctx,
+			bool inter_locked);
+tListElem *csr_nonscan_pending_ll_peek_head(struct sAniSirGlobal *mac_ctx,
+			bool inter_locked);
 tListElem *csr_nonscan_active_ll_remove_head(struct sAniSirGlobal *mac_ctx,
-			bool fInterlocked);
+			bool inter_locked);
 tListElem *csr_nonscan_pending_ll_remove_head(struct sAniSirGlobal *mac_ctx,
-			bool fInterlocked);
+			bool inter_locked);
 uint32_t csr_nonscan_pending_ll_count(struct sAniSirGlobal *mac_ctx);
 void csr_nonscan_pending_ll_insert_head(struct sAniSirGlobal *mac_ctx,
-		tListElem *entry, bool fInterlocked);
+		tListElem *entry, bool inter_locked);
 void csr_nonscan_pending_ll_insert_tail(struct sAniSirGlobal *mac_ctx,
-		tListElem *entry, bool fInterlocked);
+		tListElem *entry, bool inter_locked);
 uint32_t csr_nonscan_active_ll_count(struct sAniSirGlobal *mac_ctx);
 void csr_nonscan_active_ll_insert_head(struct sAniSirGlobal *mac_ctx,
-		tListElem *entry, bool fInterlocked);
+		tListElem *entry, bool inter_locked);
 tListElem *csr_nonscan_pending_ll_next(struct sAniSirGlobal *mac_ctx,
-		tListElem *entry, bool fInterlocked);
+		tListElem *entry, bool inter_locked);
 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,

+ 13 - 0
core/sme/inc/sme_api.h

@@ -50,6 +50,7 @@
 #include "sme_rrm_internal.h"
 #include "sir_types.h"
 #include "scheduler_api.h"
+#include "wlan_serialization_api.h"
 
 /*--------------------------------------------------------------------------
   Preprocessor definitions and constants
@@ -242,6 +243,18 @@ QDF_STATUS sme_get_soft_ap_domain(tHalHandle hHal,
 		v_REGDOMAIN_t *domainIdSoftAp);
 QDF_STATUS sme_set_reg_info(tHalHandle hHal, uint8_t *apCntryCode);
 QDF_STATUS sme_hdd_ready_ind(tHalHandle hHal);
+/**
+ * sme_ser_cmd_callback() - callback from serialization module
+ * @buf: serialization command buffer
+ * @reason: reason why serialization module has given this callback
+ *
+ * Serialization module will give callback to SME for why it triggered
+ * the callback
+ *
+ * Return: QDF_STATUS_SUCCESS
+ */
+QDF_STATUS sme_ser_cmd_callback(void *buf,
+				enum wlan_serialization_cb_reason reason);
 QDF_STATUS sme_process_msg(tHalHandle hHal, struct scheduler_msg *pMsg);
 QDF_STATUS sme_mc_process_handler(struct scheduler_msg *msg);
 void sme_free_msg(tHalHandle hHal, struct scheduler_msg *pMsg);

+ 27 - 1
core/sme/inc/sme_inside.h

@@ -48,6 +48,7 @@
 #include "sme_qos_internal.h"
 
 #include "sme_rrm_api.h"
+#include "wlan_serialization_api.h"
 ePhyChanBondState csr_convert_cb_ini_value_to_phy_cb_state(uint32_t cbIniValue);
 
 /*--------------------------------------------------------------------------
@@ -59,6 +60,8 @@ ePhyChanBondState csr_convert_cb_ini_value_to_phy_cb_state(uint32_t cbIniValue);
  * to make sure we have space for these cmds + some additional cmds.
  */
 #define SME_TOTAL_COMMAND                (HAL_NUM_STA * 3)
+/* default sme timeout is set to 30 secs */
+#define SME_DEFAULT_CMD_TIMEOUT  30000
 
 typedef struct sGenericPmcCmd {
 	uint32_t size;          /* sizeof the data in the union, if any */
@@ -196,6 +199,29 @@ typedef struct tagSmeCmd {
 /*--------------------------------------------------------------------------
   Internal to SME
   ------------------------------------------------------------------------*/
+/**
+ * csr_get_cmd_type() - to convert sme command type to serialization cmd type
+ * @sme_cmd: sme command pointer
+ *
+ * This API will convert SME command type to serialization command type which
+ * new serialization module understands
+ *
+ * Return: serialization cmd type based on sme command type
+ */
+enum wlan_serialization_cmd_type csr_get_cmd_type(tSmeCmd *sme_cmd);
+/**
+ * csr_set_serialization_params_to_cmd() - take sme params and create new
+ *						serialization command
+ * @mac_ctx: pointer to mac context
+ * @sme_cmd: sme command pointer
+ * @cmd: serialization command pointer
+ * @high_priority: if command is high priority
+ *
+ * Return: QDF_STATUS_SUCCESS or QDF_STATUS_E_FAILURE
+ */
+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);
@@ -215,6 +241,7 @@ 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);
 bool csr_roam_is_valid40_mhz_channel(tpAniSirGlobal pmac, uint8_t channel);
@@ -269,7 +296,6 @@ QDF_STATUS csr_create_roam_scan_channel_list(tpAniSirGlobal pMac,
 QDF_STATUS p2p_process_remain_on_channel_cmd(tpAniSirGlobal pMac,
 					     tSmeCmd *p2pRemainonChn);
 ePhyChanBondState csr_convert_cb_ini_value_to_phy_cb_state(uint32_t cbIniValue);
-void active_list_cmd_timeout_handle(void *userData);
 void csr_process_set_dual_mac_config(tpAniSirGlobal mac, tSmeCmd *command);
 void csr_process_set_antenna_mode(tpAniSirGlobal mac, tSmeCmd *command);
 void csr_process_set_hw_mode(tpAniSirGlobal mac, tSmeCmd *command);

+ 0 - 2
core/sme/inc/sme_internal.h

@@ -181,8 +181,6 @@ typedef struct tagSmeStruct {
 	uint32_t totalSmeCmd;
 	/* following pointer contains array of pointers for tSmeCmd* */
 	void **pSmeCmdBufAddr;
-	tDblLinkList smeCmdActiveList;
-	tDblLinkList smeCmdPendingList;
 	tDblLinkList smeCmdFreeList;    /* preallocated roam cmd list */
 	enum tQDF_ADAPTER_MODE currDeviceMode;
 #ifdef FEATURE_WLAN_LPHB

+ 189 - 196
core/sme/src/common/sme_api.c

@@ -67,9 +67,6 @@
 static tSelfRecoveryStats g_self_recovery_stats;
 
 static QDF_STATUS init_sme_cmd_list(tpAniSirGlobal pMac);
-static void sme_abort_command(tpAniSirGlobal pMac, tSmeCmd *pCommand,
-			      bool fStopping);
-
 eCsrPhyMode sme_get_phy_mode(tHalHandle hHal);
 
 QDF_STATUS sme_handle_change_country_code(tpAniSirGlobal pMac, void *pMsgBuf);
@@ -137,7 +134,7 @@ QDF_STATUS sme_release_global_lock(tSmeStruct *psSme)
  */
 static QDF_STATUS sme_process_set_hw_mode_resp(tpAniSirGlobal mac, uint8_t *msg)
 {
-	tListElem *entry = NULL;
+	tListElem *entry;
 	tSmeCmd *command = NULL;
 	bool found;
 	hw_mode_cb callback = NULL;
@@ -154,7 +151,7 @@ static QDF_STATUS sme_process_set_hw_mode_resp(tpAniSirGlobal mac, uint8_t *msg)
 		 */
 	}
 
-	entry = csr_nonscan_active_ll_peak_head(mac, LL_ACCESS_LOCK);
+	entry = csr_nonscan_active_ll_peek_head(mac, LL_ACCESS_LOCK);
 	if (!entry) {
 		sms_log(mac, LOGE, FL("No cmd found in active list"));
 		return QDF_STATUS_E_FAILURE;
@@ -249,7 +246,7 @@ end:
 		/* Now put this command back on the avilable command list */
 		csr_release_command(mac, command);
 	}
-	sme_process_pending_queue(mac);
+
 	return QDF_STATUS_SUCCESS;
 }
 
@@ -311,19 +308,10 @@ static QDF_STATUS init_sme_cmd_list(tpAniSirGlobal pMac)
 	QDF_STATUS status;
 	tSmeCmd *pCmd;
 	uint32_t cmd_idx;
-	QDF_STATUS qdf_status;
-	qdf_mc_timer_t *cmdTimeoutTimer = NULL;
 	uint32_t sme_cmd_ptr_ary_sz;
 
 	pMac->sme.totalSmeCmd = SME_TOTAL_COMMAND;
 
-	status = csr_ll_open(pMac->hHdd, &pMac->sme.smeCmdActiveList);
-	if (!QDF_IS_STATUS_SUCCESS(status))
-		goto end;
-
-	status = csr_ll_open(pMac->hHdd, &pMac->sme.smeCmdPendingList);
-	if (!QDF_IS_STATUS_SUCCESS(status))
-		goto end;
 
 	status = csr_ll_open(pMac->hHdd, &pMac->sme.smeScanCmdActiveList);
 	if (!QDF_IS_STATUS_SUCCESS(status))
@@ -368,28 +356,6 @@ static QDF_STATUS init_sme_cmd_list(tpAniSirGlobal pMac)
 				&pCmd->Link, LL_ACCESS_LOCK);
 	}
 
-	/* This timer is only to debug the active list command timeout */
-
-	cmdTimeoutTimer =
-		(qdf_mc_timer_t *) qdf_mem_malloc(sizeof(qdf_mc_timer_t));
-	if (cmdTimeoutTimer) {
-		pMac->sme.smeCmdActiveList.cmdTimeoutTimer = cmdTimeoutTimer;
-		qdf_status =
-			qdf_mc_timer_init(pMac->sme.smeCmdActiveList.
-					  cmdTimeoutTimer, QDF_TIMER_TYPE_SW,
-					  active_list_cmd_timeout_handle, (void *)pMac);
-
-		if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
-			QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
-				  "Init Timer fail for active list command process time out");
-			qdf_mem_free(pMac->sme.smeCmdActiveList.
-				     cmdTimeoutTimer);
-			pMac->sme.smeCmdActiveList.cmdTimeoutTimer = NULL;
-		} else {
-			pMac->sme.smeCmdActiveList.cmdTimeoutDuration =
-				SME_ACTIVE_LIST_CMD_TIMEOUT_VALUE;
-		}
-	}
 
 end:
 	if (!QDF_IS_STATUS_SUCCESS(status))
@@ -399,10 +365,11 @@ end:
 	return status;
 }
 
-void sme_release_command(tpAniSirGlobal pMac, tSmeCmd *pCmd)
+void sme_release_command(tpAniSirGlobal mac_ctx, tSmeCmd *sme_cmd)
 {
-	pCmd->command = eSmeNoCommand;
-	csr_ll_insert_tail(&pMac->sme.smeCmdFreeList, &pCmd->Link, LL_ACCESS_LOCK);
+	sme_cmd->command = eSmeNoCommand;
+	csr_ll_insert_tail(&mac_ctx->sme.smeCmdFreeList, &sme_cmd->Link,
+				LL_ACCESS_LOCK);
 }
 
 static void sme_release_cmd_list(tpAniSirGlobal pMac, tDblLinkList *pList)
@@ -414,15 +381,18 @@ static void sme_release_cmd_list(tpAniSirGlobal pMac, tDblLinkList *pList)
 		/* 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);
-		sme_abort_command(pMac, pCommand, true);
+		csr_abort_command(pMac, pCommand, true);
 	}
 }
 
 static void purge_sme_cmd_list(tpAniSirGlobal pMac)
 {
-	/* release any out standing commands back to free command list */
-	sme_release_cmd_list(pMac, &pMac->sme.smeCmdPendingList);
-	sme_release_cmd_list(pMac, &pMac->sme.smeCmdActiveList);
+	/* purge pending command list */
+	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);
 }
@@ -458,7 +428,7 @@ void purge_sme_session_cmd_list(tpAniSirGlobal pMac, uint32_t sessionId,
 
 	while ((pEntry = csr_ll_remove_head(&localList, LL_ACCESS_NOLOCK))) {
 		pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
-		sme_abort_command(pMac, pCommand, true);
+		csr_abort_command(pMac, pCommand, true);
 	}
 	csr_ll_close(&localList);
 }
@@ -468,17 +438,10 @@ static QDF_STATUS free_sme_cmd_list(tpAniSirGlobal pMac)
 	QDF_STATUS status = QDF_STATUS_SUCCESS;
 
 	purge_sme_cmd_list(pMac);
-	csr_ll_close(&pMac->sme.smeCmdPendingList);
-	csr_ll_close(&pMac->sme.smeCmdActiveList);
 	csr_ll_close(&pMac->sme.smeScanCmdPendingList);
 	csr_ll_close(&pMac->sme.smeScanCmdActiveList);
 	csr_ll_close(&pMac->sme.smeCmdFreeList);
 
-	/*destroy active list command time out timer */
-	qdf_mc_timer_destroy(pMac->sme.smeCmdActiveList.cmdTimeoutTimer);
-	qdf_mem_free(pMac->sme.smeCmdActiveList.cmdTimeoutTimer);
-	pMac->sme.smeCmdActiveList.cmdTimeoutTimer = NULL;
-
 	status = qdf_mutex_acquire(&pMac->sme.lkSmeGlobalLock);
 	if (status != QDF_STATUS_SUCCESS) {
 		sms_log(pMac, LOGE,
@@ -546,7 +509,7 @@ tSmeCmd *sme_get_command_buffer(tpAniSirGlobal pMac)
 		int idx = 1;
 
 		/* Cannot change pRetCmd here since it needs to return later. */
-		pEntry = csr_nonscan_active_ll_peak_head(pMac, LL_ACCESS_LOCK);
+		pEntry = csr_nonscan_active_ll_peek_head(pMac, LL_ACCESS_LOCK);
 		if (pEntry) {
 			pTempCmd = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
 		}
@@ -563,7 +526,7 @@ tSmeCmd *sme_get_command_buffer(tpAniSirGlobal pMac)
 		/* dump what is in the pending queue */
 		csr_nonscan_pending_ll_lock(pMac);
 		pEntry =
-			csr_nonscan_pending_ll_peak_head(pMac,
+			csr_nonscan_pending_ll_peek_head(pMac,
 					 LL_ACCESS_NOLOCK);
 		while (pEntry && !sme_command_queue_full) {
 			pTempCmd = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
@@ -628,40 +591,6 @@ void sme_push_command(tpAniSirGlobal pMac, tSmeCmd *pCmd, bool fHighPriority)
 	return;
 }
 
-/* For commands that need to do extra cleanup. */
-static void sme_abort_command(tpAniSirGlobal pMac, tSmeCmd *pCommand,
-			      bool fStopping)
-{
-	if (eSmePmcCommandMask & pCommand->command) {
-		sms_log(pMac, LOG1,
-				"No need to process PMC commands");
-		return;
-	}
-	if (eSmeCsrCommandMask & pCommand->command) {
-		csr_abort_command(pMac, pCommand, fStopping);
-		return;
-	}
-	switch (pCommand->command) {
-	case eSmeCommandRemainOnChannel:
-		if (NULL != pCommand->u.remainChlCmd.callback) {
-			remainOnChanCallback callback =
-				pCommand->u.remainChlCmd.callback;
-			/* process the msg */
-			if (callback) {
-				callback(pMac, pCommand->u.remainChlCmd.
-					callbackCtx, eCSR_SCAN_ABORT,
-					pCommand->u.remainChlCmd.scan_id);
-			}
-		}
-		csr_release_command(pMac, pCommand);
-		break;
-	default:
-		csr_release_command(pMac, pCommand);
-		break;
-	}
-
-}
-
 static
 tListElem *csr_get_pending_cmd_to_process(tpAniSirGlobal pMac,
 				uint8_t sessionId, bool fInterlocked)
@@ -671,7 +600,7 @@ tListElem *csr_get_pending_cmd_to_process(tpAniSirGlobal pMac,
 
 	/* 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_peak_head(pMac, LL_ACCESS_LOCK);
+	pCurEntry = csr_nonscan_pending_ll_peek_head(pMac, LL_ACCESS_LOCK);
 	while (pCurEntry) {
 		pCommand = GET_BASE_ADDR(pCurEntry, tSmeCmd, Link);
 		if (pCommand->sessionId != sessionId) {
@@ -698,7 +627,7 @@ static bool sme_process_scan_queue(tpAniSirGlobal pMac)
 
 	if ((!csr_nonscan_active_ll_is_list_empty(pMac,
 				   LL_ACCESS_LOCK))) {
-		pSmeEntry = csr_nonscan_active_ll_peak_head(pMac,
+		pSmeEntry = csr_nonscan_active_ll_peek_head(pMac,
 					LL_ACCESS_LOCK);
 		if (pSmeEntry)
 			pSmeCommand = GET_BASE_ADDR(pSmeEntry, tSmeCmd, Link);
@@ -776,6 +705,169 @@ end:
 	return status;
 }
 
+/**
+ * sme_ser_handle_active_cmd() - handle command activation callback from
+ *					new serialization module
+ * @cmd: pointer to new serialization command
+ *
+ * This API is to handle command activation callback from new serialization
+ * callback
+ *
+ * Return: QDF_STATUS_SUCCESS
+ */
+static
+QDF_STATUS sme_ser_handle_active_cmd(struct wlan_serialization_command *cmd)
+{
+	tSmeCmd *sme_cmd;
+	tHalHandle hal;
+	tpAniSirGlobal mac_ctx;
+	QDF_STATUS status = QDF_STATUS_SUCCESS;
+	bool do_continue;
+
+	if (!cmd) {
+		sms_log(mac_ctx, LOGE, FL("No serialization command found"));
+		return QDF_STATUS_E_FAILURE;
+	}
+
+	hal = cds_get_context(QDF_MODULE_ID_SME);
+	mac_ctx = PMAC_STRUCT(hal);
+	if (!mac_ctx) {
+		sms_log(mac_ctx, LOGE, FL("No mac_ctx found"));
+		return QDF_STATUS_E_FAILURE;
+	}
+	sme_cmd = cmd->umac_cmd;
+	if (!sme_cmd) {
+		sms_log(mac_ctx, LOGE, FL("No SME command found"));
+		return QDF_STATUS_E_FAILURE;
+	}
+
+	switch (sme_cmd->command) {
+	case eSmeCommandRoam:
+		status = csr_roam_process_command(mac_ctx, sme_cmd);
+		break;
+	case eSmeCommandWmStatusChange:
+		csr_roam_process_wm_status_change_command(mac_ctx,
+					sme_cmd);
+		break;
+	case eSmeCommandSetKey:
+		status = csr_roam_process_set_key_command(mac_ctx, sme_cmd);
+		break;
+	case eSmeCommandNdpInitiatorRequest:
+		status = csr_process_ndp_initiator_request(mac_ctx, sme_cmd);
+		break;
+	case eSmeCommandNdpResponderRequest:
+		status = csr_process_ndp_responder_request(mac_ctx, sme_cmd);
+		break;
+	case eSmeCommandNdpDataEndInitiatorRequest:
+		status = csr_process_ndp_data_end_request(mac_ctx, sme_cmd);
+		break;
+	case eSmeCommandRemainOnChannel:
+		status = p2p_process_remain_on_channel_cmd(mac_ctx, sme_cmd);
+		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:
+#ifndef WLAN_MDM_CODE_REDUCTION_OPT
+		do_continue = qos_process_command(mac_ctx, sme_cmd);
+		if (do_continue)
+			status = QDF_STATUS_E_FAILURE;
+#endif
+		break;
+#ifdef FEATURE_WLAN_TDLS
+	case eSmeCommandTdlsSendMgmt:
+	case eSmeCommandTdlsAddPeer:
+	case eSmeCommandTdlsDelPeer:
+	case eSmeCommandTdlsLinkEstablish:
+		status = csr_tdls_process_cmd(mac_ctx, sme_cmd);
+		break;
+#endif
+	case e_sme_command_set_hw_mode:
+		csr_process_set_hw_mode(mac_ctx, sme_cmd);
+		break;
+	case e_sme_command_nss_update:
+		csr_process_nss_update_req(mac_ctx, sme_cmd);
+		break;
+	case e_sme_command_set_dual_mac_config:
+		csr_process_set_dual_mac_config(mac_ctx, sme_cmd);
+		break;
+	case e_sme_command_set_antenna_mode:
+		csr_process_set_antenna_mode(mac_ctx, sme_cmd);
+		break;
+	default:
+		/* something is wrong */
+		/* remove it from the active list */
+		sms_log(mac_ctx, LOGE, FL("unknown command %d"),
+			sme_cmd->command);
+		status = QDF_STATUS_E_FAILURE;
+		break;
+	}
+	if (!QDF_IS_STATUS_SUCCESS(status)) {
+		sms_log(mac_ctx, LOGE, FL("Releasing memory for %d"),
+			sme_cmd->command);
+		csr_release_command(mac_ctx, sme_cmd);
+	}
+	return status;
+}
+
+QDF_STATUS sme_ser_cmd_callback(void *buf,
+				enum wlan_serialization_cb_reason reason)
+{
+	struct wlan_serialization_command *cmd = buf;
+	tHalHandle hal;
+	tpAniSirGlobal mac_ctx;
+	QDF_STATUS status = QDF_STATUS_SUCCESS;
+	tSmeCmd *sme_cmd;
+
+	hal = cds_get_context(QDF_MODULE_ID_SME);
+	mac_ctx = PMAC_STRUCT(hal);
+	if (!mac_ctx) {
+		sms_log(mac_ctx, LOGE, FL("mac_ctx is null"));
+		return QDF_STATUS_E_FAILURE;
+	}
+	/*
+	 * Do not acquire lock here as sme global lock is already acquired in
+	 * caller or MC thread context
+	 */
+	if (!cmd) {
+		sms_log(mac_ctx, LOGE, FL("serialization command is null"));
+		return QDF_STATUS_E_FAILURE;
+	}
+
+	switch (reason) {
+	case WLAN_SER_CB_ACTIVATE_CMD:
+		sms_log(mac_ctx, LOG1,
+			FL("WLAN_SER_CB_ACTIVATE_CMD callback"));
+		status = sme_ser_handle_active_cmd(cmd);
+		break;
+	case WLAN_SER_CB_CANCEL_CMD:
+		sms_log(mac_ctx, LOG1,
+			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,
+			FL("WLAN_SER_CB_RELEASE_MEM_CMD callback"));
+		sme_cmd = cmd->umac_cmd;
+		csr_release_command_buffer(mac_ctx, sme_cmd);
+		break;
+	case WLAN_SER_CB_ACTIVE_CMD_TIMEOUT:
+		sms_log(mac_ctx, LOG1,
+			FL("WLAN_SER_CB_ACTIVE_CMD_TIMEOUT callback"));
+		break;
+	default:
+		sms_log(mac_ctx, LOG1, FL("STOP: unknown reason code"));
+		return QDF_STATUS_E_FAILURE;
+	}
+	return status;
+}
+
 /**
  * sme_process_command() - processes SME commnd
  * @mac_ctx:       mac global context
@@ -831,7 +923,7 @@ static bool sme_process_command(tpAniSirGlobal pMac)
 	}
 
 	/* Peek the command */
-	pEntry = csr_nonscan_pending_ll_peak_head(pMac, LL_ACCESS_LOCK);
+	pEntry = csr_nonscan_pending_ll_peek_head(pMac, LL_ACCESS_LOCK);
 sme_process_cmd:
 	if (!pEntry) {
 		csr_nonscan_active_ll_unlock(pMac);
@@ -1024,7 +1116,7 @@ static uint32_t sme_get_sessionid_from_activelist(tpAniSirGlobal mac)
 	tSmeCmd *command;
 	uint32_t session_id = CSR_SESSION_ID_INVALID;
 
-	entry = csr_nonscan_active_ll_peak_head(mac, LL_ACCESS_LOCK);
+	entry = csr_nonscan_active_ll_peek_head(mac, LL_ACCESS_LOCK);
 	if (entry) {
 		command = GET_BASE_ADDR(entry, tSmeCmd, Link);
 		session_id = command->sessionId;
@@ -2361,7 +2453,7 @@ static QDF_STATUS sme_process_dual_mac_config_resp(tpAniSirGlobal mac,
 		 */
 	}
 
-	entry = csr_nonscan_active_ll_peak_head(mac, LL_ACCESS_LOCK);
+	entry = csr_nonscan_active_ll_peek_head(mac, LL_ACCESS_LOCK);
 	if (!entry) {
 		sms_log(mac, LOGE, FL("No cmd found in active list"));
 		return QDF_STATUS_E_FAILURE;
@@ -2399,7 +2491,6 @@ static QDF_STATUS sme_process_dual_mac_config_resp(tpAniSirGlobal mac,
 		/* Now put this command back on the available command list */
 		csr_release_command(mac, command);
 
-	sme_process_pending_queue(mac);
 	return QDF_STATUS_SUCCESS;
 }
 
@@ -2429,7 +2520,7 @@ static QDF_STATUS sme_process_antenna_mode_resp(tpAniSirGlobal mac,
 		 */
 	}
 
-	entry = csr_nonscan_active_ll_peak_head(mac, LL_ACCESS_LOCK);
+	entry = csr_nonscan_active_ll_peek_head(mac, LL_ACCESS_LOCK);
 	if (!entry) {
 		sms_log(mac, LOGE, FL("No cmd found in active list"));
 		return QDF_STATUS_E_FAILURE;
@@ -2466,7 +2557,6 @@ static QDF_STATUS sme_process_antenna_mode_resp(tpAniSirGlobal mac,
 		/* Now put this command back on the available command list */
 		csr_release_command(mac, command);
 
-	sme_process_pending_queue(mac);
 	return QDF_STATUS_SUCCESS;
 }
 
@@ -3091,7 +3181,7 @@ QDF_STATUS sme_process_nss_update_resp(tpAniSirGlobal mac, uint8_t *msg)
 		 */
 	}
 
-	entry = csr_nonscan_active_ll_peak_head(mac, LL_ACCESS_LOCK);
+	entry = csr_nonscan_active_ll_peek_head(mac, LL_ACCESS_LOCK);
 	if (!entry) {
 		sms_log(mac, LOGE, FL("No cmd found in active list"));
 		return QDF_STATUS_E_FAILURE;
@@ -3131,7 +3221,7 @@ QDF_STATUS sme_process_nss_update_resp(tpAniSirGlobal mac, uint8_t *msg)
 		/* Now put this command back on the avilable command list */
 		csr_release_command(mac, command);
 	}
-	sme_process_pending_queue(mac);
+
 	return QDF_STATUS_SUCCESS;
 }
 
@@ -11186,7 +11276,7 @@ void sme_get_command_q_status(tHalHandle hHal)
 		return;
 	}
 
-	pEntry = csr_nonscan_active_ll_peak_head(pMac, LL_ACCESS_LOCK);
+	pEntry = csr_nonscan_active_ll_peek_head(pMac, LL_ACCESS_LOCK);
 	if (pEntry) {
 		pTempCmd = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
 	}
@@ -11811,103 +11901,6 @@ void sme_get_recovery_stats(tHalHandle hHal)
 	}
 }
 
-/**
- * sme_save_active_cmd_stats() - To save active command stats
- * @hHal: HAL context
- *
- * This routine is to save active command stats
- *
- * Return: None
- */
-static void sme_save_active_cmd_stats(tHalHandle hHal)
-{
-	tSmeCmd *pTempCmd = NULL;
-	tListElem *pEntry;
-	tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
-	uint8_t statidx = 0;
-	tActiveCmdStats *actv_cmd_stat = NULL;
-
-	if (NULL == pMac) {
-		QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
-				FL("pMac is NULL"));
-		return;
-	}
-
-	pEntry = csr_nonscan_active_ll_peak_head(pMac, LL_ACCESS_LOCK);
-	if (pEntry)
-		pTempCmd = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
-
-	if (!pTempCmd)
-		return;
-
-	if (eSmeCsrCommandMask & pTempCmd->command) {
-		statidx = g_self_recovery_stats.cmdStatsIndx;
-		actv_cmd_stat = &g_self_recovery_stats.activeCmdStats[statidx];
-		actv_cmd_stat->command = pTempCmd->command;
-		actv_cmd_stat->sessionId = pTempCmd->sessionId;
-		actv_cmd_stat->timestamp = cds_get_monotonic_boottime();
-		if (eSmeCommandRoam == pTempCmd->command)
-			actv_cmd_stat->reason = pTempCmd->u.roamCmd.roamReason;
-		else if (eSmeCommandScan == pTempCmd->command)
-			actv_cmd_stat->reason = pTempCmd->u.scanCmd.reason;
-		else
-			actv_cmd_stat->reason = 0xFF;
-
-		g_self_recovery_stats.cmdStatsIndx =
-			((g_self_recovery_stats.cmdStatsIndx + 1) &
-				(MAX_ACTIVE_CMD_STATS - 1));
-	}
-	return;
-}
-
-void active_list_cmd_timeout_handle(void *userData)
-{
-	tHalHandle hal = (tHalHandle)userData;
-	tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
-	tListElem *entry;
-	tSmeCmd *temp_cmd = NULL;
-
-	if (NULL == mac_ctx) {
-		QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
-			"%s: mac_ctx is null", __func__);
-		return;
-	}
-	/* Return if no cmd pending in active list as
-	 * in this case we should not be here.
-	 */
-	if (0 == csr_nonscan_active_ll_count(mac_ctx))
-		return;
-	sms_log(mac_ctx, LOGE,
-		FL("Active List command timeout Cmd List Count %d"),
-		  csr_nonscan_active_ll_count(mac_ctx));
-	sme_get_command_q_status(hal);
-
-	if (mac_ctx->roam.configParam.enable_fatal_event)
-		cds_flush_logs(WLAN_LOG_TYPE_FATAL,
-			WLAN_LOG_INDICATOR_HOST_DRIVER,
-			WLAN_LOG_REASON_SME_COMMAND_STUCK,
-			false,
-			mac_ctx->sme.enableSelfRecovery ? true : false);
-	else
-		qdf_trace_dump_all(mac_ctx, 0, 0, 500, 0);
-
-	entry = csr_nonscan_active_ll_peak_head(mac_ctx, LL_ACCESS_LOCK);
-	if (entry)
-		temp_cmd = GET_BASE_ADDR(entry, tSmeCmd, Link);
-	/* Ignore if ROC took more than 120 sec */
-	if (temp_cmd && (eSmeCommandRemainOnChannel == temp_cmd->command))
-		return;
-
-	if (mac_ctx->sme.enableSelfRecovery) {
-		sme_save_active_cmd_stats(hal);
-		cds_trigger_recovery(false);
-	} else {
-		if (!mac_ctx->roam.configParam.enable_fatal_event &&
-		   !(cds_is_load_or_unload_in_progress() ||
-		    cds_is_driver_recovering()))
-			QDF_BUG(0);
-	}
-}
 
 QDF_STATUS sme_notify_modem_power_state(tHalHandle hHal, uint32_t value)
 {

+ 397 - 106
core/sme/src/csr/csr_api_roam.c

@@ -57,6 +57,7 @@
 #include "sme_nan_datapath.h"
 #include "pld_common.h"
 #include <wlan_logging_sock_svc.h>
+#include "wlan_objmgr_psoc_obj.h"
 
 #define MAX_PWR_FCC_CHAN_12 8
 #define MAX_PWR_FCC_CHAN_13 2
@@ -189,7 +190,7 @@ static ePhyChanBondState csr_get_cb_mode_from_ies(tpAniSirGlobal pMac,
 						  tDot11fBeaconIEs *pIes);
 
 static void csr_roaming_state_config_cnf_processor(tpAniSirGlobal pMac,
-				uint32_t result, uint8_t session_id);
+			tSmeCmd *pCommand, uint32_t result, uint8_t session_id);
 QDF_STATUS csr_roam_open(tpAniSirGlobal pMac);
 QDF_STATUS csr_roam_close(tpAniSirGlobal pMac);
 void csr_roamMICErrorTimerHandler(void *pv);
@@ -1324,34 +1325,48 @@ void csr_release_roc_req_cmd(tpAniSirGlobal mac_ctx, tSmeCmd *sme_cmd)
 	}
 }
 
-void csr_abort_command(tpAniSirGlobal pMac, tSmeCmd *pCommand, bool fStopping)
+void csr_cancel_command(tpAniSirGlobal mac_ctx, tSmeCmd *sme_cmd)
 {
-
-	if (eSmeCsrCommandMask & pCommand->command) {
-		switch (pCommand->command) {
-		case eSmeCommandScan:
-			/* We need to inform the requester before dropping the scan command */
-			sms_log(pMac, LOGW,
+	switch (sme_cmd->command) {
+	case eSmeCommandRemainOnChannel:
+		if (NULL != sme_cmd->u.remainChlCmd.callback) {
+			remainOnChanCallback callback =
+				sme_cmd->u.remainChlCmd.callback;
+			/* process the msg */
+			if (callback) {
+				callback(mac_ctx, sme_cmd->u.remainChlCmd.
+					callbackCtx, eCSR_SCAN_ABORT,
+					sme_cmd->u.remainChlCmd.scan_id);
+			}
+		}
+		break;
+	case eSmeCommandScan:
+		/*
+		 * We need to inform the requester before dropping
+		 * the scan command
+		 */
+		sms_log(mac_ctx, LOGW,
 				"%s: Drop scan reason %d callback %p", __func__,
-				pCommand->u.scanCmd.reason,
-				pCommand->u.scanCmd.callback);
-			if (NULL != pCommand->u.scanCmd.callback) {
-				sms_log(pMac, LOGW, "%s callback scan requester",
+				sme_cmd->u.scanCmd.reason,
+				sme_cmd->u.scanCmd.callback);
+		if (NULL != sme_cmd->u.scanCmd.callback) {
+			sms_log(mac_ctx, LOGW, "%s callback scan requester",
 					__func__);
-				csr_scan_call_callback(pMac, pCommand,
-						       eCSR_SCAN_ABORT);
-			}
-			break;
-
-		default:
-			sms_log(pMac, LOGW, " CSR abort standard command %d",
-				pCommand->command);
-			break;
+			csr_scan_call_callback(mac_ctx, sme_cmd,
+					eCSR_SCAN_ABORT);
 		}
-		csr_release_command(pMac, pCommand);
+		break;
+	default:
+		break;
 	}
 }
 
+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)
 {
@@ -3196,7 +3211,7 @@ static void csr_roam_remove_duplicate_pending_cmd_from_list(
 		return;
 	}
 	csr_nonscan_pending_ll_lock(mac_ctx);
-	entry = csr_nonscan_pending_ll_peak_head(mac_ctx, LL_ACCESS_NOLOCK);
+	entry = csr_nonscan_pending_ll_peek_head(mac_ctx, LL_ACCESS_NOLOCK);
 	while (entry) {
 		next_entry = csr_nonscan_pending_ll_next(mac_ctx, entry,
 						LL_ACCESS_NOLOCK);
@@ -4666,7 +4681,7 @@ void csr_roam_ccm_cfg_set_callback(tpAniSirGlobal pMac, int32_t result,
 					uint8_t session_id)
 {
 	tListElem *pEntry =
-		csr_nonscan_active_ll_peak_head(pMac, LL_ACCESS_LOCK);
+		csr_nonscan_active_ll_peek_head(pMac, LL_ACCESS_LOCK);
 	uint32_t sessionId;
 	tSmeCmd *pCommand = NULL;
 #ifdef WLAN_FEATURE_ROAM_OFFLOAD
@@ -4688,8 +4703,8 @@ void csr_roam_ccm_cfg_set_callback(tpAniSirGlobal pMac, int32_t result,
 
 	if (CSR_IS_ROAM_JOINING(pMac, sessionId)
 	    && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId)) {
-		csr_roaming_state_config_cnf_processor(pMac, (uint32_t) result,
-						session_id);
+		csr_roaming_state_config_cnf_processor(pMac, pCommand,
+				(uint32_t) result, session_id);
 	}
 }
 
@@ -5750,52 +5765,32 @@ void csr_reinit_wm_status_change_cmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
 		    0);
 }
 
-void csr_roam_complete(tpAniSirGlobal pMac, eCsrRoamCompleteResult Result,
-		       void *Context, uint8_t session_id)
+void csr_roam_complete(tpAniSirGlobal mac_ctx, eCsrRoamCompleteResult Result,
+			void *Context, uint8_t session_id)
 {
-	tListElem *pEntry;
-	tSmeCmd *pCommand;
-	bool fReleaseCommand = true;
-	QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
-		  "%s: Roam Completion ...", __func__);
-	pEntry = csr_nonscan_active_ll_peak_head(pMac, LL_ACCESS_LOCK);
-	if (pEntry) {
-		pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
-		/* If the head of the queue is Active and it is a ROAM command, remove */
-		/* and put this on the Free queue. */
-		if (eSmeCommandRoam == pCommand->command) {
-			/* we need to process the result first before removing it from active list because state changes */
-			/* still happening insides roamQProcessRoamResults so no other roam command should be issued */
-			fReleaseCommand =
-				csr_roam_process_results(pMac, pCommand, Result,
-							 Context);
-			if (fReleaseCommand) {
-				if (csr_nonscan_active_ll_remove_entry(pMac,
-						pEntry, LL_ACCESS_LOCK)) {
-					csr_release_command(pMac, pCommand);
-				} else {
-					sms_log(pMac, LOGE,
-						" **********csr_roam_complete fail to release command reason %d",
-						pCommand->u.roamCmd.roamReason);
-				}
-			} else {
-				sms_log(pMac, LOGE,
-					" **********csr_roam_complete fail to release command reason %d",
-					pCommand->u.roamCmd.roamReason);
-			}
-		} else {
-			sms_log(pMac, LOGW,
-				"CSR: Roam Completion called but ROAM command is not ACTIVE ...");
-		}
-	} else {
-		sms_log(pMac, LOGW,
-			"CSR: Roam Completion called but NO commands are ACTIVE ...");
+	tSmeCmd *sme_cmd;
+	struct wlan_serialization_command *cmd;
+
+	cmd = wlan_serialization_peek_head_active_cmd_using_psoc(
+				mac_ctx->psoc, false);
+	if (!cmd) {
+		sms_log(mac_ctx, LOGE,
+			FL("Roam completion called but cmd is not active"));
+		return;
 	}
-	if (fReleaseCommand) {
-		sme_process_pending_queue(pMac);
+	sme_cmd = cmd->umac_cmd;
+	if (!sme_cmd) {
+		sms_log(mac_ctx, LOGE,
+			FL("sme_cmd is NULL"));
+		return;
+	}
+	if (eSmeCommandRoam == sme_cmd->command) {
+		csr_roam_process_results(mac_ctx, sme_cmd, Result, Context);
+		csr_release_command(mac_ctx, sme_cmd);
 	}
 }
 
+
 void csr_reset_pmkid_candidate_list(tpAniSirGlobal pMac, uint32_t sessionId)
 {
 	tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
@@ -7594,7 +7589,7 @@ QDF_STATUS csr_dequeue_roam_command(tpAniSirGlobal pMac, eCsrRoamReason reason,
 {
 	tListElem *pEntry;
 	tSmeCmd *pCommand;
-	pEntry = csr_nonscan_active_ll_peak_head(pMac, LL_ACCESS_LOCK);
+	pEntry = csr_nonscan_active_ll_peek_head(pMac, LL_ACCESS_LOCK);
 	if (pEntry) {
 		pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
 		if ((eSmeCommandRoam == pCommand->command) &&
@@ -7624,7 +7619,6 @@ QDF_STATUS csr_dequeue_roam_command(tpAniSirGlobal pMac, eCsrRoamReason reason,
 		sms_log(pMac, LOGE,
 			FL("pEntry NULL for eWNI_SME_FT_PRE_AUTH_RSP"));
 	}
-	sme_process_pending_queue(pMac);
 	return QDF_STATUS_SUCCESS;
 }
 
@@ -8455,7 +8449,7 @@ bool is_disconnect_pending(tpAniSirGlobal pmac,
 	bool disconnect_cmd_exist = false;
 
 	csr_nonscan_pending_ll_lock(pmac);
-	entry = csr_nonscan_pending_ll_peak_head(pmac, LL_ACCESS_NOLOCK);
+	entry = csr_nonscan_pending_ll_peek_head(pmac, LL_ACCESS_NOLOCK);
 	while (entry) {
 		next_entry = csr_nonscan_pending_ll_next(pmac,
 					entry, LL_ACCESS_NOLOCK);
@@ -8492,7 +8486,7 @@ static void csr_roam_join_rsp_processor(tpAniSirGlobal pMac,
 		return;
 	}
 	/* The head of the active list is the request we sent */
-	pEntry = csr_nonscan_active_ll_peak_head(pMac, LL_ACCESS_LOCK);
+	pEntry = csr_nonscan_active_ll_peek_head(pMac, LL_ACCESS_LOCK);
 	if (pEntry) {
 		pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
 	}
@@ -8612,7 +8606,7 @@ csr_roam_reissue_roam_command(tpAniSirGlobal pMac, uint8_t session_id)
 	uint32_t sessionId;
 	tCsrRoamSession *pSession;
 
-	pEntry = csr_nonscan_active_ll_peak_head(pMac, LL_ACCESS_LOCK);
+	pEntry = csr_nonscan_active_ll_peek_head(pMac, LL_ACCESS_LOCK);
 	if (NULL == pEntry) {
 		sms_log(pMac, LOGE,
 			FL("Disassoc rsp can't continue, no active CMD"));
@@ -8677,7 +8671,7 @@ bool csr_is_roam_command_waiting_for_session(tpAniSirGlobal pMac, uint32_t sessi
 	tSmeCmd *pCommand = NULL;
 	/* alwasy lock active list before locking pending list */
 	csr_nonscan_active_ll_lock(pMac);
-	pEntry = csr_nonscan_active_ll_peak_head(pMac, LL_ACCESS_NOLOCK);
+	pEntry = csr_nonscan_active_ll_peek_head(pMac, LL_ACCESS_NOLOCK);
 	if (pEntry) {
 		pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
 		if ((eSmeCommandRoam == pCommand->command)
@@ -8687,7 +8681,7 @@ bool csr_is_roam_command_waiting_for_session(tpAniSirGlobal pMac, uint32_t sessi
 	}
 	if (false == fRet) {
 		csr_nonscan_pending_ll_lock(pMac);
-		pEntry = csr_nonscan_pending_ll_peak_head(pMac,
+		pEntry = csr_nonscan_pending_ll_peek_head(pMac,
 					 LL_ACCESS_NOLOCK);
 		while (pEntry) {
 			pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
@@ -8728,7 +8722,7 @@ bool csr_is_scan_for_roam_command_active(tpAniSirGlobal pMac,
 	tSmeCmd *pCommand;
 	/* alwasy lock active list before locking pending list */
 	csr_nonscan_active_ll_lock(pMac);
-	pEntry = csr_nonscan_active_ll_peak_head(pMac, LL_ACCESS_NOLOCK);
+	pEntry = csr_nonscan_active_ll_peek_head(pMac, LL_ACCESS_NOLOCK);
 	if (pEntry) {
 		pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
 		if ((eSmeCommandScan == pCommand->command) &&
@@ -8743,23 +8737,19 @@ bool csr_is_scan_for_roam_command_active(tpAniSirGlobal pMac,
 
 static void
 csr_roaming_state_config_cnf_processor(tpAniSirGlobal mac_ctx,
-			uint32_t result, uint8_t sme_session_id)
+			tSmeCmd *cmd, uint32_t result, uint8_t sme_session_id)
 {
-	tListElem *entry = csr_nonscan_active_ll_peak_head(mac_ctx,
-					     LL_ACCESS_LOCK);
 	tCsrScanResult *scan_result = NULL;
 	tSirBssDescription *bss_desc = NULL;
-	tSmeCmd *cmd = NULL;
 	uint32_t session_id;
 	tCsrRoamSession *session;
 	tDot11fBeaconIEs *local_ies = NULL;
 	QDF_STATUS status = QDF_STATUS_E_FAILURE;
 
-	if (NULL == entry) {
-		sms_log(mac_ctx, LOGE, FL("CFG_CNF with active list empty"));
+	if (NULL == cmd) {
+		sms_log(mac_ctx, LOGE, FL("given sme cmd is null"));
 		return;
 	}
-	cmd = GET_BASE_ADDR(entry, tSmeCmd, Link);
 	session_id = cmd->sessionId;
 	session = CSR_GET_SESSION(mac_ctx, session_id);
 
@@ -9080,7 +9070,7 @@ csr_dequeue_command(tpAniSirGlobal mac_ctx)
 {
 	bool fRemoveCmd;
 	tSmeCmd *cmd = NULL;
-	tListElem *entry = csr_nonscan_active_ll_peak_head(mac_ctx,
+	tListElem *entry = csr_nonscan_active_ll_peek_head(mac_ctx,
 					    LL_ACCESS_LOCK);
 	if (!entry) {
 		sms_log(mac_ctx, LOGE, FL("NO commands are active"));
@@ -11163,7 +11153,7 @@ csr_roam_chk_lnk_set_ctx_rsp(tpAniSirGlobal mac_ctx, tSirSmeRsp *msg_ptr)
 	tListElem *entry;
 
 	qdf_mem_set(&roam_info, sizeof(roam_info), 0);
-	entry = csr_nonscan_active_ll_peak_head(mac_ctx, LL_ACCESS_LOCK);
+	entry = csr_nonscan_active_ll_peek_head(mac_ctx, LL_ACCESS_LOCK);
 	if (!entry) {
 		sms_log(mac_ctx, LOGE, FL("CSR: NO commands are ACTIVE ..."));
 		goto process_pending_n_exit;
@@ -11280,7 +11270,7 @@ remove_entry_n_process_pending:
 		csr_release_command(mac_ctx, cmd);
 
 process_pending_n_exit:
-	sme_process_pending_queue(mac_ctx);
+	return;
 }
 
 
@@ -11599,7 +11589,6 @@ void csr_roam_wait_for_key_time_out_handler(void *pv)
 		if (csr_is_conn_state_connected_infra(pMac, pInfo->sessionId)) {
 			csr_roam_link_up(pMac,
 					 pSession->connectedProfile.bssid);
-			sme_process_pending_queue(pMac);
 			status = sme_acquire_global_lock(&pMac->sme);
 			if (QDF_IS_STATUS_SUCCESS(status)) {
 				csr_roam_disconnect(pMac, pInfo->sessionId,
@@ -11813,7 +11802,7 @@ static void csr_roam_wm_status_change_complete(tpAniSirGlobal pMac,
 {
 	tListElem *pEntry;
 	tSmeCmd *pCommand;
-	pEntry = csr_nonscan_active_ll_peak_head(pMac, LL_ACCESS_LOCK);
+	pEntry = csr_nonscan_active_ll_peek_head(pMac, LL_ACCESS_LOCK);
 	if (pEntry) {
 		pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
 		if (eSmeCommandWmStatusChange == pCommand->command) {
@@ -11835,7 +11824,6 @@ static void csr_roam_wm_status_change_complete(tpAniSirGlobal pMac,
 		sms_log(pMac, LOGW,
 			"CSR: WmStatusChange Completion called but NO commands are ACTIVE ...");
 	}
-	sme_process_pending_queue(pMac);
 }
 
 void csr_roam_process_wm_status_change_command(tpAniSirGlobal pMac,
@@ -18204,6 +18192,7 @@ tSmeCmd *csr_get_command_buffer(tpAniSirGlobal pMac)
 static void csr_free_cmd_memory(tpAniSirGlobal pMac, tSmeCmd *pCommand)
 {
 	if (!pCommand) {
+		sms_log(pMac, LOGE, "pCommand is NULL");
 		return;
 	}
 	switch (pCommand->command) {
@@ -18236,7 +18225,7 @@ static void csr_free_cmd_memory(tpAniSirGlobal pMac, tSmeCmd *pCommand)
 	}
 }
 
-void csr_release_command(tpAniSirGlobal pMac, tSmeCmd *pCommand)
+void csr_release_command_buffer(tpAniSirGlobal pMac, tSmeCmd *pCommand)
 {
 	if (pMac->roam.sPendingCommands > 0) {
 		/*
@@ -18252,35 +18241,337 @@ void csr_release_command(tpAniSirGlobal pMac, tSmeCmd *pCommand)
 	}
 }
 
-/* Return SUCCESS is the command is queued, failed */
-QDF_STATUS csr_queue_sme_command(tpAniSirGlobal pMac, tSmeCmd *pCommand,
-				 bool fHighPriority)
+void csr_release_command(tpAniSirGlobal mac_ctx, tSmeCmd *sme_cmd)
+{
+	struct wlan_serialization_queued_cmd_info cmd_info;
+
+	if (!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,
+				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,
+				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"));
+		}
+	} else {
+		csr_release_command_buffer(mac_ctx, sme_cmd);
+	}
+}
+
+static enum wlan_serialization_cmd_type csr_get_scan_cmd_type(tSmeCmd *sme_cmd)
+{
+	enum wlan_serialization_cmd_type cmd_type = WLAN_SER_CMD_MAX;
+
+	switch (sme_cmd->u.scanCmd.reason) {
+	case eCsrScanOther:
+		cmd_type = WLAN_SER_CMD_SCAN_OTHER;
+		break;
+	case eCsrScanLostLink1:
+		cmd_type = WLAN_SER_CMD_SCAN_LOST_LINK1;
+		break;
+	case eCsrScanLostLink2:
+		cmd_type = WLAN_SER_CMD_SCAN_LOST_LINK2;
+		break;
+	case eCsrScanLostLink3:
+		cmd_type = WLAN_SER_CMD_SCAN_LOST_LINK3;
+		break;
+	case eCsrScan11d1:
+		cmd_type = WLAN_SER_CMD_SCAN_11D_TYPE1;
+		break;
+	case eCsrScan11d2:
+		cmd_type = WLAN_SER_CMD_SCAN_11D_TYPE2;
+		break;
+	case eCsrScan11dDone:
+		cmd_type = WLAN_SER_CMD_SCAN_11D_DONE;
+		break;
+	case eCsrScanUserRequest:
+		cmd_type = WLAN_SER_CMD_SCAN_USER_REQ;
+		break;
+	case eCsrScanForSsid:
+		cmd_type = WLAN_SER_CMD_SCAN_FOR_SSID;
+		break;
+	case eCsrScanIdleScan:
+		cmd_type = WLAN_SER_CMD_SCAN_IDLE_SCAN;
+		break;
+	case eCsrScanProbeBss:
+		cmd_type = WLAN_SER_CMD_SCAN_PROBE_BSS;
+		break;
+	case eCsrScanAbortNormalScan:
+		cmd_type = WLAN_SER_CMD_SCAN_ABORT_NORMAL_SCAN;
+		break;
+	case eCsrScanP2PFindPeer:
+		cmd_type = WLAN_SER_CMD_SCAN_P2P_FIND_PEER;
+		break;
+	case eCsrScanCandidateFound:
+		cmd_type = WLAN_SER_CMD_SCAN_CANDIDATE_FOUND;
+		break;
+	default:
+		break;
+	}
+
+	return cmd_type;
+}
+
+static enum wlan_serialization_cmd_type csr_get_roam_cmd_type(tSmeCmd *sme_cmd)
 {
-	if (!SME_IS_START(pMac)) {
-		sms_log(pMac, LOGE, FL("Sme in stop state"));
+	enum wlan_serialization_cmd_type cmd_type = WLAN_SER_CMD_MAX;
+	switch (sme_cmd->u.roamCmd.roamReason) {
+	case eCsrForcedDisassoc:
+		cmd_type = WLAN_SER_CMD_FORCE_DISASSOC;
+		break;
+	case eCsrHddIssued:
+		cmd_type = WLAN_SER_CMD_HDD_ISSUED;
+		break;
+	case eCsrLostLink1:
+		cmd_type = WLAN_SER_CMD_LOST_LINK1;
+		break;
+	case eCsrLostLink2:
+		cmd_type = WLAN_SER_CMD_LOST_LINK2;
+		break;
+	case eCsrLostLink3:
+		cmd_type = WLAN_SER_CMD_LOST_LINK3;
+		break;
+	case eCsrForcedDisassocMICFailure:
+		cmd_type = WLAN_SER_CMD_FORCE_DISASSOC_MIC_FAIL;
+		break;
+	case eCsrHddIssuedReassocToSameAP:
+		cmd_type = WLAN_SER_CMD_HDD_ISSUE_REASSOC_SAME_AP;
+		break;
+	case eCsrSmeIssuedReassocToSameAP:
+		cmd_type = WLAN_SER_CMD_SME_ISSUE_REASSOC_SAME_AP;
+		break;
+	case eCsrSmeIssuedReassocToDiffAP:
+		cmd_type = WLAN_SER_CMD_SME_ISSUE_REASSOC_DIFF_AP;
+		break;
+	case eCsrForcedDeauth:
+		cmd_type = WLAN_SER_CMD_FORCE_DEAUTH;
+		break;
+	case eCsrSmeIssuedDisassocForHandoff:
+		cmd_type =
+			WLAN_SER_CMD_SME_ISSUE_DISASSOC_FOR_HANDOFF;
+		break;
+	case eCsrSmeIssuedAssocToSimilarAP:
+		cmd_type =
+			WLAN_SER_CMD_SME_ISSUE_ASSOC_TO_SIMILAR_AP;
+		break;
+	case eCsrSmeIssuedIbssJoinFailure:
+		cmd_type = WLAN_SER_CMD_SME_ISSUE_IBSS_JOIN_FAIL;
+		break;
+	case eCsrForcedIbssLeave:
+		cmd_type = WLAN_SER_CMD_FORCE_IBSS_LEAVE;
+		break;
+	case eCsrStopBss:
+		cmd_type = WLAN_SER_CMD_STOP_BSS;
+		break;
+	case eCsrSmeIssuedFTReassoc:
+		cmd_type = WLAN_SER_CMD_SME_ISSUE_FT_REASSOC;
+		break;
+	case eCsrForcedDisassocSta:
+		cmd_type = WLAN_SER_CMD_FORCE_DISASSOC_STA;
+		break;
+	case eCsrForcedDeauthSta:
+		cmd_type = WLAN_SER_CMD_FORCE_DEAUTH_STA;
+		break;
+	case eCsrPerformPreauth:
+		cmd_type = WLAN_SER_CMD_PERFORM_PRE_AUTH;
+		break;
+	case eCsrLostLink1Abort:
+		cmd_type = WLAN_SER_CMD_LOST_LINK1_ABORT;
+		break;
+	case eCsrLostLink2Abort:
+		cmd_type = WLAN_SER_CMD_LOST_LINK2_ABORT;
+		break;
+	case eCsrLostLink3Abort:
+		cmd_type = WLAN_SER_CMD_LOST_LINK3_ABORT;
+		break;
+	default:
+		break;
+	}
+
+	return cmd_type;
+}
+
+enum wlan_serialization_cmd_type csr_get_cmd_type(tSmeCmd *sme_cmd)
+{
+	enum wlan_serialization_cmd_type cmd_type = WLAN_SER_CMD_MAX;
+
+	switch (sme_cmd->command) {
+	case eSmeCommandScan:
+		cmd_type = csr_get_scan_cmd_type(sme_cmd);
+		break;
+	case eSmeCommandRoam:
+		cmd_type = csr_get_roam_cmd_type(sme_cmd);
+		break;
+	case eSmeCommandWmStatusChange:
+		cmd_type = WLAN_SER_CMD_WM_STATUS_CHANGE;
+		break;
+	case eSmeCommandSetKey:
+		cmd_type = WLAN_SER_CMD_SET_KEY;
+		break;
+	case eSmeCommandNdpInitiatorRequest:
+		cmd_type = WLAN_SER_CMD_NDP_INIT_REQ;
+		break;
+	case eSmeCommandNdpResponderRequest:
+		cmd_type = WLAN_SER_CMD_NDP_RESP_REQ;
+		break;
+	case eSmeCommandNdpDataEndInitiatorRequest:
+		cmd_type = WLAN_SER_CMD_NDP_DATA_END_INIT_REQ;
+		break;
+	case eSmeCommandRemainOnChannel:
+		cmd_type = WLAN_SER_CMD_REMAIN_ON_CHANNEL;
+		break;
+	case eSmeCommandEnterStandby:
+		cmd_type = WLAN_SER_CMD_ENTER_STANDBY;
+		break;
+	case eSmeCommandAddTs:
+		cmd_type = WLAN_SER_CMD_ADDTS;
+		break;
+	case eSmeCommandDelTs:
+		cmd_type = WLAN_SER_CMD_DELTS;
+		break;
+	case eSmeCommandTdlsSendMgmt:
+		cmd_type = WLAN_SER_CMD_TDLS_SEND_MGMT;
+		break;
+	case eSmeCommandTdlsAddPeer:
+		cmd_type = WLAN_SER_CMD_TDLS_ADD_PEER;
+		break;
+	case eSmeCommandTdlsDelPeer:
+		cmd_type = WLAN_SER_CMD_TDLS_DEL_PEER;
+		break;
+	case eSmeCommandTdlsLinkEstablish:
+		cmd_type = WLAN_SER_CMD_TDLS_LINK_EST;
+		break;
+	case e_sme_command_set_hw_mode:
+		cmd_type = WLAN_SER_CMD_SET_HW_MODE;
+		break;
+	case e_sme_command_nss_update:
+		cmd_type = WLAN_SER_CMD_NSS_UPDATE;
+		break;
+	case e_sme_command_set_dual_mac_config:
+		cmd_type = WLAN_SER_CMD_SET_DUAL_MAC_CONFIG;
+		break;
+	case e_sme_command_set_antenna_mode:
+		cmd_type = WLAN_SER_CMD_SET_ANTENNA_MODE;
+		break;
+	case eSmeCommandOemDataReq:
+		cmd_type = WLAN_SER_CMD_OEM_DATA_REQ;
+		break;
+	case eSmeCommandEnterBmps:
+		cmd_type = WLAN_SER_CMD_ENTER_BMPS;
+		break;
+	case eSmeCommandExitBmps:
+		cmd_type = WLAN_SER_CMD_EXIT_BMPS;
+		break;
+	case eSmeCommandEnterUapsd:
+		cmd_type = WLAN_SER_CMD_ENTER_UAPSD;
+		break;
+	case eSmeCommandExitUapsd:
+		cmd_type = WLAN_SER_CMD_EXIT_UAPSD;
+		break;
+	case eSmeCommandExitWowl:
+		cmd_type = WLAN_SER_CMD_EXIT_WOWL;
+		break;
+	default:
+		break;
+	}
+
+	return cmd_type;
+}
+
+QDF_STATUS csr_set_serialization_params_to_cmd(tpAniSirGlobal mac_ctx,
+		tSmeCmd *sme_cmd, struct wlan_serialization_command *cmd,
+		uint8_t high_priority)
+{
+	QDF_STATUS status = QDF_STATUS_E_FAILURE;
+
+	if (!sme_cmd) {
+		sms_log(mac_ctx, LOGE, FL("Invalid sme_cmd"));
+		return status;
+	}
+	if (!cmd) {
+		sms_log(mac_ctx, LOGE, FL("Invalid serialization_cmd"));
+		return status;
+	}
+
+	/*
+	 * no need to fill command id for non-scan as they will be
+	 * zero always
+	 */
+	cmd->cmd_type = csr_get_cmd_type(sme_cmd);
+	if (cmd->cmd_type == WLAN_SER_CMD_MAX) {
+		sms_log(mac_ctx, LOGE, FL("serialization enum not found"));
+		return status;
+	}
+	cmd->vdev = wlan_objmgr_get_vdev_by_id_from_psoc(mac_ctx->psoc,
+				sme_cmd->sessionId, WLAN_LEGACY_SME_ID);
+	cmd->umac_cmd = sme_cmd;
+	cmd->cmd_timeout_duration = SME_DEFAULT_CMD_TIMEOUT;
+	cmd->cmd_cb = sme_ser_cmd_callback;
+	cmd->is_high_priority = high_priority;
+	return QDF_STATUS_SUCCESS;
+}
+
+QDF_STATUS csr_queue_sme_command(tpAniSirGlobal mac_ctx, tSmeCmd *sme_cmd,
+				 bool high_priority)
+{
+	struct wlan_serialization_command cmd;
+
+	if (!SME_IS_START(mac_ctx)) {
+		sms_log(mac_ctx, LOGE, FL("Sme in stop state"));
 		QDF_ASSERT(0);
 		return QDF_STATUS_E_PERM;
 	}
 
-	if ((eSmeCommandScan == pCommand->command) && pMac->scan.fDropScanCmd) {
-		sms_log(pMac, LOGW, FL(" drop scan (scan reason %d) command"),
-			pCommand->u.scanCmd.reason);
+	if ((eSmeCommandScan == sme_cmd->command) &&
+				mac_ctx->scan.fDropScanCmd) {
+		sms_log(mac_ctx, LOGW, FL("drop scan (scan reason %d) command"),
+			sme_cmd->u.scanCmd.reason);
 		return QDF_STATUS_CSR_WRONG_STATE;
 	}
 
-	if ((pCommand->command == eSmeCommandScan)
-	    || (pCommand->command == eSmeCommandRemainOnChannel)) {
-		sms_log(pMac, LOGW,
+	if ((sme_cmd->command == eSmeCommandScan)
+	    || (sme_cmd->command == eSmeCommandRemainOnChannel)) {
+		sms_log(mac_ctx, LOGW,
 		FL("scan pending list count %d scan_id %d"),
-			pMac->sme.smeScanCmdPendingList.Count,
-			pCommand->u.scanCmd.scanID);
-		csr_ll_insert_tail(&pMac->sme.smeScanCmdPendingList,
-				   &pCommand->Link, LL_ACCESS_LOCK);
+			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(pMac);
+		sme_process_pending_queue(mac_ctx);
 		return QDF_STATUS_SUCCESS;
 	}
-	sme_push_command(pMac, pCommand, fHighPriority);
+	qdf_mem_zero(&cmd, sizeof(struct wlan_serialization_command));
+	if (QDF_STATUS_SUCCESS ==
+			csr_set_serialization_params_to_cmd(mac_ctx, sme_cmd,
+						&cmd, high_priority)) {
+		if (WLAN_SER_CMD_DENIED_UNSPECIFIED ==
+				wlan_serialization_request(&cmd)) {
+			sms_log(mac_ctx, LOGE, FL("failed to enq to req"));
+			return QDF_STATUS_E_FAILURE;
+		}
+	} else {
+		sms_log(mac_ctx, LOGE, FL("failed to set ser params"));
+		return QDF_STATUS_E_FAILURE;
+	}
 	return QDF_STATUS_SUCCESS;
 }
 

+ 1 - 1
core/sme/src/csr/csr_api_scan.c

@@ -6775,7 +6775,7 @@ QDF_STATUS csr_remove_nonscan_cmd_from_pending_list(tpAniSirGlobal pMac,
 	}
 
 	csr_nonscan_pending_ll_lock(pMac);
-	pEntry = csr_nonscan_pending_ll_peak_head(pMac, LL_ACCESS_NOLOCK);
+	pEntry = csr_nonscan_pending_ll_peek_head(pMac, LL_ACCESS_NOLOCK);
 
 	/*
 	 * Have to make sure we don't loop back to the head of the list,

+ 1 - 1
core/sme/src/csr/csr_host_scan_roam.c

@@ -77,7 +77,7 @@ QDF_STATUS csr_roam_issue_reassociate_cmd(tpAniSirGlobal pMac,
 	bool fHighPriority = true;
 	bool fRemoveCmd = false;
 	tListElem *pEntry;
-	pEntry = csr_nonscan_active_ll_peak_head(pMac, LL_ACCESS_LOCK);
+	pEntry = csr_nonscan_active_ll_peek_head(pMac, LL_ACCESS_LOCK);
 	if (pEntry) {
 		pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
 		if (!pCommand) {

+ 1 - 0
core/sme/src/csr/csr_inside_api.h

@@ -615,6 +615,7 @@ QDF_STATUS csr_queue_sme_command(tpAniSirGlobal pMac, tSmeCmd *pCommand,
 				 bool fHighPriority);
 tSmeCmd *csr_get_command_buffer(tpAniSirGlobal pMac);
 void csr_release_command(tpAniSirGlobal pMac, tSmeCmd *pCommand);
+void csr_release_command_buffer(tpAniSirGlobal pMac, tSmeCmd *pCommand);
 void csr_scan_flush_bss_entry(tpAniSirGlobal pMac,
 			      tpSmeCsaOffloadInd pCsaOffloadInd);
 QDF_STATUS csr_get_active_scan_entry(tpAniSirGlobal mac, uint32_t scan_id,

+ 7 - 7
core/sme/src/csr/csr_tdls_process.c

@@ -57,7 +57,7 @@ static QDF_STATUS csr_tdls_remove_sme_cmd(tpAniSirGlobal pMac,
 	tListElem *pEntry;
 	tSmeCmd *pCommand;
 
-	pEntry = csr_nonscan_active_ll_peak_head(pMac, LL_ACCESS_LOCK);
+	pEntry = csr_nonscan_active_ll_peek_head(pMac, LL_ACCESS_LOCK);
 	if (pEntry) {
 		pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
 		if (cmdType == pCommand->command) {
@@ -66,7 +66,6 @@ static QDF_STATUS csr_tdls_remove_sme_cmd(tpAniSirGlobal pMac,
 				qdf_mem_zero(&pCommand->u.tdlsCmd,
 					     sizeof(tTdlsCmd));
 				csr_release_command(pMac, pCommand);
-				sme_process_pending_queue(pMac);
 				status = QDF_STATUS_SUCCESS;
 			}
 		}
@@ -127,7 +126,7 @@ QDF_STATUS csr_tdls_send_mgmt_req(tHalHandle hHal, uint8_t sessionId,
 
 	tdlsSendMgmtCmd->command = eSmeCommandTdlsSendMgmt;
 	tdlsSendMgmtCmd->u.tdlsCmd.size = sizeof(tTdlsSendMgmtCmdInfo);
-	sme_push_command(pMac, tdlsSendMgmtCmd, false);
+	csr_queue_sme_command(pMac, tdlsSendMgmtCmd, false);
 	status = QDF_STATUS_SUCCESS;
 	sms_log(pMac, LOG1,
 		FL("Successfully posted eSmeCommandTdlsSendMgmt to SME"));
@@ -201,7 +200,7 @@ QDF_STATUS csr_tdls_change_peer_sta(tHalHandle hHal, uint8_t sessionId,
 			tdlsAddStaCmd->command = eSmeCommandTdlsAddPeer;
 			tdlsAddStaCmd->u.tdlsCmd.size =
 				sizeof(tTdlsAddStaCmdInfo);
-			sme_push_command(pMac, tdlsAddStaCmd, false);
+			csr_queue_sme_command(pMac, tdlsAddStaCmd, false);
 			status = QDF_STATUS_SUCCESS;
 			sms_log(pMac, LOG1,
 			FL("Successfully posted eSmeCommandTdlsAddPeer to SME to modify peer "));
@@ -273,7 +272,8 @@ QDF_STATUS csr_tdls_send_link_establish_params(tHalHandle hHal,
 				eSmeCommandTdlsLinkEstablish;
 			tdlsLinkEstablishCmd->u.tdlsCmd.size =
 				sizeof(tTdlsLinkEstablishCmdInfo);
-			sme_push_command(pMac, tdlsLinkEstablishCmd, false);
+			csr_queue_sme_command(pMac, tdlsLinkEstablishCmd,
+						false);
 			status = QDF_STATUS_SUCCESS;
 			sms_log(pMac, LOG1,
 			FL("Successfully posted eSmeCommandTdlsLinkEstablish to SME"));
@@ -312,7 +312,7 @@ QDF_STATUS csr_tdls_add_peer_sta(tHalHandle hHal, uint8_t sessionId,
 			tdlsAddStaCmd->command = eSmeCommandTdlsAddPeer;
 			tdlsAddStaCmd->u.tdlsCmd.size =
 				sizeof(tTdlsAddStaCmdInfo);
-			sme_push_command(pMac, tdlsAddStaCmd, false);
+			csr_queue_sme_command(pMac, tdlsAddStaCmd, false);
 			status = QDF_STATUS_SUCCESS;
 			sms_log(pMac, LOG1,
 			FL("Successfully posted eSmeCommandTdlsAddPeer to SME"));
@@ -350,7 +350,7 @@ QDF_STATUS csr_tdls_del_peer_sta(tHalHandle hHal, uint8_t sessionId,
 			tdlsDelStaCmd->command = eSmeCommandTdlsDelPeer;
 			tdlsDelStaCmd->u.tdlsCmd.size =
 				sizeof(tTdlsDelStaCmdInfo);
-			sme_push_command(pMac, tdlsDelStaCmd, false);
+			csr_queue_sme_command(pMac, tdlsDelStaCmd, false);
 			status = QDF_STATUS_SUCCESS;
 			sms_log(pMac, LOG1,
 			FL("Successfully posted eSmeCommandTdlsDelPeer to SME"));

+ 130 - 77
core/sme/src/csr/csr_util.c

@@ -42,6 +42,7 @@
 #include "wma_types.h"
 #include "cds_utils.h"
 #include "cds_concurrency.h"
+#include "wlan_serialization_api.h"
 
 
 uint8_t csr_wpa_oui[][CSR_WPA_OUI_SIZE] = {
@@ -254,129 +255,181 @@ const char *get_e_csr_roam_result_str(eCsrRoamResult val)
 	}
 }
 
-void csr_nonscan_pending_ll_unlock(struct sAniSirGlobal *mac_ctx)
+void purge_sme_session_pending_cmd_list(struct sAniSirGlobal *mac_ctx,
+				uint32_t session_id)
 {
-	csr_ll_unlock(&mac_ctx->sme.smeCmdPendingList);
+	uint8_t vdev_id = session_id;
+
+	wlan_serialization_purge_cmd_list(mac_ctx->psoc, &vdev_id,
+			false, false, false, true, false);
 }
 
-void csr_nonscan_active_ll_unlock(struct sAniSirGlobal *mac_ctx)
+void purge_sme_session_active_cmd_list(struct sAniSirGlobal *mac_ctx,
+				uint32_t session_id)
 {
-	csr_ll_unlock(&mac_ctx->sme.smeCmdActiveList);
+	uint8_t vdev_id = session_id;
+
+	wlan_serialization_purge_cmd_list(mac_ctx->psoc, &vdev_id,
+			false, false, true, false, false);
 }
 
-void csr_nonscan_pending_ll_lock(struct sAniSirGlobal *mac_ctx)
+void csr_nonscan_active_ll_insert_head(struct sAniSirGlobal *mac_ctx,
+			tListElem *entry, bool inter_locked)
 {
-	csr_ll_lock(&mac_ctx->sme.smeCmdPendingList);
 }
 
-void csr_nonscan_active_ll_lock(struct sAniSirGlobal *mac_ctx)
+void csr_nonscan_pending_ll_insert_head(struct sAniSirGlobal *mac_ctx,
+		tListElem *entry, bool inter_locked)
 {
-	csr_ll_lock(&mac_ctx->sme.smeCmdActiveList);
 }
 
-bool csr_get_bss_id_bss_desc(tHalHandle hHal, tSirBssDescription *pSirBssDesc,
-			     struct qdf_mac_addr *pBssId)
+void csr_nonscan_pending_ll_insert_tail(struct sAniSirGlobal *mac_ctx,
+		tListElem *entry, bool inter_locked)
 {
-	qdf_mem_copy(pBssId, &pSirBssDesc->bssId[0],
-			sizeof(struct qdf_mac_addr));
-	return true;
 }
-bool csr_nonscan_active_ll_is_list_empty(struct sAniSirGlobal *mac_ctx,
-				bool fInterlocked)
+void csr_nonscan_pending_ll_unlock(struct sAniSirGlobal *mac_ctx)
 {
-	return csr_ll_is_list_empty(&mac_ctx->sme.smeCmdActiveList,
-					fInterlocked);
 }
-bool csr_nonscan_pending_ll_is_list_empty(struct sAniSirGlobal *mac_ctx,
-				bool fInterlocked)
+
+void csr_nonscan_active_ll_unlock(struct sAniSirGlobal *mac_ctx)
 {
-	return csr_ll_is_list_empty(&mac_ctx->sme.smeCmdPendingList,
-					fInterlocked);
 }
-bool csr_nonscan_active_ll_remove_entry(struct sAniSirGlobal *mac_ctx,
-		tListElem *entry, bool fInterlocked)
+
+void csr_nonscan_pending_ll_lock(struct sAniSirGlobal *mac_ctx)
 {
-	return csr_ll_remove_entry(&mac_ctx->sme.smeCmdActiveList, entry,
-					fInterlocked);
 }
-bool csr_nonscan_pending_ll_remove_entry(struct sAniSirGlobal *mac_ctx,
-		tListElem *entry, bool fInterlocked)
+
+void csr_nonscan_active_ll_lock(struct sAniSirGlobal *mac_ctx)
 {
-	return csr_ll_remove_entry(&mac_ctx->sme.smeCmdPendingList, entry,
-					fInterlocked);
 }
-tListElem *csr_nonscan_active_ll_peak_head(struct sAniSirGlobal *mac_ctx,
-		bool fInterlocked)
+uint32_t csr_nonscan_active_ll_count(struct sAniSirGlobal *mac_ctx)
 {
-	return csr_ll_peek_head(&mac_ctx->sme.smeCmdActiveList, fInterlocked);
+	return wlan_serialization_get_active_list_count(mac_ctx->psoc, false);
 }
-tListElem *csr_nonscan_pending_ll_peak_head(struct sAniSirGlobal *mac_ctx,
-		bool fInterlocked)
+
+uint32_t csr_nonscan_pending_ll_count(struct sAniSirGlobal *mac_ctx)
 {
-	return csr_ll_peek_head(&mac_ctx->sme.smeCmdPendingList, fInterlocked);
+	return wlan_serialization_get_pending_list_count(mac_ctx->psoc, false);
 }
-tListElem *csr_nonscan_active_ll_remove_head(struct sAniSirGlobal *mac_ctx,
-		bool fInterlocked)
+
+bool csr_nonscan_active_ll_is_list_empty(struct sAniSirGlobal *mac_ctx,
+				bool inter_locked)
 {
-	return csr_ll_remove_head(&mac_ctx->sme.smeCmdActiveList,
-				fInterlocked);
+	return !wlan_serialization_get_active_list_count(mac_ctx->psoc, false);
 }
-tListElem *csr_nonscan_pending_ll_remove_head(struct sAniSirGlobal *mac_ctx,
-		bool fInterlocked)
+bool csr_nonscan_pending_ll_is_list_empty(struct sAniSirGlobal *mac_ctx,
+				bool inter_locked)
 {
-	return csr_ll_remove_head(&mac_ctx->sme.smeCmdPendingList,
-				fInterlocked);
+	return !wlan_serialization_get_pending_list_count(mac_ctx->psoc, false);
 }
-
-uint32_t csr_nonscan_active_ll_count(struct sAniSirGlobal *mac_ctx)
+tListElem *csr_nonscan_active_ll_peek_head(struct sAniSirGlobal *mac_ctx,
+		bool inter_locked)
 {
-	return csr_ll_count(&mac_ctx->sme.smeCmdActiveList);
-}
+	struct wlan_serialization_command *cmd;
+	tSmeCmd *sme_cmd;
 
-void csr_nonscan_active_ll_insert_head(struct sAniSirGlobal *mac_ctx,
-			tListElem *entry, bool fInterlocked)
-{
-	csr_ll_insert_head(&mac_ctx->sme.smeCmdActiveList, entry,
-			fInterlocked);
+	sms_log(mac_ctx, LOGE, "Enter");
+	cmd = wlan_serialization_peek_head_active_cmd_using_psoc(mac_ctx->psoc,
+								 false);
+	if (!cmd) {
+		sms_log(mac_ctx, LOGE, "No cmd found");
+		return NULL;
+	}
+	sme_cmd = cmd->umac_cmd;
+	sms_log(mac_ctx, LOGE, "Exit");
+
+	return &sme_cmd->Link;
 }
-uint32_t csr_nonscan_pending_ll_count(struct sAniSirGlobal *mac_ctx)
+tListElem *csr_nonscan_pending_ll_peek_head(struct sAniSirGlobal *mac_ctx,
+		bool inter_locked)
 {
-	return csr_ll_count(&mac_ctx->sme.smeCmdPendingList);
-}
+	struct wlan_serialization_command *cmd;
+	tSmeCmd *sme_cmd;
 
-void csr_nonscan_pending_ll_insert_head(struct sAniSirGlobal *mac_ctx,
-		tListElem *entry, bool fInterlocked)
+	sms_log(mac_ctx, LOGE, "Enter");
+	cmd = wlan_serialization_peek_head_pending_cmd_using_psoc(mac_ctx->psoc,
+								  false);
+	if (!cmd) {
+		sms_log(mac_ctx, LOGE, "No cmd found");
+		return NULL;
+	}
+	sme_cmd = cmd->umac_cmd;
+	sms_log(mac_ctx, LOGE, "Exit");
+
+	return &sme_cmd->Link;
+}
+bool csr_nonscan_active_ll_remove_entry(struct sAniSirGlobal *mac_ctx,
+		tListElem *entry, bool inter_locked)
 {
-	csr_ll_insert_head(&mac_ctx->sme.smeCmdPendingList, entry,
-			fInterlocked);
+	tListElem *head;
+
+	sms_log(mac_ctx, LOGE, "Enter");
+	head = csr_nonscan_active_ll_peek_head(mac_ctx, inter_locked);
+	if (head == entry) {
+		sms_log(mac_ctx, LOGE, "Exit");
+		return true;
+	} else {
+		sms_log(mac_ctx, LOGE, "Exit");
+		return false;
+	}
 }
+bool csr_nonscan_pending_ll_remove_entry(struct sAniSirGlobal *mac_ctx,
+		tListElem *entry, bool inter_locked)
+{
+	tListElem *head;
 
-void csr_nonscan_pending_ll_insert_tail(struct sAniSirGlobal *mac_ctx,
-		tListElem *entry, bool fInterlocked)
+	sms_log(mac_ctx, LOGE, "Enter");
+	head = csr_nonscan_pending_ll_peek_head(mac_ctx, inter_locked);
+	if (head == entry) {
+		sms_log(mac_ctx, LOGE, "Exit");
+		return true;
+	} else {
+		sms_log(mac_ctx, LOGE, "Exit");
+		return false;
+	}
+}
+tListElem *csr_nonscan_active_ll_remove_head(struct sAniSirGlobal *mac_ctx,
+		bool inter_locked)
 {
-	csr_ll_insert_tail(&mac_ctx->sme.smeCmdPendingList, entry,
-				fInterlocked);
+	return csr_nonscan_active_ll_peek_head(mac_ctx, inter_locked);
 }
-
-tListElem *csr_nonscan_pending_ll_next(struct sAniSirGlobal *mac_ctx,
-				tListElem *entry, bool fInterlocked)
+tListElem *csr_nonscan_pending_ll_remove_head(struct sAniSirGlobal *mac_ctx,
+		bool inter_locked)
 {
-	return csr_ll_next(&mac_ctx->sme.smeCmdPendingList, entry,
-						fInterlocked);
+	return csr_nonscan_pending_ll_peek_head(mac_ctx, inter_locked);
 }
 
-void purge_sme_session_pending_cmd_list(struct sAniSirGlobal *mac_ctx,
-				uint32_t session_id)
-{
-	purge_sme_session_cmd_list(mac_ctx, session_id,
-				&mac_ctx->sme.smeCmdPendingList);
+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");
+	if (!entry)
+		return NULL;
+	sme_cmd = GET_BASE_ADDR(entry, tSmeCmd, Link);
+	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, false);
+	if (!tcmd) {
+		sms_log(mac_ctx, LOGE, "No cmd found");
+		return NULL;
+	}
+	sme_cmd = tcmd->umac_cmd;
+	sms_log(mac_ctx, LOGE, "Exit");
+	return &sme_cmd->Link;
 }
 
-void purge_sme_session_active_cmd_list(struct sAniSirGlobal *mac_ctx,
-				uint32_t session_id)
+bool csr_get_bss_id_bss_desc(tHalHandle hHal, tSirBssDescription *pSirBssDesc,
+			     struct qdf_mac_addr *pBssId)
 {
-	purge_sme_session_cmd_list(mac_ctx, session_id,
-				&mac_ctx->sme.smeCmdActiveList);
+	qdf_mem_copy(pBssId, &pSirBssDesc->bssId[0],
+			sizeof(struct qdf_mac_addr));
+	return true;
 }
 
 bool csr_is_bss_id_equal(tHalHandle hHal, tSirBssDescription *pSirBssDesc1,

+ 1 - 2
core/sme/src/nan/nan_datapath_api.c

@@ -625,7 +625,7 @@ void sme_ndp_msg_processor(tpAniSirGlobal mac_ctx, struct scheduler_msg *msg)
 	eSmeCommandType cmd_to_rel = eSmeNoCommand;
 	bool send_to_user = true;
 
-	entry = csr_nonscan_active_ll_peak_head(mac_ctx,
+	entry = csr_nonscan_active_ll_peek_head(mac_ctx,
 				 LL_ACCESS_LOCK);
 	if (entry != NULL)
 		cmd = GET_BASE_ADDR(entry, tSmeCmd, Link);
@@ -778,7 +778,6 @@ void sme_ndp_msg_processor(tpAniSirGlobal mac_ctx, struct scheduler_msg *msg)
 		if (csr_nonscan_active_ll_remove_entry(mac_ctx,
 				     entry, LL_ACCESS_LOCK))
 			csr_release_command(mac_ctx, cmd);
-		sme_process_pending_queue(mac_ctx);
 	}
 }
 

+ 3 - 5
core/sme/src/qos/sme_qos.c

@@ -810,7 +810,7 @@ QDF_STATUS sme_qos_msg_processor(tpAniSirGlobal mac_ctx,
 	/* switch on the msg type & make the state transition accordingly */
 	switch (msg_type) {
 	case eWNI_SME_ADDTS_RSP:
-		entry = csr_nonscan_active_ll_peak_head(mac_ctx,
+		entry = csr_nonscan_active_ll_peek_head(mac_ctx,
 				LL_ACCESS_LOCK);
 		if (NULL == entry)
 			break;
@@ -821,11 +821,10 @@ QDF_STATUS sme_qos_msg_processor(tpAniSirGlobal mac_ctx,
 					LL_ACCESS_LOCK)) {
 				qos_release_command(mac_ctx, command);
 			}
-			sme_process_pending_queue(mac_ctx);
 		}
 		break;
 	case eWNI_SME_DELTS_RSP:
-		entry = csr_nonscan_active_ll_peak_head(mac_ctx,
+		entry = csr_nonscan_active_ll_peek_head(mac_ctx,
 				LL_ACCESS_LOCK);
 		if (NULL == entry)
 			break;
@@ -836,7 +835,6 @@ QDF_STATUS sme_qos_msg_processor(tpAniSirGlobal mac_ctx,
 					LL_ACCESS_LOCK)) {
 				qos_release_command(mac_ctx, command);
 			}
-			sme_process_pending_queue(mac_ctx);
 		}
 		break;
 	case eWNI_SME_DELTS_IND:
@@ -7505,7 +7503,7 @@ static QDF_STATUS qos_issue_command(tpAniSirGlobal pMac, uint8_t sessionId,
 		}
 	} while (0);
 	if (QDF_IS_STATUS_SUCCESS(status) && pCommand) {
-		sme_push_command(pMac, pCommand, false);
+		csr_queue_sme_command(pMac, pCommand, false);
 	} else if (pCommand) {
 		qos_release_command(pMac, pCommand);
 	}