xref: /dragonfly/sys/dev/netif/ath/ath/if_ath_tx.h (revision df052c2a)
1572ff6f6SMatthew Dillon /*-
2572ff6f6SMatthew Dillon  * Copyright (c) 2002-2009 Sam Leffler, Errno Consulting
3572ff6f6SMatthew Dillon  * All rights reserved.
4572ff6f6SMatthew Dillon  *
5572ff6f6SMatthew Dillon  * Redistribution and use in source and binary forms, with or without
6572ff6f6SMatthew Dillon  * modification, are permitted provided that the following conditions
7572ff6f6SMatthew Dillon  * are met:
8572ff6f6SMatthew Dillon  * 1. Redistributions of source code must retain the above copyright
9572ff6f6SMatthew Dillon  *    notice, this list of conditions and the following disclaimer,
10572ff6f6SMatthew Dillon  *    without modification.
11572ff6f6SMatthew Dillon  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
12572ff6f6SMatthew Dillon  *    similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
13572ff6f6SMatthew Dillon  *    redistribution must be conditioned upon including a substantially
14572ff6f6SMatthew Dillon  *    similar Disclaimer requirement for further binary redistribution.
15572ff6f6SMatthew Dillon  *
16572ff6f6SMatthew Dillon  * NO WARRANTY
17572ff6f6SMatthew Dillon  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18572ff6f6SMatthew Dillon  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19*df052c2aSSascha Wildner  * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTABILITY
20572ff6f6SMatthew Dillon  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
21572ff6f6SMatthew Dillon  * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY,
22572ff6f6SMatthew Dillon  * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23572ff6f6SMatthew Dillon  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24572ff6f6SMatthew Dillon  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
25572ff6f6SMatthew Dillon  * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26572ff6f6SMatthew Dillon  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
27572ff6f6SMatthew Dillon  * THE POSSIBILITY OF SUCH DAMAGES.
28572ff6f6SMatthew Dillon  *
29572ff6f6SMatthew Dillon  * $FreeBSD$
30572ff6f6SMatthew Dillon  */
31572ff6f6SMatthew Dillon #ifndef	__IF_ATH_TX_H__
32572ff6f6SMatthew Dillon #define	__IF_ATH_TX_H__
33572ff6f6SMatthew Dillon 
34572ff6f6SMatthew Dillon /*
35572ff6f6SMatthew Dillon  * some general macros
36572ff6f6SMatthew Dillon  */
37572ff6f6SMatthew Dillon #define	INCR(_l, _sz)		(_l) ++; (_l) &= ((_sz) - 1)
38572ff6f6SMatthew Dillon /*
39572ff6f6SMatthew Dillon  * return block-ack bitmap index given sequence and starting sequence
40572ff6f6SMatthew Dillon  */
41572ff6f6SMatthew Dillon #define	ATH_BA_INDEX(_st, _seq)	(((_seq) - (_st)) & (IEEE80211_SEQ_RANGE - 1))
42572ff6f6SMatthew Dillon 
43572ff6f6SMatthew Dillon #define	WME_BA_BMP_SIZE	64
44572ff6f6SMatthew Dillon #define	WME_MAX_BA	WME_BA_BMP_SIZE
45572ff6f6SMatthew Dillon 
46572ff6f6SMatthew Dillon /*
47572ff6f6SMatthew Dillon  * How 'busy' to try and keep the hardware txq
48572ff6f6SMatthew Dillon  */
49572ff6f6SMatthew Dillon #define	ATH_AGGR_MIN_QDEPTH		2
50572ff6f6SMatthew Dillon #define	ATH_NONAGGR_MIN_QDEPTH		32
51572ff6f6SMatthew Dillon 
52572ff6f6SMatthew Dillon /*
53572ff6f6SMatthew Dillon  * Watermark for scheduling TIDs in order to maximise aggregation.
54572ff6f6SMatthew Dillon  *
55572ff6f6SMatthew Dillon  * If hwq_depth is greater than this, don't schedule the TID
56572ff6f6SMatthew Dillon  * for packet scheduling - the hardware is already busy servicing
57572ff6f6SMatthew Dillon  * this TID.
58572ff6f6SMatthew Dillon  *
59572ff6f6SMatthew Dillon  * If hwq_depth is less than this, schedule the TID for packet
60572ff6f6SMatthew Dillon  * scheduling in the completion handler.
61572ff6f6SMatthew Dillon  */
62572ff6f6SMatthew Dillon #define	ATH_AGGR_SCHED_HIGH		4
63572ff6f6SMatthew Dillon #define	ATH_AGGR_SCHED_LOW		2
64572ff6f6SMatthew Dillon 
65572ff6f6SMatthew Dillon /*
66572ff6f6SMatthew Dillon  * return whether a bit at index _n in bitmap _bm is set
67572ff6f6SMatthew Dillon  * _sz is the size of the bitmap
68572ff6f6SMatthew Dillon  */
69572ff6f6SMatthew Dillon #define	ATH_BA_ISSET(_bm, _n)	(((_n) < (WME_BA_BMP_SIZE)) &&		\
70572ff6f6SMatthew Dillon 	    ((_bm)[(_n) >> 5] & (1 << ((_n) & 31))))
71572ff6f6SMatthew Dillon 
72572ff6f6SMatthew Dillon 
73572ff6f6SMatthew Dillon /* extracting the seqno from buffer seqno */
74572ff6f6SMatthew Dillon #define	SEQNO(_a)	((_a) >> IEEE80211_SEQ_SEQ_SHIFT)
75572ff6f6SMatthew Dillon 
76572ff6f6SMatthew Dillon /*
77572ff6f6SMatthew Dillon  * Whether the current sequence number is within the
78572ff6f6SMatthew Dillon  * BAW.
79572ff6f6SMatthew Dillon  */
80572ff6f6SMatthew Dillon #define	BAW_WITHIN(_start, _bawsz, _seqno)	\
81572ff6f6SMatthew Dillon 	    ((((_seqno) - (_start)) & 4095) < (_bawsz))
82572ff6f6SMatthew Dillon 
83572ff6f6SMatthew Dillon /*
84572ff6f6SMatthew Dillon  * Maximum aggregate size
85572ff6f6SMatthew Dillon  */
86572ff6f6SMatthew Dillon #define	ATH_AGGR_MAXSIZE	65530
87572ff6f6SMatthew Dillon 
88572ff6f6SMatthew Dillon extern void ath_tx_node_flush(struct ath_softc *sc, struct ath_node *an);
89572ff6f6SMatthew Dillon extern void ath_tx_txq_drain(struct ath_softc *sc, struct ath_txq *txq);
90572ff6f6SMatthew Dillon extern void ath_txfrag_cleanup(struct ath_softc *sc, ath_bufhead *frags,
91572ff6f6SMatthew Dillon     struct ieee80211_node *ni);
92572ff6f6SMatthew Dillon extern int ath_txfrag_setup(struct ath_softc *sc, ath_bufhead *frags,
93572ff6f6SMatthew Dillon     struct mbuf *m0, struct ieee80211_node *ni);
94572ff6f6SMatthew Dillon extern int ath_tx_start(struct ath_softc *sc, struct ieee80211_node *ni,
95572ff6f6SMatthew Dillon     struct ath_buf *bf, struct mbuf *m0);
96572ff6f6SMatthew Dillon extern int ath_raw_xmit(struct ieee80211_node *ni, struct mbuf *m,
97572ff6f6SMatthew Dillon     const struct ieee80211_bpf_params *params);
98572ff6f6SMatthew Dillon 
99572ff6f6SMatthew Dillon /* software queue stuff */
100572ff6f6SMatthew Dillon extern void ath_tx_swq(struct ath_softc *sc, struct ieee80211_node *ni,
101572ff6f6SMatthew Dillon     struct ath_txq *txq, int queue_to_head, struct ath_buf *bf);
102572ff6f6SMatthew Dillon extern void ath_tx_tid_init(struct ath_softc *sc, struct ath_node *an);
103572ff6f6SMatthew Dillon extern void ath_tx_tid_hw_queue_aggr(struct ath_softc *sc, struct ath_node *an,
104572ff6f6SMatthew Dillon     struct ath_tid *tid);
105572ff6f6SMatthew Dillon extern void ath_tx_tid_hw_queue_norm(struct ath_softc *sc, struct ath_node *an,
106572ff6f6SMatthew Dillon     struct ath_tid *tid);
107572ff6f6SMatthew Dillon extern void ath_txq_sched(struct ath_softc *sc, struct ath_txq *txq);
108572ff6f6SMatthew Dillon extern void ath_tx_normal_comp(struct ath_softc *sc, struct ath_buf *bf,
109572ff6f6SMatthew Dillon     int fail);
110572ff6f6SMatthew Dillon extern void ath_tx_aggr_comp(struct ath_softc *sc, struct ath_buf *bf,
111572ff6f6SMatthew Dillon     int fail);
112572ff6f6SMatthew Dillon extern void ath_tx_addto_baw(struct ath_softc *sc, struct ath_node *an,
113572ff6f6SMatthew Dillon     struct ath_tid *tid, struct ath_buf *bf);
114572ff6f6SMatthew Dillon extern struct ieee80211_tx_ampdu * ath_tx_get_tx_tid(struct ath_node *an,
115572ff6f6SMatthew Dillon     int tid);
116572ff6f6SMatthew Dillon extern void ath_tx_tid_sched(struct ath_softc *sc, struct ath_tid *tid);
117572ff6f6SMatthew Dillon 
118572ff6f6SMatthew Dillon /* TX addba handling */
119572ff6f6SMatthew Dillon extern	int ath_addba_request(struct ieee80211_node *ni,
120572ff6f6SMatthew Dillon     struct ieee80211_tx_ampdu *tap, int dialogtoken,
121572ff6f6SMatthew Dillon     int baparamset, int batimeout);
122572ff6f6SMatthew Dillon extern	int ath_addba_response(struct ieee80211_node *ni,
123572ff6f6SMatthew Dillon     struct ieee80211_tx_ampdu *tap, int dialogtoken,
124572ff6f6SMatthew Dillon     int code, int batimeout);
125572ff6f6SMatthew Dillon extern	void ath_addba_stop(struct ieee80211_node *ni,
126572ff6f6SMatthew Dillon     struct ieee80211_tx_ampdu *tap);
127572ff6f6SMatthew Dillon extern	void ath_bar_response(struct ieee80211_node *ni,
128572ff6f6SMatthew Dillon      struct ieee80211_tx_ampdu *tap, int status);
129572ff6f6SMatthew Dillon extern	void ath_addba_response_timeout(struct ieee80211_node *ni,
130572ff6f6SMatthew Dillon     struct ieee80211_tx_ampdu *tap);
131572ff6f6SMatthew Dillon 
132572ff6f6SMatthew Dillon /*
133572ff6f6SMatthew Dillon  * AP mode power save handling (of stations)
134572ff6f6SMatthew Dillon  */
135572ff6f6SMatthew Dillon extern	void ath_tx_node_sleep(struct ath_softc *sc, struct ath_node *an);
136572ff6f6SMatthew Dillon extern	void ath_tx_node_wakeup(struct ath_softc *sc, struct ath_node *an);
137572ff6f6SMatthew Dillon extern	int ath_tx_node_is_asleep(struct ath_softc *sc, struct ath_node *an);
138572ff6f6SMatthew Dillon extern	void ath_tx_node_reassoc(struct ath_softc *sc, struct ath_node *an);
139572ff6f6SMatthew Dillon 
140572ff6f6SMatthew Dillon /*
141572ff6f6SMatthew Dillon  * Hardware queue stuff
142572ff6f6SMatthew Dillon  */
143572ff6f6SMatthew Dillon extern	void ath_tx_push_pending(struct ath_softc *sc, struct ath_txq *txq);
144572ff6f6SMatthew Dillon 
145572ff6f6SMatthew Dillon /*
146572ff6f6SMatthew Dillon  * Misc debugging stuff
147572ff6f6SMatthew Dillon  */
148572ff6f6SMatthew Dillon #ifdef	ATH_DEBUG_ALQ
149572ff6f6SMatthew Dillon extern	void ath_tx_alq_post(struct ath_softc *sc, struct ath_buf *bf_first);
150572ff6f6SMatthew Dillon #endif	/* ATH_DEBUG_ALQ */
151572ff6f6SMatthew Dillon 
152572ff6f6SMatthew Dillon /*
153572ff6f6SMatthew Dillon  * Setup path
154572ff6f6SMatthew Dillon  */
155572ff6f6SMatthew Dillon #define	ath_txdma_setup(_sc)			\
156572ff6f6SMatthew Dillon 	(_sc)->sc_tx.xmit_setup(_sc)
157572ff6f6SMatthew Dillon #define	ath_txdma_teardown(_sc)			\
158572ff6f6SMatthew Dillon 	(_sc)->sc_tx.xmit_teardown(_sc)
159572ff6f6SMatthew Dillon #define	ath_txq_restart_dma(_sc, _txq)		\
160572ff6f6SMatthew Dillon 	(_sc)->sc_tx.xmit_dma_restart((_sc), (_txq))
161572ff6f6SMatthew Dillon #define	ath_tx_handoff(_sc, _txq, _bf)		\
162572ff6f6SMatthew Dillon 	(_sc)->sc_tx.xmit_handoff((_sc), (_txq), (_bf))
163572ff6f6SMatthew Dillon #define	ath_draintxq(_sc, _rtype)		\
164572ff6f6SMatthew Dillon 	(_sc)->sc_tx.xmit_drain((_sc), (_rtype))
165572ff6f6SMatthew Dillon 
166572ff6f6SMatthew Dillon extern	void ath_xmit_setup_legacy(struct ath_softc *sc);
167572ff6f6SMatthew Dillon 
168572ff6f6SMatthew Dillon #endif
169