xref: /freebsd/sys/dev/ath/if_ath_tx.h (revision 25408c853d9ecb2e76b9e38407338f86ecb8a55c)
1 /*-
2  * Copyright (c) 2002-2009 Sam Leffler, Errno Consulting
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer,
10  *    without modification.
11  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
12  *    similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
13  *    redistribution must be conditioned upon including a substantially
14  *    similar Disclaimer requirement for further binary redistribution.
15  *
16  * NO WARRANTY
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19  * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
20  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
21  * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY,
22  * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
25  * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
27  * THE POSSIBILITY OF SUCH DAMAGES.
28  *
29  * $FreeBSD$
30  */
31 #ifndef	__IF_ATH_TX_H__
32 #define	__IF_ATH_TX_H__
33 
34 /*
35  * some general macros
36  */
37 #define	INCR(_l, _sz)		(_l) ++; (_l) &= ((_sz) - 1)
38 /*
39  * return block-ack bitmap index given sequence and starting sequence
40  */
41 #define	ATH_BA_INDEX(_st, _seq)	(((_seq) - (_st)) & (IEEE80211_SEQ_RANGE - 1))
42 
43 #define	WME_BA_BMP_SIZE	64
44 #define	WME_MAX_BA	WME_BA_BMP_SIZE
45 
46 /*
47  * How 'busy' to try and keep the hardware txq
48  */
49 #define	ATH_AGGR_MIN_QDEPTH		2
50 
51 /*
52  * Watermark for scheduling TIDs in order to maximise aggregation.
53  *
54  * If hwq_depth is greater than this, don't schedule the TID
55  * for packet scheduling - the hardware is already busy servicing
56  * this TID.
57  *
58  * If hwq_depth is less than this, schedule the TID for packet
59  * scheduling in the completion handler.
60  */
61 #define	ATH_AGGR_SCHED_HIGH		4
62 #define	ATH_AGGR_SCHED_LOW		2
63 
64 /*
65  * return whether a bit at index _n in bitmap _bm is set
66  * _sz is the size of the bitmap
67  */
68 #define	ATH_BA_ISSET(_bm, _n)	(((_n) < (WME_BA_BMP_SIZE)) &&		\
69 	    ((_bm)[(_n) >> 5] & (1 << ((_n) & 31))))
70 
71 
72 /* extracting the seqno from buffer seqno */
73 #define	SEQNO(_a)	((_a) >> IEEE80211_SEQ_SEQ_SHIFT)
74 
75 /*
76  * Whether the current sequence number is within the
77  * BAW.
78  */
79 #define	BAW_WITHIN(_start, _bawsz, _seqno)	\
80 	    ((((_seqno) - (_start)) & 4095) < (_bawsz))
81 
82 extern void ath_freetx(struct mbuf *m);
83 extern void ath_tx_node_flush(struct ath_softc *sc, struct ath_node *an);
84 extern void ath_tx_txq_drain(struct ath_softc *sc, struct ath_txq *txq);
85 extern void ath_txfrag_cleanup(struct ath_softc *sc, ath_bufhead *frags,
86     struct ieee80211_node *ni);
87 extern int ath_txfrag_setup(struct ath_softc *sc, ath_bufhead *frags,
88     struct mbuf *m0, struct ieee80211_node *ni);
89 extern int ath_tx_start(struct ath_softc *sc, struct ieee80211_node *ni,
90     struct ath_buf *bf, struct mbuf *m0);
91 extern int ath_raw_xmit(struct ieee80211_node *ni, struct mbuf *m,
92     const struct ieee80211_bpf_params *params);
93 
94 /* software queue stuff */
95 extern void ath_tx_swq(struct ath_softc *sc, struct ieee80211_node *ni,
96     struct ath_txq *txq, struct ath_buf *bf);
97 extern void ath_tx_tid_init(struct ath_softc *sc, struct ath_node *an);
98 extern void ath_tx_tid_hw_queue_aggr(struct ath_softc *sc, struct ath_node *an,
99     struct ath_tid *tid);
100 extern void ath_tx_tid_hw_queue_norm(struct ath_softc *sc, struct ath_node *an,
101     struct ath_tid *tid);
102 extern void ath_txq_sched(struct ath_softc *sc, struct ath_txq *txq);
103 extern void ath_tx_normal_comp(struct ath_softc *sc, struct ath_buf *bf,
104     int fail);
105 extern void ath_tx_aggr_comp(struct ath_softc *sc, struct ath_buf *bf,
106     int fail);
107 extern void ath_tx_addto_baw(struct ath_softc *sc, struct ath_node *an,
108     struct ath_tid *tid, struct ath_buf *bf);
109 extern struct ieee80211_tx_ampdu * ath_tx_get_tx_tid(struct ath_node *an,
110     int tid);
111 
112 /* TX addba handling */
113 extern	int ath_addba_request(struct ieee80211_node *ni,
114     struct ieee80211_tx_ampdu *tap, int dialogtoken,
115     int baparamset, int batimeout);
116 extern	int ath_addba_response(struct ieee80211_node *ni,
117     struct ieee80211_tx_ampdu *tap, int dialogtoken,
118     int code, int batimeout);
119 extern	void ath_addba_stop(struct ieee80211_node *ni,
120     struct ieee80211_tx_ampdu *tap);
121 extern	void ath_bar_response(struct ieee80211_node *ni,
122      struct ieee80211_tx_ampdu *tap, int status);
123 extern	void ath_addba_response_timeout(struct ieee80211_node *ni,
124     struct ieee80211_tx_ampdu *tap);
125 
126 /*
127  * AP mode power save handling (of stations)
128  */
129 extern	void ath_tx_node_sleep(struct ath_softc *sc, struct ath_node *an);
130 extern	void ath_tx_node_wakeup(struct ath_softc *sc, struct ath_node *an);
131 
132 /*
133  * Setup path
134  */
135 #define	ath_txdma_setup(_sc)			\
136 	(_sc)->sc_tx.xmit_setup(_sc)
137 #define	ath_txdma_teardown(_sc)			\
138 	(_sc)->sc_tx.xmit_teardown(_sc)
139 #define	ath_txq_restart_dma(_sc, _txq)		\
140 	(_sc)->sc_tx.xmit_dma_restart((_sc), (_txq))
141 #define	ath_tx_handoff(_sc, _txq, _bf)		\
142 	(_sc)->sc_tx.xmit_handoff((_sc), (_txq), (_bf))
143 #define	ath_draintxq(_sc, _rtype)		\
144 	(_sc)->sc_tx.xmit_drain((_sc), (_rtype))
145 
146 extern	void ath_xmit_setup_legacy(struct ath_softc *sc);
147 
148 #endif
149