virtio-win / kvm-guest-drivers-windows

Windows paravirtualized drivers for QEMU\KVM
https://www.linux-kvm.org/page/WindowsGuestDrivers
BSD 3-Clause "New" or "Revised" License
2k stars 385 forks source link

Does NETKVM support mergeable #381

Closed suoben closed 5 years ago

suoben commented 5 years ago

In the Parandis_initializecontext function we set the VIRTIO_NET_F_MRG_RXBUF, but we didn't use the num_buffers(num_buffers defined invirtio_net_hdr_mrg_rxbuf) for mergeable,Does windows NETKVM support mergeable?Hope for your reply!

YanVugenfirer commented 5 years ago

For some reason this message is not shown here. Re-copying from email:

In the Parandis_initializecontext function we set the VIRTIO_NET_F_MRG_RXBUF, but we didn't use the num_buffers(num_buffers defined invirtio_net_hdr_mrg_rxbuf) for mergeable,For example, the Virtio-net driver for Linux is handled as follows:

static struct sk_buff *receive_mergeable(struct net_device *dev,
struct virtnet_info *vi,
struct receive_queue *rq,
void *buf,
unsigned int len)
{
struct virtio_net_hdr_mrg_rxbuf *hdr = page_address(buf);
u16 num_buf = virtio16_to_cpu(rq->vq->vdev, hdr->num_buffers);
struct page *page = buf;
struct sk_buff *skb = page_to_skb(vi, rq, page, len);
int i;

if (unlikely(!skb))

    goto err_skb;

while (--num_buf) {

    i = skb_shinfo(skb)->nr_frags;

    if (i >= MAX_SKB_FRAGS) {

        pr_debug("%s: packet too long\n", skb->dev->name);

        skb->dev->stats.rx_length_errors++;

        return NULL;

    }

    page = virtqueue_get_buf(rq->vq, &len);

    if (!page) {

        pr_debug("%s: rx error: %d buffers %d missing\n",

             dev->name,

             virtio16_to_cpu(rq->vq->vdev,

                     hdr->num_buffers),

             num_buf);

        dev->stats.rx_length_errors++;

        goto err_buf;

    }

    if (len > PAGE_SIZE)

        len = PAGE_SIZE;

    set_skb_frag(skb, page, 0, &len);

    --rq->num;

}

return skb;

err_skb:
give_pages(rq, page);
while (--num_buf) {
buf = virtqueue_get_buf(rq->vq, &len);
if (unlikely(!buf)) {
pr_debug("%s: rx error: %d buffers missing\n",
dev->name, num_buf);
dev->stats.rx_length_errors++;
break;
}
page = buf;
give_pages(rq, page);
--rq->num;
}
err_buf:
dev->stats.rx_dropped++;
dev_kfree_skb(skb);
return NULL;
}

Does windows NETKVM support mergeable?Hope for your reply!

YanVugenfirer commented 5 years ago

In general, we should support mergeable buffers. But of course, we can have some bug or deficiency in the support.

Do you see a specific issue?

suoben commented 5 years ago

1.Configure Vhostuser network cards for VM,Running "iperf3-s" inside VM 2.Create hnic on the host and configure IP to communicate with the VM 3.ifconfig hnic0 mtu 8888 4.iperf3 -c vmip -l 6000 -t 0 -u -b 10G

By following the steps above, the VM may hang,there are some bugs in the mergeable process?

YanVugenfirer commented 5 years ago

Do you configure large MTU on VM as well?

suoben commented 5 years ago

The MTU of the virtual machine defaults to 1500, I have not modified

YanVugenfirer commented 5 years ago

Please modify as well

suoben commented 5 years ago

If I change Hnic's MTU to 1500, it's well. If I modify the MTU of the VM to 8888, and the hnic's mtu is 8888,it's still hang. when the MTU is over 4084,VM is hang,I'm guessing mergable has some bugs

suoben commented 5 years ago

If I comment out "pContext->bUseMergedBuffers = AckFeature(pContext, VIRTIO_NET_F_MRG_RXBUF);",it is well too

YanVugenfirer commented 5 years ago

Can you please provide your VM command line and host network setup? Thanks.

suoben commented 5 years ago

1.Configure Vhostuser network cards for VM,Configure static IP(vmip:192.168.3.105) for network cards,and running "iperf3 -s" inside VM. The network card configuration file is as follows: `

  <source type='unix' path='/var/run/vhost-user/uevstap02' mode='client'/>
  <target dev='uevstap02'/>
  <model type='virtio'/>
  <boot order='2'/>
  <alias name='net0'/>
  <address type='pci' domain='0x0000' bus='0x04' slot='0x03' function='0x0'/>
</interface>`

Execute the following command: ovs-vsctl --timeout=15 add-br br0 -- set bridge br0 datapath_type=dpdk other_config:fwd_mode=openflow ovs-vsctl --timeout=15 add-port br0 uevstap02 -- set interface uevstap02 type=virtio 2.Create hnic on the host and configure IP to communicate with the VM Execute the following command: ovs-vsctl add-port br0 hnic0 -- set interface hnic0 type=hnic options:numa_id=1 ifconfig hnic0 192.168.3.101/16 3.ifconfig hnic0 mtu 8888 4.iperf3 -c vmip -l 6000 -t 0 -u -b 10G

In the same scene, I tested centos7.5. it is well

ybendito commented 5 years ago

@suoben What it the Windows guest OS?

suoben commented 5 years ago

win2008 ent r2 sp1

ybendito commented 5 years ago

@suoben Can you please check it with one of 2012, 2012R2 or 2016 or respective client OS, i.e 8.1 or 10? I suspect that some problem might exist for Win7 and earlier.

suoben commented 5 years ago

I tested 2012R2 and 2016, it is well,some bugs might exist for Win7 and earlier,thanks all.

ybendito commented 5 years ago

@suoben The problem that we want to understand and find a root cause is VM hang. In general this should never happen: if the MTU is not configured in the guest (in advanced properties of the adapter), each packet bigger than MTU is discarded. If the MTU is configured in the guest as well as on host side, the networking shall work regardless settings of mergeable buffers, as the guest provides packets sized as MTU (+header). The question: does the problem (VM hang) happen with 2008R2 if you use network interface other than vhostuser:dpdk? For example 'bridge'? Thanks

suoben commented 5 years ago

It's vhostuser's problem.vhostuser does not support mergeable well,We've solved this problem.thanks all.