ReactOS 0.4.17-dev-1281-g065abb3
UcxEndpoint Class Reference

#include <pipe.h>

Collaboration diagram for UcxEndpoint:

Public Member Functions

VOID SetWdfIoQueue (_In_ WDFQUEUE Queue)
 
VOID NeedToCancelTransfers ()
 
UCXSSTREAMS GetStaticStreamsReferenced (_In_ PVOID Tag)
 
VOID DeleteFromHub ()
 
VOID ReleaseCancelSync ()
 
VOID HandleHubReset (_In_ WDFREQUEST Request)
 
NTSTATUS OnHcdResetDone (_In_ PIRP Irp)
 
NTSTATUS OpenStaticStreams (_In_ PIRP Irp, _In_ PURB Urb)
 
NTSTATUS CloseStaticStreams (_In_ PIRP Irp, _In_ PURB Urb)
 
VOID HandleClientStreamsEnable (_In_ WDFREQUEST Request)
 
VOID HandleClientStreamsDisable (_In_ WDFREQUEST Request)
 
NTSTATUS OpenStaticStreamsComplete (_In_ PIRP Irp, _In_ PURB Urb)
 
NTSTATUS CloseStaticStreamsComplete (_In_ PIRP Irp)
 
NTSTATUS AbortPipe (_In_ PIRP Irp, _In_ PURB Urb)
 
NTSTATUS GetIsochPathDelays (_In_ PIRP Irp, _In_ PURB Urb)
 
BOOLEAN HasMachine () const
 
BOOLEAN Post (_In_ EpEvent Event)
 
PVOID TakePending ()
 
VOID SetPending (_In_ PVOID Pending)
 

Static Public Member Functions

static _Must_inspect_result_ NTSTATUS Create (_In_ UCXUSBDEVICE UsbDevice, _Inout_ PUCXENDPOINT_INIT *EndpointInit, _In_opt_ PWDF_OBJECT_ATTRIBUTES Attributes, _Out_ UCXENDPOINT *Endpoint)
 
static VOID InitSetEventCallbacks (_Inout_ PUCXENDPOINT_INIT Init, _In_ PUCX_ENDPOINT_EVENT_CALLBACKS Callbacks)
 
static VOID InitSetDefaultEventCallbacks (_Inout_ PUCXENDPOINT_INIT Init, _In_ PUCX_DEFAULT_ENDPOINT_EVENT_CALLBACKS Callbacks)
 
static _Must_inspect_result_ NTSTATUS CreateDefaultFromHub (_In_ UCXUSBDEVICE UsbDevice, _In_ ULONG MaxPacketSize, _Out_ UCXENDPOINT *Endpoint)
 
static _Must_inspect_result_ NTSTATUS CreateFromHub (_In_ UCXUSBDEVICE UsbDevice, _In_ PUSB_ENDPOINT_DESCRIPTOR Descriptor, _In_ ULONG DescriptorBufferLength, _In_opt_ PUSB_SUPERSPEED_ENDPOINT_COMPANION_DESCRIPTOR Companion, _Out_ UCXENDPOINT *Endpoint)
 
static UcxEndpoint * FromHandle (_In_ UCXENDPOINT Handle)
 
static UcxEndpoint * FromPipe (_In_ USBD_PIPE_HANDLE Handle)
 

Public Attributes

UCXENDPOINT m_Handle
 
UcxController * m_Controller
 
UcxUsbDevice * m_Device
 
UcxPipe m_Pipe
 
UcxStaticStreams * m_Streams
 
LONG m_StreamsOpenCount
 
UcxEndpointCallbacks m_Callbacks
 
USB_ENDPOINT_DESCRIPTOR m_Descriptor
 
LIST_ENTRY m_DeviceLink
 
LIST_ENTRY m_TrackingLink
 
LIST_ENTRY m_DisconnectLink
 
LIST_ENTRY m_ControllerResetLink
 
LIST_ENTRY m_TreePurgeLink
 
LIST_ENTRY m_OperationLink
 
EndpointMachine m_Machine
 
BOOLEAN m_HasMachine
 
PVOID m_Pending
 
BOOLEAN m_OpenFailedOnReset
 
IO_CSQ_IRP_CONTEXT m_AbortCsqContext
 
LONG m_CancelSync
 
BOOLEAN m_ClientHoldsHandle
 
BOOLEAN m_ClearTtOnCancel
 

Private Member Functions

VOID Initialize (_In_ UcxUsbDevice *Device, _In_ const UcxEndpointInit *Init)
 

Static Private Member Functions

static NTSTATUS CreateThroughHcd (_In_ UcxUsbDevice *Device, _Inout_ UcxEndpointInit *Init, _In_ ULONG MaxPacketSize, _In_opt_ PUSB_ENDPOINT_DESCRIPTOR Descriptor, _In_ ULONG DescriptorBufferLength, _In_opt_ PUSB_SUPERSPEED_ENDPOINT_COMPANION_DESCRIPTOR Companion, _Out_ UCXENDPOINT *Endpoint)
 

Static Private Attributes

static EVT_WDF_OBJECT_CONTEXT_DESTROY EvtDestroy
 

Friends

class EndpointMachine
 

Detailed Description

Definition at line 121 of file pipe.h.

Member Function Documentation

◆ AbortPipe()

NTSTATUS UcxEndpoint::AbortPipe ( _In_ PIRP  Irp,
_In_ PURB  Urb 
)

Only a running endpoint takes the abort; the IRP waits in the cancel safe queue.

Definition at line 38 of file pipeio.cpp.

