InterfaceIsr.c 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. #include "headers.h"
  2. static void read_int_callback(struct urb *urb/*, struct pt_regs *regs*/)
  3. {
  4. int status = urb->status;
  5. PS_INTERFACE_ADAPTER psIntfAdapter = (PS_INTERFACE_ADAPTER)urb->context;
  6. PMINI_ADAPTER Adapter = psIntfAdapter->psAdapter ;
  7. if (netif_msg_intr(Adapter))
  8. pr_info(PFX "%s: interrupt status %d\n",
  9. Adapter->dev->name, status);
  10. if(Adapter->device_removed == TRUE)
  11. {
  12. BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, INTF_INIT, DBG_LVL_ALL,"Device has Got Removed.");
  13. return ;
  14. }
  15. if(((Adapter->bPreparingForLowPowerMode == TRUE) && (Adapter->bDoSuspend == TRUE)) ||
  16. psIntfAdapter->bSuspended ||
  17. psIntfAdapter->bPreparingForBusSuspend)
  18. {
  19. BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, INTF_INIT, DBG_LVL_ALL,"Interrupt call back is called while suspending the device");
  20. return ;
  21. }
  22. //BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, NEXT_SEND, DBG_LVL_ALL, "interrupt urb status %d", status);
  23. switch (status) {
  24. /* success */
  25. case STATUS_SUCCESS:
  26. if ( urb->actual_length )
  27. {
  28. if(psIntfAdapter->ulInterruptData[1] & 0xFF)
  29. {
  30. BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, INTF_INIT, DBG_LVL_ALL, "Got USIM interrupt");
  31. }
  32. if(psIntfAdapter->ulInterruptData[1] & 0xFF00)
  33. {
  34. atomic_set(&Adapter->CurrNumFreeTxDesc,
  35. (psIntfAdapter->ulInterruptData[1] & 0xFF00) >> 8);
  36. atomic_set (&Adapter->uiMBupdate, TRUE);
  37. BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, INTF_INIT, DBG_LVL_ALL, "TX mailbox contains %d",
  38. atomic_read(&Adapter->CurrNumFreeTxDesc));
  39. }
  40. if(psIntfAdapter->ulInterruptData[1] >> 16)
  41. {
  42. Adapter->CurrNumRecvDescs=
  43. (psIntfAdapter->ulInterruptData[1] >> 16);
  44. BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, INTF_INIT, DBG_LVL_ALL,"RX mailbox contains %d",
  45. Adapter->CurrNumRecvDescs);
  46. InterfaceRx(psIntfAdapter);
  47. }
  48. if(Adapter->fw_download_done &&
  49. !Adapter->downloadDDR &&
  50. atomic_read(&Adapter->CurrNumFreeTxDesc))
  51. {
  52. psIntfAdapter->psAdapter->downloadDDR +=1;
  53. wake_up(&Adapter->tx_packet_wait_queue);
  54. }
  55. if(FALSE == Adapter->waiting_to_fw_download_done)
  56. {
  57. Adapter->waiting_to_fw_download_done = TRUE;
  58. wake_up(&Adapter->ioctl_fw_dnld_wait_queue);
  59. }
  60. if(!atomic_read(&Adapter->TxPktAvail))
  61. {
  62. atomic_set(&Adapter->TxPktAvail, 1);
  63. wake_up(&Adapter->tx_packet_wait_queue);
  64. }
  65. BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, INTF_INIT, DBG_LVL_ALL,"Firing interrupt in URB");
  66. }
  67. break;
  68. case -ENOENT :
  69. {
  70. BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, INTF_INIT, DBG_LVL_ALL,"URB has got disconnected ....");
  71. return ;
  72. }
  73. case -EINPROGRESS:
  74. {
  75. //This situation may happened when URBunlink is used. for detail check usb_unlink_urb documentation.
  76. BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, INTF_INIT, DBG_LVL_ALL,"Impossibe condition has occurred... something very bad is going on");
  77. break ;
  78. //return;
  79. }
  80. case -EPIPE:
  81. {
  82. BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, INTF_INIT, DBG_LVL_ALL,"Interrupt IN endPoint has got halted/stalled...need to clear this");
  83. Adapter->bEndPointHalted = TRUE ;
  84. wake_up(&Adapter->tx_packet_wait_queue);
  85. urb->status = STATUS_SUCCESS ;
  86. return;
  87. }
  88. /* software-driven interface shutdown */
  89. case -ECONNRESET: //URB got unlinked.
  90. case -ESHUTDOWN: // hardware gone. this is the serious problem.
  91. //Occurs only when something happens with the host controller device
  92. case -ENODEV : //Device got removed
  93. case -EINVAL : //Some thing very bad happened with the URB. No description is available.
  94. BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, INTF_INIT, DBG_LVL_ALL,"interrupt urb error %d", status);
  95. urb->status = STATUS_SUCCESS ;
  96. break ;
  97. //return;
  98. default:
  99. //This is required to check what is the defaults conditions when it occurs..
  100. BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, NEXT_SEND, DBG_LVL_ALL,"GOT DEFAULT INTERRUPT URB STATUS :%d..Please Analyze it...", status);
  101. break;
  102. }
  103. StartInterruptUrb(psIntfAdapter);
  104. }
  105. int CreateInterruptUrb(PS_INTERFACE_ADAPTER psIntfAdapter)
  106. {
  107. psIntfAdapter->psInterruptUrb = usb_alloc_urb(0, GFP_KERNEL);
  108. if (!psIntfAdapter->psInterruptUrb)
  109. {
  110. BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_OTHERS, INTF_INIT, DBG_LVL_ALL,"Cannot allocate interrupt urb");
  111. return -ENOMEM;
  112. }
  113. psIntfAdapter->psInterruptUrb->transfer_buffer =
  114. psIntfAdapter->ulInterruptData;
  115. psIntfAdapter->psInterruptUrb->transfer_buffer_length =
  116. sizeof(psIntfAdapter->ulInterruptData);
  117. psIntfAdapter->sIntrIn.int_in_pipe = usb_rcvintpipe(psIntfAdapter->udev,
  118. psIntfAdapter->sIntrIn.int_in_endpointAddr);
  119. usb_fill_int_urb(psIntfAdapter->psInterruptUrb, psIntfAdapter->udev,
  120. psIntfAdapter->sIntrIn.int_in_pipe,
  121. psIntfAdapter->psInterruptUrb->transfer_buffer,
  122. psIntfAdapter->psInterruptUrb->transfer_buffer_length,
  123. read_int_callback, psIntfAdapter,
  124. psIntfAdapter->sIntrIn.int_in_interval);
  125. BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_OTHERS, INTF_INIT, DBG_LVL_ALL,"Interrupt Interval: %d\n",
  126. psIntfAdapter->sIntrIn.int_in_interval);
  127. return 0;
  128. }
  129. INT StartInterruptUrb(PS_INTERFACE_ADAPTER psIntfAdapter)
  130. {
  131. INT status = 0;
  132. if( FALSE == psIntfAdapter->psAdapter->device_removed &&
  133. FALSE == psIntfAdapter->psAdapter->bEndPointHalted &&
  134. FALSE == psIntfAdapter->bSuspended &&
  135. FALSE == psIntfAdapter->bPreparingForBusSuspend &&
  136. FALSE == psIntfAdapter->psAdapter->StopAllXaction)
  137. {
  138. status = usb_submit_urb(psIntfAdapter->psInterruptUrb, GFP_ATOMIC);
  139. if (status)
  140. {
  141. BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_OTHERS, INTF_INIT, DBG_LVL_ALL,"Cannot send int urb %d\n", status);
  142. if(status == -EPIPE)
  143. {
  144. psIntfAdapter->psAdapter->bEndPointHalted = TRUE ;
  145. wake_up(&psIntfAdapter->psAdapter->tx_packet_wait_queue);
  146. }
  147. }
  148. }
  149. return status;
  150. }