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