162306a36Sopenharmony_ci/* 262306a36Sopenharmony_ci * Copyright (c) 2008-2011 Atheros Communications Inc. 362306a36Sopenharmony_ci * 462306a36Sopenharmony_ci * Permission to use, copy, modify, and/or distribute this software for any 562306a36Sopenharmony_ci * purpose with or without fee is hereby granted, provided that the above 662306a36Sopenharmony_ci * copyright notice and this permission notice appear in all copies. 762306a36Sopenharmony_ci * 862306a36Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 962306a36Sopenharmony_ci * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 1062306a36Sopenharmony_ci * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 1162306a36Sopenharmony_ci * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 1262306a36Sopenharmony_ci * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 1362306a36Sopenharmony_ci * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 1462306a36Sopenharmony_ci * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 1562306a36Sopenharmony_ci */ 1662306a36Sopenharmony_ci 1762306a36Sopenharmony_ci#ifndef ATH9K_H 1862306a36Sopenharmony_ci#define ATH9K_H 1962306a36Sopenharmony_ci 2062306a36Sopenharmony_ci#include <linux/etherdevice.h> 2162306a36Sopenharmony_ci#include <linux/device.h> 2262306a36Sopenharmony_ci#include <linux/interrupt.h> 2362306a36Sopenharmony_ci#include <linux/kstrtox.h> 2462306a36Sopenharmony_ci#include <linux/leds.h> 2562306a36Sopenharmony_ci#include <linux/completion.h> 2662306a36Sopenharmony_ci#include <linux/time.h> 2762306a36Sopenharmony_ci#include <linux/hw_random.h> 2862306a36Sopenharmony_ci 2962306a36Sopenharmony_ci#include "common.h" 3062306a36Sopenharmony_ci#include "debug.h" 3162306a36Sopenharmony_ci#include "mci.h" 3262306a36Sopenharmony_ci#include "dfs.h" 3362306a36Sopenharmony_ci 3462306a36Sopenharmony_cistruct ath_node; 3562306a36Sopenharmony_cistruct ath_vif; 3662306a36Sopenharmony_ci 3762306a36Sopenharmony_ciextern struct ieee80211_ops ath9k_ops; 3862306a36Sopenharmony_ciextern int ath9k_modparam_nohwcrypt; 3962306a36Sopenharmony_ciextern int ath9k_led_blink; 4062306a36Sopenharmony_ciextern bool is_ath9k_unloaded; 4162306a36Sopenharmony_ciextern int ath9k_use_chanctx; 4262306a36Sopenharmony_ci 4362306a36Sopenharmony_ci/*************************/ 4462306a36Sopenharmony_ci/* Descriptor Management */ 4562306a36Sopenharmony_ci/*************************/ 4662306a36Sopenharmony_ci 4762306a36Sopenharmony_ci#define ATH_TXSTATUS_RING_SIZE 512 4862306a36Sopenharmony_ci 4962306a36Sopenharmony_ci/* Macro to expand scalars to 64-bit objects */ 5062306a36Sopenharmony_ci#define ito64(x) (sizeof(x) == 1) ? \ 5162306a36Sopenharmony_ci (((unsigned long long int)(x)) & (0xff)) : \ 5262306a36Sopenharmony_ci (sizeof(x) == 2) ? \ 5362306a36Sopenharmony_ci (((unsigned long long int)(x)) & 0xffff) : \ 5462306a36Sopenharmony_ci ((sizeof(x) == 4) ? \ 5562306a36Sopenharmony_ci (((unsigned long long int)(x)) & 0xffffffff) : \ 5662306a36Sopenharmony_ci (unsigned long long int)(x)) 5762306a36Sopenharmony_ci 5862306a36Sopenharmony_ci#define ATH_TXBUF_RESET(_bf) do { \ 5962306a36Sopenharmony_ci (_bf)->bf_lastbf = NULL; \ 6062306a36Sopenharmony_ci (_bf)->bf_next = NULL; \ 6162306a36Sopenharmony_ci memset(&((_bf)->bf_state), 0, \ 6262306a36Sopenharmony_ci sizeof(struct ath_buf_state)); \ 6362306a36Sopenharmony_ci } while (0) 6462306a36Sopenharmony_ci 6562306a36Sopenharmony_ci#define DS2PHYS(_dd, _ds) \ 6662306a36Sopenharmony_ci ((_dd)->dd_desc_paddr + ((caddr_t)(_ds) - (caddr_t)(_dd)->dd_desc)) 6762306a36Sopenharmony_ci#define ATH_DESC_4KB_BOUND_CHECK(_daddr) ((((_daddr) & 0xFFF) > 0xF7F) ? 1 : 0) 6862306a36Sopenharmony_ci#define ATH_DESC_4KB_BOUND_NUM_SKIPPED(_len) ((_len) / 4096) 6962306a36Sopenharmony_ci 7062306a36Sopenharmony_cistruct ath_descdma { 7162306a36Sopenharmony_ci void *dd_desc; 7262306a36Sopenharmony_ci dma_addr_t dd_desc_paddr; 7362306a36Sopenharmony_ci u32 dd_desc_len; 7462306a36Sopenharmony_ci}; 7562306a36Sopenharmony_ci 7662306a36Sopenharmony_ciint ath_descdma_setup(struct ath_softc *sc, struct ath_descdma *dd, 7762306a36Sopenharmony_ci struct list_head *head, const char *name, 7862306a36Sopenharmony_ci int nbuf, int ndesc, bool is_tx); 7962306a36Sopenharmony_ci 8062306a36Sopenharmony_ci/***********/ 8162306a36Sopenharmony_ci/* RX / TX */ 8262306a36Sopenharmony_ci/***********/ 8362306a36Sopenharmony_ci 8462306a36Sopenharmony_ci#define ATH_TXQ_SETUP(sc, i) ((sc)->tx.txqsetup & (1<<i)) 8562306a36Sopenharmony_ci 8662306a36Sopenharmony_ci/* increment with wrap-around */ 8762306a36Sopenharmony_ci#define INCR(_l, _sz) do { \ 8862306a36Sopenharmony_ci (_l)++; \ 8962306a36Sopenharmony_ci (_l) &= ((_sz) - 1); \ 9062306a36Sopenharmony_ci } while (0) 9162306a36Sopenharmony_ci 9262306a36Sopenharmony_ci#define ATH_RXBUF 512 9362306a36Sopenharmony_ci#define ATH_TXBUF 512 9462306a36Sopenharmony_ci#define ATH_TXBUF_RESERVE 5 9562306a36Sopenharmony_ci#define ATH_TXMAXTRY 13 9662306a36Sopenharmony_ci#define ATH_MAX_SW_RETRIES 30 9762306a36Sopenharmony_ci 9862306a36Sopenharmony_ci#define TID_TO_WME_AC(_tid) \ 9962306a36Sopenharmony_ci ((((_tid) == 0) || ((_tid) == 3)) ? IEEE80211_AC_BE : \ 10062306a36Sopenharmony_ci (((_tid) == 1) || ((_tid) == 2)) ? IEEE80211_AC_BK : \ 10162306a36Sopenharmony_ci (((_tid) == 4) || ((_tid) == 5)) ? IEEE80211_AC_VI : \ 10262306a36Sopenharmony_ci IEEE80211_AC_VO) 10362306a36Sopenharmony_ci 10462306a36Sopenharmony_ci#define ATH_AGGR_DELIM_SZ 4 10562306a36Sopenharmony_ci#define ATH_AGGR_MINPLEN 256 /* in bytes, minimum packet length */ 10662306a36Sopenharmony_ci/* number of delimiters for encryption padding */ 10762306a36Sopenharmony_ci#define ATH_AGGR_ENCRYPTDELIM 10 10862306a36Sopenharmony_ci/* minimum h/w qdepth to be sustained to maximize aggregation */ 10962306a36Sopenharmony_ci#define ATH_AGGR_MIN_QDEPTH 2 11062306a36Sopenharmony_ci/* minimum h/w qdepth for non-aggregated traffic */ 11162306a36Sopenharmony_ci#define ATH_NON_AGGR_MIN_QDEPTH 8 11262306a36Sopenharmony_ci#define ATH_HW_CHECK_POLL_INT 1000 11362306a36Sopenharmony_ci#define ATH_TXFIFO_DEPTH 8 11462306a36Sopenharmony_ci#define ATH_TX_ERROR 0x01 11562306a36Sopenharmony_ci 11662306a36Sopenharmony_ci/* Stop tx traffic 1ms before the GO goes away */ 11762306a36Sopenharmony_ci#define ATH_P2P_PS_STOP_TIME 1000 11862306a36Sopenharmony_ci 11962306a36Sopenharmony_ci#define IEEE80211_SEQ_SEQ_SHIFT 4 12062306a36Sopenharmony_ci#define IEEE80211_SEQ_MAX 4096 12162306a36Sopenharmony_ci#define IEEE80211_WEP_IVLEN 3 12262306a36Sopenharmony_ci#define IEEE80211_WEP_KIDLEN 1 12362306a36Sopenharmony_ci#define IEEE80211_WEP_CRCLEN 4 12462306a36Sopenharmony_ci#define IEEE80211_MAX_MPDU_LEN (3840 + FCS_LEN + \ 12562306a36Sopenharmony_ci (IEEE80211_WEP_IVLEN + \ 12662306a36Sopenharmony_ci IEEE80211_WEP_KIDLEN + \ 12762306a36Sopenharmony_ci IEEE80211_WEP_CRCLEN)) 12862306a36Sopenharmony_ci 12962306a36Sopenharmony_ci/* return whether a bit at index _n in bitmap _bm is set 13062306a36Sopenharmony_ci * _sz is the size of the bitmap */ 13162306a36Sopenharmony_ci#define ATH_BA_ISSET(_bm, _n) (((_n) < (WME_BA_BMP_SIZE)) && \ 13262306a36Sopenharmony_ci ((_bm)[(_n) >> 5] & (1 << ((_n) & 31)))) 13362306a36Sopenharmony_ci 13462306a36Sopenharmony_ci/* return block-ack bitmap index given sequence and starting sequence */ 13562306a36Sopenharmony_ci#define ATH_BA_INDEX(_st, _seq) (((_seq) - (_st)) & (IEEE80211_SEQ_MAX - 1)) 13662306a36Sopenharmony_ci 13762306a36Sopenharmony_ci/* return the seqno for _start + _offset */ 13862306a36Sopenharmony_ci#define ATH_BA_INDEX2SEQ(_seq, _offset) (((_seq) + (_offset)) & (IEEE80211_SEQ_MAX - 1)) 13962306a36Sopenharmony_ci 14062306a36Sopenharmony_ci/* returns delimiter padding required given the packet length */ 14162306a36Sopenharmony_ci#define ATH_AGGR_GET_NDELIM(_len) \ 14262306a36Sopenharmony_ci (((_len) >= ATH_AGGR_MINPLEN) ? 0 : \ 14362306a36Sopenharmony_ci DIV_ROUND_UP(ATH_AGGR_MINPLEN - (_len), ATH_AGGR_DELIM_SZ)) 14462306a36Sopenharmony_ci 14562306a36Sopenharmony_ci#define BAW_WITHIN(_start, _bawsz, _seqno) \ 14662306a36Sopenharmony_ci ((((_seqno) - (_start)) & 4095) < (_bawsz)) 14762306a36Sopenharmony_ci 14862306a36Sopenharmony_ci#define ATH_AN_2_TID(_an, _tidno) ath_node_to_tid(_an, _tidno) 14962306a36Sopenharmony_ci 15062306a36Sopenharmony_ci#define IS_HT_RATE(rate) (rate & 0x80) 15162306a36Sopenharmony_ci#define IS_CCK_RATE(rate) ((rate >= 0x18) && (rate <= 0x1e)) 15262306a36Sopenharmony_ci#define IS_OFDM_RATE(rate) ((rate >= 0x8) && (rate <= 0xf)) 15362306a36Sopenharmony_ci 15462306a36Sopenharmony_cienum { 15562306a36Sopenharmony_ci WLAN_RC_PHY_OFDM, 15662306a36Sopenharmony_ci WLAN_RC_PHY_CCK, 15762306a36Sopenharmony_ci}; 15862306a36Sopenharmony_ci 15962306a36Sopenharmony_cistruct ath_txq { 16062306a36Sopenharmony_ci int mac80211_qnum; /* mac80211 queue number, -1 means not mac80211 Q */ 16162306a36Sopenharmony_ci u32 axq_qnum; /* ath9k hardware queue number */ 16262306a36Sopenharmony_ci void *axq_link; 16362306a36Sopenharmony_ci struct list_head axq_q; 16462306a36Sopenharmony_ci spinlock_t axq_lock; 16562306a36Sopenharmony_ci u32 axq_depth; 16662306a36Sopenharmony_ci u32 axq_ampdu_depth; 16762306a36Sopenharmony_ci bool axq_tx_inprogress; 16862306a36Sopenharmony_ci struct list_head txq_fifo[ATH_TXFIFO_DEPTH]; 16962306a36Sopenharmony_ci u8 txq_headidx; 17062306a36Sopenharmony_ci u8 txq_tailidx; 17162306a36Sopenharmony_ci int pending_frames; 17262306a36Sopenharmony_ci struct sk_buff_head complete_q; 17362306a36Sopenharmony_ci}; 17462306a36Sopenharmony_ci 17562306a36Sopenharmony_cistruct ath_frame_info { 17662306a36Sopenharmony_ci struct ath_buf *bf; 17762306a36Sopenharmony_ci u16 framelen; 17862306a36Sopenharmony_ci s8 txq; 17962306a36Sopenharmony_ci u8 keyix; 18062306a36Sopenharmony_ci u8 rtscts_rate; 18162306a36Sopenharmony_ci u8 retries : 6; 18262306a36Sopenharmony_ci u8 dyn_smps : 1; 18362306a36Sopenharmony_ci u8 baw_tracked : 1; 18462306a36Sopenharmony_ci u8 tx_power; 18562306a36Sopenharmony_ci enum ath9k_key_type keytype:2; 18662306a36Sopenharmony_ci}; 18762306a36Sopenharmony_ci 18862306a36Sopenharmony_cistruct ath_rxbuf { 18962306a36Sopenharmony_ci struct list_head list; 19062306a36Sopenharmony_ci struct sk_buff *bf_mpdu; 19162306a36Sopenharmony_ci void *bf_desc; 19262306a36Sopenharmony_ci dma_addr_t bf_daddr; 19362306a36Sopenharmony_ci dma_addr_t bf_buf_addr; 19462306a36Sopenharmony_ci}; 19562306a36Sopenharmony_ci 19662306a36Sopenharmony_ci/** 19762306a36Sopenharmony_ci * enum buffer_type - Buffer type flags 19862306a36Sopenharmony_ci * 19962306a36Sopenharmony_ci * @BUF_AMPDU: This buffer is an ampdu, as part of an aggregate (during TX) 20062306a36Sopenharmony_ci * @BUF_AGGR: Indicates whether the buffer can be aggregated 20162306a36Sopenharmony_ci * (used in aggregation scheduling) 20262306a36Sopenharmony_ci */ 20362306a36Sopenharmony_cienum buffer_type { 20462306a36Sopenharmony_ci BUF_AMPDU = BIT(0), 20562306a36Sopenharmony_ci BUF_AGGR = BIT(1), 20662306a36Sopenharmony_ci}; 20762306a36Sopenharmony_ci 20862306a36Sopenharmony_ci#define bf_isampdu(bf) (bf->bf_state.bf_type & BUF_AMPDU) 20962306a36Sopenharmony_ci#define bf_isaggr(bf) (bf->bf_state.bf_type & BUF_AGGR) 21062306a36Sopenharmony_ci 21162306a36Sopenharmony_cistruct ath_buf_state { 21262306a36Sopenharmony_ci u8 bf_type; 21362306a36Sopenharmony_ci u8 bfs_paprd; 21462306a36Sopenharmony_ci u8 ndelim; 21562306a36Sopenharmony_ci bool stale; 21662306a36Sopenharmony_ci u16 seqno; 21762306a36Sopenharmony_ci unsigned long bfs_paprd_timestamp; 21862306a36Sopenharmony_ci}; 21962306a36Sopenharmony_ci 22062306a36Sopenharmony_cistruct ath_buf { 22162306a36Sopenharmony_ci struct list_head list; 22262306a36Sopenharmony_ci struct ath_buf *bf_lastbf; /* last buf of this unit (a frame or 22362306a36Sopenharmony_ci an aggregate) */ 22462306a36Sopenharmony_ci struct ath_buf *bf_next; /* next subframe in the aggregate */ 22562306a36Sopenharmony_ci struct sk_buff *bf_mpdu; /* enclosing frame structure */ 22662306a36Sopenharmony_ci void *bf_desc; /* virtual addr of desc */ 22762306a36Sopenharmony_ci dma_addr_t bf_daddr; /* physical addr of desc */ 22862306a36Sopenharmony_ci dma_addr_t bf_buf_addr; /* physical addr of data buffer, for DMA */ 22962306a36Sopenharmony_ci struct ieee80211_tx_rate rates[4]; 23062306a36Sopenharmony_ci struct ath_buf_state bf_state; 23162306a36Sopenharmony_ci}; 23262306a36Sopenharmony_ci 23362306a36Sopenharmony_cistruct ath_atx_tid { 23462306a36Sopenharmony_ci struct list_head list; 23562306a36Sopenharmony_ci struct sk_buff_head retry_q; 23662306a36Sopenharmony_ci struct ath_node *an; 23762306a36Sopenharmony_ci struct ath_txq *txq; 23862306a36Sopenharmony_ci unsigned long tx_buf[BITS_TO_LONGS(ATH_TID_MAX_BUFS)]; 23962306a36Sopenharmony_ci u16 seq_start; 24062306a36Sopenharmony_ci u16 seq_next; 24162306a36Sopenharmony_ci u16 baw_size; 24262306a36Sopenharmony_ci u8 tidno; 24362306a36Sopenharmony_ci int baw_head; /* first un-acked tx buffer */ 24462306a36Sopenharmony_ci int baw_tail; /* next unused tx buffer slot */ 24562306a36Sopenharmony_ci 24662306a36Sopenharmony_ci s8 bar_index; 24762306a36Sopenharmony_ci bool active; 24862306a36Sopenharmony_ci bool clear_ps_filter; 24962306a36Sopenharmony_ci}; 25062306a36Sopenharmony_ci 25162306a36Sopenharmony_civoid ath_tx_queue_tid(struct ath_softc *sc, struct ath_atx_tid *tid); 25262306a36Sopenharmony_ci 25362306a36Sopenharmony_cistruct ath_node { 25462306a36Sopenharmony_ci struct ath_softc *sc; 25562306a36Sopenharmony_ci struct ieee80211_sta *sta; /* station struct we're part of */ 25662306a36Sopenharmony_ci struct ieee80211_vif *vif; /* interface with which we're associated */ 25762306a36Sopenharmony_ci 25862306a36Sopenharmony_ci u16 maxampdu; 25962306a36Sopenharmony_ci u8 mpdudensity; 26062306a36Sopenharmony_ci s8 ps_key; 26162306a36Sopenharmony_ci 26262306a36Sopenharmony_ci bool sleeping; 26362306a36Sopenharmony_ci bool no_ps_filter; 26462306a36Sopenharmony_ci 26562306a36Sopenharmony_ci#ifdef CONFIG_ATH9K_STATION_STATISTICS 26662306a36Sopenharmony_ci struct ath_rx_rate_stats rx_rate_stats; 26762306a36Sopenharmony_ci#endif 26862306a36Sopenharmony_ci u8 key_idx[4]; 26962306a36Sopenharmony_ci 27062306a36Sopenharmony_ci int ackto; 27162306a36Sopenharmony_ci struct list_head list; 27262306a36Sopenharmony_ci}; 27362306a36Sopenharmony_ci 27462306a36Sopenharmony_cistruct ath_tx_control { 27562306a36Sopenharmony_ci struct ath_txq *txq; 27662306a36Sopenharmony_ci struct ath_node *an; 27762306a36Sopenharmony_ci struct ieee80211_sta *sta; 27862306a36Sopenharmony_ci u8 paprd; 27962306a36Sopenharmony_ci}; 28062306a36Sopenharmony_ci 28162306a36Sopenharmony_ci 28262306a36Sopenharmony_ci/** 28362306a36Sopenharmony_ci * @txq_map: Index is mac80211 queue number. This is 28462306a36Sopenharmony_ci * not necessarily the same as the hardware queue number 28562306a36Sopenharmony_ci * (axq_qnum). 28662306a36Sopenharmony_ci */ 28762306a36Sopenharmony_cistruct ath_tx { 28862306a36Sopenharmony_ci u32 txqsetup; 28962306a36Sopenharmony_ci spinlock_t txbuflock; 29062306a36Sopenharmony_ci struct list_head txbuf; 29162306a36Sopenharmony_ci struct ath_txq txq[ATH9K_NUM_TX_QUEUES]; 29262306a36Sopenharmony_ci struct ath_descdma txdma; 29362306a36Sopenharmony_ci struct ath_txq *txq_map[IEEE80211_NUM_ACS]; 29462306a36Sopenharmony_ci struct ath_txq *uapsdq; 29562306a36Sopenharmony_ci u16 max_aggr_framelen[IEEE80211_NUM_ACS][4][32]; 29662306a36Sopenharmony_ci}; 29762306a36Sopenharmony_ci 29862306a36Sopenharmony_cistruct ath_rx_edma { 29962306a36Sopenharmony_ci struct sk_buff_head rx_fifo; 30062306a36Sopenharmony_ci u32 rx_fifo_hwsize; 30162306a36Sopenharmony_ci}; 30262306a36Sopenharmony_ci 30362306a36Sopenharmony_cistruct ath_rx { 30462306a36Sopenharmony_ci u8 defant; 30562306a36Sopenharmony_ci u8 rxotherant; 30662306a36Sopenharmony_ci bool discard_next; 30762306a36Sopenharmony_ci u32 *rxlink; 30862306a36Sopenharmony_ci u32 num_pkts; 30962306a36Sopenharmony_ci struct list_head rxbuf; 31062306a36Sopenharmony_ci struct ath_descdma rxdma; 31162306a36Sopenharmony_ci struct ath_rx_edma rx_edma[ATH9K_RX_QUEUE_MAX]; 31262306a36Sopenharmony_ci 31362306a36Sopenharmony_ci struct ath_rxbuf *buf_hold; 31462306a36Sopenharmony_ci struct sk_buff *frag; 31562306a36Sopenharmony_ci 31662306a36Sopenharmony_ci u32 ampdu_ref; 31762306a36Sopenharmony_ci}; 31862306a36Sopenharmony_ci 31962306a36Sopenharmony_ci/*******************/ 32062306a36Sopenharmony_ci/* Channel Context */ 32162306a36Sopenharmony_ci/*******************/ 32262306a36Sopenharmony_ci 32362306a36Sopenharmony_cistruct ath_acq { 32462306a36Sopenharmony_ci struct list_head acq_new; 32562306a36Sopenharmony_ci struct list_head acq_old; 32662306a36Sopenharmony_ci spinlock_t lock; 32762306a36Sopenharmony_ci}; 32862306a36Sopenharmony_ci 32962306a36Sopenharmony_cistruct ath_chanctx { 33062306a36Sopenharmony_ci struct cfg80211_chan_def chandef; 33162306a36Sopenharmony_ci struct list_head vifs; 33262306a36Sopenharmony_ci struct ath_acq acq[IEEE80211_NUM_ACS]; 33362306a36Sopenharmony_ci int hw_queue_base; 33462306a36Sopenharmony_ci 33562306a36Sopenharmony_ci /* do not dereference, use for comparison only */ 33662306a36Sopenharmony_ci struct ieee80211_vif *primary_sta; 33762306a36Sopenharmony_ci 33862306a36Sopenharmony_ci struct ath_beacon_config beacon; 33962306a36Sopenharmony_ci struct ath9k_hw_cal_data caldata; 34062306a36Sopenharmony_ci struct timespec64 tsf_ts; 34162306a36Sopenharmony_ci u64 tsf_val; 34262306a36Sopenharmony_ci u32 last_beacon; 34362306a36Sopenharmony_ci 34462306a36Sopenharmony_ci int flush_timeout; 34562306a36Sopenharmony_ci u16 txpower; 34662306a36Sopenharmony_ci u16 cur_txpower; 34762306a36Sopenharmony_ci bool offchannel; 34862306a36Sopenharmony_ci bool stopped; 34962306a36Sopenharmony_ci bool active; 35062306a36Sopenharmony_ci bool assigned; 35162306a36Sopenharmony_ci bool switch_after_beacon; 35262306a36Sopenharmony_ci 35362306a36Sopenharmony_ci short nvifs; 35462306a36Sopenharmony_ci short nvifs_assigned; 35562306a36Sopenharmony_ci unsigned int rxfilter; 35662306a36Sopenharmony_ci}; 35762306a36Sopenharmony_ci 35862306a36Sopenharmony_cienum ath_chanctx_event { 35962306a36Sopenharmony_ci ATH_CHANCTX_EVENT_BEACON_PREPARE, 36062306a36Sopenharmony_ci ATH_CHANCTX_EVENT_BEACON_SENT, 36162306a36Sopenharmony_ci ATH_CHANCTX_EVENT_TSF_TIMER, 36262306a36Sopenharmony_ci ATH_CHANCTX_EVENT_BEACON_RECEIVED, 36362306a36Sopenharmony_ci ATH_CHANCTX_EVENT_AUTHORIZED, 36462306a36Sopenharmony_ci ATH_CHANCTX_EVENT_SWITCH, 36562306a36Sopenharmony_ci ATH_CHANCTX_EVENT_ASSIGN, 36662306a36Sopenharmony_ci ATH_CHANCTX_EVENT_UNASSIGN, 36762306a36Sopenharmony_ci ATH_CHANCTX_EVENT_CHANGE, 36862306a36Sopenharmony_ci ATH_CHANCTX_EVENT_ENABLE_MULTICHANNEL, 36962306a36Sopenharmony_ci}; 37062306a36Sopenharmony_ci 37162306a36Sopenharmony_cienum ath_chanctx_state { 37262306a36Sopenharmony_ci ATH_CHANCTX_STATE_IDLE, 37362306a36Sopenharmony_ci ATH_CHANCTX_STATE_WAIT_FOR_BEACON, 37462306a36Sopenharmony_ci ATH_CHANCTX_STATE_WAIT_FOR_TIMER, 37562306a36Sopenharmony_ci ATH_CHANCTX_STATE_SWITCH, 37662306a36Sopenharmony_ci ATH_CHANCTX_STATE_FORCE_ACTIVE, 37762306a36Sopenharmony_ci}; 37862306a36Sopenharmony_ci 37962306a36Sopenharmony_cistruct ath_chanctx_sched { 38062306a36Sopenharmony_ci bool beacon_pending; 38162306a36Sopenharmony_ci bool beacon_adjust; 38262306a36Sopenharmony_ci bool offchannel_pending; 38362306a36Sopenharmony_ci bool wait_switch; 38462306a36Sopenharmony_ci bool force_noa_update; 38562306a36Sopenharmony_ci bool extend_absence; 38662306a36Sopenharmony_ci bool mgd_prepare_tx; 38762306a36Sopenharmony_ci enum ath_chanctx_state state; 38862306a36Sopenharmony_ci u8 beacon_miss; 38962306a36Sopenharmony_ci 39062306a36Sopenharmony_ci u32 next_tbtt; 39162306a36Sopenharmony_ci u32 switch_start_time; 39262306a36Sopenharmony_ci unsigned int offchannel_duration; 39362306a36Sopenharmony_ci unsigned int channel_switch_time; 39462306a36Sopenharmony_ci 39562306a36Sopenharmony_ci /* backup, in case the hardware timer fails */ 39662306a36Sopenharmony_ci struct timer_list timer; 39762306a36Sopenharmony_ci}; 39862306a36Sopenharmony_ci 39962306a36Sopenharmony_cienum ath_offchannel_state { 40062306a36Sopenharmony_ci ATH_OFFCHANNEL_IDLE, 40162306a36Sopenharmony_ci ATH_OFFCHANNEL_PROBE_SEND, 40262306a36Sopenharmony_ci ATH_OFFCHANNEL_PROBE_WAIT, 40362306a36Sopenharmony_ci ATH_OFFCHANNEL_SUSPEND, 40462306a36Sopenharmony_ci ATH_OFFCHANNEL_ROC_START, 40562306a36Sopenharmony_ci ATH_OFFCHANNEL_ROC_WAIT, 40662306a36Sopenharmony_ci ATH_OFFCHANNEL_ROC_DONE, 40762306a36Sopenharmony_ci}; 40862306a36Sopenharmony_ci 40962306a36Sopenharmony_cienum ath_roc_complete_reason { 41062306a36Sopenharmony_ci ATH_ROC_COMPLETE_EXPIRE, 41162306a36Sopenharmony_ci ATH_ROC_COMPLETE_ABORT, 41262306a36Sopenharmony_ci ATH_ROC_COMPLETE_CANCEL, 41362306a36Sopenharmony_ci}; 41462306a36Sopenharmony_ci 41562306a36Sopenharmony_cistruct ath_offchannel { 41662306a36Sopenharmony_ci struct ath_chanctx chan; 41762306a36Sopenharmony_ci struct timer_list timer; 41862306a36Sopenharmony_ci struct cfg80211_scan_request *scan_req; 41962306a36Sopenharmony_ci struct ieee80211_vif *scan_vif; 42062306a36Sopenharmony_ci int scan_idx; 42162306a36Sopenharmony_ci enum ath_offchannel_state state; 42262306a36Sopenharmony_ci struct ieee80211_channel *roc_chan; 42362306a36Sopenharmony_ci struct ieee80211_vif *roc_vif; 42462306a36Sopenharmony_ci int roc_duration; 42562306a36Sopenharmony_ci int duration; 42662306a36Sopenharmony_ci}; 42762306a36Sopenharmony_ci 42862306a36Sopenharmony_cistatic inline struct ath_atx_tid * 42962306a36Sopenharmony_ciath_node_to_tid(struct ath_node *an, u8 tidno) 43062306a36Sopenharmony_ci{ 43162306a36Sopenharmony_ci struct ieee80211_sta *sta = an->sta; 43262306a36Sopenharmony_ci struct ieee80211_vif *vif = an->vif; 43362306a36Sopenharmony_ci struct ieee80211_txq *txq; 43462306a36Sopenharmony_ci 43562306a36Sopenharmony_ci BUG_ON(!vif); 43662306a36Sopenharmony_ci if (sta) 43762306a36Sopenharmony_ci txq = sta->txq[tidno % ARRAY_SIZE(sta->txq)]; 43862306a36Sopenharmony_ci else 43962306a36Sopenharmony_ci txq = vif->txq; 44062306a36Sopenharmony_ci 44162306a36Sopenharmony_ci return (struct ath_atx_tid *) txq->drv_priv; 44262306a36Sopenharmony_ci} 44362306a36Sopenharmony_ci 44462306a36Sopenharmony_ci#define case_rtn_string(val) case val: return #val 44562306a36Sopenharmony_ci 44662306a36Sopenharmony_ci#define ath_for_each_chanctx(_sc, _ctx) \ 44762306a36Sopenharmony_ci for (ctx = &sc->chanctx[0]; \ 44862306a36Sopenharmony_ci ctx <= &sc->chanctx[ARRAY_SIZE(sc->chanctx) - 1]; \ 44962306a36Sopenharmony_ci ctx++) 45062306a36Sopenharmony_ci 45162306a36Sopenharmony_civoid ath_chanctx_init(struct ath_softc *sc); 45262306a36Sopenharmony_civoid ath_chanctx_set_channel(struct ath_softc *sc, struct ath_chanctx *ctx, 45362306a36Sopenharmony_ci struct cfg80211_chan_def *chandef); 45462306a36Sopenharmony_ci 45562306a36Sopenharmony_ci#ifdef CONFIG_ATH9K_CHANNEL_CONTEXT 45662306a36Sopenharmony_ci 45762306a36Sopenharmony_cistatic inline struct ath_chanctx * 45862306a36Sopenharmony_ciath_chanctx_get(struct ieee80211_chanctx_conf *ctx) 45962306a36Sopenharmony_ci{ 46062306a36Sopenharmony_ci struct ath_chanctx **ptr = (void *) ctx->drv_priv; 46162306a36Sopenharmony_ci return *ptr; 46262306a36Sopenharmony_ci} 46362306a36Sopenharmony_ci 46462306a36Sopenharmony_cibool ath9k_is_chanctx_enabled(void); 46562306a36Sopenharmony_civoid ath9k_fill_chanctx_ops(void); 46662306a36Sopenharmony_civoid ath9k_init_channel_context(struct ath_softc *sc); 46762306a36Sopenharmony_civoid ath9k_offchannel_init(struct ath_softc *sc); 46862306a36Sopenharmony_civoid ath9k_deinit_channel_context(struct ath_softc *sc); 46962306a36Sopenharmony_ciint ath9k_init_p2p(struct ath_softc *sc); 47062306a36Sopenharmony_civoid ath9k_deinit_p2p(struct ath_softc *sc); 47162306a36Sopenharmony_civoid ath9k_p2p_remove_vif(struct ath_softc *sc, 47262306a36Sopenharmony_ci struct ieee80211_vif *vif); 47362306a36Sopenharmony_civoid ath9k_p2p_beacon_sync(struct ath_softc *sc); 47462306a36Sopenharmony_civoid ath9k_p2p_bss_info_changed(struct ath_softc *sc, 47562306a36Sopenharmony_ci struct ieee80211_vif *vif); 47662306a36Sopenharmony_civoid ath9k_beacon_add_noa(struct ath_softc *sc, struct ath_vif *avp, 47762306a36Sopenharmony_ci struct sk_buff *skb); 47862306a36Sopenharmony_civoid ath9k_p2p_ps_timer(void *priv); 47962306a36Sopenharmony_civoid ath9k_chanctx_wake_queues(struct ath_softc *sc, struct ath_chanctx *ctx); 48062306a36Sopenharmony_civoid ath9k_chanctx_stop_queues(struct ath_softc *sc, struct ath_chanctx *ctx); 48162306a36Sopenharmony_civoid ath_chanctx_check_active(struct ath_softc *sc, struct ath_chanctx *ctx); 48262306a36Sopenharmony_ci 48362306a36Sopenharmony_civoid ath_chanctx_beacon_recv_ev(struct ath_softc *sc, 48462306a36Sopenharmony_ci enum ath_chanctx_event ev); 48562306a36Sopenharmony_civoid ath_chanctx_beacon_sent_ev(struct ath_softc *sc, 48662306a36Sopenharmony_ci enum ath_chanctx_event ev); 48762306a36Sopenharmony_civoid ath_chanctx_event(struct ath_softc *sc, struct ieee80211_vif *vif, 48862306a36Sopenharmony_ci enum ath_chanctx_event ev); 48962306a36Sopenharmony_civoid ath_chanctx_set_next(struct ath_softc *sc, bool force); 49062306a36Sopenharmony_civoid ath_offchannel_next(struct ath_softc *sc); 49162306a36Sopenharmony_civoid ath_scan_complete(struct ath_softc *sc, bool abort); 49262306a36Sopenharmony_civoid ath_roc_complete(struct ath_softc *sc, 49362306a36Sopenharmony_ci enum ath_roc_complete_reason reason); 49462306a36Sopenharmony_cistruct ath_chanctx* ath_is_go_chanctx_present(struct ath_softc *sc); 49562306a36Sopenharmony_ci 49662306a36Sopenharmony_ci#else 49762306a36Sopenharmony_ci 49862306a36Sopenharmony_cistatic inline bool ath9k_is_chanctx_enabled(void) 49962306a36Sopenharmony_ci{ 50062306a36Sopenharmony_ci return false; 50162306a36Sopenharmony_ci} 50262306a36Sopenharmony_cistatic inline void ath9k_fill_chanctx_ops(void) 50362306a36Sopenharmony_ci{ 50462306a36Sopenharmony_ci} 50562306a36Sopenharmony_cistatic inline void ath9k_init_channel_context(struct ath_softc *sc) 50662306a36Sopenharmony_ci{ 50762306a36Sopenharmony_ci} 50862306a36Sopenharmony_cistatic inline void ath9k_offchannel_init(struct ath_softc *sc) 50962306a36Sopenharmony_ci{ 51062306a36Sopenharmony_ci} 51162306a36Sopenharmony_cistatic inline void ath9k_deinit_channel_context(struct ath_softc *sc) 51262306a36Sopenharmony_ci{ 51362306a36Sopenharmony_ci} 51462306a36Sopenharmony_cistatic inline void ath_chanctx_beacon_recv_ev(struct ath_softc *sc, 51562306a36Sopenharmony_ci enum ath_chanctx_event ev) 51662306a36Sopenharmony_ci{ 51762306a36Sopenharmony_ci} 51862306a36Sopenharmony_cistatic inline void ath_chanctx_beacon_sent_ev(struct ath_softc *sc, 51962306a36Sopenharmony_ci enum ath_chanctx_event ev) 52062306a36Sopenharmony_ci{ 52162306a36Sopenharmony_ci} 52262306a36Sopenharmony_cistatic inline void ath_chanctx_event(struct ath_softc *sc, 52362306a36Sopenharmony_ci struct ieee80211_vif *vif, 52462306a36Sopenharmony_ci enum ath_chanctx_event ev) 52562306a36Sopenharmony_ci{ 52662306a36Sopenharmony_ci} 52762306a36Sopenharmony_cistatic inline int ath9k_init_p2p(struct ath_softc *sc) 52862306a36Sopenharmony_ci{ 52962306a36Sopenharmony_ci return 0; 53062306a36Sopenharmony_ci} 53162306a36Sopenharmony_cistatic inline void ath9k_deinit_p2p(struct ath_softc *sc) 53262306a36Sopenharmony_ci{ 53362306a36Sopenharmony_ci} 53462306a36Sopenharmony_cistatic inline void ath9k_p2p_remove_vif(struct ath_softc *sc, 53562306a36Sopenharmony_ci struct ieee80211_vif *vif) 53662306a36Sopenharmony_ci{ 53762306a36Sopenharmony_ci} 53862306a36Sopenharmony_cistatic inline void ath9k_p2p_beacon_sync(struct ath_softc *sc) 53962306a36Sopenharmony_ci{ 54062306a36Sopenharmony_ci} 54162306a36Sopenharmony_cistatic inline void ath9k_p2p_bss_info_changed(struct ath_softc *sc, 54262306a36Sopenharmony_ci struct ieee80211_vif *vif) 54362306a36Sopenharmony_ci{ 54462306a36Sopenharmony_ci} 54562306a36Sopenharmony_cistatic inline void ath9k_beacon_add_noa(struct ath_softc *sc, struct ath_vif *avp, 54662306a36Sopenharmony_ci struct sk_buff *skb) 54762306a36Sopenharmony_ci{ 54862306a36Sopenharmony_ci} 54962306a36Sopenharmony_cistatic inline void ath9k_p2p_ps_timer(struct ath_softc *sc) 55062306a36Sopenharmony_ci{ 55162306a36Sopenharmony_ci} 55262306a36Sopenharmony_cistatic inline void ath9k_chanctx_wake_queues(struct ath_softc *sc, 55362306a36Sopenharmony_ci struct ath_chanctx *ctx) 55462306a36Sopenharmony_ci{ 55562306a36Sopenharmony_ci} 55662306a36Sopenharmony_cistatic inline void ath9k_chanctx_stop_queues(struct ath_softc *sc, 55762306a36Sopenharmony_ci struct ath_chanctx *ctx) 55862306a36Sopenharmony_ci{ 55962306a36Sopenharmony_ci} 56062306a36Sopenharmony_cistatic inline void ath_chanctx_check_active(struct ath_softc *sc, 56162306a36Sopenharmony_ci struct ath_chanctx *ctx) 56262306a36Sopenharmony_ci{ 56362306a36Sopenharmony_ci} 56462306a36Sopenharmony_ci 56562306a36Sopenharmony_ci#endif /* CONFIG_ATH9K_CHANNEL_CONTEXT */ 56662306a36Sopenharmony_ci 56762306a36Sopenharmony_cistatic inline void ath_txq_lock(struct ath_softc *sc, struct ath_txq *txq) 56862306a36Sopenharmony_ci{ 56962306a36Sopenharmony_ci spin_lock_bh(&txq->axq_lock); 57062306a36Sopenharmony_ci} 57162306a36Sopenharmony_cistatic inline void ath_txq_unlock(struct ath_softc *sc, struct ath_txq *txq) 57262306a36Sopenharmony_ci{ 57362306a36Sopenharmony_ci spin_unlock_bh(&txq->axq_lock); 57462306a36Sopenharmony_ci} 57562306a36Sopenharmony_ci 57662306a36Sopenharmony_civoid ath_startrecv(struct ath_softc *sc); 57762306a36Sopenharmony_cibool ath_stoprecv(struct ath_softc *sc); 57862306a36Sopenharmony_ciu32 ath_calcrxfilter(struct ath_softc *sc); 57962306a36Sopenharmony_ciint ath_rx_init(struct ath_softc *sc, int nbufs); 58062306a36Sopenharmony_civoid ath_rx_cleanup(struct ath_softc *sc); 58162306a36Sopenharmony_ciint ath_rx_tasklet(struct ath_softc *sc, int flush, bool hp); 58262306a36Sopenharmony_cistruct ath_txq *ath_txq_setup(struct ath_softc *sc, int qtype, int subtype); 58362306a36Sopenharmony_civoid ath_txq_unlock_complete(struct ath_softc *sc, struct ath_txq *txq); 58462306a36Sopenharmony_civoid ath_tx_cleanupq(struct ath_softc *sc, struct ath_txq *txq); 58562306a36Sopenharmony_cibool ath_drain_all_txq(struct ath_softc *sc); 58662306a36Sopenharmony_civoid ath_draintxq(struct ath_softc *sc, struct ath_txq *txq); 58762306a36Sopenharmony_civoid ath_tx_node_init(struct ath_softc *sc, struct ath_node *an); 58862306a36Sopenharmony_civoid ath_tx_node_cleanup(struct ath_softc *sc, struct ath_node *an); 58962306a36Sopenharmony_civoid ath_txq_schedule(struct ath_softc *sc, struct ath_txq *txq); 59062306a36Sopenharmony_civoid ath_txq_schedule_all(struct ath_softc *sc); 59162306a36Sopenharmony_ciint ath_tx_init(struct ath_softc *sc, int nbufs); 59262306a36Sopenharmony_ciint ath_txq_update(struct ath_softc *sc, int qnum, 59362306a36Sopenharmony_ci struct ath9k_tx_queue_info *q); 59462306a36Sopenharmony_ciu32 ath_pkt_duration(struct ath_softc *sc, u8 rix, int pktlen, 59562306a36Sopenharmony_ci int width, int half_gi, bool shortPreamble); 59662306a36Sopenharmony_civoid ath_update_max_aggr_framelen(struct ath_softc *sc, int queue, int txop); 59762306a36Sopenharmony_civoid ath_assign_seq(struct ath_common *common, struct sk_buff *skb); 59862306a36Sopenharmony_ciint ath_tx_start(struct ieee80211_hw *hw, struct sk_buff *skb, 59962306a36Sopenharmony_ci struct ath_tx_control *txctl); 60062306a36Sopenharmony_civoid ath_tx_cabq(struct ieee80211_hw *hw, struct ieee80211_vif *vif, 60162306a36Sopenharmony_ci struct sk_buff *skb); 60262306a36Sopenharmony_civoid ath_tx_tasklet(struct ath_softc *sc); 60362306a36Sopenharmony_civoid ath_tx_edma_tasklet(struct ath_softc *sc); 60462306a36Sopenharmony_ciint ath_tx_aggr_start(struct ath_softc *sc, struct ieee80211_sta *sta, 60562306a36Sopenharmony_ci u16 tid, u16 *ssn); 60662306a36Sopenharmony_civoid ath_tx_aggr_stop(struct ath_softc *sc, struct ieee80211_sta *sta, u16 tid); 60762306a36Sopenharmony_ci 60862306a36Sopenharmony_civoid ath_tx_aggr_wakeup(struct ath_softc *sc, struct ath_node *an); 60962306a36Sopenharmony_civoid ath_tx_aggr_sleep(struct ieee80211_sta *sta, struct ath_softc *sc, 61062306a36Sopenharmony_ci struct ath_node *an); 61162306a36Sopenharmony_civoid ath9k_release_buffered_frames(struct ieee80211_hw *hw, 61262306a36Sopenharmony_ci struct ieee80211_sta *sta, 61362306a36Sopenharmony_ci u16 tids, int nframes, 61462306a36Sopenharmony_ci enum ieee80211_frame_release_type reason, 61562306a36Sopenharmony_ci bool more_data); 61662306a36Sopenharmony_civoid ath9k_wake_tx_queue(struct ieee80211_hw *hw, struct ieee80211_txq *queue); 61762306a36Sopenharmony_ci 61862306a36Sopenharmony_ci/********/ 61962306a36Sopenharmony_ci/* VIFs */ 62062306a36Sopenharmony_ci/********/ 62162306a36Sopenharmony_ci 62262306a36Sopenharmony_ci#define P2P_DEFAULT_CTWIN 10 62362306a36Sopenharmony_ci 62462306a36Sopenharmony_cistruct ath_vif { 62562306a36Sopenharmony_ci struct list_head list; 62662306a36Sopenharmony_ci 62762306a36Sopenharmony_ci u16 seq_no; 62862306a36Sopenharmony_ci 62962306a36Sopenharmony_ci /* BSS info */ 63062306a36Sopenharmony_ci u8 bssid[ETH_ALEN] __aligned(2); 63162306a36Sopenharmony_ci u16 aid; 63262306a36Sopenharmony_ci bool assoc; 63362306a36Sopenharmony_ci 63462306a36Sopenharmony_ci struct ieee80211_vif *vif; 63562306a36Sopenharmony_ci struct ath_node mcast_node; 63662306a36Sopenharmony_ci int av_bslot; 63762306a36Sopenharmony_ci __le64 tsf_adjust; /* TSF adjustment for staggered beacons */ 63862306a36Sopenharmony_ci struct ath_buf *av_bcbuf; 63962306a36Sopenharmony_ci struct ath_chanctx *chanctx; 64062306a36Sopenharmony_ci 64162306a36Sopenharmony_ci /* P2P Client */ 64262306a36Sopenharmony_ci struct ieee80211_noa_data noa; 64362306a36Sopenharmony_ci 64462306a36Sopenharmony_ci /* P2P GO */ 64562306a36Sopenharmony_ci u8 noa_index; 64662306a36Sopenharmony_ci u32 offchannel_start; 64762306a36Sopenharmony_ci u32 offchannel_duration; 64862306a36Sopenharmony_ci 64962306a36Sopenharmony_ci /* These are used for both periodic and one-shot */ 65062306a36Sopenharmony_ci u32 noa_start; 65162306a36Sopenharmony_ci u32 noa_duration; 65262306a36Sopenharmony_ci bool periodic_noa; 65362306a36Sopenharmony_ci bool oneshot_noa; 65462306a36Sopenharmony_ci}; 65562306a36Sopenharmony_ci 65662306a36Sopenharmony_cistruct ath9k_vif_iter_data { 65762306a36Sopenharmony_ci u8 hw_macaddr[ETH_ALEN]; /* address of the first vif */ 65862306a36Sopenharmony_ci u8 mask[ETH_ALEN]; /* bssid mask */ 65962306a36Sopenharmony_ci bool has_hw_macaddr; 66062306a36Sopenharmony_ci u8 slottime; 66162306a36Sopenharmony_ci bool beacons; 66262306a36Sopenharmony_ci 66362306a36Sopenharmony_ci int naps; /* number of AP vifs */ 66462306a36Sopenharmony_ci int nmeshes; /* number of mesh vifs */ 66562306a36Sopenharmony_ci int nstations; /* number of station vifs */ 66662306a36Sopenharmony_ci int nadhocs; /* number of adhoc vifs */ 66762306a36Sopenharmony_ci int nocbs; /* number of OCB vifs */ 66862306a36Sopenharmony_ci int nbcnvifs; /* number of beaconing vifs */ 66962306a36Sopenharmony_ci struct ieee80211_vif *primary_beacon_vif; 67062306a36Sopenharmony_ci struct ieee80211_vif *primary_sta; 67162306a36Sopenharmony_ci}; 67262306a36Sopenharmony_ci 67362306a36Sopenharmony_civoid ath9k_calculate_iter_data(struct ath_softc *sc, 67462306a36Sopenharmony_ci struct ath_chanctx *ctx, 67562306a36Sopenharmony_ci struct ath9k_vif_iter_data *iter_data); 67662306a36Sopenharmony_civoid ath9k_calculate_summary_state(struct ath_softc *sc, 67762306a36Sopenharmony_ci struct ath_chanctx *ctx); 67862306a36Sopenharmony_civoid ath9k_set_txpower(struct ath_softc *sc, struct ieee80211_vif *vif); 67962306a36Sopenharmony_ci 68062306a36Sopenharmony_ci/*******************/ 68162306a36Sopenharmony_ci/* Beacon Handling */ 68262306a36Sopenharmony_ci/*******************/ 68362306a36Sopenharmony_ci 68462306a36Sopenharmony_ci/* 68562306a36Sopenharmony_ci * Regardless of the number of beacons we stagger, (i.e. regardless of the 68662306a36Sopenharmony_ci * number of BSSIDs) if a given beacon does not go out even after waiting this 68762306a36Sopenharmony_ci * number of beacon intervals, the game's up. 68862306a36Sopenharmony_ci */ 68962306a36Sopenharmony_ci#define BSTUCK_THRESH 9 69062306a36Sopenharmony_ci#define ATH_BCBUF 8 69162306a36Sopenharmony_ci#define ATH_DEFAULT_BINTVAL 100 /* TU */ 69262306a36Sopenharmony_ci#define ATH_DEFAULT_BMISS_LIMIT 10 69362306a36Sopenharmony_ci 69462306a36Sopenharmony_ci#define TSF_TO_TU(_h,_l) \ 69562306a36Sopenharmony_ci ((((u32)(_h)) << 22) | (((u32)(_l)) >> 10)) 69662306a36Sopenharmony_ci 69762306a36Sopenharmony_cistruct ath_beacon { 69862306a36Sopenharmony_ci enum { 69962306a36Sopenharmony_ci OK, /* no change needed */ 70062306a36Sopenharmony_ci UPDATE, /* update pending */ 70162306a36Sopenharmony_ci COMMIT /* beacon sent, commit change */ 70262306a36Sopenharmony_ci } updateslot; /* slot time update fsm */ 70362306a36Sopenharmony_ci 70462306a36Sopenharmony_ci u32 beaconq; 70562306a36Sopenharmony_ci u32 bmisscnt; 70662306a36Sopenharmony_ci struct ieee80211_vif *bslot[ATH_BCBUF]; 70762306a36Sopenharmony_ci int slottime; 70862306a36Sopenharmony_ci int slotupdate; 70962306a36Sopenharmony_ci struct ath_descdma bdma; 71062306a36Sopenharmony_ci struct ath_txq *cabq; 71162306a36Sopenharmony_ci struct list_head bbuf; 71262306a36Sopenharmony_ci 71362306a36Sopenharmony_ci bool tx_processed; 71462306a36Sopenharmony_ci bool tx_last; 71562306a36Sopenharmony_ci}; 71662306a36Sopenharmony_ci 71762306a36Sopenharmony_civoid ath9k_beacon_tasklet(struct tasklet_struct *t); 71862306a36Sopenharmony_civoid ath9k_beacon_config(struct ath_softc *sc, struct ieee80211_vif *main_vif, 71962306a36Sopenharmony_ci bool beacons); 72062306a36Sopenharmony_civoid ath9k_beacon_assign_slot(struct ath_softc *sc, struct ieee80211_vif *vif); 72162306a36Sopenharmony_civoid ath9k_beacon_remove_slot(struct ath_softc *sc, struct ieee80211_vif *vif); 72262306a36Sopenharmony_civoid ath9k_beacon_ensure_primary_slot(struct ath_softc *sc); 72362306a36Sopenharmony_civoid ath9k_set_beacon(struct ath_softc *sc); 72462306a36Sopenharmony_cibool ath9k_csa_is_finished(struct ath_softc *sc, struct ieee80211_vif *vif); 72562306a36Sopenharmony_civoid ath9k_csa_update(struct ath_softc *sc); 72662306a36Sopenharmony_ci 72762306a36Sopenharmony_ci/*******************/ 72862306a36Sopenharmony_ci/* Link Monitoring */ 72962306a36Sopenharmony_ci/*******************/ 73062306a36Sopenharmony_ci 73162306a36Sopenharmony_ci#define ATH_STA_SHORT_CALINTERVAL 1000 /* 1 second */ 73262306a36Sopenharmony_ci#define ATH_AP_SHORT_CALINTERVAL 100 /* 100 ms */ 73362306a36Sopenharmony_ci#define ATH_ANI_POLLINTERVAL_OLD 100 /* 100 ms */ 73462306a36Sopenharmony_ci#define ATH_ANI_POLLINTERVAL_NEW 1000 /* 1000 ms */ 73562306a36Sopenharmony_ci#define ATH_LONG_CALINTERVAL_INT 1000 /* 1000 ms */ 73662306a36Sopenharmony_ci#define ATH_LONG_CALINTERVAL 30000 /* 30 seconds */ 73762306a36Sopenharmony_ci#define ATH_RESTART_CALINTERVAL 1200000 /* 20 minutes */ 73862306a36Sopenharmony_ci#define ATH_ANI_MAX_SKIP_COUNT 10 73962306a36Sopenharmony_ci#define ATH_PAPRD_TIMEOUT 100 /* msecs */ 74062306a36Sopenharmony_ci#define ATH_PLL_WORK_INTERVAL 100 74162306a36Sopenharmony_ci 74262306a36Sopenharmony_civoid ath_hw_check_work(struct work_struct *work); 74362306a36Sopenharmony_civoid ath_reset_work(struct work_struct *work); 74462306a36Sopenharmony_cibool ath_hw_check(struct ath_softc *sc); 74562306a36Sopenharmony_civoid ath_hw_pll_work(struct work_struct *work); 74662306a36Sopenharmony_civoid ath_paprd_calibrate(struct work_struct *work); 74762306a36Sopenharmony_civoid ath_ani_calibrate(struct timer_list *t); 74862306a36Sopenharmony_civoid ath_start_ani(struct ath_softc *sc); 74962306a36Sopenharmony_civoid ath_stop_ani(struct ath_softc *sc); 75062306a36Sopenharmony_civoid ath_check_ani(struct ath_softc *sc); 75162306a36Sopenharmony_ciint ath_update_survey_stats(struct ath_softc *sc); 75262306a36Sopenharmony_civoid ath_update_survey_nf(struct ath_softc *sc, int channel); 75362306a36Sopenharmony_civoid ath9k_queue_reset(struct ath_softc *sc, enum ath_reset_type type); 75462306a36Sopenharmony_civoid ath_ps_full_sleep(struct timer_list *t); 75562306a36Sopenharmony_civoid __ath9k_flush(struct ieee80211_hw *hw, u32 queues, bool drop, 75662306a36Sopenharmony_ci bool sw_pending, bool timeout_override); 75762306a36Sopenharmony_ci 75862306a36Sopenharmony_ci/**********/ 75962306a36Sopenharmony_ci/* BTCOEX */ 76062306a36Sopenharmony_ci/**********/ 76162306a36Sopenharmony_ci 76262306a36Sopenharmony_ci#define ATH_DUMP_BTCOEX(_s, _val) \ 76362306a36Sopenharmony_ci do { \ 76462306a36Sopenharmony_ci len += scnprintf(buf + len, size - len, \ 76562306a36Sopenharmony_ci "%20s : %10d\n", _s, (_val)); \ 76662306a36Sopenharmony_ci } while (0) 76762306a36Sopenharmony_ci 76862306a36Sopenharmony_cienum bt_op_flags { 76962306a36Sopenharmony_ci BT_OP_PRIORITY_DETECTED, 77062306a36Sopenharmony_ci BT_OP_SCAN, 77162306a36Sopenharmony_ci}; 77262306a36Sopenharmony_ci 77362306a36Sopenharmony_cistruct ath_btcoex { 77462306a36Sopenharmony_ci spinlock_t btcoex_lock; 77562306a36Sopenharmony_ci struct timer_list period_timer; /* Timer for BT period */ 77662306a36Sopenharmony_ci struct timer_list no_stomp_timer; 77762306a36Sopenharmony_ci u32 bt_priority_cnt; 77862306a36Sopenharmony_ci unsigned long bt_priority_time; 77962306a36Sopenharmony_ci unsigned long op_flags; 78062306a36Sopenharmony_ci int bt_stomp_type; /* Types of BT stomping */ 78162306a36Sopenharmony_ci u32 btcoex_no_stomp; /* in msec */ 78262306a36Sopenharmony_ci u32 btcoex_period; /* in msec */ 78362306a36Sopenharmony_ci u32 btscan_no_stomp; /* in msec */ 78462306a36Sopenharmony_ci u32 duty_cycle; 78562306a36Sopenharmony_ci u32 bt_wait_time; 78662306a36Sopenharmony_ci int rssi_count; 78762306a36Sopenharmony_ci struct ath_mci_profile mci; 78862306a36Sopenharmony_ci u8 stomp_audio; 78962306a36Sopenharmony_ci}; 79062306a36Sopenharmony_ci 79162306a36Sopenharmony_ci#ifdef CONFIG_ATH9K_BTCOEX_SUPPORT 79262306a36Sopenharmony_ciint ath9k_init_btcoex(struct ath_softc *sc); 79362306a36Sopenharmony_civoid ath9k_deinit_btcoex(struct ath_softc *sc); 79462306a36Sopenharmony_civoid ath9k_start_btcoex(struct ath_softc *sc); 79562306a36Sopenharmony_civoid ath9k_stop_btcoex(struct ath_softc *sc); 79662306a36Sopenharmony_civoid ath9k_btcoex_timer_resume(struct ath_softc *sc); 79762306a36Sopenharmony_civoid ath9k_btcoex_timer_pause(struct ath_softc *sc); 79862306a36Sopenharmony_civoid ath9k_btcoex_handle_interrupt(struct ath_softc *sc, u32 status); 79962306a36Sopenharmony_ciu16 ath9k_btcoex_aggr_limit(struct ath_softc *sc, u32 max_4ms_framelen); 80062306a36Sopenharmony_civoid ath9k_btcoex_stop_gen_timer(struct ath_softc *sc); 80162306a36Sopenharmony_ciint ath9k_dump_btcoex(struct ath_softc *sc, u8 *buf, u32 size); 80262306a36Sopenharmony_ci#else 80362306a36Sopenharmony_cistatic inline int ath9k_init_btcoex(struct ath_softc *sc) 80462306a36Sopenharmony_ci{ 80562306a36Sopenharmony_ci return 0; 80662306a36Sopenharmony_ci} 80762306a36Sopenharmony_cistatic inline void ath9k_deinit_btcoex(struct ath_softc *sc) 80862306a36Sopenharmony_ci{ 80962306a36Sopenharmony_ci} 81062306a36Sopenharmony_cistatic inline void ath9k_start_btcoex(struct ath_softc *sc) 81162306a36Sopenharmony_ci{ 81262306a36Sopenharmony_ci} 81362306a36Sopenharmony_cistatic inline void ath9k_stop_btcoex(struct ath_softc *sc) 81462306a36Sopenharmony_ci{ 81562306a36Sopenharmony_ci} 81662306a36Sopenharmony_cistatic inline void ath9k_btcoex_handle_interrupt(struct ath_softc *sc, 81762306a36Sopenharmony_ci u32 status) 81862306a36Sopenharmony_ci{ 81962306a36Sopenharmony_ci} 82062306a36Sopenharmony_cistatic inline u16 ath9k_btcoex_aggr_limit(struct ath_softc *sc, 82162306a36Sopenharmony_ci u32 max_4ms_framelen) 82262306a36Sopenharmony_ci{ 82362306a36Sopenharmony_ci return 0; 82462306a36Sopenharmony_ci} 82562306a36Sopenharmony_cistatic inline void ath9k_btcoex_stop_gen_timer(struct ath_softc *sc) 82662306a36Sopenharmony_ci{ 82762306a36Sopenharmony_ci} 82862306a36Sopenharmony_cistatic inline int ath9k_dump_btcoex(struct ath_softc *sc, u8 *buf, u32 size) 82962306a36Sopenharmony_ci{ 83062306a36Sopenharmony_ci return 0; 83162306a36Sopenharmony_ci} 83262306a36Sopenharmony_ci#endif /* CONFIG_ATH9K_BTCOEX_SUPPORT */ 83362306a36Sopenharmony_ci 83462306a36Sopenharmony_ci/********************/ 83562306a36Sopenharmony_ci/* LED Control */ 83662306a36Sopenharmony_ci/********************/ 83762306a36Sopenharmony_ci 83862306a36Sopenharmony_ci#define ATH_LED_PIN_DEF 1 83962306a36Sopenharmony_ci#define ATH_LED_PIN_9287 8 84062306a36Sopenharmony_ci#define ATH_LED_PIN_9300 10 84162306a36Sopenharmony_ci#define ATH_LED_PIN_9485 6 84262306a36Sopenharmony_ci#define ATH_LED_PIN_9462 4 84362306a36Sopenharmony_ci 84462306a36Sopenharmony_ci#ifdef CONFIG_MAC80211_LEDS 84562306a36Sopenharmony_civoid ath_init_leds(struct ath_softc *sc); 84662306a36Sopenharmony_civoid ath_deinit_leds(struct ath_softc *sc); 84762306a36Sopenharmony_ci#else 84862306a36Sopenharmony_cistatic inline void ath_init_leds(struct ath_softc *sc) 84962306a36Sopenharmony_ci{ 85062306a36Sopenharmony_ci} 85162306a36Sopenharmony_ci 85262306a36Sopenharmony_cistatic inline void ath_deinit_leds(struct ath_softc *sc) 85362306a36Sopenharmony_ci{ 85462306a36Sopenharmony_ci} 85562306a36Sopenharmony_ci#endif 85662306a36Sopenharmony_ci 85762306a36Sopenharmony_ci/************************/ 85862306a36Sopenharmony_ci/* Wake on Wireless LAN */ 85962306a36Sopenharmony_ci/************************/ 86062306a36Sopenharmony_ci 86162306a36Sopenharmony_ci#ifdef CONFIG_ATH9K_WOW 86262306a36Sopenharmony_civoid ath9k_init_wow(struct ieee80211_hw *hw); 86362306a36Sopenharmony_civoid ath9k_deinit_wow(struct ieee80211_hw *hw); 86462306a36Sopenharmony_ciint ath9k_suspend(struct ieee80211_hw *hw, 86562306a36Sopenharmony_ci struct cfg80211_wowlan *wowlan); 86662306a36Sopenharmony_ciint ath9k_resume(struct ieee80211_hw *hw); 86762306a36Sopenharmony_civoid ath9k_set_wakeup(struct ieee80211_hw *hw, bool enabled); 86862306a36Sopenharmony_ci#else 86962306a36Sopenharmony_cistatic inline void ath9k_init_wow(struct ieee80211_hw *hw) 87062306a36Sopenharmony_ci{ 87162306a36Sopenharmony_ci} 87262306a36Sopenharmony_cistatic inline void ath9k_deinit_wow(struct ieee80211_hw *hw) 87362306a36Sopenharmony_ci{ 87462306a36Sopenharmony_ci} 87562306a36Sopenharmony_cistatic inline int ath9k_suspend(struct ieee80211_hw *hw, 87662306a36Sopenharmony_ci struct cfg80211_wowlan *wowlan) 87762306a36Sopenharmony_ci{ 87862306a36Sopenharmony_ci return 0; 87962306a36Sopenharmony_ci} 88062306a36Sopenharmony_cistatic inline int ath9k_resume(struct ieee80211_hw *hw) 88162306a36Sopenharmony_ci{ 88262306a36Sopenharmony_ci return 0; 88362306a36Sopenharmony_ci} 88462306a36Sopenharmony_cistatic inline void ath9k_set_wakeup(struct ieee80211_hw *hw, bool enabled) 88562306a36Sopenharmony_ci{ 88662306a36Sopenharmony_ci} 88762306a36Sopenharmony_ci#endif /* CONFIG_ATH9K_WOW */ 88862306a36Sopenharmony_ci 88962306a36Sopenharmony_ci/*******************************/ 89062306a36Sopenharmony_ci/* Antenna diversity/combining */ 89162306a36Sopenharmony_ci/*******************************/ 89262306a36Sopenharmony_ci 89362306a36Sopenharmony_ci#define ATH_ANT_RX_CURRENT_SHIFT 4 89462306a36Sopenharmony_ci#define ATH_ANT_RX_MAIN_SHIFT 2 89562306a36Sopenharmony_ci#define ATH_ANT_RX_MASK 0x3 89662306a36Sopenharmony_ci 89762306a36Sopenharmony_ci#define ATH_ANT_DIV_COMB_SHORT_SCAN_INTR 50 89862306a36Sopenharmony_ci#define ATH_ANT_DIV_COMB_SHORT_SCAN_PKTCOUNT 0x100 89962306a36Sopenharmony_ci#define ATH_ANT_DIV_COMB_MAX_PKTCOUNT 0x200 90062306a36Sopenharmony_ci#define ATH_ANT_DIV_COMB_INIT_COUNT 95 90162306a36Sopenharmony_ci#define ATH_ANT_DIV_COMB_MAX_COUNT 100 90262306a36Sopenharmony_ci#define ATH_ANT_DIV_COMB_ALT_ANT_RATIO 30 90362306a36Sopenharmony_ci#define ATH_ANT_DIV_COMB_ALT_ANT_RATIO2 20 90462306a36Sopenharmony_ci#define ATH_ANT_DIV_COMB_ALT_ANT_RATIO_LOW_RSSI 50 90562306a36Sopenharmony_ci#define ATH_ANT_DIV_COMB_ALT_ANT_RATIO2_LOW_RSSI 50 90662306a36Sopenharmony_ci 90762306a36Sopenharmony_ci#define ATH_ANT_DIV_COMB_LNA1_DELTA_HI -4 90862306a36Sopenharmony_ci#define ATH_ANT_DIV_COMB_LNA1_DELTA_MID -2 90962306a36Sopenharmony_ci#define ATH_ANT_DIV_COMB_LNA1_DELTA_LOW 2 91062306a36Sopenharmony_ci 91162306a36Sopenharmony_cistruct ath_ant_comb { 91262306a36Sopenharmony_ci u16 count; 91362306a36Sopenharmony_ci u16 total_pkt_count; 91462306a36Sopenharmony_ci bool scan; 91562306a36Sopenharmony_ci bool scan_not_start; 91662306a36Sopenharmony_ci int main_total_rssi; 91762306a36Sopenharmony_ci int alt_total_rssi; 91862306a36Sopenharmony_ci int alt_recv_cnt; 91962306a36Sopenharmony_ci int main_recv_cnt; 92062306a36Sopenharmony_ci int rssi_lna1; 92162306a36Sopenharmony_ci int rssi_lna2; 92262306a36Sopenharmony_ci int rssi_add; 92362306a36Sopenharmony_ci int rssi_sub; 92462306a36Sopenharmony_ci int rssi_first; 92562306a36Sopenharmony_ci int rssi_second; 92662306a36Sopenharmony_ci int rssi_third; 92762306a36Sopenharmony_ci int ant_ratio; 92862306a36Sopenharmony_ci int ant_ratio2; 92962306a36Sopenharmony_ci bool alt_good; 93062306a36Sopenharmony_ci int quick_scan_cnt; 93162306a36Sopenharmony_ci enum ath9k_ant_div_comb_lna_conf main_conf; 93262306a36Sopenharmony_ci enum ath9k_ant_div_comb_lna_conf first_quick_scan_conf; 93362306a36Sopenharmony_ci enum ath9k_ant_div_comb_lna_conf second_quick_scan_conf; 93462306a36Sopenharmony_ci bool first_ratio; 93562306a36Sopenharmony_ci bool second_ratio; 93662306a36Sopenharmony_ci unsigned long scan_start_time; 93762306a36Sopenharmony_ci 93862306a36Sopenharmony_ci /* 93962306a36Sopenharmony_ci * Card-specific config values. 94062306a36Sopenharmony_ci */ 94162306a36Sopenharmony_ci int low_rssi_thresh; 94262306a36Sopenharmony_ci int fast_div_bias; 94362306a36Sopenharmony_ci}; 94462306a36Sopenharmony_ci 94562306a36Sopenharmony_civoid ath_ant_comb_scan(struct ath_softc *sc, struct ath_rx_status *rs); 94662306a36Sopenharmony_ci 94762306a36Sopenharmony_ci/********************/ 94862306a36Sopenharmony_ci/* Main driver core */ 94962306a36Sopenharmony_ci/********************/ 95062306a36Sopenharmony_ci 95162306a36Sopenharmony_ci#define ATH9K_PCI_CUS198 0x0001 95262306a36Sopenharmony_ci#define ATH9K_PCI_CUS230 0x0002 95362306a36Sopenharmony_ci#define ATH9K_PCI_CUS217 0x0004 95462306a36Sopenharmony_ci#define ATH9K_PCI_CUS252 0x0008 95562306a36Sopenharmony_ci#define ATH9K_PCI_WOW 0x0010 95662306a36Sopenharmony_ci#define ATH9K_PCI_BT_ANT_DIV 0x0020 95762306a36Sopenharmony_ci#define ATH9K_PCI_D3_L1_WAR 0x0040 95862306a36Sopenharmony_ci#define ATH9K_PCI_AR9565_1ANT 0x0080 95962306a36Sopenharmony_ci#define ATH9K_PCI_AR9565_2ANT 0x0100 96062306a36Sopenharmony_ci#define ATH9K_PCI_NO_PLL_PWRSAVE 0x0200 96162306a36Sopenharmony_ci#define ATH9K_PCI_KILLER 0x0400 96262306a36Sopenharmony_ci#define ATH9K_PCI_LED_ACT_HI 0x0800 96362306a36Sopenharmony_ci 96462306a36Sopenharmony_ci/* 96562306a36Sopenharmony_ci * Default cache line size, in bytes. 96662306a36Sopenharmony_ci * Used when PCI device not fully initialized by bootrom/BIOS 96762306a36Sopenharmony_ci*/ 96862306a36Sopenharmony_ci#define DEFAULT_CACHELINE 32 96962306a36Sopenharmony_ci#define ATH_CABQ_READY_TIME 80 /* % of beacon interval */ 97062306a36Sopenharmony_ci#define ATH_TXPOWER_MAX 100 /* .5 dBm units */ 97162306a36Sopenharmony_ci#define MAX_GTT_CNT 5 97262306a36Sopenharmony_ci 97362306a36Sopenharmony_ci/* Powersave flags */ 97462306a36Sopenharmony_ci#define PS_WAIT_FOR_BEACON BIT(0) 97562306a36Sopenharmony_ci#define PS_WAIT_FOR_CAB BIT(1) 97662306a36Sopenharmony_ci#define PS_WAIT_FOR_PSPOLL_DATA BIT(2) 97762306a36Sopenharmony_ci#define PS_WAIT_FOR_TX_ACK BIT(3) 97862306a36Sopenharmony_ci#define PS_BEACON_SYNC BIT(4) 97962306a36Sopenharmony_ci#define PS_WAIT_FOR_ANI BIT(5) 98062306a36Sopenharmony_ci 98162306a36Sopenharmony_ci#define ATH9K_NUM_CHANCTX 2 /* supports 2 operating channels */ 98262306a36Sopenharmony_ci 98362306a36Sopenharmony_cistruct ath_softc { 98462306a36Sopenharmony_ci struct ieee80211_hw *hw; 98562306a36Sopenharmony_ci struct device *dev; 98662306a36Sopenharmony_ci 98762306a36Sopenharmony_ci struct survey_info *cur_survey; 98862306a36Sopenharmony_ci struct survey_info survey[ATH9K_NUM_CHANNELS]; 98962306a36Sopenharmony_ci 99062306a36Sopenharmony_ci spinlock_t intr_lock; 99162306a36Sopenharmony_ci struct tasklet_struct intr_tq; 99262306a36Sopenharmony_ci struct tasklet_struct bcon_tasklet; 99362306a36Sopenharmony_ci struct ath_hw *sc_ah; 99462306a36Sopenharmony_ci void __iomem *mem; 99562306a36Sopenharmony_ci int irq; 99662306a36Sopenharmony_ci spinlock_t sc_serial_rw; 99762306a36Sopenharmony_ci spinlock_t sc_pm_lock; 99862306a36Sopenharmony_ci spinlock_t sc_pcu_lock; 99962306a36Sopenharmony_ci struct mutex mutex; 100062306a36Sopenharmony_ci struct work_struct paprd_work; 100162306a36Sopenharmony_ci struct work_struct hw_reset_work; 100262306a36Sopenharmony_ci struct completion paprd_complete; 100362306a36Sopenharmony_ci wait_queue_head_t tx_wait; 100462306a36Sopenharmony_ci 100562306a36Sopenharmony_ci#ifdef CONFIG_ATH9K_CHANNEL_CONTEXT 100662306a36Sopenharmony_ci struct work_struct chanctx_work; 100762306a36Sopenharmony_ci struct ath_gen_timer *p2p_ps_timer; 100862306a36Sopenharmony_ci struct ath_vif *p2p_ps_vif; 100962306a36Sopenharmony_ci struct ath_chanctx_sched sched; 101062306a36Sopenharmony_ci struct ath_offchannel offchannel; 101162306a36Sopenharmony_ci struct ath_chanctx *next_chan; 101262306a36Sopenharmony_ci struct completion go_beacon; 101362306a36Sopenharmony_ci struct timespec64 last_event_time; 101462306a36Sopenharmony_ci#endif 101562306a36Sopenharmony_ci 101662306a36Sopenharmony_ci unsigned long driver_data; 101762306a36Sopenharmony_ci 101862306a36Sopenharmony_ci u8 gtt_cnt; 101962306a36Sopenharmony_ci u32 intrstatus; 102062306a36Sopenharmony_ci u16 ps_flags; /* PS_* */ 102162306a36Sopenharmony_ci bool ps_enabled; 102262306a36Sopenharmony_ci bool ps_idle; 102362306a36Sopenharmony_ci short nbcnvifs; 102462306a36Sopenharmony_ci unsigned long ps_usecount; 102562306a36Sopenharmony_ci 102662306a36Sopenharmony_ci struct ath_rx rx; 102762306a36Sopenharmony_ci struct ath_tx tx; 102862306a36Sopenharmony_ci struct ath_beacon beacon; 102962306a36Sopenharmony_ci 103062306a36Sopenharmony_ci struct cfg80211_chan_def cur_chandef; 103162306a36Sopenharmony_ci struct ath_chanctx chanctx[ATH9K_NUM_CHANCTX]; 103262306a36Sopenharmony_ci struct ath_chanctx *cur_chan; 103362306a36Sopenharmony_ci spinlock_t chan_lock; 103462306a36Sopenharmony_ci 103562306a36Sopenharmony_ci#ifdef CONFIG_MAC80211_LEDS 103662306a36Sopenharmony_ci bool led_registered; 103762306a36Sopenharmony_ci char led_name[32]; 103862306a36Sopenharmony_ci struct led_classdev led_cdev; 103962306a36Sopenharmony_ci#endif 104062306a36Sopenharmony_ci 104162306a36Sopenharmony_ci#ifdef CONFIG_ATH9K_DEBUGFS 104262306a36Sopenharmony_ci struct ath9k_debug debug; 104362306a36Sopenharmony_ci#endif 104462306a36Sopenharmony_ci struct delayed_work hw_check_work; 104562306a36Sopenharmony_ci struct delayed_work hw_pll_work; 104662306a36Sopenharmony_ci struct timer_list sleep_timer; 104762306a36Sopenharmony_ci 104862306a36Sopenharmony_ci#ifdef CONFIG_ATH9K_BTCOEX_SUPPORT 104962306a36Sopenharmony_ci struct ath_btcoex btcoex; 105062306a36Sopenharmony_ci struct ath_mci_coex mci_coex; 105162306a36Sopenharmony_ci struct work_struct mci_work; 105262306a36Sopenharmony_ci#endif 105362306a36Sopenharmony_ci 105462306a36Sopenharmony_ci struct ath_descdma txsdma; 105562306a36Sopenharmony_ci 105662306a36Sopenharmony_ci struct ath_ant_comb ant_comb; 105762306a36Sopenharmony_ci u8 ant_tx, ant_rx; 105862306a36Sopenharmony_ci struct dfs_pattern_detector *dfs_detector; 105962306a36Sopenharmony_ci u64 dfs_prev_pulse_ts; 106062306a36Sopenharmony_ci u32 wow_enabled; 106162306a36Sopenharmony_ci 106262306a36Sopenharmony_ci struct ath_spec_scan_priv spec_priv; 106362306a36Sopenharmony_ci 106462306a36Sopenharmony_ci struct ieee80211_vif *tx99_vif; 106562306a36Sopenharmony_ci struct sk_buff *tx99_skb; 106662306a36Sopenharmony_ci bool tx99_state; 106762306a36Sopenharmony_ci s16 tx99_power; 106862306a36Sopenharmony_ci 106962306a36Sopenharmony_ci#ifdef CONFIG_ATH9K_WOW 107062306a36Sopenharmony_ci u32 wow_intr_before_sleep; 107162306a36Sopenharmony_ci bool force_wow; 107262306a36Sopenharmony_ci#endif 107362306a36Sopenharmony_ci 107462306a36Sopenharmony_ci#ifdef CONFIG_ATH9K_HWRNG 107562306a36Sopenharmony_ci struct hwrng rng_ops; 107662306a36Sopenharmony_ci u32 rng_last; 107762306a36Sopenharmony_ci char rng_name[sizeof("ath9k_65535")]; 107862306a36Sopenharmony_ci#endif 107962306a36Sopenharmony_ci}; 108062306a36Sopenharmony_ci 108162306a36Sopenharmony_ci/********/ 108262306a36Sopenharmony_ci/* TX99 */ 108362306a36Sopenharmony_ci/********/ 108462306a36Sopenharmony_ci 108562306a36Sopenharmony_ci#ifdef CONFIG_ATH9K_TX99 108662306a36Sopenharmony_civoid ath9k_tx99_init_debug(struct ath_softc *sc); 108762306a36Sopenharmony_ciint ath9k_tx99_send(struct ath_softc *sc, struct sk_buff *skb, 108862306a36Sopenharmony_ci struct ath_tx_control *txctl); 108962306a36Sopenharmony_ci#else 109062306a36Sopenharmony_cistatic inline void ath9k_tx99_init_debug(struct ath_softc *sc) 109162306a36Sopenharmony_ci{ 109262306a36Sopenharmony_ci} 109362306a36Sopenharmony_cistatic inline int ath9k_tx99_send(struct ath_softc *sc, 109462306a36Sopenharmony_ci struct sk_buff *skb, 109562306a36Sopenharmony_ci struct ath_tx_control *txctl) 109662306a36Sopenharmony_ci{ 109762306a36Sopenharmony_ci return 0; 109862306a36Sopenharmony_ci} 109962306a36Sopenharmony_ci#endif /* CONFIG_ATH9K_TX99 */ 110062306a36Sopenharmony_ci 110162306a36Sopenharmony_ci/***************************/ 110262306a36Sopenharmony_ci/* Random Number Generator */ 110362306a36Sopenharmony_ci/***************************/ 110462306a36Sopenharmony_ci#ifdef CONFIG_ATH9K_HWRNG 110562306a36Sopenharmony_civoid ath9k_rng_start(struct ath_softc *sc); 110662306a36Sopenharmony_civoid ath9k_rng_stop(struct ath_softc *sc); 110762306a36Sopenharmony_ci#else 110862306a36Sopenharmony_cistatic inline void ath9k_rng_start(struct ath_softc *sc) 110962306a36Sopenharmony_ci{ 111062306a36Sopenharmony_ci} 111162306a36Sopenharmony_ci 111262306a36Sopenharmony_cistatic inline void ath9k_rng_stop(struct ath_softc *sc) 111362306a36Sopenharmony_ci{ 111462306a36Sopenharmony_ci} 111562306a36Sopenharmony_ci#endif 111662306a36Sopenharmony_ci 111762306a36Sopenharmony_cistatic inline void ath_read_cachesize(struct ath_common *common, int *csz) 111862306a36Sopenharmony_ci{ 111962306a36Sopenharmony_ci common->bus_ops->read_cachesize(common, csz); 112062306a36Sopenharmony_ci} 112162306a36Sopenharmony_ci 112262306a36Sopenharmony_civoid ath9k_tasklet(struct tasklet_struct *t); 112362306a36Sopenharmony_ciint ath_cabq_update(struct ath_softc *); 112462306a36Sopenharmony_ciu8 ath9k_parse_mpdudensity(u8 mpdudensity); 112562306a36Sopenharmony_ciirqreturn_t ath_isr(int irq, void *dev); 112662306a36Sopenharmony_ciint ath_reset(struct ath_softc *sc, struct ath9k_channel *hchan); 112762306a36Sopenharmony_civoid ath_cancel_work(struct ath_softc *sc); 112862306a36Sopenharmony_civoid ath_restart_work(struct ath_softc *sc); 112962306a36Sopenharmony_ciint ath9k_init_device(u16 devid, struct ath_softc *sc, 113062306a36Sopenharmony_ci const struct ath_bus_ops *bus_ops); 113162306a36Sopenharmony_civoid ath9k_deinit_device(struct ath_softc *sc); 113262306a36Sopenharmony_ciu8 ath_txchainmask_reduction(struct ath_softc *sc, u8 chainmask, u32 rate); 113362306a36Sopenharmony_civoid ath_start_rfkill_poll(struct ath_softc *sc); 113462306a36Sopenharmony_civoid ath9k_rfkill_poll_state(struct ieee80211_hw *hw); 113562306a36Sopenharmony_civoid ath9k_ps_wakeup(struct ath_softc *sc); 113662306a36Sopenharmony_civoid ath9k_ps_restore(struct ath_softc *sc); 113762306a36Sopenharmony_ci 113862306a36Sopenharmony_ci#ifdef CONFIG_ATH9K_PCI 113962306a36Sopenharmony_ciint ath_pci_init(void); 114062306a36Sopenharmony_civoid ath_pci_exit(void); 114162306a36Sopenharmony_ci#else 114262306a36Sopenharmony_cistatic inline int ath_pci_init(void) { return 0; }; 114362306a36Sopenharmony_cistatic inline void ath_pci_exit(void) {}; 114462306a36Sopenharmony_ci#endif 114562306a36Sopenharmony_ci 114662306a36Sopenharmony_ci#ifdef CONFIG_ATH9K_AHB 114762306a36Sopenharmony_ciint ath_ahb_init(void); 114862306a36Sopenharmony_civoid ath_ahb_exit(void); 114962306a36Sopenharmony_ci#else 115062306a36Sopenharmony_cistatic inline int ath_ahb_init(void) { return 0; }; 115162306a36Sopenharmony_cistatic inline void ath_ahb_exit(void) {}; 115262306a36Sopenharmony_ci#endif 115362306a36Sopenharmony_ci 115462306a36Sopenharmony_ci#endif /* ATH9K_H */ 1155