From: Jens Freimann Date: Mon, 17 Dec 2018 21:31:30 +0000 (+0100) Subject: net/virtio: add packed virtqueue defines X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=4c3f5822eb21476fbbd807a7c40584c1090695e5;p=dpdk.git net/virtio: add packed virtqueue defines Signed-off-by: Jens Freimann Reviewed-by: Maxime Coquelin --- diff --git a/drivers/net/virtio/virtio_pci.h b/drivers/net/virtio/virtio_pci.h index e961a58ca6..4c975a5316 100644 --- a/drivers/net/virtio/virtio_pci.h +++ b/drivers/net/virtio/virtio_pci.h @@ -113,6 +113,7 @@ struct virtnet_ctl; #define VIRTIO_F_VERSION_1 32 #define VIRTIO_F_IOMMU_PLATFORM 33 +#define VIRTIO_F_RING_PACKED 34 /* * Some VirtIO feature bits (currently bits 28 through 31) are diff --git a/drivers/net/virtio/virtio_ring.h b/drivers/net/virtio/virtio_ring.h index 9e3c2a0152..464449074f 100644 --- a/drivers/net/virtio/virtio_ring.h +++ b/drivers/net/virtio/virtio_ring.h @@ -15,6 +15,10 @@ #define VRING_DESC_F_WRITE 2 /* This means the buffer contains a list of buffer descriptors. */ #define VRING_DESC_F_INDIRECT 4 +/* This flag means the descriptor was made available by the driver */ +#define VRING_DESC_F_AVAIL(b) ((uint16_t)(b) << 7) +/* This flag means the descriptor was used by the device */ +#define VRING_DESC_F_USED(b) ((uint16_t)(b) << 15) /* The Host uses this in used->flags to advise the Guest: don't kick me * when you add a buffer. It's unreliable, so it's simply an @@ -54,6 +58,32 @@ struct vring_used { struct vring_used_elem ring[0]; }; +/* For support of packed virtqueues in Virtio 1.1 the format of descriptors + * looks like this. + */ +struct vring_packed_desc { + uint64_t addr; + uint32_t len; + uint16_t id; + uint16_t flags; +}; + +#define RING_EVENT_FLAGS_ENABLE 0x0 +#define RING_EVENT_FLAGS_DISABLE 0x1 +#define RING_EVENT_FLAGS_DESC 0x2 +struct vring_packed_desc_event { + uint16_t desc_event_off_wrap; + uint16_t desc_event_flags; +}; + +struct vring_packed { + unsigned int num; + struct vring_packed_desc *desc_packed; + struct vring_packed_desc_event *driver_event; + struct vring_packed_desc_event *device_event; + +}; + struct vring { unsigned int num; struct vring_desc *desc; diff --git a/drivers/net/virtio/virtqueue.h b/drivers/net/virtio/virtqueue.h index 26518ed98c..d4e0858e40 100644 --- a/drivers/net/virtio/virtqueue.h +++ b/drivers/net/virtio/virtqueue.h @@ -161,11 +161,17 @@ struct virtio_pmd_ctrl { struct vq_desc_extra { void *cookie; uint16_t ndescs; + uint16_t next; }; struct virtqueue { struct virtio_hw *hw; /**< virtio_hw structure pointer. */ struct vring vq_ring; /**< vring keeping desc, used and avail */ + struct vring_packed ring_packed; /**< vring keeping descs */ + bool avail_wrap_counter; + bool used_wrap_counter; + uint16_t event_flags_shadow; + uint16_t avail_used_flags; /** * Last consumed descriptor in the used table, * trails vq_ring.used->idx.