DPDK patches and discussions
 help / color / mirror / Atom feed
From: Cheng Jiang <Cheng1.jiang@intel.com>
To: maxime.coquelin@redhat.com, tiwei.bie@intel.com,
	zhihong.wang@intel.com, yong.liu@intel.com
Cc: dev@dpdk.org, Cheng Jiang <Cheng1.jiang@intel.com>
Subject: [dpdk-dev] [PATCH v2] net/virtio: packed ring notification data feature support
Date: Wed, 18 Dec 2019 08:17:11 +0000
Message-ID: <20191218081711.9055-1-Cheng1.jiang@intel.com> (raw)
In-Reply-To: <20191204150312.32697-1-Cheng1.jiang@intel.com>

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

Signed-off-by: Cheng Jiang <Cheng1.jiang@intel.com>
---

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(-)

diff --git a/drivers/net/virtio/virtio_ethdev.h b/drivers/net/virtio/virtio_ethdev.h
index a10111758..cd8947656 100644
--- a/drivers/net/virtio/virtio_ethdev.h
+++ b/drivers/net/virtio/virtio_ethdev.h
@@ -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 |	\
diff --git a/drivers/net/virtio/virtio_pci.c b/drivers/net/virtio/virtio_pci.c
index 4468e89cb..8b4e001a1 100644
--- a/drivers/net/virtio/virtio_pci.c
+++ b/drivers/net/virtio/virtio_pci.c
@@ -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 = {
diff --git a/drivers/net/virtio/virtio_pci.h b/drivers/net/virtio/virtio_pci.h
index a38cb45ad..7433d2f08 100644
--- a/drivers/net/virtio/virtio_pci.h
+++ b/drivers/net/virtio/virtio_pci.h
@@ -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


  parent reply	other threads:[~2019-12-18  8:19 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-04 15:03 [dpdk-dev] [DPDK] " Cheng Jiang
2019-12-09  1:59 ` Liu, Yong
2019-12-12  9:08   ` Jiang, Cheng1
2019-12-18  8:17 ` Cheng Jiang [this message]
2019-12-18  9:51   ` [dpdk-dev] [PATCH v2] " Gavin Hu
2019-12-23  2:34     ` Jiang, Cheng1
2019-12-23  5:15   ` [dpdk-dev] [PATCH v3] " Cheng Jiang
2019-12-23  6:49     ` Gavin Hu
2020-01-13  3:31     ` [dpdk-dev] [PATCH v4] " Cheng Jiang
2020-01-13 15:02       ` Maxime Coquelin
2020-01-15 11:18       ` Maxime Coquelin
2020-01-09  7:29 ` [dpdk-dev] [DPDK] " Liu, Yong
2020-01-13  2:57   ` Jiang, Cheng1

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191218081711.9055-1-Cheng1.jiang@intel.com \
    --to=cheng1.jiang@intel.com \
    --cc=dev@dpdk.org \
    --cc=maxime.coquelin@redhat.com \
    --cc=tiwei.bie@intel.com \
    --cc=yong.liu@intel.com \
    --cc=zhihong.wang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

DPDK patches and discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.dpdk.org/dev/0 dev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dev dev/ https://inbox.dpdk.org/dev \
		dev@dpdk.org
	public-inbox-index dev

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.dev


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git