18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * Copyright (c) 2008-2011 Atheros Communications Inc. 38c2ecf20Sopenharmony_ci * 48c2ecf20Sopenharmony_ci * Permission to use, copy, modify, and/or distribute this software for any 58c2ecf20Sopenharmony_ci * purpose with or without fee is hereby granted, provided that the above 68c2ecf20Sopenharmony_ci * copyright notice and this permission notice appear in all copies. 78c2ecf20Sopenharmony_ci * 88c2ecf20Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 98c2ecf20Sopenharmony_ci * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 108c2ecf20Sopenharmony_ci * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 118c2ecf20Sopenharmony_ci * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 128c2ecf20Sopenharmony_ci * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 138c2ecf20Sopenharmony_ci * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 148c2ecf20Sopenharmony_ci * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 158c2ecf20Sopenharmony_ci */ 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_ci#ifndef ATH9K_H 188c2ecf20Sopenharmony_ci#define ATH9K_H 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_ci#include <linux/etherdevice.h> 218c2ecf20Sopenharmony_ci#include <linux/device.h> 228c2ecf20Sopenharmony_ci#include <linux/interrupt.h> 238c2ecf20Sopenharmony_ci#include <linux/leds.h> 248c2ecf20Sopenharmony_ci#include <linux/completion.h> 258c2ecf20Sopenharmony_ci#include <linux/time.h> 268c2ecf20Sopenharmony_ci#include <linux/hw_random.h> 278c2ecf20Sopenharmony_ci 288c2ecf20Sopenharmony_ci#include "common.h" 298c2ecf20Sopenharmony_ci#include "debug.h" 308c2ecf20Sopenharmony_ci#include "mci.h" 318c2ecf20Sopenharmony_ci#include "dfs.h" 328c2ecf20Sopenharmony_ci 338c2ecf20Sopenharmony_cistruct ath_node; 348c2ecf20Sopenharmony_cistruct ath_vif; 358c2ecf20Sopenharmony_ci 368c2ecf20Sopenharmony_ciextern struct ieee80211_ops ath9k_ops; 378c2ecf20Sopenharmony_ciextern int ath9k_modparam_nohwcrypt; 388c2ecf20Sopenharmony_ciextern int ath9k_led_blink; 398c2ecf20Sopenharmony_ciextern bool is_ath9k_unloaded; 408c2ecf20Sopenharmony_ciextern int ath9k_use_chanctx; 418c2ecf20Sopenharmony_ci 428c2ecf20Sopenharmony_ci/*************************/ 438c2ecf20Sopenharmony_ci/* Descriptor Management */ 448c2ecf20Sopenharmony_ci/*************************/ 458c2ecf20Sopenharmony_ci 468c2ecf20Sopenharmony_ci#define ATH_TXSTATUS_RING_SIZE 512 478c2ecf20Sopenharmony_ci 488c2ecf20Sopenharmony_ci/* Macro to expand scalars to 64-bit objects */ 498c2ecf20Sopenharmony_ci#define ito64(x) (sizeof(x) == 1) ? \ 508c2ecf20Sopenharmony_ci (((unsigned long long int)(x)) & (0xff)) : \ 518c2ecf20Sopenharmony_ci (sizeof(x) == 2) ? \ 528c2ecf20Sopenharmony_ci (((unsigned long long int)(x)) & 0xffff) : \ 538c2ecf20Sopenharmony_ci ((sizeof(x) == 4) ? \ 548c2ecf20Sopenharmony_ci (((unsigned long long int)(x)) & 0xffffffff) : \ 558c2ecf20Sopenharmony_ci (unsigned long long int)(x)) 568c2ecf20Sopenharmony_ci 578c2ecf20Sopenharmony_ci#define ATH_TXBUF_RESET(_bf) do { \ 588c2ecf20Sopenharmony_ci (_bf)->bf_lastbf = NULL; \ 598c2ecf20Sopenharmony_ci (_bf)->bf_next = NULL; \ 608c2ecf20Sopenharmony_ci memset(&((_bf)->bf_state), 0, \ 618c2ecf20Sopenharmony_ci sizeof(struct ath_buf_state)); \ 628c2ecf20Sopenharmony_ci } while (0) 638c2ecf20Sopenharmony_ci 648c2ecf20Sopenharmony_ci#define DS2PHYS(_dd, _ds) \ 658c2ecf20Sopenharmony_ci ((_dd)->dd_desc_paddr + ((caddr_t)(_ds) - (caddr_t)(_dd)->dd_desc)) 668c2ecf20Sopenharmony_ci#define ATH_DESC_4KB_BOUND_CHECK(_daddr) ((((_daddr) & 0xFFF) > 0xF7F) ? 1 : 0) 678c2ecf20Sopenharmony_ci#define ATH_DESC_4KB_BOUND_NUM_SKIPPED(_len) ((_len) / 4096) 688c2ecf20Sopenharmony_ci 698c2ecf20Sopenharmony_cistruct ath_descdma { 708c2ecf20Sopenharmony_ci void *dd_desc; 718c2ecf20Sopenharmony_ci dma_addr_t dd_desc_paddr; 728c2ecf20Sopenharmony_ci u32 dd_desc_len; 738c2ecf20Sopenharmony_ci}; 748c2ecf20Sopenharmony_ci 758c2ecf20Sopenharmony_ciint ath_descdma_setup(struct ath_softc *sc, struct ath_descdma *dd, 768c2ecf20Sopenharmony_ci struct list_head *head, const char *name, 778c2ecf20Sopenharmony_ci int nbuf, int ndesc, bool is_tx); 788c2ecf20Sopenharmony_ci 798c2ecf20Sopenharmony_ci/***********/ 808c2ecf20Sopenharmony_ci/* RX / TX */ 818c2ecf20Sopenharmony_ci/***********/ 828c2ecf20Sopenharmony_ci 838c2ecf20Sopenharmony_ci#define ATH_TXQ_SETUP(sc, i) ((sc)->tx.txqsetup & (1<<i)) 848c2ecf20Sopenharmony_ci 858c2ecf20Sopenharmony_ci/* increment with wrap-around */ 868c2ecf20Sopenharmony_ci#define INCR(_l, _sz) do { \ 878c2ecf20Sopenharmony_ci (_l)++; \ 888c2ecf20Sopenharmony_ci (_l) &= ((_sz) - 1); \ 898c2ecf20Sopenharmony_ci } while (0) 908c2ecf20Sopenharmony_ci 918c2ecf20Sopenharmony_ci#define ATH_RXBUF 512 928c2ecf20Sopenharmony_ci#define ATH_TXBUF 512 938c2ecf20Sopenharmony_ci#define ATH_TXBUF_RESERVE 5 948c2ecf20Sopenharmony_ci#define ATH_TXMAXTRY 13 958c2ecf20Sopenharmony_ci#define ATH_MAX_SW_RETRIES 30 968c2ecf20Sopenharmony_ci 978c2ecf20Sopenharmony_ci#define TID_TO_WME_AC(_tid) \ 988c2ecf20Sopenharmony_ci ((((_tid) == 0) || ((_tid) == 3)) ? IEEE80211_AC_BE : \ 998c2ecf20Sopenharmony_ci (((_tid) == 1) || ((_tid) == 2)) ? IEEE80211_AC_BK : \ 1008c2ecf20Sopenharmony_ci (((_tid) == 4) || ((_tid) == 5)) ? IEEE80211_AC_VI : \ 1018c2ecf20Sopenharmony_ci IEEE80211_AC_VO) 1028c2ecf20Sopenharmony_ci 1038c2ecf20Sopenharmony_ci#define ATH_AGGR_DELIM_SZ 4 1048c2ecf20Sopenharmony_ci#define ATH_AGGR_MINPLEN 256 /* in bytes, minimum packet length */ 1058c2ecf20Sopenharmony_ci/* number of delimiters for encryption padding */ 1068c2ecf20Sopenharmony_ci#define ATH_AGGR_ENCRYPTDELIM 10 1078c2ecf20Sopenharmony_ci/* minimum h/w qdepth to be sustained to maximize aggregation */ 1088c2ecf20Sopenharmony_ci#define ATH_AGGR_MIN_QDEPTH 2 1098c2ecf20Sopenharmony_ci/* minimum h/w qdepth for non-aggregated traffic */ 1108c2ecf20Sopenharmony_ci#define ATH_NON_AGGR_MIN_QDEPTH 8 1118c2ecf20Sopenharmony_ci#define ATH_HW_CHECK_POLL_INT 1000 1128c2ecf20Sopenharmony_ci#define ATH_TXFIFO_DEPTH 8 1138c2ecf20Sopenharmony_ci#define ATH_TX_ERROR 0x01 1148c2ecf20Sopenharmony_ci 1158c2ecf20Sopenharmony_ci/* Stop tx traffic 1ms before the GO goes away */ 1168c2ecf20Sopenharmony_ci#define ATH_P2P_PS_STOP_TIME 1000 1178c2ecf20Sopenharmony_ci 1188c2ecf20Sopenharmony_ci#define IEEE80211_SEQ_SEQ_SHIFT 4 1198c2ecf20Sopenharmony_ci#define IEEE80211_SEQ_MAX 4096 1208c2ecf20Sopenharmony_ci#define IEEE80211_WEP_IVLEN 3 1218c2ecf20Sopenharmony_ci#define IEEE80211_WEP_KIDLEN 1 1228c2ecf20Sopenharmony_ci#define IEEE80211_WEP_CRCLEN 4 1238c2ecf20Sopenharmony_ci#define IEEE80211_MAX_MPDU_LEN (3840 + FCS_LEN + \ 1248c2ecf20Sopenharmony_ci (IEEE80211_WEP_IVLEN + \ 1258c2ecf20Sopenharmony_ci IEEE80211_WEP_KIDLEN + \ 1268c2ecf20Sopenharmony_ci IEEE80211_WEP_CRCLEN)) 1278c2ecf20Sopenharmony_ci 1288c2ecf20Sopenharmony_ci/* return whether a bit at index _n in bitmap _bm is set 1298c2ecf20Sopenharmony_ci * _sz is the size of the bitmap */ 1308c2ecf20Sopenharmony_ci#define ATH_BA_ISSET(_bm, _n) (((_n) < (WME_BA_BMP_SIZE)) && \ 1318c2ecf20Sopenharmony_ci ((_bm)[(_n) >> 5] & (1 << ((_n) & 31)))) 1328c2ecf20Sopenharmony_ci 1338c2ecf20Sopenharmony_ci/* return block-ack bitmap index given sequence and starting sequence */ 1348c2ecf20Sopenharmony_ci#define ATH_BA_INDEX(_st, _seq) (((_seq) - (_st)) & (IEEE80211_SEQ_MAX - 1)) 1358c2ecf20Sopenharmony_ci 1368c2ecf20Sopenharmony_ci/* return the seqno for _start + _offset */ 1378c2ecf20Sopenharmony_ci#define ATH_BA_INDEX2SEQ(_seq, _offset) (((_seq) + (_offset)) & (IEEE80211_SEQ_MAX - 1)) 1388c2ecf20Sopenharmony_ci 1398c2ecf20Sopenharmony_ci/* returns delimiter padding required given the packet length */ 1408c2ecf20Sopenharmony_ci#define ATH_AGGR_GET_NDELIM(_len) \ 1418c2ecf20Sopenharmony_ci (((_len) >= ATH_AGGR_MINPLEN) ? 0 : \ 1428c2ecf20Sopenharmony_ci DIV_ROUND_UP(ATH_AGGR_MINPLEN - (_len), ATH_AGGR_DELIM_SZ)) 1438c2ecf20Sopenharmony_ci 1448c2ecf20Sopenharmony_ci#define BAW_WITHIN(_start, _bawsz, _seqno) \ 1458c2ecf20Sopenharmony_ci ((((_seqno) - (_start)) & 4095) < (_bawsz)) 1468c2ecf20Sopenharmony_ci 1478c2ecf20Sopenharmony_ci#define ATH_AN_2_TID(_an, _tidno) ath_node_to_tid(_an, _tidno) 1488c2ecf20Sopenharmony_ci 1498c2ecf20Sopenharmony_ci#define IS_HT_RATE(rate) (rate & 0x80) 1508c2ecf20Sopenharmony_ci#define IS_CCK_RATE(rate) ((rate >= 0x18) && (rate <= 0x1e)) 1518c2ecf20Sopenharmony_ci#define IS_OFDM_RATE(rate) ((rate >= 0x8) && (rate <= 0xf)) 1528c2ecf20Sopenharmony_ci 1538c2ecf20Sopenharmony_cienum { 1548c2ecf20Sopenharmony_ci WLAN_RC_PHY_OFDM, 1558c2ecf20Sopenharmony_ci WLAN_RC_PHY_CCK, 1568c2ecf20Sopenharmony_ci}; 1578c2ecf20Sopenharmony_ci 1588c2ecf20Sopenharmony_cistruct ath_txq { 1598c2ecf20Sopenharmony_ci int mac80211_qnum; /* mac80211 queue number, -1 means not mac80211 Q */ 1608c2ecf20Sopenharmony_ci u32 axq_qnum; /* ath9k hardware queue number */ 1618c2ecf20Sopenharmony_ci void *axq_link; 1628c2ecf20Sopenharmony_ci struct list_head axq_q; 1638c2ecf20Sopenharmony_ci spinlock_t axq_lock; 1648c2ecf20Sopenharmony_ci u32 axq_depth; 1658c2ecf20Sopenharmony_ci u32 axq_ampdu_depth; 1668c2ecf20Sopenharmony_ci bool axq_tx_inprogress; 1678c2ecf20Sopenharmony_ci struct list_head txq_fifo[ATH_TXFIFO_DEPTH]; 1688c2ecf20Sopenharmony_ci u8 txq_headidx; 1698c2ecf20Sopenharmony_ci u8 txq_tailidx; 1708c2ecf20Sopenharmony_ci int pending_frames; 1718c2ecf20Sopenharmony_ci struct sk_buff_head complete_q; 1728c2ecf20Sopenharmony_ci}; 1738c2ecf20Sopenharmony_ci 1748c2ecf20Sopenharmony_cistruct ath_frame_info { 1758c2ecf20Sopenharmony_ci struct ath_buf *bf; 1768c2ecf20Sopenharmony_ci u16 framelen; 1778c2ecf20Sopenharmony_ci s8 txq; 1788c2ecf20Sopenharmony_ci u8 keyix; 1798c2ecf20Sopenharmony_ci u8 rtscts_rate; 1808c2ecf20Sopenharmony_ci u8 retries : 6; 1818c2ecf20Sopenharmony_ci u8 dyn_smps : 1; 1828c2ecf20Sopenharmony_ci u8 baw_tracked : 1; 1838c2ecf20Sopenharmony_ci u8 tx_power; 1848c2ecf20Sopenharmony_ci enum ath9k_key_type keytype:2; 1858c2ecf20Sopenharmony_ci}; 1868c2ecf20Sopenharmony_ci 1878c2ecf20Sopenharmony_cistruct ath_rxbuf { 1888c2ecf20Sopenharmony_ci struct list_head list; 1898c2ecf20Sopenharmony_ci struct sk_buff *bf_mpdu; 1908c2ecf20Sopenharmony_ci void *bf_desc; 1918c2ecf20Sopenharmony_ci dma_addr_t bf_daddr; 1928c2ecf20Sopenharmony_ci dma_addr_t bf_buf_addr; 1938c2ecf20Sopenharmony_ci}; 1948c2ecf20Sopenharmony_ci 1958c2ecf20Sopenharmony_ci/** 1968c2ecf20Sopenharmony_ci * enum buffer_type - Buffer type flags 1978c2ecf20Sopenharmony_ci * 1988c2ecf20Sopenharmony_ci * @BUF_AMPDU: This buffer is an ampdu, as part of an aggregate (during TX) 1998c2ecf20Sopenharmony_ci * @BUF_AGGR: Indicates whether the buffer can be aggregated 2008c2ecf20Sopenharmony_ci * (used in aggregation scheduling) 2018c2ecf20Sopenharmony_ci */ 2028c2ecf20Sopenharmony_cienum buffer_type { 2038c2ecf20Sopenharmony_ci BUF_AMPDU = BIT(0), 2048c2ecf20Sopenharmony_ci BUF_AGGR = BIT(1), 2058c2ecf20Sopenharmony_ci}; 2068c2ecf20Sopenharmony_ci 2078c2ecf20Sopenharmony_ci#define bf_isampdu(bf) (bf->bf_state.bf_type & BUF_AMPDU) 2088c2ecf20Sopenharmony_ci#define bf_isaggr(bf) (bf->bf_state.bf_type & BUF_AGGR) 2098c2ecf20Sopenharmony_ci 2108c2ecf20Sopenharmony_cistruct ath_buf_state { 2118c2ecf20Sopenharmony_ci u8 bf_type; 2128c2ecf20Sopenharmony_ci u8 bfs_paprd; 2138c2ecf20Sopenharmony_ci u8 ndelim; 2148c2ecf20Sopenharmony_ci bool stale; 2158c2ecf20Sopenharmony_ci u16 seqno; 2168c2ecf20Sopenharmony_ci unsigned long bfs_paprd_timestamp; 2178c2ecf20Sopenharmony_ci}; 2188c2ecf20Sopenharmony_ci 2198c2ecf20Sopenharmony_cistruct ath_buf { 2208c2ecf20Sopenharmony_ci struct list_head list; 2218c2ecf20Sopenharmony_ci struct ath_buf *bf_lastbf; /* last buf of this unit (a frame or 2228c2ecf20Sopenharmony_ci an aggregate) */ 2238c2ecf20Sopenharmony_ci struct ath_buf *bf_next; /* next subframe in the aggregate */ 2248c2ecf20Sopenharmony_ci struct sk_buff *bf_mpdu; /* enclosing frame structure */ 2258c2ecf20Sopenharmony_ci void *bf_desc; /* virtual addr of desc */ 2268c2ecf20Sopenharmony_ci dma_addr_t bf_daddr; /* physical addr of desc */ 2278c2ecf20Sopenharmony_ci dma_addr_t bf_buf_addr; /* physical addr of data buffer, for DMA */ 2288c2ecf20Sopenharmony_ci struct ieee80211_tx_rate rates[4]; 2298c2ecf20Sopenharmony_ci struct ath_buf_state bf_state; 2308c2ecf20Sopenharmony_ci}; 2318c2ecf20Sopenharmony_ci 2328c2ecf20Sopenharmony_cistruct ath_atx_tid { 2338c2ecf20Sopenharmony_ci struct list_head list; 2348c2ecf20Sopenharmony_ci struct sk_buff_head retry_q; 2358c2ecf20Sopenharmony_ci struct ath_node *an; 2368c2ecf20Sopenharmony_ci struct ath_txq *txq; 2378c2ecf20Sopenharmony_ci unsigned long tx_buf[BITS_TO_LONGS(ATH_TID_MAX_BUFS)]; 2388c2ecf20Sopenharmony_ci u16 seq_start; 2398c2ecf20Sopenharmony_ci u16 seq_next; 2408c2ecf20Sopenharmony_ci u16 baw_size; 2418c2ecf20Sopenharmony_ci u8 tidno; 2428c2ecf20Sopenharmony_ci int baw_head; /* first un-acked tx buffer */ 2438c2ecf20Sopenharmony_ci int baw_tail; /* next unused tx buffer slot */ 2448c2ecf20Sopenharmony_ci 2458c2ecf20Sopenharmony_ci s8 bar_index; 2468c2ecf20Sopenharmony_ci bool active; 2478c2ecf20Sopenharmony_ci bool clear_ps_filter; 2488c2ecf20Sopenharmony_ci}; 2498c2ecf20Sopenharmony_ci 2508c2ecf20Sopenharmony_civoid ath_tx_queue_tid(struct ath_softc *sc, struct ath_atx_tid *tid); 2518c2ecf20Sopenharmony_ci 2528c2ecf20Sopenharmony_cistruct ath_node { 2538c2ecf20Sopenharmony_ci struct ath_softc *sc; 2548c2ecf20Sopenharmony_ci struct ieee80211_sta *sta; /* station struct we're part of */ 2558c2ecf20Sopenharmony_ci struct ieee80211_vif *vif; /* interface with which we're associated */ 2568c2ecf20Sopenharmony_ci 2578c2ecf20Sopenharmony_ci u16 maxampdu; 2588c2ecf20Sopenharmony_ci u8 mpdudensity; 2598c2ecf20Sopenharmony_ci s8 ps_key; 2608c2ecf20Sopenharmony_ci 2618c2ecf20Sopenharmony_ci bool sleeping; 2628c2ecf20Sopenharmony_ci bool no_ps_filter; 2638c2ecf20Sopenharmony_ci 2648c2ecf20Sopenharmony_ci#ifdef CONFIG_ATH9K_STATION_STATISTICS 2658c2ecf20Sopenharmony_ci struct ath_rx_rate_stats rx_rate_stats; 2668c2ecf20Sopenharmony_ci#endif 2678c2ecf20Sopenharmony_ci u8 key_idx[4]; 2688c2ecf20Sopenharmony_ci 2698c2ecf20Sopenharmony_ci int ackto; 2708c2ecf20Sopenharmony_ci struct list_head list; 2718c2ecf20Sopenharmony_ci}; 2728c2ecf20Sopenharmony_ci 2738c2ecf20Sopenharmony_cistruct ath_tx_control { 2748c2ecf20Sopenharmony_ci struct ath_txq *txq; 2758c2ecf20Sopenharmony_ci struct ath_node *an; 2768c2ecf20Sopenharmony_ci struct ieee80211_sta *sta; 2778c2ecf20Sopenharmony_ci u8 paprd; 2788c2ecf20Sopenharmony_ci}; 2798c2ecf20Sopenharmony_ci 2808c2ecf20Sopenharmony_ci 2818c2ecf20Sopenharmony_ci/** 2828c2ecf20Sopenharmony_ci * @txq_map: Index is mac80211 queue number. This is 2838c2ecf20Sopenharmony_ci * not necessarily the same as the hardware queue number 2848c2ecf20Sopenharmony_ci * (axq_qnum). 2858c2ecf20Sopenharmony_ci */ 2868c2ecf20Sopenharmony_cistruct ath_tx { 2878c2ecf20Sopenharmony_ci u32 txqsetup; 2888c2ecf20Sopenharmony_ci spinlock_t txbuflock; 2898c2ecf20Sopenharmony_ci struct list_head txbuf; 2908c2ecf20Sopenharmony_ci struct ath_txq txq[ATH9K_NUM_TX_QUEUES]; 2918c2ecf20Sopenharmony_ci struct ath_descdma txdma; 2928c2ecf20Sopenharmony_ci struct ath_txq *txq_map[IEEE80211_NUM_ACS]; 2938c2ecf20Sopenharmony_ci struct ath_txq *uapsdq; 2948c2ecf20Sopenharmony_ci u16 max_aggr_framelen[IEEE80211_NUM_ACS][4][32]; 2958c2ecf20Sopenharmony_ci}; 2968c2ecf20Sopenharmony_ci 2978c2ecf20Sopenharmony_cistruct ath_rx_edma { 2988c2ecf20Sopenharmony_ci struct sk_buff_head rx_fifo; 2998c2ecf20Sopenharmony_ci u32 rx_fifo_hwsize; 3008c2ecf20Sopenharmony_ci}; 3018c2ecf20Sopenharmony_ci 3028c2ecf20Sopenharmony_cistruct ath_rx { 3038c2ecf20Sopenharmony_ci u8 defant; 3048c2ecf20Sopenharmony_ci u8 rxotherant; 3058c2ecf20Sopenharmony_ci bool discard_next; 3068c2ecf20Sopenharmony_ci u32 *rxlink; 3078c2ecf20Sopenharmony_ci u32 num_pkts; 3088c2ecf20Sopenharmony_ci struct list_head rxbuf; 3098c2ecf20Sopenharmony_ci struct ath_descdma rxdma; 3108c2ecf20Sopenharmony_ci struct ath_rx_edma rx_edma[ATH9K_RX_QUEUE_MAX]; 3118c2ecf20Sopenharmony_ci 3128c2ecf20Sopenharmony_ci struct ath_rxbuf *buf_hold; 3138c2ecf20Sopenharmony_ci struct sk_buff *frag; 3148c2ecf20Sopenharmony_ci 3158c2ecf20Sopenharmony_ci u32 ampdu_ref; 3168c2ecf20Sopenharmony_ci}; 3178c2ecf20Sopenharmony_ci 3188c2ecf20Sopenharmony_ci/*******************/ 3198c2ecf20Sopenharmony_ci/* Channel Context */ 3208c2ecf20Sopenharmony_ci/*******************/ 3218c2ecf20Sopenharmony_ci 3228c2ecf20Sopenharmony_cistruct ath_acq { 3238c2ecf20Sopenharmony_ci struct list_head acq_new; 3248c2ecf20Sopenharmony_ci struct list_head acq_old; 3258c2ecf20Sopenharmony_ci spinlock_t lock; 3268c2ecf20Sopenharmony_ci}; 3278c2ecf20Sopenharmony_ci 3288c2ecf20Sopenharmony_cistruct ath_chanctx { 3298c2ecf20Sopenharmony_ci struct cfg80211_chan_def chandef; 3308c2ecf20Sopenharmony_ci struct list_head vifs; 3318c2ecf20Sopenharmony_ci struct ath_acq acq[IEEE80211_NUM_ACS]; 3328c2ecf20Sopenharmony_ci int hw_queue_base; 3338c2ecf20Sopenharmony_ci 3348c2ecf20Sopenharmony_ci /* do not dereference, use for comparison only */ 3358c2ecf20Sopenharmony_ci struct ieee80211_vif *primary_sta; 3368c2ecf20Sopenharmony_ci 3378c2ecf20Sopenharmony_ci struct ath_beacon_config beacon; 3388c2ecf20Sopenharmony_ci struct ath9k_hw_cal_data caldata; 3398c2ecf20Sopenharmony_ci struct timespec64 tsf_ts; 3408c2ecf20Sopenharmony_ci u64 tsf_val; 3418c2ecf20Sopenharmony_ci u32 last_beacon; 3428c2ecf20Sopenharmony_ci 3438c2ecf20Sopenharmony_ci int flush_timeout; 3448c2ecf20Sopenharmony_ci u16 txpower; 3458c2ecf20Sopenharmony_ci u16 cur_txpower; 3468c2ecf20Sopenharmony_ci bool offchannel; 3478c2ecf20Sopenharmony_ci bool stopped; 3488c2ecf20Sopenharmony_ci bool active; 3498c2ecf20Sopenharmony_ci bool assigned; 3508c2ecf20Sopenharmony_ci bool switch_after_beacon; 3518c2ecf20Sopenharmony_ci 3528c2ecf20Sopenharmony_ci short nvifs; 3538c2ecf20Sopenharmony_ci short nvifs_assigned; 3548c2ecf20Sopenharmony_ci unsigned int rxfilter; 3558c2ecf20Sopenharmony_ci}; 3568c2ecf20Sopenharmony_ci 3578c2ecf20Sopenharmony_cienum ath_chanctx_event { 3588c2ecf20Sopenharmony_ci ATH_CHANCTX_EVENT_BEACON_PREPARE, 3598c2ecf20Sopenharmony_ci ATH_CHANCTX_EVENT_BEACON_SENT, 3608c2ecf20Sopenharmony_ci ATH_CHANCTX_EVENT_TSF_TIMER, 3618c2ecf20Sopenharmony_ci ATH_CHANCTX_EVENT_BEACON_RECEIVED, 3628c2ecf20Sopenharmony_ci ATH_CHANCTX_EVENT_AUTHORIZED, 3638c2ecf20Sopenharmony_ci ATH_CHANCTX_EVENT_SWITCH, 3648c2ecf20Sopenharmony_ci ATH_CHANCTX_EVENT_ASSIGN, 3658c2ecf20Sopenharmony_ci ATH_CHANCTX_EVENT_UNASSIGN, 3668c2ecf20Sopenharmony_ci ATH_CHANCTX_EVENT_CHANGE, 3678c2ecf20Sopenharmony_ci ATH_CHANCTX_EVENT_ENABLE_MULTICHANNEL, 3688c2ecf20Sopenharmony_ci}; 3698c2ecf20Sopenharmony_ci 3708c2ecf20Sopenharmony_cienum ath_chanctx_state { 3718c2ecf20Sopenharmony_ci ATH_CHANCTX_STATE_IDLE, 3728c2ecf20Sopenharmony_ci ATH_CHANCTX_STATE_WAIT_FOR_BEACON, 3738c2ecf20Sopenharmony_ci ATH_CHANCTX_STATE_WAIT_FOR_TIMER, 3748c2ecf20Sopenharmony_ci ATH_CHANCTX_STATE_SWITCH, 3758c2ecf20Sopenharmony_ci ATH_CHANCTX_STATE_FORCE_ACTIVE, 3768c2ecf20Sopenharmony_ci}; 3778c2ecf20Sopenharmony_ci 3788c2ecf20Sopenharmony_cistruct ath_chanctx_sched { 3798c2ecf20Sopenharmony_ci bool beacon_pending; 3808c2ecf20Sopenharmony_ci bool beacon_adjust; 3818c2ecf20Sopenharmony_ci bool offchannel_pending; 3828c2ecf20Sopenharmony_ci bool wait_switch; 3838c2ecf20Sopenharmony_ci bool force_noa_update; 3848c2ecf20Sopenharmony_ci bool extend_absence; 3858c2ecf20Sopenharmony_ci bool mgd_prepare_tx; 3868c2ecf20Sopenharmony_ci enum ath_chanctx_state state; 3878c2ecf20Sopenharmony_ci u8 beacon_miss; 3888c2ecf20Sopenharmony_ci 3898c2ecf20Sopenharmony_ci u32 next_tbtt; 3908c2ecf20Sopenharmony_ci u32 switch_start_time; 3918c2ecf20Sopenharmony_ci unsigned int offchannel_duration; 3928c2ecf20Sopenharmony_ci unsigned int channel_switch_time; 3938c2ecf20Sopenharmony_ci 3948c2ecf20Sopenharmony_ci /* backup, in case the hardware timer fails */ 3958c2ecf20Sopenharmony_ci struct timer_list timer; 3968c2ecf20Sopenharmony_ci}; 3978c2ecf20Sopenharmony_ci 3988c2ecf20Sopenharmony_cienum ath_offchannel_state { 3998c2ecf20Sopenharmony_ci ATH_OFFCHANNEL_IDLE, 4008c2ecf20Sopenharmony_ci ATH_OFFCHANNEL_PROBE_SEND, 4018c2ecf20Sopenharmony_ci ATH_OFFCHANNEL_PROBE_WAIT, 4028c2ecf20Sopenharmony_ci ATH_OFFCHANNEL_SUSPEND, 4038c2ecf20Sopenharmony_ci ATH_OFFCHANNEL_ROC_START, 4048c2ecf20Sopenharmony_ci ATH_OFFCHANNEL_ROC_WAIT, 4058c2ecf20Sopenharmony_ci ATH_OFFCHANNEL_ROC_DONE, 4068c2ecf20Sopenharmony_ci}; 4078c2ecf20Sopenharmony_ci 4088c2ecf20Sopenharmony_cienum ath_roc_complete_reason { 4098c2ecf20Sopenharmony_ci ATH_ROC_COMPLETE_EXPIRE, 4108c2ecf20Sopenharmony_ci ATH_ROC_COMPLETE_ABORT, 4118c2ecf20Sopenharmony_ci ATH_ROC_COMPLETE_CANCEL, 4128c2ecf20Sopenharmony_ci}; 4138c2ecf20Sopenharmony_ci 4148c2ecf20Sopenharmony_cistruct ath_offchannel { 4158c2ecf20Sopenharmony_ci struct ath_chanctx chan; 4168c2ecf20Sopenharmony_ci struct timer_list timer; 4178c2ecf20Sopenharmony_ci struct cfg80211_scan_request *scan_req; 4188c2ecf20Sopenharmony_ci struct ieee80211_vif *scan_vif; 4198c2ecf20Sopenharmony_ci int scan_idx; 4208c2ecf20Sopenharmony_ci enum ath_offchannel_state state; 4218c2ecf20Sopenharmony_ci struct ieee80211_channel *roc_chan; 4228c2ecf20Sopenharmony_ci struct ieee80211_vif *roc_vif; 4238c2ecf20Sopenharmony_ci int roc_duration; 4248c2ecf20Sopenharmony_ci int duration; 4258c2ecf20Sopenharmony_ci}; 4268c2ecf20Sopenharmony_ci 4278c2ecf20Sopenharmony_cistatic inline struct ath_atx_tid * 4288c2ecf20Sopenharmony_ciath_node_to_tid(struct ath_node *an, u8 tidno) 4298c2ecf20Sopenharmony_ci{ 4308c2ecf20Sopenharmony_ci struct ieee80211_sta *sta = an->sta; 4318c2ecf20Sopenharmony_ci struct ieee80211_vif *vif = an->vif; 4328c2ecf20Sopenharmony_ci struct ieee80211_txq *txq; 4338c2ecf20Sopenharmony_ci 4348c2ecf20Sopenharmony_ci BUG_ON(!vif); 4358c2ecf20Sopenharmony_ci if (sta) 4368c2ecf20Sopenharmony_ci txq = sta->txq[tidno % ARRAY_SIZE(sta->txq)]; 4378c2ecf20Sopenharmony_ci else 4388c2ecf20Sopenharmony_ci txq = vif->txq; 4398c2ecf20Sopenharmony_ci 4408c2ecf20Sopenharmony_ci return (struct ath_atx_tid *) txq->drv_priv; 4418c2ecf20Sopenharmony_ci} 4428c2ecf20Sopenharmony_ci 4438c2ecf20Sopenharmony_ci#define case_rtn_string(val) case val: return #val 4448c2ecf20Sopenharmony_ci 4458c2ecf20Sopenharmony_ci#define ath_for_each_chanctx(_sc, _ctx) \ 4468c2ecf20Sopenharmony_ci for (ctx = &sc->chanctx[0]; \ 4478c2ecf20Sopenharmony_ci ctx <= &sc->chanctx[ARRAY_SIZE(sc->chanctx) - 1]; \ 4488c2ecf20Sopenharmony_ci ctx++) 4498c2ecf20Sopenharmony_ci 4508c2ecf20Sopenharmony_civoid ath_chanctx_init(struct ath_softc *sc); 4518c2ecf20Sopenharmony_civoid ath_chanctx_set_channel(struct ath_softc *sc, struct ath_chanctx *ctx, 4528c2ecf20Sopenharmony_ci struct cfg80211_chan_def *chandef); 4538c2ecf20Sopenharmony_ci 4548c2ecf20Sopenharmony_ci#ifdef CONFIG_ATH9K_CHANNEL_CONTEXT 4558c2ecf20Sopenharmony_ci 4568c2ecf20Sopenharmony_cistatic inline struct ath_chanctx * 4578c2ecf20Sopenharmony_ciath_chanctx_get(struct ieee80211_chanctx_conf *ctx) 4588c2ecf20Sopenharmony_ci{ 4598c2ecf20Sopenharmony_ci struct ath_chanctx **ptr = (void *) ctx->drv_priv; 4608c2ecf20Sopenharmony_ci return *ptr; 4618c2ecf20Sopenharmony_ci} 4628c2ecf20Sopenharmony_ci 4638c2ecf20Sopenharmony_cibool ath9k_is_chanctx_enabled(void); 4648c2ecf20Sopenharmony_civoid ath9k_fill_chanctx_ops(void); 4658c2ecf20Sopenharmony_civoid ath9k_init_channel_context(struct ath_softc *sc); 4668c2ecf20Sopenharmony_civoid ath9k_offchannel_init(struct ath_softc *sc); 4678c2ecf20Sopenharmony_civoid ath9k_deinit_channel_context(struct ath_softc *sc); 4688c2ecf20Sopenharmony_ciint ath9k_init_p2p(struct ath_softc *sc); 4698c2ecf20Sopenharmony_civoid ath9k_deinit_p2p(struct ath_softc *sc); 4708c2ecf20Sopenharmony_civoid ath9k_p2p_remove_vif(struct ath_softc *sc, 4718c2ecf20Sopenharmony_ci struct ieee80211_vif *vif); 4728c2ecf20Sopenharmony_civoid ath9k_p2p_beacon_sync(struct ath_softc *sc); 4738c2ecf20Sopenharmony_civoid ath9k_p2p_bss_info_changed(struct ath_softc *sc, 4748c2ecf20Sopenharmony_ci struct ieee80211_vif *vif); 4758c2ecf20Sopenharmony_civoid ath9k_beacon_add_noa(struct ath_softc *sc, struct ath_vif *avp, 4768c2ecf20Sopenharmony_ci struct sk_buff *skb); 4778c2ecf20Sopenharmony_civoid ath9k_p2p_ps_timer(void *priv); 4788c2ecf20Sopenharmony_civoid ath9k_chanctx_wake_queues(struct ath_softc *sc, struct ath_chanctx *ctx); 4798c2ecf20Sopenharmony_civoid ath9k_chanctx_stop_queues(struct ath_softc *sc, struct ath_chanctx *ctx); 4808c2ecf20Sopenharmony_civoid ath_chanctx_check_active(struct ath_softc *sc, struct ath_chanctx *ctx); 4818c2ecf20Sopenharmony_ci 4828c2ecf20Sopenharmony_civoid ath_chanctx_beacon_recv_ev(struct ath_softc *sc, 4838c2ecf20Sopenharmony_ci enum ath_chanctx_event ev); 4848c2ecf20Sopenharmony_civoid ath_chanctx_beacon_sent_ev(struct ath_softc *sc, 4858c2ecf20Sopenharmony_ci enum ath_chanctx_event ev); 4868c2ecf20Sopenharmony_civoid ath_chanctx_event(struct ath_softc *sc, struct ieee80211_vif *vif, 4878c2ecf20Sopenharmony_ci enum ath_chanctx_event ev); 4888c2ecf20Sopenharmony_civoid ath_chanctx_set_next(struct ath_softc *sc, bool force); 4898c2ecf20Sopenharmony_civoid ath_offchannel_next(struct ath_softc *sc); 4908c2ecf20Sopenharmony_civoid ath_scan_complete(struct ath_softc *sc, bool abort); 4918c2ecf20Sopenharmony_civoid ath_roc_complete(struct ath_softc *sc, 4928c2ecf20Sopenharmony_ci enum ath_roc_complete_reason reason); 4938c2ecf20Sopenharmony_cistruct ath_chanctx* ath_is_go_chanctx_present(struct ath_softc *sc); 4948c2ecf20Sopenharmony_ci 4958c2ecf20Sopenharmony_ci#else 4968c2ecf20Sopenharmony_ci 4978c2ecf20Sopenharmony_cistatic inline bool ath9k_is_chanctx_enabled(void) 4988c2ecf20Sopenharmony_ci{ 4998c2ecf20Sopenharmony_ci return false; 5008c2ecf20Sopenharmony_ci} 5018c2ecf20Sopenharmony_cistatic inline void ath9k_fill_chanctx_ops(void) 5028c2ecf20Sopenharmony_ci{ 5038c2ecf20Sopenharmony_ci} 5048c2ecf20Sopenharmony_cistatic inline void ath9k_init_channel_context(struct ath_softc *sc) 5058c2ecf20Sopenharmony_ci{ 5068c2ecf20Sopenharmony_ci} 5078c2ecf20Sopenharmony_cistatic inline void ath9k_offchannel_init(struct ath_softc *sc) 5088c2ecf20Sopenharmony_ci{ 5098c2ecf20Sopenharmony_ci} 5108c2ecf20Sopenharmony_cistatic inline void ath9k_deinit_channel_context(struct ath_softc *sc) 5118c2ecf20Sopenharmony_ci{ 5128c2ecf20Sopenharmony_ci} 5138c2ecf20Sopenharmony_cistatic inline void ath_chanctx_beacon_recv_ev(struct ath_softc *sc, 5148c2ecf20Sopenharmony_ci enum ath_chanctx_event ev) 5158c2ecf20Sopenharmony_ci{ 5168c2ecf20Sopenharmony_ci} 5178c2ecf20Sopenharmony_cistatic inline void ath_chanctx_beacon_sent_ev(struct ath_softc *sc, 5188c2ecf20Sopenharmony_ci enum ath_chanctx_event ev) 5198c2ecf20Sopenharmony_ci{ 5208c2ecf20Sopenharmony_ci} 5218c2ecf20Sopenharmony_cistatic inline void ath_chanctx_event(struct ath_softc *sc, 5228c2ecf20Sopenharmony_ci struct ieee80211_vif *vif, 5238c2ecf20Sopenharmony_ci enum ath_chanctx_event ev) 5248c2ecf20Sopenharmony_ci{ 5258c2ecf20Sopenharmony_ci} 5268c2ecf20Sopenharmony_cistatic inline int ath9k_init_p2p(struct ath_softc *sc) 5278c2ecf20Sopenharmony_ci{ 5288c2ecf20Sopenharmony_ci return 0; 5298c2ecf20Sopenharmony_ci} 5308c2ecf20Sopenharmony_cistatic inline void ath9k_deinit_p2p(struct ath_softc *sc) 5318c2ecf20Sopenharmony_ci{ 5328c2ecf20Sopenharmony_ci} 5338c2ecf20Sopenharmony_cistatic inline void ath9k_p2p_remove_vif(struct ath_softc *sc, 5348c2ecf20Sopenharmony_ci struct ieee80211_vif *vif) 5358c2ecf20Sopenharmony_ci{ 5368c2ecf20Sopenharmony_ci} 5378c2ecf20Sopenharmony_cistatic inline void ath9k_p2p_beacon_sync(struct ath_softc *sc) 5388c2ecf20Sopenharmony_ci{ 5398c2ecf20Sopenharmony_ci} 5408c2ecf20Sopenharmony_cistatic inline void ath9k_p2p_bss_info_changed(struct ath_softc *sc, 5418c2ecf20Sopenharmony_ci struct ieee80211_vif *vif) 5428c2ecf20Sopenharmony_ci{ 5438c2ecf20Sopenharmony_ci} 5448c2ecf20Sopenharmony_cistatic inline void ath9k_beacon_add_noa(struct ath_softc *sc, struct ath_vif *avp, 5458c2ecf20Sopenharmony_ci struct sk_buff *skb) 5468c2ecf20Sopenharmony_ci{ 5478c2ecf20Sopenharmony_ci} 5488c2ecf20Sopenharmony_cistatic inline void ath9k_p2p_ps_timer(struct ath_softc *sc) 5498c2ecf20Sopenharmony_ci{ 5508c2ecf20Sopenharmony_ci} 5518c2ecf20Sopenharmony_cistatic inline void ath9k_chanctx_wake_queues(struct ath_softc *sc, 5528c2ecf20Sopenharmony_ci struct ath_chanctx *ctx) 5538c2ecf20Sopenharmony_ci{ 5548c2ecf20Sopenharmony_ci} 5558c2ecf20Sopenharmony_cistatic inline void ath9k_chanctx_stop_queues(struct ath_softc *sc, 5568c2ecf20Sopenharmony_ci struct ath_chanctx *ctx) 5578c2ecf20Sopenharmony_ci{ 5588c2ecf20Sopenharmony_ci} 5598c2ecf20Sopenharmony_cistatic inline void ath_chanctx_check_active(struct ath_softc *sc, 5608c2ecf20Sopenharmony_ci struct ath_chanctx *ctx) 5618c2ecf20Sopenharmony_ci{ 5628c2ecf20Sopenharmony_ci} 5638c2ecf20Sopenharmony_ci 5648c2ecf20Sopenharmony_ci#endif /* CONFIG_ATH9K_CHANNEL_CONTEXT */ 5658c2ecf20Sopenharmony_ci 5668c2ecf20Sopenharmony_cistatic inline void ath_txq_lock(struct ath_softc *sc, struct ath_txq *txq) 5678c2ecf20Sopenharmony_ci{ 5688c2ecf20Sopenharmony_ci spin_lock_bh(&txq->axq_lock); 5698c2ecf20Sopenharmony_ci} 5708c2ecf20Sopenharmony_cistatic inline void ath_txq_unlock(struct ath_softc *sc, struct ath_txq *txq) 5718c2ecf20Sopenharmony_ci{ 5728c2ecf20Sopenharmony_ci spin_unlock_bh(&txq->axq_lock); 5738c2ecf20Sopenharmony_ci} 5748c2ecf20Sopenharmony_ci 5758c2ecf20Sopenharmony_civoid ath_startrecv(struct ath_softc *sc); 5768c2ecf20Sopenharmony_cibool ath_stoprecv(struct ath_softc *sc); 5778c2ecf20Sopenharmony_ciu32 ath_calcrxfilter(struct ath_softc *sc); 5788c2ecf20Sopenharmony_ciint ath_rx_init(struct ath_softc *sc, int nbufs); 5798c2ecf20Sopenharmony_civoid ath_rx_cleanup(struct ath_softc *sc); 5808c2ecf20Sopenharmony_ciint ath_rx_tasklet(struct ath_softc *sc, int flush, bool hp); 5818c2ecf20Sopenharmony_cistruct ath_txq *ath_txq_setup(struct ath_softc *sc, int qtype, int subtype); 5828c2ecf20Sopenharmony_civoid ath_txq_unlock_complete(struct ath_softc *sc, struct ath_txq *txq); 5838c2ecf20Sopenharmony_civoid ath_tx_cleanupq(struct ath_softc *sc, struct ath_txq *txq); 5848c2ecf20Sopenharmony_cibool ath_drain_all_txq(struct ath_softc *sc); 5858c2ecf20Sopenharmony_civoid ath_draintxq(struct ath_softc *sc, struct ath_txq *txq); 5868c2ecf20Sopenharmony_civoid ath_tx_node_init(struct ath_softc *sc, struct ath_node *an); 5878c2ecf20Sopenharmony_civoid ath_tx_node_cleanup(struct ath_softc *sc, struct ath_node *an); 5888c2ecf20Sopenharmony_civoid ath_txq_schedule(struct ath_softc *sc, struct ath_txq *txq); 5898c2ecf20Sopenharmony_civoid ath_txq_schedule_all(struct ath_softc *sc); 5908c2ecf20Sopenharmony_ciint ath_tx_init(struct ath_softc *sc, int nbufs); 5918c2ecf20Sopenharmony_ciint ath_txq_update(struct ath_softc *sc, int qnum, 5928c2ecf20Sopenharmony_ci struct ath9k_tx_queue_info *q); 5938c2ecf20Sopenharmony_ciu32 ath_pkt_duration(struct ath_softc *sc, u8 rix, int pktlen, 5948c2ecf20Sopenharmony_ci int width, int half_gi, bool shortPreamble); 5958c2ecf20Sopenharmony_civoid ath_update_max_aggr_framelen(struct ath_softc *sc, int queue, int txop); 5968c2ecf20Sopenharmony_civoid ath_assign_seq(struct ath_common *common, struct sk_buff *skb); 5978c2ecf20Sopenharmony_ciint ath_tx_start(struct ieee80211_hw *hw, struct sk_buff *skb, 5988c2ecf20Sopenharmony_ci struct ath_tx_control *txctl); 5998c2ecf20Sopenharmony_civoid ath_tx_cabq(struct ieee80211_hw *hw, struct ieee80211_vif *vif, 6008c2ecf20Sopenharmony_ci struct sk_buff *skb); 6018c2ecf20Sopenharmony_civoid ath_tx_tasklet(struct ath_softc *sc); 6028c2ecf20Sopenharmony_civoid ath_tx_edma_tasklet(struct ath_softc *sc); 6038c2ecf20Sopenharmony_ciint ath_tx_aggr_start(struct ath_softc *sc, struct ieee80211_sta *sta, 6048c2ecf20Sopenharmony_ci u16 tid, u16 *ssn); 6058c2ecf20Sopenharmony_civoid ath_tx_aggr_stop(struct ath_softc *sc, struct ieee80211_sta *sta, u16 tid); 6068c2ecf20Sopenharmony_ci 6078c2ecf20Sopenharmony_civoid ath_tx_aggr_wakeup(struct ath_softc *sc, struct ath_node *an); 6088c2ecf20Sopenharmony_civoid ath_tx_aggr_sleep(struct ieee80211_sta *sta, struct ath_softc *sc, 6098c2ecf20Sopenharmony_ci struct ath_node *an); 6108c2ecf20Sopenharmony_civoid ath9k_release_buffered_frames(struct ieee80211_hw *hw, 6118c2ecf20Sopenharmony_ci struct ieee80211_sta *sta, 6128c2ecf20Sopenharmony_ci u16 tids, int nframes, 6138c2ecf20Sopenharmony_ci enum ieee80211_frame_release_type reason, 6148c2ecf20Sopenharmony_ci bool more_data); 6158c2ecf20Sopenharmony_civoid ath9k_wake_tx_queue(struct ieee80211_hw *hw, struct ieee80211_txq *queue); 6168c2ecf20Sopenharmony_ci 6178c2ecf20Sopenharmony_ci/********/ 6188c2ecf20Sopenharmony_ci/* VIFs */ 6198c2ecf20Sopenharmony_ci/********/ 6208c2ecf20Sopenharmony_ci 6218c2ecf20Sopenharmony_ci#define P2P_DEFAULT_CTWIN 10 6228c2ecf20Sopenharmony_ci 6238c2ecf20Sopenharmony_cistruct ath_vif { 6248c2ecf20Sopenharmony_ci struct list_head list; 6258c2ecf20Sopenharmony_ci 6268c2ecf20Sopenharmony_ci u16 seq_no; 6278c2ecf20Sopenharmony_ci 6288c2ecf20Sopenharmony_ci /* BSS info */ 6298c2ecf20Sopenharmony_ci u8 bssid[ETH_ALEN] __aligned(2); 6308c2ecf20Sopenharmony_ci u16 aid; 6318c2ecf20Sopenharmony_ci bool assoc; 6328c2ecf20Sopenharmony_ci 6338c2ecf20Sopenharmony_ci struct ieee80211_vif *vif; 6348c2ecf20Sopenharmony_ci struct ath_node mcast_node; 6358c2ecf20Sopenharmony_ci int av_bslot; 6368c2ecf20Sopenharmony_ci __le64 tsf_adjust; /* TSF adjustment for staggered beacons */ 6378c2ecf20Sopenharmony_ci struct ath_buf *av_bcbuf; 6388c2ecf20Sopenharmony_ci struct ath_chanctx *chanctx; 6398c2ecf20Sopenharmony_ci 6408c2ecf20Sopenharmony_ci /* P2P Client */ 6418c2ecf20Sopenharmony_ci struct ieee80211_noa_data noa; 6428c2ecf20Sopenharmony_ci 6438c2ecf20Sopenharmony_ci /* P2P GO */ 6448c2ecf20Sopenharmony_ci u8 noa_index; 6458c2ecf20Sopenharmony_ci u32 offchannel_start; 6468c2ecf20Sopenharmony_ci u32 offchannel_duration; 6478c2ecf20Sopenharmony_ci 6488c2ecf20Sopenharmony_ci /* These are used for both periodic and one-shot */ 6498c2ecf20Sopenharmony_ci u32 noa_start; 6508c2ecf20Sopenharmony_ci u32 noa_duration; 6518c2ecf20Sopenharmony_ci bool periodic_noa; 6528c2ecf20Sopenharmony_ci bool oneshot_noa; 6538c2ecf20Sopenharmony_ci}; 6548c2ecf20Sopenharmony_ci 6558c2ecf20Sopenharmony_cistruct ath9k_vif_iter_data { 6568c2ecf20Sopenharmony_ci u8 hw_macaddr[ETH_ALEN]; /* address of the first vif */ 6578c2ecf20Sopenharmony_ci u8 mask[ETH_ALEN]; /* bssid mask */ 6588c2ecf20Sopenharmony_ci bool has_hw_macaddr; 6598c2ecf20Sopenharmony_ci u8 slottime; 6608c2ecf20Sopenharmony_ci bool beacons; 6618c2ecf20Sopenharmony_ci 6628c2ecf20Sopenharmony_ci int naps; /* number of AP vifs */ 6638c2ecf20Sopenharmony_ci int nmeshes; /* number of mesh vifs */ 6648c2ecf20Sopenharmony_ci int nstations; /* number of station vifs */ 6658c2ecf20Sopenharmony_ci int nwds; /* number of WDS vifs */ 6668c2ecf20Sopenharmony_ci int nadhocs; /* number of adhoc vifs */ 6678c2ecf20Sopenharmony_ci int nocbs; /* number of OCB vifs */ 6688c2ecf20Sopenharmony_ci int nbcnvifs; /* number of beaconing vifs */ 6698c2ecf20Sopenharmony_ci struct ieee80211_vif *primary_beacon_vif; 6708c2ecf20Sopenharmony_ci struct ieee80211_vif *primary_sta; 6718c2ecf20Sopenharmony_ci}; 6728c2ecf20Sopenharmony_ci 6738c2ecf20Sopenharmony_civoid ath9k_calculate_iter_data(struct ath_softc *sc, 6748c2ecf20Sopenharmony_ci struct ath_chanctx *ctx, 6758c2ecf20Sopenharmony_ci struct ath9k_vif_iter_data *iter_data); 6768c2ecf20Sopenharmony_civoid ath9k_calculate_summary_state(struct ath_softc *sc, 6778c2ecf20Sopenharmony_ci struct ath_chanctx *ctx); 6788c2ecf20Sopenharmony_civoid ath9k_set_txpower(struct ath_softc *sc, struct ieee80211_vif *vif); 6798c2ecf20Sopenharmony_ci 6808c2ecf20Sopenharmony_ci/*******************/ 6818c2ecf20Sopenharmony_ci/* Beacon Handling */ 6828c2ecf20Sopenharmony_ci/*******************/ 6838c2ecf20Sopenharmony_ci 6848c2ecf20Sopenharmony_ci/* 6858c2ecf20Sopenharmony_ci * Regardless of the number of beacons we stagger, (i.e. regardless of the 6868c2ecf20Sopenharmony_ci * number of BSSIDs) if a given beacon does not go out even after waiting this 6878c2ecf20Sopenharmony_ci * number of beacon intervals, the game's up. 6888c2ecf20Sopenharmony_ci */ 6898c2ecf20Sopenharmony_ci#define BSTUCK_THRESH 9 6908c2ecf20Sopenharmony_ci#define ATH_BCBUF 8 6918c2ecf20Sopenharmony_ci#define ATH_DEFAULT_BINTVAL 100 /* TU */ 6928c2ecf20Sopenharmony_ci#define ATH_DEFAULT_BMISS_LIMIT 10 6938c2ecf20Sopenharmony_ci 6948c2ecf20Sopenharmony_ci#define TSF_TO_TU(_h,_l) \ 6958c2ecf20Sopenharmony_ci ((((u32)(_h)) << 22) | (((u32)(_l)) >> 10)) 6968c2ecf20Sopenharmony_ci 6978c2ecf20Sopenharmony_cistruct ath_beacon { 6988c2ecf20Sopenharmony_ci enum { 6998c2ecf20Sopenharmony_ci OK, /* no change needed */ 7008c2ecf20Sopenharmony_ci UPDATE, /* update pending */ 7018c2ecf20Sopenharmony_ci COMMIT /* beacon sent, commit change */ 7028c2ecf20Sopenharmony_ci } updateslot; /* slot time update fsm */ 7038c2ecf20Sopenharmony_ci 7048c2ecf20Sopenharmony_ci u32 beaconq; 7058c2ecf20Sopenharmony_ci u32 bmisscnt; 7068c2ecf20Sopenharmony_ci struct ieee80211_vif *bslot[ATH_BCBUF]; 7078c2ecf20Sopenharmony_ci int slottime; 7088c2ecf20Sopenharmony_ci int slotupdate; 7098c2ecf20Sopenharmony_ci struct ath_descdma bdma; 7108c2ecf20Sopenharmony_ci struct ath_txq *cabq; 7118c2ecf20Sopenharmony_ci struct list_head bbuf; 7128c2ecf20Sopenharmony_ci 7138c2ecf20Sopenharmony_ci bool tx_processed; 7148c2ecf20Sopenharmony_ci bool tx_last; 7158c2ecf20Sopenharmony_ci}; 7168c2ecf20Sopenharmony_ci 7178c2ecf20Sopenharmony_civoid ath9k_beacon_tasklet(struct tasklet_struct *t); 7188c2ecf20Sopenharmony_civoid ath9k_beacon_config(struct ath_softc *sc, struct ieee80211_vif *main_vif, 7198c2ecf20Sopenharmony_ci bool beacons); 7208c2ecf20Sopenharmony_civoid ath9k_beacon_assign_slot(struct ath_softc *sc, struct ieee80211_vif *vif); 7218c2ecf20Sopenharmony_civoid ath9k_beacon_remove_slot(struct ath_softc *sc, struct ieee80211_vif *vif); 7228c2ecf20Sopenharmony_civoid ath9k_beacon_ensure_primary_slot(struct ath_softc *sc); 7238c2ecf20Sopenharmony_civoid ath9k_set_beacon(struct ath_softc *sc); 7248c2ecf20Sopenharmony_cibool ath9k_csa_is_finished(struct ath_softc *sc, struct ieee80211_vif *vif); 7258c2ecf20Sopenharmony_civoid ath9k_csa_update(struct ath_softc *sc); 7268c2ecf20Sopenharmony_ci 7278c2ecf20Sopenharmony_ci/*******************/ 7288c2ecf20Sopenharmony_ci/* Link Monitoring */ 7298c2ecf20Sopenharmony_ci/*******************/ 7308c2ecf20Sopenharmony_ci 7318c2ecf20Sopenharmony_ci#define ATH_STA_SHORT_CALINTERVAL 1000 /* 1 second */ 7328c2ecf20Sopenharmony_ci#define ATH_AP_SHORT_CALINTERVAL 100 /* 100 ms */ 7338c2ecf20Sopenharmony_ci#define ATH_ANI_POLLINTERVAL_OLD 100 /* 100 ms */ 7348c2ecf20Sopenharmony_ci#define ATH_ANI_POLLINTERVAL_NEW 1000 /* 1000 ms */ 7358c2ecf20Sopenharmony_ci#define ATH_LONG_CALINTERVAL_INT 1000 /* 1000 ms */ 7368c2ecf20Sopenharmony_ci#define ATH_LONG_CALINTERVAL 30000 /* 30 seconds */ 7378c2ecf20Sopenharmony_ci#define ATH_RESTART_CALINTERVAL 1200000 /* 20 minutes */ 7388c2ecf20Sopenharmony_ci#define ATH_ANI_MAX_SKIP_COUNT 10 7398c2ecf20Sopenharmony_ci#define ATH_PAPRD_TIMEOUT 100 /* msecs */ 7408c2ecf20Sopenharmony_ci#define ATH_PLL_WORK_INTERVAL 100 7418c2ecf20Sopenharmony_ci 7428c2ecf20Sopenharmony_civoid ath_hw_check_work(struct work_struct *work); 7438c2ecf20Sopenharmony_civoid ath_reset_work(struct work_struct *work); 7448c2ecf20Sopenharmony_cibool ath_hw_check(struct ath_softc *sc); 7458c2ecf20Sopenharmony_civoid ath_hw_pll_work(struct work_struct *work); 7468c2ecf20Sopenharmony_civoid ath_paprd_calibrate(struct work_struct *work); 7478c2ecf20Sopenharmony_civoid ath_ani_calibrate(struct timer_list *t); 7488c2ecf20Sopenharmony_civoid ath_start_ani(struct ath_softc *sc); 7498c2ecf20Sopenharmony_civoid ath_stop_ani(struct ath_softc *sc); 7508c2ecf20Sopenharmony_civoid ath_check_ani(struct ath_softc *sc); 7518c2ecf20Sopenharmony_ciint ath_update_survey_stats(struct ath_softc *sc); 7528c2ecf20Sopenharmony_civoid ath_update_survey_nf(struct ath_softc *sc, int channel); 7538c2ecf20Sopenharmony_civoid ath9k_queue_reset(struct ath_softc *sc, enum ath_reset_type type); 7548c2ecf20Sopenharmony_civoid ath_ps_full_sleep(struct timer_list *t); 7558c2ecf20Sopenharmony_civoid __ath9k_flush(struct ieee80211_hw *hw, u32 queues, bool drop, 7568c2ecf20Sopenharmony_ci bool sw_pending, bool timeout_override); 7578c2ecf20Sopenharmony_ci 7588c2ecf20Sopenharmony_ci/**********/ 7598c2ecf20Sopenharmony_ci/* BTCOEX */ 7608c2ecf20Sopenharmony_ci/**********/ 7618c2ecf20Sopenharmony_ci 7628c2ecf20Sopenharmony_ci#define ATH_DUMP_BTCOEX(_s, _val) \ 7638c2ecf20Sopenharmony_ci do { \ 7648c2ecf20Sopenharmony_ci len += scnprintf(buf + len, size - len, \ 7658c2ecf20Sopenharmony_ci "%20s : %10d\n", _s, (_val)); \ 7668c2ecf20Sopenharmony_ci } while (0) 7678c2ecf20Sopenharmony_ci 7688c2ecf20Sopenharmony_cienum bt_op_flags { 7698c2ecf20Sopenharmony_ci BT_OP_PRIORITY_DETECTED, 7708c2ecf20Sopenharmony_ci BT_OP_SCAN, 7718c2ecf20Sopenharmony_ci}; 7728c2ecf20Sopenharmony_ci 7738c2ecf20Sopenharmony_cistruct ath_btcoex { 7748c2ecf20Sopenharmony_ci spinlock_t btcoex_lock; 7758c2ecf20Sopenharmony_ci struct timer_list period_timer; /* Timer for BT period */ 7768c2ecf20Sopenharmony_ci struct timer_list no_stomp_timer; 7778c2ecf20Sopenharmony_ci u32 bt_priority_cnt; 7788c2ecf20Sopenharmony_ci unsigned long bt_priority_time; 7798c2ecf20Sopenharmony_ci unsigned long op_flags; 7808c2ecf20Sopenharmony_ci int bt_stomp_type; /* Types of BT stomping */ 7818c2ecf20Sopenharmony_ci u32 btcoex_no_stomp; /* in msec */ 7828c2ecf20Sopenharmony_ci u32 btcoex_period; /* in msec */ 7838c2ecf20Sopenharmony_ci u32 btscan_no_stomp; /* in msec */ 7848c2ecf20Sopenharmony_ci u32 duty_cycle; 7858c2ecf20Sopenharmony_ci u32 bt_wait_time; 7868c2ecf20Sopenharmony_ci int rssi_count; 7878c2ecf20Sopenharmony_ci struct ath_mci_profile mci; 7888c2ecf20Sopenharmony_ci u8 stomp_audio; 7898c2ecf20Sopenharmony_ci}; 7908c2ecf20Sopenharmony_ci 7918c2ecf20Sopenharmony_ci#ifdef CONFIG_ATH9K_BTCOEX_SUPPORT 7928c2ecf20Sopenharmony_ciint ath9k_init_btcoex(struct ath_softc *sc); 7938c2ecf20Sopenharmony_civoid ath9k_deinit_btcoex(struct ath_softc *sc); 7948c2ecf20Sopenharmony_civoid ath9k_start_btcoex(struct ath_softc *sc); 7958c2ecf20Sopenharmony_civoid ath9k_stop_btcoex(struct ath_softc *sc); 7968c2ecf20Sopenharmony_civoid ath9k_btcoex_timer_resume(struct ath_softc *sc); 7978c2ecf20Sopenharmony_civoid ath9k_btcoex_timer_pause(struct ath_softc *sc); 7988c2ecf20Sopenharmony_civoid ath9k_btcoex_handle_interrupt(struct ath_softc *sc, u32 status); 7998c2ecf20Sopenharmony_ciu16 ath9k_btcoex_aggr_limit(struct ath_softc *sc, u32 max_4ms_framelen); 8008c2ecf20Sopenharmony_civoid ath9k_btcoex_stop_gen_timer(struct ath_softc *sc); 8018c2ecf20Sopenharmony_ciint ath9k_dump_btcoex(struct ath_softc *sc, u8 *buf, u32 size); 8028c2ecf20Sopenharmony_ci#else 8038c2ecf20Sopenharmony_cistatic inline int ath9k_init_btcoex(struct ath_softc *sc) 8048c2ecf20Sopenharmony_ci{ 8058c2ecf20Sopenharmony_ci return 0; 8068c2ecf20Sopenharmony_ci} 8078c2ecf20Sopenharmony_cistatic inline void ath9k_deinit_btcoex(struct ath_softc *sc) 8088c2ecf20Sopenharmony_ci{ 8098c2ecf20Sopenharmony_ci} 8108c2ecf20Sopenharmony_cistatic inline void ath9k_start_btcoex(struct ath_softc *sc) 8118c2ecf20Sopenharmony_ci{ 8128c2ecf20Sopenharmony_ci} 8138c2ecf20Sopenharmony_cistatic inline void ath9k_stop_btcoex(struct ath_softc *sc) 8148c2ecf20Sopenharmony_ci{ 8158c2ecf20Sopenharmony_ci} 8168c2ecf20Sopenharmony_cistatic inline void ath9k_btcoex_handle_interrupt(struct ath_softc *sc, 8178c2ecf20Sopenharmony_ci u32 status) 8188c2ecf20Sopenharmony_ci{ 8198c2ecf20Sopenharmony_ci} 8208c2ecf20Sopenharmony_cistatic inline u16 ath9k_btcoex_aggr_limit(struct ath_softc *sc, 8218c2ecf20Sopenharmony_ci u32 max_4ms_framelen) 8228c2ecf20Sopenharmony_ci{ 8238c2ecf20Sopenharmony_ci return 0; 8248c2ecf20Sopenharmony_ci} 8258c2ecf20Sopenharmony_cistatic inline void ath9k_btcoex_stop_gen_timer(struct ath_softc *sc) 8268c2ecf20Sopenharmony_ci{ 8278c2ecf20Sopenharmony_ci} 8288c2ecf20Sopenharmony_cistatic inline int ath9k_dump_btcoex(struct ath_softc *sc, u8 *buf, u32 size) 8298c2ecf20Sopenharmony_ci{ 8308c2ecf20Sopenharmony_ci return 0; 8318c2ecf20Sopenharmony_ci} 8328c2ecf20Sopenharmony_ci#endif /* CONFIG_ATH9K_BTCOEX_SUPPORT */ 8338c2ecf20Sopenharmony_ci 8348c2ecf20Sopenharmony_ci/********************/ 8358c2ecf20Sopenharmony_ci/* LED Control */ 8368c2ecf20Sopenharmony_ci/********************/ 8378c2ecf20Sopenharmony_ci 8388c2ecf20Sopenharmony_ci#define ATH_LED_PIN_DEF 1 8398c2ecf20Sopenharmony_ci#define ATH_LED_PIN_9287 8 8408c2ecf20Sopenharmony_ci#define ATH_LED_PIN_9300 10 8418c2ecf20Sopenharmony_ci#define ATH_LED_PIN_9485 6 8428c2ecf20Sopenharmony_ci#define ATH_LED_PIN_9462 4 8438c2ecf20Sopenharmony_ci 8448c2ecf20Sopenharmony_ci#ifdef CONFIG_MAC80211_LEDS 8458c2ecf20Sopenharmony_civoid ath_init_leds(struct ath_softc *sc); 8468c2ecf20Sopenharmony_civoid ath_deinit_leds(struct ath_softc *sc); 8478c2ecf20Sopenharmony_ci#else 8488c2ecf20Sopenharmony_cistatic inline void ath_init_leds(struct ath_softc *sc) 8498c2ecf20Sopenharmony_ci{ 8508c2ecf20Sopenharmony_ci} 8518c2ecf20Sopenharmony_ci 8528c2ecf20Sopenharmony_cistatic inline void ath_deinit_leds(struct ath_softc *sc) 8538c2ecf20Sopenharmony_ci{ 8548c2ecf20Sopenharmony_ci} 8558c2ecf20Sopenharmony_ci#endif 8568c2ecf20Sopenharmony_ci 8578c2ecf20Sopenharmony_ci/************************/ 8588c2ecf20Sopenharmony_ci/* Wake on Wireless LAN */ 8598c2ecf20Sopenharmony_ci/************************/ 8608c2ecf20Sopenharmony_ci 8618c2ecf20Sopenharmony_ci#ifdef CONFIG_ATH9K_WOW 8628c2ecf20Sopenharmony_civoid ath9k_init_wow(struct ieee80211_hw *hw); 8638c2ecf20Sopenharmony_civoid ath9k_deinit_wow(struct ieee80211_hw *hw); 8648c2ecf20Sopenharmony_ciint ath9k_suspend(struct ieee80211_hw *hw, 8658c2ecf20Sopenharmony_ci struct cfg80211_wowlan *wowlan); 8668c2ecf20Sopenharmony_ciint ath9k_resume(struct ieee80211_hw *hw); 8678c2ecf20Sopenharmony_civoid ath9k_set_wakeup(struct ieee80211_hw *hw, bool enabled); 8688c2ecf20Sopenharmony_ci#else 8698c2ecf20Sopenharmony_cistatic inline void ath9k_init_wow(struct ieee80211_hw *hw) 8708c2ecf20Sopenharmony_ci{ 8718c2ecf20Sopenharmony_ci} 8728c2ecf20Sopenharmony_cistatic inline void ath9k_deinit_wow(struct ieee80211_hw *hw) 8738c2ecf20Sopenharmony_ci{ 8748c2ecf20Sopenharmony_ci} 8758c2ecf20Sopenharmony_cistatic inline int ath9k_suspend(struct ieee80211_hw *hw, 8768c2ecf20Sopenharmony_ci struct cfg80211_wowlan *wowlan) 8778c2ecf20Sopenharmony_ci{ 8788c2ecf20Sopenharmony_ci return 0; 8798c2ecf20Sopenharmony_ci} 8808c2ecf20Sopenharmony_cistatic inline int ath9k_resume(struct ieee80211_hw *hw) 8818c2ecf20Sopenharmony_ci{ 8828c2ecf20Sopenharmony_ci return 0; 8838c2ecf20Sopenharmony_ci} 8848c2ecf20Sopenharmony_cistatic inline void ath9k_set_wakeup(struct ieee80211_hw *hw, bool enabled) 8858c2ecf20Sopenharmony_ci{ 8868c2ecf20Sopenharmony_ci} 8878c2ecf20Sopenharmony_ci#endif /* CONFIG_ATH9K_WOW */ 8888c2ecf20Sopenharmony_ci 8898c2ecf20Sopenharmony_ci/*******************************/ 8908c2ecf20Sopenharmony_ci/* Antenna diversity/combining */ 8918c2ecf20Sopenharmony_ci/*******************************/ 8928c2ecf20Sopenharmony_ci 8938c2ecf20Sopenharmony_ci#define ATH_ANT_RX_CURRENT_SHIFT 4 8948c2ecf20Sopenharmony_ci#define ATH_ANT_RX_MAIN_SHIFT 2 8958c2ecf20Sopenharmony_ci#define ATH_ANT_RX_MASK 0x3 8968c2ecf20Sopenharmony_ci 8978c2ecf20Sopenharmony_ci#define ATH_ANT_DIV_COMB_SHORT_SCAN_INTR 50 8988c2ecf20Sopenharmony_ci#define ATH_ANT_DIV_COMB_SHORT_SCAN_PKTCOUNT 0x100 8998c2ecf20Sopenharmony_ci#define ATH_ANT_DIV_COMB_MAX_PKTCOUNT 0x200 9008c2ecf20Sopenharmony_ci#define ATH_ANT_DIV_COMB_INIT_COUNT 95 9018c2ecf20Sopenharmony_ci#define ATH_ANT_DIV_COMB_MAX_COUNT 100 9028c2ecf20Sopenharmony_ci#define ATH_ANT_DIV_COMB_ALT_ANT_RATIO 30 9038c2ecf20Sopenharmony_ci#define ATH_ANT_DIV_COMB_ALT_ANT_RATIO2 20 9048c2ecf20Sopenharmony_ci#define ATH_ANT_DIV_COMB_ALT_ANT_RATIO_LOW_RSSI 50 9058c2ecf20Sopenharmony_ci#define ATH_ANT_DIV_COMB_ALT_ANT_RATIO2_LOW_RSSI 50 9068c2ecf20Sopenharmony_ci 9078c2ecf20Sopenharmony_ci#define ATH_ANT_DIV_COMB_LNA1_DELTA_HI -4 9088c2ecf20Sopenharmony_ci#define ATH_ANT_DIV_COMB_LNA1_DELTA_MID -2 9098c2ecf20Sopenharmony_ci#define ATH_ANT_DIV_COMB_LNA1_DELTA_LOW 2 9108c2ecf20Sopenharmony_ci 9118c2ecf20Sopenharmony_cistruct ath_ant_comb { 9128c2ecf20Sopenharmony_ci u16 count; 9138c2ecf20Sopenharmony_ci u16 total_pkt_count; 9148c2ecf20Sopenharmony_ci bool scan; 9158c2ecf20Sopenharmony_ci bool scan_not_start; 9168c2ecf20Sopenharmony_ci int main_total_rssi; 9178c2ecf20Sopenharmony_ci int alt_total_rssi; 9188c2ecf20Sopenharmony_ci int alt_recv_cnt; 9198c2ecf20Sopenharmony_ci int main_recv_cnt; 9208c2ecf20Sopenharmony_ci int rssi_lna1; 9218c2ecf20Sopenharmony_ci int rssi_lna2; 9228c2ecf20Sopenharmony_ci int rssi_add; 9238c2ecf20Sopenharmony_ci int rssi_sub; 9248c2ecf20Sopenharmony_ci int rssi_first; 9258c2ecf20Sopenharmony_ci int rssi_second; 9268c2ecf20Sopenharmony_ci int rssi_third; 9278c2ecf20Sopenharmony_ci int ant_ratio; 9288c2ecf20Sopenharmony_ci int ant_ratio2; 9298c2ecf20Sopenharmony_ci bool alt_good; 9308c2ecf20Sopenharmony_ci int quick_scan_cnt; 9318c2ecf20Sopenharmony_ci enum ath9k_ant_div_comb_lna_conf main_conf; 9328c2ecf20Sopenharmony_ci enum ath9k_ant_div_comb_lna_conf first_quick_scan_conf; 9338c2ecf20Sopenharmony_ci enum ath9k_ant_div_comb_lna_conf second_quick_scan_conf; 9348c2ecf20Sopenharmony_ci bool first_ratio; 9358c2ecf20Sopenharmony_ci bool second_ratio; 9368c2ecf20Sopenharmony_ci unsigned long scan_start_time; 9378c2ecf20Sopenharmony_ci 9388c2ecf20Sopenharmony_ci /* 9398c2ecf20Sopenharmony_ci * Card-specific config values. 9408c2ecf20Sopenharmony_ci */ 9418c2ecf20Sopenharmony_ci int low_rssi_thresh; 9428c2ecf20Sopenharmony_ci int fast_div_bias; 9438c2ecf20Sopenharmony_ci}; 9448c2ecf20Sopenharmony_ci 9458c2ecf20Sopenharmony_civoid ath_ant_comb_scan(struct ath_softc *sc, struct ath_rx_status *rs); 9468c2ecf20Sopenharmony_ci 9478c2ecf20Sopenharmony_ci/********************/ 9488c2ecf20Sopenharmony_ci/* Main driver core */ 9498c2ecf20Sopenharmony_ci/********************/ 9508c2ecf20Sopenharmony_ci 9518c2ecf20Sopenharmony_ci#define ATH9K_PCI_CUS198 0x0001 9528c2ecf20Sopenharmony_ci#define ATH9K_PCI_CUS230 0x0002 9538c2ecf20Sopenharmony_ci#define ATH9K_PCI_CUS217 0x0004 9548c2ecf20Sopenharmony_ci#define ATH9K_PCI_CUS252 0x0008 9558c2ecf20Sopenharmony_ci#define ATH9K_PCI_WOW 0x0010 9568c2ecf20Sopenharmony_ci#define ATH9K_PCI_BT_ANT_DIV 0x0020 9578c2ecf20Sopenharmony_ci#define ATH9K_PCI_D3_L1_WAR 0x0040 9588c2ecf20Sopenharmony_ci#define ATH9K_PCI_AR9565_1ANT 0x0080 9598c2ecf20Sopenharmony_ci#define ATH9K_PCI_AR9565_2ANT 0x0100 9608c2ecf20Sopenharmony_ci#define ATH9K_PCI_NO_PLL_PWRSAVE 0x0200 9618c2ecf20Sopenharmony_ci#define ATH9K_PCI_KILLER 0x0400 9628c2ecf20Sopenharmony_ci#define ATH9K_PCI_LED_ACT_HI 0x0800 9638c2ecf20Sopenharmony_ci 9648c2ecf20Sopenharmony_ci/* 9658c2ecf20Sopenharmony_ci * Default cache line size, in bytes. 9668c2ecf20Sopenharmony_ci * Used when PCI device not fully initialized by bootrom/BIOS 9678c2ecf20Sopenharmony_ci*/ 9688c2ecf20Sopenharmony_ci#define DEFAULT_CACHELINE 32 9698c2ecf20Sopenharmony_ci#define ATH_CABQ_READY_TIME 80 /* % of beacon interval */ 9708c2ecf20Sopenharmony_ci#define ATH_TXPOWER_MAX 100 /* .5 dBm units */ 9718c2ecf20Sopenharmony_ci#define MAX_GTT_CNT 5 9728c2ecf20Sopenharmony_ci 9738c2ecf20Sopenharmony_ci/* Powersave flags */ 9748c2ecf20Sopenharmony_ci#define PS_WAIT_FOR_BEACON BIT(0) 9758c2ecf20Sopenharmony_ci#define PS_WAIT_FOR_CAB BIT(1) 9768c2ecf20Sopenharmony_ci#define PS_WAIT_FOR_PSPOLL_DATA BIT(2) 9778c2ecf20Sopenharmony_ci#define PS_WAIT_FOR_TX_ACK BIT(3) 9788c2ecf20Sopenharmony_ci#define PS_BEACON_SYNC BIT(4) 9798c2ecf20Sopenharmony_ci#define PS_WAIT_FOR_ANI BIT(5) 9808c2ecf20Sopenharmony_ci 9818c2ecf20Sopenharmony_ci#define ATH9K_NUM_CHANCTX 2 /* supports 2 operating channels */ 9828c2ecf20Sopenharmony_ci 9838c2ecf20Sopenharmony_cistruct ath_softc { 9848c2ecf20Sopenharmony_ci struct ieee80211_hw *hw; 9858c2ecf20Sopenharmony_ci struct device *dev; 9868c2ecf20Sopenharmony_ci 9878c2ecf20Sopenharmony_ci struct survey_info *cur_survey; 9888c2ecf20Sopenharmony_ci struct survey_info survey[ATH9K_NUM_CHANNELS]; 9898c2ecf20Sopenharmony_ci 9908c2ecf20Sopenharmony_ci spinlock_t intr_lock; 9918c2ecf20Sopenharmony_ci struct tasklet_struct intr_tq; 9928c2ecf20Sopenharmony_ci struct tasklet_struct bcon_tasklet; 9938c2ecf20Sopenharmony_ci struct ath_hw *sc_ah; 9948c2ecf20Sopenharmony_ci void __iomem *mem; 9958c2ecf20Sopenharmony_ci int irq; 9968c2ecf20Sopenharmony_ci spinlock_t sc_serial_rw; 9978c2ecf20Sopenharmony_ci spinlock_t sc_pm_lock; 9988c2ecf20Sopenharmony_ci spinlock_t sc_pcu_lock; 9998c2ecf20Sopenharmony_ci struct mutex mutex; 10008c2ecf20Sopenharmony_ci struct work_struct paprd_work; 10018c2ecf20Sopenharmony_ci struct work_struct hw_reset_work; 10028c2ecf20Sopenharmony_ci struct completion paprd_complete; 10038c2ecf20Sopenharmony_ci wait_queue_head_t tx_wait; 10048c2ecf20Sopenharmony_ci 10058c2ecf20Sopenharmony_ci#ifdef CONFIG_ATH9K_CHANNEL_CONTEXT 10068c2ecf20Sopenharmony_ci struct work_struct chanctx_work; 10078c2ecf20Sopenharmony_ci struct ath_gen_timer *p2p_ps_timer; 10088c2ecf20Sopenharmony_ci struct ath_vif *p2p_ps_vif; 10098c2ecf20Sopenharmony_ci struct ath_chanctx_sched sched; 10108c2ecf20Sopenharmony_ci struct ath_offchannel offchannel; 10118c2ecf20Sopenharmony_ci struct ath_chanctx *next_chan; 10128c2ecf20Sopenharmony_ci struct completion go_beacon; 10138c2ecf20Sopenharmony_ci struct timespec64 last_event_time; 10148c2ecf20Sopenharmony_ci#endif 10158c2ecf20Sopenharmony_ci 10168c2ecf20Sopenharmony_ci unsigned long driver_data; 10178c2ecf20Sopenharmony_ci 10188c2ecf20Sopenharmony_ci u8 gtt_cnt; 10198c2ecf20Sopenharmony_ci u32 intrstatus; 10208c2ecf20Sopenharmony_ci u16 ps_flags; /* PS_* */ 10218c2ecf20Sopenharmony_ci bool ps_enabled; 10228c2ecf20Sopenharmony_ci bool ps_idle; 10238c2ecf20Sopenharmony_ci short nbcnvifs; 10248c2ecf20Sopenharmony_ci unsigned long ps_usecount; 10258c2ecf20Sopenharmony_ci 10268c2ecf20Sopenharmony_ci struct ath_rx rx; 10278c2ecf20Sopenharmony_ci struct ath_tx tx; 10288c2ecf20Sopenharmony_ci struct ath_beacon beacon; 10298c2ecf20Sopenharmony_ci 10308c2ecf20Sopenharmony_ci struct cfg80211_chan_def cur_chandef; 10318c2ecf20Sopenharmony_ci struct ath_chanctx chanctx[ATH9K_NUM_CHANCTX]; 10328c2ecf20Sopenharmony_ci struct ath_chanctx *cur_chan; 10338c2ecf20Sopenharmony_ci spinlock_t chan_lock; 10348c2ecf20Sopenharmony_ci 10358c2ecf20Sopenharmony_ci#ifdef CONFIG_MAC80211_LEDS 10368c2ecf20Sopenharmony_ci bool led_registered; 10378c2ecf20Sopenharmony_ci char led_name[32]; 10388c2ecf20Sopenharmony_ci struct led_classdev led_cdev; 10398c2ecf20Sopenharmony_ci#endif 10408c2ecf20Sopenharmony_ci 10418c2ecf20Sopenharmony_ci#ifdef CONFIG_ATH9K_DEBUGFS 10428c2ecf20Sopenharmony_ci struct ath9k_debug debug; 10438c2ecf20Sopenharmony_ci#endif 10448c2ecf20Sopenharmony_ci struct delayed_work hw_check_work; 10458c2ecf20Sopenharmony_ci struct delayed_work hw_pll_work; 10468c2ecf20Sopenharmony_ci struct timer_list sleep_timer; 10478c2ecf20Sopenharmony_ci 10488c2ecf20Sopenharmony_ci#ifdef CONFIG_ATH9K_BTCOEX_SUPPORT 10498c2ecf20Sopenharmony_ci struct ath_btcoex btcoex; 10508c2ecf20Sopenharmony_ci struct ath_mci_coex mci_coex; 10518c2ecf20Sopenharmony_ci struct work_struct mci_work; 10528c2ecf20Sopenharmony_ci#endif 10538c2ecf20Sopenharmony_ci 10548c2ecf20Sopenharmony_ci struct ath_descdma txsdma; 10558c2ecf20Sopenharmony_ci 10568c2ecf20Sopenharmony_ci struct ath_ant_comb ant_comb; 10578c2ecf20Sopenharmony_ci u8 ant_tx, ant_rx; 10588c2ecf20Sopenharmony_ci struct dfs_pattern_detector *dfs_detector; 10598c2ecf20Sopenharmony_ci u64 dfs_prev_pulse_ts; 10608c2ecf20Sopenharmony_ci u32 wow_enabled; 10618c2ecf20Sopenharmony_ci 10628c2ecf20Sopenharmony_ci struct ath_spec_scan_priv spec_priv; 10638c2ecf20Sopenharmony_ci 10648c2ecf20Sopenharmony_ci struct ieee80211_vif *tx99_vif; 10658c2ecf20Sopenharmony_ci struct sk_buff *tx99_skb; 10668c2ecf20Sopenharmony_ci bool tx99_state; 10678c2ecf20Sopenharmony_ci s16 tx99_power; 10688c2ecf20Sopenharmony_ci 10698c2ecf20Sopenharmony_ci#ifdef CONFIG_ATH9K_WOW 10708c2ecf20Sopenharmony_ci u32 wow_intr_before_sleep; 10718c2ecf20Sopenharmony_ci bool force_wow; 10728c2ecf20Sopenharmony_ci#endif 10738c2ecf20Sopenharmony_ci 10748c2ecf20Sopenharmony_ci#ifdef CONFIG_ATH9K_HWRNG 10758c2ecf20Sopenharmony_ci u32 rng_last; 10768c2ecf20Sopenharmony_ci struct task_struct *rng_task; 10778c2ecf20Sopenharmony_ci#endif 10788c2ecf20Sopenharmony_ci}; 10798c2ecf20Sopenharmony_ci 10808c2ecf20Sopenharmony_ci/********/ 10818c2ecf20Sopenharmony_ci/* TX99 */ 10828c2ecf20Sopenharmony_ci/********/ 10838c2ecf20Sopenharmony_ci 10848c2ecf20Sopenharmony_ci#ifdef CONFIG_ATH9K_TX99 10858c2ecf20Sopenharmony_civoid ath9k_tx99_init_debug(struct ath_softc *sc); 10868c2ecf20Sopenharmony_ciint ath9k_tx99_send(struct ath_softc *sc, struct sk_buff *skb, 10878c2ecf20Sopenharmony_ci struct ath_tx_control *txctl); 10888c2ecf20Sopenharmony_ci#else 10898c2ecf20Sopenharmony_cistatic inline void ath9k_tx99_init_debug(struct ath_softc *sc) 10908c2ecf20Sopenharmony_ci{ 10918c2ecf20Sopenharmony_ci} 10928c2ecf20Sopenharmony_cistatic inline int ath9k_tx99_send(struct ath_softc *sc, 10938c2ecf20Sopenharmony_ci struct sk_buff *skb, 10948c2ecf20Sopenharmony_ci struct ath_tx_control *txctl) 10958c2ecf20Sopenharmony_ci{ 10968c2ecf20Sopenharmony_ci return 0; 10978c2ecf20Sopenharmony_ci} 10988c2ecf20Sopenharmony_ci#endif /* CONFIG_ATH9K_TX99 */ 10998c2ecf20Sopenharmony_ci 11008c2ecf20Sopenharmony_ci/***************************/ 11018c2ecf20Sopenharmony_ci/* Random Number Generator */ 11028c2ecf20Sopenharmony_ci/***************************/ 11038c2ecf20Sopenharmony_ci#ifdef CONFIG_ATH9K_HWRNG 11048c2ecf20Sopenharmony_civoid ath9k_rng_start(struct ath_softc *sc); 11058c2ecf20Sopenharmony_civoid ath9k_rng_stop(struct ath_softc *sc); 11068c2ecf20Sopenharmony_ci#else 11078c2ecf20Sopenharmony_cistatic inline void ath9k_rng_start(struct ath_softc *sc) 11088c2ecf20Sopenharmony_ci{ 11098c2ecf20Sopenharmony_ci} 11108c2ecf20Sopenharmony_ci 11118c2ecf20Sopenharmony_cistatic inline void ath9k_rng_stop(struct ath_softc *sc) 11128c2ecf20Sopenharmony_ci{ 11138c2ecf20Sopenharmony_ci} 11148c2ecf20Sopenharmony_ci#endif 11158c2ecf20Sopenharmony_ci 11168c2ecf20Sopenharmony_cistatic inline void ath_read_cachesize(struct ath_common *common, int *csz) 11178c2ecf20Sopenharmony_ci{ 11188c2ecf20Sopenharmony_ci common->bus_ops->read_cachesize(common, csz); 11198c2ecf20Sopenharmony_ci} 11208c2ecf20Sopenharmony_ci 11218c2ecf20Sopenharmony_civoid ath9k_tasklet(struct tasklet_struct *t); 11228c2ecf20Sopenharmony_ciint ath_cabq_update(struct ath_softc *); 11238c2ecf20Sopenharmony_ciu8 ath9k_parse_mpdudensity(u8 mpdudensity); 11248c2ecf20Sopenharmony_ciirqreturn_t ath_isr(int irq, void *dev); 11258c2ecf20Sopenharmony_ciint ath_reset(struct ath_softc *sc, struct ath9k_channel *hchan); 11268c2ecf20Sopenharmony_civoid ath_cancel_work(struct ath_softc *sc); 11278c2ecf20Sopenharmony_civoid ath_restart_work(struct ath_softc *sc); 11288c2ecf20Sopenharmony_ciint ath9k_init_device(u16 devid, struct ath_softc *sc, 11298c2ecf20Sopenharmony_ci const struct ath_bus_ops *bus_ops); 11308c2ecf20Sopenharmony_civoid ath9k_deinit_device(struct ath_softc *sc); 11318c2ecf20Sopenharmony_civoid ath9k_reload_chainmask_settings(struct ath_softc *sc); 11328c2ecf20Sopenharmony_ciu8 ath_txchainmask_reduction(struct ath_softc *sc, u8 chainmask, u32 rate); 11338c2ecf20Sopenharmony_civoid ath_start_rfkill_poll(struct ath_softc *sc); 11348c2ecf20Sopenharmony_civoid ath9k_rfkill_poll_state(struct ieee80211_hw *hw); 11358c2ecf20Sopenharmony_civoid ath9k_ps_wakeup(struct ath_softc *sc); 11368c2ecf20Sopenharmony_civoid ath9k_ps_restore(struct ath_softc *sc); 11378c2ecf20Sopenharmony_ci 11388c2ecf20Sopenharmony_ci#ifdef CONFIG_ATH9K_PCI 11398c2ecf20Sopenharmony_ciint ath_pci_init(void); 11408c2ecf20Sopenharmony_civoid ath_pci_exit(void); 11418c2ecf20Sopenharmony_ci#else 11428c2ecf20Sopenharmony_cistatic inline int ath_pci_init(void) { return 0; }; 11438c2ecf20Sopenharmony_cistatic inline void ath_pci_exit(void) {}; 11448c2ecf20Sopenharmony_ci#endif 11458c2ecf20Sopenharmony_ci 11468c2ecf20Sopenharmony_ci#ifdef CONFIG_ATH9K_AHB 11478c2ecf20Sopenharmony_ciint ath_ahb_init(void); 11488c2ecf20Sopenharmony_civoid ath_ahb_exit(void); 11498c2ecf20Sopenharmony_ci#else 11508c2ecf20Sopenharmony_cistatic inline int ath_ahb_init(void) { return 0; }; 11518c2ecf20Sopenharmony_cistatic inline void ath_ahb_exit(void) {}; 11528c2ecf20Sopenharmony_ci#endif 11538c2ecf20Sopenharmony_ci 11548c2ecf20Sopenharmony_ci#endif /* ATH9K_H */ 1155