Browse Source

qcacld-3.0: Add vdev state machine for IBSS

Add support for VDEV state machine support for IBSS join, leave and
coalesce.

Change-Id: Iaf93f1a1b92f63b35add2f98146f4af12dc09d9c
CRs-Fixed: 2330961
Rajeev Kumar Sirasanagandla 6 years ago
parent
commit
2f17f8d2fd

+ 44 - 16
core/mac/src/pe/lim/lim_ibss_peer_mgmt.c

@@ -476,7 +476,7 @@ ibss_status_chg_notify(tpAniSirGlobal pMac, tSirMacAddr peerAddr,
 	}
 }
 
-static void ibss_bss_add(tpAniSirGlobal pMac, tpPESession psessionEntry)
+void ibss_bss_add(tpAniSirGlobal pMac, tpPESession psessionEntry)
 {
 	tLimMlmStartReq mlmStartReq;
 	uint32_t cfg;
@@ -569,11 +569,17 @@ static void ibss_bss_add(tpAniSirGlobal pMac, tpPESession psessionEntry)
 		     psessionEntry->pLimStartBssReq->ssId.length + 1);
 
 	pe_debug("invoking ADD_BSS as part of coalescing!");
+#ifdef CONFIG_VDEV_SM
+	wlan_vdev_mlme_sm_deliver_evt(psessionEntry->vdev,
+				      WLAN_VDEV_SM_EV_START,
+				      sizeof(mlmStartReq), &mlmStartReq);
+#else
 	if (lim_mlm_add_bss(pMac, &mlmStartReq, psessionEntry) !=
 	    eSIR_SME_SUCCESS) {
 		pe_err("AddBss failure");
 		return;
 	}
+#endif
 	/* Update fields in Beacon */
 	if (sch_set_fixed_beacon_fields(pMac, psessionEntry) != QDF_STATUS_SUCCESS) {
 		pe_err("Unable to set fixed Beacon fields");
@@ -582,21 +588,19 @@ static void ibss_bss_add(tpAniSirGlobal pMac, tpPESession psessionEntry)
 
 }
 
-/* delete the current BSS */
-static void ibss_bss_delete(tpAniSirGlobal pMac, tpPESession psessionEntry)
+void ibss_bss_delete(tpAniSirGlobal mac_ctx, tpPESession session)
 {
 	QDF_STATUS status;
 
 	pe_debug("Initiating IBSS Delete BSS");
-	if (psessionEntry->limMlmState != eLIM_MLM_BSS_STARTED_STATE) {
+	if (session->limMlmState != eLIM_MLM_BSS_STARTED_STATE) {
 		pe_warn("Incorrect LIM MLM state for delBss: %d",
-			psessionEntry->limMlmState);
+			session->limMlmState);
 		return;
 	}
-	status = lim_del_bss(pMac, NULL, psessionEntry->bssIdx, psessionEntry);
-	if (status != QDF_STATUS_SUCCESS)
-		pe_err("delBss failed for bss: %d",
-			       psessionEntry->bssIdx);
+	status = lim_del_bss(mac_ctx, NULL, session->bssIdx, session);
+	if (QDF_IS_STATUS_ERROR(status))
+		pe_err("delBss failed for bss: %d", session->bssIdx);
 }
 
 /**
@@ -641,13 +645,15 @@ void lim_ibss_init(tpAniSirGlobal pMac)
  * @param  pMac - Pointer to Global MAC structure
  * @return None
  */
