if_ath_tx.h revision 241170
18870Srgrimes/*- 250476Speter * Copyright (c) 2002-2009 Sam Leffler, Errno Consulting 38870Srgrimes * All rights reserved. 42116Sjkh * 52116Sjkh * Redistribution and use in source and binary forms, with or without 68870Srgrimes * modification, are permitted provided that the following conditions 72116Sjkh * are met: 82116Sjkh * 1. Redistributions of source code must retain the above copyright 98870Srgrimes * notice, this list of conditions and the following disclaimer, 102116Sjkh * without modification. 112116Sjkh * 2. Redistributions in binary form must reproduce at minimum a disclaimer 128870Srgrimes * similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any 138870Srgrimes * redistribution must be conditioned upon including a substantially 142116Sjkh * similar Disclaimer requirement for further binary redistribution. 152116Sjkh * 162116Sjkh * NO WARRANTY 172116Sjkh * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 188870Srgrimes * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 198870Srgrimes * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY 2087804Sphantom * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 212116Sjkh * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, 222116Sjkh * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 232116Sjkh * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 242116Sjkh * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 252116Sjkh * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 268870Srgrimes * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 272116Sjkh * THE POSSIBILITY OF SUCH DAMAGES. 282116Sjkh * 292116Sjkh * $FreeBSD: head/sys/dev/ath/if_ath_tx.h 241170 2012-10-03 23:23:45Z adrian $ 302116Sjkh */ 318870Srgrimes#ifndef __IF_ATH_TX_H__ 322116Sjkh#define __IF_ATH_TX_H__ 332116Sjkh 348870Srgrimes/* 352116Sjkh * some general macros 362116Sjkh */ 378870Srgrimes#define INCR(_l, _sz) (_l) ++; (_l) &= ((_sz) - 1) 382116Sjkh/* 392116Sjkh * return block-ack bitmap index given sequence and starting sequence 408870Srgrimes */ 412116Sjkh#define ATH_BA_INDEX(_st, _seq) (((_seq) - (_st)) & (IEEE80211_SEQ_RANGE - 1)) 428870Srgrimes 432116Sjkh#define WME_BA_BMP_SIZE 64 4433662Sjb#define WME_MAX_BA WME_BA_BMP_SIZE 4533662Sjb 4633662Sjb/* 4733662Sjb * How 'busy' to try and keep the hardware txq 4833662Sjb */ 4942044Sdfr#define ATH_AGGR_MIN_QDEPTH 2 5042044Sdfr 5133662Sjb/* 5222808Sbde * Watermark for scheduling TIDs in order to maximise aggregation. 532116Sjkh * 542116Sjkh * If hwq_depth is greater than this, don't schedule the TID 5522731Sbde * for packet scheduling - the hardware is already busy servicing 562116Sjkh * this TID. 57117917Sbde * 58117917Sbde * If hwq_depth is less than this, schedule the TID for packet 5933662Sjb * scheduling in the completion handler. 602116Sjkh */ 61130149Sdas#define ATH_AGGR_SCHED_HIGH 4 62130149Sdas#define ATH_AGGR_SCHED_LOW 2 6393211Sbde 642116Sjkh/* 652116Sjkh * return whether a bit at index _n in bitmap _bm is set 662116Sjkh * _sz is the size of the bitmap 67117909Speter */ 682116Sjkh#define ATH_BA_ISSET(_bm, _n) (((_n) < (WME_BA_BMP_SIZE)) && \ 692116Sjkh ((_bm)[(_n) >> 5] & (1 << ((_n) & 31)))) 70119017Sgordon 7193211Sbde 7293211Sbde/* extracting the seqno from buffer seqno */ 732116Sjkh#define SEQNO(_a) ((_a) >> IEEE80211_SEQ_SEQ_SHIFT) 742116Sjkh 752116Sjkh/* 762116Sjkh * Whether the current sequence number is within the 772116Sjkh * BAW. 782116Sjkh */ 79130149Sdas#define BAW_WITHIN(_start, _bawsz, _seqno) \ 802116Sjkh ((((_seqno) - (_start)) & 4095) < (_bawsz)) 812116Sjkh 822116Sjkhextern void ath_freetx(struct mbuf *m); 832116Sjkhextern void ath_tx_node_flush(struct ath_softc *sc, struct ath_node *an); 842116Sjkhextern void ath_tx_txq_drain(struct ath_softc *sc, struct ath_txq *txq); 8591514Sobrienextern void ath_txfrag_cleanup(struct ath_softc *sc, ath_bufhead *frags, 862116Sjkh struct ieee80211_node *ni); 872116Sjkhextern int ath_txfrag_setup(struct ath_softc *sc, ath_bufhead *frags, 882116Sjkh struct mbuf *m0, struct ieee80211_node *ni); 892116Sjkhextern int ath_tx_start(struct ath_softc *sc, struct ieee80211_node *ni, 902116Sjkh struct ath_buf *bf, struct mbuf *m0); 912116Sjkhextern int ath_raw_xmit(struct ieee80211_node *ni, struct mbuf *m, 922116Sjkh const struct ieee80211_bpf_params *params); 932116Sjkh 942116Sjkh/* software queue stuff */ 952116Sjkhextern void ath_tx_swq(struct ath_softc *sc, struct ieee80211_node *ni, 962116Sjkh struct ath_txq *txq, struct ath_buf *bf); 972116Sjkhextern void ath_tx_tid_init(struct ath_softc *sc, struct ath_node *an); 9822948Sbdeextern void ath_tx_tid_hw_queue_aggr(struct ath_softc *sc, struct ath_node *an, 9922948Sbde struct ath_tid *tid); 1002116Sjkhextern void ath_tx_tid_hw_queue_norm(struct ath_softc *sc, struct ath_node *an, 101121497Sdes struct ath_tid *tid); 102121497Sdesextern void ath_txq_sched(struct ath_softc *sc, struct ath_txq *txq); 103121497Sdesextern void ath_tx_normal_comp(struct ath_softc *sc, struct ath_buf *bf, 104121497Sdes int fail); 105121497Sdesextern void ath_tx_aggr_comp(struct ath_softc *sc, struct ath_buf *bf, 106129040Sstefanf int fail); 107121497Sdesextern void ath_tx_addto_baw(struct ath_softc *sc, struct ath_node *an, 108129864Sstefanf struct ath_tid *tid, struct ath_buf *bf); 109129864Sstefanfextern struct ieee80211_tx_ampdu * ath_tx_get_tx_tid(struct ath_node *an, 110129864Sstefanf int tid); 111129864Sstefanf 1122116Sjkh/* TX addba handling */ 1132116Sjkhextern int ath_addba_request(struct ieee80211_node *ni, 1142116Sjkh struct ieee80211_tx_ampdu *tap, int dialogtoken, 115117912Speter int baparamset, int batimeout); 116130149Sdasextern int ath_addba_response(struct ieee80211_node *ni, 117117912Speter struct ieee80211_tx_ampdu *tap, int dialogtoken, 1186953Sbde int code, int batimeout); 119117912Speterextern void ath_addba_stop(struct ieee80211_node *ni, 1206953Sbde struct ieee80211_tx_ampdu *tap); 121117912Speterextern void ath_bar_response(struct ieee80211_node *ni, 1226953Sbde struct ieee80211_tx_ampdu *tap, int status); 123117912Speterextern void ath_addba_response_timeout(struct ieee80211_node *ni, 124117912Speter struct ieee80211_tx_ampdu *tap); 125130149Sdas 12696462Sru/* 12774870Sru * AP mode power save handling (of stations) 128130149Sdas */ 129130149Sdasextern void ath_tx_node_sleep(struct ath_softc *sc, struct ath_node *an); 13011682Sbdeextern void ath_tx_node_wakeup(struct ath_softc *sc, struct ath_node *an); 13111682Sbde 13211682Sbde/* 13313987Smpp * Setup path 13413987Smpp */ 13513987Smpp#define ath_txdma_setup(_sc) \ 13613987Smpp (_sc)->sc_tx.xmit_setup(_sc) 13713987Smpp#define ath_txdma_teardown(_sc) \ 13813987Smpp (_sc)->sc_tx.xmit_teardown(_sc) 13913987Smpp#define ath_txq_restart_dma(_sc, _txq) \ 14013987Smpp (_sc)->sc_tx.xmit_dma_restart((_sc), (_txq)) 14113987Smpp#define ath_tx_handoff(_sc, _txq, _bf) \ 14213987Smpp (_sc)->sc_tx.xmit_handoff((_sc), (_txq), (_bf)) 14313987Smpp#define ath_draintxq(_sc, _rtype) \ 14413987Smpp (_sc)->sc_tx.xmit_drain((_sc), (_rtype)) 14584403Sbde 14684403Sbdeextern void ath_xmit_setup_legacy(struct ath_softc *sc); 14713987Smpp 148129038Sstefanf#endif 149130149Sdas