浏览代码

qcacld-3.0: Use CSA to change SAP DFS channel

If STA interface is added after softap is started on DFS channel,
then SAP is stopped and re-started on non-dfs channel which is selected
using driver internal acs. But, internal acs is now obsolete. Therefore,
select non-dfs channel from preffered channel list and use SAP CSA
instead of restart.

Change-Id: I95e50c3ffbce35cf30cc9a06f0f14c9e60eb3e3f
CRs-Fixed: 2301895
Rajeev Kumar Sirasanagandla 6 年之前
父节点
当前提交
4133d86be3
共有 4 个文件被更改,包括 108 次插入58 次删除
  1. 103 53
      core/hdd/src/wlan_hdd_main.c
  2. 1 1
      core/mac/inc/sir_api.h
  3. 4 0
      core/sap/inc/sap_api.h
  4. 0 4
      core/sap/src/sap_ch_select.h

+ 103 - 53
core/hdd/src/wlan_hdd_main.c

@@ -8196,6 +8196,96 @@ static void hdd_set_thermal_level_cb(hdd_handle_t hdd_handle, u_int8_t level)
 		ucfg_ipa_send_mcc_scc_msg(hdd_ctx->hdd_pdev, hdd_ctx->mcc_mode);
 }
 
+/**
+ * hdd_get_safe_channel() - Get safe channel from current regulatory
+ * @hdd_ctx: pointer to hdd context
+ * @adapter: pointer to softap adapter
+ *
+ * This function is used to get safe channel from current regulatory valid
+ * channels to restart SAP if failed to get safe channel from PCL.
+ *
+ * Return: Channel number to restart SAP in case of success. In case of any
+ * failure, the channel number returned is zero.
+ */
+static uint8_t
+hdd_get_safe_channel(struct hdd_context *hdd_ctx,
+		     struct hdd_adapter *adapter)
+{
+	struct sir_pcl_list pcl = {0};
+	uint32_t i, j;
+	bool found = false;
+	int ret;
+
+	/* Try for safe channel from all valid channel */
+	pcl.pcl_len = MAX_NUM_CHAN;
+	ret = hdd_get_valid_chan(hdd_ctx, pcl.pcl_list,
+				 &pcl.pcl_len);
+	if (ret) {
+		hdd_err("error %d in getting valid channel list", ret);
+		return INVALID_CHANNEL_ID;
+	}
+
+	for (i = 0; i < pcl.pcl_len; i++) {
+		hdd_debug("chan[%d]:%d", i, pcl.pcl_list[i]);
+		found = false;
+		for (j = 0; j < hdd_ctx->unsafe_channel_count; j++) {
+			if (pcl.pcl_list[i] ==
+					hdd_ctx->unsafe_channel_list[j]) {
+				hdd_debug("unsafe chan:%d", pcl.pcl_list[i]);
+				found = true;
+				break;
+			}
+		}
+
+		if (found)
+			continue;
+
+		if ((pcl.pcl_list[i] >=
+		   adapter->session.ap.sap_config.acs_cfg.start_ch) &&
+		   (pcl.pcl_list[i] <=
+		   adapter->session.ap.sap_config.acs_cfg.end_ch)) {
+			hdd_debug("found safe chan:%d", pcl.pcl_list[i]);
+			return pcl.pcl_list[i];
+		}
+	}
+
+	return INVALID_CHANNEL_ID;
+}
+
+#else
+/**
+ * hdd_set_thermal_level_cb() - set thermal level callback function
+ * @hdd_handle:	opaque handle for the hdd context
+ * @level:	thermal level
+ *
+ * Change IPA data path to SW path when the thermal throttle level greater
+ * than 0, and restore the original data path when throttle level is 0
+ *
+ * Return: none
+ */
+static void hdd_set_thermal_level_cb(hdd_handle_t hdd_handle, u_int8_t level)
+{
+}
+
+/**
+ * hdd_get_safe_channel() - Get safe channel from current regulatory
+ * @hdd_ctx: pointer to hdd context
+ * @adapter: pointer to softap adapter
+ *
+ * This function is used to get safe channel from current regulatory valid
+ * channels to restart SAP if failed to get safe channel from PCL.
+ *
+ * Return: Channel number to restart SAP in case of success. In case of any
+ * failure, the channel number returned is zero.
+ */
+static uint8_t
+hdd_get_safe_channel(struct hdd_context *hdd_ctx,
+		     struct hdd_adapter *adapter)
+{
+	return 0;
+}
+#endif
+
 /**
  * hdd_get_safe_channel_from_pcl_and_acs_range() - Get safe channel for SAP
  * restart
@@ -8208,16 +8298,14 @@ static void hdd_set_thermal_level_cb(hdd_handle_t hdd_handle, u_int8_t level)
  * Return: Channel number to restart SAP in case of success. In case of any
  * failure, the channel number returned is zero.
  */
