Skip to content

Commit 95d8211

Browse files
committed
wifi: rtw89: dynamically update EHT preamble puncturing
JIRA: https://issues.redhat.com/browse/RHEL-114891 commit b552a3e Author: Kuan-Chung Chen <damon.chen@realtek.com> Date: Tue Jul 15 11:52:57 2025 +0800 wifi: rtw89: dynamically update EHT preamble puncturing When the 'Disabled Subchannel Bitmap' within the EHT Operation element is changed, mac80211 parse and pass it to the driver. The driver is then updated with this puncturing bitmap to optimize bandwidth usage and prevent interference from degrading performance across the entire channel. Signed-off-by: Kuan-Chung Chen <damon.chen@realtek.com> Signed-off-by: Ping-Ke Shih <pkshih@realtek.com> Link: https://patch.msgid.link/20250715035259.45061-4-pkshih@realtek.com Signed-off-by: Jose Ignacio Tornos Martinez <jtornosm@redhat.com>
1 parent 4f62efc commit 95d8211

File tree

10 files changed

+115
-0
lines changed

10 files changed

+115
-0
lines changed

drivers/net/wireless/realtek/rtw89/chan.c

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,48 @@ void rtw89_chan_create(struct rtw89_chan *chan, u8 center_chan, u8 primary_chan,
129129
bandwidth);
130130
}
131131

132+
static void _rtw89_chan_update_punctured(struct rtw89_dev *rtwdev,
133+
struct rtw89_vif_link *rtwvif_link,
134+
const struct cfg80211_chan_def *chandef)
135+
{
136+
struct ieee80211_bss_conf *bss_conf;
137+
138+
if (rtwvif_link->wifi_role != RTW89_WIFI_ROLE_STATION &&
139+
rtwvif_link->wifi_role != RTW89_WIFI_ROLE_P2P_CLIENT)
140+
return;
141+
142+
rcu_read_lock();
143+
144+
bss_conf = rtw89_vif_rcu_dereference_link(rtwvif_link, true);
145+
if (!bss_conf->eht_support) {
146+
rcu_read_unlock();
147+
return;
148+
}
149+
150+
rcu_read_unlock();
151+
152+
rtw89_chip_h2c_punctured_cmac_tbl(rtwdev, rtwvif_link, chandef->punctured);
153+
}
154+
155+
static void rtw89_chan_update_punctured(struct rtw89_dev *rtwdev,
156+
enum rtw89_chanctx_idx idx,
157+
const struct cfg80211_chan_def *chandef)
158+
{
159+
struct rtw89_vif_link *rtwvif_link;
160+
struct rtw89_vif *rtwvif;
161+
unsigned int link_id;
162+
163+
rtw89_for_each_rtwvif(rtwdev, rtwvif) {
164+
rtw89_vif_for_each_link(rtwvif, rtwvif_link, link_id) {
165+
if (!rtwvif_link->chanctx_assigned ||
166+
rtwvif_link->chanctx_idx != idx)
167+
continue;
168+
169+
_rtw89_chan_update_punctured(rtwdev, rtwvif_link, chandef);
170+
}
171+
}
172+
}
173+
132174
bool rtw89_assign_entity_chan(struct rtw89_dev *rtwdev,
133175
enum rtw89_chanctx_idx idx,
134176
const struct rtw89_chan *new)
@@ -3245,6 +3287,9 @@ void rtw89_chanctx_ops_change(struct rtw89_dev *rtwdev,
32453287
rtw89_config_entity_chandef(rtwdev, idx, &ctx->def);
32463288
rtw89_set_channel(rtwdev);
32473289
}
3290+
3291+
if (changed & IEEE80211_CHANCTX_CHANGE_PUNCTURING)
3292+
rtw89_chan_update_punctured(rtwdev, idx, &ctx->def);
32483293
}
32493294

32503295
int rtw89_chanctx_ops_assign_vif(struct rtw89_dev *rtwdev,
@@ -3388,5 +3433,7 @@ int rtw89_chanctx_ops_reassign_vif(struct rtw89_dev *rtwdev,
33883433
return ret;
33893434
}
33903435

3436+
_rtw89_chan_update_punctured(rtwdev, rtwvif_link, &new_ctx->def);
3437+
33913438
return 0;
33923439
}

drivers/net/wireless/realtek/rtw89/core.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3779,6 +3779,9 @@ struct rtw89_chip_ops {
37793779
struct rtw89_sta_link *rtwsta_link);
37803780
int (*h2c_txtime_cmac_tbl)(struct rtw89_dev *rtwdev,
37813781
struct rtw89_sta_link *rtwsta_link);
3782+
int (*h2c_punctured_cmac_tbl)(struct rtw89_dev *rtwdev,
3783+
struct rtw89_vif_link *rtwvif_link,
3784+
u16 punctured);
37823785
int (*h2c_default_dmac_tbl)(struct rtw89_dev *rtwdev,
37833786
struct rtw89_vif_link *rtwvif_link,
37843787
struct rtw89_sta_link *rtwsta_link);

