diff options
author | Michael S. Tsirkin <mst@redhat.com> | 2014-10-07 10:39:42 -0400 |
---|---|---|
committer | Michael S. Tsirkin <mst@redhat.com> | 2014-12-09 05:05:23 -0500 |
commit | e16e12be34648777606a2c03a3526409b38f0e63 (patch) | |
tree | 36298911ba8eed0a4805c2c30a56d92520d23432 | |
parent | d4024af56f7c6cdb7e721994204fb07b2cda8be9 (diff) |
virtio: use u32, not bitmap for features
It seemed like a good idea to use bitmap for features
in struct virtio_device, but it's actually a pain,
and seems to become even more painful when we get more
than 32 feature bits. Just change it to a u32 for now.
Based on patch by Rusty.
Suggested-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
-rw-r--r-- | drivers/char/virtio_console.c | 2 | ||||
-rw-r--r-- | drivers/lguest/lguest_device.c | 8 | ||||
-rw-r--r-- | drivers/misc/mic/card/mic_virtio.c | 2 | ||||
-rw-r--r-- | drivers/remoteproc/remoteproc_virtio.c | 2 | ||||
-rw-r--r-- | drivers/s390/kvm/kvm_virtio.c | 2 | ||||
-rw-r--r-- | drivers/s390/kvm/virtio_ccw.c | 23 | ||||
-rw-r--r-- | drivers/virtio/virtio.c | 10 | ||||
-rw-r--r-- | drivers/virtio/virtio_mmio.c | 8 | ||||
-rw-r--r-- | drivers/virtio/virtio_pci.c | 3 | ||||
-rw-r--r-- | drivers/virtio/virtio_ring.c | 2 | ||||
-rw-r--r-- | include/linux/virtio.h | 3 | ||||
-rw-r--r-- | include/linux/virtio_config.h | 6 | ||||
-rw-r--r-- | tools/virtio/linux/virtio.h | 22 | ||||
-rw-r--r-- | tools/virtio/linux/virtio_config.h | 2 | ||||
-rw-r--r-- | tools/virtio/virtio_test.c | 5 | ||||
-rw-r--r-- | tools/virtio/vringh_test.c | 16 |
16 files changed, 42 insertions, 74 deletions
diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c index cf7a561fad7c..8d00aa7f60f0 100644 --- a/drivers/char/virtio_console.c +++ b/drivers/char/virtio_console.c | |||
@@ -355,7 +355,7 @@ static inline bool use_multiport(struct ports_device *portdev) | |||
355 | */ | 355 | */ |
356 | if (!portdev->vdev) | 356 | if (!portdev->vdev) |
357 | return 0; | 357 | return 0; |
358 | return portdev->vdev->features[0] & (1 << VIRTIO_CONSOLE_F_MULTIPORT); | 358 | return __virtio_test_bit(portdev->vdev, VIRTIO_CONSOLE_F_MULTIPORT); |
359 | } | 359 | } |
360 | 360 | ||
361 | static DEFINE_SPINLOCK(dma_bufs_lock); | 361 | static DEFINE_SPINLOCK(dma_bufs_lock); |
diff --git a/drivers/lguest/lguest_device.c b/drivers/lguest/lguest_device.c index d0a1d8a45c81..97aeb7dce5fc 100644 --- a/drivers/lguest/lguest_device.c +++ b/drivers/lguest/lguest_device.c | |||
@@ -137,14 +137,14 @@ static void lg_finalize_features(struct virtio_device *vdev) | |||
137 | vring_transport_features(vdev); | 137 | vring_transport_features(vdev); |
138 | 138 | ||
139 | /* | 139 | /* |
140 | * The vdev->feature array is a Linux bitmask: this isn't the same as a | 140 | * Since lguest is currently x86-only, we're little-endian. That |
141 | * the simple array of bits used by lguest devices for features. So we | 141 | * means we could just memcpy. But it's not time critical, and in |
142 | * do this slow, manual conversion which is completely general. | 142 | * case someone copies this code, we do it the slow, obvious way. |
143 | */ | 143 | */ |
144 | memset(out_features, 0, desc->feature_len); | 144 | memset(out_features, 0, desc->feature_len); |
145 | bits = min_t(unsigned, desc->feature_len, sizeof(vdev->features)) * 8; | 145 | bits = min_t(unsigned, desc->feature_len, sizeof(vdev->features)) * 8; |
146 | for (i = 0; i < bits; i++) { | 146 | for (i = 0; i < bits; i++) { |
147 | if (test_bit(i, vdev->features)) | 147 | if (__virtio_test_bit(vdev, i)) |
148 | out_features[i / 8] |= (1 << (i % 8)); | 148 | out_features[i / 8] |= (1 << (i % 8)); |
149 | } | 149 | } |
150 | 150 | ||
diff --git a/drivers/misc/mic/card/mic_virtio.c b/drivers/misc/mic/card/mic_virtio.c index e64794730e21..4f070ad1875c 100644 --- a/drivers/misc/mic/card/mic_virtio.c +++ b/drivers/misc/mic/card/mic_virtio.c | |||
@@ -101,7 +101,7 @@ static void mic_finalize_features(struct virtio_device *vdev) | |||
101 | bits = min_t(unsigned, feature_len, | 101 | bits = min_t(unsigned, feature_len, |
102 | sizeof(vdev->features)) * 8; | 102 | sizeof(vdev->features)) * 8; |
103 | for (i = 0; i < bits; i++) { | 103 | for (i = 0; i < bits; i++) { |
104 | if (test_bit(i, vdev->features)) | 104 | if (__virtio_test_bit(vdev, i)) |
105 | iowrite8(ioread8(&out_features[i / 8]) | (1 << (i % 8)), | 105 | iowrite8(ioread8(&out_features[i / 8]) | (1 << (i % 8)), |
106 | &out_features[i / 8]); | 106 | &out_features[i / 8]); |
107 | } | 107 | } |
diff --git a/drivers/remoteproc/remoteproc_virtio.c b/drivers/remoteproc/remoteproc_virtio.c index a34b50690b4e..dafaf38dac0a 100644 --- a/drivers/remoteproc/remoteproc_virtio.c +++ b/drivers/remoteproc/remoteproc_virtio.c | |||
@@ -231,7 +231,7 @@ static void rproc_virtio_finalize_features(struct virtio_device *vdev) | |||
231 | * Remember the finalized features of our vdev, and provide it | 231 | * Remember the finalized features of our vdev, and provide it |
232 | * to the remote processor once it is powered on. | 232 | * to the remote processor once it is powered on. |
233 | */ | 233 | */ |
234 | rsc->gfeatures = vdev->features[0]; | 234 | rsc->gfeatures = vdev->features; |
235 | } | 235 | } |
236 | 236 | ||
237 | static void rproc_virtio_get(struct virtio_device *vdev, unsigned offset, | 237 | static void rproc_virtio_get(struct virtio_device *vdev, unsigned offset, |
diff --git a/drivers/s390/kvm/kvm_virtio.c b/drivers/s390/kvm/kvm_virtio.c index 643129070c51..fcd312d0c018 100644 --- a/drivers/s390/kvm/kvm_virtio.c +++ b/drivers/s390/kvm/kvm_virtio.c | |||
@@ -106,7 +106,7 @@ static void kvm_finalize_features(struct virtio_device *vdev) | |||
106 | memset(out_features, 0, desc->feature_len); | 106 | memset(out_features, 0, desc->feature_len); |
107 | bits = min_t(unsigned, desc->feature_len, sizeof(vdev->features)) * 8; | 107 | bits = min_t(unsigned, desc->feature_len, sizeof(vdev->features)) * 8; |
108 | for (i = 0; i < bits; i++) { | 108 | for (i = 0; i < bits; i++) { |
109 | if (test_bit(i, vdev->features)) | 109 | if (__virtio_test_bit(vdev, i)) |
110 | out_features[i / 8] |= (1 << (i % 8)); | 110 | out_features[i / 8] |= (1 << (i % 8)); |
111 | } | 111 | } |
112 | } | 112 | } |
diff --git a/drivers/s390/kvm/virtio_ccw.c b/drivers/s390/kvm/virtio_ccw.c index bda52f18e967..1dbee95838fe 100644 --- a/drivers/s390/kvm/virtio_ccw.c +++ b/drivers/s390/kvm/virtio_ccw.c | |||
@@ -701,7 +701,6 @@ static void virtio_ccw_finalize_features(struct virtio_device *vdev) | |||
701 | { | 701 | { |
702 | struct virtio_ccw_device *vcdev = to_vc_device(vdev); | 702 | struct virtio_ccw_device *vcdev = to_vc_device(vdev); |
703 | struct virtio_feature_desc *features; | 703 | struct virtio_feature_desc *features; |
704 | int i; | ||
705 | struct ccw1 *ccw; | 704 | struct ccw1 *ccw; |
706 | 705 | ||
707 | ccw = kzalloc(sizeof(*ccw), GFP_DMA | GFP_KERNEL); | 706 | ccw = kzalloc(sizeof(*ccw), GFP_DMA | GFP_KERNEL); |
@@ -715,19 +714,15 @@ static void virtio_ccw_finalize_features(struct virtio_device *vdev) | |||
715 | /* Give virtio_ring a chance to accept features. */ | 714 | /* Give virtio_ring a chance to accept features. */ |
716 | vring_transport_features(vdev); | 715 | vring_transport_features(vdev); |
717 | 716 | ||
718 | for (i = 0; i < sizeof(*vdev->features) / sizeof(features->features); | 717 | features->index = 0; |
719 | i++) { | 718 | features->features = cpu_to_le32(vdev->features); |
720 | int highbits = i % 2 ? 32 : 0; | 719 | /* Write the feature bits to the host. */ |
721 | features->index = i; | 720 | ccw->cmd_code = CCW_CMD_WRITE_FEAT; |
722 | features->features = cpu_to_le32(vdev->features[i / 2] | 721 | ccw->flags = 0; |
723 | >> highbits); | 722 | ccw->count = sizeof(*features); |
724 | /* Write the feature bits to the host. */ | 723 | ccw->cda = (__u32)(unsigned long)features; |
725 | ccw->cmd_code = CCW_CMD_WRITE_FEAT; | 724 | ccw_io_helper(vcdev, ccw, VIRTIO_CCW_DOING_WRITE_FEAT); |
726 | ccw->flags = 0; | 725 | |
727 | ccw->count = sizeof(*features); | ||
728 | ccw->cda = (__u32)(unsigned long)features; | ||
729 | ccw_io_helper(vcdev, ccw, VIRTIO_CCW_DOING_WRITE_FEAT); | ||
730 | } | ||
731 | out_free: | 726 | out_free: |
732 | kfree(features); | 727 | kfree(features); |
733 | kfree(ccw); | 728 | kfree(ccw); |
diff --git a/drivers/virtio/virtio.c b/drivers/virtio/virtio.c index df598dd8c5c8..2b9aafb4d679 100644 --- a/drivers/virtio/virtio.c +++ b/drivers/virtio/virtio.c | |||
@@ -49,9 +49,9 @@ static ssize_t features_show(struct device *_d, | |||
49 | 49 | ||
50 | /* We actually represent this as a bitstring, as it could be | 50 | /* We actually represent this as a bitstring, as it could be |
51 | * arbitrary length in future. */ | 51 | * arbitrary length in future. */ |
52 | for (i = 0; i < ARRAY_SIZE(dev->features)*BITS_PER_LONG; i++) | 52 | for (i = 0; i < sizeof(dev->features)*8; i++) |
53 | len += sprintf(buf+len, "%c", | 53 | len += sprintf(buf+len, "%c", |
54 | test_bit(i, dev->features) ? '1' : '0'); | 54 | __virtio_test_bit(dev, i) ? '1' : '0'); |
55 | len += sprintf(buf+len, "\n"); | 55 | len += sprintf(buf+len, "\n"); |
56 | return len; | 56 | return len; |
57 | } | 57 | } |
@@ -168,18 +168,18 @@ static int virtio_dev_probe(struct device *_d) | |||
168 | device_features = dev->config->get_features(dev); | 168 | device_features = dev->config->get_features(dev); |
169 | 169 | ||
170 | /* Features supported by both device and driver into dev->features. */ | 170 | /* Features supported by both device and driver into dev->features. */ |
171 | memset(dev->features, 0, sizeof(dev->features)); | 171 | dev->features = 0; |
172 | for (i = 0; i < drv->feature_table_size; i++) { | 172 | for (i = 0; i < drv->feature_table_size; i++) { |
173 | unsigned int f = drv->feature_table[i]; | 173 | unsigned int f = drv->feature_table[i]; |
174 | BUG_ON(f >= 32); | 174 | BUG_ON(f >= 32); |
175 | if (device_features & (1 << f)) | 175 | if (device_features & (1 << f)) |
176 | set_bit(f, dev->features); | 176 | __virtio_set_bit(dev, f); |
177 | } | 177 | } |
178 | 178 | ||
179 | /* Transport features always preserved to pass to finalize_features. */ | 179 | /* Transport features always preserved to pass to finalize_features. */ |
180 | for (i = VIRTIO_TRANSPORT_F_START; i < VIRTIO_TRANSPORT_F_END; i++) | 180 | for (i = VIRTIO_TRANSPORT_F_START; i < VIRTIO_TRANSPORT_F_END; i++) |
181 | if (device_features & (1 << i)) | 181 | if (device_features & (1 << i)) |
182 | set_bit(i, dev->features); | 182 | __virtio_set_bit(dev, i); |
183 | 183 | ||
184 | dev->config->finalize_features(dev); | 184 | dev->config->finalize_features(dev); |
185 | 185 | ||
diff --git a/drivers/virtio/virtio_mmio.c b/drivers/virtio/virtio_mmio.c index ef9a1650bb80..eb5b0e2b434a 100644 --- a/drivers/virtio/virtio_mmio.c +++ b/drivers/virtio/virtio_mmio.c | |||
@@ -155,16 +155,12 @@ static u32 vm_get_features(struct virtio_device *vdev) | |||
155 | static void vm_finalize_features(struct virtio_device *vdev) | 155 | static void vm_finalize_features(struct virtio_device *vdev) |
156 | { | 156 | { |
157 | struct virtio_mmio_device *vm_dev = to_virtio_mmio_device(vdev); | 157 | struct virtio_mmio_device *vm_dev = to_virtio_mmio_device(vdev); |
158 | int i; | ||
159 | 158 | ||
160 | /* Give virtio_ring a chance to accept features. */ | 159 | /* Give virtio_ring a chance to accept features. */ |
161 | vring_transport_features(vdev); | 160 | vring_transport_features(vdev); |
162 | 161 | ||
163 | for (i = 0; i < ARRAY_SIZE(vdev->features); i++) { | 162 | writel(0, vm_dev->base + VIRTIO_MMIO_GUEST_FEATURES_SEL); |
164 | writel(i, vm_dev->base + VIRTIO_MMIO_GUEST_FEATURES_SEL); | 163 | writel(vdev->features, vm_dev->base + VIRTIO_MMIO_GUEST_FEATURES); |
165 | writel(vdev->features[i], | ||
166 | vm_dev->base + VIRTIO_MMIO_GUEST_FEATURES); | ||
167 | } | ||
168 | } | 164 | } |
169 | 165 | ||
170 | static void vm_get(struct virtio_device *vdev, unsigned offset, | 166 | static void vm_get(struct virtio_device *vdev, unsigned offset, |
diff --git a/drivers/virtio/virtio_pci.c b/drivers/virtio/virtio_pci.c index d34ebfa604f3..4e112c158488 100644 --- a/drivers/virtio/virtio_pci.c +++ b/drivers/virtio/virtio_pci.c | |||
@@ -120,8 +120,7 @@ static void vp_finalize_features(struct virtio_device *vdev) | |||
120 | vring_transport_features(vdev); | 120 | vring_transport_features(vdev); |
121 | 121 | ||
122 | /* We only support 32 feature bits. */ | 122 | /* We only support 32 feature bits. */ |
123 | BUILD_BUG_ON(ARRAY_SIZE(vdev->features) != 1); | 123 | iowrite32(vdev->features, vp_dev->ioaddr + VIRTIO_PCI_GUEST_FEATURES); |
124 | iowrite32(vdev->features[0], vp_dev->ioaddr+VIRTIO_PCI_GUEST_FEATURES); | ||
125 | } | 124 | } |
126 | 125 | ||
127 | /* virtio config->get() implementation */ | 126 | /* virtio config->get() implementation */ |
diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c index 3b1f89b6e743..839247cd8263 100644 --- a/drivers/virtio/virtio_ring.c +++ b/drivers/virtio/virtio_ring.c | |||
@@ -781,7 +781,7 @@ void vring_transport_features(struct virtio_device *vdev) | |||
781 | break; | 781 | break; |
782 | default: | 782 | default: |
783 | /* We don't understand this bit. */ | 783 | /* We don't understand this bit. */ |
784 | clear_bit(i, vdev->features); | 784 | __virtio_clear_bit(vdev, i); |
785 | } | 785 | } |
786 | } | 786 | } |
787 | } | 787 | } |
diff --git a/include/linux/virtio.h b/include/linux/virtio.h index 65261a7244fc..7828a7f47c2c 100644 --- a/include/linux/virtio.h +++ b/include/linux/virtio.h | |||
@@ -101,8 +101,7 @@ struct virtio_device { | |||
101 | const struct virtio_config_ops *config; | 101 | const struct virtio_config_ops *config; |
102 | const struct vringh_config_ops *vringh_config; | 102 | const struct vringh_config_ops *vringh_config; |
103 | struct list_head vqs; | 103 | struct list_head vqs; |
104 | /* Note that this is a Linux set_bit-style bitmap. */ | 104 | u32 features; |
105 | unsigned long features[1]; | ||
106 | void *priv; | 105 | void *priv; |
107 | }; | 106 | }; |
108 | 107 | ||
diff --git a/include/linux/virtio_config.h b/include/linux/virtio_config.h index d8e28a2a5738..ffc2ae04879c 100644 --- a/include/linux/virtio_config.h +++ b/include/linux/virtio_config.h | |||
@@ -92,7 +92,7 @@ static inline bool __virtio_test_bit(const struct virtio_device *vdev, | |||
92 | else | 92 | else |
93 | BUG_ON(fbit >= 32); | 93 | BUG_ON(fbit >= 32); |
94 | 94 | ||
95 | return test_bit(fbit, vdev->features); | 95 | return vdev->features & BIT(fbit); |
96 | } | 96 | } |
97 | 97 | ||
98 | /** | 98 | /** |
@@ -109,7 +109,7 @@ static inline void __virtio_set_bit(struct virtio_device *vdev, | |||
109 | else | 109 | else |
110 | BUG_ON(fbit >= 32); | 110 | BUG_ON(fbit >= 32); |
111 | 111 | ||
112 | set_bit(fbit, vdev->features); | 112 | vdev->features |= BIT(fbit); |
113 | } | 113 | } |
114 | 114 | ||
115 | /** | 115 | /** |
@@ -126,7 +126,7 @@ static inline void __virtio_clear_bit(struct virtio_device *vdev, | |||
126 | else | 126 | else |
127 | BUG_ON(fbit >= 32); | 127 | BUG_ON(fbit >= 32); |
128 | 128 | ||
129 | clear_bit(fbit, vdev->features); | 129 | vdev->features &= ~BIT(fbit); |
130 | } | 130 | } |
131 | 131 | ||
132 | /** | 132 | /** |
diff --git a/tools/virtio/linux/virtio.h b/tools/virtio/linux/virtio.h index 5a2d1f0f6bc7..72bff70bfeeb 100644 --- a/tools/virtio/linux/virtio.h +++ b/tools/virtio/linux/virtio.h | |||
@@ -6,31 +6,11 @@ | |||
6 | /* TODO: empty stubs for now. Broken but enough for virtio_ring.c */ | 6 | /* TODO: empty stubs for now. Broken but enough for virtio_ring.c */ |
7 | #define list_add_tail(a, b) do {} while (0) | 7 | #define list_add_tail(a, b) do {} while (0) |
8 | #define list_del(a) do {} while (0) | 8 | #define list_del(a) do {} while (0) |
9 | |||
10 | #define BIT_WORD(nr) ((nr) / BITS_PER_LONG) | ||
11 | #define BITS_PER_BYTE 8 | ||
12 | #define BITS_PER_LONG (sizeof(long) * BITS_PER_BYTE) | ||
13 | #define BIT_MASK(nr) (1UL << ((nr) % BITS_PER_LONG)) | ||
14 | |||
15 | /* TODO: Not atomic as it should be: | ||
16 | * we don't use this for anything important. */ | ||
17 | static inline void clear_bit(int nr, volatile unsigned long *addr) | ||
18 | { | ||
19 | unsigned long mask = BIT_MASK(nr); | ||
20 | unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr); | ||
21 | |||
22 | *p &= ~mask; | ||
23 | } | ||
24 | |||
25 | static inline int test_bit(int nr, const volatile unsigned long *addr) | ||
26 | { | ||
27 | return 1UL & (addr[BIT_WORD(nr)] >> (nr & (BITS_PER_LONG-1))); | ||
28 | } | ||
29 | /* end of stubs */ | 9 | /* end of stubs */ |
30 | 10 | ||
31 | struct virtio_device { | 11 | struct virtio_device { |
32 | void *dev; | 12 | void *dev; |
33 | unsigned long features[1]; | 13 | u32 features; |
34 | }; | 14 | }; |
35 | 15 | ||
36 | struct virtqueue { | 16 | struct virtqueue { |
diff --git a/tools/virtio/linux/virtio_config.h b/tools/virtio/linux/virtio_config.h index 5049967f99f7..83b27e8e9d72 100644 --- a/tools/virtio/linux/virtio_config.h +++ b/tools/virtio/linux/virtio_config.h | |||
@@ -2,5 +2,5 @@ | |||
2 | #define VIRTIO_TRANSPORT_F_END 32 | 2 | #define VIRTIO_TRANSPORT_F_END 32 |
3 | 3 | ||
4 | #define virtio_has_feature(dev, feature) \ | 4 | #define virtio_has_feature(dev, feature) \ |
5 | test_bit((feature), (dev)->features) | 5 | (__virtio_test_bit((dev), feature)) |
6 | 6 | ||
diff --git a/tools/virtio/virtio_test.c b/tools/virtio/virtio_test.c index 00ea679b3826..db3437c641a6 100644 --- a/tools/virtio/virtio_test.c +++ b/tools/virtio/virtio_test.c | |||
@@ -60,7 +60,7 @@ void vhost_vq_setup(struct vdev_info *dev, struct vq_info *info) | |||
60 | { | 60 | { |
61 | struct vhost_vring_state state = { .index = info->idx }; | 61 | struct vhost_vring_state state = { .index = info->idx }; |
62 | struct vhost_vring_file file = { .index = info->idx }; | 62 | struct vhost_vring_file file = { .index = info->idx }; |
63 | unsigned long long features = dev->vdev.features[0]; | 63 | unsigned long long features = dev->vdev.features; |
64 | struct vhost_vring_addr addr = { | 64 | struct vhost_vring_addr addr = { |
65 | .index = info->idx, | 65 | .index = info->idx, |
66 | .desc_user_addr = (uint64_t)(unsigned long)info->vring.desc, | 66 | .desc_user_addr = (uint64_t)(unsigned long)info->vring.desc, |
@@ -113,8 +113,7 @@ static void vdev_info_init(struct vdev_info* dev, unsigned long long features) | |||
113 | { | 113 | { |
114 | int r; | 114 | int r; |
115 | memset(dev, 0, sizeof *dev); | 115 | memset(dev, 0, sizeof *dev); |
116 | dev->vdev.features[0] = features; | 116 | dev->vdev.features = features; |
117 | dev->vdev.features[1] = features >> 32; | ||
118 | dev->buf_size = 1024; | 117 | dev->buf_size = 1024; |
119 | dev->buf = malloc(dev->buf_size); | 118 | dev->buf = malloc(dev->buf_size); |
120 | assert(dev->buf); | 119 | assert(dev->buf); |
diff --git a/tools/virtio/vringh_test.c b/tools/virtio/vringh_test.c index 14a4f4cab5b9..9d4b1bca54be 100644 --- a/tools/virtio/vringh_test.c +++ b/tools/virtio/vringh_test.c | |||
@@ -304,7 +304,7 @@ static int parallel_test(unsigned long features, | |||
304 | close(to_guest[1]); | 304 | close(to_guest[1]); |
305 | close(to_host[0]); | 305 | close(to_host[0]); |
306 | 306 | ||
307 | gvdev.vdev.features[0] = features; | 307 | gvdev.vdev.features = features; |
308 | gvdev.to_host_fd = to_host[1]; | 308 | gvdev.to_host_fd = to_host[1]; |
309 | gvdev.notifies = 0; | 309 | gvdev.notifies = 0; |
310 | 310 | ||
@@ -449,13 +449,13 @@ int main(int argc, char *argv[]) | |||
449 | bool fast_vringh = false, parallel = false; | 449 | bool fast_vringh = false, parallel = false; |
450 | 450 | ||
451 | getrange = getrange_iov; | 451 | getrange = getrange_iov; |
452 | vdev.features[0] = 0; | 452 | vdev.features = 0; |
453 | 453 | ||
454 | while (argv[1]) { | 454 | while (argv[1]) { |
455 | if (strcmp(argv[1], "--indirect") == 0) | 455 | if (strcmp(argv[1], "--indirect") == 0) |
456 | vdev.features[0] |= (1 << VIRTIO_RING_F_INDIRECT_DESC); | 456 | __virtio_set_bit(&vdev, VIRTIO_RING_F_INDIRECT_DESC); |
457 | else if (strcmp(argv[1], "--eventidx") == 0) | 457 | else if (strcmp(argv[1], "--eventidx") == 0) |
458 | vdev.features[0] |= (1 << VIRTIO_RING_F_EVENT_IDX); | 458 | __virtio_set_bit(&vdev, VIRTIO_RING_F_EVENT_IDX); |
459 | else if (strcmp(argv[1], "--slow-range") == 0) | 459 | else if (strcmp(argv[1], "--slow-range") == 0) |
460 | getrange = getrange_slow; | 460 | getrange = getrange_slow; |
461 | else if (strcmp(argv[1], "--fast-vringh") == 0) | 461 | else if (strcmp(argv[1], "--fast-vringh") == 0) |
@@ -468,7 +468,7 @@ int main(int argc, char *argv[]) | |||
468 | } | 468 | } |
469 | 469 | ||
470 | if (parallel) | 470 | if (parallel) |
471 | return parallel_test(vdev.features[0], getrange, fast_vringh); | 471 | return parallel_test(vdev.features, getrange, fast_vringh); |
472 | 472 | ||
473 | if (posix_memalign(&__user_addr_min, PAGE_SIZE, USER_MEM) != 0) | 473 | if (posix_memalign(&__user_addr_min, PAGE_SIZE, USER_MEM) != 0) |
474 | abort(); | 474 | abort(); |
@@ -483,7 +483,7 @@ int main(int argc, char *argv[]) | |||
483 | 483 | ||
484 | /* Set up host side. */ | 484 | /* Set up host side. */ |
485 | vring_init(&vrh.vring, RINGSIZE, __user_addr_min, ALIGN); | 485 | vring_init(&vrh.vring, RINGSIZE, __user_addr_min, ALIGN); |
486 | vringh_init_user(&vrh, vdev.features[0], RINGSIZE, true, | 486 | vringh_init_user(&vrh, vdev.features, RINGSIZE, true, |
487 | vrh.vring.desc, vrh.vring.avail, vrh.vring.used); | 487 | vrh.vring.desc, vrh.vring.avail, vrh.vring.used); |
488 | 488 | ||
489 | /* No descriptor to get yet... */ | 489 | /* No descriptor to get yet... */ |
@@ -652,13 +652,13 @@ int main(int argc, char *argv[]) | |||
652 | } | 652 | } |
653 | 653 | ||
654 | /* Test weird (but legal!) indirect. */ | 654 | /* Test weird (but legal!) indirect. */ |
655 | if (vdev.features[0] & (1 << VIRTIO_RING_F_INDIRECT_DESC)) { | 655 | if (__virtio_test_bit(&vdev, VIRTIO_RING_F_INDIRECT_DESC)) { |
656 | char *data = __user_addr_max - USER_MEM/4; | 656 | char *data = __user_addr_max - USER_MEM/4; |
657 | struct vring_desc *d = __user_addr_max - USER_MEM/2; | 657 | struct vring_desc *d = __user_addr_max - USER_MEM/2; |
658 | struct vring vring; | 658 | struct vring vring; |
659 | 659 | ||
660 | /* Force creation of direct, which we modify. */ | 660 | /* Force creation of direct, which we modify. */ |
661 | vdev.features[0] &= ~(1 << VIRTIO_RING_F_INDIRECT_DESC); | 661 | __virtio_clear_bit(&vdev, VIRTIO_RING_F_INDIRECT_DESC); |
662 | vq = vring_new_virtqueue(0, RINGSIZE, ALIGN, &vdev, true, | 662 | vq = vring_new_virtqueue(0, RINGSIZE, ALIGN, &vdev, true, |
663 | __user_addr_min, | 663 | __user_addr_min, |
664 | never_notify_host, | 664 | never_notify_host, |