From: "Michael S. Tsirkin" <mst@redhat.com>
To: linux-kernel@vger.kernel.org
Cc: Rusty Russell <rusty@rustcorp.com.au>,
Carsten Otte <cotte@de.ibm.com>,
Christian Borntraeger <borntraeger@de.ibm.com>,
linux390@de.ibm.com, Martin Schwidefsky <schwidefsky@de.ibm.com>,
Heiko Carstens <heiko.carstens@de.ibm.com>,
Shirley Ma <xma@us.ibm.com>,
lguest@lists.ozlabs.org, linux-kernel@vger.kernel.org,
virtualization@lists.linux-foundation.org,
netdev@vger.kernel.org, linux-s390@vger.kernel.org,
kvm@vger.kernel.org, Krishna Kumar <krkumar2@in.ibm.com>,
Tom Lendacky <tahm@linux.vnet.ibm.com>,
steved@us.ibm.com, habanero@linux.vnet.ibm.com
Subject: [PATCH 01/18] virtio: 64 bit features
Date: Wed, 4 May 2011 23:50:29 +0300 [thread overview]
Message-ID: <45e900e472b72cc17c40e4dcc1587b1b0ca8d6c5.1304541919.git.mst@redhat.com> (raw)
In-Reply-To: <cover.1304541918.git.mst@redhat.com>
Extend features to 64 bit so we can use more
transport bits.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
drivers/lguest/lguest_device.c | 8 ++++----
drivers/s390/kvm/kvm_virtio.c | 8 ++++----
drivers/virtio/virtio.c | 8 ++++----
drivers/virtio/virtio_pci.c | 34 ++++++++++++++++++++++++++++------
drivers/virtio/virtio_ring.c | 2 ++
include/linux/virtio.h | 2 +-
include/linux/virtio_config.h | 15 +++++++++------
include/linux/virtio_pci.h | 9 ++++++++-
8 files changed, 60 insertions(+), 26 deletions(-)
diff --git a/drivers/lguest/lguest_device.c b/drivers/lguest/lguest_device.c
index 69c84a1..d2d6953 100644
--- a/drivers/lguest/lguest_device.c
+++ b/drivers/lguest/lguest_device.c
@@ -93,17 +93,17 @@ static unsigned desc_size(const struct lguest_device_desc *desc)
}
/* This gets the device's feature bits. */
-static u32 lg_get_features(struct virtio_device *vdev)
+static u64 lg_get_features(struct virtio_device *vdev)
{
unsigned int i;
- u32 features = 0;
+ u64 features = 0;
struct lguest_device_desc *desc = to_lgdev(vdev)->desc;
u8 *in_features = lg_features(desc);
/* We do this the slow but generic way. */
- for (i = 0; i < min(desc->feature_len * 8, 32); i++)
+ for (i = 0; i < min(desc->feature_len * 8, 64); i++)
if (in_features[i / 8] & (1 << (i % 8)))
- features |= (1 << i);
+ features |= (1ull << i);
return features;
}
diff --git a/drivers/s390/kvm/kvm_virtio.c b/drivers/s390/kvm/kvm_virtio.c
index 414427d..c56293c 100644
--- a/drivers/s390/kvm/kvm_virtio.c
+++ b/drivers/s390/kvm/kvm_virtio.c
@@ -79,16 +79,16 @@ static unsigned desc_size(const struct kvm_device_desc *desc)
}
/* This gets the device's feature bits. */
-static u32 kvm_get_features(struct virtio_device *vdev)
+static u64 kvm_get_features(struct virtio_device *vdev)
{
unsigned int i;
- u32 features = 0;
+ u64 features = 0;
struct kvm_device_desc *desc = to_kvmdev(vdev)->desc;
u8 *in_features = kvm_vq_features(desc);
- for (i = 0; i < min(desc->feature_len * 8, 32); i++)
+ for (i = 0; i < min(desc->feature_len * 8, 64); i++)
if (in_features[i / 8] & (1 << (i % 8)))
- features |= (1 << i);
+ features |= (1ull << i);
return features;
}
diff --git a/drivers/virtio/virtio.c b/drivers/virtio/virtio.c
index efb35aa..52b24d7 100644
--- a/drivers/virtio/virtio.c
+++ b/drivers/virtio/virtio.c
@@ -112,7 +112,7 @@ static int virtio_dev_probe(struct device *_d)
struct virtio_device *dev = container_of(_d,struct virtio_device,dev);
struct virtio_driver *drv = container_of(dev->dev.driver,
struct virtio_driver, driver);
- u32 device_features;
+ u64 device_features;
/* We have a driver! */
add_status(dev, VIRTIO_CONFIG_S_DRIVER);
@@ -124,14 +124,14 @@ static int virtio_dev_probe(struct device *_d)
memset(dev->features, 0, sizeof(dev->features));
for (i = 0; i < drv->feature_table_size; i++) {
unsigned int f = drv->feature_table[i];
- BUG_ON(f >= 32);
- if (device_features & (1 << f))
+ BUG_ON(f >= 64);
+ if (device_features & (1ull << f))
set_bit(f, dev->features);
}
/* Transport features always preserved to pass to finalize_features. */
for (i = VIRTIO_TRANSPORT_F_START; i < VIRTIO_TRANSPORT_F_END; i++)
- if (device_features & (1 << i))
+ if (device_features & (1ull << i))
set_bit(i, dev->features);
dev->config->finalize_features(dev);
diff --git a/drivers/virtio/virtio_pci.c b/drivers/virtio/virtio_pci.c
index 4fb5b2b..04b216f 100644
--- a/drivers/virtio/virtio_pci.c
+++ b/drivers/virtio/virtio_pci.c
@@ -44,6 +44,8 @@ struct virtio_pci_device
spinlock_t lock;
struct list_head virtqueues;
+ /* 64 bit features */
+ int features_hi;
/* MSI-X support */
int msix_enabled;
int intx_enabled;
@@ -103,26 +105,46 @@ static struct virtio_pci_device *to_vp_device(struct virtio_device *vdev)
}
/* virtio config->get_features() implementation */
-static u32 vp_get_features(struct virtio_device *vdev)
+static u64 vp_get_features(struct virtio_device *vdev)
{
struct virtio_pci_device *vp_dev = to_vp_device(vdev);
+ u32 flo, fhi;
- /* When someone needs more than 32 feature bits, we'll need to
+ /* When someone needs more than 32 feature bits, we need to
* steal a bit to indicate that the rest are somewhere else. */
- return ioread32(vp_dev->ioaddr + VIRTIO_PCI_HOST_FEATURES);
+ flo = ioread32(vp_dev->ioaddr + VIRTIO_PCI_HOST_FEATURES);
+ if (flo & (0x1 << VIRTIO_F_FEATURES_HI)) {
+ vp_dev->features_hi = 1;
+ iowrite32(0x1 << VIRTIO_F_FEATURES_HI,
+ vp_dev->ioaddr + VIRTIO_PCI_GUEST_FEATURES);
+ fhi = ioread32(vp_dev->ioaddr + VIRTIO_PCI_HOST_FEATURES_HI);
+ } else {
+ vp_dev->features_hi = 0;
+ fhi = 0;
+ }
+ return (((u64)fhi) << 32) | flo;
}
/* virtio config->finalize_features() implementation */
static void vp_finalize_features(struct virtio_device *vdev)
{
struct virtio_pci_device *vp_dev = to_vp_device(vdev);
+ u32 flo, fhi;
/* Give virtio_ring a chance to accept features. */
vring_transport_features(vdev);
- /* We only support 32 feature bits. */
- BUILD_BUG_ON(ARRAY_SIZE(vdev->features) != 1);
- iowrite32(vdev->features[0], vp_dev->ioaddr+VIRTIO_PCI_GUEST_FEATURES);
+ /* We only support 64 feature bits. */
+ BUILD_BUG_ON(ARRAY_SIZE(vdev->features) != 64 / BITS_PER_LONG);
+ flo = vdev->features[0];
+ fhi = vdev->features[64 / BITS_PER_LONG - 1] >> (BITS_PER_LONG - 32);
+ iowrite32(flo, vp_dev->ioaddr + VIRTIO_PCI_GUEST_FEATURES);
+ if (flo & (0x1 << VIRTIO_F_FEATURES_HI)) {
+ vp_dev->features_hi = 1;
+ iowrite32(fhi, vp_dev->ioaddr + VIRTIO_PCI_GUEST_FEATURES_HI);
+ } else {
+ vp_dev->features_hi = 0;
+ }
}
/* virtio config->get() implementation */
diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
index cc2f73e..059e02d 100644
--- a/drivers/virtio/virtio_ring.c
+++ b/drivers/virtio/virtio_ring.c
@@ -469,6 +469,8 @@ void vring_transport_features(struct virtio_device *vdev)
for (i = VIRTIO_TRANSPORT_F_START; i < VIRTIO_TRANSPORT_F_END; i++) {
switch (i) {
+ case VIRTIO_F_FEATURES_HI:
+ break;
case VIRTIO_RING_F_INDIRECT_DESC:
break;
default:
diff --git a/include/linux/virtio.h b/include/linux/virtio.h
index aff5b4f..718336b 100644
--- a/include/linux/virtio.h
+++ b/include/linux/virtio.h
@@ -105,7 +105,7 @@ struct virtio_device {
struct virtio_config_ops *config;
struct list_head vqs;
/* Note that this is a Linux set_bit-style bitmap. */
- unsigned long features[1];
+ unsigned long features[64 / BITS_PER_LONG];
void *priv;
};
diff --git a/include/linux/virtio_config.h b/include/linux/virtio_config.h
index 800617b..b1a1981 100644
--- a/include/linux/virtio_config.h
+++ b/include/linux/virtio_config.h
@@ -18,16 +18,19 @@
/* We've given up on this device. */
#define VIRTIO_CONFIG_S_FAILED 0x80
-/* Some virtio feature bits (currently bits 28 through 31) are reserved for the
+/* Some virtio feature bits (currently bits 28 through 39) are reserved for the
* transport being used (eg. virtio_ring), the rest are per-device feature
* bits. */
#define VIRTIO_TRANSPORT_F_START 28
-#define VIRTIO_TRANSPORT_F_END 32
+#define VIRTIO_TRANSPORT_F_END 40
/* Do we get callbacks when the ring is completely used, even if we've
* suppressed them? */
#define VIRTIO_F_NOTIFY_ON_EMPTY 24
+/* Enables feature bits 32 to 63 (only really required for virtio_pci). */
+#define VIRTIO_F_FEATURES_HI 31
+
#ifdef __KERNEL__
#include <linux/err.h>
#include <linux/virtio.h>
@@ -72,7 +75,7 @@
* @del_vqs: free virtqueues found by find_vqs().
* @get_features: get the array of feature bits for this device.
* vdev: the virtio_device
- * Returns the first 32 feature bits (all we currently need).
+ * Returns the first 64 feature bits (all we currently need).
* @finalize_features: confirm what device features we'll be using.
* vdev: the virtio_device
* This gives the final feature bits for the device: it can change
@@ -92,7 +95,7 @@ struct virtio_config_ops {
vq_callback_t *callbacks[],
const char *names[]);
void (*del_vqs)(struct virtio_device *);
- u32 (*get_features)(struct virtio_device *vdev);
+ u64 (*get_features)(struct virtio_device *vdev);
void (*finalize_features)(struct virtio_device *vdev);
};
@@ -110,9 +113,9 @@ static inline bool virtio_has_feature(const struct virtio_device *vdev,
{
/* Did you forget to fix assumptions on max features? */
if (__builtin_constant_p(fbit))
- BUILD_BUG_ON(fbit >= 32);
+ BUILD_BUG_ON(fbit >= 64);
else
- BUG_ON(fbit >= 32);
+ BUG_ON(fbit >= 64);
if (fbit < VIRTIO_TRANSPORT_F_START)
virtio_check_driver_offered_feature(vdev, fbit);
diff --git a/include/linux/virtio_pci.h b/include/linux/virtio_pci.h
index 9a3d7c4..90f9725 100644
--- a/include/linux/virtio_pci.h
+++ b/include/linux/virtio_pci.h
@@ -55,9 +55,16 @@
/* Vector value used to disable MSI for queue */
#define VIRTIO_MSI_NO_VECTOR 0xffff
+/* An extended 32-bit r/o bitmask of the features supported by the host */
+#define VIRTIO_PCI_HOST_FEATURES_HI 24
+
+/* An extended 32-bit r/w bitmask of features activated by the guest */
+#define VIRTIO_PCI_GUEST_FEATURES_HI 28
+
/* The remaining space is defined by each driver as the per-driver
* configuration space */
-#define VIRTIO_PCI_CONFIG(dev) ((dev)->msix_enabled ? 24 : 20)
+#define VIRTIO_PCI_CONFIG(dev) ((dev)->features_hi ? 32 : \
+ (dev)->msix_enabled ? 24 : 20)
/* Virtio ABI version, this must match exactly */
#define VIRTIO_PCI_ABI_VERSION 0
--
1.7.5.53.gc233e
next prev parent reply other threads:[~2011-05-04 20:50 UTC|newest]
Thread overview: 51+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-04 20:50 [PATCH 00/18] virtio and vhost-net performance enhancements Michael S. Tsirkin
2011-05-04 20:50 ` Michael S. Tsirkin [this message]
2011-05-04 20:50 ` [PATCH 02/18] virtio_test: update for 64 bit features Michael S. Tsirkin
2011-05-04 20:50 ` [PATCH 03/18] vhost: fix " Michael S. Tsirkin
2011-05-04 20:51 ` [PATCH 04/18] virtio: don't delay avail index update Michael S. Tsirkin
2011-05-04 20:51 ` [PATCH 05/18] virtio: used event index interface Michael S. Tsirkin
2011-05-04 21:56 ` Tom Lendacky
2011-05-05 9:38 ` Michael S. Tsirkin
2011-05-04 20:51 ` [PATCH 06/18] virtio_ring: avail " Michael S. Tsirkin
2011-05-09 4:13 ` Rusty Russell
[not found] ` <87aaewh5pg.fsf-8n+1lVoiYb80n/F98K4Iww@public.gmane.org>
2011-05-15 12:47 ` Michael S. Tsirkin
[not found] ` <20110515124727.GA24932-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2011-05-16 6:23 ` Rusty Russell
[not found] ` <87k4drduzs.fsf-8n+1lVoiYb80n/F98K4Iww@public.gmane.org>
2011-05-17 6:00 ` Michael S. Tsirkin
[not found] ` <20110517060052.GB26989-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2011-05-18 0:08 ` Rusty Russell
2011-05-04 20:51 ` [PATCH 07/18] virtio ring: inline function to check for events Michael S. Tsirkin
2011-05-05 8:34 ` Stefan Hajnoczi
2011-05-05 8:56 ` Michael S. Tsirkin
2011-05-04 20:51 ` [PATCH 08/18] virtio_ring: support for used_event idx feature Michael S. Tsirkin
[not found] ` <dd16b9f3bad847b0eadc7f94368e27982c1a7560.1304541919.git.mst-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2011-05-09 4:17 ` Rusty Russell
[not found] ` <878vugh5ib.fsf-8n+1lVoiYb80n/F98K4Iww@public.gmane.org>
2011-05-15 12:47 ` Michael S. Tsirkin
2011-05-04 20:51 ` [PATCH 09/18] virtio: use avail_event index Michael S. Tsirkin
2011-05-04 21:58 ` Tom Lendacky
2011-05-05 9:34 ` Michael S. Tsirkin
[not found] ` <8bba6a0a8eee17e741c5155b04ff1b1c9f34bf94.1304541919.git.mst-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2011-05-09 4:33 ` Rusty Russell
[not found] ` <874o54h4rt.fsf-8n+1lVoiYb80n/F98K4Iww@public.gmane.org>
2011-05-15 13:55 ` Michael S. Tsirkin
[not found] ` <20110515135541.GF24932-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2011-05-16 7:12 ` Rusty Russell
[not found] ` <87ei3zdsq2.fsf-8n+1lVoiYb80n/F98K4Iww@public.gmane.org>
2011-05-17 6:10 ` Michael S. Tsirkin
[not found] ` <20110517061031.GC26989-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2011-05-18 0:19 ` Rusty Russell
[not found] ` <87tycsn9lt.fsf-8n+1lVoiYb80n/F98K4Iww@public.gmane.org>
2011-05-18 5:43 ` Michael S. Tsirkin
2011-05-19 7:27 ` Michael S. Tsirkin
2011-05-17 16:23 ` Tom Lendacky
2011-05-04 20:51 ` [PATCH 10/18] vhost: utilize used_event index Michael S. Tsirkin
2011-05-04 20:52 ` [PATCH 11/18] vhost: support avail_event idx Michael S. Tsirkin
2011-05-04 20:52 ` [PATCH 12/18] virtio_test: support used_event index Michael S. Tsirkin
2011-05-04 20:52 ` [PATCH 13/18] virtio_test: avail_event index support Michael S. Tsirkin
2011-05-04 20:52 ` [PATCH 14/18] virtio: add api for delayed callbacks Michael S. Tsirkin
[not found] ` <64d47c628b3fdc0ac156aed4be182933d8bcc0db.1304541919.git.mst-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2011-05-09 5:57 ` Rusty Russell
[not found] ` <871v08h0vm.fsf-8n+1lVoiYb80n/F98K4Iww@public.gmane.org>
2011-05-15 12:48 ` Michael S. Tsirkin
[not found] ` <20110515124818.GD24932-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2011-05-16 7:13 ` Rusty Russell
[not found] ` <87boz3dsoe.fsf-8n+1lVoiYb80n/F98K4Iww@public.gmane.org>
2011-05-19 7:24 ` Michael S. Tsirkin
[not found] ` <20110519072412.GA31253-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2011-05-20 7:43 ` Rusty Russell
2011-05-04 20:52 ` [PATCH 15/18] virtio_net: delay TX callbacks Michael S. Tsirkin
2011-05-04 20:52 ` [PATCH 16/18] virtio_ring: Add capacity check API Michael S. Tsirkin
2011-05-04 20:53 ` [PATCH 17/18] virtio_net: fix TX capacity checks using new API Michael S. Tsirkin
2011-05-04 20:53 ` [PATCH 18/18] virtio_net: limit xmit polling Michael S. Tsirkin
2011-05-05 15:07 ` [PATCH 0/3] virtio and vhost-net performance enhancements Michael S. Tsirkin
2011-05-05 15:08 ` [PATCH 1/3] virtio: fix avail event support Michael S. Tsirkin
2011-05-05 15:08 ` [PATCH 2/3] virtio_ring: check used_event offset Michael S. Tsirkin
2011-05-05 15:08 ` [PATCH 3/3] virtio_ring: need_event api comment fix Michael S. Tsirkin
[not found] ` <c8b6d8a8df4927826d0024fceeb68726c50d0b1a.1304605817.git.mst-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2011-05-09 5:59 ` Rusty Russell
2011-05-11 17:10 ` [PATCH 00/18] virtio and vhost-net performance enhancements Krishna Kumar2
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=45e900e472b72cc17c40e4dcc1587b1b0ca8d6c5.1304541919.git.mst@redhat.com \
--to=mst@redhat.com \
--cc=borntraeger@de.ibm.com \
--cc=cotte@de.ibm.com \
--cc=habanero@linux.vnet.ibm.com \
--cc=heiko.carstens@de.ibm.com \
--cc=krkumar2@in.ibm.com \
--cc=kvm@vger.kernel.org \
--cc=lguest@lists.ozlabs.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=linux390@de.ibm.com \
--cc=netdev@vger.kernel.org \
--cc=rusty@rustcorp.com.au \
--cc=schwidefsky@de.ibm.com \
--cc=steved@us.ibm.com \
--cc=tahm@linux.vnet.ibm.com \
--cc=virtualization@lists.linux-foundation.org \
--cc=xma@us.ibm.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
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).