Lines Matching defs:pUrb
54 static PVUSBCTRLEXTRA vusbMsgAllocExtraData(PVUSBURB pUrb);
163 * Note that pUrb->pUsbIns, pUrb->VUsb.pDev and pUrb->VUsb.pDev->pUsbIns can all be NULL.
165 void vusbUrbTrace(PVUSBURB pUrb, const char *pszMsg, bool fComplete)
167 PVUSBDEV pDev = pUrb->VUsb.pDev; /* Can be NULL when called from usbProxyConstruct and friends. */
168 PVUSBPIPE pPipe = &pDev->aPipes[pUrb->EndPt];
169 const uint8_t *pbData = pUrb->abData;
170 uint32_t cbData = pUrb->cbData;
179 pUrb->pszDesc, s_cchMaxMsg, pszMsg,
181 pUrb->pUsbIns ? pUrb->pUsbIns->pszName : "",
182 vusbUrbStatusName(pUrb->enmStatus),
184 pUrb->EndPt,
185 vusbUrbDirName(pUrb->enmDir),
186 vusbUrbTypeName(pUrb->enmType),
187 pUrb->cbData,
188 pUrb->cbData,
189 pUrb->Hci.EdAddr,
190 pUrb->Hci.cTds,
191 pUrb->Hci.cTds ? pUrb->Hci.paTds[0].TdAddr : ~(uint32_t)0,
192 pUrb->VUsb.u64SubmitTS,
193 RTTimeNanoTS() - pUrb->VUsb.u64SubmitTS,
194 pUrb->fShortNotOk ? "ShortNotOk" : "ShortOk"));
197 if ( pUrb->enmType == VUSBXFERTYPE_CTRL
198 && pUrb->enmStatus == VUSBSTATUS_OK)
202 if ( pUrb->enmType == VUSBXFERTYPE_MSG
203 || ( pUrb->enmDir == VUSBDIRECTION_SETUP
204 && pUrb->enmType == VUSBXFERTYPE_CTRL
217 pSetup = (PVUSBSETUP)pUrb->abData;
222 pUrb->pszDesc, s_cchMaxMsg, pszMsg,
230 && pUrb->enmStatus == VUSBSTATUS_OK
235 && pUrb->enmDir == VUSBDIRECTION_IN
236 && pUrb->enmType == VUSBXFERTYPE_CTRL
237 && pUrb->enmStatus == VUSBSTATUS_OK
558 if ( pUrb->enmType == VUSBXFERTYPE_BULK
559 && pUrb->enmDir == VUSBDIRECTION_OUT
560 && pUrb->cbData >= 12
561 && !memcmp(pUrb->abData, "USBC", 4))
572 } *pUsbC = (struct usbc *)pUrb->abData;
667 && pUrb->enmType == VUSBXFERTYPE_BULK
668 && pUrb->enmDir == VUSBDIRECTION_IN
669 && pUrb->cbData >= 12
670 && !memcmp(pUrb->abData, "USBS", 4))
679 } *pUsbS = (struct usbs *)pUrb->abData;
688 && pUrb->enmType == VUSBXFERTYPE_BULK
689 && pUrb->enmDir == VUSBDIRECTION_IN
693 const uint8_t *pb = pUrb->abData;
771 cbData = pUrb->cbData - sizeof(*pSetup);
823 ? pUrb->enmDir != VUSBDIRECTION_OUT
824 : pUrb->enmDir == VUSBDIRECTION_OUT))
827 if (pUrb->enmType == VUSBXFERTYPE_MSG && pUrb->VUsb.pCtrlUrb)
828 vusbUrbTrace(pUrb->VUsb.pCtrlUrb, "NESTED MSG", fComplete);
839 static void vusbMsgSetupCompletion(PVUSBURB pUrb)
841 PVUSBDEV pDev = pUrb->VUsb.pDev;
842 PVUSBPIPE pPipe = &pDev->aPipes[pUrb->EndPt];
847 pUrb->pszDesc, pUrb->cbData, pSetup->wLength, pExtra->cbLeft, pPipe, g_apszCtlStates[pExtra->enmStage])); NOREF(pSetup);
849 pUrb->enmStatus = VUSBSTATUS_OK;
858 static void vusbMsgDataCompletion(PVUSBURB pUrb)
860 PVUSBDEV pDev = pUrb->VUsb.pDev;
861 PVUSBPIPE pPipe = &pDev->aPipes[pUrb->EndPt];
866 pUrb->pszDesc, pUrb->cbData, pSetup->wLength, pExtra->cbLeft, pPipe)); NOREF(pSetup);
868 pUrb->enmStatus = VUSBSTATUS_OK;
877 static void vusbMsgStatusCompletion(PVUSBURB pUrb)
879 PVUSBDEV pDev = pUrb->VUsb.pDev;
880 PVUSBPIPE pPipe = &pDev->aPipes[pUrb->EndPt];
895 pUrb->pszDesc, pDev, pDev->pUsbIns->pszName, pPipe, g_apszCtlStates[pExtra->enmStage]));
896 pUrb->enmStatus = VUSBSTATUS_OK;
901 pUrb->pszDesc, pDev, pDev->pUsbIns->pszName, pPipe, g_apszCtlStates[pExtra->enmStage]));
902 pUrb->enmStatus = VUSBSTATUS_STALL;
916 * @param pUrb The URB originating from the HCI.
918 static void vusbCtrlCompletion(PVUSBURB pUrb)
920 PVUSBDEV pDev = pUrb->VUsb.pDev;
921 PVUSBPIPE pPipe = &pDev->aPipes[pUrb->EndPt];
923 LogFlow(("%s: vusbCtrlCompletion: pDev=%p[%s]\n", pUrb->pszDesc, pDev, pDev->pUsbIns->pszName));
928 vusbMsgSetupCompletion(pUrb);
931 vusbMsgDataCompletion(pUrb);
934 vusbMsgStatusCompletion(pUrb);
943 * @param pUrb The URB within the control pipe extra state data.
945 static void vusbMsgCompletion(PVUSBURB pUrb)
947 PVUSBDEV pDev = pUrb->VUsb.pDev;
948 PVUSBPIPE pPipe = &pDev->aPipes[pUrb->EndPt];
954 LogFlow(("%s: vusbMsgCompletion: pDev=%p[%s]\n", pUrb->pszDesc, pDev, pDev->pUsbIns->pszName));
955 vusbUrbTrace(pUrb, "vusbMsgCompletion", true);
957 Assert(&pExtra->Urb == pUrb);
960 if (pUrb->enmStatus == VUSBSTATUS_OK)
964 pExtra->cbLeft = pUrb->cbData - sizeof(VUSBSETUP);
969 PVUSBURB pCtrlUrb = pUrb->VUsb.pCtrlUrb;
976 Assert( pUrb->enmState == VUSBURBSTATE_REAPED
977 || pUrb->enmState == VUSBURBSTATE_CANCELLED);
978 if (pUrb->enmState != VUSBURBSTATE_CANCELLED)
979 pUrb->enmState = VUSBURBSTATE_ALLOCATED;
991 * @param pUrb The URB in question.
993 int vusbUrbErrorRh(PVUSBURB pUrb)
995 PVUSBDEV pDev = pUrb->VUsb.pDev;
998 LogFlow(("%s: vusbUrbErrorRh: pDev=%p[%s] rh=%p\n", pUrb->pszDesc, pDev, pDev->pUsbIns ? pDev->pUsbIns->pszName : "", pRh));
999 return pRh->pIRhPort->pfnXferError(pRh->pIRhPort, pUrb);
1005 * @param pUrb The URB to complete.
1007 void vusbUrbCompletionRh(PVUSBURB pUrb)
1010 pUrb->pszDesc, vusbUrbTypeName(pUrb->enmType), vusbUrbStatusName(pUrb->enmStatus)));
1011 AssertMsg( pUrb->enmState == VUSBURBSTATE_REAPED
1012 || pUrb->enmState == VUSBURBSTATE_CANCELLED, ("%d\n", pUrb->enmState));
1014 if (pUrb->VUsb.pDev->hSniffer)
1016 int rc = VUSBSnifferRecordEvent(pUrb->VUsb.pDev->hSniffer, pUrb,
1017 pUrb->enmStatus == VUSBSTATUS_OK
1024 PVUSBROOTHUB pRh = vusbDevGetRh(pUrb->VUsb.pDev);
1030 int rc = VUSBSnifferRecordEvent(pRh->hSniffer, pUrb,
1031 pUrb->enmStatus == VUSBSTATUS_OK
1042 if (pUrb->enmType != VUSBXFERTYPE_MSG)
1044 Assert(pUrb->enmType >= 0 && pUrb->enmType < (int)RT_ELEMENTS(pRh->aTypes));
1046 if ( pUrb->enmStatus == VUSBSTATUS_OK
1047 || pUrb->enmStatus == VUSBSTATUS_DATA_UNDERRUN
1048 || pUrb->enmStatus == VUSBSTATUS_DATA_OVERRUN)
1050 if (pUrb->enmType == VUSBXFERTYPE_ISOC)
1052 for (unsigned i = 0; i < pUrb->cIsocPkts; i++)
1054 const unsigned cb = pUrb->aIsocPkts[i].cb;
1060 if (pUrb->enmDir == VUSBDIRECTION_IN)
1074 switch (pUrb->aIsocPkts[i].enmStatus)
1090 STAM_COUNTER_ADD(&pRh->Total.StatActBytes, pUrb->cbData);
1091 STAM_COUNTER_ADD(&pRh->aTypes[pUrb->enmType].StatActBytes, pUrb->cbData);
1092 if (pUrb->enmDir == VUSBDIRECTION_IN)
1094 STAM_COUNTER_ADD(&pRh->Total.StatActReadBytes, pUrb->cbData);
1095 STAM_COUNTER_ADD(&pRh->aTypes[pUrb->enmType].StatActReadBytes, pUrb->cbData);
1099 STAM_COUNTER_ADD(&pRh->Total.StatActWriteBytes, pUrb->cbData);
1100 STAM_COUNTER_ADD(&pRh->aTypes[pUrb->enmType].StatActWriteBytes, pUrb->cbData);
1108 STAM_COUNTER_INC(&pRh->aTypes[pUrb->enmType].StatUrbsFailed);
1117 switch (pUrb->enmType)
1120 vusbMsgCompletion(pUrb);
1136 if (pUrb->enmStatus != VUSBSTATUS_OK)
1137 vusbUrbErrorRh(pUrb);
1141 vusbUrbTrace(pUrb, "vusbUrbCompletionRh", true);
1144 pRh->pIRhPort->pfnXferCompletion(pRh->pIRhPort, pUrb);
1145 if (pUrb->enmState == VUSBURBSTATE_REAPED)
1147 LogFlow(("%s: vusbUrbCompletionRh: Freeing URB\n", pUrb->pszDesc));
1148 pUrb->VUsb.pfnFree(pUrb);
1158 DECLINLINE(bool) vusbUrbIsRequestSafe(PCVUSBSETUP pSetup, PVUSBURB pUrb)
1166 return pUrb->EndPt != 0 /* not default control pipe */
1168 || !pUrb->pUsbIns->pReg->pfnUsbClearHaltedEndpoint; /* not special need for backend */
1182 if ( !pUrb->VUsb.pDev->pDescCache->fUseCachedDescriptors
1191 return !pUrb->VUsb.pDev->pDescCache->fUseCachedStringsDescriptors;
1207 * @param pUrb The URB.
1209 int vusbUrbQueueAsyncRh(PVUSBURB pUrb)
1212 vusbUrbTrace(pUrb, "vusbUrbQueueAsyncRh", false);
1217 PVUSBDEV pDev = pUrb->VUsb.pDev;
1226 int rc = pUrb->pUsbIns->pReg->pfnUrbQueue(pUrb->pUsbIns, pUrb);
1229 LogFlow(("%s: vusbUrbQueueAsyncRh: returns %Rrc (queue_urb)\n", pUrb->pszDesc, rc));
1234 ASMAtomicIncU32(&pDev->aPipes[pUrb->EndPt].async);
1236 /* Queue the pUrb on the roothub */
1237 pUrb->VUsb.pNext = pDev->pAsyncUrbHead;
1239 pDev->pAsyncUrbHead->VUsb.ppPrev = &pUrb->VUsb.pNext;
1240 pDev->pAsyncUrbHead = pUrb;
1241 pUrb->VUsb.ppPrev = &pDev->pAsyncUrbHead;
1252 static void vusbMsgSubmitSynchronously(PVUSBURB pUrb, bool fSafeRequest)
1254 PVUSBDEV pDev = pUrb->VUsb.pDev;
1256 PVUSBPIPE pPipe = &pDev->aPipes[pUrb->EndPt];
1259 LogFlow(("%s: vusbMsgSubmitSynchronously: pDev=%p[%s]\n", pUrb->pszDesc, pDev, pDev->pUsbIns ? pDev->pUsbIns->pszName : ""));
1265 fOk = vusbDevStandardRequest(pDev, pUrb->EndPt, pSetup, pbData, &cbData);
1269 pUrb->enmState = VUSBURBSTATE_REAPED;
1273 pUrb->enmStatus = VUSBSTATUS_OK;
1278 pUrb->enmStatus = VUSBSTATUS_STALL;
1283 vusbCtrlCompletion(pUrb);
1284 vusbUrbCompletionRh(pUrb);
1331 * @param pUrb
1333 static DECLCALLBACK(void) vusbMsgFreeUrb(PVUSBURB pUrb)
1335 vusbUrbAssert(pUrb);
1336 PVUSBCTRLEXTRA pExtra = (PVUSBCTRLEXTRA)((uint8_t *)pUrb - RT_OFFSETOF(VUSBCTRLEXTRA, Urb));
1337 if ( pUrb->enmState == VUSBURBSTATE_CANCELLED
1338 && !pUrb->VUsb.pvFreeCtx)
1340 LogFlow(("vusbMsgFreeUrb: Freeing orphan: %p (pUrb=%p)\n", pExtra, pUrb));
1345 Assert(pUrb->VUsb.pvFreeCtx == &pExtra->Urb);
1346 pUrb->enmState = VUSBURBSTATE_ALLOCATED;
1376 * @param pUrb A URB we can copy default data from.
1378 static PVUSBCTRLEXTRA vusbMsgAllocExtraData(PVUSBURB pUrb)
1397 RTStrAPrintf(&pExtra->Urb.pszDesc, "URB %p msg->%p", &pExtra->Urb, pUrb);
1402 pExtra->Urb.VUsb.pDev = pUrb->VUsb.pDev;
1407 pExtra->Urb.pUsbIns = pUrb->pUsbIns;
1408 pExtra->Urb.DstAddress = pUrb->DstAddress;
1409 pExtra->Urb.EndPt = pUrb->EndPt;
1508 * @param pUrb The URB to submit.
1510 static void vusbMsgDoTransfer(PVUSBURB pUrb, PVUSBSETUP pSetup, PVUSBCTRLEXTRA pExtra, PVUSBPIPE pPipe, PVUSBDEV pDev)
1521 bool fSafeRequest = vusbUrbIsRequestSafe(pSetup, pUrb);
1524 vusbMsgSubmitSynchronously(pUrb, fSafeRequest);
1532 pUrb->pszDesc, pUrb->EndPt, &pExtra->Urb, pPipe, g_apszCtlStates[pExtra->enmStage]));
1534 Assert(pExtra->Urb.EndPt == pUrb->EndPt);
1537 pExtra->Urb.VUsb.pCtrlUrb = pUrb;
1549 pUrb->pszDesc, rc == VERR_VUSB_DEVICE_NOT_ATTACHED ? "DNR" : "CRC", rc));
1560 * @param pUrb The URB in question.
1562 static int vusbMsgStall(PVUSBURB pUrb)
1564 PVUSBPIPE pPipe = &pUrb->VUsb.pDev->aPipes[pUrb->EndPt];
1567 pUrb->pszDesc, pPipe, g_apszCtlStates[pExtra->enmStage]));
1571 pUrb->enmState = VUSBURBSTATE_REAPED;
1572 pUrb->enmStatus = VUSBSTATUS_STALL;
1573 vusbUrbCompletionRh(pUrb);
1588 * @param pUrb The URB to submit.
1590 static int vusbUrbSubmitCtrl(PVUSBURB pUrb)
1593 vusbUrbTrace(pUrb, "vusbUrbSubmitCtrl", false);
1595 PVUSBDEV pDev = pUrb->VUsb.pDev;
1596 PVUSBPIPE pPipe = &pDev->aPipes[pUrb->EndPt];
1601 if (!pExtra && !(pExtra = pPipe->pCtrl = vusbMsgAllocExtraData(pUrb)))
1620 if (pUrb->enmDir == VUSBDIRECTION_SETUP)
1623 pUrb->pszDesc, pPipe, g_apszCtlStates[pExtra->enmStage]));
1628 && !!(pSetup->bmRequestType & VUSB_DIR_TO_HOST) != (pUrb->enmDir == VUSBDIRECTION_IN))
1631 pUrb->pszDesc, pPipe, g_apszCtlStates[pExtra->enmStage]));
1645 if (pUrb->enmDir != VUSBDIRECTION_SETUP)
1647 Log(("%s: vusbUrbSubmitCtrl: Stall at setup stage (dir=%#x)!!\n", pUrb->pszDesc, pUrb->enmDir));
1648 vusbMsgStall(pUrb);
1653 if (!vusbMsgSetup(pPipe, pUrb->abData, pUrb->cbData))
1655 pUrb->enmState = VUSBURBSTATE_REAPED;
1656 pUrb->enmStatus = VUSBSTATUS_DNR;
1657 vusbUrbCompletionRh(pUrb);
1668 vusbMsgDoTransfer(pUrb, pSetup, pExtra, pPipe, pDev);
1671 LogFlow(("%s: vusbUrbSubmitCtrl: stage=SETUP - to dev: need data\n", pUrb->pszDesc));
1672 pUrb->enmState = VUSBURBSTATE_REAPED;
1673 vusbMsgSetupCompletion(pUrb);
1674 vusbUrbCompletionRh(pUrb);
1682 LogFlow(("%s: vusbUrbSubmitCtrl: stage=SETUP - to dev: sending\n", pUrb->pszDesc));
1683 vusbMsgDoTransfer(pUrb, pSetup, pExtra, pPipe, pDev);
1695 if (&pExtra->pbCur[pUrb->cbData] > &pbData[pSetup->wLength])
1699 Log(("%s: vusbUrbSubmitCtrl: pSetup->wLength == 0!! (iPhone)\n", pUrb->pszDesc));
1700 pSetup->wLength = pUrb->cbData;
1706 || (pUrb->cbData % pSetup->wLength) == 0) /* magic which need explaining... */
1710 LogFlow(("%s: vusbUrbSubmitCtrl: Var DATA, pUrb->cbData %d -> %d\n", pUrb->pszDesc, pUrb->cbData, cbLeft));
1711 pUrb->cbData = cbLeft;
1715 Log(("%s: vusbUrbSubmitCtrl: Stall at data stage!!\n", pUrb->pszDesc));
1716 vusbMsgStall(pUrb);
1721 if (pUrb->enmDir == VUSBDIRECTION_IN)
1724 const uint32_t cbRead = RT_MIN(pUrb->cbData, pExtra->cbLeft);
1725 memcpy(pUrb->abData, pExtra->pbCur, cbRead);
1729 if (pUrb->cbData == cbRead)
1730 pExtra->cbLeft -= pUrb->cbData;
1733 /* adjust the pUrb->cbData to reflect the number of bytes containing actual data. */
1734 LogFlow(("%s: vusbUrbSubmitCtrl: adjusting last DATA pUrb->cbData, %d -> %d\n",
1735 pUrb->pszDesc, pUrb->cbData, pExtra->cbLeft));
1736 pUrb->cbData = cbRead;
1743 memcpy(pExtra->pbCur, pUrb->abData, pUrb->cbData);
1746 pExtra->pbCur += pUrb->cbData;
1755 LogFlow(("%s: vusbUrbSubmitCtrl: stage=DATA - to dev: sending\n", pUrb->pszDesc));
1756 vusbMsgDoTransfer(pUrb, pSetup, pExtra, pPipe, pDev);
1761 pUrb->enmState = VUSBURBSTATE_REAPED;
1762 vusbMsgDataCompletion(pUrb);
1763 vusbUrbCompletionRh(pUrb);
1772 pUrb->enmState = VUSBURBSTATE_REAPED;
1773 vusbMsgStatusCompletion(pUrb);
1774 vusbUrbCompletionRh(pUrb);
1778 LogFlow(("%s: vusbUrbSubmitCtrl: stage=STATUS - to dev: sending\n", pUrb->pszDesc));
1779 vusbMsgDoTransfer(pUrb, pSetup, pExtra, pPipe, pDev);
1793 * @param pUrb The URB to submit.
1795 static int vusbUrbSubmitInterrupt(PVUSBURB pUrb)
1797 LogFlow(("%s: vusbUrbSubmitInterrupt: (sync)\n", pUrb->pszDesc));
1798 return vusbUrbQueueAsyncRh(pUrb);
1806 * @param pUrb The URB to submit.
1808 static int vusbUrbSubmitBulk(PVUSBURB pUrb)
1810 LogFlow(("%s: vusbUrbSubmitBulk: (async)\n", pUrb->pszDesc));
1811 return vusbUrbQueueAsyncRh(pUrb);
1819 * @param pUrb The URB to submit.
1821 static int vusbUrbSubmitIsochronous(PVUSBURB pUrb)
1823 LogFlow(("%s: vusbUrbSubmitIsochronous: (async)\n", pUrb->pszDesc));
1824 return vusbUrbQueueAsyncRh(pUrb);
1832 * @param pUrb The URB.
1834 int vusbUrbSubmitHardError(PVUSBURB pUrb)
1837 pUrb->enmState = VUSBURBSTATE_REAPED;
1838 pUrb->enmStatus = VUSBSTATUS_DNR;
1839 vusbUrbCompletionRh(pUrb);
1847 int vusbUrbSubmit(PVUSBURB pUrb)
1849 vusbUrbAssert(pUrb);
1850 Assert(pUrb->enmState == VUSBURBSTATE_ALLOCATED);
1851 PVUSBDEV pDev = pUrb->VUsb.pDev;
1862 pUrb->enmStatus = VUSBSTATUS_DNR;
1869 pUrb->VUsb.u64SubmitTS = RTTimeNanoTS();
1877 if (pUrb->EndPt >= VUSB_PIPE_MAX)
1879 Log(("%s: pDev=%p[%s]: SUBMIT: ep %i >= %i!!!\n", pUrb->pszDesc, pDev, pDev->pUsbIns->pszName, pUrb->EndPt, VUSB_PIPE_MAX));
1880 return vusbUrbSubmitHardError(pUrb);
1883 switch (pUrb->enmDir)
1886 pEndPtDesc = pDev->aPipes[pUrb->EndPt].in;
1887 pPipe = &pDev->aPipes[pUrb->EndPt];
1892 pEndPtDesc = pDev->aPipes[pUrb->EndPt].out;
1898 pUrb->pszDesc, pDev, pDev->pUsbIns->pszName, vusbUrbDirName(pUrb->enmDir), pUrb->EndPt));
1899 return vusbUrbSubmitHardError(pUrb);
1906 if ((pEndPtDesc->Core.bmAttributes & 0x3) != pUrb->enmType)
1909 pUrb->pszDesc, pDev, pDev->pUsbIns->pszName, vusbUrbTypeName(pUrb->enmType), pEndPtDesc->Core.bmAttributes,
1910 pUrb->DstAddress, pUrb->EndPt, vusbUrbDirName(pUrb->enmDir)));
1911 return vusbUrbSubmitHardError(pUrb);
1921 rc = VUSBSnifferRecordEvent(pDev->hSniffer, pUrb, VUSBSNIFFEREVENT_SUBMIT);
1929 rc = vusbUrbSubmitBufferedRead(pUrb, pPipe->hReadAhead);
1937 pUrb->enmState = VUSBURBSTATE_IN_FLIGHT;
1938 switch (pUrb->enmType)
1941 rc = vusbUrbSubmitCtrl(pUrb);
1944 rc = vusbUrbSubmitBulk(pUrb);
1947 rc = vusbUrbSubmitInterrupt(pUrb);
1950 rc = vusbUrbSubmitIsochronous(pUrb);
1953 AssertMsgFailed(("Unexpected pUrb type %d\n", pUrb->enmType));
1954 return vusbUrbSubmitHardError(pUrb);
1962 rc = vusbUrbSubmitHardError(pUrb);
1969 && !ASMAtomicReadU32(&pDev->aPipes[pUrb->EndPt].async)
1970 /* && pUrb->enmType == VUSBXFERTYPE_BULK ?? */
1971 && !vusbUrbErrorRh(pUrb))
1974 pUrb->enmState = VUSBURBSTATE_REAPED;
1975 pUrb->enmStatus = VUSBSTATUS_CRC;
1976 vusbUrbCompletionRh(pUrb);
1993 PVUSBURB pUrb = pHead;
1994 while (pUrb)
1996 vusbUrbAssert(pUrb);
1997 PVUSBURB pUrbNext = pUrb->VUsb.pNext;
1998 PVUSBDEV pDev = pUrb->VUsb.pDev;
2024 pUrb = pUrbNext;
2067 static void vusbUrbCompletion(PVUSBURB pUrb)
2069 Assert(pUrb->VUsb.pDev->aPipes);
2070 ASMAtomicDecU32(&pUrb->VUsb.pDev->aPipes[pUrb->EndPt].async);
2072 if (pUrb->enmState == VUSBURBSTATE_REAPED)
2073 vusbUrbUnlink(pUrb);
2076 if (pUrb->Hci.pNext != NULL)
2077 vusbUrbCompletionReadAhead(pUrb);
2080 vusbUrbCompletionRh(pUrb);
2087 * @param pUrb The URB to cancel.
2090 DECLHIDDEN(int) vusbUrbCancelWorker(PVUSBURB pUrb, CANCELMODE enmMode)
2092 vusbUrbAssert(pUrb);
2094 PVUSBROOTHUB pRh = vusbDevGetRh(pUrb->VUsb.pDev);
2096 if (pUrb->enmState == VUSBURBSTATE_IN_FLIGHT)
2098 LogFlow(("%s: vusbUrbCancel: Canceling in-flight\n", pUrb->pszDesc));
2100 if (pUrb->enmType != VUSBXFERTYPE_MSG)
2102 STAM_STATS({Assert(pUrb->enmType >= 0 && pUrb->enmType < (int)RT_ELEMENTS(pRh->aTypes));});
2103 STAM_COUNTER_INC(&pRh->aTypes[pUrb->enmType].StatUrbsCancelled);
2106 pUrb->enmState = VUSBURBSTATE_CANCELLED;
2107 PPDMUSBINS pUsbIns = pUrb->pUsbIns;
2108 pUsbIns->pReg->pfnUrbCancel(pUsbIns, pUrb);
2109 Assert(pUrb->enmState == VUSBURBSTATE_CANCELLED || pUrb->enmState == VUSBURBSTATE_REAPED);
2111 pUrb->enmStatus = VUSBSTATUS_CRC;
2112 vusbUrbCompletion(pUrb);
2114 else if (pUrb->enmState == VUSBURBSTATE_REAPED)
2116 LogFlow(("%s: vusbUrbCancel: Canceling reaped urb\n", pUrb->pszDesc));
2118 if (pUrb->enmType != VUSBXFERTYPE_MSG)
2120 STAM_STATS({Assert(pUrb->enmType >= 0 && pUrb->enmType < (int)RT_ELEMENTS(pRh->aTypes));});
2121 STAM_COUNTER_INC(&pRh->aTypes[pUrb->enmType].StatUrbsCancelled);
2124 pUrb->enmStatus = VUSBSTATUS_CRC;
2125 vusbUrbCompletion(pUrb);
2129 AssertMsg(pUrb->enmState == VUSBURBSTATE_CANCELLED, ("Invalid state %d, pUrb=%p\n", pUrb->enmState, pUrb));
2135 pUrb->enmStatus = VUSBSTATUS_CRC;
2138 pUrb->enmStatus = VUSBSTATUS_UNDO;
2167 * @param pUrb The URB to cancel.
2170 void vusbUrbCancel(PVUSBURB pUrb, CANCELMODE mode)
2172 int rc = vusbDevIoThreadExecSync(pUrb->VUsb.pDev, (PFNRT)vusbUrbCancelWorker, 2, pUrb, mode);
2180 void vusbUrbCancelAsync(PVUSBURB pUrb, CANCELMODE mode)
2182 int rc = vusbDevIoThreadExec(pUrb->VUsb.pDev, 0 /* fFlags */, (PFNRT)vusbUrbCancelWorker, 2, pUrb, mode);
2194 * @param pUrb The URB.
2196 void vusbUrbRipe(PVUSBURB pUrb)
2198 if ( pUrb->enmState == VUSBURBSTATE_IN_FLIGHT
2199 || pUrb->enmState == VUSBURBSTATE_REAPED)
2201 pUrb->enmState = VUSBURBSTATE_REAPED;
2202 vusbUrbCompletion(pUrb);
2204 else if (pUrb->enmState == VUSBURBSTATE_CANCELLED)
2206 vusbUrbUnlink(pUrb);
2207 LogFlow(("%s: vusbUrbRipe: Freeing cancelled URB\n", pUrb->pszDesc));
2208 pUrb->VUsb.pfnFree(pUrb);
2211 AssertMsgFailed(("Invalid URB state %d; %s\n", pUrb->enmState, pUrb->pszDesc));