Browse Source

qcacld-3.0: Cleanup roam scan channels configuration

Currently roam channel list is directly accessed from
mac->roam.neighborRoamInfo[sessionId].cfgParams.channelInfo
in multiple APIs to set/clear.
This needs to be enhanced as as firmware supports two channel
lists(static and dynamic) for roam scan, userspace may configure
both the lists. Cleanup the APIs to accommodate both of the
channel lists. Rename the variable channelInfo of cfgParams to
specific_chan_info to suit the usage.

Change-Id: I67548bc040c2296b75b9429f5891a5251a2a88d6
CRs-Fixed: 2507157
Srinivas Dasari 5 years ago
parent
commit
b78334d5ef

+ 1 - 1
core/sme/inc/csr_neighbor_roam.h

@@ -45,7 +45,7 @@ typedef enum {
 typedef struct sCsrNeighborRoamCfgParams {
 	uint32_t neighborScanPeriod;
 	uint32_t neighbor_scan_min_period;
-	tCsrChannelInfo channelInfo;
+	tCsrChannelInfo specific_chan_info;
 	uint8_t neighborLookupThreshold;
 	int8_t rssi_thresh_offset_5g;
 	uint8_t neighborReassocThreshold;

+ 20 - 4
core/sme/inc/sme_inside.h

@@ -166,11 +166,27 @@ QDF_STATUS sme_release_global_lock(struct sme_context *sme);
 QDF_STATUS
 csr_process_vdev_del_rsp(struct mac_context *mac, uint8_t *pmsg);
 
-QDF_STATUS csr_flush_cfg_bg_scan_roam_channel_list(struct mac_context *mac,
-		uint8_t sessionId);
+/**
+ * csr_flush_cfg_bg_scan_roam_channel_list() - Flush the channel list
+ * @channel_info: Channel list to be flushed
+ *
+ * Return: None
+ */
+void csr_flush_cfg_bg_scan_roam_channel_list(tCsrChannelInfo *channel_info);
+
+/**
+ * csr_create_bg_scan_roam_channel_list() - Create roam scan chan list
+ * @mac: global mac context
+ * @channel_info: Channel list to be populated for roam scan
+ * @chan_list: Channel list to be populated from
+ * @num_chan: Number of channels
+ *
+ * Return: QDF_STATUS_SUCCESS or QDF_STATUS_E_FAILURE
+ */
 QDF_STATUS csr_create_bg_scan_roam_channel_list(struct mac_context *mac,
-		uint8_t sessionId, const uint8_t *pChannelList,
-		const uint8_t num_chan);
+						tCsrChannelInfo *channel_info,
+						const uint8_t *chan_list,
+						const uint8_t num_chan);
 
 #ifdef FEATURE_WLAN_ESE
 QDF_STATUS csr_create_roam_scan_channel_list(struct mac_context *mac,

+ 38 - 30
core/sme/src/common/sme_api.c

@@ -6154,6 +6154,8 @@ QDF_STATUS sme_set_roam_scan_control(mac_handle_t mac_handle, uint8_t sessionId,
 {
 	struct mac_context *mac = MAC_CONTEXT(mac_handle);
 	QDF_STATUS status = QDF_STATUS_SUCCESS;
+	tCsrChannelInfo *specific_channel_info;
+	tCsrNeighborRoamControlInfo *neighbor_roam_info;
 
 	MTRACE(qdf_trace(QDF_MODULE_ID_SME,
 			 TRACE_CODE_SME_RX_HDD_SET_SCANCTRL, NO_SESSION, 0));
@@ -6165,29 +6167,33 @@ QDF_STATUS sme_set_roam_scan_control(mac_handle_t mac_handle, uint8_t sessionId,
 	}
 
 	status = sme_acquire_global_lock(&mac->sme);
-	if (QDF_IS_STATUS_SUCCESS(status)) {
-		QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
-			  "LFR runtime successfully set roam scan control to %d - old value is %d - roam state is %s",
-			  roamScanControl,
-			  mac->roam.configParam.nRoamScanControl,
-			  mac_trace_get_neighbour_roam_state(mac->roam.
-							     neighborRoamInfo
-							     [sessionId].
-							    neighborRoamState));
-		mac->roam.configParam.nRoamScanControl = roamScanControl;
-		if (0 == roamScanControl) {
-			QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
-				  "LFR runtime successfully cleared roam scan cache");
-			csr_flush_cfg_bg_scan_roam_channel_list(mac,
-								sessionId);
-			if (mac->mlme_cfg->lfr.roam_scan_offload_enabled) {
-				csr_roam_offload_scan(mac, sessionId,
-						   ROAM_SCAN_OFFLOAD_UPDATE_CFG,
-						     REASON_FLUSH_CHANNEL_LIST);
-			}
+	if (QDF_IS_STATUS_ERROR(status))
+		return status;
+	neighbor_roam_info = &mac->roam.neighborRoamInfo[sessionId];
+	sme_debug("LFR runtime successfully set roam scan control to %d - old value is %d - roam state is %s",
+		  roamScanControl,
+		  mac->roam.configParam.nRoamScanControl,
+		  mac_trace_get_neighbour_roam_state(
+			neighbor_roam_info->neighborRoamState));
+	if (!roamScanControl && mac->roam.configParam.nRoamScanControl) {
+		/**
+		 * Clear the specific channel info cache when roamScanControl
+		 * is set to 0. If any preffered channel list is configured,
+		 * that will be sent to firmware for further roam scans.
+		 */
+		sme_debug("LFR runtime successfully cleared roam scan cache");
+		specific_channel_info =
+			&neighbor_roam_info->cfgParams.specific_chan_info;
+		csr_flush_cfg_bg_scan_roam_channel_list(specific_channel_info);
+		if (mac->mlme_cfg->lfr.roam_scan_offload_enabled) {
+			csr_roam_offload_scan(mac, sessionId,
+					      ROAM_SCAN_OFFLOAD_UPDATE_CFG,
+					      REASON_FLUSH_CHANNEL_LIST);
 		}
-		sme_release_global_lock(&mac->sme);
 	}
+	mac->roam.configParam.nRoamScanControl = roamScanControl;
+	sme_release_global_lock(&mac->sme);
+
 	return status;
 }
 
@@ -7166,7 +7172,7 @@ uint8_t sme_get_roam_rssi_diff(mac_handle_t mac_handle)
  * sme_change_roam_scan_channel_list() - to change scan channel list
  * @mac_handle: Opaque handle to the global MAC context
  * @sessionId: sme session id
- * @pChannelList: Output channel list
+ * @channel_list: Output channel list
  * @numChannels: Output number of channels
  *
  * This routine is called to Change roam scan channel list.
@@ -7176,7 +7182,7 @@ uint8_t sme_get_roam_rssi_diff(mac_handle_t mac_handle)
  */
 QDF_STATUS sme_change_roam_scan_channel_list(mac_handle_t mac_handle,
 					     uint8_t sessionId,
-					     uint8_t *pChannelList,
+					     uint8_t *channel_list,
 					     uint8_t numChannels)
 {
 	struct mac_context *mac = MAC_CONTEXT(mac_handle);
@@ -7199,7 +7205,7 @@ QDF_STATUS sme_change_roam_scan_channel_list(mac_handle_t mac_handle,
 		sme_err("Failed to acquire SME lock");
 		return status;
 	}
-	chan_info = &pNeighborRoamInfo->cfgParams.channelInfo;
+	chan_info = &pNeighborRoamInfo->cfgParams.specific_chan_info;
 
 	if (chan_info->freq_list) {
 		for (i = 0; i < chan_info->numOfChannels; i++) {
@@ -7212,9 +7218,9 @@ QDF_STATUS sme_change_roam_scan_channel_list(mac_handle_t mac_handle,
 				break;
 		}
 	}
-	csr_flush_cfg_bg_scan_roam_channel_list(mac, sessionId);
-	csr_create_bg_scan_roam_channel_list(mac, sessionId, pChannelList,
-			numChannels);
+	csr_flush_cfg_bg_scan_roam_channel_list(chan_info);
+	csr_create_bg_scan_roam_channel_list(mac, chan_info, channel_list,
+					     numChannels);
 	sme_set_roam_scan_control(mac_handle, sessionId, 1);
 	if (chan_info->freq_list) {
 		j = 0;
@@ -7261,6 +7267,7 @@ QDF_STATUS sme_get_roam_scan_channel_list(mac_handle_t mac_handle,
 	struct mac_context *mac = MAC_CONTEXT(mac_handle);
 	tpCsrNeighborRoamControlInfo pNeighborRoamInfo = NULL;
 	QDF_STATUS status = QDF_STATUS_SUCCESS;
+	tCsrChannelInfo *specific_chan_info;
 
 	if (sessionId >= WLAN_MAX_VDEVS) {
 		QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
@@ -7272,7 +7279,8 @@ QDF_STATUS sme_get_roam_scan_channel_list(mac_handle_t mac_handle,
 	status = sme_acquire_global_lock(&mac->sme);
 	if (!QDF_IS_STATUS_SUCCESS(status))
 		return status;
-	if (!pNeighborRoamInfo->cfgParams.channelInfo.freq_list) {
+	specific_chan_info = &pNeighborRoamInfo->cfgParams.specific_chan_info;
+	if (!specific_chan_info->freq_list) {
 		QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_WARN,
 			FL("Roam Scan channel list is NOT yet initialized"));
 		*pNumChannels = 0;
@@ -7280,12 +7288,12 @@ QDF_STATUS sme_get_roam_scan_channel_list(mac_handle_t mac_handle,
 		return status;
 	}
 
-	*pNumChannels = pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels;
+	*pNumChannels = specific_chan_info->numOfChannels;
 	for (i = 0; i < (*pNumChannels); i++)
 		pOutPtr[i] =
 		wlan_reg_freq_to_chan(
 			mac->pdev,
-			pNeighborRoamInfo->cfgParams.channelInfo.freq_list[i]);
+			specific_chan_info->freq_list[i]);
 
 	pOutPtr[i] = '\0';
 	sme_release_global_lock(&mac->sme);

+ 61 - 43
core/sme/src/csr/csr_api_roam.c

@@ -1589,50 +1589,30 @@ static void init_config_param(struct mac_context *mac)
 	mac->roam.configParam.doBMPSWorkaround = 0;
 }
 
-/* This function flushes the roam scan cache */
-QDF_STATUS csr_flush_cfg_bg_scan_roam_channel_list(struct mac_context *mac,
-						   uint8_t sessionId)
+void csr_flush_cfg_bg_scan_roam_channel_list(tCsrChannelInfo *channel_info)
 {
-	QDF_STATUS status = QDF_STATUS_SUCCESS;
-
-	tpCsrNeighborRoamControlInfo pNeighborRoamInfo =
-		&mac->roam.neighborRoamInfo[sessionId];
-
 	/* Free up the memory first (if required) */
-	if (pNeighborRoamInfo->cfgParams.channelInfo.freq_list) {
-		qdf_mem_free(pNeighborRoamInfo->cfgParams.channelInfo.
-			     freq_list);
-		pNeighborRoamInfo->cfgParams.channelInfo.freq_list = NULL;
-		pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = 0;
+	if (channel_info->freq_list) {
+		qdf_mem_free(channel_info->freq_list);
+		channel_info->freq_list = NULL;
+		channel_info->numOfChannels = 0;
 	}
-	return status;
 }
 
-/*
- * This function flushes the roam scan cache and creates fresh cache
- * based on the input channel list
- */
 QDF_STATUS csr_create_bg_scan_roam_channel_list(struct mac_context *mac,
-						uint8_t sessionId,
+						tCsrChannelInfo *channel_info,
 						const uint8_t *chan_list,
 						const uint8_t num_chan)
 {
 	QDF_STATUS status = QDF_STATUS_SUCCESS;
-	tpCsrNeighborRoamControlInfo pNeighborRoamInfo =
-		&mac->roam.neighborRoamInfo[sessionId];
 
-	pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = num_chan;
-	pNeighborRoamInfo->cfgParams.channelInfo.freq_list =
-		qdf_mem_malloc(sizeof(uint32_t) * num_chan);
-	if (!pNeighborRoamInfo->cfgParams.channelInfo.freq_list) {
-		pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = 0;
+	channel_info->freq_list = qdf_mem_malloc(sizeof(uint32_t) * num_chan);
+	if (!channel_info->freq_list)
 		return QDF_STATUS_E_NOMEM;
-	}
 
-	/* Update the roam global structure */
-	sme_chan_to_freq_list(mac->pdev,
-			      pNeighborRoamInfo->cfgParams.channelInfo.
-			      freq_list, chan_list, num_chan);
+	channel_info->numOfChannels = num_chan;
+	sme_chan_to_freq_list(mac->pdev, channel_info->freq_list,
+			      chan_list, num_chan);
 	return status;
 }
 
@@ -17664,23 +17644,23 @@ csr_check_band_channel_match(enum band_info band, uint8_t channel)
 }
 
 /**
- * csr_fetch_ch_lst_from_ini() - fetch channel list from ini and update req msg
+ * csr_populate_roam_chan_list()
  * parameters
  * @mac_ctx:      global mac ctx
- * @roam_info:    roam info struct
- * @req_buf:      out param, roam offload scan request packet
+ * @dst: Destination roam network to populate the roam chan list
+ * @src: Source channel list
  *
- * Return: result of operation
+ * Return: QDF_STATUS enumeration
  */
 static QDF_STATUS
-csr_fetch_ch_lst_from_ini(struct mac_context *mac_ctx,
-			  tpCsrNeighborRoamControlInfo roam_info,
-			  struct roam_offload_scan_req *req_buf)
+csr_populate_roam_chan_list(struct mac_context *mac_ctx,
+			    tSirRoamNetworkType *dst,
+			    tCsrChannelInfo *src)
 {
 	enum band_info band;
 	uint8_t i = 0;
 	uint8_t num_channels = 0;
-	uint32_t *freq_lst = roam_info->cfgParams.channelInfo.freq_list;
+	uint32_t *freq_lst = src->freq_list;
 	uint16_t  unsafe_chan[NUM_CHANNELS];
 	uint16_t  unsafe_chan_cnt = 0;
 	uint16_t  cnt = 0;
@@ -17710,7 +17690,12 @@ csr_fetch_ch_lst_from_ini(struct mac_context *mac_ctx,
 		return QDF_STATUS_E_FAILURE;
 	}
 
-	for (i = 0; i < roam_info->cfgParams.channelInfo.numOfChannels; i++) {
+	num_channels = dst->ChannelCount;
+	for (i = 0; i < src->numOfChannels; i++) {
+		if (csr_is_channel_present_in_list(dst->ChannelCache,
+						   num_channels,
+			wlan_reg_freq_to_chan(mac_ctx->pdev, *freq_lst)))
+			continue;
 		if (!csr_check_band_freq_match(
 			band, *freq_lst))
 			continue;
@@ -17750,13 +17735,43 @@ csr_fetch_ch_lst_from_ini(struct mac_context *mac_ctx,
 				continue;
 			}
 		}
-		req_buf->ConnectedNetwork.ChannelCache[num_channels++] =
+		dst->ChannelCache[num_channels++] =
 			wlan_reg_freq_to_chan(mac_ctx->pdev, *freq_lst);
 		freq_lst++;
+	}
+	dst->ChannelCount = num_channels;
+
+	return QDF_STATUS_SUCCESS;
+}
 
+/**
+ * csr_fetch_ch_lst_from_ini() - fetch channel list from ini and update req msg
+ * parameters
+ * @mac_ctx:      global mac ctx
+ * @roam_info:    roam info struct
+ * @req_buf:      out param, roam offload scan request packet
+ *
+ * Return: result of operation
+ */
+static QDF_STATUS
+csr_fetch_ch_lst_from_ini(struct mac_context *mac_ctx,
+			  tpCsrNeighborRoamControlInfo roam_info,
+			  struct roam_offload_scan_req *req_buf)
+{
+	QDF_STATUS status;
+	tCsrChannelInfo *specific_chan_info;
+
+	specific_chan_info = &roam_info->cfgParams.specific_chan_info;
+
+	status = csr_populate_roam_chan_list(mac_ctx,
+					     &req_buf->ConnectedNetwork,
+					     specific_chan_info);
+	if (status != QDF_STATUS_SUCCESS) {
+		sme_err("Failed to copy channels to roam list");
+		return status;
 	}
-	req_buf->ConnectedNetwork.ChannelCount = num_channels;
 	req_buf->ChannelCacheType = CHANNEL_LIST_STATIC;
+
 	return QDF_STATUS_SUCCESS;
 }
 
@@ -17984,6 +17999,9 @@ csr_create_roam_scan_offload_request(struct mac_context *mac_ctx,
 	struct roam_offload_scan_req *req_buf = NULL;
 	tpCsrChannelInfo curr_ch_lst_info =
 		&roam_info->roamChannelInfo.currentChannelListInfo;
+	tCsrChannelInfo *specific_chan_info;
+
+	specific_chan_info = &roam_info->cfgParams.specific_chan_info;
 #ifdef FEATURE_WLAN_ESE
 	/*
 	 * this flag will be true if connection is ESE and no neighbor
@@ -18121,7 +18139,7 @@ csr_create_roam_scan_offload_request(struct mac_context *mac_ctx,
 			 * the occupied channels list.
 			 * Give Preference to INI Channels
 			 */
-			if (roam_info->cfgParams.channelInfo.numOfChannels) {
+			if (specific_chan_info->numOfChannels) {
 				status = csr_fetch_ch_lst_from_ini(mac_ctx,
 								   roam_info,
 								   req_buf);

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

@@ -2987,7 +2987,7 @@ void csr_init_occupied_channels_list(struct mac_context *mac_ctx,
 		sme_debug("Invalid session");
 		return;
 	}
-	if (neighbor_roam_info->cfgParams.channelInfo.numOfChannels) {
+	if (neighbor_roam_info->cfgParams.specific_chan_info.numOfChannels) {
 		/*
 		 * Ini file contains neighbor scan channel list, hence NO need
 		 * to build occupied channel list"

+ 20 - 24
core/sme/src/csr/csr_neighbor_roam.c

@@ -1211,6 +1211,7 @@ static QDF_STATUS csr_neighbor_roam_init11r_assoc_info(struct mac_context *mac)
 QDF_STATUS csr_neighbor_roam_init(struct mac_context *mac, uint8_t sessionId)
 {
 	QDF_STATUS status;
+	tCsrChannelInfo *specific_chan_info;
 	tpCsrNeighborRoamControlInfo pNeighborRoamInfo =
 		&mac->roam.neighborRoamInfo[sessionId];
 
@@ -1246,30 +1247,26 @@ QDF_STATUS csr_neighbor_roam_init(struct mac_context *mac, uint8_t sessionId)
 	pNeighborRoamInfo->cfgParams.emptyScanRefreshPeriod =
 		mac->mlme_cfg->lfr.empty_scan_refresh_period;
 
-	pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels =
+	specific_chan_info = &pNeighborRoamInfo->cfgParams.specific_chan_info;
+	specific_chan_info->numOfChannels =
 		mac->mlme_cfg->lfr.neighbor_scan_channel_list_num;
-	QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
-			FL("number of channels: %u"),
-			pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels);
-	if (pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels != 0) {
-		pNeighborRoamInfo->cfgParams.channelInfo.freq_list =
+	sme_debug("number of channels: %u", specific_chan_info->numOfChannels);
+	if (specific_chan_info->numOfChannels != 0) {
+		specific_chan_info->freq_list =
 			qdf_mem_malloc(sizeof(uint32_t) *
-				       mac->mlme_cfg->lfr.
-				       neighbor_scan_channel_list_num);
-		if (!pNeighborRoamInfo->cfgParams.channelInfo.freq_list) {
-			pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels =
-				0;
+				       specific_chan_info->numOfChannels);
+		if (!specific_chan_info->freq_list) {
+			specific_chan_info->numOfChannels = 0;
 			return QDF_STATUS_E_NOMEM;
 		}
 
 	} else {
-		pNeighborRoamInfo->cfgParams.channelInfo.freq_list = NULL;
+		specific_chan_info->freq_list = NULL;
 	}
 
 	/* Update the roam global structure from CFG */
 	sme_chan_to_freq_list(mac->pdev,
-			      pNeighborRoamInfo->cfgParams.channelInfo.
-			      freq_list,
+			      specific_chan_info->freq_list,
 			      mac->mlme_cfg->lfr.neighbor_scan_channel_list,
 			      mac->mlme_cfg->lfr.
 			      neighbor_scan_channel_list_num);
@@ -1302,10 +1299,9 @@ QDF_STATUS csr_neighbor_roam_init(struct mac_context *mac, uint8_t sessionId)
 	status = csr_ll_open(&pNeighborRoamInfo->roamableAPList);
 	if (QDF_STATUS_SUCCESS != status) {
 		sme_err("LL Open of roam able AP List failed");
-		qdf_mem_free(pNeighborRoamInfo->cfgParams.channelInfo.
-			     freq_list);
-		pNeighborRoamInfo->cfgParams.channelInfo.freq_list = NULL;
-		pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = 0;
+		qdf_mem_free(specific_chan_info->freq_list);
+		specific_chan_info->freq_list = NULL;
+		specific_chan_info->numOfChannels = 0;
 		return QDF_STATUS_E_RESOURCES;
 	}
 
@@ -1320,8 +1316,8 @@ QDF_STATUS csr_neighbor_roam_init(struct mac_context *mac, uint8_t sessionId)
 	status = csr_neighbor_roam_init11r_assoc_info(mac);
 	if (QDF_STATUS_SUCCESS != status) {
 		sme_err("LL Open of roam able AP List failed");
-		pNeighborRoamInfo->cfgParams.channelInfo.freq_list = NULL;
-		pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = 0;
+		specific_chan_info->freq_list = NULL;
+		specific_chan_info->numOfChannels = 0;
 		csr_ll_close(&pNeighborRoamInfo->roamableAPList);
 		return QDF_STATUS_E_RESOURCES;
 	}
@@ -1357,10 +1353,10 @@ void csr_neighbor_roam_close(struct mac_context *mac, uint8_t sessionId)
 		return;
 	}
 	cfg_params = &pNeighborRoamInfo->cfgParams;
-	if (cfg_params->channelInfo.freq_list)
-		qdf_mem_free(cfg_params->channelInfo.freq_list);
-	pNeighborRoamInfo->cfgParams.channelInfo.freq_list = NULL;
-	pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = 0;
+	if (cfg_params->specific_chan_info.freq_list)
+		qdf_mem_free(cfg_params->specific_chan_info.freq_list);
+	pNeighborRoamInfo->cfgParams.specific_chan_info.freq_list = NULL;
+	pNeighborRoamInfo->cfgParams.specific_chan_info.numOfChannels = 0;
 
 	/* Should free up the nodes in the list before closing the
 	 * double Linked list