Selaa lähdekoodia

qcacld-3.0: Refactor ACS and operating chan validation APIs

The SAP config in AP context is per link and to validate
the ACS and operating channels on each link, change the APIs
mentioned below to take link info as function argument.
Existing callers moved to deflink.

1) wlan_hdd_validate_acs_channel()
2) wlan_hdd_validate_operation_channel()

Change-Id: I3936f24965bef5a7a3839b517d4c2eb9db81004b
CRs-Fixed: 3463784
Vinod Kumar Pirla 2 vuotta sitten
vanhempi
sitoutus
fb37066b22
3 muutettua tiedostoa jossa 86 lisäystä ja 85 poistoa
  1. 34 36
      core/hdd/src/wlan_hdd_cfg80211.c
  2. 10 1
      core/hdd/src/wlan_hdd_cfg80211.h
  3. 42 48
      core/hdd/src/wlan_hdd_hostapd.c

+ 34 - 36
core/hdd/src/wlan_hdd_cfg80211.c

@@ -16138,23 +16138,26 @@ static int __wlan_hdd_cfg80211_setband(struct wiphy *wiphy,
 }
 
 /**
- *wlan_hdd_validate_acs_channel() - validate channel frequency provided by ACS
- * @adapter: hdd adapter
+ * wlan_hdd_validate_acs_channel() - validate channel frequency provided by ACS
+ * @link_info: Pointer to link_info in adapter
  * @chan_freq: channel frequency in MHz
  * @chan_bw: channel bandiodth in MHz
  *
  * return: QDF status based on success or failure
  */
-static QDF_STATUS wlan_hdd_validate_acs_channel(struct hdd_adapter *adapter,
-						uint32_t chan_freq, int chan_bw)
+static QDF_STATUS
+wlan_hdd_validate_acs_channel(struct wlan_hdd_link_info *link_info,
+			      uint32_t chan_freq, int chan_bw)
 {
+	struct hdd_context *hdd_ctx;
 	struct sap_context *sap_context;
 
+	hdd_ctx = link_info->adapter->hdd_ctx;
 	if (QDF_STATUS_SUCCESS !=
-	    wlan_hdd_validate_operation_channel(adapter, chan_freq))
+	    wlan_hdd_validate_operation_channel(hdd_ctx, chan_freq))
 		return QDF_STATUS_E_FAILURE;
 
-	sap_context = WLAN_HDD_GET_SAP_CTX_PTR(adapter->deflink);
+	sap_context = WLAN_HDD_GET_SAP_CTX_PTR(link_info);
 	if ((wlansap_is_channel_in_nol_list(sap_context, chan_freq,
 					    PHY_SINGLE_CHANNEL_CENTERED))) {
 		hdd_info("channel %d is in nol", chan_freq);
@@ -16637,16 +16640,18 @@ hdd_parse_vendor_acs_chan_config(struct hdd_context *hdd_ctx,
  * Return: 0 on success, negative errno on failure
  */
 static int __wlan_hdd_cfg80211_update_vendor_channel(struct wiphy *wiphy,
-		struct wireless_dev *wdev,
-		const void *data, int data_len)
+						     struct wireless_dev *wdev,
+						     const void *data,
+						     int data_len)
 {
 	int ret_val;
-	QDF_STATUS qdf_status;
+	QDF_STATUS status;
+	enum phy_ch_width phy_ch_width;
 	uint8_t channel_cnt = 0, reason = -1;
-	struct hdd_vendor_chan_info *channel_list = NULL;
+	struct hdd_vendor_chan_info *chan_list = NULL;
 	struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(wdev->netdev);
 	struct hdd_context *hdd_ctx = wiphy_priv(wiphy);
-	struct hdd_vendor_chan_info *channel_list_ptr;
+	struct hdd_vendor_chan_info *chan_list_ptr;
 
 	hdd_enter();
 
@@ -16668,44 +16673,45 @@ static int __wlan_hdd_cfg80211_update_vendor_channel(struct wiphy *wiphy,
 		return -EINVAL;
 	}
 
-	ret_val = hdd_parse_vendor_acs_chan_config(hdd_ctx, &channel_list,
+	ret_val = hdd_parse_vendor_acs_chan_config(hdd_ctx, &chan_list,
 						   &reason, &channel_cnt, data,
 						   data_len);
-	channel_list_ptr = channel_list;
+	chan_list_ptr = chan_list;
 	if (ret_val)
 		return ret_val;
 
 	/* Validate channel to be set */
-	while (channel_cnt && channel_list) {
-		qdf_status = wlan_hdd_validate_acs_channel(adapter,
-			     channel_list->pri_chan_freq,
-			     hdd_map_nl_chan_width(channel_list->chan_width));
-		if (qdf_status == QDF_STATUS_SUCCESS)
+	while (channel_cnt && chan_list) {
+		phy_ch_width = hdd_map_nl_chan_width(chan_list->chan_width);
+		status = wlan_hdd_validate_acs_channel(adapter->deflink,
+						       chan_list->pri_chan_freq,
+						       phy_ch_width);
+		if (status == QDF_STATUS_SUCCESS)
 			break;
 		else if (channel_cnt == 1) {
 			hdd_err("invalid channel frequ %u received from app",
-				channel_list->pri_chan_freq);
-			channel_list->pri_chan_freq = 0;
+				chan_list->pri_chan_freq);
+			chan_list->pri_chan_freq = 0;
 			break;
 		}
 
 		channel_cnt--;
-		channel_list++;
+		chan_list++;
 	}
 
-	if ((channel_cnt <= 0) || !channel_list) {
+	if ((channel_cnt <= 0) || !chan_list) {
 		hdd_err("no available channel/chanlist %d/%pK", channel_cnt,
-			channel_list);
-		qdf_mem_free(channel_list_ptr);
+			chan_list);
+		qdf_mem_free(chan_list_ptr);
 		return -EINVAL;
 	}
 
 	hdd_debug("received primary channel freq as %d",
-		  channel_list->pri_chan_freq);
+		  chan_list->pri_chan_freq);
 
 	ret_val = hdd_update_acs_channel(adapter, reason,
-				      channel_cnt, channel_list);
-	qdf_mem_free(channel_list_ptr);
+					 channel_cnt, chan_list);
+	qdf_mem_free(chan_list_ptr);
 	return ret_val;
 }
 
