Lines Matching refs:txd
670 hn_txpkt_sglist(struct hn_tx_ring *txr, struct hn_txdesc *txd) in hn_txpkt_sglist() argument
673 KASSERT(txd->chim_index == HN_NVS_CHIM_IDX_INVALID && in hn_txpkt_sglist()
674 txd->chim_size == 0, ("invalid rndis sglist txd")); in hn_txpkt_sglist()
676 &txd->send_ctx, txr->hn_gpa, txr->hn_gpa_cnt)); in hn_txpkt_sglist()
680 hn_txpkt_chim(struct hn_tx_ring *txr, struct hn_txdesc *txd) in hn_txpkt_chim() argument
684 KASSERT(txd->chim_index != HN_NVS_CHIM_IDX_INVALID && in hn_txpkt_chim()
685 txd->chim_size > 0, ("invalid rndis chim txd")); in hn_txpkt_chim()
689 rndis.nvs_chim_idx = txd->chim_index; in hn_txpkt_chim()
690 rndis.nvs_chim_sz = txd->chim_size; in hn_txpkt_chim()
693 &rndis, sizeof(rndis), &txd->send_ctx)); in hn_txpkt_chim()
2652 hn_txdesc_dmamap_load(struct hn_tx_ring *txr, struct hn_txdesc *txd, in hn_txdesc_dmamap_load() argument
2658 KASSERT(txd->chim_index == HN_NVS_CHIM_IDX_INVALID, ("txd uses chim")); in hn_txdesc_dmamap_load()
2660 error = bus_dmamap_load_mbuf_sg(txr->hn_tx_data_dtag, txd->data_dmap, in hn_txdesc_dmamap_load()
2673 txd->data_dmap, m, segs, nsegs, BUS_DMA_NOWAIT); in hn_txdesc_dmamap_load()
2676 bus_dmamap_sync(txr->hn_tx_data_dtag, txd->data_dmap, in hn_txdesc_dmamap_load()
2678 txd->flags |= HN_TXD_FLAG_DMAMAP; in hn_txdesc_dmamap_load()
2684 hn_txdesc_put(struct hn_tx_ring *txr, struct hn_txdesc *txd) in hn_txdesc_put() argument
2687 KASSERT((txd->flags & HN_TXD_FLAG_ONLIST) == 0, in hn_txdesc_put()
2688 ("put an onlist txd %#x", txd->flags)); in hn_txdesc_put()
2689 KASSERT((txd->flags & HN_TXD_FLAG_ONAGG) == 0, in hn_txdesc_put()
2690 ("put an onagg txd %#x", txd->flags)); in hn_txdesc_put()
2692 KASSERT(txd->refs > 0, ("invalid txd refs %d", txd->refs)); in hn_txdesc_put()
2693 if (atomic_fetchadd_int(&txd->refs, -1) != 1) in hn_txdesc_put()
2696 if (!STAILQ_EMPTY(&txd->agg_list)) { in hn_txdesc_put()
2699 while ((tmp_txd = STAILQ_FIRST(&txd->agg_list)) != NULL) { in hn_txdesc_put()
2715 STAILQ_REMOVE_HEAD(&txd->agg_list, agg_link); in hn_txdesc_put()
2722 if (txd->chim_index != HN_NVS_CHIM_IDX_INVALID) { in hn_txdesc_put()
2723 KASSERT((txd->flags & HN_TXD_FLAG_DMAMAP) == 0, in hn_txdesc_put()
2725 hn_chim_free(txr->hn_sc, txd->chim_index); in hn_txdesc_put()
2726 txd->chim_index = HN_NVS_CHIM_IDX_INVALID; in hn_txdesc_put()
2727 txd->chim_size = 0; in hn_txdesc_put()
2728 } else if (txd->flags & HN_TXD_FLAG_DMAMAP) { in hn_txdesc_put()
2730 txd->data_dmap, BUS_DMASYNC_POSTWRITE); in hn_txdesc_put()
2732 txd->data_dmap); in hn_txdesc_put()
2733 txd->flags &= ~HN_TXD_FLAG_DMAMAP; in hn_txdesc_put()
2736 if (txd->m != NULL) { in hn_txdesc_put()
2737 m_freem(txd->m); in hn_txdesc_put()
2738 txd->m = NULL; in hn_txdesc_put()
2741 txd->flags |= HN_TXD_FLAG_ONLIST; in hn_txdesc_put()
2748 SLIST_INSERT_HEAD(&txr->hn_txlist, txd, link); in hn_txdesc_put()
2754 buf_ring_enqueue(txr->hn_txdesc_br, txd); in hn_txdesc_put()
2763 struct hn_txdesc *txd; in hn_txdesc_get() local
2767 txd = SLIST_FIRST(&txr->hn_txlist); in hn_txdesc_get()
2768 if (txd != NULL) { in hn_txdesc_get()
2776 txd = buf_ring_dequeue_sc(txr->hn_txdesc_br); in hn_txdesc_get()
2779 if (txd != NULL) { in hn_txdesc_get()
2785 KASSERT(txd->m == NULL && txd->refs == 0 && in hn_txdesc_get()
2786 STAILQ_EMPTY(&txd->agg_list) && in hn_txdesc_get()
2787 txd->chim_index == HN_NVS_CHIM_IDX_INVALID && in hn_txdesc_get()
2788 txd->chim_size == 0 && in hn_txdesc_get()
2789 (txd->flags & HN_TXD_FLAG_ONLIST) && in hn_txdesc_get()
2790 (txd->flags & HN_TXD_FLAG_ONAGG) == 0 && in hn_txdesc_get()
2791 (txd->flags & HN_TXD_FLAG_DMAMAP) == 0, ("invalid txd")); in hn_txdesc_get()
2792 txd->flags &= ~HN_TXD_FLAG_ONLIST; in hn_txdesc_get()
2793 txd->refs = 1; in hn_txdesc_get()
2795 return txd; in hn_txdesc_get()
2799 hn_txdesc_hold(struct hn_txdesc *txd) in hn_txdesc_hold() argument
2803 KASSERT(txd->refs > 0, ("invalid txd refs %d", txd->refs)); in hn_txdesc_hold()
2804 atomic_add_int(&txd->refs, 1); in hn_txdesc_hold()
2808 hn_txdesc_agg(struct hn_txdesc *agg_txd, struct hn_txdesc *txd) in hn_txdesc_agg() argument
2814 KASSERT((txd->flags & HN_TXD_FLAG_ONAGG) == 0, in hn_txdesc_agg()
2816 KASSERT(STAILQ_EMPTY(&txd->agg_list), in hn_txdesc_agg()
2819 txd->flags |= HN_TXD_FLAG_ONAGG; in hn_txdesc_agg()
2820 STAILQ_INSERT_TAIL(&agg_txd->agg_list, txd, agg_link); in hn_txdesc_agg()
2851 struct hn_txdesc *txd = sndc->hn_cbarg; in hn_txpkt_done() local
2854 txr = txd->txr; in hn_txpkt_done()
2860 hn_txdesc_put(txr, txd); in hn_txpkt_done()
2936 struct hn_txdesc *txd; in hn_flush_txagg() local
2940 txd = txr->hn_agg_txd; in hn_flush_txagg()
2941 KASSERT(txd != NULL, ("no aggregate txdesc")); in hn_flush_txagg()
2955 m = txd->m; in hn_flush_txagg()
2956 error = hn_txpkt(ifp, txr, txd); in hn_flush_txagg()
2975 hn_try_txagg(if_t ifp, struct hn_tx_ring *txr, struct hn_txdesc *txd, in hn_try_txagg() argument
3001 hn_txdesc_agg(agg_txd, txd); in hn_try_txagg()
3025 txd->chim_index = hn_chim_alloc(txr->hn_sc); in hn_try_txagg()
3026 if (txd->chim_index == HN_NVS_CHIM_IDX_INVALID) in hn_try_txagg()
3031 (txd->chim_index * txr->hn_sc->hn_chim_szmax); in hn_try_txagg()
3035 txr->hn_agg_txd = txd; in hn_try_txagg()
3048 hn_encap(if_t ifp, struct hn_tx_ring *txr, struct hn_txdesc *txd, in hn_encap() argument
3059 pkt = txd->rndis_pkt; in hn_encap()
3062 chim = hn_try_txagg(ifp, txr, txd, pkt_size); in hn_encap()
3169 struct hn_txdesc *tgt_txd = txd; in hn_encap()
3193 KASSERT(txd->chim_index == HN_NVS_CHIM_IDX_INVALID, in hn_encap()
3195 KASSERT(pkt == txd->rndis_pkt, ("RNDIS pkt not in txdesc")); in hn_encap()
3197 error = hn_txdesc_dmamap_load(txr, txd, &m_head, segs, &nsegs); in hn_encap()
3207 freed = hn_txdesc_put(txr, txd); in hn_encap()
3221 txr->hn_gpa[0].gpa_page = atop(txd->rndis_pkt_paddr); in hn_encap()
3222 txr->hn_gpa[0].gpa_ofs = txd->rndis_pkt_paddr & PAGE_MASK; in hn_encap()
3237 txd->chim_index = HN_NVS_CHIM_IDX_INVALID; in hn_encap()
3238 txd->chim_size = 0; in hn_encap()
3241 txd->m = m_head; in hn_encap()
3244 hn_nvs_sendctx_init(&txd->send_ctx, hn_txpkt_done, txd); in hn_encap()
3261 hn_txpkt(if_t ifp, struct hn_tx_ring *txr, struct hn_txdesc *txd) in hn_txpkt() argument
3272 hn_txdesc_hold(txd); in hn_txpkt()
3274 error = txr->hn_sendpkt(txr, txd); in hn_txpkt()
3279 ETHER_BPF_MTAP(ifp, txd->m); in hn_txpkt()
3280 STAILQ_FOREACH(tmp_txd, &txd->agg_list, agg_link) in hn_txpkt()
3300 hn_txdesc_put(txr, txd); in hn_txpkt()
3331 txd->m = NULL; in hn_txpkt()
3332 freed = hn_txdesc_put(txr, txd); in hn_txpkt()
5267 struct hn_txdesc *txd = &txr->hn_txdesc[i]; in hn_tx_ring_create() local
5269 txd->txr = txr; in hn_tx_ring_create()
5270 txd->chim_index = HN_NVS_CHIM_IDX_INVALID; in hn_tx_ring_create()
5271 STAILQ_INIT(&txd->agg_list); in hn_tx_ring_create()
5277 (void **)&txd->rndis_pkt, in hn_tx_ring_create()
5279 &txd->rndis_pkt_dmap); in hn_tx_ring_create()
5287 txd->rndis_pkt_dmap, in hn_tx_ring_create()
5288 txd->rndis_pkt, HN_RNDIS_PKT_LEN, in hn_tx_ring_create()
5289 hyperv_dma_map_paddr, &txd->rndis_pkt_paddr, in hn_tx_ring_create()
5295 txd->rndis_pkt, txd->rndis_pkt_dmap); in hn_tx_ring_create()
5301 &txd->data_dmap); in hn_tx_ring_create()
5306 txd->rndis_pkt_dmap); in hn_tx_ring_create()
5308 txd->rndis_pkt, txd->rndis_pkt_dmap); in hn_tx_ring_create()
5313 txd->flags |= HN_TXD_FLAG_ONLIST; in hn_tx_ring_create()
5315 SLIST_INSERT_HEAD(&txr->hn_txlist, txd, link); in hn_tx_ring_create()
5317 buf_ring_enqueue(txr->hn_txdesc_br, txd); in hn_tx_ring_create()
5367 hn_txdesc_dmamap_destroy(struct hn_txdesc *txd) in hn_txdesc_dmamap_destroy() argument
5369 struct hn_tx_ring *txr = txd->txr; in hn_txdesc_dmamap_destroy()
5371 KASSERT(txd->m == NULL, ("still has mbuf installed")); in hn_txdesc_dmamap_destroy()
5372 KASSERT((txd->flags & HN_TXD_FLAG_DMAMAP) == 0, ("still dma mapped")); in hn_txdesc_dmamap_destroy()
5374 bus_dmamap_unload(txr->hn_tx_rndis_dtag, txd->rndis_pkt_dmap); in hn_txdesc_dmamap_destroy()
5375 bus_dmamem_free(txr->hn_tx_rndis_dtag, txd->rndis_pkt, in hn_txdesc_dmamap_destroy()
5376 txd->rndis_pkt_dmap); in hn_txdesc_dmamap_destroy()
5377 bus_dmamap_destroy(txr->hn_tx_data_dtag, txd->data_dmap); in hn_txdesc_dmamap_destroy()
5381 hn_txdesc_gc(struct hn_tx_ring *txr, struct hn_txdesc *txd) in hn_txdesc_gc() argument
5384 KASSERT(txd->refs == 0 || txd->refs == 1, in hn_txdesc_gc()
5385 ("invalid txd refs %d", txd->refs)); in hn_txdesc_gc()
5388 if (txd->refs > 0 && (txd->flags & HN_TXD_FLAG_ONAGG) == 0) { in hn_txdesc_gc()
5391 freed = hn_txdesc_put(txr, txd); in hn_txdesc_gc()
5703 struct hn_txdesc *txd; in hn_start_locked() local
5739 txd = hn_txdesc_get(txr); in hn_start_locked()
5740 if (txd == NULL) { in hn_start_locked()
5747 error = hn_encap(ifp, txr, txd, &m_head); in hn_start_locked()
5767 error = hn_txpkt(ifp, txr, txd); in hn_start_locked()
5883 struct hn_txdesc *txd; in hn_xmit() local
5897 txd = hn_txdesc_get(txr); in hn_xmit()
5898 if (txd == NULL) { in hn_xmit()
5905 error = hn_encap(ifp, txr, txd, &m_head); in hn_xmit()
5925 error = hn_txpkt(ifp, txr, txd); in hn_xmit()