Lines Matching defs:txd

670 hn_txpkt_sglist(struct hn_tx_ring *txr, struct hn_txdesc *txd)
673 KASSERT(txd->chim_index == HN_NVS_CHIM_IDX_INVALID &&
674 txd->chim_size == 0, ("invalid rndis sglist txd"));
676 &txd->send_ctx, txr->hn_gpa, txr->hn_gpa_cnt));
680 hn_txpkt_chim(struct hn_tx_ring *txr, struct hn_txdesc *txd)
684 KASSERT(txd->chim_index != HN_NVS_CHIM_IDX_INVALID &&
685 txd->chim_size > 0, ("invalid rndis chim txd"));
689 rndis.nvs_chim_idx = txd->chim_index;
690 rndis.nvs_chim_sz = txd->chim_size;
693 &rndis, sizeof(rndis), &txd->send_ctx));
2652 hn_txdesc_dmamap_load(struct hn_tx_ring *txr, struct hn_txdesc *txd,
2658 KASSERT(txd->chim_index == HN_NVS_CHIM_IDX_INVALID, ("txd uses chim"));
2660 error = bus_dmamap_load_mbuf_sg(txr->hn_tx_data_dtag, txd->data_dmap,
2673 txd->data_dmap, m, segs, nsegs, BUS_DMA_NOWAIT);
2676 bus_dmamap_sync(txr->hn_tx_data_dtag, txd->data_dmap,
2678 txd->flags |= HN_TXD_FLAG_DMAMAP;
2684 hn_txdesc_put(struct hn_tx_ring *txr, struct hn_txdesc *txd)
2687 KASSERT((txd->flags & HN_TXD_FLAG_ONLIST) == 0,
2688 ("put an onlist txd %#x", txd->flags));
2689 KASSERT((txd->flags & HN_TXD_FLAG_ONAGG) == 0,
2690 ("put an onagg txd %#x", txd->flags));
2692 KASSERT(txd->refs > 0, ("invalid txd refs %d", txd->refs));
2693 if (atomic_fetchadd_int(&txd->refs, -1) != 1)
2696 if (!STAILQ_EMPTY(&txd->agg_list)) {
2699 while ((tmp_txd = STAILQ_FIRST(&txd->agg_list)) != NULL) {
2715 STAILQ_REMOVE_HEAD(&txd->agg_list, agg_link);
2722 if (txd->chim_index != HN_NVS_CHIM_IDX_INVALID) {
2723 KASSERT((txd->flags & HN_TXD_FLAG_DMAMAP) == 0,
2724 ("chim txd uses dmamap"));
2725 hn_chim_free(txr->hn_sc, txd->chim_index);
2726 txd->chim_index = HN_NVS_CHIM_IDX_INVALID;
2727 txd->chim_size = 0;
2728 } else if (txd->flags & HN_TXD_FLAG_DMAMAP) {
2730 txd->data_dmap, BUS_DMASYNC_POSTWRITE);
2732 txd->data_dmap);
2733 txd->flags &= ~HN_TXD_FLAG_DMAMAP;
2736 if (txd->m != NULL) {
2737 m_freem(txd->m);
2738 txd->m = NULL;
2741 txd->flags |= HN_TXD_FLAG_ONLIST;
2746 ("txdesc_put: invalid txd avail %d", txr->hn_txdesc_avail));
2748 SLIST_INSERT_HEAD(&txr->hn_txlist, txd, link);
2754 buf_ring_enqueue(txr->hn_txdesc_br, txd);
2763 struct hn_txdesc *txd;
2767 txd = SLIST_FIRST(&txr->hn_txlist);
2768 if (txd != NULL) {
2770 ("txdesc_get: invalid txd avail %d", txr->hn_txdesc_avail));
2776 txd = buf_ring_dequeue_sc(txr->hn_txdesc_br);
2779 if (txd != NULL) {
2785 KASSERT(txd->m == NULL && txd->refs == 0 &&
2786 STAILQ_EMPTY(&txd->agg_list) &&
2787 txd->chim_index == HN_NVS_CHIM_IDX_INVALID &&
2788 txd->chim_size == 0 &&
2789 (txd->flags & HN_TXD_FLAG_ONLIST) &&
2790 (txd->flags & HN_TXD_FLAG_ONAGG) == 0 &&
2791 (txd->flags & HN_TXD_FLAG_DMAMAP) == 0, ("invalid txd"));
2792 txd->flags &= ~HN_TXD_FLAG_ONLIST;
2793 txd->refs = 1;
2795 return txd;
2799 hn_txdesc_hold(struct hn_txdesc *txd)
2803 KASSERT(txd->refs > 0, ("invalid txd refs %d", txd->refs));
2804 atomic_add_int(&txd->refs, 1);
2808 hn_txdesc_agg(struct hn_txdesc *agg_txd, struct hn_txdesc *txd)
2814 KASSERT((txd->flags & HN_TXD_FLAG_ONAGG) == 0,
2816 KASSERT(STAILQ_EMPTY(&txd->agg_list),
2819 txd->flags |= HN_TXD_FLAG_ONAGG;
2820 STAILQ_INSERT_TAIL(&agg_txd->agg_list, txd, agg_link);
2851 struct hn_txdesc *txd = sndc->hn_cbarg;
2854 txr = txd->txr;
2860 hn_txdesc_put(txr, txd);
2936 struct hn_txdesc *txd;
2940 txd = txr->hn_agg_txd;
2941 KASSERT(txd != NULL, ("no aggregate txdesc"));
2951 * Since txd's mbuf will _not_ be freed upon hn_txpkt()
2955 m = txd->m;
2956 error = hn_txpkt(ifp, txr, txd);
2958 /* txd is freed, but m is not. */
2975 hn_try_txagg(if_t ifp, struct hn_tx_ring *txr, struct hn_txdesc *txd,
3001 hn_txdesc_agg(agg_txd, txd);
3025 txd->chim_index = hn_chim_alloc(txr->hn_sc);
3026 if (txd->chim_index == HN_NVS_CHIM_IDX_INVALID)
3031 (txd->chim_index * txr->hn_sc->hn_chim_szmax);
3035 txr->hn_agg_txd = txd;
3045 * If this function fails, then both txd and m_head0 will be freed.
3048 hn_encap(if_t ifp, struct hn_tx_ring *txr, struct hn_txdesc *txd,
3059 pkt = txd->rndis_pkt;
3062 chim = hn_try_txagg(ifp, txr, txd, pkt_size);
3169 struct hn_txdesc *tgt_txd = txd;
3193 KASSERT(txd->chim_index == HN_NVS_CHIM_IDX_INVALID,
3195 KASSERT(pkt == txd->rndis_pkt, ("RNDIS pkt not in txdesc"));
3197 error = hn_txdesc_dmamap_load(txr, txd, &m_head, segs, &nsegs);
3202 * This mbuf is not linked w/ the txd yet, so free it now.
3207 freed = hn_txdesc_put(txr, txd);
3209 ("fail to free txd upon txdma error"));
3221 txr->hn_gpa[0].gpa_page = atop(txd->rndis_pkt_paddr);
3222 txr->hn_gpa[0].gpa_ofs = txd->rndis_pkt_paddr & PAGE_MASK;
3237 txd->chim_index = HN_NVS_CHIM_IDX_INVALID;
3238 txd->chim_size = 0;
3241 txd->m = m_head;
3244 hn_nvs_sendctx_init(&txd->send_ctx, hn_txpkt_done, txd);
3257 * If this function fails, then txd will be freed, but the mbuf
3258 * associated w/ the txd will _not_ be freed.
3261 hn_txpkt(if_t ifp, struct hn_tx_ring *txr, struct hn_txdesc *txd)
3269 * Make sure that this txd and any aggregated txds are not
3272 hn_txdesc_hold(txd);
3274 error = txr->hn_sendpkt(txr, txd);
3279 ETHER_BPF_MTAP(ifp, txd->m);
3280 STAILQ_FOREACH(tmp_txd, &txd->agg_list, agg_link)
3300 hn_txdesc_put(txr, txd);
3331 txd->m = NULL;
3332 freed = hn_txdesc_put(txr, txd);
3334 ("fail to free txd upon send error"));
5269 struct hn_txdesc *txd = &txr->hn_txdesc[i];
5271 txd->txr = txr;
5272 txd->chim_index = HN_NVS_CHIM_IDX_INVALID;
5273 STAILQ_INIT(&txd->agg_list);
5279 (void **)&txd->rndis_pkt,
5281 &txd->rndis_pkt_dmap);
5289 txd->rndis_pkt_dmap,
5290 txd->rndis_pkt, HN_RNDIS_PKT_LEN,
5291 hyperv_dma_map_paddr, &txd->rndis_pkt_paddr,
5297 txd->rndis_pkt, txd->rndis_pkt_dmap);
5303 &txd->data_dmap);
5308 txd->rndis_pkt_dmap);
5310 txd->rndis_pkt, txd->rndis_pkt_dmap);
5315 txd->flags |= HN_TXD_FLAG_ONLIST;
5317 SLIST_INSERT_HEAD(&txr->hn_txlist, txd, link);
5319 buf_ring_enqueue(txr->hn_txdesc_br, txd);
5369 hn_txdesc_dmamap_destroy(struct hn_txdesc *txd)
5371 struct hn_tx_ring *txr = txd->txr;
5373 KASSERT(txd->m == NULL, ("still has mbuf installed"));
5374 KASSERT((txd->flags & HN_TXD_FLAG_DMAMAP) == 0, ("still dma mapped"));
5376 bus_dmamap_unload(txr->hn_tx_rndis_dtag, txd->rndis_pkt_dmap);
5377 bus_dmamem_free(txr->hn_tx_rndis_dtag, txd->rndis_pkt,
5378 txd->rndis_pkt_dmap);
5379 bus_dmamap_destroy(txr->hn_tx_data_dtag, txd->data_dmap);
5383 hn_txdesc_gc(struct hn_tx_ring *txr, struct hn_txdesc *txd)
5386 KASSERT(txd->refs == 0 || txd->refs == 1,
5387 ("invalid txd refs %d", txd->refs));
5389 /* Aggregated txds will be freed by their aggregating txd. */
5390 if (txd->refs > 0 && (txd->flags & HN_TXD_FLAG_ONAGG) == 0) {
5393 freed = hn_txdesc_put(txr, txd);
5409 * to the aggregating txd, two passes are used here:
5705 struct hn_txdesc *txd;
5741 txd = hn_txdesc_get(txr);
5742 if (txd == NULL) {
5749 error = hn_encap(ifp, txr, txd, &m_head);
5751 /* Both txd and m_head are freed */
5769 error = hn_txpkt(ifp, txr, txd);
5771 /* txd is freed, but m_head is not */
5885 struct hn_txdesc *txd;
5899 txd = hn_txdesc_get(txr);
5900 if (txd == NULL) {
5907 error = hn_encap(ifp, txr, txd, &m_head);
5909 /* Both txd and m_head are freed; discard */
5927 error = hn_txpkt(ifp, txr, txd);
5929 /* txd is freed, but m_head is not */