Эх сурвалжийг харах

qcacld-3.0: Fix channel weight in sap_sort_chl_weight_all

qcacld-2.0 to qcacld-3.0 propagation

Currently if acs configs channel width as 40/80MHZ, it may select
invalid channel as its second channel.
When doing sap_select_channel, if acs configs channel width as
40/80MHZ, every candidate channel and its adjacent channel should
be checked whether it can satisfy 40/80MHZ or not. Mark the weight
of the channel that can't satisfy 40/80MHZ as max value
in sap_sort_chl_weight_all, so it will not be selected.

Change-Id: I69abbb752be8d0fae2644a9000156735048d6d16
CRs-Fixed: 1085469
bings 8 жил өмнө
parent
commit
e278238ac1

+ 12 - 0
core/cds/inc/cds_reg_service.h

@@ -341,6 +341,11 @@ enum phy_ch_width {
 	CH_WIDTH_MAX
 	CH_WIDTH_MAX
 };
 };
 
 
+#define HT40PLUS_2G_FCC_CH_END       7
+#define HT40PLUS_2G_EURJAP_CH_END    9
+#define HT40MINUS_2G_CH_START        5
+#define HT40MINUS_2G_CH_END          13
+
 /**
 /**
  * struct ch_params_s
  * struct ch_params_s
  * @ch_width: channel width
  * @ch_width: channel width
@@ -382,6 +387,13 @@ QDF_STATUS cds_get_reg_domain_from_country_code(v_REGDOMAIN_t *pRegDomain,
 						const uint8_t *country_alpha2,
 						const uint8_t *country_alpha2,
 						enum country_src source);
 						enum country_src source);
 
 
+/**
+ * cds_is_fcc_regdomian() - is the regdomain FCC
+ *
+ * Return: true on FCC regdomain, false otherwise
+ */
+bool cds_is_fcc_regdomain(void);
+
 QDF_STATUS cds_read_default_country(uint8_t *default_country);
 QDF_STATUS cds_read_default_country(uint8_t *default_country);
 
 
 QDF_STATUS cds_get_channel_list_with_power(struct channel_power
 QDF_STATUS cds_get_channel_list_with_power(struct channel_power

+ 21 - 0
core/cds/src/cds_reg_service.c

@@ -39,6 +39,7 @@
 #include "cds_regdomain.h"
 #include "cds_regdomain.h"
 #include "cds_ieee80211_common_i.h"
 #include "cds_ieee80211_common_i.h"
 #include "sme_api.h"
 #include "sme_api.h"
+#include "wlan_hdd_main.h"
 
 
 const struct chan_map chan_mapping[NUM_CHANNELS] = {
 const struct chan_map chan_mapping[NUM_CHANNELS] = {
 	[CHAN_ENUM_1] = {2412, 1},
 	[CHAN_ENUM_1] = {2412, 1},
@@ -807,6 +808,26 @@ QDF_STATUS cds_get_reg_domain_from_country_code(v_REGDOMAIN_t *reg_domain_ptr,
 	return QDF_STATUS_SUCCESS;
 	return QDF_STATUS_SUCCESS;
 }
 }
 
 
+/**
+ * cds_is_fcc_regdomian() - is the regdomain FCC
+ *
+ * Return: true on FCC regdomain, false otherwise
+ */
+bool cds_is_fcc_regdomain(void)
+{
+	v_REGDOMAIN_t domainId;
+	hdd_context_t *hdd_ctx;
+
+	hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD);
+	if (wlan_hdd_validate_context(hdd_ctx))
+		return false;
+	cds_get_reg_domain_from_country_code(&domainId,
+			hdd_ctx->reg.alpha2, SOURCE_QUERY);
+	if (REGDOMAIN_FCC == domainId)
+		return true;
+	return false;
+}
+
 /*
 /*
  * cds_is_dsrc_channel() - is the channel DSRC
  * cds_is_dsrc_channel() - is the channel DSRC
  * @center_freq: center freq of the channel
  * @center_freq: center freq of the channel

+ 124 - 2
core/sap/src/sap_ch_select.c

@@ -1422,6 +1422,49 @@ static void sap_sort_chl_weight(tSapChSelSpectInfo *pSpectInfoParams)
 	}
 	}
 }
 }
 
 
+/**
+ * set_ht80_chl_bit() - to set availabe channel to ht80 channel bitmap
+ * @channel_bitmap: Pointer to the chan_bonding_bitmap structure
+ * @spect_info_params: Pointer to the tSapChSelSpectInfo structure
+ *
+ * Return: none
+ */
+static void set_ht80_chl_bit(chan_bonding_bitmap *channel_bitmap,
+			tSapChSelSpectInfo *spec_info_params)
+{
+	uint8_t i, j;
+	tSapSpectChInfo *spec_info;
+	int start_channel = 0;
+
+	channel_bitmap->chanBondingSet[0].startChannel =
+			acs_ht80_channels[0].chStartNum;
+	channel_bitmap->chanBondingSet[1].startChannel =
+			acs_ht80_channels[1].chStartNum;
+	channel_bitmap->chanBondingSet[2].startChannel =
+			acs_ht80_channels[2].chStartNum;
+	channel_bitmap->chanBondingSet[3].startChannel =
+			acs_ht80_channels[3].chStartNum;
+	channel_bitmap->chanBondingSet[4].startChannel =
+			acs_ht80_channels[4].chStartNum;
+	channel_bitmap->chanBondingSet[5].startChannel =
+			acs_ht80_channels[5].chStartNum;
+
+	spec_info = spec_info_params->pSpectCh;
+	for (j = 0; j < spec_info_params->numSpectChans; j++) {
+		for (i = 0; i < MAX_80MHZ_BANDS; i++) {
+			start_channel =
+				channel_bitmap->chanBondingSet[i].startChannel;
+			if (spec_info[j].chNum >= start_channel &&
+				(spec_info[j].chNum <= start_channel + 12)) {
+				channel_bitmap->chanBondingSet[i].channelMap |=
+					1 << ((spec_info[j].chNum -
+						start_channel)/4);
+				break;
+			}
+		}
+	}
+}
+
 /**
 /**
  * sap_sort_chl_weight_ht80() - to sort the channels with the least weight
  * sap_sort_chl_weight_ht80() - to sort the channels with the least weight
  * @pSpectInfoParams: Pointer to the tSapChSelSpectInfo structure
  * @pSpectInfoParams: Pointer to the tSapChSelSpectInfo structure
@@ -1435,7 +1478,15 @@ static void sap_sort_chl_weight_ht80(tSapChSelSpectInfo *pSpectInfoParams)
 	uint8_t i, j, n;
 	uint8_t i, j, n;
 	tSapSpectChInfo *pSpectInfo;
 	tSapSpectChInfo *pSpectInfo;
 	uint8_t minIdx;
 	uint8_t minIdx;
+	int start_channel = 0;
+	chan_bonding_bitmap *channel_bitmap;
 
 
+	channel_bitmap = qdf_mem_malloc(sizeof(chan_bonding_bitmap));
+	if (NULL == channel_bitmap) {
+		QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_DEBUG,
+			"%s: Failed to allocate memory", __func__);
+		return;
+	}
 	pSpectInfo = pSpectInfoParams->pSpectCh;
 	pSpectInfo = pSpectInfoParams->pSpectCh;
 	/* for each HT80 channel, calculate the combined weight of the
 	/* for each HT80 channel, calculate the combined weight of the
 	   four 20MHz weight */
 	   four 20MHz weight */
@@ -1503,6 +1554,24 @@ static void sap_sort_chl_weight_ht80(tSapChSelSpectInfo *pSpectInfoParams)
 		pSpectInfo[j + minIdx].weight = acs_ht80_channels[i].weight;
 		pSpectInfo[j + minIdx].weight = acs_ht80_channels[i].weight;
 	}
 	}
 
 
