X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=lib%2Flibrte_vhost%2Fvirtio-net.c;h=1785695b119ec4b8b333199b06540e5b4d213a49;hb=99c12dcca65d;hp=ea216c026f4393f7e08a66f1a91aaef4e2a6c954;hpb=4ecf22e356de2e6db2cf0a4470cb55b1638db7b0;p=dpdk.git diff --git a/lib/librte_vhost/virtio-net.c b/lib/librte_vhost/virtio-net.c index ea216c026f..1785695b11 100644 --- a/lib/librte_vhost/virtio-net.c +++ b/lib/librte_vhost/virtio-net.c @@ -53,7 +53,6 @@ #include #include "vhost-net.h" -#include "virtio-net.h" #define MAX_VHOST_DEVICE 1024 static struct virtio_net *vhost_devices[MAX_VHOST_DEVICE]; @@ -388,8 +387,6 @@ int vhost_set_features(int vid, uint64_t *pu) { struct virtio_net *dev; - uint16_t vhost_hlen; - uint16_t i; dev = get_device(vid); if (dev == NULL) @@ -400,9 +397,9 @@ vhost_set_features(int vid, uint64_t *pu) dev->features = *pu; if (dev->features & ((1 << VIRTIO_NET_F_MRG_RXBUF) | (1ULL << VIRTIO_F_VERSION_1))) { - vhost_hlen = sizeof(struct virtio_net_hdr_mrg_rxbuf); + dev->vhost_hlen = sizeof(struct virtio_net_hdr_mrg_rxbuf); } else { - vhost_hlen = sizeof(struct virtio_net_hdr); + dev->vhost_hlen = sizeof(struct virtio_net_hdr); } LOG_DEBUG(VHOST_CONFIG, "(%d) mergeable RX buffers %s, virtio 1 %s\n", @@ -410,13 +407,6 @@ vhost_set_features(int vid, uint64_t *pu) (dev->features & (1 << VIRTIO_NET_F_MRG_RXBUF)) ? "on" : "off", (dev->features & (1ULL << VIRTIO_F_VERSION_1)) ? "on" : "off"); - for (i = 0; i < dev->virt_qp_nb; i++) { - uint16_t base_idx = i * VIRTIO_QNUM; - - dev->virtqueue[base_idx + VIRTIO_RXQ]->vhost_hlen = vhost_hlen; - dev->virtqueue[base_idx + VIRTIO_TXQ]->vhost_hlen = vhost_hlen; - } - return 0; } @@ -571,6 +561,14 @@ vhost_set_vring_addr(int vid, struct vhost_vring_addr *addr) return -1; } + if (vq->last_used_idx != vq->used->idx) { + RTE_LOG(WARNING, VHOST_CONFIG, + "last_used_idx (%u) and vq->used->idx (%u) mismatches; " + "some packets maybe resent for Tx and dropped for Rx\n", + vq->last_used_idx, vq->used->idx); + vq->last_used_idx = vq->used->idx; + } + vq->log_guest_addr = addr->log_guest_addr; LOG_DEBUG(VHOST_CONFIG, "(%d) mapped address desc: %p\n", @@ -600,7 +598,6 @@ vhost_set_vring_base(int vid, struct vhost_vring_state *state) /* State->index refers to the queue index. The txq is 1, rxq is 0. */ dev->virtqueue[state->index]->last_used_idx = state->num; - dev->virtqueue[state->index]->last_used_idx_res = state->num; return 0; } @@ -797,7 +794,7 @@ rte_vhost_avail_entries(int vid, uint16_t queue_id) if (!vq->enabled) return 0; - return *(volatile uint16_t *)&vq->avail->idx - vq->last_used_idx_res; + return *(volatile uint16_t *)&vq->avail->idx - vq->last_used_idx; } int