41{
42 if (!m_HasMachine || !Post(EpEvent::ClientAbortUrb))
43 {
44 DPRINT1("Endpoint %p abort pipe failed, endpoint is not running\n", m_Handle);
45 return UcxCompleteUrb(Irp,
46 Urb,
49 }
50
52 Post(EpEvent::AbortUrbParked);
53
54 return STATUS_PENDING;
55}
#define DPRINT1
Definition: precomp.h:8
IO_CSQ m_AbortPipeCsq
Definition: hostctl.h:306
UcxController * m_Controller
Definition: pipe.h:282
BOOLEAN Post(_In_ EpEvent Event)
Definition: pipe.h:255
IO_CSQ_IRP_CONTEXT m_AbortCsqContext
Definition: pipe.h:308
UCXENDPOINT m_Handle
Definition: pipe.h:281
BOOLEAN m_HasMachine
Definition: pipe.h:303
NTSTATUS NTAPI UcxCompleteUrb(_In_ PIRP Irp, _In_ PURB Urb, _In_ NTSTATUS Status, _In_ USBD_STATUS UsbdStatus)
Definition: clientxrb.cpp:23
NTKERNELAPI VOID NTAPI IoCsqInsertIrp(_Inout_ PIO_CSQ Csq, _Inout_ PIRP Irp, _Out_opt_ PIO_CSQ_IRP_CONTEXT Context)
Insert an IRP into the CSQ.
Definition: csq.c:177
_In_ PIRP Irp
Definition: kse.h:79
#define STATUS_PENDING
Definition: telnetd.h:14
#define STATUS_NO_SUCH_DEVICE
Definition: udferr_usr.h:136
USBD_STATUS NTAPI UcxNtStatusToUsbdStatus(_In_ NTSTATUS Status)
Definition: urbroute.cpp:53
_In_opt_ PUSB_CONFIGURATION_DESCRIPTOR _Inout_ PUSBD_INTERFACE_LIST_ENTRY _Outptr_ PURB * Urb
Definition: usbdlib.h:333

Referenced by AbortPipe().

◆ CloseStaticStreams()

NTSTATUS UcxEndpoint::CloseStaticStreams ( _In_ PIRP  Irp,
_In_ PURB  Urb 
)

Definition at line 267 of file pipeio.cpp.

270{
273
275 {
276 DPRINT1("Endpoint %p streams close at IRQL %u\n", m_Handle, KeGetCurrentIrql());
278 }
279
280 if (m_Streams == NULL)
281 {
282 DPRINT1("Endpoint %p streams close with no streams open\n", m_Handle);
284 }
285
287}
UcxRootHub * m_RootHub
Definition: hostctl.h:302
BOOLEAN m_RootHubInD0
Definition: hostctl.h:323
UcxStaticStreams * m_Streams
Definition: pipe.h:286
WDFDEVICE Pdo() const
Definition: rhub.h:108
NTSTATUS NTAPI UcxForwardStreamsUrb(_In_ WDFDEVICE RootHubPdo, _In_ PIRP Irp, _In_ PURB Urb, _In_ UcxController *Controller)
Definition: clientxrb.cpp:212
#define NULL
Definition: types.h:112
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
static NTSTATUS NTAPI UcxFailStreamsUrb(_In_ PIRP Irp, _In_ PURB Urb, _In_ NTSTATUS Status)
Definition: pipeio.cpp:100
#define STATUS_SUCCESS
Definition: shellext.h:65
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define STATUS_INVALID_DEVICE_STATE
Definition: udferr_usr.h:178
#define USBD_STATUS_SUCCESS
Definition: usb.h:177

Referenced by CloseStaticStreams(), and UcxProcessSubmitUrb().

◆ CloseStaticStreamsComplete()

NTSTATUS UcxEndpoint::CloseStaticStreamsComplete ( _In_ PIRP  Irp)

Definition at line 361 of file pipeio.cpp.

363{
365 Post(EpEvent::StreamsClosed);
366
368}
VOID SetPending(_In_ PVOID Pending)
Definition: pipe.h:273
#define STATUS_MORE_PROCESSING_REQUIRED
Definition: shellext.h:68

Referenced by CloseStaticStreamsComplete().

◆ Create()

_Must_inspect_result_ NTSTATUS UcxEndpoint::Create ( _In_ UCXUSBDEVICE  UsbDevice,
_Inout_ PUCXENDPOINT_INIT *  EndpointInit,
_In_opt_ PWDF_OBJECT_ATTRIBUTES  Attributes,
_Out_ UCXENDPOINT *  Endpoint 
)
static

Definition at line 195 of file pipe.cpp.

200{
203 WDF_OBJECT_ATTRIBUTES Primary;
207
208 *Endpoint = NULL;
209
210 /* Parented to the init block's device, referenced through the parameter */
212 Primary.ParentObject = Init->Device;
214
216 if (!NT_SUCCESS(Status))
217 {
218 DPRINT1("Endpoint object create failed for UsbDevice %p 0x%lx\n", UsbDevice, Status);
219 return Status;
220 }
221
223
224 Context = new (UcxGetEndpointContext(Object)) UcxEndpoint();
225 Context->m_Handle = (UCXENDPOINT)Object;
226 Context->Initialize(Device, Init);
227
228 if (Init->CreateMachine)
229 {
230 Context->m_Machine.Initialize(Context);
231 Context->m_HasMachine = TRUE;
232
233 /* Creation reference, dropped by the machine once it deletes the object */
235 }
236
237 /* Recorded before the disconnect check, so a failure leaves them behind */
238 if (Init->Kind == UcxEndpointKind::Default)
239 {
240 NT_ASSERT(Device->m_DefaultEndpoint == NULL);
241 Device->m_DefaultEndpoint = Context;
242 Device->m_DefaultPipe = &Context->m_Pipe;
243 }
244
245 {
246 SpinLockGuard Guard(&Context->m_Controller->m_TopologyLock);
247
248 if (Device->m_Disconnected)
249 {
251 }
252 else
253 {
254 InsertHeadList(&Device->m_EndpointList, &Context->m_DeviceLink);
255 Context->m_Controller->m_ChildEndpointCount++;
256 }
257 }
258
259 if (!NT_SUCCESS(Status))
260 {
261 DPRINT1("Endpoint %p not created, UsbDevice %p is disconnected\n", Object, UsbDevice);
262
263 if (Context->m_HasMachine)
265
267 return Status;
268 }
269
270 /* Tracking may have been turned on after the insert above and taken it already */
271 if (Device->m_StalePipeIoAllowed)
272 {
273 SpinLockGuard Guard(&Device->m_TrackingLock);
274
275 if (!UcxIsListEntryLinked(&Context->m_TrackingLink))
276 InsertTailList(&Device->m_TrackingList, &Context->m_TrackingLink);
277 }
278
279 DPRINT("Endpoint %p address 0x%x created on UsbDevice %p\n",
280 Context->m_Handle, Context->m_Descriptor.bEndpointAddress, UsbDevice);
281
282 *Endpoint = Context->m_Handle;
283 Init->Created = Context->m_Handle;
285
286 return STATUS_SUCCESS;
287}
LONG NTSTATUS
Definition: precomp.h:26
static EVT_WDF_OBJECT_CONTEXT_DESTROY EvtDestroy
Definition: pipe.h:334
static UcxUsbDevice * FromHandle(_In_ UCXUSBDEVICE Handle)
Definition: devobj.cpp:18
_In_ ULONG Attributes
Definition: dispmprt.h:1077
#define TRUE
Definition: types.h:120
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define InsertTailList(ListHead, Entry)
#define InsertHeadList(ListHead, Entry)
Status
Definition: gdiplustypes.h:24
_In_ UCXUSBDEVICE UsbDevice
Definition: hostctl.h:31
_Must_inspect_result_ _In_ PUCXHUB_DEVICE_CREATE_INFO _Out_ UCXUSBDEVICE * Device
Definition: hubucx.h:258
_In_ UCXHUB_DEVICE_CONTEXT _In_ UCXENDPOINT Endpoint
Definition: hubucx.h:238
_In_ PIRP _In_ PIO_COMPLETION_ROUTINE _In_ PVOID Context
Definition: kse.h:81
#define DPRINT
Definition: sndvol32.h:73
WDFOBJECT ParentObject
Definition: wdfobject.h:130
PFN_WDF_OBJECT_CONTEXT_DESTROY EvtDestroyCallback
Definition: wdfobject.h:115
_Must_inspect_result_ _In_ UCXUSBDEVICE _Inout_ PUCXENDPOINT_INIT * EndpointInit
Definition: ucxendpoint.h:314
_Must_inspect_result_ NTSTATUS NTAPI UcxCreateObjectWithTwoContexts(_In_ PWDF_OBJECT_ATTRIBUTES Primary, _In_opt_ PWDF_OBJECT_ATTRIBUTES Secondary, _Out_ WDFOBJECT *Object)
Definition: ucxutil.cpp:19
FORCEINLINE BOOLEAN NTAPI UcxIsListEntryLinked(_In_ const LIST_ENTRY *Entry)
Definition: ucxutil.h:94
#define STATUS_DEVICE_NOT_CONNECTED
Definition: udferr_usr.h:160
WdfObjectDelete(String)
_Must_inspect_result_ _In_ WDFCOLLECTION _In_ WDFOBJECT Object
#define WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(_attributes, _contexttype)
Definition: wdfobject.h:170
#define WdfObjectReference(Handle)
Definition: wdfobject.h:803
#define WdfObjectDereference(Handle)
Definition: wdfobject.h:826
#define NT_ASSERT
Definition: rtlfuncs.h:3334

Referenced by Create().

◆ CreateDefaultFromHub()

_Must_inspect_result_ NTSTATUS UcxEndpoint::CreateDefaultFromHub ( _In_ UCXUSBDEVICE  UsbDevice,
_In_ ULONG  MaxPacketSize,
_Out_ UCXENDPOINT *  Endpoint 
)
static

Definition at line 451 of file pipe.cpp.

455{
457
458 RtlZeroMemory(&Init, sizeof(Init));
459 Init.Kind = UcxEndpointKind::Default;
460 Init.TransferType = UcxTransferType::Control;
461
462 return CreateThroughHcd(UcxUsbDevice::FromHandle(UsbDevice), &Init, MaxPacketSize, NULL, 0, NULL, Endpoint);
463}
static NTSTATUS CreateThroughHcd(_In_ UcxUsbDevice *Device, _Inout_ UcxEndpointInit *Init, _In_ ULONG MaxPacketSize, _In_opt_ PUSB_ENDPOINT_DESCRIPTOR Descriptor, _In_ ULONG DescriptorBufferLength, _In_opt_ PUSB_SUPERSPEED_ENDPOINT_COMPANION_DESCRIPTOR Companion, _Out_ UCXENDPOINT *Endpoint)
Definition: pipe.cpp:392
_Must_inspect_result_ _In_ UCXUSBDEVICE _In_ ULONG MaxPacketSize
Definition: hubucx.h:289
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262

Referenced by CreateDefaultFromHub().

◆ CreateFromHub()

_Must_inspect_result_ NTSTATUS UcxEndpoint::CreateFromHub ( _In_ UCXUSBDEVICE  UsbDevice,
_In_ PUSB_ENDPOINT_DESCRIPTOR  Descriptor,
_In_ ULONG  DescriptorBufferLength,
_In_opt_ PUSB_SUPERSPEED_ENDPOINT_COMPANION_DESCRIPTOR  Companion,
_Out_ UCXENDPOINT *  Endpoint 
)
static

Definition at line 467 of file pipe.cpp.

473{
474 static const UcxTransferType TypeFromAttributes[4] =
475 {
476 UcxTransferType::Control,
477 UcxTransferType::Isochronous,
478 UcxTransferType::Bulk,
479 UcxTransferType::Interrupt
480 };
482
483 RtlZeroMemory(&Init, sizeof(Init));
484 Init.TransferType = TypeFromAttributes[Descriptor->bmAttributes & USB_ENDPOINT_TYPE_MASK];
485 Init.Kind = (Descriptor->wMaxPacketSize == 0) ? UcxEndpointKind::ZeroBandwidth : UcxEndpointKind::Generic;
486 RtlCopyMemory(&Init.Descriptor, Descriptor, sizeof(Init.Descriptor));
487
488 if (Companion != NULL)
489 {
490 RtlCopyMemory(&Init.Companion, Companion, sizeof(Init.Companion));
491 Init.HasCompanion = TRUE;
492
493 /* The SuperSpeedPlus companion follows right after; the buffer length is not checked */
494 if (Init.TransferType == UcxTransferType::Isochronous &&
495 Companion->bmAttributes.Isochronous.SspCompanion)
496 {
497 RtlCopyMemory(&Init.IsochCompanion,
498 (PUCHAR)Companion + Companion->bLength,
499 sizeof(Init.IsochCompanion));
500 Init.HasIsochCompanion = TRUE;
501 }
502 }
503
504 return CreateThroughHcd(UcxUsbDevice::FromHandle(UsbDevice),
505 &Init,
506 0,
509 Companion,
510 Endpoint);
511}
_Must_inspect_result_ _In_ UCXUSBDEVICE _In_ ULONG _In_opt_ PUSB_SUPERSPEED_ENDPOINT_COMPANION_DESCRIPTOR Companion
Definition: hubucx.h:308
_Must_inspect_result_ _In_ UCXUSBDEVICE _In_ ULONG DescriptorBufferLength
Definition: hubucx.h:307
UcxTransferType
Definition: pipe.h:20
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
unsigned char * PUCHAR
Definition: typedefs.h:53
#define USB_ENDPOINT_TYPE_MASK
Definition: usb100.h:61
_Must_inspect_result_ _In_ WDFIORESLIST _In_ PIO_RESOURCE_DESCRIPTOR Descriptor
Definition: wdfresource.h:342

Referenced by CreateFromHub().

◆ CreateThroughHcd()

NTSTATUS UcxEndpoint::CreateThroughHcd ( _In_ UcxUsbDevice *  Device,
_Inout_ UcxEndpointInit *  Init,
_In_ ULONG  MaxPacketSize,
_In_opt_ PUSB_ENDPOINT_DESCRIPTOR  Descriptor,
_In_ ULONG  DescriptorBufferLength,
_In_opt_ PUSB_SUPERSPEED_ENDPOINT_COMPANION_DESCRIPTOR  Companion,
_Out_ UCXENDPOINT *  Endpoint 
)
staticprivate

Definition at line 392 of file pipe.cpp.

400{
401 const UCX_USBDEVICE_EVENT_CALLBACKS* Hcd = &Device->m_Callbacks.Public;
402 UCXCONTROLLER Controller = Device->m_Controller->m_Handle;
404
405 PAGED_CODE();
406
407 Init->Device = Device->m_Handle;
408 Init->CreateMachine = TRUE;
409
410 if (Init->Kind == UcxEndpointKind::Default)
411 {
413 }
414 else
415 {
417 Device->m_Handle,
420 Companion,
421 Init);
422 }
423
424 if (!NT_SUCCESS(Status))
425 DPRINT1("UsbDevice %p HCD endpoint add failed 0x%lx\n", Device->m_Handle, Status);
426
427 /* Success without an endpoint or a queue leaves nothing to send transfers to */
428 if (NT_SUCCESS(Status) &&
429 (Init->Created == NULL || FromHandle(Init->Created)->m_Pipe.Queue == NULL))
430 {
431 DPRINT1("UsbDevice %p HCD endpoint add set no endpoint %p or no queue\n", Device->m_Handle, Init->Created);
432 UcxVerifierBreak(Device->m_Controller->m_DriverVerifierEnabled);
434 }
435
436 if (NT_SUCCESS(Status))
437 {
438 *Endpoint = Init->Created;
439 return Status;
440 }
441
442 *Endpoint = NULL;
443 if (Init->Created != NULL)
444 FromHandle(Init->Created)->DeleteFromHub();
445
446 return Status;
447}
#define PAGED_CODE()
static UcxEndpoint * FromHandle(_In_ UCXENDPOINT Handle)
Definition: pipe.cpp:91
UcxPipe m_Pipe
Definition: pipe.h:284
VOID DeleteFromHub()
Definition: pipe.cpp:515
#define STATUS_INTERNAL_ERROR
Definition: ntstatus.h:559
WDFQUEUE Queue
Definition: pipe.h:31
PFN_UCX_USBDEVICE_ENDPOINT_ADD EvtUsbDeviceEndpointAdd
Definition: ucxusbdevice.h:354
PFN_UCX_USBDEVICE_DEFAULT_ENDPOINT_ADD EvtUsbDeviceDefaultEndpointAdd
Definition: ucxusbdevice.h:353
_Must_inspect_result_ _In_ WDFDEVICE _In_ PUCX_CONTROLLER_CONFIG _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ UCXCONTROLLER * Controller
FORCEINLINE VOID NTAPI UcxVerifierBreak(_In_ BOOLEAN Verifying)
Definition: ucxutil.h:168