+	/*
+	 * mark the weight of the channel that can't satisfy 80MHZ
+	 * as max value, so that it will be sorted to the bottom
+	 */
+	set_ht80_chl_bit(channel_bitmap, pSpectInfoParams);
+	for (j = 0; j < pSpectInfoParams->numSpectChans; j++) {
+		for (i = 0; i < MAX_80MHZ_BANDS; i++) {
+			start_channel =
+				channel_bitmap->chanBondingSet[i].startChannel;
+			if (pSpectInfo[j].chNum >= start_channel &&
+				(pSpectInfo[j].chNum <=
+					start_channel + 12) &&
+				channel_bitmap->chanBondingSet[i].channelMap !=
+					SAP_80MHZ_MASK)
+				pSpectInfo[j].weight = SAP_ACS_WEIGHT_MAX * 4;
+		}
+	}
+
 	pSpectInfo = pSpectInfoParams->pSpectCh;
 	pSpectInfo = pSpectInfoParams->pSpectCh;
 	for (j = 0; j < pSpectInfoParams->numSpectChans; j++) {
 	for (j = 0; j < pSpectInfoParams->numSpectChans; j++) {
 		if (CHANNEL_165 == pSpectInfo[j].chNum) {
 		if (CHANNEL_165 == pSpectInfo[j].chNum) {
@@ -1521,6 +1590,7 @@ static void sap_sort_chl_weight_ht80(tSapChSelSpectInfo *pSpectInfoParams)
 			pSpectInfo->rssiAgr, pSpectInfo->bssCount);
 			pSpectInfo->rssiAgr, pSpectInfo->bssCount);
 		pSpectInfo++;
 		pSpectInfo++;
 	}
 	}
