Deleted Added
full compact
if_ath_tx.c (243647) if_ath_tx.c (243786)
1/*-
2 * Copyright (c) 2002-2009 Sam Leffler, Errno Consulting
3 * Copyright (c) 2010-2012 Adrian Chadd, Xenion Pty Ltd
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 15 unchanged lines hidden (view full) ---

24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
26 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
28 * THE POSSIBILITY OF SUCH DAMAGES.
29 */
30
31#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2002-2009 Sam Leffler, Errno Consulting
3 * Copyright (c) 2010-2012 Adrian Chadd, Xenion Pty Ltd
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 15 unchanged lines hidden (view full) ---

24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
26 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
28 * THE POSSIBILITY OF SUCH DAMAGES.
29 */
30
31#include <sys/cdefs.h>
32__FBSDID("$FreeBSD: head/sys/dev/ath/if_ath_tx.c 243647 2012-11-28 06:55:34Z adrian $");
32__FBSDID("$FreeBSD: head/sys/dev/ath/if_ath_tx.c 243786 2012-12-02 06:24:08Z adrian $");
33
34/*
35 * Driver for the Atheros Wireless LAN controller.
36 *
37 * This software is derived from work of Atsushi Onoe; his contribution
38 * is greatly appreciated.
39 */
40

--- 662 unchanged lines hidden (view full) ---