Referenced by CreateDefaultFromHub(), CreateFromHub(), and CreateThroughHcd().

◆ DeleteFromHub()

VOID UcxEndpoint::DeleteFromHub ( )

Definition at line 515 of file pipe.cpp.

516{
517 Post(EpEvent::Delete);
518}

Referenced by CreateThroughHcd(), DeleteFromHub(), and UcxHubEndpointDelete().

◆ FromHandle()

UcxEndpoint * UcxEndpoint::FromHandle ( _In_ UCXENDPOINT  Handle)
static

Definition at line 91 of file pipe.cpp.

93{
94 return UcxGetEndpointContext(Handle);
95}
ULONG Handle
Definition: gdb_input.c:15

Referenced by CreateThroughHcd(), and FromHandle().

◆ FromPipe()

static UcxEndpoint * UcxEndpoint::FromPipe ( _In_ USBD_PIPE_HANDLE  Handle)
inlinestatic

Definition at line 241 of file pipe.h.

243 {
245 }
static UcxPipe * FromHandle(_In_ USBD_PIPE_HANDLE Handle)
Definition: pipe.h:53
UcxEndpoint * Endpoint
Definition: pipe.h:32

◆ GetIsochPathDelays()

NTSTATUS UcxEndpoint::GetIsochPathDelays ( _In_ PIRP  Irp,
_In_ PURB  Urb 
)

