]> xenbits.xensource.com Git - unikraft/unikraft.git/commitdiff
PR #610.1: Various fixes for firecracker networking
authorMarco Schlumpp <marco@unikraft.io>
Thu, 16 Feb 2023 13:37:42 +0000 (14:37 +0100)
committerMichalis Pappas <michalis@unikraft.io>
Tue, 22 Aug 2023 09:04:44 +0000 (11:04 +0200)
* There were some incorrect offsets in the orginal PR
* The feature negotiation did not work for the virtqueue

plat/drivers/virtio/virtio_mmio.c
plat/drivers/virtio/virtio_net.c
plat/drivers/virtio/virtio_ring.c

index e0f72573ac0ac6960c1e185a52a3c1d3f144ebb2..f3ad107e3c0d8bd5b3ac82fa6984a548ffde8d1f 100644 (file)
@@ -114,7 +114,7 @@ static void vm_set_features(struct virtio_dev *vdev,
        struct virtio_mmio_device *vm_dev = to_virtio_mmio_device(vdev);
 
        /* Give virtio_ring a chance to accept features. */
-       virtqueue_feature_negotiate(features);
+       features = virtqueue_feature_negotiate(features);
 
        /* Make sure there are no mixed devices */
        if (vm_dev->version == 2 &&
index 01f4fbf59696b5d1d04bd41c7bd0d87f11b7c7d7..74c032260c334e12bf4b02d69e2b5b47e55877df 100644 (file)
@@ -340,7 +340,7 @@ static int virtio_netdev_xmit(struct uk_netdev *dev,
        struct virtio_net_device *vndev;
        struct virtio_net_hdr *vhdr;
        struct virtio_net_hdr_padded *padded_hdr;
-       int16_t header_sz = sizeof(*padded_hdr);
+       int16_t header_sz;
        int rc = 0;
        int status = 0x0;
        size_t total_len = 0;
@@ -351,6 +351,9 @@ static int virtio_netdev_xmit(struct uk_netdev *dev,
        UK_ASSERT(pkt && queue);
 
        vndev = to_virtionetdev(dev);
+
+       header_sz = vndev->modern ? VIRTIO_HDR_LEN : sizeof(*vhdr);
+
        /**
         * We are reclaiming the free descriptors from buffers. The function is
         * not protected by means of locks. We need to be careful if there are
@@ -363,7 +366,7 @@ static int virtio_netdev_xmit(struct uk_netdev *dev,
        /**
         * Use the preallocated header space for the virtio header.
         */
-       rc = uk_netbuf_header(pkt, VIRTIO_HDR_LEN);
+       rc = uk_netbuf_header(pkt, vndev->modern ? VIRTIO_HDR_LEN : sizeof(*padded_hdr));
        if (unlikely(rc != 1)) {
                uk_pr_err("Failed to prepend virtio header\n");
                rc = -ENOSPC;
@@ -384,11 +387,11 @@ static int virtio_netdev_xmit(struct uk_netdev *dev,
         *       to `uk_sglist_append_netbuf()`. However, a netbuf
         *       chain can only once have set the PARTIAL_CSUM flag.
         */
-       memset(vhdr, 0, VIRTIO_HDR_LEN);
+       memset(vhdr, 0, header_sz);
        if (pkt->flags & UK_NETBUF_F_PARTIAL_CSUM) {
                vhdr->flags       |= VIRTIO_NET_HDR_F_NEEDS_CSUM;
                /* `csum_start` is without header size */
-               vhdr->csum_start   = pkt->csum_start - header_sz;
+               vhdr->csum_start   = pkt->csum_start - (vndev->modern ? VIRTIO_HDR_LEN : sizeof(*padded_hdr));
                vhdr->csum_offset  = pkt->csum_offset;
        }
        if (pkt->flags & UK_NETBUF_F_GSO_TCPV4) {
index 5f748b54285a1a3d103dcff155ac996de8ef6243..3e0e35e37f28628613b27c8d9088d62201fc6441 100644 (file)
@@ -253,6 +253,8 @@ __u64 virtqueue_feature_negotiate(__u64 feature_set)
 {
        __u64 feature = (1ULL << VIRTIO_TRANSPORT_F_START) - 1;
 
+       /* Allow version 1 flag */
+       feature |= 1ULL << VIRTIO_F_VERSION_1;
        /* Allow event index feature */
        feature |= 1ULL << VIRTIO_F_EVENT_IDX;