Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/virtio/network/if_vtnet.c
Show First 20 Lines • Show All 82 Lines • ▼ Show 20 Lines | |||||
return (rxq->vtnrx_tq == NULL ? ENOMEM : 0); | return (rxq->vtnrx_tq == NULL ? ENOMEM : 0); | ||||
} | } | ||||
static int | static int | ||||
vtnet_init_txq(struct vtnet_softc *sc, int id) | vtnet_init_txq(struct vtnet_softc *sc, int id) | ||||
{ | { | ||||
struct vtnet_txq *txq; | struct vtnet_txq *txq; | ||||
int npairs; | |||||
txq = &sc->vtnet_txqs[id]; | txq = &sc->vtnet_txqs[id]; | ||||
npairs = sc->vtnet_max_vq_pairs; | |||||
snprintf(txq->vtntx_name, sizeof(txq->vtntx_name), "%s-tx%d", | snprintf(txq->vtntx_name, sizeof(txq->vtntx_name), "%s-tx%d", | ||||
device_get_nameunit(sc->vtnet_dev), id); | device_get_nameunit(sc->vtnet_dev), id); | ||||
mtx_init(&txq->vtntx_mtx, txq->vtntx_name, NULL, MTX_DEF); | mtx_init(&txq->vtntx_mtx, txq->vtntx_name, NULL, MTX_DEF); | ||||
txq->vtntx_sc = sc; | txq->vtntx_sc = sc; | ||||
txq->vtntx_id = id; | txq->vtntx_id = id; | ||||
txq->vtntx_sg = sglist_alloc(sc->vtnet_tx_nsegs, M_NOWAIT); | txq->vtntx_sg = sglist_alloc(sc->vtnet_tx_nsegs, M_NOWAIT); | ||||
if (txq->vtntx_sg == NULL) | if (txq->vtntx_sg == NULL) | ||||
return (ENOMEM); | return (ENOMEM); | ||||
#ifndef VTNET_LEGACY_TX | #ifndef VTNET_LEGACY_TX | ||||
txq->vtntx_br = buf_ring_alloc(VTNET_DEFAULT_BUFRING_SIZE, M_DEVBUF, | txq->vtntx_br = buf_ring_alloc(VTNET_DEFAULT_BUFRING_SIZE, M_DEVBUF, | ||||
M_NOWAIT, &txq->vtntx_mtx); | M_NOWAIT, &txq->vtntx_mtx, id, npairs); | ||||
if (txq->vtntx_br == NULL) | if (txq->vtntx_br == NULL) | ||||
return (ENOMEM); | return (ENOMEM); | ||||
TASK_INIT(&txq->vtntx_defrtask, 0, vtnet_txq_tq_deferred, txq); | TASK_INIT(&txq->vtntx_defrtask, 0, vtnet_txq_tq_deferred, txq); | ||||
#endif | #endif | ||||
TASK_INIT(&txq->vtntx_intrtask, 0, vtnet_txq_tq_intr, txq); | TASK_INIT(&txq->vtntx_intrtask, 0, vtnet_txq_tq_intr, txq); | ||||
txq->vtntx_tq = taskqueue_create(txq->vtntx_name, M_NOWAIT, | txq->vtntx_tq = taskqueue_create(txq->vtntx_name, M_NOWAIT, | ||||
taskqueue_thread_enqueue, &txq->vtntx_tq); | taskqueue_thread_enqueue, &txq->vtntx_tq); | ||||
▲ Show 20 Lines • Show All 82 Lines • Show Last 20 Lines |