Answered by the controller driver when it has the callback, otherwise not supported.

Definition at line 59 of file pipeio.cpp.

62{
63 struct _URB_GET_ISOCH_PIPE_TRANSFER_PATH_DELAYS* Request = &Urb->UrbGetIsochPipeTransferPathDelays;
66
67 if (m_Pipe.TransferType != UcxTransferType::Isochronous)
68 {
69 DPRINT1("Endpoint %p path delay query on a non isoch pipe\n", m_Handle);
71 }
72
74 {
75 DPRINT("Endpoint %p has no path delay callback\n", m_Handle);
77 }
78
79 RtlZeroMemory(&Delays, sizeof(Delays));
81 if (NT_SUCCESS(Status))
82 {
83 Request->MaximumSendPathDelayInMilliSeconds = Delays.MaximumSendPathDelayInMilliSeconds;
84 Request->MaximumCompletionPathDelayInMilliSeconds = Delays.MaximumCompletionPathDelayInMilliSeconds;
85 }
86 else
87 {
88 DPRINT1("Endpoint %p path delay callback failed 0x%lx\n", m_Handle, Status);
89 }
90
92}
UcxEndpointCallbacks m_Callbacks
Definition: pipe.h:289
#define STATUS_NOT_SUPPORTED
Definition: d3dkmdt.h:48
PFN_UCX_ENDPOINT_GET_ISOCH_TRANSFER_PATH_DELAYS GetIsochTransferPathDelays
Definition: pipe.h:87
UcxTransferType TransferType
Definition: pipe.h:33
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFREQUEST Request
#define USBD_STATUS_NOT_SUPPORTED
Definition: usb.h:213
#define USBD_STATUS_INVALID_PARAMETER
Definition: usb.h:203

