linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jason Wang <jasowang@redhat.com>
To: mst@redhat.com, virtualization@lists.linux-foundation.org,
	linux-kernel@vger.kernel.org, netdev@vger.kernel.org
Cc: rusty@rustcorp.com.au, Jason Wang <jasowang@redhat.com>
Subject: [RFC V7 PATCH 1/7] virito-pci: add coalescing parameters setting
Date: Mon, 25 May 2015 01:23:58 -0400	[thread overview]
Message-ID: <1432531444-50193-2-git-send-email-jasowang@redhat.com> (raw)
In-Reply-To: <1432531444-50193-1-git-send-email-jasowang@redhat.com>

This patch introduces a transport specific methods to set or get the
coalescing parameters and implement the pci methods.

Signed-off-by: Jason Wang <jasowang@redhat.com>
---
 drivers/virtio/virtio_pci_modern.c | 15 +++++++++++++++
 include/linux/virtio_config.h      |  8 ++++++++
 include/uapi/linux/virtio_pci.h    |  4 ++++
 3 files changed, 27 insertions(+)

diff --git a/drivers/virtio/virtio_pci_modern.c b/drivers/virtio/virtio_pci_modern.c
index e88e099..ce801ae 100644
--- a/drivers/virtio/virtio_pci_modern.c
+++ b/drivers/virtio/virtio_pci_modern.c
@@ -266,6 +266,16 @@ static void vp_set_status(struct virtio_device *vdev, u8 status)
 	vp_iowrite8(status, &vp_dev->common->device_status);
 }
 
+static void vp_set_coalesce(struct virtio_device *vdev, int n,
+			    u32 coalesce_count, u32 coalesce_us)
+{
+	struct virtio_pci_device *vp_dev = to_vp_device(vdev);
+
+	iowrite16(n, &vp_dev->common->queue_select);
+	iowrite32(coalesce_count, &vp_dev->common->queue_coalesce_count);
+	iowrite32(coalesce_us, &vp_dev->common->queue_coalesce_us);
+}
+
 static void vp_reset(struct virtio_device *vdev)
 {
 	struct virtio_pci_device *vp_dev = to_vp_device(vdev);
@@ -481,6 +491,7 @@ static const struct virtio_config_ops virtio_pci_config_ops = {
 	.generation	= vp_generation,
 	.get_status	= vp_get_status,
 	.set_status	= vp_set_status,
+	.set_coalesce   = vp_set_coalesce,
 	.reset		= vp_reset,
 	.find_vqs	= vp_modern_find_vqs,
 	.del_vqs	= vp_del_vqs,
@@ -588,6 +599,10 @@ static inline void check_offsets(void)
 		     offsetof(struct virtio_pci_common_cfg, queue_used_lo));
 	BUILD_BUG_ON(VIRTIO_PCI_COMMON_Q_USEDHI !=
 		     offsetof(struct virtio_pci_common_cfg, queue_used_hi));
+	BUILD_BUG_ON(VIRTIO_PCI_COMMON_Q_COALESCE_C !=
+		offsetof(struct virtio_pci_common_cfg, queue_coalesce_count));
+	BUILD_BUG_ON(VIRTIO_PCI_COMMON_Q_COALESCE_U !=
+		offsetof(struct virtio_pci_common_cfg, queue_coalesce_us));
 }
 
 /* the PCI probing function */
diff --git a/include/linux/virtio_config.h b/include/linux/virtio_config.h
index 1e306f7..d100c32 100644
--- a/include/linux/virtio_config.h
+++ b/include/linux/virtio_config.h
@@ -28,6 +28,12 @@
  * @set_status: write the status byte
  *	vdev: the virtio_device
  *	status: the new status byte
+ * @set_coalesce: set coalescing parameters
+ *	vdev: the virtio_device
+ *	n: the queue index
+ *	coalesce_count: maximum coalesced count before issuing interrupt
+ *      coalesce_count: maximum micro seconds to wait if there's a
+ *      pending buffer
  * @reset: reset the device
  *	vdev: the virtio device
  *	After this, status and feature negotiation must be done again
@@ -66,6 +72,8 @@ struct virtio_config_ops {
 	u32 (*generation)(struct virtio_device *vdev);
 	u8 (*get_status)(struct virtio_device *vdev);
 	void (*set_status)(struct virtio_device *vdev, u8 status);
+	void (*set_coalesce)(struct virtio_device *vdev, int n,
+			     u32 coalesce_count, u32 coalesce_us);
 	void (*reset)(struct virtio_device *vdev);
 	int (*find_vqs)(struct virtio_device *, unsigned nvqs,
 			struct virtqueue *vqs[],
diff --git a/include/uapi/linux/virtio_pci.h b/include/uapi/linux/virtio_pci.h
index 7530146..3396026 100644
--- a/include/uapi/linux/virtio_pci.h
+++ b/include/uapi/linux/virtio_pci.h
@@ -155,6 +155,8 @@ struct virtio_pci_common_cfg {
 	__le32 queue_avail_hi;		/* read-write */
 	__le32 queue_used_lo;		/* read-write */
 	__le32 queue_used_hi;		/* read-write */
+	__le32 queue_coalesce_count;    /* read-write */
+	__le32 queue_coalesce_us;       /* read-write */
 };
 
 /* Macro versions of offsets for the Old Timers! */
@@ -187,6 +189,8 @@ struct virtio_pci_common_cfg {
 #define VIRTIO_PCI_COMMON_Q_AVAILHI	44
 #define VIRTIO_PCI_COMMON_Q_USEDLO	48
 #define VIRTIO_PCI_COMMON_Q_USEDHI	52
+#define VIRTIO_PCI_COMMON_Q_COALESCE_C  56
+#define VIRTIO_PCI_COMMON_Q_COALESCE_U  60
 
 #endif /* VIRTIO_PCI_NO_MODERN */
 
-- 
1.8.3.1


  reply	other threads:[~2015-05-25  5:26 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-25  5:23 [RFC V7 PATCH 0/7] enable tx interrupts for virtio-net Jason Wang
2015-05-25  5:23 ` Jason Wang [this message]
2015-05-25  5:23 ` [RFC V7 PATCH 2/7] virtio_ring: try to disable event index callbacks in virtqueue_disable_cb() Jason Wang
2015-05-25  5:24 ` [RFC V7 PATCH 3/7] virtio-net: optimize free_old_xmit_skbs stats Jason Wang
2015-05-25  5:24 ` [RFC V7 PATCH 4/7] virtio-net: add basic interrupt coalescing support Jason Wang
2015-05-25  5:24 ` [RFC V7 PATCH 5/7] virtio_net: enable tx interrupt Jason Wang
2015-05-25  5:24 ` [RFC V7 PATCH 6/7] vhost: interrupt coalescing support Jason Wang
2015-05-25  5:24 ` [RFC V7 PATCH 7/7] vhost_net: add " Jason Wang
2015-05-26 18:02   ` Stephen Hemminger
2015-05-27  8:30     ` Jason Wang

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=1432531444-50193-2-git-send-email-jasowang@redhat.com \
    --to=jasowang@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mst@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=rusty@rustcorp.com.au \
    --cc=virtualization@lists.linux-foundation.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).