Lines Matching +full:sar +full:- +full:threshold +full:- +full:num

1 // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
2 /* Copyright(c) 2018-2019 Realtek Corporation
20 #include "sar.h"
159 .n_bitrates = ARRAY_SIZE(rtw_ratetable) - 4,
172 struct rtw_bf_info *bf_info = &rtwdev->bf_info; in rtw_dynamic_csi_rate()
176 if (rtwvif->bfee.role != RTW_BFEE_SU && in rtw_dynamic_csi_rate()
177 rtwvif->bfee.role != RTW_BFEE_MU) in rtw_dynamic_csi_rate()
180 rtw_chip_cfg_csi_rate(rtwdev, rtwdev->dm_info.min_rssi, in rtw_dynamic_csi_rate()
181 bf_info->cur_csi_rpt_rate, in rtw_dynamic_csi_rate()
184 if (new_csi_rate_idx != bf_info->cur_csi_rpt_rate) in rtw_dynamic_csi_rate()
185 bf_info->cur_csi_rpt_rate = new_csi_rate_idx; in rtw_dynamic_csi_rate()
191 struct rtw_vif *rtwvif = (struct rtw_vif *)vif->drv_priv; in rtw_vif_watch_dog_iter()
193 if (vif->type == NL80211_IFTYPE_STATION) in rtw_vif_watch_dog_iter()
194 if (vif->cfg.assoc) in rtw_vif_watch_dog_iter()
195 iter_data->rtwvif = rtwvif; in rtw_vif_watch_dog_iter()
197 rtw_dynamic_csi_rate(iter_data->rtwdev, rtwvif); in rtw_vif_watch_dog_iter()
199 rtwvif->stats.tx_unicast = 0; in rtw_vif_watch_dog_iter()
200 rtwvif->stats.rx_unicast = 0; in rtw_vif_watch_dog_iter()
201 rtwvif->stats.tx_cnt = 0; in rtw_vif_watch_dog_iter()
202 rtwvif->stats.rx_cnt = 0; in rtw_vif_watch_dog_iter()
212 struct rtw_traffic_stats *stats = &rtwdev->stats; in rtw_watch_dog_work()
214 bool busy_traffic = test_bit(RTW_FLAG_BUSY_TRAFFIC, rtwdev->flags); in rtw_watch_dog_work()
218 mutex_lock(&rtwdev->mutex); in rtw_watch_dog_work()
220 if (!test_bit(RTW_FLAG_RUNNING, rtwdev->flags)) in rtw_watch_dog_work()
223 ieee80211_queue_delayed_work(rtwdev->hw, &rtwdev->watch_dog_work, in rtw_watch_dog_work()
226 if (rtwdev->stats.tx_cnt > 100 || rtwdev->stats.rx_cnt > 100) in rtw_watch_dog_work()
227 set_bit(RTW_FLAG_BUSY_TRAFFIC, rtwdev->flags); in rtw_watch_dog_work()
229 clear_bit(RTW_FLAG_BUSY_TRAFFIC, rtwdev->flags); in rtw_watch_dog_work()
231 if (busy_traffic != test_bit(RTW_FLAG_BUSY_TRAFFIC, rtwdev->flags)) in rtw_watch_dog_work()
234 if (stats->tx_cnt > RTW_LPS_THRESHOLD || in rtw_watch_dog_work()
235 stats->rx_cnt > RTW_LPS_THRESHOLD) in rtw_watch_dog_work()
240 tx_unicast_mbps = stats->tx_unicast >> RTW_TP_SHIFT; in rtw_watch_dog_work()
241 rx_unicast_mbps = stats->rx_unicast >> RTW_TP_SHIFT; in rtw_watch_dog_work()
243 ewma_tp_add(&stats->tx_ewma_tp, tx_unicast_mbps); in rtw_watch_dog_work()
244 ewma_tp_add(&stats->rx_ewma_tp, rx_unicast_mbps); in rtw_watch_dog_work()
245 stats->tx_throughput = ewma_tp_read(&stats->tx_ewma_tp); in rtw_watch_dog_work()
246 stats->rx_throughput = ewma_tp_read(&stats->rx_ewma_tp); in rtw_watch_dog_work()
249 stats->tx_unicast = 0; in rtw_watch_dog_work()
250 stats->rx_unicast = 0; in rtw_watch_dog_work()
251 stats->tx_cnt = 0; in rtw_watch_dog_work()
252 stats->rx_cnt = 0; in rtw_watch_dog_work()
254 if (test_bit(RTW_FLAG_SCANNING, rtwdev->flags)) in rtw_watch_dog_work()
269 * to avoid taking local->iflist_mtx mutex in rtw_watch_dog_work()
278 * ps by vif->type and vif->cfg.ps, all we need to do here is to in rtw_watch_dog_work()
280 * threshold. in rtw_watch_dog_work()
282 if (rtwdev->ps_enabled && data.rtwvif && !ps_active && in rtw_watch_dog_work()
283 !rtwdev->beacon_loss && !rtwdev->ap_active) in rtw_watch_dog_work()
284 rtw_enter_lps(rtwdev, data.rtwvif->port); in rtw_watch_dog_work()
286 rtwdev->watch_dog_cnt++; in rtw_watch_dog_work()
289 mutex_unlock(&rtwdev->mutex); in rtw_watch_dog_work()
297 skb_queue_walk_safe(&rtwdev->c2h_queue, skb, tmp) { in rtw_c2h_work()
298 skb_unlink(skb, &rtwdev->c2h_queue); in rtw_c2h_work()
308 mutex_lock(&rtwdev->mutex); in rtw_ips_work()
309 if (rtwdev->hw->conf.flags & IEEE80211_CONF_IDLE) in rtw_ips_work()
311 mutex_unlock(&rtwdev->mutex); in rtw_ips_work()
318 struct rtw_dev *rtwdev = si->rtwdev; in rtw_sta_rc_work()
320 mutex_lock(&rtwdev->mutex); in rtw_sta_rc_work()
322 mutex_unlock(&rtwdev->mutex); in rtw_sta_rc_work()
328 struct rtw_sta_info *si = (struct rtw_sta_info *)sta->drv_priv; in rtw_sta_add()
329 struct rtw_vif *rtwvif = (struct rtw_vif *)vif->drv_priv; in rtw_sta_add()
332 if (vif->type == NL80211_IFTYPE_STATION) { in rtw_sta_add()
333 si->mac_id = rtwvif->mac_id; in rtw_sta_add()
335 si->mac_id = rtw_acquire_macid(rtwdev); in rtw_sta_add()
336 if (si->mac_id >= RTW_MAX_MAC_ID_NUM) in rtw_sta_add()
337 return -ENOSPC; in rtw_sta_add()
340 si->rtwdev = rtwdev; in rtw_sta_add()
341 si->sta = sta; in rtw_sta_add()
342 si->vif = vif; in rtw_sta_add()
343 si->init_ra_lv = 1; in rtw_sta_add()
344 ewma_rssi_init(&si->avg_rssi); in rtw_sta_add()
345 for (i = 0; i < ARRAY_SIZE(sta->txq); i++) in rtw_sta_add()
346 rtw_txq_init(rtwdev, sta->txq[i]); in rtw_sta_add()
347 INIT_WORK(&si->rc_work, rtw_sta_rc_work); in rtw_sta_add()
350 rtw_fw_media_status_report(rtwdev, si->mac_id, true); in rtw_sta_add()
352 rtwdev->sta_cnt++; in rtw_sta_add()
353 rtwdev->beacon_loss = false; in rtw_sta_add()
355 sta->addr, si->mac_id); in rtw_sta_add()
363 struct rtw_sta_info *si = (struct rtw_sta_info *)sta->drv_priv; in rtw_sta_remove()
364 struct ieee80211_vif *vif = si->vif; in rtw_sta_remove()
367 cancel_work_sync(&si->rc_work); in rtw_sta_remove()
369 if (vif->type != NL80211_IFTYPE_STATION) in rtw_sta_remove()
370 rtw_release_macid(rtwdev, si->mac_id); in rtw_sta_remove()
372 rtw_fw_media_status_report(rtwdev, si->mac_id, false); in rtw_sta_remove()
374 for (i = 0; i < ARRAY_SIZE(sta->txq); i++) in rtw_sta_remove()
375 rtw_txq_cleanup(rtwdev, sta->txq[i]); in rtw_sta_remove()
377 kfree(si->mask); in rtw_sta_remove()
379 rtwdev->sta_cnt--; in rtw_sta_remove()
381 sta->addr, si->mac_id); in rtw_sta_remove()
393 const struct rtw_chip_info *chip = rtwdev->chip; in rtw_fwcd_prep()
394 struct rtw_fwcd_desc *desc = &rtwdev->fw.fwcd_desc; in rtw_fwcd_prep()
395 const struct rtw_fwcd_segs *segs = chip->fwcd_segs; in rtw_fwcd_prep()
396 u32 prep_size = chip->fw_rxff_size + sizeof(struct rtw_fwcd_hdr); in rtw_fwcd_prep()
400 prep_size += segs->num * sizeof(struct rtw_fwcd_hdr); in rtw_fwcd_prep()
402 for (i = 0; i < segs->num; i++) in rtw_fwcd_prep()
403 prep_size += segs->segs[i]; in rtw_fwcd_prep()
406 desc->data = vmalloc(prep_size); in rtw_fwcd_prep()
407 if (!desc->data) in rtw_fwcd_prep()
408 return -ENOMEM; in rtw_fwcd_prep()
410 desc->size = prep_size; in rtw_fwcd_prep()
411 desc->next = desc->data; in rtw_fwcd_prep()
418 struct rtw_fwcd_desc *desc = &rtwdev->fw.fwcd_desc; in rtw_fwcd_next()
422 if (!desc->data) { in rtw_fwcd_next()
427 next = desc->next + sizeof(struct rtw_fwcd_hdr); in rtw_fwcd_next()
428 if (next - desc->data + size > desc->size) { in rtw_fwcd_next()
433 hdr = (struct rtw_fwcd_hdr *)(desc->next); in rtw_fwcd_next()
434 hdr->item = item; in rtw_fwcd_next()
435 hdr->size = size; in rtw_fwcd_next()
436 hdr->padding1 = 0x01234567; in rtw_fwcd_next()
437 hdr->padding2 = 0x89abcdef; in rtw_fwcd_next()
438 desc->next = next + size; in rtw_fwcd_next()
445 struct rtw_fwcd_desc *desc = &rtwdev->fw.fwcd_desc; in rtw_fwcd_dump()
454 dev_coredumpv(rtwdev->dev, desc->data, desc->size, GFP_KERNEL); in rtw_fwcd_dump()
459 struct rtw_fwcd_desc *desc = &rtwdev->fw.fwcd_desc; in rtw_fwcd_free()
463 vfree(desc->data); in rtw_fwcd_free()
466 desc->data = NULL; in rtw_fwcd_free()
467 desc->next = NULL; in rtw_fwcd_free()
472 u32 size = rtwdev->chip->fw_rxff_size; in rtw_fw_dump_crash_log()
478 return -ENOMEM; in rtw_fw_dump_crash_log()
482 return -EINVAL; in rtw_fw_dump_crash_log()
487 return -EINVAL; in rtw_fw_dump_crash_log()
494 return -EINVAL; in rtw_fw_dump_crash_log()
503 u32 rxff = rtwdev->chip->fw_rxff_size; in rtw_dump_fw()
510 return -ENOMEM; in rtw_dump_fw()
533 size -= dump_size; in rtw_dump_fw()
547 WARN(1, "should be 4-byte aligned, addr = 0x%08x\n", addr); in rtw_dump_reg()
548 return -EINVAL; in rtw_dump_reg()
553 return -ENOMEM; in rtw_dump_reg()
570 if (conf && vif->cfg.assoc) { in rtw_vif_assoc_changed()
571 rtwvif->aid = vif->cfg.aid; in rtw_vif_assoc_changed()
572 rtwvif->net_type = RTW_NET_MGD_LINKED; in rtw_vif_assoc_changed()
574 rtwvif->aid = 0; in rtw_vif_assoc_changed()
575 rtwvif->net_type = RTW_NET_NO_LINK; in rtw_vif_assoc_changed()
586 struct rtw_sec_desc *sec = &rtwdev->sec; in rtw_reset_key_iter()
588 rtw_sec_clear_cam(rtwdev, sec, key->hw_key_idx); in rtw_reset_key_iter()
595 if (rtwdev->sta_cnt == 0) { in rtw_reset_sta_iter()
605 struct rtw_vif *rtwvif = (struct rtw_vif *)vif->drv_priv; in rtw_reset_vif_iter()
609 rtw_txq_cleanup(rtwdev, vif->txq); in rtw_reset_vif_iter()
611 rtw_release_macid(rtwdev, rtwvif->mac_id); in rtw_reset_vif_iter()
616 if (!test_bit(RTW_FLAG_RESTARTING, rtwdev->flags)) in rtw_fw_recovery()
617 ieee80211_queue_work(rtwdev->hw, &rtwdev->fw_recovery_work); in rtw_fw_recovery()
624 set_bit(RTW_FLAG_RESTARTING, rtwdev->flags); in __fw_recovery_work()
625 clear_bit(RTW_FLAG_RESTART_TRIGGERING, rtwdev->flags); in __fw_recovery_work()
649 bitmap_zero(rtwdev->hw_port, RTW_PORT_NUM); in __fw_recovery_work()
658 mutex_lock(&rtwdev->mutex); in rtw_fw_recovery_work()
660 mutex_unlock(&rtwdev->mutex); in rtw_fw_recovery_work()
662 ieee80211_restart_hw(rtwdev->hw); in rtw_fw_recovery_work()
670 struct rtw_sta_info *si = (struct rtw_sta_info *)sta->drv_priv; in rtw_txq_ba_iter()
674 tid = find_first_bit(si->tid_ba, IEEE80211_NUM_TIDS); in rtw_txq_ba_iter()
676 clear_bit(tid, si->tid_ba); in rtw_txq_ba_iter()
678 if (ret == -EINVAL) { in rtw_txq_ba_iter()
682 txq = sta->txq[tid]; in rtw_txq_ba_iter()
683 rtwtxq = (struct rtw_txq *)txq->drv_priv; in rtw_txq_ba_iter()
684 set_bit(RTW_TXQ_BLOCK_BA, &rtwtxq->flags); in rtw_txq_ba_iter()
687 tid = find_first_bit(si->tid_ba, IEEE80211_NUM_TIDS); in rtw_txq_ba_iter()
702 pkt_stat->band = NL80211_BAND_2GHZ; in rtw_set_rx_freq_band()
704 pkt_stat->band = NL80211_BAND_5GHZ; in rtw_set_rx_freq_band()
708 pkt_stat->freq = ieee80211_channel_to_frequency(channel, pkt_stat->band); in rtw_set_rx_freq_band()
715 rtw_write8(rtwdev, REG_DTIM_COUNTER_ROOT, dtim_period - 1); in rtw_set_dtim_period()
723 struct rtw_hal *hal = &rtwdev->hal; in rtw_update_channel()
724 u8 *cch_by_bw = hal->cch_by_bw; in rtw_update_channel()
751 if (primary_freq - center_freq == 10) in rtw_update_channel()
761 if (center_freq - primary_freq == 10) in rtw_update_channel()
769 cch_by_bw[RTW_CHANNEL_WIDTH_40] = center_channel - 4; in rtw_update_channel()
788 WARN(1, "unknown ch(%u) to SAR band\n", center_channel); in rtw_update_channel()
793 hal->current_primary_channel_index = primary_channel_idx; in rtw_update_channel()
794 hal->current_band_width = bandwidth; in rtw_update_channel()
795 hal->primary_channel = primary_channel; in rtw_update_channel()
796 hal->current_channel = center_channel; in rtw_update_channel()
797 hal->current_band_type = band; in rtw_update_channel()
798 hal->sar_band = sar_band; in rtw_update_channel()
804 struct ieee80211_channel *channel = chandef->chan; in rtw_get_channel_params()
805 enum nl80211_chan_width width = chandef->width; in rtw_get_channel_params()
810 center_chan = channel->hw_value; in rtw_get_channel_params()
811 primary_freq = channel->center_freq; in rtw_get_channel_params()
812 center_freq = chandef->center_freq1; in rtw_get_channel_params()
822 center_chan -= 2; in rtw_get_channel_params()
829 if (primary_freq - center_freq == 10) in rtw_get_channel_params()
830 center_chan -= 2; in rtw_get_channel_params()
832 center_chan -= 6; in rtw_get_channel_params()
834 if (center_freq - primary_freq == 10) in rtw_get_channel_params()
845 chan_params->center_chan = center_chan; in rtw_get_channel_params()
846 chan_params->bandwidth = bandwidth; in rtw_get_channel_params()
847 chan_params->primary_chan = channel->hw_value; in rtw_get_channel_params()
852 const struct rtw_chip_info *chip = rtwdev->chip; in rtw_set_channel()
853 struct ieee80211_hw *hw = rtwdev->hw; in rtw_set_channel()
854 struct rtw_hal *hal = &rtwdev->hal; in rtw_set_channel()
858 rtw_get_channel_params(&hw->conf.chandef, &ch_param); in rtw_set_channel()
869 if (rtwdev->scan_info.op_chan) in rtw_set_channel()
872 chip->ops->set_channel(rtwdev, center_chan, bandwidth, in rtw_set_channel()
873 hal->current_primary_channel_index); in rtw_set_channel()
875 if (hal->current_band_type == RTW_BAND_5G) { in rtw_set_channel()
878 if (test_bit(RTW_FLAG_SCANNING, rtwdev->flags)) in rtw_set_channel()
890 if (!test_bit(RTW_FLAG_SCANNING, rtwdev->flags)) in rtw_set_channel()
891 rtwdev->need_rfk = true; in rtw_set_channel()
896 const struct rtw_chip_info *chip = rtwdev->chip; in rtw_chip_prepare_tx()
898 if (rtwdev->need_rfk) { in rtw_chip_prepare_tx()
899 rtwdev->need_rfk = false; in rtw_chip_prepare_tx()
900 chip->ops->phy_calibration(rtwdev); in rtw_chip_prepare_tx()
919 addr = rtwvif->conf->mac_addr.addr; in rtw_vif_port_config()
920 rtw_vif_write_addr(rtwdev, addr, rtwvif->mac_addr); in rtw_vif_port_config()
923 addr = rtwvif->conf->bssid.addr; in rtw_vif_port_config()
924 rtw_vif_write_addr(rtwdev, addr, rtwvif->bssid); in rtw_vif_port_config()
927 addr = rtwvif->conf->net_type.addr; in rtw_vif_port_config()
928 mask = rtwvif->conf->net_type.mask; in rtw_vif_port_config()
929 rtw_write32_mask(rtwdev, addr, mask, rtwvif->net_type); in rtw_vif_port_config()
932 addr = rtwvif->conf->aid.addr; in rtw_vif_port_config()
933 mask = rtwvif->conf->aid.mask; in rtw_vif_port_config()
934 rtw_write32_mask(rtwdev, addr, mask, rtwvif->aid); in rtw_vif_port_config()
937 addr = rtwvif->conf->bcn_ctrl.addr; in rtw_vif_port_config()
938 mask = rtwvif->conf->bcn_ctrl.mask; in rtw_vif_port_config()
939 rtw_write8_mask(rtwdev, addr, mask, rtwvif->bcn_ctrl); in rtw_vif_port_config()
965 const struct rtw_chip_info *chip = rtwdev->chip; in rtw_hw_config_rf_ant_num()
966 struct rtw_hal *hal = &rtwdev->hal; in rtw_hw_config_rf_ant_num()
969 hw_ant_num >= hal->rf_path_num) in rtw_hw_config_rf_ant_num()
974 hal->rf_type = RF_1T1R; in rtw_hw_config_rf_ant_num()
975 hal->rf_path_num = 1; in rtw_hw_config_rf_ant_num()
976 if (!chip->fix_rf_phy_num) in rtw_hw_config_rf_ant_num()
977 hal->rf_phy_num = hal->rf_path_num; in rtw_hw_config_rf_ant_num()
978 hal->antenna_tx = BB_PATH_A; in rtw_hw_config_rf_ant_num()
979 hal->antenna_rx = BB_PATH_A; in rtw_hw_config_rf_ant_num()
990 u16 mcs_map = le16_to_cpu(sta->deflink.vht_cap.vht_mcs.rx_mcs_map); in get_vht_ra_mask()
1119 u8 rssi_level = si->rssi_level; in rtw_rate_mask_rssi()
1152 struct rtw_hal *hal = &rtwdev->hal; in rtw_rate_mask_cfg()
1153 const struct cfg80211_bitrate_mask *mask = si->mask; in rtw_rate_mask_cfg()
1157 if (!si->use_cfg_mask) in rtw_rate_mask_cfg()
1160 band = hal->current_band_type; in rtw_rate_mask_cfg()
1163 cfg_mask = mask->control[band].legacy; in rtw_rate_mask_cfg()
1166 cfg_mask = u64_encode_bits(mask->control[band].legacy, in rtw_rate_mask_cfg()
1172 cfg_mask |= u64_encode_bits(mask->control[band].ht_mcs[0], in rtw_rate_mask_cfg()
1175 cfg_mask |= u64_encode_bits(mask->control[band].ht_mcs[1], in rtw_rate_mask_cfg()
1179 cfg_mask |= u64_encode_bits(mask->control[band].vht_mcs[0], in rtw_rate_mask_cfg()
1182 cfg_mask |= u64_encode_bits(mask->control[band].vht_mcs[1], in rtw_rate_mask_cfg()
1194 struct rtw_dm_info *dm_info = &rtwdev->dm_info; in rtw_update_sta_info()
1195 struct ieee80211_sta *sta = si->sta; in rtw_update_sta_info()
1196 struct rtw_efuse *efuse = &rtwdev->efuse; in rtw_update_sta_info()
1197 struct rtw_hal *hal = &rtwdev->hal; in rtw_update_sta_info()
1210 if (sta->deflink.vht_cap.vht_supported) { in rtw_update_sta_info()
1213 if (sta->deflink.vht_cap.cap & IEEE80211_VHT_CAP_RXSTBC_MASK) in rtw_update_sta_info()
1215 if (sta->deflink.vht_cap.cap & IEEE80211_VHT_CAP_RXLDPC) in rtw_update_sta_info()
1217 } else if (sta->deflink.ht_cap.ht_supported) { in rtw_update_sta_info()
1218 ra_mask |= (sta->deflink.ht_cap.mcs.rx_mask[1] << 20) | in rtw_update_sta_info()
1219 (sta->deflink.ht_cap.mcs.rx_mask[0] << 12); in rtw_update_sta_info()
1220 if (sta->deflink.ht_cap.cap & IEEE80211_HT_CAP_RX_STBC) in rtw_update_sta_info()
1222 if (sta->deflink.ht_cap.cap & IEEE80211_HT_CAP_LDPC_CODING) in rtw_update_sta_info()
1226 if (efuse->hw_cap.nss == 1 || rtwdev->hal.txrx_1ss) in rtw_update_sta_info()
1229 if (hal->current_band_type == RTW_BAND_5G) { in rtw_update_sta_info()
1230 ra_mask |= (u64)sta->deflink.supp_rates[NL80211_BAND_5GHZ] << 4; in rtw_update_sta_info()
1232 if (sta->deflink.vht_cap.vht_supported) { in rtw_update_sta_info()
1235 } else if (sta->deflink.ht_cap.ht_supported) { in rtw_update_sta_info()
1241 dm_info->rrsr_val_init = RRSR_INIT_5G; in rtw_update_sta_info()
1242 } else if (hal->current_band_type == RTW_BAND_2G) { in rtw_update_sta_info()
1243 ra_mask |= sta->deflink.supp_rates[NL80211_BAND_2GHZ]; in rtw_update_sta_info()
1245 if (sta->deflink.vht_cap.vht_supported) { in rtw_update_sta_info()
1250 } else if (sta->deflink.ht_cap.ht_supported) { in rtw_update_sta_info()
1255 } else if (sta->deflink.supp_rates[0] <= 0xf) { in rtw_update_sta_info()
1261 dm_info->rrsr_val_init = RRSR_INIT_2G; in rtw_update_sta_info()
1268 switch (sta->deflink.bandwidth) { in rtw_update_sta_info()
1271 is_support_sgi = sta->deflink.vht_cap.vht_supported && in rtw_update_sta_info()
1272 (sta->deflink.vht_cap.cap & IEEE80211_VHT_CAP_SHORT_GI_80); in rtw_update_sta_info()
1276 is_support_sgi = sta->deflink.ht_cap.ht_supported && in rtw_update_sta_info()
1277 (sta->deflink.ht_cap.cap & IEEE80211_HT_CAP_SGI_40); in rtw_update_sta_info()
1281 is_support_sgi = sta->deflink.ht_cap.ht_supported && in rtw_update_sta_info()
1282 (sta->deflink.ht_cap.cap & IEEE80211_HT_CAP_SGI_20); in rtw_update_sta_info()
1286 if (sta->deflink.vht_cap.vht_supported && ra_mask & 0xffc00000) { in rtw_update_sta_info()
1289 } else if (sta->deflink.ht_cap.ht_supported && ra_mask & 0xfff00000) { in rtw_update_sta_info()
1300 si->bw_mode = bw_mode; in rtw_update_sta_info()
1301 si->stbc_en = stbc_en; in rtw_update_sta_info()
1302 si->ldpc_en = ldpc_en; in rtw_update_sta_info()
1303 si->rf_type = rf_type; in rtw_update_sta_info()
1304 si->sgi_enable = is_support_sgi; in rtw_update_sta_info()
1305 si->vht_enable = is_vht_enable; in rtw_update_sta_info()
1306 si->ra_mask = ra_mask; in rtw_update_sta_info()
1307 si->rate_id = rate_id; in rtw_update_sta_info()
1314 const struct rtw_chip_info *chip = rtwdev->chip; in rtw_wait_firmware_completion()
1318 fw = &rtwdev->fw; in rtw_wait_firmware_completion()
1319 wait_for_completion(&fw->completion); in rtw_wait_firmware_completion()
1320 if (!fw->firmware) in rtw_wait_firmware_completion()
1321 ret = -EINVAL; in rtw_wait_firmware_completion()
1323 if (chip->wow_fw_name) { in rtw_wait_firmware_completion()
1324 fw = &rtwdev->wow_fw; in rtw_wait_firmware_completion()
1325 wait_for_completion(&fw->completion); in rtw_wait_firmware_completion()
1326 if (!fw->firmware) in rtw_wait_firmware_completion()
1327 ret = -EINVAL; in rtw_wait_firmware_completion()
1336 const struct rtw_chip_info *chip = rtwdev->chip; in rtw_update_lps_deep_mode()
1338 if (rtw_disable_lps_deep_mode || !chip->lps_deep_mode_supported || in rtw_update_lps_deep_mode()
1339 !fw->feature) in rtw_update_lps_deep_mode()
1342 if ((chip->lps_deep_mode_supported & BIT(LPS_DEEP_MODE_PG)) && in rtw_update_lps_deep_mode()
1346 if ((chip->lps_deep_mode_supported & BIT(LPS_DEEP_MODE_LCLK)) && in rtw_update_lps_deep_mode()
1355 const struct rtw_chip_info *chip = rtwdev->chip; in rtw_power_on()
1356 struct rtw_fw_state *fw = &rtwdev->fw; in rtw_power_on()
1392 chip->ops->phy_set_param(rtwdev); in rtw_power_on()
1404 wifi_only = !rtwdev->efuse.btcoex; in rtw_power_on()
1419 if (!rtw_fw_feature_check(&rtwdev->fw, FW_FEATURE_NOTIFY_SCAN)) in rtw_core_fw_scan_notify()
1425 reinit_completion(&rtwdev->fw_scan_density); in rtw_core_fw_scan_notify()
1427 if (!wait_for_completion_timeout(&rtwdev->fw_scan_density, in rtw_core_fw_scan_notify()
1441 if (hw_scan && (rtwdev->hw->conf.flags & IEEE80211_CONF_IDLE)) { in rtw_core_scan_start()
1449 ether_addr_copy(rtwvif->mac_addr, mac_addr); in rtw_core_scan_start()
1456 set_bit(RTW_FLAG_DIG_DISABLE, rtwdev->flags); in rtw_core_scan_start()
1457 set_bit(RTW_FLAG_SCANNING, rtwdev->flags); in rtw_core_scan_start()
1463 struct rtw_vif *rtwvif = vif ? (struct rtw_vif *)vif->drv_priv : NULL; in rtw_core_scan_complete()
1469 clear_bit(RTW_FLAG_SCANNING, rtwdev->flags); in rtw_core_scan_complete()
1470 clear_bit(RTW_FLAG_DIG_DISABLE, rtwdev->flags); in rtw_core_scan_complete()
1474 ether_addr_copy(rtwvif->mac_addr, vif->addr); in rtw_core_scan_complete()
1480 if (hw_scan && (rtwdev->hw->conf.flags & IEEE80211_CONF_IDLE)) in rtw_core_scan_complete()
1481 ieee80211_queue_work(rtwdev->hw, &rtwdev->ips_work); in rtw_core_scan_complete()
1494 rtwdev->lps_conf.deep_mode = rtw_update_lps_deep_mode(rtwdev, &rtwdev->fw); in rtw_core_start()
1495 rtwdev->lps_conf.wow_deep_mode = rtw_update_lps_deep_mode(rtwdev, &rtwdev->wow_fw); in rtw_core_start()
1498 rtw_write32(rtwdev, REG_RCR, rtwdev->hal.rcr); in rtw_core_start()
1500 ieee80211_queue_delayed_work(rtwdev->hw, &rtwdev->watch_dog_work, in rtw_core_start()
1503 set_bit(RTW_FLAG_RUNNING, rtwdev->flags); in rtw_core_start()
1517 struct rtw_coex *coex = &rtwdev->coex; in rtw_core_stop()
1519 clear_bit(RTW_FLAG_RUNNING, rtwdev->flags); in rtw_core_stop()
1520 clear_bit(RTW_FLAG_FW_RUNNING, rtwdev->flags); in rtw_core_stop()
1522 mutex_unlock(&rtwdev->mutex); in rtw_core_stop()
1524 cancel_work_sync(&rtwdev->c2h_work); in rtw_core_stop()
1525 cancel_work_sync(&rtwdev->update_beacon_work); in rtw_core_stop()
1526 cancel_delayed_work_sync(&rtwdev->watch_dog_work); in rtw_core_stop()
1527 cancel_delayed_work_sync(&coex->bt_relink_work); in rtw_core_stop()
1528 cancel_delayed_work_sync(&coex->bt_reenable_work); in rtw_core_stop()
1529 cancel_delayed_work_sync(&coex->defreeze_work); in rtw_core_stop()
1530 cancel_delayed_work_sync(&coex->wl_remain_work); in rtw_core_stop()
1531 cancel_delayed_work_sync(&coex->bt_remain_work); in rtw_core_stop()
1532 cancel_delayed_work_sync(&coex->wl_connecting_work); in rtw_core_stop()
1533 cancel_delayed_work_sync(&coex->bt_multi_link_remain_work); in rtw_core_stop()
1534 cancel_delayed_work_sync(&coex->wl_ccklock_work); in rtw_core_stop()
1536 mutex_lock(&rtwdev->mutex); in rtw_core_stop()
1544 const struct rtw_chip_info *chip = rtwdev->chip; in rtw_init_ht_cap()
1545 struct rtw_efuse *efuse = &rtwdev->efuse; in rtw_init_ht_cap()
1547 ht_cap->ht_supported = true; in rtw_init_ht_cap()
1548 ht_cap->cap = 0; in rtw_init_ht_cap()
1549 ht_cap->cap |= IEEE80211_HT_CAP_SGI_20 | in rtw_init_ht_cap()
1554 ht_cap->cap |= IEEE80211_HT_CAP_LDPC_CODING; in rtw_init_ht_cap()
1556 ht_cap->cap |= IEEE80211_HT_CAP_TX_STBC; in rtw_init_ht_cap()
1558 if (efuse->hw_cap.bw & BIT(RTW_CHANNEL_WIDTH_40)) in rtw_init_ht_cap()
1559 ht_cap->cap |= IEEE80211_HT_CAP_SUP_WIDTH_20_40 | in rtw_init_ht_cap()
1562 ht_cap->ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K; in rtw_init_ht_cap()
1563 ht_cap->ampdu_density = chip->ampdu_density; in rtw_init_ht_cap()
1564 ht_cap->mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED; in rtw_init_ht_cap()
1565 if (efuse->hw_cap.nss > 1) { in rtw_init_ht_cap()
1566 ht_cap->mcs.rx_mask[0] = 0xFF; in rtw_init_ht_cap()
1567 ht_cap->mcs.rx_mask[1] = 0xFF; in rtw_init_ht_cap()
1568 ht_cap->mcs.rx_mask[4] = 0x01; in rtw_init_ht_cap()
1569 ht_cap->mcs.rx_highest = cpu_to_le16(300); in rtw_init_ht_cap()
1571 ht_cap->mcs.rx_mask[0] = 0xFF; in rtw_init_ht_cap()
1572 ht_cap->mcs.rx_mask[1] = 0x00; in rtw_init_ht_cap()
1573 ht_cap->mcs.rx_mask[4] = 0x01; in rtw_init_ht_cap()
1574 ht_cap->mcs.rx_highest = cpu_to_le16(150); in rtw_init_ht_cap()
1581 struct rtw_efuse *efuse = &rtwdev->efuse; in rtw_init_vht_cap()
1585 if (efuse->hw_cap.ptcl != EFUSE_HW_CAP_IGNORE && in rtw_init_vht_cap()
1586 efuse->hw_cap.ptcl != EFUSE_HW_CAP_PTCL_VHT) in rtw_init_vht_cap()
1589 vht_cap->vht_supported = true; in rtw_init_vht_cap()
1590 vht_cap->cap = IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_11454 | in rtw_init_vht_cap()
1596 if (rtwdev->hal.rf_path_num > 1) in rtw_init_vht_cap()
1597 vht_cap->cap |= IEEE80211_VHT_CAP_TXSTBC; in rtw_init_vht_cap()
1598 vht_cap->cap |= IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE | in rtw_init_vht_cap()
1600 vht_cap->cap |= (rtwdev->hal.bfee_sts_cap << in rtw_init_vht_cap()
1604 vht_cap->cap |= IEEE80211_VHT_CAP_RXLDPC; in rtw_init_vht_cap()
1613 if (efuse->hw_cap.nss > 1) { in rtw_init_vht_cap()
1621 vht_cap->vht_mcs.rx_mcs_map = cpu_to_le16(mcs_map); in rtw_init_vht_cap()
1622 vht_cap->vht_mcs.tx_mcs_map = cpu_to_le16(mcs_map); in rtw_init_vht_cap()
1623 vht_cap->vht_mcs.rx_highest = highest; in rtw_init_vht_cap()
1624 vht_cap->vht_mcs.tx_highest = highest; in rtw_init_vht_cap()
1631 len = rtwdev->chip->max_scan_ie_len; in rtw_get_max_scan_ie_len()
1633 if (!rtw_fw_feature_check(&rtwdev->fw, FW_FEATURE_SCAN_OFFLOAD) && in rtw_get_max_scan_ie_len()
1634 rtwdev->chip->id == RTW_CHIP_TYPE_8822C) in rtw_get_max_scan_ie_len()
1636 else if (rtw_fw_feature_ext_check(&rtwdev->fw, FW_FEATURE_EXT_OLD_PAGE_NUM)) in rtw_get_max_scan_ie_len()
1637 len -= RTW_OLD_PROBE_PG_CNT * TX_PAGE_SIZE; in rtw_get_max_scan_ie_len()
1645 struct rtw_dev *rtwdev = hw->priv; in rtw_set_supported_band()
1648 if (chip->band & RTW_BAND_2G) { in rtw_set_supported_band()
1652 if (chip->ht_supported) in rtw_set_supported_band()
1653 rtw_init_ht_cap(rtwdev, &sband->ht_cap); in rtw_set_supported_band()
1654 hw->wiphy->bands[NL80211_BAND_2GHZ] = sband; in rtw_set_supported_band()
1657 if (chip->band & RTW_BAND_5G) { in rtw_set_supported_band()
1661 if (chip->ht_supported) in rtw_set_supported_band()
1662 rtw_init_ht_cap(rtwdev, &sband->ht_cap); in rtw_set_supported_band()
1663 if (chip->vht_supported) in rtw_set_supported_band()
1664 rtw_init_vht_cap(rtwdev, &sband->vht_cap); in rtw_set_supported_band()
1665 hw->wiphy->bands[NL80211_BAND_5GHZ] = sband; in rtw_set_supported_band()
1677 kfree(hw->wiphy->bands[NL80211_BAND_2GHZ]); in rtw_unset_supported_band()
1678 kfree(hw->wiphy->bands[NL80211_BAND_5GHZ]); in rtw_unset_supported_band()
1686 if (vif->type != NL80211_IFTYPE_STATION || !vif->cfg.assoc) in rtw_vif_smps_iter()
1689 if (rtwdev->hal.txrx_1ss) in rtw_vif_smps_iter()
1697 const struct rtw_chip_info *chip = rtwdev->chip; in rtw_set_txrx_1ss()
1698 struct rtw_hal *hal = &rtwdev->hal; in rtw_set_txrx_1ss()
1700 if (!chip->ops->config_txrx_mode || rtwdev->hal.txrx_1ss == txrx_1ss) in rtw_set_txrx_1ss()
1703 rtwdev->hal.txrx_1ss = txrx_1ss; in rtw_set_txrx_1ss()
1705 chip->ops->config_txrx_mode(rtwdev, BB_PATH_A, BB_PATH_A, false); in rtw_set_txrx_1ss()
1707 chip->ops->config_txrx_mode(rtwdev, hal->antenna_tx, in rtw_set_txrx_1ss()
1708 hal->antenna_rx, false); in rtw_set_txrx_1ss()
1717 (const struct rtw_fw_hdr *)fw->firmware->data; in __update_firmware_feature()
1719 feature = le32_to_cpu(fw_hdr->feature); in __update_firmware_feature()
1720 fw->feature = feature & FW_FEATURE_SIG ? feature : 0; in __update_firmware_feature()
1722 if (rtwdev->chip->id == RTW_CHIP_TYPE_8822C && in __update_firmware_feature()
1723 RTW_FW_SUIT_VER_CODE(rtwdev->fw) < RTW_FW_VER_CODE(9, 9, 13)) in __update_firmware_feature()
1724 fw->feature_ext |= FW_FEATURE_EXT_OLD_PAGE_NUM; in __update_firmware_feature()
1731 (const struct rtw_fw_hdr *)fw->firmware->data; in __update_firmware_info()
1733 fw->h2c_version = le16_to_cpu(fw_hdr->h2c_fmt_ver); in __update_firmware_info()
1734 fw->version = le16_to_cpu(fw_hdr->version); in __update_firmware_info()
1735 fw->sub_version = fw_hdr->subversion; in __update_firmware_info()
1736 fw->sub_index = fw_hdr->subindex; in __update_firmware_info()
1745 (struct rtw_fw_hdr_legacy *)fw->firmware->data; in __update_firmware_info_legacy()
1747 fw->h2c_version = 0; in __update_firmware_info_legacy()
1748 fw->version = le16_to_cpu(legacy->version); in __update_firmware_info_legacy()
1749 fw->sub_version = legacy->subversion1; in __update_firmware_info_legacy()
1750 fw->sub_index = legacy->subversion2; in __update_firmware_info_legacy()
1765 struct rtw_dev *rtwdev = fw->rtwdev; in rtw_load_firmware_cb()
1767 if (!firmware || !firmware->data) { in rtw_load_firmware_cb()
1769 complete_all(&fw->completion); in rtw_load_firmware_cb()
1773 fw->firmware = firmware; in rtw_load_firmware_cb()
1775 complete_all(&fw->completion); in rtw_load_firmware_cb()
1778 fw->type == RTW_WOWLAN_FW ? "WOW " : "", in rtw_load_firmware_cb()
1779 fw->version, fw->sub_version, fw->sub_index, fw->h2c_version); in rtw_load_firmware_cb()
1790 fw = &rtwdev->wow_fw; in rtw_load_firmware()
1791 fw_name = rtwdev->chip->wow_fw_name; in rtw_load_firmware()
1795 fw = &rtwdev->fw; in rtw_load_firmware()
1796 fw_name = rtwdev->chip->fw_name; in rtw_load_firmware()
1801 return -ENOENT; in rtw_load_firmware()
1804 fw->type = type; in rtw_load_firmware()
1805 fw->rtwdev = rtwdev; in rtw_load_firmware()
1806 init_completion(&fw->completion); in rtw_load_firmware()
1808 ret = request_firmware_nowait(THIS_MODULE, true, fw_name, rtwdev->dev, in rtw_load_firmware()
1820 const struct rtw_chip_info *chip = rtwdev->chip; in rtw_chip_parameter_setup()
1821 struct rtw_hal *hal = &rtwdev->hal; in rtw_chip_parameter_setup()
1822 struct rtw_efuse *efuse = &rtwdev->efuse; in rtw_chip_parameter_setup()
1826 rtwdev->hci.rpwm_addr = 0x03d9; in rtw_chip_parameter_setup()
1827 rtwdev->hci.cpwm_addr = 0x03da; in rtw_chip_parameter_setup()
1830 rtwdev->hci.rpwm_addr = REG_SDIO_HRPWM1; in rtw_chip_parameter_setup()
1831 rtwdev->hci.cpwm_addr = REG_SDIO_HCPWM1_V2; in rtw_chip_parameter_setup()
1834 rtwdev->hci.rpwm_addr = 0xfe58; in rtw_chip_parameter_setup()
1835 rtwdev->hci.cpwm_addr = 0xfe57; in rtw_chip_parameter_setup()
1839 return -EINVAL; in rtw_chip_parameter_setup()
1842 hal->chip_version = rtw_read32(rtwdev, REG_SYS_CFG1); in rtw_chip_parameter_setup()
1843 hal->cut_version = BIT_GET_CHIP_VER(hal->chip_version); in rtw_chip_parameter_setup()
1844 hal->mp_chip = (hal->chip_version & BIT_RTL_ID) ? 0 : 1; in rtw_chip_parameter_setup()
1845 if (hal->chip_version & BIT_RF_TYPE_ID) { in rtw_chip_parameter_setup()
1846 hal->rf_type = RF_2T2R; in rtw_chip_parameter_setup()
1847 hal->rf_path_num = 2; in rtw_chip_parameter_setup()
1848 hal->antenna_tx = BB_PATH_AB; in rtw_chip_parameter_setup()
1849 hal->antenna_rx = BB_PATH_AB; in rtw_chip_parameter_setup()
1851 hal->rf_type = RF_1T1R; in rtw_chip_parameter_setup()
1852 hal->rf_path_num = 1; in rtw_chip_parameter_setup()
1853 hal->antenna_tx = BB_PATH_A; in rtw_chip_parameter_setup()
1854 hal->antenna_rx = BB_PATH_A; in rtw_chip_parameter_setup()
1856 hal->rf_phy_num = chip->fix_rf_phy_num ? chip->fix_rf_phy_num : in rtw_chip_parameter_setup()
1857 hal->rf_path_num; in rtw_chip_parameter_setup()
1859 efuse->physical_size = chip->phy_efuse_size; in rtw_chip_parameter_setup()
1860 efuse->logical_size = chip->log_efuse_size; in rtw_chip_parameter_setup()
1861 efuse->protect_size = chip->ptct_efuse_size; in rtw_chip_parameter_setup()
1864 rtwdev->hal.rcr |= BIT_VHT_DACK; in rtw_chip_parameter_setup()
1866 hal->bfee_sts_cap = 3; in rtw_chip_parameter_setup()
1873 struct rtw_fw_state *fw = &rtwdev->fw; in rtw_chip_efuse_enable()
1890 wait_for_completion(&fw->completion); in rtw_chip_efuse_enable()
1891 if (!fw->firmware) { in rtw_chip_efuse_enable()
1892 ret = -EINVAL; in rtw_chip_efuse_enable()
1914 struct rtw_efuse *efuse = &rtwdev->efuse; in rtw_dump_hw_feature()
1923 return -EBUSY; in rtw_dump_hw_feature()
1932 efuse->hw_cap.bw = hw_bw_cap_to_bitamp(bw); in rtw_dump_hw_feature()
1933 efuse->hw_cap.hci = GET_EFUSE_HW_CAP_HCI(hw_feature); in rtw_dump_hw_feature()
1934 efuse->hw_cap.nss = GET_EFUSE_HW_CAP_NSS(hw_feature); in rtw_dump_hw_feature()
1935 efuse->hw_cap.ptcl = GET_EFUSE_HW_CAP_PTCL(hw_feature); in rtw_dump_hw_feature()
1936 efuse->hw_cap.ant_num = GET_EFUSE_HW_CAP_ANT_NUM(hw_feature); in rtw_dump_hw_feature()
1938 rtw_hw_config_rf_ant_num(rtwdev, efuse->hw_cap.ant_num); in rtw_dump_hw_feature()
1940 if (efuse->hw_cap.nss == EFUSE_HW_CAP_IGNORE || in rtw_dump_hw_feature()
1941 efuse->hw_cap.nss > rtwdev->hal.rf_path_num) in rtw_dump_hw_feature()
1942 efuse->hw_cap.nss = rtwdev->hal.rf_path_num; in rtw_dump_hw_feature()
1946 efuse->hw_cap.hci, efuse->hw_cap.bw, efuse->hw_cap.ptcl, in rtw_dump_hw_feature()
1947 efuse->hw_cap.ant_num, efuse->hw_cap.nss); in rtw_dump_hw_feature()
1960 struct rtw_efuse *efuse = &rtwdev->efuse; in rtw_chip_efuse_info_setup()
1963 mutex_lock(&rtwdev->mutex); in rtw_chip_efuse_info_setup()
1982 if (efuse->crystal_cap == 0xff) in rtw_chip_efuse_info_setup()
1983 efuse->crystal_cap = 0; in rtw_chip_efuse_info_setup()
1984 if (efuse->pa_type_2g == 0xff) in rtw_chip_efuse_info_setup()
1985 efuse->pa_type_2g = 0; in rtw_chip_efuse_info_setup()
1986 if (efuse->pa_type_5g == 0xff) in rtw_chip_efuse_info_setup()
1987 efuse->pa_type_5g = 0; in rtw_chip_efuse_info_setup()
1988 if (efuse->lna_type_2g == 0xff) in rtw_chip_efuse_info_setup()
1989 efuse->lna_type_2g = 0; in rtw_chip_efuse_info_setup()
1990 if (efuse->lna_type_5g == 0xff) in rtw_chip_efuse_info_setup()
1991 efuse->lna_type_5g = 0; in rtw_chip_efuse_info_setup()
1992 if (efuse->channel_plan == 0xff) in rtw_chip_efuse_info_setup()
1993 efuse->channel_plan = 0x7f; in rtw_chip_efuse_info_setup()
1994 if (efuse->rf_board_option == 0xff) in rtw_chip_efuse_info_setup()
1995 efuse->rf_board_option = 0; in rtw_chip_efuse_info_setup()
1996 if (efuse->bt_setting & BIT(0)) in rtw_chip_efuse_info_setup()
1997 efuse->share_ant = true; in rtw_chip_efuse_info_setup()
1998 if (efuse->regd == 0xff) in rtw_chip_efuse_info_setup()
1999 efuse->regd = 0; in rtw_chip_efuse_info_setup()
2000 if (efuse->tx_bb_swing_setting_2g == 0xff) in rtw_chip_efuse_info_setup()
2001 efuse->tx_bb_swing_setting_2g = 0; in rtw_chip_efuse_info_setup()
2002 if (efuse->tx_bb_swing_setting_5g == 0xff) in rtw_chip_efuse_info_setup()
2003 efuse->tx_bb_swing_setting_5g = 0; in rtw_chip_efuse_info_setup()
2005 efuse->btcoex = (efuse->rf_board_option & 0xe0) == 0x20; in rtw_chip_efuse_info_setup()
2006 efuse->ext_pa_2g = efuse->pa_type_2g & BIT(4) ? 1 : 0; in rtw_chip_efuse_info_setup()
2007 efuse->ext_lna_2g = efuse->lna_type_2g & BIT(3) ? 1 : 0; in rtw_chip_efuse_info_setup()
2008 efuse->ext_pa_5g = efuse->pa_type_5g & BIT(0) ? 1 : 0; in rtw_chip_efuse_info_setup()
2009 efuse->ext_lna_5g = efuse->lna_type_5g & BIT(3) ? 1 : 0; in rtw_chip_efuse_info_setup()
2011 if (!is_valid_ether_addr(efuse->addr)) { in rtw_chip_efuse_info_setup()
2012 eth_random_addr(efuse->addr); in rtw_chip_efuse_info_setup()
2013 dev_warn(rtwdev->dev, "efuse MAC invalid, using random\n"); in rtw_chip_efuse_info_setup()
2020 mutex_unlock(&rtwdev->mutex); in rtw_chip_efuse_info_setup()
2026 struct rtw_hal *hal = &rtwdev->hal; in rtw_chip_board_info_setup()
2030 return -ENODEV; in rtw_chip_board_info_setup()
2032 rtw_phy_setup_phy_cond(rtwdev, hal->pkg_type); in rtw_chip_board_info_setup()
2035 rtw_load_table(rtwdev, rfe_def->phy_pg_tbl); in rtw_chip_board_info_setup()
2036 rtw_load_table(rtwdev, rfe_def->txpwr_lmt_tbl); in rtw_chip_board_info_setup()
2074 struct rtw_traffic_stats *stats = &rtwdev->stats; in rtw_stats_init()
2075 struct rtw_dm_info *dm_info = &rtwdev->dm_info; in rtw_stats_init()
2078 ewma_tp_init(&stats->tx_ewma_tp); in rtw_stats_init()
2079 ewma_tp_init(&stats->rx_ewma_tp); in rtw_stats_init()
2082 ewma_evm_init(&dm_info->ewma_evm[i]); in rtw_stats_init()
2084 ewma_snr_init(&dm_info->ewma_snr[i]); in rtw_stats_init()
2089 const struct rtw_chip_info *chip = rtwdev->chip; in rtw_core_init()
2090 struct rtw_coex *coex = &rtwdev->coex; in rtw_core_init()
2093 INIT_LIST_HEAD(&rtwdev->rsvd_page_list); in rtw_core_init()
2094 INIT_LIST_HEAD(&rtwdev->txqs); in rtw_core_init()
2096 timer_setup(&rtwdev->tx_report.purge_timer, in rtw_core_init()
2098 rtwdev->tx_wq = alloc_workqueue("rtw_tx_wq", WQ_UNBOUND | WQ_HIGHPRI, 0); in rtw_core_init()
2099 if (!rtwdev->tx_wq) { in rtw_core_init()
2101 return -ENOMEM; in rtw_core_init()
2104 INIT_DELAYED_WORK(&rtwdev->watch_dog_work, rtw_watch_dog_work); in rtw_core_init()
2105 INIT_DELAYED_WORK(&coex->bt_relink_work, rtw_coex_bt_relink_work); in rtw_core_init()
2106 INIT_DELAYED_WORK(&coex->bt_reenable_work, rtw_coex_bt_reenable_work); in rtw_core_init()
2107 INIT_DELAYED_WORK(&coex->defreeze_work, rtw_coex_defreeze_work); in rtw_core_init()
2108 INIT_DELAYED_WORK(&coex->wl_remain_work, rtw_coex_wl_remain_work); in rtw_core_init()
2109 INIT_DELAYED_WORK(&coex->bt_remain_work, rtw_coex_bt_remain_work); in rtw_core_init()
2110 INIT_DELAYED_WORK(&coex->wl_connecting_work, rtw_coex_wl_connecting_work); in rtw_core_init()
2111 INIT_DELAYED_WORK(&coex->bt_multi_link_remain_work, in rtw_core_init()
2113 INIT_DELAYED_WORK(&coex->wl_ccklock_work, rtw_coex_wl_ccklock_work); in rtw_core_init()
2114 INIT_WORK(&rtwdev->tx_work, rtw_tx_work); in rtw_core_init()
2115 INIT_WORK(&rtwdev->c2h_work, rtw_c2h_work); in rtw_core_init()
2116 INIT_WORK(&rtwdev->ips_work, rtw_ips_work); in rtw_core_init()
2117 INIT_WORK(&rtwdev->fw_recovery_work, rtw_fw_recovery_work); in rtw_core_init()
2118 INIT_WORK(&rtwdev->update_beacon_work, rtw_fw_update_beacon_work); in rtw_core_init()
2119 INIT_WORK(&rtwdev->ba_work, rtw_txq_ba_work); in rtw_core_init()
2120 skb_queue_head_init(&rtwdev->c2h_queue); in rtw_core_init()
2121 skb_queue_head_init(&rtwdev->coex.queue); in rtw_core_init()
2122 skb_queue_head_init(&rtwdev->tx_report.queue); in rtw_core_init()
2124 spin_lock_init(&rtwdev->txq_lock); in rtw_core_init()
2125 spin_lock_init(&rtwdev->tx_report.q_lock); in rtw_core_init()
2127 mutex_init(&rtwdev->mutex); in rtw_core_init()
2128 mutex_init(&rtwdev->hal.tx_power_mutex); in rtw_core_init()
2130 init_waitqueue_head(&rtwdev->coex.wait); in rtw_core_init()
2131 init_completion(&rtwdev->lps_leave_check); in rtw_core_init()
2132 init_completion(&rtwdev->fw_scan_density); in rtw_core_init()
2134 rtwdev->sec.total_cam_num = 32; in rtw_core_init()
2135 rtwdev->hal.current_channel = 1; in rtw_core_init()
2136 rtwdev->dm_info.fix_rate = U8_MAX; in rtw_core_init()
2141 rtwdev->hal.rcr = BIT_APP_FCS | BIT_APP_MIC | BIT_APP_ICV | in rtw_core_init()
2151 if (chip->wow_fw_name) { in rtw_core_init()
2155 wait_for_completion(&rtwdev->fw.completion); in rtw_core_init()
2156 if (rtwdev->fw.firmware) in rtw_core_init()
2157 release_firmware(rtwdev->fw.firmware); in rtw_core_init()
2165 destroy_workqueue(rtwdev->tx_wq); in rtw_core_init()
2172 struct rtw_fw_state *fw = &rtwdev->fw; in rtw_core_deinit()
2173 struct rtw_fw_state *wow_fw = &rtwdev->wow_fw; in rtw_core_deinit()
2179 if (fw->firmware) in rtw_core_deinit()
2180 release_firmware(fw->firmware); in rtw_core_deinit()
2182 if (wow_fw->firmware) in rtw_core_deinit()
2183 release_firmware(wow_fw->firmware); in rtw_core_deinit()
2185 destroy_workqueue(rtwdev->tx_wq); in rtw_core_deinit()
2186 timer_delete_sync(&rtwdev->tx_report.purge_timer); in rtw_core_deinit()
2187 spin_lock_irqsave(&rtwdev->tx_report.q_lock, flags); in rtw_core_deinit()
2188 skb_queue_purge(&rtwdev->tx_report.queue); in rtw_core_deinit()
2189 spin_unlock_irqrestore(&rtwdev->tx_report.q_lock, flags); in rtw_core_deinit()
2190 skb_queue_purge(&rtwdev->coex.queue); in rtw_core_deinit()
2191 skb_queue_purge(&rtwdev->c2h_queue); in rtw_core_deinit()
2193 list_for_each_entry_safe(rsvd_pkt, tmp, &rtwdev->rsvd_page_list, in rtw_core_deinit()
2195 list_del(&rsvd_pkt->build_list); in rtw_core_deinit()
2199 mutex_destroy(&rtwdev->mutex); in rtw_core_deinit()
2200 mutex_destroy(&rtwdev->hal.tx_power_mutex); in rtw_core_deinit()
2206 bool sta_mode_only = rtwdev->hci.type == RTW_HCI_TYPE_SDIO; in rtw_register_hw()
2207 struct rtw_hal *hal = &rtwdev->hal; in rtw_register_hw()
2211 max_tx_headroom = rtwdev->chip->tx_pkt_desc_sz; in rtw_register_hw()
2216 hw->extra_tx_headroom = max_tx_headroom; in rtw_register_hw()
2217 hw->queues = IEEE80211_NUM_ACS; in rtw_register_hw()
2218 hw->txq_data_size = sizeof(struct rtw_txq); in rtw_register_hw()
2219 hw->sta_data_size = sizeof(struct rtw_sta_info); in rtw_register_hw()
2220 hw->vif_data_size = sizeof(struct rtw_vif); in rtw_register_hw()
2236 hw->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION); in rtw_register_hw()
2238 hw->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) | in rtw_register_hw()
2241 hw->wiphy->available_antennas_tx = hal->antenna_tx; in rtw_register_hw()
2242 hw->wiphy->available_antennas_rx = hal->antenna_rx; in rtw_register_hw()
2244 hw->wiphy->flags |= WIPHY_FLAG_SUPPORTS_TDLS | in rtw_register_hw()
2247 hw->wiphy->features |= NL80211_FEATURE_SCAN_RANDOM_MAC_ADDR; in rtw_register_hw()
2248 hw->wiphy->max_scan_ssids = RTW_SCAN_MAX_SSIDS; in rtw_register_hw()
2249 hw->wiphy->max_scan_ie_len = rtw_get_max_scan_ie_len(rtwdev); in rtw_register_hw()
2251 if (!sta_mode_only && rtwdev->chip->id == RTW_CHIP_TYPE_8822C) { in rtw_register_hw()
2252 hw->wiphy->iface_combinations = rtw_iface_combs; in rtw_register_hw()
2253 hw->wiphy->n_iface_combinations = ARRAY_SIZE(rtw_iface_combs); in rtw_register_hw()
2256 wiphy_ext_feature_set(hw->wiphy, NL80211_EXT_FEATURE_CAN_REPLACE_PTK0); in rtw_register_hw()
2257 wiphy_ext_feature_set(hw->wiphy, NL80211_EXT_FEATURE_SCAN_RANDOM_SN); in rtw_register_hw()
2258 wiphy_ext_feature_set(hw->wiphy, NL80211_EXT_FEATURE_SET_SCAN_DWELL); in rtw_register_hw()
2261 hw->wiphy->wowlan = rtwdev->chip->wowlan_stub; in rtw_register_hw()
2262 hw->wiphy->max_sched_scan_ssids = rtwdev->chip->max_sched_scan_ssids; in rtw_register_hw()
2264 rtw_set_supported_band(hw, rtwdev->chip); in rtw_register_hw()
2265 SET_IEEE80211_PERM_ADDR(hw, rtwdev->efuse.addr); in rtw_register_hw()
2267 hw->wiphy->sar_capa = &rtw_sar_capa; in rtw_register_hw()
2289 rtwdev->bf_info.bfer_mu_cnt = 0; in rtw_register_hw()
2290 rtwdev->bf_info.bfer_su_cnt = 0; in rtw_register_hw()
2298 const struct rtw_chip_info *chip = rtwdev->chip; in rtw_unregister_hw()
2313 u8 v1 = rtw_read8(rtwdev, reg1->addr + i); in rtw_swap_reg_nbytes()
2314 u8 v2 = rtw_read8(rtwdev, reg2->addr + i); in rtw_swap_reg_nbytes()
2316 rtw_write8(rtwdev, reg1->addr + i, v2); in rtw_swap_reg_nbytes()
2317 rtw_write8(rtwdev, reg2->addr + i, v1); in rtw_swap_reg_nbytes()
2327 v1 = rtw_read32_mask(rtwdev, reg1->addr, reg1->mask); in rtw_swap_reg_mask()
2328 v2 = rtw_read32_mask(rtwdev, reg2->addr, reg2->mask); in rtw_swap_reg_mask()
2329 rtw_write32_mask(rtwdev, reg2->addr, reg2->mask, v1); in rtw_swap_reg_mask()
2330 rtw_write32_mask(rtwdev, reg1->addr, reg1->mask, v2); in rtw_swap_reg_mask()
2341 struct rtw_dev *rtwdev = iter_data->rtwdev; in rtw_port_switch_iter()
2342 struct rtw_vif *rtwvif_target = (struct rtw_vif *)vif->drv_priv; in rtw_port_switch_iter()
2343 struct rtw_vif *rtwvif_ap = iter_data->rtwvif_ap; in rtw_port_switch_iter()
2346 if (rtwvif_target->port != RTW_PORT_0) in rtw_port_switch_iter()
2349 rtw_dbg(rtwdev, RTW_DBG_STATE, "AP port switch from %d -> %d\n", in rtw_port_switch_iter()
2350 rtwvif_ap->port, rtwvif_target->port); in rtw_port_switch_iter()
2355 reg1 = &rtwvif_ap->conf->net_type; in rtw_port_switch_iter()
2356 reg2 = &rtwvif_target->conf->net_type; in rtw_port_switch_iter()
2359 reg1 = &rtwvif_ap->conf->mac_addr; in rtw_port_switch_iter()
2360 reg2 = &rtwvif_target->conf->mac_addr; in rtw_port_switch_iter()
2363 reg1 = &rtwvif_ap->conf->bssid; in rtw_port_switch_iter()
2364 reg2 = &rtwvif_target->conf->bssid; in rtw_port_switch_iter()
2367 reg1 = &rtwvif_ap->conf->bcn_ctrl; in rtw_port_switch_iter()
2368 reg2 = &rtwvif_target->conf->bcn_ctrl; in rtw_port_switch_iter()
2371 swap(rtwvif_target->port, rtwvif_ap->port); in rtw_port_switch_iter()
2372 swap(rtwvif_target->conf, rtwvif_ap->conf); in rtw_port_switch_iter()
2379 struct rtw_vif *rtwvif = (struct rtw_vif *)vif->drv_priv; in rtw_core_port_switch()
2382 if (vif->type != NL80211_IFTYPE_AP || rtwvif->port == RTW_PORT_0) in rtw_core_port_switch()
2392 struct rtw_vif *rtwvif = (struct rtw_vif *)vif->drv_priv; in rtw_check_sta_active_iter()
2398 if (vif->type != NL80211_IFTYPE_STATION) in rtw_check_sta_active_iter()
2401 if (vif->cfg.assoc || !is_zero_ether_addr(rtwvif->bssid)) in rtw_check_sta_active_iter()
2411 return rtwdev->ap_active || sta_active; in rtw_core_check_sta_active()
2416 if (!rtwdev->ap_active) in rtw_core_enable_beacon()