Lines Matching +full:config +full:- +full:cond
1 // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
2 /* Copyright(c) 2019-2020 Realtek Corporation
58 struct rtw89_wait_info *wait, unsigned int cond);
65 u32 h2c_desc_size = rtwdev->chip->h2c_desc_size; in rtw89_fw_h2c_alloc_skb()
74 memset(skb->data, 0, len); in rtw89_fw_h2c_alloc_skb()
91 const struct rtw89_mac_gen_def *mac = rtwdev->chip->mac_def; in rtw89_fw_check_rdy()
95 ret = read_poll_timeout_atomic(mac->fwdl_get_status, val, in rtw89_fw_check_rdy()
102 return -EINVAL; in rtw89_fw_check_rdy()
106 return -EINVAL; in rtw89_fw_check_rdy()
110 return -EINVAL; in rtw89_fw_check_rdy()
114 return -EBUSY; in rtw89_fw_check_rdy()
118 set_bit(RTW89_FLAG_FW_RDY, rtwdev->flags); in rtw89_fw_check_rdy()
137 return -EINVAL; in rtw89_fw_hdr_parser_v0()
139 info->section_num = le32_get_bits(fw_hdr->w6, FW_HDR_W6_SEC_NUM); in rtw89_fw_hdr_parser_v0()
140 base_hdr_len = struct_size(fw_hdr, sections, info->section_num); in rtw89_fw_hdr_parser_v0()
141 info->dynamic_hdr_en = le32_get_bits(fw_hdr->w7, FW_HDR_W7_DYN_HDR); in rtw89_fw_hdr_parser_v0()
143 if (info->dynamic_hdr_en) { in rtw89_fw_hdr_parser_v0()
144 info->hdr_len = le32_get_bits(fw_hdr->w3, FW_HDR_W3_LEN); in rtw89_fw_hdr_parser_v0()
145 info->dynamic_hdr_len = info->hdr_len - base_hdr_len; in rtw89_fw_hdr_parser_v0()
147 if (le32_to_cpu(fwdynhdr->hdr_len) != info->dynamic_hdr_len) { in rtw89_fw_hdr_parser_v0()
149 return -EINVAL; in rtw89_fw_hdr_parser_v0()
152 info->hdr_len = base_hdr_len; in rtw89_fw_hdr_parser_v0()
153 info->dynamic_hdr_len = 0; in rtw89_fw_hdr_parser_v0()
156 bin = fw + info->hdr_len; in rtw89_fw_hdr_parser_v0()
159 section_info = info->section_info; in rtw89_fw_hdr_parser_v0()
160 for (i = 0; i < info->section_num; i++) { in rtw89_fw_hdr_parser_v0()
161 section = &fw_hdr->sections[i]; in rtw89_fw_hdr_parser_v0()
162 section_info->type = in rtw89_fw_hdr_parser_v0()
163 le32_get_bits(section->w1, FWSECTION_HDR_W1_SECTIONTYPE); in rtw89_fw_hdr_parser_v0()
164 if (section_info->type == FWDL_SECURITY_SECTION_TYPE) { in rtw89_fw_hdr_parser_v0()
165 section_info->mssc = in rtw89_fw_hdr_parser_v0()
166 le32_get_bits(section->w2, FWSECTION_HDR_W2_MSSC); in rtw89_fw_hdr_parser_v0()
167 mssc_len += section_info->mssc * FWDL_SECURITY_SIGLEN; in rtw89_fw_hdr_parser_v0()
169 section_info->mssc = 0; in rtw89_fw_hdr_parser_v0()
172 section_info->len = le32_get_bits(section->w1, FWSECTION_HDR_W1_SEC_SIZE); in rtw89_fw_hdr_parser_v0()
173 if (le32_get_bits(section->w1, FWSECTION_HDR_W1_CHECKSUM)) in rtw89_fw_hdr_parser_v0()
174 section_info->len += FWDL_SECTION_CHKSUM_LEN; in rtw89_fw_hdr_parser_v0()
175 section_info->redl = le32_get_bits(section->w1, FWSECTION_HDR_W1_REDL); in rtw89_fw_hdr_parser_v0()
176 section_info->dladdr = in rtw89_fw_hdr_parser_v0()
177 le32_get_bits(section->w0, FWSECTION_HDR_W0_DL_ADDR) & 0x1fffffff; in rtw89_fw_hdr_parser_v0()
178 section_info->addr = bin; in rtw89_fw_hdr_parser_v0()
179 bin += section_info->len; in rtw89_fw_hdr_parser_v0()
185 return -EINVAL; in rtw89_fw_hdr_parser_v0()
195 struct rtw89_fw_secure *sec = &rtwdev->fw.sec; in __get_mssc_key_idx()
201 if (sec->mss_dev_type == RTW89_FW_MSS_DEV_TYPE_FWSEC_DEF) { in __get_mssc_key_idx()
202 if (!mss_hdr->defen) in __get_mssc_key_idx()
203 return -ENOENT; in __get_mssc_key_idx()
205 mss_sel_idx = sec->mss_cust_idx * le16_to_cpu(mss_hdr->msskey_num_max) + in __get_mssc_key_idx()
206 sec->mss_key_num; in __get_mssc_key_idx()
208 if (mss_hdr->defen) in __get_mssc_key_idx()
212 mss_sel_idx += sec->mss_dev_type * le16_to_cpu(mss_hdr->msskey_num_max) * in __get_mssc_key_idx()
213 le16_to_cpu(mss_hdr->msscust_max) + in __get_mssc_key_idx()
214 sec->mss_cust_idx * le16_to_cpu(mss_hdr->msskey_num_max) + in __get_mssc_key_idx()
215 sec->mss_key_num; in __get_mssc_key_idx()
222 return -EFAULT; in __get_mssc_key_idx()
224 if (!(mss_hdr->rmp_tbl[sel_byte_idx] & BIT(sel_bit_idx))) in __get_mssc_key_idx()
225 return -ENOENT; in __get_mssc_key_idx()
227 *key_idx = hweight8(mss_hdr->rmp_tbl[sel_byte_idx] & (BIT(sel_bit_idx) - 1)); in __get_mssc_key_idx()
230 *key_idx += hweight8(mss_hdr->rmp_tbl[i]); in __get_mssc_key_idx()
242 const struct rtw89_fw_mss_pool_hdr *mss_hdr = content + section_info->len; in __parse_formatted_mssc()
244 struct rtw89_fw_secure *sec = &rtwdev->fw.sec; in __parse_formatted_mssc()
251 if (memcmp(mss_signature, mss_hdr->signature, sizeof(mss_signature)) != 0) { in __parse_formatted_mssc()
253 return -ENOENT; in __parse_formatted_mssc()
256 if (mss_hdr->rmpfmt == MSS_POOL_RMP_TBL_BITMASK) { in __parse_formatted_mssc()
257 rmp_tbl_size = (le16_to_cpu(mss_hdr->msskey_num_max) * in __parse_formatted_mssc()
258 le16_to_cpu(mss_hdr->msscust_max) * in __parse_formatted_mssc()
259 mss_hdr->mssdev_max) >> 3; in __parse_formatted_mssc()
260 if (mss_hdr->defen) in __parse_formatted_mssc()
264 mss_hdr->rmpfmt); in __parse_formatted_mssc()
265 return -EINVAL; in __parse_formatted_mssc()
268 if (rmp_tbl_size + sizeof(*mss_hdr) != le32_to_cpu(mss_hdr->key_raw_offset)) { in __parse_formatted_mssc()
271 le32_to_cpu(mss_hdr->key_raw_offset)); in __parse_formatted_mssc()
272 return -EINVAL; in __parse_formatted_mssc()
275 key_sign_len = le16_to_cpu(section_content->key_sign_len.v) >> 2; in __parse_formatted_mssc()
279 if (info->dsp_checksum) in __parse_formatted_mssc()
283 le16_to_cpu(mss_hdr->keypair_num) * key_sign_len; in __parse_formatted_mssc()
285 if (!sec->secure_boot) in __parse_formatted_mssc()
288 sb_sel_ver = le32_to_cpu(section_content->sb_sel_ver.v); in __parse_formatted_mssc()
289 if (sb_sel_ver && sb_sel_ver != sec->sb_sel_mgn) in __parse_formatted_mssc()
296 section_info->key_addr = content + section_info->len + in __parse_formatted_mssc()
297 le32_to_cpu(mss_hdr->key_raw_offset) + in __parse_formatted_mssc()
299 section_info->key_len = key_sign_len; in __parse_formatted_mssc()
300 section_info->key_idx = real_key_idx; in __parse_formatted_mssc()
303 if (info->secure_section_exist) { in __parse_formatted_mssc()
304 section_info->ignore = true; in __parse_formatted_mssc()
308 info->secure_section_exist = true; in __parse_formatted_mssc()
313 section_info->ignore = true; in __parse_formatted_mssc()
327 section_info->mssc = in __parse_security_section()
328 le32_get_bits(section->w2, FWSECTION_HDR_V1_W2_MSSC); in __parse_security_section()
330 if (section_info->mssc == FORMATTED_MSSC) { in __parse_security_section()
334 return -EINVAL; in __parse_security_section()
336 *mssc_len = section_info->mssc * FWDL_SECURITY_SIGLEN; in __parse_security_section()
337 if (info->dsp_checksum) in __parse_security_section()
338 *mssc_len += section_info->mssc * FWDL_SECURITY_CHKSUM_LEN; in __parse_security_section()
340 info->secure_section_exist = true; in __parse_security_section()
360 info->section_num = le32_get_bits(fw_hdr->w6, FW_HDR_V1_W6_SEC_NUM); in rtw89_fw_hdr_parser_v1()
361 info->dsp_checksum = le32_get_bits(fw_hdr->w6, FW_HDR_V1_W6_DSP_CHKSUM); in rtw89_fw_hdr_parser_v1()
362 base_hdr_len = struct_size(fw_hdr, sections, info->section_num); in rtw89_fw_hdr_parser_v1()
363 info->dynamic_hdr_en = le32_get_bits(fw_hdr->w7, FW_HDR_V1_W7_DYN_HDR); in rtw89_fw_hdr_parser_v1()
365 if (info->dynamic_hdr_en) { in rtw89_fw_hdr_parser_v1()
366 info->hdr_len = le32_get_bits(fw_hdr->w5, FW_HDR_V1_W5_HDR_SIZE); in rtw89_fw_hdr_parser_v1()
367 info->dynamic_hdr_len = info->hdr_len - base_hdr_len; in rtw89_fw_hdr_parser_v1()
369 if (le32_to_cpu(fwdynhdr->hdr_len) != info->dynamic_hdr_len) { in rtw89_fw_hdr_parser_v1()
371 return -EINVAL; in rtw89_fw_hdr_parser_v1()
374 info->hdr_len = base_hdr_len; in rtw89_fw_hdr_parser_v1()
375 info->dynamic_hdr_len = 0; in rtw89_fw_hdr_parser_v1()
378 bin = fw + info->hdr_len; in rtw89_fw_hdr_parser_v1()
381 section_info = info->section_info; in rtw89_fw_hdr_parser_v1()
382 for (i = 0; i < info->section_num; i++) { in rtw89_fw_hdr_parser_v1()
383 section = &fw_hdr->sections[i]; in rtw89_fw_hdr_parser_v1()
385 section_info->type = in rtw89_fw_hdr_parser_v1()
386 le32_get_bits(section->w1, FWSECTION_HDR_V1_W1_SECTIONTYPE); in rtw89_fw_hdr_parser_v1()
387 section_info->len = in rtw89_fw_hdr_parser_v1()
388 le32_get_bits(section->w1, FWSECTION_HDR_V1_W1_SEC_SIZE); in rtw89_fw_hdr_parser_v1()
389 if (le32_get_bits(section->w1, FWSECTION_HDR_V1_W1_CHECKSUM)) in rtw89_fw_hdr_parser_v1()
390 section_info->len += FWDL_SECTION_CHKSUM_LEN; in rtw89_fw_hdr_parser_v1()
391 section_info->redl = le32_get_bits(section->w1, FWSECTION_HDR_V1_W1_REDL); in rtw89_fw_hdr_parser_v1()
392 section_info->dladdr = in rtw89_fw_hdr_parser_v1()
393 le32_get_bits(section->w0, FWSECTION_HDR_V1_W0_DL_ADDR); in rtw89_fw_hdr_parser_v1()
394 section_info->addr = bin; in rtw89_fw_hdr_parser_v1()
396 if (section_info->type == FWDL_SECURITY_SECTION_TYPE) { in rtw89_fw_hdr_parser_v1()
402 section_info->mssc = 0; in rtw89_fw_hdr_parser_v1()
407 "section[%d] type=%d len=0x%-6x mssc=%d mssc_len=%d addr=%tx\n", in rtw89_fw_hdr_parser_v1()
408 i, section_info->type, section_info->len, in rtw89_fw_hdr_parser_v1()
409 section_info->mssc, mssc_len, bin - fw); in rtw89_fw_hdr_parser_v1()
412 section_info->ignore, section_info->key_addr, in rtw89_fw_hdr_parser_v1()
413 section_info->key_addr ? in rtw89_fw_hdr_parser_v1()
414 section_info->key_addr - section_info->addr : 0, in rtw89_fw_hdr_parser_v1()
415 section_info->key_len, section_info->key_idx); in rtw89_fw_hdr_parser_v1()
417 bin += section_info->len + mssc_len; in rtw89_fw_hdr_parser_v1()
423 return -EINVAL; in rtw89_fw_hdr_parser_v1()
426 if (!info->secure_section_exist) in rtw89_fw_hdr_parser_v1()
436 const u8 *fw = fw_suit->data; in rtw89_fw_hdr_parser()
437 u32 len = fw_suit->size; in rtw89_fw_hdr_parser()
440 rtw89_err(rtwdev, "fw type %d isn't recognized\n", fw_suit->type); in rtw89_fw_hdr_parser()
441 return -ENOENT; in rtw89_fw_hdr_parser()
444 switch (fw_suit->hdr_ver) { in rtw89_fw_hdr_parser()
450 return -ENOENT; in rtw89_fw_hdr_parser()
458 struct rtw89_fw_info *fw_info = &rtwdev->fw; in rtw89_mfw_recognize()
459 const struct firmware *firmware = fw_info->req.firmware; in rtw89_mfw_recognize()
460 const u8 *mfw = firmware->data; in rtw89_mfw_recognize()
461 u32 mfw_len = firmware->size; in rtw89_mfw_recognize()
466 if (mfw_hdr->sig != RTW89_MFW_SIG) { in rtw89_mfw_recognize()
470 return -EINVAL; in rtw89_mfw_recognize()
471 fw_suit->data = mfw; in rtw89_mfw_recognize()
472 fw_suit->size = mfw_len; in rtw89_mfw_recognize()
476 for (i = 0; i < mfw_hdr->fw_nr; i++) { in rtw89_mfw_recognize()
477 tmp = &mfw_hdr->info[i]; in rtw89_mfw_recognize()
478 if (tmp->type != type) in rtw89_mfw_recognize()
489 if (tmp->cv <= rtwdev->hal.cv && !tmp->mp) { in rtw89_mfw_recognize()
490 if (!mfw_info || mfw_info->cv < tmp->cv) in rtw89_mfw_recognize()
500 return -ENOENT; in rtw89_mfw_recognize()
503 fw_suit->data = mfw + le32_to_cpu(mfw_info->shift); in rtw89_mfw_recognize()
504 fw_suit->size = le32_to_cpu(mfw_info->size); in rtw89_mfw_recognize()
510 struct rtw89_fw_info *fw_info = &rtwdev->fw; in rtw89_mfw_get_size()
511 const struct firmware *firmware = fw_info->req.firmware; in rtw89_mfw_get_size()
513 (const struct rtw89_mfw_hdr *)firmware->data; in rtw89_mfw_get_size()
517 if (mfw_hdr->sig != RTW89_MFW_SIG) { in rtw89_mfw_get_size()
522 mfw_info = &mfw_hdr->info[mfw_hdr->fw_nr - 1]; in rtw89_mfw_get_size()
523 size = le32_to_cpu(mfw_info->shift) + le32_to_cpu(mfw_info->size); in rtw89_mfw_get_size()
532 fw_suit->major_ver = le32_get_bits(hdr->w1, FW_HDR_W1_MAJOR_VERSION); in rtw89_fw_update_ver_v0()
533 fw_suit->minor_ver = le32_get_bits(hdr->w1, FW_HDR_W1_MINOR_VERSION); in rtw89_fw_update_ver_v0()
534 fw_suit->sub_ver = le32_get_bits(hdr->w1, FW_HDR_W1_SUBVERSION); in rtw89_fw_update_ver_v0()
535 fw_suit->sub_idex = le32_get_bits(hdr->w1, FW_HDR_W1_SUBINDEX); in rtw89_fw_update_ver_v0()
536 fw_suit->commitid = le32_get_bits(hdr->w2, FW_HDR_W2_COMMITID); in rtw89_fw_update_ver_v0()
537 fw_suit->build_year = le32_get_bits(hdr->w5, FW_HDR_W5_YEAR); in rtw89_fw_update_ver_v0()
538 fw_suit->build_mon = le32_get_bits(hdr->w4, FW_HDR_W4_MONTH); in rtw89_fw_update_ver_v0()
539 fw_suit->build_date = le32_get_bits(hdr->w4, FW_HDR_W4_DATE); in rtw89_fw_update_ver_v0()
540 fw_suit->build_hour = le32_get_bits(hdr->w4, FW_HDR_W4_HOUR); in rtw89_fw_update_ver_v0()
541 fw_suit->build_min = le32_get_bits(hdr->w4, FW_HDR_W4_MIN); in rtw89_fw_update_ver_v0()
542 fw_suit->cmd_ver = le32_get_bits(hdr->w7, FW_HDR_W7_CMD_VERSERION); in rtw89_fw_update_ver_v0()
549 fw_suit->major_ver = le32_get_bits(hdr->w1, FW_HDR_V1_W1_MAJOR_VERSION); in rtw89_fw_update_ver_v1()
550 fw_suit->minor_ver = le32_get_bits(hdr->w1, FW_HDR_V1_W1_MINOR_VERSION); in rtw89_fw_update_ver_v1()
551 fw_suit->sub_ver = le32_get_bits(hdr->w1, FW_HDR_V1_W1_SUBVERSION); in rtw89_fw_update_ver_v1()
552 fw_suit->sub_idex = le32_get_bits(hdr->w1, FW_HDR_V1_W1_SUBINDEX); in rtw89_fw_update_ver_v1()
553 fw_suit->commitid = le32_get_bits(hdr->w2, FW_HDR_V1_W2_COMMITID); in rtw89_fw_update_ver_v1()
554 fw_suit->build_year = le32_get_bits(hdr->w5, FW_HDR_V1_W5_YEAR); in rtw89_fw_update_ver_v1()
555 fw_suit->build_mon = le32_get_bits(hdr->w4, FW_HDR_V1_W4_MONTH); in rtw89_fw_update_ver_v1()
556 fw_suit->build_date = le32_get_bits(hdr->w4, FW_HDR_V1_W4_DATE); in rtw89_fw_update_ver_v1()
557 fw_suit->build_hour = le32_get_bits(hdr->w4, FW_HDR_V1_W4_HOUR); in rtw89_fw_update_ver_v1()
558 fw_suit->build_min = le32_get_bits(hdr->w4, FW_HDR_V1_W4_MIN); in rtw89_fw_update_ver_v1()
559 fw_suit->cmd_ver = le32_get_bits(hdr->w7, FW_HDR_V1_W3_CMD_VERSERION); in rtw89_fw_update_ver_v1()
566 const struct rtw89_fw_hdr *v0 = (const struct rtw89_fw_hdr *)fw_suit->data; in rtw89_fw_update_ver()
567 const struct rtw89_fw_hdr_v1 *v1 = (const struct rtw89_fw_hdr_v1 *)fw_suit->data; in rtw89_fw_update_ver()
572 fw_suit->type = type; in rtw89_fw_update_ver()
573 fw_suit->hdr_ver = le32_get_bits(v0->w3, FW_HDR_W3_HDR_VER); in rtw89_fw_update_ver()
575 switch (fw_suit->hdr_ver) { in rtw89_fw_update_ver()
584 fw_suit->hdr_ver); in rtw89_fw_update_ver()
585 return -ENOENT; in rtw89_fw_update_ver()
590 fw_suit->major_ver, fw_suit->minor_ver, fw_suit->sub_ver, in rtw89_fw_update_ver()
591 fw_suit->sub_idex, fw_suit->commitid, fw_suit->cmd_ver, type); in rtw89_fw_update_ver()
616 struct rtw89_hal *hal = &rtwdev->hal; in __rtw89_fw_recognize_from_elm()
622 if (hal->cv < elm->u.bbmcu.cv) in __rtw89_fw_recognize_from_elm()
626 if (fw_suit->data) in __rtw89_fw_recognize_from_elm()
629 fw_suit->data = elm->u.bbmcu.contents; in __rtw89_fw_recognize_from_elm()
630 fw_suit->size = le32_to_cpu(elm->size); in __rtw89_fw_recognize_from_elm()
649 bool (*cond)(u32 suit_ver_code, u32 comp_ver_code); member
657 .cond = __fw_feat_cond_ ## _cond, \
701 if (chip->chip_id != ent->chip_id) in rtw89_fw_iterate_feature_cfg()
704 if (ent->cond(ver_code, ent->ver_code)) in rtw89_fw_iterate_feature_cfg()
705 RTW89_SET_FW_FEATURE(ent->feature, fw); in rtw89_fw_iterate_feature_cfg()
711 const struct rtw89_chip_info *chip = rtwdev->chip; in rtw89_fw_recognize_features()
718 rtw89_fw_iterate_feature_cfg(&rtwdev->fw, chip, suit_ver_code); in rtw89_fw_recognize_features()
733 for (fw_format = chip->fw_format_max; fw_format >= 0; fw_format--) { in rtw89_early_fw_feature_recognize()
735 chip->fw_basename, fw_format); in rtw89_early_fw_feature_recognize()
750 ver_code = rtw89_compat_fw_hdr_ver_code(firmware->data); in rtw89_early_fw_feature_recognize()
763 const struct rtw89_chip_info *chip = rtwdev->chip; in rtw89_fw_recognize()
766 if (chip->try_ce_fw) { in rtw89_fw_recognize()
795 struct rtw89_fw_elm_info *elm_info = &rtwdev->fw.elm_info; in rtw89_build_phy_tbl_from_elm()
804 return -ENOMEM; in rtw89_build_phy_tbl_from_elm()
806 switch (le32_to_cpu(elm->id)) { in rtw89_build_phy_tbl_from_elm()
808 elm_info->bb_tbl = tbl; in rtw89_build_phy_tbl_from_elm()
811 elm_info->bb_gain = tbl; in rtw89_build_phy_tbl_from_elm()
818 idx = elm->u.reg2.idx; in rtw89_build_phy_tbl_from_elm()
820 elm_info->rf_radio[idx] = tbl; in rtw89_build_phy_tbl_from_elm()
821 tbl->rf_path = rf_path; in rtw89_build_phy_tbl_from_elm()
822 tbl->config = rtw89_phy_config_rf_reg_v1; in rtw89_build_phy_tbl_from_elm()
825 elm_info->rf_nctl = tbl; in rtw89_build_phy_tbl_from_elm()
829 return -ENOENT; in rtw89_build_phy_tbl_from_elm()
832 n_regs = le32_to_cpu(elm->size) / sizeof(tbl->regs[0]); in rtw89_build_phy_tbl_from_elm()
833 regs = kcalloc(n_regs, sizeof(tbl->regs[0]), GFP_KERNEL); in rtw89_build_phy_tbl_from_elm()
838 regs[i].addr = le32_to_cpu(elm->u.reg2.regs[i].addr); in rtw89_build_phy_tbl_from_elm()
839 regs[i].data = le32_to_cpu(elm->u.reg2.regs[i].data); in rtw89_build_phy_tbl_from_elm()
842 tbl->n_regs = n_regs; in rtw89_build_phy_tbl_from_elm()
843 tbl->regs = regs; in rtw89_build_phy_tbl_from_elm()
849 return -ENOMEM; in rtw89_build_phy_tbl_from_elm()
857 const struct __rtw89_fw_txpwr_element *txpwr_elm = &elm->u.txpwr; in rtw89_fw_recognize_txpwr_from_elm()
859 struct rtw89_efuse *efuse = &rtwdev->efuse; in rtw89_fw_recognize_txpwr_from_elm()
862 if (!rtwdev->rfe_data) { in rtw89_fw_recognize_txpwr_from_elm()
863 rtwdev->rfe_data = kzalloc(sizeof(*rtwdev->rfe_data), GFP_KERNEL); in rtw89_fw_recognize_txpwr_from_elm()
864 if (!rtwdev->rfe_data) in rtw89_fw_recognize_txpwr_from_elm()
865 return -ENOMEM; in rtw89_fw_recognize_txpwr_from_elm()
868 conf = (void *)rtwdev->rfe_data + offset; in rtw89_fw_recognize_txpwr_from_elm()
871 if (txpwr_elm->rfe_type == efuse->rfe_type) in rtw89_fw_recognize_txpwr_from_elm()
875 if (txpwr_elm->rfe_type == RTW89_TXPWR_CONF_DFLT_RFE_TYPE && in rtw89_fw_recognize_txpwr_from_elm()
877 conf->rfe_type == RTW89_TXPWR_CONF_DFLT_RFE_TYPE)) in rtw89_fw_recognize_txpwr_from_elm()
881 elm->id, txpwr_elm->rfe_type); in rtw89_fw_recognize_txpwr_from_elm()
886 elm->id, txpwr_elm->rfe_type); in rtw89_fw_recognize_txpwr_from_elm()
888 conf->rfe_type = txpwr_elm->rfe_type; in rtw89_fw_recognize_txpwr_from_elm()
889 conf->ent_sz = txpwr_elm->ent_sz; in rtw89_fw_recognize_txpwr_from_elm()
890 conf->num_ents = le32_to_cpu(txpwr_elm->num_ents); in rtw89_fw_recognize_txpwr_from_elm()
891 conf->data = txpwr_elm->content; in rtw89_fw_recognize_txpwr_from_elm()
900 struct rtw89_fw_elm_info *elm_info = &rtwdev->fw.elm_info; in rtw89_build_txpwr_trk_tbl_from_elm()
901 const struct rtw89_chip_info *chip = rtwdev->chip; in rtw89_build_txpwr_trk_tbl_from_elm()
908 if (chip->support_bands & BIT(NL80211_BAND_6GHZ)) in rtw89_build_txpwr_trk_tbl_from_elm()
910 if (chip->support_bands & BIT(NL80211_BAND_5GHZ)) in rtw89_build_txpwr_trk_tbl_from_elm()
912 if (chip->support_bands & BIT(NL80211_BAND_2GHZ)) in rtw89_build_txpwr_trk_tbl_from_elm()
915 bitmap = le32_to_cpu(elm->u.txpwr_trk.bitmap); in rtw89_build_txpwr_trk_tbl_from_elm()
920 return -ENOENT; in rtw89_build_txpwr_trk_tbl_from_elm()
923 elm_info->txpwr_trk = kzalloc(sizeof(*elm_info->txpwr_trk), GFP_KERNEL); in rtw89_build_txpwr_trk_tbl_from_elm()
924 if (!elm_info->txpwr_trk) in rtw89_build_txpwr_trk_tbl_from_elm()
925 return -ENOMEM; in rtw89_build_txpwr_trk_tbl_from_elm()
943 elm_info->txpwr_trk->delta[type] = &elm->u.txpwr_trk.contents[offset]; in rtw89_build_txpwr_trk_tbl_from_elm()
946 if (offset * DELTA_SWINGIDX_SIZE > le32_to_cpu(elm->size)) in rtw89_build_txpwr_trk_tbl_from_elm()
954 offset, le32_to_cpu(elm->size)); in rtw89_build_txpwr_trk_tbl_from_elm()
955 kfree(elm_info->txpwr_trk); in rtw89_build_txpwr_trk_tbl_from_elm()
956 elm_info->txpwr_trk = NULL; in rtw89_build_txpwr_trk_tbl_from_elm()
958 return -EFAULT; in rtw89_build_txpwr_trk_tbl_from_elm()
966 struct rtw89_fw_elm_info *elm_info = &rtwdev->fw.elm_info; in rtw89_build_rfk_log_fmt_from_elm()
969 if (elm_info->rfk_log_fmt) in rtw89_build_rfk_log_fmt_from_elm()
972 elm_info->rfk_log_fmt = kzalloc(sizeof(*elm_info->rfk_log_fmt), GFP_KERNEL); in rtw89_build_rfk_log_fmt_from_elm()
973 if (!elm_info->rfk_log_fmt) in rtw89_build_rfk_log_fmt_from_elm()
977 rfk_id = elm->u.rfk_log_fmt.rfk_id; in rtw89_build_rfk_log_fmt_from_elm()
981 elm_info->rfk_log_fmt->elm[rfk_id] = elm; in rtw89_build_rfk_log_fmt_from_elm()
1048 struct rtw89_fw_info *fw_info = &rtwdev->fw; in rtw89_fw_recognize_elements()
1049 const struct firmware *firmware = fw_info->req.firmware; in rtw89_fw_recognize_elements()
1050 const struct rtw89_chip_info *chip = rtwdev->chip; in rtw89_fw_recognize_elements()
1051 u32 unrecognized_elements = chip->needed_fw_elms; in rtw89_fw_recognize_elements()
1059 BUILD_BUG_ON(sizeof(chip->needed_fw_elms) * 8 < RTW89_FW_ELEMENT_ID_NUM); in rtw89_fw_recognize_elements()
1064 return -EINVAL; in rtw89_fw_recognize_elements()
1066 while (offset + sizeof(*hdr) < firmware->size) { in rtw89_fw_recognize_elements()
1067 hdr = (const struct rtw89_fw_element_hdr *)(firmware->data + offset); in rtw89_fw_recognize_elements()
1069 elm_size = le32_to_cpu(hdr->size); in rtw89_fw_recognize_elements()
1070 if (offset + elm_size >= firmware->size) { in rtw89_fw_recognize_elements()
1075 elem_id = le32_to_cpu(hdr->id); in rtw89_fw_recognize_elements()
1080 if (!handler->fn) in rtw89_fw_recognize_elements()
1083 ret = handler->fn(rtwdev, hdr, handler->arg); in rtw89_fw_recognize_elements()
1089 if (handler->name) in rtw89_fw_recognize_elements()
1091 handler->name, hdr->ver); in rtw89_fw_recognize_elements()
1102 return -ENOENT; in rtw89_fw_recognize_elements()
1116 if (!(rtwdev->fw.h2c_seq % 4)) in rtw89_h2c_pkt_set_hdr()
1118 hdr->hdr0 = cpu_to_le32(FIELD_PREP(H2C_HDR_DEL_TYPE, type) | in rtw89_h2c_pkt_set_hdr()
1122 FIELD_PREP(H2C_HDR_H2C_SEQ, rtwdev->fw.h2c_seq)); in rtw89_h2c_pkt_set_hdr()
1124 hdr->hdr1 = cpu_to_le32(FIELD_PREP(H2C_HDR_TOTAL_LEN, in rtw89_h2c_pkt_set_hdr()
1129 rtwdev->fw.h2c_seq++; in rtw89_h2c_pkt_set_hdr()
1141 hdr->hdr0 = cpu_to_le32(FIELD_PREP(H2C_HDR_DEL_TYPE, type) | in rtw89_h2c_pkt_set_hdr_fwdl()
1145 FIELD_PREP(H2C_HDR_H2C_SEQ, rtwdev->fw.h2c_seq)); in rtw89_h2c_pkt_set_hdr_fwdl()
1147 hdr->hdr1 = cpu_to_le32(FIELD_PREP(H2C_HDR_TOTAL_LEN, in rtw89_h2c_pkt_set_hdr_fwdl()
1155 le32p_replace_bits(&fw_hdr->w7, FWDL_SECTION_PER_PKT_LEN, in __rtw89_fw_download_tweak_hdr_v0()
1170 le32p_replace_bits(&fw_hdr->w7, FWDL_SECTION_PER_PKT_LEN, in __rtw89_fw_download_tweak_hdr_v1()
1173 for (sec_idx = 0; sec_idx < info->section_num; sec_idx++) { in __rtw89_fw_download_tweak_hdr_v1()
1174 section_info = &info->section_info[sec_idx]; in __rtw89_fw_download_tweak_hdr_v1()
1175 section = &fw_hdr->sections[sec_idx]; in __rtw89_fw_download_tweak_hdr_v1()
1177 if (section_info->ignore) in __rtw89_fw_download_tweak_hdr_v1()
1181 fw_hdr->sections[dst_sec_idx] = *section; in __rtw89_fw_download_tweak_hdr_v1()
1186 le32p_replace_bits(&fw_hdr->w6, dst_sec_idx, FW_HDR_V1_W6_SEC_NUM); in __rtw89_fw_download_tweak_hdr_v1()
1188 return (info->section_num - dst_sec_idx) * sizeof(*section); in __rtw89_fw_download_tweak_hdr_v1()
1195 u32 len = info->hdr_len - info->dynamic_hdr_len; in __rtw89_fw_download_hdr()
1197 const u8 *fw = fw_suit->data; in __rtw89_fw_download_hdr()
1206 return -ENOMEM; in __rtw89_fw_download_hdr()
1211 switch (fw_suit->hdr_ver) { in __rtw89_fw_download_hdr()
1213 fw_hdr = (struct rtw89_fw_hdr *)skb->data; in __rtw89_fw_download_hdr()
1217 fw_hdr_v1 = (struct rtw89_fw_hdr_v1 *)skb->data; in __rtw89_fw_download_hdr()
1221 ret = -EOPNOTSUPP; in __rtw89_fw_download_hdr()
1226 len -= truncated; in __rtw89_fw_download_hdr()
1237 ret = -1; in __rtw89_fw_download_hdr()
1252 const struct rtw89_mac_gen_def *mac = rtwdev->chip->mac_def; in rtw89_fw_download_hdr()
1261 ret = mac->fwdl_check_path_ready(rtwdev, false); in rtw89_fw_download_hdr()
1277 const u8 *section = info->addr; in __rtw89_fw_download_main()
1278 u32 residue_len = info->len; in __rtw89_fw_download_main()
1283 if (info->ignore) in __rtw89_fw_download_main()
1286 if (info->key_addr && info->key_len) { in __rtw89_fw_download_main()
1287 if (info->len > FWDL_SECTION_PER_PKT_LEN || info->len < info->key_len) in __rtw89_fw_download_main()
1289 info->len, FWDL_SECTION_PER_PKT_LEN, info->key_len); in __rtw89_fw_download_main()
1303 return -ENOMEM; in __rtw89_fw_download_main()
1308 memcpy(skb->data + pkt_len - info->key_len, in __rtw89_fw_download_main()
1309 info->key_addr, info->key_len); in __rtw89_fw_download_main()
1314 ret = -1; in __rtw89_fw_download_main()
1319 residue_len -= pkt_len; in __rtw89_fw_download_main()
1333 switch (fw_suit->type) { in rtw89_fw_get_fwdl_chk_type_from_suit()
1347 struct rtw89_fw_hdr_section_info *section_info = info->section_info; in rtw89_fw_download_main()
1348 const struct rtw89_chip_info *chip = rtwdev->chip; in rtw89_fw_download_main()
1350 u8 section_num = info->section_num; in rtw89_fw_download_main()
1353 while (section_num--) { in rtw89_fw_download_main()
1360 if (chip->chip_gen == RTW89_CHIP_AX) in rtw89_fw_download_main()
1367 fw_suit->type); in rtw89_fw_download_main()
1376 enum rtw89_chip_gen chip_gen = rtwdev->chip->chip_gen; in rtw89_fw_prog_cnt_dump()
1415 const struct rtw89_mac_gen_def *mac = rtwdev->chip->mac_def; in rtw89_fw_download_suit()
1425 if (rtwdev->chip->chip_id == RTL8922A && in rtw89_fw_download_suit()
1426 (fw_suit->type == RTW89_FW_NORMAL || fw_suit->type == RTW89_FW_WOWLAN)) in rtw89_fw_download_suit()
1429 ret = mac->fwdl_check_path_ready(rtwdev, true); in rtw89_fw_download_suit()
1450 const struct rtw89_mac_gen_def *mac = rtwdev->chip->mac_def; in __rtw89_fw_download()
1451 struct rtw89_fw_info *fw_info = &rtwdev->fw; in __rtw89_fw_download()
1453 u8 bbmcu_nr = rtwdev->chip->bbmcu_nr; in __rtw89_fw_download()
1457 mac->disable_cpu(rtwdev); in __rtw89_fw_download()
1458 ret = mac->fwdl_enable_wcpu(rtwdev, 0, true, include_bb); in __rtw89_fw_download()
1474 fw_info->h2c_seq = 0; in __rtw89_fw_download()
1475 fw_info->rec_seq = 0; in __rtw89_fw_download()
1476 fw_info->h2c_counter = 0; in __rtw89_fw_download()
1477 fw_info->c2h_counter = 0; in __rtw89_fw_download()
1478 rtwdev->mac.rpwm_seq_num = RPWM_SEQ_NUM_MAX; in __rtw89_fw_download()
1479 rtwdev->mac.cpwm_seq_num = CPWM_SEQ_NUM_MAX; in __rtw89_fw_download()
1513 struct rtw89_fw_info *fw = &rtwdev->fw; in rtw89_wait_firmware_completion()
1515 wait_for_completion(&fw->req.completion); in rtw89_wait_firmware_completion()
1516 if (!fw->req.firmware) in rtw89_wait_firmware_completion()
1517 return -EINVAL; in rtw89_wait_firmware_completion()
1528 if (req->firmware) { in rtw89_load_firmware_req()
1531 complete_all(&req->completion); in rtw89_load_firmware_req()
1536 ret = firmware_request_nowarn(&req->firmware, fw_name, rtwdev->dev); in rtw89_load_firmware_req()
1538 ret = request_firmware(&req->firmware, fw_name, rtwdev->dev); in rtw89_load_firmware_req()
1540 complete_all(&req->completion); in rtw89_load_firmware_req()
1549 const struct rtw89_chip_info *chip = rtwdev->chip; in rtw89_load_firmware_work()
1553 chip->fw_basename, rtwdev->fw.fw_format); in rtw89_load_firmware_work()
1555 rtw89_load_firmware_req(rtwdev, &rtwdev->fw.req, fw_name, false); in rtw89_load_firmware_work()
1563 kfree(tbl->regs); in rtw89_free_phy_tbl_from_elm()
1569 struct rtw89_fw_elm_info *elm_info = &rtwdev->fw.elm_info; in rtw89_unload_firmware_elements()
1572 rtw89_free_phy_tbl_from_elm(elm_info->bb_tbl); in rtw89_unload_firmware_elements()
1573 rtw89_free_phy_tbl_from_elm(elm_info->bb_gain); in rtw89_unload_firmware_elements()
1574 for (i = 0; i < ARRAY_SIZE(elm_info->rf_radio); i++) in rtw89_unload_firmware_elements()
1575 rtw89_free_phy_tbl_from_elm(elm_info->rf_radio[i]); in rtw89_unload_firmware_elements()
1576 rtw89_free_phy_tbl_from_elm(elm_info->rf_nctl); in rtw89_unload_firmware_elements()
1578 kfree(elm_info->txpwr_trk); in rtw89_unload_firmware_elements()
1579 kfree(elm_info->rfk_log_fmt); in rtw89_unload_firmware_elements()
1584 struct rtw89_fw_info *fw = &rtwdev->fw; in rtw89_unload_firmware()
1586 cancel_work_sync(&rtwdev->load_firmware_work); in rtw89_unload_firmware()
1588 if (fw->req.firmware) { in rtw89_unload_firmware()
1589 release_firmware(fw->req.firmware); in rtw89_unload_firmware()
1594 fw->req.firmware = NULL; in rtw89_unload_firmware()
1597 kfree(fw->log.fmts); in rtw89_unload_firmware()
1603 struct rtw89_fw_log *fw_log = &rtwdev->fw.log; in rtw89_fw_log_get_fmt_idx()
1606 if (fmt_id > fw_log->last_fmt_id) in rtw89_fw_log_get_fmt_idx()
1609 for (i = 0; i < fw_log->fmt_count; i++) { in rtw89_fw_log_get_fmt_idx()
1610 if (le32_to_cpu(fw_log->fmt_ids[i]) == fmt_id) in rtw89_fw_log_get_fmt_idx()
1618 struct rtw89_fw_log *log = &rtwdev->fw.log; in rtw89_fw_log_create_fmts_dict()
1620 struct rtw89_fw_suit *suit = &log->suit; in rtw89_fw_log_create_fmts_dict()
1625 suit_hdr = (const struct rtw89_fw_logsuit_hdr *)suit->data; in rtw89_fw_log_create_fmts_dict()
1626 fmt_count = le32_to_cpu(suit_hdr->count); in rtw89_fw_log_create_fmts_dict()
1627 log->fmt_ids = suit_hdr->ids; in rtw89_fw_log_create_fmts_dict()
1628 fmts_ptr = &suit_hdr->ids[fmt_count]; in rtw89_fw_log_create_fmts_dict()
1629 fmts_end_ptr = suit->data + suit->size; in rtw89_fw_log_create_fmts_dict()
1630 log->fmts = kcalloc(fmt_count, sizeof(char *), GFP_KERNEL); in rtw89_fw_log_create_fmts_dict()
1631 if (!log->fmts) in rtw89_fw_log_create_fmts_dict()
1632 return -ENOMEM; in rtw89_fw_log_create_fmts_dict()
1635 fmts_ptr = memchr_inv(fmts_ptr, 0, fmts_end_ptr - fmts_ptr); in rtw89_fw_log_create_fmts_dict()
1639 (*log->fmts)[i] = fmts_ptr; in rtw89_fw_log_create_fmts_dict()
1640 log->last_fmt_id = le32_to_cpu(log->fmt_ids[i]); in rtw89_fw_log_create_fmts_dict()
1641 log->fmt_count++; in rtw89_fw_log_create_fmts_dict()
1650 struct rtw89_fw_log *log = &rtwdev->fw.log; in rtw89_fw_log_prepare()
1651 struct rtw89_fw_suit *suit = &log->suit; in rtw89_fw_log_prepare()
1653 if (!suit || !suit->data) { in rtw89_fw_log_prepare()
1655 return -EINVAL; in rtw89_fw_log_prepare()
1657 if (log->fmts) in rtw89_fw_log_prepare()
1667 const char *(*fmts)[] = rtwdev->fw.log.fmts; in rtw89_fw_log_dump_data()
1672 if (log_fmt->argc > RTW89_C2H_FW_LOG_MAX_PARA_NUM) { in rtw89_fw_log_dump_data()
1674 log_fmt->argc); in rtw89_fw_log_dump_data()
1679 for (i = 0 ; i < log_fmt->argc; i++) in rtw89_fw_log_dump_data()
1680 args[i] = le32_to_cpu(log_fmt->u.argv[i]); in rtw89_fw_log_dump_data()
1685 "fw_enc(%d, %d, %d) %*ph", le32_to_cpu(log_fmt->fmt_id), in rtw89_fw_log_dump_data()
1686 para_int, log_fmt->argc, (int)sizeof(args), args); in rtw89_fw_log_dump_data()
1689 "fw_enc(%d, %d, %d, %s)", le32_to_cpu(log_fmt->fmt_id), in rtw89_fw_log_dump_data()
1690 para_int, log_fmt->argc, log_fmt->u.raw); in rtw89_fw_log_dump_data()
1714 len -= RTW89_C2H_HEADER_LEN; in rtw89_fw_log_dump()
1720 if (log_fmt->signature != cpu_to_le16(RTW89_C2H_FW_LOG_SIGNATURE)) in rtw89_fw_log_dump()
1723 if (!rtwdev->fw.log.fmts) in rtw89_fw_log_dump()
1726 para_int = u8_get_bits(log_fmt->feature, RTW89_C2H_FW_LOG_FEATURE_PARA_INT); in rtw89_fw_log_dump()
1727 fmt_idx = rtw89_fw_log_get_fmt_idx(rtwdev, le32_to_cpu(log_fmt->fmt_id)); in rtw89_fw_log_dump()
1729 if (!para_int && log_fmt->argc != 0 && fmt_idx != 0) in rtw89_fw_log_dump()
1731 (*rtwdev->fw.log.fmts)[fmt_idx], log_fmt->u.raw); in rtw89_fw_log_dump()
1753 return -ENOMEM; in rtw89_fw_h2c_cam()
1756 rtw89_cam_fill_addr_cam_info(rtwdev, rtwvif, rtwsta, scan_mac_addr, skb->data); in rtw89_fw_h2c_cam()
1757 rtw89_cam_fill_bssid_cam_info(rtwdev, rtwvif, rtwsta, skb->data); in rtw89_fw_h2c_cam()
1790 return -ENOMEM; in rtw89_fw_h2c_dctl_sec_cam_v1()
1793 h2c = (struct rtw89_h2c_dctlinfo_ud_v1 *)skb->data; in rtw89_fw_h2c_dctl_sec_cam_v1()
1829 return -ENOMEM; in rtw89_fw_h2c_dctl_sec_cam_v2()
1832 h2c = (struct rtw89_h2c_dctlinfo_ud_v2 *)skb->data; in rtw89_fw_h2c_dctl_sec_cam_v2()
1860 u8 mac_id = rtwsta ? rtwsta->mac_id : rtwvif->mac_id; in rtw89_fw_h2c_default_dmac_tbl_v2()
1869 return -ENOMEM; in rtw89_fw_h2c_default_dmac_tbl_v2()
1872 h2c = (struct rtw89_h2c_dctlinfo_ud_v2 *)skb->data; in rtw89_fw_h2c_default_dmac_tbl_v2()
1874 h2c->c0 = le32_encode_bits(mac_id, DCTLINFO_V2_C0_MACID) | in rtw89_fw_h2c_default_dmac_tbl_v2()
1877 h2c->m0 = cpu_to_le32(DCTLINFO_V2_W0_ALL); in rtw89_fw_h2c_default_dmac_tbl_v2()
1878 h2c->m1 = cpu_to_le32(DCTLINFO_V2_W1_ALL); in rtw89_fw_h2c_default_dmac_tbl_v2()
1879 h2c->m2 = cpu_to_le32(DCTLINFO_V2_W2_ALL); in rtw89_fw_h2c_default_dmac_tbl_v2()
1880 h2c->m3 = cpu_to_le32(DCTLINFO_V2_W3_ALL); in rtw89_fw_h2c_default_dmac_tbl_v2()
1881 h2c->m4 = cpu_to_le32(DCTLINFO_V2_W4_ALL); in rtw89_fw_h2c_default_dmac_tbl_v2()
1882 h2c->m5 = cpu_to_le32(DCTLINFO_V2_W5_ALL); in rtw89_fw_h2c_default_dmac_tbl_v2()
1883 h2c->m6 = cpu_to_le32(DCTLINFO_V2_W6_ALL); in rtw89_fw_h2c_default_dmac_tbl_v2()
1884 h2c->m7 = cpu_to_le32(DCTLINFO_V2_W7_ALL); in rtw89_fw_h2c_default_dmac_tbl_v2()
1885 h2c->m8 = cpu_to_le32(DCTLINFO_V2_W8_ALL); in rtw89_fw_h2c_default_dmac_tbl_v2()
1886 h2c->m9 = cpu_to_le32(DCTLINFO_V2_W9_ALL); in rtw89_fw_h2c_default_dmac_tbl_v2()
1887 h2c->m10 = cpu_to_le32(DCTLINFO_V2_W10_ALL); in rtw89_fw_h2c_default_dmac_tbl_v2()
1888 h2c->m11 = cpu_to_le32(DCTLINFO_V2_W11_ALL); in rtw89_fw_h2c_default_dmac_tbl_v2()
1889 h2c->m12 = cpu_to_le32(DCTLINFO_V2_W12_ALL); in rtw89_fw_h2c_default_dmac_tbl_v2()
1914 const struct rtw89_chip_info *chip = rtwdev->chip; in rtw89_fw_h2c_ba_cam()
1915 struct rtw89_vif *rtwvif = rtwsta->rtwvif; in rtw89_fw_h2c_ba_cam()
1917 u8 macid = rtwsta->mac_id; in rtw89_fw_h2c_ba_cam()
1924 rtw89_core_acquire_sta_ba_entry(rtwdev, rtwsta, params->tid, &entry_idx) : in rtw89_fw_h2c_ba_cam()
1925 rtw89_core_release_sta_ba_entry(rtwdev, rtwsta, params->tid, &entry_idx); in rtw89_fw_h2c_ba_cam()
1932 valid ? "alloc" : "free", params->tid); in rtw89_fw_h2c_ba_cam()
1939 return -ENOMEM; in rtw89_fw_h2c_ba_cam()
1942 h2c = (struct rtw89_h2c_ba_cam *)skb->data; in rtw89_fw_h2c_ba_cam()
1944 h2c->w0 = le32_encode_bits(macid, RTW89_H2C_BA_CAM_W0_MACID); in rtw89_fw_h2c_ba_cam()
1945 if (chip->bacam_ver == RTW89_BACAM_V0_EXT) in rtw89_fw_h2c_ba_cam()
1946 h2c->w1 |= le32_encode_bits(entry_idx, RTW89_H2C_BA_CAM_W1_ENTRY_IDX_V1); in rtw89_fw_h2c_ba_cam()
1948 h2c->w0 |= le32_encode_bits(entry_idx, RTW89_H2C_BA_CAM_W0_ENTRY_IDX); in rtw89_fw_h2c_ba_cam()
1951 h2c->w0 |= le32_encode_bits(valid, RTW89_H2C_BA_CAM_W0_VALID) | in rtw89_fw_h2c_ba_cam()
1952 le32_encode_bits(params->tid, RTW89_H2C_BA_CAM_W0_TID); in rtw89_fw_h2c_ba_cam()
1953 if (params->buf_size > 64) in rtw89_fw_h2c_ba_cam()
1954 h2c->w0 |= le32_encode_bits(4, RTW89_H2C_BA_CAM_W0_BMAP_SIZE); in rtw89_fw_h2c_ba_cam()
1956 h2c->w0 |= le32_encode_bits(0, RTW89_H2C_BA_CAM_W0_BMAP_SIZE); in rtw89_fw_h2c_ba_cam()
1958 h2c->w0 |= le32_encode_bits(1, RTW89_H2C_BA_CAM_W0_INIT_REQ) | in rtw89_fw_h2c_ba_cam()
1959 le32_encode_bits(params->ssn, RTW89_H2C_BA_CAM_W0_SSN); in rtw89_fw_h2c_ba_cam()
1961 if (chip->bacam_ver == RTW89_BACAM_V0_EXT) { in rtw89_fw_h2c_ba_cam()
1962 h2c->w1 |= le32_encode_bits(1, RTW89_H2C_BA_CAM_W1_STD_EN) | in rtw89_fw_h2c_ba_cam()
1963 le32_encode_bits(rtwvif->mac_idx, RTW89_H2C_BA_CAM_W1_BAND); in rtw89_fw_h2c_ba_cam()
1998 return -ENOMEM; in rtw89_fw_h2c_init_ba_cam_v0_ext()
2001 h2c = (struct rtw89_h2c_ba_cam *)skb->data; in rtw89_fw_h2c_init_ba_cam_v0_ext()
2003 h2c->w0 = le32_encode_bits(1, RTW89_H2C_BA_CAM_W0_VALID); in rtw89_fw_h2c_init_ba_cam_v0_ext()
2004 h2c->w1 = le32_encode_bits(entry_idx, RTW89_H2C_BA_CAM_W1_ENTRY_IDX_V1) | in rtw89_fw_h2c_init_ba_cam_v0_ext()
2030 const struct rtw89_chip_info *chip = rtwdev->chip; in rtw89_fw_h2c_init_dynamic_ba_cam_v0_ext()
2031 u8 entry_idx = chip->bacam_num; in rtw89_fw_h2c_init_dynamic_ba_cam_v0_ext()
2035 for (i = 0; i < chip->bacam_dynamic_num; i++) { in rtw89_fw_h2c_init_dynamic_ba_cam_v0_ext()
2045 const struct rtw89_chip_info *chip = rtwdev->chip; in rtw89_fw_h2c_ba_cam_v1()
2046 struct rtw89_vif *rtwvif = rtwsta->rtwvif; in rtw89_fw_h2c_ba_cam_v1()
2048 u8 macid = rtwsta->mac_id; in rtw89_fw_h2c_ba_cam_v1()
2056 rtw89_core_acquire_sta_ba_entry(rtwdev, rtwsta, params->tid, &entry_idx) : in rtw89_fw_h2c_ba_cam_v1()
2057 rtw89_core_release_sta_ba_entry(rtwdev, rtwsta, params->tid, &entry_idx); in rtw89_fw_h2c_ba_cam_v1()
2064 valid ? "alloc" : "free", params->tid); in rtw89_fw_h2c_ba_cam_v1()
2071 return -ENOMEM; in rtw89_fw_h2c_ba_cam_v1()
2074 h2c = (struct rtw89_h2c_ba_cam_v1 *)skb->data; in rtw89_fw_h2c_ba_cam_v1()
2076 if (params->buf_size > 512) in rtw89_fw_h2c_ba_cam_v1()
2078 else if (params->buf_size > 256) in rtw89_fw_h2c_ba_cam_v1()
2080 else if (params->buf_size > 64) in rtw89_fw_h2c_ba_cam_v1()
2085 h2c->w0 = le32_encode_bits(valid, RTW89_H2C_BA_CAM_V1_W0_VALID) | in rtw89_fw_h2c_ba_cam_v1()
2088 le32_encode_bits(params->tid, RTW89_H2C_BA_CAM_V1_W0_TID_MASK) | in rtw89_fw_h2c_ba_cam_v1()
2090 le32_encode_bits(params->ssn, RTW89_H2C_BA_CAM_V1_W0_SSN_MASK); in rtw89_fw_h2c_ba_cam_v1()
2092 entry_idx += chip->bacam_dynamic_num; /* std entry right after dynamic ones */ in rtw89_fw_h2c_ba_cam_v1()
2093 h2c->w1 = le32_encode_bits(entry_idx, RTW89_H2C_BA_CAM_V1_W1_ENTRY_IDX_MASK) | in rtw89_fw_h2c_ba_cam_v1()
2095 le32_encode_bits(!!rtwvif->mac_idx, RTW89_H2C_BA_CAM_V1_W1_BAND_SEL); in rtw89_fw_h2c_ba_cam_v1()
2128 return -ENOMEM; in rtw89_fw_h2c_init_ba_cam_users()
2131 h2c = (struct rtw89_h2c_ba_cam_init *)skb->data; in rtw89_fw_h2c_init_ba_cam_users()
2133 h2c->w0 = le32_encode_bits(users, RTW89_H2C_BA_CAM_INIT_USERS_MASK) | in rtw89_fw_h2c_init_ba_cam_users()
2171 return -ENOMEM; in rtw89_fw_h2c_fw_log()
2175 SET_LOG_CFG_LEVEL(skb->data, RTW89_FW_LOG_LEVEL_LOUD); in rtw89_fw_h2c_fw_log()
2176 SET_LOG_CFG_PATH(skb->data, BIT(RTW89_FW_LOG_LEVEL_C2H)); in rtw89_fw_h2c_fw_log()
2177 SET_LOG_CFG_COMP(skb->data, comp); in rtw89_fw_h2c_fw_log()
2178 SET_LOG_CFG_COMP_EXT(skb->data, 0); in rtw89_fw_h2c_fw_log()
2205 struct ieee80211_bss_conf *bss_conf = &vif->bss_conf; in rtw89_eapol_get()
2207 struct rtw89_wow_param *rtw_wow = &rtwdev->wow; in rtw89_eapol_get()
2213 if (rtw_wow->ptk_alg == 3) in rtw89_eapol_get()
2215 else if (rtw_wow->akm == 1 || rtw_wow->akm == 2) in rtw89_eapol_get()
2217 else if (rtw_wow->akm > 2 && rtw_wow->akm < 7) in rtw89_eapol_get()
2227 hdr->frame_control = cpu_to_le16(IEEE80211_FTYPE_DATA | in rtw89_eapol_get()
2230 ether_addr_copy(hdr->addr1, bss_conf->bssid); in rtw89_eapol_get()
2231 ether_addr_copy(hdr->addr2, vif->addr); in rtw89_eapol_get()
2232 ether_addr_copy(hdr->addr3, bss_conf->bssid); in rtw89_eapol_get()
2237 memcpy(eapol_pkt->gtkbody, gtkbody, sizeof(gtkbody)); in rtw89_eapol_get()
2238 eapol_pkt->key_des_ver = key_des_ver; in rtw89_eapol_get()
2247 struct ieee80211_bss_conf *bss_conf = &vif->bss_conf; in rtw89_sa_query_get()
2258 hdr->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | in rtw89_sa_query_get()
2261 ether_addr_copy(hdr->addr1, bss_conf->bssid); in rtw89_sa_query_get()
2262 ether_addr_copy(hdr->addr2, vif->addr); in rtw89_sa_query_get()
2263 ether_addr_copy(hdr->addr3, bss_conf->bssid); in rtw89_sa_query_get()
2268 sa_query->category = WLAN_CATEGORY_SA_QUERY; in rtw89_sa_query_get()
2269 sa_query->action = WLAN_ACTION_SA_QUERY_RESPONSE; in rtw89_sa_query_get()
2278 struct rtw89_wow_param *rtw_wow = &rtwdev->wow; in rtw89_arp_response_get()
2291 if (rtw_wow->ptk_alg) in rtw89_arp_response_get()
2297 hdr->frame_control = fc; in rtw89_arp_response_get()
2298 ether_addr_copy(hdr->addr1, rtwvif->bssid); in rtw89_arp_response_get()
2299 ether_addr_copy(hdr->addr2, rtwvif->mac_addr); in rtw89_arp_response_get()
2300 ether_addr_copy(hdr->addr3, rtwvif->bssid); in rtw89_arp_response_get()
2305 memcpy(arp_skb->llc_hdr, rfc1042_header, sizeof(rfc1042_header)); in rtw89_arp_response_get()
2306 arp_skb->llc_type = htons(ETH_P_ARP); in rtw89_arp_response_get()
2308 arp_hdr = &arp_skb->arp_hdr; in rtw89_arp_response_get()
2309 arp_hdr->ar_hrd = htons(ARPHRD_ETHER); in rtw89_arp_response_get()
2310 arp_hdr->ar_pro = htons(ETH_P_IP); in rtw89_arp_response_get()
2311 arp_hdr->ar_hln = ETH_ALEN; in rtw89_arp_response_get()
2312 arp_hdr->ar_pln = 4; in rtw89_arp_response_get()
2313 arp_hdr->ar_op = htons(ARPOP_REPLY); in rtw89_arp_response_get()
2315 ether_addr_copy(arp_skb->sender_hw, rtwvif->mac_addr); in rtw89_arp_response_get()
2316 arp_skb->sender_ip = rtwvif->ip_addr; in rtw89_arp_response_get()
2333 return -ENOMEM; in rtw89_fw_h2c_add_general_pkt()
2337 skb = ieee80211_pspoll_get(rtwdev->hw, vif); in rtw89_fw_h2c_add_general_pkt()
2340 skb = ieee80211_proberesp_get(rtwdev->hw, vif); in rtw89_fw_h2c_add_general_pkt()
2343 skb = ieee80211_nullfunc_get(rtwdev->hw, vif, -1, false); in rtw89_fw_h2c_add_general_pkt()
2346 skb = ieee80211_nullfunc_get(rtwdev->hw, vif, -1, true); in rtw89_fw_h2c_add_general_pkt()
2364 ret = rtw89_fw_h2c_add_pkt_offload(rtwdev, &info->id, skb); in rtw89_fw_h2c_add_general_pkt()
2370 list_add_tail(&info->list, &rtwvif->general_pkt_list); in rtw89_fw_h2c_add_general_pkt()
2371 *id = info->id; in rtw89_fw_h2c_add_general_pkt()
2376 return -ENOMEM; in rtw89_fw_h2c_add_general_pkt()
2382 struct list_head *pkt_list = &rtwvif->general_pkt_list; in rtw89_fw_release_general_pkt_list_vif()
2387 rtw89_fw_h2c_del_pkt_offload(rtwdev, info->id); in rtw89_fw_release_general_pkt_list_vif()
2389 rtw89_core_release_bit_map(rtwdev->pkt_offload, info->id); in rtw89_fw_release_general_pkt_list_vif()
2390 list_del(&info->list); in rtw89_fw_release_general_pkt_list_vif()
2424 return -ENOMEM; in rtw89_fw_h2c_general_pkt()
2427 SET_GENERAL_PKT_MACID(skb->data, macid); in rtw89_fw_h2c_general_pkt()
2428 SET_GENERAL_PKT_PROBRSP_ID(skb->data, H2C_GENERAL_PKT_ID_UND); in rtw89_fw_h2c_general_pkt()
2429 SET_GENERAL_PKT_PSPOLL_ID(skb->data, pkt_id_ps_poll); in rtw89_fw_h2c_general_pkt()
2430 SET_GENERAL_PKT_NULL_ID(skb->data, pkt_id_null); in rtw89_fw_h2c_general_pkt()
2431 SET_GENERAL_PKT_QOS_NULL_ID(skb->data, pkt_id_qos_null); in rtw89_fw_h2c_general_pkt()
2432 SET_GENERAL_PKT_CTS2SELF_ID(skb->data, H2C_GENERAL_PKT_ID_UND); in rtw89_fw_h2c_general_pkt()
2463 return -ENOMEM; in rtw89_fw_h2c_lps_parm()
2467 SET_LPS_PARM_MACID(skb->data, lps_param->macid); in rtw89_fw_h2c_lps_parm()
2468 SET_LPS_PARM_PSMODE(skb->data, lps_param->psmode); in rtw89_fw_h2c_lps_parm()
2469 SET_LPS_PARM_LASTRPWM(skb->data, lps_param->lastrpwm); in rtw89_fw_h2c_lps_parm()
2470 SET_LPS_PARM_RLBM(skb->data, 1); in rtw89_fw_h2c_lps_parm()
2471 SET_LPS_PARM_SMARTPS(skb->data, 1); in rtw89_fw_h2c_lps_parm()
2472 SET_LPS_PARM_AWAKEINTERVAL(skb->data, 1); in rtw89_fw_h2c_lps_parm()
2473 SET_LPS_PARM_VOUAPSD(skb->data, 0); in rtw89_fw_h2c_lps_parm()
2474 SET_LPS_PARM_VIUAPSD(skb->data, 0); in rtw89_fw_h2c_lps_parm()
2475 SET_LPS_PARM_BEUAPSD(skb->data, 0); in rtw89_fw_h2c_lps_parm()
2476 SET_LPS_PARM_BKUAPSD(skb->data, 0); in rtw89_fw_h2c_lps_parm()
2500 rtwvif->chanctx_idx); in rtw89_fw_h2c_lps_ch_info()
2501 const struct rtw89_chip_info *chip = rtwdev->chip; in rtw89_fw_h2c_lps_ch_info()
2508 if (chip->chip_gen != RTW89_CHIP_BE) in rtw89_fw_h2c_lps_ch_info()
2514 return -ENOMEM; in rtw89_fw_h2c_lps_ch_info()
2517 h2c = (struct rtw89_h2c_lps_ch_info *)skb->data; in rtw89_fw_h2c_lps_ch_info()
2519 h2c->info[0].central_ch = chan->channel; in rtw89_fw_h2c_lps_ch_info()
2520 h2c->info[0].pri_ch = chan->primary_channel; in rtw89_fw_h2c_lps_ch_info()
2521 h2c->info[0].band = chan->band_type; in rtw89_fw_h2c_lps_ch_info()
2522 h2c->info[0].bw = chan->band_width; in rtw89_fw_h2c_lps_ch_info()
2523 h2c->mlo_dbcc_mode_lps = cpu_to_le32(MLO_2_PLUS_0_1RF); in rtw89_fw_h2c_lps_ch_info()
2553 struct rtw89_vif *rtwvif = (struct rtw89_vif *)vif->drv_priv; in rtw89_fw_h2c_p2p_act()
2554 bool p2p_type_gc = rtwvif->wifi_role == RTW89_WIFI_ROLE_P2P_CLIENT; in rtw89_fw_h2c_p2p_act()
2555 u8 ctwindow_oppps = vif->bss_conf.p2p_noa_attr.oppps_ctwindow; in rtw89_fw_h2c_p2p_act()
2563 return -ENOMEM; in rtw89_fw_h2c_p2p_act()
2566 cmd = skb->data; in rtw89_fw_h2c_p2p_act()
2568 RTW89_SET_FWCMD_P2P_MACID(cmd, rtwvif->mac_id); in rtw89_fw_h2c_p2p_act()
2575 RTW89_SET_FWCMD_NOA_START_TIME(cmd, desc->start_time); in rtw89_fw_h2c_p2p_act()
2576 RTW89_SET_FWCMD_NOA_INTERVAL(cmd, desc->interval); in rtw89_fw_h2c_p2p_act()
2577 RTW89_SET_FWCMD_NOA_DURATION(cmd, desc->duration); in rtw89_fw_h2c_p2p_act()
2578 RTW89_SET_FWCMD_NOA_COUNT(cmd, desc->count); in rtw89_fw_h2c_p2p_act()
2603 const struct rtw89_chip_info *chip = rtwdev->chip; in __rtw89_fw_h2c_set_tx_path()
2604 struct rtw89_hal *hal = &rtwdev->hal; in __rtw89_fw_h2c_set_tx_path()
2608 if (chip->rf_path_num == 1) { in __rtw89_fw_h2c_set_tx_path()
2612 ntx_path = hal->antenna_tx ? hal->antenna_tx : RF_B; in __rtw89_fw_h2c_set_tx_path()
2613 map_b = hal->antenna_tx == RF_AB ? 1 : 0; in __rtw89_fw_h2c_set_tx_path()
2616 SET_CMC_TBL_NTX_PATH_EN(skb->data, ntx_path); in __rtw89_fw_h2c_set_tx_path()
2617 SET_CMC_TBL_PATH_MAP_A(skb->data, 0); in __rtw89_fw_h2c_set_tx_path()
2618 SET_CMC_TBL_PATH_MAP_B(skb->data, map_b); in __rtw89_fw_h2c_set_tx_path()
2619 SET_CMC_TBL_PATH_MAP_C(skb->data, 0); in __rtw89_fw_h2c_set_tx_path()
2620 SET_CMC_TBL_PATH_MAP_D(skb->data, 0); in __rtw89_fw_h2c_set_tx_path()
2628 const struct rtw89_chip_info *chip = rtwdev->chip; in rtw89_fw_h2c_default_cmac_tbl()
2629 u8 macid = rtwsta ? rtwsta->mac_id : rtwvif->mac_id; in rtw89_fw_h2c_default_cmac_tbl()
2636 return -ENOMEM; in rtw89_fw_h2c_default_cmac_tbl()
2639 SET_CTRL_INFO_MACID(skb->data, macid); in rtw89_fw_h2c_default_cmac_tbl()
2640 SET_CTRL_INFO_OPERATION(skb->data, 1); in rtw89_fw_h2c_default_cmac_tbl()
2641 if (chip->h2c_cctl_func_id == H2C_FUNC_MAC_CCTLINFO_UD) { in rtw89_fw_h2c_default_cmac_tbl()
2642 SET_CMC_TBL_TXPWR_MODE(skb->data, 0); in rtw89_fw_h2c_default_cmac_tbl()
2644 SET_CMC_TBL_ANTSEL_A(skb->data, 0); in rtw89_fw_h2c_default_cmac_tbl()
2645 SET_CMC_TBL_ANTSEL_B(skb->data, 0); in rtw89_fw_h2c_default_cmac_tbl()
2646 SET_CMC_TBL_ANTSEL_C(skb->data, 0); in rtw89_fw_h2c_default_cmac_tbl()
2647 SET_CMC_TBL_ANTSEL_D(skb->data, 0); in rtw89_fw_h2c_default_cmac_tbl()
2649 SET_CMC_TBL_DOPPLER_CTRL(skb->data, 0); in rtw89_fw_h2c_default_cmac_tbl()
2650 SET_CMC_TBL_TXPWR_TOLERENCE(skb->data, 0); in rtw89_fw_h2c_default_cmac_tbl()
2651 if (rtwvif->net_type == RTW89_NET_TYPE_AP_MODE) in rtw89_fw_h2c_default_cmac_tbl()
2652 SET_CMC_TBL_DATA_DCM(skb->data, 0); in rtw89_fw_h2c_default_cmac_tbl()
2656 chip->h2c_cctl_func_id, 0, 1, in rtw89_fw_h2c_default_cmac_tbl()
2677 u8 mac_id = rtwsta ? rtwsta->mac_id : rtwvif->mac_id; in rtw89_fw_h2c_default_cmac_tbl_g7()
2686 return -ENOMEM; in rtw89_fw_h2c_default_cmac_tbl_g7()
2689 h2c = (struct rtw89_h2c_cctlinfo_ud_g7 *)skb->data; in rtw89_fw_h2c_default_cmac_tbl_g7()
2691 h2c->c0 = le32_encode_bits(mac_id, CCTLINFO_G7_C0_MACID) | in rtw89_fw_h2c_default_cmac_tbl_g7()
2694 h2c->w0 = le32_encode_bits(4, CCTLINFO_G7_W0_DATARATE); in rtw89_fw_h2c_default_cmac_tbl_g7()
2695 h2c->m0 = cpu_to_le32(CCTLINFO_G7_W0_ALL); in rtw89_fw_h2c_default_cmac_tbl_g7()
2697 h2c->w1 = le32_encode_bits(4, CCTLINFO_G7_W1_DATA_RTY_LOWEST_RATE) | in rtw89_fw_h2c_default_cmac_tbl_g7()
2700 h2c->m1 = cpu_to_le32(CCTLINFO_G7_W1_ALL); in rtw89_fw_h2c_default_cmac_tbl_g7()
2702 h2c->m2 = cpu_to_le32(CCTLINFO_G7_W2_ALL); in rtw89_fw_h2c_default_cmac_tbl_g7()
2704 h2c->m3 = cpu_to_le32(CCTLINFO_G7_W3_ALL); in rtw89_fw_h2c_default_cmac_tbl_g7()
2706 h2c->w4 = le32_encode_bits(0xFFFF, CCTLINFO_G7_W4_ACT_SUBCH_CBW); in rtw89_fw_h2c_default_cmac_tbl_g7()
2707 h2c->m4 = cpu_to_le32(CCTLINFO_G7_W4_ALL); in rtw89_fw_h2c_default_cmac_tbl_g7()
2709 h2c->w5 = le32_encode_bits(2, CCTLINFO_G7_W5_NOMINAL_PKT_PADDING0) | in rtw89_fw_h2c_default_cmac_tbl_g7()
2714 h2c->m5 = cpu_to_le32(CCTLINFO_G7_W5_ALL); in rtw89_fw_h2c_default_cmac_tbl_g7()
2716 h2c->w6 = le32_encode_bits(0xb, CCTLINFO_G7_W6_RESP_REF_RATE); in rtw89_fw_h2c_default_cmac_tbl_g7()
2717 h2c->m6 = cpu_to_le32(CCTLINFO_G7_W6_ALL); in rtw89_fw_h2c_default_cmac_tbl_g7()
2719 h2c->w7 = le32_encode_bits(1, CCTLINFO_G7_W7_NC) | in rtw89_fw_h2c_default_cmac_tbl_g7()
2724 h2c->m7 = cpu_to_le32(CCTLINFO_G7_W7_ALL); in rtw89_fw_h2c_default_cmac_tbl_g7()
2726 h2c->m8 = cpu_to_le32(CCTLINFO_G7_W8_ALL); in rtw89_fw_h2c_default_cmac_tbl_g7()
2728 h2c->w14 = le32_encode_bits(0, CCTLINFO_G7_W14_VO_CURR_RATE) | in rtw89_fw_h2c_default_cmac_tbl_g7()
2731 h2c->m14 = cpu_to_le32(CCTLINFO_G7_W14_ALL); in rtw89_fw_h2c_default_cmac_tbl_g7()
2733 h2c->w15 = le32_encode_bits(0, CCTLINFO_G7_W15_BE_CURR_RATE_H) | in rtw89_fw_h2c_default_cmac_tbl_g7()
2736 h2c->m15 = cpu_to_le32(CCTLINFO_G7_W15_ALL); in rtw89_fw_h2c_default_cmac_tbl_g7()
2762 u8 nss = min(sta->deflink.rx_nss, rtwdev->hal.tx_nss) - 1; in __get_sta_he_pkt_padding()
2763 u8 ppe_thres_hdr = sta->deflink.he_cap.ppe_thres[0]; in __get_sta_he_pkt_padding()
2770 sta->deflink.he_cap.he_cap_elem.phy_cap_info[6]); in __get_sta_he_pkt_padding()
2775 sta->deflink.he_cap.he_cap_elem.phy_cap_info[9]); in __get_sta_he_pkt_padding()
2797 ppe = le16_to_cpu(*((__le16 *)&sta->deflink.he_cap.ppe_thres[idx])); in __get_sta_he_pkt_padding()
2815 const struct rtw89_chip_info *chip = rtwdev->chip; in rtw89_fw_h2c_assoc_cmac_tbl()
2817 struct rtw89_vif *rtwvif = (struct rtw89_vif *)vif->drv_priv; in rtw89_fw_h2c_assoc_cmac_tbl()
2819 rtwvif->chanctx_idx); in rtw89_fw_h2c_assoc_cmac_tbl()
2822 u8 mac_id = rtwsta ? rtwsta->mac_id : rtwvif->mac_id; in rtw89_fw_h2c_assoc_cmac_tbl()
2827 if (sta && sta->deflink.he_cap.has_he) in rtw89_fw_h2c_assoc_cmac_tbl()
2830 if (vif->p2p) in rtw89_fw_h2c_assoc_cmac_tbl()
2832 else if (chan->band_type == RTW89_BAND_2G) in rtw89_fw_h2c_assoc_cmac_tbl()
2840 return -ENOMEM; in rtw89_fw_h2c_assoc_cmac_tbl()
2843 SET_CTRL_INFO_MACID(skb->data, mac_id); in rtw89_fw_h2c_assoc_cmac_tbl()
2844 SET_CTRL_INFO_OPERATION(skb->data, 1); in rtw89_fw_h2c_assoc_cmac_tbl()
2845 SET_CMC_TBL_DISRTSFB(skb->data, 1); in rtw89_fw_h2c_assoc_cmac_tbl()
2846 SET_CMC_TBL_DISDATAFB(skb->data, 1); in rtw89_fw_h2c_assoc_cmac_tbl()
2847 SET_CMC_TBL_RTS_RTY_LOWEST_RATE(skb->data, lowest_rate); in rtw89_fw_h2c_assoc_cmac_tbl()
2848 SET_CMC_TBL_RTS_TXCNT_LMT_SEL(skb->data, 0); in rtw89_fw_h2c_assoc_cmac_tbl()
2849 SET_CMC_TBL_DATA_TXCNT_LMT_SEL(skb->data, 0); in rtw89_fw_h2c_assoc_cmac_tbl()
2850 if (vif->type == NL80211_IFTYPE_STATION) in rtw89_fw_h2c_assoc_cmac_tbl()
2851 SET_CMC_TBL_ULDL(skb->data, 1); in rtw89_fw_h2c_assoc_cmac_tbl()
2853 SET_CMC_TBL_ULDL(skb->data, 0); in rtw89_fw_h2c_assoc_cmac_tbl()
2854 SET_CMC_TBL_MULTI_PORT_ID(skb->data, rtwvif->port); in rtw89_fw_h2c_assoc_cmac_tbl()
2855 if (chip->h2c_cctl_func_id == H2C_FUNC_MAC_CCTLINFO_UD_V1) { in rtw89_fw_h2c_assoc_cmac_tbl()
2856 SET_CMC_TBL_NOMINAL_PKT_PADDING_V1(skb->data, pads[RTW89_CHANNEL_WIDTH_20]); in rtw89_fw_h2c_assoc_cmac_tbl()
2857 SET_CMC_TBL_NOMINAL_PKT_PADDING40_V1(skb->data, pads[RTW89_CHANNEL_WIDTH_40]); in rtw89_fw_h2c_assoc_cmac_tbl()
2858 SET_CMC_TBL_NOMINAL_PKT_PADDING80_V1(skb->data, pads[RTW89_CHANNEL_WIDTH_80]); in rtw89_fw_h2c_assoc_cmac_tbl()
2859 SET_CMC_TBL_NOMINAL_PKT_PADDING160_V1(skb->data, pads[RTW89_CHANNEL_WIDTH_160]); in rtw89_fw_h2c_assoc_cmac_tbl()
2860 } else if (chip->h2c_cctl_func_id == H2C_FUNC_MAC_CCTLINFO_UD) { in rtw89_fw_h2c_assoc_cmac_tbl()
2861 SET_CMC_TBL_NOMINAL_PKT_PADDING(skb->data, pads[RTW89_CHANNEL_WIDTH_20]); in rtw89_fw_h2c_assoc_cmac_tbl()
2862 SET_CMC_TBL_NOMINAL_PKT_PADDING40(skb->data, pads[RTW89_CHANNEL_WIDTH_40]); in rtw89_fw_h2c_assoc_cmac_tbl()
2863 SET_CMC_TBL_NOMINAL_PKT_PADDING80(skb->data, pads[RTW89_CHANNEL_WIDTH_80]); in rtw89_fw_h2c_assoc_cmac_tbl()
2864 SET_CMC_TBL_NOMINAL_PKT_PADDING160(skb->data, pads[RTW89_CHANNEL_WIDTH_160]); in rtw89_fw_h2c_assoc_cmac_tbl()
2867 SET_CMC_TBL_BSR_QUEUE_SIZE_FORMAT(skb->data, in rtw89_fw_h2c_assoc_cmac_tbl()
2868 sta->deflink.he_cap.has_he); in rtw89_fw_h2c_assoc_cmac_tbl()
2869 if (rtwvif->net_type == RTW89_NET_TYPE_AP_MODE) in rtw89_fw_h2c_assoc_cmac_tbl()
2870 SET_CMC_TBL_DATA_DCM(skb->data, 0); in rtw89_fw_h2c_assoc_cmac_tbl()
2874 chip->h2c_cctl_func_id, 0, 1, in rtw89_fw_h2c_assoc_cmac_tbl()
2894 u8 nss = min(sta->deflink.rx_nss, rtwdev->hal.tx_nss) - 1; in __get_sta_eht_pkt_padding()
2903 ppe_th = !!u8_get_bits(sta->deflink.eht_cap.eht_cap_elem.phy_cap_info[5], in __get_sta_eht_pkt_padding()
2908 pad = u8_get_bits(sta->deflink.eht_cap.eht_cap_elem.phy_cap_info[5], in __get_sta_eht_pkt_padding()
2917 ppe_thres_hdr = get_unaligned_le16(sta->deflink.eht_cap.eht_ppe_thres); in __get_sta_eht_pkt_padding()
2934 ppe = get_unaligned_le16(sta->deflink.eht_cap.eht_ppe_thres + idx); in __get_sta_eht_pkt_padding()
2952 struct rtw89_vif *rtwvif = (struct rtw89_vif *)vif->drv_priv; in rtw89_fw_h2c_assoc_cmac_tbl_g7()
2954 const struct rtw89_chan *chan = rtw89_chan_get(rtwdev, rtwvif->chanctx_idx); in rtw89_fw_h2c_assoc_cmac_tbl_g7()
2955 u8 mac_id = rtwsta ? rtwsta->mac_id : rtwvif->mac_id; in rtw89_fw_h2c_assoc_cmac_tbl_g7()
2965 if (sta->deflink.eht_cap.has_eht) in rtw89_fw_h2c_assoc_cmac_tbl_g7()
2967 else if (sta->deflink.he_cap.has_he) in rtw89_fw_h2c_assoc_cmac_tbl_g7()
2971 if (vif->p2p) in rtw89_fw_h2c_assoc_cmac_tbl_g7()
2973 else if (chan->band_type == RTW89_BAND_2G) in rtw89_fw_h2c_assoc_cmac_tbl_g7()
2981 return -ENOMEM; in rtw89_fw_h2c_assoc_cmac_tbl_g7()
2984 h2c = (struct rtw89_h2c_cctlinfo_ud_g7 *)skb->data; in rtw89_fw_h2c_assoc_cmac_tbl_g7()
2986 h2c->c0 = le32_encode_bits(mac_id, CCTLINFO_G7_C0_MACID) | in rtw89_fw_h2c_assoc_cmac_tbl_g7()
2989 h2c->w0 = le32_encode_bits(1, CCTLINFO_G7_W0_DISRTSFB) | in rtw89_fw_h2c_assoc_cmac_tbl_g7()
2991 h2c->m0 = cpu_to_le32(CCTLINFO_G7_W0_DISRTSFB | in rtw89_fw_h2c_assoc_cmac_tbl_g7()
2994 h2c->w1 = le32_encode_bits(lowest_rate, CCTLINFO_G7_W1_RTS_RTY_LOWEST_RATE); in rtw89_fw_h2c_assoc_cmac_tbl_g7()
2995 h2c->m1 = cpu_to_le32(CCTLINFO_G7_W1_RTS_RTY_LOWEST_RATE); in rtw89_fw_h2c_assoc_cmac_tbl_g7()
2997 h2c->w2 = le32_encode_bits(0, CCTLINFO_G7_W2_DATA_TXCNT_LMT_SEL); in rtw89_fw_h2c_assoc_cmac_tbl_g7()
2998 h2c->m2 = cpu_to_le32(CCTLINFO_G7_W2_DATA_TXCNT_LMT_SEL); in rtw89_fw_h2c_assoc_cmac_tbl_g7()
3000 h2c->w3 = le32_encode_bits(0, CCTLINFO_G7_W3_RTS_TXCNT_LMT_SEL); in rtw89_fw_h2c_assoc_cmac_tbl_g7()
3001 h2c->m3 = cpu_to_le32(CCTLINFO_G7_W3_RTS_TXCNT_LMT_SEL); in rtw89_fw_h2c_assoc_cmac_tbl_g7()
3003 h2c->w4 = le32_encode_bits(rtwvif->port, CCTLINFO_G7_W4_MULTI_PORT_ID); in rtw89_fw_h2c_assoc_cmac_tbl_g7()
3004 h2c->m4 = cpu_to_le32(CCTLINFO_G7_W4_MULTI_PORT_ID); in rtw89_fw_h2c_assoc_cmac_tbl_g7()
3006 if (rtwvif->net_type == RTW89_NET_TYPE_AP_MODE) { in rtw89_fw_h2c_assoc_cmac_tbl_g7()
3007 h2c->w4 |= le32_encode_bits(0, CCTLINFO_G7_W4_DATA_DCM); in rtw89_fw_h2c_assoc_cmac_tbl_g7()
3008 h2c->m4 |= cpu_to_le32(CCTLINFO_G7_W4_DATA_DCM); in rtw89_fw_h2c_assoc_cmac_tbl_g7()
3011 if (vif->bss_conf.eht_support) { in rtw89_fw_h2c_assoc_cmac_tbl_g7()
3012 u16 punct = vif->bss_conf.chanreq.oper.punctured; in rtw89_fw_h2c_assoc_cmac_tbl_g7()
3014 h2c->w4 |= le32_encode_bits(~punct, in rtw89_fw_h2c_assoc_cmac_tbl_g7()
3016 h2c->m4 |= cpu_to_le32(CCTLINFO_G7_W4_ACT_SUBCH_CBW); in rtw89_fw_h2c_assoc_cmac_tbl_g7()
3019 h2c->w5 = le32_encode_bits(pads[RTW89_CHANNEL_WIDTH_20], in rtw89_fw_h2c_assoc_cmac_tbl_g7()
3029 h2c->m5 = cpu_to_le32(CCTLINFO_G7_W5_NOMINAL_PKT_PADDING0 | in rtw89_fw_h2c_assoc_cmac_tbl_g7()
3035 h2c->w6 = le32_encode_bits(vif->type == NL80211_IFTYPE_STATION ? 1 : 0, in rtw89_fw_h2c_assoc_cmac_tbl_g7()
3037 h2c->m6 = cpu_to_le32(CCTLINFO_G7_W6_ULDL); in rtw89_fw_h2c_assoc_cmac_tbl_g7()
3040 h2c->w8 = le32_encode_bits(sta->deflink.he_cap.has_he, in rtw89_fw_h2c_assoc_cmac_tbl_g7()
3042 h2c->m8 = cpu_to_le32(CCTLINFO_G7_W8_BSR_QUEUE_SIZE_FORMAT); in rtw89_fw_h2c_assoc_cmac_tbl_g7()
3068 struct rtw89_sta *rtwsta = (struct rtw89_sta *)sta->drv_priv; in rtw89_fw_h2c_ampdu_cmac_tbl_g7()
3080 return -ENOMEM; in rtw89_fw_h2c_ampdu_cmac_tbl_g7()
3083 h2c = (struct rtw89_h2c_cctlinfo_ud_g7 *)skb->data; in rtw89_fw_h2c_ampdu_cmac_tbl_g7()
3085 for_each_set_bit(tid, rtwsta->ampdu_map, IEEE80211_NUM_TIDS) { in rtw89_fw_h2c_ampdu_cmac_tbl_g7()
3087 agg_num = rtwsta->ampdu_params[tid].agg_num; in rtw89_fw_h2c_ampdu_cmac_tbl_g7()
3089 agg_num = min(agg_num, rtwsta->ampdu_params[tid].agg_num); in rtw89_fw_h2c_ampdu_cmac_tbl_g7()
3105 h2c->c0 = le32_encode_bits(rtwsta->mac_id, CCTLINFO_G7_C0_MACID) | in rtw89_fw_h2c_ampdu_cmac_tbl_g7()
3108 h2c->w3 = le32_encode_bits(ba_bmap, CCTLINFO_G7_W3_BA_BMAP); in rtw89_fw_h2c_ampdu_cmac_tbl_g7()
3109 h2c->m3 = cpu_to_le32(CCTLINFO_G7_W3_BA_BMAP); in rtw89_fw_h2c_ampdu_cmac_tbl_g7()
3133 const struct rtw89_chip_info *chip = rtwdev->chip; in rtw89_fw_h2c_txtime_cmac_tbl()
3140 return -ENOMEM; in rtw89_fw_h2c_txtime_cmac_tbl()
3143 SET_CTRL_INFO_MACID(skb->data, rtwsta->mac_id); in rtw89_fw_h2c_txtime_cmac_tbl()
3144 SET_CTRL_INFO_OPERATION(skb->data, 1); in rtw89_fw_h2c_txtime_cmac_tbl()
3145 if (rtwsta->cctl_tx_time) { in rtw89_fw_h2c_txtime_cmac_tbl()
3146 SET_CMC_TBL_AMPDU_TIME_SEL(skb->data, 1); in rtw89_fw_h2c_txtime_cmac_tbl()
3147 SET_CMC_TBL_AMPDU_MAX_TIME(skb->data, rtwsta->ampdu_max_time); in rtw89_fw_h2c_txtime_cmac_tbl()
3149 if (rtwsta->cctl_tx_retry_limit) { in rtw89_fw_h2c_txtime_cmac_tbl()
3150 SET_CMC_TBL_DATA_TXCNT_LMT_SEL(skb->data, 1); in rtw89_fw_h2c_txtime_cmac_tbl()
3151 SET_CMC_TBL_DATA_TX_CNT_LMT(skb->data, rtwsta->data_tx_cnt_lmt); in rtw89_fw_h2c_txtime_cmac_tbl()
3156 chip->h2c_cctl_func_id, 0, 1, in rtw89_fw_h2c_txtime_cmac_tbl()
3175 const struct rtw89_chip_info *chip = rtwdev->chip; in rtw89_fw_h2c_txpath_cmac_tbl()
3179 if (chip->h2c_cctl_func_id != H2C_FUNC_MAC_CCTLINFO_UD) in rtw89_fw_h2c_txpath_cmac_tbl()
3185 return -ENOMEM; in rtw89_fw_h2c_txpath_cmac_tbl()
3188 SET_CTRL_INFO_MACID(skb->data, rtwsta->mac_id); in rtw89_fw_h2c_txpath_cmac_tbl()
3189 SET_CTRL_INFO_OPERATION(skb->data, 1); in rtw89_fw_h2c_txpath_cmac_tbl()
3215 rtwvif->chanctx_idx); in rtw89_fw_h2c_update_beacon()
3229 if (vif->p2p) in rtw89_fw_h2c_update_beacon()
3231 else if (chan->band_type == RTW89_BAND_2G) in rtw89_fw_h2c_update_beacon()
3236 skb_beacon = ieee80211_beacon_get_tim(rtwdev->hw, vif, &tim_offset, in rtw89_fw_h2c_update_beacon()
3240 return -ENOMEM; in rtw89_fw_h2c_update_beacon()
3251 tim_offset -= ieee80211_hdrlen(hdr->frame_control); in rtw89_fw_h2c_update_beacon()
3253 bcn_total_len = len + skb_beacon->len; in rtw89_fw_h2c_update_beacon()
3258 return -ENOMEM; in rtw89_fw_h2c_update_beacon()
3261 h2c = (struct rtw89_h2c_bcn_upd *)skb->data; in rtw89_fw_h2c_update_beacon()
3263 h2c->w0 = le32_encode_bits(rtwvif->port, RTW89_H2C_BCN_UPD_W0_PORT) | in rtw89_fw_h2c_update_beacon()
3265 le32_encode_bits(rtwvif->mac_idx, RTW89_H2C_BCN_UPD_W0_BAND) | in rtw89_fw_h2c_update_beacon()
3267 h2c->w1 = le32_encode_bits(rtwvif->mac_id, RTW89_H2C_BCN_UPD_W1_MACID) | in rtw89_fw_h2c_update_beacon()
3272 skb_put_data(skb, skb_beacon->data, skb_beacon->len); in rtw89_fw_h2c_update_beacon()
3294 const struct rtw89_chan *chan = rtw89_chan_get(rtwdev, rtwvif->chanctx_idx); in rtw89_fw_h2c_update_beacon_be()
3308 if (vif->p2p) in rtw89_fw_h2c_update_beacon_be()
3310 else if (chan->band_type == RTW89_BAND_2G) in rtw89_fw_h2c_update_beacon_be()
3315 skb_beacon = ieee80211_beacon_get_tim(rtwdev->hw, vif, &tim_offset, in rtw89_fw_h2c_update_beacon_be()
3319 return -ENOMEM; in rtw89_fw_h2c_update_beacon_be()
3330 tim_offset -= ieee80211_hdrlen(hdr->frame_control); in rtw89_fw_h2c_update_beacon_be()
3332 bcn_total_len = len + skb_beacon->len; in rtw89_fw_h2c_update_beacon_be()
3337 return -ENOMEM; in rtw89_fw_h2c_update_beacon_be()
3340 h2c = (struct rtw89_h2c_bcn_upd_be *)skb->data; in rtw89_fw_h2c_update_beacon_be()
3342 h2c->w0 = le32_encode_bits(rtwvif->port, RTW89_H2C_BCN_UPD_BE_W0_PORT) | in rtw89_fw_h2c_update_beacon_be()
3344 le32_encode_bits(rtwvif->mac_idx, RTW89_H2C_BCN_UPD_BE_W0_BAND) | in rtw89_fw_h2c_update_beacon_be()
3346 h2c->w1 = le32_encode_bits(rtwvif->mac_id, RTW89_H2C_BCN_UPD_BE_W1_MACID) | in rtw89_fw_h2c_update_beacon_be()
3351 skb_put_data(skb, skb_beacon->data, skb_beacon->len); in rtw89_fw_h2c_update_beacon_be()
3381 u8 mac_id = rtwsta ? rtwsta->mac_id : rtwvif->mac_id; in rtw89_fw_h2c_role_maintain()
3385 if (rtwvif->net_type == RTW89_NET_TYPE_AP_MODE) { in rtw89_fw_h2c_role_maintain()
3389 self_role = rtwvif->self_role; in rtw89_fw_h2c_role_maintain()
3391 self_role = rtwvif->self_role; in rtw89_fw_h2c_role_maintain()
3397 return -ENOMEM; in rtw89_fw_h2c_role_maintain()
3400 SET_FWROLE_MAINTAIN_MACID(skb->data, mac_id); in rtw89_fw_h2c_role_maintain()
3401 SET_FWROLE_MAINTAIN_SELF_ROLE(skb->data, self_role); in rtw89_fw_h2c_role_maintain()
3402 SET_FWROLE_MAINTAIN_UPD_MODE(skb->data, upd_mode); in rtw89_fw_h2c_role_maintain()
3403 SET_FWROLE_MAINTAIN_WIFI_ROLE(skb->data, rtwvif->wifi_role); in rtw89_fw_h2c_role_maintain()
3433 if (sta->deflink.eht_cap.has_eht) in rtw89_fw_get_sta_type()
3435 else if (sta->deflink.he_cap.has_he) in rtw89_fw_get_sta_type()
3441 if (vif->bss_conf.eht_support) in rtw89_fw_get_sta_type()
3443 else if (vif->bss_conf.he_support) in rtw89_fw_get_sta_type()
3453 u8 mac_id = rtwsta ? rtwsta->mac_id : rtwvif->mac_id; in rtw89_fw_h2c_join_info()
3454 u8 self_role = rtwvif->self_role; in rtw89_fw_h2c_join_info()
3456 u8 net_type = rtwvif->net_type; in rtw89_fw_h2c_join_info()
3463 if (rtwdev->chip->chip_gen == RTW89_CHIP_BE) { in rtw89_fw_h2c_join_info()
3476 return -ENOMEM; in rtw89_fw_h2c_join_info()
3479 h2c = (struct rtw89_h2c_join *)skb->data; in rtw89_fw_h2c_join_info()
3481 h2c->w0 = le32_encode_bits(mac_id, RTW89_H2C_JOININFO_W0_MACID) | in rtw89_fw_h2c_join_info()
3483 le32_encode_bits(rtwvif->mac_idx, RTW89_H2C_JOININFO_W0_BAND) | in rtw89_fw_h2c_join_info()
3484 le32_encode_bits(rtwvif->wmm, RTW89_H2C_JOININFO_W0_WMM) | in rtw89_fw_h2c_join_info()
3485 le32_encode_bits(rtwvif->trigger, RTW89_H2C_JOININFO_W0_TGR) | in rtw89_fw_h2c_join_info()
3490 le32_encode_bits(rtwvif->port, RTW89_H2C_JOININFO_W0_PORT_ID) | in rtw89_fw_h2c_join_info()
3492 le32_encode_bits(rtwvif->wifi_role, RTW89_H2C_JOININFO_W0_WIFI_ROLE) | in rtw89_fw_h2c_join_info()
3498 h2c_v1 = (struct rtw89_h2c_join_v1 *)skb->data; in rtw89_fw_h2c_join_info()
3502 h2c_v1->w1 = le32_encode_bits(sta_type, RTW89_H2C_JOININFO_W1_STA_TYPE); in rtw89_fw_h2c_join_info()
3503 h2c_v1->w2 = 0; in rtw89_fw_h2c_join_info()
3534 return -ENOMEM; in rtw89_fw_h2c_notify_dbcc()
3537 h2c = (struct rtw89_h2c_notify_dbcc *)skb->data; in rtw89_fw_h2c_notify_dbcc()
3539 h2c->w0 = le32_encode_bits(en, RTW89_H2C_NOTIFY_DBCC_EN); in rtw89_fw_h2c_notify_dbcc()
3570 if (RTW89_CHK_FW_FEATURE(MACID_PAUSE_SLEEP, &rtwdev->fw)) { in rtw89_fw_h2c_macid_pause()
3581 return -ENOMEM; in rtw89_fw_h2c_macid_pause()
3586 h2c_new = (struct rtw89_fw_macid_pause_sleep_grp *)skb->data; in rtw89_fw_h2c_macid_pause()
3588 h2c_new->n[0].pause_mask_grp[grp] = set; in rtw89_fw_h2c_macid_pause()
3589 h2c_new->n[0].sleep_mask_grp[grp] = set; in rtw89_fw_h2c_macid_pause()
3591 h2c_new->n[0].pause_grp[grp] = set; in rtw89_fw_h2c_macid_pause()
3592 h2c_new->n[0].sleep_grp[grp] = set; in rtw89_fw_h2c_macid_pause()
3595 h2c = (struct rtw89_fw_macid_pause_grp *)skb->data; in rtw89_fw_h2c_macid_pause()
3597 h2c->mask_grp[grp] = set; in rtw89_fw_h2c_macid_pause()
3599 h2c->pause_grp[grp] = set; in rtw89_fw_h2c_macid_pause()
3630 return -ENOMEM; in rtw89_fw_h2c_set_edca()
3633 RTW89_SET_EDCA_SEL(skb->data, 0); in rtw89_fw_h2c_set_edca()
3634 RTW89_SET_EDCA_BAND(skb->data, rtwvif->mac_idx); in rtw89_fw_h2c_set_edca()
3635 RTW89_SET_EDCA_WMM(skb->data, 0); in rtw89_fw_h2c_set_edca()
3636 RTW89_SET_EDCA_AC(skb->data, ac); in rtw89_fw_h2c_set_edca()
3637 RTW89_SET_EDCA_PARAM(skb->data, val); in rtw89_fw_h2c_set_edca()
3669 return -ENOMEM; in rtw89_fw_h2c_tsf32_toggle()
3672 cmd = skb->data; in rtw89_fw_h2c_tsf32_toggle()
3674 RTW89_SET_FWCMD_TSF32_TOGL_BAND(cmd, rtwvif->mac_idx); in rtw89_fw_h2c_tsf32_toggle()
3676 RTW89_SET_FWCMD_TSF32_TOGL_PORT(cmd, rtwvif->port); in rtw89_fw_h2c_tsf32_toggle()
3707 return -ENOMEM; in rtw89_fw_h2c_set_ofld_cfg()
3734 struct ieee80211_bss_conf *bss_conf = vif ? &vif->bss_conf : NULL; in rtw89_fw_h2c_set_bcn_fltr_cfg()
3742 if (!RTW89_CHK_FW_FEATURE(BEACON_FILTER, &rtwdev->fw)) in rtw89_fw_h2c_set_bcn_fltr_cfg()
3743 return -EINVAL; in rtw89_fw_h2c_set_bcn_fltr_cfg()
3745 if (!rtwvif || !bss_conf || rtwvif->net_type != RTW89_NET_TYPE_INFRA) in rtw89_fw_h2c_set_bcn_fltr_cfg()
3746 return -EINVAL; in rtw89_fw_h2c_set_bcn_fltr_cfg()
3751 return -ENOMEM; in rtw89_fw_h2c_set_bcn_fltr_cfg()
3755 h2c = (struct rtw89_h2c_bcnfltr *)skb->data; in rtw89_fw_h2c_set_bcn_fltr_cfg()
3757 if (bss_conf->cqm_rssi_hyst) in rtw89_fw_h2c_set_bcn_fltr_cfg()
3758 hyst = bss_conf->cqm_rssi_hyst; in rtw89_fw_h2c_set_bcn_fltr_cfg()
3759 if (bss_conf->cqm_rssi_thold) in rtw89_fw_h2c_set_bcn_fltr_cfg()
3760 thold = bss_conf->cqm_rssi_thold; in rtw89_fw_h2c_set_bcn_fltr_cfg()
3762 h2c->w0 = le32_encode_bits(connect, RTW89_H2C_BCNFLTR_W0_MON_RSSI) | in rtw89_fw_h2c_set_bcn_fltr_cfg()
3771 le32_encode_bits(rtwvif->mac_id, RTW89_H2C_BCNFLTR_W0_MAC_ID); in rtw89_fw_h2c_set_bcn_fltr_cfg()
3799 if (!RTW89_CHK_FW_FEATURE(BEACON_FILTER, &rtwdev->fw)) in rtw89_fw_h2c_rssi_offload()
3800 return -EINVAL; in rtw89_fw_h2c_rssi_offload()
3803 return -EINVAL; in rtw89_fw_h2c_rssi_offload()
3808 return -ENOMEM; in rtw89_fw_h2c_rssi_offload()
3811 rssi = phy_ppdu->rssi_avg >> RSSI_FACTOR; in rtw89_fw_h2c_rssi_offload()
3813 h2c = (struct rtw89_h2c_ofld_rssi *)skb->data; in rtw89_fw_h2c_rssi_offload()
3815 h2c->w0 = le32_encode_bits(phy_ppdu->mac_id, RTW89_H2C_OFLD_RSSI_W0_MACID) | in rtw89_fw_h2c_rssi_offload()
3817 h2c->w1 = le32_encode_bits(rssi, RTW89_H2C_OFLD_RSSI_W1_VAL); in rtw89_fw_h2c_rssi_offload()
3838 struct rtw89_traffic_stats *stats = &rtwvif->stats; in rtw89_fw_h2c_tp_offload()
3844 if (rtwvif->net_type != RTW89_NET_TYPE_INFRA) in rtw89_fw_h2c_tp_offload()
3845 return -EINVAL; in rtw89_fw_h2c_tp_offload()
3850 return -ENOMEM; in rtw89_fw_h2c_tp_offload()
3854 h2c = (struct rtw89_h2c_ofld *)skb->data; in rtw89_fw_h2c_tp_offload()
3856 h2c->w0 = le32_encode_bits(rtwvif->mac_id, RTW89_H2C_OFLD_W0_MAC_ID) | in rtw89_fw_h2c_tp_offload()
3857 le32_encode_bits(stats->tx_throughput, RTW89_H2C_OFLD_W0_TX_TP) | in rtw89_fw_h2c_tp_offload()
3858 le32_encode_bits(stats->rx_throughput, RTW89_H2C_OFLD_W0_RX_TP); in rtw89_fw_h2c_tp_offload()
3879 const struct rtw89_chip_info *chip = rtwdev->chip; in rtw89_fw_h2c_ra()
3887 if (chip->chip_gen == RTW89_CHIP_BE) { in rtw89_fw_h2c_ra()
3895 return -ENOMEM; in rtw89_fw_h2c_ra()
3898 h2c = (struct rtw89_h2c_ra *)skb->data; in rtw89_fw_h2c_ra()
3900 "ra cmd msk: %llx ", ra->ra_mask); in rtw89_fw_h2c_ra()
3902 h2c->w0 = le32_encode_bits(ra->mode_ctrl, RTW89_H2C_RA_W0_MODE) | in rtw89_fw_h2c_ra()
3903 le32_encode_bits(ra->bw_cap, RTW89_H2C_RA_W0_BW_CAP) | in rtw89_fw_h2c_ra()
3904 le32_encode_bits(ra->macid, RTW89_H2C_RA_W0_MACID) | in rtw89_fw_h2c_ra()
3905 le32_encode_bits(ra->dcm_cap, RTW89_H2C_RA_W0_DCM) | in rtw89_fw_h2c_ra()
3906 le32_encode_bits(ra->er_cap, RTW89_H2C_RA_W0_ER) | in rtw89_fw_h2c_ra()
3907 le32_encode_bits(ra->init_rate_lv, RTW89_H2C_RA_W0_INIT_RATE_LV) | in rtw89_fw_h2c_ra()
3908 le32_encode_bits(ra->upd_all, RTW89_H2C_RA_W0_UPD_ALL) | in rtw89_fw_h2c_ra()
3909 le32_encode_bits(ra->en_sgi, RTW89_H2C_RA_W0_SGI) | in rtw89_fw_h2c_ra()
3910 le32_encode_bits(ra->ldpc_cap, RTW89_H2C_RA_W0_LDPC) | in rtw89_fw_h2c_ra()
3911 le32_encode_bits(ra->stbc_cap, RTW89_H2C_RA_W0_STBC) | in rtw89_fw_h2c_ra()
3912 le32_encode_bits(ra->ss_num, RTW89_H2C_RA_W0_SS_NUM) | in rtw89_fw_h2c_ra()
3913 le32_encode_bits(ra->giltf, RTW89_H2C_RA_W0_GILTF) | in rtw89_fw_h2c_ra()
3914 le32_encode_bits(ra->upd_bw_nss_mask, RTW89_H2C_RA_W0_UPD_BW_NSS_MASK) | in rtw89_fw_h2c_ra()
3915 le32_encode_bits(ra->upd_mask, RTW89_H2C_RA_W0_UPD_MASK); in rtw89_fw_h2c_ra()
3916 h2c->w1 = le32_encode_bits(ra->ra_mask, RTW89_H2C_RA_W1_RAMASK_LO32); in rtw89_fw_h2c_ra()
3917 h2c->w2 = le32_encode_bits(ra->ra_mask >> 32, RTW89_H2C_RA_W2_RAMASK_HI32); in rtw89_fw_h2c_ra()
3918 h2c->w3 = le32_encode_bits(ra->fix_giltf_en, RTW89_H2C_RA_W3_FIX_GILTF_EN) | in rtw89_fw_h2c_ra()
3919 le32_encode_bits(ra->fix_giltf, RTW89_H2C_RA_W3_FIX_GILTF); in rtw89_fw_h2c_ra()
3925 h2c_v1->w4 = le32_encode_bits(ra->mode_ctrl, RTW89_H2C_RA_V1_W4_MODE_EHT) | in rtw89_fw_h2c_ra()
3926 le32_encode_bits(ra->bw_cap, RTW89_H2C_RA_V1_W4_BW_EHT); in rtw89_fw_h2c_ra()
3932 h2c->w2 |= le32_encode_bits(1, RTW89_H2C_RA_W2_BFEE_CSI_CTL); in rtw89_fw_h2c_ra()
3933 h2c->w3 |= le32_encode_bits(ra->band_num, RTW89_H2C_RA_W3_BAND_NUM) | in rtw89_fw_h2c_ra()
3934 le32_encode_bits(ra->cr_tbl_sel, RTW89_H2C_RA_W3_CR_TBL_SEL) | in rtw89_fw_h2c_ra()
3935 le32_encode_bits(ra->fixed_csi_rate_en, RTW89_H2C_RA_W3_FIXED_CSI_RATE_EN) | in rtw89_fw_h2c_ra()
3936 le32_encode_bits(ra->ra_csi_rate_en, RTW89_H2C_RA_W3_RA_CSI_RATE_EN) | in rtw89_fw_h2c_ra()
3937 le32_encode_bits(ra->csi_mcs_ss_idx, RTW89_H2C_RA_W3_FIXED_CSI_MCS_SS_IDX) | in rtw89_fw_h2c_ra()
3938 le32_encode_bits(ra->csi_mode, RTW89_H2C_RA_W3_FIXED_CSI_MODE) | in rtw89_fw_h2c_ra()
3939 le32_encode_bits(ra->csi_gi_ltf, RTW89_H2C_RA_W3_FIXED_CSI_GI_LTF) | in rtw89_fw_h2c_ra()
3940 le32_encode_bits(ra->csi_bw, RTW89_H2C_RA_W3_FIXED_CSI_BW); in rtw89_fw_h2c_ra()
3963 struct rtw89_btc *btc = &rtwdev->btc; in rtw89_fw_h2c_cxdrv_init()
3964 struct rtw89_btc_dm *dm = &btc->dm; in rtw89_fw_h2c_cxdrv_init()
3965 struct rtw89_btc_init_info *init_info = &dm->init_info.init; in rtw89_fw_h2c_cxdrv_init()
3966 struct rtw89_btc_module *module = &init_info->module; in rtw89_fw_h2c_cxdrv_init()
3967 struct rtw89_btc_ant_info *ant = &module->ant; in rtw89_fw_h2c_cxdrv_init()
3976 return -ENOMEM; in rtw89_fw_h2c_cxdrv_init()
3979 h2c = (struct rtw89_h2c_cxinit *)skb->data; in rtw89_fw_h2c_cxdrv_init()
3981 h2c->hdr.type = type; in rtw89_fw_h2c_cxdrv_init()
3982 h2c->hdr.len = len - H2C_LEN_CXDRVHDR; in rtw89_fw_h2c_cxdrv_init()
3984 h2c->ant_type = ant->type; in rtw89_fw_h2c_cxdrv_init()
3985 h2c->ant_num = ant->num; in rtw89_fw_h2c_cxdrv_init()
3986 h2c->ant_iso = ant->isolation; in rtw89_fw_h2c_cxdrv_init()
3987 h2c->ant_info = in rtw89_fw_h2c_cxdrv_init()
3988 u8_encode_bits(ant->single_pos, RTW89_H2C_CXINIT_ANT_INFO_POS) | in rtw89_fw_h2c_cxdrv_init()
3989 u8_encode_bits(ant->diversity, RTW89_H2C_CXINIT_ANT_INFO_DIVERSITY) | in rtw89_fw_h2c_cxdrv_init()
3990 u8_encode_bits(ant->btg_pos, RTW89_H2C_CXINIT_ANT_INFO_BTG_POS) | in rtw89_fw_h2c_cxdrv_init()
3991 u8_encode_bits(ant->stream_cnt, RTW89_H2C_CXINIT_ANT_INFO_STREAM_CNT); in rtw89_fw_h2c_cxdrv_init()
3993 h2c->mod_rfe = module->rfe_type; in rtw89_fw_h2c_cxdrv_init()
3994 h2c->mod_cv = module->cv; in rtw89_fw_h2c_cxdrv_init()
3995 h2c->mod_info = in rtw89_fw_h2c_cxdrv_init()
3996 u8_encode_bits(module->bt_solo, RTW89_H2C_CXINIT_MOD_INFO_BT_SOLO) | in rtw89_fw_h2c_cxdrv_init()
3997 u8_encode_bits(module->bt_pos, RTW89_H2C_CXINIT_MOD_INFO_BT_POS) | in rtw89_fw_h2c_cxdrv_init()
3998 u8_encode_bits(module->switch_type, RTW89_H2C_CXINIT_MOD_INFO_SW_TYPE) | in rtw89_fw_h2c_cxdrv_init()
3999 u8_encode_bits(module->wa_type, RTW89_H2C_CXINIT_MOD_INFO_WA_TYPE); in rtw89_fw_h2c_cxdrv_init()
4000 h2c->mod_adie_kt = module->kt_ver_adie; in rtw89_fw_h2c_cxdrv_init()
4001 h2c->wl_gch = init_info->wl_guard_ch; in rtw89_fw_h2c_cxdrv_init()
4003 h2c->info = in rtw89_fw_h2c_cxdrv_init()
4004 u8_encode_bits(init_info->wl_only, RTW89_H2C_CXINIT_INFO_WL_ONLY) | in rtw89_fw_h2c_cxdrv_init()
4005 u8_encode_bits(init_info->wl_init_ok, RTW89_H2C_CXINIT_INFO_WL_INITOK) | in rtw89_fw_h2c_cxdrv_init()
4006 u8_encode_bits(init_info->dbcc_en, RTW89_H2C_CXINIT_INFO_DBCC_EN) | in rtw89_fw_h2c_cxdrv_init()
4007 u8_encode_bits(init_info->cx_other, RTW89_H2C_CXINIT_INFO_CX_OTHER) | in rtw89_fw_h2c_cxdrv_init()
4008 u8_encode_bits(init_info->bt_only, RTW89_H2C_CXINIT_INFO_BT_ONLY); in rtw89_fw_h2c_cxdrv_init()
4030 struct rtw89_btc *btc = &rtwdev->btc; in rtw89_fw_h2c_cxdrv_init_v7()
4031 struct rtw89_btc_dm *dm = &btc->dm; in rtw89_fw_h2c_cxdrv_init_v7()
4032 struct rtw89_btc_init_info_v7 *init_info = &dm->init_info.init_v7; in rtw89_fw_h2c_cxdrv_init_v7()
4041 return -ENOMEM; in rtw89_fw_h2c_cxdrv_init_v7()
4044 h2c = (struct rtw89_h2c_cxinit_v7 *)skb->data; in rtw89_fw_h2c_cxdrv_init_v7()
4046 h2c->hdr.type = type; in rtw89_fw_h2c_cxdrv_init_v7()
4047 h2c->hdr.ver = btc->ver->fcxinit; in rtw89_fw_h2c_cxdrv_init_v7()
4048 h2c->hdr.len = len - H2C_LEN_CXDRVHDR_V7; in rtw89_fw_h2c_cxdrv_init_v7()
4049 h2c->init = *init_info; in rtw89_fw_h2c_cxdrv_init_v7()
4076 struct rtw89_btc *btc = &rtwdev->btc; in rtw89_fw_h2c_cxdrv_role()
4077 const struct rtw89_btc_ver *ver = btc->ver; in rtw89_fw_h2c_cxdrv_role()
4078 struct rtw89_btc_wl_info *wl = &btc->cx.wl; in rtw89_fw_h2c_cxdrv_role()
4079 struct rtw89_btc_wl_role_info *role_info = &wl->role_info; in rtw89_fw_h2c_cxdrv_role()
4080 struct rtw89_btc_wl_role_info_bpos *bpos = &role_info->role_map.role; in rtw89_fw_h2c_cxdrv_role()
4081 struct rtw89_btc_wl_active_role *active = role_info->active_role; in rtw89_fw_h2c_cxdrv_role()
4089 len = H2C_LEN_CXDRVINFO_ROLE_SIZE(ver->max_role_num); in rtw89_fw_h2c_cxdrv_role()
4094 return -ENOMEM; in rtw89_fw_h2c_cxdrv_role()
4097 cmd = skb->data; in rtw89_fw_h2c_cxdrv_role()
4100 RTW89_SET_FWCMD_CXHDR_LEN(cmd, len - H2C_LEN_CXDRVHDR); in rtw89_fw_h2c_cxdrv_role()
4102 RTW89_SET_FWCMD_CXROLE_CONNECT_CNT(cmd, role_info->connect_cnt); in rtw89_fw_h2c_cxdrv_role()
4103 RTW89_SET_FWCMD_CXROLE_LINK_MODE(cmd, role_info->link_mode); in rtw89_fw_h2c_cxdrv_role()
4105 RTW89_SET_FWCMD_CXROLE_ROLE_NONE(cmd, bpos->none); in rtw89_fw_h2c_cxdrv_role()
4106 RTW89_SET_FWCMD_CXROLE_ROLE_STA(cmd, bpos->station); in rtw89_fw_h2c_cxdrv_role()
4107 RTW89_SET_FWCMD_CXROLE_ROLE_AP(cmd, bpos->ap); in rtw89_fw_h2c_cxdrv_role()
4108 RTW89_SET_FWCMD_CXROLE_ROLE_VAP(cmd, bpos->vap); in rtw89_fw_h2c_cxdrv_role()
4109 RTW89_SET_FWCMD_CXROLE_ROLE_ADHOC(cmd, bpos->adhoc); in rtw89_fw_h2c_cxdrv_role()
4110 RTW89_SET_FWCMD_CXROLE_ROLE_ADHOC_MASTER(cmd, bpos->adhoc_master); in rtw89_fw_h2c_cxdrv_role()
4111 RTW89_SET_FWCMD_CXROLE_ROLE_MESH(cmd, bpos->mesh); in rtw89_fw_h2c_cxdrv_role()
4112 RTW89_SET_FWCMD_CXROLE_ROLE_MONITOR(cmd, bpos->moniter); in rtw89_fw_h2c_cxdrv_role()
4113 RTW89_SET_FWCMD_CXROLE_ROLE_P2P_DEV(cmd, bpos->p2p_device); in rtw89_fw_h2c_cxdrv_role()
4114 RTW89_SET_FWCMD_CXROLE_ROLE_P2P_GC(cmd, bpos->p2p_gc); in rtw89_fw_h2c_cxdrv_role()
4115 RTW89_SET_FWCMD_CXROLE_ROLE_P2P_GO(cmd, bpos->p2p_go); in rtw89_fw_h2c_cxdrv_role()
4116 RTW89_SET_FWCMD_CXROLE_ROLE_NAN(cmd, bpos->nan); in rtw89_fw_h2c_cxdrv_role()
4119 RTW89_SET_FWCMD_CXROLE_ACT_CONNECTED(cmd, active->connected, i, offset); in rtw89_fw_h2c_cxdrv_role()
4120 RTW89_SET_FWCMD_CXROLE_ACT_PID(cmd, active->pid, i, offset); in rtw89_fw_h2c_cxdrv_role()
4121 RTW89_SET_FWCMD_CXROLE_ACT_PHY(cmd, active->phy, i, offset); in rtw89_fw_h2c_cxdrv_role()
4122 RTW89_SET_FWCMD_CXROLE_ACT_NOA(cmd, active->noa, i, offset); in rtw89_fw_h2c_cxdrv_role()
4123 RTW89_SET_FWCMD_CXROLE_ACT_BAND(cmd, active->band, i, offset); in rtw89_fw_h2c_cxdrv_role()
4124 RTW89_SET_FWCMD_CXROLE_ACT_CLIENT_PS(cmd, active->client_ps, i, offset); in rtw89_fw_h2c_cxdrv_role()
4125 RTW89_SET_FWCMD_CXROLE_ACT_BW(cmd, active->bw, i, offset); in rtw89_fw_h2c_cxdrv_role()
4126 RTW89_SET_FWCMD_CXROLE_ACT_ROLE(cmd, active->role, i, offset); in rtw89_fw_h2c_cxdrv_role()
4127 RTW89_SET_FWCMD_CXROLE_ACT_CH(cmd, active->ch, i, offset); in rtw89_fw_h2c_cxdrv_role()
4128 RTW89_SET_FWCMD_CXROLE_ACT_TX_LVL(cmd, active->tx_lvl, i, offset); in rtw89_fw_h2c_cxdrv_role()
4129 RTW89_SET_FWCMD_CXROLE_ACT_RX_LVL(cmd, active->rx_lvl, i, offset); in rtw89_fw_h2c_cxdrv_role()
4130 RTW89_SET_FWCMD_CXROLE_ACT_TX_RATE(cmd, active->tx_rate, i, offset); in rtw89_fw_h2c_cxdrv_role()
4131 RTW89_SET_FWCMD_CXROLE_ACT_RX_RATE(cmd, active->rx_rate, i, offset); in rtw89_fw_h2c_cxdrv_role()
4157 struct rtw89_btc *btc = &rtwdev->btc; in rtw89_fw_h2c_cxdrv_role_v1()
4158 const struct rtw89_btc_ver *ver = btc->ver; in rtw89_fw_h2c_cxdrv_role_v1()
4159 struct rtw89_btc_wl_info *wl = &btc->cx.wl; in rtw89_fw_h2c_cxdrv_role_v1()
4160 struct rtw89_btc_wl_role_info_v1 *role_info = &wl->role_info_v1; in rtw89_fw_h2c_cxdrv_role_v1()
4161 struct rtw89_btc_wl_role_info_bpos *bpos = &role_info->role_map.role; in rtw89_fw_h2c_cxdrv_role_v1()
4162 struct rtw89_btc_wl_active_role_v1 *active = role_info->active_role_v1; in rtw89_fw_h2c_cxdrv_role_v1()
4169 len = H2C_LEN_CXDRVINFO_ROLE_SIZE_V1(ver->max_role_num); in rtw89_fw_h2c_cxdrv_role_v1()
4174 return -ENOMEM; in rtw89_fw_h2c_cxdrv_role_v1()
4177 cmd = skb->data; in rtw89_fw_h2c_cxdrv_role_v1()
4180 RTW89_SET_FWCMD_CXHDR_LEN(cmd, len - H2C_LEN_CXDRVHDR); in rtw89_fw_h2c_cxdrv_role_v1()
4182 RTW89_SET_FWCMD_CXROLE_CONNECT_CNT(cmd, role_info->connect_cnt); in rtw89_fw_h2c_cxdrv_role_v1()
4183 RTW89_SET_FWCMD_CXROLE_LINK_MODE(cmd, role_info->link_mode); in rtw89_fw_h2c_cxdrv_role_v1()
4185 RTW89_SET_FWCMD_CXROLE_ROLE_NONE(cmd, bpos->none); in rtw89_fw_h2c_cxdrv_role_v1()
4186 RTW89_SET_FWCMD_CXROLE_ROLE_STA(cmd, bpos->station); in rtw89_fw_h2c_cxdrv_role_v1()
4187 RTW89_SET_FWCMD_CXROLE_ROLE_AP(cmd, bpos->ap); in rtw89_fw_h2c_cxdrv_role_v1()
4188 RTW89_SET_FWCMD_CXROLE_ROLE_VAP(cmd, bpos->vap); in rtw89_fw_h2c_cxdrv_role_v1()
4189 RTW89_SET_FWCMD_CXROLE_ROLE_ADHOC(cmd, bpos->adhoc); in rtw89_fw_h2c_cxdrv_role_v1()
4190 RTW89_SET_FWCMD_CXROLE_ROLE_ADHOC_MASTER(cmd, bpos->adhoc_master); in rtw89_fw_h2c_cxdrv_role_v1()
4191 RTW89_SET_FWCMD_CXROLE_ROLE_MESH(cmd, bpos->mesh); in rtw89_fw_h2c_cxdrv_role_v1()
4192 RTW89_SET_FWCMD_CXROLE_ROLE_MONITOR(cmd, bpos->moniter); in rtw89_fw_h2c_cxdrv_role_v1()
4193 RTW89_SET_FWCMD_CXROLE_ROLE_P2P_DEV(cmd, bpos->p2p_device); in rtw89_fw_h2c_cxdrv_role_v1()
4194 RTW89_SET_FWCMD_CXROLE_ROLE_P2P_GC(cmd, bpos->p2p_gc); in rtw89_fw_h2c_cxdrv_role_v1()
4195 RTW89_SET_FWCMD_CXROLE_ROLE_P2P_GO(cmd, bpos->p2p_go); in rtw89_fw_h2c_cxdrv_role_v1()
4196 RTW89_SET_FWCMD_CXROLE_ROLE_NAN(cmd, bpos->nan); in rtw89_fw_h2c_cxdrv_role_v1()
4200 RTW89_SET_FWCMD_CXROLE_ACT_CONNECTED(cmd, active->connected, i, offset); in rtw89_fw_h2c_cxdrv_role_v1()
4201 RTW89_SET_FWCMD_CXROLE_ACT_PID(cmd, active->pid, i, offset); in rtw89_fw_h2c_cxdrv_role_v1()
4202 RTW89_SET_FWCMD_CXROLE_ACT_PHY(cmd, active->phy, i, offset); in rtw89_fw_h2c_cxdrv_role_v1()
4203 RTW89_SET_FWCMD_CXROLE_ACT_NOA(cmd, active->noa, i, offset); in rtw89_fw_h2c_cxdrv_role_v1()
4204 RTW89_SET_FWCMD_CXROLE_ACT_BAND(cmd, active->band, i, offset); in rtw89_fw_h2c_cxdrv_role_v1()
4205 RTW89_SET_FWCMD_CXROLE_ACT_CLIENT_PS(cmd, active->client_ps, i, offset); in rtw89_fw_h2c_cxdrv_role_v1()
4206 RTW89_SET_FWCMD_CXROLE_ACT_BW(cmd, active->bw, i, offset); in rtw89_fw_h2c_cxdrv_role_v1()
4207 RTW89_SET_FWCMD_CXROLE_ACT_ROLE(cmd, active->role, i, offset); in rtw89_fw_h2c_cxdrv_role_v1()
4208 RTW89_SET_FWCMD_CXROLE_ACT_CH(cmd, active->ch, i, offset); in rtw89_fw_h2c_cxdrv_role_v1()
4209 RTW89_SET_FWCMD_CXROLE_ACT_TX_LVL(cmd, active->tx_lvl, i, offset); in rtw89_fw_h2c_cxdrv_role_v1()
4210 RTW89_SET_FWCMD_CXROLE_ACT_RX_LVL(cmd, active->rx_lvl, i, offset); in rtw89_fw_h2c_cxdrv_role_v1()
4211 RTW89_SET_FWCMD_CXROLE_ACT_TX_RATE(cmd, active->tx_rate, i, offset); in rtw89_fw_h2c_cxdrv_role_v1()
4212 RTW89_SET_FWCMD_CXROLE_ACT_RX_RATE(cmd, active->rx_rate, i, offset); in rtw89_fw_h2c_cxdrv_role_v1()
4213 RTW89_SET_FWCMD_CXROLE_ACT_NOA_DUR(cmd, active->noa_duration, i, offset); in rtw89_fw_h2c_cxdrv_role_v1()
4216 offset = len - H2C_LEN_CXDRVINFO_ROLE_DBCC_LEN; in rtw89_fw_h2c_cxdrv_role_v1()
4217 RTW89_SET_FWCMD_CXROLE_MROLE_TYPE(cmd, role_info->mrole_type, offset); in rtw89_fw_h2c_cxdrv_role_v1()
4218 RTW89_SET_FWCMD_CXROLE_MROLE_NOA(cmd, role_info->mrole_noa_duration, offset); in rtw89_fw_h2c_cxdrv_role_v1()
4219 RTW89_SET_FWCMD_CXROLE_DBCC_EN(cmd, role_info->dbcc_en, offset); in rtw89_fw_h2c_cxdrv_role_v1()
4220 RTW89_SET_FWCMD_CXROLE_DBCC_CHG(cmd, role_info->dbcc_chg, offset); in rtw89_fw_h2c_cxdrv_role_v1()
4221 RTW89_SET_FWCMD_CXROLE_DBCC_2G_PHY(cmd, role_info->dbcc_2g_phy, offset); in rtw89_fw_h2c_cxdrv_role_v1()
4222 RTW89_SET_FWCMD_CXROLE_LINK_MODE_CHG(cmd, role_info->link_mode_chg, offset); in rtw89_fw_h2c_cxdrv_role_v1()
4247 struct rtw89_btc *btc = &rtwdev->btc; in rtw89_fw_h2c_cxdrv_role_v2()
4248 const struct rtw89_btc_ver *ver = btc->ver; in rtw89_fw_h2c_cxdrv_role_v2()
4249 struct rtw89_btc_wl_info *wl = &btc->cx.wl; in rtw89_fw_h2c_cxdrv_role_v2()
4250 struct rtw89_btc_wl_role_info_v2 *role_info = &wl->role_info_v2; in rtw89_fw_h2c_cxdrv_role_v2()
4251 struct rtw89_btc_wl_role_info_bpos *bpos = &role_info->role_map.role; in rtw89_fw_h2c_cxdrv_role_v2()
4252 struct rtw89_btc_wl_active_role_v2 *active = role_info->active_role_v2; in rtw89_fw_h2c_cxdrv_role_v2()
4259 len = H2C_LEN_CXDRVINFO_ROLE_SIZE_V2(ver->max_role_num); in rtw89_fw_h2c_cxdrv_role_v2()
4264 return -ENOMEM; in rtw89_fw_h2c_cxdrv_role_v2()
4267 cmd = skb->data; in rtw89_fw_h2c_cxdrv_role_v2()
4270 RTW89_SET_FWCMD_CXHDR_LEN(cmd, len - H2C_LEN_CXDRVHDR); in rtw89_fw_h2c_cxdrv_role_v2()
4272 RTW89_SET_FWCMD_CXROLE_CONNECT_CNT(cmd, role_info->connect_cnt); in rtw89_fw_h2c_cxdrv_role_v2()
4273 RTW89_SET_FWCMD_CXROLE_LINK_MODE(cmd, role_info->link_mode); in rtw89_fw_h2c_cxdrv_role_v2()
4275 RTW89_SET_FWCMD_CXROLE_ROLE_NONE(cmd, bpos->none); in rtw89_fw_h2c_cxdrv_role_v2()
4276 RTW89_SET_FWCMD_CXROLE_ROLE_STA(cmd, bpos->station); in rtw89_fw_h2c_cxdrv_role_v2()
4277 RTW89_SET_FWCMD_CXROLE_ROLE_AP(cmd, bpos->ap); in rtw89_fw_h2c_cxdrv_role_v2()
4278 RTW89_SET_FWCMD_CXROLE_ROLE_VAP(cmd, bpos->vap); in rtw89_fw_h2c_cxdrv_role_v2()
4279 RTW89_SET_FWCMD_CXROLE_ROLE_ADHOC(cmd, bpos->adhoc); in rtw89_fw_h2c_cxdrv_role_v2()
4280 RTW89_SET_FWCMD_CXROLE_ROLE_ADHOC_MASTER(cmd, bpos->adhoc_master); in rtw89_fw_h2c_cxdrv_role_v2()
4281 RTW89_SET_FWCMD_CXROLE_ROLE_MESH(cmd, bpos->mesh); in rtw89_fw_h2c_cxdrv_role_v2()
4282 RTW89_SET_FWCMD_CXROLE_ROLE_MONITOR(cmd, bpos->moniter); in rtw89_fw_h2c_cxdrv_role_v2()
4283 RTW89_SET_FWCMD_CXROLE_ROLE_P2P_DEV(cmd, bpos->p2p_device); in rtw89_fw_h2c_cxdrv_role_v2()
4284 RTW89_SET_FWCMD_CXROLE_ROLE_P2P_GC(cmd, bpos->p2p_gc); in rtw89_fw_h2c_cxdrv_role_v2()
4285 RTW89_SET_FWCMD_CXROLE_ROLE_P2P_GO(cmd, bpos->p2p_go); in rtw89_fw_h2c_cxdrv_role_v2()
4286 RTW89_SET_FWCMD_CXROLE_ROLE_NAN(cmd, bpos->nan); in rtw89_fw_h2c_cxdrv_role_v2()
4290 RTW89_SET_FWCMD_CXROLE_ACT_CONNECTED_V2(cmd, active->connected, i, offset); in rtw89_fw_h2c_cxdrv_role_v2()
4291 RTW89_SET_FWCMD_CXROLE_ACT_PID_V2(cmd, active->pid, i, offset); in rtw89_fw_h2c_cxdrv_role_v2()
4292 RTW89_SET_FWCMD_CXROLE_ACT_PHY_V2(cmd, active->phy, i, offset); in rtw89_fw_h2c_cxdrv_role_v2()
4293 RTW89_SET_FWCMD_CXROLE_ACT_NOA_V2(cmd, active->noa, i, offset); in rtw89_fw_h2c_cxdrv_role_v2()
4294 RTW89_SET_FWCMD_CXROLE_ACT_BAND_V2(cmd, active->band, i, offset); in rtw89_fw_h2c_cxdrv_role_v2()
4295 RTW89_SET_FWCMD_CXROLE_ACT_CLIENT_PS_V2(cmd, active->client_ps, i, offset); in rtw89_fw_h2c_cxdrv_role_v2()
4296 RTW89_SET_FWCMD_CXROLE_ACT_BW_V2(cmd, active->bw, i, offset); in rtw89_fw_h2c_cxdrv_role_v2()
4297 RTW89_SET_FWCMD_CXROLE_ACT_ROLE_V2(cmd, active->role, i, offset); in rtw89_fw_h2c_cxdrv_role_v2()
4298 RTW89_SET_FWCMD_CXROLE_ACT_CH_V2(cmd, active->ch, i, offset); in rtw89_fw_h2c_cxdrv_role_v2()
4299 RTW89_SET_FWCMD_CXROLE_ACT_NOA_DUR_V2(cmd, active->noa_duration, i, offset); in rtw89_fw_h2c_cxdrv_role_v2()
4302 offset = len - H2C_LEN_CXDRVINFO_ROLE_DBCC_LEN; in rtw89_fw_h2c_cxdrv_role_v2()
4303 RTW89_SET_FWCMD_CXROLE_MROLE_TYPE(cmd, role_info->mrole_type, offset); in rtw89_fw_h2c_cxdrv_role_v2()
4304 RTW89_SET_FWCMD_CXROLE_MROLE_NOA(cmd, role_info->mrole_noa_duration, offset); in rtw89_fw_h2c_cxdrv_role_v2()
4305 RTW89_SET_FWCMD_CXROLE_DBCC_EN(cmd, role_info->dbcc_en, offset); in rtw89_fw_h2c_cxdrv_role_v2()
4306 RTW89_SET_FWCMD_CXROLE_DBCC_CHG(cmd, role_info->dbcc_chg, offset); in rtw89_fw_h2c_cxdrv_role_v2()
4307 RTW89_SET_FWCMD_CXROLE_DBCC_2G_PHY(cmd, role_info->dbcc_2g_phy, offset); in rtw89_fw_h2c_cxdrv_role_v2()
4308 RTW89_SET_FWCMD_CXROLE_LINK_MODE_CHG(cmd, role_info->link_mode_chg, offset); in rtw89_fw_h2c_cxdrv_role_v2()
4330 struct rtw89_btc *btc = &rtwdev->btc; in rtw89_fw_h2c_cxdrv_role_v7()
4331 struct rtw89_btc_wl_role_info_v7 *role = &btc->cx.wl.role_info_v7; in rtw89_fw_h2c_cxdrv_role_v7()
4340 return -ENOMEM; in rtw89_fw_h2c_cxdrv_role_v7()
4343 h2c = (struct rtw89_h2c_cxrole_v7 *)skb->data; in rtw89_fw_h2c_cxdrv_role_v7()
4345 h2c->hdr.type = type; in rtw89_fw_h2c_cxdrv_role_v7()
4346 h2c->hdr.ver = btc->ver->fwlrole; in rtw89_fw_h2c_cxdrv_role_v7()
4347 h2c->hdr.len = len - H2C_LEN_CXDRVHDR_V7; in rtw89_fw_h2c_cxdrv_role_v7()
4348 memcpy(&h2c->_u8, role, sizeof(h2c->_u8)); in rtw89_fw_h2c_cxdrv_role_v7()
4349 h2c->_u32.role_map = cpu_to_le32(role->role_map); in rtw89_fw_h2c_cxdrv_role_v7()
4350 h2c->_u32.mrole_type = cpu_to_le32(role->mrole_type); in rtw89_fw_h2c_cxdrv_role_v7()
4351 h2c->_u32.mrole_noa_duration = cpu_to_le32(role->mrole_noa_duration); in rtw89_fw_h2c_cxdrv_role_v7()
4352 h2c->_u32.dbcc_en = cpu_to_le32(role->dbcc_en); in rtw89_fw_h2c_cxdrv_role_v7()
4353 h2c->_u32.dbcc_chg = cpu_to_le32(role->dbcc_chg); in rtw89_fw_h2c_cxdrv_role_v7()
4354 h2c->_u32.dbcc_2g_phy = cpu_to_le32(role->dbcc_2g_phy); in rtw89_fw_h2c_cxdrv_role_v7()
4376 struct rtw89_btc *btc = &rtwdev->btc; in rtw89_fw_h2c_cxdrv_role_v8()
4377 struct rtw89_btc_wl_role_info_v8 *role = &btc->cx.wl.role_info_v8; in rtw89_fw_h2c_cxdrv_role_v8()
4386 return -ENOMEM; in rtw89_fw_h2c_cxdrv_role_v8()
4389 h2c = (struct rtw89_h2c_cxrole_v8 *)skb->data; in rtw89_fw_h2c_cxdrv_role_v8()
4391 h2c->hdr.type = type; in rtw89_fw_h2c_cxdrv_role_v8()
4392 h2c->hdr.ver = btc->ver->fwlrole; in rtw89_fw_h2c_cxdrv_role_v8()
4393 h2c->hdr.len = len - H2C_LEN_CXDRVHDR_V7; in rtw89_fw_h2c_cxdrv_role_v8()
4394 memcpy(&h2c->_u8, role, sizeof(h2c->_u8)); in rtw89_fw_h2c_cxdrv_role_v8()
4395 h2c->_u32.role_map = cpu_to_le32(role->role_map); in rtw89_fw_h2c_cxdrv_role_v8()
4396 h2c->_u32.mrole_type = cpu_to_le32(role->mrole_type); in rtw89_fw_h2c_cxdrv_role_v8()
4397 h2c->_u32.mrole_noa_duration = cpu_to_le32(role->mrole_noa_duration); in rtw89_fw_h2c_cxdrv_role_v8()
4420 struct rtw89_btc *btc = &rtwdev->btc; in rtw89_fw_h2c_cxdrv_ctrl()
4421 const struct rtw89_btc_ver *ver = btc->ver; in rtw89_fw_h2c_cxdrv_ctrl()
4422 struct rtw89_btc_ctrl *ctrl = &btc->ctrl.ctrl; in rtw89_fw_h2c_cxdrv_ctrl()
4430 return -ENOMEM; in rtw89_fw_h2c_cxdrv_ctrl()
4433 cmd = skb->data; in rtw89_fw_h2c_cxdrv_ctrl()
4436 RTW89_SET_FWCMD_CXHDR_LEN(cmd, H2C_LEN_CXDRVINFO_CTRL - H2C_LEN_CXDRVHDR); in rtw89_fw_h2c_cxdrv_ctrl()
4438 RTW89_SET_FWCMD_CXCTRL_MANUAL(cmd, ctrl->manual); in rtw89_fw_h2c_cxdrv_ctrl()
4439 RTW89_SET_FWCMD_CXCTRL_IGNORE_BT(cmd, ctrl->igno_bt); in rtw89_fw_h2c_cxdrv_ctrl()
4440 RTW89_SET_FWCMD_CXCTRL_ALWAYS_FREERUN(cmd, ctrl->always_freerun); in rtw89_fw_h2c_cxdrv_ctrl()
4441 if (ver->fcxctrl == 0) in rtw89_fw_h2c_cxdrv_ctrl()
4442 RTW89_SET_FWCMD_CXCTRL_TRACE_STEP(cmd, ctrl->trace_step); in rtw89_fw_h2c_cxdrv_ctrl()
4464 struct rtw89_btc *btc = &rtwdev->btc; in rtw89_fw_h2c_cxdrv_ctrl_v7()
4465 struct rtw89_btc_ctrl_v7 *ctrl = &btc->ctrl.ctrl_v7; in rtw89_fw_h2c_cxdrv_ctrl_v7()
4474 return -ENOMEM; in rtw89_fw_h2c_cxdrv_ctrl_v7()
4477 h2c = (struct rtw89_h2c_cxctrl_v7 *)skb->data; in rtw89_fw_h2c_cxdrv_ctrl_v7()
4479 h2c->hdr.type = type; in rtw89_fw_h2c_cxdrv_ctrl_v7()
4480 h2c->hdr.ver = btc->ver->fcxctrl; in rtw89_fw_h2c_cxdrv_ctrl_v7()
4481 h2c->hdr.len = sizeof(*h2c) - H2C_LEN_CXDRVHDR_V7; in rtw89_fw_h2c_cxdrv_ctrl_v7()
4482 h2c->ctrl = *ctrl; in rtw89_fw_h2c_cxdrv_ctrl_v7()
4504 struct rtw89_btc *btc = &rtwdev->btc; in rtw89_fw_h2c_cxdrv_trx()
4505 struct rtw89_btc_trx_info *trx = &btc->dm.trx_info; in rtw89_fw_h2c_cxdrv_trx()
4513 return -ENOMEM; in rtw89_fw_h2c_cxdrv_trx()
4516 cmd = skb->data; in rtw89_fw_h2c_cxdrv_trx()
4519 RTW89_SET_FWCMD_CXHDR_LEN(cmd, H2C_LEN_CXDRVINFO_TRX - H2C_LEN_CXDRVHDR); in rtw89_fw_h2c_cxdrv_trx()
4521 RTW89_SET_FWCMD_CXTRX_TXLV(cmd, trx->tx_lvl); in rtw89_fw_h2c_cxdrv_trx()
4522 RTW89_SET_FWCMD_CXTRX_RXLV(cmd, trx->rx_lvl); in rtw89_fw_h2c_cxdrv_trx()
4523 RTW89_SET_FWCMD_CXTRX_WLRSSI(cmd, trx->wl_rssi); in rtw89_fw_h2c_cxdrv_trx()
4524 RTW89_SET_FWCMD_CXTRX_BTRSSI(cmd, trx->bt_rssi); in rtw89_fw_h2c_cxdrv_trx()
4525 RTW89_SET_FWCMD_CXTRX_TXPWR(cmd, trx->tx_power); in rtw89_fw_h2c_cxdrv_trx()
4526 RTW89_SET_FWCMD_CXTRX_RXGAIN(cmd, trx->rx_gain); in rtw89_fw_h2c_cxdrv_trx()
4527 RTW89_SET_FWCMD_CXTRX_BTTXPWR(cmd, trx->bt_tx_power); in rtw89_fw_h2c_cxdrv_trx()
4528 RTW89_SET_FWCMD_CXTRX_BTRXGAIN(cmd, trx->bt_rx_gain); in rtw89_fw_h2c_cxdrv_trx()
4529 RTW89_SET_FWCMD_CXTRX_CN(cmd, trx->cn); in rtw89_fw_h2c_cxdrv_trx()
4530 RTW89_SET_FWCMD_CXTRX_NHM(cmd, trx->nhm); in rtw89_fw_h2c_cxdrv_trx()
4531 RTW89_SET_FWCMD_CXTRX_BTPROFILE(cmd, trx->bt_profile); in rtw89_fw_h2c_cxdrv_trx()
4532 RTW89_SET_FWCMD_CXTRX_RSVD2(cmd, trx->rsvd2); in rtw89_fw_h2c_cxdrv_trx()
4533 RTW89_SET_FWCMD_CXTRX_TXRATE(cmd, trx->tx_rate); in rtw89_fw_h2c_cxdrv_trx()
4534 RTW89_SET_FWCMD_CXTRX_RXRATE(cmd, trx->rx_rate); in rtw89_fw_h2c_cxdrv_trx()
4535 RTW89_SET_FWCMD_CXTRX_TXTP(cmd, trx->tx_tp); in rtw89_fw_h2c_cxdrv_trx()
4536 RTW89_SET_FWCMD_CXTRX_RXTP(cmd, trx->rx_tp); in rtw89_fw_h2c_cxdrv_trx()
4537 RTW89_SET_FWCMD_CXTRX_RXERRRA(cmd, trx->rx_err_ratio); in rtw89_fw_h2c_cxdrv_trx()
4560 struct rtw89_btc *btc = &rtwdev->btc; in rtw89_fw_h2c_cxdrv_rfk()
4561 struct rtw89_btc_wl_info *wl = &btc->cx.wl; in rtw89_fw_h2c_cxdrv_rfk()
4562 struct rtw89_btc_wl_rfk_info *rfk_info = &wl->rfk_info; in rtw89_fw_h2c_cxdrv_rfk()
4570 return -ENOMEM; in rtw89_fw_h2c_cxdrv_rfk()
4573 cmd = skb->data; in rtw89_fw_h2c_cxdrv_rfk()
4576 RTW89_SET_FWCMD_CXHDR_LEN(cmd, H2C_LEN_CXDRVINFO_RFK - H2C_LEN_CXDRVHDR); in rtw89_fw_h2c_cxdrv_rfk()
4578 RTW89_SET_FWCMD_CXRFK_STATE(cmd, rfk_info->state); in rtw89_fw_h2c_cxdrv_rfk()
4579 RTW89_SET_FWCMD_CXRFK_PATH_MAP(cmd, rfk_info->path_map); in rtw89_fw_h2c_cxdrv_rfk()
4580 RTW89_SET_FWCMD_CXRFK_PHY_MAP(cmd, rfk_info->phy_map); in rtw89_fw_h2c_cxdrv_rfk()
4581 RTW89_SET_FWCMD_CXRFK_BAND(cmd, rfk_info->band); in rtw89_fw_h2c_cxdrv_rfk()
4582 RTW89_SET_FWCMD_CXRFK_TYPE(cmd, rfk_info->type); in rtw89_fw_h2c_cxdrv_rfk()
4605 struct rtw89_wait_info *wait = &rtwdev->mac.fw_ofld_wait; in rtw89_fw_h2c_del_pkt_offload()
4607 unsigned int cond; in rtw89_fw_h2c_del_pkt_offload() local
4614 return -ENOMEM; in rtw89_fw_h2c_del_pkt_offload()
4617 cmd = skb->data; in rtw89_fw_h2c_del_pkt_offload()
4627 cond = RTW89_FW_OFLD_WAIT_COND_PKT_OFLD(id, RTW89_PKT_OFLD_OP_DEL); in rtw89_fw_h2c_del_pkt_offload()
4629 ret = rtw89_h2c_tx_and_wait(rtwdev, skb, wait, cond); in rtw89_fw_h2c_del_pkt_offload()
4637 rtw89_core_release_bit_map(rtwdev->pkt_offload, id); in rtw89_fw_h2c_del_pkt_offload()
4644 struct rtw89_wait_info *wait = &rtwdev->mac.fw_ofld_wait; in rtw89_fw_h2c_add_pkt_offload()
4646 unsigned int cond; in rtw89_fw_h2c_add_pkt_offload() local
4651 alloc_id = rtw89_core_acquire_bit_map(rtwdev->pkt_offload, in rtw89_fw_h2c_add_pkt_offload()
4654 return -ENOSPC; in rtw89_fw_h2c_add_pkt_offload()
4658 skb = rtw89_fw_h2c_alloc_skb_with_hdr(rtwdev, H2C_LEN_PKT_OFLD + skb_ofld->len); in rtw89_fw_h2c_add_pkt_offload()
4661 rtw89_core_release_bit_map(rtwdev->pkt_offload, alloc_id); in rtw89_fw_h2c_add_pkt_offload()
4662 return -ENOMEM; in rtw89_fw_h2c_add_pkt_offload()
4665 cmd = skb->data; in rtw89_fw_h2c_add_pkt_offload()
4669 RTW89_SET_FWCMD_PACKET_OFLD_PKT_LENGTH(cmd, skb_ofld->len); in rtw89_fw_h2c_add_pkt_offload()
4670 skb_put_data(skb, skb_ofld->data, skb_ofld->len); in rtw89_fw_h2c_add_pkt_offload()
4675 H2C_LEN_PKT_OFLD + skb_ofld->len); in rtw89_fw_h2c_add_pkt_offload()
4677 cond = RTW89_FW_OFLD_WAIT_COND_PKT_OFLD(alloc_id, RTW89_PKT_OFLD_OP_ADD); in rtw89_fw_h2c_add_pkt_offload()
4679 ret = rtw89_h2c_tx_and_wait(rtwdev, skb, wait, cond); in rtw89_fw_h2c_add_pkt_offload()
4684 rtw89_core_release_bit_map(rtwdev->pkt_offload, alloc_id); in rtw89_fw_h2c_add_pkt_offload()
4694 struct rtw89_wait_info *wait = &rtwdev->mac.fw_ofld_wait; in rtw89_fw_h2c_scan_list_offload()
4699 unsigned int cond; in rtw89_fw_h2c_scan_list_offload() local
4709 return -ENOMEM; in rtw89_fw_h2c_scan_list_offload()
4712 h2c = (struct rtw89_h2c_chinfo *)skb->data; in rtw89_fw_h2c_scan_list_offload()
4714 h2c->ch_num = ch_num; in rtw89_fw_h2c_scan_list_offload()
4715 h2c->elem_size = sizeof(*elem) / 4; /* in unit of 4 bytes */ in rtw89_fw_h2c_scan_list_offload()
4720 elem->w0 = le32_encode_bits(ch_info->period, RTW89_H2C_CHINFO_W0_PERIOD) | in rtw89_fw_h2c_scan_list_offload()
4721 le32_encode_bits(ch_info->dwell_time, RTW89_H2C_CHINFO_W0_DWELL) | in rtw89_fw_h2c_scan_list_offload()
4722 le32_encode_bits(ch_info->central_ch, RTW89_H2C_CHINFO_W0_CENTER_CH) | in rtw89_fw_h2c_scan_list_offload()
4723 le32_encode_bits(ch_info->pri_ch, RTW89_H2C_CHINFO_W0_PRI_CH); in rtw89_fw_h2c_scan_list_offload()
4725 elem->w1 = le32_encode_bits(ch_info->bw, RTW89_H2C_CHINFO_W1_BW) | in rtw89_fw_h2c_scan_list_offload()
4726 le32_encode_bits(ch_info->notify_action, RTW89_H2C_CHINFO_W1_ACTION) | in rtw89_fw_h2c_scan_list_offload()
4727 le32_encode_bits(ch_info->num_pkt, RTW89_H2C_CHINFO_W1_NUM_PKT) | in rtw89_fw_h2c_scan_list_offload()
4728 le32_encode_bits(ch_info->tx_pkt, RTW89_H2C_CHINFO_W1_TX) | in rtw89_fw_h2c_scan_list_offload()
4729 le32_encode_bits(ch_info->pause_data, RTW89_H2C_CHINFO_W1_PAUSE_DATA) | in rtw89_fw_h2c_scan_list_offload()
4730 le32_encode_bits(ch_info->ch_band, RTW89_H2C_CHINFO_W1_BAND) | in rtw89_fw_h2c_scan_list_offload()
4731 le32_encode_bits(ch_info->probe_id, RTW89_H2C_CHINFO_W1_PKT_ID) | in rtw89_fw_h2c_scan_list_offload()
4732 le32_encode_bits(ch_info->dfs_ch, RTW89_H2C_CHINFO_W1_DFS) | in rtw89_fw_h2c_scan_list_offload()
4733 le32_encode_bits(ch_info->tx_null, RTW89_H2C_CHINFO_W1_TX_NULL) | in rtw89_fw_h2c_scan_list_offload()
4734 le32_encode_bits(ch_info->rand_seq_num, RTW89_H2C_CHINFO_W1_RANDOM); in rtw89_fw_h2c_scan_list_offload()
4736 elem->w2 = le32_encode_bits(ch_info->pkt_id[0], RTW89_H2C_CHINFO_W2_PKT0) | in rtw89_fw_h2c_scan_list_offload()
4737 le32_encode_bits(ch_info->pkt_id[1], RTW89_H2C_CHINFO_W2_PKT1) | in rtw89_fw_h2c_scan_list_offload()
4738 le32_encode_bits(ch_info->pkt_id[2], RTW89_H2C_CHINFO_W2_PKT2) | in rtw89_fw_h2c_scan_list_offload()
4739 le32_encode_bits(ch_info->pkt_id[3], RTW89_H2C_CHINFO_W2_PKT3); in rtw89_fw_h2c_scan_list_offload()
4741 elem->w3 = le32_encode_bits(ch_info->pkt_id[4], RTW89_H2C_CHINFO_W3_PKT4) | in rtw89_fw_h2c_scan_list_offload()
4742 le32_encode_bits(ch_info->pkt_id[5], RTW89_H2C_CHINFO_W3_PKT5) | in rtw89_fw_h2c_scan_list_offload()
4743 le32_encode_bits(ch_info->pkt_id[6], RTW89_H2C_CHINFO_W3_PKT6) | in rtw89_fw_h2c_scan_list_offload()
4744 le32_encode_bits(ch_info->pkt_id[7], RTW89_H2C_CHINFO_W3_PKT7); in rtw89_fw_h2c_scan_list_offload()
4751 cond = RTW89_SCANOFLD_WAIT_COND_ADD_CH; in rtw89_fw_h2c_scan_list_offload()
4753 ret = rtw89_h2c_tx_and_wait(rtwdev, skb, wait, cond); in rtw89_fw_h2c_scan_list_offload()
4765 struct rtw89_wait_info *wait = &rtwdev->mac.fw_ofld_wait; in rtw89_fw_h2c_scan_list_offload_be()
4770 unsigned int cond; in rtw89_fw_h2c_scan_list_offload_be() local
4780 return -ENOMEM; in rtw89_fw_h2c_scan_list_offload_be()
4784 h2c = (struct rtw89_h2c_chinfo *)skb->data; in rtw89_fw_h2c_scan_list_offload_be()
4786 h2c->ch_num = ch_num; in rtw89_fw_h2c_scan_list_offload_be()
4787 h2c->elem_size = sizeof(*elem) / 4; /* in unit of 4 bytes */ in rtw89_fw_h2c_scan_list_offload_be()
4788 h2c->arg = u8_encode_bits(RTW89_PHY_0, RTW89_H2C_CHINFO_ARG_MAC_IDX_MASK); in rtw89_fw_h2c_scan_list_offload_be()
4793 elem->w0 = le32_encode_bits(ch_info->period, RTW89_H2C_CHINFO_BE_W0_PERIOD) | in rtw89_fw_h2c_scan_list_offload_be()
4794 le32_encode_bits(ch_info->dwell_time, RTW89_H2C_CHINFO_BE_W0_DWELL) | in rtw89_fw_h2c_scan_list_offload_be()
4795 le32_encode_bits(ch_info->central_ch, in rtw89_fw_h2c_scan_list_offload_be()
4797 le32_encode_bits(ch_info->pri_ch, RTW89_H2C_CHINFO_BE_W0_PRI_CH); in rtw89_fw_h2c_scan_list_offload_be()
4799 elem->w1 = le32_encode_bits(ch_info->bw, RTW89_H2C_CHINFO_BE_W1_BW) | in rtw89_fw_h2c_scan_list_offload_be()
4800 le32_encode_bits(ch_info->ch_band, RTW89_H2C_CHINFO_BE_W1_CH_BAND) | in rtw89_fw_h2c_scan_list_offload_be()
4801 le32_encode_bits(ch_info->dfs_ch, RTW89_H2C_CHINFO_BE_W1_DFS) | in rtw89_fw_h2c_scan_list_offload_be()
4802 le32_encode_bits(ch_info->pause_data, in rtw89_fw_h2c_scan_list_offload_be()
4804 le32_encode_bits(ch_info->tx_null, RTW89_H2C_CHINFO_BE_W1_TX_NULL) | in rtw89_fw_h2c_scan_list_offload_be()
4805 le32_encode_bits(ch_info->rand_seq_num, in rtw89_fw_h2c_scan_list_offload_be()
4807 le32_encode_bits(ch_info->notify_action, in rtw89_fw_h2c_scan_list_offload_be()
4809 le32_encode_bits(ch_info->probe_id != 0xff ? 1 : 0, in rtw89_fw_h2c_scan_list_offload_be()
4811 le32_encode_bits(ch_info->leave_crit, in rtw89_fw_h2c_scan_list_offload_be()
4813 le32_encode_bits(ch_info->chkpt_timer, in rtw89_fw_h2c_scan_list_offload_be()
4816 elem->w2 = le32_encode_bits(ch_info->leave_time, in rtw89_fw_h2c_scan_list_offload_be()
4818 le32_encode_bits(ch_info->leave_th, in rtw89_fw_h2c_scan_list_offload_be()
4820 le32_encode_bits(ch_info->tx_pkt_ctrl, in rtw89_fw_h2c_scan_list_offload_be()
4823 elem->w3 = le32_encode_bits(ch_info->pkt_id[0], RTW89_H2C_CHINFO_BE_W3_PKT0) | in rtw89_fw_h2c_scan_list_offload_be()
4824 le32_encode_bits(ch_info->pkt_id[1], RTW89_H2C_CHINFO_BE_W3_PKT1) | in rtw89_fw_h2c_scan_list_offload_be()
4825 le32_encode_bits(ch_info->pkt_id[2], RTW89_H2C_CHINFO_BE_W3_PKT2) | in rtw89_fw_h2c_scan_list_offload_be()
4826 le32_encode_bits(ch_info->pkt_id[3], RTW89_H2C_CHINFO_BE_W3_PKT3); in rtw89_fw_h2c_scan_list_offload_be()
4828 elem->w4 = le32_encode_bits(ch_info->pkt_id[4], RTW89_H2C_CHINFO_BE_W4_PKT4) | in rtw89_fw_h2c_scan_list_offload_be()
4829 le32_encode_bits(ch_info->pkt_id[5], RTW89_H2C_CHINFO_BE_W4_PKT5) | in rtw89_fw_h2c_scan_list_offload_be()
4830 le32_encode_bits(ch_info->pkt_id[6], RTW89_H2C_CHINFO_BE_W4_PKT6) | in rtw89_fw_h2c_scan_list_offload_be()
4831 le32_encode_bits(ch_info->pkt_id[7], RTW89_H2C_CHINFO_BE_W4_PKT7); in rtw89_fw_h2c_scan_list_offload_be()
4833 elem->w5 = le32_encode_bits(ch_info->sw_def, RTW89_H2C_CHINFO_BE_W5_SW_DEF) | in rtw89_fw_h2c_scan_list_offload_be()
4834 le32_encode_bits(ch_info->fw_probe0_ssids, in rtw89_fw_h2c_scan_list_offload_be()
4837 elem->w6 = le32_encode_bits(ch_info->fw_probe0_shortssids, in rtw89_fw_h2c_scan_list_offload_be()
4839 le32_encode_bits(ch_info->fw_probe0_bssids, in rtw89_fw_h2c_scan_list_offload_be()
4847 cond = RTW89_SCANOFLD_WAIT_COND_ADD_CH; in rtw89_fw_h2c_scan_list_offload_be()
4849 ret = rtw89_h2c_tx_and_wait(rtwdev, skb, wait, cond); in rtw89_fw_h2c_scan_list_offload_be()
4864 struct rtw89_wait_info *wait = &rtwdev->mac.fw_ofld_wait; in rtw89_fw_h2c_scan_offload_ax()
4865 struct rtw89_chan *op = &rtwdev->scan_info.op_chan; in rtw89_fw_h2c_scan_offload_ax()
4870 unsigned int cond; in rtw89_fw_h2c_scan_offload_ax() local
4877 return -ENOMEM; in rtw89_fw_h2c_scan_offload_ax()
4880 h2c = (struct rtw89_h2c_scanofld *)skb->data; in rtw89_fw_h2c_scan_offload_ax()
4882 if (option->delay) { in rtw89_fw_h2c_scan_offload_ax()
4889 tsf += option->delay * RTW89_SCAN_DELAY_TSF_UNIT; in rtw89_fw_h2c_scan_offload_ax()
4893 h2c->w0 = le32_encode_bits(rtwvif->mac_id, RTW89_H2C_SCANOFLD_W0_MACID) | in rtw89_fw_h2c_scan_offload_ax()
4894 le32_encode_bits(rtwvif->port, RTW89_H2C_SCANOFLD_W0_PORT_ID) | in rtw89_fw_h2c_scan_offload_ax()
4896 le32_encode_bits(option->enable, RTW89_H2C_SCANOFLD_W0_OPERATION); in rtw89_fw_h2c_scan_offload_ax()
4898 h2c->w1 = le32_encode_bits(true, RTW89_H2C_SCANOFLD_W1_NOTIFY_END) | in rtw89_fw_h2c_scan_offload_ax()
4899 le32_encode_bits(option->target_ch_mode, in rtw89_fw_h2c_scan_offload_ax()
4902 le32_encode_bits(option->repeat, RTW89_H2C_SCANOFLD_W1_SCAN_TYPE); in rtw89_fw_h2c_scan_offload_ax()
4904 h2c->w2 = le32_encode_bits(option->norm_pd, RTW89_H2C_SCANOFLD_W2_NORM_PD) | in rtw89_fw_h2c_scan_offload_ax()
4905 le32_encode_bits(option->slow_pd, RTW89_H2C_SCANOFLD_W2_SLOW_PD); in rtw89_fw_h2c_scan_offload_ax()
4907 if (option->target_ch_mode) { in rtw89_fw_h2c_scan_offload_ax()
4908 h2c->w1 |= le32_encode_bits(op->band_width, in rtw89_fw_h2c_scan_offload_ax()
4910 le32_encode_bits(op->primary_channel, in rtw89_fw_h2c_scan_offload_ax()
4912 le32_encode_bits(op->channel, in rtw89_fw_h2c_scan_offload_ax()
4914 h2c->w0 |= le32_encode_bits(op->band_type, in rtw89_fw_h2c_scan_offload_ax()
4918 h2c->tsf_high = le32_encode_bits(upper_32_bits(tsf), in rtw89_fw_h2c_scan_offload_ax()
4920 h2c->tsf_low = le32_encode_bits(lower_32_bits(tsf), in rtw89_fw_h2c_scan_offload_ax()
4928 if (option->enable) in rtw89_fw_h2c_scan_offload_ax()
4929 cond = RTW89_SCANOFLD_WAIT_COND_START; in rtw89_fw_h2c_scan_offload_ax()
4931 cond = RTW89_SCANOFLD_WAIT_COND_STOP; in rtw89_fw_h2c_scan_offload_ax()
4933 ret = rtw89_h2c_tx_and_wait(rtwdev, skb, wait, cond); in rtw89_fw_h2c_scan_offload_ax()
4949 sband = rtwdev->hw->wiphy->bands[NL80211_BAND_6GHZ]; in rtw89_scan_get_6g_disabled_chan()
4951 option->prohib_chan = U64_MAX; in rtw89_scan_get_6g_disabled_chan()
4955 for (i = 0; i < sband->n_channels; i++) { in rtw89_scan_get_6g_disabled_chan()
4956 chan = &sband->channels[i]; in rtw89_scan_get_6g_disabled_chan()
4957 if (chan->flags & IEEE80211_CHAN_DISABLED) { in rtw89_scan_get_6g_disabled_chan()
4958 idx = (chan->hw_value - 1) / 4; in rtw89_scan_get_6g_disabled_chan()
4959 option->prohib_chan |= BIT(idx); in rtw89_scan_get_6g_disabled_chan()
4969 struct rtw89_hw_scan_info *scan_info = &rtwdev->scan_info; in rtw89_fw_h2c_scan_offload_be()
4970 struct rtw89_wait_info *wait = &rtwdev->mac.fw_ofld_wait; in rtw89_fw_h2c_scan_offload_be()
4971 struct cfg80211_scan_request *req = rtwvif->scan_req; in rtw89_fw_h2c_scan_offload_be()
4973 struct rtw89_chan *op = &scan_info->op_chan; in rtw89_fw_h2c_scan_offload_be()
4978 u8 macc_role_size = sizeof(*macc_role) * option->num_macc_role; in rtw89_fw_h2c_scan_offload_be()
4979 u8 opch_size = sizeof(*opch) * option->num_opch; in rtw89_fw_h2c_scan_offload_be()
4982 unsigned int cond; in rtw89_fw_h2c_scan_offload_be() local
4994 return -ENOMEM; in rtw89_fw_h2c_scan_offload_be()
4998 h2c = (struct rtw89_h2c_scanofld_be *)skb->data; in rtw89_fw_h2c_scan_offload_be()
4999 ptr = skb->data; in rtw89_fw_h2c_scan_offload_be()
5004 list_for_each_entry(pkt_info, &scan_info->pkt_list[NL80211_BAND_6GHZ], list) { in rtw89_fw_h2c_scan_offload_be()
5005 if (pkt_info->wildcard_6ghz) { in rtw89_fw_h2c_scan_offload_be()
5007 probe_id[NL80211_BAND_6GHZ] = pkt_info->id; in rtw89_fw_h2c_scan_offload_be()
5013 h2c->w0 = le32_encode_bits(option->operation, RTW89_H2C_SCANOFLD_BE_W0_OP) | in rtw89_fw_h2c_scan_offload_be()
5014 le32_encode_bits(option->scan_mode, in rtw89_fw_h2c_scan_offload_be()
5016 le32_encode_bits(option->repeat, RTW89_H2C_SCANOFLD_BE_W0_REPEAT) | in rtw89_fw_h2c_scan_offload_be()
5019 le32_encode_bits(rtwvif->mac_id, RTW89_H2C_SCANOFLD_BE_W0_MACID) | in rtw89_fw_h2c_scan_offload_be()
5020 le32_encode_bits(rtwvif->port, RTW89_H2C_SCANOFLD_BE_W0_PORT) | in rtw89_fw_h2c_scan_offload_be()
5021 le32_encode_bits(option->band, RTW89_H2C_SCANOFLD_BE_W0_BAND); in rtw89_fw_h2c_scan_offload_be()
5023 h2c->w1 = le32_encode_bits(option->num_macc_role, RTW89_H2C_SCANOFLD_BE_W1_NUM_MACC_ROLE) | in rtw89_fw_h2c_scan_offload_be()
5024 le32_encode_bits(option->num_opch, RTW89_H2C_SCANOFLD_BE_W1_NUM_OP) | in rtw89_fw_h2c_scan_offload_be()
5025 le32_encode_bits(option->norm_pd, RTW89_H2C_SCANOFLD_BE_W1_NORM_PD); in rtw89_fw_h2c_scan_offload_be()
5027 h2c->w2 = le32_encode_bits(option->slow_pd, RTW89_H2C_SCANOFLD_BE_W2_SLOW_PD) | in rtw89_fw_h2c_scan_offload_be()
5028 le32_encode_bits(option->norm_cy, RTW89_H2C_SCANOFLD_BE_W2_NORM_CY) | in rtw89_fw_h2c_scan_offload_be()
5029 le32_encode_bits(option->opch_end, RTW89_H2C_SCANOFLD_BE_W2_OPCH_END); in rtw89_fw_h2c_scan_offload_be()
5031 h2c->w3 = le32_encode_bits(0, RTW89_H2C_SCANOFLD_BE_W3_NUM_SSID) | in rtw89_fw_h2c_scan_offload_be()
5036 h2c->w4 = le32_encode_bits(probe_id[NL80211_BAND_5GHZ], in rtw89_fw_h2c_scan_offload_be()
5040 le32_encode_bits(option->delay, RTW89_H2C_SCANOFLD_BE_W4_DELAY_START); in rtw89_fw_h2c_scan_offload_be()
5042 h2c->w5 = le32_encode_bits(option->mlo_mode, RTW89_H2C_SCANOFLD_BE_W5_MLO_MODE); in rtw89_fw_h2c_scan_offload_be()
5044 h2c->w6 = le32_encode_bits(option->prohib_chan, in rtw89_fw_h2c_scan_offload_be()
5046 h2c->w7 = le32_encode_bits(option->prohib_chan >> 32, in rtw89_fw_h2c_scan_offload_be()
5048 if (!wowlan && req->no_cck) { in rtw89_fw_h2c_scan_offload_be()
5049 h2c->w0 |= le32_encode_bits(true, RTW89_H2C_SCANOFLD_BE_W0_PROBE_WITH_RATE); in rtw89_fw_h2c_scan_offload_be()
5050 h2c->w8 = le32_encode_bits(RTW89_HW_RATE_OFDM6, in rtw89_fw_h2c_scan_offload_be()
5058 if (RTW89_CHK_FW_FEATURE(SCAN_OFFLOAD_BE_V0, &rtwdev->fw)) { in rtw89_fw_h2c_scan_offload_be()
5063 h2c->w9 = le32_encode_bits(sizeof(*h2c) / sizeof(h2c->w0), in rtw89_fw_h2c_scan_offload_be()
5065 le32_encode_bits(sizeof(*macc_role) / sizeof(macc_role->w0), in rtw89_fw_h2c_scan_offload_be()
5067 le32_encode_bits(sizeof(*opch) / sizeof(opch->w0), in rtw89_fw_h2c_scan_offload_be()
5073 for (i = 0; i < option->num_macc_role; i++) { in rtw89_fw_h2c_scan_offload_be()
5075 macc_role->w0 = in rtw89_fw_h2c_scan_offload_be()
5083 for (i = 0; i < option->num_opch; i++) { in rtw89_fw_h2c_scan_offload_be()
5085 opch->w0 = le32_encode_bits(rtwvif->mac_id, in rtw89_fw_h2c_scan_offload_be()
5087 le32_encode_bits(option->band, in rtw89_fw_h2c_scan_offload_be()
5089 le32_encode_bits(rtwvif->port, in rtw89_fw_h2c_scan_offload_be()
5098 opch->w1 = le32_encode_bits(RTW89_CHANNEL_TIME, in rtw89_fw_h2c_scan_offload_be()
5100 le32_encode_bits(op->band_type, in rtw89_fw_h2c_scan_offload_be()
5102 le32_encode_bits(op->band_width, in rtw89_fw_h2c_scan_offload_be()
5106 le32_encode_bits(op->primary_channel, in rtw89_fw_h2c_scan_offload_be()
5108 le32_encode_bits(op->channel, in rtw89_fw_h2c_scan_offload_be()
5111 opch->w2 = le32_encode_bits(0, in rtw89_fw_h2c_scan_offload_be()
5118 opch->w3 = le32_encode_bits(RTW89_SCANOFLD_PKT_NONE, in rtw89_fw_h2c_scan_offload_be()
5134 if (option->enable) in rtw89_fw_h2c_scan_offload_be()
5135 cond = RTW89_SCANOFLD_BE_WAIT_COND_START; in rtw89_fw_h2c_scan_offload_be()
5137 cond = RTW89_SCANOFLD_BE_WAIT_COND_STOP; in rtw89_fw_h2c_scan_offload_be()
5139 ret = rtw89_h2c_tx_and_wait(rtwdev, skb, wait, cond); in rtw89_fw_h2c_scan_offload_be()
5153 u8 class = info->rf_path == RF_PATH_A ? in rtw89_fw_h2c_rf_reg()
5160 return -ENOMEM; in rtw89_fw_h2c_rf_reg()
5162 skb_put_data(skb, info->rtw89_phy_config_rf_h2c[page], len); in rtw89_fw_h2c_rf_reg()
5183 struct rtw89_rfk_mcc_info *rfk_mcc = &rtwdev->rfk_mcc; in rtw89_fw_h2c_rf_ntfy_mcc()
5192 return -ENOMEM; in rtw89_fw_h2c_rf_ntfy_mcc()
5195 mccch = (struct rtw89_fw_h2c_rf_get_mccch *)skb->data; in rtw89_fw_h2c_rf_ntfy_mcc()
5197 idx = rfk_mcc->table_idx; in rtw89_fw_h2c_rf_ntfy_mcc()
5198 mccch->ch_0 = cpu_to_le32(rfk_mcc->ch[0]); in rtw89_fw_h2c_rf_ntfy_mcc()
5199 mccch->ch_1 = cpu_to_le32(rfk_mcc->ch[1]); in rtw89_fw_h2c_rf_ntfy_mcc()
5200 mccch->band_0 = cpu_to_le32(rfk_mcc->band[0]); in rtw89_fw_h2c_rf_ntfy_mcc()
5201 mccch->band_1 = cpu_to_le32(rfk_mcc->band[1]); in rtw89_fw_h2c_rf_ntfy_mcc()
5202 mccch->current_channel = cpu_to_le32(rfk_mcc->ch[idx]); in rtw89_fw_h2c_rf_ntfy_mcc()
5203 mccch->current_band_type = cpu_to_le32(rfk_mcc->band[idx]); in rtw89_fw_h2c_rf_ntfy_mcc()
5227 struct rtw89_rfk_mcc_info *rfk_mcc = &rtwdev->rfk_mcc; in rtw89_fw_h2c_rf_pre_ntfy()
5230 u8 tbl_sel = rfk_mcc->table_idx; in rtw89_fw_h2c_rf_pre_ntfy()
5238 if (RTW89_CHK_FW_FEATURE(RFK_PRE_NOTIFY_V0, &rtwdev->fw)) { in rtw89_fw_h2c_rf_pre_ntfy()
5246 return -ENOMEM; in rtw89_fw_h2c_rf_pre_ntfy()
5249 h2c = (struct rtw89_fw_h2c_rfk_pre_info *)skb->data; in rtw89_fw_h2c_rf_pre_ntfy()
5251 h2c->common.mlo_mode = cpu_to_le32(rtwdev->mlo_dbcc_mode); in rtw89_fw_h2c_rf_pre_ntfy()
5257 h2c->common.dbcc.ch[path][tbl] = in rtw89_fw_h2c_rf_pre_ntfy()
5258 cpu_to_le32(rfk_mcc->ch[tbl]); in rtw89_fw_h2c_rf_pre_ntfy()
5259 h2c->common.dbcc.band[path][tbl] = in rtw89_fw_h2c_rf_pre_ntfy()
5260 cpu_to_le32(rfk_mcc->band[tbl]); in rtw89_fw_h2c_rf_pre_ntfy()
5265 h2c->common.tbl.cur_ch[path] = cpu_to_le32(rfk_mcc->ch[tbl_sel]); in rtw89_fw_h2c_rf_pre_ntfy()
5266 h2c->common.tbl.cur_band[path] = cpu_to_le32(rfk_mcc->band[tbl_sel]); in rtw89_fw_h2c_rf_pre_ntfy()
5269 h2c->common.phy_idx = cpu_to_le32(phy_idx); in rtw89_fw_h2c_rf_pre_ntfy()
5272 h2c_v0 = (struct rtw89_fw_h2c_rfk_pre_info_v0 *)skb->data; in rtw89_fw_h2c_rf_pre_ntfy()
5274 h2c_v0->cur_band = cpu_to_le32(rfk_mcc->band[tbl_sel]); in rtw89_fw_h2c_rf_pre_ntfy()
5275 h2c_v0->cur_bw = cpu_to_le32(rfk_mcc->bw[tbl_sel]); in rtw89_fw_h2c_rf_pre_ntfy()
5276 h2c_v0->cur_center_ch = cpu_to_le32(rfk_mcc->ch[tbl_sel]); in rtw89_fw_h2c_rf_pre_ntfy()
5279 h2c_v0->ktbl_sel0 = cpu_to_le32(val32); in rtw89_fw_h2c_rf_pre_ntfy()
5281 h2c_v0->ktbl_sel1 = cpu_to_le32(val32); in rtw89_fw_h2c_rf_pre_ntfy()
5283 h2c_v0->rfmod0 = cpu_to_le32(val32); in rtw89_fw_h2c_rf_pre_ntfy()
5285 h2c_v0->rfmod1 = cpu_to_le32(val32); in rtw89_fw_h2c_rf_pre_ntfy()
5288 h2c_v0->mlo_1_1 = cpu_to_le32(1); in rtw89_fw_h2c_rf_pre_ntfy()
5290 h2c_v0->rfe_type = cpu_to_le32(rtwdev->efuse.rfe_type); in rtw89_fw_h2c_rf_pre_ntfy()
5296 h2c->mlo_1_1 = cpu_to_le32(1); in rtw89_fw_h2c_rf_pre_ntfy()
5319 struct rtw89_hal *hal = &rtwdev->hal; in rtw89_fw_h2c_rf_tssi()
5328 return -ENOMEM; in rtw89_fw_h2c_rf_tssi()
5331 h2c = (struct rtw89_h2c_rf_tssi *)skb->data; in rtw89_fw_h2c_rf_tssi()
5333 h2c->len = cpu_to_le16(len); in rtw89_fw_h2c_rf_tssi()
5334 h2c->phy = phy_idx; in rtw89_fw_h2c_rf_tssi()
5335 h2c->ch = chan->channel; in rtw89_fw_h2c_rf_tssi()
5336 h2c->bw = chan->band_width; in rtw89_fw_h2c_rf_tssi()
5337 h2c->band = chan->band_type; in rtw89_fw_h2c_rf_tssi()
5338 h2c->hwtx_en = true; in rtw89_fw_h2c_rf_tssi()
5339 h2c->cv = hal->cv; in rtw89_fw_h2c_rf_tssi()
5340 h2c->tssi_mode = tssi_mode; in rtw89_fw_h2c_rf_tssi()
5373 return -ENOMEM; in rtw89_fw_h2c_rf_iqk()
5376 h2c = (struct rtw89_h2c_rf_iqk *)skb->data; in rtw89_fw_h2c_rf_iqk()
5378 h2c->phy_idx = cpu_to_le32(phy_idx); in rtw89_fw_h2c_rf_iqk()
5379 h2c->dbcc = cpu_to_le32(rtwdev->dbcc_en); in rtw89_fw_h2c_rf_iqk()
5409 return -ENOMEM; in rtw89_fw_h2c_rf_dpk()
5412 h2c = (struct rtw89_h2c_rf_dpk *)skb->data; in rtw89_fw_h2c_rf_dpk()
5414 h2c->len = len; in rtw89_fw_h2c_rf_dpk()
5415 h2c->phy = phy_idx; in rtw89_fw_h2c_rf_dpk()
5416 h2c->dpk_enable = true; in rtw89_fw_h2c_rf_dpk()
5417 h2c->kpath = RF_AB; in rtw89_fw_h2c_rf_dpk()
5418 h2c->cur_band = chan->band_type; in rtw89_fw_h2c_rf_dpk()
5419 h2c->cur_bw = chan->band_width; in rtw89_fw_h2c_rf_dpk()
5420 h2c->cur_ch = chan->channel; in rtw89_fw_h2c_rf_dpk()
5421 h2c->dpk_dbg_en = rtw89_debug_is_enabled(rtwdev, RTW89_DBG_RFK); in rtw89_fw_h2c_rf_dpk()
5443 struct rtw89_hal *hal = &rtwdev->hal; in rtw89_fw_h2c_rf_txgapk()
5452 return -ENOMEM; in rtw89_fw_h2c_rf_txgapk()
5455 h2c = (struct rtw89_h2c_rf_txgapk *)skb->data; in rtw89_fw_h2c_rf_txgapk()
5457 h2c->len = len; in rtw89_fw_h2c_rf_txgapk()
5458 h2c->ktype = 2; in rtw89_fw_h2c_rf_txgapk()
5459 h2c->phy = phy_idx; in rtw89_fw_h2c_rf_txgapk()
5460 h2c->kpath = RF_AB; in rtw89_fw_h2c_rf_txgapk()
5461 h2c->band = chan->band_type; in rtw89_fw_h2c_rf_txgapk()
5462 h2c->bw = chan->band_width; in rtw89_fw_h2c_rf_txgapk()
5463 h2c->ch = chan->channel; in rtw89_fw_h2c_rf_txgapk()
5464 h2c->cv = hal->cv; in rtw89_fw_h2c_rf_txgapk()
5494 return -ENOMEM; in rtw89_fw_h2c_rf_dack()
5497 h2c = (struct rtw89_h2c_rf_dack *)skb->data; in rtw89_fw_h2c_rf_dack()
5499 h2c->len = cpu_to_le32(len); in rtw89_fw_h2c_rf_dack()
5500 h2c->phy = cpu_to_le32(phy_idx); in rtw89_fw_h2c_rf_dack()
5501 h2c->type = cpu_to_le32(0); in rtw89_fw_h2c_rf_dack()
5531 return -ENOMEM; in rtw89_fw_h2c_rf_rxdck()
5534 h2c = (struct rtw89_h2c_rf_rxdck *)skb->data; in rtw89_fw_h2c_rf_rxdck()
5536 h2c->len = len; in rtw89_fw_h2c_rf_rxdck()
5537 h2c->phy = phy_idx; in rtw89_fw_h2c_rf_rxdck()
5538 h2c->is_afe = false; in rtw89_fw_h2c_rf_rxdck()
5539 h2c->kpath = RF_AB; in rtw89_fw_h2c_rf_rxdck()
5540 h2c->cur_band = chan->band_type; in rtw89_fw_h2c_rf_rxdck()
5541 h2c->cur_bw = chan->band_width; in rtw89_fw_h2c_rf_rxdck()
5542 h2c->cur_ch = chan->channel; in rtw89_fw_h2c_rf_rxdck()
5543 h2c->rxdck_dbg_en = rtw89_debug_is_enabled(rtwdev, RTW89_DBG_RFK); in rtw89_fw_h2c_rf_rxdck()
5572 return -ENOMEM; in rtw89_fw_h2c_raw_with_hdr()
5601 return -ENOMEM; in rtw89_fw_h2c_raw()
5622 lockdep_assert_held(&rtwdev->mutex); in rtw89_fw_send_all_early_h2c()
5624 list_for_each_entry(early_h2c, &rtwdev->early_h2c_list, list) { in rtw89_fw_send_all_early_h2c()
5625 rtw89_fw_h2c_raw(rtwdev, early_h2c->h2c, early_h2c->h2c_len); in rtw89_fw_send_all_early_h2c()
5633 mutex_lock(&rtwdev->mutex); in rtw89_fw_free_all_early_h2c()
5634 list_for_each_entry_safe(early_h2c, tmp, &rtwdev->early_h2c_list, list) { in rtw89_fw_free_all_early_h2c()
5635 list_del(&early_h2c->list); in rtw89_fw_free_all_early_h2c()
5636 kfree(early_h2c->h2c); in rtw89_fw_free_all_early_h2c()
5639 mutex_unlock(&rtwdev->mutex); in rtw89_fw_free_all_early_h2c()
5644 const struct rtw89_c2h_hdr *hdr = (const struct rtw89_c2h_hdr *)c2h->data; in rtw89_fw_c2h_parse_attr()
5647 attr->category = le32_get_bits(hdr->w0, RTW89_C2H_HDR_W0_CATEGORY); in rtw89_fw_c2h_parse_attr()
5648 attr->class = le32_get_bits(hdr->w0, RTW89_C2H_HDR_W0_CLASS); in rtw89_fw_c2h_parse_attr()
5649 attr->func = le32_get_bits(hdr->w0, RTW89_C2H_HDR_W0_FUNC); in rtw89_fw_c2h_parse_attr()
5650 attr->len = le32_get_bits(hdr->w1, RTW89_C2H_HDR_W1_LEN); in rtw89_fw_c2h_parse_attr()
5657 u8 category = attr->category; in rtw89_fw_c2h_chk_atomic()
5658 u8 class = attr->class; in rtw89_fw_c2h_chk_atomic()
5659 u8 func = attr->func; in rtw89_fw_c2h_chk_atomic()
5682 skb_queue_tail(&rtwdev->c2h_queue, c2h); in rtw89_fw_c2h_irqsafe()
5683 ieee80211_queue_work(rtwdev->hw, &rtwdev->c2h_work); in rtw89_fw_c2h_irqsafe()
5690 u8 category = attr->category; in rtw89_fw_c2h_cmd_handle()
5691 u8 class = attr->class; in rtw89_fw_c2h_cmd_handle()
5692 u8 func = attr->func; in rtw89_fw_c2h_cmd_handle()
5693 u16 len = attr->len; in rtw89_fw_c2h_cmd_handle()
5696 if (!test_bit(RTW89_FLAG_RUNNING, rtwdev->flags)) in rtw89_fw_c2h_cmd_handle()
5718 rtw89_hex_dump(rtwdev, RTW89_DBG_FW, "C2H: ", skb->data, skb->len); in rtw89_fw_c2h_cmd_handle()
5727 skb_queue_walk_safe(&rtwdev->c2h_queue, skb, tmp) { in rtw89_fw_c2h_work()
5728 skb_unlink(skb, &rtwdev->c2h_queue); in rtw89_fw_c2h_work()
5729 mutex_lock(&rtwdev->mutex); in rtw89_fw_c2h_work()
5731 mutex_unlock(&rtwdev->mutex); in rtw89_fw_c2h_work()
5739 const struct rtw89_chip_info *chip = rtwdev->chip; in rtw89_fw_write_h2c_reg()
5740 struct rtw89_fw_info *fw_info = &rtwdev->fw; in rtw89_fw_write_h2c_reg()
5741 const u32 *h2c_reg = chip->h2c_regs; in rtw89_fw_write_h2c_reg()
5746 rtwdev, chip->h2c_ctrl_reg); in rtw89_fw_write_h2c_reg()
5752 len = DIV_ROUND_UP(info->content_len + RTW89_H2CREG_HDR_LEN, in rtw89_fw_write_h2c_reg()
5753 sizeof(info->u.h2creg[0])); in rtw89_fw_write_h2c_reg()
5755 u32p_replace_bits(&info->u.hdr.w0, info->id, RTW89_H2CREG_HDR_FUNC_MASK); in rtw89_fw_write_h2c_reg()
5756 u32p_replace_bits(&info->u.hdr.w0, len, RTW89_H2CREG_HDR_LEN_MASK); in rtw89_fw_write_h2c_reg()
5759 rtw89_write32(rtwdev, h2c_reg[i], info->u.h2creg[i]); in rtw89_fw_write_h2c_reg()
5761 fw_info->h2c_counter++; in rtw89_fw_write_h2c_reg()
5762 rtw89_write8_mask(rtwdev, chip->h2c_counter_reg.addr, in rtw89_fw_write_h2c_reg()
5763 chip->h2c_counter_reg.mask, fw_info->h2c_counter); in rtw89_fw_write_h2c_reg()
5764 rtw89_write8(rtwdev, chip->h2c_ctrl_reg, B_AX_H2CREG_TRIGGER); in rtw89_fw_write_h2c_reg()
5772 const struct rtw89_chip_info *chip = rtwdev->chip; in rtw89_fw_read_c2h_reg()
5773 struct rtw89_fw_info *fw_info = &rtwdev->fw; in rtw89_fw_read_c2h_reg()
5774 const u32 *c2h_reg = chip->c2h_regs; in rtw89_fw_read_c2h_reg()
5778 info->id = RTW89_FWCMD_C2HREG_FUNC_NULL; in rtw89_fw_read_c2h_reg()
5782 chip->c2h_ctrl_reg); in rtw89_fw_read_c2h_reg()
5789 info->u.c2hreg[i] = rtw89_read32(rtwdev, c2h_reg[i]); in rtw89_fw_read_c2h_reg()
5791 rtw89_write8(rtwdev, chip->c2h_ctrl_reg, 0); in rtw89_fw_read_c2h_reg()
5793 info->id = u32_get_bits(info->u.hdr.w0, RTW89_C2HREG_HDR_FUNC_MASK); in rtw89_fw_read_c2h_reg()
5794 info->content_len = in rtw89_fw_read_c2h_reg()
5795 (u32_get_bits(info->u.hdr.w0, RTW89_C2HREG_HDR_LEN_MASK) << 2) - in rtw89_fw_read_c2h_reg()
5798 fw_info->c2h_counter++; in rtw89_fw_read_c2h_reg()
5799 rtw89_write8_mask(rtwdev, chip->c2h_counter_reg.addr, in rtw89_fw_read_c2h_reg()
5800 chip->c2h_counter_reg.mask, fw_info->c2h_counter); in rtw89_fw_read_c2h_reg()
5811 if (h2c_info && h2c_info->id != RTW89_FWCMD_H2CREG_FUNC_GET_FEATURE) in rtw89_fw_msg_reg()
5812 lockdep_assert_held(&rtwdev->mutex); in rtw89_fw_msg_reg()
5815 return -EINVAL; in rtw89_fw_msg_reg()
5837 if (!test_bit(RTW89_FLAG_POWERON, rtwdev->flags)) { in rtw89_fw_st_dbg_dump()
5856 struct list_head *pkt_list = rtwdev->scan_info.pkt_list; in rtw89_release_pkt_list()
5861 if (!(rtwdev->chip->support_bands & BIT(idx))) in rtw89_release_pkt_list()
5865 if (test_bit(info->id, rtwdev->pkt_offload)) in rtw89_release_pkt_list()
5866 rtw89_fw_h2c_del_pkt_offload(rtwdev, info->id); in rtw89_release_pkt_list()
5867 list_del(&info->list); in rtw89_release_pkt_list()
5878 struct cfg80211_scan_request *req = rtwvif->scan_req; in rtw89_is_6ghz_wildcard_probe_req()
5883 if (req->ssids[ssid_idx].ssid_len) { in rtw89_is_6ghz_wildcard_probe_req()
5884 memcpy(info->ssid, req->ssids[ssid_idx].ssid, in rtw89_is_6ghz_wildcard_probe_req()
5885 req->ssids[ssid_idx].ssid_len); in rtw89_is_6ghz_wildcard_probe_req()
5886 info->ssid_len = req->ssids[ssid_idx].ssid_len; in rtw89_is_6ghz_wildcard_probe_req()
5889 info->wildcard_6ghz = true; in rtw89_is_6ghz_wildcard_probe_req()
5898 struct rtw89_hw_scan_info *scan_info = &rtwdev->scan_info; in rtw89_append_probe_req_ie()
5899 struct ieee80211_scan_ies *ies = rtwvif->scan_ies; in rtw89_append_probe_req_ie()
5906 if (!(rtwdev->chip->support_bands & BIT(band))) in rtw89_append_probe_req_ie()
5911 ret = -ENOMEM; in rtw89_append_probe_req_ie()
5914 skb_put_data(new, ies->ies[band], ies->len[band]); in rtw89_append_probe_req_ie()
5915 skb_put_data(new, ies->common_ies, ies->common_ie_len); in rtw89_append_probe_req_ie()
5919 ret = -ENOMEM; in rtw89_append_probe_req_ie()
5927 ret = rtw89_fw_h2c_add_pkt_offload(rtwdev, &info->id, new); in rtw89_append_probe_req_ie()
5934 list_add_tail(&info->list, &scan_info->pkt_list[band]); in rtw89_append_probe_req_ie()
5944 struct cfg80211_scan_request *req = rtwvif->scan_req; in rtw89_hw_scan_update_probe_req()
5946 u8 num = req->n_ssids, i; in rtw89_hw_scan_update_probe_req()
5950 skb = ieee80211_probereq_get(rtwdev->hw, rtwvif->mac_addr, in rtw89_hw_scan_update_probe_req()
5951 req->ssids[i].ssid, in rtw89_hw_scan_update_probe_req()
5952 req->ssids[i].ssid_len, in rtw89_hw_scan_update_probe_req()
5953 req->ie_len); in rtw89_hw_scan_update_probe_req()
5955 return -ENOMEM; in rtw89_hw_scan_update_probe_req()
5971 struct ieee80211_vif *vif = rtwdev->scan_info.scanning_vif; in rtw89_update_6ghz_rnr_chan()
5972 struct list_head *pkt_list = rtwdev->scan_info.pkt_list; in rtw89_update_6ghz_rnr_chan()
5974 struct ieee80211_scan_ies *ies = rtwvif->scan_ies; in rtw89_update_6ghz_rnr_chan()
5983 if (!req->n_6ghz_params) in rtw89_update_6ghz_rnr_chan()
5986 for (i = 0; i < req->n_6ghz_params; i++) { in rtw89_update_6ghz_rnr_chan()
5987 params = &req->scan_6ghz_params[i]; in rtw89_update_6ghz_rnr_chan()
5989 if (req->channels[params->channel_idx]->hw_value != in rtw89_update_6ghz_rnr_chan()
5990 ch_info->pri_ch) in rtw89_update_6ghz_rnr_chan()
5995 if (ether_addr_equal(tmp->bssid, params->bssid)) { in rtw89_update_6ghz_rnr_chan()
6003 skb = ieee80211_probereq_get(rtwdev->hw, rtwvif->mac_addr, in rtw89_update_6ghz_rnr_chan()
6004 NULL, 0, req->ie_len); in rtw89_update_6ghz_rnr_chan()
6005 skb_put_data(skb, ies->ies[NL80211_BAND_6GHZ], ies->len[NL80211_BAND_6GHZ]); in rtw89_update_6ghz_rnr_chan()
6006 skb_put_data(skb, ies->common_ies, ies->common_ie_len); in rtw89_update_6ghz_rnr_chan()
6007 hdr = (struct ieee80211_hdr *)skb->data; in rtw89_update_6ghz_rnr_chan()
6008 ether_addr_copy(hdr->addr3, params->bssid); in rtw89_update_6ghz_rnr_chan()
6012 ret = -ENOMEM; in rtw89_update_6ghz_rnr_chan()
6017 ret = rtw89_fw_h2c_add_pkt_offload(rtwdev, &info->id, skb); in rtw89_update_6ghz_rnr_chan()
6024 ether_addr_copy(info->bssid, params->bssid); in rtw89_update_6ghz_rnr_chan()
6025 info->channel_6ghz = req->channels[params->channel_idx]->hw_value; in rtw89_update_6ghz_rnr_chan()
6026 list_add_tail(&info->list, &rtwdev->scan_info.pkt_list[NL80211_BAND_6GHZ]); in rtw89_update_6ghz_rnr_chan()
6028 ch_info->tx_pkt = true; in rtw89_update_6ghz_rnr_chan()
6029 ch_info->period = RTW89_CHANNEL_TIME_6G + RTW89_DWELL_TIME_6G; in rtw89_update_6ghz_rnr_chan()
6042 struct rtw89_wow_param *rtw_wow = &rtwdev->wow; in rtw89_pno_scan_add_chan_ax()
6046 ch_info->notify_action = RTW89_SCANOFLD_DEBUG_MASK; in rtw89_pno_scan_add_chan_ax()
6047 ch_info->dfs_ch = chan_type == RTW89_CHAN_DFS; in rtw89_pno_scan_add_chan_ax()
6048 ch_info->bw = RTW89_SCAN_WIDTH; in rtw89_pno_scan_add_chan_ax()
6049 ch_info->tx_pkt = true; in rtw89_pno_scan_add_chan_ax()
6050 ch_info->cfg_tx_pwr = false; in rtw89_pno_scan_add_chan_ax()
6051 ch_info->tx_pwr_idx = 0; in rtw89_pno_scan_add_chan_ax()
6052 ch_info->tx_null = false; in rtw89_pno_scan_add_chan_ax()
6053 ch_info->pause_data = false; in rtw89_pno_scan_add_chan_ax()
6054 ch_info->probe_id = RTW89_SCANOFLD_PKT_NONE; in rtw89_pno_scan_add_chan_ax()
6057 list_for_each_entry(info, &rtw_wow->pno_pkt_list, list) { in rtw89_pno_scan_add_chan_ax()
6058 if (info->channel_6ghz && in rtw89_pno_scan_add_chan_ax()
6059 ch_info->pri_ch != info->channel_6ghz) in rtw89_pno_scan_add_chan_ax()
6061 else if (info->channel_6ghz && probe_count != 0) in rtw89_pno_scan_add_chan_ax()
6062 ch_info->period += RTW89_CHANNEL_TIME_6G; in rtw89_pno_scan_add_chan_ax()
6064 if (info->wildcard_6ghz) in rtw89_pno_scan_add_chan_ax()
6067 ch_info->pkt_id[probe_count++] = info->id; in rtw89_pno_scan_add_chan_ax()
6071 ch_info->num_pkt = probe_count; in rtw89_pno_scan_add_chan_ax()
6076 if (ch_info->ch_band != RTW89_BAND_6G) in rtw89_pno_scan_add_chan_ax()
6077 ch_info->period = max_t(u8, ch_info->period, in rtw89_pno_scan_add_chan_ax()
6079 ch_info->dwell_time = RTW89_DWELL_TIME; in rtw89_pno_scan_add_chan_ax()
6092 struct rtw89_hw_scan_info *scan_info = &rtwdev->scan_info; in rtw89_hw_scan_add_chan()
6093 struct ieee80211_vif *vif = rtwdev->scan_info.scanning_vif; in rtw89_hw_scan_add_chan()
6094 struct rtw89_vif *rtwvif = (struct rtw89_vif *)vif->drv_priv; in rtw89_hw_scan_add_chan()
6095 struct cfg80211_scan_request *req = rtwvif->scan_req; in rtw89_hw_scan_add_chan()
6096 struct rtw89_chan *op = &rtwdev->scan_info.op_chan; in rtw89_hw_scan_add_chan()
6101 ch_info->notify_action = RTW89_SCANOFLD_DEBUG_MASK; in rtw89_hw_scan_add_chan()
6102 ch_info->dfs_ch = chan_type == RTW89_CHAN_DFS; in rtw89_hw_scan_add_chan()
6103 ch_info->bw = RTW89_SCAN_WIDTH; in rtw89_hw_scan_add_chan()
6104 ch_info->tx_pkt = true; in rtw89_hw_scan_add_chan()
6105 ch_info->cfg_tx_pwr = false; in rtw89_hw_scan_add_chan()
6106 ch_info->tx_pwr_idx = 0; in rtw89_hw_scan_add_chan()
6107 ch_info->tx_null = false; in rtw89_hw_scan_add_chan()
6108 ch_info->pause_data = false; in rtw89_hw_scan_add_chan()
6109 ch_info->probe_id = RTW89_SCANOFLD_PKT_NONE; in rtw89_hw_scan_add_chan()
6111 if (ch_info->ch_band == RTW89_BAND_6G) { in rtw89_hw_scan_add_chan()
6112 if ((ssid_num == 1 && req->ssids[0].ssid_len == 0) || in rtw89_hw_scan_add_chan()
6113 !ch_info->is_psc) { in rtw89_hw_scan_add_chan()
6114 ch_info->tx_pkt = false; in rtw89_hw_scan_add_chan()
6115 if (!req->duration_mandatory) in rtw89_hw_scan_add_chan()
6116 ch_info->period -= RTW89_DWELL_TIME_6G; in rtw89_hw_scan_add_chan()
6125 band = rtw89_hw_to_nl80211_band(ch_info->ch_band); in rtw89_hw_scan_add_chan()
6127 list_for_each_entry(info, &scan_info->pkt_list[band], list) { in rtw89_hw_scan_add_chan()
6128 if (info->channel_6ghz && in rtw89_hw_scan_add_chan()
6129 ch_info->pri_ch != info->channel_6ghz) in rtw89_hw_scan_add_chan()
6131 else if (info->channel_6ghz && probe_count != 0) in rtw89_hw_scan_add_chan()
6132 ch_info->period += RTW89_CHANNEL_TIME_6G; in rtw89_hw_scan_add_chan()
6134 if (info->wildcard_6ghz) in rtw89_hw_scan_add_chan()
6137 ch_info->pkt_id[probe_count++] = info->id; in rtw89_hw_scan_add_chan()
6141 ch_info->num_pkt = probe_count; in rtw89_hw_scan_add_chan()
6146 ch_info->central_ch = op->channel; in rtw89_hw_scan_add_chan()
6147 ch_info->pri_ch = op->primary_channel; in rtw89_hw_scan_add_chan()
6148 ch_info->ch_band = op->band_type; in rtw89_hw_scan_add_chan()
6149 ch_info->bw = op->band_width; in rtw89_hw_scan_add_chan()
6150 ch_info->tx_null = true; in rtw89_hw_scan_add_chan()
6151 ch_info->num_pkt = 0; in rtw89_hw_scan_add_chan()
6154 if (ch_info->ch_band != RTW89_BAND_6G) in rtw89_hw_scan_add_chan()
6155 ch_info->period = max_t(u8, ch_info->period, in rtw89_hw_scan_add_chan()
6157 ch_info->dwell_time = RTW89_DWELL_TIME; in rtw89_hw_scan_add_chan()
6170 struct rtw89_wow_param *rtw_wow = &rtwdev->wow; in rtw89_pno_scan_add_chan_be()
6174 ch_info->notify_action = RTW89_SCANOFLD_DEBUG_MASK; in rtw89_pno_scan_add_chan_be()
6175 ch_info->dfs_ch = chan_type == RTW89_CHAN_DFS; in rtw89_pno_scan_add_chan_be()
6176 ch_info->bw = RTW89_SCAN_WIDTH; in rtw89_pno_scan_add_chan_be()
6177 ch_info->tx_null = false; in rtw89_pno_scan_add_chan_be()
6178 ch_info->pause_data = false; in rtw89_pno_scan_add_chan_be()
6179 ch_info->probe_id = RTW89_SCANOFLD_PKT_NONE; in rtw89_pno_scan_add_chan_be()
6182 list_for_each_entry(info, &rtw_wow->pno_pkt_list, list) { in rtw89_pno_scan_add_chan_be()
6183 ch_info->pkt_id[probe_count++] = info->id; in rtw89_pno_scan_add_chan_be()
6190 ch_info->pkt_id[i] = RTW89_SCANOFLD_PKT_NONE; in rtw89_pno_scan_add_chan_be()
6194 ch_info->period = max_t(u8, ch_info->period, RTW89_DFS_CHAN_TIME); in rtw89_pno_scan_add_chan_be()
6195 ch_info->dwell_time = RTW89_DWELL_TIME; in rtw89_pno_scan_add_chan_be()
6209 struct rtw89_hw_scan_info *scan_info = &rtwdev->scan_info; in rtw89_hw_scan_add_chan_be()
6210 struct ieee80211_vif *vif = rtwdev->scan_info.scanning_vif; in rtw89_hw_scan_add_chan_be()
6211 struct rtw89_vif *rtwvif = (struct rtw89_vif *)vif->drv_priv; in rtw89_hw_scan_add_chan_be()
6212 struct cfg80211_scan_request *req = rtwvif->scan_req; in rtw89_hw_scan_add_chan_be()
6216 ch_info->notify_action = RTW89_SCANOFLD_DEBUG_MASK; in rtw89_hw_scan_add_chan_be()
6217 ch_info->dfs_ch = chan_type == RTW89_CHAN_DFS; in rtw89_hw_scan_add_chan_be()
6218 ch_info->bw = RTW89_SCAN_WIDTH; in rtw89_hw_scan_add_chan_be()
6219 ch_info->tx_null = false; in rtw89_hw_scan_add_chan_be()
6220 ch_info->pause_data = false; in rtw89_hw_scan_add_chan_be()
6221 ch_info->probe_id = RTW89_SCANOFLD_PKT_NONE; in rtw89_hw_scan_add_chan_be()
6224 band = rtw89_hw_to_nl80211_band(ch_info->ch_band); in rtw89_hw_scan_add_chan_be()
6226 list_for_each_entry(info, &scan_info->pkt_list[band], list) { in rtw89_hw_scan_add_chan_be()
6227 if (info->channel_6ghz && in rtw89_hw_scan_add_chan_be()
6228 ch_info->pri_ch != info->channel_6ghz) in rtw89_hw_scan_add_chan_be()
6231 if (info->wildcard_6ghz) in rtw89_hw_scan_add_chan_be()
6234 ch_info->pkt_id[probe_count++] = info->id; in rtw89_hw_scan_add_chan_be()
6240 if (ch_info->ch_band == RTW89_BAND_6G) { in rtw89_hw_scan_add_chan_be()
6241 if ((ssid_num == 1 && req->ssids[0].ssid_len == 0) || in rtw89_hw_scan_add_chan_be()
6242 !ch_info->is_psc) { in rtw89_hw_scan_add_chan_be()
6243 ch_info->probe_id = RTW89_SCANOFLD_PKT_NONE; in rtw89_hw_scan_add_chan_be()
6244 if (!req->duration_mandatory) in rtw89_hw_scan_add_chan_be()
6245 ch_info->period -= RTW89_DWELL_TIME_6G; in rtw89_hw_scan_add_chan_be()
6250 ch_info->pkt_id[i] = RTW89_SCANOFLD_PKT_NONE; in rtw89_hw_scan_add_chan_be()
6254 if (ch_info->ch_band != RTW89_BAND_6G) in rtw89_hw_scan_add_chan_be()
6255 ch_info->period = in rtw89_hw_scan_add_chan_be()
6256 max_t(u8, ch_info->period, RTW89_DFS_CHAN_TIME); in rtw89_hw_scan_add_chan_be()
6257 ch_info->dwell_time = RTW89_DWELL_TIME; in rtw89_hw_scan_add_chan_be()
6270 struct rtw89_wow_param *rtw_wow = &rtwdev->wow; in rtw89_pno_scan_add_chan_list_ax()
6271 struct cfg80211_sched_scan_request *nd_config = rtw_wow->nd_config; in rtw89_pno_scan_add_chan_list_ax()
6282 idx < nd_config->n_channels && list_len < RTW89_SCAN_LIST_LIMIT; in rtw89_pno_scan_add_chan_list_ax()
6284 channel = nd_config->channels[idx]; in rtw89_pno_scan_add_chan_list_ax()
6287 ret = -ENOMEM; in rtw89_pno_scan_add_chan_list_ax()
6291 ch_info->period = RTW89_CHANNEL_TIME; in rtw89_pno_scan_add_chan_list_ax()
6292 ch_info->ch_band = rtw89_nl80211_to_hw_band(channel->band); in rtw89_pno_scan_add_chan_list_ax()
6293 ch_info->central_ch = channel->hw_value; in rtw89_pno_scan_add_chan_list_ax()
6294 ch_info->pri_ch = channel->hw_value; in rtw89_pno_scan_add_chan_list_ax()
6295 ch_info->is_psc = cfg80211_channel_is_psc(channel); in rtw89_pno_scan_add_chan_list_ax()
6297 if (channel->flags & in rtw89_pno_scan_add_chan_list_ax()
6303 rtw89_pno_scan_add_chan_ax(rtwdev, type, nd_config->n_match_sets, ch_info); in rtw89_pno_scan_add_chan_list_ax()
6304 list_add_tail(&ch_info->list, &chan_list); in rtw89_pno_scan_add_chan_list_ax()
6310 list_del(&ch_info->list); in rtw89_pno_scan_add_chan_list_ax()
6320 struct cfg80211_scan_request *req = rtwvif->scan_req; in rtw89_hw_scan_add_chan_list_ax()
6324 bool random_seq = req->flags & NL80211_SCAN_FLAG_RANDOM_SN; in rtw89_hw_scan_add_chan_list_ax()
6331 for (idx = rtwdev->scan_info.last_chan_idx, list_len = 0; in rtw89_hw_scan_add_chan_list_ax()
6332 idx < req->n_channels && list_len < RTW89_SCAN_LIST_LIMIT; in rtw89_hw_scan_add_chan_list_ax()
6334 channel = req->channels[idx]; in rtw89_hw_scan_add_chan_list_ax()
6337 ret = -ENOMEM; in rtw89_hw_scan_add_chan_list_ax()
6341 if (req->duration) in rtw89_hw_scan_add_chan_list_ax()
6342 ch_info->period = req->duration; in rtw89_hw_scan_add_chan_list_ax()
6343 else if (channel->band == NL80211_BAND_6GHZ) in rtw89_hw_scan_add_chan_list_ax()
6344 ch_info->period = RTW89_CHANNEL_TIME_6G + in rtw89_hw_scan_add_chan_list_ax()
6347 ch_info->period = RTW89_CHANNEL_TIME; in rtw89_hw_scan_add_chan_list_ax()
6349 ch_info->ch_band = rtw89_nl80211_to_hw_band(channel->band); in rtw89_hw_scan_add_chan_list_ax()
6350 ch_info->central_ch = channel->hw_value; in rtw89_hw_scan_add_chan_list_ax()
6351 ch_info->pri_ch = channel->hw_value; in rtw89_hw_scan_add_chan_list_ax()
6352 ch_info->rand_seq_num = random_seq; in rtw89_hw_scan_add_chan_list_ax()
6353 ch_info->is_psc = cfg80211_channel_is_psc(channel); in rtw89_hw_scan_add_chan_list_ax()
6355 if (channel->flags & in rtw89_hw_scan_add_chan_list_ax()
6360 rtw89_hw_scan_add_chan(rtwdev, type, req->n_ssids, ch_info); in rtw89_hw_scan_add_chan_list_ax()
6363 off_chan_time + ch_info->period > RTW89_OFF_CHAN_TIME) { in rtw89_hw_scan_add_chan_list_ax()
6366 ret = -ENOMEM; in rtw89_hw_scan_add_chan_list_ax()
6372 tmp->period = req->duration_mandatory ? in rtw89_hw_scan_add_chan_list_ax()
6373 req->duration : RTW89_CHANNEL_TIME; in rtw89_hw_scan_add_chan_list_ax()
6375 list_add_tail(&tmp->list, &chan_list); in rtw89_hw_scan_add_chan_list_ax()
6379 list_add_tail(&ch_info->list, &chan_list); in rtw89_hw_scan_add_chan_list_ax()
6380 off_chan_time += ch_info->period; in rtw89_hw_scan_add_chan_list_ax()
6382 rtwdev->scan_info.last_chan_idx = idx; in rtw89_hw_scan_add_chan_list_ax()
6387 list_del(&ch_info->list); in rtw89_hw_scan_add_chan_list_ax()
6397 struct rtw89_wow_param *rtw_wow = &rtwdev->wow; in rtw89_pno_scan_add_chan_list_be()
6398 struct cfg80211_sched_scan_request *nd_config = rtw_wow->nd_config; in rtw89_pno_scan_add_chan_list_be()
6409 idx < nd_config->n_channels && list_len < RTW89_SCAN_LIST_LIMIT; in rtw89_pno_scan_add_chan_list_be()
6411 channel = nd_config->channels[idx]; in rtw89_pno_scan_add_chan_list_be()
6414 ret = -ENOMEM; in rtw89_pno_scan_add_chan_list_be()
6418 ch_info->period = RTW89_CHANNEL_TIME; in rtw89_pno_scan_add_chan_list_be()
6419 ch_info->ch_band = rtw89_nl80211_to_hw_band(channel->band); in rtw89_pno_scan_add_chan_list_be()
6420 ch_info->central_ch = channel->hw_value; in rtw89_pno_scan_add_chan_list_be()
6421 ch_info->pri_ch = channel->hw_value; in rtw89_pno_scan_add_chan_list_be()
6422 ch_info->is_psc = cfg80211_channel_is_psc(channel); in rtw89_pno_scan_add_chan_list_be()
6424 if (channel->flags & in rtw89_pno_scan_add_chan_list_be()
6431 nd_config->n_match_sets, ch_info); in rtw89_pno_scan_add_chan_list_be()
6432 list_add_tail(&ch_info->list, &chan_list); in rtw89_pno_scan_add_chan_list_be()
6439 list_del(&ch_info->list); in rtw89_pno_scan_add_chan_list_be()
6449 struct cfg80211_scan_request *req = rtwvif->scan_req; in rtw89_hw_scan_add_chan_list_be()
6458 random_seq = !!(req->flags & NL80211_SCAN_FLAG_RANDOM_SN); in rtw89_hw_scan_add_chan_list_be()
6461 for (idx = rtwdev->scan_info.last_chan_idx, list_len = 0; in rtw89_hw_scan_add_chan_list_be()
6462 idx < req->n_channels && list_len < RTW89_SCAN_LIST_LIMIT; in rtw89_hw_scan_add_chan_list_be()
6464 channel = req->channels[idx]; in rtw89_hw_scan_add_chan_list_be()
6467 ret = -ENOMEM; in rtw89_hw_scan_add_chan_list_be()
6471 if (req->duration) in rtw89_hw_scan_add_chan_list_be()
6472 ch_info->period = req->duration; in rtw89_hw_scan_add_chan_list_be()
6473 else if (channel->band == NL80211_BAND_6GHZ) in rtw89_hw_scan_add_chan_list_be()
6474 ch_info->period = RTW89_CHANNEL_TIME_6G + RTW89_DWELL_TIME_6G; in rtw89_hw_scan_add_chan_list_be()
6476 ch_info->period = RTW89_CHANNEL_TIME; in rtw89_hw_scan_add_chan_list_be()
6478 ch_info->ch_band = rtw89_nl80211_to_hw_band(channel->band); in rtw89_hw_scan_add_chan_list_be()
6479 ch_info->central_ch = channel->hw_value; in rtw89_hw_scan_add_chan_list_be()
6480 ch_info->pri_ch = channel->hw_value; in rtw89_hw_scan_add_chan_list_be()
6481 ch_info->rand_seq_num = random_seq; in rtw89_hw_scan_add_chan_list_be()
6482 ch_info->is_psc = cfg80211_channel_is_psc(channel); in rtw89_hw_scan_add_chan_list_be()
6484 if (channel->flags & (IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IR)) in rtw89_hw_scan_add_chan_list_be()
6488 rtw89_hw_scan_add_chan_be(rtwdev, type, req->n_ssids, ch_info); in rtw89_hw_scan_add_chan_list_be()
6490 list_add_tail(&ch_info->list, &chan_list); in rtw89_hw_scan_add_chan_list_be()
6493 rtwdev->scan_info.last_chan_idx = idx; in rtw89_hw_scan_add_chan_list_be()
6498 list_del(&ch_info->list); in rtw89_hw_scan_add_chan_list_be()
6508 const struct rtw89_mac_gen_def *mac = rtwdev->chip->mac_def; in rtw89_hw_scan_prehandle()
6516 ret = mac->add_chan_list(rtwdev, rtwvif, connected); in rtw89_hw_scan_prehandle()
6524 struct rtw89_vif *rtwvif = (struct rtw89_vif *)vif->drv_priv; in rtw89_hw_scan_start()
6525 const struct rtw89_mac_gen_def *mac = rtwdev->chip->mac_def; in rtw89_hw_scan_start()
6526 struct cfg80211_scan_request *req = &scan_req->req; in rtw89_hw_scan_start()
6527 u32 rx_fltr = rtwdev->hal.rx_fltr; in rtw89_hw_scan_start()
6530 rtw89_get_channel(rtwdev, rtwvif, &rtwdev->scan_info.op_chan); in rtw89_hw_scan_start()
6531 rtwdev->scan_info.scanning_vif = vif; in rtw89_hw_scan_start()
6532 rtwdev->scan_info.last_chan_idx = 0; in rtw89_hw_scan_start()
6533 rtwdev->scan_info.abort = false; in rtw89_hw_scan_start()
6534 rtwvif->scan_ies = &scan_req->ies; in rtw89_hw_scan_start()
6535 rtwvif->scan_req = req; in rtw89_hw_scan_start()
6536 ieee80211_stop_queues(rtwdev->hw); in rtw89_hw_scan_start()
6539 if (req->flags & NL80211_SCAN_FLAG_RANDOM_ADDR) in rtw89_hw_scan_start()
6540 get_random_mask_addr(mac_addr, req->mac_addr, in rtw89_hw_scan_start()
6541 req->mac_addr_mask); in rtw89_hw_scan_start()
6543 ether_addr_copy(mac_addr, vif->addr); in rtw89_hw_scan_start()
6550 rtw89_mac_reg_by_idx(rtwdev, mac->rx_fltr, RTW89_MAC_0), in rtw89_hw_scan_start()
6560 const struct rtw89_mac_gen_def *mac = rtwdev->chip->mac_def; in rtw89_hw_scan_complete()
6561 struct rtw89_hw_scan_info *scan_info = &rtwdev->scan_info; in rtw89_hw_scan_complete()
6571 rtw89_mac_reg_by_idx(rtwdev, mac->rx_fltr, RTW89_MAC_0), in rtw89_hw_scan_complete()
6573 rtwdev->hal.rx_fltr); in rtw89_hw_scan_complete()
6576 ieee80211_scan_completed(rtwdev->hw, &info); in rtw89_hw_scan_complete()
6577 ieee80211_wake_queues(rtwdev->hw); in rtw89_hw_scan_complete()
6582 rtwvif->scan_req = NULL; in rtw89_hw_scan_complete()
6583 rtwvif->scan_ies = NULL; in rtw89_hw_scan_complete()
6584 scan_info->last_chan_idx = 0; in rtw89_hw_scan_complete()
6585 scan_info->scanning_vif = NULL; in rtw89_hw_scan_complete()
6586 scan_info->abort = false; in rtw89_hw_scan_complete()
6593 struct rtw89_hw_scan_info *scan_info = &rtwdev->scan_info; in rtw89_hw_scan_abort()
6596 scan_info->abort = true; in rtw89_hw_scan_abort()
6616 if (!is_zero_ether_addr(rtwvif->bssid)) in rtw89_is_any_vif_connected_or_connecting()
6626 const struct rtw89_mac_gen_def *mac = rtwdev->chip->mac_def; in rtw89_hw_scan_offload()
6632 rtwvif = vif ? (struct rtw89_vif *)vif->drv_priv : NULL; in rtw89_hw_scan_offload()
6634 return -EINVAL; in rtw89_hw_scan_offload()
6645 if (rtwdev->chip->chip_gen == RTW89_CHIP_BE) { in rtw89_hw_scan_offload()
6650 opt.mlo_mode = rtwdev->mlo_dbcc_mode; in rtw89_hw_scan_offload()
6655 ret = mac->scan_offload(rtwdev, &opt, rtwvif, false); in rtw89_hw_scan_offload()
6671 return -ENOMEM; in rtw89_fw_h2c_trigger_cpu_exception()
6675 RTW89_SET_FWCMD_CPU_EXCEPTION_TYPE(skb->data, in rtw89_fw_h2c_trigger_cpu_exception()
6708 return -ENOMEM; in rtw89_fw_h2c_pkt_drop()
6711 switch (params->sel) { in rtw89_fw_h2c_pkt_drop()
6721 params->sel); in rtw89_fw_h2c_pkt_drop()
6726 RTW89_SET_FWCMD_PKT_DROP_SEL(skb->data, params->sel); in rtw89_fw_h2c_pkt_drop()
6727 RTW89_SET_FWCMD_PKT_DROP_MACID(skb->data, params->macid); in rtw89_fw_h2c_pkt_drop()
6728 RTW89_SET_FWCMD_PKT_DROP_BAND(skb->data, params->mac_band); in rtw89_fw_h2c_pkt_drop()
6729 RTW89_SET_FWCMD_PKT_DROP_PORT(skb->data, params->port); in rtw89_fw_h2c_pkt_drop()
6730 RTW89_SET_FWCMD_PKT_DROP_MBSSID(skb->data, params->mbssid); in rtw89_fw_h2c_pkt_drop()
6731 RTW89_SET_FWCMD_PKT_DROP_ROLE_A_INFO_TF_TRS(skb->data, params->tf_trs); in rtw89_fw_h2c_pkt_drop()
6732 RTW89_SET_FWCMD_PKT_DROP_MACID_BAND_SEL_0(skb->data, in rtw89_fw_h2c_pkt_drop()
6733 params->macid_band_sel[0]); in rtw89_fw_h2c_pkt_drop()
6734 RTW89_SET_FWCMD_PKT_DROP_MACID_BAND_SEL_1(skb->data, in rtw89_fw_h2c_pkt_drop()
6735 params->macid_band_sel[1]); in rtw89_fw_h2c_pkt_drop()
6736 RTW89_SET_FWCMD_PKT_DROP_MACID_BAND_SEL_2(skb->data, in rtw89_fw_h2c_pkt_drop()
6737 params->macid_band_sel[2]); in rtw89_fw_h2c_pkt_drop()
6738 RTW89_SET_FWCMD_PKT_DROP_MACID_BAND_SEL_3(skb->data, in rtw89_fw_h2c_pkt_drop()
6739 params->macid_band_sel[3]); in rtw89_fw_h2c_pkt_drop()
6773 return -EPERM; in rtw89_fw_h2c_keep_alive()
6779 return -ENOMEM; in rtw89_fw_h2c_keep_alive()
6784 RTW89_SET_KEEP_ALIVE_ENABLE(skb->data, enable); in rtw89_fw_h2c_keep_alive()
6785 RTW89_SET_KEEP_ALIVE_PKT_NULL_ID(skb->data, pkt_id); in rtw89_fw_h2c_keep_alive()
6786 RTW89_SET_KEEP_ALIVE_PERIOD(skb->data, 5); in rtw89_fw_h2c_keep_alive()
6787 RTW89_SET_KEEP_ALIVE_MACID(skb->data, rtwvif->mac_id); in rtw89_fw_h2c_keep_alive()
6829 return -ENOMEM; in rtw89_fw_h2c_arp_offload()
6833 h2c = (struct rtw89_h2c_arp_offload *)skb->data; in rtw89_fw_h2c_arp_offload()
6835 h2c->w0 = le32_encode_bits(enable, RTW89_H2C_ARP_OFFLOAD_W0_ENABLE) | in rtw89_fw_h2c_arp_offload()
6837 le32_encode_bits(rtwvif->mac_id, RTW89_H2C_ARP_OFFLOAD_W0_MACID) | in rtw89_fw_h2c_arp_offload()
6864 struct rtw89_wow_param *rtw_wow = &rtwdev->wow; in rtw89_fw_h2c_disconnect_detect()
6866 u8 macid = rtwvif->mac_id; in rtw89_fw_h2c_disconnect_detect()
6872 return -ENOMEM; in rtw89_fw_h2c_disconnect_detect()
6877 if (test_bit(RTW89_WOW_FLAG_EN_DISCONNECT, rtw_wow->flags)) { in rtw89_fw_h2c_disconnect_detect()
6878 RTW89_SET_DISCONNECT_DETECT_ENABLE(skb->data, enable); in rtw89_fw_h2c_disconnect_detect()
6879 RTW89_SET_DISCONNECT_DETECT_DISCONNECT(skb->data, !enable); in rtw89_fw_h2c_disconnect_detect()
6880 RTW89_SET_DISCONNECT_DETECT_MAC_ID(skb->data, macid); in rtw89_fw_h2c_disconnect_detect()
6881 RTW89_SET_DISCONNECT_DETECT_CHECK_PERIOD(skb->data, 100); in rtw89_fw_h2c_disconnect_detect()
6882 RTW89_SET_DISCONNECT_DETECT_TRY_PKT_COUNT(skb->data, 5); in rtw89_fw_h2c_disconnect_detect()
6908 struct rtw89_wow_param *rtw_wow = &rtwdev->wow; in rtw89_fw_h2c_cfg_pno()
6909 struct cfg80211_sched_scan_request *nd_config = rtw_wow->nd_config; in rtw89_fw_h2c_cfg_pno()
6918 return -ENOMEM; in rtw89_fw_h2c_cfg_pno()
6922 h2c = (struct rtw89_h2c_cfg_nlo *)skb->data; in rtw89_fw_h2c_cfg_pno()
6924 h2c->w0 = le32_encode_bits(enable, RTW89_H2C_NLO_W0_ENABLE) | in rtw89_fw_h2c_cfg_pno()
6926 le32_encode_bits(rtwvif->mac_id, RTW89_H2C_NLO_W0_MACID); in rtw89_fw_h2c_cfg_pno()
6929 h2c->nlo_cnt = nd_config->n_match_sets; in rtw89_fw_h2c_cfg_pno()
6930 for (i = 0 ; i < nd_config->n_match_sets; i++) { in rtw89_fw_h2c_cfg_pno()
6931 h2c->ssid_len[i] = nd_config->match_sets[i].ssid.ssid_len; in rtw89_fw_h2c_cfg_pno()
6932 memcpy(h2c->ssid[i], nd_config->match_sets[i].ssid.ssid, in rtw89_fw_h2c_cfg_pno()
6933 nd_config->match_sets[i].ssid.ssid_len); in rtw89_fw_h2c_cfg_pno()
6959 struct rtw89_wow_param *rtw_wow = &rtwdev->wow; in rtw89_fw_h2c_wow_global()
6961 u8 macid = rtwvif->mac_id; in rtw89_fw_h2c_wow_global()
6969 return -ENOMEM; in rtw89_fw_h2c_wow_global()
6973 h2c = (struct rtw89_h2c_wow_global *)skb->data; in rtw89_fw_h2c_wow_global()
6975 h2c->w0 = le32_encode_bits(enable, RTW89_H2C_WOW_GLOBAL_W0_ENABLE) | in rtw89_fw_h2c_wow_global()
6977 le32_encode_bits(rtw_wow->ptk_alg, in rtw89_fw_h2c_wow_global()
6979 le32_encode_bits(rtw_wow->gtk_alg, in rtw89_fw_h2c_wow_global()
6981 h2c->key_info = rtw_wow->key_info; in rtw89_fw_h2c_wow_global()
7008 struct rtw89_wow_param *rtw_wow = &rtwdev->wow; in rtw89_fw_h2c_wow_wakeup_ctrl()
7010 u8 macid = rtwvif->mac_id; in rtw89_fw_h2c_wow_wakeup_ctrl()
7016 return -ENOMEM; in rtw89_fw_h2c_wow_wakeup_ctrl()
7021 if (rtw_wow->pattern_cnt) in rtw89_fw_h2c_wow_wakeup_ctrl()
7022 RTW89_SET_WOW_WAKEUP_CTRL_PATTERN_MATCH_ENABLE(skb->data, enable); in rtw89_fw_h2c_wow_wakeup_ctrl()
7023 if (test_bit(RTW89_WOW_FLAG_EN_MAGIC_PKT, rtw_wow->flags)) in rtw89_fw_h2c_wow_wakeup_ctrl()
7024 RTW89_SET_WOW_WAKEUP_CTRL_MAGIC_ENABLE(skb->data, enable); in rtw89_fw_h2c_wow_wakeup_ctrl()
7025 if (test_bit(RTW89_WOW_FLAG_EN_DISCONNECT, rtw_wow->flags)) in rtw89_fw_h2c_wow_wakeup_ctrl()
7026 RTW89_SET_WOW_WAKEUP_CTRL_DEAUTH_ENABLE(skb->data, enable); in rtw89_fw_h2c_wow_wakeup_ctrl()
7028 RTW89_SET_WOW_WAKEUP_CTRL_MAC_ID(skb->data, macid); in rtw89_fw_h2c_wow_wakeup_ctrl()
7060 return -ENOMEM; in rtw89_fw_wow_cam_update()
7065 RTW89_SET_WOW_CAM_UPD_R_W(skb->data, cam_info->r_w); in rtw89_fw_wow_cam_update()
7066 RTW89_SET_WOW_CAM_UPD_IDX(skb->data, cam_info->idx); in rtw89_fw_wow_cam_update()
7067 if (cam_info->valid) { in rtw89_fw_wow_cam_update()
7068 RTW89_SET_WOW_CAM_UPD_WKFM1(skb->data, cam_info->mask[0]); in rtw89_fw_wow_cam_update()
7069 RTW89_SET_WOW_CAM_UPD_WKFM2(skb->data, cam_info->mask[1]); in rtw89_fw_wow_cam_update()
7070 RTW89_SET_WOW_CAM_UPD_WKFM3(skb->data, cam_info->mask[2]); in rtw89_fw_wow_cam_update()
7071 RTW89_SET_WOW_CAM_UPD_WKFM4(skb->data, cam_info->mask[3]); in rtw89_fw_wow_cam_update()
7072 RTW89_SET_WOW_CAM_UPD_CRC(skb->data, cam_info->crc); in rtw89_fw_wow_cam_update()
7073 RTW89_SET_WOW_CAM_UPD_NEGATIVE_PATTERN_MATCH(skb->data, in rtw89_fw_wow_cam_update()
7074 cam_info->negative_pattern_match); in rtw89_fw_wow_cam_update()
7075 RTW89_SET_WOW_CAM_UPD_SKIP_MAC_HDR(skb->data, in rtw89_fw_wow_cam_update()
7076 cam_info->skip_mac_hdr); in rtw89_fw_wow_cam_update()
7077 RTW89_SET_WOW_CAM_UPD_UC(skb->data, cam_info->uc); in rtw89_fw_wow_cam_update()
7078 RTW89_SET_WOW_CAM_UPD_MC(skb->data, cam_info->mc); in rtw89_fw_wow_cam_update()
7079 RTW89_SET_WOW_CAM_UPD_BC(skb->data, cam_info->bc); in rtw89_fw_wow_cam_update()
7081 RTW89_SET_WOW_CAM_UPD_VALID(skb->data, cam_info->valid); in rtw89_fw_wow_cam_update()
7106 struct rtw89_wow_param *rtw_wow = &rtwdev->wow; in rtw89_fw_h2c_wow_gtk_ofld()
7107 struct rtw89_wow_gtk_info *gtk_info = &rtw_wow->gtk_info; in rtw89_fw_h2c_wow_gtk_ofld()
7109 u8 macid = rtwvif->mac_id; in rtw89_fw_h2c_wow_gtk_ofld()
7116 if (!rtw_wow->gtk_alg) in rtw89_fw_h2c_wow_gtk_ofld()
7122 return -ENOMEM; in rtw89_fw_h2c_wow_gtk_ofld()
7126 h2c = (struct rtw89_h2c_wow_gtk_ofld *)skb->data; in rtw89_fw_h2c_wow_gtk_ofld()
7137 if (gtk_info->igtk_keyid) { in rtw89_fw_h2c_wow_gtk_ofld()
7146 h2c->w0 = le32_encode_bits(enable, RTW89_H2C_WOW_GTK_OFLD_W0_EN) | in rtw89_fw_h2c_wow_gtk_ofld()
7148 le32_encode_bits(gtk_info->igtk_keyid ? 1 : 0, in rtw89_fw_h2c_wow_gtk_ofld()
7152 h2c->w1 = le32_encode_bits(gtk_info->igtk_keyid ? pkt_id_sa_query : 0, in rtw89_fw_h2c_wow_gtk_ofld()
7154 le32_encode_bits(rtw_wow->akm, RTW89_H2C_WOW_GTK_OFLD_W1_ALGO_AKM_SUIT); in rtw89_fw_h2c_wow_gtk_ofld()
7155 h2c->gtk_info = rtw_wow->gtk_info; in rtw89_fw_h2c_wow_gtk_ofld()
7179 struct rtw89_wait_info *wait = &rtwdev->mac.ps_wait; in rtw89_fw_h2c_fwips()
7187 return -ENOMEM; in rtw89_fw_h2c_fwips()
7190 h2c = (struct rtw89_h2c_fwips *)skb->data; in rtw89_fw_h2c_fwips()
7192 h2c->w0 = le32_encode_bits(rtwvif->mac_id, RTW89_H2C_FW_IPS_W0_MACID) | in rtw89_fw_h2c_fwips()
7206 struct rtw89_wait_info *wait = &rtwdev->wow.wait; in rtw89_fw_h2c_wow_request_aoac()
7214 return -ENOMEM; in rtw89_fw_h2c_wow_request_aoac()
7237 struct rtw89_wait_info *wait, unsigned int cond) in rtw89_h2c_tx_and_wait() argument
7245 return -EBUSY; in rtw89_h2c_tx_and_wait()
7248 if (test_bit(RTW89_FLAG_SER_HANDLING, rtwdev->flags)) in rtw89_h2c_tx_and_wait()
7251 return rtw89_wait_for_cond(wait, cond); in rtw89_h2c_tx_and_wait()
7258 struct rtw89_wait_info *wait = &rtwdev->mcc.wait; in rtw89_fw_h2c_add_mcc()
7260 unsigned int cond; in rtw89_fw_h2c_add_mcc() local
7266 return -ENOMEM; in rtw89_fw_h2c_add_mcc()
7270 RTW89_SET_FWCMD_ADD_MCC_MACID(skb->data, p->macid); in rtw89_fw_h2c_add_mcc()
7271 RTW89_SET_FWCMD_ADD_MCC_CENTRAL_CH_SEG0(skb->data, p->central_ch_seg0); in rtw89_fw_h2c_add_mcc()
7272 RTW89_SET_FWCMD_ADD_MCC_CENTRAL_CH_SEG1(skb->data, p->central_ch_seg1); in rtw89_fw_h2c_add_mcc()
7273 RTW89_SET_FWCMD_ADD_MCC_PRIMARY_CH(skb->data, p->primary_ch); in rtw89_fw_h2c_add_mcc()
7274 RTW89_SET_FWCMD_ADD_MCC_BANDWIDTH(skb->data, p->bandwidth); in rtw89_fw_h2c_add_mcc()
7275 RTW89_SET_FWCMD_ADD_MCC_GROUP(skb->data, p->group); in rtw89_fw_h2c_add_mcc()
7276 RTW89_SET_FWCMD_ADD_MCC_C2H_RPT(skb->data, p->c2h_rpt); in rtw89_fw_h2c_add_mcc()
7277 RTW89_SET_FWCMD_ADD_MCC_DIS_TX_NULL(skb->data, p->dis_tx_null); in rtw89_fw_h2c_add_mcc()
7278 RTW89_SET_FWCMD_ADD_MCC_DIS_SW_RETRY(skb->data, p->dis_sw_retry); in rtw89_fw_h2c_add_mcc()
7279 RTW89_SET_FWCMD_ADD_MCC_IN_CURR_CH(skb->data, p->in_curr_ch); in rtw89_fw_h2c_add_mcc()
7280 RTW89_SET_FWCMD_ADD_MCC_SW_RETRY_COUNT(skb->data, p->sw_retry_count); in rtw89_fw_h2c_add_mcc()
7281 RTW89_SET_FWCMD_ADD_MCC_TX_NULL_EARLY(skb->data, p->tx_null_early); in rtw89_fw_h2c_add_mcc()
7282 RTW89_SET_FWCMD_ADD_MCC_BTC_IN_2G(skb->data, p->btc_in_2g); in rtw89_fw_h2c_add_mcc()
7283 RTW89_SET_FWCMD_ADD_MCC_PTA_EN(skb->data, p->pta_en); in rtw89_fw_h2c_add_mcc()
7284 RTW89_SET_FWCMD_ADD_MCC_RFK_BY_PASS(skb->data, p->rfk_by_pass); in rtw89_fw_h2c_add_mcc()
7285 RTW89_SET_FWCMD_ADD_MCC_CH_BAND_TYPE(skb->data, p->ch_band_type); in rtw89_fw_h2c_add_mcc()
7286 RTW89_SET_FWCMD_ADD_MCC_DURATION(skb->data, p->duration); in rtw89_fw_h2c_add_mcc()
7287 RTW89_SET_FWCMD_ADD_MCC_COURTESY_EN(skb->data, p->courtesy_en); in rtw89_fw_h2c_add_mcc()
7288 RTW89_SET_FWCMD_ADD_MCC_COURTESY_NUM(skb->data, p->courtesy_num); in rtw89_fw_h2c_add_mcc()
7289 RTW89_SET_FWCMD_ADD_MCC_COURTESY_TARGET(skb->data, p->courtesy_target); in rtw89_fw_h2c_add_mcc()
7297 cond = RTW89_MCC_WAIT_COND(p->group, H2C_FUNC_ADD_MCC); in rtw89_fw_h2c_add_mcc()
7298 return rtw89_h2c_tx_and_wait(rtwdev, skb, wait, cond); in rtw89_fw_h2c_add_mcc()
7305 struct rtw89_wait_info *wait = &rtwdev->mcc.wait; in rtw89_fw_h2c_start_mcc()
7307 unsigned int cond; in rtw89_fw_h2c_start_mcc() local
7313 return -ENOMEM; in rtw89_fw_h2c_start_mcc()
7317 RTW89_SET_FWCMD_START_MCC_GROUP(skb->data, p->group); in rtw89_fw_h2c_start_mcc()
7318 RTW89_SET_FWCMD_START_MCC_BTC_IN_GROUP(skb->data, p->btc_in_group); in rtw89_fw_h2c_start_mcc()
7319 RTW89_SET_FWCMD_START_MCC_OLD_GROUP_ACTION(skb->data, p->old_group_action); in rtw89_fw_h2c_start_mcc()
7320 RTW89_SET_FWCMD_START_MCC_OLD_GROUP(skb->data, p->old_group); in rtw89_fw_h2c_start_mcc()
7321 RTW89_SET_FWCMD_START_MCC_NOTIFY_CNT(skb->data, p->notify_cnt); in rtw89_fw_h2c_start_mcc()
7322 RTW89_SET_FWCMD_START_MCC_NOTIFY_RXDBG_EN(skb->data, p->notify_rxdbg_en); in rtw89_fw_h2c_start_mcc()
7323 RTW89_SET_FWCMD_START_MCC_MACID(skb->data, p->macid); in rtw89_fw_h2c_start_mcc()
7324 RTW89_SET_FWCMD_START_MCC_TSF_LOW(skb->data, p->tsf_low); in rtw89_fw_h2c_start_mcc()
7325 RTW89_SET_FWCMD_START_MCC_TSF_HIGH(skb->data, p->tsf_high); in rtw89_fw_h2c_start_mcc()
7333 cond = RTW89_MCC_WAIT_COND(p->group, H2C_FUNC_START_MCC); in rtw89_fw_h2c_start_mcc()
7334 return rtw89_h2c_tx_and_wait(rtwdev, skb, wait, cond); in rtw89_fw_h2c_start_mcc()
7341 struct rtw89_wait_info *wait = &rtwdev->mcc.wait; in rtw89_fw_h2c_stop_mcc()
7343 unsigned int cond; in rtw89_fw_h2c_stop_mcc() local
7349 return -ENOMEM; in rtw89_fw_h2c_stop_mcc()
7353 RTW89_SET_FWCMD_STOP_MCC_MACID(skb->data, macid); in rtw89_fw_h2c_stop_mcc()
7354 RTW89_SET_FWCMD_STOP_MCC_GROUP(skb->data, group); in rtw89_fw_h2c_stop_mcc()
7355 RTW89_SET_FWCMD_STOP_MCC_PREV_GROUPS(skb->data, prev_groups); in rtw89_fw_h2c_stop_mcc()
7363 cond = RTW89_MCC_WAIT_COND(group, H2C_FUNC_STOP_MCC); in rtw89_fw_h2c_stop_mcc()
7364 return rtw89_h2c_tx_and_wait(rtwdev, skb, wait, cond); in rtw89_fw_h2c_stop_mcc()
7371 struct rtw89_wait_info *wait = &rtwdev->mcc.wait; in rtw89_fw_h2c_del_mcc_group()
7373 unsigned int cond; in rtw89_fw_h2c_del_mcc_group() local
7379 return -ENOMEM; in rtw89_fw_h2c_del_mcc_group()
7383 RTW89_SET_FWCMD_DEL_MCC_GROUP_GROUP(skb->data, group); in rtw89_fw_h2c_del_mcc_group()
7384 RTW89_SET_FWCMD_DEL_MCC_GROUP_PREV_GROUPS(skb->data, prev_groups); in rtw89_fw_h2c_del_mcc_group()
7392 cond = RTW89_MCC_WAIT_COND(group, H2C_FUNC_DEL_MCC_GROUP); in rtw89_fw_h2c_del_mcc_group()
7393 return rtw89_h2c_tx_and_wait(rtwdev, skb, wait, cond); in rtw89_fw_h2c_del_mcc_group()
7399 struct rtw89_wait_info *wait = &rtwdev->mcc.wait; in rtw89_fw_h2c_reset_mcc_group()
7401 unsigned int cond; in rtw89_fw_h2c_reset_mcc_group() local
7407 return -ENOMEM; in rtw89_fw_h2c_reset_mcc_group()
7411 RTW89_SET_FWCMD_RESET_MCC_GROUP_GROUP(skb->data, group); in rtw89_fw_h2c_reset_mcc_group()
7419 cond = RTW89_MCC_WAIT_COND(group, H2C_FUNC_RESET_MCC_GROUP); in rtw89_fw_h2c_reset_mcc_group()
7420 return rtw89_h2c_tx_and_wait(rtwdev, skb, wait, cond); in rtw89_fw_h2c_reset_mcc_group()
7428 struct rtw89_wait_info *wait = &rtwdev->mcc.wait; in rtw89_fw_h2c_mcc_req_tsf()
7431 unsigned int cond; in rtw89_fw_h2c_mcc_req_tsf() local
7438 return -ENOMEM; in rtw89_fw_h2c_mcc_req_tsf()
7442 RTW89_SET_FWCMD_MCC_REQ_TSF_GROUP(skb->data, req->group); in rtw89_fw_h2c_mcc_req_tsf()
7443 RTW89_SET_FWCMD_MCC_REQ_TSF_MACID_X(skb->data, req->macid_x); in rtw89_fw_h2c_mcc_req_tsf()
7444 RTW89_SET_FWCMD_MCC_REQ_TSF_MACID_Y(skb->data, req->macid_y); in rtw89_fw_h2c_mcc_req_tsf()
7452 cond = RTW89_MCC_WAIT_COND(req->group, H2C_FUNC_MCC_REQ_TSF); in rtw89_fw_h2c_mcc_req_tsf()
7453 ret = rtw89_h2c_tx_and_wait(rtwdev, skb, wait, cond); in rtw89_fw_h2c_mcc_req_tsf()
7457 tmp = (struct rtw89_mac_mcc_tsf_rpt *)wait->data.buf; in rtw89_fw_h2c_mcc_req_tsf()
7467 struct rtw89_wait_info *wait = &rtwdev->mcc.wait; in rtw89_fw_h2c_mcc_macid_bitmap()
7469 unsigned int cond; in rtw89_fw_h2c_mcc_macid_bitmap() local
7480 return -ENOMEM; in rtw89_fw_h2c_mcc_macid_bitmap()
7484 RTW89_SET_FWCMD_MCC_MACID_BITMAP_GROUP(skb->data, group); in rtw89_fw_h2c_mcc_macid_bitmap()
7485 RTW89_SET_FWCMD_MCC_MACID_BITMAP_MACID(skb->data, macid); in rtw89_fw_h2c_mcc_macid_bitmap()
7486 RTW89_SET_FWCMD_MCC_MACID_BITMAP_BITMAP_LENGTH(skb->data, map_len); in rtw89_fw_h2c_mcc_macid_bitmap()
7487 RTW89_SET_FWCMD_MCC_MACID_BITMAP_BITMAP(skb->data, bitmap, map_len); in rtw89_fw_h2c_mcc_macid_bitmap()
7495 cond = RTW89_MCC_WAIT_COND(group, H2C_FUNC_MCC_MACID_BITMAP); in rtw89_fw_h2c_mcc_macid_bitmap()
7496 return rtw89_h2c_tx_and_wait(rtwdev, skb, wait, cond); in rtw89_fw_h2c_mcc_macid_bitmap()
7503 struct rtw89_wait_info *wait = &rtwdev->mcc.wait; in rtw89_fw_h2c_mcc_sync()
7505 unsigned int cond; in rtw89_fw_h2c_mcc_sync() local
7511 return -ENOMEM; in rtw89_fw_h2c_mcc_sync()
7515 RTW89_SET_FWCMD_MCC_SYNC_GROUP(skb->data, group); in rtw89_fw_h2c_mcc_sync()
7516 RTW89_SET_FWCMD_MCC_SYNC_MACID_SOURCE(skb->data, source); in rtw89_fw_h2c_mcc_sync()
7517 RTW89_SET_FWCMD_MCC_SYNC_MACID_TARGET(skb->data, target); in rtw89_fw_h2c_mcc_sync()
7518 RTW89_SET_FWCMD_MCC_SYNC_SYNC_OFFSET(skb->data, offset); in rtw89_fw_h2c_mcc_sync()
7526 cond = RTW89_MCC_WAIT_COND(group, H2C_FUNC_MCC_SYNC); in rtw89_fw_h2c_mcc_sync()
7527 return rtw89_h2c_tx_and_wait(rtwdev, skb, wait, cond); in rtw89_fw_h2c_mcc_sync()
7534 struct rtw89_wait_info *wait = &rtwdev->mcc.wait; in rtw89_fw_h2c_mcc_set_duration()
7536 unsigned int cond; in rtw89_fw_h2c_mcc_set_duration() local
7542 return -ENOMEM; in rtw89_fw_h2c_mcc_set_duration()
7546 RTW89_SET_FWCMD_MCC_SET_DURATION_GROUP(skb->data, p->group); in rtw89_fw_h2c_mcc_set_duration()
7547 RTW89_SET_FWCMD_MCC_SET_DURATION_BTC_IN_GROUP(skb->data, p->btc_in_group); in rtw89_fw_h2c_mcc_set_duration()
7548 RTW89_SET_FWCMD_MCC_SET_DURATION_START_MACID(skb->data, p->start_macid); in rtw89_fw_h2c_mcc_set_duration()
7549 RTW89_SET_FWCMD_MCC_SET_DURATION_MACID_X(skb->data, p->macid_x); in rtw89_fw_h2c_mcc_set_duration()
7550 RTW89_SET_FWCMD_MCC_SET_DURATION_MACID_Y(skb->data, p->macid_y); in rtw89_fw_h2c_mcc_set_duration()
7551 RTW89_SET_FWCMD_MCC_SET_DURATION_START_TSF_LOW(skb->data, in rtw89_fw_h2c_mcc_set_duration()
7552 p->start_tsf_low); in rtw89_fw_h2c_mcc_set_duration()
7553 RTW89_SET_FWCMD_MCC_SET_DURATION_START_TSF_HIGH(skb->data, in rtw89_fw_h2c_mcc_set_duration()
7554 p->start_tsf_high); in rtw89_fw_h2c_mcc_set_duration()
7555 RTW89_SET_FWCMD_MCC_SET_DURATION_DURATION_X(skb->data, p->duration_x); in rtw89_fw_h2c_mcc_set_duration()
7556 RTW89_SET_FWCMD_MCC_SET_DURATION_DURATION_Y(skb->data, p->duration_y); in rtw89_fw_h2c_mcc_set_duration()
7564 cond = RTW89_MCC_WAIT_COND(p->group, H2C_FUNC_MCC_SET_DURATION); in rtw89_fw_h2c_mcc_set_duration()
7565 return rtw89_h2c_tx_and_wait(rtwdev, skb, wait, cond); in rtw89_fw_h2c_mcc_set_duration()
7579 slot_h2c->w0 = le32_encode_bits(slot_arg->duration, in rtw89_fw_h2c_mrc_add_slot()
7581 le32_encode_bits(slot_arg->courtesy_en, in rtw89_fw_h2c_mrc_add_slot()
7583 le32_encode_bits(slot_arg->role_num, in rtw89_fw_h2c_mrc_add_slot()
7585 slot_h2c->w1 = le32_encode_bits(slot_arg->courtesy_period, in rtw89_fw_h2c_mrc_add_slot()
7587 le32_encode_bits(slot_arg->courtesy_target, in rtw89_fw_h2c_mrc_add_slot()
7590 for (i = 0; i < slot_arg->role_num; i++) { in rtw89_fw_h2c_mrc_add_slot()
7591 slot_h2c->roles[i].w0 = in rtw89_fw_h2c_mrc_add_slot()
7592 le32_encode_bits(slot_arg->roles[i].macid, in rtw89_fw_h2c_mrc_add_slot()
7594 le32_encode_bits(slot_arg->roles[i].role_type, in rtw89_fw_h2c_mrc_add_slot()
7596 le32_encode_bits(slot_arg->roles[i].is_master, in rtw89_fw_h2c_mrc_add_slot()
7598 le32_encode_bits(slot_arg->roles[i].en_tx_null, in rtw89_fw_h2c_mrc_add_slot()
7604 slot_h2c->roles[i].w1 = in rtw89_fw_h2c_mrc_add_slot()
7605 le32_encode_bits(slot_arg->roles[i].central_ch, in rtw89_fw_h2c_mrc_add_slot()
7607 le32_encode_bits(slot_arg->roles[i].primary_ch, in rtw89_fw_h2c_mrc_add_slot()
7609 le32_encode_bits(slot_arg->roles[i].bw, in rtw89_fw_h2c_mrc_add_slot()
7611 le32_encode_bits(slot_arg->roles[i].band, in rtw89_fw_h2c_mrc_add_slot()
7613 le32_encode_bits(slot_arg->roles[i].null_early, in rtw89_fw_h2c_mrc_add_slot()
7619 slot_h2c->roles[i].macid_main_bitmap = in rtw89_fw_h2c_mrc_add_slot()
7620 cpu_to_le32(slot_arg->roles[i].macid_main_bitmap); in rtw89_fw_h2c_mrc_add_slot()
7621 slot_h2c->roles[i].macid_paired_bitmap = in rtw89_fw_h2c_mrc_add_slot()
7622 cpu_to_le32(slot_arg->roles[i].macid_paired_bitmap); in rtw89_fw_h2c_mrc_add_slot()
7626 return struct_size(slot_h2c, roles, slot_arg->role_num); in rtw89_fw_h2c_mrc_add_slot()
7640 for (i = 0; i < arg->slot_num; i++) in rtw89_fw_h2c_mrc_add()
7641 len += rtw89_fw_h2c_mrc_add_slot(rtwdev, &arg->slots[i], NULL); in rtw89_fw_h2c_mrc_add()
7646 return -ENOMEM; in rtw89_fw_h2c_mrc_add()
7650 tmp = skb->data; in rtw89_fw_h2c_mrc_add()
7653 h2c_head->w0 = le32_encode_bits(arg->sch_idx, in rtw89_fw_h2c_mrc_add()
7655 le32_encode_bits(arg->sch_type, in rtw89_fw_h2c_mrc_add()
7657 le32_encode_bits(arg->slot_num, in rtw89_fw_h2c_mrc_add()
7659 le32_encode_bits(arg->btc_in_sch, in rtw89_fw_h2c_mrc_add()
7663 for (i = 0; i < arg->slot_num; i++) in rtw89_fw_h2c_mrc_add()
7664 tmp += rtw89_fw_h2c_mrc_add_slot(rtwdev, &arg->slots[i], tmp); in rtw89_fw_h2c_mrc_add()
7676 return -EBUSY; in rtw89_fw_h2c_mrc_add()
7685 struct rtw89_wait_info *wait = &rtwdev->mcc.wait; in rtw89_fw_h2c_mrc_start()
7689 unsigned int cond; in rtw89_fw_h2c_mrc_start() local
7694 return -ENOMEM; in rtw89_fw_h2c_mrc_start()
7698 h2c = (struct rtw89_h2c_mrc_start *)skb->data; in rtw89_fw_h2c_mrc_start()
7700 h2c->w0 = le32_encode_bits(arg->sch_idx, in rtw89_fw_h2c_mrc_start()
7702 le32_encode_bits(arg->old_sch_idx, in rtw89_fw_h2c_mrc_start()
7704 le32_encode_bits(arg->action, in rtw89_fw_h2c_mrc_start()
7707 h2c->start_tsf_high = cpu_to_le32(arg->start_tsf >> 32); in rtw89_fw_h2c_mrc_start()
7708 h2c->start_tsf_low = cpu_to_le32(arg->start_tsf); in rtw89_fw_h2c_mrc_start()
7716 cond = RTW89_MRC_WAIT_COND(arg->sch_idx, H2C_FUNC_START_MRC); in rtw89_fw_h2c_mrc_start()
7717 return rtw89_h2c_tx_and_wait(rtwdev, skb, wait, cond); in rtw89_fw_h2c_mrc_start()
7722 struct rtw89_wait_info *wait = &rtwdev->mcc.wait; in rtw89_fw_h2c_mrc_del()
7726 unsigned int cond; in rtw89_fw_h2c_mrc_del() local
7731 return -ENOMEM; in rtw89_fw_h2c_mrc_del()
7735 h2c = (struct rtw89_h2c_mrc_del *)skb->data; in rtw89_fw_h2c_mrc_del()
7737 h2c->w0 = le32_encode_bits(sch_idx, RTW89_H2C_MRC_DEL_W0_SCH_IDX) | in rtw89_fw_h2c_mrc_del()
7746 cond = RTW89_MRC_WAIT_COND(sch_idx, H2C_FUNC_DEL_MRC); in rtw89_fw_h2c_mrc_del()
7747 return rtw89_h2c_tx_and_wait(rtwdev, skb, wait, cond); in rtw89_fw_h2c_mrc_del()
7754 struct rtw89_wait_info *wait = &rtwdev->mcc.wait; in rtw89_fw_h2c_mrc_req_tsf()
7762 len = struct_size(h2c, infos, arg->num); in rtw89_fw_h2c_mrc_req_tsf()
7766 return -ENOMEM; in rtw89_fw_h2c_mrc_req_tsf()
7770 h2c = (struct rtw89_h2c_mrc_req_tsf *)skb->data; in rtw89_fw_h2c_mrc_req_tsf()
7772 h2c->req_tsf_num = arg->num; in rtw89_fw_h2c_mrc_req_tsf()
7773 for (i = 0; i < arg->num; i++) in rtw89_fw_h2c_mrc_req_tsf()
7774 h2c->infos[i] = in rtw89_fw_h2c_mrc_req_tsf()
7775 u8_encode_bits(arg->infos[i].band, in rtw89_fw_h2c_mrc_req_tsf()
7777 u8_encode_bits(arg->infos[i].port, in rtw89_fw_h2c_mrc_req_tsf()
7790 tmp = (struct rtw89_mac_mrc_tsf_rpt *)wait->data.buf; in rtw89_fw_h2c_mrc_req_tsf()
7807 return -ENOMEM; in rtw89_fw_h2c_mrc_upd_bitmap()
7811 h2c = (struct rtw89_h2c_mrc_upd_bitmap *)skb->data; in rtw89_fw_h2c_mrc_upd_bitmap()
7813 h2c->w0 = le32_encode_bits(arg->sch_idx, in rtw89_fw_h2c_mrc_upd_bitmap()
7815 le32_encode_bits(arg->action, in rtw89_fw_h2c_mrc_upd_bitmap()
7817 le32_encode_bits(arg->macid, in rtw89_fw_h2c_mrc_upd_bitmap()
7819 h2c->w1 = le32_encode_bits(arg->client_macid, in rtw89_fw_h2c_mrc_upd_bitmap()
7832 return -EBUSY; in rtw89_fw_h2c_mrc_upd_bitmap()
7849 return -ENOMEM; in rtw89_fw_h2c_mrc_sync()
7853 h2c = (struct rtw89_h2c_mrc_sync *)skb->data; in rtw89_fw_h2c_mrc_sync()
7855 h2c->w0 = le32_encode_bits(true, RTW89_H2C_MRC_SYNC_W0_SYNC_EN) | in rtw89_fw_h2c_mrc_sync()
7856 le32_encode_bits(arg->src.port, in rtw89_fw_h2c_mrc_sync()
7858 le32_encode_bits(arg->src.band, in rtw89_fw_h2c_mrc_sync()
7860 le32_encode_bits(arg->dest.port, in rtw89_fw_h2c_mrc_sync()
7862 le32_encode_bits(arg->dest.band, in rtw89_fw_h2c_mrc_sync()
7864 h2c->w1 = le32_encode_bits(arg->offset, RTW89_H2C_MRC_SYNC_W1_OFFSET); in rtw89_fw_h2c_mrc_sync()
7876 return -EBUSY; in rtw89_fw_h2c_mrc_sync()
7891 len = struct_size(h2c, slots, arg->slot_num); in rtw89_fw_h2c_mrc_upd_duration()
7895 return -ENOMEM; in rtw89_fw_h2c_mrc_upd_duration()
7899 h2c = (struct rtw89_h2c_mrc_upd_duration *)skb->data; in rtw89_fw_h2c_mrc_upd_duration()
7901 h2c->w0 = le32_encode_bits(arg->sch_idx, in rtw89_fw_h2c_mrc_upd_duration()
7903 le32_encode_bits(arg->slot_num, in rtw89_fw_h2c_mrc_upd_duration()
7908 h2c->start_tsf_high = cpu_to_le32(arg->start_tsf >> 32); in rtw89_fw_h2c_mrc_upd_duration()
7909 h2c->start_tsf_low = cpu_to_le32(arg->start_tsf); in rtw89_fw_h2c_mrc_upd_duration()
7911 for (i = 0; i < arg->slot_num; i++) { in rtw89_fw_h2c_mrc_upd_duration()
7912 h2c->slots[i] = in rtw89_fw_h2c_mrc_upd_duration()
7913 le32_encode_bits(arg->slots[i].slot_idx, in rtw89_fw_h2c_mrc_upd_duration()
7915 le32_encode_bits(arg->slots[i].duration, in rtw89_fw_h2c_mrc_upd_duration()
7929 return -EBUSY; in rtw89_fw_h2c_mrc_upd_duration()
7950 (ent_sz) - __var_sz);\
7959 if (!__fw_txpwr_entry_acceptable(e, cursor, conf->ent_sz)) in fw_txpwr_byrate_entry_valid()
7962 if (e->band >= RTW89_BAND_NUM || e->bw >= RTW89_BYR_BW_NUM) in fw_txpwr_byrate_entry_valid()
7965 switch (e->rs) { in fw_txpwr_byrate_entry_valid()
7967 if (e->shf + e->len > RTW89_RATE_CCK_NUM) in fw_txpwr_byrate_entry_valid()
7971 if (e->shf + e->len > RTW89_RATE_OFDM_NUM) in fw_txpwr_byrate_entry_valid()
7975 if (e->shf + e->len > __RTW89_RATE_MCS_NUM || in fw_txpwr_byrate_entry_valid()
7976 e->nss >= RTW89_NSS_NUM || in fw_txpwr_byrate_entry_valid()
7977 e->ofdma >= RTW89_OFDMA_NUM) in fw_txpwr_byrate_entry_valid()
7981 if (e->shf + e->len > RTW89_RATE_HEDCM_NUM || in fw_txpwr_byrate_entry_valid()
7982 e->nss >= RTW89_NSS_HEDCM_NUM || in fw_txpwr_byrate_entry_valid()
7983 e->ofdma >= RTW89_OFDMA_NUM) in fw_txpwr_byrate_entry_valid()
7987 if (e->shf + e->len > __RTW89_RATE_OFFSET_NUM) in fw_txpwr_byrate_entry_valid()
8001 const struct rtw89_txpwr_conf *conf = tbl->data; in rtw89_fw_load_txpwr_byrate()
8014 byr_head = &rtwdev->byr[entry.band][entry.bw]; in rtw89_fw_load_txpwr_byrate()
8033 if (!__fw_txpwr_entry_acceptable(e, cursor, conf->ent_sz)) in fw_txpwr_lmt_2ghz_entry_valid()
8036 if (e->bw >= RTW89_2G_BW_NUM) in fw_txpwr_lmt_2ghz_entry_valid()
8038 if (e->nt >= RTW89_NTX_NUM) in fw_txpwr_lmt_2ghz_entry_valid()
8040 if (e->rs >= RTW89_RS_LMT_NUM) in fw_txpwr_lmt_2ghz_entry_valid()
8042 if (e->bf >= RTW89_BF_NUM) in fw_txpwr_lmt_2ghz_entry_valid()
8044 if (e->regd >= RTW89_REGD_NUM) in fw_txpwr_lmt_2ghz_entry_valid()
8046 if (e->ch_idx >= RTW89_2G_CH_NUM) in fw_txpwr_lmt_2ghz_entry_valid()
8055 const struct rtw89_txpwr_conf *conf = &data->conf; in rtw89_fw_load_txpwr_lmt_2ghz()
8063 data->v[entry.bw][entry.nt][entry.rs][entry.bf][entry.regd] in rtw89_fw_load_txpwr_lmt_2ghz()
8073 if (!__fw_txpwr_entry_acceptable(e, cursor, conf->ent_sz)) in fw_txpwr_lmt_5ghz_entry_valid()
8076 if (e->bw >= RTW89_5G_BW_NUM) in fw_txpwr_lmt_5ghz_entry_valid()
8078 if (e->nt >= RTW89_NTX_NUM) in fw_txpwr_lmt_5ghz_entry_valid()
8080 if (e->rs >= RTW89_RS_LMT_NUM) in fw_txpwr_lmt_5ghz_entry_valid()
8082 if (e->bf >= RTW89_BF_NUM) in fw_txpwr_lmt_5ghz_entry_valid()
8084 if (e->regd >= RTW89_REGD_NUM) in fw_txpwr_lmt_5ghz_entry_valid()
8086 if (e->ch_idx >= RTW89_5G_CH_NUM) in fw_txpwr_lmt_5ghz_entry_valid()
8095 const struct rtw89_txpwr_conf *conf = &data->conf; in rtw89_fw_load_txpwr_lmt_5ghz()
8103 data->v[entry.bw][entry.nt][entry.rs][entry.bf][entry.regd] in rtw89_fw_load_txpwr_lmt_5ghz()
8113 if (!__fw_txpwr_entry_acceptable(e, cursor, conf->ent_sz)) in fw_txpwr_lmt_6ghz_entry_valid()
8116 if (e->bw >= RTW89_6G_BW_NUM) in fw_txpwr_lmt_6ghz_entry_valid()
8118 if (e->nt >= RTW89_NTX_NUM) in fw_txpwr_lmt_6ghz_entry_valid()
8120 if (e->rs >= RTW89_RS_LMT_NUM) in fw_txpwr_lmt_6ghz_entry_valid()
8122 if (e->bf >= RTW89_BF_NUM) in fw_txpwr_lmt_6ghz_entry_valid()
8124 if (e->regd >= RTW89_REGD_NUM) in fw_txpwr_lmt_6ghz_entry_valid()
8126 if (e->reg_6ghz_power >= NUM_OF_RTW89_REG_6GHZ_POWER) in fw_txpwr_lmt_6ghz_entry_valid()
8128 if (e->ch_idx >= RTW89_6G_CH_NUM) in fw_txpwr_lmt_6ghz_entry_valid()
8137 const struct rtw89_txpwr_conf *conf = &data->conf; in rtw89_fw_load_txpwr_lmt_6ghz()
8145 data->v[entry.bw][entry.nt][entry.rs][entry.bf][entry.regd] in rtw89_fw_load_txpwr_lmt_6ghz()
8155 if (!__fw_txpwr_entry_acceptable(e, cursor, conf->ent_sz)) in fw_txpwr_lmt_ru_2ghz_entry_valid()
8158 if (e->ru >= RTW89_RU_NUM) in fw_txpwr_lmt_ru_2ghz_entry_valid()
8160 if (e->nt >= RTW89_NTX_NUM) in fw_txpwr_lmt_ru_2ghz_entry_valid()
8162 if (e->regd >= RTW89_REGD_NUM) in fw_txpwr_lmt_ru_2ghz_entry_valid()
8164 if (e->ch_idx >= RTW89_2G_CH_NUM) in fw_txpwr_lmt_ru_2ghz_entry_valid()
8173 const struct rtw89_txpwr_conf *conf = &data->conf; in rtw89_fw_load_txpwr_lmt_ru_2ghz()
8181 data->v[entry.ru][entry.nt][entry.regd][entry.ch_idx] = entry.v; in rtw89_fw_load_txpwr_lmt_ru_2ghz()
8190 if (!__fw_txpwr_entry_acceptable(e, cursor, conf->ent_sz)) in fw_txpwr_lmt_ru_5ghz_entry_valid()
8193 if (e->ru >= RTW89_RU_NUM) in fw_txpwr_lmt_ru_5ghz_entry_valid()
8195 if (e->nt >= RTW89_NTX_NUM) in fw_txpwr_lmt_ru_5ghz_entry_valid()
8197 if (e->regd >= RTW89_REGD_NUM) in fw_txpwr_lmt_ru_5ghz_entry_valid()
8199 if (e->ch_idx >= RTW89_5G_CH_NUM) in fw_txpwr_lmt_ru_5ghz_entry_valid()
8208 const struct rtw89_txpwr_conf *conf = &data->conf; in rtw89_fw_load_txpwr_lmt_ru_5ghz()
8216 data->v[entry.ru][entry.nt][entry.regd][entry.ch_idx] = entry.v; in rtw89_fw_load_txpwr_lmt_ru_5ghz()
8225 if (!__fw_txpwr_entry_acceptable(e, cursor, conf->ent_sz)) in fw_txpwr_lmt_ru_6ghz_entry_valid()
8228 if (e->ru >= RTW89_RU_NUM) in fw_txpwr_lmt_ru_6ghz_entry_valid()
8230 if (e->nt >= RTW89_NTX_NUM) in fw_txpwr_lmt_ru_6ghz_entry_valid()
8232 if (e->regd >= RTW89_REGD_NUM) in fw_txpwr_lmt_ru_6ghz_entry_valid()
8234 if (e->reg_6ghz_power >= NUM_OF_RTW89_REG_6GHZ_POWER) in fw_txpwr_lmt_ru_6ghz_entry_valid()
8236 if (e->ch_idx >= RTW89_6G_CH_NUM) in fw_txpwr_lmt_ru_6ghz_entry_valid()
8245 const struct rtw89_txpwr_conf *conf = &data->conf; in rtw89_fw_load_txpwr_lmt_ru_6ghz()
8253 data->v[entry.ru][entry.nt][entry.regd][entry.reg_6ghz_power] in rtw89_fw_load_txpwr_lmt_ru_6ghz()
8263 if (!__fw_txpwr_entry_acceptable(e, cursor, conf->ent_sz)) in fw_tx_shape_lmt_entry_valid()
8266 if (e->band >= RTW89_BAND_NUM) in fw_tx_shape_lmt_entry_valid()
8268 if (e->tx_shape_rs >= RTW89_RS_TX_SHAPE_NUM) in fw_tx_shape_lmt_entry_valid()
8270 if (e->regd >= RTW89_REGD_NUM) in fw_tx_shape_lmt_entry_valid()
8279 const struct rtw89_txpwr_conf *conf = &data->conf; in rtw89_fw_load_tx_shape_lmt()
8287 data->v[entry.band][entry.tx_shape_rs][entry.regd] = entry.v; in rtw89_fw_load_tx_shape_lmt()
8296 if (!__fw_txpwr_entry_acceptable(e, cursor, conf->ent_sz)) in fw_tx_shape_lmt_ru_entry_valid()
8299 if (e->band >= RTW89_BAND_NUM) in fw_tx_shape_lmt_ru_entry_valid()
8301 if (e->regd >= RTW89_REGD_NUM) in fw_tx_shape_lmt_ru_entry_valid()
8310 const struct rtw89_txpwr_conf *conf = &data->conf; in rtw89_fw_load_tx_shape_lmt_ru()
8318 data->v[entry.band][entry.regd] = entry.v; in rtw89_fw_load_tx_shape_lmt_ru()
8326 struct rtw89_rfe_data *rfe_data = rtwdev->rfe_data; in rtw89_load_rfe_data_from_fw()
8332 parms = &rfe_data->rfe_parms; in rtw89_load_rfe_data_from_fw()
8336 if (rtw89_txpwr_conf_valid(&rfe_data->byrate.conf)) { in rtw89_load_rfe_data_from_fw()
8337 rfe_data->byrate.tbl.data = &rfe_data->byrate.conf; in rtw89_load_rfe_data_from_fw()
8338 rfe_data->byrate.tbl.size = 0; /* don't care here */ in rtw89_load_rfe_data_from_fw()
8339 rfe_data->byrate.tbl.load = rtw89_fw_load_txpwr_byrate; in rtw89_load_rfe_data_from_fw()
8340 parms->byr_tbl = &rfe_data->byrate.tbl; in rtw89_load_rfe_data_from_fw()
8343 if (rtw89_txpwr_conf_valid(&rfe_data->lmt_2ghz.conf)) { in rtw89_load_rfe_data_from_fw()
8344 rtw89_fw_load_txpwr_lmt_2ghz(&rfe_data->lmt_2ghz); in rtw89_load_rfe_data_from_fw()
8345 parms->rule_2ghz.lmt = &rfe_data->lmt_2ghz.v; in rtw89_load_rfe_data_from_fw()
8348 if (rtw89_txpwr_conf_valid(&rfe_data->lmt_5ghz.conf)) { in rtw89_load_rfe_data_from_fw()
8349 rtw89_fw_load_txpwr_lmt_5ghz(&rfe_data->lmt_5ghz); in rtw89_load_rfe_data_from_fw()
8350 parms->rule_5ghz.lmt = &rfe_data->lmt_5ghz.v; in rtw89_load_rfe_data_from_fw()
8353 if (rtw89_txpwr_conf_valid(&rfe_data->lmt_6ghz.conf)) { in rtw89_load_rfe_data_from_fw()
8354 rtw89_fw_load_txpwr_lmt_6ghz(&rfe_data->lmt_6ghz); in rtw89_load_rfe_data_from_fw()
8355 parms->rule_6ghz.lmt = &rfe_data->lmt_6ghz.v; in rtw89_load_rfe_data_from_fw()
8358 if (rtw89_txpwr_conf_valid(&rfe_data->lmt_ru_2ghz.conf)) { in rtw89_load_rfe_data_from_fw()
8359 rtw89_fw_load_txpwr_lmt_ru_2ghz(&rfe_data->lmt_ru_2ghz); in rtw89_load_rfe_data_from_fw()
8360 parms->rule_2ghz.lmt_ru = &rfe_data->lmt_ru_2ghz.v; in rtw89_load_rfe_data_from_fw()
8363 if (rtw89_txpwr_conf_valid(&rfe_data->lmt_ru_5ghz.conf)) { in rtw89_load_rfe_data_from_fw()
8364 rtw89_fw_load_txpwr_lmt_ru_5ghz(&rfe_data->lmt_ru_5ghz); in rtw89_load_rfe_data_from_fw()
8365 parms->rule_5ghz.lmt_ru = &rfe_data->lmt_ru_5ghz.v; in rtw89_load_rfe_data_from_fw()
8368 if (rtw89_txpwr_conf_valid(&rfe_data->lmt_ru_6ghz.conf)) { in rtw89_load_rfe_data_from_fw()
8369 rtw89_fw_load_txpwr_lmt_ru_6ghz(&rfe_data->lmt_ru_6ghz); in rtw89_load_rfe_data_from_fw()
8370 parms->rule_6ghz.lmt_ru = &rfe_data->lmt_ru_6ghz.v; in rtw89_load_rfe_data_from_fw()
8373 if (rtw89_txpwr_conf_valid(&rfe_data->tx_shape_lmt.conf)) { in rtw89_load_rfe_data_from_fw()
8374 rtw89_fw_load_tx_shape_lmt(&rfe_data->tx_shape_lmt); in rtw89_load_rfe_data_from_fw()
8375 parms->tx_shape.lmt = &rfe_data->tx_shape_lmt.v; in rtw89_load_rfe_data_from_fw()
8378 if (rtw89_txpwr_conf_valid(&rfe_data->tx_shape_lmt_ru.conf)) { in rtw89_load_rfe_data_from_fw()
8379 rtw89_fw_load_tx_shape_lmt_ru(&rfe_data->tx_shape_lmt_ru); in rtw89_load_rfe_data_from_fw()
8380 parms->tx_shape.lmt_ru = &rfe_data->tx_shape_lmt_ru.v; in rtw89_load_rfe_data_from_fw()