From: Jens Freimann <jfreimann@redhat.com>
To: dev@dpdk.org
Cc: tiwei.bie@intel.com, yliu@fridaylinux.org,
maxime.coquelin@redhat.com, mst@redhat.com
Subject: [dpdk-dev] [PATCH v3 20/21] net/virtio: add support for event suppression
Date: Thu, 5 Apr 2018 12:10:30 +0200 [thread overview]
Message-ID: <20180405101031.26468-21-jfreimann@redhat.com> (raw)
In-Reply-To: <20180405101031.26468-1-jfreimann@redhat.com>
Signed-off-by: Jens Freimann <jfreimann@redhat.com>
---
drivers/net/virtio/virtio_ethdev.c | 2 +-
drivers/net/virtio/virtio_ethdev.h | 2 +-
drivers/net/virtio/virtio_rxtx.c | 15 +++++++-
drivers/net/virtio/virtqueue.h | 73 ++++++++++++++++++++++++++++++++++++--
4 files changed, 86 insertions(+), 6 deletions(-)
diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c
index a3c3376d7..65a6a9d89 100644
--- a/drivers/net/virtio/virtio_ethdev.c
+++ b/drivers/net/virtio/virtio_ethdev.c
@@ -727,7 +727,7 @@ virtio_dev_rx_queue_intr_enable(struct rte_eth_dev *dev, uint16_t queue_id)
struct virtnet_rx *rxvq = dev->data->rx_queues[queue_id];
struct virtqueue *vq = rxvq->vq;
- virtqueue_enable_intr(vq);
+ virtqueue_enable_intr(vq, 0, 0);
return 0;
}
diff --git a/drivers/net/virtio/virtio_ethdev.h b/drivers/net/virtio/virtio_ethdev.h
index 3aeced4bb..19d3f2617 100644
--- a/drivers/net/virtio/virtio_ethdev.h
+++ b/drivers/net/virtio/virtio_ethdev.h
@@ -37,7 +37,7 @@
1u << VIRTIO_RING_F_INDIRECT_DESC | \
1ULL << VIRTIO_F_VERSION_1 | \
1ULL << VIRTIO_F_RING_PACKED | \
- 1ULL << VIRTIO_F_IOMMU_PLATFORM)
+ 1ULL << VIRTIO_RING_F_EVENT_IDX)
#define VIRTIO_PMD_SUPPORTED_GUEST_FEATURES \
(VIRTIO_PMD_DEFAULT_GUEST_FEATURES | \
diff --git a/drivers/net/virtio/virtio_rxtx.c b/drivers/net/virtio/virtio_rxtx.c
index a48ca6aaa..ed65434ce 100644
--- a/drivers/net/virtio/virtio_rxtx.c
+++ b/drivers/net/virtio/virtio_rxtx.c
@@ -127,6 +127,10 @@ virtio_xmit_pkts_packed(void *tx_queue, struct rte_mbuf **tx_pkts,
rte_smp_wmb();
_set_desc_avail(&desc[head_idx], wrap_counter);
+ if (unlikely(virtqueue_kick_prepare_packed(vq))) {
+ virtqueue_notify(vq);
+ PMD_RX_LOG(DEBUG, "Notified");
+ }
}
txvq->stats.packets += i;
@@ -998,6 +1002,10 @@ virtio_recv_pkts_packed(void *rx_queue, struct rte_mbuf **rx_pkts,
}
rxvq->stats.packets += nb_rx;
+ if (nb_rx > 0 && unlikely(virtqueue_kick_prepare_packed(vq))) {
+ virtqueue_notify(vq);
+ PMD_RX_LOG(DEBUG, "Notified");
+ }
vq->vq_used_cons_idx = used_idx;
@@ -1276,8 +1284,13 @@ virtio_recv_mergeable_pkts(void *rx_queue,
rxvq->stats.packets += nb_rx;
- if (vtpci_packed_queue(vq->hw))
+ if (vtpci_packed_queue(vq->hw)) {
+ if (unlikely(virtqueue_kick_prepare(vq))) {
+ virtqueue_notify(vq);
+ PMD_RX_LOG(DEBUG, "Notified");
+ }
return nb_rx;
+ }
/* Allocate new mbuf for the used descriptor */
error = ENOSPC;
diff --git a/drivers/net/virtio/virtqueue.h b/drivers/net/virtio/virtqueue.h
index 7196bd717..6fd3317d2 100644
--- a/drivers/net/virtio/virtqueue.h
+++ b/drivers/net/virtio/virtqueue.h
@@ -176,6 +176,8 @@ struct virtqueue {
uint16_t vq_free_cnt; /**< num of desc available */
uint16_t vq_avail_idx; /**< sync until needed */
uint16_t vq_free_thresh; /**< free threshold */
+ uint16_t vq_signalled_avail;
+ int vq_signalled_avail_valid;
void *vq_ring_virt_mem; /**< linear address of vring*/
unsigned int vq_ring_size;
@@ -273,16 +275,34 @@ vring_desc_init(struct vring_desc *dp, uint16_t n)
static inline void
virtqueue_disable_intr(struct virtqueue *vq)
{
- vq->vq_ring.avail->flags |= VRING_AVAIL_F_NO_INTERRUPT;
+ if (vtpci_packed_queue(vq->hw) && vtpci_with_feature(vq->hw,
+ VIRTIO_RING_F_EVENT_IDX))
+ vq->vq_ring.device_event->desc_event_flags = RING_EVENT_FLAGS_DISABLE;
+ else
+ vq->vq_ring.avail->flags |= VRING_AVAIL_F_NO_INTERRUPT;
}
/**
* Tell the backend to interrupt us.
*/
static inline void
-virtqueue_enable_intr(struct virtqueue *vq)
+virtqueue_enable_intr(struct virtqueue *vq, uint16_t off, uint16_t wrap_counter)
{
- vq->vq_ring.avail->flags &= (~VRING_AVAIL_F_NO_INTERRUPT);
+ uint16_t *flags = &vq->vq_ring.device_event->desc_event_flags;
+ uint16_t *event_off_wrap = &vq->vq_ring.device_event->desc_event_off_wrap;
+ if (vtpci_packed_queue(vq->hw)) {
+ *flags = 0;
+ *event_off_wrap = 0;
+ if (*event_off_wrap & RING_EVENT_FLAGS_DESC) {
+ *event_off_wrap = off | 0x7FFF;
+ *event_off_wrap |= wrap_counter << 15;
+ *flags |= RING_EVENT_FLAGS_DESC;
+ } else
+ *event_off_wrap = 0;
+ *flags |= RING_EVENT_FLAGS_ENABLE;
+ } else {
+ vq->vq_ring.avail->flags &= (~VRING_AVAIL_F_NO_INTERRUPT);
+ }
}
/**
@@ -342,12 +362,59 @@ vq_update_avail_ring(struct virtqueue *vq, uint16_t desc_idx)
vq->vq_avail_idx++;
}
+static int vhost_idx_diff(struct virtqueue *vq, uint16_t old, uint16_t new)
+{
+ if (new > old)
+ return new - old;
+ return (new + vq->vq_nentries - old);
+}
+
+static int vring_packed_need_event(struct virtqueue *vq,
+ uint16_t event_off, uint16_t new,
+ uint16_t old)
+{
+ return (uint16_t)(vhost_idx_diff(vq, new, event_off) - 1) <
+ (uint16_t)vhost_idx_diff(vq, new, old);
+}
+
+
static inline int
virtqueue_kick_prepare(struct virtqueue *vq)
{
return !(vq->vq_ring.used->flags & VRING_USED_F_NO_NOTIFY);
}
+static inline int
+virtqueue_kick_prepare_packed(struct virtqueue *vq)
+{
+ uint16_t notify_offset, flags, wrap;
+ uint16_t old, new;
+ int v;
+
+ if (vtpci_packed_queue(vq->hw)) {
+ flags = vq->vq_ring.device_event->desc_event_flags;
+ if (!(flags & RING_EVENT_FLAGS_DESC))
+ return flags & RING_EVENT_FLAGS_ENABLE;
+ virtio_rmb();
+ notify_offset = vq->vq_ring.device_event->desc_event_off_wrap;
+ wrap = notify_offset & 0x1;
+ notify_offset >>= 1;
+
+ old = vq->vq_signalled_avail;
+ v = vq->vq_signalled_avail_valid;
+ new = vq->vq_signalled_avail = vq->vq_avail_idx;
+ vq->vq_signalled_avail_valid = 1;
+
+ if (unlikely(!v))
+ return 0;
+
+ return (vring_packed_need_event(vq, new, old, notify_offset) &&
+ wrap == vq->vq_ring.avail_wrap_counter);
+ } else {
+ return !(vq->vq_ring.used->flags & VRING_USED_F_NO_NOTIFY);
+ }
+}
+
static inline void
virtqueue_notify(struct virtqueue *vq)
{
--
2.14.3
next prev parent reply other threads:[~2018-04-05 10:11 UTC|newest]
Thread overview: 65+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-05 10:10 [dpdk-dev] [PATCH v3 00/21] implement packed virtqueues Jens Freimann
2018-04-05 10:10 ` [dpdk-dev] [PATCH v3 01/21] net/virtio: by default disable " Jens Freimann
2018-04-05 13:42 ` Maxime Coquelin
2018-04-05 14:19 ` Jens Freimann
2018-04-05 10:10 ` [dpdk-dev] [PATCH v3 02/21] net/virtio: vring init for packed queues Jens Freimann
2018-04-05 14:15 ` Maxime Coquelin
2018-04-05 14:24 ` Jens Freimann
2018-04-05 14:22 ` Tiwei Bie
2018-04-05 15:16 ` Jens Freimann
2018-04-05 10:10 ` [dpdk-dev] [PATCH v3 03/21] net/virtio: add virtio 1.1 defines Jens Freimann
2018-04-05 14:16 ` Maxime Coquelin
2018-04-05 14:27 ` Tiwei Bie
2018-04-05 14:33 ` Jens Freimann
2018-04-05 10:10 ` [dpdk-dev] [PATCH v3 04/21] net/virtio: add packed virtqueue helpers Jens Freimann
2018-04-05 14:27 ` Maxime Coquelin
2018-04-05 14:34 ` Jens Freimann
2018-04-05 14:40 ` Tiwei Bie
2018-04-05 15:14 ` Jens Freimann
2018-04-05 10:10 ` [dpdk-dev] [PATCH v3 05/21] net/virtio: dump packed virtqueue data Jens Freimann
2018-04-05 14:29 ` Maxime Coquelin
2018-04-08 3:53 ` Tiwei Bie
2018-04-05 10:10 ` [dpdk-dev] [PATCH v3 06/21] net/virtio-user: add option to use packed queues Jens Freimann
2018-04-05 14:35 ` Maxime Coquelin
2018-04-05 10:10 ` [dpdk-dev] [PATCH v3 07/21] net/virtio: implement transmit path for " Jens Freimann
2018-04-06 7:56 ` Maxime Coquelin
2018-04-06 8:10 ` Jens Freimann
2018-04-08 4:51 ` Tiwei Bie
2018-04-09 6:20 ` Jens Freimann
2018-04-05 10:10 ` [dpdk-dev] [PATCH v3 08/21] net/virtio: implement receive " Jens Freimann
2018-04-06 7:51 ` Maxime Coquelin
2018-04-06 8:12 ` Jens Freimann
2018-04-05 10:10 ` [dpdk-dev] [PATCH v3 09/21] vhost: disable packed virtqueues by default Jens Freimann
2018-04-05 10:10 ` [dpdk-dev] [PATCH v3 10/21] vhost: turn of indirect descriptors for packed virtqueues Jens Freimann
2018-04-06 8:12 ` Maxime Coquelin
2018-04-05 10:10 ` [dpdk-dev] [PATCH v3 11/21] vhost: add virtio 1.1 defines Jens Freimann
2018-04-06 8:15 ` Maxime Coquelin
2018-04-05 10:10 ` [dpdk-dev] [PATCH v3 12/21] vhost: vring address setup for packed queues Jens Freimann
2018-04-06 8:19 ` Maxime Coquelin
2018-04-06 8:23 ` Jens Freimann
2018-04-05 10:10 ` [dpdk-dev] [PATCH v3 13/21] vhost: add helpers for packed virtqueues Jens Freimann
2018-04-06 9:20 ` Maxime Coquelin
2018-04-06 9:21 ` Jens Freimann
2018-04-05 10:10 ` [dpdk-dev] [PATCH v3 14/21] vhost: dequeue for packed queues Jens Freimann
2018-04-06 9:30 ` Maxime Coquelin
2018-04-06 10:07 ` Jens Freimann
2018-04-05 10:10 ` [dpdk-dev] [PATCH v3 15/21] vhost: packed queue enqueue path Jens Freimann
2018-04-06 9:36 ` Maxime Coquelin
2018-04-06 12:17 ` Jens Freimann
2018-04-05 10:10 ` [dpdk-dev] [PATCH v3 16/21] vhost: enable packed virtqueues Jens Freimann
2018-04-05 10:10 ` [dpdk-dev] [PATCH v3 17/21] net/virtio: disable ctrl virtqueue for packed rings Jens Freimann
2018-04-06 9:38 ` Maxime Coquelin
2018-04-06 9:43 ` Jens Freimann
2018-04-06 9:48 ` Maxime Coquelin
2018-04-05 10:10 ` [dpdk-dev] [PATCH v3 18/21] net/virtio: add support for mergeable buffers with packed virtqueues Jens Freimann
2018-04-06 10:05 ` Maxime Coquelin
2018-04-08 6:02 ` Tiwei Bie
2018-04-05 10:10 ` [dpdk-dev] [PATCH v3 19/21] vhost: support mergeable rx buffers with packed queues Jens Freimann
2018-04-06 13:04 ` Maxime Coquelin
2018-04-06 14:07 ` Jens Freimann
2018-04-05 10:10 ` Jens Freimann [this message]
2018-04-06 13:50 ` [dpdk-dev] [PATCH v3 20/21] net/virtio: add support for event suppression Maxime Coquelin
2018-04-06 14:09 ` Jens Freimann
2018-04-08 6:07 ` Tiwei Bie
2018-04-09 6:09 ` Jens Freimann
2018-04-05 10:10 ` [dpdk-dev] [PATCH v3 21/21] vhost: add event suppression for packed queues Jens Freimann
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=20180405101031.26468-21-jfreimann@redhat.com \
--to=jfreimann@redhat.com \
--cc=dev@dpdk.org \
--cc=maxime.coquelin@redhat.com \
--cc=mst@redhat.com \
--cc=tiwei.bie@intel.com \
--cc=yliu@fridaylinux.org \
/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
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).