Referenced by GetIsochPathDelays(), and UcxProcessSubmitUrb().

◆ GetStaticStreamsReferenced()

UCXSSTREAMS UcxEndpoint::GetStaticStreamsReferenced ( _In_ PVOID  Tag)

Definition at line 370 of file pipe.cpp.

372{
373 UCXSSTREAMS Streams = NULL;
374
375 if (m_Streams == NULL)
376 return NULL;
377
379
380 if (m_Streams != NULL)
381 {
382 Streams = m_Streams->m_Handle;
384 }
385
386 return Streams;
387}
KSPIN_LOCK m_TopologyLock
Definition: hostctl.h:310
UCXSSTREAMS m_Handle
Definition: pipe.h:380
_Must_inspect_result_ _In_ UCXENDPOINT _In_ PVOID Tag
Definition: ucxendpoint.h:325
#define WdfObjectReferenceWithTag(Handle, Tag)
Definition: wdfobject.h:806

Referenced by GetStaticStreamsReferenced(), and UcxApiEndpointGetStaticStreamsReferenced().

◆ HandleClientStreamsDisable()

VOID UcxEndpoint::HandleClientStreamsDisable ( _In_ WDFREQUEST  Request)

Definition at line 298 of file pipeio.cpp.

300{
302 Post(EpEvent::ClientStreamsDisable);
303}

Referenced by UcxUsbDevice::DispatchManagement(), UcxUsbDevice::FailManagement(), and HandleClientStreamsDisable().

◆ HandleClientStreamsEnable()

VOID UcxEndpoint::HandleClientStreamsEnable ( _In_ WDFREQUEST  Request)

Definition at line 290 of file pipeio.cpp.

292{
294 Post(EpEvent::ClientStreamsEnable);
295}

Referenced by UcxUsbDevice::DispatchManagement(), and HandleClientStreamsEnable().

◆ HandleHubReset()

VOID UcxEndpoint::HandleHubReset ( _In_ WDFREQUEST  Request)

Definition at line 16 of file pipeio.cpp.

18{
20 Post(EpEvent::HubEndpointReset);
21}

Referenced by UcxUsbDevice::DispatchManagement(), and HandleHubReset().

◆ HasMachine()

BOOLEAN UcxEndpoint::HasMachine ( ) const
inline

Definition at line 248 of file pipe.h.

249 {
250 return m_HasMachine;
251 }

◆ Initialize()

VOID UcxEndpoint::Initialize ( _In_ UcxUsbDevice *  Device,
_In_ const UcxEndpointInit *  Init 
)
private

Definition at line 143 of file pipe.cpp.

146{
147 USB_DEVICE_SPEED Speed = Device->Speed();
148
149 m_Controller = Device->m_Controller;
151 m_Callbacks = Init->Callbacks;
152 m_Descriptor = Init->Descriptor;
153
154 m_Pipe.Endpoint = this;
155 m_Pipe.Kind = Init->Kind;
156 m_Pipe.TransferType = Init->TransferType;
157 m_Pipe.Self = &m_Pipe;
159
160 if (Init->TransferType != UcxTransferType::Control)
162
163 if (Init->TransferType == UcxTransferType::Isochronous)
164 {
165 if (UcxIsSlowSpeed(Speed))
166 {
169 }
170 else
171 {
172 /* bInterval 0 wraps to the top bit, as the x86 shift does */
175 }
176 }
177
178 /* Only async transfers of slow devices behind a real TT need the TT cleared */
180 Init->TransferType != UcxTransferType::Interrupt &&
181 Init->TransferType != UcxTransferType::Isochronous &&
182 UcxIsSlowSpeed(Speed) &&
183 Device->m_Info.TtHub != NULL;
184
191}
BOOLEAN m_ClearTtBufferOnAsyncCancel
Definition: hostctl.h:337
USB_ENDPOINT_DESCRIPTOR m_Descriptor
Definition: pipe.h:290
LIST_ENTRY m_ControllerResetLink
Definition: pipe.h:298
LIST_ENTRY m_TreePurgeLink
Definition: pipe.h:299
UcxUsbDevice * m_Device
Definition: pipe.h:283
LIST_ENTRY m_DisconnectLink
Definition: pipe.h:297
LIST_ENTRY m_TrackingLink
Definition: pipe.h:294
LIST_ENTRY m_OperationLink
Definition: pipe.h:300
LIST_ENTRY m_DeviceLink
Definition: pipe.h:293
BOOLEAN m_ClearTtOnCancel
Definition: pipe.h:314
#define FALSE
Definition: types.h:117
static BOOLEAN NTAPI UcxIsSlowSpeed(_In_ USB_DEVICE_SPEED Speed)
Definition: pipe.cpp:41
ULONG NTAPI UcxComputeMaxTransferSize(_In_ USB_DEVICE_SPEED Speed, _In_ USHORT BcdUsb, _In_ const UcxEndpointInit *Init)
Definition: pipe.cpp:49
UcxPipe * Self
Definition: pipe.h:40
ULONG IsochPacketLimit
Definition: pipe.h:38
UcxEndpointKind Kind
Definition: pipe.h:34
ULONG MaximumTransferSize
Definition: pipe.h:37
ULONG IsochPeriodMicroframes
Definition: pipe.h:39
BOOLEAN DirectionIn
Definition: pipe.h:36
FORCEINLINE VOID NTAPI UcxClearListEntry(_Out_ PLIST_ENTRY Entry)
Definition: ucxutil.h:84
#define USB_ENDPOINT_DIRECTION_IN(x)
Definition: usb100.h:76
enum _USB_DEVICE_SPEED USB_DEVICE_SPEED

