rtw88: Don't set RX_FLAG_DECRYPTED if packet has no encryption
authorPing-Ke Shih <pkshih@realtek.com>
Wed, 2 Oct 2019 06:35:26 +0000 (14:35 +0800)
committerKalle Valo <kvalo@codeaurora.org>
Fri, 4 Oct 2019 13:45:01 +0000 (16:45 +0300)
The value of GET_RX_DESC_SWDEC() indicates that if this RX
packet requires software decryption or not. And software
decryption is required when the packet was encrypted and the
hardware failed to decrypt it.

So, GET_RX_DESC_SWDEC() is negative does not mean that this
packet is decrypted, it might just have no encryption at all.
To actually see if the packet is decrypted, driver needs to
further check if the hardware has successfully decrypted it,
with a specific type of encryption algorithm.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
drivers/net/wireless/realtek/rtw88/rtw8822b.c
drivers/net/wireless/realtek/rtw88/rtw8822c.c
drivers/net/wireless/realtek/rtw88/rx.h

index 2b6cd7cf763b39eec28fc2e96ad9035adc8f7f1f..1e20c4465bc9b96b69da8919dc385ac2bb2aaa48 100644 (file)
@@ -836,7 +836,8 @@ static void rtw8822b_query_rx_desc(struct rtw_dev *rtwdev, u8 *rx_desc,
        pkt_stat->phy_status = GET_RX_DESC_PHYST(rx_desc);
        pkt_stat->icv_err = GET_RX_DESC_ICV_ERR(rx_desc);
        pkt_stat->crc_err = GET_RX_DESC_CRC32(rx_desc);
-       pkt_stat->decrypted = !GET_RX_DESC_SWDEC(rx_desc);
+       pkt_stat->decrypted = !GET_RX_DESC_SWDEC(rx_desc) &&
+                             GET_RX_DESC_ENC_TYPE(rx_desc) != RX_DESC_ENC_NONE;
        pkt_stat->is_c2h = GET_RX_DESC_C2H(rx_desc);
        pkt_stat->pkt_len = GET_RX_DESC_PKT_LEN(rx_desc);
        pkt_stat->drv_info_sz = GET_RX_DESC_DRV_INFO_SIZE(rx_desc);
index 3b3bc39cf7400dfa2ce8b84e92b08f9f5c2a2365..5075c7045b8fcd4e73b05efe74369a3a9e0ae059 100644 (file)
@@ -1704,7 +1704,8 @@ static void rtw8822c_query_rx_desc(struct rtw_dev *rtwdev, u8 *rx_desc,
        pkt_stat->phy_status = GET_RX_DESC_PHYST(rx_desc);
        pkt_stat->icv_err = GET_RX_DESC_ICV_ERR(rx_desc);
        pkt_stat->crc_err = GET_RX_DESC_CRC32(rx_desc);
-       pkt_stat->decrypted = !GET_RX_DESC_SWDEC(rx_desc);
+       pkt_stat->decrypted = !GET_RX_DESC_SWDEC(rx_desc) &&
+                             GET_RX_DESC_ENC_TYPE(rx_desc) != RX_DESC_ENC_NONE;
        pkt_stat->is_c2h = GET_RX_DESC_C2H(rx_desc);
        pkt_stat->pkt_len = GET_RX_DESC_PKT_LEN(rx_desc);
        pkt_stat->drv_info_sz = GET_RX_DESC_DRV_INFO_SIZE(rx_desc);
index 383f3b2babc101d59d39db24ba2bfaaa3b025717..3342e37612813a7004f2ca1345d5621f59237d6a 100644 (file)
@@ -5,6 +5,15 @@
 #ifndef __RTW_RX_H_
 #define __RTW_RX_H_
 
+enum rtw_rx_desc_enc {
+       RX_DESC_ENC_NONE        = 0,
+       RX_DESC_ENC_WEP40       = 1,
+       RX_DESC_ENC_TKIP_WO_MIC = 2,
+       RX_DESC_ENC_TKIP_MIC    = 3,
+       RX_DESC_ENC_AES         = 4,
+       RX_DESC_ENC_WEP104      = 5,
+};
+
 #define GET_RX_DESC_PHYST(rxdesc)                                              \
        le32_get_bits(*((__le32 *)(rxdesc) + 0x00), BIT(26))
 #define GET_RX_DESC_ICV_ERR(rxdesc)                                            \
@@ -21,6 +30,8 @@
        le32_get_bits(*((__le32 *)(rxdesc) + 0x00), GENMASK(19, 16))
 #define GET_RX_DESC_SHIFT(rxdesc)                                              \
        le32_get_bits(*((__le32 *)(rxdesc) + 0x00), GENMASK(25, 24))
+#define GET_RX_DESC_ENC_TYPE(rxdesc)                                           \
+       le32_get_bits(*((__le32 *)(rxdesc) + 0x00), GENMASK(22, 20))
 #define GET_RX_DESC_RX_RATE(rxdesc)                                            \
        le32_get_bits(*((__le32 *)(rxdesc) + 0x03), GENMASK(6, 0))
 #define GET_RX_DESC_MACID(rxdesc)                                              \