瀏覽代碼

qcacld-3.0: Implement NAN datapath interface create

qcacld-2.0 to qcacld-3.0 propagation

Add changes to support session and BSS creation in NDI mode.

CRs-Fixed: 962367
Change-Id: I585cd89702a2c412783ae93fb1558ed5bfe31fd9
Deepak Dhamdhere 9 年之前
父節點
當前提交
e2dd5440bf

+ 3 - 0
core/cds/src/cds_api.c

@@ -1591,6 +1591,9 @@ QDF_STATUS cds_get_vdev_types(enum tQDF_ADAPTER_MODE mode, uint32_t *type,
 	case QDF_MONITOR_MODE:
 		*type = WMI_VDEV_TYPE_MONITOR;
 		break;
+	case QDF_NDI_MODE:
+		*type = WMI_VDEV_TYPE_NDI;
+		break;
 	default:
 		QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_ERROR,
 			  "Invalid device mode %d", mode);

+ 2 - 1
core/mac/src/cfg/cfg_api.c

@@ -727,7 +727,8 @@ tSirRetStatus cfg_get_capability_info(tpAniSirGlobal pMac, uint16_t *pCap,
 	else if (LIM_IS_AP_ROLE(sessionEntry) ||
 		LIM_IS_STA_ROLE(sessionEntry))
 		pCapInfo->ess = 1;      /* ESS bit */
-	else if (LIM_IS_P2P_DEVICE_ROLE(sessionEntry)) {
+	else if (LIM_IS_P2P_DEVICE_ROLE(sessionEntry) ||
+		LIM_IS_NDI_ROLE(sessionEntry)) {
 		pCapInfo->ess = 0;
 		pCapInfo->ibss = 0;
 	} else

+ 4 - 3
core/mac/src/pe/lim/lim_process_mlm_req_messages.c

@@ -603,11 +603,12 @@ lim_mlm_add_bss(tpAniSirGlobal mac_ctx,
 		     session->selfMacAddr, sizeof(tSirMacAddr));
 
 	addbss_param->bssType = mlm_start_req->bssType;
-	if ((mlm_start_req->bssType == eSIR_IBSS_MODE)) {
+	if (mlm_start_req->bssType == eSIR_IBSS_MODE)
 		addbss_param->operMode = BSS_OPERATIONAL_MODE_STA;
-	} else if (mlm_start_req->bssType == eSIR_INFRA_AP_MODE) {
+	else if (mlm_start_req->bssType == eSIR_INFRA_AP_MODE)
 		addbss_param->operMode = BSS_OPERATIONAL_MODE_AP;
-	}
+	else if (mlm_start_req->bssType == eSIR_NDI_MODE)
+		addbss_param->operMode = BSS_OPERATIONAL_MODE_NDI;
 
 	addbss_param->shortSlotTimeSupported = session->shortSlotTimeSupported;
 	addbss_param->beaconInterval = mlm_start_req->beaconPeriod;

+ 8 - 3
core/mac/src/pe/lim/lim_process_mlm_rsp_messages.c

@@ -49,6 +49,7 @@
 #include "cds_utils.h"
 #include "lim_types.h"
 #include "cds_concurrency.h"
+#include "nan_datapath.h"
 
 #define MAX_SUPPORTED_PEERS_WEP 16
 
@@ -254,12 +255,14 @@ void lim_process_mlm_start_cnf(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
 		MTRACE(mac_trace
 			       (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
 			       psessionEntry->limSmeState));
-		if (psessionEntry->bssType == eSIR_INFRA_AP_MODE) {
+		if (psessionEntry->bssType == eSIR_INFRA_AP_MODE)
 			lim_log(pMac, LOG1,
 				FL("*** Started BSS in INFRA AP SIDE***"));
-		} else {
+		else if (psessionEntry->bssType == eSIR_NDI_MODE)
+			lim_log(pMac, LOG1,
+				FL("*** Started BSS in NDI mode ***"));
+		else
 			lim_log(pMac, LOG1, FL("*** Started BSS ***"));
-		}
 	} else {
 		/* Start BSS is a failure */
 		pe_delete_session(pMac, psessionEntry);
@@ -2672,6 +2675,8 @@ void lim_process_mlm_add_bss_rsp(tpAniSirGlobal mac_ctx,
 	mlm_start_cnf.sessionId = session_entry->peSessionId;
 	if (eSIR_IBSS_MODE == bss_type) {
 		lim_process_ibss_mlm_add_bss_rsp(mac_ctx, msg, session_entry);
+	} else if (eSIR_NDI_MODE == session_entry->bssType) {
+		lim_process_ndi_mlm_add_bss_rsp(mac_ctx, msg, session_entry);
 	} else {
 		if (eLIM_SME_WT_START_BSS_STATE == session_entry->limSmeState) {
 			if (eLIM_MLM_WT_ADD_BSS_RSP_STATE !=

+ 39 - 24
core/mac/src/pe/lim/lim_process_sme_req_messages.c

@@ -698,27 +698,34 @@ __lim_handle_sme_start_bss_request(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
 			}
 		}
 
-		/* Probe resp add ie */
-		lim_start_bss_update_add_ie_buffer(mac_ctx,
-			&session->addIeParams.probeRespData_buff,
-			&session->addIeParams.probeRespDataLen,
-			sme_start_bss_req->addIeParams.probeRespData_buff,
-			sme_start_bss_req->addIeParams.probeRespDataLen);
-
-		/* Probe Beacon add ie */
-		lim_start_bss_update_add_ie_buffer(mac_ctx,
-			&session->addIeParams.probeRespBCNData_buff,
-			&session->addIeParams.probeRespBCNDataLen,
-			sme_start_bss_req->addIeParams.probeRespBCNData_buff,
-			sme_start_bss_req->addIeParams.probeRespBCNDataLen);
-
-		/* Assoc resp IE */
-		lim_start_bss_update_add_ie_buffer(mac_ctx,
-			&session->addIeParams.assocRespData_buff,
-			&session->addIeParams.assocRespDataLen,
-			sme_start_bss_req->addIeParams.assocRespData_buff,
-			sme_start_bss_req->addIeParams.assocRespDataLen);
-
+		if (QDF_NDI_MODE != sme_start_bss_req->bssPersona) {
+			/* Probe resp add ie */
+			lim_start_bss_update_add_ie_buffer(mac_ctx,
+				&session->addIeParams.probeRespData_buff,
+				&session->addIeParams.probeRespDataLen,
+				sme_start_bss_req->addIeParams.
+					probeRespData_buff,
+				sme_start_bss_req->addIeParams.
+					probeRespDataLen);
+
+			/* Probe Beacon add ie */
+			lim_start_bss_update_add_ie_buffer(mac_ctx,
+				&session->addIeParams.probeRespBCNData_buff,
+				&session->addIeParams.probeRespBCNDataLen,
+				sme_start_bss_req->addIeParams.
+					probeRespBCNData_buff,
+				sme_start_bss_req->addIeParams.
+					probeRespBCNDataLen);
+
+			/* Assoc resp IE */
+			lim_start_bss_update_add_ie_buffer(mac_ctx,
+				&session->addIeParams.assocRespData_buff,
+				&session->addIeParams.assocRespDataLen,
+				sme_start_bss_req->addIeParams.
+					assocRespData_buff,
+				sme_start_bss_req->addIeParams.
+					assocRespDataLen);
+		}
 		/* Store the session related params in newly created session */
 		session->pLimStartBssReq = sme_start_bss_req;
 
@@ -826,6 +833,10 @@ __lim_handle_sme_start_bss_request(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
 			session->vdev_nss = vdev_type_nss->ibss;
 
 			break;
+		case eSIR_NDI_MODE:
+			session->limSystemRole = eLIM_NDI_ROLE;
+			break;
+
 
 		/*
 		 * There is one more mode called auto mode.
@@ -861,7 +872,8 @@ __lim_handle_sme_start_bss_request(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
 					sizeof(tpSirAssocReq)), 0);
 		}
 
-		if (!sme_start_bss_req->channelId) {
+		if (!sme_start_bss_req->channelId &&
+		    sme_start_bss_req->bssType != eSIR_NDI_MODE) {
 			lim_log(mac_ctx, LOGE,
 				FL("Received invalid eWNI_SME_START_BSS_REQ"));
 			ret_code = eSIR_SME_INVALID_PARAMETERS;
@@ -924,7 +936,9 @@ __lim_handle_sme_start_bss_request(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
 		lim_set_rs_nie_wp_aiefrom_sme_start_bss_req_message(mac_ctx,
 				&sme_start_bss_req->rsnIE, session);
 
-		if (LIM_IS_AP_ROLE(session) || LIM_IS_IBSS_ROLE(session)) {
+		if (LIM_IS_AP_ROLE(session) ||
+		    LIM_IS_IBSS_ROLE(session) ||
+		    LIM_IS_NDI_ROLE(session)) {
 			session->gLimProtectionControl =
 				sme_start_bss_req->protEnabled;
 			/*
@@ -962,7 +976,8 @@ __lim_handle_sme_start_bss_request(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
 		/* Fill PE session Id from the session Table */
 		mlm_start_req->sessionId = session->peSessionId;
 
-		if (mlm_start_req->bssType == eSIR_INFRA_AP_MODE) {
+		if (mlm_start_req->bssType == eSIR_INFRA_AP_MODE ||
+		    mlm_start_req->bssType == eSIR_NDI_MODE) {
 			/*
 			 * Copy the BSSId from sessionTable to
 			 * mlmStartReq struct

+ 2 - 0
core/mac/src/pe/lim/lim_send_sme_rsp_messages.c

@@ -612,6 +612,7 @@ lim_send_sme_start_bss_rsp(tpAniSirGlobal pMac,
 			pSirSmeRsp->bssDescription.channelId =
 				psessionEntry->currentOperChannel;
 
+		if (!LIM_IS_NDI_ROLE(psessionEntry)) {
 			curLen = psessionEntry->schBeaconOffsetBegin - ieOffset;
 			qdf_mem_copy((uint8_t *) &pSirSmeRsp->bssDescription.
 				     ieFields,
@@ -630,6 +631,7 @@ lim_send_sme_start_bss_rsp(tpAniSirGlobal pMac,
 				sizeof(uint32_t) + ieLen;
 			/* This is the size of the message, subtracting the size of the pointer to ieFields */
 			size += ieLen - sizeof(uint32_t);
+		}
 #ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
 			if (psessionEntry->cc_switch_mode
 			    != QDF_MCC_TO_SCC_SWITCH_DISABLE) {

+ 2 - 0
core/mac/src/pe/lim/lim_sme_req_utils.c

@@ -409,6 +409,8 @@ lim_is_sme_start_bss_req_valid(tpAniSirGlobal mac_ctx,
 		break;
 	case eSIR_INFRA_AP_MODE:
 		break;
+	case eSIR_NDI_MODE:
+		break;
 	default:
 		/**
 		 * Should not have received start BSS req with bssType

+ 1 - 0
core/mac/src/pe/lim/lim_utils.c

@@ -6749,6 +6749,7 @@ const char *lim_bss_type_to_string(const uint16_t bss_type)
 	CASE_RETURN_STRING(eSIR_INFRA_AP_MODE);
 	CASE_RETURN_STRING(eSIR_IBSS_MODE);
 	CASE_RETURN_STRING(eSIR_AUTO_MODE);
+	CASE_RETURN_STRING(eSIR_NDI_MODE);
 	default:
 		return "Unknown bss_type";
 	}

+ 48 - 0
core/mac/src/pe/nan/nan_datapath.c

@@ -24,6 +24,8 @@
  * MAC NAN Data path API implementation
  */
 
+#include "lim_utils.h"
+#include "lim_api.h"
 #include "nan_datapath.h"
 
 /**
@@ -49,3 +51,49 @@ QDF_STATUS handle_ndp_event_message(tpAniSirGlobal mac_ctx, tpSirMsgQ msg)
 {
 	return QDF_STATUS_SUCCESS;
 }
+
+/**
+ * lim_process_ndi_mlm_add_bss_rsp() - Process ADD_BSS response for NDI
+ * @mac_ctx: Pointer to Global MAC structure
+ * @lim_msgq: The MsgQ header, which contains the response buffer
+ * @session_entry: PE session
+ *
+ * Return: None
+ */
+void lim_process_ndi_mlm_add_bss_rsp(tpAniSirGlobal mac_ctx, tpSirMsgQ lim_msgq,
+		tpPESession session_entry)
+{
+	tLimMlmStartCnf mlm_start_cnf;
+	tpAddBssParams add_bss_params = (tpAddBssParams) lim_msgq->bodyptr;
+
+	lim_log(mac_ctx, LOG1, FL("Status %d"), add_bss_params->status);
+	if (NULL == add_bss_params) {
+		lim_log(mac_ctx, LOGE, FL("Invalid body pointer in message"));
+		goto end;
+	}
+	if (QDF_STATUS_SUCCESS == add_bss_params->status) {
+		lim_log(mac_ctx, LOG1,
+		       FL("WDA_ADD_BSS_RSP returned QDF_STATUS_SUCCESS"));
+		session_entry->limMlmState = eLIM_MLM_BSS_STARTED_STATE;
+		MTRACE(mac_trace(mac_ctx, TRACE_CODE_MLM_STATE,
+			session_entry->peSessionId,
+			session_entry->limMlmState));
+		session_entry->bssIdx = (uint8_t) add_bss_params->bssIdx;
+		session_entry->limSystemRole = eLIM_NDI_ROLE;
+		session_entry->statypeForBss = STA_ENTRY_SELF;
+		/* Apply previously set configuration at HW */
+		lim_apply_configuration(mac_ctx, session_entry);
+		mlm_start_cnf.resultCode = eSIR_SME_SUCCESS;
+	} else {
+		lim_log(mac_ctx, LOGE,
+			FL("WDA_ADD_BSS_REQ failed with status %d"),
+			add_bss_params->status);
+		mlm_start_cnf.resultCode = eSIR_SME_HAL_SEND_MESSAGE_FAIL;
+	}
+	mlm_start_cnf.sessionId = session_entry->peSessionId;
+	lim_post_sme_message(mac_ctx, LIM_MLM_START_CNF,
+				(uint32_t *) &mlm_start_cnf);
+end:
+	qdf_mem_free(lim_msgq->bodyptr);
+	lim_msgq->bodyptr = NULL;
+}

+ 11 - 0
core/mac/src/pe/nan/nan_datapath.h

@@ -106,6 +106,9 @@ QDF_STATUS lim_handle_ndp_request_message(tpAniSirGlobal mac_ctx,
 /* Function to process NDP events */
 QDF_STATUS lim_handle_ndp_event_message(tpAniSirGlobal mac_ctx,
 					tpSirMsgQ msg);
+void lim_process_ndi_mlm_add_bss_rsp(tpAniSirGlobal mac_ctx,
+				     tpSirMsgQ lim_msg_q,
+				     tpPESession session_entry);
 #else
 /* Function to process NDP requests */
 static inline QDF_STATUS lim_handle_ndp_request_message(tpAniSirGlobal mac_ctx,
@@ -119,6 +122,14 @@ static inline QDF_STATUS lim_handle_ndp_event_message(tpAniSirGlobal mac_ctx,
 {
 	return QDF_STATUS_SUCCESS;
 }
+
+/* Function to process NDP events */
+static inline void lim_process_ndi_mlm_add_bss_rsp(tpAniSirGlobal mac_ctx,
+						   tpSirMsgQ lim_msg_q,
+						   tpPESession session_entry)
+{
+}
+
 #endif /* WLAN_FEATURE_NAN_DATAPATH */
 
 #endif /* __MAC_NAN_DATAPATH_H */

+ 15 - 1
core/sme/inc/csr_api.h

@@ -667,6 +667,10 @@ typedef enum {
 	eCSR_ASSOC_STATE_TYPE_INFRA_CONNECTED,
 	/* Disconnecting with AP or stop connecting process */
 	eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTING,
+	/* NAN Data interface not started */
+	eCSR_CONNECT_STATE_TYPE_NDI_NOT_STARTED,
+	/* NAN Data inteface started */
+	eCSR_CONNECT_STATE_TYPE_NDI_STARTED,
 
 } eCsrConnectState;
 
@@ -1616,9 +1620,19 @@ typedef QDF_STATUS (*csr_roamSessionCloseCallback)(void *pContext);
 				       (pProfile)->BSSType)
 #define CSR_IS_INFRA_AP(pProfile) (eCSR_BSS_TYPE_INFRA_AP ==  \
 				   (pProfile)->BSSType)
-#define CSR_IS_NDI(pProfile) (eCSR_BSS_TYPE_NDI == (pProfile)->BSSType)
+#ifdef WLAN_FEATURE_NAN_DATAPATH
+#define CSR_IS_NDI(profile)  (eCSR_BSS_TYPE_NDI == (profile)->BSSType)
+#else
+#define CSR_IS_NDI(profile)  (false)
+#endif
 #define CSR_IS_CONN_INFRA_AP(pProfile)  (eCSR_BSS_TYPE_INFRA_AP == \
 					 (pProfile)->BSSType)
+#ifdef WLAN_FEATURE_NAN_DATAPATH
+#define CSR_IS_CONN_NDI(profile)  (eCSR_BSS_TYPE_NDI == (profile)->BSSType)
+#else
+#define CSR_IS_CONN_NDI(profile)  (false)
+#endif
+
 #define CSR_IS_CLOSE_SESSION_COMMAND(pCommand) \
 	((pCommand)->command == eSmeCommandDelStaSession)
 

+ 58 - 0
core/sme/inc/sme_nan_datapath.h

@@ -27,6 +27,9 @@
 #ifndef __SME_NAN_DATAPATH_H
 #define __SME_NAN_DATAPATH_H
 
+#ifdef WLAN_FEATURE_NAN_DATAPATH
+#include "qdf_types.h"
+#include "sir_api.h"
 #include "ani_global.h"
 
 /* NAN initiator request handler */
@@ -48,4 +51,59 @@ QDF_STATUS sme_ndp_sched_req_handler(uint32_t session_id,
 /* Function to handle NDP messages from lower layers */
 void sme_ndp_message_processor(tpAniSirGlobal mac_ctx, uint16_t msg_type,
 				void *msg);
+
+/* Start NDI BSS */
+QDF_STATUS csr_roam_start_ndi(tpAniSirGlobal mac_ctx, uint32_t session_id,
+			      tCsrRoamProfile *profile);
+
+void csr_roam_fill_roaminfo_ndp(tpAniSirGlobal mac_ctx,
+				tCsrRoamInfo *roam_info,
+				eCsrRoamResult roam_result,
+				tSirResultCodes status_code,
+				uint32_t reason_code,
+				uint32_t transaction_id);
+
+void csr_roam_save_ndi_connected_info(tpAniSirGlobal mac_ctx,
+				      uint32_t session_id,
+				      tCsrRoamProfile *roam_profile,
+				      tSirBssDescription *bss_desc);
+
+void csr_roam_update_ndp_return_params(tpAniSirGlobal mac_ctx,
+					uint32_t result,
+					uint32_t *roam_status,
+					uint32_t *roam_result);
+#else
+
+/* Start NDI BSS */
+static inline QDF_STATUS csr_roam_start_ndi(tpAniSirGlobal mac_ctx,
+					uint32_t session_id,
+					tCsrRoamProfile *profile)
+{
+	return QDF_STATUS_SUCCESS;
+}
+
+/* Fill in ndp information in roam_info */
+static inline void csr_roam_fill_roaminfo_ndp(tpAniSirGlobal mac_ctx,
+					      tCsrRoamInfo *roam_info,
+					      eCsrRoamResult roam_result,
+					      tSirResultCodes status_code,
+					      uint32_t reason_code,
+					      uint32_t transaction_id)
+{
+}
+
+static inline void csr_roam_save_ndi_connected_info(tpAniSirGlobal mac_ctx,
+					uint32_t session_id,
+					tCsrRoamProfile *roam_profile,
+					tSirBssDescription *bss_desc)
+{
+}
+
+static inline void csr_roam_update_ndp_return_params(tpAniSirGlobal mac_ctx,
+						uint32_t result,
+						uint32_t *roam_status,
+						uint32_t *roam_result)
+{
+}
+#endif /* WLAN_FEATURE_NAN_DATAPATH */
 #endif /* __SME_NAN_DATAPATH_H */

+ 60 - 20
core/sme/src/csr/csr_api_roam.c

@@ -54,6 +54,7 @@
 #include "sme_power_save_api.h"
 #include "wma.h"
 #include "cds_concurrency.h"
+#include "sme_nan_datapath.h"
 
 #define MAX_PWR_FCC_CHAN_12 8
 #define MAX_PWR_FCC_CHAN_13 2
@@ -177,11 +178,6 @@ static void csr_roam_update_connected_profile_from_new_bss(tpAniSirGlobal pMac,
 							   uint32_t sessionId,
 							   tSirSmeNewBssInfo *
 							   pNewBss);
-static void csr_roam_prepare_bss_params(tpAniSirGlobal pMac, uint32_t sessionId,
-					tCsrRoamProfile *pProfile,
-					tSirBssDescription *pBssDesc,
-					tBssConfigParam *pBssConfig,
-					tDot11fBeaconIEs *pIes);
 static ePhyChanBondState csr_get_cb_mode_from_ies(tpAniSirGlobal pMac,
 						  uint8_t primaryChn,
 						  tDot11fBeaconIEs *pIes);
@@ -3862,7 +3858,7 @@ QDF_STATUS csr_roam_prepare_bss_config(tpAniSirGlobal pMac,
 	return QDF_STATUS_SUCCESS;
 }
 
-static QDF_STATUS csr_roam_prepare_bss_config_from_profile(tpAniSirGlobal pMac,
+QDF_STATUS csr_roam_prepare_bss_config_from_profile(tpAniSirGlobal pMac,
 							   tCsrRoamProfile *pProfile,
 							   tBssConfigParam *
 							   pBssConfig,
@@ -5162,6 +5158,13 @@ static void csr_roam_join_handle_profile(tpAniSirGlobal mac_ctx,
 			*roam_state = eCsrContinueRoaming;
 		else
 			*roam_state = eCsrStopRoaming;
+	} else if (CSR_IS_NDI(profile)) {
+		csr_roam_assign_default_param(mac_ctx, cmd);
+		status = csr_roam_start_ndi(mac_ctx, session_id, profile);
+		if (QDF_IS_STATUS_SUCCESS(status))
+			*roam_state = eCsrContinueRoaming;
+		else
+			*roam_state = eCsrStopRoaming;
 	} else {
 		/* Nothing we can do */
 		sms_log(mac_ctx, LOGW, FL("cannot continue without BSS list"));
@@ -6284,11 +6287,23 @@ static void csr_roam_process_start_bss_success(tpAniSirGlobal mac_ctx,
 	else if (CSR_IS_INFRA_AP(profile))
 		session->connectState =
 			eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
+	else if (CSR_IS_NDI(profile))
+		session->connectState = eCSR_CONNECT_STATE_TYPE_NDI_STARTED;
 	else
 		session->connectState = eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED;
+
+	bss_desc = &start_bss_rsp->bssDescription;
+	if (CSR_IS_NDI(profile)) {
+		csr_roam_state_change(mac_ctx, eCSR_ROAMING_STATE_JOINED,
+			session_id);
+		csr_roam_save_ndi_connected_info(mac_ctx, session_id, profile,
+						bss_desc);
+		roam_info.u.pConnectedProfile = &session->connectedProfile;
+		qdf_mem_copy(&roam_info.bssid, &bss_desc->bssId,
+			    sizeof(struct qdf_mac_addr));
+	}
 	csr_roam_state_change(mac_ctx, eCSR_ROAMING_STATE_JOINED,
 			session_id);
-	bss_desc = &start_bss_rsp->bssDescription;
 	if (!QDF_IS_STATUS_SUCCESS
 		(csr_get_parsed_bss_description_ies(mac_ctx, bss_desc,
 						    &ies_ptr))) {
@@ -6308,12 +6323,10 @@ static void csr_roam_process_start_bss_success(tpAniSirGlobal mac_ctx,
 	csr_roam_save_connected_bss_desc(mac_ctx, session_id, bss_desc);
 	csr_roam_free_connect_profile(&session->connectedProfile);
 	csr_roam_free_connected_info(mac_ctx, &session->connectedInfo);
-	if (bss_desc) {
-		csr_roam_save_connected_infomation(mac_ctx, session_id,
-				profile, bss_desc, ies_ptr);
-		qdf_mem_copy(&roam_info.bssid, &bss_desc->bssId,
+	csr_roam_save_connected_infomation(mac_ctx, session_id,
+			profile, bss_desc, ies_ptr);
+	qdf_mem_copy(&roam_info.bssid, &bss_desc->bssId,
 			sizeof(struct qdf_mac_addr));
-	}
 	/* We are done with the IEs so free it */
 	qdf_mem_free(ies_ptr);
 #ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
@@ -6383,19 +6396,28 @@ static void csr_roam_process_start_bss_success(tpAniSirGlobal mac_ctx,
 			roam_status = eCSR_ROAM_INFRA_IND;
 			roam_result = eCSR_ROAM_RESULT_INFRA_STARTED;
 		}
+		if (CSR_IS_NDI(profile)) {
+			csr_roam_update_ndp_return_params(mac_ctx,
+					eCsrStartBssSuccess,
+					&roam_status, &roam_result);
+			csr_roam_fill_roaminfo_ndp(mac_ctx, &roam_info,
+					roam_result,
+					start_bss_rsp->statusCode,
+					0, 0);
+		}
 		/*
 		 * Only tell upper layer is we start the BSS because Vista
 		 * doesn't like multiple connection indications. If we don't
 		 * start the BSS ourself, handler of eSIR_SME_JOINED_NEW_BSS
 		 * will trigger the connection start indication in Vista
 		 */
-		qdf_mem_set(&roam_info, sizeof(tCsrRoamInfo), 0);
 		roam_info.statusCode = session->joinFailStatusCode.statusCode;
 		roam_info.reasonCode = session->joinFailStatusCode.reasonCode;
 		/* We start the IBSS (didn't find any matched IBSS out there) */
 		roam_info.pBssDesc = bss_desc;
 		roam_info.staId = (uint8_t) start_bss_rsp->staId;
-		qdf_mem_copy(roam_info.bssid.bytes, bss_desc->bssId,
+		if (bss_desc)
+			qdf_mem_copy(roam_info.bssid.bytes, bss_desc->bssId,
 				sizeof(struct qdf_mac_addr));
 		if (!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
 				(csr_is_concurrent_session_running(mac_ctx))) {
@@ -6823,6 +6845,7 @@ static bool csr_roam_process_results(tpAniSirGlobal mac_ctx, tSmeCmd *cmd,
 	eRoamCmdStatus roam_status;
 	eCsrRoamResult roam_result;
 	host_log_ibss_pkt_type *ibss_log;
+	tSirSmeStartBssRsp  *start_bss_rsp = NULL;
 
 	if (!session) {
 		sms_log(mac_ctx, LOGE, FL("session %d not found "), session_id);
@@ -6846,18 +6869,29 @@ static bool csr_roam_process_results(tpAniSirGlobal mac_ctx, tSmeCmd *cmd,
 			WLAN_HOST_DIAG_LOG_REPORT(ibss_log);
 		}
 #endif
+		start_bss_rsp = (tSirSmeStartBssRsp *)context;
+		qdf_mem_set(&roam_info, sizeof(roam_info), 0);
 		roam_status = eCSR_ROAM_IBSS_IND;
 		roam_result = eCSR_ROAM_RESULT_IBSS_STARTED;
 		if (CSR_IS_INFRA_AP(profile)) {
 			roam_status = eCSR_ROAM_INFRA_IND;
 			roam_result = eCSR_ROAM_RESULT_INFRA_START_FAILED;
 		}
+		if (CSR_IS_NDI(profile)) {
+			csr_roam_update_ndp_return_params(mac_ctx,
+				eCsrStartBssFailure,
+				&roam_status, &roam_result);
+			csr_roam_fill_roaminfo_ndp(mac_ctx, &roam_info,
+				roam_result,
+				(start_bss_rsp) ? start_bss_rsp->statusCode :
+				QDF_STATUS_E_FAILURE, 0, 0);
+		}
+
 		if (context) {
 			bss_desc = (tSirBssDescription *) context;
 		} else {
 			bss_desc = NULL;
 		}
-		qdf_mem_set(&roam_info, sizeof(tCsrRoamInfo), 0);
 		roam_info.pBssDesc = bss_desc;
 		csr_roam_call_callback(mac_ctx, session_id, &roam_info,
 				cmd->u.roamCmd.roamId, roam_status,
@@ -7537,13 +7571,14 @@ QDF_STATUS csr_roam_connect(tpAniSirGlobal pMac, uint32_t sessionId,
 		}
 	} else if (NULL != pProfile) {
 		/* Check whether it is for start ibss */
-		if (CSR_IS_START_IBSS(pProfile)) {
+		if (CSR_IS_START_IBSS(pProfile) ||
+		    CSR_IS_NDI(pProfile)) {
 			status = csr_roam_issue_connect(pMac, sessionId,
 					pProfile, NULL, eCsrHddIssued,
 					roamId, false, false);
 			if (!QDF_IS_STATUS_SUCCESS(status)) {
 				sms_log(pMac, LOGE,
-					FL("CSR failed to issue startIBSS cmd with status = 0x%08X"),
+					FL("Failed with status = 0x%08X"),
 					status);
 				fCallCallback = true;
 			}
@@ -8604,7 +8639,8 @@ csr_roaming_state_config_cnf_processor(tpAniSirGlobal mac_ctx,
 		bss_desc = &scan_result->Result.BssDescriptor;
 	}
 	if (csr_is_bss_type_ibss(cmd->u.roamCmd.roamProfile.BSSType)
-	    || CSR_IS_INFRA_AP(&cmd->u.roamCmd.roamProfile)) {
+	    || CSR_IS_INFRA_AP(&cmd->u.roamCmd.roamProfile)
+	    || CSR_IS_NDI(&cmd->u.roamCmd.roamProfile)) {
 		if (!QDF_IS_STATUS_SUCCESS(csr_roam_issue_start_bss(mac_ctx,
 						session_id, &session->bssParams,
 						&cmd->u.roamCmd.roamProfile,
@@ -12743,7 +12779,7 @@ QDF_STATUS csr_roam_issue_start_bss(tpAniSirGlobal pMac, uint32_t sessionId,
 	return status;
 }
 
-static void csr_roam_prepare_bss_params(tpAniSirGlobal pMac, uint32_t sessionId,
+void csr_roam_prepare_bss_params(tpAniSirGlobal pMac, uint32_t sessionId,
 					tCsrRoamProfile *pProfile,
 					tSirBssDescription *pBssDesc,
 					tBssConfigParam *pBssConfig,
@@ -12760,7 +12796,11 @@ static void csr_roam_prepare_bss_params(tpAniSirGlobal pMac, uint32_t sessionId,
 
 	if (pBssDesc) {
 		csr_roam_get_bss_start_parms_from_bss_desc(pMac, pBssDesc, pIes,
-							   &pSession->bssParams);
+							&pSession->bssParams);
+		if (CSR_IS_NDI(pProfile)) {
+			qdf_copy_macaddr(&pSession->bssParams.bssid,
+				&pSession->selfMacAddr);
+		}
 	} else {
 		csr_roam_get_bss_start_parms(pMac, pProfile, &pSession->bssParams);
 		/* Use the first SSID */

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

@@ -1070,3 +1070,16 @@ bool is_disconnect_pending(tpAniSirGlobal mac_ctx,
 void csr_scan_active_list_timeout_handle(void *userData);
 QDF_STATUS csr_prepare_disconnect_command(tpAniSirGlobal mac,
 			uint32_t session_id, tSmeCmd **sme_cmd);
+QDF_STATUS csr_roam_prepare_bss_config_from_profile(tpAniSirGlobal mac_ctx,
+		tCsrRoamProfile *profile, tBssConfigParam *bss_cfg,
+		tSirBssDescription *bss_desc);
+void csr_roam_prepare_bss_params(tpAniSirGlobal mac_ctx, uint32_t session_id,
+		tCsrRoamProfile *profile, tSirBssDescription *bss_desc,
+		tBssConfigParam *bss_cfg, tDot11fBeaconIEs *ies);
+
+QDF_STATUS csr_roam_set_bss_config_cfg(tpAniSirGlobal mac_ctx,
+		uint32_t session_id,
+		tCsrRoamProfile *profile, tSirBssDescription *bss_desc,
+		tBssConfigParam *bss_cfg, tDot11fBeaconIEs *ies,
+		bool reset_country);
+

+ 11 - 0
core/sme/src/csr/csr_util.c

@@ -1961,6 +1961,14 @@ csr_isconcurrentsession_valid(tpAniSirGlobal mac_ctx, uint32_t cur_sessionid,
 				QDF_TRACE_LEVEL_INFO,
 				FL("**P2P-Client session**"));
 			return QDF_STATUS_SUCCESS;
+		case QDF_NDI_MODE:
+			if (bss_persona != QDF_STA_MODE) {
+				QDF_TRACE(QDF_MODULE_ID_SME,
+					QDF_TRACE_LEVEL_ERROR,
+					FL("***NDI mode can co-exist only with STA ***"));
+				return QDF_STATUS_E_FAILURE;
+			}
+			break;
 		default:
 			QDF_TRACE(QDF_MODULE_ID_SME,
 				QDF_TRACE_LEVEL_ERROR,
@@ -5339,6 +5347,9 @@ tSirBssType csr_translate_bsstype_to_mac_type(eCsrRoamBssType csrtype)
 	case eCSR_BSS_TYPE_INFRA_AP:
 		ret = eSIR_INFRA_AP_MODE;
 		break;
+	case eCSR_BSS_TYPE_NDI:
+		ret = eSIR_NDI_MODE;
+		break;
 	case eCSR_BSS_TYPE_ANY:
 	default:
 		ret = eSIR_AUTO_MODE;

+ 153 - 0
core/sme/src/nan/nan_datapath_api.c

@@ -23,6 +23,11 @@
  *
  * SME NAN Data path API implementation
  */
+#include "sms_debug.h"
+#include "sme_api.h"
+#include "csr_inside_api.h"
+#include "sme_inside.h"
+#include "csr_internal.h"
 #include "sme_nan_datapath.h"
 
 /**
@@ -78,4 +83,152 @@ QDF_STATUS sme_ndp_sched_req_handler(uint32_t session_id,
 	return QDF_STATUS_SUCCESS;
 }
 
+/**
+ * csr_roam_start_ndi() - Start connection for NAN datapath
+ * @mac_ctx: Global MAC context
+ * @session: SME session ID
+ * @profile: Configuration profile
+ *
+ * Return: Success or failure code
+ */
+QDF_STATUS csr_roam_start_ndi(tpAniSirGlobal mac_ctx, uint32_t session,
+			tCsrRoamProfile *profile)
+{
+	QDF_STATUS status;
+	tBssConfigParam bss_cfg = {0};
+
+	/* Build BSS configuration from profile */
+	status = csr_roam_prepare_bss_config_from_profile(mac_ctx, profile,
+						    &bss_cfg, NULL);
+	if (QDF_IS_STATUS_SUCCESS(status)) {
+		mac_ctx->roam.roamSession[session].bssParams.uCfgDot11Mode
+			= bss_cfg.uCfgDot11Mode;
+		/* Copy profile parameters to PE session */
+		csr_roam_prepare_bss_params(mac_ctx, session, profile, NULL,
+			&bss_cfg, NULL);
+		/*
+		 * Following routine will eventually call
+		 * csrRoamIssueStartBss through csrRoamCcmCfgSetCallback
+		 */
+		status = csr_roam_set_bss_config_cfg(mac_ctx, session, profile,
+						NULL, &bss_cfg, NULL, false);
+	}
+
+	if (QDF_IS_STATUS_SUCCESS(status))
+		sms_log(mac_ctx, LOG1, FL("Profile config is valid"));
+	else
+		sms_log(mac_ctx, LOGE,
+			FL("Profile config is invalid. status = 0x%x"), status);
+
+	return status;
+}
+
+/**
+ * csr_roam_fill_roaminfo_ndp() - fill the ndi create struct inside roam info
+ * @mac_ctx: Global MAC context
+ * @roam_info: roam info to be updated with ndi create params
+ * @roam_result: roam result to update
+ * @status_code: status code to update
+ * @reason_code: reason code to update
+ * @transaction_id: transcation id to update
+ *
+ * Return: None
+ */
+void csr_roam_fill_roaminfo_ndp(tpAniSirGlobal mac_ctx,
+		tCsrRoamInfo *roam_info,
+		eCsrRoamResult roam_result,
+		tSirResultCodes status_code,
+		uint32_t reason_code,
+		uint32_t transaction_id)
+{
+	struct ndi_create_rsp *rsp_params;
+
+	sms_log(mac_ctx, LOG1,
+		FL("reason 0x%x, status 0x%x, transaction_id %d"),
+		reason_code, status_code, transaction_id);
+	rsp_params = (struct ndi_create_rsp *)
+			&roam_info->ndp.ndi_create_params;
+	rsp_params->reason = reason_code;
+	rsp_params->status = status_code;
+	rsp_params->transaction_id = transaction_id;
+}
 
+/**
+ * csr_roam_save_ndi_connected_info() - Save connected profile parameters
+ * @mac_ctx: Global MAC context
+ * @session_id: Session ID
+ * @roam_profile: Profile given for starting BSS
+ * @bssdesc: BSS description from tSirSmeStartBssRsp response
+ *
+ * Saves NDI profile parameters into session's connected profile.
+ *
+ * Return: None
+ */
+void csr_roam_save_ndi_connected_info(tpAniSirGlobal mac_ctx,
+				      uint32_t session_id,
+				      tCsrRoamProfile *roam_profile,
+				      tSirBssDescription *bssdesc)
+{
+	tCsrRoamSession *roam_session = NULL;
+	tCsrRoamConnectedProfile *connect_profile = NULL;
+
+	roam_session = CSR_GET_SESSION(mac_ctx, session_id);
+	if (NULL == roam_session) {
+		QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
+			FL("session %d not found"), session_id);
+		return;
+	}
+
+	connect_profile = &roam_session->connectedProfile;
+	qdf_mem_set(&roam_session->connectedProfile,
+		sizeof(connect_profile), 0);
+	connect_profile->AuthType = roam_profile->negotiatedAuthType;
+		connect_profile->AuthInfo = roam_profile->AuthType;
+	connect_profile->CBMode = roam_profile->CBMode;
+	connect_profile->EncryptionType =
+		roam_profile->negotiatedUCEncryptionType;
+		connect_profile->EncryptionInfo = roam_profile->EncryptionType;
+	connect_profile->mcEncryptionType =
+		roam_profile->negotiatedMCEncryptionType;
+		connect_profile->mcEncryptionInfo =
+			roam_profile->mcEncryptionType;
+	connect_profile->BSSType = roam_profile->BSSType;
+	connect_profile->modifyProfileFields.uapsd_mask =
+		roam_profile->uapsd_mask;
+	connect_profile->operationChannel = bssdesc->channelId;
+	connect_profile->beaconInterval = 0;
+	qdf_mem_copy(&connect_profile->Keys, &roam_profile->Keys,
+		sizeof(roam_profile->Keys));
+	csr_get_bss_id_bss_desc(mac_ctx, bssdesc, &connect_profile->bssid);
+	connect_profile->SSID.length = 0;
+	csr_free_connect_bss_desc(mac_ctx, session_id);
+	connect_profile->qap = false;
+	connect_profile->qosConnection = false;
+}
+
+/**
+ * csr_roam_update_ndp_return_params() - updates ndp return parameters
+ * @mac_ctx: MAC context handle
+ * @result: result of the roaming command
+ * @roam_status: roam status returned to the roam command initiator
+ * @roam_result: roam result returned to the roam command initiator
+ *
+ * Results: None
+ */
+void csr_roam_update_ndp_return_params(tpAniSirGlobal mac_ctx,
+					uint32_t result,
+					uint32_t *roam_status,
+					uint32_t *roam_result)
+{
+	switch (result) {
+	case eCsrStartBssSuccess:
+	case eCsrStartBssFailure:
+		*roam_status = eCSR_ROAM_NDP_STATUS_UPDATE;
+		*roam_result = eCSR_ROAM_RESULT_NDP_CREATE_RSP;
+		break;
+	default:
+		sms_log(mac_ctx, LOGE,
+			FL("Invalid CSR Roam result code: %d"), result);
+		break;
+	}
+}

+ 1 - 0
core/wma/inc/wma.h

@@ -48,6 +48,7 @@
 #include "lim_types.h"
 #include "wmi_unified_api.h"
 #include "cdp_txrx_cmn.h"
+#include "ol_defines.h"
 
 /* Platform specific configuration for max. no. of fragments */
 #define QCA_OL_11AC_TX_MAX_FRAGS            2

+ 4 - 0
core/wma/inc/wma_internal.h

@@ -28,6 +28,10 @@
 #ifndef WMA_INTERNAL_H
 #define WMA_INTERNAL_H
 
+#if !defined(REMOVE_PKT_LOG)
+#include "pktlog_ac.h"
+#endif
+
 /* ################### defines ################### */
 /*
  * TODO: Following constant should be shared by firwmare in

+ 10 - 1
core/wma/src/wma_dev_if.c

@@ -76,6 +76,7 @@
 
 
 #include "cds_concurrency.h"
+#include "wma_nan_datapath.h"
 
 /**
  * wma_find_vdev_by_addr() - find vdev_id from mac address
@@ -210,6 +211,9 @@ enum wlan_op_mode wma_get_txrx_vdev_type(uint32_t type)
 	case WMI_VDEV_TYPE_MONITOR:
 		vdev_type = wlan_op_mode_monitor;
 		break;
+	case WMI_VDEV_TYPE_NDI:
+		vdev_type = wlan_op_mode_ndi;
+		break;
 	default:
 		WMA_LOGE("Invalid vdev type %u", type);
 		vdev_type = wlan_op_mode_unknown;
@@ -1584,7 +1588,8 @@ ol_txrx_vdev_handle wma_vdev_attach(tp_wma_handle wma_handle,
 	if (((self_sta_req->type == WMI_VDEV_TYPE_AP) &&
 	    (self_sta_req->sub_type == WMI_UNIFIED_VDEV_SUBTYPE_P2P_DEVICE)) ||
 	    (self_sta_req->type == WMI_VDEV_TYPE_OCB) ||
-	    (self_sta_req->type == WMI_VDEV_TYPE_MONITOR)) {
+	    (self_sta_req->type == WMI_VDEV_TYPE_MONITOR) ||
+	    (self_sta_req->type == WMI_VDEV_TYPE_NDI)) {
 		WMA_LOGA("Creating self peer %pM, vdev_id %hu",
 			 self_sta_req->self_mac_addr, self_sta_req->session_id);
 		status = wma_create_peer(wma_handle, txrx_pdev,
@@ -3286,6 +3291,10 @@ void wma_add_bss(tp_wma_handle wma, tpAddBssParams params)
 		break;
 #endif
 
+	case QDF_NDI_MODE:
+		wma_add_bss_ndi_mode(wma, params);
+		break;
+
 	default:
 		wma_add_bss_sta_mode(wma, params);
 		break;

+ 92 - 1
core/wma/src/wma_nan_datapath.c

@@ -24,8 +24,12 @@
  * WMA NAN Data path API implementation
  */
 
+#include "wma.h"
+#include "wma_api.h"
+#include "wmi_unified_api.h"
+#include "wmi_unified.h"
 #include "wma_nan_datapath.h"
-
+#include "wma_internal.h"
 
 /**
  * wma_handle_ndp_initiator_req() - NDP initiator request handler
@@ -162,3 +166,90 @@ QDF_STATUS wma_ndp_sched_update_rsp_event_handler(void *handle,
 {
 	return QDF_STATUS_SUCCESS;
 }
+
+/**
+ * wma_add_bss_ndi_mode() - Process BSS creation request while adding NaN
+ * Data interface
+ * @wma: wma handle
+ * @add_bss: Parameters for ADD_BSS command
+ *
+ * Sends VDEV_START command to firmware
+ * Return: None
+ */
+void wma_add_bss_ndi_mode(tp_wma_handle wma, tpAddBssParams add_bss)
+{
+	ol_txrx_pdev_handle pdev;
+	struct wma_vdev_start_req req;
+	ol_txrx_peer_handle peer = NULL;
+	struct wma_target_req *msg;
+	u_int8_t vdev_id, peer_id;
+	QDF_STATUS status;
+	struct vdev_set_params param = {0};
+
+	WMA_LOGI("%s: enter", __func__);
+	if (NULL == wma_find_vdev_by_addr(wma, add_bss->bssId, &vdev_id)) {
+		WMA_LOGE("%s: Failed to find vdev", __func__);
+		goto send_fail_resp;
+	}
+	pdev = cds_get_context(QDF_MODULE_ID_TXRX);
+
+	if (pdev) {
+		WMA_LOGE("%s: Failed to get pdev", __func__);
+		goto send_fail_resp;
+	}
+
+	wma_set_bss_rate_flags(&wma->interfaces[vdev_id], add_bss);
+
+	peer = ol_txrx_find_peer_by_addr(pdev, add_bss->selfMacAddr, &peer_id);
+	if (!peer) {
+		WMA_LOGE("%s Failed to find peer %pM", __func__,
+			add_bss->selfMacAddr);
+		goto send_fail_resp;
+	}
+
+	msg = wma_fill_vdev_req(wma, vdev_id, WMA_ADD_BSS_REQ,
+			WMA_TARGET_REQ_TYPE_VDEV_START, add_bss,
+			WMA_VDEV_START_REQUEST_TIMEOUT);
+	if (!msg) {
+		WMA_LOGE("%s Failed to allocate vdev request vdev_id %d",
+			 __func__, vdev_id);
+		goto send_fail_resp;
+	}
+
+	add_bss->staContext.staIdx = ol_txrx_local_peer_id(peer);
+
+	/*
+	 * beacon_intval, dtim_period, hidden_ssid, is_dfs, ssid
+	 * will be ignored for NDI device.
+	 */
+	qdf_mem_zero(&req, sizeof(req));
+	req.vdev_id = vdev_id;
+	req.chan = add_bss->currentOperChannel;
+	req.ch_center_freq_seg0 = add_bss->ch_center_freq_seg0;
+	req.ch_center_freq_seg1 = add_bss->ch_center_freq_seg1;
+	req.vht_capable = add_bss->vhtCapable;
+	req.max_txpow = add_bss->maxTxPower;
+	req.oper_mode = add_bss->operMode;
+
+	status = wma_vdev_start(wma, &req, false);
+	if (status != QDF_STATUS_SUCCESS) {
+		wma_remove_vdev_req(wma, vdev_id,
+			WMA_TARGET_REQ_TYPE_VDEV_START);
+		goto send_fail_resp;
+	}
+	WMA_LOGI("%s: vdev start request for NDI sent to target", __func__);
+
+	/* Initialize protection mode to no protection */
+	param.if_id = vdev_id;
+	param.param_id = WMI_VDEV_PARAM_PROTECTION_MODE;
+	param.param_value = WMI_VDEV_PARAM_PROTECTION_MODE;
+	if (wmi_unified_vdev_set_param_send(wma->wmi_handle, &param))
+		WMA_LOGE("Failed to initialize protection mode");
+
+
+	return;
+send_fail_resp:
+	add_bss->status = QDF_STATUS_E_FAILURE;
+	wma_send_msg(wma, WMA_ADD_BSS_RSP, (void *)add_bss, 0);
+}
+

+ 7 - 0
core/wma/src/wma_nan_datapath.h

@@ -32,6 +32,8 @@
 
 #ifdef WLAN_FEATURE_NAN_DATAPATH
 
+void wma_add_bss_ndi_mode(tp_wma_handle wma, tpAddBssParams add_bss);
+
 /**
  * wma_update_hdd_cfg_ndp() - Update target device NAN datapath capability
  * @wma_handle: pointer to WMA context
@@ -51,6 +53,11 @@ static inline void wma_update_hdd_cfg_ndp(tp_wma_handle wma_handle,
 {
 	return;
 }
+static inline void wma_add_bss_ndi_mode(tp_wma_handle wma,
+					tpAddBssParams add_bss)
+{
+	return;
+}
 
 #endif /* WLAN_FEATURE_NAN_DATAPATH */