From owner-svn-src-head@freebsd.org Sun Jun 17 20:45:49 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 904F110095BD; Sun, 17 Jun 2018 20:45:49 +0000 (UTC) (envelope-from bryanv@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46DA37E621; Sun, 17 Jun 2018 20:45:49 +0000 (UTC) (envelope-from bryanv@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 283A61A71C; Sun, 17 Jun 2018 20:45:49 +0000 (UTC) (envelope-from bryanv@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w5HKjnMJ027226; Sun, 17 Jun 2018 20:45:49 GMT (envelope-from bryanv@FreeBSD.org) Received: (from bryanv@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w5HKjmE6027224; Sun, 17 Jun 2018 20:45:48 GMT (envelope-from bryanv@FreeBSD.org) Message-Id: <201806172045.w5HKjmE6027224@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bryanv set sender to bryanv@FreeBSD.org using -f From: Bryan Venteicher Date: Sun, 17 Jun 2018 20:45:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r335305 - head/sys/dev/virtio X-SVN-Group: head X-SVN-Commit-Author: bryanv X-SVN-Commit-Paths: head/sys/dev/virtio X-SVN-Commit-Revision: 335305 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 17 Jun 2018 20:45:49 -0000 Author: bryanv Date: Sun Jun 17 20:45:48 2018 New Revision: 335305 URL: https://svnweb.freebsd.org/changeset/base/335305 Log: Update VirtIO definitions from Linux virtio_config.h and virtio_ring.h headers Modified: head/sys/dev/virtio/virtio_config.h head/sys/dev/virtio/virtio_ring.h Modified: head/sys/dev/virtio/virtio_config.h ============================================================================== --- head/sys/dev/virtio/virtio_config.h Sun Jun 17 20:44:20 2018 (r335304) +++ head/sys/dev/virtio/virtio_config.h Sun Jun 17 20:45:48 2018 (r335305) @@ -33,35 +33,58 @@ /* Status byte for guest to report progress. */ #define VIRTIO_CONFIG_STATUS_RESET 0x00 +/* We have seen device and processed generic fields. */ #define VIRTIO_CONFIG_STATUS_ACK 0x01 -#define VIRTIO_CONFIG_STATUS_DRIVER 0x03 +/* We have found a driver for the device. */ +#define VIRTIO_CONFIG_STATUS_DRIVER 0x02 +/* Driver has used its parts of the config, and is happy. */ #define VIRTIO_CONFIG_STATUS_DRIVER_OK 0x04 +/* Driver has finished configuring features (modern only). */ +#define VIRTIO_CONFIG_S_FEATURES_OK 0x08 +/* Device entered invalid state, driver must reset it. */ +#define VIRTIO_CONFIG_S_NEEDS_RESET 0x40 +/* We've given up on this device. */ #define VIRTIO_CONFIG_STATUS_FAILED 0x80 /* * Generate interrupt when the virtqueue ring is * completely used, even if we've suppressed them. */ -#define VIRTIO_F_NOTIFY_ON_EMPTY (1 << 24) +#define VIRTIO_F_NOTIFY_ON_EMPTY (1UL << 24) +/* Can the device handle any descriptor layout? */ +#define VIRTIO_F_ANY_LAYOUT (1UL << 27) + /* Support for indirect buffer descriptors. */ -#define VIRTIO_RING_F_INDIRECT_DESC (1 << 28) +#define VIRTIO_RING_F_INDIRECT_DESC (1UL << 28) /* Support to suppress interrupt until specific index is reached. */ -#define VIRTIO_RING_F_EVENT_IDX (1 << 29) +#define VIRTIO_RING_F_EVENT_IDX (1UL << 29) /* * The guest should never negotiate this feature; it * is used to detect faulty drivers. */ -#define VIRTIO_F_BAD_FEATURE (1 << 30) +#define VIRTIO_F_BAD_FEATURE (1UL << 30) +/* v1.0 compliant. */ +#define VIRTIO_F_VERSION_1 (1ULL << 32) + /* - * Some VirtIO feature bits (currently bits 28 through 31) are + * If clear - device has the IOMMU bypass quirk feature. + * If set - use platform tools to detect the IOMMU. + * + * Note the reverse polarity (compared to most other features), + * this is for compatibility with legacy systems. + */ +#define VIRTIO_F_IOMMU_PLATFORM (1ULL << 33) + +/* + * Some VirtIO feature bits (currently bits 28 through 34) are * reserved for the transport being used (eg. virtio_ring), the * rest are per-device feature bits. */ #define VIRTIO_TRANSPORT_F_START 28 -#define VIRTIO_TRANSPORT_F_END 32 +#define VIRTIO_TRANSPORT_F_END 34 #endif /* _VIRTIO_CONFIG_H_ */ Modified: head/sys/dev/virtio/virtio_ring.h ============================================================================== --- head/sys/dev/virtio/virtio_ring.h Sun Jun 17 20:44:20 2018 (r335304) +++ head/sys/dev/virtio/virtio_ring.h Sun Jun 17 20:45:48 2018 (r335305) @@ -92,6 +92,13 @@ struct vring { struct vring_used *used; }; +/* Alignment requirements for vring elements. + * When using pre-virtio 1.0 layout, these fall out naturally. + */ +#define VRING_AVAIL_ALIGN_SIZE 2 +#define VRING_USED_ALIGN_SIZE 4 +#define VRING_DESC_ALIGN_SIZE 16 + /* The standard layout for the ring is a continuous chunk of memory which * looks like this. We assume num is a power of 2. *