703 * XXX It may not be a bad idea to just stuff the QCU ID into bf_state
704 * and retire bfs_txq; then make sure the CABQ QCU ID is populated
705 * correctly.
706 */
707static void
708ath_tx_handoff_mcast(struct ath_softc *sc, struct ath_txq *txq,
709 struct ath_buf *bf)
710{
33
34/*
35 * Driver for the Atheros Wireless LAN controller.
36 *
37 * This software is derived from work of Atsushi Onoe; his contribution
38 * is greatly appreciated.
39 */
40

--- 662 unchanged lines hidden (view full) ---

703 * XXX It may not be a bad idea to just stuff the QCU ID into bf_state
704 * and retire bfs_txq; then make sure the CABQ QCU ID is populated
705 * correctly.
706 */
707static void
708ath_tx_handoff_mcast(struct ath_softc *sc, struct ath_txq *txq,
709 struct ath_buf *bf)
710{
711 ATH_TXQ_LOCK_ASSERT(txq);
711 ATH_TX_LOCK_ASSERT(sc);
712
712 KASSERT((bf->bf_flags & ATH_BUF_BUSY) == 0,
713 ("%s: busy status 0x%x", __func__, bf->bf_flags));
714 if (txq->axq_link != NULL) {
715 struct ath_buf *last = ATH_TXQ_LAST(txq, axq_q_s);
716 struct ieee80211_frame *wh;
717
718 /* mark previous frame */
719 wh = mtod(last->bf_m, struct ieee80211_frame *);

--- 20 unchanged lines hidden (view full) ---

740 /*
741 * Insert the frame on the outbound list and pass it on
742 * to the hardware. Multicast frames buffered for power
743 * save stations and transmit from the CAB queue are stored
744 * on a s/w only queue and loaded on to the CAB queue in
745 * the SWBA handler since frames only go out on DTIM and
746 * to avoid possible races.
747 */
713 KASSERT((bf->bf_flags & ATH_BUF_BUSY) == 0,
714 ("%s: busy status 0x%x", __func__, bf->bf_flags));
715 if (txq->axq_link != NULL) {
716 struct ath_buf *last = ATH_TXQ_LAST(txq, axq_q_s);
717 struct ieee80211_frame *wh;
718
719 /* mark previous frame */
720 wh = mtod(last->bf_m, struct ieee80211_frame *);

--- 20 unchanged lines hidden (view full) ---

741 /*
742 * Insert the frame on the outbound list and pass it on
743 * to the hardware. Multicast frames buffered for power
744 * save stations and transmit from the CAB queue are stored
745 * on a s/w only queue and loaded on to the CAB queue in
746 * the SWBA handler since frames only go out on DTIM and
747 * to avoid possible races.
748 */
748 ATH_TXQ_LOCK_ASSERT(txq);
749 ATH_TX_LOCK_ASSERT(sc);
749 KASSERT((bf->bf_flags & ATH_BUF_BUSY) == 0,
750 ("%s: busy status 0x%x", __func__, bf->bf_flags));
751 KASSERT(txq->axq_qnum != ATH_TXQ_SWQ,
752 ("ath_tx_handoff_hw called for mcast queue"));
753
754#if 0
755 /*
756 * This causes a LOR. Find out where the PCU lock is being

--- 162 unchanged lines hidden (view full) ---

919 * This must be called whether the queue is empty or not.
920 */
921static void
922ath_legacy_tx_dma_restart(struct ath_softc *sc, struct ath_txq *txq)
923{
924 struct ath_hal *ah = sc->sc_ah;
925 struct ath_buf *bf, *bf_last;
926
750 KASSERT((bf->bf_flags & ATH_BUF_BUSY) == 0,
751 ("%s: busy status 0x%x", __func__, bf->bf_flags));
752 KASSERT(txq->axq_qnum != ATH_TXQ_SWQ,
753 ("ath_tx_handoff_hw called for mcast queue"));
754
755#if 0
756 /*
757 * This causes a LOR. Find out where the PCU lock is being

--- 162 unchanged lines hidden (view full) ---

920 * This must be called whether the queue is empty or not.
921 */
922static void
923ath_legacy_tx_dma_restart(struct ath_softc *sc, struct ath_txq *txq)
924{
925 struct ath_hal *ah = sc->sc_ah;
926 struct ath_buf *bf, *bf_last;
927
927 ATH_TXQ_LOCK_ASSERT(txq);
928 ATH_TX_LOCK_ASSERT(sc);
928
929 /* This is always going to be cleared, empty or not */
930 txq->axq_flags &= ~ATH_TXQ_PUTPENDING;
931
932 /* XXX make this ATH_TXQ_FIRST */
933 bf = TAILQ_FIRST(&txq->axq_q);
934 bf_last = ATH_TXQ_LAST(txq, axq_q_s);
935

--- 9 unchanged lines hidden (view full) ---

945 * Hand off a packet to the hardware (or mcast queue.)
946 *
947 * The relevant hardware txq should be locked.
948 */
949static void
950ath_legacy_xmit_handoff(struct ath_softc *sc, struct ath_txq *txq,
951 struct ath_buf *bf)
952{
929
930 /* This is always going to be cleared, empty or not */
931 txq->axq_flags &= ~ATH_TXQ_PUTPENDING;
932
933 /* XXX make this ATH_TXQ_FIRST */
934 bf = TAILQ_FIRST(&txq->axq_q);
935 bf_last = ATH_TXQ_LAST(txq, axq_q_s);
936

--- 9 unchanged lines hidden (view full) ---

946 * Hand off a packet to the hardware (or mcast queue.)
947 *
948 * The relevant hardware txq should be locked.
949 */
950static void
951ath_legacy_xmit_handoff(struct ath_softc *sc, struct ath_txq *txq,
952 struct ath_buf *bf)
953{
953 ATH_TXQ_LOCK_ASSERT(txq);
954 ATH_TX_LOCK_ASSERT(sc);
954
955#ifdef ATH_DEBUG_ALQ
956 if (if_ath_alq_checkdebug(&sc->sc_alq, ATH_ALQ_EDMA_TXDESC))
957 ath_tx_alq_post(sc, bf);
958#endif
959
960 if (txq->axq_qnum == ATH_TXQ_SWQ)
961 ath_tx_handoff_mcast(sc, txq, bf);

--- 428 unchanged lines hidden (view full) ---

1390/*
1391 * Update the CLRDMASK bit in the ath_buf if it needs to be set.
1392 */
1393static void
1394ath_tx_update_clrdmask(struct ath_softc *sc, struct ath_tid *tid,
1395 struct ath_buf *bf)
1396{
1397
955
956#ifdef ATH_DEBUG_ALQ
957 if (if_ath_alq_checkdebug(&sc->sc_alq, ATH_ALQ_EDMA_TXDESC))
958 ath_tx_alq_post(sc, bf);
959#endif
960
961 if (txq->axq_qnum == ATH_TXQ_SWQ)
962 ath_tx_handoff_mcast(sc, txq, bf);

--- 428 unchanged lines hidden (view full) ---

1391/*
1392 * Update the CLRDMASK bit in the ath_buf if it needs to be set.
1393 */
1394static void
1395ath_tx_update_clrdmask(struct ath_softc *sc, struct ath_tid *tid,
1396 struct ath_buf *bf)
1397{
1398
1398 ATH_TID_LOCK_ASSERT(sc, tid);
1399 ATH_TX_LOCK_ASSERT(sc);
1399
1400 if (tid->clrdmask == 1) {
1401 bf->bf_state.bfs_txflags |= HAL_TXDESC_CLRDMASK;
1402 tid->clrdmask = 0;
1403 }
1404}
1405
1406/*

--- 9 unchanged lines hidden (view full) ---

1416 */
1417static void
1418ath_tx_xmit_normal(struct ath_softc *sc, struct ath_txq *txq,
1419 struct ath_buf *bf)
1420{
1421 struct ath_node *an = ATH_NODE(bf->bf_node);
1422 struct ath_tid *tid = &an->an_tid[bf->bf_state.bfs_tid];
1423
1400
1401 if (tid->clrdmask == 1) {
1402 bf->bf_state.bfs_txflags |= HAL_TXDESC_CLRDMASK;
1403 tid->clrdmask = 0;
1404 }
1405}
1406
1407/*

--- 9 unchanged lines hidden (view full) ---

1417 */
1418static void
1419ath_tx_xmit_normal(struct ath_softc *sc, struct ath_txq *txq,
1420 struct ath_buf *bf)
1421{
1422 struct ath_node *an = ATH_NODE(bf->bf_node);
1423 struct ath_tid *tid = &an->an_tid[bf->bf_state.bfs_tid];
1424
1424 ATH_TXQ_LOCK_ASSERT(txq);
1425 ATH_TX_LOCK_ASSERT(sc);
1425
1426 /*
1427 * For now, just enable CLRDMASK. ath_tx_xmit_normal() does
1428 * set a completion handler however it doesn't (yet) properly
1429 * handle the strict ordering requirements needed for normal,
1430 * non-aggregate session frames.
1431 *
1432 * Once this is implemented, only set CLRDMASK like this for

--- 54 unchanged lines hidden (view full) ---

1487
1488 /*
1489 * To ensure that both sequence numbers and the CCMP PN handling
1490 * is "correct", make sure that the relevant TID queue is locked.
1491 * Otherwise the CCMP PN and seqno may appear out of order, causing
1492 * re-ordered frames to have out of order CCMP PN's, resulting
1493 * in many, many frame drops.
1494 */
1426
1427 /*
1428 * For now, just enable CLRDMASK. ath_tx_xmit_normal() does
1429 * set a completion handler however it doesn't (yet) properly
1430 * handle the strict ordering requirements needed for normal,
1431 * non-aggregate session frames.
1432 *
1433 * Once this is implemented, only set CLRDMASK like this for

--- 54 unchanged lines hidden (view full) ---

1488
1489 /*
1490 * To ensure that both sequence numbers and the CCMP PN handling
1491 * is "correct", make sure that the relevant TID queue is locked.
1492 * Otherwise the CCMP PN and seqno may appear out of order, causing
1493 * re-ordered frames to have out of order CCMP PN's, resulting
1494 * in many, many frame drops.
1495 */
1495 ATH_TXQ_LOCK_ASSERT(txq);
1496 ATH_TX_LOCK_ASSERT(sc);
1496
1497 wh = mtod(m0, struct ieee80211_frame *);
1498 iswep = wh->i_fc[1] & IEEE80211_FC1_WEP;
1499 ismcast = IEEE80211_IS_MULTICAST(wh->i_addr1);
1500 isfrag = m0->m_flags & M_FRAG;
1501 hdrlen = ieee80211_anyhdrsize(wh);
1502 /*
1503 * Packet length must not include any

--- 279 unchanged lines hidden (view full) ---

1783 int tid;
1784 struct ath_txq *txq;
1785 int ismcast;
1786 const struct ieee80211_frame *wh;
1787 int is_ampdu, is_ampdu_tx, is_ampdu_pending;
1788 ieee80211_seq seqno;
1789 uint8_t type, subtype;
1790
1497
1498 wh = mtod(m0, struct ieee80211_frame *);
1499 iswep = wh->i_fc[1] & IEEE80211_FC1_WEP;
1500 ismcast = IEEE80211_IS_MULTICAST(wh->i_addr1);
1501 isfrag = m0->m_flags & M_FRAG;
1502 hdrlen = ieee80211_anyhdrsize(wh);
1503 /*
1504 * Packet length must not include any

--- 279 unchanged lines hidden (view full) ---

1784 int tid;
1785 struct ath_txq *txq;
1786 int ismcast;
1787 const struct ieee80211_frame *wh;
1788 int is_ampdu, is_ampdu_tx, is_ampdu_pending;
1789 ieee80211_seq seqno;
1790 uint8_t type, subtype;
1791
1792 ATH_TX_LOCK_ASSERT(sc);
1793
1791 /*
1792 * Determine the target hardware queue.
1793 *
1794 * For multicast frames, the txq gets overridden appropriately
1795 * depending upon the state of PS.
1796 *
1797 * For any other frame, we do a TID/QoS lookup inside the frame
1798 * to see what the TID should be. If it's a non-QoS frame, the

--- 13 unchanged lines hidden (view full) ---

1812 subtype = wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK;
1813
1814 /*
1815 * Enforce how deep the multicast queue can grow.
1816 *
1817 * XXX duplicated in ath_raw_xmit().
1818 */
1819 if (IEEE80211_IS_MULTICAST(wh->i_addr1)) {
1794 /*
1795 * Determine the target hardware queue.
1796 *
1797 * For multicast frames, the txq gets overridden appropriately
1798 * depending upon the state of PS.
1799 *
1800 * For any other frame, we do a TID/QoS lookup inside the frame
1801 * to see what the TID should be. If it's a non-QoS frame, the

--- 13 unchanged lines hidden (view full) ---

1815 subtype = wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK;
1816
1817 /*
1818 * Enforce how deep the multicast queue can grow.
1819 *
1820 * XXX duplicated in ath_raw_xmit().
1821 */
1822 if (IEEE80211_IS_MULTICAST(wh->i_addr1)) {
1820 ATH_TXQ_LOCK(sc->sc_cabq);
1821
1822 if (sc->sc_cabq->axq_depth > sc->sc_txq_mcastq_maxdepth) {
1823 sc->sc_stats.ast_tx_mcastq_overflow++;
1824 r = ENOBUFS;
1825 }
1823 if (sc->sc_cabq->axq_depth > sc->sc_txq_mcastq_maxdepth) {
1824 sc->sc_stats.ast_tx_mcastq_overflow++;
1825 r = ENOBUFS;
1826 }
1826
1827 ATH_TXQ_UNLOCK(sc->sc_cabq);
1828
1829 if (r != 0) {
1830 m_freem(m0);
1831 return r;
1832 }
1833 }
1834
1835 /* A-MPDU TX */
1836 is_ampdu_tx = ath_tx_ampdu_running(sc, ATH_NODE(ni), tid);

--- 25 unchanged lines hidden (view full) ---

1862 */
1863 bf->bf_state.bfs_txq = sc->sc_cabq;
1864 }
1865
1866 /* Do the generic frame setup */
1867 /* XXX should just bzero the bf_state? */
1868 bf->bf_state.bfs_dobaw = 0;
1869
1827 if (r != 0) {
1828 m_freem(m0);
1829 return r;
1830 }
1831 }
1832
1833 /* A-MPDU TX */
1834 is_ampdu_tx = ath_tx_ampdu_running(sc, ATH_NODE(ni), tid);

--- 25 unchanged lines hidden (view full) ---

1860 */
1861 bf->bf_state.bfs_txq = sc->sc_cabq;
1862 }
1863
1864 /* Do the generic frame setup */
1865 /* XXX should just bzero the bf_state? */
1866 bf->bf_state.bfs_dobaw = 0;
1867
1870 /*
1871 * Acquire the TXQ lock early, so both the encap and seqno
1872 * are allocated together.
1873 *
1874 * XXX should TXQ for CABQ traffic be the multicast queue,
1875 * or the TXQ the given PRI would allocate from? (eg for
1876 * sequence number allocation locking.)
1877 */
1878 ATH_TXQ_LOCK(txq);
1879
1880 /* A-MPDU TX? Manually set sequence number */
1881 /*
1882 * Don't do it whilst pending; the net80211 layer still
1883 * assigns them.
1884 */
1885 if (is_ampdu_tx) {
1886 /*
1887 * Always call; this function will

--- 71 unchanged lines hidden (view full) ---

1959 /*
1960 * For now, since there's no software queue,
1961 * direct-dispatch to the hardware.
1962 */
1963 bf->bf_state.bfs_txflags |= HAL_TXDESC_CLRDMASK;
1964 ath_tx_xmit_normal(sc, txq, bf);
1965#endif
1966done:
1868 /* A-MPDU TX? Manually set sequence number */
1869 /*
1870 * Don't do it whilst pending; the net80211 layer still
1871 * assigns them.
1872 */
1873 if (is_ampdu_tx) {
1874 /*
1875 * Always call; this function will

--- 71 unchanged lines hidden (view full) ---

1947 /*
1948 * For now, since there's no software queue,
1949 * direct-dispatch to the hardware.
1950 */
1951 bf->bf_state.bfs_txflags |= HAL_TXDESC_CLRDMASK;
1952 ath_tx_xmit_normal(sc, txq, bf);
1953#endif
1954done:
1967 ATH_TXQ_UNLOCK(txq);
1968
1969 return 0;
1970}
1971
1972static int
1973ath_tx_raw_start(struct ath_softc *sc, struct ieee80211_node *ni,
1974 struct ath_buf *bf, struct mbuf *m0,
1975 const struct ieee80211_bpf_params *params)
1976{

--- 8 unchanged lines hidden (view full) ---

1985 u_int flags;
1986 HAL_PKT_TYPE atype;
1987 const HAL_RATE_TABLE *rt;
1988 struct ath_desc *ds;
1989 u_int pri;
1990 int o_tid = -1;
1991 int do_override;
1992
1955 return 0;
1956}
1957
1958static int
1959ath_tx_raw_start(struct ath_softc *sc, struct ieee80211_node *ni,
1960 struct ath_buf *bf, struct mbuf *m0,
1961 const struct ieee80211_bpf_params *params)
1962{

--- 8 unchanged lines hidden (view full) ---

1971 u_int flags;
1972 HAL_PKT_TYPE atype;
1973 const HAL_RATE_TABLE *rt;
1974 struct ath_desc *ds;
1975 u_int pri;
1976 int o_tid = -1;
1977 int do_override;
1978
1979 ATH_TX_LOCK_ASSERT(sc);
1980
1993 wh = mtod(m0, struct ieee80211_frame *);
1994 ismcast = IEEE80211_IS_MULTICAST(wh->i_addr1);
1995 hdrlen = ieee80211_anyhdrsize(wh);
1996 /*
1997 * Packet length must not include any
1998 * pad bytes; deduct them here.
1999 */
2000 /* XXX honor IEEE80211_BPF_DATAPAD */

--- 18 unchanged lines hidden (view full) ---

2019#if 0
2020 device_printf(sc->sc_dev,
2021 "%s: overriding tid %d pri %d -> %d\n",
2022 __func__, o_tid, pri, TID_TO_WME_AC(o_tid));
2023#endif
2024 pri = TID_TO_WME_AC(o_tid);
2025 }
2026
1981 wh = mtod(m0, struct ieee80211_frame *);
1982 ismcast = IEEE80211_IS_MULTICAST(wh->i_addr1);
1983 hdrlen = ieee80211_anyhdrsize(wh);
1984 /*
1985 * Packet length must not include any
1986 * pad bytes; deduct them here.
1987 */
1988 /* XXX honor IEEE80211_BPF_DATAPAD */

--- 18 unchanged lines hidden (view full) ---

2007#if 0
2008 device_printf(sc->sc_dev,
2009 "%s: overriding tid %d pri %d -> %d\n",
2010 __func__, o_tid, pri, TID_TO_WME_AC(o_tid));
2011#endif
2012 pri = TID_TO_WME_AC(o_tid);
2013 }
2014
2027 ATH_TXQ_LOCK(sc->sc_ac2q[pri]);
2028
2029 /* Handle encryption twiddling if needed */
2030 if (! ath_tx_tag_crypto(sc, ni,
2031 m0, params->ibp_flags & IEEE80211_BPF_CRYPTO, 0,
2032 &hdrlen, &pktlen, &keyix)) {
2033 ath_freetx(m0);
2034 return EIO;
2035 }
2036 /* packet header may have moved, reset our local pointer */

--- 146 unchanged lines hidden (view full) ---

2183 /* Queue to software queue */
2184 ath_tx_swq(sc, ni, sc->sc_ac2q[pri], bf);
2185 }
2186#else
2187 /* Direct-dispatch to the hardware */
2188 bf->bf_state.bfs_txflags |= HAL_TXDESC_CLRDMASK;
2189 ath_tx_xmit_normal(sc, sc->sc_ac2q[pri], bf);
2190#endif
2015 /* Handle encryption twiddling if needed */
2016 if (! ath_tx_tag_crypto(sc, ni,
2017 m0, params->ibp_flags & IEEE80211_BPF_CRYPTO, 0,
2018 &hdrlen, &pktlen, &keyix)) {
2019 ath_freetx(m0);
2020 return EIO;
2021 }
2022 /* packet header may have moved, reset our local pointer */

--- 146 unchanged lines hidden (view full) ---

2169 /* Queue to software queue */
2170 ath_tx_swq(sc, ni, sc->sc_ac2q[pri], bf);
2171 }
2172#else
2173 /* Direct-dispatch to the hardware */
2174 bf->bf_state.bfs_txflags |= HAL_TXDESC_CLRDMASK;
2175 ath_tx_xmit_normal(sc, sc->sc_ac2q[pri], bf);
2176#endif
2191 ATH_TXQ_UNLOCK(sc->sc_ac2q[pri]);
2192
2193 return 0;
2194}
2195
2196/*
2197 * Send a raw frame.
2198 *
2199 * This can be called by net80211.
2200 */

--- 31 unchanged lines hidden (view full) ---

2232 }
2233
2234 /*
2235 * Enforce how deep the multicast queue can grow.
2236 *
2237 * XXX duplicated in ath_tx_start().
2238 */
2239 if (IEEE80211_IS_MULTICAST(wh->i_addr1)) {
2177 return 0;
2178}
2179
2180/*
2181 * Send a raw frame.
2182 *
2183 * This can be called by net80211.
2184 */

--- 31 unchanged lines hidden (view full) ---

2216 }
2217
2218 /*
2219 * Enforce how deep the multicast queue can grow.
2220 *
2221 * XXX duplicated in ath_tx_start().
2222 */
2223 if (IEEE80211_IS_MULTICAST(wh->i_addr1)) {
2240 ATH_TXQ_LOCK(sc->sc_cabq);
2241
2242 if (sc->sc_cabq->axq_depth > sc->sc_txq_mcastq_maxdepth) {
2243 sc->sc_stats.ast_tx_mcastq_overflow++;
2244 error = ENOBUFS;
2245 }
2246
2224 if (sc->sc_cabq->axq_depth > sc->sc_txq_mcastq_maxdepth) {
2225 sc->sc_stats.ast_tx_mcastq_overflow++;
2226 error = ENOBUFS;
2227 }
2228
2247 ATH_TXQ_UNLOCK(sc->sc_cabq);
2248
2249 if (error != 0) {
2250 m_freem(m);
2251 goto bad;
2252 }
2253 }
2254
2255 /*
2256 * Grab a TX buffer and associated resources.

--- 173 unchanged lines hidden (view full) ---

2430 */
2431void
2432ath_tx_addto_baw(struct ath_softc *sc, struct ath_node *an,
2433 struct ath_tid *tid, struct ath_buf *bf)
2434{
2435 int index, cindex;
2436 struct ieee80211_tx_ampdu *tap;
2437
2229 if (error != 0) {
2230 m_freem(m);
2231 goto bad;
2232 }
2233 }
2234
2235 /*
2236 * Grab a TX buffer and associated resources.

--- 173 unchanged lines hidden (view full) ---

2410 */
2411void
2412ath_tx_addto_baw(struct ath_softc *sc, struct ath_node *an,
2413 struct ath_tid *tid, struct ath_buf *bf)
2414{
2415 int index, cindex;
2416 struct ieee80211_tx_ampdu *tap;
2417
2438 ATH_TXQ_LOCK_ASSERT(sc->sc_ac2q[tid->ac]);
2439 ATH_TID_LOCK_ASSERT(sc, tid);
2418 ATH_TX_LOCK_ASSERT(sc);
2440
2441 if (bf->bf_state.bfs_isretried)
2442 return;
2443
2444 tap = ath_tx_get_tx_tid(an, tid->tid);
2445
2446 if (! bf->bf_state.bfs_dobaw) {
2447 device_printf(sc->sc_dev,

--- 78 unchanged lines hidden (view full) ---

2526static void
2527ath_tx_switch_baw_buf(struct ath_softc *sc, struct ath_node *an,
2528 struct ath_tid *tid, struct ath_buf *old_bf, struct ath_buf *new_bf)
2529{
2530 int index, cindex;
2531 struct ieee80211_tx_ampdu *tap;
2532 int seqno = SEQNO(old_bf->bf_state.bfs_seqno);
2533
2419
2420 if (bf->bf_state.bfs_isretried)
2421 return;
2422
2423 tap = ath_tx_get_tx_tid(an, tid->tid);
2424
2425 if (! bf->bf_state.bfs_dobaw) {
2426 device_printf(sc->sc_dev,

--- 78 unchanged lines hidden (view full) ---

2505static void
2506ath_tx_switch_baw_buf(struct ath_softc *sc, struct ath_node *an,
2507 struct ath_tid *tid, struct ath_buf *old_bf, struct ath_buf *new_bf)
2508{
2509 int index, cindex;
2510 struct ieee80211_tx_ampdu *tap;
2511 int seqno = SEQNO(old_bf->bf_state.bfs_seqno);
2512
2534 ATH_TXQ_LOCK_ASSERT(sc->sc_ac2q[tid->ac]);
2535 ATH_TID_LOCK_ASSERT(sc, tid);
2513 ATH_TX_LOCK_ASSERT(sc);
2536
2537 tap = ath_tx_get_tx_tid(an, tid->tid);
2538 index = ATH_BA_INDEX(tap->txa_start, seqno);
2539 cindex = (tid->baw_head + index) & (ATH_TID_MAX_BUFS - 1);
2540
2541 /*
2542 * Just warn for now; if it happens then we should find out
2543 * about it. It's highly likely the aggregation session will

--- 31 unchanged lines hidden (view full) ---

2575static void
2576ath_tx_update_baw(struct ath_softc *sc, struct ath_node *an,
2577 struct ath_tid *tid, const struct ath_buf *bf)
2578{
2579 int index, cindex;
2580 struct ieee80211_tx_ampdu *tap;
2581 int seqno = SEQNO(bf->bf_state.bfs_seqno);
2582
2514
2515 tap = ath_tx_get_tx_tid(an, tid->tid);
2516 index = ATH_BA_INDEX(tap->txa_start, seqno);
2517 cindex = (tid->baw_head + index) & (ATH_TID_MAX_BUFS - 1);
2518
2519 /*
2520 * Just warn for now; if it happens then we should find out
2521 * about it. It's highly likely the aggregation session will

--- 31 unchanged lines hidden (view full) ---

2553static void
2554ath_tx_update_baw(struct ath_softc *sc, struct ath_node *an,
2555 struct ath_tid *tid, const struct ath_buf *bf)
2556{
2557 int index, cindex;
2558 struct ieee80211_tx_ampdu *tap;
2559 int seqno = SEQNO(bf->bf_state.bfs_seqno);
2560
2583 ATH_TXQ_LOCK_ASSERT(sc->sc_ac2q[tid->ac]);
2584 ATH_TID_LOCK_ASSERT(sc, tid);
2561 ATH_TX_LOCK_ASSERT(sc);
2585
2586 tap = ath_tx_get_tx_tid(an, tid->tid);
2587 index = ATH_BA_INDEX(tap->txa_start, seqno);
2588 cindex = (tid->baw_head + index) & (ATH_TID_MAX_BUFS - 1);
2589
2590 DPRINTF(sc, ATH_DEBUG_SW_TX_BAW,
2591 "%s: tid=%d, baw=%d:%d, seqno=%d, index=%d, cindex=%d, "
2592 "baw head=%d, tail=%d\n",

--- 39 unchanged lines hidden (view full) ---

2632 *
2633 * The TXQ lock must be held.
2634 */
2635static void
2636ath_tx_tid_sched(struct ath_softc *sc, struct ath_tid *tid)
2637{
2638 struct ath_txq *txq = sc->sc_ac2q[tid->ac];
2639
2562
2563 tap = ath_tx_get_tx_tid(an, tid->tid);
2564 index = ATH_BA_INDEX(tap->txa_start, seqno);
2565 cindex = (tid->baw_head + index) & (ATH_TID_MAX_BUFS - 1);
2566
2567 DPRINTF(sc, ATH_DEBUG_SW_TX_BAW,
2568 "%s: tid=%d, baw=%d:%d, seqno=%d, index=%d, cindex=%d, "
2569 "baw head=%d, tail=%d\n",

--- 39 unchanged lines hidden (view full) ---

2609 *
2610 * The TXQ lock must be held.
2611 */
2612static void
2613ath_tx_tid_sched(struct ath_softc *sc, struct ath_tid *tid)
2614{
2615 struct ath_txq *txq = sc->sc_ac2q[tid->ac];
2616
2640 ATH_TXQ_LOCK_ASSERT(txq);
2617 ATH_TX_LOCK_ASSERT(sc);
2641
2642 if (tid->paused)
2643 return; /* paused, can't schedule yet */
2644
2645 if (tid->sched)
2646 return; /* already scheduled */
2647
2648 tid->sched = 1;

--- 7 unchanged lines hidden (view full) ---

2656 *
2657 * The TXQ lock must be held.
2658 */
2659static void
2660ath_tx_tid_unsched(struct ath_softc *sc, struct ath_tid *tid)
2661{
2662 struct ath_txq *txq = sc->sc_ac2q[tid->ac];
2663
2618
2619 if (tid->paused)
2620 return; /* paused, can't schedule yet */
2621
2622 if (tid->sched)
2623 return; /* already scheduled */
2624
2625 tid->sched = 1;

--- 7 unchanged lines hidden (view full) ---

2633 *
2634 * The TXQ lock must be held.
2635 */
2636static void
2637ath_tx_tid_unsched(struct ath_softc *sc, struct ath_tid *tid)
2638{
2639 struct ath_txq *txq = sc->sc_ac2q[tid->ac];
2640
2664 ATH_TXQ_LOCK_ASSERT(txq);
2641 ATH_TX_LOCK_ASSERT(sc);
2665
2666 if (tid->sched == 0)
2667 return;
2668
2669 tid->sched = 0;
2670 TAILQ_REMOVE(&txq->axq_tidq, tid, axq_qelem);
2671}
2672

--- 19 unchanged lines hidden (view full) ---

2692 __func__, pri, tid, IEEE80211_QOS_HAS_SEQ(wh));
2693
2694 /* XXX Is it a control frame? Ignore */
2695
2696 /* Does the packet require a sequence number? */
2697 if (! IEEE80211_QOS_HAS_SEQ(wh))
2698 return -1;
2699
2642
2643 if (tid->sched == 0)
2644 return;
2645
2646 tid->sched = 0;
2647 TAILQ_REMOVE(&txq->axq_tidq, tid, axq_qelem);
2648}
2649

--- 19 unchanged lines hidden (view full) ---

2669 __func__, pri, tid, IEEE80211_QOS_HAS_SEQ(wh));
2670
2671 /* XXX Is it a control frame? Ignore */
2672
2673 /* Does the packet require a sequence number? */
2674 if (! IEEE80211_QOS_HAS_SEQ(wh))
2675 return -1;
2676
2700 ATH_TID_LOCK_ASSERT(sc, &(ATH_NODE(ni)->an_tid[tid]));
2677 ATH_TX_LOCK_ASSERT(sc);
2701
2702 /*
2703 * Is it a QOS NULL Data frame? Give it a sequence number from
2704 * the default TID (IEEE80211_NONQOS_TID.)
2705 *
2706 * The RX path of everything I've looked at doesn't include the NULL
2707 * data frame sequence number in the aggregation state updates, so
2708 * assigning it a sequence number there will cause a BAW hole on the

--- 32 unchanged lines hidden (view full) ---

2741
2742 if (txq != bf->bf_state.bfs_txq) {
2743 device_printf(sc->sc_dev, "%s: txq %d != bfs_txq %d!\n",
2744 __func__,
2745 txq->axq_qnum,
2746 bf->bf_state.bfs_txq->axq_qnum);
2747 }
2748
2678
2679 /*
2680 * Is it a QOS NULL Data frame? Give it a sequence number from
2681 * the default TID (IEEE80211_NONQOS_TID.)
2682 *
2683 * The RX path of everything I've looked at doesn't include the NULL
2684 * data frame sequence number in the aggregation state updates, so
2685 * assigning it a sequence number there will cause a BAW hole on the

--- 32 unchanged lines hidden (view full) ---

2718
2719 if (txq != bf->bf_state.bfs_txq) {
2720 device_printf(sc->sc_dev, "%s: txq %d != bfs_txq %d!\n",
2721 __func__,
2722 txq->axq_qnum,
2723 bf->bf_state.bfs_txq->axq_qnum);
2724 }
2725
2749 ATH_TXQ_LOCK_ASSERT(txq);
2750 ATH_TID_LOCK_ASSERT(sc, tid);
2726 ATH_TX_LOCK_ASSERT(sc);
2751
2752 tap = ath_tx_get_tx_tid(an, tid->tid);
2753
2754 /* paused? queue */
2755 if (tid->paused) {
2756 ATH_TID_INSERT_HEAD(tid, bf, bf_list);
2757 /* XXX don't sched - we're paused! */
2758 return;

--- 68 unchanged lines hidden (view full) ---

2827 struct ath_buf *bf)
2828{
2829 struct ath_node *an = ATH_NODE(ni);
2830 struct ieee80211_frame *wh;
2831 struct ath_tid *atid;
2832 int pri, tid;
2833 struct mbuf *m0 = bf->bf_m;
2834
2727
2728 tap = ath_tx_get_tx_tid(an, tid->tid);
2729
2730 /* paused? queue */
2731 if (tid->paused) {
2732 ATH_TID_INSERT_HEAD(tid, bf, bf_list);
2733 /* XXX don't sched - we're paused! */
2734 return;

--- 68 unchanged lines hidden (view full) ---

2803 struct ath_buf *bf)
2804{
2805 struct ath_node *an = ATH_NODE(ni);
2806 struct ieee80211_frame *wh;
2807 struct ath_tid *atid;
2808 int pri, tid;
2809 struct mbuf *m0 = bf->bf_m;
2810
2835 ATH_TXQ_LOCK_ASSERT(txq);
2811 ATH_TX_LOCK_ASSERT(sc);
2836
2837 /* Fetch the TID - non-QoS frames get assigned to TID 16 */
2838 wh = mtod(m0, struct ieee80211_frame *);
2839 pri = ath_tx_getac(sc, m0);
2840 tid = ath_tx_gettid(sc, m0);
2841 atid = &an->an_tid[tid];
2842
2812
2813 /* Fetch the TID - non-QoS frames get assigned to TID 16 */
2814 wh = mtod(m0, struct ieee80211_frame *);
2815 pri = ath_tx_getac(sc, m0);
2816 tid = ath_tx_gettid(sc, m0);
2817 atid = &an->an_tid[tid];
2818
2843 ATH_TID_LOCK_ASSERT(sc, atid);
2844
2845 DPRINTF(sc, ATH_DEBUG_SW_TX, "%s: bf=%p, pri=%d, tid=%d, qos=%d\n",
2846 __func__, bf, pri, tid, IEEE80211_QOS_HAS_SEQ(wh));
2847
2848 /* Set local packet state, used to queue packets to hardware */
2849 /* XXX potentially duplicate info, re-check */
2850 /* XXX remember, txq must be the hardware queue, not the av_mcastq */
2851 bf->bf_state.bfs_tid = tid;
2852 bf->bf_state.bfs_txq = txq;

--- 112 unchanged lines hidden (view full) ---

2965 *
2966 * Since this is also called from upper layers as well as the driver,
2967 * it will get the TID lock.
2968 */
2969static void
2970ath_tx_tid_pause(struct ath_softc *sc, struct ath_tid *tid)
2971{
2972
2819 DPRINTF(sc, ATH_DEBUG_SW_TX, "%s: bf=%p, pri=%d, tid=%d, qos=%d\n",
2820 __func__, bf, pri, tid, IEEE80211_QOS_HAS_SEQ(wh));
2821
2822 /* Set local packet state, used to queue packets to hardware */
2823 /* XXX potentially duplicate info, re-check */
2824 /* XXX remember, txq must be the hardware queue, not the av_mcastq */
2825 bf->bf_state.bfs_tid = tid;
2826 bf->bf_state.bfs_txq = txq;

--- 112 unchanged lines hidden (view full) ---

2939 *
2940 * Since this is also called from upper layers as well as the driver,
2941 * it will get the TID lock.
2942 */
2943static void
2944ath_tx_tid_pause(struct ath_softc *sc, struct ath_tid *tid)
2945{
2946
2973 ATH_TXQ_LOCK_ASSERT(sc->sc_ac2q[tid->ac]);
2947 ATH_TX_LOCK_ASSERT(sc);
2974 tid->paused++;
2975 DPRINTF(sc, ATH_DEBUG_SW_TX_CTRL, "%s: paused = %d\n",
2976 __func__, tid->paused);
2977}
2978
2979/*
2980 * Unpause the current TID, and schedule it if needed.
2981 */
2982static void
2983ath_tx_tid_resume(struct ath_softc *sc, struct ath_tid *tid)
2984{
2948 tid->paused++;
2949 DPRINTF(sc, ATH_DEBUG_SW_TX_CTRL, "%s: paused = %d\n",
2950 __func__, tid->paused);
2951}
2952
2953/*
2954 * Unpause the current TID, and schedule it if needed.
2955 */
2956static void
2957ath_tx_tid_resume(struct ath_softc *sc, struct ath_tid *tid)
2958{
2985 ATH_TXQ_LOCK_ASSERT(sc->sc_ac2q[tid->ac]);
2986
2959
2960 ATH_TX_LOCK_ASSERT(sc);
2961
2987 tid->paused--;
2988
2989 DPRINTF(sc, ATH_DEBUG_SW_TX_CTRL, "%s: unpaused = %d\n",
2990 __func__, tid->paused);
2991
2992 if (tid->paused)
2993 return;
2994

--- 22 unchanged lines hidden (view full) ---

3017 * Add the given ath_buf to the TID filtered frame list.
3018 * This requires the TID be filtered.
3019 */
3020static void
3021ath_tx_tid_filt_addbuf(struct ath_softc *sc, struct ath_tid *tid,
3022 struct ath_buf *bf)
3023{
3024
2962 tid->paused--;
2963
2964 DPRINTF(sc, ATH_DEBUG_SW_TX_CTRL, "%s: unpaused = %d\n",
2965 __func__, tid->paused);
2966
2967 if (tid->paused)
2968 return;
2969

--- 22 unchanged lines hidden (view full) ---

2992 * Add the given ath_buf to the TID filtered frame list.
2993 * This requires the TID be filtered.
2994 */
2995static void
2996ath_tx_tid_filt_addbuf(struct ath_softc *sc, struct ath_tid *tid,
2997 struct ath_buf *bf)
2998{
2999
3025 ATH_TID_LOCK_ASSERT(sc, tid);
3000 ATH_TX_LOCK_ASSERT(sc);
3001
3026 if (! tid->isfiltered)
3027 device_printf(sc->sc_dev, "%s: not filtered?!\n", __func__);
3028
3029 DPRINTF(sc, ATH_DEBUG_SW_TX_FILT, "%s: bf=%p\n", __func__, bf);
3030
3031 /* Set the retry bit and bump the retry counter */
3032 ath_tx_set_retry(sc, bf);
3033 sc->sc_stats.ast_tx_swfiltered++;

--- 6 unchanged lines hidden (view full) ---

3040 * This just enables/pauses the filtered frame state if required
3041 * and appends the filtered frame to the filtered queue.
3042 */
3043static void
3044ath_tx_tid_filt_comp_buf(struct ath_softc *sc, struct ath_tid *tid,
3045 struct ath_buf *bf)
3046{
3047
3002 if (! tid->isfiltered)
3003 device_printf(sc->sc_dev, "%s: not filtered?!\n", __func__);
3004
3005 DPRINTF(sc, ATH_DEBUG_SW_TX_FILT, "%s: bf=%p\n", __func__, bf);
3006
3007 /* Set the retry bit and bump the retry counter */
3008 ath_tx_set_retry(sc, bf);
3009 sc->sc_stats.ast_tx_swfiltered++;

--- 6 unchanged lines hidden (view full) ---

3016 * This just enables/pauses the filtered frame state if required
3017 * and appends the filtered frame to the filtered queue.
3018 */
3019static void
3020ath_tx_tid_filt_comp_buf(struct ath_softc *sc, struct ath_tid *tid,
3021 struct ath_buf *bf)
3022{
3023
3048 ATH_TID_LOCK_ASSERT(sc, tid);
3024 ATH_TX_LOCK_ASSERT(sc);
3049
3050 if (! tid->isfiltered) {
3051 DPRINTF(sc, ATH_DEBUG_SW_TX_FILT, "%s: filter transition\n",
3052 __func__);
3053 tid->isfiltered = 1;
3054 ath_tx_tid_pause(sc, tid);
3055 }
3056

--- 8 unchanged lines hidden (view full) ---

3065 * the TID if applicable. Otherwise we will wait for a node PS transition
3066 * to unfilter.
3067 */
3068static void
3069ath_tx_tid_filt_comp_complete(struct ath_softc *sc, struct ath_tid *tid)
3070{
3071 struct ath_buf *bf;
3072
3025
3026 if (! tid->isfiltered) {
3027 DPRINTF(sc, ATH_DEBUG_SW_TX_FILT, "%s: filter transition\n",
3028 __func__);
3029 tid->isfiltered = 1;
3030 ath_tx_tid_pause(sc, tid);
3031 }
3032

--- 8 unchanged lines hidden (view full) ---

3041 * the TID if applicable. Otherwise we will wait for a node PS transition
3042 * to unfilter.
3043 */
3044static void
3045ath_tx_tid_filt_comp_complete(struct ath_softc *sc, struct ath_tid *tid)
3046{
3047 struct ath_buf *bf;
3048
3073 ATH_TID_LOCK_ASSERT(sc, tid);
3049 ATH_TX_LOCK_ASSERT(sc);
3074
3075 if (tid->hwq_depth != 0)
3076 return;
3077
3078 DPRINTF(sc, ATH_DEBUG_SW_TX_FILT, "%s: hwq=0, transition back\n",
3079 __func__);
3080 tid->isfiltered = 0;
3081 tid->clrdmask = 1;

--- 17 unchanged lines hidden (view full) ---

3099 */
3100static int
3101ath_tx_tid_filt_comp_single(struct ath_softc *sc, struct ath_tid *tid,
3102 struct ath_buf *bf)
3103{
3104 struct ath_buf *nbf;
3105 int retval;
3106
3050
3051 if (tid->hwq_depth != 0)
3052 return;
3053
3054 DPRINTF(sc, ATH_DEBUG_SW_TX_FILT, "%s: hwq=0, transition back\n",
3055 __func__);
3056 tid->isfiltered = 0;
3057 tid->clrdmask = 1;

--- 17 unchanged lines hidden (view full) ---

3075 */
3076static int
3077ath_tx_tid_filt_comp_single(struct ath_softc *sc, struct ath_tid *tid,
3078 struct ath_buf *bf)
3079{
3080 struct ath_buf *nbf;
3081 int retval;
3082
3107 ATH_TID_LOCK_ASSERT(sc, tid);
3083 ATH_TX_LOCK_ASSERT(sc);
3108
3109 /*
3110 * Don't allow a filtered frame to live forever.
3111 */
3112 if (bf->bf_state.bfs_retries > SWMAX_RETRIES) {
3113 sc->sc_stats.ast_tx_swretrymax++;
3114 DPRINTF(sc, ATH_DEBUG_SW_TX_FILT,
3115 "%s: bf=%p, seqno=%d, exceeded retries\n",

--- 31 unchanged lines hidden (view full) ---

3147}
3148
3149static void
3150ath_tx_tid_filt_comp_aggr(struct ath_softc *sc, struct ath_tid *tid,
3151 struct ath_buf *bf_first, ath_bufhead *bf_q)
3152{
3153 struct ath_buf *bf, *bf_next, *nbf;
3154
3084
3085 /*
3086 * Don't allow a filtered frame to live forever.
3087 */
3088 if (bf->bf_state.bfs_retries > SWMAX_RETRIES) {
3089 sc->sc_stats.ast_tx_swretrymax++;
3090 DPRINTF(sc, ATH_DEBUG_SW_TX_FILT,
3091 "%s: bf=%p, seqno=%d, exceeded retries\n",

--- 31 unchanged lines hidden (view full) ---

3123}
3124
3125static void
3126ath_tx_tid_filt_comp_aggr(struct ath_softc *sc, struct ath_tid *tid,
3127 struct ath_buf *bf_first, ath_bufhead *bf_q)
3128{
3129 struct ath_buf *bf, *bf_next, *nbf;
3130
3155 ATH_TID_LOCK_ASSERT(sc, tid);
3131 ATH_TX_LOCK_ASSERT(sc);
3156
3157 bf = bf_first;
3158 while (bf) {
3159 bf_next = bf->bf_next;
3160 bf->bf_next = NULL; /* Remove it from the aggr list */
3161
3162 /*
3163 * Don't allow a filtered frame to live forever.

--- 38 unchanged lines hidden (view full) ---

3202}
3203
3204/*
3205 * Suspend the queue because we need to TX a BAR.
3206 */
3207static void
3208ath_tx_tid_bar_suspend(struct ath_softc *sc, struct ath_tid *tid)
3209{
3132
3133 bf = bf_first;
3134 while (bf) {
3135 bf_next = bf->bf_next;
3136 bf->bf_next = NULL; /* Remove it from the aggr list */
3137
3138 /*
3139 * Don't allow a filtered frame to live forever.

--- 38 unchanged lines hidden (view full) ---

3178}
3179
3180/*
3181 * Suspend the queue because we need to TX a BAR.
3182 */
3183static void
3184ath_tx_tid_bar_suspend(struct ath_softc *sc, struct ath_tid *tid)
3185{
3210 ATH_TXQ_LOCK_ASSERT(sc->sc_ac2q[tid->ac]);
3211
3186
3187 ATH_TX_LOCK_ASSERT(sc);
3188
3212 DPRINTF(sc, ATH_DEBUG_SW_TX_BAR,
3213 "%s: tid=%p, bar_wait=%d, bar_tx=%d, called\n",
3214 __func__,
3215 tid,
3216 tid->bar_wait,
3217 tid->bar_tx);
3218
3219 /* We shouldn't be called when bar_tx is 1 */

--- 15 unchanged lines hidden (view full) ---

3235
3236/*
3237 * We've finished with BAR handling - either we succeeded or
3238 * failed. Either way, unsuspend TX.
3239 */
3240static void
3241ath_tx_tid_bar_unsuspend(struct ath_softc *sc, struct ath_tid *tid)
3242{
3189 DPRINTF(sc, ATH_DEBUG_SW_TX_BAR,
3190 "%s: tid=%p, bar_wait=%d, bar_tx=%d, called\n",
3191 __func__,
3192 tid,
3193 tid->bar_wait,
3194 tid->bar_tx);
3195
3196 /* We shouldn't be called when bar_tx is 1 */

--- 15 unchanged lines hidden (view full) ---

3212
3213/*
3214 * We've finished with BAR handling - either we succeeded or
3215 * failed. Either way, unsuspend TX.
3216 */
3217static void
3218ath_tx_tid_bar_unsuspend(struct ath_softc *sc, struct ath_tid *tid)
3219{
3243 ATH_TXQ_LOCK_ASSERT(sc->sc_ac2q[tid->ac]);
3244
3220
3221 ATH_TX_LOCK_ASSERT(sc);
3222
3245 DPRINTF(sc, ATH_DEBUG_SW_TX_BAR,
3246 "%s: tid=%p, called\n",
3247 __func__,
3248 tid);
3249
3250 if (tid->bar_tx == 0 || tid->bar_wait == 0) {
3251 device_printf(sc->sc_dev, "%s: bar_tx=%d, bar_wait=%d: ?\n",
3252 __func__, tid->bar_tx, tid->bar_wait);

--- 7 unchanged lines hidden (view full) ---

3260 * Return whether we're ready to TX a BAR frame.
3261 *
3262 * Requires the TID lock be held.
3263 */
3264static int
3265ath_tx_tid_bar_tx_ready(struct ath_softc *sc, struct ath_tid *tid)
3266{
3267
3223 DPRINTF(sc, ATH_DEBUG_SW_TX_BAR,
3224 "%s: tid=%p, called\n",
3225 __func__,
3226 tid);
3227
3228 if (tid->bar_tx == 0 || tid->bar_wait == 0) {
3229 device_printf(sc->sc_dev, "%s: bar_tx=%d, bar_wait=%d: ?\n",
3230 __func__, tid->bar_tx, tid->bar_wait);

--- 7 unchanged lines hidden (view full) ---

3238 * Return whether we're ready to TX a BAR frame.
3239 *
3240 * Requires the TID lock be held.
3241 */
3242static int
3243ath_tx_tid_bar_tx_ready(struct ath_softc *sc, struct ath_tid *tid)
3244{
3245
3268 ATH_TXQ_LOCK_ASSERT(sc->sc_ac2q[tid->ac]);
3246 ATH_TX_LOCK_ASSERT(sc);
3269
3270 if (tid->bar_wait == 0 || tid->hwq_depth > 0)
3271 return (0);
3272
3273 DPRINTF(sc, ATH_DEBUG_SW_TX_BAR, "%s: tid=%p (%d), bar ready\n",
3274 __func__, tid, tid->tid);
3275
3276 return (1);

--- 11 unchanged lines hidden (view full) ---

3288 * from this routine so the lock doesn't have to be reacquired
3289 * just to be immediately dropped by the caller.
3290 */
3291static void
3292ath_tx_tid_bar_tx(struct ath_softc *sc, struct ath_tid *tid)
3293{
3294 struct ieee80211_tx_ampdu *tap;
3295
3247
3248 if (tid->bar_wait == 0 || tid->hwq_depth > 0)
3249 return (0);
3250
3251 DPRINTF(sc, ATH_DEBUG_SW_TX_BAR, "%s: tid=%p (%d), bar ready\n",
3252 __func__, tid, tid->tid);
3253
3254 return (1);

--- 11 unchanged lines hidden (view full) ---

3266 * from this routine so the lock doesn't have to be reacquired
3267 * just to be immediately dropped by the caller.
3268 */
3269static void
3270ath_tx_tid_bar_tx(struct ath_softc *sc, struct ath_tid *tid)
3271{
3272 struct ieee80211_tx_ampdu *tap;
3273
3296 ATH_TXQ_LOCK_ASSERT(sc->sc_ac2q[tid->ac]);
3274 ATH_TX_LOCK_ASSERT(sc);
3297
3298 DPRINTF(sc, ATH_DEBUG_SW_TX_BAR,
3299 "%s: tid=%p, called\n",
3300 __func__,
3301 tid);
3302
3303 tap = ath_tx_get_tx_tid(tid->an, tid->tid);
3304

--- 39 unchanged lines hidden (view full) ---

3344 "%s: tid=%p, new BAW left edge=%d\n",
3345 __func__,
3346 tid,
3347 tap->txa_start);
3348
3349 /* Try sending the BAR frame */
3350 /* We can't hold the lock here! */
3351
3275
3276 DPRINTF(sc, ATH_DEBUG_SW_TX_BAR,
3277 "%s: tid=%p, called\n",
3278 __func__,
3279 tid);
3280
3281 tap = ath_tx_get_tx_tid(tid->an, tid->tid);
3282

--- 39 unchanged lines hidden (view full) ---

3322 "%s: tid=%p, new BAW left edge=%d\n",
3323 __func__,
3324 tid,
3325 tap->txa_start);
3326
3327 /* Try sending the BAR frame */
3328 /* We can't hold the lock here! */
3329
3352 ATH_TXQ_UNLOCK(sc->sc_ac2q[tid->ac]);
3330 ATH_TX_UNLOCK(sc);
3353 if (ieee80211_send_bar(&tid->an->an_node, tap, tap->txa_start) == 0) {
3354 /* Success? Now we wait for notification that it's done */
3331 if (ieee80211_send_bar(&tid->an->an_node, tap, tap->txa_start) == 0) {
3332 /* Success? Now we wait for notification that it's done */
3355 ATH_TXQ_LOCK(sc->sc_ac2q[tid->ac]);
3333 ATH_TX_LOCK(sc);
3356 return;
3357 }
3358
3359 /* Failure? For now, warn loudly and continue */
3334 return;
3335 }
3336
3337 /* Failure? For now, warn loudly and continue */
3360 ATH_TXQ_LOCK(sc->sc_ac2q[tid->ac]);
3338 ATH_TX_LOCK(sc);
3361 device_printf(sc->sc_dev, "%s: tid=%p, failed to TX BAR, continue!\n",
3362 __func__, tid);
3363 ath_tx_tid_bar_unsuspend(sc, tid);
3364}
3365
3366static void
3367ath_tx_tid_drain_pkt(struct ath_softc *sc, struct ath_node *an,
3368 struct ath_tid *tid, ath_bufhead *bf_cq, struct ath_buf *bf)
3369{
3370
3339 device_printf(sc->sc_dev, "%s: tid=%p, failed to TX BAR, continue!\n",
3340 __func__, tid);
3341 ath_tx_tid_bar_unsuspend(sc, tid);
3342}
3343
3344static void
3345ath_tx_tid_drain_pkt(struct ath_softc *sc, struct ath_node *an,
3346 struct ath_tid *tid, ath_bufhead *bf_cq, struct ath_buf *bf)
3347{
3348
3371 ATH_TID_LOCK_ASSERT(sc, tid);
3349 ATH_TX_LOCK_ASSERT(sc);
3372
3373 /*
3374 * If the current TID is running AMPDU, update
3375 * the BAW.
3376 */
3377 if (ath_tx_ampdu_running(sc, an, tid->tid) &&
3378 bf->bf_state.bfs_dobaw) {
3379 /*

--- 86 unchanged lines hidden (view full) ---

3466{
3467 struct ath_buf *bf;
3468 struct ieee80211_tx_ampdu *tap;
3469 struct ieee80211_node *ni = &an->an_node;
3470 int t;
3471
3472 tap = ath_tx_get_tx_tid(an, tid->tid);
3473
3350
3351 /*
3352 * If the current TID is running AMPDU, update
3353 * the BAW.
3354 */
3355 if (ath_tx_ampdu_running(sc, an, tid->tid) &&
3356 bf->bf_state.bfs_dobaw) {
3357 /*

--- 86 unchanged lines hidden (view full) ---

3444{
3445 struct ath_buf *bf;
3446 struct ieee80211_tx_ampdu *tap;
3447 struct ieee80211_node *ni = &an->an_node;
3448 int t;
3449
3450 tap = ath_tx_get_tx_tid(an, tid->tid);
3451
3474 ATH_TID_LOCK_ASSERT(sc, tid);
3452 ATH_TX_LOCK_ASSERT(sc);
3475
3476 /* Walk the queue, free frames */
3477 t = 0;
3478 for (;;) {
3479 bf = ATH_TID_FIRST(tid);
3480 if (bf == NULL) {
3481 break;
3482 }

--- 71 unchanged lines hidden (view full) ---

3554 ath_bufhead bf_cq;
3555 struct ath_buf *bf;
3556
3557 TAILQ_INIT(&bf_cq);
3558
3559 ATH_KTR(sc, ATH_KTR_NODE, 1, "ath_tx_node_flush: flush node; ni=%p",
3560 &an->an_node);
3561
3453
3454 /* Walk the queue, free frames */
3455 t = 0;
3456 for (;;) {
3457 bf = ATH_TID_FIRST(tid);
3458 if (bf == NULL) {
3459 break;
3460 }

--- 71 unchanged lines hidden (view full) ---

3532 ath_bufhead bf_cq;
3533 struct ath_buf *bf;
3534
3535 TAILQ_INIT(&bf_cq);
3536
3537 ATH_KTR(sc, ATH_KTR_NODE, 1, "ath_tx_node_flush: flush node; ni=%p",
3538 &an->an_node);
3539
3540 ATH_TX_LOCK(sc);
3562 for (tid = 0; tid < IEEE80211_TID_SIZE; tid++) {
3563 struct ath_tid *atid = &an->an_tid[tid];
3541 for (tid = 0; tid < IEEE80211_TID_SIZE; tid++) {
3542 struct ath_tid *atid = &an->an_tid[tid];
3564 struct ath_txq *txq = sc->sc_ac2q[atid->ac];
3565
3543
3566 ATH_TXQ_LOCK(txq);
3567 /* Free packets */
3568 ath_tx_tid_drain(sc, an, atid, &bf_cq);
3569 /* Remove this tid from the list of active tids */
3570 ath_tx_tid_unsched(sc, atid);
3544 /* Free packets */
3545 ath_tx_tid_drain(sc, an, atid, &bf_cq);
3546 /* Remove this tid from the list of active tids */
3547 ath_tx_tid_unsched(sc, atid);
3571 ATH_TXQ_UNLOCK(txq);
3572 }
3548 }
3549 ATH_TX_UNLOCK(sc);
3573
3574 /* Handle completed frames */
3575 while ((bf = TAILQ_FIRST(&bf_cq)) != NULL) {
3576 TAILQ_REMOVE(&bf_cq, bf, bf_list);
3577 ath_tx_default_comp(sc, bf, 0);
3578 }
3579}
3580
3581/*
3582 * Drain all the software TXQs currently with traffic queued.
3583 */
3584void
3585ath_tx_txq_drain(struct ath_softc *sc, struct ath_txq *txq)
3586{
3587 struct ath_tid *tid;
3588 ath_bufhead bf_cq;
3589 struct ath_buf *bf;
3590
3591 TAILQ_INIT(&bf_cq);
3550
3551 /* Handle completed frames */
3552 while ((bf = TAILQ_FIRST(&bf_cq)) != NULL) {
3553 TAILQ_REMOVE(&bf_cq, bf, bf_list);
3554 ath_tx_default_comp(sc, bf, 0);
3555 }
3556}
3557
3558/*
3559 * Drain all the software TXQs currently with traffic queued.
3560 */
3561void
3562ath_tx_txq_drain(struct ath_softc *sc, struct ath_txq *txq)
3563{
3564 struct ath_tid *tid;
3565 ath_bufhead bf_cq;
3566 struct ath_buf *bf;
3567
3568 TAILQ_INIT(&bf_cq);
3592 ATH_TXQ_LOCK(txq);
3569 ATH_TX_LOCK(sc);
3593
3594 /*
3595 * Iterate over all active tids for the given txq,
3596 * flushing and unsched'ing them
3597 */
3598 while (! TAILQ_EMPTY(&txq->axq_tidq)) {
3599 tid = TAILQ_FIRST(&txq->axq_tidq);
3600 ath_tx_tid_drain(sc, tid->an, tid, &bf_cq);
3601 ath_tx_tid_unsched(sc, tid);
3602 }
3603
3570
3571 /*
3572 * Iterate over all active tids for the given txq,
3573 * flushing and unsched'ing them
3574 */
3575 while (! TAILQ_EMPTY(&txq->axq_tidq)) {
3576 tid = TAILQ_FIRST(&txq->axq_tidq);
3577 ath_tx_tid_drain(sc, tid->an, tid, &bf_cq);
3578 ath_tx_tid_unsched(sc, tid);
3579 }
3580
3604 ATH_TXQ_UNLOCK(txq);
3581 ATH_TX_UNLOCK(sc);
3605
3606 while ((bf = TAILQ_FIRST(&bf_cq)) != NULL) {
3607 TAILQ_REMOVE(&bf_cq, bf, bf_list);
3608 ath_tx_default_comp(sc, bf, 0);
3609 }
3610}
3611
3612/*

--- 17 unchanged lines hidden (view full) ---

3630{
3631 struct ieee80211_node *ni = bf->bf_node;
3632 struct ath_node *an = ATH_NODE(ni);
3633 int tid = bf->bf_state.bfs_tid;
3634 struct ath_tid *atid = &an->an_tid[tid];
3635 struct ath_tx_status *ts = &bf->bf_status.ds_txstat;
3636
3637 /* The TID state is protected behind the TXQ lock */
3582
3583 while ((bf = TAILQ_FIRST(&bf_cq)) != NULL) {
3584 TAILQ_REMOVE(&bf_cq, bf, bf_list);
3585 ath_tx_default_comp(sc, bf, 0);
3586 }
3587}
3588
3589/*

--- 17 unchanged lines hidden (view full) ---

3607{
3608 struct ieee80211_node *ni = bf->bf_node;
3609 struct ath_node *an = ATH_NODE(ni);
3610 int tid = bf->bf_state.bfs_tid;
3611 struct ath_tid *atid = &an->an_tid[tid];
3612 struct ath_tx_status *ts = &bf->bf_status.ds_txstat;
3613
3614 /* The TID state is protected behind the TXQ lock */
3638 ATH_TXQ_LOCK(sc->sc_ac2q[atid->ac]);
3615 ATH_TX_LOCK(sc);
3639
3640 DPRINTF(sc, ATH_DEBUG_SW_TX, "%s: bf=%p: fail=%d, hwq_depth now %d\n",
3641 __func__, bf, fail, atid->hwq_depth - 1);
3642
3643 atid->hwq_depth--;
3644
3645#if 0
3646 /*

--- 24 unchanged lines hidden (view full) ---

3671 * for this end-node that has CLRDMASK set, so it's quite possible
3672 * that a filtered frame will be followed by a non-filtered
3673 * (complete or otherwise) frame.
3674 *
3675 * XXX should we do this before we complete the frame?
3676 */
3677 if (atid->isfiltered)
3678 ath_tx_tid_filt_comp_complete(sc, atid);
3616
3617 DPRINTF(sc, ATH_DEBUG_SW_TX, "%s: bf=%p: fail=%d, hwq_depth now %d\n",
3618 __func__, bf, fail, atid->hwq_depth - 1);
3619
3620 atid->hwq_depth--;
3621
3622#if 0
3623 /*

--- 24 unchanged lines hidden (view full) ---

3648 * for this end-node that has CLRDMASK set, so it's quite possible
3649 * that a filtered frame will be followed by a non-filtered
3650 * (complete or otherwise) frame.
3651 *
3652 * XXX should we do this before we complete the frame?
3653 */
3654 if (atid->isfiltered)
3655 ath_tx_tid_filt_comp_complete(sc, atid);
3679 ATH_TXQ_UNLOCK(sc->sc_ac2q[atid->ac]);
3656 ATH_TX_UNLOCK(sc);
3680
3681 /*
3682 * punt to rate control if we're not being cleaned up
3683 * during a hw queue drain and the frame wanted an ACK.
3684 */
3685 if (fail == 0 && ((bf->bf_state.bfs_txflags & HAL_TXDESC_NOACK) == 0))
3686 ath_tx_update_ratectrl(sc, ni, bf->bf_state.bfs_rc,
3687 ts, bf->bf_state.bfs_pktlen,

--- 15 unchanged lines hidden (view full) ---

3703 struct ieee80211_node *ni = bf->bf_node;
3704 struct ath_node *an = ATH_NODE(ni);
3705 int tid = bf->bf_state.bfs_tid;
3706 struct ath_tid *atid = &an->an_tid[tid];
3707
3708 DPRINTF(sc, ATH_DEBUG_SW_TX_CTRL, "%s: TID %d: incomp=%d\n",
3709 __func__, tid, atid->incomp);
3710
3657
3658 /*
3659 * punt to rate control if we're not being cleaned up
3660 * during a hw queue drain and the frame wanted an ACK.
3661 */
3662 if (fail == 0 && ((bf->bf_state.bfs_txflags & HAL_TXDESC_NOACK) == 0))
3663 ath_tx_update_ratectrl(sc, ni, bf->bf_state.bfs_rc,
3664 ts, bf->bf_state.bfs_pktlen,

--- 15 unchanged lines hidden (view full) ---

3680 struct ieee80211_node *ni = bf->bf_node;
3681 struct ath_node *an = ATH_NODE(ni);
3682 int tid = bf->bf_state.bfs_tid;
3683 struct ath_tid *atid = &an->an_tid[tid];
3684
3685 DPRINTF(sc, ATH_DEBUG_SW_TX_CTRL, "%s: TID %d: incomp=%d\n",
3686 __func__, tid, atid->incomp);
3687
3711 ATH_TXQ_LOCK(sc->sc_ac2q[atid->ac]);
3688 ATH_TX_LOCK(sc);
3712 atid->incomp--;
3713 if (atid->incomp == 0) {
3714 DPRINTF(sc, ATH_DEBUG_SW_TX_CTRL,
3715 "%s: TID %d: cleaned up! resume!\n",
3716 __func__, tid);
3717 atid->cleanup_inprogress = 0;
3718 ath_tx_tid_resume(sc, atid);
3719 }
3689 atid->incomp--;
3690 if (atid->incomp == 0) {
3691 DPRINTF(sc, ATH_DEBUG_SW_TX_CTRL,
3692 "%s: TID %d: cleaned up! resume!\n",
3693 __func__, tid);
3694 atid->cleanup_inprogress = 0;
3695 ath_tx_tid_resume(sc, atid);
3696 }
3720 ATH_TXQ_UNLOCK(sc->sc_ac2q[atid->ac]);
3697 ATH_TX_UNLOCK(sc);
3721
3722 ath_tx_default_comp(sc, bf, 0);
3723}
3724
3725/*
3726 * Performs transmit side cleanup when TID changes from aggregated to
3727 * unaggregated.
3728 *

--- 11 unchanged lines hidden (view full) ---

3740 struct ieee80211_tx_ampdu *tap;
3741 struct ath_buf *bf, *bf_next;
3742 ath_bufhead bf_cq;
3743
3744 DPRINTF(sc, ATH_DEBUG_SW_TX_BAW,
3745 "%s: TID %d: called\n", __func__, tid);
3746
3747 TAILQ_INIT(&bf_cq);
3698
3699 ath_tx_default_comp(sc, bf, 0);
3700}
3701
3702/*
3703 * Performs transmit side cleanup when TID changes from aggregated to
3704 * unaggregated.
3705 *

--- 11 unchanged lines hidden (view full) ---

3717 struct ieee80211_tx_ampdu *tap;
3718 struct ath_buf *bf, *bf_next;
3719 ath_bufhead bf_cq;
3720
3721 DPRINTF(sc, ATH_DEBUG_SW_TX_BAW,
3722 "%s: TID %d: called\n", __func__, tid);
3723
3724 TAILQ_INIT(&bf_cq);
3748 ATH_TXQ_LOCK(sc->sc_ac2q[atid->ac]);
3725 ATH_TX_LOCK(sc);
3749
3750 /*
3751 * Move the filtered frames to the TX queue, before
3752 * we run off and discard/process things.
3753 */
3754 /* XXX this is really quite inefficient */
3755 while ((bf = ATH_TID_FILT_LAST(atid, ath_bufhead_s)) != NULL) {
3756 ATH_TID_FILT_REMOVE(atid, bf, bf_list);

--- 65 unchanged lines hidden (view full) ---

3822 */
3823 if (! atid->cleanup_inprogress)
3824 ath_tx_tid_resume(sc, atid);
3825
3826 if (atid->cleanup_inprogress)
3827 DPRINTF(sc, ATH_DEBUG_SW_TX_CTRL,
3828 "%s: TID %d: cleanup needed: %d packets\n",
3829 __func__, tid, atid->incomp);
3726
3727 /*
3728 * Move the filtered frames to the TX queue, before
3729 * we run off and discard/process things.
3730 */
3731 /* XXX this is really quite inefficient */
3732 while ((bf = ATH_TID_FILT_LAST(atid, ath_bufhead_s)) != NULL) {
3733 ATH_TID_FILT_REMOVE(atid, bf, bf_list);

--- 65 unchanged lines hidden (view full) ---

3799 */
3800 if (! atid->cleanup_inprogress)
3801 ath_tx_tid_resume(sc, atid);
3802
3803 if (atid->cleanup_inprogress)
3804 DPRINTF(sc, ATH_DEBUG_SW_TX_CTRL,
3805 "%s: TID %d: cleanup needed: %d packets\n",
3806 __func__, tid, atid->incomp);
3830 ATH_TXQ_UNLOCK(sc->sc_ac2q[atid->ac]);
3807 ATH_TX_UNLOCK(sc);
3831
3832 /* Handle completing frames and fail them */
3833 while ((bf = TAILQ_FIRST(&bf_cq)) != NULL) {
3834 TAILQ_REMOVE(&bf_cq, bf, bf_list);
3835 ath_tx_default_comp(sc, bf, 1);
3836 }
3837}
3838

--- 63 unchanged lines hidden (view full) ---

3902ath_tx_aggr_retry_unaggr(struct ath_softc *sc, struct ath_buf *bf)
3903{
3904 struct ieee80211_node *ni = bf->bf_node;
3905 struct ath_node *an = ATH_NODE(ni);
3906 int tid = bf->bf_state.bfs_tid;
3907 struct ath_tid *atid = &an->an_tid[tid];
3908 struct ieee80211_tx_ampdu *tap;
3909
3808
3809 /* Handle completing frames and fail them */
3810 while ((bf = TAILQ_FIRST(&bf_cq)) != NULL) {
3811 TAILQ_REMOVE(&bf_cq, bf, bf_list);
3812 ath_tx_default_comp(sc, bf, 1);
3813 }
3814}
3815

--- 63 unchanged lines hidden (view full) ---

3879ath_tx_aggr_retry_unaggr(struct ath_softc *sc, struct ath_buf *bf)
3880{
3881 struct ieee80211_node *ni = bf->bf_node;
3882 struct ath_node *an = ATH_NODE(ni);
3883 int tid = bf->bf_state.bfs_tid;
3884 struct ath_tid *atid = &an->an_tid[tid];
3885 struct ieee80211_tx_ampdu *tap;
3886
3910 ATH_TXQ_LOCK(sc->sc_ac2q[atid->ac]);
3887 ATH_TX_LOCK(sc);
3911
3912 tap = ath_tx_get_tx_tid(an, tid);
3913
3914 /*
3915 * If the buffer is marked as busy, we can't directly
3916 * reuse it. Instead, try to clone the buffer.
3917 * If the clone is successful, recycle the old buffer.
3918 * If the clone is unsuccessful, set bfs_retries to max

--- 29 unchanged lines hidden (view full) ---

3948
3949 /* Suspend the TX queue and get ready to send the BAR */
3950 ath_tx_tid_bar_suspend(sc, atid);
3951
3952 /* Send the BAR if there are no other frames waiting */
3953 if (ath_tx_tid_bar_tx_ready(sc, atid))
3954 ath_tx_tid_bar_tx(sc, atid);
3955
3888
3889 tap = ath_tx_get_tx_tid(an, tid);
3890
3891 /*
3892 * If the buffer is marked as busy, we can't directly
3893 * reuse it. Instead, try to clone the buffer.
3894 * If the clone is successful, recycle the old buffer.
3895 * If the clone is unsuccessful, set bfs_retries to max

--- 29 unchanged lines hidden (view full) ---

3925
3926 /* Suspend the TX queue and get ready to send the BAR */
3927 ath_tx_tid_bar_suspend(sc, atid);
3928
3929 /* Send the BAR if there are no other frames waiting */
3930 if (ath_tx_tid_bar_tx_ready(sc, atid))
3931 ath_tx_tid_bar_tx(sc, atid);
3932
3956 ATH_TXQ_UNLOCK(sc->sc_ac2q[atid->ac]);
3933 ATH_TX_UNLOCK(sc);
3957
3958 /* Free buffer, bf is free after this call */
3959 ath_tx_default_comp(sc, bf, 0);
3960 return;
3961 }
3962
3963 /*
3964 * This increments the retry counter as well as

--- 8 unchanged lines hidden (view full) ---

3973 * retried before any current/subsequent frames.
3974 */
3975 ATH_TID_INSERT_HEAD(atid, bf, bf_list);
3976 ath_tx_tid_sched(sc, atid);
3977 /* Send the BAR if there are no other frames waiting */
3978 if (ath_tx_tid_bar_tx_ready(sc, atid))
3979 ath_tx_tid_bar_tx(sc, atid);
3980
3934
3935 /* Free buffer, bf is free after this call */
3936 ath_tx_default_comp(sc, bf, 0);
3937 return;
3938 }
3939
3940 /*
3941 * This increments the retry counter as well as

--- 8 unchanged lines hidden (view full) ---

3950 * retried before any current/subsequent frames.
3951 */
3952 ATH_TID_INSERT_HEAD(atid, bf, bf_list);
3953 ath_tx_tid_sched(sc, atid);
3954 /* Send the BAR if there are no other frames waiting */
3955 if (ath_tx_tid_bar_tx_ready(sc, atid))
3956 ath_tx_tid_bar_tx(sc, atid);
3957
3981 ATH_TXQ_UNLOCK(sc->sc_ac2q[atid->ac]);
3958 ATH_TX_UNLOCK(sc);
3982}
3983
3984/*
3985 * Common code for aggregate excessive retry/subframe retry.
3986 * If retrying, queues buffers to bf_q. If not, frees the
3987 * buffers.
3988 *
3989 * XXX should unify this with ath_tx_aggr_retry_unaggr()
3990 */
3991static int
3992ath_tx_retry_subframe(struct ath_softc *sc, struct ath_buf *bf,
3993 ath_bufhead *bf_q)
3994{
3995 struct ieee80211_node *ni = bf->bf_node;
3996 struct ath_node *an = ATH_NODE(ni);
3997 int tid = bf->bf_state.bfs_tid;
3998 struct ath_tid *atid = &an->an_tid[tid];
3999
3959}
3960
3961/*
3962 * Common code for aggregate excessive retry/subframe retry.
3963 * If retrying, queues buffers to bf_q. If not, frees the
3964 * buffers.
3965 *
3966 * XXX should unify this with ath_tx_aggr_retry_unaggr()
3967 */
3968static int
3969ath_tx_retry_subframe(struct ath_softc *sc, struct ath_buf *bf,
3970 ath_bufhead *bf_q)
3971{
3972 struct ieee80211_node *ni = bf->bf_node;
3973 struct ath_node *an = ATH_NODE(ni);
3974 int tid = bf->bf_state.bfs_tid;
3975 struct ath_tid *atid = &an->an_tid[tid];
3976
4000 ATH_TXQ_LOCK_ASSERT(sc->sc_ac2q[atid->ac]);
3977 ATH_TX_LOCK_ASSERT(sc);
4001
4002 /* XXX clr11naggr should be done for all subframes */
4003 ath_hal_clr11n_aggr(sc->sc_ah, bf->bf_desc);
4004 ath_hal_set11nburstduration(sc->sc_ah, bf->bf_desc, 0);
4005
4006 /* ath_hal_set11n_virtualmorefrag(sc->sc_ah, bf->bf_desc, 0); */
4007
4008 /*

--- 66 unchanged lines hidden (view full) ---

4075 * XXX use the length in the first frame in the series;
4076 * XXX just so things are consistent for now.
4077 */
4078 ath_tx_update_ratectrl(sc, ni, bf_first->bf_state.bfs_rc,
4079 &bf_first->bf_status.ds_txstat,
4080 bf_first->bf_state.bfs_pktlen,
4081 bf_first->bf_state.bfs_nframes, bf_first->bf_state.bfs_nframes);
4082
3978
3979 /* XXX clr11naggr should be done for all subframes */
3980 ath_hal_clr11n_aggr(sc->sc_ah, bf->bf_desc);
3981 ath_hal_set11nburstduration(sc->sc_ah, bf->bf_desc, 0);
3982
3983 /* ath_hal_set11n_virtualmorefrag(sc->sc_ah, bf->bf_desc, 0); */
3984
3985 /*

--- 66 unchanged lines hidden (view full) ---

4052 * XXX use the length in the first frame in the series;
4053 * XXX just so things are consistent for now.
4054 */
4055 ath_tx_update_ratectrl(sc, ni, bf_first->bf_state.bfs_rc,
4056 &bf_first->bf_status.ds_txstat,
4057 bf_first->bf_state.bfs_pktlen,
4058 bf_first->bf_state.bfs_nframes, bf_first->bf_state.bfs_nframes);
4059
4083 ATH_TXQ_LOCK(sc->sc_ac2q[tid->ac]);
4060 ATH_TX_LOCK(sc);
4084 tap = ath_tx_get_tx_tid(an, tid->tid);
4085 sc->sc_stats.ast_tx_aggr_failall++;
4086
4087 /* Retry all subframes */
4088 bf = bf_first;
4089 while (bf) {
4090 bf_next = bf->bf_next;
4091 bf->bf_next = NULL; /* Remove it from the aggr list */

--- 30 unchanged lines hidden (view full) ---

4122 }
4123
4124 /*
4125 * Send BAR if required
4126 */
4127 if (ath_tx_tid_bar_tx_ready(sc, tid))
4128 ath_tx_tid_bar_tx(sc, tid);
4129
4061 tap = ath_tx_get_tx_tid(an, tid->tid);
4062 sc->sc_stats.ast_tx_aggr_failall++;
4063
4064 /* Retry all subframes */
4065 bf = bf_first;
4066 while (bf) {
4067 bf_next = bf->bf_next;
4068 bf->bf_next = NULL; /* Remove it from the aggr list */

--- 30 unchanged lines hidden (view full) ---

4099 }
4100
4101 /*
4102 * Send BAR if required
4103 */
4104 if (ath_tx_tid_bar_tx_ready(sc, tid))
4105 ath_tx_tid_bar_tx(sc, tid);
4106
4130 ATH_TXQ_UNLOCK(sc->sc_ac2q[tid->ac]);
4107 ATH_TX_UNLOCK(sc);
4131
4132 /* Complete frames which errored out */
4133 while ((bf = TAILQ_FIRST(&bf_cq)) != NULL) {
4134 TAILQ_REMOVE(&bf_cq, bf, bf_list);
4135 ath_tx_default_comp(sc, bf, 0);
4136 }
4137}
4138

--- 9 unchanged lines hidden (view full) ---

4148 struct ath_buf *bf, *bf_next;
4149 struct ieee80211_node *ni = bf_first->bf_node;
4150 struct ath_node *an = ATH_NODE(ni);
4151 int tid = bf_first->bf_state.bfs_tid;
4152 struct ath_tid *atid = &an->an_tid[tid];
4153
4154 bf = bf_first;
4155
4108
4109 /* Complete frames which errored out */
4110 while ((bf = TAILQ_FIRST(&bf_cq)) != NULL) {
4111 TAILQ_REMOVE(&bf_cq, bf, bf_list);
4112 ath_tx_default_comp(sc, bf, 0);
4113 }
4114}
4115

--- 9 unchanged lines hidden (view full) ---

4125 struct ath_buf *bf, *bf_next;
4126 struct ieee80211_node *ni = bf_first->bf_node;
4127 struct ath_node *an = ATH_NODE(ni);
4128 int tid = bf_first->bf_state.bfs_tid;
4129 struct ath_tid *atid = &an->an_tid[tid];
4130
4131 bf = bf_first;
4132
4156 ATH_TXQ_LOCK(sc->sc_ac2q[atid->ac]);
4133 ATH_TX_LOCK(sc);
4157
4158 /* update incomp */
4159 while (bf) {
4160 atid->incomp--;
4161 bf = bf->bf_next;
4162 }
4163
4164 if (atid->incomp == 0) {

--- 4 unchanged lines hidden (view full) ---

4169 ath_tx_tid_resume(sc, atid);
4170 }
4171
4172 /* Send BAR if required */
4173 /* XXX why would we send a BAR when transitioning to non-aggregation? */
4174 if (ath_tx_tid_bar_tx_ready(sc, atid))
4175 ath_tx_tid_bar_tx(sc, atid);
4176
4134
4135 /* update incomp */
4136 while (bf) {
4137 atid->incomp--;
4138 bf = bf->bf_next;
4139 }
4140
4141 if (atid->incomp == 0) {

--- 4 unchanged lines hidden (view full) ---

4146 ath_tx_tid_resume(sc, atid);
4147 }
4148
4149 /* Send BAR if required */
4150 /* XXX why would we send a BAR when transitioning to non-aggregation? */
4151 if (ath_tx_tid_bar_tx_ready(sc, atid))
4152 ath_tx_tid_bar_tx(sc, atid);
4153
4177 ATH_TXQ_UNLOCK(sc->sc_ac2q[atid->ac]);
4154 ATH_TX_UNLOCK(sc);
4178
4179 /* Handle frame completion */
4180 while (bf) {
4181 bf_next = bf->bf_next;
4182 ath_tx_default_comp(sc, bf, 1);
4183 bf = bf_next;
4184 }
4185}

--- 39 unchanged lines hidden (view full) ---

4225 * has been completed and freed.
4226 */
4227 ts = bf_first->bf_status.ds_txstat;
4228
4229 TAILQ_INIT(&bf_q);
4230 TAILQ_INIT(&bf_cq);
4231
4232 /* The TID state is kept behind the TXQ lock */
4155
4156 /* Handle frame completion */
4157 while (bf) {
4158 bf_next = bf->bf_next;
4159 ath_tx_default_comp(sc, bf, 1);
4160 bf = bf_next;
4161 }
4162}

--- 39 unchanged lines hidden (view full) ---

4202 * has been completed and freed.
4203 */
4204 ts = bf_first->bf_status.ds_txstat;
4205
4206 TAILQ_INIT(&bf_q);
4207 TAILQ_INIT(&bf_cq);
4208
4209 /* The TID state is kept behind the TXQ lock */
4233 ATH_TXQ_LOCK(sc->sc_ac2q[atid->ac]);
4210 ATH_TX_LOCK(sc);
4234
4235 atid->hwq_depth--;
4236 if (atid->hwq_depth < 0)
4237 device_printf(sc->sc_dev, "%s: hwq_depth < 0: %d\n",
4238 __func__, atid->hwq_depth);
4239
4240 /*
4241 * If the TID is filtered, handle completing the filter

--- 8 unchanged lines hidden (view full) ---

4250 /*
4251 * Punt cleanup to the relevant function, not our problem now
4252 */
4253 if (atid->cleanup_inprogress) {
4254 if (atid->isfiltered)
4255 device_printf(sc->sc_dev,
4256 "%s: isfiltered=1, normal_comp?\n",
4257 __func__);
4211
4212 atid->hwq_depth--;
4213 if (atid->hwq_depth < 0)
4214 device_printf(sc->sc_dev, "%s: hwq_depth < 0: %d\n",
4215 __func__, atid->hwq_depth);
4216
4217 /*
4218 * If the TID is filtered, handle completing the filter

--- 8 unchanged lines hidden (view full) ---

4227 /*
4228 * Punt cleanup to the relevant function, not our problem now
4229 */
4230 if (atid->cleanup_inprogress) {
4231 if (atid->isfiltered)
4232 device_printf(sc->sc_dev,
4233 "%s: isfiltered=1, normal_comp?\n",
4234 __func__);
4258 ATH_TXQ_UNLOCK(sc->sc_ac2q[atid->ac]);
4235 ATH_TX_UNLOCK(sc);
4259 ath_tx_comp_cleanup_aggr(sc, bf_first);
4260 return;
4261 }
4262
4263 /*
4264 * If the frame is filtered, transition to filtered frame
4265 * mode and add this to the filtered frame list.
4266 *

--- 47 unchanged lines hidden (view full) ---

4314 * Here, handle _any_ error as a "exceeded retries" error.
4315 * Later on (when filtered frames are to be specially handled)
4316 * it'll have to be expanded.
4317 */
4318#if 0
4319 if (ts.ts_status & HAL_TXERR_XRETRY) {
4320#endif
4321 if (ts.ts_status != 0) {
4236 ath_tx_comp_cleanup_aggr(sc, bf_first);
4237 return;
4238 }
4239
4240 /*
4241 * If the frame is filtered, transition to filtered frame
4242 * mode and add this to the filtered frame list.
4243 *

--- 47 unchanged lines hidden (view full) ---

4291 * Here, handle _any_ error as a "exceeded retries" error.
4292 * Later on (when filtered frames are to be specially handled)
4293 * it'll have to be expanded.
4294 */
4295#if 0
4296 if (ts.ts_status & HAL_TXERR_XRETRY) {
4297#endif
4298 if (ts.ts_status != 0) {
4322 ATH_TXQ_UNLOCK(sc->sc_ac2q[atid->ac]);
4299 ATH_TX_UNLOCK(sc);
4323 ath_tx_comp_aggr_error(sc, bf_first, atid);
4324 return;
4325 }
4326
4327 tap = ath_tx_get_tx_tid(an, tid);
4328
4329 /*
4330 * extract starting sequence and block-ack bitmap

--- 102 unchanged lines hidden (view full) ---

4433 * Now that the BAW updates have been done, unlock
4434 *
4435 * txseq is grabbed before the lock is released so we
4436 * have a consistent view of what -was- in the BAW.
4437 * Anything after this point will not yet have been
4438 * TXed.
4439 */
4440 txseq = tap->txa_start;
4300 ath_tx_comp_aggr_error(sc, bf_first, atid);
4301 return;
4302 }
4303
4304 tap = ath_tx_get_tx_tid(an, tid);
4305
4306 /*
4307 * extract starting sequence and block-ack bitmap

--- 102 unchanged lines hidden (view full) ---

4410 * Now that the BAW updates have been done, unlock
4411 *
4412 * txseq is grabbed before the lock is released so we
4413 * have a consistent view of what -was- in the BAW.
4414 * Anything after this point will not yet have been
4415 * TXed.
4416 */
4417 txseq = tap->txa_start;
4441 ATH_TXQ_UNLOCK(sc->sc_ac2q[atid->ac]);
4418 ATH_TX_UNLOCK(sc);
4442
4443 if (nframes != nf)
4444 device_printf(sc->sc_dev,
4445 "%s: num frames seen=%d; bf nframes=%d\n",
4446 __func__, nframes, nf);
4447
4448 /*
4449 * Now we know how many frames were bad, call the rate
4450 * control code.
4451 */
4452 if (fail == 0)
4453 ath_tx_update_ratectrl(sc, ni, rc, &ts, pktlen, nframes,
4454 nbad);
4455
4456 /*
4457 * send bar if we dropped any frames
4458 */
4459 if (drops) {
4460 /* Suspend the TX queue and get ready to send the BAR */
4419
4420 if (nframes != nf)
4421 device_printf(sc->sc_dev,
4422 "%s: num frames seen=%d; bf nframes=%d\n",
4423 __func__, nframes, nf);
4424
4425 /*
4426 * Now we know how many frames were bad, call the rate
4427 * control code.
4428 */
4429 if (fail == 0)
4430 ath_tx_update_ratectrl(sc, ni, rc, &ts, pktlen, nframes,
4431 nbad);
4432
4433 /*
4434 * send bar if we dropped any frames
4435 */
4436 if (drops) {
4437 /* Suspend the TX queue and get ready to send the BAR */
4461 ATH_TXQ_LOCK(sc->sc_ac2q[atid->ac]);
4438 ATH_TX_LOCK(sc);
4462 ath_tx_tid_bar_suspend(sc, atid);
4439 ath_tx_tid_bar_suspend(sc, atid);
4463 ATH_TXQ_UNLOCK(sc->sc_ac2q[atid->ac]);
4440 ATH_TX_UNLOCK(sc);
4464 }
4465
4466 DPRINTF(sc, ATH_DEBUG_SW_TX_AGGR,
4467 "%s: txa_start now %d\n", __func__, tap->txa_start);
4468
4441 }
4442
4443 DPRINTF(sc, ATH_DEBUG_SW_TX_AGGR,
4444 "%s: txa_start now %d\n", __func__, tap->txa_start);
4445
4469 ATH_TXQ_LOCK(sc->sc_ac2q[atid->ac]);
4446 ATH_TX_LOCK(sc);
4470
4471 /* Prepend all frames to the beginning of the queue */
4472 while ((bf = TAILQ_LAST(&bf_q, ath_bufhead_s)) != NULL) {
4473 TAILQ_REMOVE(&bf_q, bf, bf_list);
4474 ATH_TID_INSERT_HEAD(atid, bf, bf_list);
4475 }
4476
4477 /*

--- 17 unchanged lines hidden (view full) ---

4495finish_send_bar:
4496
4497 /*
4498 * Send BAR if required
4499 */
4500 if (ath_tx_tid_bar_tx_ready(sc, atid))
4501 ath_tx_tid_bar_tx(sc, atid);
4502
4447
4448 /* Prepend all frames to the beginning of the queue */
4449 while ((bf = TAILQ_LAST(&bf_q, ath_bufhead_s)) != NULL) {
4450 TAILQ_REMOVE(&bf_q, bf, bf_list);
4451 ATH_TID_INSERT_HEAD(atid, bf, bf_list);
4452 }
4453
4454 /*

--- 17 unchanged lines hidden (view full) ---

4472finish_send_bar:
4473
4474 /*
4475 * Send BAR if required
4476 */
4477 if (ath_tx_tid_bar_tx_ready(sc, atid))
4478 ath_tx_tid_bar_tx(sc, atid);
4479
4503 ATH_TXQ_UNLOCK(sc->sc_ac2q[atid->ac]);
4480 ATH_TX_UNLOCK(sc);
4504
4505 /* Do deferred completion */
4506 while ((bf = TAILQ_FIRST(&bf_cq)) != NULL) {
4507 TAILQ_REMOVE(&bf_cq, bf, bf_list);
4508 ath_tx_default_comp(sc, bf, 0);
4509 }
4510}
4511

--- 32 unchanged lines hidden (view full) ---

4544 bf->bf_state.bfs_pktlen,
4545 1, (ts.ts_status == 0) ? 0 : 1);
4546
4547 /*
4548 * This is called early so atid->hwq_depth can be tracked.
4549 * This unfortunately means that it's released and regrabbed
4550 * during retry and cleanup. That's rather inefficient.
4551 */
4481
4482 /* Do deferred completion */
4483 while ((bf = TAILQ_FIRST(&bf_cq)) != NULL) {
4484 TAILQ_REMOVE(&bf_cq, bf, bf_list);
4485 ath_tx_default_comp(sc, bf, 0);
4486 }
4487}
4488

--- 32 unchanged lines hidden (view full) ---

4521 bf->bf_state.bfs_pktlen,
4522 1, (ts.ts_status == 0) ? 0 : 1);
4523
4524 /*
4525 * This is called early so atid->hwq_depth can be tracked.
4526 * This unfortunately means that it's released and regrabbed
4527 * during retry and cleanup. That's rather inefficient.
4528 */
4552 ATH_TXQ_LOCK(sc->sc_ac2q[atid->ac]);
4529 ATH_TX_LOCK(sc);
4553
4554 if (tid == IEEE80211_NONQOS_TID)
4555 device_printf(sc->sc_dev, "%s: TID=16!\n", __func__);
4556
4557 DPRINTF(sc, ATH_DEBUG_SW_TX,
4558 "%s: bf=%p: tid=%d, hwq_depth=%d, seqno=%d\n",
4559 __func__, bf, bf->bf_state.bfs_tid, atid->hwq_depth,
4560 SEQNO(bf->bf_state.bfs_seqno));

--- 17 unchanged lines hidden (view full) ---

4578 * responsibility to clean up, call the completion
4579 * function in net80211, etc.
4580 */
4581 if (atid->cleanup_inprogress) {
4582 if (atid->isfiltered)
4583 device_printf(sc->sc_dev,
4584 "%s: isfiltered=1, normal_comp?\n",
4585 __func__);
4530
4531 if (tid == IEEE80211_NONQOS_TID)
4532 device_printf(sc->sc_dev, "%s: TID=16!\n", __func__);
4533
4534 DPRINTF(sc, ATH_DEBUG_SW_TX,
4535 "%s: bf=%p: tid=%d, hwq_depth=%d, seqno=%d\n",
4536 __func__, bf, bf->bf_state.bfs_tid, atid->hwq_depth,
4537 SEQNO(bf->bf_state.bfs_seqno));

--- 17 unchanged lines hidden (view full) ---

4555 * responsibility to clean up, call the completion
4556 * function in net80211, etc.
4557 */
4558 if (atid->cleanup_inprogress) {
4559 if (atid->isfiltered)
4560 device_printf(sc->sc_dev,
4561 "%s: isfiltered=1, normal_comp?\n",
4562 __func__);
4586 ATH_TXQ_UNLOCK(sc->sc_ac2q[atid->ac]);
4563 ATH_TX_UNLOCK(sc);
4587 DPRINTF(sc, ATH_DEBUG_SW_TX, "%s: cleanup_unaggr\n",
4588 __func__);
4589 ath_tx_comp_cleanup_unaggr(sc, bf);
4590 return;
4591 }
4592
4593 /*
4594 * XXX TODO: how does cleanup, BAR and filtered frame handling

--- 39 unchanged lines hidden (view full) ---

4634 ath_tx_tid_bar_suspend(sc, atid);
4635
4636 /*
4637 * Send BAR if required
4638 */
4639 if (ath_tx_tid_bar_tx_ready(sc, atid))
4640 ath_tx_tid_bar_tx(sc, atid);
4641
4564 DPRINTF(sc, ATH_DEBUG_SW_TX, "%s: cleanup_unaggr\n",
4565 __func__);
4566 ath_tx_comp_cleanup_unaggr(sc, bf);
4567 return;
4568 }
4569
4570 /*
4571 * XXX TODO: how does cleanup, BAR and filtered frame handling

--- 39 unchanged lines hidden (view full) ---

4611 ath_tx_tid_bar_suspend(sc, atid);
4612
4613 /*
4614 * Send BAR if required
4615 */
4616 if (ath_tx_tid_bar_tx_ready(sc, atid))
4617 ath_tx_tid_bar_tx(sc, atid);
4618
4642 ATH_TXQ_UNLOCK(sc->sc_ac2q[atid->ac]);
4619 ATH_TX_UNLOCK(sc);
4643 /*
4644 * If freeframe is set, then the frame couldn't be
4645 * cloned and bf is still valid. Just complete/free it.
4646 */
4647 if (freeframe)
4648 ath_tx_default_comp(sc, bf, fail);
4649
4650
4651 return;
4652 }
4653 /*
4654 * Don't bother with the retry check if all frames
4655 * are being failed (eg during queue deletion.)
4656 */
4657#if 0
4658 if (fail == 0 && ts->ts_status & HAL_TXERR_XRETRY) {
4659#endif
4660 if (fail == 0 && ts.ts_status != 0) {
4620 /*
4621 * If freeframe is set, then the frame couldn't be
4622 * cloned and bf is still valid. Just complete/free it.
4623 */
4624 if (freeframe)
4625 ath_tx_default_comp(sc, bf, fail);
4626
4627
4628 return;
4629 }
4630 /*
4631 * Don't bother with the retry check if all frames
4632 * are being failed (eg during queue deletion.)
4633 */
4634#if 0
4635 if (fail == 0 && ts->ts_status & HAL_TXERR_XRETRY) {
4636#endif
4637 if (fail == 0 && ts.ts_status != 0) {
4661 ATH_TXQ_UNLOCK(sc->sc_ac2q[atid->ac]);
4638 ATH_TX_UNLOCK(sc);
4662 DPRINTF(sc, ATH_DEBUG_SW_TX, "%s: retry_unaggr\n",
4663 __func__);
4664 ath_tx_aggr_retry_unaggr(sc, bf);
4665 return;
4666 }
4667
4668 /* Success? Complete */
4669 DPRINTF(sc, ATH_DEBUG_SW_TX, "%s: TID=%d, seqno %d\n",

--- 21 unchanged lines hidden (view full) ---

4691 ath_tx_tid_filt_comp_complete(sc, atid);
4692
4693 /*
4694 * Send BAR if required
4695 */
4696 if (ath_tx_tid_bar_tx_ready(sc, atid))
4697 ath_tx_tid_bar_tx(sc, atid);
4698
4639 DPRINTF(sc, ATH_DEBUG_SW_TX, "%s: retry_unaggr\n",
4640 __func__);
4641 ath_tx_aggr_retry_unaggr(sc, bf);
4642 return;
4643 }
4644
4645 /* Success? Complete */
4646 DPRINTF(sc, ATH_DEBUG_SW_TX, "%s: TID=%d, seqno %d\n",

--- 21 unchanged lines hidden (view full) ---

4668 ath_tx_tid_filt_comp_complete(sc, atid);
4669
4670 /*
4671 * Send BAR if required
4672 */
4673 if (ath_tx_tid_bar_tx_ready(sc, atid))
4674 ath_tx_tid_bar_tx(sc, atid);
4675
4699 ATH_TXQ_UNLOCK(sc->sc_ac2q[atid->ac]);
4676 ATH_TX_UNLOCK(sc);
4700
4701 ath_tx_default_comp(sc, bf, fail);
4702 /* bf is freed at this point */
4703}
4704
4705void
4706ath_tx_aggr_comp(struct ath_softc *sc, struct ath_buf *bf, int fail)
4707{

--- 14 unchanged lines hidden (view full) ---

4722{
4723 struct ath_buf *bf;
4724 struct ath_txq *txq = sc->sc_ac2q[tid->ac];
4725 struct ieee80211_tx_ampdu *tap;
4726 ATH_AGGR_STATUS status;
4727 ath_bufhead bf_q;
4728
4729 DPRINTF(sc, ATH_DEBUG_SW_TX, "%s: tid=%d\n", __func__, tid->tid);
4677
4678 ath_tx_default_comp(sc, bf, fail);
4679 /* bf is freed at this point */
4680}
4681
4682void
4683ath_tx_aggr_comp(struct ath_softc *sc, struct ath_buf *bf, int fail)
4684{

--- 14 unchanged lines hidden (view full) ---

4699{
4700 struct ath_buf *bf;
4701 struct ath_txq *txq = sc->sc_ac2q[tid->ac];
4702 struct ieee80211_tx_ampdu *tap;
4703 ATH_AGGR_STATUS status;
4704 ath_bufhead bf_q;
4705
4706 DPRINTF(sc, ATH_DEBUG_SW_TX, "%s: tid=%d\n", __func__, tid->tid);
4730 ATH_TXQ_LOCK_ASSERT(txq);
4707 ATH_TX_LOCK_ASSERT(sc);
4731
4732 tap = ath_tx_get_tx_tid(an, tid->tid);
4733
4734 if (tid->tid == IEEE80211_NONQOS_TID)
4735 device_printf(sc->sc_dev, "%s: called for TID=NONQOS_TID?\n",
4736 __func__);
4737
4738 for (;;) {

--- 189 unchanged lines hidden (view full) ---

4928 struct ath_tid *tid)
4929{
4930 struct ath_buf *bf;
4931 struct ath_txq *txq = sc->sc_ac2q[tid->ac];
4932
4933 DPRINTF(sc, ATH_DEBUG_SW_TX, "%s: node %p: TID %d: called\n",
4934 __func__, an, tid->tid);
4935
4708
4709 tap = ath_tx_get_tx_tid(an, tid->tid);
4710
4711 if (tid->tid == IEEE80211_NONQOS_TID)
4712 device_printf(sc->sc_dev, "%s: called for TID=NONQOS_TID?\n",
4713 __func__);
4714
4715 for (;;) {

--- 189 unchanged lines hidden (view full) ---

4905 struct ath_tid *tid)
4906{
4907 struct ath_buf *bf;
4908 struct ath_txq *txq = sc->sc_ac2q[tid->ac];
4909
4910 DPRINTF(sc, ATH_DEBUG_SW_TX, "%s: node %p: TID %d: called\n",
4911 __func__, an, tid->tid);
4912
4936 ATH_TID_LOCK_ASSERT(sc, tid);
4913 ATH_TX_LOCK_ASSERT(sc);
4937
4938 /* Check - is AMPDU pending or running? then print out something */
4939 if (ath_tx_ampdu_pending(sc, an, tid->tid))
4940 device_printf(sc->sc_dev, "%s: tid=%d, ampdu pending?\n",
4941 __func__, tid->tid);
4942 if (ath_tx_ampdu_running(sc, an, tid->tid))
4943 device_printf(sc->sc_dev, "%s: tid=%d, ampdu running?\n",
4944 __func__, tid->tid);

--- 62 unchanged lines hidden (view full) ---

5007 * added to the end of the queue after some frames have been
5008 * scheduled.
5009 */
5010void
5011ath_txq_sched(struct ath_softc *sc, struct ath_txq *txq)
5012{
5013 struct ath_tid *tid, *next, *last;
5014
4914
4915 /* Check - is AMPDU pending or running? then print out something */
4916 if (ath_tx_ampdu_pending(sc, an, tid->tid))
4917 device_printf(sc->sc_dev, "%s: tid=%d, ampdu pending?\n",
4918 __func__, tid->tid);
4919 if (ath_tx_ampdu_running(sc, an, tid->tid))
4920 device_printf(sc->sc_dev, "%s: tid=%d, ampdu running?\n",
4921 __func__, tid->tid);

--- 62 unchanged lines hidden (view full) ---

4984 * added to the end of the queue after some frames have been
4985 * scheduled.
4986 */
4987void
4988ath_txq_sched(struct ath_softc *sc, struct ath_txq *txq)
4989{
4990 struct ath_tid *tid, *next, *last;
4991
5015 ATH_TXQ_LOCK_ASSERT(txq);
4992 ATH_TX_LOCK_ASSERT(sc);
5016
5017 /*
5018 * Don't schedule if the hardware queue is busy.
5019 * This (hopefully) gives some more time to aggregate
5020 * some packets in the aggregation queue.
5021 */
5022 if (txq->axq_aggr_depth >= sc->sc_hwq_limit) {
5023 sc->sc_aggr_stats.aggr_sched_nopkt++;

--- 133 unchanged lines hidden (view full) ---

5157 * this can cause the initial burst of packets after the addba
5158 * negotiation to "hang", as they quickly fall outside the BAW.
5159 *
5160 * The "eventual" solution should be to tag these packets with
5161 * dobaw. Although net80211 has given us a sequence number,
5162 * it'll be "after" the left edge of the BAW and thus it'll
5163 * fall within it.
5164 */
4993
4994 /*
4995 * Don't schedule if the hardware queue is busy.
4996 * This (hopefully) gives some more time to aggregate
4997 * some packets in the aggregation queue.
4998 */
4999 if (txq->axq_aggr_depth >= sc->sc_hwq_limit) {
5000 sc->sc_aggr_stats.aggr_sched_nopkt++;

--- 133 unchanged lines hidden (view full) ---

5134 * this can cause the initial burst of packets after the addba
5135 * negotiation to "hang", as they quickly fall outside the BAW.
5136 *
5137 * The "eventual" solution should be to tag these packets with
5138 * dobaw. Although net80211 has given us a sequence number,
5139 * it'll be "after" the left edge of the BAW and thus it'll
5140 * fall within it.
5141 */
5165 ATH_TXQ_LOCK(sc->sc_ac2q[atid->ac]);
5142 ATH_TX_LOCK(sc);
5166 /*
5167 * This is a bit annoying. Until net80211 HT code inherits some
5168 * (any) locking, we may have this called in parallel BUT only
5169 * one response/timeout will be called. Grr.
5170 */
5171 if (atid->addba_tx_pending == 0) {
5172 ath_tx_tid_pause(sc, atid);
5173 atid->addba_tx_pending = 1;
5174 }
5143 /*
5144 * This is a bit annoying. Until net80211 HT code inherits some
5145 * (any) locking, we may have this called in parallel BUT only
5146 * one response/timeout will be called. Grr.
5147 */
5148 if (atid->addba_tx_pending == 0) {
5149 ath_tx_tid_pause(sc, atid);
5150 atid->addba_tx_pending = 1;
5151 }
5175 ATH_TXQ_UNLOCK(sc->sc_ac2q[atid->ac]);
5152 ATH_TX_UNLOCK(sc);
5176
5177 DPRINTF(sc, ATH_DEBUG_SW_TX_CTRL,
5178 "%s: called; dialogtoken=%d, baparamset=%d, batimeout=%d\n",
5179 __func__, dialogtoken, baparamset, batimeout);
5180 DPRINTF(sc, ATH_DEBUG_SW_TX_CTRL,
5181 "%s: txa_start=%d, ni_txseqs=%d\n",
5182 __func__, tap->txa_start, ni->ni_txseqs[tid]);
5183

--- 42 unchanged lines hidden (view full) ---

5226 /*
5227 * Call this first, so the interface flags get updated
5228 * before the TID is unpaused. Otherwise a race condition
5229 * exists where the unpaused TID still doesn't yet have
5230 * IEEE80211_AGGR_RUNNING set.
5231 */
5232 r = sc->sc_addba_response(ni, tap, status, code, batimeout);
5233
5153
5154 DPRINTF(sc, ATH_DEBUG_SW_TX_CTRL,
5155 "%s: called; dialogtoken=%d, baparamset=%d, batimeout=%d\n",
5156 __func__, dialogtoken, baparamset, batimeout);
5157 DPRINTF(sc, ATH_DEBUG_SW_TX_CTRL,
5158 "%s: txa_start=%d, ni_txseqs=%d\n",
5159 __func__, tap->txa_start, ni->ni_txseqs[tid]);
5160

--- 42 unchanged lines hidden (view full) ---

5203 /*
5204 * Call this first, so the interface flags get updated
5205 * before the TID is unpaused. Otherwise a race condition
5206 * exists where the unpaused TID still doesn't yet have
5207 * IEEE80211_AGGR_RUNNING set.
5208 */
5209 r = sc->sc_addba_response(ni, tap, status, code, batimeout);
5210
5234 ATH_TXQ_LOCK(sc->sc_ac2q[atid->ac]);
5211 ATH_TX_LOCK(sc);
5235 atid->addba_tx_pending = 0;
5236 /*
5237 * XXX dirty!
5238 * Slide the BAW left edge to wherever net80211 left it for us.
5239 * Read above for more information.
5240 */
5241 tap->txa_start = ni->ni_txseqs[tid];
5242 ath_tx_tid_resume(sc, atid);
5212 atid->addba_tx_pending = 0;
5213 /*
5214 * XXX dirty!
5215 * Slide the BAW left edge to wherever net80211 left it for us.
5216 * Read above for more information.
5217 */
5218 tap->txa_start = ni->ni_txseqs[tid];
5219 ath_tx_tid_resume(sc, atid);
5243 ATH_TXQ_UNLOCK(sc->sc_ac2q[atid->ac]);
5220 ATH_TX_UNLOCK(sc);
5244 return r;
5245}
5246
5247
5248/*
5249 * Stop ADDBA on a queue.
5250 *
5251 * This can be called whilst BAR TX is currently active on the queue,

--- 8 unchanged lines hidden (view full) ---

5260 struct ath_tid *atid = &an->an_tid[tid];
5261
5262 DPRINTF(sc, ATH_DEBUG_SW_TX_CTRL, "%s: called\n", __func__);
5263
5264 /*
5265 * Pause TID traffic early, so there aren't any races
5266 * Unblock the pending BAR held traffic, if it's currently paused.
5267 */
5221 return r;
5222}
5223
5224
5225/*
5226 * Stop ADDBA on a queue.
5227 *
5228 * This can be called whilst BAR TX is currently active on the queue,

--- 8 unchanged lines hidden (view full) ---

5237 struct ath_tid *atid = &an->an_tid[tid];
5238
5239 DPRINTF(sc, ATH_DEBUG_SW_TX_CTRL, "%s: called\n", __func__);
5240
5241 /*
5242 * Pause TID traffic early, so there aren't any races
5243 * Unblock the pending BAR held traffic, if it's currently paused.
5244 */
5268 ATH_TXQ_LOCK(sc->sc_ac2q[atid->ac]);
5245 ATH_TX_LOCK(sc);
5269 ath_tx_tid_pause(sc, atid);
5270 if (atid->bar_wait) {
5271 /*
5272 * bar_unsuspend() expects bar_tx == 1, as it should be
5273 * called from the TX completion path. This quietens
5274 * the warning. It's cleared for us anyway.
5275 */
5276 atid->bar_tx = 1;
5277 ath_tx_tid_bar_unsuspend(sc, atid);
5278 }
5246 ath_tx_tid_pause(sc, atid);
5247 if (atid->bar_wait) {
5248 /*
5249 * bar_unsuspend() expects bar_tx == 1, as it should be
5250 * called from the TX completion path. This quietens
5251 * the warning. It's cleared for us anyway.
5252 */
5253 atid->bar_tx = 1;
5254 ath_tx_tid_bar_unsuspend(sc, atid);
5255 }
5279 ATH_TXQ_UNLOCK(sc->sc_ac2q[atid->ac]);
5256 ATH_TX_UNLOCK(sc);
5280
5281 /* There's no need to hold the TXQ lock here */
5282 sc->sc_addba_stop(ni, tap);
5283
5284 /*
5285 * ath_tx_tid_cleanup will resume the TID if possible, otherwise
5286 * it'll set the cleanup flag, and it'll be unpaused once
5287 * things have been cleaned up.

--- 39 unchanged lines hidden (view full) ---

5327 * XXX if this is attempt=50, the TID will be downgraded
5328 * XXX to a non-aggregate session. So we must unpause the
5329 * XXX TID here or it'll never be done.
5330 *
5331 * Also, don't call it if bar_tx/bar_wait are 0; something
5332 * has beaten us to the punch? (XXX figure out what?)
5333 */
5334 if (status == 0 || attempts == 50) {
5257
5258 /* There's no need to hold the TXQ lock here */
5259 sc->sc_addba_stop(ni, tap);
5260
5261 /*
5262 * ath_tx_tid_cleanup will resume the TID if possible, otherwise
5263 * it'll set the cleanup flag, and it'll be unpaused once
5264 * things have been cleaned up.

--- 39 unchanged lines hidden (view full) ---

5304 * XXX if this is attempt=50, the TID will be downgraded
5305 * XXX to a non-aggregate session. So we must unpause the
5306 * XXX TID here or it'll never be done.
5307 *
5308 * Also, don't call it if bar_tx/bar_wait are 0; something
5309 * has beaten us to the punch? (XXX figure out what?)
5310 */
5311 if (status == 0 || attempts == 50) {
5335 ATH_TXQ_LOCK(sc->sc_ac2q[atid->ac]);
5312 ATH_TX_LOCK(sc);
5336 if (atid->bar_tx == 0 || atid->bar_wait == 0)
5337 device_printf(sc->sc_dev,
5338 "%s: huh? bar_tx=%d, bar_wait=%d\n",
5339 __func__,
5340 atid->bar_tx, atid->bar_wait);
5341 else
5342 ath_tx_tid_bar_unsuspend(sc, atid);
5313 if (atid->bar_tx == 0 || atid->bar_wait == 0)
5314 device_printf(sc->sc_dev,
5315 "%s: huh? bar_tx=%d, bar_wait=%d\n",
5316 __func__,
5317 atid->bar_tx, atid->bar_wait);
5318 else
5319 ath_tx_tid_bar_unsuspend(sc, atid);
5343 ATH_TXQ_UNLOCK(sc->sc_ac2q[atid->ac]);
5320 ATH_TX_UNLOCK(sc);
5344 }
5345}
5346
5347/*
5348 * This is called whenever the pending ADDBA request times out.
5349 * Unpause and reschedule the TID.
5350 */
5351void
5352ath_addba_response_timeout(struct ieee80211_node *ni,
5353 struct ieee80211_tx_ampdu *tap)
5354{
5355 struct ath_softc *sc = ni->ni_ic->ic_ifp->if_softc;
5356 int tid = tap->txa_tid;
5357 struct ath_node *an = ATH_NODE(ni);
5358 struct ath_tid *atid = &an->an_tid[tid];
5359
5360 DPRINTF(sc, ATH_DEBUG_SW_TX_CTRL,
5361 "%s: called; resuming\n", __func__);
5362
5321 }
5322}
5323
5324/*
5325 * This is called whenever the pending ADDBA request times out.
5326 * Unpause and reschedule the TID.
5327 */
5328void
5329ath_addba_response_timeout(struct ieee80211_node *ni,
5330 struct ieee80211_tx_ampdu *tap)
5331{
5332 struct ath_softc *sc = ni->ni_ic->ic_ifp->if_softc;
5333 int tid = tap->txa_tid;
5334 struct ath_node *an = ATH_NODE(ni);
5335 struct ath_tid *atid = &an->an_tid[tid];
5336
5337 DPRINTF(sc, ATH_DEBUG_SW_TX_CTRL,
5338 "%s: called; resuming\n", __func__);
5339
5363 ATH_TXQ_LOCK(sc->sc_ac2q[atid->ac]);
5340 ATH_TX_LOCK(sc);
5364 atid->addba_tx_pending = 0;
5341 atid->addba_tx_pending = 0;
5365 ATH_TXQ_UNLOCK(sc->sc_ac2q[atid->ac]);
5342 ATH_TX_UNLOCK(sc);
5366
5367 /* Note: This updates the aggregate state to (again) pending */
5368 sc->sc_addba_response_timeout(ni, tap);
5369
5370 /* Unpause the TID; which reschedules it */
5343
5344 /* Note: This updates the aggregate state to (again) pending */
5345 sc->sc_addba_response_timeout(ni, tap);
5346
5347 /* Unpause the TID; which reschedules it */
5371 ATH_TXQ_LOCK(sc->sc_ac2q[atid->ac]);
5348 ATH_TX_LOCK(sc);
5372 ath_tx_tid_resume(sc, atid);
5349 ath_tx_tid_resume(sc, atid);
5373 ATH_TXQ_UNLOCK(sc->sc_ac2q[atid->ac]);
5350 ATH_TX_UNLOCK(sc);
5374}
5375
5376/*
5377 * Check if a node is asleep or not.
5378 */
5379int
5380ath_tx_node_is_asleep(struct ath_softc *sc, struct ath_node *an)
5381{

--- 51 unchanged lines hidden (view full) ---

5433 * and if it's not (ie, it's 0), it'll treat it as already
5434 * being awake. If it's 1, it'll mark it as 0 and then
5435 * unpause everything.
5436 *
5437 * (Talk about a delicate hack.)
5438 */
5439
5440 /* Suspend all traffic on the node */
5351}
5352
5353/*
5354 * Check if a node is asleep or not.
5355 */
5356int
5357ath_tx_node_is_asleep(struct ath_softc *sc, struct ath_node *an)
5358{

--- 51 unchanged lines hidden (view full) ---

5410 * and if it's not (ie, it's 0), it'll treat it as already
5411 * being awake. If it's 1, it'll mark it as 0 and then
5412 * unpause everything.
5413 *
5414 * (Talk about a delicate hack.)
5415 */
5416
5417 /* Suspend all traffic on the node */
5418 ATH_TX_LOCK(sc);
5441 for (tid = 0; tid < IEEE80211_TID_SIZE; tid++) {
5442 atid = &an->an_tid[tid];
5443 txq = sc->sc_ac2q[atid->ac];
5444
5419 for (tid = 0; tid < IEEE80211_TID_SIZE; tid++) {
5420 atid = &an->an_tid[tid];
5421 txq = sc->sc_ac2q[atid->ac];
5422
5445 ATH_TXQ_LOCK(txq);
5446 ath_tx_tid_pause(sc, atid);
5423 ath_tx_tid_pause(sc, atid);
5447 ATH_TXQ_UNLOCK(txq);
5448 }
5424 }
5425 ATH_TX_UNLOCK(sc);
5449
5450 ATH_NODE_LOCK(an);
5451
5452 /* In case of concurrency races from net80211.. */
5453 if (an->an_is_powersave == 1) {
5454 ATH_NODE_UNLOCK(an);
5455 device_printf(sc->sc_dev,
5456 "%s: an=%p: node was already asleep\n",
5457 __func__, an);
5426
5427 ATH_NODE_LOCK(an);
5428
5429 /* In case of concurrency races from net80211.. */
5430 if (an->an_is_powersave == 1) {
5431 ATH_NODE_UNLOCK(an);
5432 device_printf(sc->sc_dev,
5433 "%s: an=%p: node was already asleep\n",
5434 __func__, an);
5435 ATH_TX_LOCK(sc);
5458 for (tid = 0; tid < IEEE80211_TID_SIZE; tid++) {
5459 atid = &an->an_tid[tid];
5460 txq = sc->sc_ac2q[atid->ac];
5461
5436 for (tid = 0; tid < IEEE80211_TID_SIZE; tid++) {
5437 atid = &an->an_tid[tid];
5438 txq = sc->sc_ac2q[atid->ac];
5439
5462 ATH_TXQ_LOCK(txq);
5463 ath_tx_tid_resume(sc, atid);
5440 ath_tx_tid_resume(sc, atid);
5464 ATH_TXQ_UNLOCK(txq);
5465 }
5441 }
5442 ATH_TX_UNLOCK(sc);
5466 return;
5467 }
5468
5469 /* Mark node as in powersaving */
5470 an->an_is_powersave = 1;
5471
5472 ATH_NODE_UNLOCK(an);
5473}

--- 21 unchanged lines hidden (view full) ---

5495 return;
5496 }
5497
5498 /* Mark node as awake */
5499 an->an_is_powersave = 0;
5500
5501 ATH_NODE_UNLOCK(an);
5502
5443 return;
5444 }
5445
5446 /* Mark node as in powersaving */
5447 an->an_is_powersave = 1;
5448
5449 ATH_NODE_UNLOCK(an);
5450}

--- 21 unchanged lines hidden (view full) ---

5472 return;
5473 }
5474
5475 /* Mark node as awake */
5476 an->an_is_powersave = 0;
5477
5478 ATH_NODE_UNLOCK(an);
5479
5480 ATH_TX_LOCK(sc);
5503 for (tid = 0; tid < IEEE80211_TID_SIZE; tid++) {
5504 atid = &an->an_tid[tid];
5505 txq = sc->sc_ac2q[atid->ac];
5506
5481 for (tid = 0; tid < IEEE80211_TID_SIZE; tid++) {
5482 atid = &an->an_tid[tid];
5483 txq = sc->sc_ac2q[atid->ac];
5484
5507 ATH_TXQ_LOCK(txq);
5508 ath_tx_tid_resume(sc, atid);
5485 ath_tx_tid_resume(sc, atid);
5509 ATH_TXQ_UNLOCK(txq);
5510 }
5486 }
5487 ATH_TX_UNLOCK(sc);
5511}
5512
5513static int
5514ath_legacy_dma_txsetup(struct ath_softc *sc)
5515{
5516
5517 /* nothing new needed */
5518 return (0);

--- 30 unchanged lines hidden ---
5488}
5489
5490static int
5491ath_legacy_dma_txsetup(struct ath_softc *sc)
5492{
5493
5494 /* nothing new needed */
5495 return (0);

--- 30 unchanged lines hidden ---