-static uint8_t hdd_get_safe_channel_from_pcl_and_acs_range(
-				struct hdd_adapter *adapter)
+static uint8_t
+hdd_get_safe_channel_from_pcl_and_acs_range(struct hdd_adapter *adapter)
 {
 	struct sir_pcl_list pcl;
 	QDF_STATUS status;
-	uint32_t i, j;
+	uint32_t i;
 	mac_handle_t mac_handle;
 	struct hdd_context *hdd_ctx;
-	bool found = false;
-	int ret;
 
 	hdd_ctx = WLAN_HDD_GET_CTX(adapter);
 	if (!hdd_ctx) {
@@ -8266,42 +8354,8 @@ static uint8_t hdd_get_safe_channel_from_pcl_and_acs_range(
 
 	hdd_debug("no safe channel from PCL found in ACS range");
 
-	/* Try for safe channel from all valid channel */
-	pcl.pcl_len = MAX_NUM_CHAN;
-	ret = hdd_get_valid_chan(hdd_ctx, pcl.pcl_list,
-				 &pcl.pcl_len);
-	if (ret) {
-		hdd_err("error %d in getting valid channel list", ret);
-		return INVALID_CHANNEL_ID;
-	}
-
-	for (i = 0; i < pcl.pcl_len; i++) {
-		hdd_debug("chan[%d]:%d", i, pcl.pcl_list[i]);
-		found = false;
-		for (j = 0; j < hdd_ctx->unsafe_channel_count; j++) {
-			if (pcl.pcl_list[i] ==
-					hdd_ctx->unsafe_channel_list[j]) {
-				hdd_debug("unsafe chan:%d", pcl.pcl_list[i]);
-				found = true;
-				break;
-			}
-		}
-
-		if (found)
-			continue;
-
-		if ((pcl.pcl_list[i] >=
-		   adapter->session.ap.sap_config.acs_cfg.start_ch) &&
-		   (pcl.pcl_list[i] <=
-		   adapter->session.ap.sap_config.acs_cfg.end_ch)) {
-			hdd_debug("found safe chan:%d", pcl.pcl_list[i]);
-			return pcl.pcl_list[i];
-		}
-	}
-
-	return INVALID_CHANNEL_ID;
+	return hdd_get_safe_channel(hdd_ctx, adapter);
 }
-#endif
 
 /**
  * hdd_switch_sap_channel() - Move SAP to the given channel
@@ -8456,8 +8510,6 @@ void hdd_unsafe_channel_restart_sap(struct hdd_context *hdd_ctxt)
 			 * the ACS while restart.
 			 */
 			hdd_ctxt->acs_policy.acs_channel = AUTO_CHANNEL_SELECT;
-			adapter->session.ap.sap_config.channel =
-							AUTO_CHANNEL_SELECT;
 			hdd_debug("sending coex indication");
 			wlan_hdd_send_svc_nlink_msg(hdd_ctxt->radio_index,
 					WLAN_SVC_LTE_COEX_IND, NULL, 0);
@@ -8524,7 +8576,6 @@ static void hdd_lte_coex_restart_sap(struct hdd_adapter *adapter,
 	 * the ACS while restart.
 	 */
 	hdd_ctx->acs_policy.acs_channel = AUTO_CHANNEL_SELECT;
-	adapter->session.ap.sap_config.channel = AUTO_CHANNEL_SELECT;
 
 	hdd_debug("sending coex indication");
 
@@ -8593,10 +8644,6 @@ static void hdd_init_channel_avoidance(struct hdd_context *hdd_ctx)
 {
 }
 
-static void hdd_set_thermal_level_cb(hdd_handle_t hdd_handle, u_int8_t level)
-{
-}
-
 static inline void hdd_lte_coex_restart_sap(struct hdd_adapter *adapter,
 					    struct hdd_context *hdd_ctx)
 {
@@ -14014,6 +14061,7 @@ void hdd_check_and_restart_sap_with_non_dfs_acs(void)
 	struct hdd_adapter *ap_adapter;
 	struct hdd_context *hdd_ctx;
 	struct cds_context *cds_ctx;
+	uint8_t restart_chan;
 
 	hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD);
 	if (!hdd_ctx) {
@@ -14039,13 +14087,15 @@ void hdd_check_and_restart_sap_with_non_dfs_acs(void)
 			wlan_reg_is_dfs_ch(hdd_ctx->hdd_pdev,
 				ap_adapter->session.ap.operating_channel)) {
 
-		hdd_warn("STA-AP Mode DFS not supported. Restart SAP with Non DFS ACS");
-		ap_adapter->session.ap.sap_config.channel =
-			AUTO_CHANNEL_SELECT;
-		ap_adapter->session.ap.sap_config.
-			acs_cfg.acs_mode = true;
+		hdd_warn("STA-AP Mode DFS not supported, Switch SAP channel to Non DFS");
+
+		restart_chan =
+			hdd_get_safe_channel_from_pcl_and_acs_range(ap_adapter);
+		if (!restart_chan ||
+		    wlan_reg_is_dfs_ch(hdd_ctx->hdd_pdev, restart_chan))
+			restart_chan = SAP_DEFAULT_5GHZ_CHANNEL;
 
-		hdd_restart_sap(ap_adapter);
+		hdd_switch_sap_channel(ap_adapter, restart_chan, true);
 	}
 }
 

+ 1 - 1
core/mac/inc/sir_api.h

@@ -2993,9 +2993,9 @@ struct sir_wifi_start_log {
  * @pcl_len: Number of channels in the PCL
  */
 struct sir_pcl_list {
+	uint32_t pcl_len;
 	uint8_t pcl_list[128];
 	uint8_t weight_list[128];
-	uint32_t pcl_len;
 };
 
 /**

+ 4 - 0
core/sap/inc/sap_api.h

@@ -62,6 +62,10 @@ extern "C" {
 #define       SAP_MAX_OBSS_STA_CNT         1    /* max # of OBSS STA */
 #define       SAP_ACS_WEIGHT_MAX           (26664)
 
+#define SAP_DEFAULT_24GHZ_CHANNEL     (6)
+#define SAP_DEFAULT_5GHZ_CHANNEL      (40)
+#define SAP_CHANNEL_NOT_SELECTED (0)
+
 /*--------------------------------------------------------------------------
  * reasonCode taken from 802.11 standard.
  * ------------------------------------------------------------------------*/

+ 0 - 4
core/sap/src/sap_ch_select.h

@@ -59,10 +59,6 @@
 #define SOFTAP_MIN_TXPWR        (0)
 #define SOFTAP_MAX_TXPWR        (63)
 
-#define SAP_DEFAULT_24GHZ_CHANNEL     (6)
-#define SAP_DEFAULT_5GHZ_CHANNEL      (40)
-#define SAP_CHANNEL_NOT_SELECTED (0)
-
 #define SOFTAP_HT20_CHANNELWIDTH 0
 /* In HT40/VHT80, Effect of primary Channel RSSi on Subband1 */
 #define SAP_SUBBAND1_RSSI_EFFECT_PRIMARY  (-20)