Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
usbpipe.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
3  * All rights reserved.
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  *
19  *
20  * File: usbpipe.c
21  *
22  * Purpose: Handle USB control endpoint
23  *
24  * Author: Warren Hsu
25  *
26  * Date: Mar. 29, 2005
27  *
28  * Functions:
29  * CONTROLnsRequestOut - Write variable length bytes to MEM/BB/MAC/EEPROM
30  * CONTROLnsRequestIn - Read variable length bytes from MEM/BB/MAC/EEPROM
31  * ControlvWriteByte - Write one byte to MEM/BB/MAC/EEPROM
32  * ControlvReadByte - Read one byte from MEM/BB/MAC/EEPROM
33  * ControlvMaskByte - Read one byte from MEM/BB/MAC/EEPROM and clear/set some bits in the same address
34  *
35  * Revision History:
36  * 04-05-2004 Jerry Chen: Initial release
37  * 11-24-2004 Warren Hsu: Add ControlvWriteByte,ControlvReadByte,ControlvMaskByte
38  *
39  */
40 
41 #include "int.h"
42 #include "rxtx.h"
43 #include "dpc.h"
44 #include "control.h"
45 #include "desc.h"
46 #include "device.h"
47 
48 /*--------------------- Static Definitions -------------------------*/
49 //endpoint def
50 //endpoint 0: control
51 //endpoint 1: interrupt
52 //endpoint 2: read bulk
53 //endpoint 3: write bulk
54 
55 //static int msglevel =MSG_LEVEL_DEBUG;
56 static int msglevel =MSG_LEVEL_INFO;
57 
58 
59 #define USB_CTL_WAIT 500 //ms
60 
61 #ifndef URB_ASYNC_UNLINK
62 #define URB_ASYNC_UNLINK 0
63 #endif
64 
65 /*--------------------- Static Classes ----------------------------*/
66 
67 /*--------------------- Static Variables --------------------------*/
68 
69 /*--------------------- Static Functions --------------------------*/
70 static
71 void
72 s_nsInterruptUsbIoCompleteRead(
73  struct urb *urb
74  );
75 
76 
77 static
78 void
79 s_nsBulkInUsbIoCompleteRead(
80  struct urb *urb
81  );
82 
83 
84 static
85 void
86 s_nsBulkOutIoCompleteWrite(
87  struct urb *urb
88  );
89 
90 
91 static
92 void
93 s_nsControlInUsbIoCompleteRead(
94  struct urb *urb
95  );
96 
97 static
98 void
99 s_nsControlInUsbIoCompleteWrite(
100  struct urb *urb
101  );
102 
103 /*--------------------- Export Variables --------------------------*/
104 
105 /*--------------------- Export Functions --------------------------*/
106 
108  PSDevice pDevice,
109  BYTE byRequest,
110  WORD wValue,
111  WORD wIndex,
112  WORD wLength,
113  PBYTE pbyBuffer
114  )
115 {
116  int ntStatus;
117 
118  if (pDevice->Flags & fMP_DISCONNECTED)
119  return STATUS_FAILURE;
120 
121  if (pDevice->Flags & fMP_CONTROL_WRITES)
122  return STATUS_FAILURE;
123 
124  if (in_interrupt()) {
125  DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"in_interrupt return ..byRequest %x\n", byRequest);
126  return STATUS_FAILURE;
127  }
128 
129  ntStatus = usb_control_msg(
130  pDevice->usb,
131  usb_sndctrlpipe(pDevice->usb , 0),
132  byRequest,
133  0x40, // RequestType
134  wValue,
135  wIndex,
136  (void *) pbyBuffer,
137  wLength,
138  HZ
139  );
140  if (ntStatus >= 0) {
141  DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"usb_sndctrlpipe ntStatus= %d\n", ntStatus);
142  ntStatus = 0;
143  } else {
144  DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"usb_sndctrlpipe fail, ntStatus= %d\n", ntStatus);
145  }
146 
147  return ntStatus;
148 }
149 
151  PSDevice pDevice,
152  BYTE byRequest,
153  WORD wValue,
154  WORD wIndex,
155  WORD wLength,
156  PBYTE pbyBuffer
157  )
158 {
159  int ntStatus = 0;
160  int ii;
161 
162  if (pDevice->Flags & fMP_DISCONNECTED)
163  return STATUS_FAILURE;
164 
165  if (pDevice->Flags & fMP_CONTROL_WRITES)
166  return STATUS_FAILURE;
167 
168  pDevice->sUsbCtlRequest.bRequestType = 0x40;
169  pDevice->sUsbCtlRequest.bRequest = byRequest;
170  pDevice->sUsbCtlRequest.wValue = cpu_to_le16p(&wValue);
171  pDevice->sUsbCtlRequest.wIndex = cpu_to_le16p(&wIndex);
172  pDevice->sUsbCtlRequest.wLength = cpu_to_le16p(&wLength);
173  pDevice->pControlURB->transfer_flags |= URB_ASYNC_UNLINK;
174  pDevice->pControlURB->actual_length = 0;
175  // Notice, pbyBuffer limited point to variable buffer, can't be constant.
176  usb_fill_control_urb(pDevice->pControlURB, pDevice->usb,
177  usb_sndctrlpipe(pDevice->usb , 0), (char *) &pDevice->sUsbCtlRequest,
178  pbyBuffer, wLength, s_nsControlInUsbIoCompleteWrite, pDevice);
179 
180  ntStatus = usb_submit_urb(pDevice->pControlURB, GFP_ATOMIC);
181  if (ntStatus != 0) {
182  DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"control send request submission failed: %d\n", ntStatus);
183  return STATUS_FAILURE;
184  }
185  else {
187  }
188  spin_unlock_irq(&pDevice->lock);
189  for (ii = 0; ii <= USB_CTL_WAIT; ii ++) {
190 
191  if (pDevice->Flags & fMP_CONTROL_WRITES)
192  mdelay(1);
193  else
194  break;
195 
196  if (ii >= USB_CTL_WAIT) {
198  KERN_INFO "control send request submission timeout\n");
199  spin_lock_irq(&pDevice->lock);
201  return STATUS_FAILURE;
202  }
203  }
204  spin_lock_irq(&pDevice->lock);
205 
206  return STATUS_SUCCESS;
207 }
208 
210  PSDevice pDevice,
211  BYTE byRequest,
212  WORD wValue,
213  WORD wIndex,
214  WORD wLength,
215  PBYTE pbyBuffer
216  )
217 {
218  int ntStatus = 0;
219  int ii;
220 
221  if (pDevice->Flags & fMP_DISCONNECTED)
222  return STATUS_FAILURE;
223 
224  if (pDevice->Flags & fMP_CONTROL_READS)
225  return STATUS_FAILURE;
226 
227  pDevice->sUsbCtlRequest.bRequestType = 0xC0;
228  pDevice->sUsbCtlRequest.bRequest = byRequest;
229  pDevice->sUsbCtlRequest.wValue = cpu_to_le16p(&wValue);
230  pDevice->sUsbCtlRequest.wIndex = cpu_to_le16p(&wIndex);
231  pDevice->sUsbCtlRequest.wLength = cpu_to_le16p(&wLength);
232  pDevice->pControlURB->transfer_flags |= URB_ASYNC_UNLINK;
233  pDevice->pControlURB->actual_length = 0;
234  usb_fill_control_urb(pDevice->pControlURB, pDevice->usb,
235  usb_rcvctrlpipe(pDevice->usb , 0), (char *) &pDevice->sUsbCtlRequest,
236  pbyBuffer, wLength, s_nsControlInUsbIoCompleteRead, pDevice);
237 
238  ntStatus = usb_submit_urb(pDevice->pControlURB, GFP_ATOMIC);
239  if (ntStatus != 0) {
240  DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"control request submission failed: %d\n", ntStatus);
241  }else {
242  MP_SET_FLAG(pDevice, fMP_CONTROL_READS);
243  }
244 
245  spin_unlock_irq(&pDevice->lock);
246  for (ii = 0; ii <= USB_CTL_WAIT; ii ++) {
247 
248  if (pDevice->Flags & fMP_CONTROL_READS)
249  mdelay(1);
250  else
251  break;
252 
253  if (ii >= USB_CTL_WAIT) {
255  KERN_INFO "control rcv request submission timeout\n");
256  spin_lock_irq(&pDevice->lock);
258  return STATUS_FAILURE;
259  }
260  }
261  spin_lock_irq(&pDevice->lock);
262 
263  return ntStatus;
264 }
265 
266 static
267 void
268 s_nsControlInUsbIoCompleteWrite(
269  struct urb *urb
270  )
271 {
272  PSDevice pDevice;
273 
274  pDevice = urb->context;
275  switch (urb->status) {
276  case 0:
277  break;
278  case -EINPROGRESS:
279  DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ctrl write urb status EINPROGRESS%d\n", urb->status);
280  break;
281  case -ENOENT:
282  DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ctrl write urb status ENOENT %d\n", urb->status);
283  break;
284  default:
285  DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ctrl write urb status %d\n", urb->status);
286  }
287 
289 }
290 
291 
292 
293 /*
294  * Description:
295  * Complete function of usb Control callback
296  *
297  * Parameters:
298  * In:
299  * pDevice - Pointer to the adapter
300  *
301  * Out:
302  * none
303  *
304  * Return Value: STATUS_INSUFFICIENT_RESOURCES or result of IoCallDriver
305  *
306  */
307 static
308 void
309 s_nsControlInUsbIoCompleteRead(
310  struct urb *urb
311  )
312 {
313  PSDevice pDevice;
314 
315  pDevice = urb->context;
316  switch (urb->status) {
317  case 0:
318  break;
319  case -EINPROGRESS:
320  DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ctrl read urb status EINPROGRESS%d\n", urb->status);
321  break;
322  case -ENOENT:
323  DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ctrl read urb status = ENOENT %d\n", urb->status);
324  break;
325  default:
326  DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ctrl read urb status %d\n", urb->status);
327  }
328 
330 }
331 
332 
333 
334 
335 /*
336  * Description:
337  * Allocates an usb interrupt in irp and calls USBD.
338  *
339  * Parameters:
340  * In:
341  * pDevice - Pointer to the adapter
342  * Out:
343  * none
344  *
345  * Return Value: STATUS_INSUFFICIENT_RESOURCES or result of IoCallDriver
346  *
347  */
349 {
350  int ntStatus = STATUS_FAILURE;
351 
352  DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->s_nsStartInterruptUsbRead()\n");
353 
354  if(pDevice->intBuf.bInUse == TRUE){
355  return (STATUS_FAILURE);
356  }
357  pDevice->intBuf.bInUse = TRUE;
358 // pDevice->bEventAvailable = FALSE;
359  pDevice->ulIntInPosted++;
360 
361  //
362  // Now that we have created the urb, we will send a
363  // request to the USB device object.
364  //
365  pDevice->pInterruptURB->interval = pDevice->int_interval;
366 
367 usb_fill_bulk_urb(pDevice->pInterruptURB,
368  pDevice->usb,
369  usb_rcvbulkpipe(pDevice->usb, 1),
370  (void *) pDevice->intBuf.pDataBuf,
372  s_nsInterruptUsbIoCompleteRead,
373  pDevice);
374 
375  ntStatus = usb_submit_urb(pDevice->pInterruptURB, GFP_ATOMIC);
376  if (ntStatus != 0) {
377  DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Submit int URB failed %d\n", ntStatus);
378  }
379 
380  DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"<----s_nsStartInterruptUsbRead Return(%x)\n",ntStatus);
381  return ntStatus;
382 }
383 
384 
385 /*
386  * Description:
387  * Complete function of usb interrupt in irp.
388  *
389  * Parameters:
390  * In:
391  * pDevice - Pointer to the adapter
392  *
393  * Out:
394  * none
395  *
396  * Return Value: STATUS_INSUFFICIENT_RESOURCES or result of IoCallDriver
397  *
398  */
399 static
400 void
401 s_nsInterruptUsbIoCompleteRead(
402  struct urb *urb
403  )
404 
405 {
406  PSDevice pDevice;
407  int ntStatus;
408 
409  DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->s_nsInterruptUsbIoCompleteRead\n");
410  //
411  // The context given to IoSetCompletionRoutine is the receive buffer object
412  //
413  pDevice = (PSDevice)urb->context;
414 
415  //
416  // We have a number of cases:
417  // 1) The USB read timed out and we received no data.
418  // 2) The USB read timed out and we received some data.
419  // 3) The USB read was successful and fully filled our irp buffer.
420  // 4) The irp was cancelled.
421  // 5) Some other failure from the USB device object.
422  //
423  ntStatus = urb->status;
424 
425  DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"s_nsInterruptUsbIoCompleteRead Status %d\n", ntStatus);
426 
427  // if we were not successful, we need to free the int buffer for future use right here
428  // otherwise interrupt data handler will free int buffer after it handle it.
429  if (( ntStatus != STATUS_SUCCESS )) {
430  pDevice->ulBulkInError++;
431  pDevice->intBuf.bInUse = FALSE;
432 
433 // if (ntStatus == USBD_STATUS_CRC) {
434 // pDevice->ulIntInContCRCError++;
435 // }
436 
437 // if (ntStatus == STATUS_NOT_CONNECTED )
438 // {
439  pDevice->fKillEventPollingThread = TRUE;
440 // }
441  DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"IntUSBIoCompleteControl STATUS = %d\n", ntStatus );
442  } else {
443  pDevice->ulIntInBytesRead += (unsigned long) urb->actual_length;
444  pDevice->ulIntInContCRCError = 0;
445  pDevice->bEventAvailable = TRUE;
446  INTnsProcessData(pDevice);
447  }
448 
450 
451 
452  if (pDevice->fKillEventPollingThread != TRUE) {
453  usb_fill_bulk_urb(pDevice->pInterruptURB,
454  pDevice->usb,
455  usb_rcvbulkpipe(pDevice->usb, 1),
456  (void *) pDevice->intBuf.pDataBuf,
458  s_nsInterruptUsbIoCompleteRead,
459  pDevice);
460 
461  ntStatus = usb_submit_urb(pDevice->pInterruptURB, GFP_ATOMIC);
462  if (ntStatus != 0) {
463  DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Submit int URB failed %d\n", ntStatus);
464  }
465  }
466  //
467  // We return STATUS_MORE_PROCESSING_REQUIRED so that the completion
468  // routine (IofCompleteRequest) will stop working on the irp.
469  //
470  return ;
471 }
472 
473 /*
474  * Description:
475  * Allocates an usb BulkIn irp and calls USBD.
476  *
477  * Parameters:
478  * In:
479  * pDevice - Pointer to the adapter
480  * Out:
481  * none
482  *
483  * Return Value: STATUS_INSUFFICIENT_RESOURCES or result of IoCallDriver
484  *
485  */
487 {
488  int ntStatus = 0;
489  struct urb *pUrb;
490 
491 
492  DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->s_nsStartBulkInUsbRead\n");
493 
494  if (pDevice->Flags & fMP_DISCONNECTED)
495  return STATUS_FAILURE;
496 
497  pDevice->ulBulkInPosted++;
498 
499 
500  pUrb = pRCB->pUrb;
501  //
502  // Now that we have created the urb, we will send a
503  // request to the USB device object.
504  //
505  if (pRCB->skb == NULL) {
506  DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pRCB->skb is null \n");
507  return ntStatus;
508  }
509 
510  usb_fill_bulk_urb(pUrb,
511  pDevice->usb,
512  usb_rcvbulkpipe(pDevice->usb, 2),
513  (void *) (pRCB->skb->data),
515  s_nsBulkInUsbIoCompleteRead,
516  pRCB);
517 
518  ntStatus = usb_submit_urb(pUrb, GFP_ATOMIC);
519  if (ntStatus != 0) {
520  DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Submit Rx URB failed %d\n", ntStatus);
521  return STATUS_FAILURE ;
522  }
523  pRCB->Ref = 1;
524  pRCB->bBoolInUse= TRUE;
525 
526  return ntStatus;
527 }
528 
529 
530 
531 
532 /*
533  * Description:
534  * Complete function of usb BulkIn irp.
535  *
536  * Parameters:
537  * In:
538  * pDevice - Pointer to the adapter
539  *
540  * Out:
541  * none
542  *
543  * Return Value: STATUS_INSUFFICIENT_RESOURCES or result of IoCallDriver
544  *
545  */
546 static
547 void
548 s_nsBulkInUsbIoCompleteRead(
549  struct urb *urb
550  )
551 
552 {
553  PRCB pRCB = (PRCB)urb->context;
554  PSDevice pDevice = (PSDevice)pRCB->pDevice;
555  unsigned long bytesRead;
556  BOOL bIndicateReceive = FALSE;
557  BOOL bReAllocSkb = FALSE;
558  int status;
559 
560  DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->s_nsBulkInUsbIoCompleteRead\n");
561  status = urb->status;
562  bytesRead = urb->actual_length;
563 
564  if (status) {
565  pDevice->ulBulkInError++;
566  DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"BULK In failed %d\n", status);
567 
568  pDevice->scStatistic.RxFcsErrCnt ++;
569 //todo...xxxxxx
570 // if (status == USBD_STATUS_CRC) {
571 // pDevice->ulBulkInContCRCError++;
572 // }
573 // if (status == STATUS_DEVICE_NOT_CONNECTED )
574 // {
575 // MP_SET_FLAG(pDevice, fMP_DISCONNECTED);
576 // }
577  } else {
578  bIndicateReceive = TRUE;
579  pDevice->ulBulkInContCRCError = 0;
580  pDevice->ulBulkInBytesRead += bytesRead;
581 
582  pDevice->scStatistic.RxOkCnt ++;
583  }
584 
585 
587 
588  if (bIndicateReceive) {
589  spin_lock(&pDevice->lock);
590  if (RXbBulkInProcessData(pDevice, pRCB, bytesRead) == TRUE)
591  bReAllocSkb = TRUE;
592  spin_unlock(&pDevice->lock);
593  }
594  pRCB->Ref--;
595  if (pRCB->Ref == 0)
596  {
597  DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"RxvFreeNormal %d \n",pDevice->NumRecvFreeList);
598  spin_lock(&pDevice->lock);
599  RXvFreeRCB(pRCB, bReAllocSkb);
600  spin_unlock(&pDevice->lock);
601  }
602 
603 
604  return;
605 }
606 
607 /*
608  * Description:
609  * Allocates an usb BulkOut irp and calls USBD.
610  *
611  * Parameters:
612  * In:
613  * pDevice - Pointer to the adapter
614  * Out:
615  * none
616  *
617  * Return Value: STATUS_INSUFFICIENT_RESOURCES or result of IoCallDriver
618  *
619  */
620 int
622  PSDevice pDevice,
623  PUSB_SEND_CONTEXT pContext
624  )
625 {
626  int status;
627  struct urb *pUrb;
628 
629 
630 
631  pDevice->bPWBitOn = FALSE;
632 
633 /*
634  if (pDevice->pPendingBulkOutContext != NULL) {
635  pDevice->NumContextsQueued++;
636  EnqueueContext(pDevice->FirstTxContextQueue, pDevice->LastTxContextQueue, pContext);
637  status = STATUS_PENDING;
638  DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Send pending!\n");
639  return status;
640  }
641 */
642 
643  DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"s_nsSendBulkOut\n");
644 
645  if (MP_IS_READY(pDevice) && (pDevice->Flags & fMP_POST_WRITES)) {
646 
647  pUrb = pContext->pUrb;
648  pDevice->ulBulkOutPosted++;
649 // pDevice->pPendingBulkOutContext = pContext;
650  usb_fill_bulk_urb(
651  pUrb,
652  pDevice->usb,
653  usb_sndbulkpipe(pDevice->usb, 3),
654  (void *) &(pContext->Data[0]),
655  pContext->uBufLen,
656  s_nsBulkOutIoCompleteWrite,
657  pContext);
658 
659  status = usb_submit_urb(pUrb, GFP_ATOMIC);
660  if (status != 0)
661  {
662  DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Submit Tx URB failed %d\n", status);
663  return STATUS_FAILURE;
664  }
665  return STATUS_PENDING;
666  }
667  else {
668  pContext->bBoolInUse = FALSE;
669  return STATUS_RESOURCES;
670  }
671 }
672 
673 /*
674  * Description: s_nsBulkOutIoCompleteWrite
675  * 1a) Indicate to the protocol the status of the write.
676  * 1b) Return ownership of the packet to the protocol.
677  *
678  * 2) If any more packets are queue for sending, send another packet
679  * to USBD.
680  * If the attempt to send the packet to the driver fails,
681  * return ownership of the packet to the protocol and
682  * try another packet (until one succeeds).
683  *
684  * Parameters:
685  * In:
686  * pdoUsbDevObj - pointer to the USB device object which
687  * completed the irp
688  * pIrp - the irp which was completed by the
689  * device object
690  * pContext - the context given to IoSetCompletionRoutine
691  * before calling IoCallDriver on the irp
692  * The pContext is a pointer to the USB device object.
693  * Out:
694  * none
695  *
696  * Return Value: STATUS_MORE_PROCESSING_REQUIRED - allows the completion routine
697  * (IofCompleteRequest) to stop working on the irp.
698  *
699  */
700 static
701 void
702 s_nsBulkOutIoCompleteWrite(
703  struct urb *urb
704  )
705 {
706  PSDevice pDevice;
707  int status;
708  CONTEXT_TYPE ContextType;
709  unsigned long ulBufLen;
710  PUSB_SEND_CONTEXT pContext;
711 
712 
713  DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->s_nsBulkOutIoCompleteWrite\n");
714  //
715  // The context given to IoSetCompletionRoutine is an USB_CONTEXT struct
716  //
717  pContext = (PUSB_SEND_CONTEXT) urb->context;
718  ASSERT( NULL != pContext );
719 
720  pDevice = pContext->pDevice;
721  ContextType = pContext->Type;
722  ulBufLen = pContext->uBufLen;
723 
724  if (!netif_device_present(pDevice->dev))
725  return;
726 
727  //
728  // Perform various IRP, URB, and buffer 'sanity checks'
729  //
730 
731  status = urb->status;
732  //we should have failed, succeeded, or cancelled, but NOT be pending
734 
735  if(status == STATUS_SUCCESS) {
736  DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Write %d bytes\n",(int)ulBufLen);
737  pDevice->ulBulkOutBytesWrite += ulBufLen;
738  pDevice->ulBulkOutContCRCError = 0;
739  pDevice->nTxDataTimeCout = 0;
740 
741  } else {
742  DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"BULK Out failed %d\n", status);
743  pDevice->ulBulkOutError++;
744  }
745 
746 // pDevice->ulCheckForHangCount = 0;
747 // pDevice->pPendingBulkOutContext = NULL;
748 
749  if ( CONTEXT_DATA_PACKET == ContextType ) {
750  // Indicate to the protocol the status of the sent packet and return
751  // ownership of the packet.
752  if (pContext->pPacket != NULL) {
753  dev_kfree_skb_irq(pContext->pPacket);
754  pContext->pPacket = NULL;
755  DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"tx %d bytes\n",(int)ulBufLen);
756  }
757 
758  pDevice->dev->trans_start = jiffies;
759 
760 
761  if (status == STATUS_SUCCESS) {
762  pDevice->packetsSent++;
763  }
764  else {
765  DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Send USB error! [%08xh]\n", status);
766  pDevice->packetsSentDropped++;
767  }
768 
769  }
770  if (pDevice->bLinkPass == TRUE) {
771  if (netif_queue_stopped(pDevice->dev))
772  netif_wake_queue(pDevice->dev);
773  }
774  pContext->bBoolInUse = FALSE;
775 
776  return;
777 }