Referenced by Initialize().

◆ InitSetDefaultEventCallbacks()

VOID UcxEndpoint::InitSetDefaultEventCallbacks ( _Inout_ PUCXENDPOINT_INIT  Init,
_In_ PUCX_DEFAULT_ENDPOINT_EVENT_CALLBACKS  Callbacks 
)
static

Definition at line 125 of file pipe.cpp.

128{
129 UcxEndpointCallbacks* Target = &Init->Callbacks;
130
131 NT_ASSERT(Callbacks->Size == sizeof(*Callbacks));
132 NT_ASSERT(Init->Kind == UcxEndpointKind::Default);
133
134 Target->DefaultEndpointUpdate = Callbacks->EvtDefaultEndpointUpdate;
135 Target->Purge = Callbacks->EvtEndpointPurge;
136 Target->Start = Callbacks->EvtEndpointStart;
137 Target->Abort = Callbacks->EvtEndpointAbort;
138 Target->OkToCancelTransfers = Callbacks->EvtEndpointOkToCancelTransfers;
139 Target->EnableForwardProgress = (PFN_UCX_HCD_ENDPOINT_ENABLE_FORWARD_PROGRESS)Callbacks->Reserved1;
140}
const struct winhelp_callbacks Callbacks
Definition: callback.c:161
_In_ WDFIOTARGET Target
Definition: wdfrequest.h:306

Referenced by InitSetDefaultEventCallbacks().

◆ InitSetEventCallbacks()

VOID UcxEndpoint::InitSetEventCallbacks ( _Inout_ PUCXENDPOINT_INIT  Init,
_In_ PUCX_ENDPOINT_EVENT_CALLBACKS  Callbacks 
)
static

Definition at line 98 of file pipe.cpp.

101{
102 UcxEndpointCallbacks* Target = &Init->Callbacks;
103
104 NT_ASSERT(Init->Kind != UcxEndpointKind::Default);
105
106 Target->Purge = Callbacks->EvtEndpointPurge;
107 Target->Start = Callbacks->EvtEndpointStart;
108 Target->Abort = Callbacks->EvtEndpointAbort;
109 Target->Reset = Callbacks->EvtEndpointReset;
110 Target->OkToCancelTransfers = Callbacks->EvtEndpointOkToCancelTransfers;
111 Target->StaticStreamsAdd = Callbacks->EvtEndpointStaticStreamsAdd;
112 Target->StaticStreamsEnable = Callbacks->EvtEndpointStaticStreamsEnable;
113 Target->StaticStreamsDisable = Callbacks->EvtEndpointStaticStreamsDisable;
114 Target->EnableForwardProgress = (PFN_UCX_HCD_ENDPOINT_ENABLE_FORWARD_PROGRESS)Callbacks->Reserved1;
115
116 /* Appended by newer controller drivers, taken only from the full structure */
117 if (Callbacks->Size == sizeof(*Callbacks))
118 {
119 Target->GetIsochTransferPathDelays = Callbacks->EvtEndpointGetIsochTransferPathDelays;
120 Target->SetCharacteristic = Callbacks->EvtEndpointSetCharacteristic;
121 }
122}
HRESULT Reset([in] ID3D12CommandAllocator *allocator)
if(dx< 0)
Definition: linetemp.h:194

Referenced by InitSetEventCallbacks().

◆ NeedToCancelTransfers()

VOID UcxEndpoint::NeedToCancelTransfers ( )

Clears the TT buffer first for a low or full speed device behind a TT.

Definition at line 328 of file pipe.cpp.

329{
332
334 {
336 return;
337 }
338
339 /* A second call during a clear never gets its OK */
341 {
342 DPRINT1("Endpoint %p HCD asked to cancel transfers again during a TT clear\n", m_Handle);
344 return;
345 }
346
348
350 TtHub->m_HubClearTtBuffer(TtHub->m_HubContext,
352 m_Handle,
354 Path->PortPath[Path->TTHubDepth]);
355
357}
LONG m_CancelSync
Definition: pipe.h:311
VOID ReleaseCancelSync()
Definition: pipe.cpp:360
UCXUSBDEVICE_INFO m_Info
Definition: devobj.h:221
UCXHUB_DEVICE_CONTEXT m_HubDeviceContext
Definition: devobj.h:218
UNICODE_STRING Path
#define InterlockedCompareExchange
Definition: interlocked.h:119
PFN_UCX_ENDPOINT_OK_TO_CANCEL_TRANSFERS OkToCancelTransfers
Definition: pipe.h:81
UCXUSBDEVICE TtHub
Definition: ucxusbdevice.h:177
USB_DEVICE_PORT_PATH PortPath
Definition: ucxusbdevice.h:178

