rtw89: correct setting of RX MPDU length
authorPing-Ke Shih <pkshih@realtek.com>
Fri, 6 May 2022 12:02:13 +0000 (20:02 +0800)
committerKalle Valo <kvalo@kernel.org>
Wed, 11 May 2022 05:31:02 +0000 (08:31 +0300)
Set proper setting according to RX quota, and then it doesn't break buffer
due to size of received packet exceeding buffer size.

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

index a06ca65b339ffbe55e9035b4c2c61a9baf8a67a4..e1a1699a1a9cfb58700e84597c455c206ade718a 100644 (file)
@@ -2005,6 +2005,7 @@ static int rmac_init(struct rtw89_dev *rtwdev, u8 mac_idx)
 #define TRXCFG_RMAC_DATA_TO    15
 #define RX_MAX_LEN_UNIT 512
 #define PLD_RLS_MAX_PG 127
+#define RX_SPEC_MAX_LEN (11454 + RX_MAX_LEN_UNIT)
        int ret;
        u32 reg, rx_max_len, rx_qta;
        u16 val;
@@ -2035,11 +2036,10 @@ static int rmac_init(struct rtw89_dev *rtwdev, u8 mac_idx)
                rx_qta = rtwdev->mac.dle_info.c0_rx_qta;
        else
                rx_qta = rtwdev->mac.dle_info.c1_rx_qta;
-       rx_qta = rx_qta > PLD_RLS_MAX_PG ? PLD_RLS_MAX_PG : rx_qta;
-       rx_max_len = (rx_qta - 1) * rtwdev->mac.dle_info.ple_pg_size /
-                    RX_MAX_LEN_UNIT;
-       rx_max_len = rx_max_len > B_AX_RX_MPDU_MAX_LEN_SIZE ?
-                    B_AX_RX_MPDU_MAX_LEN_SIZE : rx_max_len;
+       rx_qta = min_t(u32, rx_qta, PLD_RLS_MAX_PG);
+       rx_max_len = rx_qta * rtwdev->mac.dle_info.ple_pg_size;
+       rx_max_len = min_t(u32, rx_max_len, RX_SPEC_MAX_LEN);
+       rx_max_len /= RX_MAX_LEN_UNIT;
        rtw89_write32_mask(rtwdev, reg, B_AX_RX_MPDU_MAX_LEN_MASK, rx_max_len);
 
        if (rtwdev->chip->chip_id == RTL8852A &&