qcacld-3.0: Fill correct txpower information

As a part of 802.11ax amendment, 6GHz band operation is added.
Since the 6 GHz channel numbers are overlapping with existing 2.4GHz
and 5GHz channel numbers, use frequency to identify unique channel
operation instead of channel number. Channel frequency is unique across
bands.

As a part of above requirement frequency attribute is added to the
struct sSirMacChanInfo, in driver some APIs directly copies this
structure info considering as every member of the structure as uint8_t,
as frequency is uint32_t this breaks above asumption and results into
corrupt info and gives undefined behaviour.

To address above issue, use the structure members individually and
give the information by member-by-member copy.

Change-Id: Ied6ad30d8a0800211f99371969ddd192ff40545c
CRs-Fixed: 2537975
This commit is contained in:
Ashish Kumar Dhanotiya
2019-09-19 18:06:30 +05:30
committed by nshrivas
szülő 3548a66560
commit b035570f53
10 fájl változott, egészen pontosan 272 új sor hozzáadva és 69 régi sor törölve

Fájl megtekintése

@@ -1710,17 +1710,17 @@ static void mlme_init_power_cfg(struct wlan_objmgr_psoc *psoc,
power->tx_power_2g = cfg_get(psoc, CFG_SET_TXPOWER_LIMIT2G);
power->tx_power_5g = cfg_get(psoc, CFG_SET_TXPOWER_LIMIT5G);
power->max_tx_power_24.max_len = CFG_MAX_TX_POWER_2_4_LEN;
power->max_tx_power_24_chan.max_len = CFG_MAX_TX_POWER_2_4_LEN;
qdf_uint8_array_parse(cfg_default(CFG_MAX_TX_POWER_2_4),
power->max_tx_power_24.data,
sizeof(power->max_tx_power_24.data),
&power->max_tx_power_24.len);
power->max_tx_power_24_chan.data,
sizeof(power->max_tx_power_24_chan.data),
&power->max_tx_power_24_chan.len);
power->max_tx_power_5.max_len = CFG_MAX_TX_POWER_5_LEN;
power->max_tx_power_5_chan.max_len = CFG_MAX_TX_POWER_5_LEN;
qdf_uint8_array_parse(cfg_default(CFG_MAX_TX_POWER_5),
power->max_tx_power_5.data,
sizeof(power->max_tx_power_5.data),
&power->max_tx_power_5.len);
power->max_tx_power_5_chan.data,
sizeof(power->max_tx_power_5_chan.data),
&power->max_tx_power_5_chan.len);
power->power_usage.max_len = CFG_POWER_USAGE_MAX_LEN;
power->power_usage.len = CFG_POWER_USAGE_MAX_LEN;

Fájl megtekintése

@@ -29,6 +29,9 @@
* @Min: 0 minimum length of tx power
* @Max: default data length of tx power in string format
* @Default: 1, 14, 20
*
* This ini contains the string in the form of first_channel number,
* number of channels and max tx power triplets
*/
#define CFG_MAX_TX_POWER_2_4_DATA "1, 14, 20"
#define CFG_MAX_TX_POWER_2_4 CFG_STRING( \
@@ -44,6 +47,9 @@
* @Min: 0 minimum length of tx power
* @Max: default data length of tx power in string format
* @Default: 36, 126, 20
*
* This ini contains the string in the form of first_channel number,
* number of channels and max tx power triplets
*/
#define CFG_MAX_TX_POWER_5_DATA "36, 126, 20"
#define CFG_MAX_TX_POWER_5 CFG_STRING( \

Fájl megtekintése

