if_ath_tx.h revision 250665
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 250665 2013-05-15 18:33:05Z 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, 101250665Sadrian struct ath_txq *txq, int queue_to_head, 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); 116250665Sadrianextern void ath_tx_tid_sched(struct ath_softc *sc, struct ath_tid *tid); 117227364Sadrian 118227364Sadrian/* TX addba handling */ 119227364Sadrianextern int ath_addba_request(struct ieee80211_node *ni, 120227364Sadrian struct ieee80211_tx_ampdu *tap, int dialogtoken, 121227364Sadrian int baparamset, int batimeout); 122227364Sadrianextern int ath_addba_response(struct ieee80211_node *ni, 123227364Sadrian struct ieee80211_tx_ampdu *tap, int dialogtoken, 124227364Sadrian int code, int batimeout); 125227364Sadrianextern void ath_addba_stop(struct ieee80211_node *ni, 126227364Sadrian struct ieee80211_tx_ampdu *tap); 127227364Sadrianextern void ath_bar_response(struct ieee80211_node *ni, 128227364Sadrian struct ieee80211_tx_ampdu *tap, int status); 129227364Sadrianextern void ath_addba_response_timeout(struct ieee80211_node *ni, 130227364Sadrian struct ieee80211_tx_ampdu *tap); 131227364Sadrian 132238710Sadrian/* 133241170Sadrian * AP mode power save handling (of stations) 134241170Sadrian */ 135241170Sadrianextern void ath_tx_node_sleep(struct ath_softc *sc, struct ath_node *an); 136241170Sadrianextern void ath_tx_node_wakeup(struct ath_softc *sc, struct ath_node *an); 137242271Sadrianextern int ath_tx_node_is_asleep(struct ath_softc *sc, struct ath_node *an); 138250608Sadrianextern void ath_tx_node_reassoc(struct ath_softc *sc, struct ath_node *an); 139241170Sadrian 140241170Sadrian/* 141250665Sadrian * Hardware queue stuff 142250665Sadrian */ 143250665Sadrianextern void ath_tx_push_pending(struct ath_softc *sc, struct ath_txq *txq); 144250665Sadrian 145250665Sadrian/* 146243162Sadrian * Misc debugging stuff 147243162Sadrian */ 148243162Sadrian#ifdef ATH_DEBUG_ALQ 149243162Sadrianextern void ath_tx_alq_post(struct ath_softc *sc, struct ath_buf *bf_first); 150243162Sadrian#endif /* ATH_DEBUG_ALQ */ 151243162Sadrian 152243162Sadrian/* 153238710Sadrian * Setup path 154238710Sadrian */ 155238710Sadrian#define ath_txdma_setup(_sc) \ 156238710Sadrian (_sc)->sc_tx.xmit_setup(_sc) 157238710Sadrian#define ath_txdma_teardown(_sc) \ 158238710Sadrian (_sc)->sc_tx.xmit_teardown(_sc) 159238930Sadrian#define ath_txq_restart_dma(_sc, _txq) \ 160238930Sadrian (_sc)->sc_tx.xmit_dma_restart((_sc), (_txq)) 161238930Sadrian#define ath_tx_handoff(_sc, _txq, _bf) \ 162238930Sadrian (_sc)->sc_tx.xmit_handoff((_sc), (_txq), (_bf)) 163239204Sadrian#define ath_draintxq(_sc, _rtype) \ 164239204Sadrian (_sc)->sc_tx.xmit_drain((_sc), (_rtype)) 165238931Sadrian 166238710Sadrianextern void ath_xmit_setup_legacy(struct ath_softc *sc); 167238710Sadrian 168218065Sadrian#endif 169