Referenced by NeedToCancelTransfers(), and UcxApiEndpointNeedToCancelTransfers().

◆ OnHcdResetDone()

NTSTATUS UcxEndpoint::OnHcdResetDone ( _In_ PIRP  Irp)

Definition at line 25 of file pipeio.cpp.

27{
29 Post(EpEvent::EndpointResetDone);
30
32}

Referenced by OnHcdResetDone(), and UcxDeviceMgmtCompletion().

◆ OpenStaticStreams()

NTSTATUS UcxEndpoint::OpenStaticStreams ( _In_ PIRP  Irp,
_In_ PURB  Urb 
)

Definition at line 171 of file pipeio.cpp.

174{
176 ULONG Count = Urb->UrbOpenStaticStreams.NumberOfStreams;
177 UcxStaticStreams* Streams;
180
181 if (Irql != PASSIVE_LEVEL)
182 {
183 DPRINT1("Endpoint %p streams open at IRQL %u\n", m_Handle, Irql);
184 if (Client->m_VerifierEnabled)
185 {
188 Irql,
189 (ULONG_PTR)Irp,
190 (ULONG_PTR)Client->m_ClientDeviceObject);
191 }
193 }
194
195 if (!Client->m_StreamsGranted)
196 {
197 DPRINT1("Endpoint %p streams open without a streams grant\n", m_Handle);
198 if (Client->m_VerifierEnabled)
199 {
202 (ULONG_PTR)Irp,
203 (ULONG_PTR)Urb,
204 (ULONG_PTR)Client->m_ClientDeviceObject);
205 }
207 }
208
209 if (Count == 0 || Count > Client->m_GrantedStreams)
210 {
211 DPRINT1("Endpoint %p streams open for %lu streams, %lu granted\n",
212 m_Handle, Count, Client->m_GrantedStreams);
213 if (Client->m_VerifierEnabled)
214 {
217 Client->m_GrantedStreams,
218 Count,
219 (ULONG_PTR)Urb);
220 }
222 }
223
224 if (UcxVerifierWantsFailure(Client->m_VerifierFailEnableStaticStreams))
225 {
227 DPRINT1("Endpoint %p streams open failed by verifier 0x%lx\n", m_Handle, Status);
229 }
230
231 /* One open at a time per endpoint */
233 {
235 DPRINT1("Endpoint %p static streams are already open\n", m_Handle);
236
237 if (Client->m_VerifierEnabled)
238 {
241 (ULONG_PTR)Irp,
242 (ULONG_PTR)Urb,
243 (ULONG_PTR)Client->m_ClientDeviceObject);
244 }
246 }
247
248 Status = UcxCreateStaticStreams(this, Count, &Streams);
249 if (!NT_SUCCESS(Status))
250 {
253 }
254
255 {
257
259 m_Streams = Streams;
260 }
261
263}
#define InterlockedIncrement
Definition: armddk.h:53
#define InterlockedDecrement
Definition: armddk.h:52
DECLSPEC_NORETURN VOID NTAPI KeBugCheckEx(IN ULONG BugCheckCode, IN ULONG_PTR BugCheckParameter1, IN ULONG_PTR BugCheckParameter2, IN ULONG_PTR BugCheckParameter3, IN ULONG_PTR BugCheckParameter4)
Definition: debug.c:485
LONG m_StreamsOpenCount
Definition: pipe.h:287
FORCEINLINE UcxXrbPreamble *NTAPI UcxXrbFromUrb(_In_ PURB Urb)
Definition: clientxrb.h:60
#define UCX_USB3_STREAMS_BAD_COUNT
Definition: clientxrb.h:27
#define UCX_BUGCHECK_USB3
Definition: clientxrb.h:22
#define UCX_USB3_STREAMS_IRQL
Definition: clientxrb.h:25
#define UCX_USB3_STREAMS_NOT_GRANTED
Definition: clientxrb.h:26
#define UCX_USB3_STREAMS_OPEN
Definition: clientxrb.h:28
_Out_ PKIRQL Irql
Definition: csq.h:179
UCHAR KIRQL
Definition: env_spec_w32.h:591
static NTSTATUS NTAPI UcxCreateStaticStreams(_In_ UcxEndpoint *Endpoint, _In_ ULONG Count, _Outptr_ UcxStaticStreams **StreamsOut)
Definition: pipeio.cpp:112
Definition: client.c:31
UcxUsbdHandle * Handle
Definition: clientxrb.h:39
uint32_t ULONG_PTR
Definition: typedefs.h:65
uint32_t ULONG
Definition: typedefs.h:59
BOOLEAN NTAPI UcxVerifierWantsFailure(_In_ ULONG Setting)
Definition: ucxutil.cpp:71
NTSTATUS NTAPI UcxRandomErrorStatus(VOID)
Definition: ucxutil.cpp:93
USHORT Count
Definition: userreq.cpp:200

Referenced by OpenStaticStreams(), and UcxProcessSubmitUrb().

◆ OpenStaticStreamsComplete()

NTSTATUS UcxEndpoint::OpenStaticStreamsComplete ( _In_ PIRP  Irp,
_In_ PURB  Urb 
)

Definition at line 306 of file pipeio.cpp.

