wifi: rtw89: fw: add H2C command to reset DMAC table for WiFi 7
authorPing-Ke Shih <pkshih@realtek.com>
Mon, 15 Jan 2024 03:37:40 +0000 (11:37 +0800)
committerKalle Valo <kvalo@kernel.org>
Thu, 18 Jan 2024 09:33:57 +0000 (11:33 +0200)
Reset DMAC table, so we get expected behavior instead of random values at
early stage.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://msgid.link/20240115033742.16372-7-pkshih@realtek.com
drivers/net/wireless/realtek/rtw89/cam.h
drivers/net/wireless/realtek/rtw89/core.c
drivers/net/wireless/realtek/rtw89/core.h
drivers/net/wireless/realtek/rtw89/fw.c
drivers/net/wireless/realtek/rtw89/fw.h
drivers/net/wireless/realtek/rtw89/mac.c
drivers/net/wireless/realtek/rtw89/rtw8851b.c
drivers/net/wireless/realtek/rtw89/rtw8852a.c
drivers/net/wireless/realtek/rtw89/rtw8852b.c
drivers/net/wireless/realtek/rtw89/rtw8852c.c
drivers/net/wireless/realtek/rtw89/rtw8922a.c

index 9a2dd5999edb12786cbb8068e1973268ae5fa6a6..fa09d11c345c8636e42a8aab1e7b322255d597ea 100644 (file)
@@ -395,7 +395,9 @@ struct rtw89_h2c_dctlinfo_ud_v2 {
 #define DCTLINFO_V2_W0_HW_EXSEQ_MACID GENMASK(14, 8)
 #define DCTLINFO_V2_W0_QOS_DATA BIT(15)
 #define DCTLINFO_V2_W0_AES_IV_L GENMASK(31, 16)
+#define DCTLINFO_V2_W0_ALL GENMASK(31, 0)
 #define DCTLINFO_V2_W1_AES_IV_H GENMASK(31, 0)
+#define DCTLINFO_V2_W1_ALL GENMASK(31, 0)
 #define DCTLINFO_V2_W2_SEQ0 GENMASK(11, 0)
 #define DCTLINFO_V2_W2_SEQ1 GENMASK(23, 12)
 #define DCTLINFO_V2_W2_AMSDU_MAX_LEN GENMASK(26, 24)
@@ -404,11 +406,13 @@ struct rtw89_h2c_dctlinfo_ud_v2 {
 #define DCTLINFO_V2_W2_WITH_LLC BIT(29)
 #define DCTLINFO_V2_W2_NAT25_EN BIT(30)
 #define DCTLINFO_V2_W2_IS_MLD BIT(31)
+#define DCTLINFO_V2_W2_ALL GENMASK(31, 0)
 #define DCTLINFO_V2_W3_SEQ2 GENMASK(11, 0)
 #define DCTLINFO_V2_W3_SEQ3 GENMASK(23, 12)
 #define DCTLINFO_V2_W3_TGT_IND GENMASK(27, 24)
 #define DCTLINFO_V2_W3_TGT_IND_EN BIT(28)
 #define DCTLINFO_V2_W3_HTC_LB GENMASK(31, 29)
+#define DCTLINFO_V2_W3_ALL GENMASK(31, 0)
 #define DCTLINFO_V2_W4_VLAN_TAG_SEL GENMASK(7, 5)
 #define DCTLINFO_V2_W4_HTC_ORDER BIT(8)
 #define DCTLINFO_V2_W4_SEC_KEY_ID GENMASK(10, 9)
@@ -425,24 +429,33 @@ struct rtw89_h2c_dctlinfo_ud_v2 {
 #define DCTLINFO_V2_W4_SEC_ENT4_KEYID GENMASK(27, 26)
 #define DCTLINFO_V2_W4_SEC_ENT5_KEYID GENMASK(29, 28)
 #define DCTLINFO_V2_W4_SEC_ENT6_KEYID GENMASK(31, 30)
+#define DCTLINFO_V2_W4_ALL GENMASK(31, 5)
 #define DCTLINFO_V2_W5_SEC_ENT7_KEYID GENMASK(1, 0)
 #define DCTLINFO_V2_W5_SEC_ENT8_KEYID GENMASK(3, 2)
 #define DCTLINFO_V2_W5_SEC_ENT_VALID_V1 GENMASK(23, 8)
 #define DCTLINFO_V2_W5_SEC_ENT0_V1 GENMASK(31, 24)
+#define DCTLINFO_V2_W5_ALL (GENMASK(31, 8) | GENMASK(3, 0))
 #define DCTLINFO_V2_W6_SEC_ENT1_V1 GENMASK(7, 0)
 #define DCTLINFO_V2_W6_SEC_ENT2_V1 GENMASK(15, 8)
 #define DCTLINFO_V2_W6_SEC_ENT3_V1 GENMASK(23, 16)
 #define DCTLINFO_V2_W6_SEC_ENT4_V1 GENMASK(31, 24)
+#define DCTLINFO_V2_W6_ALL GENMASK(31, 0)
 #define DCTLINFO_V2_W7_SEC_ENT5_V1 GENMASK(7, 0)
 #define DCTLINFO_V2_W7_SEC_ENT6_V1 GENMASK(15, 8)
 #define DCTLINFO_V2_W7_SEC_ENT7 GENMASK(23, 16)
 #define DCTLINFO_V2_W7_SEC_ENT8 GENMASK(31, 24)
+#define DCTLINFO_V2_W7_ALL GENMASK(31, 0)
 #define DCTLINFO_V2_W8_MLD_SMA_L_V1 GENMASK(31, 0)
+#define DCTLINFO_V2_W8_ALL GENMASK(31, 0)
 #define DCTLINFO_V2_W9_MLD_SMA_H_V1 GENMASK(15, 0)
 #define DCTLINFO_V2_W9_MLD_TMA_L_V1 GENMASK(31, 16)
+#define DCTLINFO_V2_W9_ALL GENMASK(31, 0)
 #define DCTLINFO_V2_W10_MLD_TMA_H_V1 GENMASK(31, 0)
+#define DCTLINFO_V2_W10_ALL GENMASK(31, 0)
 #define DCTLINFO_V2_W11_MLD_TA_BSSID_L_V1 GENMASK(31, 0)
+#define DCTLINFO_V2_W11_ALL GENMASK(31, 0)
 #define DCTLINFO_V2_W12_MLD_TA_BSSID_H_V1 GENMASK(15, 0)
+#define DCTLINFO_V2_W12_ALL GENMASK(15, 0)
 
 int rtw89_cam_init(struct rtw89_dev *rtwdev, struct rtw89_vif *vif);
 void rtw89_cam_deinit(struct rtw89_dev *rtwdev, struct rtw89_vif *vif);
index cf819434a2a1b94a9423ca0e404396a353f8b6d1..347703b68dfd3699320057033d957b9c3b9d50ab 100644 (file)
@@ -3349,6 +3349,10 @@ int rtw89_core_sta_add(struct rtw89_dev *rtwdev,
                if (ret)
                        return ret;
 
+               ret = rtw89_chip_h2c_default_dmac_tbl(rtwdev, rtwvif, rtwsta);
+               if (ret)
+                       return ret;
+
                rtw89_queue_chanctx_change(rtwdev, RTW89_CHANCTX_REMOTE_STA_CHANGE);
        }
 
index 27d314a1baed9b69f9ddd01feae09488d9fcae21..80f67f1b06793fbc5977cb6096122f334f56a464 100644 (file)
@@ -3207,6 +3207,9 @@ struct rtw89_chip_ops {
        int (*h2c_ampdu_cmac_tbl)(struct rtw89_dev *rtwdev,
                                  struct ieee80211_vif *vif,
                                  struct ieee80211_sta *sta);
+       int (*h2c_default_dmac_tbl)(struct rtw89_dev *rtwdev,
+                                   struct rtw89_vif *rtwvif,
+                                   struct rtw89_sta *rtwsta);
        int (*h2c_update_beacon)(struct rtw89_dev *rtwdev,
                                 struct rtw89_vif *rtwvif);
        int (*h2c_ba_cam)(struct rtw89_dev *rtwdev, struct rtw89_sta *rtwsta,
index 052dc3cc01eb5bbfb9cda051b2d6a1f70f6880c4..255be99b3630f07c4a0599ee0cd547d8c6f89e00 100644 (file)
@@ -1525,6 +1525,61 @@ fail:
 }
 EXPORT_SYMBOL(rtw89_fw_h2c_dctl_sec_cam_v2);
 
+int rtw89_fw_h2c_default_dmac_tbl_v2(struct rtw89_dev *rtwdev,
+                                    struct rtw89_vif *rtwvif,
+                                    struct rtw89_sta *rtwsta)
+{
+       u8 mac_id = rtwsta ? rtwsta->mac_id : rtwvif->mac_id;
+       struct rtw89_h2c_dctlinfo_ud_v2 *h2c;
+       u32 len = sizeof(*h2c);
+       struct sk_buff *skb;
+       int ret;
+
+       skb = rtw89_fw_h2c_alloc_skb_with_hdr(rtwdev, len);
+       if (!skb) {
+               rtw89_err(rtwdev, "failed to alloc skb for dctl v2\n");
+               return -ENOMEM;
+       }
+       skb_put(skb, len);
+       h2c = (struct rtw89_h2c_dctlinfo_ud_v2 *)skb->data;
+
+       h2c->c0 = le32_encode_bits(mac_id, DCTLINFO_V2_C0_MACID) |
+                 le32_encode_bits(1, DCTLINFO_V2_C0_OP);
+
+       h2c->m0 = cpu_to_le32(DCTLINFO_V2_W0_ALL);
+       h2c->m1 = cpu_to_le32(DCTLINFO_V2_W1_ALL);
+       h2c->m2 = cpu_to_le32(DCTLINFO_V2_W2_ALL);
+       h2c->m3 = cpu_to_le32(DCTLINFO_V2_W3_ALL);
+       h2c->m4 = cpu_to_le32(DCTLINFO_V2_W4_ALL);
+       h2c->m5 = cpu_to_le32(DCTLINFO_V2_W5_ALL);
+       h2c->m6 = cpu_to_le32(DCTLINFO_V2_W6_ALL);
+       h2c->m7 = cpu_to_le32(DCTLINFO_V2_W7_ALL);
+       h2c->m8 = cpu_to_le32(DCTLINFO_V2_W8_ALL);
+       h2c->m9 = cpu_to_le32(DCTLINFO_V2_W9_ALL);
+       h2c->m10 = cpu_to_le32(DCTLINFO_V2_W10_ALL);
+       h2c->m11 = cpu_to_le32(DCTLINFO_V2_W11_ALL);
+       h2c->m12 = cpu_to_le32(DCTLINFO_V2_W12_ALL);
+
+       rtw89_h2c_pkt_set_hdr(rtwdev, skb, FWCMD_TYPE_H2C,
+                             H2C_CAT_MAC,
+                             H2C_CL_MAC_FR_EXCHG,
+                             H2C_FUNC_MAC_DCTLINFO_UD_V2, 0, 0,
+                             len);
+
+       ret = rtw89_h2c_tx(rtwdev, skb, false);
+       if (ret) {
+               rtw89_err(rtwdev, "failed to send h2c\n");
+               goto fail;
+       }
+
+       return 0;
+fail:
+       dev_kfree_skb_any(skb);
+
+       return ret;
+}
+EXPORT_SYMBOL(rtw89_fw_h2c_default_dmac_tbl_v2);
+
 int rtw89_fw_h2c_ba_cam(struct rtw89_dev *rtwdev, struct rtw89_sta *rtwsta,
                        bool valid, struct ieee80211_ampdu_params *params)
 {
index b9e8fb693202316b7576e2a33cbffed0c40d63f8..b5f7240879541b8052a5a0da8b9f0d8cc7c5ea3e 100644 (file)
@@ -3955,6 +3955,9 @@ int rtw89_fw_h2c_default_cmac_tbl(struct rtw89_dev *rtwdev,
 int rtw89_fw_h2c_default_cmac_tbl_g7(struct rtw89_dev *rtwdev,
                                     struct rtw89_vif *rtwvif,
                                     struct rtw89_sta *rtwsta);
+int rtw89_fw_h2c_default_dmac_tbl_v2(struct rtw89_dev *rtwdev,
+                                    struct rtw89_vif *rtwvif,
+                                    struct rtw89_sta *rtwsta);
 int rtw89_fw_h2c_assoc_cmac_tbl(struct rtw89_dev *rtwdev,
                                struct ieee80211_vif *vif,
                                struct ieee80211_sta *sta);
@@ -4113,6 +4116,18 @@ static inline int rtw89_chip_h2c_default_cmac_tbl(struct rtw89_dev *rtwdev,
        return chip->ops->h2c_default_cmac_tbl(rtwdev, rtwvif, rtwsta);
 }
 
+static inline int rtw89_chip_h2c_default_dmac_tbl(struct rtw89_dev *rtwdev,
+                                                 struct rtw89_vif *rtwvif,
+                                                 struct rtw89_sta *rtwsta)
+{
+       const struct rtw89_chip_info *chip = rtwdev->chip;
+
+       if (chip->ops->h2c_default_dmac_tbl)
+               return chip->ops->h2c_default_dmac_tbl(rtwdev, rtwvif, rtwsta);
+
+       return 0;
+}
+
 static inline int rtw89_chip_h2c_update_beacon(struct rtw89_dev *rtwdev,
                                               struct rtw89_vif *rtwvif)
 {
index cee1e512d2646063ee19fa71e16fa8959a28db52..16f21406fbd20416c22865568fd73c6406f0027e 100644 (file)
@@ -4501,6 +4501,10 @@ int rtw89_mac_vif_init(struct rtw89_dev *rtwdev, struct rtw89_vif *rtwvif)
        if (ret)
                return ret;
 
+       ret = rtw89_chip_h2c_default_dmac_tbl(rtwdev, rtwvif, NULL);
+       if (ret)
+               return ret;
+
        return 0;
 }
 
index 05750924d339d19405d2805962f3de125b9635b2..40020d0ebbdf3d8e4491f128fa72ab7853a26c62 100644 (file)
@@ -2337,6 +2337,7 @@ static const struct rtw89_chip_ops rtw8851b_chip_ops = {
        .h2c_default_cmac_tbl   = rtw89_fw_h2c_default_cmac_tbl,
        .h2c_assoc_cmac_tbl     = rtw89_fw_h2c_assoc_cmac_tbl,
        .h2c_ampdu_cmac_tbl     = NULL,
+       .h2c_default_dmac_tbl   = NULL,
        .h2c_update_beacon      = rtw89_fw_h2c_update_beacon,
        .h2c_ba_cam             = rtw89_fw_h2c_ba_cam,
 
index e28ebefc6774dc494d79ea65119b8216f8ac89be..726b08ca58977d369db7e1505b11e71cc6f8179d 100644 (file)
@@ -2081,6 +2081,7 @@ static const struct rtw89_chip_ops rtw8852a_chip_ops = {
        .h2c_default_cmac_tbl   = rtw89_fw_h2c_default_cmac_tbl,
        .h2c_assoc_cmac_tbl     = rtw89_fw_h2c_assoc_cmac_tbl,
        .h2c_ampdu_cmac_tbl     = NULL,
+       .h2c_default_dmac_tbl   = NULL,
        .h2c_update_beacon      = rtw89_fw_h2c_update_beacon,
        .h2c_ba_cam             = rtw89_fw_h2c_ba_cam,
 
index 8b8e7b54494a6ce8a926274b3894a9f5fe1311a3..b3ad84cfad952fa14e7bba2102a9a7604c5d1865 100644 (file)
@@ -2506,6 +2506,7 @@ static const struct rtw89_chip_ops rtw8852b_chip_ops = {
        .h2c_default_cmac_tbl   = rtw89_fw_h2c_default_cmac_tbl,
        .h2c_assoc_cmac_tbl     = rtw89_fw_h2c_assoc_cmac_tbl,
        .h2c_ampdu_cmac_tbl     = NULL,
+       .h2c_default_dmac_tbl   = NULL,
        .h2c_update_beacon      = rtw89_fw_h2c_update_beacon,
        .h2c_ba_cam             = rtw89_fw_h2c_ba_cam,
 
index 9616167e3f6e802714b49913c4966c77a8b7f271..cbc896a29fb47e89887b833eebac03896afe8a31 100644 (file)
@@ -2851,6 +2851,7 @@ static const struct rtw89_chip_ops rtw8852c_chip_ops = {
        .h2c_default_cmac_tbl   = rtw89_fw_h2c_default_cmac_tbl,
        .h2c_assoc_cmac_tbl     = rtw89_fw_h2c_assoc_cmac_tbl,
        .h2c_ampdu_cmac_tbl     = NULL,
+       .h2c_default_dmac_tbl   = NULL,
        .h2c_update_beacon      = rtw89_fw_h2c_update_beacon,
        .h2c_ba_cam             = rtw89_fw_h2c_ba_cam,
 
index 46596f5583e2244058628942be9c2ea51f17686c..7ded6f4313092d14d777c21a39b62035c8254128 100644 (file)
@@ -826,6 +826,7 @@ static const struct rtw89_chip_ops rtw8922a_chip_ops = {
        .h2c_default_cmac_tbl   = rtw89_fw_h2c_default_cmac_tbl_g7,
        .h2c_assoc_cmac_tbl     = rtw89_fw_h2c_assoc_cmac_tbl_g7,
        .h2c_ampdu_cmac_tbl     = rtw89_fw_h2c_ampdu_cmac_tbl_g7,
+       .h2c_default_dmac_tbl   = rtw89_fw_h2c_default_dmac_tbl_v2,
        .h2c_update_beacon      = rtw89_fw_h2c_update_beacon_be,
        .h2c_ba_cam             = rtw89_fw_h2c_ba_cam_v1,
 };