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 | |
Malcolm Priestley | 5f38b78 | 2014-02-19 18:37:32 +0000 | [diff] [blame] | 298 | int PIPEnsInterruptRead(struct vnt_private *priv) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 299 | { |
Malcolm Priestley | 5f38b78 | 2014-02-19 18:37:32 +0000 | [diff] [blame] | 300 | int status = STATUS_FAILURE; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 301 | |
Malcolm Priestley | 5f38b78 | 2014-02-19 18:37:32 +0000 | [diff] [blame] | 302 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO |
| 303 | "---->s_nsStartInterruptUsbRead()\n"); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 304 | |
Malcolm Priestley | f764e00 | 2014-02-19 18:39:09 +0000 | [diff] [blame] | 305 | if (priv->int_buf.in_use == true) |
Malcolm Priestley | 5f38b78 | 2014-02-19 18:37:32 +0000 | [diff] [blame] | 306 | return STATUS_FAILURE; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 307 | |
Malcolm Priestley | f764e00 | 2014-02-19 18:39:09 +0000 | [diff] [blame] | 308 | priv->int_buf.in_use = true; |
Malcolm Priestley | 5f38b78 | 2014-02-19 18:37:32 +0000 | [diff] [blame] | 309 | priv->ulIntInPosted++; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 310 | |
Malcolm Priestley | 5f38b78 | 2014-02-19 18:37:32 +0000 | [diff] [blame] | 311 | usb_fill_int_urb(priv->pInterruptURB, |
| 312 | priv->usb, |
| 313 | usb_rcvbulkpipe(priv->usb, 1), |
Malcolm Priestley | f764e00 | 2014-02-19 18:39:09 +0000 | [diff] [blame] | 314 | priv->int_buf.data_buf, |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 315 | MAX_INTERRUPT_SIZE, |
| 316 | s_nsInterruptUsbIoCompleteRead, |
Malcolm Priestley | 5f38b78 | 2014-02-19 18:37:32 +0000 | [diff] [blame] | 317 | priv, |
| 318 | priv->int_interval); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 319 | |
Malcolm Priestley | 5f38b78 | 2014-02-19 18:37:32 +0000 | [diff] [blame] | 320 | status = usb_submit_urb(priv->pInterruptURB, GFP_ATOMIC); |
| 321 | if (status) { |
Malcolm Priestley | 59858f5 | 2014-02-19 18:36:37 +0000 | [diff] [blame] | 322 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO |
Malcolm Priestley | 5f38b78 | 2014-02-19 18:37:32 +0000 | [diff] [blame] | 323 | "Submit int URB failed %d\n", status); |
Malcolm Priestley | f764e00 | 2014-02-19 18:39:09 +0000 | [diff] [blame] | 324 | priv->int_buf.in_use = false; |
Malcolm Priestley | 59858f5 | 2014-02-19 18:36:37 +0000 | [diff] [blame] | 325 | } |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 326 | |
Malcolm Priestley | 5f38b78 | 2014-02-19 18:37:32 +0000 | [diff] [blame] | 327 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO |
| 328 | "<----s_nsStartInterruptUsbRead Return(%x)\n", status); |
| 329 | |
| 330 | return status; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 331 | } |
| 332 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 333 | /* |
| 334 | * Description: |
| 335 | * Complete function of usb interrupt in irp. |
| 336 | * |
| 337 | * Parameters: |
| 338 | * In: |
| 339 | * pDevice - Pointer to the adapter |
| 340 | * |
| 341 | * Out: |
| 342 | * none |
| 343 | * |
| 344 | * Return Value: STATUS_INSUFFICIENT_RESOURCES or result of IoCallDriver |
| 345 | * |
| 346 | */ |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 347 | |
Malcolm Priestley | fe5d00e | 2012-12-10 22:14:36 +0000 | [diff] [blame] | 348 | static void s_nsInterruptUsbIoCompleteRead(struct urb *urb) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 349 | { |
Malcolm Priestley | 599e4b5 | 2014-02-25 20:51:51 +0000 | [diff] [blame^] | 350 | struct vnt_private *priv = urb->context; |
Malcolm Priestley | d9ad7a9 | 2014-02-17 21:27:30 +0000 | [diff] [blame] | 351 | int status; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 352 | |
Malcolm Priestley | d9ad7a9 | 2014-02-17 21:27:30 +0000 | [diff] [blame] | 353 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO |
| 354 | "---->s_nsInterruptUsbIoCompleteRead\n"); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 355 | |
Malcolm Priestley | c98fbf9 | 2014-02-17 21:16:20 +0000 | [diff] [blame] | 356 | switch (urb->status) { |
| 357 | case 0: |
| 358 | case -ETIMEDOUT: |
| 359 | break; |
| 360 | case -ECONNRESET: |
| 361 | case -ENOENT: |
| 362 | case -ESHUTDOWN: |
Malcolm Priestley | f764e00 | 2014-02-19 18:39:09 +0000 | [diff] [blame] | 363 | priv->int_buf.in_use = false; |
Malcolm Priestley | c98fbf9 | 2014-02-17 21:16:20 +0000 | [diff] [blame] | 364 | return; |
| 365 | default: |
| 366 | break; |
| 367 | } |
| 368 | |
Malcolm Priestley | d9ad7a9 | 2014-02-17 21:27:30 +0000 | [diff] [blame] | 369 | status = urb->status; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 370 | |
Malcolm Priestley | d9ad7a9 | 2014-02-17 21:27:30 +0000 | [diff] [blame] | 371 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO |
| 372 | "s_nsInterruptUsbIoCompleteRead Status %d\n", status); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 373 | |
Malcolm Priestley | d9ad7a9 | 2014-02-17 21:27:30 +0000 | [diff] [blame] | 374 | if (status != STATUS_SUCCESS) { |
| 375 | priv->ulBulkInError++; |
Malcolm Priestley | f764e00 | 2014-02-19 18:39:09 +0000 | [diff] [blame] | 376 | priv->int_buf.in_use = false; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 377 | |
Malcolm Priestley | 247b4b6 | 2014-02-17 21:12:51 +0000 | [diff] [blame] | 378 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO |
Malcolm Priestley | d9ad7a9 | 2014-02-17 21:27:30 +0000 | [diff] [blame] | 379 | "IntUSBIoCompleteControl STATUS = %d\n", status); |
Malcolm Priestley | 247b4b6 | 2014-02-17 21:12:51 +0000 | [diff] [blame] | 380 | } else { |
Malcolm Priestley | d9ad7a9 | 2014-02-17 21:27:30 +0000 | [diff] [blame] | 381 | priv->ulIntInBytesRead += (unsigned long)urb->actual_length; |
| 382 | priv->ulIntInContCRCError = 0; |
| 383 | priv->bEventAvailable = true; |
| 384 | INTnsProcessData(priv); |
Malcolm Priestley | 247b4b6 | 2014-02-17 21:12:51 +0000 | [diff] [blame] | 385 | } |
Malcolm Priestley | 749627f | 2014-02-17 21:24:33 +0000 | [diff] [blame] | 386 | |
Malcolm Priestley | d9ad7a9 | 2014-02-17 21:27:30 +0000 | [diff] [blame] | 387 | status = usb_submit_urb(priv->pInterruptURB, GFP_ATOMIC); |
| 388 | if (status) { |
| 389 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO |
| 390 | "Submit int URB failed %d\n", status); |
| 391 | } else { |
Malcolm Priestley | f764e00 | 2014-02-19 18:39:09 +0000 | [diff] [blame] | 392 | priv->int_buf.in_use = true; |
Malcolm Priestley | d9ad7a9 | 2014-02-17 21:27:30 +0000 | [diff] [blame] | 393 | } |
| 394 | |
| 395 | return; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 396 | } |
| 397 | |
| 398 | /* |
| 399 | * Description: |
| 400 | * Allocates an usb BulkIn irp and calls USBD. |
| 401 | * |
| 402 | * Parameters: |
| 403 | * In: |
| 404 | * pDevice - Pointer to the adapter |
| 405 | * Out: |
| 406 | * none |
| 407 | * |
| 408 | * Return Value: STATUS_INSUFFICIENT_RESOURCES or result of IoCallDriver |
| 409 | * |
| 410 | */ |
Malcolm Priestley | fe5d00e | 2012-12-10 22:14:36 +0000 | [diff] [blame] | 411 | |
Malcolm Priestley | 0b787d7 | 2014-02-25 20:51:50 +0000 | [diff] [blame] | 412 | int PIPEnsBulkInUsbRead(struct vnt_private *priv, struct vnt_rcb *rcb) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 413 | { |
Malcolm Priestley | 0b787d7 | 2014-02-25 20:51:50 +0000 | [diff] [blame] | 414 | int status = 0; |
| 415 | struct urb *urb; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 416 | |
Malcolm Priestley | 0b787d7 | 2014-02-25 20:51:50 +0000 | [diff] [blame] | 417 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->s_nsStartBulkInUsbRead\n"); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 418 | |
Malcolm Priestley | 0b787d7 | 2014-02-25 20:51:50 +0000 | [diff] [blame] | 419 | if (priv->Flags & fMP_DISCONNECTED) |
| 420 | return STATUS_FAILURE; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 421 | |
Malcolm Priestley | 0b787d7 | 2014-02-25 20:51:50 +0000 | [diff] [blame] | 422 | priv->ulBulkInPosted++; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 423 | |
Malcolm Priestley | 0b787d7 | 2014-02-25 20:51:50 +0000 | [diff] [blame] | 424 | urb = rcb->pUrb; |
| 425 | if (rcb->skb == NULL) { |
| 426 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"rcb->skb is null\n"); |
| 427 | return status; |
| 428 | } |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 429 | |
Malcolm Priestley | 0b787d7 | 2014-02-25 20:51:50 +0000 | [diff] [blame] | 430 | usb_fill_bulk_urb(urb, |
| 431 | priv->usb, |
| 432 | usb_rcvbulkpipe(priv->usb, 2), |
| 433 | (void *) (rcb->skb->data), |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 434 | MAX_TOTAL_SIZE_WITH_ALL_HEADERS, |
| 435 | s_nsBulkInUsbIoCompleteRead, |
Malcolm Priestley | 0b787d7 | 2014-02-25 20:51:50 +0000 | [diff] [blame] | 436 | rcb); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 437 | |
Malcolm Priestley | 0b787d7 | 2014-02-25 20:51:50 +0000 | [diff] [blame] | 438 | status = usb_submit_urb(urb, GFP_ATOMIC); |
| 439 | if (status != 0) { |
| 440 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO |
| 441 | "Submit Rx URB failed %d\n", status); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 442 | return STATUS_FAILURE ; |
| 443 | } |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 444 | |
Malcolm Priestley | 0b787d7 | 2014-02-25 20:51:50 +0000 | [diff] [blame] | 445 | rcb->Ref = 1; |
| 446 | rcb->bBoolInUse = true; |
| 447 | |
| 448 | return status; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 449 | } |
| 450 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 451 | /* |
| 452 | * Description: |
| 453 | * Complete function of usb BulkIn irp. |
| 454 | * |
| 455 | * Parameters: |
| 456 | * In: |
| 457 | * pDevice - Pointer to the adapter |
| 458 | * |
| 459 | * Out: |
| 460 | * none |
| 461 | * |
| 462 | * Return Value: STATUS_INSUFFICIENT_RESOURCES or result of IoCallDriver |
| 463 | * |
| 464 | */ |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 465 | |
Malcolm Priestley | fe5d00e | 2012-12-10 22:14:36 +0000 | [diff] [blame] | 466 | static void s_nsBulkInUsbIoCompleteRead(struct urb *urb) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 467 | { |
Malcolm Priestley | 599e4b5 | 2014-02-25 20:51:51 +0000 | [diff] [blame^] | 468 | struct vnt_rcb *rcb = urb->context; |
Malcolm Priestley | d4fa2ab | 2014-02-25 20:51:49 +0000 | [diff] [blame] | 469 | struct vnt_private *priv = rcb->pDevice; |
| 470 | int re_alloc_skb = false; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 471 | |
Malcolm Priestley | d4fa2ab | 2014-02-25 20:51:49 +0000 | [diff] [blame] | 472 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->s_nsBulkInUsbIoCompleteRead\n"); |
Malcolm Priestley | e3a8fa1 | 2014-02-25 20:51:46 +0000 | [diff] [blame] | 473 | |
Malcolm Priestley | 6763898 | 2014-02-25 20:51:48 +0000 | [diff] [blame] | 474 | switch (urb->status) { |
| 475 | case 0: |
Malcolm Priestley | d4fa2ab | 2014-02-25 20:51:49 +0000 | [diff] [blame] | 476 | priv->ulBulkInContCRCError = 0; |
| 477 | priv->ulBulkInBytesRead += urb->actual_length; |
Malcolm Priestley | 6763898 | 2014-02-25 20:51:48 +0000 | [diff] [blame] | 478 | break; |
| 479 | case -ECONNRESET: |
| 480 | case -ENOENT: |
| 481 | case -ESHUTDOWN: |
| 482 | return; |
| 483 | case -ETIMEDOUT: |
| 484 | default: |
Malcolm Priestley | d4fa2ab | 2014-02-25 20:51:49 +0000 | [diff] [blame] | 485 | priv->ulBulkInError++; |
Malcolm Priestley | 6763898 | 2014-02-25 20:51:48 +0000 | [diff] [blame] | 486 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO |
| 487 | "BULK In failed %d\n", urb->status); |
| 488 | break; |
| 489 | } |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 490 | |
Malcolm Priestley | d4fa2ab | 2014-02-25 20:51:49 +0000 | [diff] [blame] | 491 | if (urb->actual_length) { |
| 492 | spin_lock(&priv->lock); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 493 | |
Malcolm Priestley | d4fa2ab | 2014-02-25 20:51:49 +0000 | [diff] [blame] | 494 | if (RXbBulkInProcessData(priv, rcb, urb->actual_length) == true) |
| 495 | re_alloc_skb = true; |
| 496 | |
| 497 | spin_unlock(&priv->lock); |
| 498 | } |
| 499 | |
| 500 | rcb->Ref--; |
| 501 | if (rcb->Ref == 0) { |
| 502 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"RxvFreeNormal %d\n", |
| 503 | priv->NumRecvFreeList); |
| 504 | spin_lock(&priv->lock); |
| 505 | |
| 506 | RXvFreeRCB(rcb, re_alloc_skb); |
| 507 | |
| 508 | spin_unlock(&priv->lock); |
| 509 | } |
| 510 | |
| 511 | return; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 512 | } |
| 513 | |
| 514 | /* |
| 515 | * Description: |
| 516 | * Allocates an usb BulkOut irp and calls USBD. |
| 517 | * |
| 518 | * Parameters: |
| 519 | * In: |
| 520 | * pDevice - Pointer to the adapter |
| 521 | * Out: |
| 522 | * none |
| 523 | * |
| 524 | * Return Value: STATUS_INSUFFICIENT_RESOURCES or result of IoCallDriver |
| 525 | * |
| 526 | */ |
Malcolm Priestley | fe5d00e | 2012-12-10 22:14:36 +0000 | [diff] [blame] | 527 | |
Malcolm Priestley | 3f38290 | 2014-02-25 20:51:45 +0000 | [diff] [blame] | 528 | int PIPEnsSendBulkOut(struct vnt_private *priv, |
| 529 | struct vnt_usb_send_context *context) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 530 | { |
Malcolm Priestley | fe5d00e | 2012-12-10 22:14:36 +0000 | [diff] [blame] | 531 | int status; |
Malcolm Priestley | 3f38290 | 2014-02-25 20:51:45 +0000 | [diff] [blame] | 532 | struct urb *urb; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 533 | |
Malcolm Priestley | 3f38290 | 2014-02-25 20:51:45 +0000 | [diff] [blame] | 534 | priv->bPWBitOn = false; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 535 | |
Malcolm Priestley | 3f38290 | 2014-02-25 20:51:45 +0000 | [diff] [blame] | 536 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"s_nsSendBulkOut\n"); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 537 | |
Malcolm Priestley | 3f38290 | 2014-02-25 20:51:45 +0000 | [diff] [blame] | 538 | if (!(MP_IS_READY(priv) && priv->Flags & fMP_POST_WRITES)) { |
| 539 | context->bBoolInUse = false; |
Malcolm Priestley | 1333830 | 2014-02-25 20:51:43 +0000 | [diff] [blame] | 540 | return STATUS_RESOURCES; |
| 541 | } |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 542 | |
Malcolm Priestley | 3f38290 | 2014-02-25 20:51:45 +0000 | [diff] [blame] | 543 | urb = context->pUrb; |
| 544 | priv->ulBulkOutPosted++; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 545 | |
Malcolm Priestley | 3f38290 | 2014-02-25 20:51:45 +0000 | [diff] [blame] | 546 | usb_fill_bulk_urb(urb, |
| 547 | priv->usb, |
| 548 | usb_sndbulkpipe(priv->usb, 3), |
| 549 | context->Data, |
| 550 | context->uBufLen, |
| 551 | s_nsBulkOutIoCompleteWrite, |
| 552 | context); |
| 553 | |
| 554 | status = usb_submit_urb(urb, GFP_ATOMIC); |
| 555 | if (status != 0) { |
| 556 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO |
| 557 | "Submit Tx URB failed %d\n", status); |
| 558 | context->bBoolInUse = false; |
| 559 | return STATUS_FAILURE; |
| 560 | } |
| 561 | |
| 562 | return STATUS_PENDING; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 563 | } |
| 564 | |
| 565 | /* |
| 566 | * Description: s_nsBulkOutIoCompleteWrite |
| 567 | * 1a) Indicate to the protocol the status of the write. |
| 568 | * 1b) Return ownership of the packet to the protocol. |
| 569 | * |
| 570 | * 2) If any more packets are queue for sending, send another packet |
| 571 | * to USBD. |
| 572 | * If the attempt to send the packet to the driver fails, |
| 573 | * return ownership of the packet to the protocol and |
| 574 | * try another packet (until one succeeds). |
| 575 | * |
| 576 | * Parameters: |
| 577 | * In: |
| 578 | * pdoUsbDevObj - pointer to the USB device object which |
| 579 | * completed the irp |
| 580 | * pIrp - the irp which was completed by the |
| 581 | * device object |
| 582 | * pContext - the context given to IoSetCompletionRoutine |
| 583 | * before calling IoCallDriver on the irp |
| 584 | * The pContext is a pointer to the USB device object. |
| 585 | * Out: |
| 586 | * none |
| 587 | * |
| 588 | * Return Value: STATUS_MORE_PROCESSING_REQUIRED - allows the completion routine |
| 589 | * (IofCompleteRequest) to stop working on the irp. |
| 590 | * |
| 591 | */ |
Malcolm Priestley | fe5d00e | 2012-12-10 22:14:36 +0000 | [diff] [blame] | 592 | |
| 593 | static void s_nsBulkOutIoCompleteWrite(struct urb *urb) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 594 | { |
Malcolm Priestley | 599e4b5 | 2014-02-25 20:51:51 +0000 | [diff] [blame^] | 595 | struct vnt_usb_send_context *context = urb->context; |
Malcolm Priestley | 21aa212 | 2014-02-19 21:54:45 +0000 | [diff] [blame] | 596 | struct vnt_private *priv = context->pDevice; |
Malcolm Priestley | 1450ba6 | 2014-02-19 21:56:33 +0000 | [diff] [blame] | 597 | u8 context_type = context->type; |
Malcolm Priestley | 21aa212 | 2014-02-19 21:54:45 +0000 | [diff] [blame] | 598 | unsigned long buf_len = context->uBufLen; |
Malcolm Priestley | fe5d00e | 2012-12-10 22:14:36 +0000 | [diff] [blame] | 599 | int status; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 600 | |
Malcolm Priestley | 21aa212 | 2014-02-19 21:54:45 +0000 | [diff] [blame] | 601 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->s_nsBulkOutIoCompleteWrite\n"); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 602 | |
Malcolm Priestley | e8152bf | 2014-02-19 21:53:35 +0000 | [diff] [blame] | 603 | switch (urb->status) { |
| 604 | case 0: |
| 605 | case -ETIMEDOUT: |
| 606 | break; |
| 607 | case -ECONNRESET: |
| 608 | case -ENOENT: |
| 609 | case -ESHUTDOWN: |
Malcolm Priestley | 21aa212 | 2014-02-19 21:54:45 +0000 | [diff] [blame] | 610 | context->bBoolInUse = false; |
Malcolm Priestley | e8152bf | 2014-02-19 21:53:35 +0000 | [diff] [blame] | 611 | return; |
| 612 | default: |
| 613 | break; |
| 614 | } |
| 615 | |
Malcolm Priestley | 21aa212 | 2014-02-19 21:54:45 +0000 | [diff] [blame] | 616 | if (!netif_device_present(priv->dev)) |
| 617 | return; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 618 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 619 | |
Malcolm Priestley | 21aa212 | 2014-02-19 21:54:45 +0000 | [diff] [blame] | 620 | status = urb->status; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 621 | |
Malcolm Priestley | 21aa212 | 2014-02-19 21:54:45 +0000 | [diff] [blame] | 622 | if (status == STATUS_SUCCESS) { |
| 623 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO |
| 624 | "Write %d bytes\n", (int)buf_len); |
| 625 | priv->ulBulkOutBytesWrite += buf_len; |
| 626 | priv->ulBulkOutContCRCError = 0; |
| 627 | } else { |
| 628 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO |
| 629 | "BULK Out failed %d\n", status); |
| 630 | priv->ulBulkOutError++; |
| 631 | } |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 632 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 633 | |
Malcolm Priestley | 21aa212 | 2014-02-19 21:54:45 +0000 | [diff] [blame] | 634 | if (CONTEXT_DATA_PACKET == context_type) { |
| 635 | if (context->pPacket != NULL) { |
| 636 | dev_kfree_skb_irq(context->pPacket); |
| 637 | context->pPacket = NULL; |
| 638 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO |
| 639 | "tx %d bytes\n", (int)buf_len); |
| 640 | } |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 641 | |
Malcolm Priestley | 21aa212 | 2014-02-19 21:54:45 +0000 | [diff] [blame] | 642 | priv->dev->trans_start = jiffies; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 643 | |
Malcolm Priestley | 21aa212 | 2014-02-19 21:54:45 +0000 | [diff] [blame] | 644 | if (status == STATUS_SUCCESS) { |
| 645 | priv->packetsSent++; |
| 646 | } else { |
| 647 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO |
| 648 | "Send USB error! [%08xh]\n", status); |
| 649 | priv->packetsSentDropped++; |
| 650 | } |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 651 | |
Malcolm Priestley | 21aa212 | 2014-02-19 21:54:45 +0000 | [diff] [blame] | 652 | } |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 653 | |
Malcolm Priestley | 21aa212 | 2014-02-19 21:54:45 +0000 | [diff] [blame] | 654 | if (priv->bLinkPass == true) { |
| 655 | if (netif_queue_stopped(priv->dev)) |
| 656 | netif_wake_queue(priv->dev); |
| 657 | } |
| 658 | |
| 659 | context->bBoolInUse = false; |
| 660 | |
| 661 | return; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 662 | } |