diff --git a/lib/librte_vhost/virtio-net.c b/lib/librte_vhost/virtio-net.c index 33bdacd..d304ee6 100644 --- a/lib/librte_vhost/virtio-net.c +++ b/lib/librte_vhost/virtio-net.c @@ -467,6 +467,8 @@ static int set_features(struct vhost_device_ctx ctx, uint64_t *pu) { struct virtio_net *dev; + uint16_t vhost_hlen; + uint16_t i; dev = get_device(ctx); if (dev == NULL) @@ -474,27 +476,26 @@ set_features(struct vhost_device_ctx ctx, uint64_t *pu) if (*pu & ~VHOST_FEATURES) return -1; - /* Store the negotiated feature list for the device. */ dev->features = *pu; - - /* Set the vhost_hlen depending on if VIRTIO_NET_F_MRG_RXBUF is set. */ if (dev->features & (1 << VIRTIO_NET_F_MRG_RXBUF)) { LOG_DEBUG(VHOST_CONFIG, "(%"PRIu64") Mergeable RX buffers enabled\n", dev->device_fh); - dev->virtqueue[VIRTIO_RXQ]->vhost_hlen = - sizeof(struct virtio_net_hdr_mrg_rxbuf); - dev->virtqueue[VIRTIO_TXQ]->vhost_hlen = - sizeof(struct virtio_net_hdr_mrg_rxbuf); + vhost_hlen = sizeof(struct virtio_net_hdr_mrg_rxbuf); } else { LOG_DEBUG(VHOST_CONFIG, "(%"PRIu64") Mergeable RX buffers disabled\n", dev->device_fh); - dev->virtqueue[VIRTIO_RXQ]->vhost_hlen = - sizeof(struct virtio_net_hdr); - dev->virtqueue[VIRTIO_TXQ]->vhost_hlen = - sizeof(struct virtio_net_hdr); + vhost_hlen = sizeof(struct virtio_net_hdr); + } + + 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; }