-
-static void lim_ibss_delete_all_peers(tpAniSirGlobal pMac,
-				      tpPESession psessionEntry)
+void lim_ibss_delete_all_peers(tpAniSirGlobal pMac,
+			       tpPESession psessionEntry)
 {
 	tLimIbssPeerNode *pCurrNode, *pTempNode;
 	tpDphHashNode pStaDs;
 	uint16_t peerIdx;
+#ifdef CONFIG_VDEV_SM
+	QDF_STATUS status;
+#endif
 
 	pCurrNode = pTempNode = pMac->lim.gLimIbssPeerList;
 
@@ -669,6 +675,7 @@ static void lim_ibss_delete_all_peers(tpAniSirGlobal pMac,
 					       pStaDs->staIndex,
 					       eWNI_SME_IBSS_PEER_DEPARTED_IND,
 					       psessionEntry->smeSessionId);
+			lim_del_sta(pMac, pStaDs, false, psessionEntry);
 			lim_release_peer_idx(pMac, peerIdx, psessionEntry);
 			dph_delete_hash_entry(pMac, pStaDs->staAddr, peerIdx,
 					      &psessionEntry->dph.dphHashTable);
@@ -700,7 +707,18 @@ static void lim_ibss_delete_all_peers(tpAniSirGlobal pMac,
 
 	pMac->lim.gLimNumIbssPeers = 0;
 	pMac->lim.gLimIbssPeerList = NULL;
-
+#ifdef CONFIG_VDEV_SM
+	status =
+	   wlan_vdev_mlme_sm_deliver_evt(psessionEntry->vdev,
+					 WLAN_VDEV_SM_EV_DISCONNECT_COMPLETE,
+					 sizeof(*psessionEntry), psessionEntry);
+	if (!pMac->lim.gLimIbssCoalescingHappened &&
+	    QDF_IS_STATUS_ERROR(status)) {
+		pe_err("failed to post WLAN_VDEV_SM_EV_DISCONNECT_COMPLETE for vdevid %d",
+		       psessionEntry->smeSessionId);
+		lim_send_stop_bss_failure_resp(pMac, psessionEntry);
+	}
+#endif
 }
 
 /**
@@ -714,7 +732,9 @@ static void lim_ibss_delete_all_peers(tpAniSirGlobal pMac,
 
 void lim_ibss_delete(tpAniSirGlobal pMac, tpPESession psessionEntry)
 {
+#ifndef CONFIG_VDEV_SM
 	lim_ibss_delete_all_peers(pMac, psessionEntry);
+#endif
 	ibss_coalesce_free(pMac);
 }
 
@@ -1227,12 +1247,13 @@ void lim_ibss_del_bss_rsp_when_coalescing(tpAniSirGlobal pMac, void *msg,
 			pDelBss->status, pDelBss->bssIdx);
 		goto end;
 	}
+
+#ifndef CONFIG_VDEV_SM
 	/* Delete peer entries. */
 	lim_ibss_delete_all_peers(pMac, psessionEntry);
-
+#endif
 	/* add the new bss */
 	ibss_bss_add(pMac, psessionEntry);
-
 end:
 	if (pDelBss != NULL)
 		qdf_mem_free(pDelBss);
@@ -1271,7 +1292,7 @@ void lim_ibss_add_bss_rsp_when_coalescing(tpAniSirGlobal pMac, void *msg,
 					  infoLen, pSessionEntry->smeSessionId);
 	{
 		/* Configure beacon and send beacons to HAL */
-		lim_send_beacon_ind(pMac, pSessionEntry);
+		lim_send_beacon(pMac, pSessionEntry);
 	}
 
 end:
@@ -1430,7 +1451,14 @@ lim_ibss_coalesce(tpAniSirGlobal pMac,
 		ibss_coalesce_save(pMac, pHdr, pBeacon);
 		pe_debug("IBSS Coalescing happened Delete BSSID :" MAC_ADDRESS_STR,
 			MAC_ADDR_ARRAY(currentBssId));
+#ifdef CONFIG_VDEV_SM
+		wlan_vdev_mlme_sm_deliver_evt(psessionEntry->vdev,
+					      WLAN_VDEV_SM_EV_DOWN,
+					      sizeof(*psessionEntry),
+					      psessionEntry);
+#else
 		ibss_bss_delete(pMac, psessionEntry);
+#endif
 		return QDF_STATUS_SUCCESS;
 	} else {
 		if (qdf_mem_cmp

+ 27 - 0
core/mac/src/pe/lim/lim_ibss_peer_mgmt.h

@@ -30,6 +30,33 @@
 #include "sir_common.h"
 #include "lim_utils.h"
 
+/**
+ * ibss_bss_delete()- start the ibss
+ * @mac_ctx: Pointer to Global MAC structure
+ * @session: pe session
+ *
+ * Return: None
+ */
+void ibss_bss_add(tpAniSirGlobal mac_ctx, tpPESession session);
+
+/**
+ * ibss_bss_delete()- delete the current BSS
+ * @mac_ctx: Pointer to Global MAC structure
+ * @session: pe session
+ *
+ * Return: None
+ */
+void ibss_bss_delete(tpAniSirGlobal mac_ctx, tpPESession session);
+
+/**
+ * lim_ibss_delete_all_peers: delete all IBSS peers.
+ * @mac_ctx: Pointer to Global MAC structure
+ * @session: pe session
+ *
+ * Return: None
+ */
+void lim_ibss_delete_all_peers(tpAniSirGlobal mac_ctx, tpPESession session);
+
 void lim_ibss_init(tpAniSirGlobal);
 void lim_ibss_delete(tpAniSirGlobal, tpPESession psessionEntry);
 QDF_STATUS lim_ibss_coalesce(tpAniSirGlobal, tpSirMacMgmtHdr,

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

@@ -676,9 +676,6 @@ end:
 	/* Update PE session Id */
 	mlm_start_cnf.sessionId = mlm_start_req->sessionId;
 
-	/* Free up buffer allocated for LimMlmScanReq */
-	qdf_mem_free(mlm_start_req);
-
 	/*
 	 * Respond immediately to LIM, only if MLME has not been
 	 * successfully able to send WMA_ADD_BSS_REQ to HAL.

+ 3 - 9
core/mac/src/pe/lim/lim_process_sme_req_messages.c

@@ -1065,6 +1065,7 @@ __lim_handle_sme_start_bss_request(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
 		qdf_status = lim_send_start_vdev_req(session, mlm_start_req);
 		if (QDF_IS_STATUS_ERROR(qdf_status))
 			goto free;
+		qdf_mem_free(mlm_start_req);
 		return;
 	} else {
 
@@ -2892,15 +2893,8 @@ static void __lim_counter_measures(tpAniSirGlobal pMac, tpPESession psessionEntr
 					     mac, psessionEntry, false);
 };
 
-/**
- * lim_send_stop_bss_failure_resp() -send failure delete bss resp to sme
- * @mac_ctx: mac ctx
- * @session: session pointer
- *
- * Return None
- */
-static void lim_send_stop_bss_failure_resp(tpAniSirGlobal mac_ctx,
-					   tpPESession session)
+void lim_send_stop_bss_failure_resp(tpAniSirGlobal mac_ctx,
+				    tpPESession session)
 {
 	session->limSmeState = session->limPrevSmeState;
 

+ 52 - 5
core/mac/src/pe/lim/lim_utils.c

@@ -8471,17 +8471,40 @@ void lim_send_beacon(tpAniSirGlobal mac_ctx, tpPESession session)
 QDF_STATUS lim_ap_mlme_vdev_start_send(struct vdev_mlme_obj *vdev_mlme,
 				       uint16_t data_len, void *data)
 {
+	tpPESession session;
+	tSirResultCodes ret;
+	tpLimMlmStartReq start_req = (tLimMlmStartReq *)data;
 	tpAniSirGlobal mac_ctx;
 
+	if (!data) {
+		pe_err("data is NULL");
+		return QDF_STATUS_E_INVAL;
+	}
+
 	mac_ctx = cds_get_context(QDF_MODULE_ID_PE);
 	if (!mac_ctx) {
 		pe_err("mac_ctx is NULL");
-		if (data)
-			qdf_mem_free(data);
 		return QDF_STATUS_E_INVAL;
 	}
 
-	lim_process_mlm_start_req(mac_ctx, (tLimMlmStartReq *)data);
+	session = pe_find_session_by_session_id(mac_ctx,
+						start_req->sessionId);
+	if (!session) {
+		pe_err("session is NULL");
+		return QDF_STATUS_E_INVAL;
+	}
+
+	if (LIM_IS_IBSS_ROLE(session) &&
+	    session->mac_ctx->lim.gLimIbssCoalescingHappened) {
+		ibss_bss_add(session->mac_ctx, session);
+		ret = lim_mlm_add_bss(session->mac_ctx, start_req, session);
+		if (ret != eSIR_SME_SUCCESS) {
+			pe_err("AddBss failure");
+			return QDF_STATUS_E_INVAL;
+		}
+	} else {
+		lim_process_mlm_start_req(session->mac_ctx, start_req);
+	}
 
 	return QDF_STATUS_SUCCESS;
 }
@@ -8546,7 +8569,17 @@ QDF_STATUS lim_ap_mlme_vdev_up_send(struct vdev_mlme_obj *vdev_mlme,
 QDF_STATUS lim_ap_mlme_vdev_disconnect_peers(struct vdev_mlme_obj *vdev_mlme,
 					     uint16_t data_len, void *data)
 {
-	lim_delete_all_peers((tpPESession)data);
+	tpPESession session = (tpPESession)data;
+
+	if (!data) {
+		pe_err("data is NULL");
+		return QDF_STATUS_E_INVAL;
+	}
+
+	if (LIM_IS_IBSS_ROLE(session))
+		lim_ibss_delete_all_peers(session->mac_ctx, session);
+	else
+		lim_delete_all_peers(session);
 
 	return QDF_STATUS_SUCCESS;
 }
@@ -8554,7 +8587,21 @@ QDF_STATUS lim_ap_mlme_vdev_disconnect_peers(struct vdev_mlme_obj *vdev_mlme,
 QDF_STATUS lim_ap_mlme_vdev_stop_send(struct vdev_mlme_obj *vdev_mlme,
 				      uint16_t data_len, void *data)
 {
-	return lim_send_vdev_stop((tpPESession)data);
+	tpPESession session = (tpPESession)data;
+	QDF_STATUS status = QDF_STATUS_SUCCESS;
+
+	if (!data) {
+		pe_err("data is NULL");
+		return QDF_STATUS_E_INVAL;
+	}
+
+	if (LIM_IS_IBSS_ROLE(session) &&
+	    session->mac_ctx->lim.gLimIbssCoalescingHappened)
+		ibss_bss_delete(session->mac_ctx, session);
+	else
+		status =  lim_send_vdev_stop(session);
+
+	return status;
 }
 
 QDF_STATUS lim_ap_mlme_vdev_restart_send(struct vdev_mlme_obj *vdev_mlme,

+ 10 - 0
core/mac/src/pe/lim/lim_utils.h

@@ -1365,6 +1365,16 @@ void lim_send_dfs_chan_sw_ie_update(tpAniSirGlobal mac_ctx,
  */
 void lim_process_ap_ecsa_timeout(void *session);
 
+/**
+ * lim_send_stop_bss_failure_resp() -send failure delete bss resp to sme
+ * @mac_ctx: mac ctx
+ * @session: session pointer
+ *
+ * Return None
+ */
+void lim_send_stop_bss_failure_resp(tpAniSirGlobal mac_ctx,
+				    tpPESession session);
+
 /**
  * lim_delete_all_peers() -delete all connected peers
  * @session: session pointer