@@ -21004,19 +21010,11 @@ bool wlan_hdd_is_ap_supports_immediate_power_save(uint8_t *ies, int length)
 	return true;
 }
 
-/*
- * FUNCTION: wlan_hdd_validate_operation_channel
- * called by wlan_hdd_cfg80211_start_bss() and
- * wlan_hdd_set_channel()
- * This function validates whether given channel is part of valid
- * channel list.
- */
-QDF_STATUS wlan_hdd_validate_operation_channel(struct hdd_adapter *adapter,
+QDF_STATUS wlan_hdd_validate_operation_channel(struct hdd_context *hdd_ctx,
 					       uint32_t ch_freq)
 {
 	bool value = 0;
 	uint32_t i;
-	struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
 	struct regulatory_channel *cur_chan_list;
 	QDF_STATUS status;
 

+ 10 - 1
core/hdd/src/wlan_hdd_cfg80211.h

@@ -433,7 +433,16 @@ void wlan_hdd_cfg80211_deregister_frames(struct hdd_adapter *adapter);
 void hdd_reg_notifier(struct wiphy *wiphy,
 				 struct regulatory_request *request);
 
-QDF_STATUS wlan_hdd_validate_operation_channel(struct hdd_adapter *adapter,
+/*
+ * FUNCTION: wlan_hdd_validate_operation_channel
+ * called by wlan_hdd_cfg80211_start_bss() and
+ * wlan_hdd_set_channel()
+ * @hdd_ctx: Global HDD context
+ *
+ * This function validates whether given channel is part of valid
+ * channel list.
+ */
+QDF_STATUS wlan_hdd_validate_operation_channel(struct hdd_context *hdd_ctx,
 					       uint32_t ch_freq);
 
 /**

+ 42 - 48
core/hdd/src/wlan_hdd_hostapd.c

@@ -4571,10 +4571,9 @@ static inline bool wlan_hdd_get_sap_obss(struct wlan_hdd_link_info *link_info)
  *
  * Return: 0 for success non-zero for failure
  */
-int wlan_hdd_set_channel(struct wiphy *wiphy,
-				struct net_device *dev,
-				struct cfg80211_chan_def *chandef,
-				enum nl80211_channel_type channel_type)
+int wlan_hdd_set_channel(struct wiphy *wiphy, struct net_device *dev,
+			 struct cfg80211_chan_def *chandef,
+			 enum nl80211_channel_type channel_type)
 {
 	struct hdd_adapter *adapter = NULL;
 	uint32_t num_ch = 0;
@@ -4636,59 +4635,54 @@ int wlan_hdd_set_channel(struct wiphy *wiphy,
 
 	num_ch = CFG_VALID_CHANNEL_LIST_LEN;
 
-	if (QDF_STATUS_SUCCESS !=  wlan_hdd_validate_operation_channel(
-	    adapter, chandef->chan->center_freq)) {
+	if (QDF_STATUS_SUCCESS !=
+	    wlan_hdd_validate_operation_channel(hdd_ctx,
+						chandef->chan->center_freq)) {
 		hdd_err("Invalid freq: %d", chandef->chan->center_freq);
 		return -EINVAL;
 	}
 
-	if (adapter->device_mode == QDF_SAP_MODE ||
-	    adapter->device_mode == QDF_P2P_GO_MODE) {
-		ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(adapter->deflink);
-		sap_config = &ap_ctx->sap_config;
+	ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(adapter->deflink);
+	sap_config = &ap_ctx->sap_config;
+	sap_config->chan_freq = chandef->chan->center_freq;
+	sap_config->ch_params.center_freq_seg1 = channel_seg2;
+	sap_config->ch_params.center_freq_seg0 =
+			ieee80211_frequency_to_channel(chandef->center_freq1);
+
+	if (QDF_SAP_MODE == adapter->device_mode) {
+		/* set channel to what hostapd configured */
 		sap_config->chan_freq = chandef->chan->center_freq;
 		sap_config->ch_params.center_freq_seg1 = channel_seg2;
-		sap_config->ch_params.center_freq_seg0 =
-			ieee80211_frequency_to_channel(chandef->center_freq1);
 
-		if (QDF_SAP_MODE == adapter->device_mode) {
-			/* set channel to what hostapd configured */
-			sap_config->chan_freq = chandef->chan->center_freq;
-			sap_config->ch_params.center_freq_seg1 = channel_seg2;
-
-			sme_config = qdf_mem_malloc(sizeof(*sme_config));
-			if (!sme_config)
-				return -ENOMEM;
-
-			sme_get_config_param(mac_handle, sme_config);
-			switch (channel_type) {
-			case NL80211_CHAN_HT20:
-			case NL80211_CHAN_NO_HT:
-				sme_config->csr_config.obssEnabled = false;
-				sap_config->sec_ch_freq = 0;
-				break;
-			case NL80211_CHAN_HT40MINUS:
-				sap_config->sec_ch_freq =
-					sap_config->chan_freq - 20;
-				break;
-			case NL80211_CHAN_HT40PLUS:
-				sap_config->sec_ch_freq =
-					sap_config->chan_freq + 20;
-				break;
-			default:
-				hdd_err("Error!!! Invalid HT20/40 mode !");
-				qdf_mem_free(sme_config);
-				return -EINVAL;
-			}
-			sme_config->csr_config.obssEnabled =
-					wlan_hdd_get_sap_obss(link_info);
+		sme_config = qdf_mem_malloc(sizeof(*sme_config));
+		if (!sme_config)
+			return -ENOMEM;
 
-			sme_update_config(mac_handle, sme_config);
+		sme_get_config_param(mac_handle, sme_config);
+		switch (channel_type) {
+		case NL80211_CHAN_HT20:
+		case NL80211_CHAN_NO_HT:
+			sme_config->csr_config.obssEnabled = false;
+			sap_config->sec_ch_freq = 0;
+			break;
+		case NL80211_CHAN_HT40MINUS:
+			sap_config->sec_ch_freq =
+				sap_config->chan_freq - 20;
+			break;
+		case NL80211_CHAN_HT40PLUS:
+			sap_config->sec_ch_freq =
+				sap_config->chan_freq + 20;
+			break;
+		default:
+			hdd_err("Error!!! Invalid HT20/40 mode !");
 			qdf_mem_free(sme_config);
+			return -EINVAL;
 		}
-	} else {
-		hdd_err("Invalid device mode failed to set valid channel");
-		return -EINVAL;
+		sme_config->csr_config.obssEnabled =
+					wlan_hdd_get_sap_obss(link_info);
+
+		sme_update_config(mac_handle, sme_config);
+		qdf_mem_free(sme_config);
 	}
 
 	return status;
@@ -6433,7 +6427,7 @@ int wlan_hdd_cfg80211_start_bss(struct hdd_adapter *adapter,
 		hdd_ctx->dev_dfs_cac_status = DFS_CAC_NEVER_DONE;
 
 	if (QDF_STATUS_SUCCESS !=
-	    wlan_hdd_validate_operation_channel(adapter, config->chan_freq)) {
+	    wlan_hdd_validate_operation_channel(hdd_ctx, config->chan_freq)) {
 		hdd_err("Invalid Ch_freq: %d", config->chan_freq);
 		ret = -EINVAL;
 		goto error;