diff options
author | Stefan Fritsch <sf@cvs.openbsd.org> | 2019-03-24 18:21:13 +0000 |
---|---|---|
committer | Stefan Fritsch <sf@cvs.openbsd.org> | 2019-03-24 18:21:13 +0000 |
commit | 3a694342e6b1a22d33c6e05c443fc6bb5c81c686 (patch) | |
tree | 416bd5f07024c473f59d51ebaa5e884b19c1025a /sys/dev/pv | |
parent | c372793d0df7d5ba3134e978e10ef5eb40f81925 (diff) |
virtio: Prepare for 64 feature bits
virtio 1.0 supports an arbitrary number of feature bits. However, so far
no more than 64 are used (compared to 32 in virtio 0.9). Adjust data
types to support 64 feature bits.
Later, we may want to use bitmaps and setbit(), ... to support even more
feature bits.
ok mlarkin@
Diffstat (limited to 'sys/dev/pv')
-rw-r--r-- | sys/dev/pv/if_vio.c | 42 | ||||
-rw-r--r-- | sys/dev/pv/vioblk.c | 4 | ||||
-rw-r--r-- | sys/dev/pv/vioblkreg.h | 20 | ||||
-rw-r--r-- | sys/dev/pv/viocon.c | 8 | ||||
-rw-r--r-- | sys/dev/pv/viomb.c | 6 | ||||
-rw-r--r-- | sys/dev/pv/vioscsireg.h | 6 | ||||
-rw-r--r-- | sys/dev/pv/virtio.c | 8 | ||||
-rw-r--r-- | sys/dev/pv/virtioreg.h | 12 | ||||
-rw-r--r-- | sys/dev/pv/virtiovar.h | 8 | ||||
-rw-r--r-- | sys/dev/pv/vmmci.c | 10 |
10 files changed, 62 insertions, 62 deletions
diff --git a/sys/dev/pv/if_vio.c b/sys/dev/pv/if_vio.c index c3f472e1ce0..a2ff1a81391 100644 --- a/sys/dev/pv/if_vio.c +++ b/sys/dev/pv/if_vio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_vio.c,v 1.8 2019/01/19 16:23:46 sf Exp $ */ +/* $OpenBSD: if_vio.c,v 1.9 2019/03/24 18:21:12 sf Exp $ */ /* * Copyright (c) 2012 Stefan Fritsch, Alexander Fiveg. @@ -68,25 +68,25 @@ #define VIRTIO_NET_CONFIG_STATUS 6 /* 16bit */ /* Feature bits */ -#define VIRTIO_NET_F_CSUM (1<<0) -#define VIRTIO_NET_F_GUEST_CSUM (1<<1) -#define VIRTIO_NET_F_MAC (1<<5) -#define VIRTIO_NET_F_GSO (1<<6) -#define VIRTIO_NET_F_GUEST_TSO4 (1<<7) -#define VIRTIO_NET_F_GUEST_TSO6 (1<<8) -#define VIRTIO_NET_F_GUEST_ECN (1<<9) -#define VIRTIO_NET_F_GUEST_UFO (1<<10) -#define VIRTIO_NET_F_HOST_TSO4 (1<<11) -#define VIRTIO_NET_F_HOST_TSO6 (1<<12) -#define VIRTIO_NET_F_HOST_ECN (1<<13) -#define VIRTIO_NET_F_HOST_UFO (1<<14) -#define VIRTIO_NET_F_MRG_RXBUF (1<<15) -#define VIRTIO_NET_F_STATUS (1<<16) -#define VIRTIO_NET_F_CTRL_VQ (1<<17) -#define VIRTIO_NET_F_CTRL_RX (1<<18) -#define VIRTIO_NET_F_CTRL_VLAN (1<<19) -#define VIRTIO_NET_F_CTRL_RX_EXTRA (1<<20) -#define VIRTIO_NET_F_GUEST_ANNOUNCE (1<<21) +#define VIRTIO_NET_F_CSUM (1ULL<<0) +#define VIRTIO_NET_F_GUEST_CSUM (1ULL<<1) +#define VIRTIO_NET_F_MAC (1ULL<<5) +#define VIRTIO_NET_F_GSO (1ULL<<6) +#define VIRTIO_NET_F_GUEST_TSO4 (1ULL<<7) +#define VIRTIO_NET_F_GUEST_TSO6 (1ULL<<8) +#define VIRTIO_NET_F_GUEST_ECN (1ULL<<9) +#define VIRTIO_NET_F_GUEST_UFO (1ULL<<10) +#define VIRTIO_NET_F_HOST_TSO4 (1ULL<<11) +#define VIRTIO_NET_F_HOST_TSO6 (1ULL<<12) +#define VIRTIO_NET_F_HOST_ECN (1ULL<<13) +#define VIRTIO_NET_F_HOST_UFO (1ULL<<14) +#define VIRTIO_NET_F_MRG_RXBUF (1ULL<<15) +#define VIRTIO_NET_F_STATUS (1ULL<<16) +#define VIRTIO_NET_F_CTRL_VQ (1ULL<<17) +#define VIRTIO_NET_F_CTRL_RX (1ULL<<18) +#define VIRTIO_NET_F_CTRL_VLAN (1ULL<<19) +#define VIRTIO_NET_F_CTRL_RX_EXTRA (1ULL<<20) +#define VIRTIO_NET_F_GUEST_ANNOUNCE (1ULL<<21) /* * Config(8) flags. The lowest byte is reserved for generic virtio stuff. @@ -507,7 +507,7 @@ vio_attach(struct device *parent, struct device *self, void *aux) { struct vio_softc *sc = (struct vio_softc *)self; struct virtio_softc *vsc = (struct virtio_softc *)parent; - uint32_t features; + uint64_t features; int i; struct ifnet *ifp = &sc->sc_ac.ac_if; diff --git a/sys/dev/pv/vioblk.c b/sys/dev/pv/vioblk.c index 061043e8796..b3f820dc210 100644 --- a/sys/dev/pv/vioblk.c +++ b/sys/dev/pv/vioblk.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vioblk.c,v 1.10 2019/01/08 16:23:01 sf Exp $ */ +/* $OpenBSD: vioblk.c,v 1.11 2019/03/24 18:21:12 sf Exp $ */ /* * Copyright (c) 2012 Stefan Fritsch. @@ -168,7 +168,7 @@ vioblk_attach(struct device *parent, struct device *self, void *aux) struct vioblk_softc *sc = (struct vioblk_softc *)self; struct virtio_softc *vsc = (struct virtio_softc *)parent; struct scsibus_attach_args saa; - uint32_t features; + uint64_t features; int qsize; vsc->sc_vqs = &sc->sc_vq[0]; diff --git a/sys/dev/pv/vioblkreg.h b/sys/dev/pv/vioblkreg.h index 754f2bb9793..d78eaf97b21 100644 --- a/sys/dev/pv/vioblkreg.h +++ b/sys/dev/pv/vioblkreg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: vioblkreg.h,v 1.2 2017/03/26 21:43:31 mlarkin Exp $ */ +/* $OpenBSD: vioblkreg.h,v 1.3 2019/03/24 18:21:12 sf Exp $ */ /* * Copyright (c) 2012 Stefan Fritsch. @@ -40,15 +40,15 @@ #define VIRTIO_BLK_CONFIG_BLK_SIZE 20 /* 32bit */ /* Feature bits */ -#define VIRTIO_BLK_F_BARRIER (1<<0) -#define VIRTIO_BLK_F_SIZE_MAX (1<<1) -#define VIRTIO_BLK_F_SEG_MAX (1<<2) -#define VIRTIO_BLK_F_GEOMETRY (1<<4) -#define VIRTIO_BLK_F_RO (1<<5) -#define VIRTIO_BLK_F_BLK_SIZE (1<<6) -#define VIRTIO_BLK_F_SCSI (1<<7) -#define VIRTIO_BLK_F_FLUSH (1<<9) -#define VIRTIO_BLK_F_TOPOLOGY (1<<10) +#define VIRTIO_BLK_F_BARRIER (1ULL<<0) +#define VIRTIO_BLK_F_SIZE_MAX (1ULL<<1) +#define VIRTIO_BLK_F_SEG_MAX (1ULL<<2) +#define VIRTIO_BLK_F_GEOMETRY (1ULL<<4) +#define VIRTIO_BLK_F_RO (1ULL<<5) +#define VIRTIO_BLK_F_BLK_SIZE (1ULL<<6) +#define VIRTIO_BLK_F_SCSI (1ULL<<7) +#define VIRTIO_BLK_F_FLUSH (1ULL<<9) +#define VIRTIO_BLK_F_TOPOLOGY (1ULL<<10) /* Command */ #define VIRTIO_BLK_T_IN 0 diff --git a/sys/dev/pv/viocon.c b/sys/dev/pv/viocon.c index cdd547ac33c..12475f34bed 100644 --- a/sys/dev/pv/viocon.c +++ b/sys/dev/pv/viocon.c @@ -1,4 +1,4 @@ -/* $OpenBSD: viocon.c,v 1.5 2019/01/08 16:24:09 sf Exp $ */ +/* $OpenBSD: viocon.c,v 1.6 2019/03/24 18:21:12 sf Exp $ */ /* * Copyright (c) 2013-2015 Stefan Fritsch <sf@sfritsch.de> @@ -30,9 +30,9 @@ /* features */ -#define VIRTIO_CONSOLE_F_SIZE (1<<0) -#define VIRTIO_CONSOLE_F_MULTIPORT (1<<1) -#define VIRTIO_CONSOLE_F_EMERG_WRITE (1<<2) +#define VIRTIO_CONSOLE_F_SIZE (1ULL<<0) +#define VIRTIO_CONSOLE_F_MULTIPORT (1ULL<<1) +#define VIRTIO_CONSOLE_F_EMERG_WRITE (1ULL<<2) /* config space */ #define VIRTIO_CONSOLE_COLS 0 /* 16 bits */ diff --git a/sys/dev/pv/viomb.c b/sys/dev/pv/viomb.c index 0dbb812de25..d73b706533b 100644 --- a/sys/dev/pv/viomb.c +++ b/sys/dev/pv/viomb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: viomb.c,v 1.3 2019/01/19 16:21:00 sf Exp $ */ +/* $OpenBSD: viomb.c,v 1.4 2019/03/24 18:21:12 sf Exp $ */ /* $NetBSD: viomb.c,v 1.1 2011/10/30 12:12:21 hannken Exp $ */ /* @@ -68,8 +68,8 @@ #define VIRTIO_BALLOON_CONFIG_ACTUAL 4 /* 32bit */ /* Feature bits */ -#define VIRTIO_BALLOON_F_MUST_TELL_HOST (1<<0) -#define VIRTIO_BALLOON_F_STATS_VQ (1<<1) +#define VIRTIO_BALLOON_F_MUST_TELL_HOST (1ULL<<0) +#define VIRTIO_BALLOON_F_STATS_VQ (1ULL<<1) static const struct virtio_feature_name viomb_feature_names[] = { #if VIRTIO_DEBUG diff --git a/sys/dev/pv/vioscsireg.h b/sys/dev/pv/vioscsireg.h index 4034309cef5..f69b562ec96 100644 --- a/sys/dev/pv/vioscsireg.h +++ b/sys/dev/pv/vioscsireg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: vioscsireg.h,v 1.1 2017/01/21 11:22:57 reyk Exp $ */ +/* $OpenBSD: vioscsireg.h,v 1.2 2019/03/24 18:21:12 sf Exp $ */ /* * Copyright (c) 2013 Google Inc. * @@ -28,8 +28,8 @@ #define VIRTIO_SCSI_CONFIG_MAX_LUN 32 /* 32bit */ /* Feature bits */ -#define VIRTIO_SCSI_F_INOUT (1<<0) -#define VIRTIO_SCSI_F_HOTPLUG (1<<1) +#define VIRTIO_SCSI_F_INOUT (1ULL<<0) +#define VIRTIO_SCSI_F_HOTPLUG (1ULL<<1) /* Response status values */ #define VIRTIO_SCSI_S_OK 0 diff --git a/sys/dev/pv/virtio.c b/sys/dev/pv/virtio.c index 242789d0c70..27bca1a5506 100644 --- a/sys/dev/pv/virtio.c +++ b/sys/dev/pv/virtio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: virtio.c,v 1.14 2019/03/24 18:17:24 sf Exp $ */ +/* $OpenBSD: virtio.c,v 1.15 2019/03/24 18:21:12 sf Exp $ */ /* $NetBSD: virtio.c,v 1.3 2011/11/02 23:05:52 njoly Exp $ */ /* @@ -84,7 +84,7 @@ static const struct virtio_feature_name transport_feature_names[] = { }; void -virtio_log_features(uint32_t host, uint32_t neg, +virtio_log_features(uint64_t host, uint64_t neg, const struct virtio_feature_name *guest_feature_names) { const struct virtio_feature_name *namep; @@ -92,7 +92,7 @@ virtio_log_features(uint32_t host, uint32_t neg, char c; uint32_t bit; - for (i = 0; i < 32; i++) { + for (i = 0; i < 64; i++) { if (i == 30) { /* * VIRTIO_F_BAD_FEATURE is only used for @@ -103,7 +103,7 @@ virtio_log_features(uint32_t host, uint32_t neg, bit = 1 << i; if ((host&bit) == 0) continue; - namep = (i < 24) ? guest_feature_names : + namep = (i < 24 || i > 37) ? guest_feature_names : transport_feature_names; while (namep->bit && namep->bit != bit) namep++; diff --git a/sys/dev/pv/virtioreg.h b/sys/dev/pv/virtioreg.h index 2cc4af2b32d..acc43eaaafa 100644 --- a/sys/dev/pv/virtioreg.h +++ b/sys/dev/pv/virtioreg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: virtioreg.h,v 1.3 2019/01/10 18:22:17 sf Exp $ */ +/* $OpenBSD: virtioreg.h,v 1.4 2019/03/24 18:21:12 sf Exp $ */ /* $NetBSD: virtioreg.h,v 1.1 2011/10/30 12:12:21 hannken Exp $ */ /* @@ -83,11 +83,11 @@ #define PCI_PRODUCT_VIRTIO_VMMCI 65535 /* private id */ /* device-independent feature bits */ -#define VIRTIO_F_NOTIFY_ON_EMPTY (1<<24) -#define VIRTIO_F_RING_INDIRECT_DESC (1<<28) -#define VIRTIO_F_RING_EVENT_IDX (1<<29) -#define VIRTIO_F_BAD_FEATURE (1<<30) -#define VIRTIO_F_VERSION_1 (1<<32) +#define VIRTIO_F_NOTIFY_ON_EMPTY (1ULL<<24) +#define VIRTIO_F_RING_INDIRECT_DESC (1ULL<<28) +#define VIRTIO_F_RING_EVENT_IDX (1ULL<<29) +#define VIRTIO_F_BAD_FEATURE (1ULL<<30) +#define VIRTIO_F_VERSION_1 (1ULL<<32) /* device status bits */ #define VIRTIO_CONFIG_DEVICE_STATUS_RESET 0 diff --git a/sys/dev/pv/virtiovar.h b/sys/dev/pv/virtiovar.h index da1351b6ac3..0872fb02791 100644 --- a/sys/dev/pv/virtiovar.h +++ b/sys/dev/pv/virtiovar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: virtiovar.h,v 1.11 2019/03/24 18:17:24 sf Exp $ */ +/* $OpenBSD: virtiovar.h,v 1.12 2019/03/24 18:21:12 sf Exp $ */ /* $NetBSD: virtiovar.h,v 1.1 2011/10/30 12:12:21 hannken Exp $ */ /* @@ -151,7 +151,7 @@ struct virtio_ops { uint16_t (*read_queue_size)(struct virtio_softc *, uint16_t); void (*setup_queue)(struct virtio_softc *, struct virtqueue *, uint64_t); void (*set_status)(struct virtio_softc *, int); - uint32_t (*neg_features)(struct virtio_softc *, uint32_t, const struct virtio_feature_name *); + uint64_t (*neg_features)(struct virtio_softc *, uint64_t, const struct virtio_feature_name *); int (*poll_intr)(void *); }; @@ -164,7 +164,7 @@ struct virtio_softc { int sc_ipl; /* set by child */ - uint32_t sc_features; + uint64_t sc_features; int sc_indirect; int sc_nvqs; /* set by child */ @@ -224,7 +224,7 @@ int virtio_start_vq_intr(struct virtio_softc *, struct virtqueue *); const char *virtio_device_string(int); #if VIRTIO_DEBUG -void virtio_log_features(uint32_t, uint32_t, const struct virtio_feature_name *); +void virtio_log_features(uint64_t, uint64_t, const struct virtio_feature_name *); void virtio_vq_dump(struct virtqueue *vq); #endif int virtio_nused(struct virtqueue *vq); diff --git a/sys/dev/pv/vmmci.c b/sys/dev/pv/vmmci.c index ac44e542885..23c4930d7bc 100644 --- a/sys/dev/pv/vmmci.c +++ b/sys/dev/pv/vmmci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vmmci.c,v 1.3 2017/05/02 09:50:38 mlarkin Exp $ */ +/* $OpenBSD: vmmci.c,v 1.4 2019/03/24 18:21:12 sf Exp $ */ /* * Copyright (c) 2017 Reyk Floeter <reyk@openbsd.org> @@ -72,9 +72,9 @@ struct cfattach vmmci_ca = { #define VMMCI_CONFIG_TIME_USEC 12 /* Feature bits */ -#define VMMCI_F_TIMESYNC (1<<0) -#define VMMCI_F_ACK (1<<1) -#define VMMCI_F_SYNCRTC (1<<2) +#define VMMCI_F_TIMESYNC (1ULL<<0) +#define VMMCI_F_ACK (1ULL<<1) +#define VMMCI_F_SYNCRTC (1ULL<<2) struct cfdriver vmmci_cd = { NULL, "vmmci", DV_DULL @@ -94,7 +94,7 @@ vmmci_attach(struct device *parent, struct device *self, void *aux) { struct vmmci_softc *sc = (struct vmmci_softc *)self; struct virtio_softc *vsc = (struct virtio_softc *)parent; - uint32_t features; + uint64_t features; if (vsc->sc_child != NULL) panic("already attached to something else"); |