[bug report] wifi: ath11k: fill parameters for vdev set tpc power WMI command
Dan Carpenter
dan.carpenter at linaro.org
Wed Feb 7 01:52:02 PST 2024
Hello Wen Gong,
The patch 92425f788fee: "wifi: ath11k: fill parameters for vdev set
tpc power WMI command" from Jan 11, 2024 (linux-next), leads to the
following Smatch static checker warning:
drivers/net/wireless/ath/ath11k/mac.c:7751 ath11k_mac_fill_reg_tpc_info()
error: uninitialized symbol 'eirp_power'.
drivers/net/wireless/ath/ath11k/mac.c
7583 void ath11k_mac_fill_reg_tpc_info(struct ath11k *ar,
7584 struct ieee80211_vif *vif,
7585 struct ieee80211_chanctx_conf *ctx)
7586 {
7587 struct ath11k_base *ab = ar->ab;
7588 struct ath11k_vif *arvif = (void *)vif->drv_priv;
7589 struct ieee80211_bss_conf *bss_conf = &vif->bss_conf;
7590 struct ath11k_reg_tpc_power_info *reg_tpc_info = &arvif->reg_tpc_info;
7591 struct ieee80211_channel *chan, *temp_chan;
7592 u8 pwr_lvl_idx, num_pwr_levels, pwr_reduction;
7593 bool is_psd_power = false, is_tpe_present = false;
7594 s8 max_tx_power[IEEE80211_MAX_NUM_PWR_LEVEL],
7595 psd_power, tx_power, eirp_power;
7596 u16 start_freq, center_freq;
7597
7598 chan = ctx->def.chan;
7599 start_freq = ath11k_mac_get_6ghz_start_frequency(&ctx->def);
7600 pwr_reduction = bss_conf->pwr_reduction;
7601
7602 if (arvif->reg_tpc_info.num_pwr_levels) {
7603 is_tpe_present = true;
7604 num_pwr_levels = arvif->reg_tpc_info.num_pwr_levels;
7605 } else {
7606 num_pwr_levels = ath11k_mac_get_num_pwr_levels(&ctx->def);
7607 }
7608
7609 for (pwr_lvl_idx = 0; pwr_lvl_idx < num_pwr_levels; pwr_lvl_idx++) {
7610 /* STA received TPE IE*/
7611 if (is_tpe_present) {
7612 /* local power is PSD power*/
7613 if (chan->flags & IEEE80211_CHAN_PSD) {
7614 /* Connecting AP is psd power */
7615 if (reg_tpc_info->is_psd_power) {
7616 is_psd_power = true;
7617 ath11k_mac_get_psd_channel(ar, 20,
7618 &start_freq,
7619 ¢er_freq,
7620 pwr_lvl_idx,
7621 &temp_chan,
7622 &tx_power);
7623 psd_power = temp_chan->psd;
7624 eirp_power = tx_power;
7625 max_tx_power[pwr_lvl_idx] =
7626 min_t(s8,
7627 psd_power,
7628 reg_tpc_info->tpe[pwr_lvl_idx]);
7629 /* Connecting AP is not psd power */
7630 } else {
7631 ath11k_mac_get_eirp_power(ar,
7632 &start_freq,
7633 ¢er_freq,
7634 pwr_lvl_idx,
7635 &temp_chan,
7636 &ctx->def,
7637 &tx_power);
7638 psd_power = temp_chan->psd;
7639 /* convert psd power to EIRP power based
7640 * on channel width
7641 */
7642 tx_power =
7643 min_t(s8, tx_power,
7644 psd_power + 13 + pwr_lvl_idx * 3);
7645 max_tx_power[pwr_lvl_idx] =
7646 min_t(s8,
7647 tx_power,
7648 reg_tpc_info->tpe[pwr_lvl_idx]);
There a couple of else paths where eirp_power doesn't get set.
7649 }
7650 /* local power is not PSD power */
7651 } else {
7652 /* Connecting AP is psd power */
7653 if (reg_tpc_info->is_psd_power) {
7654 is_psd_power = true;
7655 ath11k_mac_get_psd_channel(ar, 20,
7656 &start_freq,
7657 ¢er_freq,
7658 pwr_lvl_idx,
7659 &temp_chan,
7660 &tx_power);
7661 eirp_power = tx_power;
7662 max_tx_power[pwr_lvl_idx] =
7663 reg_tpc_info->tpe[pwr_lvl_idx];
7664 /* Connecting AP is not psd power */
7665 } else {
7666 ath11k_mac_get_eirp_power(ar,
7667 &start_freq,
7668 ¢er_freq,
7669 pwr_lvl_idx,
7670 &temp_chan,
7671 &ctx->def,
7672 &tx_power);
7673 max_tx_power[pwr_lvl_idx] =
7674 min_t(s8,
7675 tx_power,
7676 reg_tpc_info->tpe[pwr_lvl_idx]);
Here too.
7677 }
7678 }
7679 /* STA not received TPE IE */
7680 } else {
7681 /* local power is PSD power*/
7682 if (chan->flags & IEEE80211_CHAN_PSD) {
7683 is_psd_power = true;
7684 ath11k_mac_get_psd_channel(ar, 20,
7685 &start_freq,
7686 ¢er_freq,
7687 pwr_lvl_idx,
7688 &temp_chan,
7689 &tx_power);
7690 psd_power = temp_chan->psd;
7691 eirp_power = tx_power;
7692 max_tx_power[pwr_lvl_idx] = psd_power;
7693 } else {
7694 ath11k_mac_get_eirp_power(ar,
7695 &start_freq,
7696 ¢er_freq,
7697 pwr_lvl_idx,
7698 &temp_chan,
7699 &ctx->def,
7700 &tx_power);
7701 max_tx_power[pwr_lvl_idx] = tx_power;
And here.
7702 }
7703 }
7704
7705 if (is_psd_power) {
7706 /* If AP local power constraint is present */
7707 if (pwr_reduction)
7708 eirp_power = eirp_power - pwr_reduction;
You'd have to hit an else path here as well. Probably it can't actually
hit all the else paths and be uninitialized... Hard to tell.
7709
7710 /* If firmware updated max tx power is non zero, then take
7711 * the min of firmware updated ap tx power
7712 * and max power derived from above mentioned parameters.
7713 */
7714 ath11k_dbg(ab, ATH11K_DBG_MAC,
7715 "eirp power : %d firmware report power : %d\n",
7716 eirp_power, ar->max_allowed_tx_power);
7717 /* Firmware reports lower max_allowed_tx_power during vdev
7718 * start response. In case of 6 GHz, firmware is not aware
7719 * of EIRP power unless driver sets EIRP power through WMI
7720 * TPC command. So radio which does not support idle power
7721 * save can set maximum calculated EIRP power directly to
7722 * firmware through TPC command without min comparison with
7723 * vdev start response's max_allowed_tx_power.
7724 */
7725 if (ar->max_allowed_tx_power && ab->hw_params.idle_ps)
7726 eirp_power = min_t(s8,
7727 eirp_power,
7728 ar->max_allowed_tx_power);
7729 } else {
7730 /* If AP local power constraint is present */
7731 if (pwr_reduction)
7732 max_tx_power[pwr_lvl_idx] =
7733 max_tx_power[pwr_lvl_idx] - pwr_reduction;
7734 /* If firmware updated max tx power is non zero, then take
7735 * the min of firmware updated ap tx power
7736 * and max power derived from above mentioned parameters.
7737 */
7738 if (ar->max_allowed_tx_power && ab->hw_params.idle_ps)
7739 max_tx_power[pwr_lvl_idx] =
7740 min_t(s8,
7741 max_tx_power[pwr_lvl_idx],
7742 ar->max_allowed_tx_power);
7743 }
7744 reg_tpc_info->chan_power_info[pwr_lvl_idx].chan_cfreq = center_freq;
7745 reg_tpc_info->chan_power_info[pwr_lvl_idx].tx_power =
7746 max_tx_power[pwr_lvl_idx];
7747 }
7748
7749 reg_tpc_info->num_pwr_levels = num_pwr_levels;
7750 reg_tpc_info->is_psd_power = is_psd_power;
--> 7751 reg_tpc_info->eirp_power = eirp_power;
7752 reg_tpc_info->ap_power_type =
7753 ath11k_reg_ap_pwr_convert(vif->bss_conf.power_type);
7754 }
regards,
dan carpenter
More information about the ath11k
mailing list