]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
wifi: rtw89: fw: add CMAC H2C command for TX AMPDU for RTL8922D
authorPing-Ke Shih <pkshih@realtek.com>
Tue, 6 Jan 2026 03:09:07 +0000 (11:09 +0800)
committerPing-Ke Shih <pkshih@realtek.com>
Fri, 9 Jan 2026 05:45:32 +0000 (13:45 +0800)
CMAC H2C command is to configure CMAC such as TX retry and padding. Add to
update CMAC function block while AMPDU is established.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20260106030911.15528-7-pkshih@realtek.com
drivers/net/wireless/realtek/rtw89/fw.c
drivers/net/wireless/realtek/rtw89/fw.h

index 00ab803e6b0c2b2ec0672cddc2cf1f7a4cfd0fbe..1b2b6a66c6697289c9acc6ccb642a9ec861552e5 100644 (file)
@@ -4071,6 +4071,72 @@ fail:
 }
 EXPORT_SYMBOL(rtw89_fw_h2c_ampdu_cmac_tbl_g7);
 
+int rtw89_fw_h2c_ampdu_cmac_tbl_be(struct rtw89_dev *rtwdev,
+                                  struct rtw89_vif_link *rtwvif_link,
+                                  struct rtw89_sta_link *rtwsta_link)
+{
+       struct rtw89_sta *rtwsta = rtwsta_link->rtwsta;
+       struct rtw89_h2c_cctlinfo_ud_be *h2c;
+       u32 len = sizeof(*h2c);
+       struct sk_buff *skb;
+       u16 agg_num = 0;
+       u8 ba_bmap = 0;
+       int ret;
+       u8 tid;
+
+       skb = rtw89_fw_h2c_alloc_skb_with_hdr(rtwdev, len);
+       if (!skb) {
+               rtw89_err(rtwdev, "failed to alloc skb for ampdu cmac be\n");
+               return -ENOMEM;
+       }
+       skb_put(skb, len);
+       h2c = (struct rtw89_h2c_cctlinfo_ud_be *)skb->data;
+
+       for_each_set_bit(tid, rtwsta->ampdu_map, IEEE80211_NUM_TIDS) {
+               if (agg_num == 0)
+                       agg_num = rtwsta->ampdu_params[tid].agg_num;
+               else
+                       agg_num = min(agg_num, rtwsta->ampdu_params[tid].agg_num);
+       }
+
+       if (agg_num <= 0x20)
+               ba_bmap = 3;
+       else if (agg_num > 0x20 && agg_num <= 0x40)
+               ba_bmap = 0;
+       else if (agg_num > 0x40 && agg_num <= 0x80)
+               ba_bmap = 1;
+       else if (agg_num > 0x80 && agg_num <= 0x100)
+               ba_bmap = 2;
+       else if (agg_num > 0x100 && agg_num <= 0x200)
+               ba_bmap = 4;
+       else if (agg_num > 0x200 && agg_num <= 0x400)
+               ba_bmap = 5;
+
+       h2c->c0 = le32_encode_bits(rtwsta_link->mac_id, BE_CCTL_INFO_C0_V1_MACID) |
+                 le32_encode_bits(1, BE_CCTL_INFO_C0_V1_OP);
+
+       h2c->w3 = le32_encode_bits(ba_bmap, BE_CCTL_INFO_W3_BA_BMAP);
+       h2c->m3 = cpu_to_le32(BE_CCTL_INFO_W3_BA_BMAP);
+
+       rtw89_h2c_pkt_set_hdr(rtwdev, skb, FWCMD_TYPE_H2C,
+                             H2C_CAT_MAC, H2C_CL_MAC_FR_EXCHG,
+                             H2C_FUNC_MAC_CCTLINFO_UD_G7, 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_ampdu_cmac_tbl_be);
+
 int rtw89_fw_h2c_txtime_cmac_tbl(struct rtw89_dev *rtwdev,
                                 struct rtw89_sta_link *rtwsta_link)
 {
index 5da937de06bf1ea0100a69bfaf973d1f06e435a7..b2ad180da68d661bca3fb6f8e80db4214d3a51d1 100644 (file)
@@ -5043,6 +5043,9 @@ int rtw89_fw_h2c_assoc_cmac_tbl_be(struct rtw89_dev *rtwdev,
 int rtw89_fw_h2c_ampdu_cmac_tbl_g7(struct rtw89_dev *rtwdev,
                                   struct rtw89_vif_link *rtwvif_link,
                                   struct rtw89_sta_link *rtwsta_link);
+int rtw89_fw_h2c_ampdu_cmac_tbl_be(struct rtw89_dev *rtwdev,
+                                  struct rtw89_vif_link *rtwvif_link,
+                                  struct rtw89_sta_link *rtwsta_link);
 int rtw89_fw_h2c_txtime_cmac_tbl(struct rtw89_dev *rtwdev,
                                 struct rtw89_sta_link *rtwsta_link);
 int rtw89_fw_h2c_txtime_cmac_tbl_g7(struct rtw89_dev *rtwdev,