wifi: rtw89: 8852b: add chip_ops to query PPDU
authorPing-Ke Shih <pkshih@realtek.com>
Sun, 9 Oct 2022 12:54:00 +0000 (20:54 +0800)
committerKalle Valo <kvalo@kernel.org>
Wed, 12 Oct 2022 04:34:56 +0000 (07:34 +0300)
Add to parse PPDU to get frequency and RSSI of received packets.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20221009125403.19662-7-pkshih@realtek.com
drivers/net/wireless/realtek/rtw89/rtw8852b.c

index ee5a29f35db257e0086b289d72f770f05b139ce0..abb35553a2b044a7ca78d408267cd62605483cae 100644 (file)
@@ -1707,6 +1707,37 @@ static void rtw8852b_btc_set_wl_rx_gain(struct rtw89_dev *rtwdev, u32 level)
 {
 }
 
+static void rtw8852b_fill_freq_with_ppdu(struct rtw89_dev *rtwdev,
+                                        struct rtw89_rx_phy_ppdu *phy_ppdu,
+                                        struct ieee80211_rx_status *status)
+{
+       u16 chan = phy_ppdu->chan_idx;
+       u8 band;
+
+       if (chan == 0)
+               return;
+
+       band = chan <= 14 ? NL80211_BAND_2GHZ : NL80211_BAND_5GHZ;
+       status->freq = ieee80211_channel_to_frequency(chan, band);
+       status->band = band;
+}
+
+static void rtw8852b_query_ppdu(struct rtw89_dev *rtwdev,
+                               struct rtw89_rx_phy_ppdu *phy_ppdu,
+                               struct ieee80211_rx_status *status)
+{
+       u8 path;
+       u8 *rx_power = phy_ppdu->rssi;
+
+       status->signal = RTW89_RSSI_RAW_TO_DBM(max(rx_power[RF_PATH_A], rx_power[RF_PATH_B]));
+       for (path = 0; path < rtwdev->chip->rf_path_num; path++) {
+               status->chains |= BIT(path);
+               status->chain_signal[path] = RTW89_RSSI_RAW_TO_DBM(rx_power[path]);
+       }
+       if (phy_ppdu->valid)
+               rtw8852b_fill_freq_with_ppdu(rtwdev, phy_ppdu, status);
+}
+
 static int rtw8852b_mac_enable_bb_rf(struct rtw89_dev *rtwdev)
 {
        int ret;
@@ -1775,6 +1806,7 @@ static const struct rtw89_chip_ops rtw8852b_chip_ops = {
        .init_txpwr_unit        = rtw8852b_init_txpwr_unit,
        .get_thermal            = rtw8852b_get_thermal,
        .ctrl_btg               = rtw8852b_ctrl_btg,
+       .query_ppdu             = rtw8852b_query_ppdu,
        .bb_ctrl_btc_preagc     = rtw8852b_bb_ctrl_btc_preagc,
        .pwr_on_func            = rtw8852b_pwr_on_func,
        .pwr_off_func           = rtw8852b_pwr_off_func,