virtio 1.0: tools update
Michael S. Tsirkin
maintainercover virtio 1.0: tools update
virtio test support for virtio 1.0.
Probably a good idea to include for 3.19.
Michael S. Tsirkin (6):
tools/virtio: more stubs
tools/virtio: fix vringh test
tools/virtio: 64 bit features
tools/virtio: enable -Werror
tools/virtio: add virtio 1.0 in virtio_test
tools/virtio: add virtio 1.0 in vringh_test
tools/virtio/linux/virtio.h | 1 + tools/virtio/linux/virtio_byteorder.h | 8 ++++++++ tools/virtio/linux/virtio_config.h | 25 +++++++++++++++++++++++-- tools/virtio/uapi/linux/virtio_types.h | 1 + tools/virtio/virtio_test.c | 14 +++++++++++++- tools/virtio/vringh_test.c | 5 ++++- tools/virtio/Makefile | 2 +- 7 files changed, 51 insertions(+), 5 deletions(-) create mode 100644 tools/virtio/linux/virtio_byteorder.h create mode 100644 tools/virtio/uapi/linux/virtio_types.h
Signature · 1 line
MST
Michael S. Tsirkin
maintainerPATCH 1/6 tools/virtio: more stubs
As usual, add more stubs to fix test build after main codebase changes.
--- tools/virtio/linux/virtio.h | 1 + tools/virtio/linux/virtio_byteorder.h | 8 ++++++++ tools/virtio/linux/virtio_config.h | 25 +++++++++++++++++++++++-- tools/virtio/uapi/linux/virtio_types.h | 1 + 4 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 tools/virtio/linux/virtio_byteorder.h create mode 100644 tools/virtio/uapi/linux/virtio_types.h
tools/virtio/linux/virtio.h +1 -0
@@ -6,6 +6,7 @@/* TODO: empty stubs for now. Broken but enough for virtio_ring.c */ #define list_add_tail (a, b) do {} while (0)#define list_del (a) do {} while (0) +#define list_for_each_entry (a, b, c) while (0)/* end of stubs */ struct virtio_device {
tools/virtio/linux/virtio_byteorder.h new file +8 -0
@@ -0,0 +1,8 @@ +#ifndef _LINUX_VIRTIO_BYTEORDER_STUB_H +#define _LINUX_VIRTIO_BYTEORDER_STUB_H + +#include <asm/byteorder.h> +#include "../../include/linux/byteorder/generic.h" +#include "../../include/linux/virtio_byteorder.h" + +#endif
tools/virtio/linux/virtio_config.h +23 -2
@@ -1,8 +1,7 @@#include <linux/virtio_byteorder.h> #include <linux/virtio.h> +#include <uapi/linux/virtio_config.h> -#define VIRTIO_TRANSPORT_F_START 28 -#define VIRTIO_TRANSPORT_F_END 32/* * __virtio_test_bit - helper to test feature bits. For use by transports. * Devices should normally use virtio_has_feature,
@@ -16,6 +15,28 @@ static inline bool __virtio_test_bit(const struct virtio_device *vdev,return vdev->features & (1ULL << fbit); } +/** +* __virtio_set_bit - helper to set feature bits. For use by transports. +* @vdev: the device +* @fbit: the feature bit +*/ +static inline void __virtio_set_bit (struct virtio_device *vdev, +unsigned int fbit) +{ + vdev->features |= (1ULL << fbit); +} + +/** +* __virtio_clear_bit - helper to clear feature bits. For use by transports. +* @vdev: the device +* @fbit: the feature bit +*/ +static inline void __virtio_clear_bit (struct virtio_device *vdev, +unsigned int fbit) +{ + vdev->features &= ~(1ULL << fbit); +} +#define virtio_has_feature (dev, feature) \ (__virtio_test_bit((dev), feature))
tools/virtio/uapi/linux/virtio_types.h new file +1 -0
@@ -0,0 +1 @@ +#include "../../include/uapi/linux/virtio_types.h"
Signature · 1 line
MST
Re: [PATCH 1/6] tools/virtio: more stubs
Quoted 2 lines · Michael S. Tsirkin
As usual, add more stubs to fix test build after main codebase changes.
This doesn't apply, since:
tools/virtio/linux/virtio_config.h line 5
Quoted 12 lines
tools/virtio/linux/virtio_config.h +1
-2@@ -1,8 +1,7 @@#include <linux/virtio_byteorder.h> #include <linux/virtio.h> +#include <uapi/linux/virtio_config.h> -#define VIRTIO_TRANSPORT_F_START 28 -#define VIRTIO_TRANSPORT_F_END 32/*
Version in master has no headers in this file.
What's this based on?
Thanks,
Rusty.
Michael S. Tsirkin
maintainerPATCH 2/6 tools/virtio: fix vringh test
In reply to Michael S. TsirkinInclude missing virtio_config.h
--- tools/virtio/vringh_test.c | 1 + 1 file changed, 1 insertion(+)
tools/virtio/vringh_test.c +1 -0
@@ -7,6 +7,7 @@#include <linux/virtio.h> #include <linux/vringh.h> #include <linux/virtio_ring.h> +#include <linux/virtio_config.h> #include <linux/uaccess.h> #include <sys/types.h> #include <sys/stat.h>
Signature · 1 line
MST
Michael S. Tsirkin
maintainerPATCH 3/6 tools/virtio: 64 bit features
In reply to Michael S. TsirkinMissed one place where vringh_test used
long to pass features. Fix it up to u64.
--- tools/virtio/vringh_test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/virtio/vringh_test.c +1 -1
@@ -132,7 +132,7 @@ static inline int vringh_get_head(struct vringh *vrh, u16 *head)return 1 ; } -static int parallel_test (unsigned long features, +static int parallel_test (u64 features,bool (*getrange)(struct vringh *vrh,u64 addr,struct vringh_range *r),bool fast_vringh)
Signature · 1 line
MST
Michael S. Tsirkin
maintainerPATCH 4/6 tools/virtio: enable -Werror
In reply to Michael S. TsirkinSeems to mostly be a positive.
--- tools/virtio/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/virtio/Makefile +1 -1
@@ -3,7 +3,7 @@ test: virtio_test vringh_test virtio_test: virtio_ring.o virtio_test.o vringh_test: vringh_test.o vringh.o virtio_ring.o -CFLAGS += -g -O2 -Wall -I. -I../include/ -I ../../usr/include/ -Wno-pointer-sign -fno-strict-overflow -fno-strict-aliasing -fno-common -MMD -U_FORTIFY_SOURCE +CFLAGS += -g -O2 -Werror -Wall -I. -I../include/ -I ../../usr/include/ -Wno-pointer-sign -fno-strict-overflow -fno-strict-aliasing -fno-common -MMD -U_FORTIFY_SOURCE vpath %.c ../../drivers/virtio ../../drivers/vhost mod: ${MAKE} -C `pwd`/../.. M=`pwd`/vhost_test
Signature · 1 line
MST
Michael S. Tsirkin
maintainerPATCH 5/6 tools/virtio: add virtio 1.0 in virtio_test
In reply to Michael S. Tsirkin--- tools/virtio/virtio_test.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
tools/virtio/virtio_test.c +13 -1
@@ -228,6 +228,14 @@ const struct option longopts[] = { .val = 'i', }, { + .name = "virtio-1", + .val = '1', + }, + { + .name = "no-virtio-1", + .val = '0', + }, + { .name = "delayed-interrupt", .val = 'D', },
@@ -244,6 +252,7 @@ static void help(void)fprintf (stderr,"Usage: virtio_test [--help]" " [--no-indirect]" " [--no-event-idx]" +" [--no-virtio-1]" " [--delayed-interrupt]" "\n" ); }
@@ -252,7 +261,7 @@ int main(int argc, char **argv) {struct vdev_info dev;unsigned long long features = (1ULL <<VIRTIO_RING_F_INDIRECT_DESC ) | - (1ULL <<VIRTIO_RING_F_EVENT_IDX ); + (1ULL <<VIRTIO_RING_F_EVENT_IDX ) | (1ULL <<VIRTIO_F_VERSION_1 );int o;bool delayed = false;
@@ -273,6 +282,9 @@ int main(int argc, char **argv)case 'i' : features &= ~(1ULL <<VIRTIO_RING_F_INDIRECT_DESC );break ; +case '0' : + features &= ~(1ULL <<VIRTIO_F_VERSION_1 ); +break ;case 'D' : delayed = true;break ;
Signature · 1 line
MST
Michael S. Tsirkin
maintainerPATCH 6/6 tools/virtio: add virtio 1.0 in vringh_test
In reply to Michael S. Tsirkin--- tools/virtio/vringh_test.c | 2 ++ 1 file changed, 2 insertions(+)
tools/virtio/vringh_test.c +2 -0
@@ -457,6 +457,8 @@ int main(int argc, char *argv[])__virtio_set_bit (&vdev,VIRTIO_RING_F_INDIRECT_DESC ); else if (strcmp(argv[1], "--eventidx") == 0) __virtio_set_bit(&vdev, VIRTIO_RING_F_EVENT_IDX); + else if (strcmp(argv[1], "--virtio-1") == 0) + __virtio_set_bit(&vdev, VIRTIO_F_VERSION_1); else if (strcmp(argv[1], "--slow-range") == 0) getrange = getrange_slow; else if (strcmp(argv[1], "--fast-vringh") == 0)
Signature · 1 line
MST