From abd6790ce8db259a6cc24918207ebe35eb7c4e89 Mon Sep 17 00:00:00 2001 From: Bryan Venteicher Date: Thu, 4 Jul 2013 17:57:26 +0000 Subject: [PATCH] Merge virtio changes from projects/virtio Contains projects/virtio commits: r245738: virtio: Minor man page tweaks r246060: virtio: Cleanup feature description printing r246306: virtio: Remove old debugging flag r247238: virtio: Remove PRIx64 macros from format strings r247239: virtio: Constify some fields r247240: virtio: Minor code simplifications r249962: virtio: Update to my freebsd.org email address MFC after: 1 month --- share/man/man4/virtio.4 | 6 +-- share/man/man4/virtio_balloon.4 | 2 +- share/man/man4/virtio_blk.4 | 2 +- share/man/man4/virtio_scsi.4 | 2 +- share/man/man4/vtnet.4 | 2 +- sys/dev/virtio/balloon/virtio_balloon.c | 2 +- sys/dev/virtio/block/virtio_blk.c | 2 +- sys/dev/virtio/network/if_vtnet.c | 2 +- sys/dev/virtio/network/if_vtnetvar.h | 2 +- sys/dev/virtio/pci/virtio_pci.c | 5 +-- sys/dev/virtio/scsi/virtio_scsi.c | 2 +- sys/dev/virtio/scsi/virtio_scsivar.h | 2 +- sys/dev/virtio/virtio.c | 59 ++++++++++++------------- sys/dev/virtio/virtio.h | 2 +- sys/dev/virtio/virtio_bus_if.m | 5 +-- sys/dev/virtio/virtio_if.m | 2 +- sys/dev/virtio/virtqueue.c | 2 +- sys/dev/virtio/virtqueue.h | 2 +- 18 files changed, 48 insertions(+), 55 deletions(-) diff --git a/share/man/man4/virtio.4 b/share/man/man4/virtio.4 index 6856f697fcc7..10ebf209bb12 100644 --- a/share/man/man4/virtio.4 +++ b/share/man/man4/virtio.4 @@ -53,10 +53,10 @@ This emulation is often inefficient. .Pp VirtIO defines an interface for efficient I/O between the hypervisor and VM. The -.Xr virtio 4 +.Nm module provides a shared memory transport called a virtqueue. The -.Xr virtio_pci 4 +.Xr virtio_pci device driver represents an emulated PCI device that the hypervisor makes available to the VM. This device provides the probing, configuration, and @@ -94,4 +94,4 @@ Support for VirtIO first appeared in .An -nosplit .Fx support for VirtIO was first added by -.An Bryan Venteicher Aq bryanv@daemoninthecloset.org . +.An Bryan Venteicher Aq bryanv@FreeBSD.org . diff --git a/share/man/man4/virtio_balloon.4 b/share/man/man4/virtio_balloon.4 index 96e8c736f4d4..450b5cdfce94 100644 --- a/share/man/man4/virtio_balloon.4 +++ b/share/man/man4/virtio_balloon.4 @@ -59,6 +59,6 @@ The hypervisor can later signal the balloon to return the memory. The .Nm driver was written by -.An Bryan Venteicher Aq bryanv@daemoninthecloset.org . +.An Bryan Venteicher Aq bryanv@FreeBSD.org . It first appeared in .Fx 9.0 . diff --git a/share/man/man4/virtio_blk.4 b/share/man/man4/virtio_blk.4 index d71ca7e603e4..eb5fded32d3a 100644 --- a/share/man/man4/virtio_blk.4 +++ b/share/man/man4/virtio_blk.4 @@ -87,6 +87,6 @@ be toggled between writethrough and writeback. The .Nm driver was written by -.An Bryan Venteicher Aq bryanv@daemoninthecloset.org . +.An Bryan Venteicher Aq bryanv@FreeBSD.org . It first appeared in .Fx 9.0 . diff --git a/share/man/man4/virtio_scsi.4 b/share/man/man4/virtio_scsi.4 index a2d30d4d8121..b136de6ba97c 100644 --- a/share/man/man4/virtio_scsi.4 +++ b/share/man/man4/virtio_scsi.4 @@ -87,6 +87,6 @@ Enable tracing prints. The .Nm driver was written by -.An Bryan Venteicher Aq bryanv@daemoninthecloset.org . +.An Bryan Venteicher Aq bryanv@FreeBSD.org . It first appeared in .Fx 10.0 . diff --git a/share/man/man4/vtnet.4 b/share/man/man4/vtnet.4 index febb0ac75f24..8d4d2024deac 100644 --- a/share/man/man4/vtnet.4 +++ b/share/man/man4/vtnet.4 @@ -89,7 +89,7 @@ The default value is 0. The .Nm driver was written by -.An Bryan Venteicher Aq bryanv@daemoninthecloset.org . +.An Bryan Venteicher Aq bryanv@FreeBSD.org . It first appeared in .Fx 9.0 . .Sh CAVEATS diff --git a/sys/dev/virtio/balloon/virtio_balloon.c b/sys/dev/virtio/balloon/virtio_balloon.c index c222032ab786..9a87cf24d5e9 100644 --- a/sys/dev/virtio/balloon/virtio_balloon.c +++ b/sys/dev/virtio/balloon/virtio_balloon.c @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2011, Bryan Venteicher + * Copyright (c) 2011, Bryan Venteicher * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/dev/virtio/block/virtio_blk.c b/sys/dev/virtio/block/virtio_blk.c index 2d76398ace77..5219a3843ad3 100644 --- a/sys/dev/virtio/block/virtio_blk.c +++ b/sys/dev/virtio/block/virtio_blk.c @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2011, Bryan Venteicher + * Copyright (c) 2011, Bryan Venteicher * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/dev/virtio/network/if_vtnet.c b/sys/dev/virtio/network/if_vtnet.c index 329614a97378..89604d1b26b0 100644 --- a/sys/dev/virtio/network/if_vtnet.c +++ b/sys/dev/virtio/network/if_vtnet.c @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2011, Bryan Venteicher + * Copyright (c) 2011, Bryan Venteicher * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/dev/virtio/network/if_vtnetvar.h b/sys/dev/virtio/network/if_vtnetvar.h index da7e61dea906..d870436e4542 100644 --- a/sys/dev/virtio/network/if_vtnetvar.h +++ b/sys/dev/virtio/network/if_vtnetvar.h @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2011, Bryan Venteicher + * Copyright (c) 2011, Bryan Venteicher * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/dev/virtio/pci/virtio_pci.c b/sys/dev/virtio/pci/virtio_pci.c index 02a9d23633a1..0e7d412fff89 100644 --- a/sys/dev/virtio/pci/virtio_pci.c +++ b/sys/dev/virtio/pci/virtio_pci.c @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2011, Bryan Venteicher + * Copyright (c) 2011, Bryan Venteicher * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -487,9 +487,6 @@ vtpci_alloc_virtqueues(device_t dev, int flags, int nvqs, if (nvqs <= 0 || nvqs > VIRTIO_MAX_VIRTQUEUES) return (EINVAL); - if (flags & VIRTIO_ALLOC_VQS_DISABLE_MSIX) - sc->vtpci_flags |= VTPCI_FLAG_NO_MSIX; - for (idx = 0; idx < nvqs; idx++) { vqx = &sc->vtpci_vqx[idx]; info = &vq_info[idx]; diff --git a/sys/dev/virtio/scsi/virtio_scsi.c b/sys/dev/virtio/scsi/virtio_scsi.c index d471937aaf8f..64aa62d84321 100644 --- a/sys/dev/virtio/scsi/virtio_scsi.c +++ b/sys/dev/virtio/scsi/virtio_scsi.c @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2012, Bryan Venteicher + * Copyright (c) 2012, Bryan Venteicher * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/dev/virtio/scsi/virtio_scsivar.h b/sys/dev/virtio/scsi/virtio_scsivar.h index ca53f2110a30..f30f66751b81 100644 --- a/sys/dev/virtio/scsi/virtio_scsivar.h +++ b/sys/dev/virtio/scsi/virtio_scsivar.h @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2012, Bryan Venteicher + * Copyright (c) 2012, Bryan Venteicher * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/dev/virtio/virtio.c b/sys/dev/virtio/virtio.c index 6c6b0bc056ab..ea2b91acda68 100644 --- a/sys/dev/virtio/virtio.c +++ b/sys/dev/virtio/virtio.c @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2011, Bryan Venteicher + * Copyright (c) 2011, Bryan Venteicher * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -36,7 +36,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include #include #include @@ -49,8 +48,8 @@ static int virtio_modevent(module_t, int, void *); static const char *virtio_feature_name(uint64_t, struct virtio_feature_desc *); static struct virtio_ident { - uint16_t devid; - char *name; + uint16_t devid; + const char *name; } virtio_ident_table[] = { { VIRTIO_ID_NETWORK, "Network" }, { VIRTIO_ID_BLOCK, "Block" }, @@ -87,9 +86,29 @@ virtio_device_name(uint16_t devid) return (NULL); } +static const char * +virtio_feature_name(uint64_t val, struct virtio_feature_desc *desc) +{ + int i, j; + struct virtio_feature_desc *descs[2] = { desc, + virtio_common_feature_desc }; + + for (i = 0; i < 2; i++) { + if (descs[i] == NULL) + continue; + + for (j = 0; descs[i][j].vfd_val != 0; j++) { + if (val == descs[i][j].vfd_val) + return (descs[i][j].vfd_str); + } + } + + return (NULL); +} + void virtio_describe(device_t dev, const char *msg, - uint64_t features, struct virtio_feature_desc *feature_desc) + uint64_t features, struct virtio_feature_desc *desc) { struct sbuf sb; uint64_t val; @@ -98,13 +117,12 @@ virtio_describe(device_t dev, const char *msg, int n; if ((buf = malloc(512, M_TEMP, M_NOWAIT)) == NULL) { - device_printf(dev, "%s features: 0x%"PRIx64"\n", msg, - features); + device_printf(dev, "%s features: %#jx\n", msg, (uintmax_t) features); return; } sbuf_new(&sb, buf, 512, SBUF_FIXEDLEN); - sbuf_printf(&sb, "%s features: 0x%"PRIx64, msg, features); + sbuf_printf(&sb, "%s features: %#jx", msg, (uintmax_t) features); for (n = 0, val = 1ULL << 63; val != 0; val >>= 1) { /* @@ -119,15 +137,9 @@ virtio_describe(device_t dev, const char *msg, else sbuf_cat(&sb, ","); - name = NULL; - if (feature_desc != NULL) - name = virtio_feature_name(val, feature_desc); + name = virtio_feature_name(val, desc); if (name == NULL) - name = virtio_feature_name(val, - virtio_common_feature_desc); - - if (name == NULL) - sbuf_printf(&sb, "0x%"PRIx64, val); + sbuf_printf(&sb, "%#jx", (uintmax_t) val); else sbuf_cat(&sb, name); } @@ -147,18 +159,6 @@ virtio_describe(device_t dev, const char *msg, free(buf, M_TEMP); } -static const char * -virtio_feature_name(uint64_t val, struct virtio_feature_desc *feature_desc) -{ - int i; - - for (i = 0; feature_desc[i].vfd_val != 0; i++) - if (val == feature_desc[i].vfd_val) - return (feature_desc[i].vfd_str); - - return (NULL); -} - /* * VirtIO bus method wrappers. */ @@ -251,13 +251,12 @@ virtio_modevent(module_t mod, int type, void *unused) { int error; - error = 0; - switch (type) { case MOD_LOAD: case MOD_QUIESCE: case MOD_UNLOAD: case MOD_SHUTDOWN: + error = 0; break; default: error = EOPNOTSUPP; diff --git a/sys/dev/virtio/virtio.h b/sys/dev/virtio/virtio.h index 4d069dd94cd3..e201640dca64 100644 --- a/sys/dev/virtio/virtio.h +++ b/sys/dev/virtio/virtio.h @@ -99,7 +99,7 @@ struct vq_alloc_info; struct virtio_feature_desc { uint64_t vfd_val; - char *vfd_str; + const char *vfd_str; }; const char *virtio_device_name(uint16_t devid); diff --git a/sys/dev/virtio/virtio_bus_if.m b/sys/dev/virtio/virtio_bus_if.m index ec2029de16ac..74341ffe3751 100644 --- a/sys/dev/virtio/virtio_bus_if.m +++ b/sys/dev/virtio/virtio_bus_if.m @@ -1,5 +1,5 @@ #- -# Copyright (c) 2011, Bryan Venteicher +# Copyright (c) 2011, Bryan Venteicher # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -50,9 +50,6 @@ METHOD int alloc_virtqueues { int nvqs; struct vq_alloc_info *info; }; -HEADER { -#define VIRTIO_ALLOC_VQS_DISABLE_MSIX 0x1 -}; METHOD int setup_intr { device_t dev; diff --git a/sys/dev/virtio/virtio_if.m b/sys/dev/virtio/virtio_if.m index 13b0660a058e..9a99d371f663 100644 --- a/sys/dev/virtio/virtio_if.m +++ b/sys/dev/virtio/virtio_if.m @@ -1,5 +1,5 @@ #- -# Copyright (c) 2011, Bryan Venteicher +# Copyright (c) 2011, Bryan Venteicher # All rights reserved. # # Redistribution and use in source and binary forms, with or without diff --git a/sys/dev/virtio/virtqueue.c b/sys/dev/virtio/virtqueue.c index 275a92dc75b4..88ce57744831 100644 --- a/sys/dev/virtio/virtqueue.c +++ b/sys/dev/virtio/virtqueue.c @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2011, Bryan Venteicher + * Copyright (c) 2011, Bryan Venteicher * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/dev/virtio/virtqueue.h b/sys/dev/virtio/virtqueue.h index 80e52ff2dbd8..128a10a79e26 100644 --- a/sys/dev/virtio/virtqueue.h +++ b/sys/dev/virtio/virtqueue.h @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2011, Bryan Venteicher + * Copyright (c) 2011, Bryan Venteicher * All rights reserved. * * Redistribution and use in source and binary forms, with or without