if_ath_tx.h revision 238931
1218065Sadrian/*-
2218065Sadrian * Copyright (c) 2002-2009 Sam Leffler, Errno Consulting
3218065Sadrian * All rights reserved.
4218065Sadrian *
5218065Sadrian * Redistribution and use in source and binary forms, with or without
6218065Sadrian * modification, are permitted provided that the following conditions
7218065Sadrian * are met:
8218065Sadrian * 1. Redistributions of source code must retain the above copyright
9218065Sadrian *    notice, this list of conditions and the following disclaimer,
10218065Sadrian *    without modification.
11218065Sadrian * 2. Redistributions in binary form must reproduce at minimum a disclaimer
12218065Sadrian *    similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
13218065Sadrian *    redistribution must be conditioned upon including a substantially
14218065Sadrian *    similar Disclaimer requirement for further binary redistribution.
15218065Sadrian *
16218065Sadrian * NO WARRANTY
17218065Sadrian * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18218065Sadrian * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19218065Sadrian * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
20218065Sadrian * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
21218065Sadrian * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY,
22218065Sadrian * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23218065Sadrian * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24218065Sadrian * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
25218065Sadrian * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26218065Sadrian * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
27218065Sadrian * THE POSSIBILITY OF SUCH DAMAGES.
28218065Sadrian *
29218065Sadrian * $FreeBSD: head/sys/dev/ath/if_ath_tx.h 238931 2012-07-31 03:09:48Z adrian $
30218065Sadrian */
31218065Sadrian#ifndef	__IF_ATH_TX_H__
32218065Sadrian#define	__IF_ATH_TX_H__
33218065Sadrian
34227346Sadrian/*
35227364Sadrian * some general macros
36227364Sadrian */
37227364Sadrian#define	INCR(_l, _sz)		(_l) ++; (_l) &= ((_sz) - 1)
38227364Sadrian/*
39227364Sadrian * return block-ack bitmap index given sequence and starting sequence
40227364Sadrian */
41227364Sadrian#define	ATH_BA_INDEX(_st, _seq)	(((_seq) - (_st)) & (IEEE80211_SEQ_RANGE - 1))
42227364Sadrian
43227364Sadrian#define	WME_BA_BMP_SIZE	64
44227364Sadrian#define	WME_MAX_BA	WME_BA_BMP_SIZE
45227364Sadrian
46227364Sadrian/*
47227346Sadrian * How 'busy' to try and keep the hardware txq
48227346Sadrian */
49227346Sadrian#define	ATH_AGGR_MIN_QDEPTH		2
50227346Sadrian
51227346Sadrian/*
52227346Sadrian * Watermark for scheduling TIDs in order to maximise aggregation.
53227346Sadrian *
54227346Sadrian * If hwq_depth is greater than this, don't schedule the TID
55227346Sadrian * for packet scheduling - the hardware is already busy servicing
56227346Sadrian * this TID.
57227346Sadrian *
58227346Sadrian * If hwq_depth is less than this, schedule the TID for packet
59227346Sadrian * scheduling in the completion handler.
60227346Sadrian */
61227346Sadrian#define	ATH_AGGR_SCHED_HIGH		4
62227346Sadrian#define	ATH_AGGR_SCHED_LOW		2
63227346Sadrian
64227364Sadrian/*
65227364Sadrian * return whether a bit at index _n in bitmap _bm is set
66227364Sadrian * _sz is the size of the bitmap
67227364Sadrian */
68227364Sadrian#define	ATH_BA_ISSET(_bm, _n)	(((_n) < (WME_BA_BMP_SIZE)) &&		\
69227364Sadrian	    ((_bm)[(_n) >> 5] & (1 << ((_n) & 31))))
70227364Sadrian
71227364Sadrian
72227364Sadrian/* extracting the seqno from buffer seqno */
73227364Sadrian#define	SEQNO(_a)	((_a) >> IEEE80211_SEQ_SEQ_SHIFT)
74227364Sadrian
75227364Sadrian/*
76227364Sadrian * Whether the current sequence number is within the
77227364Sadrian * BAW.
78227364Sadrian */
79227364Sadrian#define	BAW_WITHIN(_start, _bawsz, _seqno)	\
80227364Sadrian	    ((((_seqno) - (_start)) & 4095) < (_bawsz))
81227364Sadrian
82218065Sadrianextern void ath_freetx(struct mbuf *m);
83227364Sadrianextern void ath_tx_node_flush(struct ath_softc *sc, struct ath_node *an);
84227364Sadrianextern void ath_tx_txq_drain(struct ath_softc *sc, struct ath_txq *txq);
85218065Sadrianextern void ath_txfrag_cleanup(struct ath_softc *sc, ath_bufhead *frags,
86218065Sadrian    struct ieee80211_node *ni);
87218065Sadrianextern int ath_txfrag_setup(struct ath_softc *sc, ath_bufhead *frags,
88218065Sadrian    struct mbuf *m0, struct ieee80211_node *ni);
89218065Sadrianextern int ath_tx_start(struct ath_softc *sc, struct ieee80211_node *ni,
90218065Sadrian    struct ath_buf *bf, struct mbuf *m0);
91218065Sadrianextern int ath_raw_xmit(struct ieee80211_node *ni, struct mbuf *m,
92218065Sadrian    const struct ieee80211_bpf_params *params);
93218065Sadrian
94227364Sadrian/* software queue stuff */
95227364Sadrianextern void ath_tx_swq(struct ath_softc *sc, struct ieee80211_node *ni,
96227364Sadrian    struct ath_txq *txq, struct ath_buf *bf);
97227364Sadrianextern void ath_tx_tid_init(struct ath_softc *sc, struct ath_node *an);
98227364Sadrianextern void ath_tx_tid_hw_queue_aggr(struct ath_softc *sc, struct ath_node *an,
99227364Sadrian    struct ath_tid *tid);
100227364Sadrianextern void ath_tx_tid_hw_queue_norm(struct ath_softc *sc, struct ath_node *an,
101227364Sadrian    struct ath_tid *tid);
102227364Sadrianextern void ath_txq_sched(struct ath_softc *sc, struct ath_txq *txq);
103227364Sadrianextern void ath_tx_normal_comp(struct ath_softc *sc, struct ath_buf *bf,
104227364Sadrian    int fail);
105227364Sadrianextern void ath_tx_aggr_comp(struct ath_softc *sc, struct ath_buf *bf,
106227364Sadrian    int fail);
107227364Sadrianextern void ath_tx_addto_baw(struct ath_softc *sc, struct ath_node *an,
108227364Sadrian    struct ath_tid *tid, struct ath_buf *bf);
109227364Sadrianextern struct ieee80211_tx_ampdu * ath_tx_get_tx_tid(struct ath_node *an,
110227364Sadrian    int tid);
111227364Sadrian
112227364Sadrian/* TX addba handling */
113227364Sadrianextern	int ath_addba_request(struct ieee80211_node *ni,
114227364Sadrian    struct ieee80211_tx_ampdu *tap, int dialogtoken,
115227364Sadrian    int baparamset, int batimeout);
116227364Sadrianextern	int ath_addba_response(struct ieee80211_node *ni,
117227364Sadrian    struct ieee80211_tx_ampdu *tap, int dialogtoken,
118227364Sadrian    int code, int batimeout);
119227364Sadrianextern	void ath_addba_stop(struct ieee80211_node *ni,
120227364Sadrian    struct ieee80211_tx_ampdu *tap);
121227364Sadrianextern	void ath_bar_response(struct ieee80211_node *ni,
122227364Sadrian     struct ieee80211_tx_ampdu *tap, int status);
123227364Sadrianextern	void ath_addba_response_timeout(struct ieee80211_node *ni,
124227364Sadrian    struct ieee80211_tx_ampdu *tap);
125227364Sadrian
126238710Sadrian/*
127238710Sadrian * Setup path
128238710Sadrian */
129238710Sadrian#define	ath_txdma_setup(_sc)			\
130238710Sadrian	(_sc)->sc_tx.xmit_setup(_sc)
131238710Sadrian#define	ath_txdma_teardown(_sc)			\
132238710Sadrian	(_sc)->sc_tx.xmit_teardown(_sc)
133238930Sadrian#define	ath_txq_restart_dma(_sc, _txq)		\
134238930Sadrian	(_sc)->sc_tx.xmit_dma_restart((_sc), (_txq))
135238930Sadrian#define	ath_tx_handoff(_sc, _txq, _bf)		\
136238930Sadrian	(_sc)->sc_tx.xmit_handoff((_sc), (_txq), (_bf))
137238931Sadrian#define	ath_tx_draintxq(_sc, _txq)		\
138238931Sadrian	(_sc)->sc_tx.xmit_drainq((_sc), (_txq))
139238931Sadrian#define	ath_tx_processq(_sc, _txq, _dosched)	\
140238931Sadrian	(_sc)->sc_tx.xmit_processq((_sc), (_txq), (_dosched))
141238931Sadrian
142238710Sadrianextern	void ath_xmit_setup_legacy(struct ath_softc *sc);
143238710Sadrian
144218065Sadrian#endif
145