@@ -54,7 +54,7 @@
#define CFG_STR_DATA_LEN 17
#define CFG_EDCA_DATA_LEN 17
#define CFG_MAX_TX_POWER_2_4_LEN 128
#define CFG_MAX_TX_POWER_5_LEN 128
#define CFG_MAX_TX_POWER_5_LEN 256
#define CFG_POWER_USAGE_MAX_LEN 4
#define CFG_MAX_STR_LEN 256
#define MAX_VENDOR_IES_LEN 1532
@@ -1882,8 +1882,18 @@ struct mlme_power_usage {
/*
* struct wlan_mlme_power - power related config items
* @max_tx_power_24: max power Tx for 2.4 ghz
* @max_tx_power_5: max power Tx for 5 ghz
* @max_tx_power_24: max power Tx for 2.4 ghz, this is based on frequencies
* @max_tx_power_5: max power Tx for 5 ghz, this is based on frequencies
* @max_tx_power_24_chan: max power Tx for 2.4 ghz, this is based on channel
* numbers, this is added to parse the ini values to maintain the backward
* compatibility, these channel numbers are converted to frequencies and copied
* to max_tx_power_24 structure, once this conversion is done this structure
* should not be used.
* @max_tx_power_5_chan: max power Tx for 5 ghz, this is based on channel
* numbers, this is added to parse the ini values to maintain the backward
* compatibility, these channel numbers are converted to frequencies and copied
* to max_tx_power_24 structure, once this conversion is done this structure
* should not be used.
* @power_usage: power usage mode, min, max, mod
* @tx_power_2g: limit tx power in 2.4 ghz
* @tx_power_5g: limit tx power in 5 ghz
@@ -1894,6 +1904,8 @@ struct mlme_power_usage {
struct wlan_mlme_power {
struct mlme_max_tx_power_24 max_tx_power_24;
struct mlme_max_tx_power_5 max_tx_power_5;
struct mlme_max_tx_power_24 max_tx_power_24_chan;
struct mlme_max_tx_power_5 max_tx_power_5_chan;
struct mlme_power_usage power_usage;
uint8_t tx_power_2g;
uint8_t tx_power_5g;

Fájl megtekintése

@@ -101,6 +101,17 @@ QDF_STATUS ucfg_mlme_global_init(void);
*/
QDF_STATUS ucfg_mlme_global_deinit(void);
/**
* ucfg_mlme_cfg_chan_to_freq() - convert channel numbers to frequencies
* @pdev: pointer to pdev object
*
* convert the channels numbers received as part of cfg items to
* frequencies.
*
* Return: None
*/
void ucfg_mlme_cfg_chan_to_freq(struct wlan_objmgr_pdev *pdev);
/**
* wlan_mlme_get_power_usage() - Get the power usage info
* @psoc: pointer to psoc object

Fájl megtekintése

@@ -155,6 +155,104 @@ QDF_STATUS ucfg_mlme_pdev_close(struct wlan_objmgr_pdev *pdev)
return QDF_STATUS_SUCCESS;
}
/**
* ucfg_mlme_convert_power_cfg_chan_to_freq() - converts channel numbers to
* frequencies and copies the triplets to power_freq_data array
* @pdev: pointer to pdev object
* @max_length: Max length of the power chan data array
* @length: length of the data present in power_chan_data array
* @power_chan_data: Power data array from which channel numbers needs to be
* converted to frequencies
* @power_freq_data: Power data array in which the power data needs to be copied
* after conversion of channel numbers to frequencies
*
* power_data is received in the form of (first_channel_number,
* number_of_channels, max_tx_power) triplet, convert the channel numbers from
* the power_chan_data array to frequencies and copy the triplets
* (first_frequency, number_of_channels, max_tx_power) values to
* the power_freq_data array
*
* Return: Number of bytes filled in power_freq_data
*/
static uint32_t ucfg_mlme_convert_power_cfg_chan_to_freq(
struct wlan_objmgr_pdev *pdev,
uint32_t max_length,
qdf_size_t length,
uint8_t *power_chan_data,
uint8_t *power_freq_data)
{
uint32_t count = 0, rem_length = length, copied_length = 0, i = 0;
tSirMacChanInfo *pwr_cfg_data;
pwr_cfg_data = qdf_mem_malloc(max_length);
if (!pwr_cfg_data)
return 0;
mlme_legacy_debug("max_length %d length %zu", max_length, length);
while ((rem_length >= 3) &&
(copied_length <= (max_length - (sizeof(tSirMacChanInfo))))) {
pwr_cfg_data[i].first_freq = wlan_reg_chan_to_freq(
pdev,
power_chan_data[count++]);
pwr_cfg_data[i].numChannels = power_chan_data[count++];
pwr_cfg_data[i].maxTxPower = power_chan_data[count++];
copied_length += sizeof(tSirMacChanInfo);
rem_length -= 3;
mlme_legacy_debug("First freq %d num channels %d max tx power %d",
pwr_cfg_data[i].first_freq,
pwr_cfg_data[i].numChannels,
pwr_cfg_data[i].maxTxPower);
i++;
}
qdf_mem_zero(power_freq_data, max_length);
qdf_mem_copy(power_freq_data, pwr_cfg_data, copied_length);
qdf_mem_free(pwr_cfg_data);
return copied_length;
}
void ucfg_mlme_cfg_chan_to_freq(struct wlan_objmgr_pdev *pdev)
{
struct wlan_objmgr_psoc *psoc = wlan_pdev_get_psoc(pdev);
struct wlan_mlme_psoc_obj *mlme_obj;
struct wlan_mlme_cfg *mlme_cfg;
uint32_t converted_data_len = 0;
mlme_obj = mlme_get_psoc_obj(psoc);
if (!mlme_obj)
return;
mlme_cfg = &mlme_obj->cfg;
mlme_cfg->power.max_tx_power_24.max_len = CFG_MAX_TX_POWER_2_4_LEN;
converted_data_len = ucfg_mlme_convert_power_cfg_chan_to_freq(
pdev,
mlme_cfg->power.max_tx_power_24_chan.max_len,
mlme_cfg->power.max_tx_power_24_chan.len,
mlme_cfg->power.max_tx_power_24_chan.data,
mlme_cfg->power.max_tx_power_24.data);
if (!converted_data_len) {
mlme_legacy_err("mlme cfg power 2_4 data chan number to freq failed");
return;
}
mlme_cfg->power.max_tx_power_24.len = converted_data_len;
mlme_cfg->power.max_tx_power_5.max_len = CFG_MAX_TX_POWER_5_LEN;
converted_data_len = ucfg_mlme_convert_power_cfg_chan_to_freq(
pdev,
mlme_cfg->power.max_tx_power_5_chan.max_len,
mlme_cfg->power.max_tx_power_5_chan.len,
mlme_cfg->power.max_tx_power_5_chan.data,
mlme_cfg->power.max_tx_power_5.data);
if (!converted_data_len) {
mlme_legacy_err("mlme cfg power 5 data chan number to freq failed");
return;
}
mlme_cfg->power.max_tx_power_5.len = converted_data_len;
}
QDF_STATUS
ucfg_mlme_get_sta_keep_alive_period(struct wlan_objmgr_psoc *psoc,
uint32_t *val)