Skip to content

Commit

Permalink
wifi: rtw89: 8922a: Add new fields for scan offload H2C command
Browse files Browse the repository at this point in the history
Update scan offload H2C format to fit firmware version 35.21.
The new fields indicate lengths of variable length members, so
when driver and firmware are using mismatch version, FW could
handle the parsing better.

Signed-off-by: Po-Hao Huang <[email protected]>
Signed-off-by: Ping-Ke Shih <[email protected]>
Link: https://patch.msgid.link/[email protected]
  • Loading branch information
Po-Hao Huang authored and Ping-Ke Shih committed Aug 7, 2024
1 parent ca33c15 commit 6ca6b91
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 6 deletions.
1 change: 1 addition & 0 deletions drivers/net/wireless/realtek/rtw89/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -4367,6 +4367,7 @@ enum rtw89_fw_feature {
RTW89_FW_FEATURE_NO_LPS_PG,
RTW89_FW_FEATURE_BEACON_FILTER,
RTW89_FW_FEATURE_MACID_PAUSE_SLEEP,
RTW89_FW_FEATURE_SCAN_OFFLOAD_BE_V0,
RTW89_FW_FEATURE_WOW_REASON_V1,
RTW89_FW_FEATURE_RFK_PRE_NOTIFY_V0,
};
Expand Down
22 changes: 19 additions & 3 deletions drivers/net/wireless/realtek/rtw89/fw.c
Original file line number Diff line number Diff line change
Expand Up @@ -683,6 +683,7 @@ static const struct __fw_feat_cfg fw_feat_tbl[] = {
__CFG_FW_FEAT(RTL8922A, ge, 0, 34, 30, 0, CRASH_TRIGGER),
__CFG_FW_FEAT(RTL8922A, ge, 0, 34, 11, 0, MACID_PAUSE_SLEEP),
__CFG_FW_FEAT(RTL8922A, ge, 0, 34, 35, 0, SCAN_OFFLOAD),
__CFG_FW_FEAT(RTL8922A, lt, 0, 35, 21, 0, SCAN_OFFLOAD_BE_V0),
__CFG_FW_FEAT(RTL8922A, ge, 0, 35, 12, 0, BEACON_FILTER),
__CFG_FW_FEAT(RTL8922A, ge, 0, 35, 22, 0, WOW_REASON_V1),
__CFG_FW_FEAT(RTL8922A, lt, 0, 35, 31, 0, RFK_PRE_NOTIFY_V0),
Expand Down Expand Up @@ -4907,6 +4908,7 @@ int rtw89_fw_h2c_scan_offload_be(struct rtw89_dev *rtwdev,
u8 macc_role_size = sizeof(*macc_role) * option->num_macc_role;
u8 opch_size = sizeof(*opch) * option->num_opch;
u8 probe_id[NUM_NL80211_BANDS];
u8 cfg_len = sizeof(*h2c);
unsigned int cond;
void *ptr;
int ret;
Expand All @@ -4915,7 +4917,7 @@ int rtw89_fw_h2c_scan_offload_be(struct rtw89_dev *rtwdev,

rtw89_scan_get_6g_disabled_chan(rtwdev, option);

len = sizeof(*h2c) + macc_role_size + opch_size;
len = cfg_len + macc_role_size + opch_size;
skb = rtw89_fw_h2c_alloc_skb_with_hdr(rtwdev, len);
if (!skb) {
rtw89_err(rtwdev, "failed to alloc skb for h2c scan offload\n");
Expand Down Expand Up @@ -4980,10 +4982,24 @@ int rtw89_fw_h2c_scan_offload_be(struct rtw89_dev *rtwdev,
le32_encode_bits(RTW89_HW_RATE_OFDM6,
RTW89_H2C_SCANOFLD_BE_W8_PROBE_RATE_6GHZ);
}
ptr += sizeof(*h2c);

if (RTW89_CHK_FW_FEATURE(SCAN_OFFLOAD_BE_V0, &rtwdev->fw)) {
cfg_len = offsetofend(typeof(*h2c), w8);
goto flex_member;
}

h2c->w9 = le32_encode_bits(sizeof(*h2c) / sizeof(h2c->w0),
RTW89_H2C_SCANOFLD_BE_W9_SIZE_CFG) |
le32_encode_bits(sizeof(*macc_role) / sizeof(macc_role->w0),
RTW89_H2C_SCANOFLD_BE_W9_SIZE_MACC) |
le32_encode_bits(sizeof(*opch) / sizeof(opch->w0),
RTW89_H2C_SCANOFLD_BE_W9_SIZE_OP);

flex_member:
ptr += cfg_len;

for (i = 0; i < option->num_macc_role; i++) {
macc_role = (struct rtw89_h2c_scanofld_be_macc_role *)&h2c->role[i];
macc_role = ptr;
macc_role->w0 =
le32_encode_bits(0, RTW89_H2C_SCANOFLD_BE_MACC_ROLE_W0_BAND) |
le32_encode_bits(0, RTW89_H2C_SCANOFLD_BE_MACC_ROLE_W0_PORT) |
Expand Down
7 changes: 6 additions & 1 deletion drivers/net/wireless/realtek/rtw89/fw.h
Original file line number Diff line number Diff line change
Expand Up @@ -2711,7 +2711,9 @@ struct rtw89_h2c_scanofld_be {
__le32 w6;
__le32 w7;
__le32 w8;
struct rtw89_h2c_scanofld_be_macc_role role[];
__le32 w9; /* Added after SCAN_OFFLOAD_BE_V1 */
/* struct rtw89_h2c_scanofld_be_macc_role (flexible number) */
/* struct rtw89_h2c_scanofld_be_opch (flexible number) */
} __packed;

#define RTW89_H2C_SCANOFLD_BE_W0_OP GENMASK(1, 0)
Expand Down Expand Up @@ -2742,6 +2744,9 @@ struct rtw89_h2c_scanofld_be {
#define RTW89_H2C_SCANOFLD_BE_W8_PROBE_RATE_2GHZ GENMASK(7, 0)
#define RTW89_H2C_SCANOFLD_BE_W8_PROBE_RATE_5GHZ GENMASK(15, 8)
#define RTW89_H2C_SCANOFLD_BE_W8_PROBE_RATE_6GHZ GENMASK(23, 16)
#define RTW89_H2C_SCANOFLD_BE_W9_SIZE_CFG GENMASK(7, 0)
#define RTW89_H2C_SCANOFLD_BE_W9_SIZE_MACC GENMASK(15, 8)
#define RTW89_H2C_SCANOFLD_BE_W9_SIZE_OP GENMASK(23, 16)

static inline void RTW89_SET_FWCMD_P2P_MACID(void *cmd, u32 val)
{
Expand Down
4 changes: 2 additions & 2 deletions drivers/net/wireless/realtek/rtw89/rtw8922a.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
#include "rtw8922a_rfk.h"
#include "util.h"

#define RTW8922A_FW_FORMAT_MAX 0
#define RTW8922A_FW_FORMAT_MAX 1
#define RTW8922A_FW_BASENAME "rtw89/rtw8922a_fw"
#define RTW8922A_MODULE_FIRMWARE \
RTW8922A_FW_BASENAME ".bin"
RTW8922A_FW_BASENAME "-" __stringify(RTW8922A_FW_FORMAT_MAX) ".bin"

#define HE_N_USER_MAX_8922A 4

Expand Down

0 comments on commit 6ca6b91

Please sign in to comment.