summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichelle Bergeron <[email protected]>2017-03-15 10:16:55 -0700
committerWei Mao <[email protected]>2017-03-15 10:16:55 -0700
commit6b8cbe40b82f442860902752ff2df18ac1daf229 (patch)
tree353856eefce1b62f750fcdcac85a0790efd5d47b
parent360ed51d5a49fb859ba1f6e1bc4be8ceca39c1bc (diff)
Fix issue #66 - Confusing `MaximumTransferSize` and `maxTransferSize` in
usbsamp
-rw-r--r--usb/usbsamp/sys/bulkrwr.c73
-rw-r--r--usb/usbsamp/sys/private.h22
-rw-r--r--usb/usbsamp/sys/stream.c89
3 files changed, 88 insertions, 96 deletions
diff --git a/usb/usbsamp/sys/bulkrwr.c b/usb/usbsamp/sys/bulkrwr.c
index 475c89ed..872a49ba 100644
--- a/usb/usbsamp/sys/bulkrwr.c
+++ b/usb/usbsamp/sys/bulkrwr.c
@@ -74,7 +74,7 @@ Return Value:
WDF_OBJECT_ATTRIBUTES objectAttribs;
USBD_PIPE_HANDLE usbdPipeHandle;
PDEVICE_CONTEXT deviceContext;
- ULONG maxTransferSize;
+ ULONG maxPacketSize;
PPIPE_CONTEXT pipeContext;
UsbSamp_DbgPrint(3, ("UsbSamp_DispatchReadWrite - begins\n"));
@@ -128,7 +128,7 @@ Return Value:
rwContext->Read = TRUE;
UsbSamp_DbgPrint(3, ("Read operation\n"));
- }
+ }
else {
status = WdfRequestRetrieveInputWdmMdl(Request, &requestMdl);
if (!NT_SUCCESS(status)){
@@ -146,12 +146,12 @@ Return Value:
//
// The transfer request is for totalLength.
- // We can perform a max of maxTransfersize in each stage.
+ // We can perform a max of maxPacketSize in each stage.
//
- maxTransferSize = GetMaxTransferSize(pipe, deviceContext);
+ maxPacketSize = GetMaxPacketSize(pipe, deviceContext);
- if (totalLength > maxTransferSize) {
- stageLength = maxTransferSize;
+ if (totalLength > maxPacketSize) {
+ stageLength = maxPacketSize;
}
else {
stageLength = totalLength;
@@ -181,7 +181,7 @@ Return Value:
objectAttribs.ParentObject = Request;
status = WdfUsbTargetDeviceCreateUrb(deviceContext->WdfUsbTargetDevice,
- &objectAttribs,
+ &objectAttribs,
&urbMemory,
&urb);
@@ -194,9 +194,9 @@ Return Value:
if(WdfUsbPipeTypeBulk == pipeInfo.PipeType &&
pipeContext->StreamConfigured == TRUE) {
//
- // For super speed bulk pipe with streams, we specify one of its associated
- // usbd pipe handles to format an URB for sending or receiving data.
- // The usbd pipe handle is returned by the HCD via sucessful open-streams request
+ // For super speed bulk pipe with streams, we specify one of its associated
+ // usbd pipe handles to format an URB for sending or receiving data.
+ // The usbd pipe handle is returned by the HCD via successful open-streams request
//
usbdPipeHandle = GetStreamPipeHandleFromBulkPipe(pipe);
}
@@ -290,7 +290,7 @@ Return Value:
PURB urb;
PCHAR operation;
ULONG bytesReadWritten;
- ULONG maxTransferSize;
+ ULONG maxPacketSize;
PDEVICE_CONTEXT deviceContext;
rwContext = GetRequestContext(Request);
@@ -298,7 +298,7 @@ Return Value:
if (rwContext->Read) {
operation = "Read";
- }
+ }
else {
operation = "Write";
}
@@ -336,13 +336,13 @@ Return Value:
UsbSamp_DbgPrint(3, ("Stage next %s transfer...\n", operation));
//
- // The transfer request is for totalLength.
- // We can perform a max of maxTransfersize in each stage.
+ // The transfer request is for totalLength.
+ // We can perform a max of maxPacketSize in each stage.
//
- maxTransferSize = GetMaxTransferSize(pipe, deviceContext);
+ maxPacketSize = GetMaxPacketSize(pipe, deviceContext);
- if (rwContext->Length > maxTransferSize) {
- stageLength = maxTransferSize;
+ if (rwContext->Length > maxPacketSize) {
+ stageLength = maxPacketSize;
}
else {
stageLength = rwContext->Length;
@@ -360,7 +360,7 @@ Return Value:
UsbSamp_DbgPrint(1, ("WdfRequestRetrieveOutputWdmMdl for Read failed %x\n", status));
goto End;
}
- }
+ }
else {
status = WdfRequestRetrieveInputWdmMdl(Request, &requestMdl);
if (!NT_SUCCESS(status)){
@@ -478,8 +478,8 @@ Return Value:
PDEVICE_CONTEXT deviceContext;
PPIPE_CONTEXT pipeContext;
- ULONG maxTransferSize;
-
+ ULONG maxPacketSize;
+
UsbSamp_DbgPrint(3, ("UsbSamp_DispatchReadWrite - begins\n"));
//
@@ -515,7 +515,7 @@ Return Value:
status = WdfRequestRetrieveOutputBuffer(Request, Length, &virtualAddress, &totalLength);
rwContext->Read = TRUE;
- }
+ }
else { //Write
status = WdfRequestRetrieveInputBuffer(Request, Length, &virtualAddress, &totalLength);
@@ -529,15 +529,15 @@ Return Value:
//
// The transfer request is for totalLength.
- // We can perform a max of maxTransfersize in each stage.
+ // We can perform a max of maxPacketSize in each stage.
//
- maxTransferSize = GetMaxTransferSize(pipe, deviceContext);
+ maxPacketSize = GetMaxPacketSize(pipe, deviceContext);
- if (totalLength > maxTransferSize) {
- stageLength = maxTransferSize;
+ if (totalLength > maxPacketSize) {
+ stageLength = maxPacketSize;
}
else {
- stageLength = totalLength;
+ stageLength = totalLength;
}
WDF_OBJECT_ATTRIBUTES_INIT(&objectAttribs);
@@ -566,7 +566,7 @@ Return Value:
Request,
reqMemory,
&offset);
- }
+ }
else {
UsbSamp_DbgPrint(3, ("Write operation\n"));
@@ -662,7 +662,7 @@ Return Value:
PWDF_USB_REQUEST_COMPLETION_PARAMS usbCompletionParams;
PPIPE_CONTEXT pipeContext;
WDF_USB_PIPE_INFORMATION pipeInfo;
- ULONG maxTransferSize;
+ ULONG maxPacketSize;
PDEVICE_CONTEXT deviceContext;
usbCompletionParams = CompletionParams->Parameters.Usb.Completion;
@@ -672,7 +672,7 @@ Return Value:
if (rwContext->Read) {
operation = "Read";
bytesReadWritten = (ULONG)usbCompletionParams->Parameters.PipeRead.Length;
- }
+ }
else {
operation = "Write";
bytesReadWritten = (ULONG)usbCompletionParams->Parameters.PipeWrite.Length;
@@ -712,13 +712,13 @@ Return Value:
UsbSamp_DbgPrint(3, ("Stage next %s transfer...\n", operation));
//
- // The transfer request is for totalLength.
- // We can perform a max of maxTransfersize in each stage.
+ // The transfer request is for totalLength.
+ // We can perform a max of maxPacketSize in each stage.
//
- maxTransferSize = GetMaxTransferSize(pipe, deviceContext);
+ maxPacketSize = GetMaxPacketSize(pipe, deviceContext);
- if (rwContext->Length > maxTransferSize) {
- stageLength = maxTransferSize;
+ if (rwContext->Length > maxPacketSize) {
+ stageLength = maxPacketSize;
}
else
{
@@ -738,7 +738,7 @@ Return Value:
usbCompletionParams->Parameters.PipeRead.Buffer,
&offset);
- }
+ }
else {
status = WdfUsbTargetPipeFormatRequestForWrite(
@@ -842,7 +842,7 @@ QueuePassiveLevelCallback(
Routine Description:
This routine is used to queue workitems so that the callback
- functions can be executed at PASSIVE_LEVEL in the conext of
+ functions can be executed at PASSIVE_LEVEL in the context of
a system thread.
Arguments:
@@ -904,4 +904,3 @@ DbgPrintRWContext(
(PVOID)rwContext->VirtualAddress));
return;
}
-
diff --git a/usb/usbsamp/sys/private.h b/usb/usbsamp/sys/private.h
index ef164908..d6d7898b 100644
--- a/usb/usbsamp/sys/private.h
+++ b/usb/usbsamp/sys/private.h
@@ -70,9 +70,9 @@ Environment:
#endif
-#define MAX_FULL_SPEED_TRANSFER_SIZE 64
-#define MAX_HIGH_SPEED_TRANSFER_SIZE 512
-#define MAX_SUPER_SPEED_TRANSFER_SIZE 1024
+#define MAX_FULL_SPEED_PACKET_SIZE 64
+#define MAX_HIGH_SPEED_PACKET_SIZE 512
+#define MAX_SUPER_SPEED_PACKET_SIZE 1024
#define MAX_STREAM_VALID_PACKET_SIZE 1024
#define REMOTE_WAKEUP_MASK 0x20
@@ -109,7 +109,7 @@ typedef struct _DEVICE_CONTEXT {
ULONG MaximumTransferSize;
WDFQUEUE IsochReadQueue;
-
+
WDFQUEUE IsochWriteQueue;
BOOLEAN IsStaticStreamsSupported;
@@ -118,7 +118,7 @@ typedef struct _DEVICE_CONTEXT {
USBD_HANDLE UsbdHandle;
-
+
} DEVICE_CONTEXT, *PDEVICE_CONTEXT;
WDF_DECLARE_CONTEXT_TYPE_WITH_NAME(DEVICE_CONTEXT, GetDeviceContext)
@@ -153,8 +153,8 @@ typedef struct _USBSAMP_STREAM_INFO {
//
typedef struct _PIPE_CONTEXT {
- ULONG NextFrameNumber;
-
+ ULONG NextFrameNumber;
+
ULONG TransferSizePerMicroframe;
ULONG TransferSizePerFrame;
@@ -172,7 +172,7 @@ WDF_DECLARE_CONTEXT_TYPE_WITH_NAME(PIPE_CONTEXT, GetPipeContext)
//
-// This context is associated with every request recevied by the driver
+// This context is associated with every request received by the driver
// from the app.
//
typedef struct _REQUEST_CONTEXT {
@@ -321,7 +321,7 @@ RetrieveDeviceInformation(
USBD_STATUS
-UsbSamp_ValidateConfigurationDescriptor(
+UsbSamp_ValidateConfigurationDescriptor(
_In_reads_bytes_(BufferLength) PUSB_CONFIGURATION_DESCRIPTOR ConfigDesc,
_In_ ULONG BufferLength,
_Inout_ PUCHAR *Offset
@@ -381,8 +381,8 @@ ConfigureStreamPipeHandleForRequest(
#endif
ULONG
-GetMaxTransferSize(
- _In_ WDFUSBPIPE Pipe,
+GetMaxPacketSize(
+ _In_ WDFUSBPIPE Pipe,
_In_ PDEVICE_CONTEXT DeviceContext
);
diff --git a/usb/usbsamp/sys/stream.c b/usb/usbsamp/sys/stream.c
index 37067f0a..55243d06 100644
--- a/usb/usbsamp/sys/stream.c
+++ b/usb/usbsamp/sys/stream.c
@@ -76,8 +76,8 @@ Return Value:
//
// Note: All super speed bulk stream I/O transfers use USBD Handle obtained in
// UsbSamp_EvtDeviceAdd. If you call WdfUsbTargetDeviceQueryUsbCapability
- // method instead of USBD_QueryUsbCapability here, it will not set stream
- // capabilites for USBD Handle used by stream transfer in which case
+ // method instead of USBD_QueryUsbCapability here, it will not set stream
+ // capabilities for USBD Handle used by stream transfer in which case
// the open streams request will fail in this example.
//
status = USBD_QueryUsbCapability(pDevContext->UsbdHandle,
@@ -89,11 +89,11 @@ Return Value:
UsbSamp_DbgPrint(1, ("USBD_QueryUsbCapability %x\n", status));
}
- return status;
+ return status;
}
#if (NTDDI_VERSION >= NTDDI_WIN8)
-
+
NTSTATUS
InitializePipeContextForSuperSpeedBulkPipe(
_In_ PDEVICE_CONTEXT DeviceContext,
@@ -112,7 +112,7 @@ Arguments:
InterfaceNumber - InterfaceNumber of selected interface
- Pipe - Bullk Pipe
+ Pipe - Bulk Pipe
Return Value:
@@ -126,13 +126,13 @@ Return Value:
PUSB_ENDPOINT_DESCRIPTOR pEndpointDescriptor;
PUSB_SUPERSPEED_ENDPOINT_COMPANION_DESCRIPTOR pEndpointCompanionDescriptor;
- UCHAR endpointAddress;
- ULONG maxStreams;
- ULONG supportedStreams;
+ UCHAR endpointAddress;
+ ULONG maxStreams;
+ ULONG supportedStreams;
PUSBSAMP_STREAM_INFO pStreamInfo;
- NTSTATUS status;
- PURB pUrb = NULL;
- ULONG i;
+ NTSTATUS status;
+ PURB pUrb = NULL;
+ ULONG i;
PAGED_CODE();
@@ -140,12 +140,12 @@ Return Value:
WdfUsbTargetPipeGetInformation(Pipe, &pipeInfo);
pipeContext = GetPipeContext(Pipe);
pStreamInfo = &pipeContext->StreamInfo;
-
+
pStreamInfo->NumberOfStreams = 0;
pStreamInfo->StreamList = NULL;
-
+
pipeContext->StreamConfigured = FALSE;
-
+
//
// Validate that the endpoint/pipe is of type BULK.
// Streams are only allowed on a SS BULK endpoint.
@@ -168,24 +168,24 @@ Return Value:
if (pEndpointDescriptor != NULL &&
pEndpointCompanionDescriptor != NULL) {
-
+
maxStreams = pEndpointCompanionDescriptor->bmAttributes.Bulk.MaxStreams;
if (maxStreams == 0) {
supportedStreams = 0;
-
+
} else {
-
+
supportedStreams = 1 << maxStreams;
}
} else {
-
+
UsbSamp_DbgPrint(1, ("Endpoint Descriptor or Endpoint Companion Descriptor is NULL.\n"));
status = STATUS_INVALID_PARAMETER;
goto End;
-
+
}
if (supportedStreams == 0) {
@@ -234,13 +234,13 @@ Return Value:
Pipe,
NULL,
NULL,
- pUrb
+ pUrb
);
if (NT_SUCCESS(status)) {
pipeContext->StreamConfigured = TRUE;
-
+
}
End:
if (!NT_SUCCESS(status)) {
@@ -275,7 +275,7 @@ Routine Description:
Arguments:
- Pipe - Bullk Pipe
+ Pipe - Bulk Pipe
Return Value:
@@ -291,7 +291,7 @@ Return Value:
pipeContext = GetPipeContext(Pipe);
- if (pipeContext->StreamConfigured == FALSE)
+ if (pipeContext->StreamConfigured == FALSE)
{
streamPipeHandle = NULL;
goto End;
@@ -327,14 +327,14 @@ ConfigureStreamPipeHandleForRequest(
Routine Description:
- The framework has formated request for super speed bulk pipe.
+ The framework has formated request for super speed bulk pipe.
For stream transfer, use the associated stream's PipeHandle for transfer.
Arguments:
-
+
Request - Read/Write Request.
- Pipe - Bullk Pipe
+ Pipe - Bulk Pipe
Return Value:
@@ -358,8 +358,8 @@ Return Value:
//
// The framework uses pipe's Pipehandle for data transfer by default.
- // For stream transfer, we should use the associated stream's PipeHandle of
- // the super speed bulk pipe for transfer. Replace the PipeHandle with
+ // For stream transfer, we should use the associated stream's PipeHandle of
+ // the super speed bulk pipe for transfer. Replace the PipeHandle with
// its associated stream's PipeHandle .
//
urb = irpSp->Parameters.Others.Argument1;
@@ -371,7 +371,7 @@ Return Value:
#endif
ULONG
-GetMaxTransferSize(
+GetMaxPacketSize(
_In_ WDFUSBPIPE Pipe,
_In_ PDEVICE_CONTEXT DeviceContext
)
@@ -382,8 +382,8 @@ Routine Description:
This routine returns maximum packet size of a bulk pipe
Arguments:
-
- Pipe - Bullk Pipe
+
+ Pipe - Bulk Pipe
Return Value:
@@ -391,9 +391,9 @@ Return Value:
--*/
{
- ULONG maxTransferSize;
+ ULONG maxPacketSize;
PPIPE_CONTEXT pipeContext;
-
+
pipeContext = GetPipeContext(Pipe);
if (pipeContext->StreamConfigured == TRUE) {
@@ -403,31 +403,24 @@ Return Value:
// MAX_STREAM_VALID_PACKET_SIZE which depends on the implementation
// of super speed bulk stream endpoint
//
- maxTransferSize = MAX_STREAM_VALID_PACKET_SIZE;
+ maxPacketSize = MAX_STREAM_VALID_PACKET_SIZE;
}
else{
if (DeviceContext->IsDeviceSuperSpeed == TRUE)
{
- maxTransferSize = MAX_SUPER_SPEED_TRANSFER_SIZE;
- }
+ maxPacketSize = MAX_SUPER_SPEED_PACKET_SIZE;
+ }
else if (DeviceContext->IsDeviceHighSpeed == TRUE)
{
- maxTransferSize = MAX_HIGH_SPEED_TRANSFER_SIZE;
+ maxPacketSize = MAX_HIGH_SPEED_PACKET_SIZE;
}
else
- {
- maxTransferSize = MAX_FULL_SPEED_TRANSFER_SIZE;
+ {
+ maxPacketSize = MAX_FULL_SPEED_PACKET_SIZE;
}
-
+
}
- return maxTransferSize;
+ return maxPacketSize;
}
-
-
-
-
-
-
-