From patchwork Wed Apr 6 12:40:18 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laszlo Ersek X-Patchwork-Id: 65173 Delivered-To: patch@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp1027641lbc; Wed, 6 Apr 2016 05:41:08 -0700 (PDT) X-Received: by 10.98.11.78 with SMTP id t75mr37585981pfi.72.1459946453937; Wed, 06 Apr 2016 05:40:53 -0700 (PDT) Return-Path: Received: from ml01.01.org (ml01.01.org. [198.145.21.10]) by mx.google.com with ESMTPS id f63si4424857pfj.137.2016.04.06.05.40.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 06 Apr 2016 05:40:53 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) client-ip=198.145.21.10; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id F03311A1FB2; Wed, 6 Apr 2016 05:40:50 -0700 (PDT) X-Original-To: edk2-devel@ml01.01.org Delivered-To: edk2-devel@ml01.01.org Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id CFE451A1FB2 for ; Wed, 6 Apr 2016 05:40:49 -0700 (PDT) Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6B89CED27A; Wed, 6 Apr 2016 12:40:49 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com ([10.3.113.15]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u36CeV8T027635; Wed, 6 Apr 2016 08:40:46 -0400 From: Laszlo Ersek To: edk2-devel-01 Date: Wed, 6 Apr 2016 14:40:18 +0200 Message-Id: <1459946427-15771-9-git-send-email-lersek@redhat.com> In-Reply-To: <1459946427-15771-1-git-send-email-lersek@redhat.com> References: <1459946427-15771-1-git-send-email-lersek@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 06 Apr 2016 12:40:49 +0000 (UTC) Subject: [edk2] [wave 3 PATCH v2 08/17] OvmfPkg: IndustryStandard: add definitions from the VirtIo 1.0 spec X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Jordan Justen , Ard Biesheuvel MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" These header files are intentionally minimal, and intentionally kept apart from the VirtIo 0.9.5 headers. The header inclusion chains end up like this (the Virtio10*.h header files in the middle are new): Virtio.h -> Virtio10.h -> Virtio095.h ^ ^ | | VirtioNet.h -> Virtio10Net.h -> Virtio095Net.h Cc: Ard Biesheuvel Cc: Jordan Justen Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Laszlo Ersek Tested-by: Ard Biesheuvel --- Notes: v2: - keep Ard's Tested-by - rebase on top of Virtio095.h and Virtio095Net.h [Jordan] - rename the "Legacy" field in VIRTIO_1_0_NET_REQ to "V0_9_5" [Jordan] (The original suggestion was V0_95; however that doesn't reflect the dots in the actual spec version string -- it is virtio-0.9.5, not virtio-0.95.) - I'm fine with an Acked-by for this, of course OvmfPkg/Include/IndustryStandard/Virtio.h | 2 +- OvmfPkg/Include/IndustryStandard/Virtio10.h | 81 ++++++++++++++++++++ OvmfPkg/Include/IndustryStandard/{VirtioNet.h => Virtio10Net.h} | 24 ++++-- OvmfPkg/Include/IndustryStandard/VirtioNet.h | 2 +- 4 files changed, 100 insertions(+), 9 deletions(-) -- 1.8.3.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/OvmfPkg/Include/IndustryStandard/Virtio.h b/OvmfPkg/Include/IndustryStandard/Virtio.h index e1682fc69a42..dddec388318e 100644 --- a/OvmfPkg/Include/IndustryStandard/Virtio.h +++ b/OvmfPkg/Include/IndustryStandard/Virtio.h @@ -15,10 +15,10 @@ WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. **/ #ifndef _VIRTIO_H_ #define _VIRTIO_H_ -#include +#include #endif // _VIRTIO_H_ diff --git a/OvmfPkg/Include/IndustryStandard/Virtio10.h b/OvmfPkg/Include/IndustryStandard/Virtio10.h new file mode 100644 index 000000000000..de692c1d1ee9 --- /dev/null +++ b/OvmfPkg/Include/IndustryStandard/Virtio10.h @@ -0,0 +1,81 @@ +/** @file + Definitions from the VirtIo 1.0 specification (csprd05). + + Copyright (C) 2016, Red Hat, Inc. + + This program and the accompanying materials are licensed and made available + under the terms and conditions of the BSD License which accompanies this + distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT + WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +**/ + +#ifndef _VIRTIO_1_0_H_ +#define _VIRTIO_1_0_H_ + +#include + +// +// Structures for parsing the VirtIo 1.0 specific PCI capabilities from the +// config space +// +#pragma pack (1) +typedef struct { + UINT8 CapId; // Capability identifier (generic) + UINT8 CapNext; // Link to next capability (generic) +} VIRTIO_PCI_CAP_LINK; + +typedef struct { + UINT8 ConfigType; // Identifies the specific VirtIo 1.0 config structure + UINT8 Bar; // The BAR that contains the structure + UINT8 Padding[3]; + UINT32 Offset; // Offset within Bar until the start of the structure + UINT32 Length; // Length of the structure +} VIRTIO_PCI_CAP; +#pragma pack () + +// +// Values for the VIRTIO_PCI_CAP.ConfigType field +// +#define VIRTIO_PCI_CAP_COMMON_CFG 1 // Common configuration +#define VIRTIO_PCI_CAP_NOTIFY_CFG 2 // Notifications +#define VIRTIO_PCI_CAP_DEVICE_CFG 4 // Device specific configuration + +// +// Structure pointed-to by Bar and Offset in VIRTIO_PCI_CAP when ConfigType is +// VIRTIO_PCI_CAP_COMMON_CFG +// +#pragma pack (1) +typedef struct { + UINT32 DeviceFeatureSelect; + UINT32 DeviceFeature; + UINT32 DriverFeatureSelect; + UINT32 DriverFeature; + UINT16 MsixConfig; + UINT16 NumQueues; + UINT8 DeviceStatus; + UINT8 ConfigGeneration; + UINT16 QueueSelect; + UINT16 QueueSize; + UINT16 QueueMsixVector; + UINT16 QueueEnable; + UINT16 QueueNotifyOff; + UINT64 QueueDesc; + UINT64 QueueAvail; + UINT64 QueueUsed; +} VIRTIO_PCI_COMMON_CFG; +#pragma pack () + +// +// VirtIo 1.0 device status bits +// +#define VSTAT_FEATURES_OK BIT3 + +// +// VirtIo 1.0 reserved (device-independent) feature bits +// +#define VIRTIO_F_VERSION_1 BIT32 + +#endif // _VIRTIO_1_0_H_ diff --git a/OvmfPkg/Include/IndustryStandard/VirtioNet.h b/OvmfPkg/Include/IndustryStandard/Virtio10Net.h similarity index 51% copy from OvmfPkg/Include/IndustryStandard/VirtioNet.h copy to OvmfPkg/Include/IndustryStandard/Virtio10Net.h index db4882abaef3..cfd25fc4148d 100644 --- a/OvmfPkg/Include/IndustryStandard/VirtioNet.h +++ b/OvmfPkg/Include/IndustryStandard/Virtio10Net.h @@ -1,22 +1,32 @@ /** @file - Virtio Network Device specific type and macro definitions corresponding to - the virtio specifications. + Definitions from the VirtIo 1.0 specification (csprd05), specifically for the + network device. - Copyright (C) 2013-2016, Red Hat, Inc. + Copyright (C) 2016, Red Hat, Inc. This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - **/ -#ifndef _VIRTIO_NET_H_ -#define _VIRTIO_NET_H_ +#ifndef _VIRTIO_1_0_NET_H_ +#define _VIRTIO_1_0_NET_H_ +#include #include -#endif // _VIRTIO_NET_H_ +// +// VirtIo 1.0 packet header +// +#pragma pack (1) +typedef struct { + VIRTIO_NET_REQ V0_9_5; + UINT16 NumBuffers; +} VIRTIO_1_0_NET_REQ; +#pragma pack () + +#endif // _VIRTIO_1_0_NET_H_ diff --git a/OvmfPkg/Include/IndustryStandard/VirtioNet.h b/OvmfPkg/Include/IndustryStandard/VirtioNet.h index db4882abaef3..9b0bfdc585d0 100644 --- a/OvmfPkg/Include/IndustryStandard/VirtioNet.h +++ b/OvmfPkg/Include/IndustryStandard/VirtioNet.h @@ -13,10 +13,10 @@ WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. **/ #ifndef _VIRTIO_NET_H_ #define _VIRTIO_NET_H_ -#include +#include #endif // _VIRTIO_NET_H_