Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/virtio/network/if_vtnet.c
Context not available. | |||||
struct virtqueue *vq; | struct virtqueue *vq; | ||||
int nbufs, error; | int nbufs, error; | ||||
#ifdef DEV_NETMAP | |||||
error = vtnet_netmap_rxq_populate(rxq); | |||||
if (error >= 0) | |||||
return (error); | |||||
#endif /* DEV_NETMAP */ | |||||
vq = rxq->vtnrx_vq; | vq = rxq->vtnrx_vq; | ||||
error = ENOSPC; | error = ENOSPC; | ||||
Context not available. | |||||
struct virtqueue *vq; | struct virtqueue *vq; | ||||
struct mbuf *m; | struct mbuf *m; | ||||
int last; | int last; | ||||
#ifdef DEV_NETMAP | |||||
int netmap_bufs = vtnet_netmap_queue_on(rxq->vtnrx_sc, NR_RX, | |||||
rxq->vtnrx_id); | |||||
#else /* !DEV_NETMAP */ | |||||
int netmap_bufs = 0; | |||||
#endif /* !DEV_NETMAP */ | |||||
vq = rxq->vtnrx_vq; | vq = rxq->vtnrx_vq; | ||||
last = 0; | last = 0; | ||||
while ((m = virtqueue_drain(vq, &last)) != NULL) | while ((m = virtqueue_drain(vq, &last)) != NULL) { | ||||
m_freem(m); | if (!netmap_bufs) | ||||
m_freem(m); | |||||
} | |||||
KASSERT(virtqueue_empty(vq), | KASSERT(virtqueue_empty(vq), | ||||
("%s: mbufs remaining in rx queue %p", __func__, rxq)); | ("%s: mbufs remaining in rx queue %p", __func__, rxq)); | ||||
Context not available. | |||||
VTNET_RXQ_LOCK_ASSERT(rxq); | VTNET_RXQ_LOCK_ASSERT(rxq); | ||||
#ifdef DEV_NETMAP | |||||
if (netmap_rx_irq(ifp, 0, &deq)) { | |||||
return (FALSE); | |||||
} | |||||
#endif /* DEV_NETMAP */ | |||||
while (count-- > 0) { | while (count-- > 0) { | ||||
m = virtqueue_dequeue(vq, &len); | m = virtqueue_dequeue(vq, &len); | ||||
if (m == NULL) | if (m == NULL) | ||||
Context not available. | |||||
return; | return; | ||||
} | } | ||||
#ifdef DEV_NETMAP | |||||
if (netmap_rx_irq(ifp, rxq->vtnrx_id, &more)) | |||||
bryanv: `more` is not initialized at this point, and then assigned before being used later on, so is it… | |||||
Done Inline ActionsThe value returned in the third argument is used on Linux, and not used on FreeBSD. Something not-NULL must be provided to tell netmap that this is an RX interrupt (if NULL, it means it is a TX interrupt). vmaffione: The value returned in the third argument is used on Linux, and not used on FreeBSD. Something… | |||||
return; | |||||
#endif /* DEV_NETMAP */ | |||||
VTNET_RXQ_LOCK(rxq); | VTNET_RXQ_LOCK(rxq); | ||||
again: | again: | ||||
Context not available. | |||||
struct virtqueue *vq; | struct virtqueue *vq; | ||||
struct vtnet_tx_header *txhdr; | struct vtnet_tx_header *txhdr; | ||||
int last; | int last; | ||||
#ifdef DEV_NETMAP | |||||
int netmap_bufs = vtnet_netmap_queue_on(txq->vtntx_sc, NR_TX, | |||||
txq->vtntx_id); | |||||
#else /* !DEV_NETMAP */ | |||||
int netmap_bufs = 0; | |||||
#endif /* !DEV_NETMAP */ | |||||
vq = txq->vtntx_vq; | vq = txq->vtntx_vq; | ||||
last = 0; | last = 0; | ||||
while ((txhdr = virtqueue_drain(vq, &last)) != NULL) { | while ((txhdr = virtqueue_drain(vq, &last)) != NULL) { | ||||
m_freem(txhdr->vth_mbuf); | if (!netmap_bufs) { | ||||
uma_zfree(vtnet_tx_header_zone, txhdr); | m_freem(txhdr->vth_mbuf); | ||||
uma_zfree(vtnet_tx_header_zone, txhdr); | |||||
} | |||||
} | } | ||||
KASSERT(virtqueue_empty(vq), | KASSERT(virtqueue_empty(vq), | ||||
Context not available. | |||||
deq = 0; | deq = 0; | ||||
VTNET_TXQ_LOCK_ASSERT(txq); | VTNET_TXQ_LOCK_ASSERT(txq); | ||||
#ifdef DEV_NETMAP | |||||
if (netmap_tx_irq(txq->vtntx_sc->vtnet_ifp, txq->vtntx_id)) { | |||||
virtqueue_disable_intr(vq); // XXX luigi | |||||
return 0; // XXX or 1 ? | |||||
} | |||||
#endif /* DEV_NETMAP */ | |||||
while ((txhdr = virtqueue_dequeue(vq, NULL)) != NULL) { | while ((txhdr = virtqueue_dequeue(vq, NULL)) != NULL) { | ||||
m = txhdr->vth_mbuf; | m = txhdr->vth_mbuf; | ||||
deq++; | deq++; | ||||
Context not available. | |||||
return; | return; | ||||
} | } | ||||
#ifdef DEV_NETMAP | |||||
if (netmap_tx_irq(ifp, txq->vtntx_id)) | |||||
Done Inline ActionsTo generally match the style used elsewhere in this file, can you add a != 0 here? bryanv: To generally match the style used elsewhere in this file, can you add a `!= 0` here? | |||||
Done Inline ActionsFixed here and also for the netmap_rx_irq call. vmaffione: Fixed here and also for the netmap_rx_irq call. | |||||
return; | |||||
#endif /* DEV_NETMAP */ | |||||
VTNET_TXQ_LOCK(txq); | VTNET_TXQ_LOCK(txq); | ||||
if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) { | if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) { | ||||
Context not available. | |||||
struct vtnet_txq *txq; | struct vtnet_txq *txq; | ||||
int i; | int i; | ||||
#ifdef DEV_NETMAP | |||||
if (nm_native_on(NA(sc->vtnet_ifp))) | |||||
return; | |||||
#endif /* DEV_NETMAP */ | |||||
for (i = 0; i < sc->vtnet_act_vq_pairs; i++) { | for (i = 0; i < sc->vtnet_act_vq_pairs; i++) { | ||||
rxq = &sc->vtnet_rxqs[i]; | rxq = &sc->vtnet_rxqs[i]; | ||||
vtnet_rxq_free_mbufs(rxq); | vtnet_rxq_free_mbufs(rxq); | ||||
Context not available. | |||||
("%s: too many rx mbufs %d for %d segments", __func__, | ("%s: too many rx mbufs %d for %d segments", __func__, | ||||
sc->vtnet_rx_nmbufs, sc->vtnet_rx_nsegs)); | sc->vtnet_rx_nmbufs, sc->vtnet_rx_nsegs)); | ||||
#ifdef DEV_NETMAP | |||||
if (vtnet_netmap_init_rx_buffers(sc)) | |||||
return 0; | |||||
#endif /* DEV_NETMAP */ | |||||
for (i = 0; i < sc->vtnet_act_vq_pairs; i++) { | for (i = 0; i < sc->vtnet_act_vq_pairs; i++) { | ||||
rxq = &sc->vtnet_rxqs[i]; | rxq = &sc->vtnet_rxqs[i]; | ||||
Context not available. | |||||
sc = xsc; | sc = xsc; | ||||
#ifdef DEV_NETMAP | |||||
if (!NA(sc->vtnet_ifp)) { | |||||
D("try to attach again"); | |||||
vtnet_netmap_attach(sc); | |||||
} | |||||
#endif /* DEV_NETMAP */ | |||||
VTNET_CORE_LOCK(sc); | VTNET_CORE_LOCK(sc); | ||||
vtnet_init_locked(sc); | vtnet_init_locked(sc); | ||||
VTNET_CORE_UNLOCK(sc); | VTNET_CORE_UNLOCK(sc); | ||||
Context not available. |
more is not initialized at this point, and then assigned before being used later on, so is it needed here?