Lines Matching +full:- +full:1200 +full:ps
1 // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
2 /* Copyright(c) 2018-2019 Realtek Corporation
16 #include "ps.h"
71 val = rtw_read32_mask(rtwdev, reg->addr, reg->mask);
74 reg->desc, reg->addr, reg->mask, val);
100 sub_cmd_id = c2h->payload[0];
125 return 1200;
147 struct rtw_sta_info *si = (struct rtw_sta_info *)sta->drv_priv;
152 mac_id = GET_RA_REPORT_MACID(ra_data->payload);
153 if (si->mac_id != mac_id)
156 si->ra_report.txrate.flags = 0;
158 rate = GET_RA_REPORT_RATE(ra_data->payload);
159 sgi = GET_RA_REPORT_SGI(ra_data->payload);
160 bw = GET_RA_REPORT_BW(ra_data->payload);
163 si->ra_report.txrate.legacy = rtw_desc_to_bitrate(rate);
169 si->ra_report.txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
171 si->ra_report.txrate.flags |= RATE_INFO_FLAGS_MCS;
174 si->ra_report.txrate.mcs = mcs;
175 si->ra_report.txrate.nss = nss;
179 si->ra_report.txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
182 si->ra_report.txrate.bw = RATE_INFO_BW_80;
184 si->ra_report.txrate.bw = RATE_INFO_BW_40;
186 si->ra_report.txrate.bw = RATE_INFO_BW_20;
189 bit_rate = cfg80211_calculate_bitrate(&si->ra_report.txrate);
191 si->ra_report.desc_rate = rate;
192 si->ra_report.bit_rate = bit_rate;
194 sta->deflink.agg.max_rc_amsdu_len = get_max_amsdu_len(bit_rate);
205 rtwdev->dm_info.tx_rate = GET_RA_REPORT_RATE(payload);
220 struct rtw_dev *rtwdev = iter_data->rtwdev;
221 u8 *payload = iter_data->payload;
236 rtwdev->beacon_loss = false;
239 rtwdev->beacon_loss = true;
259 struct rtw_dm_info *dm_info = &rtwdev->dm_info;
261 dm_info->scan_density = payload[0];
264 dm_info->scan_density);
270 struct rtw_hw_reg_offset *edcca_th = rtwdev->chip->edcca_th;
275 result->density, result->igi, result->l2h_th_init, result->l2h,
276 result->h2l, result->option);
295 pkt_offset = *((u32 *)skb->cb);
296 c2h = (struct rtw_c2h_cmd *)(skb->data + pkt_offset);
297 len = skb->len - pkt_offset - 2;
299 mutex_lock(&rtwdev->mutex);
301 if (!test_bit(RTW_FLAG_RUNNING, rtwdev->flags))
304 switch (c2h->id) {
309 rtw_coex_bt_info_notify(rtwdev, c2h->payload, len);
312 rtw_coex_bt_hid_info_notify(rtwdev, c2h->payload, len);
315 rtw_coex_wl_fwdbginfo_notify(rtwdev, c2h->payload, len);
318 rtw_fw_bcn_filter_notify(rtwdev, c2h->payload, len);
324 rtw_fw_ra_report_handle(rtwdev, c2h->payload, len);
327 rtw_dbg(rtwdev, RTW_DBG_FW, "C2H 0x%x isn't handled\n", c2h->id);
332 mutex_unlock(&rtwdev->mutex);
341 c2h = (struct rtw_c2h_cmd *)(skb->data + pkt_offset);
342 len = skb->len - pkt_offset - 2;
343 *((u32 *)skb->cb) = pkt_offset;
346 c2h->id, c2h->seq, len);
348 switch (c2h->id) {
353 complete(&rtwdev->lps_leave_check);
357 complete(&rtwdev->fw_scan_density);
358 rtw_fw_scan_result(rtwdev, c2h->payload, len);
362 rtw_fw_adaptivity_result(rtwdev, c2h->payload, len);
367 *((u32 *)skb->cb) = pkt_offset;
368 skb_queue_tail(&rtwdev->c2h_queue, skb);
369 ieee80211_queue_work(rtwdev->hw, &rtwdev->c2h_work);
391 rtw_dbg(rtwdev, RTW_DBG_FW, "send H2C content %08x %08x\n", h2c->w0,
392 h2c->w1);
394 lockdep_assert_held(&rtwdev->mutex);
396 box = rtwdev->h2c.last_box_num;
429 rtw_write32(rtwdev, box_ex_reg, h2c->w1);
430 rtw_write32(rtwdev, box_reg, h2c->w0);
432 if (++rtwdev->h2c.last_box_num >= 4)
433 rtwdev->h2c.last_box_num = 0;
450 lockdep_assert_held(&rtwdev->mutex);
452 box = rtwdev->h2c.last_box_num;
484 rtw_write32(rtwdev, box_ex_reg, le32_to_cpu(h2c_cmd->msg_ext));
485 rtw_write32(rtwdev, box_reg, le32_to_cpu(h2c_cmd->msg));
487 if (++rtwdev->h2c.last_box_num >= 4)
488 rtwdev->h2c.last_box_num = 0;
500 lockdep_assert_held(&rtwdev->mutex);
502 FW_OFFLOAD_H2C_SET_SEQ_NUM(h2c_pkt, rtwdev->h2c.seq);
506 rtwdev->h2c.seq++;
512 struct rtw_fifo_conf *fifo = &rtwdev->fifo;
524 fifo->rsvd_fw_txbuf_addr -
525 fifo->rsvd_boundary);
533 struct rtw_hal *hal = &rtwdev->hal;
534 struct rtw_efuse *efuse = &rtwdev->efuse;
542 if (hal->rf_type == RF_1T1R)
544 else if (hal->rf_type == RF_2T2R)
550 PHYDM_INFO_SET_REF_TYPE(h2c_pkt, efuse->rfe_option);
552 PHYDM_INFO_SET_CUT_VER(h2c_pkt, hal->cut_version);
553 PHYDM_INFO_SET_RX_ANT_STATUS(h2c_pkt, hal->antenna_tx);
554 PHYDM_INFO_SET_TX_ANT_STATUS(h2c_pkt, hal->antenna_rx);
566 IQK_SET_CLEAR(h2c_pkt, para->clear);
567 IQK_SET_SEGMENT_IQK(h2c_pkt, para->segment_iqk);
600 if (rtwvif->net_type != RTW_NET_MGD_LINKED)
607 u32_encode_bits(rtwvif->port, RTW_H2C_DEFAULT_PORT_W0_PORTID) |
608 u32_encode_bits(rtwvif->mac_id, RTW_H2C_DEFAULT_PORT_W0_MACID);
633 SET_BT_MP_INFO_SEQ(h2c_pkt, req->seq);
634 SET_BT_MP_INFO_OP_CODE(h2c_pkt, req->op_code);
635 SET_BT_MP_INFO_PARA1(h2c_pkt, req->para1);
636 SET_BT_MP_INFO_PARA2(h2c_pkt, req->para2);
637 SET_BT_MP_INFO_PARA3(h2c_pkt, req->para3);
645 u8 index = 0 - bt_pwr_dec_lvl;
713 u8 rssi = ewma_rssi_read(&si->avg_rssi);
714 bool stbc_en = si->stbc_en ? true : false;
718 SET_RSSI_INFO_MACID(h2c_pkt, si->mac_id);
733 SET_RA_INFO_MACID(h2c_pkt, si->mac_id);
734 SET_RA_INFO_RATE_ID(h2c_pkt, si->rate_id);
735 SET_RA_INFO_INIT_RA_LVL(h2c_pkt, si->init_ra_lv);
736 SET_RA_INFO_SGI_EN(h2c_pkt, si->sgi_enable);
737 SET_RA_INFO_BW_MODE(h2c_pkt, si->bw_mode);
738 SET_RA_INFO_LDPC(h2c_pkt, !!si->ldpc_en);
740 SET_RA_INFO_VHT_EN(h2c_pkt, si->vht_enable);
742 SET_RA_INFO_RA_MASK0(h2c_pkt, (si->ra_mask & 0xff));
743 SET_RA_INFO_RA_MASK1(h2c_pkt, (si->ra_mask & 0xff00) >> 8);
744 SET_RA_INFO_RA_MASK2(h2c_pkt, (si->ra_mask & 0xff0000) >> 16);
745 SET_RA_INFO_RA_MASK3(h2c_pkt, (si->ra_mask & 0xff000000) >> 24);
747 si->init_ra_lv = 0;
765 struct rtw_traffic_stats *stats = &rtwdev->stats;
766 struct rtw_dm_info *dm_info = &rtwdev->dm_info;
770 SET_WL_PHY_INFO_TX_TP(h2c_pkt, stats->tx_throughput);
771 SET_WL_PHY_INFO_RX_TP(h2c_pkt, stats->rx_throughput);
772 SET_WL_PHY_INFO_TX_RATE_DESC(h2c_pkt, dm_info->tx_rate);
773 SET_WL_PHY_INFO_RX_RATE_DESC(h2c_pkt, dm_info->curr_rx_rate);
774 SET_WL_PHY_INFO_RX_EVM(h2c_pkt, dm_info->rx_evm_dbm[RF_PATH_A]);
781 struct ieee80211_bss_conf *bss_conf = &vif->bss_conf;
782 struct ieee80211_sta *sta = ieee80211_find_sta(vif, bss_conf->bssid);
785 sta ? (struct rtw_sta_info *)sta->drv_priv : NULL;
790 if (!rtw_fw_feature_check(&rtwdev->fw, FW_FEATURE_BCN_FILTER))
793 if (bss_conf->cqm_rssi_thold)
794 thold = bss_conf->cqm_rssi_thold;
795 if (bss_conf->cqm_rssi_hyst)
796 hyst = bss_conf->cqm_rssi_hyst;
810 ether_addr_copy(&h2c_pkt[1], bss_conf->bssid);
821 SET_BCN_FILTER_OFFLOAD_P1_MACID(h2c_pkt, si->mac_id);
823 SET_BCN_FILTER_OFFLOAD_P1_BCN_INTERVAL(h2c_pkt, bss_conf->beacon_int);
829 struct rtw_lps_conf *conf = &rtwdev->lps_conf;
834 SET_PWR_MODE_SET_MODE(h2c_pkt, conf->mode);
835 SET_PWR_MODE_SET_RLBM(h2c_pkt, conf->rlbm);
836 SET_PWR_MODE_SET_SMART_PS(h2c_pkt, conf->smart_ps);
837 SET_PWR_MODE_SET_AWAKE_INTERVAL(h2c_pkt, conf->awake_interval);
838 SET_PWR_MODE_SET_PORT_ID(h2c_pkt, conf->port_id);
839 SET_PWR_MODE_SET_PWR_STATE(h2c_pkt, conf->state);
864 struct rtw_wow_param *rtw_wow = &rtwdev->wow;
874 if (test_bit(RTW_WOW_FLAG_EN_DISCONNECT, rtw_wow->flags)) {
886 struct rtw_wow_param *rtw_wow = &rtwdev->wow;
893 if (test_bit(RTW_WOW_FLAG_EN_MAGIC_PKT, rtw_wow->flags))
895 if (test_bit(RTW_WOW_FLAG_EN_DISCONNECT, rtw_wow->flags))
897 if (test_bit(RTW_WOW_FLAG_EN_REKEY_PKT, rtw_wow->flags))
899 if (rtw_wow->pattern_cnt)
940 list_for_each_entry(rsvd_pkt, &rtwdev->rsvd_page_list, build_list) {
941 if (type == rsvd_pkt->type)
942 location = rsvd_pkt->page;
980 struct rtw_lps_conf *conf = &rtwdev->lps_conf;
991 LPS_PG_SEC_CAM_EN(h2c_pkt, conf->sec_cam_backup);
992 LPS_PG_PATTERN_CAM_EN(h2c_pkt, conf->pattern_cam_backup);
1003 list_for_each_entry(rsvd_pkt, &rtwdev->rsvd_page_list, build_list) {
1004 if (rsvd_pkt->type != RSVD_PROBE_REQ)
1006 if ((!ssid && !rsvd_pkt->ssid) ||
1007 cfg80211_ssid_eq(rsvd_pkt->ssid, ssid))
1008 location = rsvd_pkt->page;
1020 list_for_each_entry(rsvd_pkt, &rtwdev->rsvd_page_list, build_list) {
1021 if (rsvd_pkt->type != RSVD_PROBE_REQ)
1023 if ((!ssid && !rsvd_pkt->ssid) ||
1024 cfg80211_ssid_eq(rsvd_pkt->ssid, ssid))
1025 size = rsvd_pkt->probe_req_size;
1059 struct rtw_dev *rtwdev = hw->priv;
1060 const struct rtw_chip_info *chip = rtwdev->chip;
1061 struct rtw_pno_request *pno_req = &rtwdev->wow.pno_req;
1069 if (!pno_req->inited || !pno_req->match_set_cnt)
1072 size = sizeof(struct rtw_nlo_info_hdr) + pno_req->match_set_cnt *
1073 IEEE80211_MAX_SSID_LEN + chip->tx_pkt_desc_sz;
1079 skb_reserve(skb, chip->tx_pkt_desc_sz);
1083 nlo_hdr->nlo_count = pno_req->match_set_cnt;
1084 nlo_hdr->hidden_ap_count = pno_req->match_set_cnt;
1087 memset(nlo_hdr->pattern_check, 0xA5, FW_NLO_INFO_CHECK_SIZE);
1089 for (i = 0; i < pno_req->match_set_cnt; i++)
1090 nlo_hdr->ssid_len[i] = pno_req->match_sets[i].ssid.ssid_len;
1092 for (i = 0; i < pno_req->match_set_cnt; i++) {
1093 ssid = &pno_req->match_sets[i].ssid;
1100 nlo_hdr->location[i] = loc;
1103 for (i = 0; i < pno_req->match_set_cnt; i++) {
1105 memcpy(pos, pno_req->match_sets[i].ssid.ssid,
1106 pno_req->match_sets[i].ssid.ssid_len);
1114 struct rtw_dev *rtwdev = hw->priv;
1115 const struct rtw_chip_info *chip = rtwdev->chip;
1116 struct rtw_pno_request *pno_req = &rtwdev->wow.pno_req;
1117 struct ieee80211_channel *channels = pno_req->channels;
1119 int count = pno_req->channel_cnt;
1123 skb = alloc_skb(4 * count + chip->tx_pkt_desc_sz, GFP_KERNEL);
1127 skb_reserve(skb, chip->tx_pkt_desc_sz);
1148 struct rtw_dev *rtwdev = hw->priv;
1149 const struct rtw_chip_info *chip = rtwdev->chip;
1150 struct rtw_dpk_info *dpk_info = &rtwdev->dm_info.dpk_info;
1155 size = chip->tx_pkt_desc_sz + sizeof(*dpk_hdr);
1160 skb_reserve(skb, chip->tx_pkt_desc_sz);
1162 dpk_hdr->dpk_ch = dpk_info->dpk_ch;
1163 dpk_hdr->dpk_path_ok = dpk_info->dpk_path_ok[0];
1164 memcpy(dpk_hdr->dpk_txagc, dpk_info->dpk_txagc, 2);
1165 memcpy(dpk_hdr->dpk_gs, dpk_info->dpk_gs, 4);
1166 memcpy(dpk_hdr->coef, dpk_info->coef, 160);
1173 struct rtw_dev *rtwdev = hw->priv;
1174 const struct rtw_chip_info *chip = rtwdev->chip;
1175 struct rtw_lps_conf *conf = &rtwdev->lps_conf;
1177 struct rtw_wow_param *rtw_wow = &rtwdev->wow;
1181 size = chip->tx_pkt_desc_sz + sizeof(*pg_info_hdr);
1186 skb_reserve(skb, chip->tx_pkt_desc_sz);
1188 pg_info_hdr->tx_bu_page_count = rtwdev->fifo.rsvd_drv_pg_num;
1189 pg_info_hdr->macid = find_first_bit(rtwdev->mac_id_map, RTW_MAX_MAC_ID_NUM);
1190 pg_info_hdr->sec_cam_count =
1191 rtw_sec_cam_pg_backup(rtwdev, pg_info_hdr->sec_cam);
1192 pg_info_hdr->pattern_count = rtw_wow->pattern_cnt;
1194 conf->sec_cam_backup = pg_info_hdr->sec_cam_count != 0;
1195 conf->pattern_cam_backup = rtw_wow->pattern_cnt != 0;
1209 if (rsvd_pkt->type == RSVD_DUMMY) {
1218 rtwvif = rsvd_pkt->rtwvif;
1224 switch (rsvd_pkt->type) {
1227 rsvd_pkt->tim_offset = tim_offset;
1236 skb_new = ieee80211_nullfunc_get(hw, vif, -1, false);
1239 skb_new = ieee80211_nullfunc_get(hw, vif, -1, true);
1248 ssid = (struct cfg80211_ssid *)rsvd_pkt->ssid;
1250 skb_new = ieee80211_probereq_get(hw, vif->addr,
1251 ssid->ssid,
1252 ssid->ssid_len, 0);
1254 skb_new = ieee80211_probereq_get(hw, vif->addr, NULL, 0, 0);
1256 rsvd_pkt->probe_req_size = (u16)skb_new->len;
1278 const struct rtw_chip_info *chip = rtwdev->chip;
1282 pkt_desc = skb_push(skb, chip->tx_pkt_desc_sz);
1283 memset(pkt_desc, 0, chip->tx_pkt_desc_sz);
1296 struct sk_buff *skb = rsvd_pkt->skb;
1299 memcpy(buf + page_margin + page_size * (page - 1),
1300 skb->data, skb->len);
1302 memcpy(buf, skb->data, skb->len);
1316 INIT_LIST_HEAD(&rsvd_pkt->vif_list);
1317 INIT_LIST_HEAD(&rsvd_pkt->build_list);
1318 rsvd_pkt->type = type;
1319 rsvd_pkt->add_txdesc = txdesc;
1328 lockdep_assert_held(&rtwdev->mutex);
1330 list_add_tail(&rsvd_pkt->vif_list, &rtwvif->rsvd_page_list);
1346 rsvd_pkt->rtwvif = rtwvif;
1362 rsvd_pkt->rtwvif = rtwvif;
1363 rsvd_pkt->ssid = ssid;
1372 lockdep_assert_held(&rtwdev->mutex);
1375 list_for_each_entry_safe(rsvd_pkt, tmp, &rtwvif->rsvd_page_list,
1377 list_del(&rsvd_pkt->vif_list);
1378 if (!list_empty(&rsvd_pkt->build_list))
1379 list_del(&rsvd_pkt->build_list);
1389 if (vif->type != NL80211_IFTYPE_AP &&
1390 vif->type != NL80211_IFTYPE_ADHOC &&
1391 vif->type != NL80211_IFTYPE_MESH_POINT) {
1393 vif->type);
1404 struct rtw_wow_param *rtw_wow = &rtwdev->wow;
1405 struct rtw_pno_request *rtw_pno_req = &rtw_wow->pno_req;
1409 if (vif->type != NL80211_IFTYPE_STATION) {
1411 vif->type);
1415 for (i = 0 ; i < rtw_pno_req->match_set_cnt; i++) {
1416 ssid = &rtw_pno_req->match_sets[i].ssid;
1430 if (vif->type != NL80211_IFTYPE_STATION) {
1432 vif->type);
1453 lockdep_assert_held(&rtwdev->mutex);
1456 return -EINVAL;
1492 ret = -EBUSY;
1496 rsvd_pg_head = rtwdev->fifo.rsvd_boundary;
1511 pg_size = rtwdev->chip->page_size;
1512 pg_num = size / pg_size + ((size & (pg_size - 1)) ? 1 : 0);
1513 if (pg_num > rtwdev->fifo.rsvd_drv_pg_num)
1514 return -ENOMEM;
1516 pg_addr = rtwdev->fifo.rsvd_drv_addr;
1525 list_for_each_entry_safe(rsvd_pkt, tmp, &rtwdev->rsvd_page_list,
1527 list_del_init(&rsvd_pkt->build_list);
1532 if (rsvd_pkt->type == RSVD_DUMMY)
1541 struct rtw_vif *rtwvif = (struct rtw_vif *)vif->drv_priv;
1545 if (vif->type == NL80211_IFTYPE_AP && !rtwdev->ap_active)
1548 list_for_each_entry(rsvd_pkt, &rtwvif->rsvd_page_list, vif_list) {
1549 if (rsvd_pkt->type == RSVD_BEACON)
1550 list_add(&rsvd_pkt->build_list,
1551 &rtwdev->rsvd_page_list);
1553 list_add_tail(&rsvd_pkt->build_list,
1554 &rtwdev->rsvd_page_list);
1567 rsvd_pkt = list_first_entry_or_null(&rtwdev->rsvd_page_list,
1571 return -EINVAL;
1575 if (rsvd_pkt->type != RSVD_BEACON) {
1581 return -ENOMEM;
1584 list_add(&dummy_pkt->build_list, &rtwdev->rsvd_page_list);
1592 struct ieee80211_hw *hw = rtwdev->hw;
1593 const struct rtw_chip_info *chip = rtwdev->chip;
1602 page_size = chip->page_size;
1603 tx_desc_sz = chip->tx_pkt_desc_sz;
1604 page_margin = page_size - tx_desc_sz;
1613 list_for_each_entry(rsvd_pkt, &rtwdev->rsvd_page_list, build_list) {
1621 * And iter->len will be added with size of tx_desc_sz.
1623 if (rsvd_pkt->add_txdesc)
1624 rtw_fill_rsvd_page_desc(rtwdev, iter, rsvd_pkt->type);
1626 rsvd_pkt->skb = iter;
1627 rsvd_pkt->page = total_page;
1638 if (rsvd_pkt->type != RSVD_BEACON &&
1639 rsvd_pkt->type != RSVD_DUMMY) {
1643 total_page += rtw_len_to_page(iter->len + tx_desc_sz,
1646 total_page += rtw_len_to_page(iter->len, page_size);
1650 if (total_page > rtwdev->fifo.rsvd_drv_pg_num) {
1655 *size = (total_page - 1) * page_size + page_margin;
1663 * Note that the first rsvd_pkt is a beacon no matter what vif->type.
1667 list_for_each_entry(rsvd_pkt, &rtwdev->rsvd_page_list, build_list) {
1671 page += rtw_len_to_page(rsvd_pkt->skb->len +
1674 page += rtw_len_to_page(rsvd_pkt->skb->len, page_size);
1676 kfree_skb(rsvd_pkt->skb);
1677 rsvd_pkt->skb = NULL;
1683 list_for_each_entry(rsvd_pkt, &rtwdev->rsvd_page_list, build_list) {
1684 kfree_skb(rsvd_pkt->skb);
1685 rsvd_pkt->skb = NULL;
1693 struct ieee80211_hw *hw = rtwdev->hw;
1698 rsvd_pkt = list_first_entry_or_null(&rtwdev->rsvd_page_list,
1702 return -ENOENT;
1705 if (rsvd_pkt->type != RSVD_BEACON &&
1706 rsvd_pkt->type != RSVD_DUMMY) {
1708 rsvd_pkt->type);
1709 return -EINVAL;
1715 return -ENOMEM;
1718 ret = rtw_download_drv_rsvd_page(rtwdev, skb->data, skb->len);
1736 return -ENOMEM;
1767 mutex_lock(&rtwdev->mutex);
1770 mutex_unlock(&rtwdev->mutex);
1790 size -= 4;
1808 const struct rtw_chip_info *chip = rtwdev->chip;
1816 offset += rtwdev->fifo.rsvd_boundary << TX_PAGE_SIZE_SHIFT;
1817 residue = offset & (FIFO_PAGE_SIZE - 1);
1818 start_pg = (offset >> FIFO_PAGE_SIZE_SHIFT) + chip->fw_fifo_addr[sel];
1830 if ((start_addr + size) > rtwdev->chip->fw_fifo_addr[sel])
1841 if (!rtwdev->chip->fw_fifo_addr[0]) {
1843 return -ENOTSUPP;
1847 return -EINVAL;
1851 return -EINVAL;
1856 return -EINVAL;
1867 const struct rtw_chip_info *chip = rtwdev->chip;
1878 size += chip->tx_pkt_desc_sz;
1907 struct rtw_pno_request *rtw_pno_req = &rtwdev->wow.pno_req;
1935 CH_SWITCH_SET_CH_NUM(h2c_pkt, rtw_pno_req->channel_cnt);
1936 CH_SWITCH_SET_INFO_SIZE(h2c_pkt, rtw_pno_req->channel_cnt * 4);
1946 struct rtw_dm_info *dm_info = &rtwdev->dm_info;
1950 dm_info->edcca_mode = RTW_EDCCA_NORMAL;
1956 SET_ADAPTIVITY_MODE(h2c_pkt, dm_info->edcca_mode);
1958 SET_ADAPTIVITY_IGI(h2c_pkt, dm_info->igi_history[0]);
1959 SET_ADAPTIVITY_L2H(h2c_pkt, dm_info->l2h_th_ini);
1960 SET_ADAPTIVITY_DENSITY(h2c_pkt, dm_info->scan_density);
1979 const struct rtw_chip_info *chip = rtwdev->chip;
1980 struct ieee80211_scan_ies *ies = rtwvif->scan_ies;
1985 if (!(BIT(idx) & chip->band))
1989 return -ENOMEM;
1990 skb_put_data(new, ies->ies[idx], ies->len[idx]);
1991 skb_put_data(new, ies->common_ies, ies->common_ie_len);
2002 const struct rtw_chip_info *chip = rtwdev->chip;
2004 u8 page_offset = 1, *buf, page_size = chip->page_size;
2005 u16 pg_addr = rtwdev->fifo.rsvd_h2c_info_addr, loc;
2007 u8 tx_desc_sz = chip->tx_pkt_desc_sz;
2012 if (rtw_fw_feature_ext_check(&rtwdev->fw, FW_FEATURE_EXT_OLD_PAGE_NUM))
2021 return -ENOMEM;
2023 buf_offset -= tx_desc_sz;
2027 if (skb->len > page_size * page_cnt) {
2031 ret = -EINVAL;
2035 memcpy(buf + buf_offset, skb->data, skb->len);
2036 pkt_len = skb->len - tx_desc_sz;
2037 loc = pg_addr - rtwdev->fifo.rsvd_boundary + page_offset;
2051 rtwdev->scan_info.probe_pg_size = page_offset;
2063 struct cfg80211_scan_request *req = rtwvif->scan_req;
2066 u8 num = req->n_ssids, i, bands = 0;
2071 skb = ieee80211_probereq_get(rtwdev->hw, rtwvif->mac_addr,
2072 req->ssids[i].ssid,
2073 req->ssids[i].ssid_len,
2074 req->ie_len);
2076 ret = -ENOMEM;
2099 u8 *chan = &buf[list->size];
2102 if (list->size > list->buf_size)
2103 return -ENOMEM;
2105 CH_INFO_SET_CH(chan, info->channel);
2106 CH_INFO_SET_PRI_CH_IDX(chan, info->pri_ch_idx);
2107 CH_INFO_SET_BW(chan, info->bw);
2108 CH_INFO_SET_TIMEOUT(chan, info->timeout);
2109 CH_INFO_SET_ACTION_ID(chan, info->action_id);
2110 CH_INFO_SET_EXTRA_INFO(chan, info->extra_info);
2111 if (info->extra_info) {
2114 EXTRA_CH_INFO_SET_SIZE(chan, RTW_EX_CH_INFO_SIZE -
2119 list->size += info_size;
2120 list->ch_num++;
2128 struct cfg80211_scan_request *req = rtwvif->scan_req;
2129 struct rtw_fifo_conf *fifo = &rtwdev->fifo;
2133 for (i = 0; i < req->n_channels; i++) {
2136 channel = req->channels[i];
2137 ch_info.channel = channel->hw_value;
2140 ch_info.timeout = req->duration_mandatory ?
2141 req->duration : RTW_CHANNEL_TIME;
2143 if (channel->flags & (IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IR)) {
2158 if (list->size > fifo->rsvd_pg_num << TX_PAGE_SIZE_SHIFT) {
2160 return -EINVAL;
2163 list->addr = fifo->rsvd_h2c_info_addr + rtwdev->scan_info.probe_pg_size;
2164 ret = rtw_fw_write_data_rsvd_page(rtwdev, list->addr, buf, list->size);
2176 struct rtw_hw_scan_info *scan_info = &rtwdev->scan_info;
2177 struct cfg80211_scan_request *req = rtwvif->scan_req;
2178 struct rtw_fifo_conf *fifo = &rtwdev->fifo;
2180 u8 pkt_loc = fifo->rsvd_h2c_info_addr - fifo->rsvd_boundary + 1;
2181 bool random_seq = req->flags & NL80211_SCAN_FLAG_RANDOM_SN;
2187 SCAN_OFFLOAD_SET_START(h2c_pkt, opt->switch_en);
2188 SCAN_OFFLOAD_SET_BACK_OP_EN(h2c_pkt, opt->back_op_en);
2190 SCAN_OFFLOAD_SET_NO_CCK_EN(h2c_pkt, req->no_cck);
2191 SCAN_OFFLOAD_SET_CH_NUM(h2c_pkt, list->ch_num);
2192 SCAN_OFFLOAD_SET_CH_INFO_SIZE(h2c_pkt, list->size);
2193 SCAN_OFFLOAD_SET_CH_INFO_LOC(h2c_pkt, list->addr - fifo->rsvd_boundary);
2194 SCAN_OFFLOAD_SET_OP_CH(h2c_pkt, scan_info->op_chan);
2195 SCAN_OFFLOAD_SET_OP_PRI_CH_IDX(h2c_pkt, scan_info->op_pri_ch_idx);
2196 SCAN_OFFLOAD_SET_OP_BW(h2c_pkt, scan_info->op_bw);
2197 SCAN_OFFLOAD_SET_OP_PORT_ID(h2c_pkt, rtwvif->port);
2198 SCAN_OFFLOAD_SET_OP_DWELL_TIME(h2c_pkt, req->duration_mandatory ?
2199 req->duration : RTW_CHANNEL_TIME);
2201 SCAN_OFFLOAD_SET_SSID_NUM(h2c_pkt, req->n_ssids);
2210 struct rtw_vif *rtwvif = (struct rtw_vif *)vif->drv_priv;
2211 struct cfg80211_scan_request *req = &scan_req->req;
2214 rtwdev->scan_info.scanning_vif = vif;
2215 rtwvif->scan_ies = &scan_req->ies;
2216 rtwvif->scan_req = req;
2218 ieee80211_stop_queues(rtwdev->hw);
2222 if (req->flags & NL80211_SCAN_FLAG_RANDOM_ADDR)
2223 get_random_mask_addr(mac_addr, req->mac_addr,
2224 req->mac_addr_mask);
2226 ether_addr_copy(mac_addr, vif->addr);
2230 rtwdev->hal.rcr &= ~BIT_CBSSID_BCN;
2231 rtw_write32(rtwdev, REG_RCR, rtwdev->hal.rcr);
2240 struct rtw_hw_scan_info *scan_info = &rtwdev->scan_info;
2241 struct rtw_hal *hal = &rtwdev->hal;
2243 u8 chan = scan_info->op_chan;
2248 rtwdev->hal.rcr |= BIT_CBSSID_BCN;
2249 rtw_write32(rtwdev, REG_RCR, rtwdev->hal.rcr);
2253 rtwvif = (struct rtw_vif *)vif->drv_priv;
2256 rtw_phy_set_tx_power_level(rtwdev, hal->current_channel);
2257 ieee80211_wake_queues(rtwdev->hw);
2258 ieee80211_scan_completed(rtwdev->hw, &info);
2260 rtwvif->scan_req = NULL;
2261 rtwvif->scan_ies = NULL;
2262 rtwdev->scan_info.scanning_vif = NULL;
2268 struct cfg80211_scan_request *req = rtwvif->scan_req;
2269 int size = req->n_channels * (RTW_CH_INFO_SIZE + RTW_EX_CH_INFO_SIZE);
2275 return -ENOMEM;
2283 list->buf_size = size;
2284 list->size = 0;
2285 list->ch_num = 0;
2296 struct rtw_vif *rtwvif = vif ? (struct rtw_vif *)vif->drv_priv : NULL;
2297 struct rtw_hw_scan_info *scan_info = &rtwdev->scan_info;
2303 return -EINVAL;
2306 cs_option.back_op_en = scan_info->op_chan != 0;
2314 if (rtwdev->ap_active) {
2325 struct ieee80211_vif *vif = rtwdev->scan_info.scanning_vif;
2327 if (!rtw_fw_feature_check(&rtwdev->fw, FW_FEATURE_SCAN_OFFLOAD))
2336 struct ieee80211_vif *vif = rtwdev->scan_info.scanning_vif;
2341 if (!test_bit(RTW_FLAG_SCANNING, rtwdev->flags))
2345 rc = GET_SCAN_REPORT_RETURN_CODE(c2h->payload);
2355 struct rtw_hw_scan_info *scan_info = &rtwdev->scan_info;
2356 struct rtw_hal *hal = &rtwdev->hal;
2360 scan_info->op_chan = hal->current_channel;
2361 scan_info->op_bw = hal->current_band_width;
2362 scan_info->op_pri_ch_idx = hal->current_primary_channel_index;
2363 scan_info->op_pri_ch = hal->primary_channel;
2365 band = scan_info->op_chan > 14 ? RTW_BAND_5G : RTW_BAND_2G;
2366 rtw_update_channel(rtwdev, scan_info->op_chan,
2367 scan_info->op_pri_ch,
2368 band, scan_info->op_bw);
2374 struct rtw_hw_scan_info *scan_info = &rtwdev->scan_info;
2376 scan_info->op_chan = 0;
2377 scan_info->op_bw = 0;
2378 scan_info->op_pri_ch_idx = 0;
2379 scan_info->op_pri_ch = 0;
2384 struct rtw_hw_scan_info *scan_info = &rtwdev->scan_info;
2386 return channel == scan_info->op_chan;
2391 struct rtw_hal *hal = &rtwdev->hal;
2396 if (!test_bit(RTW_FLAG_SCANNING, rtwdev->flags))
2400 chan = GET_CHAN_SWITCH_CENTRAL_CH(c2h->payload);
2401 id = GET_CHAN_SWITCH_ID(c2h->payload);
2402 status = GET_CHAN_SWITCH_STATUS(c2h->payload);
2410 ieee80211_wake_queues(rtwdev->hw);
2419 if (test_bit(RTW_FLAG_SCANNING, rtwdev->flags))
2427 * if next channel is non-op channel.
2430 rtw_is_op_chan(rtwdev, hal->current_channel)) {
2432 ieee80211_stop_queues(rtwdev->hw);