For sending scan channel list command to firmware through wmi, remain on channel's scan request parameter needs to be updated. Add scan_req_params as an argument to the existing update_scan_chan_list to update scan request parameter through wmi. Also, rename regulatory update scan channel list to the ath11k_wmi_update_scan_chan_list since it is moved to wmi file. Co-developed-by: Karthikeyan Periyasamy <periyasa@xxxxxxxxxxxxxx> Signed-off-by: Karthikeyan Periyasamy <periyasa@xxxxxxxxxxxxxx> Signed-off-by: P Praneesh <ppranees@xxxxxxxxxxxxxx> --- drivers/net/wireless/ath/ath11k/mac.c | 2 +- drivers/net/wireless/ath/ath11k/reg.c | 96 +------------------------------- drivers/net/wireless/ath/ath11k/reg.h | 1 - drivers/net/wireless/ath/ath11k/wmi.c | 101 ++++++++++++++++++++++++++++++++++ drivers/net/wireless/ath/ath11k/wmi.h | 4 ++ 5 files changed, 107 insertions(+), 97 deletions(-) diff --git a/drivers/net/wireless/ath/ath11k/mac.c b/drivers/net/wireless/ath/ath11k/mac.c index 1cc5560..fc2edef 100644 --- a/drivers/net/wireless/ath/ath11k/mac.c +++ b/drivers/net/wireless/ath/ath11k/mac.c @@ -5256,7 +5256,7 @@ static int ath11k_mac_op_start(struct ieee80211_hw *hw) /* TODO: Do we need to enable ANI? */ - ath11k_reg_update_chan_list(ar); + ath11k_wmi_update_scan_chan_list(ar, NULL); ar->num_started_vdevs = 0; ar->num_created_vdevs = 0; diff --git a/drivers/net/wireless/ath/ath11k/reg.c b/drivers/net/wireless/ath/ath11k/reg.c index a66b5bd..a453329 100644 --- a/drivers/net/wireless/ath/ath11k/reg.c +++ b/drivers/net/wireless/ath/ath11k/reg.c @@ -88,100 +88,6 @@ ath11k_reg_notifier(struct wiphy *wiphy, struct regulatory_request *request) "INIT Country code set to fw failed : %d\n", ret); } -int ath11k_reg_update_chan_list(struct ath11k *ar) -{ - struct ieee80211_supported_band **bands; - struct scan_chan_list_params *params; - struct ieee80211_channel *channel; - struct ieee80211_hw *hw = ar->hw; - struct channel_param *ch; - enum nl80211_band band; - int num_channels = 0; - int i, ret; - - bands = hw->wiphy->bands; - for (band = 0; band < NUM_NL80211_BANDS; band++) { - if (!bands[band]) - continue; - - for (i = 0; i < bands[band]->n_channels; i++) { - if (bands[band]->channels[i].flags & - IEEE80211_CHAN_DISABLED) - continue; - - num_channels++; - } - } - - if (WARN_ON(!num_channels)) - return -EINVAL; - - params = kzalloc(struct_size(params, ch_param, num_channels), - GFP_KERNEL); - if (!params) - return -ENOMEM; - - params->pdev_id = ar->pdev->pdev_id; - params->nallchans = num_channels; - - ch = params->ch_param; - - for (band = 0; band < NUM_NL80211_BANDS; band++) { - if (!bands[band]) - continue; - - for (i = 0; i < bands[band]->n_channels; i++) { - channel = &bands[band]->channels[i]; - - if (channel->flags & IEEE80211_CHAN_DISABLED) - continue; - - /* TODO: Set to true/false based on some condition? */ - ch->allow_ht = true; - ch->allow_vht = true; - ch->allow_he = true; - - ch->dfs_set = - !!(channel->flags & IEEE80211_CHAN_RADAR); - ch->is_chan_passive = !!(channel->flags & - IEEE80211_CHAN_NO_IR); - ch->is_chan_passive |= ch->dfs_set; - ch->mhz = channel->center_freq; - ch->cfreq1 = channel->center_freq; - ch->minpower = 0; - ch->maxpower = channel->max_power * 2; - ch->maxregpower = channel->max_reg_power * 2; - ch->antennamax = channel->max_antenna_gain * 2; - - /* TODO: Use appropriate phymodes */ - if (channel->band == NL80211_BAND_2GHZ) - ch->phy_mode = MODE_11G; - else - ch->phy_mode = MODE_11A; - - if (channel->band == NL80211_BAND_6GHZ && - cfg80211_channel_is_psc(channel)) - ch->psc_channel = true; - - ath11k_dbg(ar->ab, ATH11K_DBG_WMI, - "mac channel [%d/%d] freq %d maxpower %d regpower %d antenna %d mode %d\n", - i, params->nallchans, - ch->mhz, ch->maxpower, ch->maxregpower, - ch->antennamax, ch->phy_mode); - - ch++; - /* TODO: use quarrter/half rate, cfreq12, dfs_cfreq2 - * set_agile, reg_class_idx - */ - } - } - - ret = ath11k_wmi_send_scan_chan_list_cmd(ar, params); - kfree(params); - - return ret; -} - static void ath11k_copy_regd(struct ieee80211_regdomain *regd_orig, struct ieee80211_regdomain *regd_copy) { @@ -256,7 +162,7 @@ int ath11k_regd_update(struct ath11k *ar) goto err; if (ar->state == ATH11K_STATE_ON) { - ret = ath11k_reg_update_chan_list(ar); + ret = ath11k_wmi_update_scan_chan_list(ar, NULL); if (ret) goto err; } diff --git a/drivers/net/wireless/ath/ath11k/reg.h b/drivers/net/wireless/ath/ath11k/reg.h index 5fb9dc0..44830e6 100644 --- a/drivers/net/wireless/ath/ath11k/reg.h +++ b/drivers/net/wireless/ath/ath11k/reg.h @@ -32,5 +32,4 @@ struct ieee80211_regdomain * ath11k_reg_build_regd(struct ath11k_base *ab, struct cur_regulatory_info *reg_info, bool intersect); int ath11k_regd_update(struct ath11k *ar); -int ath11k_reg_update_chan_list(struct ath11k *ar); #endif diff --git a/drivers/net/wireless/ath/ath11k/wmi.c b/drivers/net/wireless/ath/ath11k/wmi.c index 5ae2ef4..2fe32cb 100644 --- a/drivers/net/wireless/ath/ath11k/wmi.c +++ b/drivers/net/wireless/ath/ath11k/wmi.c @@ -1950,6 +1950,107 @@ int ath11k_wmi_send_peer_assoc_cmd(struct ath11k *ar, return ret; } +int ath11k_wmi_update_scan_chan_list(struct ath11k *ar, + struct scan_req_params *arg) +{ + struct ieee80211_supported_band **bands; + struct scan_chan_list_params *params; + struct channel_param *ch; + struct cfg80211_chan_def *chandef; + struct ieee80211_channel *channel, *req_channel; + enum nl80211_band band; + int num_channels = 0; + int params_len, i, ret; + bool found = false; + + bands = ar->hw->wiphy->bands; + for (band = 0; band < NUM_NL80211_BANDS; band++) { + if (!bands[band]) + continue; + for (i = 0; i < bands[band]->n_channels; i++) { + if (bands[band]->channels[i].flags & + IEEE80211_CHAN_DISABLED) + continue; + num_channels++; + } + } + + if (WARN_ON(!num_channels)) + return -EINVAL; + + params_len = sizeof(struct scan_chan_list_params) + + num_channels * sizeof(struct channel_param); + params = kzalloc(params_len, GFP_KERNEL); + + if (!params) + return -ENOMEM; + + params->pdev_id = ar->pdev->pdev_id; + params->nallchans = num_channels; + + ch = params->ch_param; + chandef = arg ? arg->chandef : NULL; + req_channel = chandef ? chandef->chan : NULL; + + for (band = 0; band < NUM_NL80211_BANDS; band++) { + if (!bands[band]) + continue; + for (i = 0; i < bands[band]->n_channels; i++) { + channel = &bands[band]->channels[i]; + + if (channel->flags & IEEE80211_CHAN_DISABLED) + continue; + + if (req_channel && !found && + req_channel->center_freq == channel->center_freq) { + ch->mhz = arg->freq; + ch->cfreq1 = chandef->center_freq1; + ch->cfreq2 = chandef->center_freq2; + + ch->phy_mode = arg->phymode; + channel = req_channel; + found = true; + } else { + ch->mhz = channel->center_freq; + ch->cfreq1 = channel->center_freq; + ch->phy_mode = (channel->band == NL80211_BAND_2GHZ) ? + MODE_11G : MODE_11A; + } + + /* TODO: Set to true/false based on some condition? */ + ch->allow_ht = true; + ch->allow_vht = true; + ch->allow_he = true; + + ch->dfs_set = !!(channel->flags & IEEE80211_CHAN_RADAR); + ch->is_chan_passive = !!(channel->flags & IEEE80211_CHAN_NO_IR); + ch->is_chan_passive |= ch->dfs_set; + ch->minpower = 0; + ch->maxpower = channel->max_power; + ch->maxregpower = channel->max_reg_power; + ch->antennamax = channel->max_antenna_gain; + + if (channel->band == NL80211_BAND_6GHZ && + cfg80211_channel_is_psc(channel)) + ch->psc_channel = true; + + ath11k_dbg(ar->ab, ATH11K_DBG_WMI, + "mac channel [%d/%d] freq %d maxpower %d regpower %d antenna %d mode %d flag 0x%x chandef: %pK\n", + i, params->nallchans, + ch->mhz, ch->maxpower, ch->maxregpower, + ch->antennamax, ch->phy_mode, channel->flags, + chandef); + + ch++; + } + } + + ret = ath11k_wmi_send_scan_chan_list_cmd(ar, params); + kfree(params); + + return ret; +} + void ath11k_wmi_start_scan_init(struct ath11k *ar, struct scan_req_params *arg) { diff --git a/drivers/net/wireless/ath/ath11k/wmi.h b/drivers/net/wireless/ath/ath11k/wmi.h index 0584e68..aeec4e9 100644 --- a/drivers/net/wireless/ath/ath11k/wmi.h +++ b/drivers/net/wireless/ath/ath11k/wmi.h @@ -3311,6 +3311,9 @@ struct scan_req_params { u32 num_hint_bssid; struct hint_short_ssid hint_s_ssid[WLAN_SCAN_MAX_HINT_S_SSID]; struct hint_bssid hint_bssid[WLAN_SCAN_MAX_HINT_BSSID]; + u32 phymode; + u32 freq; + struct cfg80211_chan_def *chandef; }; struct wmi_ssid_arg { @@ -5378,6 +5381,7 @@ int ath11k_wmi_send_peer_delete_cmd(struct ath11k *ar, const u8 *peer_addr, u8 vdev_id); int ath11k_wmi_vdev_delete(struct ath11k *ar, u8 vdev_id); void ath11k_wmi_start_scan_init(struct ath11k *ar, struct scan_req_params *arg); +int ath11k_wmi_update_scan_chan_list(struct ath11k *ar, struct scan_req_params *arg); int ath11k_wmi_send_scan_start_cmd(struct ath11k *ar, struct scan_req_params *params); int ath11k_wmi_send_scan_stop_cmd(struct ath11k *ar, -- 2.7.4