X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=drivers%2Fnet%2Fvirtio%2Fvirtqueue.c;h=1f9af3c31b06772fcb5d9471fb2572c5a58a3ce3;hb=9b7466f6ce5bb43200f082fea1e8eb1c22ecd5d3;hp=5ff1e3587ebc1f8617e0a2a604737d5a971a599d;hpb=4cdc4d98313e717df7d1dba769d71e7e4050da54;p=dpdk.git diff --git a/drivers/net/virtio/virtqueue.c b/drivers/net/virtio/virtqueue.c index 5ff1e3587e..1f9af3c31b 100644 --- a/drivers/net/virtio/virtqueue.c +++ b/drivers/net/virtio/virtqueue.c @@ -7,7 +7,7 @@ #include "virtqueue.h" #include "virtio_logs.h" -#include "virtio_pci.h" +#include "virtio.h" #include "virtio_rxtx_simple.h" /* @@ -32,7 +32,8 @@ virtqueue_detach_unused(struct virtqueue *vq) end = (vq->vq_avail_idx + vq->vq_free_cnt) & (vq->vq_nentries - 1); for (idx = 0; idx < vq->vq_nentries; idx++) { - if (hw->use_simple_rx && type == VTNET_RQ) { + if (hw->use_vec_rx && !virtio_with_packed_queue(hw) && + type == VTNET_RQ) { if (start <= end && idx >= start && idx < end) continue; if (start > end && (idx >= start || idx < end)) @@ -92,12 +93,12 @@ virtqueue_rxvq_flush_split(struct virtqueue *vq) uint16_t used_idx, desc_idx; uint16_t nb_used, i; - nb_used = VIRTQUEUE_NUSED(vq); + nb_used = virtqueue_nused(vq); for (i = 0; i < nb_used; i++) { used_idx = vq->vq_used_cons_idx & (vq->vq_nentries - 1); uep = &vq->vq_split.ring.used->ring[used_idx]; - if (hw->use_simple_rx) { + if (hw->use_vec_rx) { desc_idx = used_idx; rte_pktmbuf_free(vq->sw_ring[desc_idx]); vq->vq_free_cnt++; @@ -121,7 +122,7 @@ virtqueue_rxvq_flush_split(struct virtqueue *vq) vq->vq_used_cons_idx++; } - if (hw->use_simple_rx) { + if (hw->use_vec_rx) { while (vq->vq_free_cnt >= RTE_VIRTIO_VPMD_RX_REARM_THRESH) { virtio_rxq_rearm_vec(rxq); if (virtqueue_kick_prepare(vq)) @@ -136,8 +137,81 @@ virtqueue_rxvq_flush(struct virtqueue *vq) { struct virtio_hw *hw = vq->hw; - if (vtpci_packed_queue(hw)) + if (virtio_with_packed_queue(hw)) virtqueue_rxvq_flush_packed(vq); else virtqueue_rxvq_flush_split(vq); } + +int +virtqueue_rxvq_reset_packed(struct virtqueue *vq) +{ + int size = vq->vq_nentries; + struct vq_desc_extra *dxp; + struct virtnet_rx *rxvq; + uint16_t desc_idx; + + vq->vq_used_cons_idx = 0; + vq->vq_desc_head_idx = 0; + vq->vq_avail_idx = 0; + vq->vq_desc_tail_idx = (uint16_t)(vq->vq_nentries - 1); + vq->vq_free_cnt = vq->vq_nentries; + + vq->vq_packed.used_wrap_counter = 1; + vq->vq_packed.cached_flags = VRING_PACKED_DESC_F_AVAIL; + vq->vq_packed.event_flags_shadow = 0; + vq->vq_packed.cached_flags |= VRING_DESC_F_WRITE; + + rxvq = &vq->rxq; + memset(rxvq->mz->addr, 0, rxvq->mz->len); + + for (desc_idx = 0; desc_idx < vq->vq_nentries; desc_idx++) { + dxp = &vq->vq_descx[desc_idx]; + if (dxp->cookie != NULL) { + rte_pktmbuf_free(dxp->cookie); + dxp->cookie = NULL; + } + } + + vring_desc_init_packed(vq, size); + + virtqueue_disable_intr(vq); + return 0; +} + +int +virtqueue_txvq_reset_packed(struct virtqueue *vq) +{ + int size = vq->vq_nentries; + struct vq_desc_extra *dxp; + struct virtnet_tx *txvq; + uint16_t desc_idx; + + vq->vq_used_cons_idx = 0; + vq->vq_desc_head_idx = 0; + vq->vq_avail_idx = 0; + vq->vq_desc_tail_idx = (uint16_t)(vq->vq_nentries - 1); + vq->vq_free_cnt = vq->vq_nentries; + + vq->vq_packed.used_wrap_counter = 1; + vq->vq_packed.cached_flags = VRING_PACKED_DESC_F_AVAIL; + vq->vq_packed.event_flags_shadow = 0; + + txvq = &vq->txq; + memset(txvq->mz->addr, 0, txvq->mz->len); + memset(txvq->virtio_net_hdr_mz->addr, 0, + txvq->virtio_net_hdr_mz->len); + + for (desc_idx = 0; desc_idx < vq->vq_nentries; desc_idx++) { + dxp = &vq->vq_descx[desc_idx]; + if (dxp->cookie != NULL) { + rte_pktmbuf_free(dxp->cookie); + dxp->cookie = NULL; + } + } + + vring_desc_init_packed(vq, size); + + virtqueue_disable_intr(vq); + return 0; +}