Ver Fonte

qcacld-3.0: Replace the CSR API with connection mgr API

Replace the CSR API to get connect info with cnx mgr API.

Change-Id: Ia037016a6eab0fd4ebec6cbbb991ff255b43bb2d
CRs-Fixed: 2847585
gaurank kathpalia há 4 anos atrás
pai
commit
deceac79c3

+ 9 - 1
components/umac/mlme/connection_mgr/core/src/wlan_cm_vdev_api.h

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012-2015, 2020, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2012-2015, 2020-2021, The Linux Foundation. All rights reserved.
  *
  * Permission to use, copy, modify, and/or distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above
@@ -178,6 +178,14 @@ QDF_STATUS
 cm_csr_connect_done_ind(struct wlan_objmgr_vdev *vdev,
 			struct wlan_cm_connect_resp *rsp);
 
+/**
+ * cm_is_vdevid_connected() - check if vdev_id is in conneted state
+ * @vdev: vdev pointer
+ *
+ * Return: bool
+ */
+bool cm_is_vdevid_connected(struct wlan_objmgr_pdev *pdev, uint8_t vdev_id);
+
 /**
  * cm_disconnect_start_ind() - Connection manager ext disconnect start
  * indication

+ 19 - 1
components/umac/mlme/connection_mgr/core/src/wlan_cm_vdev_connect.c

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012-2015, 2020, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2012-2015, 2020-2021, The Linux Foundation. All rights reserved.
  *
  * Permission to use, copy, modify, and/or distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above
@@ -286,3 +286,21 @@ void wlan_cm_free_connect_rsp(struct cm_vdev_join_rsp *rsp)
 	qdf_mem_zero(rsp, sizeof(*rsp));
 	qdf_mem_free(rsp);
 }
+
+bool cm_is_vdevid_connected(struct wlan_objmgr_pdev *pdev, uint8_t vdev_id)
+{
+	struct wlan_objmgr_vdev *vdev;
+	bool connected;
+
+	vdev = wlan_objmgr_get_vdev_by_id_from_pdev(pdev, vdev_id,
+						    WLAN_MLME_CM_ID);
+	if (!vdev) {
+		mlme_err("vdev_id: %d: vdev not found", vdev_id);
+		return false;
+	}
+
+	connected = cm_is_vdev_connected(vdev);
+	wlan_objmgr_vdev_release_ref(vdev, WLAN_MLME_CM_ID);
+
+	return connected;
+}

+ 10 - 22
core/sme/inc/csr_internal.h

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2020 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2011-2021 The Linux Foundation. All rights reserved.
  *
  * Permission to use, copy, modify, and/or distribute this software for
  * any purpose with or without fee is hereby granted, provided that the
@@ -102,8 +102,6 @@ enum csr_scan_reason {
 enum csr_roam_reason {
 	/* Roaming because we've not established the initial connection. */
 	eCsrNoConnection,
-	/* roaming because LIM reported a cap change in the associated AP. */
-	eCsrCapsChange,
 #ifndef FEATURE_CM_ENABLE
 	/* roaming because someone asked us to Disassoc & stay disassociated. */
 	eCsrForcedDisassoc,
@@ -854,13 +852,14 @@ void csr_set_global_cfgs(struct mac_context *mac);
 void csr_set_default_dot11_mode(struct mac_context *mac);
 bool csr_is_conn_state_disconnected(struct mac_context *mac,
 						   uint32_t sessionId);
-bool csr_is_conn_state_connected_infra(struct mac_context *mac,
-							uint32_t sessionId);
 bool csr_is_conn_state_connected(struct mac_context *mac,
 					       uint32_t sessionId);
+#ifndef FEATURE_CM_ENABLE
+bool csr_is_conn_state_connected_infra(struct mac_context *mac,
+							uint32_t sessionId);
 bool csr_is_conn_state_infra(struct mac_context *mac,
 					uint32_t sessionId);
-
+#endif
 bool csr_is_conn_state_wds(struct mac_context *mac, uint32_t sessionId);
 bool csr_is_conn_state_connected_wds(struct mac_context *mac,
 						    uint32_t sessionId);
