diff --git a/components/cmn_services/policy_mgr/src/wlan_policy_mgr_core.c b/components/cmn_services/policy_mgr/src/wlan_policy_mgr_core.c index f5a91a2ec465..939ef9870d60 100644 --- a/components/cmn_services/policy_mgr/src/wlan_policy_mgr_core.c +++ b/components/cmn_services/policy_mgr/src/wlan_policy_mgr_core.c @@ -1806,12 +1806,13 @@ enum phy_ch_width policy_mgr_get_ch_width(enum hw_mode_bandwidth bw) /** * policy_mgr_get_sbs_channels() - provides the sbs channel(s) - * with respect to current connection(s) - * @channels: the channel(s) on which current connection(s) is - * @len: Number of channels - * @pcl_weight: Pointer to the weights of PCL - * @weight_len: Max length of the weight list - * @index: Index from which the weight list needs to be populated + * with respect to current connection(s) + * @psoc: psoc object + * @pcl_freqs: the channel(s) on which current connection(s) is + * @pcl_weights: Pointer to the weights of PCL + * @pcl_sz: Max length of the PCL list + * @index: Index from which the weight list needs to be populated, + * will increase accordingly if any channel is obtained * @group_id: Next available groups for weight assignment * @available_5g_channels: List of available 5g channels * @available_5g_channels_len: Length of the 5g channels list @@ -1823,25 +1824,34 @@ enum phy_ch_width policy_mgr_get_ch_width(enum hw_mode_bandwidth bw) * Return: QDF_STATUS */ -static QDF_STATUS policy_mgr_get_sbs_channels( - uint32_t *ch_freq_list, - uint32_t *len, uint8_t *pcl_weight, uint32_t weight_len, - uint32_t *index, enum policy_mgr_pcl_group_id group_id, - uint32_t *available_5g_ch_freqs, - uint32_t available_5g_channels_len, - bool add_5g_channels) +static QDF_STATUS +policy_mgr_get_sbs_channels(struct wlan_objmgr_psoc *psoc, uint32_t *pcl_freqs, + uint8_t *pcl_weights, uint32_t pcl_sz, + uint32_t *index, + enum policy_mgr_pcl_group_id group_id, + uint32_t *available_5g_ch_freqs, + uint32_t available_5g_channels_len, + bool add_5g_channels) { - QDF_STATUS status = QDF_STATUS_SUCCESS; - uint32_t conn_index = 0, num_channels = 0; + uint32_t conn_index = 0; uint32_t num_5g_channels = 0, cur_5g_ch_freq = 0; uint32_t remaining_5g_ch_freqs[NUM_CHANNELS] = {}; uint32_t remaining_channel_index = 0; - uint32_t j = 0, i = 0, weight1, weight2; + uint32_t j = 0, i = 0, weight1, weight2, idx; + struct policy_mgr_psoc_priv_obj *pm_ctx; - if (!ch_freq_list || !len) { + if (!policy_mgr_is_hw_sbs_capable(psoc)) + return QDF_STATUS_E_NOSUPPORT; + + if (!pcl_freqs || !pcl_weights || !index || !pcl_sz) { policy_mgr_err("channels or len is NULL"); - status = QDF_STATUS_E_FAILURE; - return status; + return QDF_STATUS_E_INVAL; + } + + pm_ctx = policy_mgr_get_context(psoc); + if (!pm_ctx) { + policy_mgr_err("Invalid Context"); + return QDF_STATUS_E_FAILURE; } if (group_id == POLICY_MGR_PCL_GROUP_ID1_ID2) { @@ -1855,9 +1865,11 @@ static QDF_STATUS policy_mgr_get_sbs_channels( weight2 = WEIGHT_OF_GROUP4_PCL_CHANNELS; } + idx = *index; policy_mgr_debug("weight1=%d weight2=%d index=%d ", - weight1, weight2, *index); + weight1, weight2, idx); + qdf_mutex_acquire(&pm_ctx->qdf_conc_list_lock); while (PM_CONC_CONNECTION_LIST_VALID_INDEX(conn_index)) { if (WLAN_REG_IS_5GHZ_CH_FREQ( pm_conc_connection_list[conn_index].freq) && @@ -1872,13 +1884,14 @@ static QDF_STATUS policy_mgr_get_sbs_channels( conn_index = 0; if (num_5g_channels > 1) { /* This case we are already in SBS so return the channels */ - while (PM_CONC_CONNECTION_LIST_VALID_INDEX(conn_index)) { - ch_freq_list[num_channels++] = + while (PM_CONC_CONNECTION_LIST_VALID_INDEX(conn_index) && + idx < pcl_sz) { + pcl_freqs[idx] = pm_conc_connection_list[conn_index++].freq; - if (*index < weight_len) - pcl_weight[(*index)++] = weight1; + pcl_weights[idx] = weight1; + idx++; } - *len = num_channels; + /* fix duplicate issue later */ if (add_5g_channels) for (j = 0; j < available_5g_channels_len; j++) @@ -1889,33 +1902,38 @@ static QDF_STATUS policy_mgr_get_sbs_channels( /* Get list of valid sbs channels for the current * connected channel */ - for (j = 0; j < available_5g_channels_len; j++) { + for (j = 0; (j < available_5g_channels_len) && + (j < NUM_CHANNELS) && idx < pcl_sz; j++) { if (WLAN_REG_IS_FREQUENCY_VALID_5G_SBS( cur_5g_ch_freq, available_5g_ch_freqs[j])) { - ch_freq_list[num_channels++] = - available_5g_ch_freqs[j]; + pcl_freqs[idx] = available_5g_ch_freqs[j]; + pcl_weights[idx] = weight1; + idx++; } else { remaining_5g_ch_freqs[ remaining_channel_index++] = available_5g_ch_freqs[j]; continue; } - if (*index < weight_len) - pcl_weight[(*index)++] = weight1; } - *len = num_channels; } if (add_5g_channels) { - qdf_mem_copy(ch_freq_list + num_channels, remaining_5g_ch_freqs, - remaining_channel_index * sizeof(*ch_freq_list)); - *len += remaining_channel_index; - for (i = 0; ((i < remaining_channel_index) - && (i < weight_len)); i++) - pcl_weight[i] = weight2; + remaining_channel_index = + QDF_MIN(idx + remaining_channel_index, pcl_sz) - idx; + qdf_mem_copy(&pcl_freqs[idx], remaining_5g_ch_freqs, + remaining_channel_index * sizeof(*pcl_freqs)); + + for (i = idx; i < idx + remaining_channel_index; i++) + pcl_weights[i] = weight2; + + idx += remaining_channel_index; } - return status; + *index = idx; + qdf_mutex_release(&pm_ctx->qdf_conc_list_lock); + + return QDF_STATUS_SUCCESS; } /** @@ -1923,36 +1941,37 @@ static QDF_STATUS policy_mgr_get_sbs_channels( * on which current connection(s) is * @psoc: psoc object * @mode: conn mode - * @ch_freq_list: the channel(s) on which current connection(s) is - * @len: Number of channels - * @order: no order OR 2.4 Ghz channel followed by 5 Ghz - * channel OR 5 Ghz channel followed by 2.4 Ghz channel + * @order: no order OR 2.4 Ghz channel followed by 5 Ghz channel OR + * 5 Ghz channel followed by 2.4 Ghz channel * @skip_dfs_channel: if this flag is true then skip the dfs channel - * @pcl_weight: Pointer to the weights of PCL - * @weight_len: Max length of the weight list - * @index: Index from which the weight list needs to be populated * @group_id: Next available groups for weight assignment - * + * @pcl_freqs: Pointer to the frequencies of PCL + * @pcl_weights: Pointer to the weights of PCL + * @pcl_sz: Max length of the PCL list + * @index: Index from which the PCL list needs to be populated, + * will increase accordingly if any channel is obtained * * This function provides the channel(s) on which current * connection(s) is/are * * Return: QDF_STATUS */ -static -QDF_STATUS policy_mgr_get_connection_channels(struct wlan_objmgr_psoc *psoc, - enum policy_mgr_con_mode mode, - uint32_t *ch_freq_list, - uint32_t *len, enum policy_mgr_pcl_channel_order order, - bool skip_dfs_channel, - uint8_t *pcl_weight, uint32_t weight_len, - uint32_t *index, enum policy_mgr_pcl_group_id group_id) +static QDF_STATUS +policy_mgr_get_connection_channels(struct wlan_objmgr_psoc *psoc, + enum policy_mgr_con_mode mode, + enum policy_mgr_pcl_channel_order order, + bool skip_dfs_channel, + enum policy_mgr_pcl_group_id group_id, + uint32_t *pcl_freqs, uint8_t *pcl_weights, + uint32_t pcl_sz, uint32_t *index) { QDF_STATUS status = QDF_STATUS_SUCCESS; - uint32_t conn_index = 0, num_channels = 0; + uint32_t conn_index = 0; uint32_t weight1, weight2; struct policy_mgr_psoc_priv_obj *pm_ctx; + struct policy_mgr_conc_connection_info *cl; bool add_6ghz = true; + uint32_t idx; pm_ctx = policy_mgr_get_context(psoc); if (!pm_ctx) { @@ -1960,12 +1979,14 @@ QDF_STATUS policy_mgr_get_connection_channels(struct wlan_objmgr_psoc *psoc, return status; } - if (!ch_freq_list || !len) { - policy_mgr_err("channels or len is NULL"); - status = QDF_STATUS_E_FAILURE; + if (!pcl_freqs || !pcl_weights || !index || !pcl_sz) { + policy_mgr_err("list or index is NULL"); + status = QDF_STATUS_E_INVAL; return status; } + idx = *index; + /* POLICY_MGR_PCL_GROUP_ID1_ID2 indicates that all three weights are * available for assignment. i.e., WEIGHT_OF_GROUP1_PCL_CHANNELS, * WEIGHT_OF_GROUP2_PCL_CHANNELS and WEIGHT_OF_GROUP3_PCL_CHANNELS @@ -1997,52 +2018,47 @@ QDF_STATUS policy_mgr_get_connection_channels(struct wlan_objmgr_psoc *psoc, add_6ghz = false; qdf_mutex_acquire(&pm_ctx->qdf_conc_list_lock); + cl = pm_conc_connection_list; if (POLICY_MGR_PCL_ORDER_NONE == order) { while (PM_CONC_CONNECTION_LIST_VALID_INDEX(conn_index)) { bool is_6ghz_ch = WLAN_REG_IS_6GHZ_CHAN_FREQ( - pm_conc_connection_list[conn_index].freq); + cl[conn_index].freq); if (skip_dfs_channel && wlan_reg_is_dfs_for_freq( - pm_ctx->pdev, - pm_conc_connection_list[conn_index].freq)) { + pm_ctx->pdev, cl[conn_index].freq)) { conn_index++; - } else if ((*index < weight_len) && + } else if ((idx < pcl_sz) && (!is_6ghz_ch || add_6ghz)) { - ch_freq_list[num_channels++] = - pm_conc_connection_list[ - conn_index++].freq; - pcl_weight[(*index)++] = weight1; + pcl_freqs[idx] = cl[conn_index++].freq; + pcl_weights[idx] = weight1; + idx++; } else { conn_index++; } } - *len = num_channels; } else if (POLICY_MGR_PCL_ORDER_24G_THEN_5G == order) { while (PM_CONC_CONNECTION_LIST_VALID_INDEX(conn_index)) { - if (WLAN_REG_IS_24GHZ_CH_FREQ( - pm_conc_connection_list[conn_index].freq) - && (*index < weight_len)) { - ch_freq_list[num_channels++] = - pm_conc_connection_list[ - conn_index++].freq; - pcl_weight[(*index)++] = weight1; + if (WLAN_REG_IS_24GHZ_CH_FREQ(cl[conn_index].freq) && + idx < pcl_sz) { + pcl_freqs[idx] = cl[conn_index++].freq; + pcl_weights[idx] = weight1; + idx++; } else { conn_index++; } } + conn_index = 0; while (PM_CONC_CONNECTION_LIST_VALID_INDEX(conn_index)) { if (skip_dfs_channel && - wlan_reg_is_dfs_for_freq( - pm_ctx->pdev, - pm_conc_connection_list[conn_index].freq)) { + wlan_reg_is_dfs_for_freq(pm_ctx->pdev, + cl[conn_index].freq)) { conn_index++; } else if (WLAN_REG_IS_5GHZ_CH_FREQ( - pm_conc_connection_list[conn_index].freq) && - (*index < weight_len)) { - ch_freq_list[num_channels++] = - pm_conc_connection_list[ - conn_index++].freq; - pcl_weight[(*index)++] = weight2; + cl[conn_index].freq) && + (idx < pcl_sz)) { + pcl_freqs[idx] = cl[conn_index++].freq; + pcl_weights[idx] = weight2; + idx++; } else { conn_index++; } @@ -2051,44 +2067,38 @@ QDF_STATUS policy_mgr_get_connection_channels(struct wlan_objmgr_psoc *psoc, while (add_6ghz && PM_CONC_CONNECTION_LIST_VALID_INDEX(conn_index)) { bool is_6ghz_ch = WLAN_REG_IS_6GHZ_CHAN_FREQ( - pm_conc_connection_list[conn_index].freq); - if (is_6ghz_ch && (*index < weight_len)) { - ch_freq_list[num_channels++] = - pm_conc_connection_list[ - conn_index++].freq; - pcl_weight[(*index)++] = weight2; + cl[conn_index].freq); + if (is_6ghz_ch && idx < pcl_sz) { + pcl_freqs[idx] = cl[conn_index++].freq; + pcl_weights[idx] = weight2; + idx++; } else { conn_index++; } } - *len = num_channels; } else if (POLICY_MGR_PCL_ORDER_5G_THEN_2G == order) { while (PM_CONC_CONNECTION_LIST_VALID_INDEX(conn_index)) { if (skip_dfs_channel && wlan_reg_is_dfs_for_freq( - pm_ctx->pdev, - pm_conc_connection_list[conn_index].freq)) { + pm_ctx->pdev, cl[conn_index].freq)) { conn_index++; } else if (WLAN_REG_IS_5GHZ_CH_FREQ( - pm_conc_connection_list[conn_index].freq) && - (*index < weight_len)) { - ch_freq_list[num_channels++] = - pm_conc_connection_list[ - conn_index++].freq; - pcl_weight[(*index)++] = weight1; + cl[conn_index].freq) && + (idx < pcl_sz)) { + pcl_freqs[idx] = cl[conn_index++].freq; + pcl_weights[idx] = weight1; + idx++; } else { conn_index++; } } conn_index = 0; while (PM_CONC_CONNECTION_LIST_VALID_INDEX(conn_index)) { - if (WLAN_REG_IS_24GHZ_CH_FREQ( - pm_conc_connection_list[conn_index].freq) && - (*index < weight_len)) { - ch_freq_list[num_channels++] = - pm_conc_connection_list[ - conn_index++].freq; - pcl_weight[(*index)++] = weight2; + if (WLAN_REG_IS_24GHZ_CH_FREQ(cl[conn_index].freq) && + idx < pcl_sz) { + pcl_freqs[idx] = cl[conn_index++].freq; + pcl_weights[idx] = weight2; + idx++; } else { conn_index++; @@ -2098,21 +2108,21 @@ QDF_STATUS policy_mgr_get_connection_channels(struct wlan_objmgr_psoc *psoc, while (add_6ghz && PM_CONC_CONNECTION_LIST_VALID_INDEX(conn_index)) { bool is_6ghz_ch = WLAN_REG_IS_6GHZ_CHAN_FREQ( - pm_conc_connection_list[conn_index].freq); - if (is_6ghz_ch && (*index < weight_len)) { - ch_freq_list[num_channels++] = - pm_conc_connection_list[ - conn_index++].freq; - pcl_weight[(*index)++] = weight2; + cl[conn_index].freq); + if (is_6ghz_ch && idx < pcl_sz) { + pcl_freqs[idx] = cl[conn_index++].freq; + pcl_weights[idx] = weight2; + idx++; } else { conn_index++; } } - *len = num_channels; } else { policy_mgr_err("unknown order %d", order); status = QDF_STATUS_E_FAILURE; } + + *index = idx; qdf_mutex_release(&pm_ctx->qdf_conc_list_lock); return status; @@ -2181,14 +2191,28 @@ void policy_mgr_set_weight_of_dfs_passive_channels_to_zero( return; } -static void policy_mgr_add_5g_to_pcl( - struct wlan_objmgr_psoc *psoc, - uint32_t *ch_freq_list, - uint32_t *len, - uint8_t *pcl_weight, uint32_t weight_len, - uint32_t *index, enum policy_mgr_pcl_group_id group_id, - const uint32_t *chlist_5g, uint8_t chlist_5g_len, - const uint32_t *chlist_6g, uint8_t chlist_6g_len) +/** + * policy_mgr_add_5g_to_pcl() - add the 5G/6G channels into PCL + * @psoc: psoc object + * @pcl_freqs: Pointer to the frequencies of PCL + * @pcl_weights: Pointer to the weights of PCL + * @pcl_sz: Max length of the PCL list + * @index: Index from which the PCL list needs to be populated, + * will increase accordingly if any channel is obtained + * @group_id: Next available groups for weight assignment + * @chlist_5g: Pointer to the 5G channel list + * @chlist_5g_len: Length of the 5G channel list + * @chlist_6g: Pointer to the 6G channel list + * @chlist_6g_len: Length of the 6G channel list + * + * Return: None + */ +static void +policy_mgr_add_5g_to_pcl(struct wlan_objmgr_psoc *psoc, uint32_t *pcl_freqs, + uint8_t *pcl_weights, uint32_t pcl_sz, uint32_t *index, + enum policy_mgr_pcl_group_id group_id, + const uint32_t *chlist_5g, uint8_t chlist_5g_len, + const uint32_t *chlist_6g, uint8_t chlist_6g_len) { struct policy_mgr_psoc_priv_obj *pm_ctx; uint32_t weight1, weight2; @@ -2197,6 +2221,7 @@ static void policy_mgr_add_5g_to_pcl( const uint32_t *chlist2; uint8_t chlist2_len; uint32_t i; + uint32_t len = 0, idx; pm_ctx = policy_mgr_get_context(psoc); if (!pm_ctx) { @@ -2204,6 +2229,8 @@ static void policy_mgr_add_5g_to_pcl( return; } + idx = *index; + if (group_id == POLICY_MGR_PCL_GROUP_ID1_ID2) { weight1 = WEIGHT_OF_GROUP1_PCL_CHANNELS; weight2 = WEIGHT_OF_GROUP2_PCL_CHANNELS; @@ -2225,42 +2252,74 @@ static void policy_mgr_add_5g_to_pcl( chlist2 = chlist_6g; chlist2_len = chlist_6g_len; } - if ((chlist1_len + *index) > weight_len) { + if ((chlist1_len + idx) > pcl_sz) { policy_mgr_err("no enough weight len %d chlist1_len %d %d", - weight_len, chlist1_len, *index); + pcl_sz, chlist1_len, idx); return; } - qdf_mem_copy(ch_freq_list, chlist1, chlist1_len * sizeof(*chlist1)); + qdf_mem_copy(&pcl_freqs[idx], chlist1, chlist1_len * sizeof(*chlist1)); for (i = 0; i < chlist1_len; i++) - pcl_weight[(*index)++] = weight1; + pcl_weights[idx++] = weight1; - *len += chlist1_len; + len += chlist1_len; - if ((chlist2_len + *index) > weight_len) { + if ((chlist2_len + idx) > pcl_sz) { policy_mgr_err("no enough weight len chlist2_len %d %d %d", - weight_len, chlist2_len, *index); + pcl_sz, chlist2_len, idx); return; } - qdf_mem_copy(&ch_freq_list[chlist1_len], chlist2, + qdf_mem_copy(&pcl_freqs[idx], chlist2, chlist2_len * sizeof(*chlist2)); for (i = 0; i < chlist2_len; i++) - pcl_weight[(*index)++] = weight2; - *len += chlist2_len; + pcl_weights[idx++] = weight2; + len += chlist2_len; + *index = idx; policy_mgr_debug("Add 5g chlist len %d 6g chlist len %d len %d index %d order %d", - chlist_5g_len, chlist_6g_len, *len, *index, + chlist_5g_len, chlist_6g_len, len, idx, pm_ctx->cfg.pcl_band_priority); } +/** + * policy_mgr_add_24g_to_pcl() - add the 2.4G channels into PCL + * @pcl_freqs: Pointer to the frequencies of PCL + * @pcl_weights: Pointer to the weights of PCL + * @pcl_sz: Max length of the PCL list + * @index: Index from which the PCL list needs to be populated, + * will increase accordingly if any channel is obtained + * @weight: group for weight assignment + * @chlist_24g: Pointer to the 2.4G channel list + * @chlist_24g_len: Length of the 2.4G channel list + * + * Return: None + */ +static void +policy_mgr_add_24g_to_pcl(uint32_t *pcl_freqs, uint8_t *pcl_weights, + uint32_t pcl_sz, uint32_t *index, uint32_t weight, + const uint32_t *chlist_24g, uint8_t chlist_24g_len) +{ + uint32_t num_to_add, i; + + num_to_add = QDF_MIN((*index + chlist_24g_len), pcl_sz) - *index; + qdf_mem_copy(&pcl_freqs[*index], chlist_24g, + num_to_add * sizeof(*chlist_24g)); + for (i = *index; i < *index + num_to_add; i++) + pcl_weights[i] = weight; + + *index = i; + policy_mgr_debug("Add 24g chlist len %d len %d index %d", + chlist_24g_len, num_to_add, *index); +} + /** * policy_mgr_get_channel_list() - provides the channel list * suggestion for new connection - * @pcl: The preferred channel list enum - * @pcl_channels: PCL channels - * @len: length of the PCL + * @pcl: The preferred channel list enum * @mode: concurrency mode for which channel list is requested + * @pcl_channels: PCL channels * @pcl_weights: Weights of the PCL - * @weight_len: Max length of the weight list + * @pcl_sz: Max length of the PCL list + * @len: length of the PCL obtained * * This function provides the actual channel list based on the * current regulatory domain derived using preferred channel @@ -2269,17 +2328,18 @@ static void policy_mgr_add_5g_to_pcl( * Return: Channel List */ QDF_STATUS policy_mgr_get_channel_list(struct wlan_objmgr_psoc *psoc, - enum policy_mgr_pcl_type pcl, - uint32_t *pcl_channels, uint32_t *len, - enum policy_mgr_con_mode mode, - uint8_t *pcl_weights, uint32_t weight_len) + enum policy_mgr_pcl_type pcl, + enum policy_mgr_con_mode mode, + uint32_t *pcl_channels, + uint8_t *pcl_weights, + uint32_t pcl_sz, uint32_t *len) { QDF_STATUS status = QDF_STATUS_E_FAILURE; uint32_t num_channels = 0; uint32_t sbs_num_channels = 0; uint32_t chan_index_24 = 0, chan_index_5 = 0, chan_index_6 = 0; bool skip_dfs_channel = false; - uint32_t i = 0, j = 0; + uint32_t i = 0; struct policy_mgr_psoc_priv_obj *pm_ctx; uint32_t *channel_list, *channel_list_24, *channel_list_5, *sbs_channel_list, *channel_list_6; @@ -2389,323 +2449,236 @@ QDF_STATUS policy_mgr_get_channel_list(struct wlan_objmgr_psoc *psoc, */ switch (pcl) { case PM_24G: - chan_index_24 = QDF_MIN(chan_index_24, weight_len); - qdf_mem_copy(pcl_channels, channel_list_24, - chan_index_24 * sizeof(*pcl_channels)); - *len = chan_index_24; - for (i = 0; i < *len; i++) - pcl_weights[i] = WEIGHT_OF_GROUP1_PCL_CHANNELS; + policy_mgr_add_24g_to_pcl(pcl_channels, pcl_weights, pcl_sz, + len, WEIGHT_OF_GROUP1_PCL_CHANNELS, + channel_list_24, chan_index_24); status = QDF_STATUS_SUCCESS; break; case PM_5G: - policy_mgr_add_5g_to_pcl( - psoc, pcl_channels, len, - pcl_weights, weight_len, - &i, - POLICY_MGR_PCL_GROUP_ID1_ID2, - channel_list_5, chan_index_5, - channel_list_6, chan_index_6); + policy_mgr_add_5g_to_pcl(psoc, pcl_channels, pcl_weights, + pcl_sz, len, + POLICY_MGR_PCL_GROUP_ID1_ID2, + channel_list_5, chan_index_5, + channel_list_6, chan_index_6); status = QDF_STATUS_SUCCESS; break; case PM_SCC_CH: case PM_MCC_CH: - policy_mgr_get_connection_channels( - psoc, mode, - channel_list, &num_channels, POLICY_MGR_PCL_ORDER_NONE, - skip_dfs_channel, pcl_weights, weight_len, &i, - POLICY_MGR_PCL_GROUP_ID1_ID2); - qdf_mem_copy(pcl_channels, channel_list, - num_channels * sizeof(*pcl_channels)); - *len = num_channels; + policy_mgr_get_connection_channels(psoc, mode, + POLICY_MGR_PCL_ORDER_NONE, + skip_dfs_channel, + POLICY_MGR_PCL_GROUP_ID1_ID2, + pcl_channels, pcl_weights, + pcl_sz, len); status = QDF_STATUS_SUCCESS; break; case PM_SCC_CH_24G: case PM_MCC_CH_24G: - policy_mgr_get_connection_channels( - psoc, mode, - channel_list, &num_channels, POLICY_MGR_PCL_ORDER_NONE, - skip_dfs_channel, pcl_weights, weight_len, &i, - POLICY_MGR_PCL_GROUP_ID1_ID2); - qdf_mem_copy(pcl_channels, channel_list, - num_channels * sizeof(*pcl_channels)); - *len = num_channels; - chan_index_24 = QDF_MIN((num_channels + chan_index_24), - weight_len) - num_channels; - qdf_mem_copy(&pcl_channels[num_channels], channel_list_24, - chan_index_24 * sizeof(*pcl_channels)); - *len += chan_index_24; - for (j = 0; j < chan_index_24; i++, j++) - pcl_weights[i] = WEIGHT_OF_GROUP2_PCL_CHANNELS; - + policy_mgr_get_connection_channels(psoc, mode, + POLICY_MGR_PCL_ORDER_NONE, + skip_dfs_channel, + POLICY_MGR_PCL_GROUP_ID1_ID2, + pcl_channels, pcl_weights, + pcl_sz, len); + policy_mgr_add_24g_to_pcl(pcl_channels, pcl_weights, pcl_sz, + len, WEIGHT_OF_GROUP2_PCL_CHANNELS, + channel_list_24, chan_index_24); status = QDF_STATUS_SUCCESS; break; case PM_SCC_CH_5G: case PM_MCC_CH_5G: - policy_mgr_get_connection_channels( - psoc, mode, - channel_list, &num_channels, POLICY_MGR_PCL_ORDER_NONE, - skip_dfs_channel, pcl_weights, weight_len, &i, - POLICY_MGR_PCL_GROUP_ID1_ID2); - qdf_mem_copy(pcl_channels, channel_list, - num_channels * sizeof(*pcl_channels)); - *len = num_channels; - policy_mgr_add_5g_to_pcl( - psoc, &pcl_channels[num_channels], len, - pcl_weights, weight_len, - &i, - POLICY_MGR_PCL_GROUP_ID2_ID3, - channel_list_5, chan_index_5, - channel_list_6, chan_index_6); + policy_mgr_get_connection_channels(psoc, mode, + POLICY_MGR_PCL_ORDER_NONE, + skip_dfs_channel, + POLICY_MGR_PCL_GROUP_ID1_ID2, + pcl_channels, pcl_weights, + pcl_sz, len); + policy_mgr_add_5g_to_pcl(psoc, pcl_channels, pcl_weights, + pcl_sz, len, + POLICY_MGR_PCL_GROUP_ID2_ID3, + channel_list_5, chan_index_5, + channel_list_6, chan_index_6); status = QDF_STATUS_SUCCESS; break; case PM_24G_SCC_CH: case PM_24G_MCC_CH: - chan_index_24 = QDF_MIN(chan_index_24, weight_len); - qdf_mem_copy(pcl_channels, channel_list_24, - chan_index_24 * sizeof(*pcl_channels)); - *len = chan_index_24; - for (i = 0; i < chan_index_24; i++) - pcl_weights[i] = WEIGHT_OF_GROUP1_PCL_CHANNELS; - policy_mgr_get_connection_channels( - psoc, mode, - channel_list, &num_channels, POLICY_MGR_PCL_ORDER_NONE, - skip_dfs_channel, pcl_weights, weight_len, &i, - POLICY_MGR_PCL_GROUP_ID2_ID3); - qdf_mem_copy(&pcl_channels[chan_index_24], channel_list, - num_channels * sizeof(*pcl_channels)); - *len += num_channels; + policy_mgr_add_24g_to_pcl(pcl_channels, pcl_weights, pcl_sz, + len, WEIGHT_OF_GROUP1_PCL_CHANNELS, + channel_list_24, chan_index_24); + policy_mgr_get_connection_channels(psoc, mode, + POLICY_MGR_PCL_ORDER_NONE, + skip_dfs_channel, + POLICY_MGR_PCL_GROUP_ID2_ID3, + pcl_channels, pcl_weights, + pcl_sz, len); status = QDF_STATUS_SUCCESS; break; case PM_5G_SCC_CH: case PM_5G_MCC_CH: - policy_mgr_add_5g_to_pcl( - psoc, pcl_channels, len, - pcl_weights, weight_len, - &i, - POLICY_MGR_PCL_GROUP_ID1_ID2, - channel_list_5, chan_index_5, - channel_list_6, chan_index_6); - - policy_mgr_get_connection_channels( - psoc, mode, - channel_list, &num_channels, POLICY_MGR_PCL_ORDER_NONE, - skip_dfs_channel, pcl_weights, weight_len, &i, - POLICY_MGR_PCL_GROUP_ID3_ID4); - qdf_mem_copy(&pcl_channels[*len], channel_list, - num_channels * sizeof(*pcl_channels)); - *len += num_channels; + policy_mgr_add_5g_to_pcl(psoc, pcl_channels, pcl_weights, + pcl_sz, len, + POLICY_MGR_PCL_GROUP_ID1_ID2, + channel_list_5, chan_index_5, + channel_list_6, chan_index_6); + policy_mgr_get_connection_channels(psoc, mode, + POLICY_MGR_PCL_ORDER_NONE, + skip_dfs_channel, + POLICY_MGR_PCL_GROUP_ID3_ID4, + pcl_channels, pcl_weights, + pcl_sz, len); status = QDF_STATUS_SUCCESS; break; case PM_SCC_ON_24_SCC_ON_5: policy_mgr_get_connection_channels( - psoc, mode, - channel_list, &num_channels, - POLICY_MGR_PCL_ORDER_24G_THEN_5G, - skip_dfs_channel, pcl_weights, weight_len, &i, - POLICY_MGR_PCL_GROUP_ID1_ID2); - qdf_mem_copy(pcl_channels, channel_list, - num_channels * sizeof(*pcl_channels)); - *len = num_channels; + psoc, mode, + POLICY_MGR_PCL_ORDER_24G_THEN_5G, + skip_dfs_channel, + POLICY_MGR_PCL_GROUP_ID1_ID2, + pcl_channels, pcl_weights, pcl_sz, len); status = QDF_STATUS_SUCCESS; break; case PM_SCC_ON_5_SCC_ON_24: policy_mgr_get_connection_channels( - psoc, mode, - channel_list, &num_channels, - POLICY_MGR_PCL_ORDER_5G_THEN_2G, - skip_dfs_channel, pcl_weights, weight_len, &i, - POLICY_MGR_PCL_GROUP_ID1_ID2); - qdf_mem_copy(pcl_channels, channel_list, - num_channels * sizeof(*pcl_channels)); - *len = num_channels; + psoc, mode, + POLICY_MGR_PCL_ORDER_5G_THEN_2G, + skip_dfs_channel, + POLICY_MGR_PCL_GROUP_ID1_ID2, + pcl_channels, pcl_weights, pcl_sz, len); status = QDF_STATUS_SUCCESS; break; case PM_SCC_ON_24_SCC_ON_5_24G: policy_mgr_get_connection_channels( - psoc, mode, - channel_list, &num_channels, - POLICY_MGR_PCL_ORDER_24G_THEN_5G, - skip_dfs_channel, pcl_weights, weight_len, &i, - POLICY_MGR_PCL_GROUP_ID1_ID2); - qdf_mem_copy(pcl_channels, channel_list, - num_channels * sizeof(*pcl_channels)); - *len = num_channels; - chan_index_24 = QDF_MIN((num_channels + chan_index_24), - weight_len) - num_channels; - qdf_mem_copy(&pcl_channels[num_channels], channel_list_24, - chan_index_24 * sizeof(*pcl_channels)); - *len += chan_index_24; - for (j = 0; j < chan_index_24; i++, j++) - pcl_weights[i] = WEIGHT_OF_GROUP3_PCL_CHANNELS; + psoc, mode, + POLICY_MGR_PCL_ORDER_24G_THEN_5G, + skip_dfs_channel, + POLICY_MGR_PCL_GROUP_ID1_ID2, + pcl_channels, pcl_weights, pcl_sz, len); + policy_mgr_add_24g_to_pcl(pcl_channels, pcl_weights, pcl_sz, + len, WEIGHT_OF_GROUP3_PCL_CHANNELS, + channel_list_24, chan_index_24); status = QDF_STATUS_SUCCESS; break; case PM_SCC_ON_24_SCC_ON_5_5G: policy_mgr_get_connection_channels( - psoc, mode, - channel_list, &num_channels, - POLICY_MGR_PCL_ORDER_24G_THEN_5G, - skip_dfs_channel, pcl_weights, weight_len, &i, - POLICY_MGR_PCL_GROUP_ID1_ID2); - qdf_mem_copy(pcl_channels, channel_list, - num_channels * sizeof(*pcl_channels)); - *len = num_channels; - policy_mgr_add_5g_to_pcl( - psoc, &pcl_channels[num_channels], len, - pcl_weights, weight_len, - &i, - POLICY_MGR_PCL_GROUP_ID3_ID4, - channel_list_5, chan_index_5, - channel_list_6, chan_index_6); + psoc, mode, + POLICY_MGR_PCL_ORDER_24G_THEN_5G, + skip_dfs_channel, + POLICY_MGR_PCL_GROUP_ID1_ID2, + pcl_channels, pcl_weights, pcl_sz, len); + policy_mgr_add_5g_to_pcl(psoc, pcl_channels, pcl_weights, + pcl_sz, len, + POLICY_MGR_PCL_GROUP_ID3_ID4, + channel_list_5, chan_index_5, + channel_list_6, chan_index_6); status = QDF_STATUS_SUCCESS; break; case PM_SCC_ON_5_SCC_ON_24_24G: policy_mgr_get_connection_channels( - psoc, mode, - channel_list, &num_channels, - POLICY_MGR_PCL_ORDER_5G_THEN_2G, - skip_dfs_channel, pcl_weights, weight_len, &i, - POLICY_MGR_PCL_GROUP_ID1_ID2); - qdf_mem_copy(pcl_channels, channel_list, - num_channels * sizeof(*pcl_channels)); - *len = num_channels; - chan_index_24 = QDF_MIN((num_channels + chan_index_24), - weight_len) - num_channels; - qdf_mem_copy(&pcl_channels[num_channels], channel_list_24, - chan_index_24 * sizeof(*pcl_channels)); - *len += chan_index_24; - for (j = 0; j < chan_index_24; i++, j++) - pcl_weights[i] = WEIGHT_OF_GROUP3_PCL_CHANNELS; + psoc, mode, + POLICY_MGR_PCL_ORDER_5G_THEN_2G, + skip_dfs_channel, + POLICY_MGR_PCL_GROUP_ID1_ID2, + pcl_channels, pcl_weights, pcl_sz, len); + policy_mgr_add_24g_to_pcl(pcl_channels, pcl_weights, pcl_sz, + len, WEIGHT_OF_GROUP3_PCL_CHANNELS, + channel_list_24, chan_index_24); status = QDF_STATUS_SUCCESS; break; case PM_SCC_ON_5_SCC_ON_24_5G: policy_mgr_get_connection_channels( - psoc, mode, - channel_list, &num_channels, - POLICY_MGR_PCL_ORDER_5G_THEN_2G, - skip_dfs_channel, pcl_weights, weight_len, &i, - POLICY_MGR_PCL_GROUP_ID1_ID2); - qdf_mem_copy(pcl_channels, channel_list, - num_channels * sizeof(*pcl_channels)); - *len = num_channels; - policy_mgr_add_5g_to_pcl( - psoc, &pcl_channels[num_channels], len, - pcl_weights, weight_len, - &i, - POLICY_MGR_PCL_GROUP_ID3_ID4, - channel_list_5, chan_index_5, - channel_list_6, chan_index_6); + psoc, mode, + POLICY_MGR_PCL_ORDER_5G_THEN_2G, + skip_dfs_channel, + POLICY_MGR_PCL_GROUP_ID1_ID2, + pcl_channels, pcl_weights, pcl_sz, len); + policy_mgr_add_5g_to_pcl(psoc, pcl_channels, pcl_weights, + pcl_sz, len, + POLICY_MGR_PCL_GROUP_ID3_ID4, + channel_list_5, chan_index_5, + channel_list_6, chan_index_6); status = QDF_STATUS_SUCCESS; break; case PM_24G_SCC_CH_SBS_CH: - qdf_mem_copy(pcl_channels, channel_list_24, - chan_index_24 * sizeof(*pcl_channels)); - *len = chan_index_24; - for (i = 0; ((i < chan_index_24) && (i < weight_len)); i++) - pcl_weights[i] = WEIGHT_OF_GROUP1_PCL_CHANNELS; - policy_mgr_get_connection_channels( - psoc, mode, - channel_list, &num_channels, POLICY_MGR_PCL_ORDER_NONE, - skip_dfs_channel, pcl_weights, weight_len, &i, - POLICY_MGR_PCL_GROUP_ID2_ID3); - qdf_mem_copy(&pcl_channels[chan_index_24], channel_list, - num_channels * sizeof(*pcl_channels)); - *len += num_channels; - if (policy_mgr_is_hw_sbs_capable(psoc)) { - policy_mgr_get_sbs_channels( - sbs_channel_list, &sbs_num_channels, pcl_weights, - weight_len, &i, POLICY_MGR_PCL_GROUP_ID3_ID4, - channel_list_5, chan_index_5, false); - qdf_mem_copy( - &pcl_channels[chan_index_24 + num_channels], - sbs_channel_list, - sbs_num_channels * sizeof(*pcl_channels)); - *len += sbs_num_channels; - } + policy_mgr_add_24g_to_pcl(pcl_channels, pcl_weights, pcl_sz, + len, WEIGHT_OF_GROUP1_PCL_CHANNELS, + channel_list_24, chan_index_24); + + policy_mgr_get_connection_channels(psoc, mode, + POLICY_MGR_PCL_ORDER_NONE, + skip_dfs_channel, + POLICY_MGR_PCL_GROUP_ID2_ID3, + pcl_channels, pcl_weights, + pcl_sz, len); + + policy_mgr_get_sbs_channels(psoc, pcl_channels, pcl_weights, + pcl_sz, len, + POLICY_MGR_PCL_GROUP_ID3_ID4, + channel_list_5, chan_index_5, + false); status = QDF_STATUS_SUCCESS; break; case PM_24G_SCC_CH_SBS_CH_5G: - qdf_mem_copy(pcl_channels, channel_list_24, - chan_index_24 * sizeof(*pcl_channels)); - *len = chan_index_24; - for (i = 0; ((i < chan_index_24) && (i < weight_len)); i++) - pcl_weights[i] = WEIGHT_OF_GROUP1_PCL_CHANNELS; + policy_mgr_add_24g_to_pcl(pcl_channels, pcl_weights, pcl_sz, + len, WEIGHT_OF_GROUP1_PCL_CHANNELS, + channel_list_24, chan_index_24); policy_mgr_get_connection_channels( - psoc, mode, - channel_list, &num_channels, POLICY_MGR_PCL_ORDER_NONE, - skip_dfs_channel, pcl_weights, weight_len, &i, - POLICY_MGR_PCL_GROUP_ID2_ID3); - qdf_mem_copy(&pcl_channels[chan_index_24], channel_list, - num_channels * sizeof(*pcl_channels)); - *len += num_channels; + psoc, mode, + POLICY_MGR_PCL_ORDER_NONE, + skip_dfs_channel, + POLICY_MGR_PCL_GROUP_ID2_ID3, + pcl_channels, pcl_weights, + pcl_sz, len); if (policy_mgr_is_hw_sbs_capable(psoc)) { policy_mgr_get_sbs_channels( - sbs_channel_list, &sbs_num_channels, pcl_weights, - weight_len, &i, POLICY_MGR_PCL_GROUP_ID3_ID4, - channel_list_5, chan_index_5, true); - qdf_mem_copy( - &pcl_channels[chan_index_24 + num_channels], - sbs_channel_list, - sbs_num_channels * sizeof(*pcl_channels)); - *len += sbs_num_channels; + psoc, pcl_channels, + pcl_weights, pcl_sz, len, + POLICY_MGR_PCL_GROUP_ID3_ID4, + channel_list_5, chan_index_5, + true); } else { - policy_mgr_add_5g_to_pcl( - psoc, - &pcl_channels[chan_index_24 + num_channels], - len, - pcl_weights, weight_len, - &i, - POLICY_MGR_PCL_GROUP_ID3_ID4, - channel_list_5, chan_index_5, - channel_list_6, chan_index_6); + policy_mgr_add_5g_to_pcl(psoc, pcl_channels, + pcl_weights, pcl_sz, len, + POLICY_MGR_PCL_GROUP_ID3_ID4, + channel_list_5, chan_index_5, + channel_list_6, chan_index_6); } status = QDF_STATUS_SUCCESS; break; case PM_24G_SBS_CH_MCC_CH: - qdf_mem_copy(pcl_channels, channel_list_24, - chan_index_24 * sizeof(*pcl_channels)); - *len = chan_index_24; - for (i = 0; ((i < chan_index_24) && (i < weight_len)); i++) - pcl_weights[i] = WEIGHT_OF_GROUP1_PCL_CHANNELS; + policy_mgr_add_24g_to_pcl(pcl_channels, pcl_weights, pcl_sz, + len, WEIGHT_OF_GROUP1_PCL_CHANNELS, + channel_list_24, chan_index_24); if (policy_mgr_is_hw_sbs_capable(psoc)) { policy_mgr_get_sbs_channels( - sbs_channel_list, &sbs_num_channels, pcl_weights, - weight_len, &i, POLICY_MGR_PCL_GROUP_ID2_ID3, - channel_list_5, chan_index_5, false); - qdf_mem_copy(&pcl_channels[num_channels], - sbs_channel_list, - sbs_num_channels * sizeof(*pcl_channels)); - *len += sbs_num_channels; + psoc, pcl_channels, + pcl_weights, + pcl_sz, len, + POLICY_MGR_PCL_GROUP_ID2_ID3, + channel_list_5, chan_index_5, + false); } policy_mgr_get_connection_channels( - psoc, mode, - channel_list, &num_channels, POLICY_MGR_PCL_ORDER_NONE, - skip_dfs_channel, pcl_weights, weight_len, &i, - POLICY_MGR_PCL_GROUP_ID2_ID3); - qdf_mem_copy(&pcl_channels[chan_index_24], channel_list, - num_channels * sizeof(*pcl_channels)); - *len += num_channels; + psoc, mode, + POLICY_MGR_PCL_ORDER_NONE, + skip_dfs_channel, + POLICY_MGR_PCL_GROUP_ID2_ID3, + pcl_channels, pcl_weights, + pcl_sz, len); status = QDF_STATUS_SUCCESS; break; case PM_SBS_CH_5G: if (policy_mgr_is_hw_sbs_capable(psoc)) { policy_mgr_get_sbs_channels( - sbs_channel_list, &sbs_num_channels, pcl_weights, - weight_len, &i, POLICY_MGR_PCL_GROUP_ID1_ID2, - channel_list_5, chan_index_5, true); - qdf_mem_copy(&pcl_channels[num_channels], - sbs_channel_list, - sbs_num_channels * sizeof(*pcl_channels)); - *len += sbs_num_channels; - } else { - policy_mgr_add_5g_to_pcl( - psoc, - pcl_channels, - len, - pcl_weights, weight_len, - &i, + psoc, pcl_channels, + pcl_weights, pcl_sz, len, POLICY_MGR_PCL_GROUP_ID1_ID2, - channel_list_5, chan_index_5, - channel_list_6, chan_index_6); + channel_list_5, chan_index_5, true); + } else { + policy_mgr_add_5g_to_pcl(psoc, pcl_channels, + pcl_weights, pcl_sz, len, + POLICY_MGR_PCL_GROUP_ID1_ID2, + channel_list_5, chan_index_5, + channel_list_6, chan_index_6); } status = QDF_STATUS_SUCCESS; break; @@ -2722,10 +2695,10 @@ QDF_STATUS policy_mgr_get_channel_list(struct wlan_objmgr_psoc *psoc, if ((mode == PM_SAP_MODE) || (mode == PM_P2P_GO_MODE)) policy_mgr_update_with_safe_channel_list(psoc, pcl_channels, len, pcl_weights, - weight_len); + pcl_sz); policy_mgr_set_weight_of_dfs_passive_channels_to_zero(psoc, - pcl_channels, len, pcl_weights, weight_len); + pcl_channels, len, pcl_weights, pcl_sz); end: qdf_mem_free(channel_list); qdf_mem_free(channel_list_24); diff --git a/components/cmn_services/policy_mgr/src/wlan_policy_mgr_i.h b/components/cmn_services/policy_mgr/src/wlan_policy_mgr_i.h index e70b599e774b..4caca995244f 100644 --- a/components/cmn_services/policy_mgr/src/wlan_policy_mgr_i.h +++ b/components/cmn_services/policy_mgr/src/wlan_policy_mgr_i.h @@ -571,11 +571,32 @@ void pm_dbs_opportunistic_timer_handler(void *data); enum policy_mgr_con_mode policy_mgr_get_mode(uint8_t type, uint8_t subtype); +/** + * policy_mgr_get_bw() - Convert phy_ch_width to hw_mode_bandwidth. + * @chan_width: phy_ch_width + * + * Return: hw_mode_bandwidth + */ +enum hw_mode_bandwidth policy_mgr_get_bw(enum phy_ch_width chan_width); + +/** + * policy_mgr_get_channel_list() - Get channel list based on PCL and mode + * @psoc: psoc object + * @pcl: pcl type + * @mode: interface mode + * @pcl_channels: pcl channel list buffer + * @pcl_weights: pcl weight buffer + * @pcl_sz: pcl channel list buffer size + * @len: pcl channel number returned from API + * + * Return: QDF_STATUS + */ QDF_STATUS policy_mgr_get_channel_list(struct wlan_objmgr_psoc *psoc, - enum policy_mgr_pcl_type pcl, - uint32_t *pcl_channels, uint32_t *len, - enum policy_mgr_con_mode mode, - uint8_t *pcl_weights, uint32_t weight_len); + enum policy_mgr_pcl_type pcl, + enum policy_mgr_con_mode mode, + uint32_t *pcl_channels, + uint8_t *pcl_weights, + uint32_t pcl_sz, uint32_t *len); /** * policy_mgr_allow_new_home_channel() - Check for allowed number of diff --git a/components/cmn_services/policy_mgr/src/wlan_policy_mgr_pcl.c b/components/cmn_services/policy_mgr/src/wlan_policy_mgr_pcl.c index 5be8fa6d3e8d..1ee749afad46 100644 --- a/components/cmn_services/policy_mgr/src/wlan_policy_mgr_pcl.c +++ b/components/cmn_services/policy_mgr/src/wlan_policy_mgr_pcl.c @@ -1022,8 +1022,8 @@ QDF_STATUS policy_mgr_get_pcl(struct wlan_objmgr_psoc *psoc, /* once the PCL enum is obtained find out the exact channel list with * help from sme_get_cfg_valid_channels */ - status = policy_mgr_get_channel_list(psoc, pcl, pcl_channels, len, mode, - pcl_weight, weight_len); + status = policy_mgr_get_channel_list(psoc, pcl, mode, pcl_channels, + pcl_weight, weight_len, len); if (QDF_IS_STATUS_ERROR(status)) { policy_mgr_err("failed to get channel list:%d", status); return status;