+	qdf_mem_free(channel_bitmap);
 }
 }
 
 
 /**
 /**
@@ -1675,6 +1745,7 @@ static void sap_sort_chl_weight_ht40_24_g(tSapChSelSpectInfo *pSpectInfoParams)
 	uint8_t i, j;
 	uint8_t i, j;
 	tSapSpectChInfo *pSpectInfo;
 	tSapSpectChInfo *pSpectInfo;
 	uint32_t tmpWeight1, tmpWeight2;
 	uint32_t tmpWeight1, tmpWeight2;
+	uint32_t ht40plus2gendch = 0;
 
 
 	pSpectInfo = pSpectInfoParams->pSpectCh;
 	pSpectInfo = pSpectInfoParams->pSpectCh;
 	/*
 	/*
@@ -1758,6 +1829,33 @@ static void sap_sort_chl_weight_ht40_24_g(tSapChSelSpectInfo *pSpectInfoParams)
 			}
 			}
 		}
 		}
 	}
 	}
+	/*
+	 * Every channel should be checked. Add the check for the omissive
+	 * channel. Mark the channel whose combination can't satisfy 40MHZ
+	 * as max value, so that it will be sorted to the bottom.
+	 */
+	if (cds_is_fcc_regdomain())
+		ht40plus2gendch = HT40PLUS_2G_FCC_CH_END;
+	else
+		ht40plus2gendch = HT40PLUS_2G_EURJAP_CH_END;
+	for (i = HT40MINUS_2G_CH_START; i <= ht40plus2gendch; i++) {
+		for (j = 0; j < pSpectInfoParams->numSpectChans; j++) {
+			if (pSpectInfo[j].chNum == i &&
+				((pSpectInfo[j].chNum + 4) !=
+					pSpectInfo[j+4].chNum) &&
+				((pSpectInfo[j].chNum - 4) !=
+					pSpectInfo[j-4].chNum))
+				pSpectInfo[j].weight = SAP_ACS_WEIGHT_MAX * 2;
+		}
+	}
+	for (i = ht40plus2gendch + 1; i <= HT40MINUS_2G_CH_END; i++) {
+		for (j = 0; j < pSpectInfoParams->numSpectChans; j++) {
+			if (pSpectInfo[j].chNum == i &&
+				(pSpectInfo[j].chNum - 4) !=
+					pSpectInfo[j-4].chNum)
+				pSpectInfo[j].weight = SAP_ACS_WEIGHT_MAX * 2;
+		}
+	}
 	sap_sort_chl_weight(pSpectInfoParams);
 	sap_sort_chl_weight(pSpectInfoParams);
 }
 }
 
 
@@ -1821,6 +1919,23 @@ static void sap_sort_chl_weight_ht40_5_g(tSapChSelSpectInfo *pSpectInfoParams)
 			pSpectInfo[j].weight = SAP_ACS_WEIGHT_MAX * 2;
 			pSpectInfo[j].weight = SAP_ACS_WEIGHT_MAX * 2;
 	}
 	}
 
 
