Lines Matching defs:bf

130     struct ieee80211_node *ni, struct ath_buf *bf, struct mbuf *m0);
135 struct ath_tid *tid, struct ath_buf *bf);
141 struct ath_buf *bf;
146 bf = bf_first;
148 while (bf != NULL) {
150 if (bf->bf_nseg == 0)
152 n = ((bf->bf_nseg - 1) / sc->sc_tx_nmaps) + 1;
153 for (i = 0, ds = (const char *) bf->bf_desc;
161 bf = bf->bf_next;
198 ath_tx_set_retry(struct ath_softc *sc, struct ath_buf *bf)
202 wh = mtod(bf->bf_m, struct ieee80211_frame *);
204 if (bf->bf_state.bfs_isretried == 0) {
206 bus_dmamap_sync(sc->sc_dmat, bf->bf_dmamap,
209 bf->bf_state.bfs_isretried = 1;
210 bf->bf_state.bfs_retries ++;
259 struct ath_buf *bf, *next;
263 TAILQ_FOREACH_SAFE(bf, frags, bf_list, next) {
264 /* NB: bf assumed clean */
265 TAILQ_REMOVE(frags, bf, bf_list);
266 ath_returnbuf_head(sc, bf);
281 struct ath_buf *bf;
286 bf = _ath_getbuf_locked(sc, ATH_BUFTYPE_NORMAL);
287 if (bf == NULL) { /* out of buffers, cleanup */
294 TAILQ_INSERT_TAIL(frags, bf, bf_list);
302 ath_tx_dmasetup(struct ath_softc *sc, struct ath_buf *bf, struct mbuf *m0)
311 error = bus_dmamap_load_mbuf_sg(sc->sc_dmat, bf->bf_dmamap, m0,
312 bf->bf_segs, &bf->bf_nseg,
316 bf->bf_nseg = ATH_MAX_SCATTER + 1;
327 if (bf->bf_nseg > ATH_MAX_SCATTER) { /* too many desc's, linearize */
336 error = bus_dmamap_load_mbuf_sg(sc->sc_dmat, bf->bf_dmamap, m0,
337 bf->bf_segs, &bf->bf_nseg,
344 KASSERT(bf->bf_nseg <= ATH_MAX_SCATTER,
345 ("too many segments after defrag; nseg %u", bf->bf_nseg));
346 } else if (bf->bf_nseg == 0) { /* null packet, discard */
353 bus_dmamap_sync(sc->sc_dmat, bf->bf_dmamap, BUS_DMASYNC_PREWRITE);
354 bf->bf_m = m0;
366 struct ath_buf *bf, bool is_aggr, int is_first_subframe,
398 ds = (char *) bf->bf_desc;
402 for (i = 0; i < bf->bf_nseg; i++) {
403 bufAddrList[bp] = bf->bf_segs[i].ds_addr;
404 segLenList[bp] = bf->bf_segs[i].ds_len;
411 if ((i != bf->bf_nseg - 1) && (bp < numTxMaps))
419 if (i == bf->bf_nseg - 1)
423 bf->bf_daddr + dd->dd_descsize * (dsp + 1));
434 , bf->bf_descid /* XXX desc id */
435 , bf->bf_state.bfs_tx_queue
437 , i == bf->bf_nseg - 1 /* last segment */
471 bf->bf_state.bfs_ndelim);
474 bf->bf_lastds = (struct ath_desc *) ds;
488 bus_dmamap_sync(sc->sc_dmat, bf->bf_dmamap, BUS_DMASYNC_PREWRITE);
508 struct ath_buf *bf)
510 struct ath_rc_series *rc = bf->bf_state.bfs_rc;
513 if (! bf->bf_state.bfs_ismrr)
520 else if (bf->bf_state.bfs_txflags & HAL_TXDESC_NOACK) {
535 ath_buf_set_rate(sc, ni, bf);
537 ath_hal_setupxtxdesc(sc->sc_ah, bf->bf_desc
549 * bf->bf_next.
554 struct ath_buf *bf, *bf_prev = NULL;
561 bf = bf_first;
563 if (bf->bf_state.bfs_txrate0 == 0)
564 DPRINTF(sc, ATH_DEBUG_SW_TX_AGGR, "%s: bf=%p, txrate0=%d\n",
565 __func__, bf, 0);
566 if (bf->bf_state.bfs_rc[0].ratecode == 0)
567 DPRINTF(sc, ATH_DEBUG_SW_TX_AGGR, "%s: bf=%p, rix0=%d\n",
568 __func__, bf, 0);
574 while (bf != NULL) {
576 "%s: bf=%p, nseg=%d, pktlen=%d, seqno=%d\n",
577 __func__, bf, bf->bf_nseg, bf->bf_state.bfs_pktlen,
578 SEQNO(bf->bf_state.bfs_seqno));
584 ath_hal_setuptxdesc(sc->sc_ah, bf->bf_desc
585 , bf->bf_state.bfs_pktlen /* packet length */
586 , bf->bf_state.bfs_hdrlen /* header length */
587 , bf->bf_state.bfs_atype /* Atheros packet type */
588 , bf->bf_state.bfs_txpower /* txpower */
589 , bf->bf_state.bfs_txrate0
590 , bf->bf_state.bfs_try0 /* series 0 rate/tries */
591 , bf->bf_state.bfs_keyix /* key cache index */
592 , bf->bf_state.bfs_txantenna /* antenna mode */
593 , bf->bf_state.bfs_txflags | HAL_TXDESC_INTREQ /* flags */
594 , bf->bf_state.bfs_ctsrate /* rts/cts rate */
595 , bf->bf_state.bfs_ctsduration /* rts/cts duration */
602 if (bf == bf_first) {
606 ath_tx_set_ratectrl(sc, bf->bf_node, bf);
613 ath_tx_chaindesclist(sc, ds0, bf,
615 !! (bf == bf_first), /* is_first_subframe */
616 !! (bf->bf_next == NULL) /* is_last_subframe */
619 if (bf == bf_first) {
626 bf->bf_state.bfs_al,
627 bf->bf_state.bfs_ndelim);
636 bf->bf_daddr);
639 bf_prev = bf;
640 bf = bf->bf_next;
700 struct ath_buf *bf)
704 KASSERT((bf->bf_flags & ATH_BUF_BUSY) == 0,
705 ("%s: busy status 0x%x", __func__, bf->bf_flags));
711 if (bf->bf_state.bfs_tx_queue != sc->sc_cabq->axq_qnum) {
713 "%s: bf=%p, bfs_tx_queue=%d, axq_qnum=%d\n",
714 __func__, bf, bf->bf_state.bfs_tx_queue,
732 bf->bf_daddr);
734 ATH_TXQ_INSERT_TAIL(txq, bf, bf_list);
743 struct ath_buf *bf)
757 KASSERT((bf->bf_flags & ATH_BUF_BUSY) == 0,
758 ("%s: busy status 0x%x", __func__, bf->bf_flags));
804 ATH_TXQ_INSERT_TAIL(txq, bf, bf_list);
806 "ath_tx_handoff: non-tdma: txq=%u, add bf=%p "
809 bf,
819 *txq->axq_link = bf->bf_daddr;
823 (caddr_t)bf->bf_daddr, bf->bf_desc,
829 (caddr_t)bf->bf_daddr, bf->bf_desc,
830 bf->bf_lastds);
863 * Ensure that the bf TXQ matches this TXQ, so later
866 if (bf->bf_state.bfs_tx_queue != txq->axq_qnum) {
868 "%s: bf=%p, bfs_tx_queue=%d, axq_qnum=%d\n",
869 __func__, bf, bf->bf_state.bfs_tx_queue,
876 if (bf->bf_state.bfs_aggr)
882 ath_hal_gettxdesclinkptr(ah, bf->bf_lastds, &txq->axq_link);
913 struct ath_buf *bf, *bf_last;
918 bf = TAILQ_FIRST(&txq->axq_q);
921 if (bf == NULL)
925 "%s: Q%d: bf=%p, bf_last=%p, daddr=0x%08x\n",
928 bf,
930 (uint32_t) bf->bf_daddr);
946 ath_hal_puttxbuf(sc->sc_ah, txq->axq_qnum, bf->bf_daddr);
961 struct ath_buf *bf)
967 ath_tx_alq_post(sc, bf);
971 ath_tx_handoff_mcast(sc, txq, bf);
973 ath_tx_handoff_hw(sc, txq, bf);
1046 ath_tx_calc_protection(struct ath_softc *sc, struct ath_buf *bf)
1055 flags = bf->bf_state.bfs_txflags;
1056 rix = bf->bf_state.bfs_rc[0].rix;
1057 shortPreamble = bf->bf_state.bfs_shpream;
1058 wh = mtod(bf->bf_m, struct ieee80211_frame *);
1061 if (bf->bf_flags & ATH_BUF_TOA_PROBE) {
1064 bf->bf_state.bfs_doprot = 0;
1076 bf->bf_state.bfs_doprot = 1;
1109 bf->bf_state.bfs_txflags = flags;
1119 ath_tx_calc_duration(struct ath_softc *sc, struct ath_buf *bf)
1127 int isfrag = bf->bf_m->m_flags & M_FRAG;
1129 flags = bf->bf_state.bfs_txflags;
1130 rix = bf->bf_state.bfs_rc[0].rix;
1131 shortPreamble = bf->bf_state.bfs_shpream;
1132 wh = mtod(bf->bf_m, struct ieee80211_frame *);
1158 bf->bf_nextfraglen,
1168 bf->bf_state.bfs_ismrr = 0;
1169 bf->bf_state.bfs_try0 = ATH_TXMGTTRY;
1259 ath_tx_set_rtscts(struct ath_softc *sc, struct ath_buf *bf)
1263 uint8_t rix = bf->bf_state.bfs_rc[0].rix;
1270 if ((bf->bf_state.bfs_txflags &
1273 bf->bf_state.bfs_ctsrate = 0;
1274 bf->bf_state.bfs_ctsduration = 0;
1282 if (bf->bf_state.bfs_doprot)
1285 rix = bf->bf_state.bfs_rc[0].rix;
1291 if (bf->bf_state.bfs_ctsrate0 != 0)
1292 cix = ath_tx_findrix(sc, bf->bf_state.bfs_ctsrate0);
1299 bf->bf_state.bfs_shpream);
1304 bf->bf_state.bfs_shpream, bf->bf_state.bfs_pktlen,
1305 rt, bf->bf_state.bfs_txflags);
1308 bf->bf_state.bfs_ctsrate = ctsrate;
1309 bf->bf_state.bfs_ctsduration = ctsduration;
1315 bf->bf_state.bfs_ismrr = 0;
1316 bf->bf_state.bfs_try0 =
1317 bf->bf_state.bfs_rc[0].tries = ATH_TXMGTTRY; /* XXX ew */
1331 ath_tx_setds(struct ath_softc *sc, struct ath_buf *bf)
1333 struct ath_desc *ds = bf->bf_desc;
1336 if (bf->bf_state.bfs_txrate0 == 0)
1338 "%s: bf=%p, txrate0=%d\n", __func__, bf, 0);
1341 , bf->bf_state.bfs_pktlen /* packet length */
1342 , bf->bf_state.bfs_hdrlen /* header length */
1343 , bf->bf_state.bfs_atype /* Atheros packet type */
1344 , bf->bf_state.bfs_txpower /* txpower */
1345 , bf->bf_state.bfs_txrate0
1346 , bf->bf_state.bfs_try0 /* series 0 rate/tries */
1347 , bf->bf_state.bfs_keyix /* key cache index */
1348 , bf->bf_state.bfs_txantenna /* antenna mode */
1349 , bf->bf_state.bfs_txflags /* flags */
1350 , bf->bf_state.bfs_ctsrate /* rts/cts rate */
1351 , bf->bf_state.bfs_ctsduration /* rts/cts duration */
1357 bf->bf_lastds = ds;
1358 bf->bf_last = bf;
1361 ath_tx_set_ratectrl(sc, bf->bf_node, bf);
1362 ath_tx_chaindesclist(sc, ds, bf, 0, 0, 0);
1379 ath_tx_do_ratelookup(struct ath_softc *sc, struct ath_buf *bf, int tid,
1387 if (! bf->bf_state.bfs_doratelookup)
1391 bzero(bf->bf_state.bfs_rc, sizeof(bf->bf_state.bfs_rc));
1393 ATH_NODE_LOCK(ATH_NODE(bf->bf_node));
1394 ath_rate_findrate(sc, ATH_NODE(bf->bf_node), bf->bf_state.bfs_shpream,
1398 bf->bf_state.bfs_rc[0].rix = rix;
1399 bf->bf_state.bfs_rc[0].ratecode = rate;
1400 bf->bf_state.bfs_rc[0].tries = try0;
1402 if (bf->bf_state.bfs_ismrr && try0 != ATH_TXMAXTRY)
1403 ath_rate_getxtxrates(sc, ATH_NODE(bf->bf_node), rix,
1404 is_aggr, bf->bf_state.bfs_rc);
1405 ATH_NODE_UNLOCK(ATH_NODE(bf->bf_node));
1409 bf->bf_state.bfs_try0 = try0;
1410 bf->bf_state.bfs_txrate0 = rate;
1411 bf->bf_state.bfs_rc_maxpktlen = maxpktlen;
1419 struct ath_buf *bf)
1421 struct ath_node *an = ATH_NODE(bf->bf_node);
1426 bf->bf_state.bfs_txflags |= HAL_TXDESC_CLRDMASK;
1506 struct ath_buf *bf)
1508 struct ath_node *an = ATH_NODE(bf->bf_node);
1509 struct ath_tid *tid = &an->an_tid[bf->bf_state.bfs_tid];
1522 bf->bf_state.bfs_txflags |= HAL_TXDESC_CLRDMASK;
1525 ath_tx_do_ratelookup(sc, bf, tid->tid, bf->bf_state.bfs_pktlen, false);
1526 ath_tx_calc_duration(sc, bf);
1527 ath_tx_calc_protection(sc, bf);
1528 ath_tx_set_rtscts(sc, bf);
1529 ath_tx_rate_fill_rcflags(sc, bf);
1530 ath_tx_setds(sc, bf);
1536 bf->bf_comp = ath_tx_normal_comp;
1539 ath_tx_handoff(sc, txq, bf);
1556 struct ath_buf *bf, struct mbuf *m0, struct ath_txq *txq)
1610 error = ath_tx_dmasetup(sc, bf, m0);
1614 bf->bf_node = ni; /* NB: held reference */
1615 m0 = bf->bf_m; /* NB: may have changed */
1619 ds = bf->bf_desc;
1700 bf->bf_state.bfs_doratelookup = 1;
1800 bf->bf_flags |= ATH_BUF_TOA_PROBE;
1861 bzero(&bf->bf_state.bfs_rc, sizeof(bf->bf_state.bfs_rc));
1867 bf->bf_state.bfs_rc[0].rix = rix;
1868 bf->bf_state.bfs_rc[0].tries = try0;
1869 bf->bf_state.bfs_rc[0].ratecode = txrate;
1872 bf->bf_state.bfs_pktlen = pktlen;
1873 bf->bf_state.bfs_hdrlen = hdrlen;
1874 bf->bf_state.bfs_atype = atype;
1875 bf->bf_state.bfs_txpower = ieee80211_get_node_txpower(ni);
1876 bf->bf_state.bfs_txrate0 = txrate;
1877 bf->bf_state.bfs_try0 = try0;
1878 bf->bf_state.bfs_keyix = keyix;
1879 bf->bf_state.bfs_txantenna = sc->sc_txantenna;
1880 bf->bf_state.bfs_txflags = flags;
1881 bf->bf_state.bfs_shpream = shortPreamble;
1884 bf->bf_state.bfs_ctsrate0 = 0; /* ie, no hard-coded ctsrate */
1885 bf->bf_state.bfs_ctsrate = 0; /* calculated later */
1886 bf->bf_state.bfs_ctsduration = 0;
1887 bf->bf_state.bfs_ismrr = ismrr;
1905 struct ath_buf *bf, struct mbuf *m0)
2005 bf->bf_state.bfs_tid = tid;
2006 bf->bf_state.bfs_tx_queue = txq->axq_qnum;
2007 bf->bf_state.bfs_pri = pri;
2025 bf->bf_state.bfs_tx_queue = sc->sc_cabq->axq_qnum;
2031 bf->bf_state.bfs_dobaw = 0;
2048 seqno = ath_tx_tid_seqno_assign(sc, ni, bf, m0);
2057 bf->bf_state.bfs_dobaw = 1;
2065 bf->bf_state.bfs_seqno = M_SEQNO_GET(m0) << IEEE80211_SEQ_SEQ_SHIFT;
2074 r = ath_tx_normal_setup(sc, ni, bf, m0, txq);
2080 m0 = bf->bf_m;
2110 "%s: bf=%p: mcastq: TX'ing\n", __func__, bf);
2111 bf->bf_state.bfs_txflags |= HAL_TXDESC_CLRDMASK;
2112 ath_tx_xmit_normal(sc, txq, bf);
2115 ath_tx_swq(sc, ni, txq, queue_to_head, bf);
2117 bf->bf_state.bfs_txflags |= HAL_TXDESC_CLRDMASK;
2118 ath_tx_xmit_normal(sc, txq, bf);
2125 bf->bf_state.bfs_txflags |= HAL_TXDESC_CLRDMASK;
2131 ath_tx_leak_count_update(sc, tid, bf);
2132 ath_tx_xmit_normal(sc, txq, bf);
2140 struct ath_buf *bf, struct mbuf *m0,
2176 "ath_tx_raw_start: ni=%p, bf=%p, raw", ni, bf);
2219 bf->bf_state.bfs_dobaw = 0;
2221 error = ath_tx_dmasetup(sc, bf, m0);
2224 m0 = bf->bf_m; /* NB: may have changed */
2227 bf->bf_node = ni; /* NB: held reference */
2236 bf->bf_state.bfs_doprot = 1;
2268 bf->bf_flags |= ATH_BUF_TOA_PROBE;
2285 bf->bf_state.bfs_ctsrate0 = params->ibp_ctsrate;
2314 ds = bf->bf_desc;
2318 bf->bf_state.bfs_pktlen = pktlen;
2319 bf->bf_state.bfs_hdrlen = hdrlen;
2320 bf->bf_state.bfs_atype = atype;
2321 bf->bf_state.bfs_txpower = MIN(params->ibp_power,
2323 bf->bf_state.bfs_txrate0 = txrate;
2324 bf->bf_state.bfs_try0 = try0;
2325 bf->bf_state.bfs_keyix = keyix;
2326 bf->bf_state.bfs_txantenna = txantenna;
2327 bf->bf_state.bfs_txflags = flags;
2328 bf->bf_state.bfs_shpream =
2332 bf->bf_state.bfs_tid = WME_AC_TO_TID(pri);
2333 bf->bf_state.bfs_tx_queue = sc->sc_ac2q[pri]->axq_qnum;
2334 bf->bf_state.bfs_pri = pri;
2337 bf->bf_state.bfs_ctsrate = 0;
2338 bf->bf_state.bfs_ctsduration = 0;
2339 bf->bf_state.bfs_ismrr = ismrr;
2342 bzero(&bf->bf_state.bfs_rc, sizeof(bf->bf_state.bfs_rc));
2344 bf->bf_state.bfs_rc[0].rix = rix;
2345 bf->bf_state.bfs_rc[0].tries = try0;
2346 bf->bf_state.bfs_rc[0].ratecode = txrate;
2352 bf->bf_state.bfs_rc[1].rix = rix;
2353 bf->bf_state.bfs_rc[1].tries = params->ibp_try1;
2356 bf->bf_state.bfs_rc[2].rix = rix;
2357 bf->bf_state.bfs_rc[2].tries = params->ibp_try2;
2360 bf->bf_state.bfs_rc[3].rix = rix;
2361 bf->bf_state.bfs_rc[3].tries = params->ibp_try3;
2367 ath_tx_rate_fill_rcflags(sc, bf);
2384 bf->bf_state.bfs_txflags |= HAL_TXDESC_CLRDMASK;
2391 ath_tx_xmit_normal(sc, sc->sc_ac2q[pri], bf);
2395 ath_tx_swq(sc, ni, sc->sc_ac2q[pri], queue_to_head, bf);
2397 bf->bf_state.bfs_txflags |= HAL_TXDESC_CLRDMASK;
2398 ath_tx_xmit_normal(sc, sc->sc_ac2q[pri], bf);
2402 bf->bf_state.bfs_txflags |= HAL_TXDESC_CLRDMASK;
2408 ath_tx_leak_count_update(sc, tid, bf);
2409 ath_tx_xmit_normal(sc, sc->sc_ac2q[pri], bf);
2425 struct ath_buf *bf;
2476 bf = ath_getbuf(sc, ATH_BUFTYPE_MGMT);
2477 if (bf == NULL) {
2483 ATH_KTR(sc, ATH_KTR_TX, 3, "ath_raw_xmit: m=%p, params=%p, bf=%p\n",
2484 m, params, bf);
2491 if (ath_tx_start(sc, ni, bf, m)) {
2500 if (ath_tx_raw_start(sc, ni, bf, m, params)) {
2530 "bf=%p",
2533 bf);
2535 ath_returnbuf_head(sc, bf);
2658 struct ath_tid *tid, struct ath_buf *bf)
2665 if (bf->bf_state.bfs_isretried)
2670 if (! bf->bf_state.bfs_dobaw) {
2673 __func__, SEQNO(bf->bf_state.bfs_seqno),
2677 if (bf->bf_state.bfs_addedbaw)
2681 __func__, tid->tid, SEQNO(bf->bf_state.bfs_seqno),
2690 SEQNO(bf->bf_state.bfs_seqno))) {
2692 "%s: bf=%p: outside of BAW?? tid=%d, seqno %d; window %d:%d; "
2694 __func__, bf, tid->tid, SEQNO(bf->bf_state.bfs_seqno),
2703 index = ATH_BA_INDEX(tap->txa_start, SEQNO(bf->bf_state.bfs_seqno));
2708 __func__, tid->tid, SEQNO(bf->bf_state.bfs_seqno),
2721 "%s: BA bf: %p; seqno=%d ; new bf: %p; seqno=%d\n",
2725 bf,
2726 SEQNO(bf->bf_state.bfs_seqno)
2729 tid->tx_buf[cindex] = bf;
2781 "%s: old bf=%p, new bf=%p\n", __func__, old_bf, new_bf);
2796 struct ath_tid *tid, const struct ath_buf *bf)
2800 int seqno = SEQNO(bf->bf_state.bfs_seqno);
2824 if (tid->tx_buf[cindex] != bf) {
2826 "%s: comp bf=%p, seq=%d; slot bf=%p, seqno=%d\n",
2827 __func__, bf, SEQNO(bf->bf_state.bfs_seqno),
2847 struct ath_buf *bf)
2854 wh = mtod(bf->bf_m, struct ieee80211_frame *);
2878 bus_dmamap_sync(sc->sc_dmat, bf->bf_dmamap,
2985 struct ath_buf *bf, struct mbuf *m0)
3049 struct ath_txq *txq, struct ath_buf *bf)
3051 struct ath_tid *tid = &an->an_tid[bf->bf_state.bfs_tid];
3060 ATH_TID_INSERT_HEAD(tid, bf, bf_list);
3066 if (bf->bf_state.bfs_dobaw &&
3068 SEQNO(bf->bf_state.bfs_seqno)))) {
3069 ATH_TID_INSERT_HEAD(tid, bf, bf_list);
3084 if (bf->bf_state.bfs_aggr != 0 || bf->bf_state.bfs_nframes > 1) {
3087 bf->bf_state.bfs_aggr, bf->bf_state.bfs_nframes);
3088 bf->bf_state.bfs_aggr = 0;
3089 bf->bf_state.bfs_nframes = 1;
3093 ath_tx_update_clrdmask(sc, tid, bf);
3096 ath_tx_do_ratelookup(sc, bf, tid->tid, bf->bf_state.bfs_pktlen,
3098 ath_tx_calc_duration(sc, bf);
3099 ath_tx_calc_protection(sc, bf);
3100 ath_tx_set_rtscts(sc, bf);
3101 ath_tx_rate_fill_rcflags(sc, bf);
3102 ath_tx_setds(sc, bf);
3111 if (bf->bf_state.bfs_dobaw) {
3112 ath_tx_addto_baw(sc, an, tid, bf);
3113 bf->bf_state.bfs_addedbaw = 1;
3117 bf->bf_comp = ath_tx_aggr_comp;
3124 ath_tx_leak_count_update(sc, tid, bf);
3127 ath_tx_handoff(sc, txq, bf);
3138 struct ath_txq *txq, int queue_to_head, struct ath_buf *bf)
3144 struct mbuf *m0 = bf->bf_m;
3154 DPRINTF(sc, ATH_DEBUG_SW_TX, "%s: bf=%p, pri=%d, tid=%d, qos=%d\n",
3155 __func__, bf, pri, tid, IEEE80211_QOS_HAS_SEQ(wh));
3159 bf->bf_state.bfs_tid = tid;
3160 bf->bf_state.bfs_tx_queue = txq->axq_qnum;
3161 bf->bf_state.bfs_pri = pri;
3180 ATH_TID_INSERT_HEAD(atid, bf, bf_list);
3182 ATH_TID_INSERT_TAIL(atid, bf, bf_list);
3186 ATH_TID_INSERT_TAIL(atid, bf, bf_list);
3208 ATH_TID_INSERT_TAIL(atid, bf, bf_list);
3223 bf = ATH_TID_FIRST(atid);
3224 ATH_TID_REMOVE(atid, bf, bf_list);
3231 bf->bf_state.bfs_aggr = 0;
3232 bf->bf_state.bfs_nframes = 1;
3235 ath_tx_xmit_aggr(sc, an, txq, bf);
3265 ath_tx_update_clrdmask(sc, atid, bf);
3272 ath_tx_leak_count_update(sc, atid, bf);
3277 ath_tx_xmit_normal(sc, txq, bf);
3281 ATH_TID_INSERT_TAIL(atid, bf, bf_list);
3431 struct ath_buf *bf)
3440 DPRINTF(sc, ATH_DEBUG_SW_TX_FILT, "%s: bf=%p\n", __func__, bf);
3443 ath_tx_set_retry(sc, bf);
3446 ATH_TID_FILT_INSERT_TAIL(tid, bf, bf_list);
3456 struct ath_buf *bf)
3469 ath_tx_tid_filt_addbuf(sc, tid, bf);
3482 struct ath_buf *bf;
3501 while ((bf = ATH_TID_FILT_LAST(tid, ath_bufhead_s)) != NULL) {
3502 ATH_TID_FILT_REMOVE(tid, bf, bf_list);
3503 ATH_TID_INSERT_HEAD(tid, bf, bf_list);
3519 * since the buffer may be cloned, bf must be not touched after this
3524 struct ath_buf *bf)
3534 if (bf->bf_state.bfs_retries > SWMAX_RETRIES) {
3537 "%s: bf=%p, seqno=%d, exceeded retries\n",
3539 bf,
3540 SEQNO(bf->bf_state.bfs_seqno));
3549 if (bf->bf_flags & ATH_BUF_BUSY) {
3550 nbf = ath_tx_retry_clone(sc, tid->an, tid, bf);
3553 __func__, bf, nbf);
3555 nbf = bf;
3561 __func__, bf);
3577 struct ath_buf *bf, *bf_next, *nbf;
3581 bf = bf_first;
3582 while (bf) {
3583 bf_next = bf->bf_next;
3584 bf->bf_next = NULL; /* Remove it from the aggr list */
3589 if (bf->bf_state.bfs_retries > SWMAX_RETRIES) {
3592 "%s: tid=%d, bf=%p, seqno=%d, exceeded retries\n",
3595 bf,
3596 SEQNO(bf->bf_state.bfs_seqno));
3597 TAILQ_INSERT_TAIL(bf_q, bf, bf_list);
3601 if (bf->bf_flags & ATH_BUF_BUSY) {
3602 nbf = ath_tx_retry_clone(sc, tid->an, tid, bf);
3605 __func__, tid->tid, bf, nbf, SEQNO(bf->bf_state.bfs_seqno));
3607 nbf = bf;
3617 __func__, tid->tid, bf, SEQNO(bf->bf_state.bfs_seqno));
3618 TAILQ_INSERT_TAIL(bf_q, bf, bf_list);
3623 bf = bf_next;
3809 struct ath_tid *tid, ath_bufhead *bf_cq, struct ath_buf *bf)
3819 bf->bf_state.bfs_dobaw) {
3825 if (bf->bf_state.bfs_retries > 0) {
3826 ath_tx_update_baw(sc, an, tid, bf);
3827 bf->bf_state.bfs_dobaw = 0;
3833 if (! bf->bf_state.bfs_addedbaw)
3836 __func__, SEQNO(bf->bf_state.bfs_seqno));
3841 bf->bf_next = NULL;
3844 TAILQ_INSERT_TAIL(bf_cq, bf, bf_list);
3849 const char *pfx, struct ath_tid *tid, struct ath_buf *bf)
3859 "%s: %s: %6D: bf=%p: addbaw=%d, dobaw=%d, "
3865 bf,
3866 bf->bf_state.bfs_addedbaw,
3867 bf->bf_state.bfs_dobaw,
3868 SEQNO(bf->bf_state.bfs_seqno),
3869 bf->bf_state.bfs_retries);
3871 "%s: %s: %6D: bf=%p: txq[%d] axq_depth=%d, axq_aggr_depth=%d\n",
3876 bf,
3881 "%s: %s: %6D: bf=%p: tid txq_depth=%d hwq_depth=%d, bar_wait=%d, "
3887 bf,
3910 mtod(bf->bf_m, const uint8_t *),
3911 bf->bf_m->m_len, 0, -1);
3933 struct ath_buf *bf;
3945 bf = ATH_TID_FIRST(tid);
3946 if (bf == NULL) {
3951 ath_tx_tid_drain_print(sc, an, "norm", tid, bf);
3955 ATH_TID_REMOVE(tid, bf, bf_list);
3956 ath_tx_tid_drain_pkt(sc, an, tid, bf_cq, bf);
3962 bf = ATH_TID_FILT_FIRST(tid);
3963 if (bf == NULL)
3967 ath_tx_tid_drain_print(sc, an, "filt", tid, bf);
3971 ATH_TID_FILT_REMOVE(tid, bf, bf_list);
3972 ath_tx_tid_drain_pkt(sc, an, tid, bf_cq, bf);
4093 struct ath_buf *bf;
4134 while ((bf = TAILQ_FIRST(&bf_cq)) != NULL) {
4135 TAILQ_REMOVE(&bf_cq, bf, bf_list);
4136 ath_tx_default_comp(sc, bf, 0);
4148 struct ath_buf *bf;
4165 while ((bf = TAILQ_FIRST(&bf_cq)) != NULL) {
4166 TAILQ_REMOVE(&bf_cq, bf, bf_list);
4167 ath_tx_default_comp(sc, bf, 0);
4188 ath_tx_normal_comp(struct ath_softc *sc, struct ath_buf *bf, int fail)
4190 struct ieee80211_node *ni = bf->bf_node;
4192 int tid = bf->bf_state.bfs_tid;
4194 struct ath_tx_status *ts = &bf->bf_status.ds_txstat;
4199 DPRINTF(sc, ATH_DEBUG_SW_TX, "%s: bf=%p: fail=%d, hwq_depth now %d\n",
4200 __func__, bf, fail, atid->hwq_depth - 1);
4216 ath_tx_tid_filt_comp_buf(sc, atid, bf);
4257 if (fail == 0 && ((bf->bf_state.bfs_txflags & HAL_TXDESC_NOACK) == 0))
4258 ath_tx_update_ratectrl(sc, ni, bf->bf_state.bfs_rc,
4260 bf->bf_state.bfs_pktlen,
4261 bf->bf_state.bfs_pktlen,
4264 ath_tx_default_comp(sc, bf, fail);
4275 ath_tx_comp_cleanup_unaggr(struct ath_softc *sc, struct ath_buf *bf)
4277 struct ieee80211_node *ni = bf->bf_node;
4279 int tid = bf->bf_state.bfs_tid;
4289 if (bf->bf_state.bfs_dobaw) {
4290 ath_tx_update_baw(sc, an, atid, bf);
4291 if (!bf->bf_state.bfs_addedbaw)
4294 __func__, SEQNO(bf->bf_state.bfs_seqno));
4306 ath_tx_default_comp(sc, bf, 0);
4319 struct ath_buf *bf, *bf_next;
4331 bf = bf_head;
4332 while (bf != NULL) {
4333 bf_next = bf->bf_next; /* next aggregate frame, or NULL */
4343 if (bf->bf_state.bfs_addedbaw) {
4344 ath_tx_update_baw(sc, an, atid, bf);
4345 bf->bf_state.bfs_dobaw = 0;
4351 bf->bf_comp = ath_tx_normal_comp;
4352 bf->bf_next = NULL;
4357 TAILQ_INSERT_TAIL(bf_cq, bf, bf_list);
4362 bf = bf_next;
4384 struct ath_buf *bf, *bf_next;
4398 while ((bf = ATH_TID_FILT_LAST(atid, ath_bufhead_s)) != NULL) {
4399 ATH_TID_FILT_REMOVE(atid, bf, bf_list);
4400 ATH_TID_INSERT_HEAD(atid, bf, bf_list);
4409 bf = ATH_TID_FIRST(atid);
4410 while (bf) {
4415 bf_next = TAILQ_NEXT(bf, bf_list);
4420 ath_tx_tid_cleanup_frame(sc, an, tid, bf, bf_cq);
4425 bf = bf_next;
4452 struct ath_tid *tid, struct ath_buf *bf)
4460 * works out, 'bf' will have no DMA mapping, no mbuf
4463 nbf = ath_buf_clone(sc, bf);
4497 if (bf->bf_state.bfs_dobaw)
4498 ath_tx_switch_baw_buf(sc, an, tid, bf, nbf);
4501 ath_freebuf(sc, bf);
4517 ath_tx_aggr_retry_unaggr(struct ath_softc *sc, struct ath_buf *bf)
4519 struct ieee80211_node *ni = bf->bf_node;
4521 int tid = bf->bf_state.bfs_tid;
4537 if ((bf->bf_state.bfs_retries < SWMAX_RETRIES) &&
4538 (bf->bf_flags & ATH_BUF_BUSY)) {
4540 nbf = ath_tx_retry_clone(sc, an, atid, bf);
4542 /* bf has been freed at this point */
4543 bf = nbf;
4545 bf->bf_state.bfs_retries = SWMAX_RETRIES + 1;
4548 if (bf->bf_state.bfs_retries >= SWMAX_RETRIES) {
4551 __func__, SEQNO(bf->bf_state.bfs_seqno));
4555 if (bf->bf_state.bfs_dobaw) {
4556 ath_tx_update_baw(sc, an, atid, bf);
4557 if (! bf->bf_state.bfs_addedbaw)
4560 __func__, SEQNO(bf->bf_state.bfs_seqno));
4562 bf->bf_state.bfs_dobaw = 0;
4573 /* Free buffer, bf is free after this call */
4574 ath_tx_default_comp(sc, bf, 0);
4583 ath_tx_set_retry(sc, bf);
4590 ATH_TID_INSERT_HEAD(atid, bf, bf_list);
4607 ath_tx_retry_subframe(struct ath_softc *sc, struct ath_buf *bf,
4610 struct ieee80211_node *ni = bf->bf_node;
4612 int tid = bf->bf_state.bfs_tid;
4618 ath_hal_clr11n_aggr(sc->sc_ah, bf->bf_desc);
4619 ath_hal_set11nburstduration(sc->sc_ah, bf->bf_desc, 0);
4621 /* ath_hal_set11n_virtualmorefrag(sc->sc_ah, bf->bf_desc, 0); */
4631 if ((bf->bf_state.bfs_retries < SWMAX_RETRIES) &&
4632 (bf->bf_flags & ATH_BUF_BUSY)) {
4634 nbf = ath_tx_retry_clone(sc, an, atid, bf);
4636 /* bf has been freed at this point */
4637 bf = nbf;
4639 bf->bf_state.bfs_retries = SWMAX_RETRIES + 1;
4642 if (bf->bf_state.bfs_retries >= SWMAX_RETRIES) {
4646 __func__, SEQNO(bf->bf_state.bfs_seqno));
4647 ath_tx_update_baw(sc, an, atid, bf);
4648 if (!bf->bf_state.bfs_addedbaw)
4651 __func__, SEQNO(bf->bf_state.bfs_seqno));
4652 bf->bf_state.bfs_dobaw = 0;
4656 ath_tx_set_retry(sc, bf);
4658 bf->bf_next = NULL; /* Just to make sure */
4661 bf->bf_state.bfs_aggr = 0;
4662 bf->bf_state.bfs_ndelim = 0; /* ??? needed? */
4663 bf->bf_state.bfs_nframes = 1;
4665 TAILQ_INSERT_TAIL(bf_q, bf, bf_list);
4678 struct ath_buf *bf_next, *bf;
4701 bf = bf_first;
4702 while (bf) {
4703 bf_next = bf->bf_next;
4704 bf->bf_next = NULL; /* Remove it from the aggr list */
4706 if (ath_tx_retry_subframe(sc, bf, &bf_q)) {
4708 bf->bf_next = NULL;
4709 TAILQ_INSERT_TAIL(&bf_cq, bf, bf_list);
4711 bf = bf_next;
4715 while ((bf = TAILQ_LAST(&bf_q, ath_bufhead_s)) != NULL) {
4716 TAILQ_REMOVE(&bf_q, bf, bf_list);
4717 ATH_TID_INSERT_HEAD(tid, bf, bf_list);
4746 while ((bf = TAILQ_FIRST(&bf_cq)) != NULL) {
4747 TAILQ_REMOVE(&bf_cq, bf, bf_list);
4748 ath_tx_default_comp(sc, bf, 0);
4761 struct ath_buf *bf, *bf_next;
4773 bf = bf_first;
4774 while (bf) {
4776 if (bf->bf_state.bfs_dobaw) {
4777 ath_tx_update_baw(sc, an, atid, bf);
4778 if (!bf->bf_state.bfs_addedbaw)
4781 __func__, SEQNO(bf->bf_state.bfs_seqno));
4783 bf = bf->bf_next;
4806 bf = bf_first;
4807 while (bf) {
4808 bf_next = bf->bf_next;
4809 bf->bf_next = NULL;
4810 ath_tx_default_comp(sc, bf, 1);
4811 bf = bf_next;
4825 //struct ath_desc *ds = bf->bf_lastds;
4837 struct ath_buf *bf, *bf_next;
4907 TAILQ_FOREACH_SAFE(bf, &bf_cq, bf_list, bf_next) {
4908 if (bf->bf_state.bfs_addedbaw)
4910 if (bf->bf_state.bfs_dobaw) {
4911 ath_tx_update_baw(sc, an, atid, bf);
4912 if (!bf->bf_state.bfs_addedbaw)
4916 SEQNO(bf->bf_state.bfs_seqno));
4918 bf->bf_state.bfs_dobaw = 0;
5022 bf = bf_first;
5042 while (bf) {
5045 SEQNO(bf->bf_state.bfs_seqno));
5046 bf_next = bf->bf_next;
5047 bf->bf_next = NULL; /* Remove it from the aggr list */
5050 "%s: checking bf=%p seqno=%d; ack=%d\n",
5051 __func__, bf, SEQNO(bf->bf_state.bfs_seqno),
5056 ath_tx_update_baw(sc, an, atid, bf);
5057 bf->bf_state.bfs_dobaw = 0;
5058 if (!bf->bf_state.bfs_addedbaw)
5061 __func__, SEQNO(bf->bf_state.bfs_seqno));
5062 bf->bf_next = NULL;
5063 TAILQ_INSERT_TAIL(&bf_cq, bf, bf_list);
5066 if (ath_tx_retry_subframe(sc, bf, &bf_q)) {
5068 bf->bf_next = NULL;
5069 TAILQ_INSERT_TAIL(&bf_cq, bf, bf_list);
5073 bf = bf_next;
5089 "%s: num frames seen=%d; bf nframes=%d\n",
5117 while ((bf = TAILQ_LAST(&bf_q, ath_bufhead_s)) != NULL) {
5118 TAILQ_REMOVE(&bf_q, bf, bf_list);
5119 ATH_TID_INSERT_HEAD(atid, bf, bf_list);
5151 while ((bf = TAILQ_FIRST(&bf_cq)) != NULL) {
5152 TAILQ_REMOVE(&bf_cq, bf, bf_list);
5153 ath_tx_default_comp(sc, bf, 0);
5165 ath_tx_aggr_comp_unaggr(struct ath_softc *sc, struct ath_buf *bf, int fail)
5167 struct ieee80211_node *ni = bf->bf_node;
5169 int tid = bf->bf_state.bfs_tid;
5176 * bf pointer.
5178 ts = bf->bf_status.ds_txstat;
5186 if (fail == 0 && ((bf->bf_state.bfs_txflags & HAL_TXDESC_NOACK) == 0))
5187 ath_tx_update_ratectrl(sc, ni, bf->bf_state.bfs_rc,
5188 &bf->bf_status.ds_txstat,
5189 bf->bf_state.bfs_pktlen,
5190 bf->bf_state.bfs_pktlen,
5204 "%s: bf=%p: tid=%d, hwq_depth=%d, seqno=%d\n",
5205 __func__, bf, bf->bf_state.bfs_tid, atid->hwq_depth,
5206 SEQNO(bf->bf_state.bfs_seqno));
5235 ath_tx_comp_cleanup_unaggr(sc, bf);
5259 freeframe = ath_tx_tid_filt_comp_single(sc, atid, bf);
5261 * If freeframe=0 then bf is no longer ours; don't
5266 if (bf->bf_state.bfs_addedbaw)
5268 if (bf->bf_state.bfs_dobaw) {
5269 ath_tx_update_baw(sc, an, atid, bf);
5270 if (!bf->bf_state.bfs_addedbaw)
5273 __func__, SEQNO(bf->bf_state.bfs_seqno));
5275 bf->bf_state.bfs_dobaw = 0;
5294 * cloned and bf is still valid. Just complete/free it.
5297 ath_tx_default_comp(sc, bf, fail);
5312 ath_tx_aggr_retry_unaggr(sc, bf);
5318 __func__, tid, SEQNO(bf->bf_state.bfs_seqno));
5319 if (bf->bf_state.bfs_dobaw) {
5320 ath_tx_update_baw(sc, an, atid, bf);
5321 bf->bf_state.bfs_dobaw = 0;
5322 if (!bf->bf_state.bfs_addedbaw)
5325 __func__, SEQNO(bf->bf_state.bfs_seqno));
5349 ath_tx_default_comp(sc, bf, fail);
5350 /* bf is freed at this point */
5354 ath_tx_aggr_comp(struct ath_softc *sc, struct ath_buf *bf, int fail)
5356 if (bf->bf_state.bfs_aggr)
5357 ath_tx_aggr_comp_aggr(sc, bf, fail);
5359 ath_tx_aggr_comp_unaggr(sc, bf, fail);
5374 struct ath_buf *bf;
5387 TAILQ_FOREACH(bf, &tid->tid_q, bf_list) {
5395 SEQNO(bf->bf_state.bfs_seqno)))) {
5400 if (! bf->bf_state.bfs_dobaw) {
5404 nbytes += bf->bf_state.bfs_pktlen;
5430 struct ath_buf *bf;
5465 bf = ATH_TID_FIRST(tid);
5466 if (bf == NULL) {
5474 if (! bf->bf_state.bfs_dobaw) {
5478 ATH_TID_REMOVE(tid, bf, bf_list);
5480 if (bf->bf_state.bfs_nframes > 1)
5484 bf->bf_state.bfs_aggr,
5485 bf->bf_state.bfs_nframes);
5493 bf->bf_state.bfs_aggr = 0;
5494 bf->bf_state.bfs_nframes = 1;
5497 ath_tx_update_clrdmask(sc, tid, bf);
5499 ath_tx_do_ratelookup(sc, bf, tid->tid,
5500 bf->bf_state.bfs_pktlen, false);
5501 ath_tx_calc_duration(sc, bf);
5502 ath_tx_calc_protection(sc, bf);
5503 ath_tx_set_rtscts(sc, bf);
5504 ath_tx_rate_fill_rcflags(sc, bf);
5505 ath_tx_setds(sc, bf);
5506 ath_hal_clr11n_aggr(sc->sc_ah, bf->bf_desc);
5522 ath_tx_do_ratelookup(sc, bf, tid->tid, swq_pktbytes, true);
5529 ath_tx_calc_duration(sc, bf);
5530 ath_tx_calc_protection(sc, bf);
5532 ath_tx_set_rtscts(sc, bf);
5533 ath_tx_rate_fill_rcflags(sc, bf);
5550 bf = TAILQ_FIRST(&bf_q);
5560 if (bf->bf_state.bfs_nframes == 1) {
5565 ath_tx_update_clrdmask(sc, tid, bf);
5567 bf->bf_state.bfs_aggr = 0;
5568 bf->bf_state.bfs_ndelim = 0;
5569 ath_tx_setds(sc, bf);
5570 ath_hal_clr11n_aggr(sc->sc_ah, bf->bf_desc);
5579 __func__, bf->bf_state.bfs_nframes,
5580 bf->bf_state.bfs_al);
5581 bf->bf_state.bfs_aggr = 1;
5582 sc->sc_aggr_stats.aggr_pkts[bf->bf_state.bfs_nframes]++;
5586 ath_tx_update_clrdmask(sc, tid, bf);
5591 ath_tx_calc_duration(sc, bf);
5592 ath_tx_calc_protection(sc, bf);
5599 ath_tx_set_rtscts(sc, bf);
5606 ath_tx_setds_11n(sc, bf);
5610 bf->bf_comp = ath_tx_aggr_comp;
5612 if (bf->bf_state.bfs_tid == IEEE80211_NONQOS_TID)
5621 ath_tx_leak_count_update(sc, tid, bf);
5624 ath_tx_handoff(sc, txq, bf);
5661 struct ath_buf *bf;
5688 bf = ATH_TID_FIRST(tid);
5689 if (bf == NULL) {
5693 ATH_TID_REMOVE(tid, bf, bf_list);
5696 if (tid->tid != bf->bf_state.bfs_tid) {
5698 " tid %d\n", __func__, bf->bf_state.bfs_tid,
5702 bf->bf_comp = ath_tx_normal_comp;
5708 bf->bf_state.bfs_txflags |= HAL_TXDESC_CLRDMASK;
5711 ath_tx_update_clrdmask(sc, tid, bf);
5714 ath_tx_do_ratelookup(sc, bf, tid->tid,
5715 bf->bf_state.bfs_pktlen, false);
5716 ath_tx_calc_duration(sc, bf);
5717 ath_tx_calc_protection(sc, bf);
5718 ath_tx_set_rtscts(sc, bf);
5719 ath_tx_rate_fill_rcflags(sc, bf);
5720 ath_tx_setds(sc, bf);
5727 ath_tx_leak_count_update(sc, tid, bf);
5734 ath_tx_handoff(sc, txq, bf);
5939 * a "bf->bf_state.bfs_dobaw" flag, and this isn't set for these
6050 struct ath_buf *bf;
6107 while ((bf = TAILQ_FIRST(&bf_cq)) != NULL) {
6108 TAILQ_REMOVE(&bf_cq, bf, bf_list);
6109 ath_tx_default_comp(sc, bf, 1);
6126 struct ath_buf *bf;
6160 while ((bf = TAILQ_FIRST(&bf_cq)) != NULL) {
6161 TAILQ_REMOVE(&bf_cq, bf, bf_list);
6162 ath_tx_default_comp(sc, bf, 1);