Skip to contentSkip to conversation

net/virtio: packed ring notification data feature support

dpdk-dev Superseded Cheng Jiang 4 participants 13 messages Dec 4, 2019 – Jan 15, 2020 Network drivers

lore
Share & tools
lore
#0 lore raw

This patch supports the feature that the driver passes extra data (besides identifying the virtqueue) in its device notifications.

---
 drivers/net/virtio/virtio_ethdev.h |  3 ++-
 drivers/net/virtio/virtio_pci.c    | 15 ++++++++++++++-
 drivers/net/virtio/virtio_pci.h    |  6 ++++++
 3 files changed, 22 insertions(+), 2 deletions(-)
drivers/net/virtio/virtio_ethdev.h +2 -1
index a10111758..cd8947656 100644
@@ -36,7 +36,8 @@
 	 1ULL << VIRTIO_F_IN_ORDER        |	\
 	 1ULL << VIRTIO_F_RING_PACKED	  |	\
 	 1ULL << VIRTIO_F_IOMMU_PLATFORM  |	\
-	 1ULL << VIRTIO_F_ORDER_PLATFORM)
+	 1ULL << VIRTIO_F_ORDER_PLATFORM  |	\
+	 1ULL << VIRTIO_F_NOTIFICATION_DATA)
 
 #define VIRTIO_PMD_SUPPORTED_GUEST_FEATURES	\
 	(VIRTIO_PMD_DEFAULT_GUEST_FEATURES |	\
drivers/net/virtio/virtio_pci.c +14 -1
index 4468e89cb..2462a7dab 100644
@@ -418,7 +418,20 @@ modern_del_queue(struct virtio_hw *hw, struct virtqueue *vq)
 static void
 modern_notify_queue(struct virtio_hw *hw __rte_unused, struct virtqueue *vq)
 {
-	rte_write16(vq->vq_queue_index, vq->notify_addr);
+	uint32_t notify_data;
+
+	if (!vtpci_with_feature(hw, VIRTIO_F_NOTIFICATION_DATA)) {
+		rte_write16(vq->vq_queue_index, vq->notify_addr);
+		return;
+	}
+
+	if (vtpci_with_feature(hw, VIRTIO_F_RING_PACKED))
+		notify_data = ((((uint32_t)vq->vq_packed.used_wrap_counter << 15) |
+				vq->vq_avail_idx) << 16) | vq->vq_queue_index;
+	else
+		notify_data = ((uint32_t)vq->vq_avail_idx << 16) |
+				vq->vq_queue_index;
+	rte_write32(notify_data, vq->notify_addr);
 }
 
 const struct virtio_pci_ops modern_ops = {
drivers/net/virtio/virtio_pci.h +6 -0
index a38cb45ad..7433d2f08 100644
@@ -135,6 +135,12 @@ struct virtnet_ctl;
  */
 #define VIRTIO_F_ORDER_PLATFORM 36
 
+/*
+ * This feature indicates that the driver passes extra data (besides
+ * identifying the virtqueue) in its device notifications.
+ */
+#define VIRTIO_F_NOTIFICATION_DATA 38
+
 /* The Guest publishes the used index for which it expects an interrupt
  * at the end of the avail ring. Host should ignore the avail->flags field. */
 /* The Host publishes the avail index for which it expects a kick
Signature · 1 line
2.17.1
#1 lore raw
Quoted 42 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of Cheng Jiang
Sent: Wednesday, December 04, 2019 11:03 PM
To: [email protected]
Cc: [email protected]; Bie, Tiwei <[email protected]>; Wang, Zhihong <[email protected]>; Jiang, Cheng1 <[email protected]>
Subject: [dpdk-dev] [DPDK] net/virtio: packed ring notification data feature support

This patch supports the feature that the driver passes extra data (besides identifying the virtqueue) in its device notifications.

---
 drivers/net/virtio/virtio_ethdev.h |  3 ++-
 drivers/net/virtio/virtio_pci.c    | 15 ++++++++++++++-
 drivers/net/virtio/virtio_pci.h    |  6 ++++++
 3 files changed, 22 insertions(+), 2 deletions(-)
drivers/net/virtio/virtio_ethdev.h +2 -1
index a10111758..cd8947656 100644
@@ -36,7 +36,8 @@
 	 1ULL << VIRTIO_F_IN_ORDER        |	\
 	 1ULL << VIRTIO_F_RING_PACKED	  |	\
 	 1ULL << VIRTIO_F_IOMMU_PLATFORM  |	\
-	 1ULL << VIRTIO_F_ORDER_PLATFORM)
+	 1ULL << VIRTIO_F_ORDER_PLATFORM  |	\
+	 1ULL << VIRTIO_F_NOTIFICATION_DATA)
 
 #define VIRTIO_PMD_SUPPORTED_GUEST_FEATURES	\
 	(VIRTIO_PMD_DEFAULT_GUEST_FEATURES |	\
drivers/net/virtio/virtio_pci.c +0 -0
index 4468e89cb..2462a7dab 100644

drivers/net/virtio/virtio_pci.c modern_del_queue(struct virtio_hw *hw, struct · line 422

Quoted 5 lines
drivers/net/virtio/virtio_pci.c +0 -0
@@ -418,7 +418,20 @@ modern_del_queue(struct virtio_hw *hw, struct
 virtqueue *vq)
 static void
 modern_notify_queue(struct virtio_hw *hw __rte_unused, struct virtqueue
 *vq)
 {

Hi Cheng,
hw pointer will be used in notify function, please remove rte_unused attribute.

Thanks,
Marvin

Quoted 40 lines
drivers/net/virtio/virtio_pci.c +9 -1
-	rte_write16(vq->vq_queue_index, vq->notify_addr);
+	uint32_t notify_data;
+
+	if (!vtpci_with_feature(hw, VIRTIO_F_NOTIFICATION_DATA)) {
+		rte_write16(vq->vq_queue_index, vq->notify_addr);
+		return;
+	}
+
+	if (vtpci_with_feature(hw, VIRTIO_F_RING_PACKED))
+		notify_data = ((((uint32_t)vq->vq_packed.used_wrap_counter <<

15) |

drivers/net/virtio/virtio_pci.c +5 -0
+				vq->vq_avail_idx) << 16) | vq->vq_queue_index;
+	else
+		notify_data = ((uint32_t)vq->vq_avail_idx << 16) |
+				vq->vq_queue_index;
+	rte_write32(notify_data, vq->notify_addr);
 }
 
 const struct virtio_pci_ops modern_ops = {
drivers/net/virtio/virtio_pci.h +6 -0
index a38cb45ad..7433d2f08 100644
@@ -135,6 +135,12 @@ struct virtnet_ctl;
  */
 #define VIRTIO_F_ORDER_PLATFORM 36
 
+/*
+ * This feature indicates that the driver passes extra data (besides
+ * identifying the virtqueue) in its device notifications.
+ */
+#define VIRTIO_F_NOTIFICATION_DATA 38
+
 /* The Guest publishes the used index for which it expects an interrupt
  * at the end of the avail ring. Host should ignore the avail->flags

field. */
/* The Host publishes the avail index for which it expects a kick
--
2.17.1

#2 lore raw
Quoted 63 lines

-----Original Message-----
From: Liu, Yong
Sent: Monday, December 9, 2019 10:00 AM
To: Jiang, Cheng1 <[email protected]>; [email protected]
Cc: [email protected]; Bie, Tiwei <[email protected]>; Wang, Zhihong <[email protected]>; Jiang, Cheng1 <[email protected]>
Subject: RE: [dpdk-dev] [DPDK] net/virtio: packed ring notification data feature support

Quoted 40 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of Cheng Jiang
Sent: Wednesday, December 04, 2019 11:03 PM
To: [email protected]
Cc: [email protected]; Bie, Tiwei <[email protected]>; Wang, Zhihong <[email protected]>; Jiang, Cheng1 <[email protected]>
Subject: [dpdk-dev] [DPDK] net/virtio: packed ring notification data feature support

This patch supports the feature that the driver passes extra data (besides identifying the virtqueue) in its device notifications.

---
 drivers/net/virtio/virtio_ethdev.h |  3 ++-
 drivers/net/virtio/virtio_pci.c    | 15 ++++++++++++++-
 drivers/net/virtio/virtio_pci.h    |  6 ++++++
 3 files changed, 22 insertions(+), 2 deletions(-)
drivers/net/virtio/virtio_ethdev.h +2 -1
index a10111758..cd8947656 100644
@@ -36,7 +36,8 @@
 	 1ULL << VIRTIO_F_IN_ORDER        |	\
 	 1ULL << VIRTIO_F_RING_PACKED	  |	\
 	 1ULL << VIRTIO_F_IOMMU_PLATFORM  |	\
-	 1ULL << VIRTIO_F_ORDER_PLATFORM)
+	 1ULL << VIRTIO_F_ORDER_PLATFORM  |	\
+	 1ULL << VIRTIO_F_NOTIFICATION_DATA)
 
 #define VIRTIO_PMD_SUPPORTED_GUEST_FEATURES	\
 	(VIRTIO_PMD_DEFAULT_GUEST_FEATURES |	\
(quoted diff) +0 -0

b/drivers/net/virtio/virtio_pci.c index 4468e89cb..2462a7dab 100644

drivers/net/virtio/virtio_pci.c +0 -0
@@ -418,7 +418,20 @@ modern_del_queue(struct virtio_hw *hw, struct
Quoted 4 lines

virtqueue *vq) static void modern_notify_queue(struct virtio_hw *hw __rte_unused, struct virtqueue
*vq)
{

Hi Cheng,
hw pointer will be used in notify function, please remove rte_unused attribute.

Quoted 3 lines

Thanks,
Marvin

Sure, I'll remove it in the next version.

Thanks very much!
Cheng

Quoted 41 lines
Quoted 41 lines
drivers/net/virtio/virtio_pci.c +9 -1
-	rte_write16(vq->vq_queue_index, vq->notify_addr);
+	uint32_t notify_data;
+
+	if (!vtpci_with_feature(hw, VIRTIO_F_NOTIFICATION_DATA)) {
+		rte_write16(vq->vq_queue_index, vq->notify_addr);
+		return;
+	}
+
+	if (vtpci_with_feature(hw, VIRTIO_F_RING_PACKED))
+		notify_data = ((((uint32_t)vq-

vq_packed.used_wrap_counter <<
15) |

drivers/net/virtio/virtio_pci.c +1 -0
+				vq->vq_avail_idx) << 16) | vq-

vq_queue_index;

drivers/net/virtio/virtio_pci.c +4 -0
+	else
+		notify_data = ((uint32_t)vq->vq_avail_idx << 16) |
+				vq->vq_queue_index;
+	rte_write32(notify_data, vq->notify_addr);
 }
 
 const struct virtio_pci_ops modern_ops = { diff --git

a/drivers/net/virtio/virtio_pci.h b/drivers/net/virtio/virtio_pci.h index a38cb45ad..7433d2f08 100644

drivers/net/virtio/virtio_pci.h +6 -0
@@ -135,6 +135,12 @@ struct virtnet_ctl;
  */
 #define VIRTIO_F_ORDER_PLATFORM 36
 
+/*
+ * This feature indicates that the driver passes extra data (besides
+ * identifying the virtqueue) in its device notifications.
+ */
+#define VIRTIO_F_NOTIFICATION_DATA 38
+
 /* The Guest publishes the used index for which it expects an interrupt
  * at the end of the avail ring. Host should ignore the avail->flags

field. */
/* The Host publishes the avail index for which it expects a kick
--
2.17.1

#3 lore raw

PATCH v2 1/1 net/virtio: packed ring notification data feature support

In reply to Cheng Jiang

This patch supports the feature that the driver passes extra data (besides identifying the virtqueue) in its device notifications.

---

v2:
* Removed rte_unused attribute in *hw.
* Added some comments on notify_data.

 drivers/net/virtio/virtio_ethdev.h |  3 ++-
 drivers/net/virtio/virtio_pci.c    | 27 +++++++++++++++++++++++++--
 drivers/net/virtio/virtio_pci.h    |  6 ++++++
 3 files changed, 33 insertions(+), 3 deletions(-)
drivers/net/virtio/virtio_ethdev.h +2 -1
index a10111758..cd8947656 100644
@@ -36,7 +36,8 @@
 	 1ULL << VIRTIO_F_IN_ORDER        |	\
 	 1ULL << VIRTIO_F_RING_PACKED	  |	\
 	 1ULL << VIRTIO_F_IOMMU_PLATFORM  |	\
-	 1ULL << VIRTIO_F_ORDER_PLATFORM)
+	 1ULL << VIRTIO_F_ORDER_PLATFORM  |	\
+	 1ULL << VIRTIO_F_NOTIFICATION_DATA)
 
 #define VIRTIO_PMD_SUPPORTED_GUEST_FEATURES	\
 	(VIRTIO_PMD_DEFAULT_GUEST_FEATURES |	\
drivers/net/virtio/virtio_pci.c +25 -2
index 4468e89cb..8b4e001a1 100644
@@ -416,9 +416,32 @@ modern_del_queue(struct virtio_hw *hw, struct virtqueue *vq)
 }
 
 static void
-modern_notify_queue(struct virtio_hw *hw __rte_unused, struct virtqueue *vq)
+modern_notify_queue(struct virtio_hw *hw, struct virtqueue *vq)
 {
-	rte_write16(vq->vq_queue_index, vq->notify_addr);
+	uint32_t notify_data;
+
+	if (!vtpci_with_feature(hw, VIRTIO_F_NOTIFICATION_DATA)) {
+		rte_write16(vq->vq_queue_index, vq->notify_addr);
+		return;
+	}
+
+	if (vtpci_with_feature(hw, VIRTIO_F_RING_PACKED)) {
+		/*
+		 * Bit[0:15]: vq queue index
+		 * Bit[16:30]: avail index
+		 * Bit[31]: avail wrap counter
+		 */
+		notify_data = ((((uint32_t)vq->vq_packed.used_wrap_counter << 15) |
+				vq->vq_avail_idx) << 16) | vq->vq_queue_index;
+	} else {
+		/*
+		 * Bit[0:15]: vq queue index
+		 * Bit[16:31]: avail index
+		 */
+		notify_data = ((uint32_t)vq->vq_avail_idx << 16) |
+				vq->vq_queue_index;
+	}
+	rte_write32(notify_data, vq->notify_addr);
 }
 
 const struct virtio_pci_ops modern_ops = {
drivers/net/virtio/virtio_pci.h +6 -0
index a38cb45ad..7433d2f08 100644
@@ -135,6 +135,12 @@ struct virtnet_ctl;
  */
 #define VIRTIO_F_ORDER_PLATFORM 36
 
+/*
+ * This feature indicates that the driver passes extra data (besides
+ * identifying the virtqueue) in its device notifications.
+ */
+#define VIRTIO_F_NOTIFICATION_DATA 38
+
 /* The Guest publishes the used index for which it expects an interrupt
  * at the end of the avail ring. Host should ignore the avail->flags field. */
 /* The Host publishes the avail index for which it expects a kick
Signature · 1 line
2.17.1
#4 lore raw

Hi Jiang,

Quoted 11 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of Cheng Jiang
Sent: Wednesday, December 18, 2019 4:17 PM
To: [email protected]; [email protected]; [email protected]; [email protected]
Cc: [email protected]; Cheng Jiang <[email protected]>
Subject: [dpdk-dev] [PATCH v2] net/virtio: packed ring notification data feature support

This patch supports the feature that the driver passes extra data (besides identifying the virtqueue) in its device notifications.

Can the commit log be more specific about the extra data? Something like "expand the notification to include the avail index and avail wrap counter, if any"?

Quoted 56 lines

---

v2:
* Removed rte_unused attribute in *hw.
* Added some comments on notify_data.

 drivers/net/virtio/virtio_ethdev.h |  3 ++-
 drivers/net/virtio/virtio_pci.c    | 27 +++++++++++++++++++++++++--
 drivers/net/virtio/virtio_pci.h    |  6 ++++++
 3 files changed, 33 insertions(+), 3 deletions(-)
drivers/net/virtio/virtio_ethdev.h +2 -1
index a10111758..cd8947656 100644
@@ -36,7 +36,8 @@
 	 1ULL << VIRTIO_F_IN_ORDER        |	\
 	 1ULL << VIRTIO_F_RING_PACKED	  |	\
 	 1ULL << VIRTIO_F_IOMMU_PLATFORM  |	\
-	 1ULL << VIRTIO_F_ORDER_PLATFORM)
+	 1ULL << VIRTIO_F_ORDER_PLATFORM  |	\
+	 1ULL << VIRTIO_F_NOTIFICATION_DATA)
 
 #define VIRTIO_PMD_SUPPORTED_GUEST_FEATURES	\
 	(VIRTIO_PMD_DEFAULT_GUEST_FEATURES |	\
drivers/net/virtio/virtio_pci.c +15 -2
index 4468e89cb..8b4e001a1 100644
@@ -416,9 +416,32 @@ modern_del_queue(struct virtio_hw *hw, struct
 virtqueue *vq)
 }
 
 static void
-modern_notify_queue(struct virtio_hw *hw __rte_unused, struct virtqueue
 *vq)
+modern_notify_queue(struct virtio_hw *hw, struct virtqueue *vq)
 {
-	rte_write16(vq->vq_queue_index, vq->notify_addr);
+	uint32_t notify_data;
+
+	if (!vtpci_with_feature(hw, VIRTIO_F_NOTIFICATION_DATA)) {
+		rte_write16(vq->vq_queue_index, vq->notify_addr);
+		return;
+	}
+
+	if (vtpci_with_feature(hw, VIRTIO_F_RING_PACKED)) {
+		/*
+		 * Bit[0:15]: vq queue index
+		 * Bit[16:30]: avail index
+		 * Bit[31]: avail wrap counter
+		 */
+		notify_data = ((((uint32_t)vq-
Quoted 1 line
Quoted 1 line

vq_packed.used_wrap_counter << 15) |

Why not do ' used_wrap_counter << 31' to be more straightforward and matches the above comment?

Quoted 34 lines
drivers/net/virtio/virtio_pci.c +1 -0
+				vq->vq_avail_idx) << 16) | vq-
Quoted 1 line

vq_queue_index;

drivers/net/virtio/virtio_pci.c +9 -0
+	} else {
+		/*
+		 * Bit[0:15]: vq queue index
+		 * Bit[16:31]: avail index
+		 */
+		notify_data = ((uint32_t)vq->vq_avail_idx << 16) |
+				vq->vq_queue_index;
+	}
+	rte_write32(notify_data, vq->notify_addr);
 }
 
 const struct virtio_pci_ops modern_ops = {
drivers/net/virtio/virtio_pci.h +6 -1
index a38cb45ad..7433d2f08 100644
@@ -135,6 +135,12 @@ struct virtnet_ctl;
  */
 #define VIRTIO_F_ORDER_PLATFORM 36
 
+/*
+ * This feature indicates that the driver passes extra data (besides
+ * identifying the virtqueue) in its device notifications.
+ */
+#define VIRTIO_F_NOTIFICATION_DATA 38
+
 /* The Guest publishes the used index for which it expects an interrupt
  * at the end of the avail ring. Host should ignore the avail->flags field. */
 /* The Host publishes the avail index for which it expects a kick
--

2.17.1

#5 lore raw

Hi Gavin,

Quoted 21 lines

-----Original Message-----
From: Gavin Hu [mailto:[email protected]]
Sent: Wednesday, December 18, 2019 5:52 PM
To: Jiang, Cheng1 <[email protected]>; [email protected]; Bie, Tiwei <[email protected]>; Wang, Zhihong <[email protected]>; Liu, Yong <[email protected]>
Cc: [email protected]; nd <[email protected]>
Subject: RE: [dpdk-dev] [PATCH v2] net/virtio: packed ring notification data feature support

Hi Jiang,

Quoted 9 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of Cheng Jiang
Sent: Wednesday, December 18, 2019 4:17 PM
To: [email protected]; [email protected]; [email protected]; [email protected]
Cc: [email protected]; Cheng Jiang <[email protected]>
Subject: [dpdk-dev] [PATCH v2] net/virtio: packed ring notification data feature support

Quoted 5 lines
Quoted 2 lines

This patch supports the feature that the driver passes extra data (besides identifying the virtqueue) in its device notifications.

Can the commit log be more specific about the extra data? Something like "expand the notification to include the avail index and avail wrap counter, if any"?

It makes more sense. I will add more specific commit log in the next version. Thank you.

Quoted 56 lines
Quoted 56 lines

---

v2:
* Removed rte_unused attribute in *hw.
* Added some comments on notify_data.

 drivers/net/virtio/virtio_ethdev.h |  3 ++-
 drivers/net/virtio/virtio_pci.c    | 27 +++++++++++++++++++++++++--
 drivers/net/virtio/virtio_pci.h    |  6 ++++++
 3 files changed, 33 insertions(+), 3 deletions(-)
drivers/net/virtio/virtio_ethdev.h +2 -1
index a10111758..cd8947656 100644
@@ -36,7 +36,8 @@
 	 1ULL << VIRTIO_F_IN_ORDER        |	\
 	 1ULL << VIRTIO_F_RING_PACKED	  |	\
 	 1ULL << VIRTIO_F_IOMMU_PLATFORM  |	\
-	 1ULL << VIRTIO_F_ORDER_PLATFORM)
+	 1ULL << VIRTIO_F_ORDER_PLATFORM  |	\
+	 1ULL << VIRTIO_F_NOTIFICATION_DATA)
 
 #define VIRTIO_PMD_SUPPORTED_GUEST_FEATURES	\
 	(VIRTIO_PMD_DEFAULT_GUEST_FEATURES |	\
(quoted diff) +0 -0

b/drivers/net/virtio/virtio_pci.c index 4468e89cb..8b4e001a1 100644

drivers/net/virtio/virtio_pci.c +0 -1
@@ -416,9 +416,32 @@ modern_del_queue(struct virtio_hw *hw, struct
 virtqueue *vq)  }
 
 static void
-modern_notify_queue(struct virtio_hw *hw __rte_unused, struct

virtqueue
*vq)

drivers/net/virtio/virtio_pci.c +15 -1
+modern_notify_queue(struct virtio_hw *hw, struct virtqueue *vq)
 {
-	rte_write16(vq->vq_queue_index, vq->notify_addr);
+	uint32_t notify_data;
+
+	if (!vtpci_with_feature(hw, VIRTIO_F_NOTIFICATION_DATA)) {
+		rte_write16(vq->vq_queue_index, vq->notify_addr);
+		return;
+	}
+
+	if (vtpci_with_feature(hw, VIRTIO_F_RING_PACKED)) {
+		/*
+		 * Bit[0:15]: vq queue index
+		 * Bit[16:30]: avail index
+		 * Bit[31]: avail wrap counter
+		 */
+		notify_data = ((((uint32_t)vq-
Quoted 3 lines
Quoted 1 line
Quoted 1 line

vq_packed.used_wrap_counter << 15) |

Why not do ' used_wrap_counter << 31' to be more straightforward and matches the above comment?

Sure, you're right. I'll modify the patch in the next version.

Thanks again.
Cheng

Quoted 35 lines
Quoted 35 lines
drivers/net/virtio/virtio_pci.c +1 -0
+				vq->vq_avail_idx) << 16) | vq-
Quoted 1 line

vq_queue_index;

drivers/net/virtio/virtio_pci.c +9 -0
+	} else {
+		/*
+		 * Bit[0:15]: vq queue index
+		 * Bit[16:31]: avail index
+		 */
+		notify_data = ((uint32_t)vq->vq_avail_idx << 16) |
+				vq->vq_queue_index;
+	}
+	rte_write32(notify_data, vq->notify_addr);
 }
 
 const struct virtio_pci_ops modern_ops = { diff --git

a/drivers/net/virtio/virtio_pci.h b/drivers/net/virtio/virtio_pci.h index a38cb45ad..7433d2f08 100644

drivers/net/virtio/virtio_pci.h +6 -0
@@ -135,6 +135,12 @@ struct virtnet_ctl;
  */
 #define VIRTIO_F_ORDER_PLATFORM 36
 
+/*
+ * This feature indicates that the driver passes extra data (besides
+ * identifying the virtqueue) in its device notifications.
+ */
+#define VIRTIO_F_NOTIFICATION_DATA 38
+
 /* The Guest publishes the used index for which it expects an interrupt
  * at the end of the avail ring. Host should ignore the avail->flags

field. */
/* The Host publishes the avail index for which it expects a kick
--
2.17.1

#6 lore raw

PATCH v3 1/1 net/virtio: packed ring notification data feature support

In reply to Cheng Jiang

This patch supports the feature that the driver passes extra data (besides identifying the virtqueue) in its device notifications, expanding the notifications to include the avail index and avail wrap counter.

---

v3:
* Modified the commit log to make it more detailed.
* Modified the shift mode of notify_data to make it more intuitive.

v2:
* Removed rte_unused attribute in *hw.
* Added some comments on notify_data.

 drivers/net/virtio/virtio_ethdev.h |  3 ++-
 drivers/net/virtio/virtio_pci.c    | 28 ++++++++++++++++++++++++++--
 drivers/net/virtio/virtio_pci.h    |  6 ++++++
 3 files changed, 34 insertions(+), 3 deletions(-)
drivers/net/virtio/virtio_ethdev.h +2 -1
index a10111758..cd8947656 100644
@@ -36,7 +36,8 @@
 	 1ULL << VIRTIO_F_IN_ORDER        |	\
 	 1ULL << VIRTIO_F_RING_PACKED	  |	\
 	 1ULL << VIRTIO_F_IOMMU_PLATFORM  |	\
-	 1ULL << VIRTIO_F_ORDER_PLATFORM)
+	 1ULL << VIRTIO_F_ORDER_PLATFORM  |	\
+	 1ULL << VIRTIO_F_NOTIFICATION_DATA)
 
 #define VIRTIO_PMD_SUPPORTED_GUEST_FEATURES	\
 	(VIRTIO_PMD_DEFAULT_GUEST_FEATURES |	\
drivers/net/virtio/virtio_pci.c +26 -2
index 4468e89cb..dedd6bdda 100644
@@ -416,9 +416,33 @@ modern_del_queue(struct virtio_hw *hw, struct virtqueue *vq)
 }
 
 static void
-modern_notify_queue(struct virtio_hw *hw __rte_unused, struct virtqueue *vq)
+modern_notify_queue(struct virtio_hw *hw, struct virtqueue *vq)
 {
-	rte_write16(vq->vq_queue_index, vq->notify_addr);
+	uint32_t notify_data;
+
+	if (!vtpci_with_feature(hw, VIRTIO_F_NOTIFICATION_DATA)) {
+		rte_write16(vq->vq_queue_index, vq->notify_addr);
+		return;
+	}
+
+	if (vtpci_with_feature(hw, VIRTIO_F_RING_PACKED)) {
+		/*
+		 * Bit[0:15]: vq queue index
+		 * Bit[16:30]: avail index
+		 * Bit[31]: avail wrap counter
+		 */
+		notify_data = ((uint32_t)vq->vq_packed.used_wrap_counter << 31) |
+				((uint32_t)vq->vq_avail_idx << 16) |
+				vq->vq_queue_index;
+	} else {
+		/*
+		 * Bit[0:15]: vq queue index
+		 * Bit[16:31]: avail index
+		 */
+		notify_data = ((uint32_t)vq->vq_avail_idx << 16) |
+				vq->vq_queue_index;
+	}
+	rte_write32(notify_data, vq->notify_addr);
 }
 
 const struct virtio_pci_ops modern_ops = {
drivers/net/virtio/virtio_pci.h +6 -0
index a38cb45ad..7433d2f08 100644
@@ -135,6 +135,12 @@ struct virtnet_ctl;
  */
 #define VIRTIO_F_ORDER_PLATFORM 36
 
+/*
+ * This feature indicates that the driver passes extra data (besides
+ * identifying the virtqueue) in its device notifications.
+ */
+#define VIRTIO_F_NOTIFICATION_DATA 38
+
 /* The Guest publishes the used index for which it expects an interrupt
  * at the end of the avail ring. Host should ignore the avail->flags field. */
 /* The Host publishes the avail index for which it expects a kick
Signature · 1 line
2.17.1
#8 lore raw

PATCH v4 1/1 net/virtio: packed ring notification data feature support

In reply to Cheng Jiang

This patch supports the feature that the driver passes extra data (besides identifying the virtqueue) in its device notifications, expanding the notifications to include the avail index and avail wrap counter.

---

v4:
* Replaced used_wrap_counter with avail_wrap_counter.

v3:
* Modified the commit log to make it more detailed.
* Modified the shift mode of notify_data to make it more intuitive.

v2:
* Removed rte_unused attribute in *hw.
* Added some comments on notify_data.

 drivers/net/virtio/virtio_ethdev.h |  3 ++-
 drivers/net/virtio/virtio_pci.c    | 29 +++++++++++++++++++++++++++--
 drivers/net/virtio/virtio_pci.h    |  6 ++++++
 3 files changed, 35 insertions(+), 3 deletions(-)
drivers/net/virtio/virtio_ethdev.h +2 -1
index a10111758..cd8947656 100644
@@ -36,7 +36,8 @@
 	 1ULL << VIRTIO_F_IN_ORDER        |	\
 	 1ULL << VIRTIO_F_RING_PACKED	  |	\
 	 1ULL << VIRTIO_F_IOMMU_PLATFORM  |	\
-	 1ULL << VIRTIO_F_ORDER_PLATFORM)
+	 1ULL << VIRTIO_F_ORDER_PLATFORM  |	\
+	 1ULL << VIRTIO_F_NOTIFICATION_DATA)
 
 #define VIRTIO_PMD_SUPPORTED_GUEST_FEATURES	\
 	(VIRTIO_PMD_DEFAULT_GUEST_FEATURES |	\
drivers/net/virtio/virtio_pci.c +27 -2
index 4468e89cb..29a354bf7 100644
@@ -416,9 +416,34 @@ modern_del_queue(struct virtio_hw *hw, struct virtqueue *vq)
 }
 
 static void
-modern_notify_queue(struct virtio_hw *hw __rte_unused, struct virtqueue *vq)
+modern_notify_queue(struct virtio_hw *hw, struct virtqueue *vq)
 {
-	rte_write16(vq->vq_queue_index, vq->notify_addr);
+	uint32_t notify_data;
+
+	if (!vtpci_with_feature(hw, VIRTIO_F_NOTIFICATION_DATA)) {
+		rte_write16(vq->vq_queue_index, vq->notify_addr);
+		return;
+	}
+
+	if (vtpci_with_feature(hw, VIRTIO_F_RING_PACKED)) {
+		/*
+		 * Bit[0:15]: vq queue index
+		 * Bit[16:30]: avail index
+		 * Bit[31]: avail wrap counter
+		 */
+		notify_data = ((uint32_t)(!!(vq->vq_packed.cached_flags &
+				VRING_PACKED_DESC_F_AVAIL)) << 31) |
+				((uint32_t)vq->vq_avail_idx << 16) |
+				vq->vq_queue_index;
+	} else {
+		/*
+		 * Bit[0:15]: vq queue index
+		 * Bit[16:31]: avail index
+		 */
+		notify_data = ((uint32_t)vq->vq_avail_idx << 16) |
+				vq->vq_queue_index;
+	}
+	rte_write32(notify_data, vq->notify_addr);
 }
 
 const struct virtio_pci_ops modern_ops = {
drivers/net/virtio/virtio_pci.h +6 -0
index a38cb45ad..7433d2f08 100644
@@ -135,6 +135,12 @@ struct virtnet_ctl;
  */
 #define VIRTIO_F_ORDER_PLATFORM 36
 
+/*
+ * This feature indicates that the driver passes extra data (besides
+ * identifying the virtqueue) in its device notifications.
+ */
+#define VIRTIO_F_NOTIFICATION_DATA 38
+
 /* The Guest publishes the used index for which it expects an interrupt
  * at the end of the avail ring. Host should ignore the avail->flags field. */
 /* The Host publishes the avail index for which it expects a kick
Signature · 1 line
2.17.1
Reviewed-by on v4 1/1
#9 lore raw
Quoted 15 lines · Cheng Jiang

This patch supports the feature that the driver passes extra data (besides identifying the virtqueue) in its device notifications, expanding the notifications to include the avail index and avail wrap counter.

---

v4:
* Replaced used_wrap_counter with avail_wrap_counter.

v3:
* Modified the commit log to make it more detailed.
* Modified the shift mode of notify_data to make it more intuitive.

Quoted 9 lines

v2:
* Removed rte_unused attribute in *hw.
* Added some comments on notify_data.

 drivers/net/virtio/virtio_ethdev.h |  3 ++-
 drivers/net/virtio/virtio_pci.c    | 29 +++++++++++++++++++++++++++--
 drivers/net/virtio/virtio_pci.h    |  6 ++++++
 3 files changed, 35 insertions(+), 3 deletions(-)

Thanks,
Maxime

#10 lore raw
In reply to Cheng Jiang
Quoted 15 lines · Cheng Jiang

This patch supports the feature that the driver passes extra data (besides identifying the virtqueue) in its device notifications, expanding the notifications to include the avail index and avail wrap counter.

---

v4:
* Replaced used_wrap_counter with avail_wrap_counter.

v3:
* Modified the commit log to make it more detailed.
* Modified the shift mode of notify_data to make it more intuitive.

Quoted 8 lines

v2:
* Removed rte_unused attribute in *hw.
* Added some comments on notify_data.

 drivers/net/virtio/virtio_ethdev.h |  3 ++-
 drivers/net/virtio/virtio_pci.c    | 29 +++++++++++++++++++++++++++--
 drivers/net/virtio/virtio_pci.h    |  6 ++++++
 3 files changed, 35 insertions(+), 3 deletions(-)

Applied to dpdk-next-virtio/master

Thanks,
Maxime

#11 lore raw
In reply to Cheng Jiang
Quoted 29 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of Cheng Jiang
Sent: Wednesday, December 04, 2019 11:03 PM
To: [email protected]
Cc: [email protected]; Bie, Tiwei <[email protected]>; Wang, Zhihong <[email protected]>; Jiang, Cheng1 <[email protected]>
Subject: [dpdk-dev] [DPDK] net/virtio: packed ring notification data feature support

This patch supports the feature that the driver passes extra data (besides identifying the virtqueue) in its device notifications.

---
 drivers/net/virtio/virtio_ethdev.h |  3 ++-
 drivers/net/virtio/virtio_pci.c    | 15 ++++++++++++++-
 drivers/net/virtio/virtio_pci.h    |  6 ++++++
 3 files changed, 22 insertions(+), 2 deletions(-)
drivers/net/virtio/virtio_ethdev.h +2 -0
index a10111758..cd8947656 100644
+	if (vtpci_with_feature(hw, VIRTIO_F_RING_PACKED))
+		notify_data = ((((uint32_t)vq->vq_packed.used_wrap_counter <<

15) |

drivers/net/virtio/virtio_ethdev.h

Quoted 4 lines
drivers/net/virtio/virtio_ethdev.h +4 -0
+				vq->vq_avail_idx) << 16) | vq->vq_queue_index;
+	else
+		notify_data = ((uint32_t)vq->vq_avail_idx << 16) |
+				vq->vq_queue_index;

Hi Cheng,
According to virtio1.1 spec, wrap counter should refer to next available descriptor. So used_wrap_counter should be replaced with avail_wrap_counter. Sorry for late noticing.

Thanks,
Marvin

Quoted 3 lines
drivers/net/virtio/virtio_ethdev.h +1 -0
+	rte_write32(notify_data, vq->notify_addr);
 }
#12 lore raw

Hi Marvin,

Quoted 53 lines

-----Original Message-----
From: Liu, Yong
Sent: Thursday, January 9, 2020 3:29 PM
To: Jiang, Cheng1 <[email protected]>; [email protected]
Cc: [email protected]; Bie, Tiwei <[email protected]>; Wang, Zhihong <[email protected]>; Jiang, Cheng1 <[email protected]>
Subject: RE: [dpdk-dev] [DPDK] net/virtio: packed ring notification data feature support

Quoted 31 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of Cheng Jiang
Sent: Wednesday, December 04, 2019 11:03 PM
To: [email protected]
Cc: [email protected]; Bie, Tiwei <[email protected]>; Wang, Zhihong <[email protected]>; Jiang, Cheng1 <[email protected]>
Subject: [dpdk-dev] [DPDK] net/virtio: packed ring notification data feature support

This patch supports the feature that the driver passes extra data (besides identifying the virtqueue) in its device notifications.

---
 drivers/net/virtio/virtio_ethdev.h |  3 ++-
 drivers/net/virtio/virtio_pci.c    | 15 ++++++++++++++-
 drivers/net/virtio/virtio_pci.h    |  6 ++++++
 3 files changed, 22 insertions(+), 2 deletions(-)
drivers/net/virtio/virtio_ethdev.h +2 -0
index a10111758..cd8947656 100644
+	if (vtpci_with_feature(hw, VIRTIO_F_RING_PACKED))
+		notify_data = ((((uint32_t)vq-

vq_packed.used_wrap_counter <<
15) |

drivers/net/virtio/virtio_ethdev.h +1 -0
+				vq->vq_avail_idx) << 16) | vq-

vq_queue_index;

drivers/net/virtio/virtio_ethdev.h

Quoted 3 lines
drivers/net/virtio/virtio_ethdev.h +3 -0
+	else
+		notify_data = ((uint32_t)vq->vq_avail_idx << 16) |
+				vq->vq_queue_index;

Hi Cheng,
According to virtio1.1 spec, wrap counter should refer to next available descriptor.
So used_wrap_counter should be replaced with avail_wrap_counter. Sorry for late noticing.

Quoted 3 lines

Thanks,
Marvin

Sure, I'm going to modify it in the next version.
Thanks very much.

Cheng

Quoted 3 lines
Quoted 3 lines
drivers/net/virtio/virtio_ethdev.h +1 -0
+	rte_write32(notify_data, vq->notify_addr);
 }