1 /* SPDX-License-Identifier: BSD-3-Clause-Clear */ 2 /* 3 * Copyright (c) 2018-2019 The Linux Foundation. All rights reserved. 4 */ 5 6 #ifndef ATH11K_CORE_H 7 #define ATH11K_CORE_H 8 9 #include <linux/types.h> 10 #include <linux/interrupt.h> 11 #include <linux/irq.h> 12 #include <linux/bitfield.h> 13 #include "qmi.h" 14 #include "htc.h" 15 #include "wmi.h" 16 #include "hal.h" 17 #include "dp.h" 18 #include "ce.h" 19 #include "mac.h" 20 #include "hw.h" 21 #include "hal_rx.h" 22 #include "reg.h" 23 #include "thermal.h" 24 25 #define SM(_v, _f) (((_v) << _f##_LSB) & _f##_MASK) 26 27 #define ATH11K_TX_MGMT_NUM_PENDING_MAX 512 28 29 #define ATH11K_TX_MGMT_TARGET_MAX_SUPPORT_WMI 64 30 31 /* Pending management packets threshold for dropping probe responses */ 32 #define ATH11K_PRB_RSP_DROP_THRESHOLD ((ATH11K_TX_MGMT_TARGET_MAX_SUPPORT_WMI * 3) / 4) 33 34 #define ATH11K_INVALID_HW_MAC_ID 0xFF 35 36 enum ath11k_supported_bw { 37 ATH11K_BW_20 = 0, 38 ATH11K_BW_40 = 1, 39 ATH11K_BW_80 = 2, 40 ATH11K_BW_160 = 3, 41 }; 42 43 enum wme_ac { 44 WME_AC_BE, 45 WME_AC_BK, 46 WME_AC_VI, 47 WME_AC_VO, 48 WME_NUM_AC 49 }; 50 51 #define ATH11K_HT_MCS_MAX 7 52 #define ATH11K_VHT_MCS_MAX 9 53 #define ATH11K_HE_MCS_MAX 11 54 55 static inline enum wme_ac ath11k_tid_to_ac(u32 tid) 56 { 57 return (((tid == 0) || (tid == 3)) ? WME_AC_BE : 58 ((tid == 1) || (tid == 2)) ? WME_AC_BK : 59 ((tid == 4) || (tid == 5)) ? WME_AC_VI : 60 WME_AC_VO); 61 } 62 63 struct ath11k_skb_cb { 64 dma_addr_t paddr; 65 u8 eid; 66 struct ath11k *ar; 67 struct ieee80211_vif *vif; 68 } __packed; 69 70 struct ath11k_skb_rxcb { 71 dma_addr_t paddr; 72 bool is_first_msdu; 73 bool is_last_msdu; 74 bool is_continuation; 75 struct hal_rx_desc *rx_desc; 76 u8 err_rel_src; 77 u8 err_code; 78 u8 mac_id; 79 u8 unmapped; 80 }; 81 82 enum ath11k_hw_rev { 83 ATH11K_HW_IPQ8074, 84 }; 85 86 enum ath11k_firmware_mode { 87 /* the default mode, standard 802.11 functionality */ 88 ATH11K_FIRMWARE_MODE_NORMAL, 89 90 /* factory tests etc */ 91 ATH11K_FIRMWARE_MODE_FTM, 92 }; 93 94 #define ATH11K_IRQ_NUM_MAX 52 95 #define ATH11K_EXT_IRQ_GRP_NUM_MAX 11 96 #define ATH11K_EXT_IRQ_NUM_MAX 16 97 98 extern const u8 ath11k_reo_status_ring_mask[ATH11K_EXT_IRQ_GRP_NUM_MAX]; 99 extern const u8 ath11k_tx_ring_mask[ATH11K_EXT_IRQ_GRP_NUM_MAX]; 100 extern const u8 ath11k_rx_ring_mask[ATH11K_EXT_IRQ_GRP_NUM_MAX]; 101 extern const u8 ath11k_rx_err_ring_mask[ATH11K_EXT_IRQ_GRP_NUM_MAX]; 102 extern const u8 ath11k_rx_wbm_rel_ring_mask[ATH11K_EXT_IRQ_GRP_NUM_MAX]; 103 extern const u8 ath11k_rxdma2host_ring_mask[ATH11K_EXT_IRQ_GRP_NUM_MAX]; 104 extern const u8 ath11k_host2rxdma_ring_mask[ATH11K_EXT_IRQ_GRP_NUM_MAX]; 105 extern const u8 rx_mon_status_ring_mask[ATH11K_EXT_IRQ_GRP_NUM_MAX]; 106 107 struct ath11k_ext_irq_grp { 108 struct ath11k_base *ab; 109 u32 irqs[ATH11K_EXT_IRQ_NUM_MAX]; 110 u32 num_irq; 111 u32 grp_id; 112 struct napi_struct napi; 113 struct net_device napi_ndev; 114 /* Queue of pending packets, not expected to be accessed concurrently 115 * to avoid locking overhead. 116 */ 117 struct sk_buff_head pending_q; 118 }; 119 120 #define HEHANDLE_CAP_PHYINFO_SIZE 3 121 #define HECAP_PHYINFO_SIZE 9 122 #define HECAP_MACINFO_SIZE 5 123 #define HECAP_TXRX_MCS_NSS_SIZE 2 124 #define HECAP_PPET16_PPET8_MAX_SIZE 25 125 126 #define HE_PPET16_PPET8_SIZE 8 127 128 /* 802.11ax PPE (PPDU packet Extension) threshold */ 129 struct he_ppe_threshold { 130 u32 numss_m1; 131 u32 ru_mask; 132 u32 ppet16_ppet8_ru3_ru0[HE_PPET16_PPET8_SIZE]; 133 }; 134 135 struct ath11k_he { 136 u8 hecap_macinfo[HECAP_MACINFO_SIZE]; 137 u32 hecap_rxmcsnssmap; 138 u32 hecap_txmcsnssmap; 139 u32 hecap_phyinfo[HEHANDLE_CAP_PHYINFO_SIZE]; 140 struct he_ppe_threshold hecap_ppet; 141 u32 heop_param; 142 }; 143 144 #define MAX_RADIOS 3 145 146 enum { 147 WMI_HOST_TP_SCALE_MAX = 0, 148 WMI_HOST_TP_SCALE_50 = 1, 149 WMI_HOST_TP_SCALE_25 = 2, 150 WMI_HOST_TP_SCALE_12 = 3, 151 WMI_HOST_TP_SCALE_MIN = 4, 152 WMI_HOST_TP_SCALE_SIZE = 5, 153 }; 154 155 enum ath11k_scan_state { 156 ATH11K_SCAN_IDLE, 157 ATH11K_SCAN_STARTING, 158 ATH11K_SCAN_RUNNING, 159 ATH11K_SCAN_ABORTING, 160 }; 161 162 enum ath11k_dev_flags { 163 ATH11K_CAC_RUNNING, 164 ATH11K_FLAG_CORE_REGISTERED, 165 ATH11K_FLAG_CRASH_FLUSH, 166 ATH11K_FLAG_RAW_MODE, 167 ATH11K_FLAG_HW_CRYPTO_DISABLED, 168 ATH11K_FLAG_BTCOEX, 169 ATH11K_FLAG_RECOVERY, 170 ATH11K_FLAG_UNREGISTERING, 171 ATH11K_FLAG_REGISTERED, 172 }; 173 174 enum ath11k_monitor_flags { 175 ATH11K_FLAG_MONITOR_ENABLED, 176 }; 177 178 struct ath11k_vif { 179 u32 vdev_id; 180 enum wmi_vdev_type vdev_type; 181 enum wmi_vdev_subtype vdev_subtype; 182 u32 beacon_interval; 183 u32 dtim_period; 184 u16 ast_hash; 185 u16 tcl_metadata; 186 u8 hal_addr_search_flags; 187 u8 search_type; 188 189 struct ath11k *ar; 190 struct ieee80211_vif *vif; 191 192 u16 tx_seq_no; 193 struct wmi_wmm_params_all_arg wmm_params; 194 struct list_head list; 195 union { 196 struct { 197 u32 uapsd; 198 } sta; 199 struct { 200 /* 127 stations; wmi limit */ 201 u8 tim_bitmap[16]; 202 u8 tim_len; 203 u32 ssid_len; 204 u8 ssid[IEEE80211_MAX_SSID_LEN]; 205 bool hidden_ssid; 206 /* P2P_IE with NoA attribute for P2P_GO case */ 207 u32 noa_len; 208 u8 *noa_data; 209 } ap; 210 } u; 211 212 bool is_started; 213 bool is_up; 214 u32 aid; 215 u8 bssid[ETH_ALEN]; 216 struct cfg80211_bitrate_mask bitrate_mask; 217 int num_legacy_stations; 218 int rtscts_prot_mode; 219 int txpower; 220 }; 221 222 struct ath11k_vif_iter { 223 u32 vdev_id; 224 struct ath11k_vif *arvif; 225 }; 226 227 struct ath11k_rx_peer_stats { 228 u64 num_msdu; 229 u64 num_mpdu_fcs_ok; 230 u64 num_mpdu_fcs_err; 231 u64 tcp_msdu_count; 232 u64 udp_msdu_count; 233 u64 other_msdu_count; 234 u64 ampdu_msdu_count; 235 u64 non_ampdu_msdu_count; 236 u64 stbc_count; 237 u64 beamformed_count; 238 u64 mcs_count[HAL_RX_MAX_MCS + 1]; 239 u64 nss_count[HAL_RX_MAX_NSS]; 240 u64 bw_count[HAL_RX_BW_MAX]; 241 u64 gi_count[HAL_RX_GI_MAX]; 242 u64 coding_count[HAL_RX_SU_MU_CODING_MAX]; 243 u64 tid_count[IEEE80211_NUM_TIDS + 1]; 244 u64 pream_cnt[HAL_RX_PREAMBLE_MAX]; 245 u64 reception_type[HAL_RX_RECEPTION_TYPE_MAX]; 246 u64 rx_duration; 247 u64 dcm_count; 248 u64 ru_alloc_cnt[HAL_RX_RU_ALLOC_TYPE_MAX]; 249 }; 250 251 #define ATH11K_HE_MCS_NUM 12 252 #define ATH11K_VHT_MCS_NUM 10 253 #define ATH11K_BW_NUM 4 254 #define ATH11K_NSS_NUM 4 255 #define ATH11K_LEGACY_NUM 12 256 #define ATH11K_GI_NUM 4 257 #define ATH11K_HT_MCS_NUM 32 258 259 enum ath11k_pkt_rx_err { 260 ATH11K_PKT_RX_ERR_FCS, 261 ATH11K_PKT_RX_ERR_TKIP, 262 ATH11K_PKT_RX_ERR_CRYPT, 263 ATH11K_PKT_RX_ERR_PEER_IDX_INVAL, 264 ATH11K_PKT_RX_ERR_MAX, 265 }; 266 267 enum ath11k_ampdu_subfrm_num { 268 ATH11K_AMPDU_SUBFRM_NUM_10, 269 ATH11K_AMPDU_SUBFRM_NUM_20, 270 ATH11K_AMPDU_SUBFRM_NUM_30, 271 ATH11K_AMPDU_SUBFRM_NUM_40, 272 ATH11K_AMPDU_SUBFRM_NUM_50, 273 ATH11K_AMPDU_SUBFRM_NUM_60, 274 ATH11K_AMPDU_SUBFRM_NUM_MORE, 275 ATH11K_AMPDU_SUBFRM_NUM_MAX, 276 }; 277 278 enum ath11k_amsdu_subfrm_num { 279 ATH11K_AMSDU_SUBFRM_NUM_1, 280 ATH11K_AMSDU_SUBFRM_NUM_2, 281 ATH11K_AMSDU_SUBFRM_NUM_3, 282 ATH11K_AMSDU_SUBFRM_NUM_4, 283 ATH11K_AMSDU_SUBFRM_NUM_MORE, 284 ATH11K_AMSDU_SUBFRM_NUM_MAX, 285 }; 286 287 enum ath11k_counter_type { 288 ATH11K_COUNTER_TYPE_BYTES, 289 ATH11K_COUNTER_TYPE_PKTS, 290 ATH11K_COUNTER_TYPE_MAX, 291 }; 292 293 enum ath11k_stats_type { 294 ATH11K_STATS_TYPE_SUCC, 295 ATH11K_STATS_TYPE_FAIL, 296 ATH11K_STATS_TYPE_RETRY, 297 ATH11K_STATS_TYPE_AMPDU, 298 ATH11K_STATS_TYPE_MAX, 299 }; 300 301 struct ath11k_htt_data_stats { 302 u64 legacy[ATH11K_COUNTER_TYPE_MAX][ATH11K_LEGACY_NUM]; 303 u64 ht[ATH11K_COUNTER_TYPE_MAX][ATH11K_HT_MCS_NUM]; 304 u64 vht[ATH11K_COUNTER_TYPE_MAX][ATH11K_VHT_MCS_NUM]; 305 u64 he[ATH11K_COUNTER_TYPE_MAX][ATH11K_HE_MCS_NUM]; 306 u64 bw[ATH11K_COUNTER_TYPE_MAX][ATH11K_BW_NUM]; 307 u64 nss[ATH11K_COUNTER_TYPE_MAX][ATH11K_NSS_NUM]; 308 u64 gi[ATH11K_COUNTER_TYPE_MAX][ATH11K_GI_NUM]; 309 }; 310 311 struct ath11k_htt_tx_stats { 312 struct ath11k_htt_data_stats stats[ATH11K_STATS_TYPE_MAX]; 313 u64 tx_duration; 314 u64 ba_fails; 315 u64 ack_fails; 316 }; 317 318 struct ath11k_per_ppdu_tx_stats { 319 u16 succ_pkts; 320 u16 failed_pkts; 321 u16 retry_pkts; 322 u32 succ_bytes; 323 u32 failed_bytes; 324 u32 retry_bytes; 325 }; 326 327 struct ath11k_sta { 328 struct ath11k_vif *arvif; 329 330 /* the following are protected by ar->data_lock */ 331 u32 changed; /* IEEE80211_RC_* */ 332 u32 bw; 333 u32 nss; 334 u32 smps; 335 336 struct work_struct update_wk; 337 struct rate_info txrate; 338 struct rate_info last_txrate; 339 u64 rx_duration; 340 u64 tx_duration; 341 u8 rssi_comb; 342 struct ath11k_htt_tx_stats *tx_stats; 343 struct ath11k_rx_peer_stats *rx_stats; 344 }; 345 346 #define ATH11K_NUM_CHANS 41 347 #define ATH11K_MAX_5G_CHAN 173 348 349 enum ath11k_state { 350 ATH11K_STATE_OFF, 351 ATH11K_STATE_ON, 352 ATH11K_STATE_RESTARTING, 353 ATH11K_STATE_RESTARTED, 354 ATH11K_STATE_WEDGED, 355 /* Add other states as required */ 356 }; 357 358 /* Antenna noise floor */ 359 #define ATH11K_DEFAULT_NOISE_FLOOR -95 360 361 struct ath11k_fw_stats { 362 struct dentry *debugfs_fwstats; 363 u32 pdev_id; 364 u32 stats_id; 365 struct list_head pdevs; 366 struct list_head vdevs; 367 struct list_head bcn; 368 }; 369 370 struct ath11k_dbg_htt_stats { 371 u8 type; 372 u8 reset; 373 struct debug_htt_stats_req *stats_req; 374 /* protects shared stats req buffer */ 375 spinlock_t lock; 376 }; 377 378 struct ath11k_debug { 379 struct dentry *debugfs_pdev; 380 struct ath11k_dbg_htt_stats htt_stats; 381 u32 extd_tx_stats; 382 struct ath11k_fw_stats fw_stats; 383 struct completion fw_stats_complete; 384 bool fw_stats_done; 385 u32 extd_rx_stats; 386 u32 pktlog_filter; 387 u32 pktlog_mode; 388 u32 pktlog_peer_valid; 389 u8 pktlog_peer_addr[ETH_ALEN]; 390 }; 391 392 struct ath11k_per_peer_tx_stats { 393 u32 succ_bytes; 394 u32 retry_bytes; 395 u32 failed_bytes; 396 u16 succ_pkts; 397 u16 retry_pkts; 398 u16 failed_pkts; 399 u32 duration; 400 u8 ba_fails; 401 bool is_ampdu; 402 }; 403 404 #define ATH11K_FLUSH_TIMEOUT (5 * HZ) 405 406 struct ath11k_vdev_stop_status { 407 bool stop_in_progress; 408 u32 vdev_id; 409 }; 410 411 struct ath11k { 412 struct ath11k_base *ab; 413 struct ath11k_pdev *pdev; 414 struct ieee80211_hw *hw; 415 struct ieee80211_ops *ops; 416 struct ath11k_pdev_wmi *wmi; 417 struct ath11k_pdev_dp dp; 418 u8 mac_addr[ETH_ALEN]; 419 u32 ht_cap_info; 420 u32 vht_cap_info; 421 struct ath11k_he ar_he; 422 enum ath11k_state state; 423 struct { 424 struct completion started; 425 struct completion completed; 426 struct completion on_channel; 427 struct delayed_work timeout; 428 enum ath11k_scan_state state; 429 bool is_roc; 430 int vdev_id; 431 int roc_freq; 432 bool roc_notify; 433 } scan; 434 435 struct { 436 struct ieee80211_supported_band sbands[NUM_NL80211_BANDS]; 437 struct ieee80211_sband_iftype_data 438 iftype[NUM_NL80211_BANDS][NUM_NL80211_IFTYPES]; 439 } mac; 440 unsigned long dev_flags; 441 unsigned int filter_flags; 442 unsigned long monitor_flags; 443 u32 min_tx_power; 444 u32 max_tx_power; 445 u32 txpower_limit_2g; 446 u32 txpower_limit_5g; 447 u32 txpower_scale; 448 u32 power_scale; 449 u32 chan_tx_pwr; 450 u32 num_stations; 451 u32 max_num_stations; 452 bool monitor_present; 453 /* To synchronize concurrent synchronous mac80211 callback operations, 454 * concurrent debugfs configuration and concurrent FW statistics events. 455 */ 456 struct mutex conf_mutex; 457 /* protects the radio specific data like debug stats, ppdu_stats_info stats, 458 * vdev_stop_status info, scan data, ath11k_sta info, ath11k_vif info, 459 * channel context data, survey info, test mode data. 460 */ 461 spinlock_t data_lock; 462 463 struct list_head arvifs; 464 /* should never be NULL; needed for regular htt rx */ 465 struct ieee80211_channel *rx_channel; 466 467 /* valid during scan; needed for mgmt rx during scan */ 468 struct ieee80211_channel *scan_channel; 469 470 u8 cfg_tx_chainmask; 471 u8 cfg_rx_chainmask; 472 u8 num_rx_chains; 473 u8 num_tx_chains; 474 /* pdev_idx starts from 0 whereas pdev->pdev_id starts with 1 */ 475 u8 pdev_idx; 476 u8 lmac_id; 477 478 struct completion peer_assoc_done; 479 480 int install_key_status; 481 struct completion install_key_done; 482 483 int last_wmi_vdev_start_status; 484 struct ath11k_vdev_stop_status vdev_stop_status; 485 struct completion vdev_setup_done; 486 487 int num_peers; 488 int max_num_peers; 489 u32 num_started_vdevs; 490 u32 num_created_vdevs; 491 unsigned long long allocated_vdev_map; 492 493 struct idr txmgmt_idr; 494 /* protects txmgmt_idr data */ 495 spinlock_t txmgmt_idr_lock; 496 atomic_t num_pending_mgmt_tx; 497 498 /* cycle count is reported twice for each visited channel during scan. 499 * access protected by data_lock 500 */ 501 u32 survey_last_rx_clear_count; 502 u32 survey_last_cycle_count; 503 504 /* Channel info events are expected to come in pairs without and with 505 * COMPLETE flag set respectively for each channel visit during scan. 506 * 507 * However there are deviations from this rule. This flag is used to 508 * avoid reporting garbage data. 509 */ 510 bool ch_info_can_report_survey; 511 struct survey_info survey[ATH11K_NUM_CHANS]; 512 struct completion bss_survey_done; 513 514 struct work_struct regd_update_work; 515 516 struct work_struct wmi_mgmt_tx_work; 517 struct sk_buff_head wmi_mgmt_tx_queue; 518 519 struct ath11k_per_peer_tx_stats peer_tx_stats; 520 struct list_head ppdu_stats_info; 521 u32 ppdu_stat_list_depth; 522 523 struct ath11k_per_peer_tx_stats cached_stats; 524 u32 last_ppdu_id; 525 u32 cached_ppdu_id; 526 #ifdef CONFIG_ATH11K_DEBUGFS 527 struct ath11k_debug debug; 528 #endif 529 bool dfs_block_radar_events; 530 struct ath11k_thermal thermal; 531 }; 532 533 struct ath11k_band_cap { 534 u32 max_bw_supported; 535 u32 ht_cap_info; 536 u32 he_cap_info[2]; 537 u32 he_mcs; 538 u32 he_cap_phy_info[PSOC_HOST_MAX_PHY_SIZE]; 539 struct ath11k_ppe_threshold he_ppet; 540 }; 541 542 struct ath11k_pdev_cap { 543 u32 supported_bands; 544 u32 ampdu_density; 545 u32 vht_cap; 546 u32 vht_mcs; 547 u32 he_mcs; 548 u32 tx_chain_mask; 549 u32 rx_chain_mask; 550 u32 tx_chain_mask_shift; 551 u32 rx_chain_mask_shift; 552 struct ath11k_band_cap band[NUM_NL80211_BANDS]; 553 }; 554 555 struct ath11k_pdev { 556 struct ath11k *ar; 557 u32 pdev_id; 558 struct ath11k_pdev_cap cap; 559 u8 mac_addr[ETH_ALEN]; 560 }; 561 562 struct ath11k_board_data { 563 const struct firmware *fw; 564 const void *data; 565 size_t len; 566 }; 567 568 /* IPQ8074 HW channel counters frequency value in hertz */ 569 #define IPQ8074_CC_FREQ_HERTZ 320000 570 571 struct ath11k_soc_dp_rx_stats { 572 u32 err_ring_pkts; 573 u32 invalid_rbm; 574 u32 rxdma_error[HAL_REO_ENTR_RING_RXDMA_ECODE_MAX]; 575 u32 reo_error[HAL_REO_DEST_RING_ERROR_CODE_MAX]; 576 u32 hal_reo_error[DP_REO_DST_RING_MAX]; 577 }; 578 579 /* Master structure to hold the hw data which may be used in core module */ 580 struct ath11k_base { 581 enum ath11k_hw_rev hw_rev; 582 struct platform_device *pdev; 583 struct device *dev; 584 struct ath11k_qmi qmi; 585 struct ath11k_wmi_base wmi_ab; 586 struct completion fw_ready; 587 struct rproc *tgt_rproc; 588 int num_radios; 589 /* HW channel counters frequency value in hertz common to all MACs */ 590 u32 cc_freq_hz; 591 592 struct ath11k_htc htc; 593 594 struct ath11k_dp dp; 595 596 void __iomem *mem; 597 unsigned long mem_len; 598 599 const struct ath11k_hif_ops *hif_ops; 600 601 struct ath11k_ce ce; 602 struct timer_list rx_replenish_retry; 603 struct ath11k_hal hal; 604 /* To synchronize core_start/core_stop */ 605 struct mutex core_lock; 606 /* Protects data like peers */ 607 spinlock_t base_lock; 608 struct ath11k_pdev pdevs[MAX_RADIOS]; 609 struct ath11k_pdev __rcu *pdevs_active[MAX_RADIOS]; 610 struct ath11k_hal_reg_capabilities_ext hal_reg_cap[MAX_RADIOS]; 611 unsigned long long free_vdev_map; 612 struct list_head peers; 613 wait_queue_head_t peer_mapping_wq; 614 u8 mac_addr[ETH_ALEN]; 615 bool wmi_ready; 616 u32 wlan_init_status; 617 int irq_num[ATH11K_IRQ_NUM_MAX]; 618 struct ath11k_ext_irq_grp ext_irq_grp[ATH11K_EXT_IRQ_GRP_NUM_MAX]; 619 struct napi_struct *napi; 620 struct ath11k_targ_cap target_caps; 621 u32 ext_service_bitmap[WMI_SERVICE_EXT_BM_SIZE]; 622 bool pdevs_macaddr_valid; 623 int bd_api; 624 struct ath11k_hw_params hw_params; 625 const struct firmware *cal_file; 626 627 /* Below regd's are protected by ab->data_lock */ 628 /* This is the regd set for every radio 629 * by the firmware during initializatin 630 */ 631 struct ieee80211_regdomain *default_regd[MAX_RADIOS]; 632 /* This regd is set during dynamic country setting 633 * This may or may not be used during the runtime 634 */ 635 struct ieee80211_regdomain *new_regd[MAX_RADIOS]; 636 637 /* Current DFS Regulatory */ 638 enum ath11k_dfs_region dfs_region; 639 #ifdef CONFIG_ATH11K_DEBUGFS 640 struct dentry *debugfs_soc; 641 struct dentry *debugfs_ath11k; 642 #endif 643 struct ath11k_soc_dp_rx_stats soc_stats; 644 645 unsigned long dev_flags; 646 struct completion driver_recovery; 647 struct workqueue_struct *workqueue; 648 struct work_struct restart_work; 649 struct { 650 /* protected by data_lock */ 651 u32 fw_crash_counter; 652 } stats; 653 }; 654 655 struct ath11k_fw_stats_pdev { 656 struct list_head list; 657 658 /* PDEV stats */ 659 s32 ch_noise_floor; 660 /* Cycles spent transmitting frames */ 661 u32 tx_frame_count; 662 /* Cycles spent receiving frames */ 663 u32 rx_frame_count; 664 /* Total channel busy time, evidently */ 665 u32 rx_clear_count; 666 /* Total on-channel time */ 667 u32 cycle_count; 668 u32 phy_err_count; 669 u32 chan_tx_power; 670 u32 ack_rx_bad; 671 u32 rts_bad; 672 u32 rts_good; 673 u32 fcs_bad; 674 u32 no_beacons; 675 u32 mib_int_count; 676 677 /* PDEV TX stats */ 678 /* Num HTT cookies queued to dispatch list */ 679 s32 comp_queued; 680 /* Num HTT cookies dispatched */ 681 s32 comp_delivered; 682 /* Num MSDU queued to WAL */ 683 s32 msdu_enqued; 684 /* Num MPDU queue to WAL */ 685 s32 mpdu_enqued; 686 /* Num MSDUs dropped by WMM limit */ 687 s32 wmm_drop; 688 /* Num Local frames queued */ 689 s32 local_enqued; 690 /* Num Local frames done */ 691 s32 local_freed; 692 /* Num queued to HW */ 693 s32 hw_queued; 694 /* Num PPDU reaped from HW */ 695 s32 hw_reaped; 696 /* Num underruns */ 697 s32 underrun; 698 /* Num PPDUs cleaned up in TX abort */ 699 s32 tx_abort; 700 /* Num MPDUs requed by SW */ 701 s32 mpdus_requed; 702 /* excessive retries */ 703 u32 tx_ko; 704 /* data hw rate code */ 705 u32 data_rc; 706 /* Scheduler self triggers */ 707 u32 self_triggers; 708 /* frames dropped due to excessive sw retries */ 709 u32 sw_retry_failure; 710 /* illegal rate phy errors */ 711 u32 illgl_rate_phy_err; 712 /* wal pdev continuous xretry */ 713 u32 pdev_cont_xretry; 714 /* wal pdev tx timeouts */ 715 u32 pdev_tx_timeout; 716 /* wal pdev resets */ 717 u32 pdev_resets; 718 /* frames dropped due to non-availability of stateless TIDs */ 719 u32 stateless_tid_alloc_failure; 720 /* PhY/BB underrun */ 721 u32 phy_underrun; 722 /* MPDU is more than txop limit */ 723 u32 txop_ovf; 724 725 /* PDEV RX stats */ 726 /* Cnts any change in ring routing mid-ppdu */ 727 s32 mid_ppdu_route_change; 728 /* Total number of statuses processed */ 729 s32 status_rcvd; 730 /* Extra frags on rings 0-3 */ 731 s32 r0_frags; 732 s32 r1_frags; 733 s32 r2_frags; 734 s32 r3_frags; 735 /* MSDUs / MPDUs delivered to HTT */ 736 s32 htt_msdus; 737 s32 htt_mpdus; 738 /* MSDUs / MPDUs delivered to local stack */ 739 s32 loc_msdus; 740 s32 loc_mpdus; 741 /* AMSDUs that have more MSDUs than the status ring size */ 742 s32 oversize_amsdu; 743 /* Number of PHY errors */ 744 s32 phy_errs; 745 /* Number of PHY errors drops */ 746 s32 phy_err_drop; 747 /* Number of mpdu errors - FCS, MIC, ENC etc. */ 748 s32 mpdu_errs; 749 }; 750 751 struct ath11k_fw_stats_vdev { 752 struct list_head list; 753 754 u32 vdev_id; 755 u32 beacon_snr; 756 u32 data_snr; 757 u32 num_tx_frames[WLAN_MAX_AC]; 758 u32 num_rx_frames; 759 u32 num_tx_frames_retries[WLAN_MAX_AC]; 760 u32 num_tx_frames_failures[WLAN_MAX_AC]; 761 u32 num_rts_fail; 762 u32 num_rts_success; 763 u32 num_rx_err; 764 u32 num_rx_discard; 765 u32 num_tx_not_acked; 766 u32 tx_rate_history[MAX_TX_RATE_VALUES]; 767 u32 beacon_rssi_history[MAX_TX_RATE_VALUES]; 768 }; 769 770 struct ath11k_fw_stats_bcn { 771 struct list_head list; 772 773 u32 vdev_id; 774 u32 tx_bcn_succ_cnt; 775 u32 tx_bcn_outage_cnt; 776 }; 777 778 void ath11k_peer_unmap_event(struct ath11k_base *ab, u16 peer_id); 779 void ath11k_peer_map_event(struct ath11k_base *ab, u8 vdev_id, u16 peer_id, 780 u8 *mac_addr, u16 ast_hash); 781 struct ath11k_peer *ath11k_peer_find(struct ath11k_base *ab, int vdev_id, 782 const u8 *addr); 783 struct ath11k_peer *ath11k_peer_find_by_addr(struct ath11k_base *ab, 784 const u8 *addr); 785 struct ath11k_peer *ath11k_peer_find_by_id(struct ath11k_base *ab, int peer_id); 786 int ath11k_core_qmi_firmware_ready(struct ath11k_base *ab); 787 int ath11k_core_init(struct ath11k_base *ath11k); 788 void ath11k_core_deinit(struct ath11k_base *ath11k); 789 struct ath11k_base *ath11k_core_alloc(struct device *dev); 790 void ath11k_core_free(struct ath11k_base *ath11k); 791 int ath11k_core_fetch_bdf(struct ath11k_base *ath11k, 792 struct ath11k_board_data *bd); 793 void ath11k_core_free_bdf(struct ath11k_base *ab, struct ath11k_board_data *bd); 794 795 void ath11k_core_halt(struct ath11k *ar); 796 u8 ath11k_core_get_hw_mac_id(struct ath11k_base *ab, int pdev_idx); 797 798 static inline const char *ath11k_scan_state_str(enum ath11k_scan_state state) 799 { 800 switch (state) { 801 case ATH11K_SCAN_IDLE: 802 return "idle"; 803 case ATH11K_SCAN_STARTING: 804 return "starting"; 805 case ATH11K_SCAN_RUNNING: 806 return "running"; 807 case ATH11K_SCAN_ABORTING: 808 return "aborting"; 809 } 810 811 return "unknown"; 812 } 813 814 static inline struct ath11k_skb_cb *ATH11K_SKB_CB(struct sk_buff *skb) 815 { 816 return (struct ath11k_skb_cb *)&IEEE80211_SKB_CB(skb)->driver_data; 817 } 818 819 static inline struct ath11k_skb_rxcb *ATH11K_SKB_RXCB(struct sk_buff *skb) 820 { 821 BUILD_BUG_ON(sizeof(struct ath11k_skb_rxcb) > sizeof(skb->cb)); 822 return (struct ath11k_skb_rxcb *)skb->cb; 823 } 824 825 static inline struct ath11k_vif *ath11k_vif_to_arvif(struct ieee80211_vif *vif) 826 { 827 return (struct ath11k_vif *)vif->drv_priv; 828 } 829 830 #endif /* _CORE_H_ */ 831