From 9934f8100836c4f2687243a1c55f41bc9c8a2b40 Mon Sep 17 00:00:00 2001 From: gaurank kathpalia Date: Sat, 30 May 2020 21:45:54 +0530 Subject: [PATCH] qcacld-3.0: Ensure proper seg0 seg1 bandwidth values Some APs advertise wrong seg0, seg1, and BW values and the driver copies that info directly and sets it to the FW, which can lead to a crash in HAL layers due to the wrong configuration. Fix is to ensure that only correct combination allowed by regulatory can be passed onto the FW in the vdev start command. Change-Id: I452438f385d6f067812551071b2ea87b99b9eb01 CRs-Fixed: 2698732 --- core/mac/src/pe/lim/lim_utils.c | 46 +++++++++++++++++++++++++++------ 1 file changed, 38 insertions(+), 8 deletions(-) diff --git a/core/mac/src/pe/lim/lim_utils.c b/core/mac/src/pe/lim/lim_utils.c index ef879bb918f4..5786c225fae6 100644 --- a/core/mac/src/pe/lim/lim_utils.c +++ b/core/mac/src/pe/lim/lim_utils.c @@ -8683,13 +8683,48 @@ QDF_STATUS lim_pre_vdev_start(struct mac_context *mac, struct pe_session *session) { struct wlan_channel *des_chan; + enum reg_wifi_band band; + uint8_t band_mask; + struct ch_params ch_params = {0}; + + band = wlan_reg_freq_to_band(session->curr_op_freq); + band_mask = 1 << band; + + ch_params.ch_width = session->ch_width; + ch_params.mhz_freq_seg0 = + wlan_reg_chan_band_to_freq(mac->pdev, + session->ch_center_freq_seg0, + band_mask); + + ch_params.mhz_freq_seg1 = + wlan_reg_chan_band_to_freq(mac->pdev, + session->ch_center_freq_seg1, + band_mask); + + wlan_reg_set_channel_params_for_freq(mac->pdev, session->curr_op_freq, + 0, &ch_params); + + pe_debug("vdev id %d freq %d seg0 %d seg1 %d ch_width %d cac_duration_ms %d beacon_interval %d hidden_ssid: %d dtimPeriod %d slot_time %d bcn tx rate %d mhz seg0 %d mhz seg1 %d", + session->vdev_id, session->curr_op_freq, + ch_params.center_freq_seg0, + ch_params.center_freq_seg1, ch_params.ch_width, + session->cac_duration_ms, + session->beaconParams.beaconInterval, + session->ssidHidden, session->dtimPeriod, + session->shortSlotTimeSupported, + session->beacon_tx_rate, + ch_params.mhz_freq_seg0, + ch_params.mhz_freq_seg1); des_chan = mlme_obj->vdev->vdev_mlme.des_chan; des_chan->ch_freq = session->curr_op_freq; - des_chan->ch_width = session->ch_width; - des_chan->ch_freq_seg1 = session->ch_center_freq_seg0; - des_chan->ch_freq_seg2 = session->ch_center_freq_seg1; + des_chan->ch_width = ch_params.ch_width; + des_chan->ch_freq_seg1 = ch_params.center_freq_seg0; + des_chan->ch_freq_seg2 = ch_params.center_freq_seg1; des_chan->ch_ieee = wlan_reg_freq_to_chan(mac->pdev, des_chan->ch_freq); + session->ch_width = ch_params.ch_width; + session->ch_center_freq_seg0 = ch_params.center_freq_seg0; + session->ch_center_freq_seg1 = ch_params.center_freq_seg1; mlme_obj->mgmt.generic.maxregpower = session->maxTxPower; mlme_obj->proto.generic.beacon_interval = @@ -8702,11 +8737,6 @@ QDF_STATUS lim_pre_vdev_start(struct mac_context *mac, mlme_obj->proto.generic.slot_time = session->shortSlotTimeSupported; mlme_obj->mgmt.rate_info.bcn_tx_rate = session->beacon_tx_rate; - pe_debug("cac_duration_ms %d beacon_interval %d hidden_ssid: %d dtimPeriod %d slot_time %d bcn tx rate %d", - session->cac_duration_ms, session->beaconParams.beaconInterval, - session->ssidHidden, session->dtimPeriod, - mlme_obj->proto.generic.slot_time, session->beacon_tx_rate); - mlme_obj->proto.ht_info.allow_ht = !!session->htCapability; mlme_obj->proto.vht_info.allow_vht = !!session->vhtCapability;