@@ -869,17 +868,6 @@ bool csr_is_conn_state_disconnected_wds(struct mac_context *mac,
 bool csr_is_any_session_in_connect_state(struct mac_context *mac);
 bool csr_is_all_session_disconnected(struct mac_context *mac);
 
-/**
- * csr_get_connected_infra() - get the session id of the connected infra
- * @mac_ctx:  pointer to global mac structure
- *
- * The function check if any infra is present in connected state and if present
- * return the session id of the connected infra else if no infra is in connected
- * state return WLAN_UMAC_VDEV_ID_MAX
- *
- * Return: session id of the connected infra
- */
-uint8_t csr_get_connected_infra(struct mac_context *mac_ctx);
 bool csr_is_concurrent_session_running(struct mac_context *mac);
 bool csr_is_infra_ap_started(struct mac_context *mac);
 bool csr_is_valid_mc_concurrent_session(struct mac_context *mac,
@@ -913,18 +901,18 @@ void csr_set_cfg_privacy(struct mac_context *mac,
 			 bool fPrivacy);
 
 /**
- * csr_get_infra_operation_chan_freq() - get operating chan freq of
+ * csr_get_operation_chan_freq() - get operating chan freq of
  * given vdev id
  * @mac_ctx: Pointer to mac context
+ * @vdev: vdev
  * @vdev_id: vdev id
  *
  * Return: chan freq of given vdev id
  */
-uint32_t csr_get_infra_operation_chan_freq(
-	struct mac_context *mac, uint8_t vdev_id);
+qdf_freq_t csr_get_operation_chan_freq(struct mac_context *mac,
+				       struct wlan_objmgr_vdev *vdev,
+				       uint8_t vdev_id);
 
-bool csr_is_session_client_and_connected(struct mac_context *mac,
-		uint8_t sessionId);
 /**
  * csr_get_concurrent_operation_freq() - To get concurrent operating freq
  * @mac_ctx: Pointer to mac context

+ 75 - 24
core/sme/src/common/sme_api.c

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012-2020 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2012-2021 The Linux Foundation. All rights reserved.
  *
  * Permission to use, copy, modify, and/or distribute this software for
  * any purpose with or without fee is hereby granted, provided that the
@@ -5450,27 +5450,40 @@ static bool sme_search_in_base_ch_freq_lst(
 static void sme_disconnect_connected_sessions(struct mac_context *mac_ctx,
 					      enum wlan_reason_code reason)
 {
-	uint8_t session_id, found = false;
-	uint32_t chan_freq;
+	uint8_t vdev_id, found = false;
+	qdf_freq_t chan_freq;
+	struct wlan_objmgr_vdev *vdev;
+	enum QDF_OPMODE op_mode;
 
-	for (session_id = 0; session_id < WLAN_MAX_VDEVS; session_id++) {
-		if (!csr_is_session_client_and_connected(mac_ctx, session_id))
+	for (vdev_id = 0; vdev_id < WLAN_MAX_VDEVS; vdev_id++) {
+		vdev = wlan_objmgr_get_vdev_by_id_from_pdev(mac_ctx->pdev,
+							    vdev_id,
+							    WLAN_LEGACY_MAC_ID);
+		if (!vdev)
+			continue;
+		op_mode = wlan_vdev_mlme_get_opmode(vdev);
+		/* check only for STA and CLI */
+		if (op_mode != QDF_STA_MODE && op_mode != QDF_P2P_CLIENT_MODE) {
+			wlan_objmgr_vdev_release_ref(vdev, WLAN_LEGACY_MAC_ID);
+			continue;
+		}
+		chan_freq = csr_get_operation_chan_freq(mac_ctx, vdev, vdev_id);
+		wlan_objmgr_vdev_release_ref(vdev, WLAN_LEGACY_MAC_ID);
+		if (!chan_freq)
 			continue;
 		found = false;
-		/* Session is connected.Check the channel */
-		chan_freq = csr_get_infra_operation_chan_freq(
-					mac_ctx, session_id);
-		sme_debug("Current Operating channel : %d, session :%d",
-			  chan_freq, session_id);
+		sme_debug("Current Operating channel : %d, vdev_id :%d",
+			  chan_freq, vdev_id);
 		found = sme_search_in_base_ch_freq_lst(mac_ctx, chan_freq);
 		if (!found) {
-			sme_debug("Disconnect Session: %d", session_id);
+			sme_debug("Disconnect Session: %d", vdev_id);
 			/* This is temp ifdef will be removed in near future */
 #ifdef FEATURE_CM_ENABLE
-			cm_disconnect(mac_ctx->psoc, session_id,
+			cm_disconnect(mac_ctx->psoc, vdev_id,
 				      CM_MLME_DISCONNECT, reason, NULL);
 #else
-			csr_roam_disconnect(mac_ctx, session_id,
+			sme_debug("Disconnect Session: %d", vdev_id);
+			csr_roam_disconnect(mac_ctx, vdev_id,
 					    eCSR_DISCONNECT_REASON_UNSPECIFIED,
 					    reason);
 #endif
@@ -5495,8 +5508,13 @@ QDF_STATUS sme_8023_multicast_list(mac_handle_t mac_handle, uint8_t sessionId,
 	/* Find the connected Infra / P2P_client connected session */
 	pSession = CSR_GET_SESSION(mac, sessionId);
 	if (!CSR_IS_SESSION_VALID(mac, sessionId) ||
-			(!csr_is_conn_state_infra(mac, sessionId) &&
-			 !csr_is_ndi_started(mac, sessionId))) {
+	/* This is temp ifdef will be removed in near future */
+#ifdef FEATURE_CM_ENABLE
+	    (!cm_is_vdevid_connected(mac->pdev, sessionId) &&
+#else
+	    (!csr_is_conn_state_infra(mac, sessionId) &&
+#endif
+	     !csr_is_ndi_started(mac, sessionId))) {
 		QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
 			  "%s: Unable to find the session Id: %d", __func__,
 			  sessionId);
@@ -5507,14 +5525,24 @@ QDF_STATUS sme_8023_multicast_list(mac_handle_t mac_handle, uint8_t sessionId,
 	if (!request_buf)
 		return QDF_STATUS_E_NOMEM;
 
+	/* This is temp ifdef will be removed in near future */
+#ifdef FEATURE_CM_ENABLE
+	if (!cm_is_vdevid_connected(mac->pdev, sessionId) &&
+	    !csr_is_ndi_started(mac, sessionId)) {
+		sme_err("Request ignored, session %d is not connected or started",
+			sessionId);
+		qdf_mem_free(request_buf);
+		return QDF_STATUS_E_FAILURE;
+	}
+#else
 	if (!csr_is_conn_state_connected_infra(mac, sessionId) &&
-			!csr_is_ndi_started(mac, sessionId)) {
-		QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
-			"%s: Request ignored, session %d is not connected or started",
-			__func__, sessionId);
+	    !csr_is_ndi_started(mac, sessionId)) {
+		sme_err("Request ignored, session %d is not connected or started",
+			sessionId);
 		qdf_mem_free(request_buf);
 		return QDF_STATUS_E_FAILURE;
 	}
+#endif
 
 	qdf_mem_copy(request_buf, pMulticastAddrs,
 		     sizeof(tSirRcvFltMcAddrList));
@@ -8364,11 +8392,20 @@ int sme_send_addba_req(mac_handle_t mac_handle, uint8_t session_id, uint8_t tid,
 	struct send_add_ba_req *send_ba_req;
 	struct csr_roam_session *csr_session = NULL;
 
+	/* This is temp ifdef will be removed in near future */
+#ifdef FEATURE_CM_ENABLE
+	if (!cm_is_vdevid_connected(mac_ctx->pdev, session_id)) {
+		sme_err("STA not infra/connected state session_id: %d",
+			session_id);
+		return -EINVAL;
+	}
+#else
 	if (!csr_is_conn_state_connected_infra(mac_ctx, session_id)) {
 		sme_err("STA not infra/connected state session_id: %d",
-				session_id);
+			session_id);
 		return -EINVAL;
 	}
+#endif
 	csr_session = CSR_GET_SESSION(mac_ctx, session_id);
 	if (!csr_session) {
 		sme_err("CSR session is NULL");
@@ -11554,10 +11591,18 @@ sme_validate_session_for_cap_update(struct mac_context *mac_ctx,
 		sme_err("Session does not exist, Session_id: %d", session_id);
 		return QDF_STATUS_E_INVAL;
 	}
+	/* This is temp ifdef will be removed in near future */
+#ifdef FEATURE_CM_ENABLE
+	if (!cm_is_vdevid_connected(mac_ctx->pdev, session_id)) {
+		sme_debug("STA is not connected, Session_id: %d", session_id);
+		return QDF_STATUS_E_INVAL;
+	}
+#else
 	if (!csr_is_conn_state_connected_infra(mac_ctx, session_id)) {
 		sme_debug("STA is not connected, Session_id: %d", session_id);
 		return QDF_STATUS_E_INVAL;
 	}
+#endif
 
 	return QDF_STATUS_SUCCESS;
 }
@@ -11708,12 +11753,18 @@ int sme_config_action_tx_in_tb_ppdu(mac_handle_t mac_handle, uint8_t session_id,
 	struct scheduler_msg msg = {0};
 	struct sir_cfg_action_frm_tb_ppdu *cfg_msg;
 
+	/* This is temp ifdef will be removed in near future */
+#ifdef FEATURE_CM_ENABLE
+	if (!cm_is_vdevid_connected(mac_ctx->pdev, session_id)) {
+		sme_debug("STA is not connected, Session_id: %d", session_id);
+		return -EINVAL;
+	}
+#else
 	if (!csr_is_conn_state_connected_infra(mac_ctx, session_id)) {
-		sme_debug("STA not in connected state Session_id: %d",
-			  session_id);
+		sme_debug("STA is not connected, Session_id: %d", session_id);
 		return -EINVAL;
 	}
-
+#endif
 	cfg_msg = qdf_mem_malloc(sizeof(*cfg_msg));
 	if (!cfg_msg)
 		return -EIO;
@@ -15139,7 +15190,7 @@ int16_t sme_get_oper_chan_freq(struct wlan_objmgr_vdev *vdev)
 
 	session = CSR_GET_SESSION(mac_ctx, vdev_id);
 
-	return csr_get_infra_operation_chan_freq(mac_ctx, vdev_id);
+	return csr_get_operation_chan_freq(mac_ctx, vdev, vdev_id);
 }
 
 enum phy_ch_width sme_get_oper_ch_width(struct wlan_objmgr_vdev *vdev)

+ 15 - 1
core/sme/src/common/sme_power_save.c

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015-2020 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2015-2021 The Linux Foundation. All rights reserved.
  *
  * Permission to use, copy, modify, and/or distribute this software for
  * any purpose with or without fee is hereby granted, provided that the
@@ -354,11 +354,20 @@ QDF_STATUS sme_enable_sta_ps_check(struct mac_context *mac_ctx,
 	 * also if command is power save disable  there is not need to check
 	 * for connected state as firmware can handle this
 	 */
+	/* This is temp ifdef will be removed in near future */
+#ifdef FEATURE_CM_ENABLE
+	if (!cm_is_vdevid_connected(mac_ctx->pdev, session_id)) {
+		sme_debug("STA not infra/connected state Session_id: %d",
+			  session_id);
+		return QDF_STATUS_E_FAILURE;
+	}
+#else
 	if (!csr_is_conn_state_connected_infra(mac_ctx, session_id)) {
 		sme_debug("STA not infra/connected state Session_id: %d",
 			  session_id);
 		return QDF_STATUS_E_FAILURE;
 	}
+#endif
 
 	return QDF_STATUS_SUCCESS;
 }
@@ -392,7 +401,12 @@ QDF_STATUS sme_ps_enable_disable(mac_handle_t mac_handle, uint32_t session_id,
 		 * But kernel expects return status success even
 		 * in the disconnected state.
 		 */
+		/* This is temp ifdef will be removed in near future */
+#ifdef FEATURE_CM_ENABLE
+		if (!cm_is_vdevid_connected(mac_ctx->pdev, session_id))
+#else
 		if (!csr_is_conn_state_connected_infra(mac_ctx, session_id))
+#endif
 			status = QDF_STATUS_SUCCESS;
 		return status;
 	}

+ 129 - 62
core/sme/src/csr/csr_api_roam.c

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012-2020 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2012-2021 The Linux Foundation. All rights reserved.
  *
  * Permission to use, copy, modify, and/or distribute this software for
  * any purpose with or without fee is hereby granted, provided that the
@@ -364,10 +364,11 @@ static void csr_roaming_state_config_cnf_processor(struct mac_context *mac,
 			tSmeCmd *pCommand, uint8_t session_id);
 static QDF_STATUS csr_roam_open(struct mac_context *mac);
 static QDF_STATUS csr_roam_close(struct mac_context *mac);
+#ifndef FEATURE_CM_ENABLE
 static bool csr_roam_is_same_profile_keys(struct mac_context *mac,
 				   tCsrRoamConnectedProfile *pConnProfile,
 				   struct csr_roam_profile *pProfile2);
-
+#endif
 static QDF_STATUS csr_roam_start_roaming_timer(struct mac_context *mac,
 					       uint32_t vdev_id,
 					       uint32_t interval);
@@ -475,6 +476,7 @@ bool csr_roam_is_handoff_in_progress(struct mac_context *mac, uint8_t sessionId)
 	return csr_neighbor_roam_is_handoff_in_progress(mac, sessionId);
 }
 
+#ifndef FEATURE_CM_ENABLE
 static QDF_STATUS
 csr_roam_issue_disassociate(struct mac_context *mac, uint32_t sessionId,
 			    enum csr_roam_substate NewSubstate,
@@ -545,6 +547,7 @@ csr_roam_issue_disassociate(struct mac_context *mac, uint32_t sessionId,
 
 	return status;
 }
+#endif
 
 static void csr_roam_de_init_globals(struct mac_context *mac)
 {
@@ -3881,6 +3884,7 @@ QDF_STATUS csr_roam_save_connected_bss_desc(struct mac_context *mac,
 	return status;
 }
 
+#ifndef FEATURE_CM_ENABLE
 static
 QDF_STATUS csr_roam_prepare_bss_config(struct mac_context *mac,
 				       struct csr_roam_profile *pProfile,
@@ -4054,6 +4058,7 @@ QDF_STATUS csr_roam_prepare_bss_config(struct mac_context *mac,
 
 	return QDF_STATUS_SUCCESS;
 }
+#endif
 
 QDF_STATUS csr_roam_prepare_bss_config_from_profile(
 	struct mac_context *mac, struct csr_roam_profile *pProfile,
@@ -4831,6 +4836,7 @@ QDF_STATUS csr_roam_set_bss_config_cfg(struct mac_context *mac, uint32_t session
 	return QDF_STATUS_SUCCESS;
 }
 
+#ifndef FEATURE_CM_ENABLE
 /**
  * csr_check_for_hidden_ssid_match() - Check if the current connected SSID
  * is hidden ssid and if it matches with the roamed AP ssid.
@@ -5141,6 +5147,7 @@ static enum csr_join_state csr_roam_join(struct mac_context *mac,
 		qdf_mem_free(pIesLocal);
 	return eRoamState;
 }
+#endif
 
 static QDF_STATUS
 csr_roam_should_roam(struct mac_context *mac, uint32_t sessionId,
@@ -5316,6 +5323,7 @@ static bool csr_roam_select_bss(struct mac_context *mac_ctx,
 	return status;
 }
 
+#ifdef FEATURE_CM_ENABLE
 /**
  * csr_roam_join_handle_profile() - Handle join scenario based on profile
  * @mac_ctx:             Global MAC Context
@@ -5328,6 +5336,47 @@ static bool csr_roam_select_bss(struct mac_context *mac_ctx,
  *
  * Return: None
  */
+static void csr_roam_join_handle_profile(struct mac_context *mac_ctx,
+		uint32_t session_id, tSmeCmd *cmd,
+		struct csr_roam_info *roam_info_ptr,
+		enum csr_join_state *roam_state, tCsrScanResultInfo *result,
+		struct tag_csrscan_result *scan_result)
+{
+	QDF_STATUS status;
+	struct csr_roam_session *session;
+	struct csr_roam_profile *profile = &cmd->u.roamCmd.roamProfile;
+
+	if (!CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
+		sme_err("Invalid session id %d", session_id);
+		return;
+	}
+	session = CSR_GET_SESSION(mac_ctx, session_id);
+
+	if (CSR_IS_INFRA_AP(profile)) {
+		/* Attempt to start this WDS... */
+		csr_roam_assign_default_param(mac_ctx, cmd);
+		/* For AP WDS, we dont have any BSSDescription */
+		status = csr_roam_start_wds(mac_ctx, session_id, profile, NULL);
+		if (QDF_IS_STATUS_SUCCESS(status))
+			*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 */
+		sme_warn("cannot continue without BSS list");
+		*roam_state = eCsrStopRoaming;
+		return;
+	}
+
+}
+#else
 static void csr_roam_join_handle_profile(struct mac_context *mac_ctx,
 		uint32_t session_id, tSmeCmd *cmd,
 		struct csr_roam_info *roam_info_ptr,
@@ -5398,9 +5447,6 @@ static void csr_roam_join_handle_profile(struct mac_context *mac_ctx,
 			qdf_mem_free(ies_local);
 		roam_info_ptr->pProfile = profile;
 		session->bRefAssocStartCnt++;
-		csr_roam_call_callback(mac_ctx, session_id, roam_info_ptr,
-			cmd->u.roamCmd.roamId, eCSR_ROAM_ASSOCIATION_START,
-			eCSR_ROAM_RESULT_NONE);
 	}
 	if (cmd->u.roamCmd.pRoamBssEntry) {
 		/*
@@ -5465,6 +5511,8 @@ static void csr_roam_join_handle_profile(struct mac_context *mac_ctx,
 	}
 
 }
+#endif
+
 /**
  * csr_roam_join_next_bss() - Pick the next BSS for join
  * @mac_ctx:             Global MAC Context
@@ -5592,6 +5640,8 @@ static QDF_STATUS csr_roam(struct mac_context *mac, tSmeCmd *pCommand,
 	if ((eCsrStopRoaming == RoamState) ||
 		(eCsrStopRoamingDueToConcurrency == RoamState)) {
 		bool fComplete = false;
+		/* This is temp ifdef will be removed in near future */
+#ifndef FEATURE_CM_ENABLE
 		/* and if connected in Infrastructure mode... */
 		if (csr_is_conn_state_infra(mac, sessionId)) {
 			/* ... then we need to issue a disassociation */
@@ -5607,7 +5657,9 @@ static QDF_STATUS csr_roam(struct mac_context *mac, tSmeCmd *pCommand,
 				 */
 				fComplete = true;
 			}
-		} else if (csr_is_conn_state_connected_infra_ap(mac,
+		} else
+#endif
+		if (csr_is_conn_state_connected_infra_ap(mac,
 					sessionId)) {
 			substate = eCSR_ROAM_SUBSTATE_STOP_BSS_REQ;
 			status = csr_roam_issue_stop_bss(mac, sessionId,
@@ -5724,10 +5776,6 @@ csr_roam_trigger_reassociate(struct mac_context *mac_ctx, tSmeCmd *cmd,
 			roam_info->bss_desc = session_ptr->pConnectBssDesc;
 			roam_info->pProfile = &cmd->u.roamCmd.roamProfile;
 			session_ptr->bRefAssocStartCnt++;
-			csr_roam_call_callback(mac_ctx, session_id, roam_info,
-				cmd->u.roamCmd.roamId,
-				eCSR_ROAM_ASSOCIATION_START,
-				eCSR_ROAM_RESULT_NONE);
 
 			sme_debug("calling csr_roam_issue_reassociate");
 			status = csr_roam_issue_reassociate(mac_ctx, session_id,
@@ -5920,14 +5968,6 @@ QDF_STATUS csr_roam_process_command(struct mac_context *mac, tSmeCmd *pCommand)
 		status = csr_roam_trigger_reassociate(mac, pCommand,
 						      pSession, sessionId);
 		break;
-	case eCsrCapsChange:
-		sme_err("received eCsrCapsChange ");
-		csr_roam_state_change(mac, eCSR_ROAMING_STATE_JOINING,
-				sessionId);
-		status = csr_roam_issue_disassociate(mac, sessionId,
-				eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING,
-				false);
-		break;
 	case eCsrSmeIssuedFTReassoc:
 		sme_debug("received FT Reassoc Req");
 		status = csr_process_ft_reassoc_roam_command(mac, pCommand);
@@ -9197,7 +9237,13 @@ csr_roaming_state_config_cnf_processor(struct mac_context *mac_ctx,
 		is_ies_malloced = true;
 	}
 
-	if (csr_is_conn_state_connected_infra(mac_ctx, session_id)) {
+	/* This is temp ifdef will be removed in near future */
+#ifdef FEATURE_CM_ENABLE
+	if (cm_is_vdevid_connected(mac_ctx->pdev, session_id))
+#else
+	if (csr_is_conn_state_connected_infra(mac_ctx, session_id))
+#endif
+	{
 		if (csr_is_ssid_equal(mac_ctx, session->pConnectBssDesc,
 				      bss_desc, local_ies)) {
 			cmd->u.roamCmd.fReassoc = true;
@@ -9366,6 +9412,7 @@ static void csr_roam_roaming_state_reassoc_rsp_processor(struct mac_context *mac
 				return;
 			}
 		}
+#ifndef FEATURE_CM_ENABLE
 		/* In the event that the Reassociation fails, then we need to
 		 * Disassociate the current association and keep roaming. Note
 		 * that we will attempt to Join the AP instead of a Reassoc
@@ -9381,6 +9428,7 @@ static void csr_roam_roaming_state_reassoc_rsp_processor(struct mac_context *mac
 			csr_roam_complete(mac, eCsrJoinFailure, NULL,
 					pSmeJoinRsp->vdev_id);
 		}
+#endif
 	}
 }
 
@@ -9453,6 +9501,7 @@ csr_dequeue_command(struct mac_context *mac_ctx)
 			cmd->u.roamCmd.roamReason);
 }
 
+#ifndef FEATURE_CM_ENABLE
 /**
  * csr_post_roam_failure() - post roam failure back to csr and issues a disassoc
  * @mac:               mac global context
@@ -9498,7 +9547,7 @@ csr_post_roam_failure(struct mac_context *mac_ctx,
 		csr_roam_complete(mac_ctx, eCsrJoinFailure, NULL, session_id);
 	}
 }
-
+#endif
 /**
  * csr_check_profile_in_scan_cache() - finds if roam profile is present in scan
  * cache or not
@@ -9629,7 +9678,9 @@ purge_scan_result:
 	csr_scan_result_purge(mac, scan_handle_roam_ap);
 
 POST_ROAM_FAILURE:
+#ifndef FEATURE_CM_ENABLE
 	csr_post_roam_failure(mac, session_id, roam_info, NULL);
+#endif
 	qdf_mem_free(roam_info);
 	return status;
 }
@@ -9719,7 +9770,9 @@ void csr_handle_disassoc_ho(struct mac_context *mac, uint32_t session_id)
 POST_ROAM_FAILURE:
 	mlme_set_discon_reason_n_from_ap(mac->psoc, session_id, false,
 					 REASON_HOST_TRIGGERED_ROAM_FAILURE);
+#ifndef FEATURE_CM_ENABLE
 	csr_post_roam_failure(mac, session_id, roam_info, NULL);
+#endif
 	qdf_mem_free(roam_info);
 }
 #else
@@ -9740,11 +9793,13 @@ void csr_roam_roaming_state_disassoc_rsp_processor(struct mac_context *mac,
 	sessionId = rsp->sessionId;
 	sme_debug("sessionId %d", sessionId);
 
+	/* This is temp ifdef will be removed in near future */
+#ifndef FEATURE_CM_ENABLE
 	if (csr_is_conn_state_infra(mac, sessionId)) {
 		mac->roam.roamSession[sessionId].connectState =
 			eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
 	}
-
+#endif
 	pSession = CSR_GET_SESSION(mac, sessionId);
 	if (!pSession) {
 		sme_err("session %d not found", sessionId);
@@ -10245,12 +10300,15 @@ csr_roam_chk_lnk_set_ctx_rsp(struct mac_context *mac_ctx, tSirSmeRsp *msg_ptr)
 		/* We are done with authentication, whethere succeed or not */
 		csr_roam_substate_change(mac_ctx, eCSR_ROAM_SUBSTATE_NONE,
 					 sessionId);
+		/* This is temp ifdef will be removed in near future */
+#ifndef FEATURE_CM_ENABLE
 		/* We do it here because this linkup function is not called
 		 * after association  when a key needs to be set.
 		 */
 		if (csr_is_conn_state_connected_infra(mac_ctx, sessionId))
 			csr_roam_link_up(mac_ctx,
 					 session->connectedProfile.bssid);
+#endif
 	}
 	if (eSIR_SME_SUCCESS == pRsp->status_code) {
 		qdf_copy_macaddr(&roam_info->peerMac, &pRsp->peer_macaddr);
@@ -11514,8 +11572,11 @@ csr_roam_chk_lnk_disassoc_ind(struct mac_context *mac_ctx, tSirSmeRsp *msg_ptr)
 	session->disconnect_stats.disconnection_cnt++;
 	session->disconnect_stats.disassoc_by_peer++;
 
+	/* This is temp ifdef will be removed in near future */
+#ifndef FEATURE_CM_ENABLE
 	if (csr_is_conn_state_infra(mac_ctx, sessionId))
 		session->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
+#endif
 #ifndef WLAN_MDM_CODE_REDUCTION_OPT
 	sme_qos_csr_event_ind(mac_ctx, (uint8_t) sessionId,
 			      SME_QOS_CSR_DISCONNECT_IND, NULL);
@@ -11613,8 +11674,11 @@ csr_roam_chk_lnk_deauth_ind(struct mac_context *mac_ctx, tSirSmeRsp *msg_ptr)
 		break;
 	}
 
+	/* This is temp ifdef will be removed in near future */
+#ifndef FEATURE_CM_ENABLE
 	if (csr_is_conn_state_infra(mac_ctx, sessionId))
 		session->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
+#endif
 #ifndef WLAN_MDM_CODE_REDUCTION_OPT
 	sme_qos_csr_event_ind(mac_ctx, (uint8_t) sessionId,
 			      SME_QOS_CSR_DISCONNECT_IND, NULL);
@@ -12337,7 +12401,13 @@ void csr_roam_wait_for_key_time_out_handler(void *pv)
 		sme_debug("SME pre-auth state timeout");
 
 		status = sme_acquire_global_lock(&mac->sme);
-		if (csr_is_conn_state_connected_infra(mac, vdev_id)) {
+		/* This is temp ifdef will be removed in near future */
+#ifdef FEATURE_CM_ENABLE
+		if (cm_is_vdevid_connected(mac->pdev, vdev_id))
+#else
+		if (csr_is_conn_state_connected_infra(mac, vdev_id))
+#endif
+		{
 			csr_roam_link_up(mac,
 					 pSession->connectedProfile.bssid);
 			if (QDF_IS_STATUS_SUCCESS(status)) {
@@ -13217,6 +13287,7 @@ exit:
 	return fCheck;
 }
 
+#ifndef FEATURE_CM_ENABLE
 static bool csr_roam_is_same_profile_keys(struct mac_context *mac,
 				   tCsrRoamConnectedProfile *pConnProfile,
 				   struct csr_roam_profile *pProfile2)
@@ -13257,6 +13328,7 @@ static bool csr_roam_is_same_profile_keys(struct mac_context *mac,
 	} while (0);
 	return fCheck;
 }
+#endif
 
 /**
  * csr_populate_basic_rates() - populates OFDM or CCK rates
@@ -14117,46 +14189,39 @@ static QDF_STATUS csr_roam_start_wds(struct mac_context *mac, uint32_t sessionId
 		return QDF_STATUS_E_FAILURE;
 	}
 
-	if (csr_is_conn_state_connected_infra(mac, sessionId)) {
-		/* Disassociate from the connected Infrastructure network.*/
-		status = csr_roam_issue_disassociate(mac, sessionId,
-				eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING,
-						    false);
-	} else {
-		if (csr_is_conn_state_wds(mac, sessionId)) {
-			QDF_ASSERT(0);
-			return QDF_STATUS_E_FAILURE;
-		}
-		qdf_mem_zero(&bssConfig, sizeof(struct bss_config_param));
-		/* Assume HDD provide bssid in profile */
-		qdf_copy_macaddr(&pSession->bssParams.bssid,
-				 pProfile->BSSIDs.bssid);
-		/* there is no Bss description before we start an WDS so we
-		 * need to adopt all Bss configuration parameters from the
-		 * Profile.
-		 */
-		status = csr_roam_prepare_bss_config_from_profile(mac,
-								pProfile,
-								&bssConfig,
-								bss_desc);
-		if (QDF_IS_STATUS_SUCCESS(status)) {
-			/* Save profile for late use */
-			csr_free_roam_profile(mac, sessionId);
-			pSession->pCurRoamProfile =
-				qdf_mem_malloc(sizeof(struct csr_roam_profile));
-			if (pSession->pCurRoamProfile) {
-				csr_roam_copy_profile(mac,
-						      pSession->pCurRoamProfile,
-						      pProfile, sessionId);
-			}
-			/* Prepare some more parameters for this WDS */
-			csr_roam_prepare_bss_params(mac, sessionId, pProfile,
-						NULL, &bssConfig, NULL);
-			status = csr_roam_set_bss_config_cfg(mac, sessionId,
-							pProfile, NULL,
-							&bssConfig, NULL,
-							false);
-		}
+	if (csr_is_conn_state_wds(mac, sessionId)) {
+		QDF_ASSERT(0);
+		return QDF_STATUS_E_FAILURE;
+	}
+	qdf_mem_zero(&bssConfig, sizeof(struct bss_config_param));
+	/* Assume HDD provide bssid in profile */
+	qdf_copy_macaddr(&pSession->bssParams.bssid,
+			 pProfile->BSSIDs.bssid);
+	/* there is no Bss description before we start an WDS so we
+	 * need to adopt all Bss configuration parameters from the
+	 * Profile.
+	 */
+	status = csr_roam_prepare_bss_config_from_profile(mac,
+							pProfile,
+							&bssConfig,
+							bss_desc);
+	if (QDF_IS_STATUS_SUCCESS(status)) {
+		/* Save profile for late use */
+		csr_free_roam_profile(mac, sessionId);
+		pSession->pCurRoamProfile =
+			qdf_mem_malloc(sizeof(struct csr_roam_profile));
+		if (pSession->pCurRoamProfile) {
+			csr_roam_copy_profile(mac,
+					      pSession->pCurRoamProfile,
+					      pProfile, sessionId);
+		}
+		/* Prepare some more parameters for this WDS */
+		csr_roam_prepare_bss_params(mac, sessionId, pProfile,
+					NULL, &bssConfig, NULL);
+		status = csr_roam_set_bss_config_cfg(mac, sessionId,
+						pProfile, NULL,
+						&bssConfig, NULL,
+						false);
 	}
 
 	return status;
@@ -20374,11 +20439,13 @@ csr_process_roam_sync_callback(struct mac_context *mac_ctx,
 	}
 
 	conn_profile = &session->connectedProfile;
+#ifndef FEATURE_CM_ENABLE
 	status = csr_roam_stop_network(mac_ctx, session_id,
 				       session->pCurRoamProfile,
 				       bss_desc, ies_local);
 	if (!QDF_IS_STATUS_SUCCESS(status))
 		goto end;
+#endif
 	ps_global_info->remain_in_power_active_till_dhcp = false;
 	session->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED;
 

+ 59 - 66
core/sme/src/csr/csr_util.c

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2020 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2011-2021 The Linux Foundation. All rights reserved.
  *
  * Permission to use, copy, modify, and/or distribute this software for
  * any purpose with or without fee is hereby granted, provided that the
@@ -34,6 +34,7 @@
 #include "wlan_reg_services_api.h"
 #include "wlan_crypto_global_api.h"
 #include "wlan_cm_roam_api.h"
+#include <../../core/src/wlan_cm_vdev_api.h>
 
 uint8_t csr_wpa_oui[][CSR_WPA_OUI_SIZE] = {
 	{0x00, 0x50, 0xf2, 0x00}
@@ -245,7 +246,6 @@ const char *get_e_roam_cmd_status_str(eRoamCmdStatus val)
 		CASE_RETURN_STR(eCSR_ROAM_ROAMING_START);
 		CASE_RETURN_STR(eCSR_ROAM_ROAMING_COMPLETION);
 		CASE_RETURN_STR(eCSR_ROAM_CONNECT_COMPLETION);
-		CASE_RETURN_STR(eCSR_ROAM_ASSOCIATION_START);
 		CASE_RETURN_STR(eCSR_ROAM_ASSOCIATION_COMPLETION);
 		CASE_RETURN_STR(eCSR_ROAM_DISASSOCIATED);
 		CASE_RETURN_STR(eCSR_ROAM_ASSOCIATION_FAILURE);
@@ -540,6 +540,19 @@ static bool csr_is_conn_state(struct mac_context *mac_ctx, uint32_t session_id,
 	return mac_ctx->roam.roamSession[session_id].connectState == state;
 }
 
+bool csr_is_conn_state_connected(struct mac_context *mac, uint32_t sessionId)
+{
+	/* This is temp ifdef will be removed in near future */
+#ifdef FEATURE_CM_ENABLE
+	return cm_is_vdevid_connected(mac->pdev, sessionId) ||
+	       csr_is_conn_state_connected_wds(mac, sessionId);
+#else
+	return csr_is_conn_state_connected_infra(mac, sessionId) ||
+	       csr_is_conn_state_connected_wds(mac, sessionId);
+#endif
+}
+
+#ifndef FEATURE_CM_ENABLE
 bool csr_is_conn_state_connected_infra(struct mac_context *mac_ctx,
 				       uint32_t session_id)
 {
@@ -547,16 +560,11 @@ bool csr_is_conn_state_connected_infra(struct mac_context *mac_ctx,
 				 eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED);
 }
 
-bool csr_is_conn_state_connected(struct mac_context *mac, uint32_t sessionId)
-{
-	return csr_is_conn_state_connected_infra(mac, sessionId) ||
-	       csr_is_conn_state_connected_wds(mac, sessionId);
-}
-
 bool csr_is_conn_state_infra(struct mac_context *mac, uint32_t sessionId)
 {
 	return csr_is_conn_state_connected_infra(mac, sessionId);
 }
+#endif
 
 static tSirMacCapabilityInfo csr_get_bss_capabilities(struct bss_description *
 						      pSirBssDesc)
@@ -677,7 +685,12 @@ bool csr_is_any_session_in_connect_state(struct mac_context *mac)
 
 	for (i = 0; i < WLAN_MAX_VDEVS; i++) {
 		if (CSR_IS_SESSION_VALID(mac, i) &&
+		/* This is temp ifdef will be removed in near future */
+#ifdef FEATURE_CM_ENABLE
+		    (cm_is_vdevid_connected(mac->pdev, i) ||
+#else
 		    (csr_is_conn_state_infra(mac, i) ||
+#endif
 		     csr_is_conn_state_ap(mac, i))) {
 			return true;
 		}
@@ -686,63 +699,54 @@ bool csr_is_any_session_in_connect_state(struct mac_context *mac)
 	return false;
 }
 
-uint32_t csr_get_infra_operation_chan_freq(
-	struct mac_context *mac, uint8_t vdev_id)
+qdf_freq_t csr_get_operation_chan_freq(struct mac_context *mac,
+				       struct wlan_objmgr_vdev *vdev,
+				       uint8_t vdev_id)
 {
-	uint32_t chan_freq = 0;
-	struct csr_roam_session *session;
+	qdf_freq_t chan_freq = 0;
+	struct wlan_channel *chan;
 
-	session = CSR_GET_SESSION(mac, vdev_id);
-	if (!session)
+	if (!CSR_IS_SESSION_VALID(mac, vdev_id))
 		return chan_freq;
 
-	if (CSR_IS_SESSION_VALID(mac, vdev_id))
-		chan_freq = session->connectedProfile.op_freq;
-
-	return chan_freq;
-}
+	if (wlan_vdev_mlme_is_active(vdev) != QDF_STATUS_SUCCESS)
+		return chan_freq;
 
-bool csr_is_session_client_and_connected(struct mac_context *mac, uint8_t sessionId)
-{
-	struct csr_roam_session *pSession = NULL;
+	chan = wlan_vdev_get_active_channel(vdev);
+	if (chan)
+		chan_freq = chan->ch_freq;
 
-	if (CSR_IS_SESSION_VALID(mac, sessionId)
-	    && csr_is_conn_state_infra(mac, sessionId)) {
-		pSession = CSR_GET_SESSION(mac, sessionId);
-		if (pSession->pCurRoamProfile) {
-			if ((pSession->pCurRoamProfile->csrPersona ==
-			     QDF_STA_MODE)
-			    || (pSession->pCurRoamProfile->csrPersona ==
-				QDF_P2P_CLIENT_MODE))
-				return true;
-		}
-	}
-	return false;
+	return chan_freq;
 }
 
-uint32_t csr_get_concurrent_operation_freq(struct mac_context *mac_ctx)
+qdf_freq_t csr_get_concurrent_operation_freq(struct mac_context *mac_ctx)
 {
-	struct csr_roam_session *session = NULL;
 	uint8_t i = 0;
-	enum QDF_OPMODE persona;
+	qdf_freq_t freq;
+	struct wlan_objmgr_vdev *vdev;
+	enum QDF_OPMODE op_mode;
 
 	for (i = 0; i < WLAN_MAX_VDEVS; i++) {
-		if (!CSR_IS_SESSION_VALID(mac_ctx, i))
+		vdev = wlan_objmgr_get_vdev_by_id_from_pdev(mac_ctx->pdev,
+							    i,
+							    WLAN_LEGACY_MAC_ID);
+		if (!vdev)
 			continue;
-		session = CSR_GET_SESSION(mac_ctx, i);
-		if (!session->pCurRoamProfile)
+		op_mode = wlan_vdev_mlme_get_opmode(vdev);
+		/* check only for STA, CLI, GO and SAP */
+		if (op_mode != QDF_STA_MODE && op_mode != QDF_P2P_CLIENT_MODE &&
+		    op_mode != QDF_P2P_GO_MODE && op_mode != QDF_SAP_MODE) {
+			wlan_objmgr_vdev_release_ref(vdev, WLAN_LEGACY_MAC_ID);
 			continue;
-		persona = session->pCurRoamProfile->csrPersona;
-		if ((((persona == QDF_STA_MODE) ||
-			(persona == QDF_P2P_CLIENT_MODE)) &&
-			(session->connectState ==
-				eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED)) ||
-			(((persona == QDF_P2P_GO_MODE) ||
-				(persona == QDF_SAP_MODE))
-				 && (session->connectState !=
-					 eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED)))
-			return session->connectedProfile.op_freq;
+		}
+		freq = csr_get_operation_chan_freq(mac_ctx, vdev, i);
+		wlan_objmgr_vdev_release_ref(vdev, WLAN_LEGACY_MAC_ID);
+		if (!freq)
+			continue;
+
+		return freq;
 	}
+
 	return 0;
 }
 
@@ -1151,22 +1155,6 @@ bool csr_is_all_session_disconnected(struct mac_context *mac)
 	return fRc;
 }
 
-uint8_t csr_get_connected_infra(struct mac_context *mac_ctx)
-{
-	uint32_t i;
-	uint8_t connected_session = WLAN_UMAC_VDEV_ID_MAX;
-
-	for (i = 0; i < WLAN_MAX_VDEVS; i++) {
-		if (CSR_IS_SESSION_VALID(mac_ctx, i)
-		    && csr_is_conn_state_connected_infra(mac_ctx, i)) {
-			connected_session = i;
-			break;
-		}
-	}
-
-	return connected_session;
-}
-
 bool csr_is_concurrent_session_running(struct mac_context *mac)
 {
 	uint32_t sessionId, noOfCocurrentSession = 0;
@@ -2376,7 +2364,12 @@ static bool csr_validate_p2pgo_bcn_intrvl(struct mac_context *mac_ctx,
 		    (conn_profile->beaconInterval == 0))
 			return false;
 
+		/* This is temp ifdef will be removed in near future */
+#ifdef FEATURE_CM_ENABLE
+		if (cm_is_vdevid_connected(mac_ctx->pdev, session_id) &&
+#else
 		if (csr_is_conn_state_connected_infra(mac_ctx, session_id) &&
+#endif
 		    conn_profile->op_freq != ch_freq &&
 		    conn_profile->beaconInterval != *bcn_interval) {
 			/*

+ 16 - 5
core/sme/src/rrm/sme_rrm.c

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2020 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2011-2021 The Linux Foundation. All rights reserved.
  *
  * Permission to use, copy, modify, and/or distribute this software for
  * any purpose with or without fee is hereby granted, provided that the
@@ -38,6 +38,7 @@
 #include <wlan_scan_utils_api.h>
 #include <wlan_reg_services_api.h>
 #include <wlan_utility.h>
+#include <../../core/src/wlan_cm_vdev_api.h>
 
 /* Roam score for a neighbor AP will be calculated based on the below
  * definitions. The calculated roam score will be used to select the
@@ -579,14 +580,24 @@ static QDF_STATUS sme_rrm_send_scan_result(struct mac_context *mac_ctx,
 	}
 
 	session = CSR_GET_SESSION(mac_ctx, session_id);
-	if ((!session) ||  (!csr_is_conn_state_connected_infra(
-	    mac_ctx, session_id)) ||
-	    (!session->pConnectBssDesc)) {
+
+	/* This is temp ifdef will be removed in near future */
+#ifdef FEATURE_CM_ENABLE
+	if (!session || !cm_is_vdevid_connected(mac_ctx->pdev, session_id) ||
+	    !session->pConnectBssDesc) {
 		sme_err("Invaild session");
 		status = QDF_STATUS_E_FAILURE;
 		goto rrm_send_scan_results_done;
 	}
-
+#else
+	if (!session ||
+	    !csr_is_conn_state_connected_infra(mac_ctx, session_id) ||
+	    !session->pConnectBssDesc) {
+		sme_err("Invaild session");
+		status = QDF_STATUS_E_FAILURE;
+		goto rrm_send_scan_results_done;
+	}
+#endif
 
 	while (scan_results) {
 		/*