+	/*
+	 *Every channel should be checked. Add the check for the omissive
+	 * channel. Mark the channel whose combination can't satisfy 40MHZ
+	 * as max value, so that it will be sorted to the bottom
+	 */
+	for (j = 1; j < pSpectInfoParams->numSpectChans; j++) {
+		for (i = 0; i < ARRAY_SIZE(acs_ht40_channels5_g); i++) {
+			if (pSpectInfo[j].chNum ==
+					(acs_ht40_channels5_g[i].chStartNum +
+						4) &&
+				pSpectInfo[j - 1].chNum !=
+					acs_ht40_channels5_g[i].chStartNum) {
+				pSpectInfo[j].weight = SAP_ACS_WEIGHT_MAX * 2;
+				break;
+			}
+		}
+	}
 	/* avoid channel 165 by setting its weight to max */
 	/* avoid channel 165 by setting its weight to max */
 	pSpectInfo = pSpectInfoParams->pSpectCh;
 	pSpectInfo = pSpectInfoParams->pSpectCh;
 	for (j = 0; j < pSpectInfoParams->numSpectChans; j++) {
 	for (j = 0; j < pSpectInfoParams->numSpectChans; j++) {
@@ -2078,6 +2193,7 @@ uint8_t sap_select_channel(tHalHandle hal, ptSapContext sap_ctx,
 	tSapChSelSpectInfo spect_info_obj = { NULL, 0 };
 	tSapChSelSpectInfo spect_info_obj = { NULL, 0 };
 	tSapChSelSpectInfo *spect_info = &spect_info_obj;
 	tSapChSelSpectInfo *spect_info = &spect_info_obj;
 	uint8_t best_ch_num = SAP_CHANNEL_NOT_SELECTED;
 	uint8_t best_ch_num = SAP_CHANNEL_NOT_SELECTED;
+	uint32_t ht40plus2gendch = 0;
 #ifdef SOFTAP_CHANNEL_RANGE
 #ifdef SOFTAP_CHANNEL_RANGE
 	uint8_t count;
 	uint8_t count;
 	uint32_t start_ch_num, end_ch_num, tmp_ch_num, operating_band = 0;
 	uint32_t start_ch_num, end_ch_num, tmp_ch_num, operating_band = 0;
@@ -2220,7 +2336,12 @@ uint8_t sap_select_channel(tHalHandle hal, ptSapContext sap_ctx,
 	    (sap_ctx->acs_cfg->ch_width != CH_WIDTH_40MHZ))
 	    (sap_ctx->acs_cfg->ch_width != CH_WIDTH_40MHZ))
 		goto sap_ch_sel_end;
 		goto sap_ch_sel_end;
 
 
-	if ((best_ch_num >= 5) && (best_ch_num <= 7)) {
+	if (cds_is_fcc_regdomain())
+		ht40plus2gendch = HT40PLUS_2G_FCC_CH_END;
+	else
+		ht40plus2gendch = HT40PLUS_2G_EURJAP_CH_END;
+	if ((best_ch_num >= HT40MINUS_2G_CH_START) &&
+			(best_ch_num <= ht40plus2gendch)) {
 		int weight_below, weight_above, i;
 		int weight_below, weight_above, i;
 		tSapSpectChInfo *pspect_info;
 		tSapSpectChInfo *pspect_info;
 
 
@@ -2241,7 +2362,8 @@ uint8_t sap_select_channel(tHalHandle hal, ptSapContext sap_ctx,
 					sap_ctx->acs_cfg->pri_ch + 4;
 					sap_ctx->acs_cfg->pri_ch + 4;
 	} else if (best_ch_num >= 1 && best_ch_num <= 4) {
 	} else if (best_ch_num >= 1 && best_ch_num <= 4) {
 		sap_ctx->acs_cfg->ht_sec_ch = sap_ctx->acs_cfg->pri_ch + 4;
 		sap_ctx->acs_cfg->ht_sec_ch = sap_ctx->acs_cfg->pri_ch + 4;
-	} else if (best_ch_num >= 8 && best_ch_num <= 13) {
+	} else if (best_ch_num >= ht40plus2gendch && best_ch_num <=
+			HT40MINUS_2G_CH_END) {
 		sap_ctx->acs_cfg->ht_sec_ch = sap_ctx->acs_cfg->pri_ch - 4;
 		sap_ctx->acs_cfg->ht_sec_ch = sap_ctx->acs_cfg->pri_ch - 4;
 	} else if (best_ch_num == 14) {
 	} else if (best_ch_num == 14) {
 		sap_ctx->acs_cfg->ht_sec_ch = 0;
 		sap_ctx->acs_cfg->ht_sec_ch = 0;