Browse Source

qcacld-3.0: Use pcl channel list for sap channel selection

Use the pcl channel list to do random channel selection when the
radar is detected.

Change-Id: I286bf447a398bf1d9a7a1493ac4bbfd9847de148
CRs-Fixed: 988325
Kiran Kumar Lokere 9 years ago
parent
commit
80897d86c9
3 changed files with 58 additions and 12 deletions
  1. 2 0
      core/cds/inc/cds_concurrency.h
  2. 34 0
      core/cds/src/cds_concurrency.c
  3. 22 12
      core/sap/src/sap_fsm.c

+ 2 - 0
core/cds/inc/cds_concurrency.h

@@ -691,4 +691,6 @@ QDF_STATUS cds_handle_hw_mode_change_on_csa(uint16_t session_id,
 QDF_STATUS cds_register_sap_restart_channel_switch_cb(
 		void (*sap_restart_chan_switch_cb)(void *, uint32_t, uint32_t));
 #endif
+QDF_STATUS cds_get_pcl_for_existing_conn(enum cds_con_mode mode,
+			uint8_t *pcl_ch, uint32_t *len);
 #endif /* __CDS_CONCURRENCY_H */

+ 34 - 0
core/cds/src/cds_concurrency.c

@@ -3680,6 +3680,40 @@ static void cds_set_pcl_for_existing_combo(enum cds_con_mode mode)
 	}
 }
 
+/**
+ * cds_get_pcl_for_existing_conn() - Get PCL for existing connection
+ * @mode: Connection mode of type 'cds_con_mode'
+ *
+ * Get the PCL for an existing connection
+ *
+ * Return: None
+ */
+QDF_STATUS cds_get_pcl_for_existing_conn(enum cds_con_mode mode,
+			uint8_t *pcl_ch, uint32_t *len)
+{
+	struct cds_conc_connection_info info;
+
+	cds_context_type *cds_ctx;
+	QDF_STATUS status = QDF_STATUS_SUCCESS;
+	cds_ctx = cds_get_context(QDF_MODULE_ID_QDF);
+	if (!cds_ctx) {
+		cds_err("Invalid CDS Context");
+		return QDF_STATUS_E_INVAL;
+	}
+	qdf_mutex_acquire(&cds_ctx->qdf_conc_list_lock);
+	if (cds_mode_specific_connection_count(mode, NULL) > 0) {
+		/* Check, store and temp delete the mode's parameter */
+		cds_store_and_del_conn_info(mode, &info);
+		/* Set the PCL to the FW since connection got updated */
+		status = cds_get_pcl(mode, pcl_ch, len);
+		cds_info("Get PCL to FW for mode:%d", mode);
+		/* Restore the connection info */
+		cds_restore_deleted_conn_info(&info);
+	}
+	qdf_mutex_release(&cds_ctx->qdf_conc_list_lock);
+	return status;
+}
+
 /**
  * cds_decr_session_set_pcl() - Decrement session count and set PCL
  * @mode: Adapter mode

+ 22 - 12
core/sap/src/sap_fsm.c

@@ -738,7 +738,7 @@ static QDF_STATUS sap_get_channel_list(ptSapContext sapContext,
 #endif
 
 /*==========================================================================
-   FUNCTION    sapGet5GHzChannelList
+   FUNCTION    sap_get_5ghz_channel_list
 
    DESCRIPTION
     Function for initializing list of  2.4/5 Ghz [NON-DFS/DFS] available
@@ -757,7 +757,7 @@ static QDF_STATUS sap_get_channel_list(ptSapContext sapContext,
 
    SIDE EFFECTS
    ============================================================================*/
-static QDF_STATUS sap_get5_g_hz_channel_list(ptSapContext sapContext);
+static QDF_STATUS sap_get_5ghz_channel_list(ptSapContext sapContext);
 
 /*==========================================================================
    FUNCTION    sapStopDfsCacTimer
@@ -1278,7 +1278,7 @@ static uint8_t sap_random_channel_sel(ptSapContext sapContext)
 		ch_width = pMac->sap.SapDfsInfo.orig_chanWidth;
 	}
 
-	if (sap_get5_g_hz_channel_list(sapContext)) {
+	if (sap_get_5ghz_channel_list(sapContext)) {
 		QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO_LOW,
 			  FL("Getting 5Ghz channel list failed"));
 		return target_channel;
@@ -4439,10 +4439,14 @@ static QDF_STATUS sap_get_channel_list(ptSapContext sap_ctx,
  * Function for initializing list of  2.4/5 Ghz [NON-DFS/DFS]
  * available channels in the current regulatory domain.
  */
-static QDF_STATUS sap_get5_g_hz_channel_list(ptSapContext sapContext)
+static QDF_STATUS sap_get_5ghz_channel_list(ptSapContext sapContext)
 {
 	uint8_t count = 0;
 	int i;
+	struct sir_pcl_list pcl;
+	QDF_STATUS status;
+	enum channel_state ch_state;
+	pcl.pcl_len = 0;
 	if (NULL == sapContext) {
 		QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_ERROR,
 			  "Invalid sapContext pointer on sap_get_channel_list");
@@ -4463,15 +4467,23 @@ static QDF_STATUS sap_get5_g_hz_channel_list(ptSapContext sapContext)
 		return QDF_STATUS_E_NOMEM;
 	}
 
-	for (i = CHAN_ENUM_36; i <= CHAN_ENUM_165; i++) {
-		if (CDS_CHANNEL_STATE(i) == CHANNEL_STATE_ENABLE ||
-		    CDS_CHANNEL_STATE(i) == CHANNEL_STATE_DFS) {
+	status = cds_get_pcl_for_existing_conn(CDS_SAP_MODE,
+			pcl.pcl_list, &pcl.pcl_len);
+	if (status != QDF_STATUS_SUCCESS) {
+		cds_err("Get PCL failed");
+		return status;
+	}
+	for (i = 0; i <= pcl.pcl_len; i++) {
+		if (CDS_IS_CHANNEL_5GHZ(pcl.pcl_list[i])) {
+			ch_state = cds_get_channel_state(pcl.pcl_list[i]);
+			if (!(ch_state == CHANNEL_STATE_ENABLE ||
+				ch_state == CHANNEL_STATE_DFS))
+				continue;
 			sapContext->SapAllChnlList.channelList[count].channel =
-				CDS_CHANNEL_NUM(i);
+				pcl.pcl_list[i];
 			QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO_LOW,
 				  "%s[%d] CHANNEL = %d", __func__, __LINE__,
-				  sapContext->SapAllChnlList.channelList[count].
-				  channel);
+				  pcl.pcl_list[i]);
 			sapContext->SapAllChnlList.channelList[count].valid =
 				true;
 			count++;
@@ -4533,8 +4545,6 @@ uint8_t sap_indicate_radar(ptSapContext sapContext,
 	/* set the Radar Found flag in SapDfsInfo */
 	pMac->sap.SapDfsInfo.sap_radar_found_status = true;
 
-	sap_get5_g_hz_channel_list(sapContext);
-
 	if (dfs_event->chan_list.nchannels > SIR_DFS_MAX_20M_SUB_CH) {
 		QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_WARN,
 			  FL("nchannels >SIR_DFS_MAX_20M_SUB_CH so resetting"));