if_ath_tx.h revision 227364
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 227364 2011-11-08 22:43:13Z 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
82227364Sadrianextern void ath_txq_restart_dma(struct ath_softc *sc, struct ath_txq *txq);
83218065Sadrianextern void ath_freetx(struct mbuf *m);
84227364Sadrianextern void ath_tx_node_flush(struct ath_softc *sc, struct ath_node *an);
85227364Sadrianextern void ath_tx_txq_drain(struct ath_softc *sc, struct ath_txq *txq);
86218065Sadrianextern void ath_txfrag_cleanup(struct ath_softc *sc, ath_bufhead *frags,
87218065Sadrian    struct ieee80211_node *ni);
88218065Sadrianextern int ath_txfrag_setup(struct ath_softc *sc, ath_bufhead *frags,
89218065Sadrian    struct mbuf *m0, struct ieee80211_node *ni);
90218065Sadrianextern int ath_tx_start(struct ath_softc *sc, struct ieee80211_node *ni,
91218065Sadrian    struct ath_buf *bf, struct mbuf *m0);
92218065Sadrianextern int ath_raw_xmit(struct ieee80211_node *ni, struct mbuf *m,
93218065Sadrian    const struct ieee80211_bpf_params *params);
94218065Sadrian
95227364Sadrian/* software queue stuff */
96227364Sadrianextern void ath_tx_swq(struct ath_softc *sc, struct ieee80211_node *ni,
97227364Sadrian    struct ath_txq *txq, struct ath_buf *bf);
98227364Sadrianextern void ath_tx_tid_init(struct ath_softc *sc, struct ath_node *an);
99227364Sadrianextern void ath_tx_tid_hw_queue_aggr(struct ath_softc *sc, struct ath_node *an,
100227364Sadrian    struct ath_tid *tid);
101227364Sadrianextern void ath_tx_tid_hw_queue_norm(struct ath_softc *sc, struct ath_node *an,
102227364Sadrian    struct ath_tid *tid);
103227364Sadrianextern void ath_txq_sched(struct ath_softc *sc, struct ath_txq *txq);
104227364Sadrianextern void ath_tx_normal_comp(struct ath_softc *sc, struct ath_buf *bf,
105227364Sadrian    int fail);
106227364Sadrianextern void ath_tx_aggr_comp(struct ath_softc *sc, struct ath_buf *bf,
107227364Sadrian    int fail);
108227364Sadrianextern void ath_tx_addto_baw(struct ath_softc *sc, struct ath_node *an,
109227364Sadrian    struct ath_tid *tid, struct ath_buf *bf);
110227364Sadrianextern struct ieee80211_tx_ampdu * ath_tx_get_tx_tid(struct ath_node *an,
111227364Sadrian    int tid);
112227364Sadrian
113227364Sadrian/* TX addba handling */
114227364Sadrianextern	int ath_addba_request(struct ieee80211_node *ni,
115227364Sadrian    struct ieee80211_tx_ampdu *tap, int dialogtoken,
116227364Sadrian    int baparamset, int batimeout);
117227364Sadrianextern	int ath_addba_response(struct ieee80211_node *ni,
118227364Sadrian    struct ieee80211_tx_ampdu *tap, int dialogtoken,
119227364Sadrian    int code, int batimeout);
120227364Sadrianextern	void ath_addba_stop(struct ieee80211_node *ni,
121227364Sadrian    struct ieee80211_tx_ampdu *tap);
122227364Sadrianextern	void ath_bar_response(struct ieee80211_node *ni,
123227364Sadrian     struct ieee80211_tx_ampdu *tap, int status);
124227364Sadrianextern	void ath_addba_response_timeout(struct ieee80211_node *ni,
125227364Sadrian    struct ieee80211_tx_ampdu *tap);
126227364Sadrian
127218065Sadrian#endif
128