1b8e788a5SAdrian Chadd /*- 2*4d846d26SWarner Losh * SPDX-License-Identifier: BSD-2-Clause 3718cf2ccSPedro F. Giffuni * 4b8e788a5SAdrian Chadd * Copyright (c) 2002-2009 Sam Leffler, Errno Consulting 5b8e788a5SAdrian Chadd * All rights reserved. 6b8e788a5SAdrian Chadd * 7b8e788a5SAdrian Chadd * Redistribution and use in source and binary forms, with or without 8b8e788a5SAdrian Chadd * modification, are permitted provided that the following conditions 9b8e788a5SAdrian Chadd * are met: 10b8e788a5SAdrian Chadd * 1. Redistributions of source code must retain the above copyright 11b8e788a5SAdrian Chadd * notice, this list of conditions and the following disclaimer, 12b8e788a5SAdrian Chadd * without modification. 13b8e788a5SAdrian Chadd * 2. Redistributions in binary form must reproduce at minimum a disclaimer 14b8e788a5SAdrian Chadd * similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any 15b8e788a5SAdrian Chadd * redistribution must be conditioned upon including a substantially 16b8e788a5SAdrian Chadd * similar Disclaimer requirement for further binary redistribution. 17b8e788a5SAdrian Chadd * 18b8e788a5SAdrian Chadd * NO WARRANTY 19b8e788a5SAdrian Chadd * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20b8e788a5SAdrian Chadd * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21b8e788a5SAdrian Chadd * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY 22b8e788a5SAdrian Chadd * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 23b8e788a5SAdrian Chadd * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, 24b8e788a5SAdrian Chadd * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25b8e788a5SAdrian Chadd * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26b8e788a5SAdrian Chadd * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 27b8e788a5SAdrian Chadd * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28b8e788a5SAdrian Chadd * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 29b8e788a5SAdrian Chadd * THE POSSIBILITY OF SUCH DAMAGES. 30b8e788a5SAdrian Chadd */ 31b8e788a5SAdrian Chadd #ifndef __IF_ATH_TX_H__ 32b8e788a5SAdrian Chadd #define __IF_ATH_TX_H__ 33b8e788a5SAdrian Chadd 348f939e79SAdrian Chadd /* 35eb6f0de0SAdrian Chadd * some general macros 36eb6f0de0SAdrian Chadd */ 37eb6f0de0SAdrian Chadd #define INCR(_l, _sz) (_l) ++; (_l) &= ((_sz) - 1) 38eb6f0de0SAdrian Chadd /* 39eb6f0de0SAdrian Chadd * return block-ack bitmap index given sequence and starting sequence 40eb6f0de0SAdrian Chadd */ 41eb6f0de0SAdrian Chadd #define ATH_BA_INDEX(_st, _seq) (((_seq) - (_st)) & (IEEE80211_SEQ_RANGE - 1)) 42eb6f0de0SAdrian Chadd 43eb6f0de0SAdrian Chadd #define WME_BA_BMP_SIZE 64 44eb6f0de0SAdrian Chadd #define WME_MAX_BA WME_BA_BMP_SIZE 45eb6f0de0SAdrian Chadd 46eb6f0de0SAdrian Chadd /* 478f939e79SAdrian Chadd * How 'busy' to try and keep the hardware txq 488f939e79SAdrian Chadd */ 498f939e79SAdrian Chadd #define ATH_AGGR_MIN_QDEPTH 2 5072910f03SAdrian Chadd #define ATH_NONAGGR_MIN_QDEPTH 32 518f939e79SAdrian Chadd 528f939e79SAdrian Chadd /* 538f939e79SAdrian Chadd * Watermark for scheduling TIDs in order to maximise aggregation. 548f939e79SAdrian Chadd * 558f939e79SAdrian Chadd * If hwq_depth is greater than this, don't schedule the TID 568f939e79SAdrian Chadd * for packet scheduling - the hardware is already busy servicing 578f939e79SAdrian Chadd * this TID. 588f939e79SAdrian Chadd * 598f939e79SAdrian Chadd * If hwq_depth is less than this, schedule the TID for packet 608f939e79SAdrian Chadd * scheduling in the completion handler. 618f939e79SAdrian Chadd */ 628f939e79SAdrian Chadd #define ATH_AGGR_SCHED_HIGH 4 638f939e79SAdrian Chadd #define ATH_AGGR_SCHED_LOW 2 648f939e79SAdrian Chadd 65eb6f0de0SAdrian Chadd /* 66eb6f0de0SAdrian Chadd * return whether a bit at index _n in bitmap _bm is set 67eb6f0de0SAdrian Chadd * _sz is the size of the bitmap 68eb6f0de0SAdrian Chadd */ 69eb6f0de0SAdrian Chadd #define ATH_BA_ISSET(_bm, _n) (((_n) < (WME_BA_BMP_SIZE)) && \ 70eb6f0de0SAdrian Chadd ((_bm)[(_n) >> 5] & (1 << ((_n) & 31)))) 71eb6f0de0SAdrian Chadd 72eb6f0de0SAdrian Chadd /* extracting the seqno from buffer seqno */ 73eb6f0de0SAdrian Chadd #define SEQNO(_a) ((_a) >> IEEE80211_SEQ_SEQ_SHIFT) 74eb6f0de0SAdrian Chadd 75eb6f0de0SAdrian Chadd /* 76eb6f0de0SAdrian Chadd * Whether the current sequence number is within the 77eb6f0de0SAdrian Chadd * BAW. 78eb6f0de0SAdrian Chadd */ 79eb6f0de0SAdrian Chadd #define BAW_WITHIN(_start, _bawsz, _seqno) \ 80eb6f0de0SAdrian Chadd ((((_seqno) - (_start)) & 4095) < (_bawsz)) 81eb6f0de0SAdrian Chadd 824a502c33SAdrian Chadd /* 834a502c33SAdrian Chadd * Maximum aggregate size 844a502c33SAdrian Chadd */ 854a502c33SAdrian Chadd #define ATH_AGGR_MAXSIZE 65530 864a502c33SAdrian Chadd 87eb6f0de0SAdrian Chadd extern void ath_tx_node_flush(struct ath_softc *sc, struct ath_node *an); 88eb6f0de0SAdrian Chadd extern void ath_tx_txq_drain(struct ath_softc *sc, struct ath_txq *txq); 89b8e788a5SAdrian Chadd extern void ath_txfrag_cleanup(struct ath_softc *sc, ath_bufhead *frags, 90b8e788a5SAdrian Chadd struct ieee80211_node *ni); 91b8e788a5SAdrian Chadd extern int ath_txfrag_setup(struct ath_softc *sc, ath_bufhead *frags, 92b8e788a5SAdrian Chadd struct mbuf *m0, struct ieee80211_node *ni); 93b8e788a5SAdrian Chadd extern int ath_tx_start(struct ath_softc *sc, struct ieee80211_node *ni, 94b8e788a5SAdrian Chadd struct ath_buf *bf, struct mbuf *m0); 95b8e788a5SAdrian Chadd extern int ath_raw_xmit(struct ieee80211_node *ni, struct mbuf *m, 96b8e788a5SAdrian Chadd const struct ieee80211_bpf_params *params); 97b8e788a5SAdrian Chadd 98eb6f0de0SAdrian Chadd /* software queue stuff */ 99eb6f0de0SAdrian Chadd extern void ath_tx_swq(struct ath_softc *sc, struct ieee80211_node *ni, 10022a3aee6SAdrian Chadd struct ath_txq *txq, int queue_to_head, struct ath_buf *bf); 101eb6f0de0SAdrian Chadd extern void ath_tx_tid_init(struct ath_softc *sc, struct ath_node *an); 102eb6f0de0SAdrian Chadd extern void ath_tx_tid_hw_queue_aggr(struct ath_softc *sc, struct ath_node *an, 103eb6f0de0SAdrian Chadd struct ath_tid *tid); 104eb6f0de0SAdrian Chadd extern void ath_tx_tid_hw_queue_norm(struct ath_softc *sc, struct ath_node *an, 105eb6f0de0SAdrian Chadd struct ath_tid *tid); 106eb6f0de0SAdrian Chadd extern void ath_txq_sched(struct ath_softc *sc, struct ath_txq *txq); 107eb6f0de0SAdrian Chadd extern void ath_tx_normal_comp(struct ath_softc *sc, struct ath_buf *bf, 108eb6f0de0SAdrian Chadd int fail); 109eb6f0de0SAdrian Chadd extern void ath_tx_aggr_comp(struct ath_softc *sc, struct ath_buf *bf, 110eb6f0de0SAdrian Chadd int fail); 111eb6f0de0SAdrian Chadd extern void ath_tx_addto_baw(struct ath_softc *sc, struct ath_node *an, 112eb6f0de0SAdrian Chadd struct ath_tid *tid, struct ath_buf *bf); 113eb6f0de0SAdrian Chadd extern struct ieee80211_tx_ampdu * ath_tx_get_tx_tid(struct ath_node *an, 114eb6f0de0SAdrian Chadd int tid); 11522a3aee6SAdrian Chadd extern void ath_tx_tid_sched(struct ath_softc *sc, struct ath_tid *tid); 116eb6f0de0SAdrian Chadd 117eb6f0de0SAdrian Chadd /* TX addba handling */ 118eb6f0de0SAdrian Chadd extern int ath_addba_request(struct ieee80211_node *ni, 119eb6f0de0SAdrian Chadd struct ieee80211_tx_ampdu *tap, int dialogtoken, 120eb6f0de0SAdrian Chadd int baparamset, int batimeout); 121eb6f0de0SAdrian Chadd extern int ath_addba_response(struct ieee80211_node *ni, 122eb6f0de0SAdrian Chadd struct ieee80211_tx_ampdu *tap, int dialogtoken, 123eb6f0de0SAdrian Chadd int code, int batimeout); 124eb6f0de0SAdrian Chadd extern void ath_addba_stop(struct ieee80211_node *ni, 125eb6f0de0SAdrian Chadd struct ieee80211_tx_ampdu *tap); 126eb6f0de0SAdrian Chadd extern void ath_bar_response(struct ieee80211_node *ni, 127eb6f0de0SAdrian Chadd struct ieee80211_tx_ampdu *tap, int status); 128eb6f0de0SAdrian Chadd extern void ath_addba_response_timeout(struct ieee80211_node *ni, 129eb6f0de0SAdrian Chadd struct ieee80211_tx_ampdu *tap); 130eb6f0de0SAdrian Chadd 1313fdfc330SAdrian Chadd /* 1320eb81626SAdrian Chadd * AP mode power save handling (of stations) 1330eb81626SAdrian Chadd */ 1340eb81626SAdrian Chadd extern void ath_tx_node_sleep(struct ath_softc *sc, struct ath_node *an); 1350eb81626SAdrian Chadd extern void ath_tx_node_wakeup(struct ath_softc *sc, struct ath_node *an); 136548a605dSAdrian Chadd extern int ath_tx_node_is_asleep(struct ath_softc *sc, struct ath_node *an); 13722780332SAdrian Chadd extern void ath_tx_node_reassoc(struct ath_softc *sc, struct ath_node *an); 1380eb81626SAdrian Chadd 1390eb81626SAdrian Chadd /* 14022a3aee6SAdrian Chadd * Hardware queue stuff 14122a3aee6SAdrian Chadd */ 14222a3aee6SAdrian Chadd extern void ath_tx_push_pending(struct ath_softc *sc, struct ath_txq *txq); 14322a3aee6SAdrian Chadd 14422a3aee6SAdrian Chadd /* 145bb327d28SAdrian Chadd * Misc debugging stuff 146bb327d28SAdrian Chadd */ 147bb327d28SAdrian Chadd #ifdef ATH_DEBUG_ALQ 148bb327d28SAdrian Chadd extern void ath_tx_alq_post(struct ath_softc *sc, struct ath_buf *bf_first); 149bb327d28SAdrian Chadd #endif /* ATH_DEBUG_ALQ */ 150bb327d28SAdrian Chadd 151bb327d28SAdrian Chadd /* 1523fdfc330SAdrian Chadd * Setup path 1533fdfc330SAdrian Chadd */ 1543fdfc330SAdrian Chadd #define ath_txdma_setup(_sc) \ 1553fdfc330SAdrian Chadd (_sc)->sc_tx.xmit_setup(_sc) 1563fdfc330SAdrian Chadd #define ath_txdma_teardown(_sc) \ 1573fdfc330SAdrian Chadd (_sc)->sc_tx.xmit_teardown(_sc) 158746bab5bSAdrian Chadd #define ath_txq_restart_dma(_sc, _txq) \ 159746bab5bSAdrian Chadd (_sc)->sc_tx.xmit_dma_restart((_sc), (_txq)) 160746bab5bSAdrian Chadd #define ath_tx_handoff(_sc, _txq, _bf) \ 161746bab5bSAdrian Chadd (_sc)->sc_tx.xmit_handoff((_sc), (_txq), (_bf)) 162788e6aa9SAdrian Chadd #define ath_draintxq(_sc, _rtype) \ 163788e6aa9SAdrian Chadd (_sc)->sc_tx.xmit_drain((_sc), (_rtype)) 164f8418db5SAdrian Chadd 1653fdfc330SAdrian Chadd extern void ath_xmit_setup_legacy(struct ath_softc *sc); 1663fdfc330SAdrian Chadd 167b8e788a5SAdrian Chadd #endif 168