Răsfoiți Sursa

qcacld-3.0: Remove serialization from set key req and rsp messages

Serialization is not required to deliver the set key request coming
from upper layer as well as set key response coming from lower layer.

Take the set key request coming through IOCTL thread, and directly
post the request to protocol layer. Similarly take the set key response
coming through worker thread, and post the request to protocol layer.

Change-Id: Idcd0047f6e323d982e3159f7ef376e6eeb201395
CRs-Fixed: 2046036
Krunal Soni 8 ani în urmă
părinte
comite
d3676732ef

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

@@ -164,9 +164,6 @@ typedef enum {
 	eCsrForcedDisassocSta,
 	eCsrForcedDeauthSta,
 	eCsrPerformPreauth,
-	eCsrLostLink1Abort,
-	eCsrLostLink2Abort,
-	eCsrLostLink3Abort,
 } eCsrRoamReason;
 
 typedef enum {
@@ -1153,8 +1150,6 @@ typedef struct tagCsrRoamStruct {
 	((CSR_IS_LOSTLINK_ROAMING((pSession)->roamingReason)) || \
 		(eCsrDynamicRoaming == (pSession)->roamingReason)  ||	\
 		(eCsrReassocRoaming == (pSession)->roamingReason))
-#define CSR_IS_SET_KEY_COMMAND(pCommand) \
-	(eSmeCommandSetKey == (pCommand)->command)
 #define CSR_IS_ADDTS_WHEN_ACMOFF_SUPPORTED(pMac) \
 	(pMac->roam.configParam.addTSWhenACMIsOff)
 #define CSR_IS_LOSTLINK_ROAMING(reason) \

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

@@ -174,7 +174,6 @@ typedef struct tagSmeCmd {
 		tScanCmd scanCmd;
 		tRoamCmd roamCmd;
 		tWmStatusChangeCmd wmStatusChangeCmd;
-		tSetKeyCmd setKeyCmd;
 		tGenericPmcCmd pmcCmd;
 		tGenericQosCmd qosCmd;
 		tRemainChlCmd remainChlCmd;
@@ -232,10 +231,8 @@ void csr_roam_process_wm_status_change_command(tpAniSirGlobal pMac,
 		tSmeCmd *pCommand);
 void csr_reinit_roam_cmd(tpAniSirGlobal pMac, tSmeCmd *pCommand);
 void csr_reinit_wm_status_change_cmd(tpAniSirGlobal pMac, tSmeCmd *pCommand);
-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);
+QDF_STATUS csr_roam_send_set_key_cmd(tpAniSirGlobal mac_ctx,
+		uint32_t session_id, tSetKeyCmd *set_key_cmd);
 void csr_cancel_command(tpAniSirGlobal mac_ctx, tSmeCmd *sme_cmd);
 
 QDF_STATUS csr_is_valid_channel(tpAniSirGlobal pMac, uint8_t chnNum);

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

@@ -59,7 +59,6 @@ typedef enum eSmeCommandType {
 	eSmeCommandScan,
 	eSmeCommandRoam,
 	eSmeCommandWmStatusChange,
-	eSmeCommandSetKey,
 #ifdef FEATURE_WLAN_TDLS
 	/*
 	 * eSmeTdlsCommandMask = 0x80000,

+ 0 - 8
core/sme/src/common/sme_api.c

@@ -442,11 +442,6 @@ static void dump_csr_command_info(tpAniSirGlobal pMac, tSmeCmd *pCmd)
 			pCmd->u.wmStatusChangeCmd.Type);
 		break;
 
-	case eSmeCommandSetKey:
-		sme_debug("setKey command auth(%d) enc(%d)",
-			pCmd->u.setKeyCmd.authType, pCmd->u.setKeyCmd.encType);
-		break;
-
 	default:
 		sme_debug("default: Unhandled command %d",
 			pCmd->command);
@@ -577,9 +572,6 @@ QDF_STATUS sme_ser_handle_active_cmd(struct wlan_serialization_command *cmd)
 		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;

+ 0 - 1
core/sme/src/common/sme_trace.c

@@ -173,7 +173,6 @@ static uint8_t *sme_trace_get_command_string(uint32_t command)
 		CASE_RETURN_STRING(eSmeCommandScan);
 		CASE_RETURN_STRING(eSmeCommandRoam);
 		CASE_RETURN_STRING(eSmeCommandWmStatusChange);
-		CASE_RETURN_STRING(eSmeCommandSetKey);
 #ifdef FEATURE_WLAN_TDLS
 		CASE_RETURN_STRING(eSmeCommandTdlsSendMgmt);
 		CASE_RETURN_STRING(eSmeCommandTdlsAddPeer);

+ 117 - 195
core/sme/src/csr/csr_api_roam.c

@@ -1264,16 +1264,6 @@ void csr_release_command_wm_status_change(tpAniSirGlobal pMac,
 	csr_reinit_wm_status_change_cmd(pMac, pCommand);
 }
 
-void csr_reinit_set_key_cmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
-{
-	qdf_mem_set(&pCommand->u.setKeyCmd, sizeof(tSetKeyCmd), 0);
-}
-
-void csr_release_command_set_key(tpAniSirGlobal pMac, tSmeCmd *pCommand)
-{
-	csr_reinit_set_key_cmd(pMac, pCommand);
-}
-
 /**
  * csr_release_roc_req_cmd() - Release the command
  * @mac_ctx: Global MAC Context
@@ -9901,17 +9891,17 @@ QDF_STATUS csr_roam_issue_set_context_req(tpAniSirGlobal pMac,
  * @session:         roam session
  * @set_key:         input set key command
  * @set_key_cmd:     set key command to update
- * @enqueue_cmd:     indicates if command need to be enqueued to sme
+ * @is_key_valid:    indicates if key is valid
  *
- * This function will validate the key length, adjust if too long. Tt will
- * update bool enqueue_cmd, to false if some error has occured key are local.
+ * This function will validate the key length, adjust if too long. It will
+ * update is_key_valid flag to false if some error has occured key are local.
  *
  * Return: status of operation
  */
 static QDF_STATUS
 csr_update_key_cmd(tpAniSirGlobal mac_ctx, tCsrRoamSession *session,
-		   tCsrRoamSetKey *set_key, tSmeCmd *set_key_cmd,
-		   bool *enqueue_cmd)
+		   tCsrRoamSetKey *set_key, tSetKeyCmd *set_key_cmd,
+		   bool *is_key_valid)
 {
 	switch (set_key->encType) {
 	case eCSR_ENCRYPT_TYPE_WEP40:
@@ -9919,93 +9909,87 @@ csr_update_key_cmd(tpAniSirGlobal mac_ctx, tCsrRoamSession *session,
 		/* KeyLength maybe 0 for static WEP */
 		if (set_key->keyLength) {
 			if (set_key->keyLength < CSR_WEP40_KEY_LEN) {
-				sme_warn(
-					"Invalid WEP40 keylength [= %d]",
+				sme_warn("Invalid WEP40 keylength [= %d]",
 					set_key->keyLength);
-				*enqueue_cmd = false;
+				*is_key_valid = false;
 				return QDF_STATUS_E_INVAL;
 			}
 
-			set_key_cmd->u.setKeyCmd.keyLength = CSR_WEP40_KEY_LEN;
-			qdf_mem_copy(set_key_cmd->u.setKeyCmd.Key, set_key->Key,
+			set_key_cmd->keyLength = CSR_WEP40_KEY_LEN;
+			qdf_mem_copy(set_key_cmd->Key, set_key->Key,
 				     CSR_WEP40_KEY_LEN);
 		}
-		*enqueue_cmd = true;
+		*is_key_valid = true;
 		break;
 	case eCSR_ENCRYPT_TYPE_WEP104:
 	case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
 		/* KeyLength maybe 0 for static WEP */
 		if (set_key->keyLength) {
 			if (set_key->keyLength < CSR_WEP104_KEY_LEN) {
-				sme_warn(
-					"Invalid WEP104 keylength [= %d]",
+				sme_warn("Invalid WEP104 keylength [= %d]",
 					set_key->keyLength);
-				*enqueue_cmd = false;
+				*is_key_valid = false;
 				return QDF_STATUS_E_INVAL;
 			}
 
-			set_key_cmd->u.setKeyCmd.keyLength = CSR_WEP104_KEY_LEN;
-			qdf_mem_copy(set_key_cmd->u.setKeyCmd.Key, set_key->Key,
+			set_key_cmd->keyLength = CSR_WEP104_KEY_LEN;
+			qdf_mem_copy(set_key_cmd->Key, set_key->Key,
 				     CSR_WEP104_KEY_LEN);
 		}
-		*enqueue_cmd = true;
+		*is_key_valid = true;
 		break;
 	case eCSR_ENCRYPT_TYPE_TKIP:
 		if (set_key->keyLength < CSR_TKIP_KEY_LEN) {
-			sme_warn(
-				"Invalid TKIP keylength [= %d]",
+			sme_warn("Invalid TKIP keylength [= %d]",
 				set_key->keyLength);
-			*enqueue_cmd = false;
+			*is_key_valid = false;
 			return QDF_STATUS_E_INVAL;
 		}
-		set_key_cmd->u.setKeyCmd.keyLength = CSR_TKIP_KEY_LEN;
-		qdf_mem_copy(set_key_cmd->u.setKeyCmd.Key, set_key->Key,
+		set_key_cmd->keyLength = CSR_TKIP_KEY_LEN;
+		qdf_mem_copy(set_key_cmd->Key, set_key->Key,
 			     CSR_TKIP_KEY_LEN);
-		*enqueue_cmd = true;
+		*is_key_valid = true;
 		break;
 	case eCSR_ENCRYPT_TYPE_AES:
 		if (set_key->keyLength < CSR_AES_KEY_LEN) {
-			sme_warn(
-				"Invalid AES/CCMP keylength [= %d]",
+			sme_warn("Invalid AES/CCMP keylength [= %d]",
 				set_key->keyLength);
-			*enqueue_cmd = false;
+			*is_key_valid = false;
 			return QDF_STATUS_E_INVAL;
 		}
-		set_key_cmd->u.setKeyCmd.keyLength = CSR_AES_KEY_LEN;
-		qdf_mem_copy(set_key_cmd->u.setKeyCmd.Key, set_key->Key,
+		set_key_cmd->keyLength = CSR_AES_KEY_LEN;
+		qdf_mem_copy(set_key_cmd->Key, set_key->Key,
 			     CSR_AES_KEY_LEN);
-		*enqueue_cmd = true;
+		*is_key_valid = true;
 		break;
 #ifdef FEATURE_WLAN_WAPI
 	case eCSR_ENCRYPT_TYPE_WPI:
 		if (set_key->keyLength < CSR_WAPI_KEY_LEN) {
-			sme_warn(
-				"Invalid WAPI keylength [= %d]",
+			sme_warn("Invalid WAPI keylength [= %d]",
 				set_key->keyLength);
-			*enqueue_cmd = false;
+			*is_key_valid = false;
 			return QDF_STATUS_E_INVAL;
 		}
-		set_key_cmd->u.setKeyCmd.keyLength = CSR_WAPI_KEY_LEN;
-		qdf_mem_copy(set_key_cmd->u.setKeyCmd.Key, set_key->Key,
+		set_key_cmd->keyLength = CSR_WAPI_KEY_LEN;
+		qdf_mem_copy(set_key_cmd->Key, set_key->Key,
 			     CSR_WAPI_KEY_LEN);
 		if (session->pCurRoamProfile) {
 			session->pCurRoamProfile->negotiatedUCEncryptionType =
 				eCSR_ENCRYPT_TYPE_WPI;
 		} else {
 			sme_err("pCurRoamProfile is NULL");
-			*enqueue_cmd = false;
+			*is_key_valid = false;
 			return QDF_STATUS_E_INVAL;
 		}
-		*enqueue_cmd = true;
+		*is_key_valid = true;
 		break;
 #endif /* FEATURE_WLAN_WAPI */
 #ifdef FEATURE_WLAN_ESE
 	case eCSR_ENCRYPT_TYPE_KRK:
 		/* no need to enqueue KRK key request, since they are local */
-		*enqueue_cmd = false;
+		*is_key_valid = false;
 		if (set_key->keyLength < CSR_KRK_KEY_LEN) {
-			sme_warn(
-				"Invalid KRK keylength [= %d]",
+			sme_warn("Invalid KRK keylength [= %d]",
 				set_key->keyLength);
 			return QDF_STATUS_E_INVAL;
 		}
@@ -10017,10 +10001,9 @@ csr_update_key_cmd(tpAniSirGlobal mac_ctx, tCsrRoamSession *session,
 #ifdef WLAN_FEATURE_ROAM_OFFLOAD
 	case eCSR_ENCRYPT_TYPE_BTK:
 		/* no need to enqueue KRK key request, since they are local */
-		*enqueue_cmd = false;
+		*is_key_valid = false;
 		if (set_key->keyLength < SIR_BTK_KEY_LEN) {
-			sme_warn(
-				"LFR3:Invalid BTK keylength [= %d]",
+			sme_warn("LFR3:Invalid BTK keylength [= %d]",
 				set_key->keyLength);
 			return QDF_STATUS_E_INVAL;
 		}
@@ -10033,134 +10016,111 @@ csr_update_key_cmd(tpAniSirGlobal mac_ctx, tCsrRoamSession *session,
 	/* Check for 11w BIP */
 	case eCSR_ENCRYPT_TYPE_AES_CMAC:
 		if (set_key->keyLength < CSR_AES_KEY_LEN) {
-			sme_warn(
-				"Invalid AES/CCMP keylength [= %d]",
+			sme_warn("Invalid AES/CCMP keylength [= %d]",
 				set_key->keyLength);
-			*enqueue_cmd = false;
+			*is_key_valid = false;
 			return QDF_STATUS_E_INVAL;
 		}
-		set_key_cmd->u.setKeyCmd.keyLength = CSR_AES_KEY_LEN;
-		qdf_mem_copy(set_key_cmd->u.setKeyCmd.Key, set_key->Key,
+		set_key_cmd->keyLength = CSR_AES_KEY_LEN;
+		qdf_mem_copy(set_key_cmd->Key, set_key->Key,
 			     CSR_AES_KEY_LEN);
-		*enqueue_cmd = true;
+		*is_key_valid = true;
 		break;
 #endif /* WLAN_FEATURE_11W */
 	default:
 		/* for open security also we want to enqueue command */
-		*enqueue_cmd = true;
+		*is_key_valid = true;
 		return QDF_STATUS_SUCCESS;
 	} /* end of switch */
 	return QDF_STATUS_SUCCESS;
 }
 
 
-static QDF_STATUS csr_roam_issue_set_key_command(tpAniSirGlobal pMac,
-						 uint32_t sessionId,
-						 tCsrRoamSetKey *pSetKey,
-						 uint32_t roamId)
+static QDF_STATUS csr_roam_issue_set_key_command(tpAniSirGlobal mac_ctx,
+						 uint32_t session_id,
+						 tCsrRoamSetKey *set_key,
+						 uint32_t roam_id)
 {
 	QDF_STATUS status = QDF_STATUS_E_INVAL;
-	bool enqueue_cmd = true;
-	tSmeCmd *pCommand = NULL;
+	bool is_key_valid = true;
+	tSetKeyCmd set_key_cmd;
 #if defined(FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_WAPI)
-	tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
+	tCsrRoamSession *session = CSR_GET_SESSION(mac_ctx, session_id);
 
-	if (NULL == pSession) {
+	if (NULL == session) {
 		QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
-			 "session %d not found", sessionId);
+			 "session %d not found", session_id);
 		return QDF_STATUS_E_FAILURE;
 	}
 #endif /* FEATURE_WLAN_ESE */
 
-	pCommand = csr_get_command_buffer(pMac);
-	if (NULL == pCommand) {
-		sme_err(" fail to get command buffer");
-		return QDF_STATUS_E_RESOURCES;
-	}
-	qdf_mem_zero(pCommand, sizeof(tSmeCmd));
-	pCommand->command = eSmeCommandSetKey;
-	pCommand->sessionId = (uint8_t) sessionId;
+	qdf_mem_zero(&set_key_cmd, sizeof(tSetKeyCmd));
 	/*
 	 * following function will validate the key length, Adjust if too long.
 	 * for static WEP the keys are not set thru' SetContextReq
 	 *
-	 * it will update bool enqueue_cmd, to false if some error has occured
-	 * key are local. enqueue sme command only if enqueue_cmd is true
+	 * it will update bool is_key_valid, to false if some error has occured
+	 * key are local. enqueue sme command only if is_key_valid is true
 	 * status is indication of success or failure and will be returned to
 	 * called of current function if command is not enqueued due to key req
 	 * being local
 	 */
-	status = csr_update_key_cmd(pMac, pSession, pSetKey,
-				    pCommand, &enqueue_cmd);
-	if (enqueue_cmd) {
-		pCommand->u.setKeyCmd.roamId = roamId;
-		pCommand->u.setKeyCmd.encType = pSetKey->encType;
-		pCommand->u.setKeyCmd.keyDirection = pSetKey->keyDirection;
-		qdf_copy_macaddr(&pCommand->u.setKeyCmd.peermac,
-				 &pSetKey->peerMac);
+	status = csr_update_key_cmd(mac_ctx, session, set_key,
+				    &set_key_cmd, &is_key_valid);
+	if (is_key_valid) {
+		set_key_cmd.roamId = roam_id;
+		set_key_cmd.encType = set_key->encType;
+		set_key_cmd.keyDirection = set_key->keyDirection;
+		qdf_copy_macaddr(&set_key_cmd.peermac,
+				 &set_key->peerMac);
 		/* 0 for supplicant */
-		pCommand->u.setKeyCmd.paeRole = pSetKey->paeRole;
-		pCommand->u.setKeyCmd.keyId = pSetKey->keyId;
-		qdf_mem_copy(pCommand->u.setKeyCmd.keyRsc, pSetKey->keyRsc,
+		set_key_cmd.paeRole = set_key->paeRole;
+		set_key_cmd.keyId = set_key->keyId;
+		qdf_mem_copy(set_key_cmd.keyRsc, set_key->keyRsc,
 			     CSR_MAX_RSC_LEN);
 		/*
 		 * Always put set key to the head of the Q because it is the
 		 * only thing to get executed in case of WT_KEY state
 		 */
-
-		status = csr_queue_sme_command(pMac, pCommand, true);
-		if (!QDF_IS_STATUS_SUCCESS(status)) {
-			sme_err(
-				"fail to send message status = %d", status);
-			/* update to false so that command can be freed */
-			enqueue_cmd = false;
-		}
+		sme_debug("set key req for session-%d authtype-%d",
+			session_id, set_key->encType);
+		status = csr_roam_send_set_key_cmd(mac_ctx, session_id,
+						&set_key_cmd);
+		if (!QDF_IS_STATUS_SUCCESS(status))
+			sme_err("fail to send message status = %d", status);
 	}
-
-	/*
-	 * Free the command if enqueue_cmd == false:
-	 * this means that command was not enqueued because either there has
-	 * been a failure, or it is a "local" operation like the set ESE CCKM
-	 * KRK key.
-	 */
-	if (false == enqueue_cmd)
-		csr_release_command(pMac, pCommand);
-
 	return status;
 }
 
-QDF_STATUS csr_roam_process_set_key_command(tpAniSirGlobal pMac,
-							tSmeCmd *pCommand)
+QDF_STATUS csr_roam_send_set_key_cmd(tpAniSirGlobal mac_ctx,
+				uint32_t session_id, tSetKeyCmd *set_key_cmd)
 {
 	QDF_STATUS status;
-	uint8_t numKeys = (pCommand->u.setKeyCmd.keyLength) ? 1 : 0;
-	tAniEdType edType = csr_translate_encrypt_type_to_ed_type(pCommand->u.
-							setKeyCmd.encType);
-	bool fUnicast =
-		(pCommand->u.setKeyCmd.peermac.bytes[0] == 0xFF) ? false : true;
-	uint32_t sessionId = pCommand->sessionId;
+	uint8_t num_keys = (set_key_cmd->keyLength) ? 1 : 0;
+	tAniEdType ed_type = csr_translate_encrypt_type_to_ed_type(
+						set_key_cmd->encType);
+	bool unicast = (set_key_cmd->peermac.bytes[0] == 0xFF) ? false : true;
 #ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
-	tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
+	tCsrRoamSession *session = CSR_GET_SESSION(mac_ctx, session_id);
 
 	WLAN_HOST_DIAG_EVENT_DEF(setKeyEvent,
 				 host_event_wlan_security_payload_type);
 
-	if (NULL == pSession) {
-		sme_err("  session %d not found ", sessionId);
+	if (NULL == session) {
+		sme_err("session %d not found", session_id);
 		return QDF_STATUS_E_FAILURE;
 	}
 
-	if (eSIR_ED_NONE != edType) {
+	if (eSIR_ED_NONE != ed_type) {
 		qdf_mem_set(&setKeyEvent,
-			    sizeof(host_event_wlan_security_payload_type), 0);
-		if (qdf_is_macaddr_group(&pCommand->u.setKeyCmd.peermac)) {
+			sizeof(host_event_wlan_security_payload_type), 0);
+		if (qdf_is_macaddr_group(&set_key_cmd->peermac)) {
 			setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_BCAST_REQ;
 			setKeyEvent.encryptionModeMulticast =
 				(uint8_t) diag_enc_type_from_csr_type(
-							pCommand->u.
-							setKeyCmd.encType);
+					set_key_cmd->encType);
 			setKeyEvent.encryptionModeUnicast =
-				(uint8_t) diag_enc_type_from_csr_type(pSession->
+				(uint8_t) diag_enc_type_from_csr_type(session->
 							connectedProfile.
 							EncryptionType);
 		} else {
@@ -10168,50 +10128,43 @@ QDF_STATUS csr_roam_process_set_key_command(tpAniSirGlobal pMac,
 				WLAN_SECURITY_EVENT_SET_UNICAST_REQ;
 			setKeyEvent.encryptionModeUnicast =
 				(uint8_t) diag_enc_type_from_csr_type(
-							pCommand->u.
-							setKeyCmd.encType);
+					set_key_cmd->encType);
 			setKeyEvent.encryptionModeMulticast =
-				(uint8_t) diag_enc_type_from_csr_type(pSession->
+				(uint8_t) diag_enc_type_from_csr_type(session->
 							connectedProfile.
 							mcEncryptionType);
 		}
 		qdf_mem_copy(setKeyEvent.bssid,
-			     pSession->connectedProfile.bssid.bytes,
+			     session->connectedProfile.bssid.bytes,
 			     QDF_MAC_ADDR_SIZE);
-		if (CSR_IS_ENC_TYPE_STATIC(pCommand->u.setKeyCmd.encType)) {
+		if (CSR_IS_ENC_TYPE_STATIC(set_key_cmd->encType)) {
 			uint32_t defKeyId;
 			/* It has to be static WEP here */
-			if (IS_SIR_STATUS_SUCCESS(wlan_cfg_get_int(pMac,
+			if (IS_SIR_STATUS_SUCCESS(wlan_cfg_get_int(mac_ctx,
 					WNI_CFG_WEP_DEFAULT_KEYID,
 					&defKeyId))) {
 				setKeyEvent.keyId = (uint8_t) defKeyId;
 			}
 		} else {
-			setKeyEvent.keyId = pCommand->u.setKeyCmd.keyId;
+			setKeyEvent.keyId = set_key_cmd->keyId;
 		}
 		setKeyEvent.authMode =
-			(uint8_t) diag_auth_type_from_csr_type(pSession->
+			(uint8_t) diag_auth_type_from_csr_type(session->
 							       connectedProfile.
 							       AuthType);
 		WLAN_HOST_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
 	}
 #endif /* FEATURE_WLAN_DIAG_SUPPORT_CSR */
-	if (csr_is_set_key_allowed(pMac, sessionId)) {
-		status = csr_send_mb_set_context_req_msg(pMac, sessionId,
-							 pCommand->u.
-							 setKeyCmd.peermac,
-							 numKeys,
-							 edType, fUnicast,
-							 pCommand->u.setKeyCmd.
-							 keyDirection,
-						pCommand->u.setKeyCmd.keyId,
-							 pCommand->u.setKeyCmd.
-							 keyLength,
-						pCommand->u.setKeyCmd.Key,
-							 pCommand->u.setKeyCmd.
-							 paeRole,
-							 pCommand->u.setKeyCmd.
-							 keyRsc);
+	if (csr_is_set_key_allowed(mac_ctx, session_id)) {
+		status = csr_send_mb_set_context_req_msg(mac_ctx, session_id,
+					set_key_cmd->peermac,
+					num_keys, ed_type, unicast,
+					set_key_cmd->keyDirection,
+					set_key_cmd->keyId,
+					set_key_cmd->keyLength,
+					set_key_cmd->Key,
+					set_key_cmd->paeRole,
+					set_key_cmd->keyRsc);
 	} else {
 		sme_warn(" cannot process not connected");
 		/* Set this status so the error handling take
@@ -10221,20 +10174,18 @@ QDF_STATUS csr_roam_process_set_key_command(tpAniSirGlobal pMac,
 	}
 	if (!QDF_IS_STATUS_SUCCESS(status)) {
 		sme_err("  error status %d", status);
-		csr_roam_call_callback(pMac, sessionId, NULL,
-				       pCommand->u.setKeyCmd.roamId,
+		csr_roam_call_callback(mac_ctx, session_id, NULL,
+				       set_key_cmd->roamId,
 				       eCSR_ROAM_SET_KEY_COMPLETE,
 				       eCSR_ROAM_RESULT_FAILURE);
 #ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
-		if (eSIR_ED_NONE != edType) {
-			if (qdf_is_macaddr_group(
-					&pCommand->u.setKeyCmd.peermac)) {
+		if (eSIR_ED_NONE != ed_type) {
+			if (qdf_is_macaddr_group(&set_key_cmd->peermac))
 				setKeyEvent.eventId =
 					WLAN_SECURITY_EVENT_SET_BCAST_RSP;
-			} else {
+			else
 				setKeyEvent.eventId =
 					WLAN_SECURITY_EVENT_SET_UNICAST_RSP;
-			}
 			setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
 			WLAN_HOST_DIAG_EVENT_REPORT(&setKeyEvent,
 						    EVENT_WLAN_SECURITY);
@@ -11401,25 +11352,18 @@ csr_roam_chk_lnk_set_ctx_rsp(tpAniSirGlobal mac_ctx, tSirSmeRsp *msg_ptr)
 	uint32_t sessionId = CSR_SESSION_ID_INVALID;
 	QDF_STATUS status;
 	tCsrRoamInfo *roam_info_ptr = NULL;
-	tSmeCmd *cmd;
 	tCsrRoamInfo roam_info;
 	eCsrRoamResult result = eCSR_ROAM_RESULT_NONE;
 	tSirSmeSetContextRsp *pRsp = (tSirSmeSetContextRsp *) msg_ptr;
-	tListElem *entry;
 
-	qdf_mem_set(&roam_info, sizeof(roam_info), 0);
-	entry = csr_nonscan_active_ll_peek_head(mac_ctx, LL_ACCESS_LOCK);
-	if (!entry) {
-		sme_err("CSR: NO commands are ACTIVE ...");
-		goto process_pending_n_exit;
-	}
 
-	cmd = GET_BASE_ADDR(entry, tSmeCmd, Link);
-	if (eSmeCommandSetKey != cmd->command) {
-		sme_err("CSR: setkey cmd is not ACTIVE ...");
-		goto process_pending_n_exit;
+	if (!pRsp) {
+		sme_err("set key response is NULL");
+		return;
 	}
-	sessionId = cmd->sessionId;
+
+	qdf_mem_set(&roam_info, sizeof(roam_info), 0);
+	sessionId = pRsp->sessionId;
 	session = CSR_GET_SESSION(mac_ctx, sessionId);
 	if (!session) {
 		sme_err("session %d not found", sessionId);
@@ -11453,7 +11397,7 @@ csr_roam_chk_lnk_set_ctx_rsp(tpAniSirGlobal mac_ctx, tSirSmeRsp *msg_ptr)
 				    sizeof(tSirSetActiveModeSetBncFilterReq));
 			if (NULL == pMsg) {
 				sme_err("Malloc failed");
-				goto remove_entry_n_process_pending;
+				return;
 			}
 			pMsg->messageType = eWNI_SME_SET_BCN_FILTER_REQ;
 			pMsg->length = sizeof(tSirSetActiveModeSetBncFilterReq);
@@ -11481,7 +11425,7 @@ csr_roam_chk_lnk_set_ctx_rsp(tpAniSirGlobal mac_ctx, tSirSmeRsp *msg_ptr)
 					struct sme_obss_ht40_scanind_msg));
 				if (NULL == msg) {
 					sme_err("Malloc failed");
-					goto remove_entry_n_process_pending;
+					return;
 				}
 				msg->msg_type = eWNI_SME_HT40_OBSS_SCAN_IND;
 				msg->length =
@@ -11503,9 +11447,9 @@ csr_roam_chk_lnk_set_ctx_rsp(tpAniSirGlobal mac_ctx, tSirSmeRsp *msg_ptr)
 			pRsp->statusCode,
 			MAC_ADDR_ARRAY(pRsp->peer_macaddr.bytes));
 	}
+	/* keeping roam_id = 0 as nobody is using roam_id for set_key */
 	csr_roam_call_callback(mac_ctx, sessionId, &roam_info,
-			       cmd->u.setKeyCmd.roamId,
-			       eCSR_ROAM_SET_KEY_COMPLETE, result);
+			       0, eCSR_ROAM_SET_KEY_COMPLETE, result);
 	/* Indicate SME_QOS that the SET_KEY is completed, so that SME_QOS
 	 * can go ahead and initiate the TSPEC if any are pending
 	 */
@@ -11520,12 +11464,6 @@ csr_roam_chk_lnk_set_ctx_rsp(tpAniSirGlobal mac_ctx, tSirSmeRsp *msg_ptr)
 		session->isPrevApInfoValid = false;
 	}
 #endif
-remove_entry_n_process_pending:
-	if (csr_nonscan_active_ll_remove_entry(mac_ctx, entry,
-				LL_ACCESS_LOCK))
-		csr_release_command(mac_ctx, cmd);
-
-process_pending_n_exit:
 	return;
 }
 
@@ -18451,9 +18389,6 @@ static void csr_free_cmd_memory(tpAniSirGlobal pMac, tSmeCmd *pCommand)
 	case eSmeCommandWmStatusChange:
 		csr_release_command_wm_status_change(pMac, pCommand);
 		break;
-	case eSmeCommandSetKey:
-		csr_release_command_set_key(pMac, pCommand);
-		break;
 	case eSmeCommandNdpInitiatorRequest:
 		csr_release_ndp_initiator_req(pMac, pCommand);
 		break;
@@ -18653,15 +18588,6 @@ static enum wlan_serialization_cmd_type csr_get_roam_cmd_type(tSmeCmd *sme_cmd)
 	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;
 	}
@@ -18683,9 +18609,6 @@ enum wlan_serialization_cmd_type csr_get_cmd_type(tSmeCmd *sme_cmd)
 	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;
@@ -18816,8 +18739,7 @@ QDF_STATUS csr_queue_sme_command(tpAniSirGlobal mac_ctx, tSmeCmd *sme_cmd,
 	}
 
 	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)) {
+		if (!CSR_IS_DISCONNECT_COMMAND(sme_cmd)) {
 			sme_err("Can't process cmd(%d), waiting for key",
 				sme_cmd->command);
 			return QDF_STATUS_CMD_NOT_QUEUED;