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