if_ath_tx.h revision 247085
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 247085 2013-02-21 06:18:40Z 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 82247085Sadrian/* 83247085Sadrian * Maximum aggregate size 84247085Sadrian */ 85247085Sadrian#define ATH_AGGR_MAXSIZE 65530 86247085Sadrian 87218065Sadrianextern void ath_freetx(struct mbuf *m); 88227364Sadrianextern void ath_tx_node_flush(struct ath_softc *sc, struct ath_node *an); 89227364Sadrianextern void ath_tx_txq_drain(struct ath_softc *sc, struct ath_txq *txq); 90218065Sadrianextern void ath_txfrag_cleanup(struct ath_softc *sc, ath_bufhead *frags, 91218065Sadrian struct ieee80211_node *ni); 92218065Sadrianextern int ath_txfrag_setup(struct ath_softc *sc, ath_bufhead *frags, 93218065Sadrian struct mbuf *m0, struct ieee80211_node *ni); 94218065Sadrianextern int ath_tx_start(struct ath_softc *sc, struct ieee80211_node *ni, 95218065Sadrian struct ath_buf *bf, struct mbuf *m0); 96218065Sadrianextern int ath_raw_xmit(struct ieee80211_node *ni, struct mbuf *m, 97218065Sadrian const struct ieee80211_bpf_params *params); 98218065Sadrian 99227364Sadrian/* software queue stuff */ 100227364Sadrianextern void ath_tx_swq(struct ath_softc *sc, struct ieee80211_node *ni, 101227364Sadrian struct ath_txq *txq, struct ath_buf *bf); 102227364Sadrianextern void ath_tx_tid_init(struct ath_softc *sc, struct ath_node *an); 103227364Sadrianextern void ath_tx_tid_hw_queue_aggr(struct ath_softc *sc, struct ath_node *an, 104227364Sadrian struct ath_tid *tid); 105227364Sadrianextern void ath_tx_tid_hw_queue_norm(struct ath_softc *sc, struct ath_node *an, 106227364Sadrian struct ath_tid *tid); 107227364Sadrianextern void ath_txq_sched(struct ath_softc *sc, struct ath_txq *txq); 108227364Sadrianextern void ath_tx_normal_comp(struct ath_softc *sc, struct ath_buf *bf, 109227364Sadrian int fail); 110227364Sadrianextern void ath_tx_aggr_comp(struct ath_softc *sc, struct ath_buf *bf, 111227364Sadrian int fail); 112227364Sadrianextern void ath_tx_addto_baw(struct ath_softc *sc, struct ath_node *an, 113227364Sadrian struct ath_tid *tid, struct ath_buf *bf); 114227364Sadrianextern struct ieee80211_tx_ampdu * ath_tx_get_tx_tid(struct ath_node *an, 115227364Sadrian int tid); 116227364Sadrian 117227364Sadrian/* TX addba handling */ 118227364Sadrianextern int ath_addba_request(struct ieee80211_node *ni, 119227364Sadrian struct ieee80211_tx_ampdu *tap, int dialogtoken, 120227364Sadrian int baparamset, int batimeout); 121227364Sadrianextern int ath_addba_response(struct ieee80211_node *ni, 122227364Sadrian struct ieee80211_tx_ampdu *tap, int dialogtoken, 123227364Sadrian int code, int batimeout); 124227364Sadrianextern void ath_addba_stop(struct ieee80211_node *ni, 125227364Sadrian struct ieee80211_tx_ampdu *tap); 126227364Sadrianextern void ath_bar_response(struct ieee80211_node *ni, 127227364Sadrian struct ieee80211_tx_ampdu *tap, int status); 128227364Sadrianextern void ath_addba_response_timeout(struct ieee80211_node *ni, 129227364Sadrian struct ieee80211_tx_ampdu *tap); 130227364Sadrian 131238710Sadrian/* 132241170Sadrian * AP mode power save handling (of stations) 133241170Sadrian */ 134241170Sadrianextern void ath_tx_node_sleep(struct ath_softc *sc, struct ath_node *an); 135241170Sadrianextern void ath_tx_node_wakeup(struct ath_softc *sc, struct ath_node *an); 136242271Sadrianextern int ath_tx_node_is_asleep(struct ath_softc *sc, struct ath_node *an); 137241170Sadrian 138241170Sadrian/* 139243162Sadrian * Misc debugging stuff 140243162Sadrian */ 141243162Sadrian#ifdef ATH_DEBUG_ALQ 142243162Sadrianextern void ath_tx_alq_post(struct ath_softc *sc, struct ath_buf *bf_first); 143243162Sadrian#endif /* ATH_DEBUG_ALQ */ 144243162Sadrian 145243162Sadrian/* 146238710Sadrian * Setup path 147238710Sadrian */ 148238710Sadrian#define ath_txdma_setup(_sc) \ 149238710Sadrian (_sc)->sc_tx.xmit_setup(_sc) 150238710Sadrian#define ath_txdma_teardown(_sc) \ 151238710Sadrian (_sc)->sc_tx.xmit_teardown(_sc) 152238930Sadrian#define ath_txq_restart_dma(_sc, _txq) \ 153238930Sadrian (_sc)->sc_tx.xmit_dma_restart((_sc), (_txq)) 154238930Sadrian#define ath_tx_handoff(_sc, _txq, _bf) \ 155238930Sadrian (_sc)->sc_tx.xmit_handoff((_sc), (_txq), (_bf)) 156239204Sadrian#define ath_draintxq(_sc, _rtype) \ 157239204Sadrian (_sc)->sc_tx.xmit_drain((_sc), (_rtype)) 158238931Sadrian 159238710Sadrianextern void ath_xmit_setup_legacy(struct ath_softc *sc); 160238710Sadrian 161218065Sadrian#endif 162