wifi: rtw89: 8922a: hook handlers of TX/RX descriptors to chip_ops
authorPing-Ke Shih <pkshih@realtek.com>
Wed, 24 Jan 2024 03:36:32 +0000 (11:36 +0800)
committerKalle Valo <kvalo@kernel.org>
Thu, 1 Feb 2024 10:19:50 +0000 (12:19 +0200)
Hook implemented handlers to chip_ops, and fill packet frequency and signal
strength to RX status from RX PPDU status packet.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://msgid.link/20240124033637.12330-2-pkshih@realtek.com
drivers/net/wireless/realtek/rtw89/rtw8922a.c

index f34e2a8bff076163f8ff4598470044f953fa28a5..9c7465d0715b54f6429f07ee664b666233f084ed 100644 (file)
@@ -1250,6 +1250,39 @@ static void rtw8922a_ctrl_nbtg_bt_tx(struct rtw89_dev *rtwdev, bool en,
        }
 }
 
+static void rtw8922a_fill_freq_with_ppdu(struct rtw89_dev *rtwdev,
+                                        struct rtw89_rx_phy_ppdu *phy_ppdu,
+                                        struct ieee80211_rx_status *status)
+{
+       u8 chan_idx = phy_ppdu->chan_idx;
+       enum nl80211_band band;
+       u8 ch;
+
+       if (chan_idx == 0)
+               return;
+
+       rtw89_decode_chan_idx(rtwdev, chan_idx, &ch, &band);
+       status->freq = ieee80211_channel_to_frequency(ch, band);
+       status->band = band;
+}
+
+static void rtw8922a_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)
+               rtw8922a_fill_freq_with_ppdu(rtwdev, phy_ppdu, status);
+}
+
 static int rtw8922a_mac_enable_bb_rf(struct rtw89_dev *rtwdev)
 {
        rtw89_write8_set(rtwdev, R_BE_FEN_RST_ENABLE,
@@ -1291,10 +1324,14 @@ static const struct rtw89_chip_ops rtw8922a_chip_ops = {
        .set_txpwr_ctrl         = rtw8922a_set_txpwr_ctrl,
        .init_txpwr_unit        = NULL,
        .ctrl_btg_bt_rx         = rtw8922a_ctrl_btg_bt_rx,
+       .query_ppdu             = rtw8922a_query_ppdu,
        .ctrl_nbtg_bt_tx        = rtw8922a_ctrl_nbtg_bt_tx,
        .set_txpwr_ul_tb_offset = NULL,
        .pwr_on_func            = rtw8922a_pwr_on_func,
        .pwr_off_func           = rtw8922a_pwr_off_func,
+       .query_rxdesc           = rtw89_core_query_rxdesc_v2,
+       .fill_txdesc            = rtw89_core_fill_txdesc_v2,
+       .fill_txdesc_fwcmd      = rtw89_core_fill_txdesc_fwcmd_v2,
        .h2c_dctl_sec_cam       = rtw89_fw_h2c_dctl_sec_cam_v2,
        .h2c_default_cmac_tbl   = rtw89_fw_h2c_default_cmac_tbl_g7,
        .h2c_assoc_cmac_tbl     = rtw89_fw_h2c_assoc_cmac_tbl_g7,