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: releng/10.2/sys/dev/ath/if_ath_tx.h 250866 2013-05-21 18:13:57Z 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 50250866Sadrian#define ATH_NONAGGR_MIN_QDEPTH 32 51227346Sadrian 52227346Sadrian/* 53227346Sadrian * Watermark for scheduling TIDs in order to maximise aggregation. 54227346Sadrian * 55227346Sadrian * If hwq_depth is greater than this, don't schedule the TID 56227346Sadrian * for packet scheduling - the hardware is already busy servicing 57227346Sadrian * this TID. 58227346Sadrian * 59227346Sadrian * If hwq_depth is less than this, schedule the TID for packet 60227346Sadrian * scheduling in the completion handler. 61227346Sadrian */ 62227346Sadrian#define ATH_AGGR_SCHED_HIGH 4 63227346Sadrian#define ATH_AGGR_SCHED_LOW 2 64227346Sadrian 65227364Sadrian/* 66227364Sadrian * return whether a bit at index _n in bitmap _bm is set 67227364Sadrian * _sz is the size of the bitmap 68227364Sadrian */ 69227364Sadrian#define ATH_BA_ISSET(_bm, _n) (((_n) < (WME_BA_BMP_SIZE)) && \ 70227364Sadrian ((_bm)[(_n) >> 5] & (1 << ((_n) & 31)))) 71227364Sadrian 72227364Sadrian 73227364Sadrian/* extracting the seqno from buffer seqno */ 74227364Sadrian#define SEQNO(_a) ((_a) >> IEEE80211_SEQ_SEQ_SHIFT) 75227364Sadrian 76227364Sadrian/* 77227364Sadrian * Whether the current sequence number is within the 78227364Sadrian * BAW. 79227364Sadrian */ 80227364Sadrian#define BAW_WITHIN(_start, _bawsz, _seqno) \ 81227364Sadrian ((((_seqno) - (_start)) & 4095) < (_bawsz)) 82227364Sadrian 83247085Sadrian/* 84247085Sadrian * Maximum aggregate size 85247085Sadrian */ 86247085Sadrian#define ATH_AGGR_MAXSIZE 65530 87247085Sadrian 88218065Sadrianextern void ath_freetx(struct mbuf *m); 89227364Sadrianextern void ath_tx_node_flush(struct ath_softc *sc, struct ath_node *an); 90227364Sadrianextern void ath_tx_txq_drain(struct ath_softc *sc, struct ath_txq *txq); 91218065Sadrianextern void ath_txfrag_cleanup(struct ath_softc *sc, ath_bufhead *frags, 92218065Sadrian struct ieee80211_node *ni); 93218065Sadrianextern int ath_txfrag_setup(struct ath_softc *sc, ath_bufhead *frags, 94218065Sadrian struct mbuf *m0, struct ieee80211_node *ni); 95218065Sadrianextern int ath_tx_start(struct ath_softc *sc, struct ieee80211_node *ni, 96218065Sadrian struct ath_buf *bf, struct mbuf *m0); 97218065Sadrianextern int ath_raw_xmit(struct ieee80211_node *ni, struct mbuf *m, 98218065Sadrian const struct ieee80211_bpf_params *params); 99218065Sadrian 100227364Sadrian/* software queue stuff */ 101227364Sadrianextern void ath_tx_swq(struct ath_softc *sc, struct ieee80211_node *ni, 102250665Sadrian struct ath_txq *txq, int queue_to_head, struct ath_buf *bf); 103227364Sadrianextern void ath_tx_tid_init(struct ath_softc *sc, struct ath_node *an); 104227364Sadrianextern void ath_tx_tid_hw_queue_aggr(struct ath_softc *sc, struct ath_node *an, 105227364Sadrian struct ath_tid *tid); 106227364Sadrianextern void ath_tx_tid_hw_queue_norm(struct ath_softc *sc, struct ath_node *an, 107227364Sadrian struct ath_tid *tid); 108227364Sadrianextern void ath_txq_sched(struct ath_softc *sc, struct ath_txq *txq); 109227364Sadrianextern void ath_tx_normal_comp(struct ath_softc *sc, struct ath_buf *bf, 110227364Sadrian int fail); 111227364Sadrianextern void ath_tx_aggr_comp(struct ath_softc *sc, struct ath_buf *bf, 112227364Sadrian int fail); 113227364Sadrianextern void ath_tx_addto_baw(struct ath_softc *sc, struct ath_node *an, 114227364Sadrian struct ath_tid *tid, struct ath_buf *bf); 115227364Sadrianextern struct ieee80211_tx_ampdu * ath_tx_get_tx_tid(struct ath_node *an, 116227364Sadrian int tid); 117250665Sadrianextern void ath_tx_tid_sched(struct ath_softc *sc, struct ath_tid *tid); 118227364Sadrian 119227364Sadrian/* TX addba handling */ 120227364Sadrianextern int ath_addba_request(struct ieee80211_node *ni, 121227364Sadrian struct ieee80211_tx_ampdu *tap, int dialogtoken, 122227364Sadrian int baparamset, int batimeout); 123227364Sadrianextern int ath_addba_response(struct ieee80211_node *ni, 124227364Sadrian struct ieee80211_tx_ampdu *tap, int dialogtoken, 125227364Sadrian int code, int batimeout); 126227364Sadrianextern void ath_addba_stop(struct ieee80211_node *ni, 127227364Sadrian struct ieee80211_tx_ampdu *tap); 128227364Sadrianextern void ath_bar_response(struct ieee80211_node *ni, 129227364Sadrian struct ieee80211_tx_ampdu *tap, int status); 130227364Sadrianextern void ath_addba_response_timeout(struct ieee80211_node *ni, 131227364Sadrian struct ieee80211_tx_ampdu *tap); 132227364Sadrian 133238710Sadrian/* 134241170Sadrian * AP mode power save handling (of stations) 135241170Sadrian */ 136241170Sadrianextern void ath_tx_node_sleep(struct ath_softc *sc, struct ath_node *an); 137241170Sadrianextern void ath_tx_node_wakeup(struct ath_softc *sc, struct ath_node *an); 138242271Sadrianextern int ath_tx_node_is_asleep(struct ath_softc *sc, struct ath_node *an); 139250608Sadrianextern void ath_tx_node_reassoc(struct ath_softc *sc, struct ath_node *an); 140241170Sadrian 141241170Sadrian/* 142250665Sadrian * Hardware queue stuff 143250665Sadrian */ 144250665Sadrianextern void ath_tx_push_pending(struct ath_softc *sc, struct ath_txq *txq); 145250665Sadrian 146250665Sadrian/* 147243162Sadrian * Misc debugging stuff 148243162Sadrian */ 149243162Sadrian#ifdef ATH_DEBUG_ALQ 150243162Sadrianextern void ath_tx_alq_post(struct ath_softc *sc, struct ath_buf *bf_first); 151243162Sadrian#endif /* ATH_DEBUG_ALQ */ 152243162Sadrian 153243162Sadrian/* 154238710Sadrian * Setup path 155238710Sadrian */ 156238710Sadrian#define ath_txdma_setup(_sc) \ 157238710Sadrian (_sc)->sc_tx.xmit_setup(_sc) 158238710Sadrian#define ath_txdma_teardown(_sc) \ 159238710Sadrian (_sc)->sc_tx.xmit_teardown(_sc) 160238930Sadrian#define ath_txq_restart_dma(_sc, _txq) \ 161238930Sadrian (_sc)->sc_tx.xmit_dma_restart((_sc), (_txq)) 162238930Sadrian#define ath_tx_handoff(_sc, _txq, _bf) \ 163238930Sadrian (_sc)->sc_tx.xmit_handoff((_sc), (_txq), (_bf)) 164239204Sadrian#define ath_draintxq(_sc, _rtype) \ 165239204Sadrian (_sc)->sc_tx.xmit_drain((_sc), (_rtype)) 166238931Sadrian 167238710Sadrianextern void ath_xmit_setup_legacy(struct ath_softc *sc); 168238710Sadrian 169218065Sadrian#endif 170