309{
310 PUSBD_STREAM_INFORMATION Info = Urb->UrbOpenStaticStreams.Streams;
311 UcxStaticStreams* Streams;
313 ULONG Index;
314
315 if (!NT_SUCCESS(Irp->IoStatus.Status))
316 {
317 DPRINT1("Endpoint %p HCD streams enable failed 0x%lx\n", m_Handle, Irp->IoStatus.Status);
318
319 {
321
322 Streams = m_Streams;
323 m_Streams = NULL;
324 }
325
326 if (Streams != NULL)
327 WdfObjectDelete(Streams->m_Handle);
328 }
329 else
330 {
331 Streams = m_Streams;
332
333 for (Index = 0; Index < Streams->m_StreamCount; Index++)
334 {
335 Entry = Streams->Stream(Index);
336
337 Info[Index].PipeHandle = Entry->Pipe.Handle();
338 Info[Index].StreamID = Entry->StreamId;
339 Info[Index].MaximumTransferSize = Entry->Pipe.MaximumTransferSize;
340 Info[Index].PipeFlags = 0;
341 }
342 }
343
344 /* The machine never saw this open; finish it here */
346 {
350
352 }
353
355 Post(EpEvent::StreamsOpened);
356
358}
BOOLEAN m_OpenFailedOnReset
Definition: pipe.h:306
UcxStream * Stream(_In_ ULONG Index)
Definition: pipe.h:373
ULONG m_StreamCount
Definition: pipe.h:381
VOID NTAPI UcxCompleteHeldUrbIrp(_In_ PIRP Irp)
Definition: clientxrb.cpp:61
PLIST_ENTRY Entry
Definition: devhcd.cpp:1262
_Must_inspect_result_ _In_ WDFCHILDLIST _In_ PWDF_CHILD_LIST_ITERATOR _Out_ WDFDEVICE _Inout_opt_ PWDF_CHILD_RETRIEVE_INFO Info
Definition: wdfchildlist.h:690
_In_ WDFCOLLECTION _In_ ULONG Index

Referenced by OpenStaticStreamsComplete().

◆ Post()

◆ ReleaseCancelSync()

VOID UcxEndpoint::ReleaseCancelSync ( )

TT clear handshake: one decrement from the hub callback, one from the hub's ack.

Definition at line 360 of file pipe.cpp.

Referenced by NeedToCancelTransfers(), ReleaseCancelSync(), and UcxHubClearTtBufferComplete().

◆ SetPending()

VOID UcxEndpoint::SetPending ( _In_ PVOID  Pending)
inline

◆ SetWdfIoQueue()

VOID UcxEndpoint::SetWdfIoQueue ( _In_ WDFQUEUE  Queue)

Definition at line 313 of file pipe.cpp.

315{
316 if (m_Pipe.Queue != NULL)
317 {
318 DPRINT1("Endpoint %p already has queue %p\n", m_Handle, m_Pipe.Queue);
319 return;
320 }
321
324}
_Must_inspect_result_ _In_ WDFDEVICE _In_ PIRP _In_ WDFQUEUE Queue
Definition: wdfdevice.h:2231

Referenced by UcxRootHub::CreateEndpoint(), SetWdfIoQueue(), and UcxApiEndpointSetWdfIoQueue().

◆ TakePending()

Friends And Related Function Documentation

◆ EndpointMachine

friend class EndpointMachine
friend

Definition at line 336 of file pipe.h.

Member Data Documentation

◆ EvtDestroy

VOID NTAPI UcxEndpoint::EvtDestroy
staticprivate

Definition at line 334 of file pipe.h.

Referenced by Create().

◆ m_AbortCsqContext

IO_CSQ_IRP_CONTEXT UcxEndpoint::m_AbortCsqContext

Definition at line 308 of file pipe.h.

Referenced by AbortPipe(), and EndpointMachine::CompleteAbortUrb().

◆ m_Callbacks

◆ m_CancelSync

LONG UcxEndpoint::m_CancelSync

Definition at line 311 of file pipe.h.

Referenced by NeedToCancelTransfers(), and ReleaseCancelSync().

◆ m_ClearTtOnCancel

BOOLEAN UcxEndpoint::m_ClearTtOnCancel

Definition at line 314 of file pipe.h.

Referenced by Initialize(), and NeedToCancelTransfers().

◆ m_ClientHoldsHandle

BOOLEAN UcxEndpoint::m_ClientHoldsHandle

Definition at line 313 of file pipe.h.

Referenced by EndpointMachine::ClientHoldsHandle(), and UcxHubEndpointExposed().

◆ m_Controller

◆ m_ControllerResetLink

LIST_ENTRY UcxEndpoint::m_ControllerResetLink

Definition at line 298 of file pipe.h.

Referenced by Initialize().

◆ m_Descriptor

USB_ENDPOINT_DESCRIPTOR UcxEndpoint::m_Descriptor

Definition at line 290 of file pipe.h.

Referenced by Initialize(), NeedToCancelTransfers(), and EndpointMachine::ParkAsStale().

◆ m_Device

◆ m_DeviceLink

LIST_ENTRY UcxEndpoint::m_DeviceLink

◆ m_DisconnectLink

LIST_ENTRY UcxEndpoint::m_DisconnectLink

Definition at line 297 of file pipe.h.

Referenced by Initialize().

◆ m_Handle

◆ m_HasMachine

BOOLEAN UcxEndpoint::m_HasMachine

Definition at line 303 of file pipe.h.

Referenced by AbortPipe(), and HasMachine().

◆ m_Machine

EndpointMachine UcxEndpoint::m_Machine

Definition at line 302 of file pipe.h.

Referenced by Post().

◆ m_OpenFailedOnReset

BOOLEAN UcxEndpoint::m_OpenFailedOnReset

Definition at line 306 of file pipe.h.

Referenced by OpenStaticStreamsComplete().

◆ m_OperationLink

LIST_ENTRY UcxEndpoint::m_OperationLink

Definition at line 300 of file pipe.h.

Referenced by Initialize().

◆ m_Pending

PVOID UcxEndpoint::m_Pending

Definition at line 305 of file pipe.h.

Referenced by SetPending(), and TakePending().

◆ m_Pipe

◆ m_Streams

◆ m_StreamsOpenCount

◆ m_TrackingLink

LIST_ENTRY UcxEndpoint::m_TrackingLink

Definition at line 294 of file pipe.h.

Referenced by Initialize().

◆ m_TreePurgeLink

LIST_ENTRY UcxEndpoint::m_TreePurgeLink

Definition at line 299 of file pipe.h.

Referenced by Initialize().


The documentation for this class was generated from the following files: