ath11k: report rssi of each chain to mac80211 for QCA6390/WCN6855
Hello Wen Gong,
The patch b488c766442f: "ath11k: report rssi of each chain to mac80211 for QCA6390/WCN6855" from Dec 17, 2021, leads to the following Smatch static checker warning:
drivers/net/wireless/ath/ath11k/wmi.c:5800 ath11k_wmi_tlv_rssi_chain_parse() warn: missing error code here? 'ieee80211_find_sta_by_ifaddr()' failed. 'ret' = '0'
drivers/net/wireless/ath/ath11k/wmi.c
5755 static int ath11k_wmi_tlv_rssi_chain_parse(struct ath11k_base *ab,
5756 u16 tag, u16 len,
5757 const void *ptr, void *data)
5758 {
5759 struct wmi_tlv_fw_stats_parse *parse = data;
5760 const struct wmi_stats_event *ev = parse->ev;
5761 struct ath11k_fw_stats *stats = parse->stats;
5762 struct ath11k *ar;
5763 struct ath11k_vif *arvif;
5764 struct ieee80211_sta *sta;
5765 struct ath11k_sta *arsta;
5766 const struct wmi_rssi_stats *stats_rssi = (const struct wmi_rssi_stats *)ptr;
5767 int j, ret = 0;
5768
5769 if (tag != WMI_TAG_RSSI_STATS)
5770 return -EPROTO;
5771
5772 rcu_read_lock();
5773
5774 ar = ath11k_mac_get_ar_by_pdev_id(ab, ev->pdev_id);
5775 stats->stats_id = WMI_REQUEST_RSSI_PER_CHAIN_STAT;
5776
5777 ath11k_dbg(ab, ATH11K_DBG_WMI,
5778 "wmi stats vdev id %d mac %pM\n",
5779 stats_rssi->vdev_id, stats_rssi->peer_macaddr.addr);
5780
5781 arvif = ath11k_mac_get_arvif(ar, stats_rssi->vdev_id);
5782 if (!arvif) {
5783 ath11k_warn(ab, "not found vif for vdev id %d\n",
5784 stats_rssi->vdev_id);
5785 ret = -EPROTO;
5786 goto exit;
5787 }
5788
5789 ath11k_dbg(ab, ATH11K_DBG_WMI,
5790 "wmi stats bssid %pM vif %pK\n",
5791 arvif->bssid, arvif->vif);
5792
5793 sta = ieee80211_find_sta_by_ifaddr(ar->hw,
5794 arvif->bssid,
5795 NULL);
5796 if (!sta) {
5797 ath11k_dbg(ab, ATH11K_DBG_WMI,
5798 "not found station of bssid %pM for rssi chain\n",
5799 arvif->bssid);--> 5800 goto exit;
Should this return an error code or zero? It's hard for me to tell. If returning a zero is correct then doing the "ret = 0;" assignment within 4 (or 5?) lines of the "goto exit;" will silence the warning.
5801 }
5802
5803 arsta = (struct ath11k_sta *)sta->drv_priv;
5804
5805 BUILD_BUG_ON(ARRAY_SIZE(arsta->chain_signal) >
5806 ARRAY_SIZE(stats_rssi->rssi_avg_beacon));
5807
5808 for (j = 0; j < ARRAY_SIZE(arsta->chain_signal); j++) {
5809 arsta->chain_signal[j] = stats_rssi->rssi_avg_beacon[j];
5810 ath11k_dbg(ab, ATH11K_DBG_WMI,
5811 "wmi stats beacon rssi[%d] %d data rssi[%d] %d\n",
5812 j,
5813 stats_rssi->rssi_avg_beacon[j],
5814 j,
5815 stats_rssi->rssi_avg_data[j]);
5816 }
5817
5818 exit:
5819 rcu_read_unlock();
5820 return ret;
5821 }regards,
dan carpenter
Signature · 3 lines
ath11k mailing list [email protected] http://lists.infradead.org/mailman/listinfo/ath11k
Quoted 8 lines · Dan Carpenter
Hello Wen Gong,
The patch
b488c766442f: "ath11k: report rssi of each chain to mac80211 for QCA6390/WCN6855" from Dec 17, 2021, leads to the following Smatch static checker warning:drivers/net/wireless/ath/ath11k/wmi.c:5800 ath11k_wmi_tlv_rssi_chain_parse() warn: missing error code here? 'ieee80211_find_sta_by_ifaddr()' failed. 'ret' = '0'
yes, it should return 0.
please see this commit:
ath11k: fix warning of not found station for bssid in message
Quoted 76 lines
drivers/net/wireless/ath/ath11k/wmi.c5755 static int ath11k_wmi_tlv_rssi_chain_parse(struct ath11k_base *ab, 5756 u16 tag, u16 len, 5757 const void *ptr, void *data) 5758 { 5759 struct wmi_tlv_fw_stats_parse *parse = data; 5760 const struct wmi_stats_event *ev = parse->ev; 5761 struct ath11k_fw_stats *stats = parse->stats; 5762 struct ath11k *ar; 5763 struct ath11k_vif *arvif; 5764 struct ieee80211_sta *sta; 5765 struct ath11k_sta *arsta; 5766 const struct wmi_rssi_stats *stats_rssi = (const struct wmi_rssi_stats *)ptr; 5767 int j, ret = 0; 5768 5769 if (tag != WMI_TAG_RSSI_STATS) 5770 return -EPROTO; 5771 5772 rcu_read_lock(); 5773 5774 ar = ath11k_mac_get_ar_by_pdev_id(ab, ev->pdev_id); 5775 stats->stats_id = WMI_REQUEST_RSSI_PER_CHAIN_STAT; 5776 5777 ath11k_dbg(ab, ATH11K_DBG_WMI, 5778 "wmi stats vdev id %d mac %pM\n", 5779 stats_rssi->vdev_id, stats_rssi->peer_macaddr.addr); 5780 5781 arvif = ath11k_mac_get_arvif(ar, stats_rssi->vdev_id); 5782 if (!arvif) { 5783 ath11k_warn(ab, "not found vif for vdev id %d\n", 5784 stats_rssi->vdev_id); 5785 ret = -EPROTO; 5786 goto exit; 5787 } 5788 5789 ath11k_dbg(ab, ATH11K_DBG_WMI, 5790 "wmi stats bssid %pM vif %pK\n", 5791 arvif->bssid, arvif->vif); 5792 5793 sta = ieee80211_find_sta_by_ifaddr(ar->hw, 5794 arvif->bssid, 5795 NULL); 5796 if (!sta) { 5797 ath11k_dbg(ab, ATH11K_DBG_WMI, 5798 "not found station of bssid %pM for rssi chain\n", 5799 arvif->bssid);--> 5800 goto exit;
Should this return an error code or zero? It's hard for me to tell. If returning a zero is correct then doing the "ret = 0;" assignment within 4 (or 5?) lines of the "goto exit;" will silence the warning.
5801 } 5802 5803 arsta = (struct ath11k_sta *)sta->drv_priv; 5804 5805 BUILD_BUG_ON(ARRAY_SIZE(arsta->chain_signal) > 5806 ARRAY_SIZE(stats_rssi->rssi_avg_beacon)); 5807 5808 for (j = 0; j < ARRAY_SIZE(arsta->chain_signal); j++) { 5809 arsta->chain_signal[j] = stats_rssi->rssi_avg_beacon[j]; 5810 ath11k_dbg(ab, ATH11K_DBG_WMI, 5811 "wmi stats beacon rssi[%d] %d data rssi[%d] %d\n", 5812 j, 5813 stats_rssi->rssi_avg_beacon[j], 5814 j, 5815 stats_rssi->rssi_avg_data[j]); 5816 } 5817 5818 exit: 5819 rcu_read_unlock(); 5820 return ret; 5821 }regards,
dan carpenter
Signature · 3 lines
ath11k mailing list [email protected] http://lists.infradead.org/mailman/listinfo/ath11k
Quoted 10 lines · Wen Gong
Quoted 8 lines · Dan Carpenter
Hello Wen Gong,
The patch
b488c766442f: "ath11k: report rssi of each chain to mac80211 for QCA6390/WCN6855" from Dec 17, 2021, leads to the following Smatch static checker warning:drivers/net/wireless/ath/ath11k/wmi.c:5800 ath11k_wmi_tlv_rssi_chain_parse() warn: missing error code here? 'ieee80211_find_sta_by_ifaddr()' failed. 'ret' = '0'
Quoted 8 lines
yes, it should return 0.
please see this commit:
ath11k: fix warning of not found station for bssid in message
We could silence the warning and make the code more obvious by setting the "ret = 0;" explicitly or another option would be to add a comment.
regards,
dan carpenter
Signature · 3 lines
ath11k mailing list [email protected] http://lists.infradead.org/mailman/listinfo/ath11k