VirtualBox

source: vbox/trunk/src/VBox/Devices/VirtIO/Virtio_1_0.h@ 81653

Last change on this file since 81653 was 81653, checked in by vboxsync, 5 years ago

Virtio_1_0: Very superficial code review (style mostly), preparing for some refactoring. bugref:9218 bugref:9440

  • Eliminated Virtio_1_0_impl.h.
  • Function documentation should be placed with implementation rather than the prototype. The only exception to this is when there are multiple implementations of the same function.
  • Don't use '-' with @param or @return.
  • If you want to document specific return values use '@retval value description'.
  • I also prefer a function description starting with a single sentence giving a brief description of the function. Details can follow in separate paragraphs below that (empty line after brief). (Doxygen is configured to do this automatically in the output, but it make the source code much easier to read when doing it there too.)
  • Use @note or @remark instead of "NOTE: xxxxxx" and similar in doxygen comments.
  • I don't like using the 'p' prefix for physical addresses, so s/pGcPhys/GCPhys/.
  • DRIVER_OK is a predicate macro and should include a verb: IS_DRIVER_OK
  • VIRTQ_USED_T::auRing needs to drop the 'u' as it's a struct not an unsigned integer (probably copy & paste).
  • VIRTQ_AVAIL_T::auRing and VIRTQ_USED_T::aRing both seems to be variable length arrays, yet they have members after them. This is cool for documentation purposes, but compilers might do weird stuff if not careful. I'd much prefer having a comment with the trailing member(s) after a variable sized member, then use RT_FLEXIBLE_ARRAY for the array size.
  • 'idx' is a valid prefix, so 'uIdx' could be written just 'idx' (VIRTQ_USED_T, VIRTQ_AVAIL_T).
  • MATCH_COMMON_CFG, ..., COMMON_CFG_ACCESSOR_INDEXED_READONLY are picking up loads of locals from virtioCommonCfgAccessed and should restricted to the scope of that function.
  • LogRel in virtioQueueGet: only ever split log strings on newlines, makes grepping for them a lot easier.
  • Dropping 'const' from VIRTQSTATE::szVirtqName to avoid unnecessary casts.
  • ++
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 24.8 KB
Line 
1/* $Id: Virtio_1_0.h 81653 2019-11-04 13:46:33Z vboxsync $ */
2/** @file
3 * Virtio_1_0.h - Virtio Declarations
4 */
5
6/*
7 * Copyright (C) 2009-2019 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18#ifndef VBOX_INCLUDED_SRC_VirtIO_Virtio_1_0_h
19#define VBOX_INCLUDED_SRC_VirtIO_Virtio_1_0_h
20#ifndef RT_WITHOUT_PRAGMA_ONCE
21# pragma once
22#endif
23
24#include <iprt/ctype.h>
25#include <iprt/sg.h>
26
27typedef void * VIRTIOHANDLE; /**< Opaque handle to the VirtIO framework */
28
29
30/**
31 * Important sizing and bounds params for this impl. of VirtIO 1.0 PCI device
32 */
33 /**
34 * TEMPORARY NOTE: Some of these values are experimental during development and will likely change.
35 */
36#define VIRTIO_MAX_QUEUE_NAME_SIZE 32 /**< Maximum length of a queue name */
37#define VIRTQ_MAX_SIZE 1024 /**< Max size (# desc elements) of a virtq */
38#define VIRTQ_MAX_CNT 24 /**< Max queues we allow guest to create */
39#define VIRTIO_NOTIFY_OFFSET_MULTIPLIER 2 /**< VirtIO Notify Cap. MMIO config param */
40#define VIRTIO_REGION_PCI_CAP 2 /**< BAR for VirtIO Cap. MMIO (impl specific) */
41#define VIRTIO_REGION_MSIX_CAP 0 /**< Bar for MSI-X handling */
42
43#define VIRTIO_HEX_DUMP(logLevel, pv, cb, base, title) \
44 do { \
45 if (LogIsItEnabled(logLevel, LOG_GROUP)) \
46 virtioHexDump((pv), (cb), (base), (title)); \
47 } while (0)
48
49
50/**
51 * The following structure holds the pre-processed context of descriptor chain pulled from a virtio queue
52 * to conduct a transaction between the client of this virtio implementation and the guest VM's virtio driver.
53 * It contains the head index of the descriptor chain, the output data from the client that has been
54 * converted to a contiguous virtual memory and a physical memory scatter-gather buffer for use by by
55 * the virtio framework to complete the transaction in the final phase of round-trip processing.
56 *
57 * The client should not modify the contents of this buffer. The primary field of interest to the
58 * client is pVirtSrc, which contains the VirtIO "OUT" (to device) buffer from the guest.
59 *
60 * Typical use is, When the client (worker thread) detects available data on the queue, it pulls the
61 * next one of these descriptor chain structs off the queue using virtioQueueGet(), processes the
62 * virtual memory buffer pVirtSrc, produces result data to pass back to the guest driver and calls
63 * virtioQueuePut() to return the result data to the client.
64 */
65typedef struct VIRTIO_DESC_CHAIN
66{
67 uint32_t uHeadIdx; /**< Head idx of associated desc chain */
68 uint32_t cbPhysSend; /**< Total size of src buffer */
69 PRTSGBUF pSgPhysSend; /**< Phys S/G/ buf for data from guest */
70 uint32_t cbPhysReturn; /**< Total size of dst buffer */
71 PRTSGBUF pSgPhysReturn; /**< Phys S/G buf to store result for guest */
72} VIRTIO_DESC_CHAIN_T, *PVIRTIO_DESC_CHAIN_T, **PPVIRTIO_DESC_CHAIN_T;
73
74/**
75 * The following structure is used to pass the PCI parameters from the consumer
76 * to this generic VirtIO framework. This framework provides the Vendor ID as Virtio.
77 */
78typedef struct VIRTIOPCIPARAMS
79{
80 uint16_t uDeviceId; /**< PCI Cfg Device ID */
81 uint16_t uClassBase; /**< PCI Cfg Base Class */
82 uint16_t uClassSub; /**< PCI Cfg Subclass */
83 uint16_t uClassProg; /**< PCI Cfg Programming Interface Class */
84 uint16_t uSubsystemId; /**< PCI Cfg Card Manufacturer Vendor ID */
85 uint16_t uSubsystemVendorId; /**< PCI Cfg Chipset Manufacturer Vendor ID */
86 uint16_t uRevisionId; /**< PCI Cfg Revision ID */
87 uint16_t uInterruptLine; /**< PCI Cfg Interrupt line */
88 uint16_t uInterruptPin; /**< PCI Cfg Interrupt pin */
89} VIRTIOPCIPARAMS, *PVIRTIOPCIPARAMS;
90
91/**
92 * Implementation-specific client callback to notify client of significant device status
93 * changes.
94 *
95 * @param hVirtio Handle to VirtIO framework
96 * @param fDriverOk True if guest driver is okay (thus queues, etc... are valid)
97 * @param pClient Pointer to opaque client data (state)
98 */
99typedef DECLCALLBACK(void) FNVIRTIOSTATUSCHANGED(VIRTIOHANDLE hVirtio, void *pClient, uint32_t fDriverOk);
100typedef FNVIRTIOSTATUSCHANGED *PFNVIRTIOSTATUSCHANGED;
101
102/**
103 * When guest-to-host queue notifications are enabled, the guest driver notifies the host
104 * that the avail queue has buffers, and this callback informs the client.
105 *
106 * @param hVirtio Handle to the VirtIO framework
107 * @param qIdx Index of the notified queue
108 * @param pClient Pointer to opaque client data (state)
109 */
110typedef DECLCALLBACK(void) FNVIRTIOQUEUENOTIFIED(VIRTIOHANDLE hVirtio, void *pClient, uint16_t qIdx);
111typedef FNVIRTIOQUEUENOTIFIED *PFNVIRTIOQUEUENOTIFIED;
112
113 /**
114 * Implementation-specific client callback to access VirtIO Device-specific capabilities
115 * (other VirtIO capabilities and features are handled in VirtIO implementation)
116 *
117 * @param pDevIns The device instance.
118 * @param offset Offset within device specific capabilities struct
119 * @param pvBuf Buffer in which to save read data
120 * @param cbWrite Number of bytes to write
121 */
122typedef DECLCALLBACK(int) FNVIRTIODEVCAPWRITE(PPDMDEVINS pDevIns, uint32_t uOffset, const void *pvBuf, uint32_t cbWrite);
123typedef FNVIRTIODEVCAPWRITE *PFNVIRTIODEVCAPWRITE;
124
125/**
126 * Implementation-specific client ballback to access VirtIO Device-specific capabilities
127 * (other VirtIO capabilities and features are handled in VirtIO implementation)
128 *
129 * @param pDevIns The device instance.
130 * @param offset Offset within device specific capabilities struct
131 * @param pvBuf Buffer in which to save read data
132 * @param cbRead Number of bytes to read
133 */
134typedef DECLCALLBACK(int) FNVIRTIODEVCAPREAD(PPDMDEVINS pDevIns, uint32_t uOffset, void *pvBuf, uint32_t cbRead);
135typedef FNVIRTIODEVCAPREAD *PFNVIRTIODEVCAPREAD;
136
137
138/** @name VirtIO port I/O callbacks.
139 * @{ */
140typedef struct VIRTIOCALLBACKS
141{
142 DECLCALLBACKMEMBER(void, pfnVirtioStatusChanged)(VIRTIOHANDLE hVirtio, void *pClient, uint32_t fDriverOk);
143 DECLCALLBACKMEMBER(void, pfnVirtioQueueNotified)(VIRTIOHANDLE hVirtio, void *pClient, uint16_t qIdx);
144 DECLCALLBACKMEMBER(int, pfnVirtioDevCapRead)(PPDMDEVINS pDevIns, uint32_t uOffset, void *pvBuf, uint32_t cbRead);
145 DECLCALLBACKMEMBER(int, pfnVirtioDevCapWrite)(PPDMDEVINS pDevIns, uint32_t uOffset, const void *pvBuf, uint32_t cbWrite);
146 DECLCALLBACKMEMBER(int, pfnSSMDevLiveExec)(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uPass);
147 DECLCALLBACKMEMBER(int, pfnSSMDevSaveExec)(PPDMDEVINS pDevIns, PSSMHANDLE pSSM);
148 DECLCALLBACKMEMBER(int, pfnSSMDevLoadExec)(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass);
149 DECLCALLBACKMEMBER(int, pfnSSMDevLoadDone)(PPDMDEVINS pDevIns, PSSMHANDLE pSSM);
150} VIRTIOCALLBACKS, *PVIRTIOCALLBACKS;
151/** @} */
152
153/** API for VirtIO client */
154
155int virtioQueueAttach(VIRTIOHANDLE hVirtio, uint16_t qIdx, const char *pcszName);
156
157/**
158 * Detaches from queue and release resources
159 *
160 * @param hVirtio Handle for VirtIO framework
161 * @param qIdx Queue number
162 */
163int virtioQueueDetach(VIRTIOHANDLE hVirtio, uint16_t qIdx);
164
165int virtioQueueGet(VIRTIOHANDLE hVirtio, uint16_t qIdx, PPVIRTIO_DESC_CHAIN_T ppDescChain, bool fRemove);
166
167int virtioQueuePut(VIRTIOHANDLE hVirtio, uint16_t qIdx, PRTSGBUF pSgVirtReturn,
168 PVIRTIO_DESC_CHAIN_T pDescChain, bool fFence);
169
170
171int virtioQueueSync(VIRTIOHANDLE hVirtio, uint16_t qIdx);
172
173bool virtioQueueIsEmpty(VIRTIOHANDLE hVirtio, uint16_t qIdx);
174
175bool virtioIsQueueEnabled(VIRTIOHANDLE hVirtio, uint16_t qIdx);
176
177void virtioQueueEnable(VIRTIOHANDLE hVirtio, uint16_t qIdx, bool fEnabled);
178
179/**
180 * Request orderly teardown of VirtIO on host and guest
181 * @param hVirtio Handle for VirtIO framework
182 *
183 */
184void virtioResetAll(VIRTIOHANDLE hVirtio);
185
186void virtioPropagateResumeNotification(VIRTIOHANDLE hVirtio);
187
188const char *virtioQueueGetName(VIRTIOHANDLE hVirtio, uint16_t qIdx);
189
190uint64_t virtioGetNegotiatedFeatures(VIRTIOHANDLE hVirtio);
191
192/**
193 * Constructor sets up the PCI device controller and VirtIO state
194 *
195 * @param pDevIns Device instance data
196 * @param pClientContext Opaque client context (such as state struct)
197 * @param pVirtio Device State
198 * @param pPciParams Values to populate industry standard PCI Configuration Space data structure
199 * @param pcszInstance Device instance name
200 * @param uDevSpecificFeatures VirtIO device-specific features offered by client
201 * @param devCapReadCallback Client handler to call upon guest read to device specific capabilities.
202 * @param devCapWriteCallback Client handler to call upon guest write to device specific capabilities.
203 * @param devStatusChangedCallback Client handler to call for major device status changes
204 * @param queueNotifiedCallback Client handler for guest-to-host notifications that avail queue has ring data
205 * @param ssmLiveExecCallback Client handler for SSM live exec
206 * @param ssmSaveExecCallback Client handler for SSM save exec
207 * @param ssmLoadExecCallback Client handler for SSM load exec
208 * @param ssmLoadDoneCallback Client handler for SSM load done
209 * @param cbDevSpecificCfg Size of virtio_pci_device_cap device-specific configuration struct
210 * @param pDevSpecificCfg Address of client's VirtIO dev-specific configuration struct
211 */
212int virtioConstruct(PPDMDEVINS pDevIns,
213 void *pClientContext,
214 VIRTIOHANDLE *phVirtio,
215 PVIRTIOPCIPARAMS pPciParams,
216 const char *pcszInstance,
217 uint64_t uDevSpecificFeatures,
218 PFNVIRTIODEVCAPREAD devCapReadCallback,
219 PFNVIRTIODEVCAPWRITE devCapWriteCallback,
220 PFNVIRTIOSTATUSCHANGED devStatusChangedCallback,
221 PFNVIRTIOQUEUENOTIFIED queueNotifiedCallback,
222 PFNSSMDEVLIVEEXEC ssmLiveExecCallback,
223 PFNSSMDEVSAVEEXEC ssmSaveExecCallback,
224 PFNSSMDEVLOADEXEC ssmLoadExecCallback,
225 PFNSSMDEVLOADDONE ssmLoadDoneCallback,
226 uint16_t cbDevSpecificCfg,
227 void *pDevSpecificCfg);
228
229void virtioLogMappedIoValue(const char *pszFunc, const char *pszMember, uint32_t uMemberSize,
230 const void *pv, uint32_t cb, uint32_t uOffset,
231 int fWrite, int fHasIndex, uint32_t idx);
232void virtioHexDump(uint8_t *pv, uint32_t cb, uint32_t uBase, const char *pszTitle);
233
234
235/** @name Saved state versions.
236 * The saved state version is changed if either common or any of specific
237 * parts are changed. That is, it is perfectly possible that the version
238 * of saved vnet state will increase as a result of change in vblk structure
239 * for example.
240 *
241 * @todo r=bird: I'd like to have each device register their own SSM state and
242 * make calls into virtio for it to save itself, saving/loading its own
243 * internal version number rather than getting it from SSM.
244 */
245#define VIRTIO_SAVEDSTATE_VERSION 1
246/** @} */
247
248#define VIRTIO_F_VERSION_1 RT_BIT_64(32) /**< Required feature bit for 1.0 devices */
249
250#define VIRTIO_F_INDIRECT_DESC RT_BIT_64(28) /**< Allow descs to point to list of descs */
251#define VIRTIO_F_EVENT_IDX RT_BIT_64(29) /**< Allow notification disable for n elems */
252#define VIRTIO_F_RING_INDIRECT_DESC RT_BIT_64(28) /**< Doc bug: Goes under two names in spec */
253#define VIRTIO_F_RING_EVENT_IDX RT_BIT_64(29) /**< Doc bug: Goes under two names in spec */
254
255#define VIRTIO_DEV_INDEPENDENT_FEATURES_OFFERED ( 0 ) /**< TBD: Add VIRTIO_F_INDIRECT_DESC */
256
257#define VIRTIO_ISR_VIRTQ_INTERRUPT RT_BIT_32(0) /**< Virtq interrupt bit of ISR register */
258#define VIRTIO_ISR_DEVICE_CONFIG RT_BIT_32(1) /**< Device configuration changed bit of ISR */
259#define DEVICE_PCI_VENDOR_ID_VIRTIO 0x1AF4 /**< Guest driver locates dev via (mandatory) */
260#define DEVICE_PCI_REVISION_ID_VIRTIO 1 /**< VirtIO 1.0 non-transitional drivers >= 1 */
261
262/** Reserved (*negotiated*) Feature Bits (e.g. device independent features, VirtIO 1.0 spec,section 6) */
263
264#define VIRTIO_MSI_NO_VECTOR 0xffff /**< Vector value to disable MSI for queue */
265
266/** Device Status field constants (from Virtio 1.0 spec) */
267#define VIRTIO_STATUS_ACKNOWLEDGE 0x01 /**< Guest driver: Located this VirtIO device */
268#define VIRTIO_STATUS_DRIVER 0x02 /**< Guest driver: Can drive this VirtIO dev. */
269#define VIRTIO_STATUS_DRIVER_OK 0x04 /**< Guest driver: Driver set-up and ready */
270#define VIRTIO_STATUS_FEATURES_OK 0x08 /**< Guest driver: Feature negotiation done */
271#define VIRTIO_STATUS_FAILED 0x80 /**< Guest driver: Fatal error, gave up */
272#define VIRTIO_STATUS_DEVICE_NEEDS_RESET 0x40 /**< Device experienced unrecoverable error */
273
274/** @def Virtio Device PCI Capabilities type codes */
275#define VIRTIO_PCI_CAP_COMMON_CFG 1 /**< Common configuration PCI capability ID */
276#define VIRTIO_PCI_CAP_NOTIFY_CFG 2 /**< Notification area PCI capability ID */
277#define VIRTIO_PCI_CAP_ISR_CFG 3 /**< ISR PCI capability id */
278#define VIRTIO_PCI_CAP_DEVICE_CFG 4 /**< Device-specific PCI cfg capability ID */
279#define VIRTIO_PCI_CAP_PCI_CFG 5 /**< PCI CFG capability ID */
280
281#define VIRTIO_PCI_CAP_ID_VENDOR 0x09 /**< Vendor-specific PCI CFG Device Cap. ID */
282
283/**
284 * The following is the PCI capability struct common to all VirtIO capability types
285 */
286typedef struct virtio_pci_cap
287{
288 /* All little-endian */
289 uint8_t uCapVndr; /**< Generic PCI field: PCI_CAP_ID_VNDR */
290 uint8_t uCapNext; /**< Generic PCI field: next ptr. */
291 uint8_t uCapLen; /**< Generic PCI field: capability length */
292 uint8_t uCfgType; /**< Identifies the structure. */
293 uint8_t uBar; /**< Where to find it. */
294 uint8_t uPadding[3]; /**< Pad to full dword. */
295 uint32_t uOffset; /**< Offset within bar. (L.E.) */
296 uint32_t uLength; /**< Length of struct, in bytes. (L.E.) */
297} VIRTIO_PCI_CAP_T, *PVIRTIO_PCI_CAP_T;
298
299/**
300 * Local implementation's usage context of a queue (e.g. not part of VirtIO specification)
301 */
302typedef struct VIRTQSTATE
303{
304 char szVirtqName[32]; /**< Dev-specific name of queue */
305 uint16_t uAvailIdx; /**< Consumer's position in avail ring */
306 uint16_t uUsedIdx; /**< Consumer's position in used ring */
307 bool fEventThresholdReached; /**< Don't lose track while queueing ahead */
308} VIRTQSTATE, *PVIRTQSTATE;
309
310/**
311 * VirtIO 1.0 Capabilities' related MMIO-mapped structs:
312 *
313 * Note: virtio_pci_device_cap is dev-specific, implemented by client. Definition unknown here.
314 */
315typedef struct virtio_pci_common_cfg
316{
317 /* Per device fields */
318 uint32_t uDeviceFeaturesSelect; /**< RW (driver selects device features) */
319 uint32_t uDeviceFeatures; /**< RO (device reports features to driver) */
320 uint32_t uDriverFeaturesSelect; /**< RW (driver selects driver features) */
321 uint32_t uDriverFeatures; /**< RW (driver-accepted device features) */
322 uint16_t uMsixConfig; /**< RW (driver sets MSI-X config vector) */
323 uint16_t uNumQueues; /**< RO (device specifies max queues) */
324 uint8_t uDeviceStatus; /**< RW (driver writes device status, 0=reset) */
325 uint8_t uConfigGeneration; /**< RO (device changes when changing configs) */
326
327 /* Per virtqueue fields (as determined by uQueueSelect) */
328 uint16_t uQueueSelect; /**< RW (selects queue focus for these fields) */
329 uint16_t uQueueSize; /**< RW (queue size, 0 - 2^n) */
330 uint16_t uQueueMsixVector; /**< RW (driver selects MSI-X queue vector) */
331 uint16_t uQueueEnable; /**< RW (driver controls usability of queue) */
332 uint16_t uQueueNotifyOff; /**< RO (offset uto virtqueue; see spec) */
333 uint64_t aGCPhysQueueDesc; /**< RW (driver writes desc table phys addr) */
334 uint64_t aGCPhysQueueAvail; /**< RW (driver writes avail ring phys addr) */
335 uint64_t aGCPhysQueueUsed; /**< RW (driver writes used ring phys addr) */
336} VIRTIO_PCI_COMMON_CFG_T, *PVIRTIO_PCI_COMMON_CFG_T;
337
338typedef struct virtio_pci_notify_cap
339{
340 struct virtio_pci_cap pciCap; /**< Notification MMIO mapping capability */
341 uint32_t uNotifyOffMultiplier; /**< notify_off_multiplier */
342} VIRTIO_PCI_NOTIFY_CAP_T, *PVIRTIO_PCI_NOTIFY_CAP_T;
343
344typedef struct virtio_pci_cfg_cap
345{
346 struct virtio_pci_cap pciCap; /**< Cap. defines the BAR/off/len to access */
347 uint8_t uPciCfgData[4]; /**< I/O buf for above cap. */
348} VIRTIO_PCI_CFG_CAP_T, *PVIRTIO_PCI_CFG_CAP_T;
349
350/**
351 * The core (/common) state of the VirtIO PCI device
352 *
353 * @implements PDMILEDPORTS
354 */
355typedef struct VIRTIOSTATE
356{
357 char szInstance[16]; /**< Instance name, e.g. "VIRTIOSCSI0" */
358 R3PTRTYPE(void *) pClientContext; /**< Client callback returned on callbacks */
359
360 PPDMDEVINSR3 pDevInsR3; /**< Device instance - R3 */
361
362 RTGCPHYS GCPhysPciCapBase; /**< Pointer to MMIO mapped capability data */
363 RTGCPHYS GCPhysCommonCfg; /**< Pointer to MMIO mapped capability data */
364 RTGCPHYS GCPhysNotifyCap; /**< Pointer to MMIO mapped capability data */
365 RTGCPHYS GCPhysIsrCap; /**< Pointer to MMIO mapped capability data */
366 RTGCPHYS GCPhysDeviceCap; /**< Pointer to MMIO mapped capability data */
367
368 RTGCPHYS aGCPhysQueueDesc[VIRTQ_MAX_CNT]; /**< (MMIO) PhysAdr per-Q desc structs GUEST */
369 RTGCPHYS aGCPhysQueueAvail[VIRTQ_MAX_CNT]; /**< (MMIO) PhysAdr per-Q avail structs GUEST */
370 RTGCPHYS aGCPhysQueueUsed[VIRTQ_MAX_CNT]; /**< (MMIO) PhysAdr per-Q used structs GUEST */
371 uint16_t uQueueNotifyOff[VIRTQ_MAX_CNT]; /**< (MMIO) per-Q notify offset HOST */
372 uint16_t uQueueMsixVector[VIRTQ_MAX_CNT]; /**< (MMIO) Per-queue vector for MSI-X GUEST */
373 uint16_t uQueueEnable[VIRTQ_MAX_CNT]; /**< (MMIO) Per-queue enable GUEST */
374 uint16_t uQueueSize[VIRTQ_MAX_CNT]; /**< (MMIO) Per-queue size HOST/GUEST */
375 uint16_t uQueueSelect; /**< (MMIO) queue selector GUEST */
376 uint16_t padding;
377 uint64_t uDeviceFeatures; /**< (MMIO) Host features offered HOST */
378 uint64_t uDriverFeatures; /**< (MMIO) Host features accepted GUEST */
379 uint32_t uDeviceFeaturesSelect; /**< (MMIO) hi/lo select uDeviceFeatures GUEST */
380 uint32_t uDriverFeaturesSelect; /**< (MMIO) hi/lo select uDriverFeatures GUEST */
381 uint32_t uMsixConfig; /**< (MMIO) MSI-X vector GUEST */
382 uint32_t uNumQueues; /**< (MMIO) Actual number of queues GUEST */
383 uint8_t uDeviceStatus; /**< (MMIO) Device Status GUEST */
384 uint8_t uPrevDeviceStatus; /**< (MMIO) Prev Device Status GUEST */
385 uint8_t uConfigGeneration; /**< (MMIO) Device config sequencer HOST */
386
387 VIRTQSTATE virtqState[VIRTQ_MAX_CNT]; /**< Local impl-specific queue context */
388 VIRTIOCALLBACKS virtioCallbacks; /**< Callback vectors to client */
389
390 PVIRTIO_PCI_CFG_CAP_T pPciCfgCap; /**< Pointer to struct in configuration area */
391 PVIRTIO_PCI_NOTIFY_CAP_T pNotifyCap; /**< Pointer to struct in configuration area */
392 PVIRTIO_PCI_CAP_T pCommonCfgCap; /**< Pointer to struct in configuration area */
393 PVIRTIO_PCI_CAP_T pIsrCap; /**< Pointer to struct in configuration area */
394 PVIRTIO_PCI_CAP_T pDeviceCap; /**< Pointer to struct in configuration area */
395
396 uint32_t cbDevSpecificCfg; /**< Size of client's dev-specific config data */
397 void *pDevSpecificCfg; /**< Pointer to client's struct */
398 void *pPrevDevSpecificCfg; /**< Previous read dev-specific cfg of client */
399 bool fGenUpdatePending; /**< If set, update cfg gen after driver reads */
400 uint8_t uPciCfgDataOff;
401 uint8_t uISR; /**< Interrupt Status Register. */
402 uint8_t fMsiSupport;
403
404} VIRTIOSTATE, *PVIRTIOSTATE;
405
406/** virtq related flags */
407#define VIRTQ_DESC_F_NEXT 1 /**< Indicates this descriptor chains to next */
408#define VIRTQ_DESC_F_WRITE 2 /**< Marks buffer as write-only (default ro) */
409#define VIRTQ_DESC_F_INDIRECT 4 /**< Buffer is list of buffer descriptors */
410
411#define VIRTQ_USED_F_NO_NOTIFY 1 /**< Dev to Drv: Don't notify when buf added */
412#define VIRTQ_AVAIL_F_NO_INTERRUPT 1 /**< Drv to Dev: Don't notify when buf eaten */
413
414
415#endif /* !VBOX_INCLUDED_SRC_VirtIO_Virtio_1_0_h */
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette