Skip to contentSkip to conversation

virtio: add VIRTIO_RING_NO_LEGACY

PATCH Superseded Matej Genci 2 participants 4 messages Sep 10, 2019 – Sep 11, 2019 virtio core

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 virtio: add VIRTIO_RING_NO_LEGACY

Add macro to disable legacy functions vring_init and vring_size.

---

V2: Put all legacy APIs inside guards.

---
 include/uapi/linux/virtio_ring.h | 8 ++++++++
 1 file changed, 8 insertions(+)
include/uapi/linux/virtio_ring.h +8 -0
index 4c4e24c291a5..efe5a421b4ea 100644
@@ -118,6 +118,8 @@ struct vring_used {
 	struct vring_used_elem ring[];
 };
 
+#ifndef VIRTIO_RING_NO_LEGACY
+
 struct vring {
 	unsigned int num;
 
@@ -128,6 +130,8 @@ struct vring {
 	struct vring_used *used;
 };
 
+#endif /* VIRTIO_RING_NO_LEGACY */
+
 /* Alignment requirements for vring elements.
  * When using pre-virtio 1.0 layout, these fall out naturally.
  */
@@ -135,6 +139,8 @@ struct vring {
 #define VRING_USED_ALIGN_SIZE 4
 #define VRING_DESC_ALIGN_SIZE 16
 
+#ifndef VIRTIO_RING_NO_LEGACY
+
 /* The standard layout for the ring is a continuous chunk of memory which looks
  * like this.  We assume num is a power of 2.
  *
@@ -195,6 +201,8 @@ static inline int vring_need_event(__u16 event_idx, __u16 new_idx, __u16 old)
 	return (__u16)(new_idx - event_idx - 1) < (__u16)(new_idx - old);
 }
 
+#endif /* VIRTIO_RING_NO_LEGACY */
+
 struct vring_packed_desc_event {
 	/* Descriptor Ring Change Event Offset/Wrap Counter. */
 	__le16 off_wrap;
Signature · 1 line
2.22.0
#1 lore raw
Quoted 43 lines · Matej Genci

Add macro to disable legacy functions vring_init and vring_size.

---

V2: Put all legacy APIs inside guards.

---
 include/uapi/linux/virtio_ring.h | 8 ++++++++
 1 file changed, 8 insertions(+)
include/uapi/linux/virtio_ring.h +6 -0
index 4c4e24c291a5..efe5a421b4ea 100644
@@ -118,6 +118,8 @@ struct vring_used {
 	struct vring_used_elem ring[];
 };
 
+#ifndef VIRTIO_RING_NO_LEGACY
+
 struct vring {
 	unsigned int num;
 
@@ -128,6 +130,8 @@ struct vring {
 	struct vring_used *used;
 };
 
+#endif /* VIRTIO_RING_NO_LEGACY */
+
 /* Alignment requirements for vring elements.
  * When using pre-virtio 1.0 layout, these fall out naturally.
  */
@@ -135,6 +139,8 @@ struct vring {
 #define VRING_USED_ALIGN_SIZE 4
 #define VRING_DESC_ALIGN_SIZE 16
 
+#ifndef VIRTIO_RING_NO_LEGACY
+
 /* The standard layout for the ring is a continuous chunk of memory which looks
  * like this.  We assume num is a power of 2.
  *

include/uapi/linux/virtio_ring.h static inline int vring_need_event(__u16 event_idx, __u16 new_idx, __u16 old) · line 208

Quoted 8 lines
include/uapi/linux/virtio_ring.h +2 -0
@@ -195,6 +201,8 @@ static inline int vring_need_event(__u16 event_idx, __u16 new_idx, __u16 old)
 	return (__u16)(new_idx - event_idx - 1) < (__u16)(new_idx - old);
 }
 
+#endif /* VIRTIO_RING_NO_LEGACY */
+
 struct vring_packed_desc_event {
 	/* Descriptor Ring Change Event Offset/Wrap Counter. */
 	__le16 off_wrap;

OK almost but vring_need_event is actually useful for all variants so should be outside the guards :) Sorry about it.

Signature · 1 line
MST
#2 lore raw
In reply to Matej Genci
Quoted 43 lines · Matej Genci

Add macro to disable legacy functions vring_init and vring_size.

---

V2: Put all legacy APIs inside guards.

---
 include/uapi/linux/virtio_ring.h | 8 ++++++++
 1 file changed, 8 insertions(+)
include/uapi/linux/virtio_ring.h +6 -0
index 4c4e24c291a5..efe5a421b4ea 100644
@@ -118,6 +118,8 @@ struct vring_used {
 	struct vring_used_elem ring[];
 };
 
+#ifndef VIRTIO_RING_NO_LEGACY
+
 struct vring {
 	unsigned int num;
 
@@ -128,6 +130,8 @@ struct vring {
 	struct vring_used *used;
 };
 
+#endif /* VIRTIO_RING_NO_LEGACY */
+
 /* Alignment requirements for vring elements.
  * When using pre-virtio 1.0 layout, these fall out naturally.
  */
@@ -135,6 +139,8 @@ struct vring {
 #define VRING_USED_ALIGN_SIZE 4
 #define VRING_DESC_ALIGN_SIZE 16
 
+#ifndef VIRTIO_RING_NO_LEGACY
+
 /* The standard layout for the ring is a continuous chunk of memory which looks
  * like this.  We assume num is a power of 2.
  *

include/uapi/linux/virtio_ring.h static inline int vring_need_event(__u16 event_idx, __u16 new_idx, __u16 old) · line 208

Quoted 8 lines
include/uapi/linux/virtio_ring.h +2 -0
@@ -195,6 +201,8 @@ static inline int vring_need_event(__u16 event_idx, __u16 new_idx, __u16 old)
 	return (__u16)(new_idx - event_idx - 1) < (__u16)(new_idx - old);
 }
 
+#endif /* VIRTIO_RING_NO_LEGACY */
+
 struct vring_packed_desc_event {
 	/* Descriptor Ring Change Event Offset/Wrap Counter. */
 	__le16 off_wrap;

OK almost but vring_need_event is actually useful for all variants so should be outside the guards :) Sorry about it.

Signature · 1 line
MST
#3 lore raw
In reply to Matej Genci
Quoted 3 lines · Matej Genci

Add macro to disable legacy functions vring_init and vring_size.

And I guess we should be able to define this macro in drivers/virtio/virtio_pci_modern.c
?

Will be handy to make sure we don't mask too much.

Quoted 51 lines

---

V2: Put all legacy APIs inside guards.

---
 include/uapi/linux/virtio_ring.h | 8 ++++++++
 1 file changed, 8 insertions(+)
include/uapi/linux/virtio_ring.h +8 -0
index 4c4e24c291a5..efe5a421b4ea 100644
@@ -118,6 +118,8 @@ struct vring_used {
 	struct vring_used_elem ring[];
 };
 
+#ifndef VIRTIO_RING_NO_LEGACY
+
 struct vring {
 	unsigned int num;
 
@@ -128,6 +130,8 @@ struct vring {
 	struct vring_used *used;
 };
 
+#endif /* VIRTIO_RING_NO_LEGACY */
+
 /* Alignment requirements for vring elements.
  * When using pre-virtio 1.0 layout, these fall out naturally.
  */
@@ -135,6 +139,8 @@ struct vring {
 #define VRING_USED_ALIGN_SIZE 4
 #define VRING_DESC_ALIGN_SIZE 16
 
+#ifndef VIRTIO_RING_NO_LEGACY
+
 /* The standard layout for the ring is a continuous chunk of memory which looks
  * like this.  We assume num is a power of 2.
  *
@@ -195,6 +201,8 @@ static inline int vring_need_event(__u16 event_idx, __u16 new_idx, __u16 old)
 	return (__u16)(new_idx - event_idx - 1) < (__u16)(new_idx - old);
 }
 
+#endif /* VIRTIO_RING_NO_LEGACY */
+
 struct vring_packed_desc_event {
 	/* Descriptor Ring Change Event Offset/Wrap Counter. */
 	__le16 off_wrap;
Signature · 1 line
2.22.0