drivers/net/wireless/realtek/rtw89/fw.c

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3745,6 +3745,49 @@ int rtw89_fw_h2c_txtime_cmac_tbl_g7(struct rtw89_dev *rtwdev,
37453745
}
37463746
EXPORT_SYMBOL(rtw89_fw_h2c_txtime_cmac_tbl_g7);
37473747

3748+
int rtw89_fw_h2c_punctured_cmac_tbl_g7(struct rtw89_dev *rtwdev,
3749+
struct rtw89_vif_link *rtwvif_link,
3750+
u16 punctured)
3751+
{
3752+
struct rtw89_h2c_cctlinfo_ud_g7 *h2c;
3753+
u32 len = sizeof(*h2c);
3754+
struct sk_buff *skb;
3755+
int ret;
3756+
3757+
skb = rtw89_fw_h2c_alloc_skb_with_hdr(rtwdev, len);
3758+
if (!skb) {
3759+
rtw89_err(rtwdev, "failed to alloc skb for punctured cmac g7\n");
3760+
return -ENOMEM;
3761+
}
3762+
3763+
skb_put(skb, len);
3764+
h2c = (struct rtw89_h2c_cctlinfo_ud_g7 *)skb->data;
3765+
3766+
h2c->c0 = le32_encode_bits(rtwvif_link->mac_id, CCTLINFO_G7_C0_MACID) |
3767+
le32_encode_bits(1, CCTLINFO_G7_C0_OP);
3768+
3769+
h2c->w4 = le32_encode_bits(~punctured, CCTLINFO_G7_W4_ACT_SUBCH_CBW);
3770+
h2c->m4 = cpu_to_le32(CCTLINFO_G7_W4_ACT_SUBCH_CBW);
3771+
3772+
rtw89_h2c_pkt_set_hdr(rtwdev, skb, FWCMD_TYPE_H2C,
3773+
H2C_CAT_MAC, H2C_CL_MAC_FR_EXCHG,
3774+
H2C_FUNC_MAC_CCTLINFO_UD_G7, 0, 1,
3775+
len);
3776+
3777+
ret = rtw89_h2c_tx(rtwdev, skb, false);
3778+
if (ret) {
3779+
rtw89_err(rtwdev, "failed to send h2c\n");
3780+
goto fail;
3781+
}
3782+
3783+
return 0;
3784+
fail:
3785+
dev_kfree_skb_any(skb);
3786+
3787+
return ret;
3788+
}
3789+
EXPORT_SYMBOL(rtw89_fw_h2c_punctured_cmac_tbl_g7);
3790+
37483791
int rtw89_fw_h2c_txpath_cmac_tbl(struct rtw89_dev *rtwdev,
37493792
struct rtw89_sta_link *rtwsta_link)
37503793
{

drivers/net/wireless/realtek/rtw89/fw.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4736,6 +4736,9 @@ int rtw89_fw_h2c_txtime_cmac_tbl(struct rtw89_dev *rtwdev,
47364736
struct rtw89_sta_link *rtwsta_link);
47374737
int rtw89_fw_h2c_txtime_cmac_tbl_g7(struct rtw89_dev *rtwdev,
47384738
struct rtw89_sta_link *rtwsta_link);
4739+
int rtw89_fw_h2c_punctured_cmac_tbl_g7(struct rtw89_dev *rtwdev,
4740+
struct rtw89_vif_link *rtwvif_link,
4741+
u16 punctured);
47394742
int rtw89_fw_h2c_txpath_cmac_tbl(struct rtw89_dev *rtwdev,
47404743
struct rtw89_sta_link *rtwsta_link);
47414744
int rtw89_fw_h2c_update_beacon(struct rtw89_dev *rtwdev,
@@ -5038,6 +5041,19 @@ int rtw89_chip_h2c_txtime_cmac_tbl(struct rtw89_dev *rtwdev,
50385041
return chip->ops->h2c_txtime_cmac_tbl(rtwdev, rtwsta_link);
50395042
}
50405043

5044+
static inline
5045+
int rtw89_chip_h2c_punctured_cmac_tbl(struct rtw89_dev *rtwdev,
5046+
struct rtw89_vif_link *rtwvif_link,
5047+
u16 punctured)
5048+
{
5049+
const struct rtw89_chip_info *chip = rtwdev->chip;
5050+
5051+
if (!chip->ops->h2c_punctured_cmac_tbl)
5052+
return 0;
5053+
5054+
return chip->ops->h2c_punctured_cmac_tbl(rtwdev, rtwvif_link, punctured);
5055+
}
5056+
50415057
static inline
50425058
int rtw89_chip_h2c_ba_cam(struct rtw89_dev *rtwdev, struct rtw89_sta *rtwsta,
50435059
bool valid, struct ieee80211_ampdu_params *params)

drivers/net/wireless/realtek/rtw89/rtw8851b.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2546,6 +2546,7 @@ static const struct rtw89_chip_ops rtw8851b_chip_ops = {
25462546
.h2c_assoc_cmac_tbl = rtw89_fw_h2c_assoc_cmac_tbl,
25472547
.h2c_ampdu_cmac_tbl = NULL,
25482548
.h2c_txtime_cmac_tbl = rtw89_fw_h2c_txtime_cmac_tbl,
2549+
.h2c_punctured_cmac_tbl = NULL,
25492550
.h2c_default_dmac_tbl = NULL,
25502551
.h2c_update_beacon = rtw89_fw_h2c_update_beacon,
25512552
.h2c_ba_cam = rtw89_fw_h2c_ba_cam,

drivers/net/wireless/realtek/rtw89/rtw8852a.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2151,6 +2151,7 @@ static const struct rtw89_chip_ops rtw8852a_chip_ops = {
21512151
.h2c_assoc_cmac_tbl = rtw89_fw_h2c_assoc_cmac_tbl,
21522152
.h2c_ampdu_cmac_tbl = NULL,
21532153
.h2c_txtime_cmac_tbl = rtw89_fw_h2c_txtime_cmac_tbl,
2154+
.h2c_punctured_cmac_tbl = NULL,
21542155
.h2c_default_dmac_tbl = NULL,
21552156
.h2c_update_beacon = rtw89_fw_h2c_update_beacon,
21562157
.h2c_ba_cam = rtw89_fw_h2c_ba_cam,

drivers/net/wireless/realtek/rtw89/rtw8852b.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -851,6 +851,7 @@ static const struct rtw89_chip_ops rtw8852b_chip_ops = {
851851
.h2c_assoc_cmac_tbl = rtw89_fw_h2c_assoc_cmac_tbl,
852852
.h2c_ampdu_cmac_tbl = NULL,
853853
.h2c_txtime_cmac_tbl = rtw89_fw_h2c_txtime_cmac_tbl,
854+
.h2c_punctured_cmac_tbl = NULL,
854855
.h2c_default_dmac_tbl = NULL,
855856
.h2c_update_beacon = rtw89_fw_h2c_update_beacon,
856857
.h2c_ba_cam = rtw89_fw_h2c_ba_cam,

drivers/net/wireless/realtek/rtw89/rtw8852bt.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -717,6 +717,7 @@ static const struct rtw89_chip_ops rtw8852bt_chip_ops = {
717717
.h2c_assoc_cmac_tbl = rtw89_fw_h2c_assoc_cmac_tbl,
718718
.h2c_ampdu_cmac_tbl = NULL,
719719
.h2c_txtime_cmac_tbl = rtw89_fw_h2c_txtime_cmac_tbl,
720+
.h2c_punctured_cmac_tbl = NULL,
720721
.h2c_default_dmac_tbl = NULL,
721722
.h2c_update_beacon = rtw89_fw_h2c_update_beacon,
722723
.h2c_ba_cam = rtw89_fw_h2c_ba_cam,

drivers/net/wireless/realtek/rtw89/rtw8852c.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2971,6 +2971,7 @@ static const struct rtw89_chip_ops rtw8852c_chip_ops = {
29712971
.h2c_assoc_cmac_tbl = rtw89_fw_h2c_assoc_cmac_tbl,
29722972
.h2c_ampdu_cmac_tbl = NULL,
29732973
.h2c_txtime_cmac_tbl = rtw89_fw_h2c_txtime_cmac_tbl,
2974+
.h2c_punctured_cmac_tbl = NULL,
29742975
.h2c_default_dmac_tbl = NULL,
29752976
.h2c_update_beacon = rtw89_fw_h2c_update_beacon,
29762977
.h2c_ba_cam = rtw89_fw_h2c_ba_cam,

drivers/net/wireless/realtek/rtw89/rtw8922a.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2826,6 +2826,7 @@ static const struct rtw89_chip_ops rtw8922a_chip_ops = {
28262826
.h2c_assoc_cmac_tbl = rtw89_fw_h2c_assoc_cmac_tbl_g7,
28272827
.h2c_ampdu_cmac_tbl = rtw89_fw_h2c_ampdu_cmac_tbl_g7,
28282828
.h2c_txtime_cmac_tbl = rtw89_fw_h2c_txtime_cmac_tbl_g7,
2829+
.h2c_punctured_cmac_tbl = rtw89_fw_h2c_punctured_cmac_tbl_g7,
28292830
.h2c_default_dmac_tbl = rtw89_fw_h2c_default_dmac_tbl_v2,
28302831
.h2c_update_beacon = rtw89_fw_h2c_update_beacon_be,
28312832
.h2c_ba_cam = rtw89_fw_h2c_ba_cam_v1,

0 commit comments

Comments
 (0)