Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d09310f3 authored by Asutosh Mohapatra's avatar Asutosh Mohapatra Committed by Gerrit - the friendly Code Review server
Browse files

qcacld-3.0: iwpriv return US regardless of any countrycode

Currently iw_get_channel_list_with_cc is not providing correct
channel list info.
To address this issue need to replace the legacy function
sme_get_country_code and update iw_get_channel_list function.

Change-Id: I28e059d8bde48392edd745463f7d667be233c473
CRs-Fixed: 3236375
parent 31f4e02f
Loading
Loading
Loading
Loading
+37 −58
Original line number Diff line number Diff line
@@ -1918,16 +1918,13 @@ static int iw_get_channel_list(struct net_device *dev,
{
	uint32_t num_channels = 0;
	uint8_t i = 0;
	uint8_t band_start_channel = MIN_24GHZ_CHANNEL;
	uint8_t band_end_channel = MAX_5GHZ_CHANNEL;
	struct hdd_adapter *hostapd_adapter = (netdev_priv(dev));
	struct channel_list_info *channel_list =
		(struct channel_list_info *)extra;
	bool enable_dfs_scan = true;
	enum band_info cur_band = BAND_ALL;
	struct regulatory_channel *cur_chan_list = NULL;
	struct hdd_context *hdd_ctx;
	int ret;
	bool is_dfs_mode_enabled = false;
	QDF_STATUS status;

	hdd_enter_dev(dev);

@@ -1940,59 +1937,44 @@ static int iw_get_channel_list(struct net_device *dev,
	if (0 != ret)
		return ret;

	if (QDF_STATUS_SUCCESS != ucfg_reg_get_band(hdd_ctx->pdev, &cur_band)) {
		hdd_err_rl("not able get the current frequency band");
		return -EIO;
	}
	cur_chan_list = qdf_mem_malloc(sizeof(*cur_chan_list) * NUM_CHANNELS);
	if (!cur_chan_list)
		return -ENOMEM;

	if (BAND_2G == cur_band) {
		band_start_channel = MIN_24GHZ_CHANNEL;
		band_end_channel = MAX_24GHZ_CHANNEL;
	} else if (BAND_5G == cur_band) {
		band_start_channel = MIN_5GHZ_CHANNEL;
		band_end_channel = MAX_5GHZ_CHANNEL;
	}

	if (cur_band != BAND_2G)
		band_end_channel = MAX_5GHZ_CHANNEL;
	ucfg_scan_cfg_get_dfs_chan_scan_allowed(hdd_ctx->psoc,
						&enable_dfs_scan);
	if (hostapd_adapter->device_mode == QDF_STA_MODE &&
	    enable_dfs_scan) {
		is_dfs_mode_enabled = true;
	} else if (hostapd_adapter->device_mode == QDF_SAP_MODE) {
		if (QDF_STATUS_SUCCESS != ucfg_mlme_get_dfs_master_capability(
				hdd_ctx->psoc, &is_dfs_mode_enabled)) {
			hdd_err_rl("Fail to get dfs master mode capability");
			return -EINVAL;
		}
	status = ucfg_reg_get_current_chan_list(hdd_ctx->pdev, cur_chan_list);
	if (status != QDF_STATUS_SUCCESS) {
		hdd_err_rl("Failed to get the current channel list");
		qdf_mem_free(cur_chan_list);
		return -EIO;
	}

	hdd_debug_rl("curBand = %d, StartChannel = %hu, EndChannel = %hu, is_dfs_mode_enabled = %d",
		     cur_band, band_start_channel, band_end_channel,
		     is_dfs_mode_enabled);
	for (i = 0; i < NUM_CHANNELS; i++) {
		/*
		 * current channel list includes all channels. do not report
		 * disabled channels
		 */
		if (cur_chan_list[i].chan_flags & REGULATORY_CHAN_DISABLED)
			continue;

	for (i = band_start_channel; i <= band_end_channel; i++) {
		if ((CHANNEL_STATE_ENABLE ==
		     wlan_reg_get_channel_state_for_freq(
						hdd_ctx->pdev,
						WLAN_REG_CH_TO_FREQ(i))) ||
		    (is_dfs_mode_enabled && CHANNEL_STATE_DFS ==
		     wlan_reg_get_channel_state_for_freq(
						hdd_ctx->pdev,
						WLAN_REG_CH_TO_FREQ(i)))) {
		/*
		 * do not include 6 GHz channels since they are ambiguous with
		 * 2.4 GHz and 5 GHz channels. 6 GHz-aware applications should
		 * not be using this interface, but instead should be using the
		 * frequency-based interface
		 */
		if (wlan_reg_is_6ghz_chan_freq(cur_chan_list[i].center_freq))
			continue;
		channel_list->channels[num_channels] =
						WLAN_REG_CH_NUM(i);
						cur_chan_list[i].chan_num;
		num_channels++;
		}

	}

	qdf_mem_free(cur_chan_list);
	hdd_debug_rl("number of channels %d", num_channels);

	channel_list->num_channels = num_channels;
	wrqu->data.length = num_channels + 1;
	hdd_exit();

	return 0;
}

@@ -2007,9 +1989,8 @@ int iw_get_channel_list_with_cc(struct net_device *dev,
	uint8_t ubuf[CFG_COUNTRY_CODE_LEN] = {0};
	uint8_t ubuf_len = CFG_COUNTRY_CODE_LEN;
	struct channel_list_info channel_list;

	struct mac_context *mac = MAC_CONTEXT(mac_handle);
	hdd_enter_dev(dev);

	memset(&channel_list, 0, sizeof(channel_list));

	if (0 != iw_get_channel_list(dev, info, wrqu, (char *)&channel_list)) {
@@ -2028,15 +2009,13 @@ int iw_get_channel_list_with_cc(struct net_device *dev,
		return -EINVAL;
	}
	len = scnprintf(buf, WE_MAX_STR_LEN, "%u ", channel_list.num_channels);
	if (QDF_STATUS_SUCCESS == sme_get_country_code(mac_handle, ubuf,
						       &ubuf_len)) {
	ucfg_reg_get_cc_and_src(mac->psoc, ubuf);
	/* Printing Country code in getChannelList */
	for (i = 0; i < (ubuf_len - 1); i++)
		len += scnprintf(buf + len, WE_MAX_STR_LEN - len, "%c", ubuf[i]);
	}

	for (i = 0; i < channel_list.num_channels; i++)
		len += scnprintf(buf + len, WE_MAX_STR_LEN - len, " %u", channel_list.channels[i]);

	wrqu->data.length = strlen(extra) + 1;

	hdd_exit();