VirtualBox

source: vbox/trunk/src/VBox/Devices/USB/DrvVUSBRootHub.cpp@ 27867

Last change on this file since 27867 was 26978, checked in by vboxsync, 15 years ago

superflous

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 56.8 KB
Line 
1/* $Id: DrvVUSBRootHub.cpp 26978 2010-03-02 21:37:37Z vboxsync $ */
2/** @file
3 * Virtual USB - Root Hub Driver.
4 */
5
6/*
7 * Copyright (C) 2006-2007 Sun Microsystems, Inc.
8 *
9 * Sun Microsystems, Inc. confidential
10 * All rights reserved
11 */
12
13
14/** @page pg_dev_vusb VUSB - Virtual USB
15 *
16 * @todo read thru this and correct typos. Merge with old docs.
17 *
18 *
19 * The Virtual USB component glues USB devices and host controllers together.
20 * The VUSB takes the form of a PDM driver which is attached to the HCI. USB
21 * devices are created by, attached to, and managed by the VUSB roothub. The
22 * VUSB also exposes an interface which is used by Main to attach and detach
23 * proxied USB devices.
24 *
25 *
26 * @section sec_dev_vusb_urb The Life of an URB
27 *
28 * The URB is created when the HCI calls the roothub (VUSB) method pfnNewUrb.
29 * VUSB has a pool of URBs, if no free URBs are availabe a new one is
30 * allocated. The returned URB starts life in the ALLOCATED state and all
31 * fields are initalized with sensible defaults.
32 *
33 * The HCI then copies any request data into the URB if it's an host2dev
34 * transfer. It then submits the URB by calling the pfnSubmitUrb roothub
35 * method.
36 *
37 * pfnSubmitUrb will start by checking if it knows the device address, and if
38 * it doesn't the URB is completed with a device-not-ready error. When the
39 * device address is known to it, action is taken based on the kind of
40 * transfer it is. There are four kinds of transfers: 1. control, 2. bulk,
41 * 3. interrupt, and 4. isochronous. In either case something eventually ends
42 * up being submitted to the device.
43 *
44 *
45 * If an URB fails submitting, may or may not be completed. This depends on
46 * heuristics in some cases and on the kind of failure in others. If
47 * pfnSubmitUrb returns a failure, the HCI should retry submitting it at a
48 * later time. If pfnSubmitUrb returns success the URB is submitted, and it
49 * can even been completed.
50 *
51 * The URB is in the IN_FLIGHT state from the time it's successfully submitted
52 * and till it's reaped or cancelled.
53 *
54 * When an URB transfer or in some case submit failure occurs, the pfnXferError
55 * callback of the HCI is consulted about what to do. If pfnXferError indicates
56 * that the URB should be retried, pfnSubmitUrb will fail. If it indicates that
57 * it should fail, the URB will be completed.
58 *
59 * Completing an URB means that the URB status is set and the HCI
60 * pfnXferCompletion callback is invoked with the URB. The HCI is the supposed
61 * to report the transfer status to the guest OS. After completion the URB
62 * is freed and returned to the pool, unless it was cancelled. If it was
63 * cancelled it will have to await reaping before it's actually freed.
64 *
65 *
66 * @subsection subsec_dev_vusb_urb_ctrl Control
67 *
68 * The control transfer is the most complex one, from VUSB's point of view,
69 * with its three stages and being bi-directional. A control transfer starts
70 * with a SETUP packet containing the request description and two basic
71 * parameters. It is followed by zero or more DATA packets which either picks
72 * up incoming data (dev2host) or supplies the request data (host2dev). This
73 * can then be followed by a STATUS packet which gets the status of the whole
74 * transfer.
75 *
76 * What makes the control transfer complicated is that for a host2dev request
77 * the URB is assembled from the SETUP and DATA stage, and for a dev2host
78 * request the returned data must be kept around for the DATA stage. For both
79 * transfer directions the status of the transfer has to be kept around for
80 * the STATUS stage.
81 *
82 * To complicate matters futher, VUSB must intercept and in some cases emulate
83 * some of the standard requests in order to keep the virtual device state
84 * correct and provide the correct virtualization of a device.
85 *
86 * @subsection subsec_dev_vusb_urb_bulk Bulk and Interrupt
87 *
88 * The bulk and interrupt transfer types are relativly simple compared to the
89 * control transfer. VUSB is not inspecting the request content or anything,
90 * but passes it down the device.
91 *
92 * @subsection subsec_dev_vusb_urb_bulk Isochronous
93 *
94 * This kind of transfers hasn't yet been implemented.
95 *
96 */
97
98
99/** @page pg_dev_vusb_old VUSB - Virtual USB Core
100 *
101 * The virtual USB core is controlled by the roothub and the underlying HCI
102 * emulator, it is responsible for device addressing, managing configurations,
103 * interfaces and endpoints, assembling and splitting multi-part control
104 * messages and in general acts as a middle layer between the USB device
105 * emulation code and USB HCI emulation code.
106 *
107 * All USB devices are represented by a struct vusb_dev. This structure
108 * contains things like the device state, device address, all the configuration
109 * descriptors, the currently selected configuration and a mapping between
110 * endpoint addresses and endpoint descriptors.
111 *
112 * Each vusb_dev also has a pointer to a vusb_dev_ops structure which serves as
113 * the virtual method table and includes a virtual constructor and destructor.
114 * After a vusb_dev is created it may be attached to a hub device such as a
115 * roothub (using vusbHubAttach). Although each hub structure has cPorts
116 * and cDevices fields, it is the responsibility of the hub device to allocate
117 * a free port for the new device.
118 *
119 * Devices can chose one of two interfaces for dealing with requests, the
120 * synchronous interface or the asynchronous interface. The synchronous
121 * interface is much simpler and ought to be used for devices which are
122 * unlikely to sleep for long periods in order to serve requests. The
123 * asynchronous interface on the other hand is more difficult to use but is
124 * useful for the USB proxy or if one were to write a mass storage device
125 * emulator. Currently the synchronous interface only supports control and bulk
126 * endpoints and is no longer used by anything.
127 *
128 * In order to use the asynchronous interface, the queue_urb, cancel_urb and
129 * pfnUrbReap fields must be set in the devices vusb_dev_ops structure. The
130 * queue_urb method is used to submit a request to a device without blocking,
131 * it returns 1 if successful and 0 on any kind of failure. A successfully
132 * queued URB is completed when the pfnUrbReap method returns it. Each function
133 * address is reference counted so that pfnUrbReap will only be called if there
134 * are URBs outstanding. For a roothub to reap an URB from any one of it's
135 * devices, the vusbRhReapAsyncUrbs() function is used.
136 *
137 * There are four types of messages an URB may contain:
138 * -# Control - represents a single packet of a multi-packet control
139 * transfer, these are only really used by the host controller to
140 * submit the parts to the usb core.
141 * -# Message - the usb core assembles multiple control transfers in
142 * to single message transfers. In this case the data buffer
143 * contains the setup packet in little endian followed by the full
144 * buffer. In the case of an host-to-device control message, the
145 * message packet is created when the STATUS transfer is seen. In
146 * the case of device-to-host messages, the message packet is
147 * created after the SETUP transfer is seen. Also, certain control
148 * requests never go the real device and get handled synchronously.
149 * -# Bulk - Currently the only endpoint type that does error checking
150 * and endpoint halting.
151 * -# Interrupt - The only non-periodic type supported.
152 *
153 * Hubs are special cases of devices, they have a number of downstream ports
154 * that other devices can be attached to and removed from.
155 *
156 * After a device has been attached (vusbHubAttach):
157 * -# The hub attach method is called, which sends a hub status
158 * change message to the OS.
159 * -# The OS resets the device, and it appears on the default
160 * address with it's config 0 selected (a pseudo-config that
161 * contains only 1 interface with 1 endpoint - the default
162 * message pipe).
163 * -# The OS assigns the device a new address and selects an
164 * appropriate config.
165 * -# The device is ready.
166 *
167 * After a device has been detached (vusbDevDetach):
168 * -# All pending URBs are cancelled.
169 * -# The devices address is unassigned.
170 * -# The hub detach method is called which signals the OS
171 * of the status change.
172 * -# The OS unlinks the ED's for that device.
173 *
174 * A device can also request detachment from within its own methods by
175 * calling vusbDevUnplugged().
176 *
177 * Roothubs are responsible for driving the whole system, they are special
178 * cases of hubs and as such implement attach and detach methods, each one
179 * is described by a struct vusb_roothub. Once a roothub has submitted an
180 * URB to the USB core, a number of callbacks to the roothub are required
181 * for when the URB completes, since the roothub typically wants to inform
182 * the OS when transfers are completed.
183 *
184 * There are four callbacks to be concerned with:
185 * -# prepare - This is called after the URB is successfully queued.
186 * -# completion - This is called after the URB completed.
187 * -# error - This is called if the URB errored, some systems have
188 * automatic resubmission of failed requests, so this callback
189 * should keep track of the error count and return 1 if the count
190 * is above the number of allowed resubmissions.
191 * -# halt_ep - This is called after errors on bulk pipes in order
192 * to halt the pipe.
193 *
194 */
195
196/*******************************************************************************
197* Header Files *
198*******************************************************************************/
199#define LOG_GROUP LOG_GROUP_DRV_VUSB
200#include <VBox/pdm.h>
201#include <VBox/vmapi.h>
202#include <VBox/err.h>
203#include <iprt/alloc.h>
204#include <VBox/log.h>
205#include <iprt/time.h>
206#include <iprt/thread.h>
207#include <iprt/semaphore.h>
208#include <iprt/string.h>
209#include <iprt/assert.h>
210#include <iprt/asm.h>
211#include <iprt/uuid.h>
212#include "VUSBInternal.h"
213#include "Builtins.h"
214
215
216
217/**
218 * Attaches a device to a specific hub.
219 *
220 * This function is called by the vusb_add_device() and vusbRhAttachDevice().
221 *
222 * @returns VBox status code.
223 * @param pHub The hub to attach it to.
224 * @param pDev The device to attach.
225 * @thread EMT
226 */
227static int vusbHubAttach(PVUSBHUB pHub, PVUSBDEV pDev)
228{
229 LogFlow(("vusbHubAttach: pHub=%p[%s] pDev=%p[%s]\n", pHub, pHub->pszName, pDev, pDev->pUsbIns->pszName));
230 AssertMsg(pDev->enmState == VUSB_DEVICE_STATE_DETACHED, ("enmState=%d\n", pDev->enmState));
231
232 pDev->pHub = pHub;
233 pDev->enmState = VUSB_DEVICE_STATE_ATTACHED;
234
235 /* noone else ever messes with the default pipe while we are attached */
236 vusbDevMapEndpoint(pDev, &g_Endpoint0);
237 vusbDevDoSelectConfig(pDev, &g_Config0);
238
239 int rc = pHub->pOps->pfnAttach(pHub, pDev);
240 if (RT_FAILURE(rc))
241 {
242 pDev->pHub = NULL;
243 pDev->enmState = VUSB_DEVICE_STATE_DETACHED;
244 }
245 return rc;
246}
247
248
249/* -=-=-=-=-=- PDMUSBHUBREG methods -=-=-=-=-=- */
250
251/** @copydoc PDMUSBHUBREG::pfnAttachDevice */
252static DECLCALLBACK(int) vusbPDMHubAttachDevice(PPDMDRVINS pDrvIns, PPDMUSBINS pUsbIns, uint32_t *piPort)
253{
254 PVUSBROOTHUB pThis = PDMINS_2_DATA(pDrvIns, PVUSBROOTHUB);
255
256 /*
257 * Allocate a new VUSB device and initialize it.
258 */
259 PVUSBDEV pDev = (PVUSBDEV)RTMemAllocZ(sizeof(*pDev));
260 AssertReturn(pDev, VERR_NO_MEMORY);
261 int rc = vusbDevInit(pDev, pUsbIns);
262 if (RT_SUCCESS(rc))
263 {
264 pUsbIns->pvVUsbDev2 = pDev;
265 rc = vusbHubAttach(&pThis->Hub, pDev);
266 if (RT_SUCCESS(rc))
267 {
268 *piPort = UINT32_MAX; ///@todo implement piPort
269 return rc;
270 }
271
272 RTMemFree(pDev->paIfStates);
273 pUsbIns->pvVUsbDev2 = NULL;
274 }
275 RTMemFree(pDev);
276 return rc;
277}
278
279
280/** @copydoc PDMUSBHUBREG::pfnDetachDevice */
281static DECLCALLBACK(int) vusbPDMHubDetachDevice(PPDMDRVINS pDrvIns, PPDMUSBINS pUsbIns, uint32_t iPort)
282{
283 PVUSBDEV pDev = (PVUSBDEV)pUsbIns->pvVUsbDev2;
284 Assert(pDev);
285 vusbDevDestroy(pDev);
286 RTMemFree(pDev);
287 pUsbIns->pvVUsbDev2 = NULL;
288 return VINF_SUCCESS;
289}
290
291/**
292 * The hub registration structure.
293 */
294static const PDMUSBHUBREG g_vusbHubReg =
295{
296 PDM_USBHUBREG_VERSION,
297 vusbPDMHubAttachDevice,
298 vusbPDMHubDetachDevice,
299 PDM_USBHUBREG_VERSION
300};
301
302
303/* -=-=-=-=-=- VUSBIROOTHUBCONNECTOR methods -=-=-=-=-=- */
304
305
306/**
307 * Finds an device attached to a roothub by it's address.
308 *
309 * @returns Pointer to the device.
310 * @returns NULL if not found.
311 * @param pRh Pointer to the root hub.
312 * @param Address The device address.
313 */
314static PVUSBDEV vusbRhFindDevByAddress(PVUSBROOTHUB pRh, uint8_t Address)
315{
316 unsigned iHash = vusbHashAddress(Address);
317 for (PVUSBDEV pDev = pRh->apAddrHash[iHash]; pDev; pDev = pDev->pNextHash)
318 if (pDev->u8Address == Address)
319 return pDev;
320 return NULL;
321}
322
323
324/**
325 * Callback for freeing an URB.
326 * @param pUrb The URB to free.
327 */
328static DECLCALLBACK(void) vusbRhFreeUrb(PVUSBURB pUrb)
329{
330 /*
331 * Assert sanity.
332 */
333 vusbUrbAssert(pUrb);
334 PVUSBROOTHUB pRh = (PVUSBROOTHUB)pUrb->VUsb.pvFreeCtx;
335 Assert(pRh);
336#ifdef VBOX_STRICT
337 for (PVUSBURB pCur = pRh->pAsyncUrbHead; pCur; pCur = pCur->VUsb.pNext)
338 Assert(pUrb != pCur);
339#endif
340
341 /*
342 * Free the URB description (logging builds only).
343 */
344 if (pUrb->pszDesc)
345 {
346 RTStrFree(pUrb->pszDesc);
347 pUrb->pszDesc = NULL;
348 }
349
350 /*
351 * Put it into the LIFO of free URBs.
352 * (No ppPrev is needed here.)
353 */
354 RTCritSectEnter(&pRh->CritSect);
355 pUrb->enmState = VUSBURBSTATE_FREE;
356 pUrb->VUsb.ppPrev = NULL;
357 pUrb->VUsb.pNext = pRh->pFreeUrbs;
358 pRh->pFreeUrbs = pUrb;
359 Assert(pRh->pFreeUrbs->enmState == VUSBURBSTATE_FREE);
360 RTCritSectLeave(&pRh->CritSect);
361}
362
363
364/**
365 * Worker routine for vusbRhConnNewUrb() and vusbDevNewIsocUrb().
366 */
367PVUSBURB vusbRhNewUrb(PVUSBROOTHUB pRh, uint8_t DstAddress, uint32_t cbData, uint32_t cTds)
368{
369 /*
370 * Reuse or allocate a new URB.
371 */
372 /** @todo try find a best fit, MSD which submits rather big URBs intermixed with small control
373 * messages ends up with a 2+ of these big URBs when a single one is sufficient. */
374 /** @todo The allocations should be done by the device, at least as an option, since the devices
375 * frequently wish to associate their own stuff with the in-flight URB or need special buffering
376 * (isochronous on Darwin for instance). */
377 RTCritSectEnter(&pRh->CritSect);
378 PVUSBURB pUrbPrev = NULL;
379 PVUSBURB pUrb = pRh->pFreeUrbs;
380 while (pUrb)
381 {
382 if ( pUrb->VUsb.cbDataAllocated >= cbData
383 && pUrb->VUsb.cTdsAllocated >= cTds)
384 break;
385 pUrbPrev = pUrb;
386 pUrb = pUrb->VUsb.pNext;
387 }
388 if (pUrb)
389 {
390 if (pUrbPrev)
391 pUrbPrev->VUsb.pNext = pUrb->VUsb.pNext;
392 else
393 pRh->pFreeUrbs = pUrb->VUsb.pNext;
394 Assert(pUrb->u32Magic == VUSBURB_MAGIC);
395 Assert(pUrb->VUsb.pvFreeCtx == pRh);
396 Assert(pUrb->VUsb.pfnFree == vusbRhFreeUrb);
397 Assert(pUrb->enmState == VUSBURBSTATE_FREE);
398 Assert(!pUrb->VUsb.pNext || pUrb->VUsb.pNext->enmState == VUSBURBSTATE_FREE);
399 }
400 else
401 {
402 /* allocate a new one. */
403 uint32_t cbDataAllocated = cbData <= _4K ? RT_ALIGN_32(cbData, _1K)
404 : cbData <= _32K ? RT_ALIGN_32(cbData, _4K)
405 : RT_ALIGN_32(cbData, 16*_1K);
406 uint32_t cTdsAllocated = RT_ALIGN_32(cTds, 16);
407
408 pUrb = (PVUSBURB)RTMemAlloc( RT_OFFSETOF(VUSBURB, abData[cbDataAllocated + 16])
409 + sizeof(pUrb->Hci.paTds[0]) * cTdsAllocated);
410 if (RT_UNLIKELY(!pUrb))
411 {
412 RTCritSectLeave(&pRh->CritSect);
413 AssertLogRelFailedReturn(NULL);
414 }
415
416 pRh->cUrbsInPool++;
417 pUrb->u32Magic = VUSBURB_MAGIC;
418 pUrb->VUsb.pvFreeCtx = pRh;
419 pUrb->VUsb.pfnFree = vusbRhFreeUrb;
420 pUrb->VUsb.cbDataAllocated = cbDataAllocated;
421 pUrb->VUsb.cTdsAllocated = cTdsAllocated;
422 pUrb->Hci.paTds = (VUSBURB::VUSBURBHCI::VUSBURBHCITD *)(&pUrb->abData[cbDataAllocated + 16]);
423 }
424 RTCritSectLeave(&pRh->CritSect);
425
426 /*
427 * (Re)init the URB
428 */
429 pUrb->enmState = VUSBURBSTATE_ALLOCATED;
430 pUrb->pszDesc = NULL;
431 pUrb->VUsb.pNext = NULL;
432 pUrb->VUsb.ppPrev = NULL;
433 pUrb->VUsb.pCtrlUrb = NULL;
434 pUrb->VUsb.u64SubmitTS = 0;
435 pUrb->VUsb.pDev = vusbRhFindDevByAddress(pRh, DstAddress);
436 pUrb->Hci.EdAddr = ~0;
437 pUrb->Hci.cTds = cTds;
438 pUrb->Hci.pNext = NULL;
439 pUrb->Hci.u32FrameNo = 0;
440 pUrb->Hci.fUnlinked = false;
441 pUrb->Dev.pvPrivate = NULL;
442 pUrb->Dev.pNext = NULL;
443 pUrb->pUsbIns = pUrb->VUsb.pDev ? pUrb->VUsb.pDev->pUsbIns : NULL;
444 pUrb->DstAddress = DstAddress;
445 pUrb->EndPt = ~0;
446 pUrb->enmType = VUSBXFERTYPE_INVALID;
447 pUrb->enmDir = VUSBDIRECTION_INVALID;
448 pUrb->fShortNotOk = false;
449 pUrb->enmStatus = VUSBSTATUS_INVALID;
450 pUrb->cbData = cbData;
451 return pUrb;
452}
453
454
455/** @copydoc VUSBIROOTHUBCONNECTOR::pfnNewUrb */
456static DECLCALLBACK(PVUSBURB) vusbRhConnNewUrb(PVUSBIROOTHUBCONNECTOR pInterface, uint8_t DstAddress, uint32_t cbData, uint32_t cTds)
457{
458 PVUSBROOTHUB pRh = VUSBIROOTHUBCONNECTOR_2_VUSBROOTHUB(pInterface);
459 return vusbRhNewUrb(pRh, DstAddress, cbData, cTds);
460}
461
462
463/** @copydoc VUSBIROOTHUBCONNECTOR::pfnSubmitUrb */
464static DECLCALLBACK(int) vusbRhSubmitUrb(PVUSBIROOTHUBCONNECTOR pInterface, PVUSBURB pUrb, PPDMLED pLed)
465{
466 PVUSBROOTHUB pRh = VUSBIROOTHUBCONNECTOR_2_VUSBROOTHUB(pInterface);
467 STAM_PROFILE_START(&pRh->StatSubmitUrb, a);
468
469#ifdef VBOX_WITH_STATISTICS
470 /*
471 * Total and per-type submit statistics.
472 */
473 Assert(pUrb->enmType >= 0 && pUrb->enmType < (int)RT_ELEMENTS(pRh->aTypes));
474 STAM_COUNTER_INC(&pRh->Total.StatUrbsSubmitted);
475 STAM_COUNTER_INC(&pRh->aTypes[pUrb->enmType].StatUrbsSubmitted);
476
477 STAM_COUNTER_ADD(&pRh->Total.StatReqBytes, pUrb->cbData);
478 STAM_COUNTER_ADD(&pRh->aTypes[pUrb->enmType].StatReqBytes, pUrb->cbData);
479 if (pUrb->enmDir == VUSBDIRECTION_IN)
480 {
481 STAM_COUNTER_ADD(&pRh->Total.StatReqReadBytes, pUrb->cbData);
482 STAM_COUNTER_ADD(&pRh->aTypes[pUrb->enmType].StatReqReadBytes, pUrb->cbData);
483 }
484 else
485 {
486 STAM_COUNTER_ADD(&pRh->Total.StatReqWriteBytes, pUrb->cbData);
487 STAM_COUNTER_ADD(&pRh->aTypes[pUrb->enmType].StatReqWriteBytes, pUrb->cbData);
488 }
489
490 if (pUrb->enmType == VUSBXFERTYPE_ISOC)
491 {
492 STAM_COUNTER_ADD(&pRh->StatIsocReqPkts, pUrb->cIsocPkts);
493 if (pUrb->enmDir == VUSBDIRECTION_IN)
494 STAM_COUNTER_ADD(&pRh->StatIsocReqReadPkts, pUrb->cIsocPkts);
495 else
496 STAM_COUNTER_ADD(&pRh->StatIsocReqWritePkts, pUrb->cIsocPkts);
497 }
498#endif
499
500 /*
501 * The device was resolved when we allocated the URB.
502 * Submit it to the device if we found it, if not fail with device-not-ready.
503 */
504 int rc;
505 if ( pUrb->VUsb.pDev
506 && pUrb->pUsbIns)
507 {
508 switch (pUrb->enmDir)
509 {
510 case VUSBDIRECTION_IN:
511 pLed->Asserted.s.fReading = pLed->Actual.s.fReading = 1;
512 rc = vusbUrbSubmit(pUrb);
513 pLed->Actual.s.fReading = 0;
514 break;
515 case VUSBDIRECTION_OUT:
516 pLed->Asserted.s.fWriting = pLed->Actual.s.fWriting = 1;
517 rc = vusbUrbSubmit(pUrb);
518 pLed->Actual.s.fWriting = 0;
519 break;
520 default:
521 rc = vusbUrbSubmit(pUrb);
522 break;
523 }
524
525 if (RT_FAILURE(rc))
526 {
527 LogFlow(("vusbRhSubmitUrb: freeing pUrb=%p\n", pUrb));
528 pUrb->VUsb.pfnFree(pUrb);
529 }
530 }
531 else
532 {
533 pUrb->VUsb.pDev = &pRh->Hub.Dev;
534 Log(("vusb: pRh=%p: SUBMIT: Address %i not found!!!\n", pRh, pUrb->DstAddress));
535
536 pUrb->enmState = VUSBURBSTATE_REAPED;
537 pUrb->enmStatus = VUSBSTATUS_DNR;
538 vusbUrbCompletionRh(pUrb);
539 rc = VINF_SUCCESS;
540 }
541
542 STAM_PROFILE_STOP(&pRh->StatSubmitUrb, a);
543 return rc;
544}
545
546
547/** @copydoc VUSBIROOTHUBCONNECTOR::pfnReapAsyncUrbs */
548static DECLCALLBACK(void) vusbRhReapAsyncUrbs(PVUSBIROOTHUBCONNECTOR pInterface, RTMSINTERVAL cMillies)
549{
550 PVUSBROOTHUB pRh = VUSBIROOTHUBCONNECTOR_2_VUSBROOTHUB(pInterface);
551 if (!pRh->pAsyncUrbHead)
552 return;
553
554 STAM_PROFILE_START(&pRh->StatReapAsyncUrbs, a);
555 if (!cMillies)
556 vusbUrbDoReapAsync(pRh->pAsyncUrbHead, 0);
557 else
558 {
559 uint64_t u64Start = RTTimeMilliTS();
560 do
561 {
562 vusbUrbDoReapAsync(pRh->pAsyncUrbHead, RT_MIN(cMillies >> 8, 10));
563 } while ( pRh->pAsyncUrbHead
564 && RTTimeMilliTS() - u64Start < cMillies);
565 }
566 STAM_PROFILE_STOP(&pRh->StatReapAsyncUrbs, a);
567}
568
569
570/** @copydoc VUSBIROOTHUBCONNECTOR::pfnCancelAllUrbs */
571static DECLCALLBACK(void) vusbRhCancelAllUrbs(PVUSBIROOTHUBCONNECTOR pInterface)
572{
573 PVUSBROOTHUB pRh = VUSBIROOTHUBCONNECTOR_2_VUSBROOTHUB(pInterface);
574
575 /*
576 * Cancel the URBS.
577 */
578 PVUSBURB pUrb = pRh->pAsyncUrbHead;
579 LogFlow(("vusbRhCancelAllUrbs: pRh=%p\n", pRh));
580 while (pUrb)
581 {
582 PVUSBURB pNext = pUrb->VUsb.pNext;
583 vusbUrbCancel(pUrb);
584 pUrb = pNext;
585 }
586
587 /*
588 * Reap any URBs which now are ripe.
589 */
590 pUrb = pRh->pAsyncUrbHead;
591 while (pUrb)
592 {
593 PVUSBURB pRipe;
594 if (pUrb->enmState == VUSBURBSTATE_REAPED)
595 pRipe = pUrb;
596 else
597 pRipe = pUrb->pUsbIns->pReg->pfnUrbReap(pUrb->pUsbIns, 0);
598 if (!pRipe || pUrb == pRipe)
599 pUrb = pUrb->VUsb.pNext;
600 if (pRipe)
601 {
602 pRipe->enmStatus = VUSBSTATUS_CRC;
603 vusbUrbRipe(pRipe);
604 }
605 }
606}
607
608
609/** @copydoc VUSBIROOTHUBCONNECTOR::pfnAttachDevice */
610static DECLCALLBACK(int) vusbRhAttachDevice(PVUSBIROOTHUBCONNECTOR pInterface, PVUSBIDEVICE pDevice)
611{
612 PVUSBROOTHUB pRh = VUSBIROOTHUBCONNECTOR_2_VUSBROOTHUB(pInterface);
613 return vusbHubAttach(&pRh->Hub, (PVUSBDEV)pDevice);
614}
615
616
617/** @copydoc VUSBIROOTHUBCONNECTOR::pfnDetachDevice */
618static DECLCALLBACK(int) vusbRhDetachDevice(PVUSBIROOTHUBCONNECTOR pInterface, PVUSBIDEVICE pDevice)
619{
620 PVUSBROOTHUB pRh = VUSBIROOTHUBCONNECTOR_2_VUSBROOTHUB(pInterface);
621 if (&pRh->Hub != ((PVUSBDEV)pDevice)->pHub)
622 AssertFailedReturn(VERR_INVALID_PARAMETER);
623 return vusbDevDetach((PVUSBDEV)pDevice);
624}
625
626
627/* -=-=-=-=-=- VUSB Device methods (for the root hub) -=-=-=-=-=- */
628
629
630/**
631 * @copydoc VUSBIDEVICE::pfnReset
632 */
633static DECLCALLBACK(int) vusbRhDevReset(PVUSBIDEVICE pInterface, bool fResetOnLinux, PFNVUSBRESETDONE pfnDone, void *pvUser, PVM pVM)
634{
635 PVUSBROOTHUB pRh = RT_FROM_MEMBER(pInterface, VUSBROOTHUB, Hub.Dev.IDevice);
636 Assert(!pfnDone);
637 return pRh->pIRhPort->pfnReset(pRh->pIRhPort, fResetOnLinux); /** @todo change rc from bool to vbox status everywhere! */
638}
639
640
641/**
642 * @copydoc VUSBIDEVICE::pfnPowerOn
643 */
644static DECLCALLBACK(int) vusbRhDevPowerOn(PVUSBIDEVICE pInterface)
645{
646 PVUSBROOTHUB pRh = RT_FROM_MEMBER(pInterface, VUSBROOTHUB, Hub.Dev.IDevice);
647 LogFlow(("vusbRhDevPowerOn: pRh=%p\n", pRh));
648
649 Assert( pRh->Hub.Dev.enmState != VUSB_DEVICE_STATE_DETACHED
650 && pRh->Hub.Dev.enmState != VUSB_DEVICE_STATE_RESET);
651
652 if (pRh->Hub.Dev.enmState == VUSB_DEVICE_STATE_ATTACHED)
653 pRh->Hub.Dev.enmState = VUSB_DEVICE_STATE_POWERED;
654
655 return VINF_SUCCESS;
656}
657
658
659/**
660 * @copydoc VUSBIDEVICE::pfnPowerOff
661 */
662static DECLCALLBACK(int) vusbRhDevPowerOff(PVUSBIDEVICE pInterface)
663{
664 PVUSBROOTHUB pRh = RT_FROM_MEMBER(pInterface, VUSBROOTHUB, Hub.Dev.IDevice);
665 LogFlow(("vusbRhDevPowerOff: pRh=%p\n", pRh));
666
667 Assert( pRh->Hub.Dev.enmState != VUSB_DEVICE_STATE_DETACHED
668 && pRh->Hub.Dev.enmState != VUSB_DEVICE_STATE_RESET);
669
670 /*
671 * Cancel all URBs and reap them.
672 */
673 VUSBIRhCancelAllUrbs(&pRh->IRhConnector);
674 VUSBIRhReapAsyncUrbs(&pRh->IRhConnector, 0);
675
676 pRh->Hub.Dev.enmState = VUSB_DEVICE_STATE_ATTACHED;
677 return VINF_SUCCESS;
678}
679
680/**
681 * @copydoc VUSBIDEVICE::pfnGetState
682 */
683DECLCALLBACK(VUSBDEVICESTATE) vusbRhDevGetState(PVUSBIDEVICE pInterface)
684{
685 PVUSBROOTHUB pRh = RT_FROM_MEMBER(pInterface, VUSBROOTHUB, Hub.Dev.IDevice);
686 return pRh->Hub.Dev.enmState;
687}
688
689
690
691
692/* -=-=-=-=-=- VUSB Hub methods -=-=-=-=-=- */
693
694
695/**
696 * Attach the device to the hub.
697 * Port assignments and all such stuff is up to this routine.
698 *
699 * @returns VBox status code.
700 * @param pHub Pointer to the hub.
701 * @param pDev Pointer to the device.
702 */
703static int vusbRhHubOpAttach(PVUSBHUB pHub, PVUSBDEV pDev)
704{
705 PVUSBROOTHUB pRh = (PVUSBROOTHUB)pHub;
706
707 /*
708 * Assign a port.
709 */
710 int iPort = ASMBitFirstSet(&pRh->Bitmap, sizeof(pRh->Bitmap) * 8);
711 if (iPort < 0)
712 {
713 LogRel(("VUSB: No ports available!\n"));
714 return VERR_VUSB_NO_PORTS;
715 }
716 ASMBitClear(&pRh->Bitmap, iPort);
717 pHub->cDevices++;
718 pDev->i16Port = iPort;
719
720 /*
721 * Call the HCI attach routine and let it have its say before the device is
722 * linked into the device list of this hub.
723 */
724 int rc = pRh->pIRhPort->pfnAttach(pRh->pIRhPort, &pDev->IDevice, iPort);
725 if (RT_SUCCESS(rc))
726 {
727 pDev->pNext = pRh->pDevices;
728 pRh->pDevices = pDev;
729 LogRel(("VUSB: attached '%s' to port %d\n", pDev->pUsbIns->pszName, iPort));
730 }
731 else
732 {
733 ASMBitSet(&pRh->Bitmap, iPort);
734 pHub->cDevices--;
735 pDev->i16Port = -1;
736 LogRel(("VUSB: failed to attach '%s' to port %d, rc=%Rrc\n", pDev->pUsbIns->pszName, iPort, rc));
737 }
738 return rc;
739}
740
741
742/**
743 * Detach the device from the hub.
744 *
745 * @returns VBox status code.
746 * @param pHub Pointer to the hub.
747 * @param pDev Pointer to the device.
748 */
749static void vusbRhHubOpDetach(PVUSBHUB pHub, PVUSBDEV pDev)
750{
751 PVUSBROOTHUB pRh = (PVUSBROOTHUB)pHub;
752 Assert(pDev->i16Port != -1);
753
754 /*
755 * Check that it's attached and unlink it from the linked list.
756 */
757 if (pRh->pDevices != pDev)
758 {
759 PVUSBDEV pPrev = pRh->pDevices;
760 while (pPrev && pPrev->pNext != pDev)
761 pPrev = pPrev->pNext;
762 Assert(pPrev);
763 pPrev->pNext = pDev->pNext;
764 }
765 else
766 pRh->pDevices = pDev->pNext;
767 pDev->pNext = NULL;
768
769 /*
770 * Detach the device and mark the port as available.
771 */
772 unsigned uPort = pDev->i16Port;
773 pRh->pIRhPort->pfnDetach(pRh->pIRhPort, &pDev->IDevice, uPort);
774 ASMBitSet(&pRh->Bitmap, uPort);
775 pHub->cDevices--;
776}
777
778
779/**
780 * The Hub methods implemented by the root hub.
781 */
782static const VUSBHUBOPS s_VUsbRhHubOps =
783{
784 vusbRhHubOpAttach,
785 vusbRhHubOpDetach
786};
787
788
789
790/* -=-=-=-=-=- PDM Base interface methods -=-=-=-=-=- */
791
792
793/**
794 * @interface_method_impl{PDMIBASE,pfnQueryInterface}
795 */
796static DECLCALLBACK(void *) vusbRhQueryInterface(PPDMIBASE pInterface, const char *pszIID)
797{
798 PPDMDRVINS pDrvIns = PDMIBASE_2_PDMDRV(pInterface);
799 PVUSBROOTHUB pRh = PDMINS_2_DATA(pDrvIns, PVUSBROOTHUB);
800
801 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASE, &pDrvIns->IBase);
802 PDMIBASE_RETURN_INTERFACE(pszIID, VUSBIROOTHUBCONNECTOR, &pRh->IRhConnector);
803 PDMIBASE_RETURN_INTERFACE(pszIID, VUSBIDEVICE, &pRh->Hub.Dev.IDevice);
804 return NULL;
805}
806
807
808/* -=-=-=-=-=- PDM Driver methods -=-=-=-=-=- */
809
810
811/**
812 * Destruct a driver instance.
813 *
814 * Most VM resources are freed by the VM. This callback is provided so that any non-VM
815 * resources can be freed correctly.
816 *
817 * @param pDrvIns The driver instance data.
818 */
819static DECLCALLBACK(void) vusbRhDestruct(PPDMDRVINS pDrvIns)
820{
821 PVUSBROOTHUB pRh = PDMINS_2_DATA(pDrvIns, PVUSBROOTHUB);
822 PDMDRV_CHECK_VERSIONS_RETURN_VOID(pDrvIns);
823
824 /*
825 * Free all URBs.
826 */
827 while (pRh->pFreeUrbs)
828 {
829 PVUSBURB pUrb = pRh->pFreeUrbs;
830 pRh->pFreeUrbs = pUrb->VUsb.pNext;
831
832 pUrb->u32Magic = 0;
833 pUrb->enmState = VUSBURBSTATE_INVALID;
834 pUrb->VUsb.pNext = NULL;
835 RTMemFree(pUrb);
836 }
837 RTCritSectDelete(&pRh->CritSect);
838}
839
840
841/**
842 * Construct a root hub driver instance.
843 *
844 * @copydoc FNPDMDRVCONSTRUCT
845 */
846static DECLCALLBACK(int) vusbRhConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfg, uint32_t fFlags)
847{
848 LogFlow(("vusbRhConstruct:\n"));
849 PVUSBROOTHUB pThis = PDMINS_2_DATA(pDrvIns, PVUSBROOTHUB);
850 PDMDRV_CHECK_VERSIONS_RETURN(pDrvIns);
851
852 /*
853 * Validate configuration.
854 */
855 if (!CFGMR3AreValuesValid(pCfg, "\0"))
856 return VERR_PDM_DRVINS_UNKNOWN_CFG_VALUES;
857
858 /*
859 * Check that there are no drivers below us.
860 */
861 AssertMsgReturn(PDMDrvHlpNoAttach(pDrvIns) == VERR_PDM_NO_ATTACHED_DRIVER,
862 ("Configuration error: Not possible to attach anything to this driver!\n"),
863 VERR_PDM_DRVINS_NO_ATTACH);
864
865 /*
866 * Initialize the critical section.
867 */
868 int rc = RTCritSectInit(&pThis->CritSect);
869 if (RT_FAILURE(rc))
870 return rc;
871
872 /*
873 * Initialize the data members.
874 */
875 pDrvIns->IBase.pfnQueryInterface = vusbRhQueryInterface;
876 /* the usb device */
877 pThis->Hub.Dev.enmState = VUSB_DEVICE_STATE_ATTACHED;
878 pThis->Hub.Dev.u8Address = VUSB_INVALID_ADDRESS;
879 pThis->Hub.Dev.u8NewAddress = VUSB_INVALID_ADDRESS;
880 pThis->Hub.Dev.i16Port = -1;
881 pThis->Hub.Dev.IDevice.pfnReset = vusbRhDevReset;
882 pThis->Hub.Dev.IDevice.pfnPowerOn = vusbRhDevPowerOn;
883 pThis->Hub.Dev.IDevice.pfnPowerOff = vusbRhDevPowerOff;
884 pThis->Hub.Dev.IDevice.pfnGetState = vusbRhDevGetState;
885 /* the hub */
886 pThis->Hub.pOps = &s_VUsbRhHubOps;
887 pThis->Hub.pRootHub = pThis;
888 //pThis->hub.cPorts - later
889 pThis->Hub.cDevices = 0;
890 pThis->Hub.Dev.pHub = &pThis->Hub;
891 /* misc */
892 pThis->pDrvIns = pDrvIns;
893 /* the connector */
894 pThis->IRhConnector.pfnNewUrb = vusbRhConnNewUrb;
895 pThis->IRhConnector.pfnSubmitUrb = vusbRhSubmitUrb;
896 pThis->IRhConnector.pfnReapAsyncUrbs= vusbRhReapAsyncUrbs;
897 pThis->IRhConnector.pfnCancelAllUrbs= vusbRhCancelAllUrbs;
898 pThis->IRhConnector.pfnAttachDevice = vusbRhAttachDevice;
899 pThis->IRhConnector.pfnDetachDevice = vusbRhDetachDevice;
900 /*
901 * Resolve interface(s).
902 */
903 pThis->pIRhPort = PDMIBASE_QUERY_INTERFACE(pDrvIns->pUpBase, VUSBIROOTHUBPORT);
904 AssertMsgReturn(pThis->pIRhPort, ("Configuration error: the device/driver above us doesn't expose any VUSBIROOTHUBPORT interface!\n"), VERR_PDM_MISSING_INTERFACE_ABOVE);
905
906 /*
907 * Get number of ports and the availability bitmap.
908 * ASSUME that the number of ports reported now at creation time is the max number.
909 */
910 pThis->Hub.cPorts = pThis->pIRhPort->pfnGetAvailablePorts(pThis->pIRhPort, &pThis->Bitmap);
911 Log(("vusbRhConstruct: cPorts=%d\n", pThis->Hub.cPorts));
912
913 /*
914 * Get the USB version of the attached HC.
915 * ASSUME that version 2.0 implies high-speed.
916 */
917 pThis->fHcVersions = pThis->pIRhPort->pfnGetUSBVersions(pThis->pIRhPort);
918 Log(("vusbRhConstruct: fHcVersions=%u\n", pThis->fHcVersions));
919
920 /*
921 * Register ourselves as a USB hub.
922 * The current implementation uses the VUSBIRHCONFIG interface for communication.
923 */
924 PCPDMUSBHUBHLP pHlp; /* not used currently */
925 rc = PDMDrvHlpUSBRegisterHub(pDrvIns, pThis->fHcVersions, pThis->Hub.cPorts, &g_vusbHubReg, &pHlp);
926 if (RT_FAILURE(rc))
927 return rc;
928
929 /*
930 * Statistics. (It requires a 30" monitor or extremely tiny fonts to edit this "table".)
931 */
932#ifdef VBOX_WITH_STATISTICS
933 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->Total.StatUrbsSubmitted, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT, "The number of URBs submitted.", "/VUSB/%d/UrbsSubmitted", pDrvIns->iInstance);
934 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->aTypes[VUSBXFERTYPE_BULK].StatUrbsSubmitted, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT, "Bulk transfer.", "/VUSB/%d/UrbsSubmitted/Bulk", pDrvIns->iInstance);
935 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->aTypes[VUSBXFERTYPE_CTRL].StatUrbsSubmitted, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT, "Control transfer.", "/VUSB/%d/UrbsSubmitted/Ctrl", pDrvIns->iInstance);
936 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->aTypes[VUSBXFERTYPE_INTR].StatUrbsSubmitted, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT, "Interrupt transfer.", "/VUSB/%d/UrbsSubmitted/Intr", pDrvIns->iInstance);
937 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->aTypes[VUSBXFERTYPE_ISOC].StatUrbsSubmitted, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT, "Isochronous transfer.", "/VUSB/%d/UrbsSubmitted/Isoc", pDrvIns->iInstance);
938
939 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->Total.StatUrbsCancelled, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT, "The number of URBs cancelled. (included in failed)", "/VUSB/%d/UrbsCancelled", pDrvIns->iInstance);
940 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->aTypes[VUSBXFERTYPE_BULK].StatUrbsCancelled, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT, "Bulk transfer.", "/VUSB/%d/UrbsCancelled/Bulk", pDrvIns->iInstance);
941 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->aTypes[VUSBXFERTYPE_CTRL].StatUrbsCancelled, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT, "Control transfer.", "/VUSB/%d/UrbsCancelled/Ctrl", pDrvIns->iInstance);
942 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->aTypes[VUSBXFERTYPE_INTR].StatUrbsCancelled, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT, "Interrupt transfer.", "/VUSB/%d/UrbsCancelled/Intr", pDrvIns->iInstance);
943 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->aTypes[VUSBXFERTYPE_ISOC].StatUrbsCancelled, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT, "Isochronous transfer.", "/VUSB/%d/UrbsCancelled/Isoc", pDrvIns->iInstance);
944
945 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->Total.StatUrbsFailed, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT, "The number of URBs failing.", "/VUSB/%d/UrbsFailed", pDrvIns->iInstance);
946 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->aTypes[VUSBXFERTYPE_BULK].StatUrbsFailed, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT, "Bulk transfer.", "/VUSB/%d/UrbsFailed/Bulk", pDrvIns->iInstance);
947 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->aTypes[VUSBXFERTYPE_CTRL].StatUrbsFailed, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT, "Control transfer.", "/VUSB/%d/UrbsFailed/Ctrl", pDrvIns->iInstance);
948 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->aTypes[VUSBXFERTYPE_INTR].StatUrbsFailed, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT, "Interrupt transfer.", "/VUSB/%d/UrbsFailed/Intr", pDrvIns->iInstance);
949 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->aTypes[VUSBXFERTYPE_ISOC].StatUrbsFailed, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT, "Isochronous transfer.", "/VUSB/%d/UrbsFailed/Isoc", pDrvIns->iInstance);
950
951 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->Total.StatReqBytes, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_BYTES, "Total requested transfer.", "/VUSB/%d/ReqBytes", pDrvIns->iInstance);
952 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->aTypes[VUSBXFERTYPE_BULK].StatReqBytes, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_BYTES, "Bulk transfer.", "/VUSB/%d/ReqBytes/Bulk", pDrvIns->iInstance);
953 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->aTypes[VUSBXFERTYPE_CTRL].StatReqBytes, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_BYTES, "Control transfer.", "/VUSB/%d/ReqBytes/Ctrl", pDrvIns->iInstance);
954 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->aTypes[VUSBXFERTYPE_INTR].StatReqBytes, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_BYTES, "Interrupt transfer.", "/VUSB/%d/ReqBytes/Intr", pDrvIns->iInstance);
955 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->aTypes[VUSBXFERTYPE_ISOC].StatReqBytes, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_BYTES, "Isochronous transfer.", "/VUSB/%d/ReqBytes/Isoc", pDrvIns->iInstance);
956
957 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->Total.StatReqReadBytes, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_BYTES, "Total requested read transfer.", "/VUSB/%d/ReqReadBytes", pDrvIns->iInstance);
958 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->aTypes[VUSBXFERTYPE_BULK].StatReqReadBytes, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_BYTES, "Bulk transfer.", "/VUSB/%d/ReqReadBytes/Bulk", pDrvIns->iInstance);
959 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->aTypes[VUSBXFERTYPE_CTRL].StatReqReadBytes, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_BYTES, "Control transfer.", "/VUSB/%d/ReqReadBytes/Ctrl", pDrvIns->iInstance);
960 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->aTypes[VUSBXFERTYPE_INTR].StatReqReadBytes, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_BYTES, "Interrupt transfer.", "/VUSB/%d/ReqReadBytes/Intr", pDrvIns->iInstance);
961 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->aTypes[VUSBXFERTYPE_ISOC].StatReqReadBytes, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_BYTES, "Isochronous transfer.", "/VUSB/%d/ReqReadBytes/Isoc", pDrvIns->iInstance);
962
963 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->Total.StatReqWriteBytes, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_BYTES, "Total requested write transfer.", "/VUSB/%d/ReqWriteBytes", pDrvIns->iInstance);
964 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->aTypes[VUSBXFERTYPE_BULK].StatReqWriteBytes, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_BYTES, "Bulk transfer.", "/VUSB/%d/ReqWriteBytes/Bulk", pDrvIns->iInstance);
965 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->aTypes[VUSBXFERTYPE_CTRL].StatReqWriteBytes, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_BYTES, "Control transfer.", "/VUSB/%d/ReqWriteBytes/Ctrl", pDrvIns->iInstance);
966 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->aTypes[VUSBXFERTYPE_INTR].StatReqWriteBytes, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_BYTES, "Interrupt transfer.", "/VUSB/%d/ReqWriteBytes/Intr", pDrvIns->iInstance);
967 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->aTypes[VUSBXFERTYPE_ISOC].StatReqWriteBytes, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_BYTES, "Isochronous transfer.", "/VUSB/%d/ReqWriteBytes/Isoc", pDrvIns->iInstance);
968
969 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->Total.StatActBytes, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_BYTES, "Actual total transfer.", "/VUSB/%d/ActBytes", pDrvIns->iInstance);
970 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->aTypes[VUSBXFERTYPE_BULK].StatActBytes, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_BYTES, "Bulk transfer.", "/VUSB/%d/ActBytes/Bulk", pDrvIns->iInstance);
971 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->aTypes[VUSBXFERTYPE_CTRL].StatActBytes, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_BYTES, "Control transfer.", "/VUSB/%d/ActBytes/Ctrl", pDrvIns->iInstance);
972 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->aTypes[VUSBXFERTYPE_INTR].StatActBytes, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_BYTES, "Interrupt transfer.", "/VUSB/%d/ActBytes/Intr", pDrvIns->iInstance);
973 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->aTypes[VUSBXFERTYPE_ISOC].StatActBytes, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_BYTES, "Isochronous transfer.", "/VUSB/%d/ActBytes/Isoc", pDrvIns->iInstance);
974
975 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->Total.StatActReadBytes, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_BYTES, "Actual total read transfer.", "/VUSB/%d/ActReadBytes", pDrvIns->iInstance);
976 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->aTypes[VUSBXFERTYPE_BULK].StatActReadBytes, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_BYTES, "Bulk transfer.", "/VUSB/%d/ActReadBytes/Bulk", pDrvIns->iInstance);
977 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->aTypes[VUSBXFERTYPE_CTRL].StatActReadBytes, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_BYTES, "Control transfer.", "/VUSB/%d/ActReadBytes/Ctrl", pDrvIns->iInstance);
978 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->aTypes[VUSBXFERTYPE_INTR].StatActReadBytes, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_BYTES, "Interrupt transfer.", "/VUSB/%d/ActReadBytes/Intr", pDrvIns->iInstance);
979 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->aTypes[VUSBXFERTYPE_ISOC].StatActReadBytes, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_BYTES, "Isochronous transfer.", "/VUSB/%d/ActReadBytes/Isoc", pDrvIns->iInstance);
980
981 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->Total.StatActWriteBytes, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_BYTES, "Actual total write transfer.", "/VUSB/%d/ActWriteBytes", pDrvIns->iInstance);
982 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->aTypes[VUSBXFERTYPE_BULK].StatActWriteBytes, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_BYTES, "Bulk transfer.", "/VUSB/%d/ActWriteBytes/Bulk", pDrvIns->iInstance);
983 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->aTypes[VUSBXFERTYPE_CTRL].StatActWriteBytes, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_BYTES, "Control transfer.", "/VUSB/%d/ActWriteBytes/Ctrl", pDrvIns->iInstance);
984 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->aTypes[VUSBXFERTYPE_INTR].StatActWriteBytes, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_BYTES, "Interrupt transfer.", "/VUSB/%d/ActWriteBytes/Intr", pDrvIns->iInstance);
985 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->aTypes[VUSBXFERTYPE_ISOC].StatActWriteBytes, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_BYTES, "Isochronous transfer.", "/VUSB/%d/ActWriteBytes/Isoc", pDrvIns->iInstance);
986
987 /* bulk */
988 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->aTypes[VUSBXFERTYPE_BULK].StatUrbsSubmitted, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT, "Number of submitted URBs.", "/VUSB/%d/Bulk/Urbs", pDrvIns->iInstance);
989 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->aTypes[VUSBXFERTYPE_BULK].StatUrbsFailed, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT, "Number of failed URBs.", "/VUSB/%d/Bulk/UrbsFailed", pDrvIns->iInstance);
990 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->aTypes[VUSBXFERTYPE_BULK].StatUrbsCancelled, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT, "Number of cancelled URBs.", "/VUSB/%d/Bulk/UrbsFailed/Cancelled", pDrvIns->iInstance);
991 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->aTypes[VUSBXFERTYPE_BULK].StatActBytes, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_BYTES, "Number of bytes transfered.", "/VUSB/%d/Bulk/ActBytes", pDrvIns->iInstance);
992 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->aTypes[VUSBXFERTYPE_BULK].StatActReadBytes, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_BYTES, "Read.", "/VUSB/%d/Bulk/ActBytes/Read", pDrvIns->iInstance);
993 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->aTypes[VUSBXFERTYPE_BULK].StatActWriteBytes, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_BYTES, "Write.", "/VUSB/%d/Bulk/ActBytes/Write", pDrvIns->iInstance);
994 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->aTypes[VUSBXFERTYPE_BULK].StatReqBytes, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_BYTES, "Requested number of bytes.", "/VUSB/%d/Bulk/ReqBytes", pDrvIns->iInstance);
995 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->aTypes[VUSBXFERTYPE_BULK].StatReqReadBytes, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_BYTES, "Read.", "/VUSB/%d/Bulk/ReqBytes/Read", pDrvIns->iInstance);
996 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->aTypes[VUSBXFERTYPE_BULK].StatReqWriteBytes, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_BYTES, "Write.", "/VUSB/%d/Bulk/ReqBytes/Write", pDrvIns->iInstance);
997
998 /* control */
999 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->aTypes[VUSBXFERTYPE_CTRL].StatUrbsSubmitted, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT, "Number of submitted URBs.", "/VUSB/%d/Ctrl/Urbs", pDrvIns->iInstance);
1000 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->aTypes[VUSBXFERTYPE_CTRL].StatUrbsFailed, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT, "Number of failed URBs.", "/VUSB/%d/Ctrl/UrbsFailed", pDrvIns->iInstance);
1001 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->aTypes[VUSBXFERTYPE_CTRL].StatUrbsCancelled, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT, "Number of cancelled URBs.", "/VUSB/%d/Ctrl/UrbsFailed/Cancelled", pDrvIns->iInstance);
1002 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->aTypes[VUSBXFERTYPE_CTRL].StatActBytes, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_BYTES, "Number of bytes transfered.", "/VUSB/%d/Ctrl/ActBytes", pDrvIns->iInstance);
1003 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->aTypes[VUSBXFERTYPE_CTRL].StatActReadBytes, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_BYTES, "Read.", "/VUSB/%d/Ctrl/ActBytes/Read", pDrvIns->iInstance);
1004 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->aTypes[VUSBXFERTYPE_CTRL].StatActWriteBytes, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_BYTES, "Write.", "/VUSB/%d/Ctrl/ActBytes/Write", pDrvIns->iInstance);
1005 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->aTypes[VUSBXFERTYPE_CTRL].StatReqBytes, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_BYTES, "Requested number of bytes.", "/VUSB/%d/Ctrl/ReqBytes", pDrvIns->iInstance);
1006 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->aTypes[VUSBXFERTYPE_CTRL].StatReqReadBytes, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_BYTES, "Read.", "/VUSB/%d/Ctrl/ReqBytes/Read", pDrvIns->iInstance);
1007 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->aTypes[VUSBXFERTYPE_CTRL].StatReqWriteBytes, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_BYTES, "Write.", "/VUSB/%d/Ctrl/ReqBytes/Write", pDrvIns->iInstance);
1008
1009 /* interrupt */
1010 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->aTypes[VUSBXFERTYPE_INTR].StatUrbsSubmitted, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT, "Number of submitted URBs.", "/VUSB/%d/Intr/Urbs", pDrvIns->iInstance);
1011 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->aTypes[VUSBXFERTYPE_INTR].StatUrbsFailed, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT, "Number of failed URBs.", "/VUSB/%d/Intr/UrbsFailed", pDrvIns->iInstance);
1012 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->aTypes[VUSBXFERTYPE_INTR].StatUrbsCancelled, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT, "Number of cancelled URBs.", "/VUSB/%d/Intr/UrbsFailed/Cancelled", pDrvIns->iInstance);
1013 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->aTypes[VUSBXFERTYPE_INTR].StatActBytes, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_BYTES, "Number of bytes transfered.", "/VUSB/%d/Intr/ActBytes", pDrvIns->iInstance);
1014 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->aTypes[VUSBXFERTYPE_INTR].StatActReadBytes, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_BYTES, "Read.", "/VUSB/%d/Intr/ActBytes/Read", pDrvIns->iInstance);
1015 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->aTypes[VUSBXFERTYPE_INTR].StatActWriteBytes, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_BYTES, "Write.", "/VUSB/%d/Intr/ActBytes/Write", pDrvIns->iInstance);
1016 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->aTypes[VUSBXFERTYPE_INTR].StatReqBytes, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_BYTES, "Requested number of bytes.", "/VUSB/%d/Intr/ReqBytes", pDrvIns->iInstance);
1017 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->aTypes[VUSBXFERTYPE_INTR].StatReqReadBytes, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_BYTES, "Read.", "/VUSB/%d/Intr/ReqBytes/Read", pDrvIns->iInstance);
1018 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->aTypes[VUSBXFERTYPE_INTR].StatReqWriteBytes, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_BYTES, "Write.", "/VUSB/%d/Intr/ReqBytes/Write", pDrvIns->iInstance);
1019
1020 /* isochronous */
1021 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->aTypes[VUSBXFERTYPE_ISOC].StatUrbsSubmitted, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT, "Number of submitted URBs.", "/VUSB/%d/Isoc/Urbs", pDrvIns->iInstance);
1022 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->aTypes[VUSBXFERTYPE_ISOC].StatUrbsFailed, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT, "Number of failed URBs.", "/VUSB/%d/Isoc/UrbsFailed", pDrvIns->iInstance);
1023 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->aTypes[VUSBXFERTYPE_ISOC].StatUrbsCancelled, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT, "Number of cancelled URBs.", "/VUSB/%d/Isoc/UrbsFailed/Cancelled", pDrvIns->iInstance);
1024 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->aTypes[VUSBXFERTYPE_ISOC].StatActBytes, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_BYTES, "Number of bytes transfered.", "/VUSB/%d/Isoc/ActBytes", pDrvIns->iInstance);
1025 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->aTypes[VUSBXFERTYPE_ISOC].StatActReadBytes, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_BYTES, "Read.", "/VUSB/%d/Isoc/ActBytes/Read", pDrvIns->iInstance);
1026 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->aTypes[VUSBXFERTYPE_ISOC].StatActWriteBytes, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_BYTES, "Write.", "/VUSB/%d/Isoc/ActBytes/Write", pDrvIns->iInstance);
1027 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->aTypes[VUSBXFERTYPE_ISOC].StatReqBytes, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_BYTES, "Requested number of bytes.", "/VUSB/%d/Isoc/ReqBytes", pDrvIns->iInstance);
1028 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->aTypes[VUSBXFERTYPE_ISOC].StatReqReadBytes, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_BYTES, "Read.", "/VUSB/%d/Isoc/ReqBytes/Read", pDrvIns->iInstance);
1029 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->aTypes[VUSBXFERTYPE_ISOC].StatReqWriteBytes, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_BYTES, "Write.", "/VUSB/%d/Isoc/ReqBytes/Write", pDrvIns->iInstance);
1030 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->StatIsocActPkts, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT, "Number of isochronous packets returning data.", "/VUSB/%d/Isoc/ActPkts", pDrvIns->iInstance);
1031 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->StatIsocActReadPkts, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT, "Read.", "/VUSB/%d/Isoc/ActPkts/Read", pDrvIns->iInstance);
1032 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->StatIsocActWritePkts, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT, "Write.", "/VUSB/%d/Isoc/ActPkts/Write", pDrvIns->iInstance);
1033 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->StatIsocReqPkts, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT, "Requested number of isochronous packets.", "/VUSB/%d/Isoc/ReqPkts", pDrvIns->iInstance);
1034 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->StatIsocReqReadPkts, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT, "Read.", "/VUSB/%d/Isoc/ReqPkts/Read", pDrvIns->iInstance);
1035 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->StatIsocReqWritePkts, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT, "Write.", "/VUSB/%d/Isoc/ReqPkts/Write", pDrvIns->iInstance);
1036
1037 for (unsigned i = 0; i < RT_ELEMENTS(pThis->aStatIsocDetails); i++)
1038 {
1039 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->aStatIsocDetails[i].Pkts, STAMTYPE_COUNTER, STAMVISIBILITY_USED, STAMUNIT_COUNT, ".", "/VUSB/%d/Isoc/%d", pDrvIns->iInstance, i);
1040 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->aStatIsocDetails[i].Ok, STAMTYPE_COUNTER, STAMVISIBILITY_USED, STAMUNIT_COUNT, ".", "/VUSB/%d/Isoc/%d/Ok", pDrvIns->iInstance, i);
1041 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->aStatIsocDetails[i].Ok0, STAMTYPE_COUNTER, STAMVISIBILITY_USED, STAMUNIT_COUNT, ".", "/VUSB/%d/Isoc/%d/Ok0", pDrvIns->iInstance, i);
1042 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->aStatIsocDetails[i].DataUnderrun, STAMTYPE_COUNTER, STAMVISIBILITY_USED, STAMUNIT_COUNT, ".", "/VUSB/%d/Isoc/%d/DataUnderrun", pDrvIns->iInstance, i);
1043 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->aStatIsocDetails[i].DataUnderrun0, STAMTYPE_COUNTER, STAMVISIBILITY_USED, STAMUNIT_COUNT, ".", "/VUSB/%d/Isoc/%d/DataUnderrun0", pDrvIns->iInstance, i);
1044 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->aStatIsocDetails[i].DataOverrun, STAMTYPE_COUNTER, STAMVISIBILITY_USED, STAMUNIT_COUNT, ".", "/VUSB/%d/Isoc/%d/DataOverrun", pDrvIns->iInstance, i);
1045 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->aStatIsocDetails[i].NotAccessed, STAMTYPE_COUNTER, STAMVISIBILITY_USED, STAMUNIT_COUNT, ".", "/VUSB/%d/Isoc/%d/NotAccessed", pDrvIns->iInstance, i);
1046 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->aStatIsocDetails[i].Misc, STAMTYPE_COUNTER, STAMVISIBILITY_USED, STAMUNIT_COUNT, ".", "/VUSB/%d/Isoc/%d/Misc", pDrvIns->iInstance, i);
1047 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->aStatIsocDetails[i].Bytes, STAMTYPE_COUNTER, STAMVISIBILITY_USED, STAMUNIT_BYTES, ".", "/VUSB/%d/Isoc/%d/Bytes", pDrvIns->iInstance, i);
1048 }
1049
1050 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->StatReapAsyncUrbs, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES, "Profiling the vusbRhReapAsyncUrbs body (omitting calls when nothing is in-flight).", "/VUSB/%d/ReapAsyncUrbs", pDrvIns->iInstance);
1051 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->StatSubmitUrb, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES, "Profiling the vusbRhSubmitUrb body.", "/VUSB/%d/SubmitUrb", pDrvIns->iInstance);
1052#endif
1053 PDMDrvHlpSTAMRegisterF(pDrvIns, &pThis->cUrbsInPool, STAMTYPE_U32, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT, "The number of URBs in the pool.", "/VUSB/%d/cUrbsInPool", pDrvIns->iInstance);
1054
1055 return VINF_SUCCESS;
1056}
1057
1058
1059/**
1060 * VUSB Root Hub driver registration record.
1061 */
1062const PDMDRVREG g_DrvVUSBRootHub =
1063{
1064 /* u32Version */
1065 PDM_DRVREG_VERSION,
1066 /* szName */
1067 "VUSBRootHub",
1068 /* szRCMod */
1069 "",
1070 /* szR0Mod */
1071 "",
1072 /* pszDescription */
1073 "VUSB Root Hub Driver.",
1074 /* fFlags */
1075 PDM_DRVREG_FLAGS_HOST_BITS_DEFAULT,
1076 /* fClass. */
1077 PDM_DRVREG_CLASS_USB,
1078 /* cMaxInstances */
1079 ~0,
1080 /* cbInstance */
1081 sizeof(VUSBROOTHUB),
1082 /* pfnConstruct */
1083 vusbRhConstruct,
1084 /* pfnDestruct */
1085 vusbRhDestruct,
1086 /* pfnRelocate */
1087 NULL,
1088 /* pfnIOCtl */
1089 NULL,
1090 /* pfnPowerOn */
1091 NULL,
1092 /* pfnReset */
1093 NULL,
1094 /* pfnSuspend */
1095 NULL,
1096 /* pfnResume */
1097 NULL,
1098 /* pfnAttach */
1099 NULL,
1100 /* pfnDetach */
1101 NULL,
1102 /* pfnPowerOff */
1103 NULL,
1104 /* pfnSoftReset */
1105 NULL,
1106 /* u32EndVersion */
1107 PDM_DRVREG_VERSION
1108};
1109
1110/*
1111 * Local Variables:
1112 * mode: c
1113 * c-file-style: "bsd"
1114 * c-basic-offset: 4
1115 * tab-width: 4
1116 * indent-tabs-mode: s
1117 * End:
1118 */
1119
Note: See TracBrowser for help on using the repository browser.

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