Lines Matching defs:txq
854 struct vtnet_txq *txq;
856 txq = &sc->vtnet_txqs[id];
858 snprintf(txq->vtntx_name, sizeof(txq->vtntx_name), "%s-tx%d",
860 mtx_init(&txq->vtntx_mtx, txq->vtntx_name, NULL, MTX_DEF);
862 txq->vtntx_sc = sc;
863 txq->vtntx_id = id;
865 txq->vtntx_sg = sglist_alloc(sc->vtnet_tx_nsegs, M_NOWAIT);
866 if (txq->vtntx_sg == NULL)
870 txq->vtntx_br = buf_ring_alloc(VTNET_DEFAULT_BUFRING_SIZE, M_DEVBUF,
871 M_NOWAIT, &txq->vtntx_mtx);
872 if (txq->vtntx_br == NULL)
875 TASK_INIT(&txq->vtntx_defrtask, 0, vtnet_txq_tq_deferred, txq);
877 TASK_INIT(&txq->vtntx_intrtask, 0, vtnet_txq_tq_intr, txq);
878 txq->vtntx_tq = taskqueue_create(txq->vtntx_name, M_NOWAIT,
879 taskqueue_thread_enqueue, &txq->vtntx_tq);
880 if (txq->vtntx_tq == NULL)
936 vtnet_destroy_txq(struct vtnet_txq *txq)
939 txq->vtntx_sc = NULL;
940 txq->vtntx_id = -1;
942 if (txq->vtntx_sg != NULL) {
943 sglist_free(txq->vtntx_sg);
944 txq->vtntx_sg = NULL;
948 if (txq->vtntx_br != NULL) {
949 buf_ring_free(txq->vtntx_br, M_DEVBUF);
950 txq->vtntx_br = NULL;
954 if (mtx_initialized(&txq->vtntx_mtx) != 0)
955 mtx_destroy(&txq->vtntx_mtx);
1020 struct vtnet_txq *txq;
1039 txq = &sc->vtnet_txqs[i];
1041 vtnet_tx_vq_intr, txq, &txq->vtntx_vq,
1042 "%s-tx%d", device_get_nameunit(dev), txq->vtntx_id);
1051 txq = &sc->vtnet_txqs[i];
1052 VQ_ALLOC_INFO_INIT(&info[idx+1], 0, NULL, txq, &txq->vtntx_vq,
1053 "%s-tx%d", device_get_nameunit(dev), txq->vtntx_id);
2266 vtnet_txq_intr_threshold(struct vtnet_txq *txq)
2271 sc = txq->vtntx_sc;
2281 threshold = virtqueue_size(txq->vtntx_vq) / 4;
2295 vtnet_txq_below_threshold(struct vtnet_txq *txq)
2299 vq = txq->vtntx_vq;
2301 return (virtqueue_nfree(vq) <= txq->vtntx_intr_threshold);
2305 vtnet_txq_notify(struct vtnet_txq *txq)
2309 vq = txq->vtntx_vq;
2311 txq->vtntx_watchdog = VTNET_TX_TIMEOUT;
2314 if (vtnet_txq_enable_intr(txq) == 0)
2322 if (vtnet_txq_eof(txq) != 0 && vtnet_txq_below_threshold(txq) == 0) {
2331 vtnet_txq_free_mbufs(struct vtnet_txq *txq)
2337 struct netmap_kring *kring = netmap_kring_on(NA(txq->vtntx_sc->vtnet_ifp),
2338 txq->vtntx_id, NR_TX);
2343 vq = txq->vtntx_vq;
2354 ("%s: mbufs remaining in tx queue %p", __func__, txq));
2361 vtnet_txq_offload_ctx(struct vtnet_txq *txq, struct mbuf *m, int *etype,
2370 sc = txq->vtntx_sc;
2420 vtnet_txq_offload_tso(struct vtnet_txq *txq, struct mbuf *m, int eth_type,
2428 sc = txq->vtntx_sc;
2457 txq->vtntx_stats.vtxs_tso++;
2463 vtnet_txq_offload(struct vtnet_txq *txq, struct mbuf *m,
2469 sc = txq->vtntx_sc;
2472 error = vtnet_txq_offload_ctx(txq, m, &etype, &proto, &csum_start);
2488 txq->vtntx_stats.vtxs_csum++;
2505 error = vtnet_txq_offload_tso(txq, m, etype, csum_start, hdr);
2518 vtnet_txq_enqueue_buf(struct vtnet_txq *txq, struct mbuf **m_head,
2527 sc = txq->vtntx_sc;
2528 vq = txq->vtntx_vq;
2529 sg = txq->vtntx_sg;
2568 vtnet_txq_encap(struct vtnet_txq *txq, struct mbuf **m_head, int flags)
2602 m = vtnet_txq_offload(txq, m, hdr);
2609 error = vtnet_txq_enqueue_buf(txq, m_head, txhdr);
2620 vtnet_start_locked(struct vtnet_txq *txq, if_t ifp)
2627 sc = txq->vtntx_sc;
2628 vq = txq->vtntx_vq;
2631 VTNET_TXQ_LOCK_ASSERT(txq);
2637 vtnet_txq_eof(txq);
2650 if (vtnet_txq_encap(txq, &m0, M_NOWAIT) != 0) {
2660 if (enq > 0 && vtnet_txq_notify(txq) != 0) {
2664 txq->vtntx_stats.vtxs_rescheduled++;
2665 taskqueue_enqueue(txq->vtntx_tq, &txq->vtntx_intrtask);
2673 struct vtnet_txq *txq;
2676 txq = &sc->vtnet_txqs[0];
2678 VTNET_TXQ_LOCK(txq);
2679 vtnet_start_locked(txq, ifp);
2680 VTNET_TXQ_UNLOCK(txq);
2686 vtnet_txq_mq_start_locked(struct vtnet_txq *txq, struct mbuf *m)
2694 sc = txq->vtntx_sc;
2695 vq = txq->vtntx_vq;
2696 br = txq->vtntx_br;
2701 VTNET_TXQ_LOCK_ASSERT(txq);
2716 vtnet_txq_eof(txq);
2727 if (vtnet_txq_encap(txq, &m, M_NOWAIT) != 0) {
2740 if (enq > 0 && vtnet_txq_notify(txq) != 0) {
2744 txq->vtntx_stats.vtxs_rescheduled++;
2745 taskqueue_enqueue(txq->vtntx_tq, &txq->vtntx_intrtask);
2755 struct vtnet_txq *txq;
2766 txq = &sc->vtnet_txqs[i];
2768 if (VTNET_TXQ_TRYLOCK(txq) != 0) {
2769 error = vtnet_txq_mq_start_locked(txq, m);
2770 VTNET_TXQ_UNLOCK(txq);
2772 error = drbr_enqueue(ifp, txq->vtntx_br, m);
2773 taskqueue_enqueue(txq->vtntx_tq, &txq->vtntx_defrtask);
2783 struct vtnet_txq *txq;
2785 txq = xtxq;
2786 sc = txq->vtntx_sc;
2788 VTNET_TXQ_LOCK(txq);
2789 if (!drbr_empty(sc->vtnet_ifp, txq->vtntx_br))
2790 vtnet_txq_mq_start_locked(txq, NULL);
2791 VTNET_TXQ_UNLOCK(txq);
2797 vtnet_txq_start(struct vtnet_txq *txq)
2802 sc = txq->vtntx_sc;
2807 vtnet_start_locked(txq, ifp);
2809 if (!drbr_empty(ifp, txq->vtntx_br))
2810 vtnet_txq_mq_start_locked(txq, NULL);
2818 struct vtnet_txq *txq;
2821 txq = xtxq;
2822 sc = txq->vtntx_sc;
2825 VTNET_TXQ_LOCK(txq);
2828 VTNET_TXQ_UNLOCK(txq);
2832 vtnet_txq_eof(txq);
2833 vtnet_txq_start(txq);
2835 VTNET_TXQ_UNLOCK(txq);
2839 vtnet_txq_eof(struct vtnet_txq *txq)
2846 vq = txq->vtntx_vq;
2848 VTNET_TXQ_LOCK_ASSERT(txq);
2854 txq->vtntx_stats.vtxs_opackets++;
2855 txq->vtntx_stats.vtxs_obytes += m->m_pkthdr.len;
2857 txq->vtntx_stats.vtxs_omcasts++;
2864 txq->vtntx_watchdog = 0;
2873 struct vtnet_txq *txq;
2876 txq = xtxq;
2877 sc = txq->vtntx_sc;
2880 if (__predict_false(txq->vtntx_id >= sc->vtnet_act_vq_pairs)) {
2887 vtnet_txq_disable_intr(txq);
2892 if (netmap_tx_irq(ifp, txq->vtntx_id) != NM_IRQ_PASS)
2896 VTNET_TXQ_LOCK(txq);
2899 VTNET_TXQ_UNLOCK(txq);
2903 vtnet_txq_eof(txq);
2904 vtnet_txq_start(txq);
2906 VTNET_TXQ_UNLOCK(txq);
2912 struct vtnet_txq *txq;
2918 txq = &sc->vtnet_txqs[i];
2920 VTNET_TXQ_LOCK(txq);
2921 vtnet_txq_start(txq);
2922 VTNET_TXQ_UNLOCK(txq);
2931 struct vtnet_txq *txq;
2938 txq = &sc->vtnet_txqs[i];
2940 VTNET_TXQ_LOCK(txq);
2941 while ((m = buf_ring_dequeue_sc(txq->vtntx_br)) != NULL)
2943 VTNET_TXQ_UNLOCK(txq);
2951 vtnet_watchdog(struct vtnet_txq *txq)
2955 ifp = txq->vtntx_sc->vtnet_ifp;
2957 VTNET_TXQ_LOCK(txq);
2958 if (txq->vtntx_watchdog == 1) {
2967 if (vtnet_txq_eof(txq) != 0)
2968 vtnet_txq_start(txq);
2971 if (txq->vtntx_watchdog == 0 || --txq->vtntx_watchdog) {
2972 VTNET_TXQ_UNLOCK(txq);
2975 VTNET_TXQ_UNLOCK(txq);
2977 if_printf(ifp, "watchdog timeout on queue %d\n", txq->vtntx_id);
3068 struct vtnet_txq *txq;
3091 txq = &sc->vtnet_txqs[i];
3092 error = taskqueue_start_threads(&txq->vtntx_tq, 1, PI_NET,
3093 "%s txq %d", device_get_nameunit(dev), txq->vtntx_id);
3096 txq->vtntx_id);
3105 struct vtnet_txq *txq;
3115 txq = &sc->vtnet_txqs[i];
3116 if (txq->vtntx_tq != NULL) {
3117 taskqueue_free(txq->vtntx_tq);
3118 txq->vtntx_tq = NULL;
3127 struct vtnet_txq *txq;
3135 txq = &sc->vtnet_txqs[i];
3136 if (txq->vtntx_tq != NULL) {
3137 taskqueue_drain(txq->vtntx_tq, &txq->vtntx_intrtask);
3139 taskqueue_drain(txq->vtntx_tq, &txq->vtntx_defrtask);
3149 struct vtnet_txq *txq;
3156 txq = &sc->vtnet_txqs[i];
3157 vtnet_txq_free_mbufs(txq);
3165 struct vtnet_txq *txq;
3181 txq = &sc->vtnet_txqs[i];
3182 VTNET_TXQ_LOCK(txq);
3183 VTNET_TXQ_UNLOCK(txq);
3320 struct vtnet_txq *txq;
3324 txq = &sc->vtnet_txqs[i];
3325 txq->vtntx_watchdog = 0;
3326 txq->vtntx_intr_threshold = vtnet_txq_intr_threshold(txq);
4116 struct sysctl_oid_list *child, struct vtnet_txq *txq)
4123 snprintf(namebuf, sizeof(namebuf), "txq%d", txq->vtntx_id);
4128 stats = &txq->vtntx_stats;
4304 vtnet_txq_enable_intr(struct vtnet_txq *txq)
4308 vq = txq->vtntx_vq;
4310 if (vtnet_txq_below_threshold(txq) != 0)
4321 vtnet_txq_disable_intr(struct vtnet_txq *txq)
4324 virtqueue_disable_intr(txq->vtntx_vq);
4438 struct vtnet_txq *txq;
4446 txq = &sc->vtnet_txqs[0];
4447 error = vtnet_txq_encap(txq, &m, M_NOWAIT | M_USE_RESERVE);
4449 (void)vtnet_txq_notify(txq);