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. --- sys/dev/fdt/virtio_mmio.c | 8 ++++---- sys/dev/pci/virtio_pci.c | 8 ++++---- sys/dev/pv/if_vio.c | 40 +++++++++++++++++++-------------------- sys/dev/pv/vioblk.c | 2 +- sys/dev/pv/vioblkreg.h | 18 +++++++++--------- sys/dev/pv/viocon.c | 6 +++--- sys/dev/pv/viomb.c | 4 ++-- sys/dev/pv/vioscsireg.h | 4 ++-- sys/dev/pv/virtio.c | 6 +++--- sys/dev/pv/virtioreg.h | 10 +++++----- sys/dev/pv/virtiovar.h | 6 +++--- sys/dev/pv/vmmci.c | 8 ++++---- 12 files changed, 60 insertions(+), 60 deletions(-) diff --git a/sys/dev/fdt/virtio_mmio.c b/sys/dev/fdt/virtio_mmio.c index 3a74e647c19..2d7a131125d 100644 --- a/sys/dev/fdt/virtio_mmio.c +++ b/sys/dev/fdt/virtio_mmio.c @@ -91,7 +91,7 @@ void virtio_mmio_write_device_config_8(struct virtio_softc *, int, uint64_t); uint16_t virtio_mmio_read_queue_size(struct virtio_softc *, uint16_t); void virtio_mmio_setup_queue(struct virtio_softc *, struct virtqueue *, uint64_t); void virtio_mmio_set_status(struct virtio_softc *, int); -uint32_t virtio_mmio_negotiate_features(struct virtio_softc *, uint32_t, +uint64_t virtio_mmio_negotiate_features(struct virtio_softc *, uint64_t, const struct virtio_feature_name *); int virtio_mmio_intr(void *); @@ -300,12 +300,12 @@ virtio_mmio_detach(struct device *self, int flags) * Prints available / negotiated features if guest_feature_names != NULL and * VIRTIO_DEBUG is 1 */ -uint32_t -virtio_mmio_negotiate_features(struct virtio_softc *vsc, uint32_t guest_features, +uint64_t +virtio_mmio_negotiate_features(struct virtio_softc *vsc, uint64_t guest_features, const struct virtio_feature_name *guest_feature_names) { struct virtio_mmio_softc *sc = (struct virtio_mmio_softc *)vsc; - uint32_t host, neg; + uint64_t host, neg; /* * indirect descriptors can be switched off by setting bit 1 in the diff --git a/sys/dev/pci/virtio_pci.c b/sys/dev/pci/virtio_pci.c index d1ab7481df6..97e5607a55e 100644 --- a/sys/dev/pci/virtio_pci.c +++ b/sys/dev/pci/virtio_pci.c @@ -66,7 +66,7 @@ void virtio_pci_write_device_config_8(struct virtio_softc *, int, uint64_t); uint16_t virtio_pci_read_queue_size(struct virtio_softc *, uint16_t); void virtio_pci_setup_queue(struct virtio_softc *, struct virtqueue *, uint64_t); void virtio_pci_set_status(struct virtio_softc *, int); -uint32_t virtio_pci_negotiate_features(struct virtio_softc *, uint32_t, +uint64_t virtio_pci_negotiate_features(struct virtio_softc *, uint64_t, const struct virtio_feature_name *); int virtio_pci_msix_establish(struct virtio_pci_softc *, struct pci_attach_args *, int, int (*)(void *), void *); int virtio_pci_setup_msix(struct virtio_pci_softc *, struct pci_attach_args *, int); @@ -317,12 +317,12 @@ virtio_pci_detach(struct device *self, int flags) * Prints available / negotiated features if guest_feature_names != NULL and * VIRTIO_DEBUG is 1 */ -uint32_t -virtio_pci_negotiate_features(struct virtio_softc *vsc, uint32_t guest_features, +uint64_t +virtio_pci_negotiate_features(struct virtio_softc *vsc, uint64_t guest_features, const struct virtio_feature_name *guest_feature_names) { struct virtio_pci_softc *sc = (struct virtio_pci_softc *)vsc; - uint32_t host, neg; + uint64_t host, neg; /* * indirect descriptors can be switched off by setting bit 1 in the diff --git a/sys/dev/pv/if_vio.c b/sys/dev/pv/if_vio.c index d79935ca512..a4cd80af62d 100644 --- a/sys/dev/pv/if_vio.c +++ b/sys/dev/pv/if_vio.c @@ -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..fc46e52c09c 100644 --- a/sys/dev/pv/vioblk.c +++ b/sys/dev/pv/vioblk.c @@ -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..dbfa37e60ea 100644 --- a/sys/dev/pv/vioblkreg.h +++ b/sys/dev/pv/vioblkreg.h @@ -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..ed73152bbdd 100644 --- a/sys/dev/pv/viocon.c +++ b/sys/dev/pv/viocon.c @@ -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 1c380358827..3be83eed562 100644 --- a/sys/dev/pv/viomb.c +++ b/sys/dev/pv/viomb.c @@ -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..4f2a1f57b36 100644 --- a/sys/dev/pv/vioscsireg.h +++ b/sys/dev/pv/vioscsireg.h @@ -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 be81878642f..18b78927180 100644 --- a/sys/dev/pv/virtio.c +++ b/sys/dev/pv/virtio.c @@ -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..36a505d2a48 100644 --- a/sys/dev/pv/virtioreg.h +++ b/sys/dev/pv/virtioreg.h @@ -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 595c89b9a5d..4a52907a4a5 100644 --- a/sys/dev/pv/virtiovar.h +++ b/sys/dev/pv/virtiovar.h @@ -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..80ba1224e3b 100644 --- a/sys/dev/pv/vmmci.c +++ b/sys/dev/pv/vmmci.c @@ -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"); -- 2.19.0