Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 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 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 41 | #include "int.h" |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 42 | #include "rxtx.h" |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 43 | #include "dpc.h" |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 44 | #include "control.h" |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 45 | #include "desc.h" |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 46 | #include "device.h" |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 47 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 48 | //endpoint def |
| 49 | //endpoint 0: control |
| 50 | //endpoint 1: interrupt |
| 51 | //endpoint 2: read bulk |
| 52 | //endpoint 3: write bulk |
| 53 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 54 | //static int msglevel =MSG_LEVEL_DEBUG; |
| 55 | static int msglevel =MSG_LEVEL_INFO; |
| 56 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 57 | #define USB_CTL_WAIT 500 //ms |
| 58 | |
| 59 | #ifndef URB_ASYNC_UNLINK |
| 60 | #define URB_ASYNC_UNLINK 0 |
| 61 | #endif |
| 62 | |
Malcolm Priestley | fe5d00e | 2012-12-10 22:14:36 +0000 | [diff] [blame] | 63 | static void s_nsInterruptUsbIoCompleteRead(struct urb *urb); |
| 64 | static void s_nsBulkInUsbIoCompleteRead(struct urb *urb); |
| 65 | static void s_nsBulkOutIoCompleteWrite(struct urb *urb); |
| 66 | static void s_nsControlInUsbIoCompleteRead(struct urb *urb); |
| 67 | static void s_nsControlInUsbIoCompleteWrite(struct urb *urb); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 68 | |
Malcolm Priestley | fe5d00e | 2012-12-10 22:14:36 +0000 | [diff] [blame] | 69 | int PIPEnsControlOutAsyn(struct vnt_private *pDevice, u8 byRequest, |
| 70 | u16 wValue, u16 wIndex, u16 wLength, u8 *pbyBuffer) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 71 | { |
Andres More | 6487c49 | 2010-08-02 20:51:57 -0300 | [diff] [blame] | 72 | int ntStatus; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 73 | |
Andres More | 731047f | 2010-08-05 22:17:20 -0300 | [diff] [blame] | 74 | if (pDevice->Flags & fMP_DISCONNECTED) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 75 | return STATUS_FAILURE; |
| 76 | |
Andres More | 731047f | 2010-08-05 22:17:20 -0300 | [diff] [blame] | 77 | if (pDevice->Flags & fMP_CONTROL_WRITES) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 78 | return STATUS_FAILURE; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 79 | |
| 80 | if (in_interrupt()) { |
| 81 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"in_interrupt return ..byRequest %x\n", byRequest); |
| 82 | return STATUS_FAILURE; |
| 83 | } |
| 84 | |
| 85 | ntStatus = usb_control_msg( |
| 86 | pDevice->usb, |
| 87 | usb_sndctrlpipe(pDevice->usb , 0), |
| 88 | byRequest, |
| 89 | 0x40, // RequestType |
| 90 | wValue, |
| 91 | wIndex, |
Andres More | 8611a29 | 2010-05-01 14:25:00 -0300 | [diff] [blame] | 92 | (void *) pbyBuffer, |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 93 | wLength, |
| 94 | HZ |
| 95 | ); |
| 96 | if (ntStatus >= 0) { |
| 97 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"usb_sndctrlpipe ntStatus= %d\n", ntStatus); |
| 98 | ntStatus = 0; |
| 99 | } else { |
| 100 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"usb_sndctrlpipe fail, ntStatus= %d\n", ntStatus); |
| 101 | } |
| 102 | |
| 103 | return ntStatus; |
| 104 | } |
| 105 | |
Malcolm Priestley | fe5d00e | 2012-12-10 22:14:36 +0000 | [diff] [blame] | 106 | int PIPEnsControlOut(struct vnt_private *pDevice, u8 byRequest, u16 wValue, |
| 107 | u16 wIndex, u16 wLength, u8 *pbyBuffer) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 108 | { |
Andres More | 6487c49 | 2010-08-02 20:51:57 -0300 | [diff] [blame] | 109 | int ntStatus = 0; |
Malcolm Priestley | fe5d00e | 2012-12-10 22:14:36 +0000 | [diff] [blame] | 110 | int ii; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 111 | |
Andres More | 731047f | 2010-08-05 22:17:20 -0300 | [diff] [blame] | 112 | if (pDevice->Flags & fMP_DISCONNECTED) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 113 | return STATUS_FAILURE; |
| 114 | |
Andres More | 731047f | 2010-08-05 22:17:20 -0300 | [diff] [blame] | 115 | if (pDevice->Flags & fMP_CONTROL_WRITES) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 116 | return STATUS_FAILURE; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 117 | |
Malcolm Priestley | ae5943d | 2013-01-30 20:07:29 +0000 | [diff] [blame] | 118 | if (pDevice->Flags & fMP_CONTROL_READS) |
| 119 | return STATUS_FAILURE; |
| 120 | |
Malcolm Priestley | e1feda1 | 2013-10-14 19:44:13 +0100 | [diff] [blame] | 121 | if (pDevice->pControlURB->hcpriv) |
| 122 | return STATUS_FAILURE; |
| 123 | |
Malcolm Priestley | ae5943d | 2013-01-30 20:07:29 +0000 | [diff] [blame] | 124 | MP_SET_FLAG(pDevice, fMP_CONTROL_WRITES); |
| 125 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 126 | pDevice->sUsbCtlRequest.bRequestType = 0x40; |
| 127 | pDevice->sUsbCtlRequest.bRequest = byRequest; |
| 128 | pDevice->sUsbCtlRequest.wValue = cpu_to_le16p(&wValue); |
| 129 | pDevice->sUsbCtlRequest.wIndex = cpu_to_le16p(&wIndex); |
| 130 | pDevice->sUsbCtlRequest.wLength = cpu_to_le16p(&wLength); |
| 131 | pDevice->pControlURB->transfer_flags |= URB_ASYNC_UNLINK; |
| 132 | pDevice->pControlURB->actual_length = 0; |
| 133 | // Notice, pbyBuffer limited point to variable buffer, can't be constant. |
| 134 | usb_fill_control_urb(pDevice->pControlURB, pDevice->usb, |
| 135 | usb_sndctrlpipe(pDevice->usb , 0), (char *) &pDevice->sUsbCtlRequest, |
| 136 | pbyBuffer, wLength, s_nsControlInUsbIoCompleteWrite, pDevice); |
| 137 | |
Joe Perches | bfbfeec | 2010-03-24 22:17:06 -0700 | [diff] [blame] | 138 | ntStatus = usb_submit_urb(pDevice->pControlURB, GFP_ATOMIC); |
| 139 | if (ntStatus != 0) { |
Malcolm Priestley | ae5943d | 2013-01-30 20:07:29 +0000 | [diff] [blame] | 140 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO |
| 141 | "control send request submission failed: %d\n", |
| 142 | ntStatus); |
| 143 | MP_CLEAR_FLAG(pDevice, fMP_CONTROL_WRITES); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 144 | return STATUS_FAILURE; |
| 145 | } |
Malcolm Priestley | ae5943d | 2013-01-30 20:07:29 +0000 | [diff] [blame] | 146 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 147 | spin_unlock_irq(&pDevice->lock); |
| 148 | for (ii = 0; ii <= USB_CTL_WAIT; ii ++) { |
Andres More | 731047f | 2010-08-05 22:17:20 -0300 | [diff] [blame] | 149 | |
| 150 | if (pDevice->Flags & fMP_CONTROL_WRITES) |
| 151 | mdelay(1); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 152 | else |
Andres More | 731047f | 2010-08-05 22:17:20 -0300 | [diff] [blame] | 153 | break; |
| 154 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 155 | if (ii >= USB_CTL_WAIT) { |
Andres More | 731047f | 2010-08-05 22:17:20 -0300 | [diff] [blame] | 156 | DBG_PRT(MSG_LEVEL_DEBUG, |
| 157 | KERN_INFO "control send request submission timeout\n"); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 158 | spin_lock_irq(&pDevice->lock); |
| 159 | MP_CLEAR_FLAG(pDevice, fMP_CONTROL_WRITES); |
| 160 | return STATUS_FAILURE; |
| 161 | } |
| 162 | } |
| 163 | spin_lock_irq(&pDevice->lock); |
| 164 | |
| 165 | return STATUS_SUCCESS; |
| 166 | } |
| 167 | |
Malcolm Priestley | fe5d00e | 2012-12-10 22:14:36 +0000 | [diff] [blame] | 168 | int PIPEnsControlIn(struct vnt_private *pDevice, u8 byRequest, u16 wValue, |
| 169 | u16 wIndex, u16 wLength, u8 *pbyBuffer) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 170 | { |
Andres More | 6487c49 | 2010-08-02 20:51:57 -0300 | [diff] [blame] | 171 | int ntStatus = 0; |
Malcolm Priestley | fe5d00e | 2012-12-10 22:14:36 +0000 | [diff] [blame] | 172 | int ii; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 173 | |
Andres More | 731047f | 2010-08-05 22:17:20 -0300 | [diff] [blame] | 174 | if (pDevice->Flags & fMP_DISCONNECTED) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 175 | return STATUS_FAILURE; |
| 176 | |
Andres More | 731047f | 2010-08-05 22:17:20 -0300 | [diff] [blame] | 177 | if (pDevice->Flags & fMP_CONTROL_READS) |
| 178 | return STATUS_FAILURE; |
| 179 | |
Malcolm Priestley | ae5943d | 2013-01-30 20:07:29 +0000 | [diff] [blame] | 180 | if (pDevice->Flags & fMP_CONTROL_WRITES) |
| 181 | return STATUS_FAILURE; |
| 182 | |
Malcolm Priestley | e1feda1 | 2013-10-14 19:44:13 +0100 | [diff] [blame] | 183 | if (pDevice->pControlURB->hcpriv) |
| 184 | return STATUS_FAILURE; |
| 185 | |
Malcolm Priestley | ae5943d | 2013-01-30 20:07:29 +0000 | [diff] [blame] | 186 | MP_SET_FLAG(pDevice, fMP_CONTROL_READS); |
| 187 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 188 | pDevice->sUsbCtlRequest.bRequestType = 0xC0; |
| 189 | pDevice->sUsbCtlRequest.bRequest = byRequest; |
| 190 | pDevice->sUsbCtlRequest.wValue = cpu_to_le16p(&wValue); |
| 191 | pDevice->sUsbCtlRequest.wIndex = cpu_to_le16p(&wIndex); |
| 192 | pDevice->sUsbCtlRequest.wLength = cpu_to_le16p(&wLength); |
| 193 | pDevice->pControlURB->transfer_flags |= URB_ASYNC_UNLINK; |
| 194 | pDevice->pControlURB->actual_length = 0; |
| 195 | usb_fill_control_urb(pDevice->pControlURB, pDevice->usb, |
| 196 | usb_rcvctrlpipe(pDevice->usb , 0), (char *) &pDevice->sUsbCtlRequest, |
| 197 | pbyBuffer, wLength, s_nsControlInUsbIoCompleteRead, pDevice); |
| 198 | |
Joe Perches | bfbfeec | 2010-03-24 22:17:06 -0700 | [diff] [blame] | 199 | ntStatus = usb_submit_urb(pDevice->pControlURB, GFP_ATOMIC); |
| 200 | if (ntStatus != 0) { |
Malcolm Priestley | ae5943d | 2013-01-30 20:07:29 +0000 | [diff] [blame] | 201 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO |
| 202 | "control request submission failed: %d\n", ntStatus); |
| 203 | MP_CLEAR_FLAG(pDevice, fMP_CONTROL_READS); |
| 204 | return STATUS_FAILURE; |
| 205 | } |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 206 | |
| 207 | spin_unlock_irq(&pDevice->lock); |
| 208 | for (ii = 0; ii <= USB_CTL_WAIT; ii ++) { |
Andres More | 731047f | 2010-08-05 22:17:20 -0300 | [diff] [blame] | 209 | |
| 210 | if (pDevice->Flags & fMP_CONTROL_READS) |
| 211 | mdelay(1); |
| 212 | else |
| 213 | break; |
| 214 | |
| 215 | if (ii >= USB_CTL_WAIT) { |
| 216 | DBG_PRT(MSG_LEVEL_DEBUG, |
| 217 | KERN_INFO "control rcv request submission timeout\n"); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 218 | spin_lock_irq(&pDevice->lock); |
| 219 | MP_CLEAR_FLAG(pDevice, fMP_CONTROL_READS); |
| 220 | return STATUS_FAILURE; |
| 221 | } |
| 222 | } |
| 223 | spin_lock_irq(&pDevice->lock); |
| 224 | |
| 225 | return ntStatus; |
| 226 | } |
| 227 | |
Malcolm Priestley | fe5d00e | 2012-12-10 22:14:36 +0000 | [diff] [blame] | 228 | static void s_nsControlInUsbIoCompleteWrite(struct urb *urb) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 229 | { |
Malcolm Priestley | fe5d00e | 2012-12-10 22:14:36 +0000 | [diff] [blame] | 230 | struct vnt_private *pDevice = (struct vnt_private *)urb->context; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 231 | |
| 232 | pDevice = urb->context; |
| 233 | switch (urb->status) { |
| 234 | case 0: |
| 235 | break; |
| 236 | case -EINPROGRESS: |
| 237 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ctrl write urb status EINPROGRESS%d\n", urb->status); |
| 238 | break; |
| 239 | case -ENOENT: |
| 240 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ctrl write urb status ENOENT %d\n", urb->status); |
| 241 | break; |
| 242 | default: |
| 243 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ctrl write urb status %d\n", urb->status); |
| 244 | } |
| 245 | |
| 246 | MP_CLEAR_FLAG(pDevice, fMP_CONTROL_WRITES); |
| 247 | } |
| 248 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 249 | /* |
| 250 | * Description: |
| 251 | * Complete function of usb Control callback |
| 252 | * |
| 253 | * Parameters: |
| 254 | * In: |
| 255 | * pDevice - Pointer to the adapter |
| 256 | * |
| 257 | * Out: |
| 258 | * none |
| 259 | * |
| 260 | * Return Value: STATUS_INSUFFICIENT_RESOURCES or result of IoCallDriver |
| 261 | * |
| 262 | */ |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 263 | |
Malcolm Priestley | fe5d00e | 2012-12-10 22:14:36 +0000 | [diff] [blame] | 264 | static void s_nsControlInUsbIoCompleteRead(struct urb *urb) |
| 265 | { |
| 266 | struct vnt_private *pDevice = (struct vnt_private *)urb->context; |
| 267 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 268 | switch (urb->status) { |
| 269 | case 0: |
| 270 | break; |
| 271 | case -EINPROGRESS: |
| 272 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ctrl read urb status EINPROGRESS%d\n", urb->status); |
| 273 | break; |
| 274 | case -ENOENT: |
| 275 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ctrl read urb status = ENOENT %d\n", urb->status); |
| 276 | break; |
| 277 | default: |
| 278 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ctrl read urb status %d\n", urb->status); |
| 279 | } |
| 280 | |
| 281 | MP_CLEAR_FLAG(pDevice, fMP_CONTROL_READS); |
| 282 | } |
| 283 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 284 | /* |
| 285 | * Description: |
| 286 | * Allocates an usb interrupt in irp and calls USBD. |
| 287 | * |
| 288 | * Parameters: |
| 289 | * In: |
| 290 | * pDevice - Pointer to the adapter |
| 291 | * Out: |
| 292 | * none |
| 293 | * |
| 294 | * Return Value: STATUS_INSUFFICIENT_RESOURCES or result of IoCallDriver |
| 295 | * |
| 296 | */ |
Malcolm Priestley | fe5d00e | 2012-12-10 22:14:36 +0000 | [diff] [blame] | 297 | |
| 298 | int PIPEnsInterruptRead(struct vnt_private *pDevice) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 299 | { |
Malcolm Priestley | fe5d00e | 2012-12-10 22:14:36 +0000 | [diff] [blame] | 300 | int ntStatus = STATUS_FAILURE; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 301 | |
| 302 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->s_nsStartInterruptUsbRead()\n"); |
| 303 | |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 304 | if(pDevice->intBuf.bInUse == true){ |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 305 | return (STATUS_FAILURE); |
| 306 | } |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 307 | pDevice->intBuf.bInUse = true; |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 308 | // pDevice->bEventAvailable = false; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 309 | pDevice->ulIntInPosted++; |
| 310 | |
| 311 | // |
| 312 | // Now that we have created the urb, we will send a |
| 313 | // request to the USB device object. |
| 314 | // |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 315 | pDevice->pInterruptURB->interval = pDevice->int_interval; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 316 | |
| 317 | usb_fill_bulk_urb(pDevice->pInterruptURB, |
| 318 | pDevice->usb, |
| 319 | usb_rcvbulkpipe(pDevice->usb, 1), |
Andres More | 8611a29 | 2010-05-01 14:25:00 -0300 | [diff] [blame] | 320 | (void *) pDevice->intBuf.pDataBuf, |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 321 | MAX_INTERRUPT_SIZE, |
| 322 | s_nsInterruptUsbIoCompleteRead, |
| 323 | pDevice); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 324 | |
Joe Perches | bfbfeec | 2010-03-24 22:17:06 -0700 | [diff] [blame] | 325 | ntStatus = usb_submit_urb(pDevice->pInterruptURB, GFP_ATOMIC); |
| 326 | if (ntStatus != 0) { |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 327 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Submit int URB failed %d\n", ntStatus); |
| 328 | } |
| 329 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 330 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"<----s_nsStartInterruptUsbRead Return(%x)\n",ntStatus); |
| 331 | return ntStatus; |
| 332 | } |
| 333 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 334 | /* |
| 335 | * Description: |
| 336 | * Complete function of usb interrupt in irp. |
| 337 | * |
| 338 | * Parameters: |
| 339 | * In: |
| 340 | * pDevice - Pointer to the adapter |
| 341 | * |
| 342 | * Out: |
| 343 | * none |
| 344 | * |
| 345 | * Return Value: STATUS_INSUFFICIENT_RESOURCES or result of IoCallDriver |
| 346 | * |
| 347 | */ |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 348 | |
Malcolm Priestley | fe5d00e | 2012-12-10 22:14:36 +0000 | [diff] [blame] | 349 | static void s_nsInterruptUsbIoCompleteRead(struct urb *urb) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 350 | { |
Malcolm Priestley | fe5d00e | 2012-12-10 22:14:36 +0000 | [diff] [blame] | 351 | struct vnt_private *pDevice = (struct vnt_private *)urb->context; |
| 352 | int ntStatus; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 353 | |
| 354 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->s_nsInterruptUsbIoCompleteRead\n"); |
| 355 | // |
| 356 | // The context given to IoSetCompletionRoutine is the receive buffer object |
| 357 | // |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 358 | |
| 359 | // |
| 360 | // We have a number of cases: |
| 361 | // 1) The USB read timed out and we received no data. |
| 362 | // 2) The USB read timed out and we received some data. |
| 363 | // 3) The USB read was successful and fully filled our irp buffer. |
| 364 | // 4) The irp was cancelled. |
| 365 | // 5) Some other failure from the USB device object. |
| 366 | // |
Malcolm Priestley | c98fbf9 | 2014-02-17 21:16:20 +0000 | [diff] [blame] | 367 | switch (urb->status) { |
| 368 | case 0: |
| 369 | case -ETIMEDOUT: |
| 370 | break; |
| 371 | case -ECONNRESET: |
| 372 | case -ENOENT: |
| 373 | case -ESHUTDOWN: |
| 374 | pDevice->intBuf.bInUse = false; |
| 375 | return; |
| 376 | default: |
| 377 | break; |
| 378 | } |
| 379 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 380 | ntStatus = urb->status; |
| 381 | |
| 382 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"s_nsInterruptUsbIoCompleteRead Status %d\n", ntStatus); |
| 383 | |
| 384 | // if we were not successful, we need to free the int buffer for future use right here |
| 385 | // otherwise interrupt data handler will free int buffer after it handle it. |
| 386 | if (( ntStatus != STATUS_SUCCESS )) { |
| 387 | pDevice->ulBulkInError++; |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 388 | pDevice->intBuf.bInUse = false; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 389 | |
| 390 | // if (ntStatus == USBD_STATUS_CRC) { |
| 391 | // pDevice->ulIntInContCRCError++; |
| 392 | // } |
| 393 | |
| 394 | // if (ntStatus == STATUS_NOT_CONNECTED ) |
| 395 | // { |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 396 | // } |
| 397 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"IntUSBIoCompleteControl STATUS = %d\n", ntStatus ); |
Andres More | cc856e6 | 2010-05-17 21:34:01 -0300 | [diff] [blame] | 398 | } else { |
| 399 | pDevice->ulIntInBytesRead += (unsigned long) urb->actual_length; |
| 400 | pDevice->ulIntInContCRCError = 0; |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 401 | pDevice->bEventAvailable = true; |
Andres More | cc856e6 | 2010-05-17 21:34:01 -0300 | [diff] [blame] | 402 | INTnsProcessData(pDevice); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 403 | } |
| 404 | |
Joe Perches | bfbfeec | 2010-03-24 22:17:06 -0700 | [diff] [blame] | 405 | ntStatus = usb_submit_urb(pDevice->pInterruptURB, GFP_ATOMIC); |
Malcolm Priestley | 247b4b6 | 2014-02-17 21:12:51 +0000 | [diff] [blame] | 406 | if (ntStatus) { |
| 407 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO |
| 408 | "Submit int URB failed %d\n", ntStatus); |
| 409 | } else { |
| 410 | pDevice->intBuf.bInUse = true; |
| 411 | } |
Malcolm Priestley | 749627f | 2014-02-17 21:24:33 +0000 | [diff] [blame^] | 412 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 413 | // |
| 414 | // We return STATUS_MORE_PROCESSING_REQUIRED so that the completion |
| 415 | // routine (IofCompleteRequest) will stop working on the irp. |
| 416 | // |
| 417 | return ; |
| 418 | } |
| 419 | |
| 420 | /* |
| 421 | * Description: |
| 422 | * Allocates an usb BulkIn irp and calls USBD. |
| 423 | * |
| 424 | * Parameters: |
| 425 | * In: |
| 426 | * pDevice - Pointer to the adapter |
| 427 | * Out: |
| 428 | * none |
| 429 | * |
| 430 | * Return Value: STATUS_INSUFFICIENT_RESOURCES or result of IoCallDriver |
| 431 | * |
| 432 | */ |
Malcolm Priestley | fe5d00e | 2012-12-10 22:14:36 +0000 | [diff] [blame] | 433 | |
Malcolm Priestley | 115cac2 | 2013-08-28 21:12:35 +0100 | [diff] [blame] | 434 | int PIPEnsBulkInUsbRead(struct vnt_private *pDevice, struct vnt_rcb *pRCB) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 435 | { |
Andres More | 6487c49 | 2010-08-02 20:51:57 -0300 | [diff] [blame] | 436 | int ntStatus = 0; |
Malcolm Priestley | fe5d00e | 2012-12-10 22:14:36 +0000 | [diff] [blame] | 437 | struct urb *pUrb; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 438 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 439 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->s_nsStartBulkInUsbRead\n"); |
| 440 | |
Andres More | 731047f | 2010-08-05 22:17:20 -0300 | [diff] [blame] | 441 | if (pDevice->Flags & fMP_DISCONNECTED) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 442 | return STATUS_FAILURE; |
| 443 | |
| 444 | pDevice->ulBulkInPosted++; |
| 445 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 446 | pUrb = pRCB->pUrb; |
| 447 | // |
| 448 | // Now that we have created the urb, we will send a |
| 449 | // request to the USB device object. |
| 450 | // |
| 451 | if (pRCB->skb == NULL) { |
| 452 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pRCB->skb is null \n"); |
| 453 | return ntStatus; |
| 454 | } |
| 455 | |
| 456 | usb_fill_bulk_urb(pUrb, |
| 457 | pDevice->usb, |
| 458 | usb_rcvbulkpipe(pDevice->usb, 2), |
Andres More | 8611a29 | 2010-05-01 14:25:00 -0300 | [diff] [blame] | 459 | (void *) (pRCB->skb->data), |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 460 | MAX_TOTAL_SIZE_WITH_ALL_HEADERS, |
| 461 | s_nsBulkInUsbIoCompleteRead, |
| 462 | pRCB); |
| 463 | |
Joe Perches | bfbfeec | 2010-03-24 22:17:06 -0700 | [diff] [blame] | 464 | ntStatus = usb_submit_urb(pUrb, GFP_ATOMIC); |
| 465 | if (ntStatus != 0) { |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 466 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Submit Rx URB failed %d\n", ntStatus); |
| 467 | return STATUS_FAILURE ; |
| 468 | } |
| 469 | pRCB->Ref = 1; |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 470 | pRCB->bBoolInUse= true; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 471 | |
| 472 | return ntStatus; |
| 473 | } |
| 474 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 475 | /* |
| 476 | * Description: |
| 477 | * Complete function of usb BulkIn irp. |
| 478 | * |
| 479 | * Parameters: |
| 480 | * In: |
| 481 | * pDevice - Pointer to the adapter |
| 482 | * |
| 483 | * Out: |
| 484 | * none |
| 485 | * |
| 486 | * Return Value: STATUS_INSUFFICIENT_RESOURCES or result of IoCallDriver |
| 487 | * |
| 488 | */ |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 489 | |
Malcolm Priestley | fe5d00e | 2012-12-10 22:14:36 +0000 | [diff] [blame] | 490 | static void s_nsBulkInUsbIoCompleteRead(struct urb *urb) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 491 | { |
Malcolm Priestley | 115cac2 | 2013-08-28 21:12:35 +0100 | [diff] [blame] | 492 | struct vnt_rcb *pRCB = (struct vnt_rcb *)urb->context; |
Malcolm Priestley | fe5d00e | 2012-12-10 22:14:36 +0000 | [diff] [blame] | 493 | struct vnt_private *pDevice = pRCB->pDevice; |
| 494 | unsigned long bytesRead; |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 495 | int bIndicateReceive = false; |
| 496 | int bReAllocSkb = false; |
Malcolm Priestley | fe5d00e | 2012-12-10 22:14:36 +0000 | [diff] [blame] | 497 | int status; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 498 | |
| 499 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->s_nsBulkInUsbIoCompleteRead\n"); |
| 500 | status = urb->status; |
| 501 | bytesRead = urb->actual_length; |
| 502 | |
| 503 | if (status) { |
| 504 | pDevice->ulBulkInError++; |
| 505 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"BULK In failed %d\n", status); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 506 | //todo...xxxxxx |
| 507 | // if (status == USBD_STATUS_CRC) { |
| 508 | // pDevice->ulBulkInContCRCError++; |
| 509 | // } |
| 510 | // if (status == STATUS_DEVICE_NOT_CONNECTED ) |
| 511 | // { |
| 512 | // MP_SET_FLAG(pDevice, fMP_DISCONNECTED); |
| 513 | // } |
| 514 | } else { |
Malcolm Priestley | 87c6298 | 2012-11-04 16:18:56 +0000 | [diff] [blame] | 515 | if (bytesRead) |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 516 | bIndicateReceive = true; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 517 | pDevice->ulBulkInContCRCError = 0; |
| 518 | pDevice->ulBulkInBytesRead += bytesRead; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 519 | } |
| 520 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 521 | if (bIndicateReceive) { |
| 522 | spin_lock(&pDevice->lock); |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 523 | if (RXbBulkInProcessData(pDevice, pRCB, bytesRead) == true) |
| 524 | bReAllocSkb = true; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 525 | spin_unlock(&pDevice->lock); |
| 526 | } |
| 527 | pRCB->Ref--; |
| 528 | if (pRCB->Ref == 0) |
| 529 | { |
| 530 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"RxvFreeNormal %d \n",pDevice->NumRecvFreeList); |
| 531 | spin_lock(&pDevice->lock); |
| 532 | RXvFreeRCB(pRCB, bReAllocSkb); |
| 533 | spin_unlock(&pDevice->lock); |
| 534 | } |
| 535 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 536 | return; |
| 537 | } |
| 538 | |
| 539 | /* |
| 540 | * Description: |
| 541 | * Allocates an usb BulkOut irp and calls USBD. |
| 542 | * |
| 543 | * Parameters: |
| 544 | * In: |
| 545 | * pDevice - Pointer to the adapter |
| 546 | * Out: |
| 547 | * none |
| 548 | * |
| 549 | * Return Value: STATUS_INSUFFICIENT_RESOURCES or result of IoCallDriver |
| 550 | * |
| 551 | */ |
Malcolm Priestley | fe5d00e | 2012-12-10 22:14:36 +0000 | [diff] [blame] | 552 | |
Malcolm Priestley | dcdf1d0 | 2013-08-27 12:41:50 +0100 | [diff] [blame] | 553 | int PIPEnsSendBulkOut(struct vnt_private *pDevice, |
| 554 | struct vnt_usb_send_context *pContext) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 555 | { |
Malcolm Priestley | fe5d00e | 2012-12-10 22:14:36 +0000 | [diff] [blame] | 556 | int status; |
| 557 | struct urb *pUrb; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 558 | |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 559 | pDevice->bPWBitOn = false; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 560 | |
| 561 | /* |
| 562 | if (pDevice->pPendingBulkOutContext != NULL) { |
| 563 | pDevice->NumContextsQueued++; |
| 564 | EnqueueContext(pDevice->FirstTxContextQueue, pDevice->LastTxContextQueue, pContext); |
| 565 | status = STATUS_PENDING; |
| 566 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Send pending!\n"); |
| 567 | return status; |
| 568 | } |
| 569 | */ |
| 570 | |
| 571 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"s_nsSendBulkOut\n"); |
| 572 | |
Andres More | 731047f | 2010-08-05 22:17:20 -0300 | [diff] [blame] | 573 | if (MP_IS_READY(pDevice) && (pDevice->Flags & fMP_POST_WRITES)) { |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 574 | |
| 575 | pUrb = pContext->pUrb; |
| 576 | pDevice->ulBulkOutPosted++; |
| 577 | // pDevice->pPendingBulkOutContext = pContext; |
| 578 | usb_fill_bulk_urb( |
| 579 | pUrb, |
| 580 | pDevice->usb, |
Andres More | 8611a29 | 2010-05-01 14:25:00 -0300 | [diff] [blame] | 581 | usb_sndbulkpipe(pDevice->usb, 3), |
| 582 | (void *) &(pContext->Data[0]), |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 583 | pContext->uBufLen, |
| 584 | s_nsBulkOutIoCompleteWrite, |
| 585 | pContext); |
| 586 | |
Joe Perches | bfbfeec | 2010-03-24 22:17:06 -0700 | [diff] [blame] | 587 | status = usb_submit_urb(pUrb, GFP_ATOMIC); |
| 588 | if (status != 0) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 589 | { |
| 590 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Submit Tx URB failed %d\n", status); |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 591 | pContext->bBoolInUse = false; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 592 | return STATUS_FAILURE; |
| 593 | } |
| 594 | return STATUS_PENDING; |
| 595 | } |
| 596 | else { |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 597 | pContext->bBoolInUse = false; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 598 | return STATUS_RESOURCES; |
| 599 | } |
| 600 | } |
| 601 | |
| 602 | /* |
| 603 | * Description: s_nsBulkOutIoCompleteWrite |
| 604 | * 1a) Indicate to the protocol the status of the write. |
| 605 | * 1b) Return ownership of the packet to the protocol. |
| 606 | * |
| 607 | * 2) If any more packets are queue for sending, send another packet |
| 608 | * to USBD. |
| 609 | * If the attempt to send the packet to the driver fails, |
| 610 | * return ownership of the packet to the protocol and |
| 611 | * try another packet (until one succeeds). |
| 612 | * |
| 613 | * Parameters: |
| 614 | * In: |
| 615 | * pdoUsbDevObj - pointer to the USB device object which |
| 616 | * completed the irp |
| 617 | * pIrp - the irp which was completed by the |
| 618 | * device object |
| 619 | * pContext - the context given to IoSetCompletionRoutine |
| 620 | * before calling IoCallDriver on the irp |
| 621 | * The pContext is a pointer to the USB device object. |
| 622 | * Out: |
| 623 | * none |
| 624 | * |
| 625 | * Return Value: STATUS_MORE_PROCESSING_REQUIRED - allows the completion routine |
| 626 | * (IofCompleteRequest) to stop working on the irp. |
| 627 | * |
| 628 | */ |
Malcolm Priestley | fe5d00e | 2012-12-10 22:14:36 +0000 | [diff] [blame] | 629 | |
| 630 | static void s_nsBulkOutIoCompleteWrite(struct urb *urb) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 631 | { |
Malcolm Priestley | fe5d00e | 2012-12-10 22:14:36 +0000 | [diff] [blame] | 632 | struct vnt_private *pDevice; |
| 633 | int status; |
| 634 | CONTEXT_TYPE ContextType; |
| 635 | unsigned long ulBufLen; |
Malcolm Priestley | dcdf1d0 | 2013-08-27 12:41:50 +0100 | [diff] [blame] | 636 | struct vnt_usb_send_context *pContext; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 637 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 638 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->s_nsBulkOutIoCompleteWrite\n"); |
| 639 | // |
| 640 | // The context given to IoSetCompletionRoutine is an USB_CONTEXT struct |
| 641 | // |
Malcolm Priestley | dcdf1d0 | 2013-08-27 12:41:50 +0100 | [diff] [blame] | 642 | pContext = (struct vnt_usb_send_context *)urb->context; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 643 | |
| 644 | pDevice = pContext->pDevice; |
| 645 | ContextType = pContext->Type; |
| 646 | ulBufLen = pContext->uBufLen; |
| 647 | |
| 648 | if (!netif_device_present(pDevice->dev)) |
| 649 | return; |
| 650 | |
| 651 | // |
| 652 | // Perform various IRP, URB, and buffer 'sanity checks' |
| 653 | // |
| 654 | |
| 655 | status = urb->status; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 656 | |
| 657 | if(status == STATUS_SUCCESS) { |
| 658 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Write %d bytes\n",(int)ulBufLen); |
| 659 | pDevice->ulBulkOutBytesWrite += ulBufLen; |
| 660 | pDevice->ulBulkOutContCRCError = 0; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 661 | } else { |
| 662 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"BULK Out failed %d\n", status); |
| 663 | pDevice->ulBulkOutError++; |
| 664 | } |
| 665 | |
| 666 | // pDevice->ulCheckForHangCount = 0; |
| 667 | // pDevice->pPendingBulkOutContext = NULL; |
| 668 | |
| 669 | if ( CONTEXT_DATA_PACKET == ContextType ) { |
| 670 | // Indicate to the protocol the status of the sent packet and return |
| 671 | // ownership of the packet. |
| 672 | if (pContext->pPacket != NULL) { |
| 673 | dev_kfree_skb_irq(pContext->pPacket); |
| 674 | pContext->pPacket = NULL; |
| 675 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"tx %d bytes\n",(int)ulBufLen); |
| 676 | } |
| 677 | |
| 678 | pDevice->dev->trans_start = jiffies; |
| 679 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 680 | if (status == STATUS_SUCCESS) { |
| 681 | pDevice->packetsSent++; |
| 682 | } |
| 683 | else { |
| 684 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Send USB error! [%08xh]\n", status); |
| 685 | pDevice->packetsSentDropped++; |
| 686 | } |
| 687 | |
| 688 | } |
Andres More | 4e9b5e2 | 2013-02-12 20:36:30 -0500 | [diff] [blame] | 689 | if (pDevice->bLinkPass == true) { |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 690 | if (netif_queue_stopped(pDevice->dev)) |
| 691 | netif_wake_queue(pDevice->dev); |
| 692 | } |
Andres More | e269fc2 | 2013-02-12 20:36:29 -0500 | [diff] [blame] | 693 | pContext->bBoolInUse = false; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 694 | |
| 695 | return; |
| 696 | } |