wifi: rtw89: add new H2C command to pause/sleep transmitting by MAC ID
authorPing-Ke Shih <pkshih@realtek.com>
Mon, 8 Jan 2024 09:13:15 +0000 (17:13 +0800)
committerKalle Valo <kvalo@kernel.org>
Fri, 12 Jan 2024 17:10:52 +0000 (19:10 +0200)
New H2C command is introduced to pause/sleep transmitting. That extends
more bits to support more MAC ID, and currently we still configure 256
MAC ID at most.

This new command is always used by coming WiFi 7 chips, and existing
chips can use old or new command because firmware still preserves the old
one. Add a firmware feature flag to determine which command is adopted
according to firmware version.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://msgid.link/20240108091315.67358-1-pkshih@realtek.com
drivers/net/wireless/realtek/rtw89/core.h
drivers/net/wireless/realtek/rtw89/fw.c
drivers/net/wireless/realtek/rtw89/fw.h

index 63f1f0e2c30fc4b4de9dd85f30589a61e9b46c23..0c6d83c4c047755b6d6a9d369f0af104695b8058 100644 (file)
@@ -3900,6 +3900,7 @@ enum rtw89_fw_feature {
        RTW89_FW_FEATURE_NO_DEEP_PS,
        RTW89_FW_FEATURE_NO_LPS_PG,
        RTW89_FW_FEATURE_BEACON_FILTER,
+       RTW89_FW_FEATURE_MACID_PAUSE_SLEEP,
 };
 
 struct rtw89_fw_suit {
index 991c42c4e5091491c841781f35ceec431d05fc88..9d6748f65ba372bc8a0d85afc0068d23b1152570 100644 (file)
@@ -458,6 +458,7 @@ static const struct __fw_feat_cfg fw_feat_tbl[] = {
        __CFG_FW_FEAT(RTL8852C, ge, 0, 27, 40, 0, CRASH_TRIGGER),
        __CFG_FW_FEAT(RTL8852C, ge, 0, 27, 56, 10, BEACON_FILTER),
        __CFG_FW_FEAT(RTL8922A, ge, 0, 34, 30, 0, CRASH_TRIGGER),
+       __CFG_FW_FEAT(RTL8922A, ge, 0, 34, 11, 0, MACID_PAUSE_SLEEP),
 };
 
 static void rtw89_fw_iterate_feature_cfg(struct rtw89_fw_info *fw,
@@ -2489,27 +2490,49 @@ fail:
 int rtw89_fw_h2c_macid_pause(struct rtw89_dev *rtwdev, u8 sh, u8 grp,
                             bool pause)
 {
+       struct rtw89_fw_macid_pause_sleep_grp *h2c_new;
        struct rtw89_fw_macid_pause_grp *h2c;
        __le32 set = cpu_to_le32(BIT(sh));
-       u8 len = sizeof(*h2c);
+       u8 h2c_macid_pause_id;
        struct sk_buff *skb;
+       u32 len;
        int ret;
 
+       if (RTW89_CHK_FW_FEATURE(MACID_PAUSE_SLEEP, &rtwdev->fw)) {
+               h2c_macid_pause_id = H2C_FUNC_MAC_MACID_PAUSE_SLEEP;
+               len = sizeof(*h2c_new);
+       } else {
+               h2c_macid_pause_id = H2C_FUNC_MAC_MACID_PAUSE;
+               len = sizeof(*h2c);
+       }
+
        skb = rtw89_fw_h2c_alloc_skb_with_hdr(rtwdev, len);
        if (!skb) {
                rtw89_err(rtwdev, "failed to alloc skb for h2c macid pause\n");
                return -ENOMEM;
        }
        skb_put(skb, len);
-       h2c = (struct rtw89_fw_macid_pause_grp *)skb->data;
 
-       h2c->mask_grp[grp] = set;
-       if (pause)
-               h2c->pause_grp[grp] = set;
+       if (h2c_macid_pause_id == H2C_FUNC_MAC_MACID_PAUSE_SLEEP) {
+               h2c_new = (struct rtw89_fw_macid_pause_sleep_grp *)skb->data;
+
+               h2c_new->n[0].pause_mask_grp[grp] = set;
+               h2c_new->n[0].sleep_mask_grp[grp] = set;
+               if (pause) {
+                       h2c_new->n[0].pause_grp[grp] = set;
+                       h2c_new->n[0].sleep_grp[grp] = set;
+               }
+       } else {
+               h2c = (struct rtw89_fw_macid_pause_grp *)skb->data;
+
+               h2c->mask_grp[grp] = set;
+               if (pause)
+                       h2c->pause_grp[grp] = set;
+       }
 
        rtw89_h2c_pkt_set_hdr(rtwdev, skb, FWCMD_TYPE_H2C,
                              H2C_CAT_MAC, H2C_CL_MAC_FW_OFLD,
-                             H2C_FUNC_MAC_MACID_PAUSE, 1, 0,
+                             h2c_macid_pause_id, 1, 0,
                              len);
 
        ret = rtw89_h2c_tx(rtwdev, skb, false);
index ec90cc9b0b53afc670f1224733797564de910095..0365cd7b8da0ae19ab4fb97b8fb80bebbd3f4df3 100644 (file)
@@ -231,6 +231,15 @@ struct rtw89_fw_macid_pause_grp {
        __le32 mask_grp[4];
 } __packed;
 
+struct rtw89_fw_macid_pause_sleep_grp {
+       struct {
+               __le32 pause_grp[4];
+               __le32 pause_mask_grp[4];
+               __le32 sleep_grp[4];
+               __le32 sleep_mask_grp[4];
+       } __packed n[4];
+} __packed;
+
 #define RTW89_H2C_MAX_SIZE 2048
 #define RTW89_CHANNEL_TIME 45
 #define RTW89_CHANNEL_TIME_6G 20
@@ -3659,6 +3668,7 @@ enum rtw89_fw_ofld_h2c_func {
        H2C_FUNC_CFG_BCNFLTR            = 0x1e,
        H2C_FUNC_OFLD_RSSI              = 0x1f,
        H2C_FUNC_OFLD_TP                = 0x20,
+       H2C_FUNC_MAC_MACID_PAUSE_SLEEP  = 0x28,
 
        NUM_OF_RTW89_FW_OFLD_H2C_FUNC,
 };