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 | |
Malcolm Priestley | c91b186 | 2014-05-15 22:49:19 +0100 | [diff] [blame] | 85 | mutex_lock(&pDevice->usb_lock); |
| 86 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 87 | ntStatus = usb_control_msg( |
| 88 | pDevice->usb, |
| 89 | usb_sndctrlpipe(pDevice->usb , 0), |
| 90 | byRequest, |
| 91 | 0x40, // RequestType |
| 92 | wValue, |
| 93 | wIndex, |
Andres More | 8611a29 | 2010-05-01 14:25:00 -0300 | [diff] [blame] | 94 | (void *) pbyBuffer, |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 95 | wLength, |
| 96 | HZ |
| 97 | ); |
| 98 | if (ntStatus >= 0) { |
| 99 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"usb_sndctrlpipe ntStatus= %d\n", ntStatus); |
| 100 | ntStatus = 0; |
| 101 | } else { |
| 102 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"usb_sndctrlpipe fail, ntStatus= %d\n", ntStatus); |
| 103 | } |
| 104 | |
Malcolm Priestley | c91b186 | 2014-05-15 22:49:19 +0100 | [diff] [blame] | 105 | mutex_unlock(&pDevice->usb_lock); |
| 106 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 107 | return ntStatus; |
| 108 | } |
| 109 | |
Malcolm Priestley | fe5d00e | 2012-12-10 22:14:36 +0000 | [diff] [blame] | 110 | int PIPEnsControlOut(struct vnt_private *pDevice, u8 byRequest, u16 wValue, |
| 111 | u16 wIndex, u16 wLength, u8 *pbyBuffer) |
Iulia Manda | 9009dd1 | 2014-03-13 01:35:40 +0200 | [diff] [blame] | 112 | __releases(&pDevice->lock) |
| 113 | __acquires(&pDevice->lock) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 114 | { |
Andres More | 6487c49 | 2010-08-02 20:51:57 -0300 | [diff] [blame] | 115 | int ntStatus = 0; |
Malcolm Priestley | fe5d00e | 2012-12-10 22:14:36 +0000 | [diff] [blame] | 116 | int ii; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 117 | |
Andres More | 731047f | 2010-08-05 22:17:20 -0300 | [diff] [blame] | 118 | if (pDevice->Flags & fMP_DISCONNECTED) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 119 | return STATUS_FAILURE; |
| 120 | |
Andres More | 731047f | 2010-08-05 22:17:20 -0300 | [diff] [blame] | 121 | if (pDevice->Flags & fMP_CONTROL_WRITES) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 122 | return STATUS_FAILURE; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 123 | |
Malcolm Priestley | ae5943d | 2013-01-30 20:07:29 +0000 | [diff] [blame] | 124 | if (pDevice->Flags & fMP_CONTROL_READS) |
| 125 | return STATUS_FAILURE; |
| 126 | |
Malcolm Priestley | e1feda1 | 2013-10-14 19:44:13 +0100 | [diff] [blame] | 127 | if (pDevice->pControlURB->hcpriv) |
| 128 | return STATUS_FAILURE; |
| 129 | |
Malcolm Priestley | c91b186 | 2014-05-15 22:49:19 +0100 | [diff] [blame] | 130 | mutex_lock(&pDevice->usb_lock); |
| 131 | |
Malcolm Priestley | ae5943d | 2013-01-30 20:07:29 +0000 | [diff] [blame] | 132 | MP_SET_FLAG(pDevice, fMP_CONTROL_WRITES); |
| 133 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 134 | pDevice->sUsbCtlRequest.bRequestType = 0x40; |
| 135 | pDevice->sUsbCtlRequest.bRequest = byRequest; |
| 136 | pDevice->sUsbCtlRequest.wValue = cpu_to_le16p(&wValue); |
| 137 | pDevice->sUsbCtlRequest.wIndex = cpu_to_le16p(&wIndex); |
| 138 | pDevice->sUsbCtlRequest.wLength = cpu_to_le16p(&wLength); |
| 139 | pDevice->pControlURB->transfer_flags |= URB_ASYNC_UNLINK; |
| 140 | pDevice->pControlURB->actual_length = 0; |
| 141 | // Notice, pbyBuffer limited point to variable buffer, can't be constant. |
| 142 | usb_fill_control_urb(pDevice->pControlURB, pDevice->usb, |
| 143 | usb_sndctrlpipe(pDevice->usb , 0), (char *) &pDevice->sUsbCtlRequest, |
| 144 | pbyBuffer, wLength, s_nsControlInUsbIoCompleteWrite, pDevice); |
| 145 | |
Joe Perches | bfbfeec | 2010-03-24 22:17:06 -0700 | [diff] [blame] | 146 | ntStatus = usb_submit_urb(pDevice->pControlURB, GFP_ATOMIC); |
| 147 | if (ntStatus != 0) { |
Malcolm Priestley | ae5943d | 2013-01-30 20:07:29 +0000 | [diff] [blame] | 148 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO |
| 149 | "control send request submission failed: %d\n", |
| 150 | ntStatus); |
| 151 | MP_CLEAR_FLAG(pDevice, fMP_CONTROL_WRITES); |
Malcolm Priestley | c91b186 | 2014-05-15 22:49:19 +0100 | [diff] [blame] | 152 | mutex_unlock(&pDevice->usb_lock); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 153 | return STATUS_FAILURE; |
| 154 | } |
Malcolm Priestley | ae5943d | 2013-01-30 20:07:29 +0000 | [diff] [blame] | 155 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 156 | for (ii = 0; ii <= USB_CTL_WAIT; ii ++) { |
Andres More | 731047f | 2010-08-05 22:17:20 -0300 | [diff] [blame] | 157 | |
| 158 | if (pDevice->Flags & fMP_CONTROL_WRITES) |
| 159 | mdelay(1); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 160 | else |
Andres More | 731047f | 2010-08-05 22:17:20 -0300 | [diff] [blame] | 161 | break; |
| 162 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 163 | if (ii >= USB_CTL_WAIT) { |
Andres More | 731047f | 2010-08-05 22:17:20 -0300 | [diff] [blame] | 164 | DBG_PRT(MSG_LEVEL_DEBUG, |
| 165 | KERN_INFO "control send request submission timeout\n"); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 166 | MP_CLEAR_FLAG(pDevice, fMP_CONTROL_WRITES); |
Malcolm Priestley | c91b186 | 2014-05-15 22:49:19 +0100 | [diff] [blame] | 167 | mutex_unlock(&pDevice->usb_lock); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 168 | return STATUS_FAILURE; |
| 169 | } |
| 170 | } |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 171 | |
Malcolm Priestley | c91b186 | 2014-05-15 22:49:19 +0100 | [diff] [blame] | 172 | mutex_unlock(&pDevice->usb_lock); |
| 173 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 174 | return STATUS_SUCCESS; |
| 175 | } |
| 176 | |
Malcolm Priestley | fe5d00e | 2012-12-10 22:14:36 +0000 | [diff] [blame] | 177 | int PIPEnsControlIn(struct vnt_private *pDevice, u8 byRequest, u16 wValue, |
| 178 | u16 wIndex, u16 wLength, u8 *pbyBuffer) |
Iulia Manda | 9009dd1 | 2014-03-13 01:35:40 +0200 | [diff] [blame] | 179 | __releases(&pDevice->lock) |
| 180 | __acquires(&pDevice->lock) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 181 | { |
Andres More | 6487c49 | 2010-08-02 20:51:57 -0300 | [diff] [blame] | 182 | int ntStatus = 0; |
Malcolm Priestley | fe5d00e | 2012-12-10 22:14:36 +0000 | [diff] [blame] | 183 | int ii; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 184 | |
Andres More | 731047f | 2010-08-05 22:17:20 -0300 | [diff] [blame] | 185 | if (pDevice->Flags & fMP_DISCONNECTED) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 186 | return STATUS_FAILURE; |
| 187 | |
Andres More | 731047f | 2010-08-05 22:17:20 -0300 | [diff] [blame] | 188 | if (pDevice->Flags & fMP_CONTROL_READS) |
| 189 | return STATUS_FAILURE; |
| 190 | |
Malcolm Priestley | ae5943d | 2013-01-30 20:07:29 +0000 | [diff] [blame] | 191 | if (pDevice->Flags & fMP_CONTROL_WRITES) |
| 192 | return STATUS_FAILURE; |
| 193 | |
Malcolm Priestley | e1feda1 | 2013-10-14 19:44:13 +0100 | [diff] [blame] | 194 | if (pDevice->pControlURB->hcpriv) |
| 195 | return STATUS_FAILURE; |
| 196 | |
Malcolm Priestley | c91b186 | 2014-05-15 22:49:19 +0100 | [diff] [blame] | 197 | mutex_lock(&pDevice->usb_lock); |
| 198 | |
Malcolm Priestley | ae5943d | 2013-01-30 20:07:29 +0000 | [diff] [blame] | 199 | MP_SET_FLAG(pDevice, fMP_CONTROL_READS); |
| 200 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 201 | pDevice->sUsbCtlRequest.bRequestType = 0xC0; |
| 202 | pDevice->sUsbCtlRequest.bRequest = byRequest; |
| 203 | pDevice->sUsbCtlRequest.wValue = cpu_to_le16p(&wValue); |
| 204 | pDevice->sUsbCtlRequest.wIndex = cpu_to_le16p(&wIndex); |
| 205 | pDevice->sUsbCtlRequest.wLength = cpu_to_le16p(&wLength); |
| 206 | pDevice->pControlURB->transfer_flags |= URB_ASYNC_UNLINK; |
| 207 | pDevice->pControlURB->actual_length = 0; |
| 208 | usb_fill_control_urb(pDevice->pControlURB, pDevice->usb, |
| 209 | usb_rcvctrlpipe(pDevice->usb , 0), (char *) &pDevice->sUsbCtlRequest, |
| 210 | pbyBuffer, wLength, s_nsControlInUsbIoCompleteRead, pDevice); |
| 211 | |
Joe Perches | bfbfeec | 2010-03-24 22:17:06 -0700 | [diff] [blame] | 212 | ntStatus = usb_submit_urb(pDevice->pControlURB, GFP_ATOMIC); |
| 213 | if (ntStatus != 0) { |
Malcolm Priestley | ae5943d | 2013-01-30 20:07:29 +0000 | [diff] [blame] | 214 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO |
| 215 | "control request submission failed: %d\n", ntStatus); |
| 216 | MP_CLEAR_FLAG(pDevice, fMP_CONTROL_READS); |
Malcolm Priestley | c91b186 | 2014-05-15 22:49:19 +0100 | [diff] [blame] | 217 | mutex_unlock(&pDevice->usb_lock); |
Malcolm Priestley | ae5943d | 2013-01-30 20:07:29 +0000 | [diff] [blame] | 218 | return STATUS_FAILURE; |
| 219 | } |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 220 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 221 | for (ii = 0; ii <= USB_CTL_WAIT; ii ++) { |
Andres More | 731047f | 2010-08-05 22:17:20 -0300 | [diff] [blame] | 222 | |
| 223 | if (pDevice->Flags & fMP_CONTROL_READS) |
| 224 | mdelay(1); |
| 225 | else |
| 226 | break; |
| 227 | |
| 228 | if (ii >= USB_CTL_WAIT) { |
| 229 | DBG_PRT(MSG_LEVEL_DEBUG, |
| 230 | KERN_INFO "control rcv request submission timeout\n"); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 231 | MP_CLEAR_FLAG(pDevice, fMP_CONTROL_READS); |
Malcolm Priestley | c91b186 | 2014-05-15 22:49:19 +0100 | [diff] [blame] | 232 | mutex_unlock(&pDevice->usb_lock); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 233 | return STATUS_FAILURE; |
| 234 | } |
| 235 | } |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 236 | |
Malcolm Priestley | c91b186 | 2014-05-15 22:49:19 +0100 | [diff] [blame] | 237 | mutex_unlock(&pDevice->usb_lock); |
| 238 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 239 | return ntStatus; |
| 240 | } |
| 241 | |
Malcolm Priestley | fe5d00e | 2012-12-10 22:14:36 +0000 | [diff] [blame] | 242 | static void s_nsControlInUsbIoCompleteWrite(struct urb *urb) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 243 | { |
Malcolm Priestley | fe5d00e | 2012-12-10 22:14:36 +0000 | [diff] [blame] | 244 | struct vnt_private *pDevice = (struct vnt_private *)urb->context; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 245 | |
| 246 | pDevice = urb->context; |
| 247 | switch (urb->status) { |
| 248 | case 0: |
| 249 | break; |
| 250 | case -EINPROGRESS: |
| 251 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ctrl write urb status EINPROGRESS%d\n", urb->status); |
| 252 | break; |
| 253 | case -ENOENT: |
| 254 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ctrl write urb status ENOENT %d\n", urb->status); |
| 255 | break; |
| 256 | default: |
| 257 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ctrl write urb status %d\n", urb->status); |
| 258 | } |
| 259 | |
| 260 | MP_CLEAR_FLAG(pDevice, fMP_CONTROL_WRITES); |
| 261 | } |
| 262 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 263 | /* |
| 264 | * Description: |
| 265 | * Complete function of usb Control callback |
| 266 | * |
| 267 | * Parameters: |
| 268 | * In: |
| 269 | * pDevice - Pointer to the adapter |
| 270 | * |
| 271 | * Out: |
| 272 | * none |
| 273 | * |
| 274 | * Return Value: STATUS_INSUFFICIENT_RESOURCES or result of IoCallDriver |
| 275 | * |
| 276 | */ |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 277 | |
Malcolm Priestley | fe5d00e | 2012-12-10 22:14:36 +0000 | [diff] [blame] | 278 | static void s_nsControlInUsbIoCompleteRead(struct urb *urb) |
| 279 | { |
| 280 | struct vnt_private *pDevice = (struct vnt_private *)urb->context; |
| 281 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 282 | switch (urb->status) { |
| 283 | case 0: |
| 284 | break; |
| 285 | case -EINPROGRESS: |
| 286 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ctrl read urb status EINPROGRESS%d\n", urb->status); |
| 287 | break; |
| 288 | case -ENOENT: |
| 289 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ctrl read urb status = ENOENT %d\n", urb->status); |
| 290 | break; |
| 291 | default: |
| 292 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ctrl read urb status %d\n", urb->status); |
| 293 | } |
| 294 | |
| 295 | MP_CLEAR_FLAG(pDevice, fMP_CONTROL_READS); |
| 296 | } |
| 297 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 298 | /* |
| 299 | * Description: |
| 300 | * Allocates an usb interrupt in irp and calls USBD. |
| 301 | * |
| 302 | * Parameters: |
| 303 | * In: |
| 304 | * pDevice - Pointer to the adapter |
| 305 | * Out: |
| 306 | * none |
| 307 | * |
| 308 | * Return Value: STATUS_INSUFFICIENT_RESOURCES or result of IoCallDriver |
| 309 | * |
| 310 | */ |
Malcolm Priestley | fe5d00e | 2012-12-10 22:14:36 +0000 | [diff] [blame] | 311 | |
Malcolm Priestley | 5f38b78 | 2014-02-19 18:37:32 +0000 | [diff] [blame] | 312 | int PIPEnsInterruptRead(struct vnt_private *priv) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 313 | { |
Malcolm Priestley | 5f38b78 | 2014-02-19 18:37:32 +0000 | [diff] [blame] | 314 | int status = STATUS_FAILURE; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 315 | |
Malcolm Priestley | 5f38b78 | 2014-02-19 18:37:32 +0000 | [diff] [blame] | 316 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO |
| 317 | "---->s_nsStartInterruptUsbRead()\n"); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 318 | |
Malcolm Priestley | f764e00 | 2014-02-19 18:39:09 +0000 | [diff] [blame] | 319 | if (priv->int_buf.in_use == true) |
Malcolm Priestley | 5f38b78 | 2014-02-19 18:37:32 +0000 | [diff] [blame] | 320 | return STATUS_FAILURE; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 321 | |
Malcolm Priestley | f764e00 | 2014-02-19 18:39:09 +0000 | [diff] [blame] | 322 | priv->int_buf.in_use = true; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 323 | |
Malcolm Priestley | 5f38b78 | 2014-02-19 18:37:32 +0000 | [diff] [blame] | 324 | usb_fill_int_urb(priv->pInterruptURB, |
| 325 | priv->usb, |
Malcolm Priestley | b9d93d1 | 2014-03-16 12:34:11 +0000 | [diff] [blame] | 326 | usb_rcvintpipe(priv->usb, 1), |
Malcolm Priestley | f764e00 | 2014-02-19 18:39:09 +0000 | [diff] [blame] | 327 | priv->int_buf.data_buf, |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 328 | MAX_INTERRUPT_SIZE, |
| 329 | s_nsInterruptUsbIoCompleteRead, |
Malcolm Priestley | 5f38b78 | 2014-02-19 18:37:32 +0000 | [diff] [blame] | 330 | priv, |
| 331 | priv->int_interval); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 332 | |
Malcolm Priestley | 5f38b78 | 2014-02-19 18:37:32 +0000 | [diff] [blame] | 333 | status = usb_submit_urb(priv->pInterruptURB, GFP_ATOMIC); |
| 334 | if (status) { |
Malcolm Priestley | 59858f5 | 2014-02-19 18:36:37 +0000 | [diff] [blame] | 335 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO |
Malcolm Priestley | 5f38b78 | 2014-02-19 18:37:32 +0000 | [diff] [blame] | 336 | "Submit int URB failed %d\n", status); |
Malcolm Priestley | f764e00 | 2014-02-19 18:39:09 +0000 | [diff] [blame] | 337 | priv->int_buf.in_use = false; |
Malcolm Priestley | 59858f5 | 2014-02-19 18:36:37 +0000 | [diff] [blame] | 338 | } |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 339 | |
Malcolm Priestley | 5f38b78 | 2014-02-19 18:37:32 +0000 | [diff] [blame] | 340 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO |
| 341 | "<----s_nsStartInterruptUsbRead Return(%x)\n", status); |
| 342 | |
| 343 | return status; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 344 | } |
| 345 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 346 | /* |
| 347 | * Description: |
| 348 | * Complete function of usb interrupt in irp. |
| 349 | * |
| 350 | * Parameters: |
| 351 | * In: |
| 352 | * pDevice - Pointer to the adapter |
| 353 | * |
| 354 | * Out: |
| 355 | * none |
| 356 | * |
| 357 | * Return Value: STATUS_INSUFFICIENT_RESOURCES or result of IoCallDriver |
| 358 | * |
| 359 | */ |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 360 | |
Malcolm Priestley | fe5d00e | 2012-12-10 22:14:36 +0000 | [diff] [blame] | 361 | static void s_nsInterruptUsbIoCompleteRead(struct urb *urb) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 362 | { |
Malcolm Priestley | 599e4b5 | 2014-02-25 20:51:51 +0000 | [diff] [blame] | 363 | struct vnt_private *priv = urb->context; |
Malcolm Priestley | d9ad7a9 | 2014-02-17 21:27:30 +0000 | [diff] [blame] | 364 | int status; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 365 | |
Malcolm Priestley | d9ad7a9 | 2014-02-17 21:27:30 +0000 | [diff] [blame] | 366 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO |
| 367 | "---->s_nsInterruptUsbIoCompleteRead\n"); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 368 | |
Malcolm Priestley | c98fbf9 | 2014-02-17 21:16:20 +0000 | [diff] [blame] | 369 | switch (urb->status) { |
| 370 | case 0: |
| 371 | case -ETIMEDOUT: |
| 372 | break; |
| 373 | case -ECONNRESET: |
| 374 | case -ENOENT: |
| 375 | case -ESHUTDOWN: |
Malcolm Priestley | f764e00 | 2014-02-19 18:39:09 +0000 | [diff] [blame] | 376 | priv->int_buf.in_use = false; |
Malcolm Priestley | c98fbf9 | 2014-02-17 21:16:20 +0000 | [diff] [blame] | 377 | return; |
| 378 | default: |
| 379 | break; |
| 380 | } |
| 381 | |
Malcolm Priestley | d9ad7a9 | 2014-02-17 21:27:30 +0000 | [diff] [blame] | 382 | status = urb->status; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 383 | |
Malcolm Priestley | d9ad7a9 | 2014-02-17 21:27:30 +0000 | [diff] [blame] | 384 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO |
| 385 | "s_nsInterruptUsbIoCompleteRead Status %d\n", status); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 386 | |
Malcolm Priestley | d9ad7a9 | 2014-02-17 21:27:30 +0000 | [diff] [blame] | 387 | if (status != STATUS_SUCCESS) { |
Malcolm Priestley | f764e00 | 2014-02-19 18:39:09 +0000 | [diff] [blame] | 388 | priv->int_buf.in_use = false; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 389 | |
Malcolm Priestley | 247b4b6 | 2014-02-17 21:12:51 +0000 | [diff] [blame] | 390 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO |
Malcolm Priestley | d9ad7a9 | 2014-02-17 21:27:30 +0000 | [diff] [blame] | 391 | "IntUSBIoCompleteControl STATUS = %d\n", status); |
Malcolm Priestley | 247b4b6 | 2014-02-17 21:12:51 +0000 | [diff] [blame] | 392 | } else { |
Malcolm Priestley | d9ad7a9 | 2014-02-17 21:27:30 +0000 | [diff] [blame] | 393 | INTnsProcessData(priv); |
Malcolm Priestley | 247b4b6 | 2014-02-17 21:12:51 +0000 | [diff] [blame] | 394 | } |
Malcolm Priestley | 749627f | 2014-02-17 21:24:33 +0000 | [diff] [blame] | 395 | |
Malcolm Priestley | d9ad7a9 | 2014-02-17 21:27:30 +0000 | [diff] [blame] | 396 | status = usb_submit_urb(priv->pInterruptURB, GFP_ATOMIC); |
| 397 | if (status) { |
| 398 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO |
| 399 | "Submit int URB failed %d\n", status); |
| 400 | } else { |
Malcolm Priestley | f764e00 | 2014-02-19 18:39:09 +0000 | [diff] [blame] | 401 | priv->int_buf.in_use = true; |
Malcolm Priestley | d9ad7a9 | 2014-02-17 21:27:30 +0000 | [diff] [blame] | 402 | } |
| 403 | |
| 404 | return; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 405 | } |
| 406 | |
| 407 | /* |
| 408 | * Description: |
| 409 | * Allocates an usb BulkIn irp and calls USBD. |
| 410 | * |
| 411 | * Parameters: |
| 412 | * In: |
| 413 | * pDevice - Pointer to the adapter |
| 414 | * Out: |
| 415 | * none |
| 416 | * |
| 417 | * Return Value: STATUS_INSUFFICIENT_RESOURCES or result of IoCallDriver |
| 418 | * |
| 419 | */ |
Malcolm Priestley | fe5d00e | 2012-12-10 22:14:36 +0000 | [diff] [blame] | 420 | |
Malcolm Priestley | 0b787d7 | 2014-02-25 20:51:50 +0000 | [diff] [blame] | 421 | int PIPEnsBulkInUsbRead(struct vnt_private *priv, struct vnt_rcb *rcb) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 422 | { |
Malcolm Priestley | 0b787d7 | 2014-02-25 20:51:50 +0000 | [diff] [blame] | 423 | int status = 0; |
| 424 | struct urb *urb; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 425 | |
Malcolm Priestley | 0b787d7 | 2014-02-25 20:51:50 +0000 | [diff] [blame] | 426 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->s_nsStartBulkInUsbRead\n"); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 427 | |
Malcolm Priestley | 0b787d7 | 2014-02-25 20:51:50 +0000 | [diff] [blame] | 428 | if (priv->Flags & fMP_DISCONNECTED) |
| 429 | return STATUS_FAILURE; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 430 | |
Malcolm Priestley | 0b787d7 | 2014-02-25 20:51:50 +0000 | [diff] [blame] | 431 | urb = rcb->pUrb; |
| 432 | if (rcb->skb == NULL) { |
| 433 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"rcb->skb is null\n"); |
| 434 | return status; |
| 435 | } |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 436 | |
Malcolm Priestley | 0b787d7 | 2014-02-25 20:51:50 +0000 | [diff] [blame] | 437 | usb_fill_bulk_urb(urb, |
| 438 | priv->usb, |
| 439 | usb_rcvbulkpipe(priv->usb, 2), |
| 440 | (void *) (rcb->skb->data), |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 441 | MAX_TOTAL_SIZE_WITH_ALL_HEADERS, |
| 442 | s_nsBulkInUsbIoCompleteRead, |
Malcolm Priestley | 0b787d7 | 2014-02-25 20:51:50 +0000 | [diff] [blame] | 443 | rcb); |
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 | status = usb_submit_urb(urb, GFP_ATOMIC); |
| 446 | if (status != 0) { |
| 447 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO |
| 448 | "Submit Rx URB failed %d\n", status); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 449 | return STATUS_FAILURE ; |
| 450 | } |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 451 | |
Malcolm Priestley | 0b787d7 | 2014-02-25 20:51:50 +0000 | [diff] [blame] | 452 | rcb->Ref = 1; |
| 453 | rcb->bBoolInUse = true; |
| 454 | |
| 455 | return status; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 456 | } |
| 457 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 458 | /* |
| 459 | * Description: |
| 460 | * Complete function of usb BulkIn irp. |
| 461 | * |
| 462 | * Parameters: |
| 463 | * In: |
| 464 | * pDevice - Pointer to the adapter |
| 465 | * |
| 466 | * Out: |
| 467 | * none |
| 468 | * |
| 469 | * Return Value: STATUS_INSUFFICIENT_RESOURCES or result of IoCallDriver |
| 470 | * |
| 471 | */ |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 472 | |
Malcolm Priestley | fe5d00e | 2012-12-10 22:14:36 +0000 | [diff] [blame] | 473 | static void s_nsBulkInUsbIoCompleteRead(struct urb *urb) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 474 | { |
Malcolm Priestley | 599e4b5 | 2014-02-25 20:51:51 +0000 | [diff] [blame] | 475 | struct vnt_rcb *rcb = urb->context; |
Malcolm Priestley | d4fa2ab | 2014-02-25 20:51:49 +0000 | [diff] [blame] | 476 | struct vnt_private *priv = rcb->pDevice; |
Malcolm Priestley | 29b0237 | 2014-05-15 22:49:20 +0100 | [diff] [blame^] | 477 | unsigned long flags; |
Malcolm Priestley | d4fa2ab | 2014-02-25 20:51:49 +0000 | [diff] [blame] | 478 | int re_alloc_skb = false; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 479 | |
Malcolm Priestley | d4fa2ab | 2014-02-25 20:51:49 +0000 | [diff] [blame] | 480 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->s_nsBulkInUsbIoCompleteRead\n"); |
Malcolm Priestley | e3a8fa1 | 2014-02-25 20:51:46 +0000 | [diff] [blame] | 481 | |
Malcolm Priestley | 6763898 | 2014-02-25 20:51:48 +0000 | [diff] [blame] | 482 | switch (urb->status) { |
| 483 | case 0: |
Malcolm Priestley | 6763898 | 2014-02-25 20:51:48 +0000 | [diff] [blame] | 484 | break; |
| 485 | case -ECONNRESET: |
| 486 | case -ENOENT: |
| 487 | case -ESHUTDOWN: |
| 488 | return; |
| 489 | case -ETIMEDOUT: |
| 490 | default: |
Malcolm Priestley | 6763898 | 2014-02-25 20:51:48 +0000 | [diff] [blame] | 491 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO |
| 492 | "BULK In failed %d\n", urb->status); |
| 493 | break; |
| 494 | } |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 495 | |
Malcolm Priestley | d4fa2ab | 2014-02-25 20:51:49 +0000 | [diff] [blame] | 496 | if (urb->actual_length) { |
Malcolm Priestley | 29b0237 | 2014-05-15 22:49:20 +0100 | [diff] [blame^] | 497 | spin_lock_irqsave(&priv->lock, flags); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 498 | |
Malcolm Priestley | d4fa2ab | 2014-02-25 20:51:49 +0000 | [diff] [blame] | 499 | if (RXbBulkInProcessData(priv, rcb, urb->actual_length) == true) |
| 500 | re_alloc_skb = true; |
| 501 | |
Malcolm Priestley | 29b0237 | 2014-05-15 22:49:20 +0100 | [diff] [blame^] | 502 | spin_unlock_irqrestore(&priv->lock, flags); |
Malcolm Priestley | d4fa2ab | 2014-02-25 20:51:49 +0000 | [diff] [blame] | 503 | } |
| 504 | |
| 505 | rcb->Ref--; |
| 506 | if (rcb->Ref == 0) { |
| 507 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"RxvFreeNormal %d\n", |
| 508 | priv->NumRecvFreeList); |
Malcolm Priestley | 29b0237 | 2014-05-15 22:49:20 +0100 | [diff] [blame^] | 509 | spin_lock_irqsave(&priv->lock, flags); |
Malcolm Priestley | d4fa2ab | 2014-02-25 20:51:49 +0000 | [diff] [blame] | 510 | |
| 511 | RXvFreeRCB(rcb, re_alloc_skb); |
| 512 | |
Malcolm Priestley | 29b0237 | 2014-05-15 22:49:20 +0100 | [diff] [blame^] | 513 | spin_unlock_irqrestore(&priv->lock, flags); |
Malcolm Priestley | d4fa2ab | 2014-02-25 20:51:49 +0000 | [diff] [blame] | 514 | } |
| 515 | |
| 516 | return; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 517 | } |
| 518 | |
| 519 | /* |
| 520 | * Description: |
| 521 | * Allocates an usb BulkOut irp and calls USBD. |
| 522 | * |
| 523 | * Parameters: |
| 524 | * In: |
| 525 | * pDevice - Pointer to the adapter |
| 526 | * Out: |
| 527 | * none |
| 528 | * |
| 529 | * Return Value: STATUS_INSUFFICIENT_RESOURCES or result of IoCallDriver |
| 530 | * |
| 531 | */ |
Malcolm Priestley | fe5d00e | 2012-12-10 22:14:36 +0000 | [diff] [blame] | 532 | |
Malcolm Priestley | 3f38290 | 2014-02-25 20:51:45 +0000 | [diff] [blame] | 533 | int PIPEnsSendBulkOut(struct vnt_private *priv, |
| 534 | struct vnt_usb_send_context *context) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 535 | { |
Malcolm Priestley | fe5d00e | 2012-12-10 22:14:36 +0000 | [diff] [blame] | 536 | int status; |
Malcolm Priestley | 3f38290 | 2014-02-25 20:51:45 +0000 | [diff] [blame] | 537 | struct urb *urb; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 538 | |
Malcolm Priestley | 3f38290 | 2014-02-25 20:51:45 +0000 | [diff] [blame] | 539 | priv->bPWBitOn = false; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 540 | |
Malcolm Priestley | 3f38290 | 2014-02-25 20:51:45 +0000 | [diff] [blame] | 541 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"s_nsSendBulkOut\n"); |
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 | if (!(MP_IS_READY(priv) && priv->Flags & fMP_POST_WRITES)) { |
Malcolm Priestley | 30a05b3 | 2014-05-15 22:49:11 +0100 | [diff] [blame] | 544 | context->in_use = false; |
Malcolm Priestley | 1333830 | 2014-02-25 20:51:43 +0000 | [diff] [blame] | 545 | return STATUS_RESOURCES; |
| 546 | } |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 547 | |
Malcolm Priestley | 30a05b3 | 2014-05-15 22:49:11 +0100 | [diff] [blame] | 548 | urb = context->urb; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 549 | |
Malcolm Priestley | 3f38290 | 2014-02-25 20:51:45 +0000 | [diff] [blame] | 550 | usb_fill_bulk_urb(urb, |
| 551 | priv->usb, |
| 552 | usb_sndbulkpipe(priv->usb, 3), |
Malcolm Priestley | 30a05b3 | 2014-05-15 22:49:11 +0100 | [diff] [blame] | 553 | context->data, |
| 554 | context->buf_len, |
Malcolm Priestley | 3f38290 | 2014-02-25 20:51:45 +0000 | [diff] [blame] | 555 | s_nsBulkOutIoCompleteWrite, |
| 556 | context); |
| 557 | |
| 558 | status = usb_submit_urb(urb, GFP_ATOMIC); |
| 559 | if (status != 0) { |
| 560 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO |
| 561 | "Submit Tx URB failed %d\n", status); |
Malcolm Priestley | 30a05b3 | 2014-05-15 22:49:11 +0100 | [diff] [blame] | 562 | context->in_use = false; |
Malcolm Priestley | 3f38290 | 2014-02-25 20:51:45 +0000 | [diff] [blame] | 563 | return STATUS_FAILURE; |
| 564 | } |
| 565 | |
| 566 | return STATUS_PENDING; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 567 | } |
| 568 | |
| 569 | /* |
| 570 | * Description: s_nsBulkOutIoCompleteWrite |
| 571 | * 1a) Indicate to the protocol the status of the write. |
| 572 | * 1b) Return ownership of the packet to the protocol. |
| 573 | * |
| 574 | * 2) If any more packets are queue for sending, send another packet |
| 575 | * to USBD. |
| 576 | * If the attempt to send the packet to the driver fails, |
| 577 | * return ownership of the packet to the protocol and |
| 578 | * try another packet (until one succeeds). |
| 579 | * |
| 580 | * Parameters: |
| 581 | * In: |
| 582 | * pdoUsbDevObj - pointer to the USB device object which |
| 583 | * completed the irp |
| 584 | * pIrp - the irp which was completed by the |
| 585 | * device object |
| 586 | * pContext - the context given to IoSetCompletionRoutine |
| 587 | * before calling IoCallDriver on the irp |
| 588 | * The pContext is a pointer to the USB device object. |
| 589 | * Out: |
| 590 | * none |
| 591 | * |
| 592 | * Return Value: STATUS_MORE_PROCESSING_REQUIRED - allows the completion routine |
| 593 | * (IofCompleteRequest) to stop working on the irp. |
| 594 | * |
| 595 | */ |
Malcolm Priestley | fe5d00e | 2012-12-10 22:14:36 +0000 | [diff] [blame] | 596 | |
| 597 | static void s_nsBulkOutIoCompleteWrite(struct urb *urb) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 598 | { |
Malcolm Priestley | 599e4b5 | 2014-02-25 20:51:51 +0000 | [diff] [blame] | 599 | struct vnt_usb_send_context *context = urb->context; |
Malcolm Priestley | 30a05b3 | 2014-05-15 22:49:11 +0100 | [diff] [blame] | 600 | struct vnt_private *priv = context->priv; |
Malcolm Priestley | 1450ba6 | 2014-02-19 21:56:33 +0000 | [diff] [blame] | 601 | u8 context_type = context->type; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 602 | |
Malcolm Priestley | 21aa212 | 2014-02-19 21:54:45 +0000 | [diff] [blame] | 603 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->s_nsBulkOutIoCompleteWrite\n"); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 604 | |
Malcolm Priestley | e8152bf | 2014-02-19 21:53:35 +0000 | [diff] [blame] | 605 | switch (urb->status) { |
| 606 | case 0: |
Malcolm Priestley | d1b2a11 | 2014-02-27 23:06:15 +0000 | [diff] [blame] | 607 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO |
Malcolm Priestley | 30a05b3 | 2014-05-15 22:49:11 +0100 | [diff] [blame] | 608 | "Write %d bytes\n", context->buf_len); |
Malcolm Priestley | e8152bf | 2014-02-19 21:53:35 +0000 | [diff] [blame] | 609 | break; |
| 610 | case -ECONNRESET: |
| 611 | case -ENOENT: |
| 612 | case -ESHUTDOWN: |
Malcolm Priestley | 30a05b3 | 2014-05-15 22:49:11 +0100 | [diff] [blame] | 613 | context->in_use = false; |
Malcolm Priestley | e8152bf | 2014-02-19 21:53:35 +0000 | [diff] [blame] | 614 | return; |
Malcolm Priestley | d1b2a11 | 2014-02-27 23:06:15 +0000 | [diff] [blame] | 615 | case -ETIMEDOUT: |
Malcolm Priestley | e8152bf | 2014-02-19 21:53:35 +0000 | [diff] [blame] | 616 | default: |
Malcolm Priestley | d1b2a11 | 2014-02-27 23:06:15 +0000 | [diff] [blame] | 617 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO |
| 618 | "BULK Out failed %d\n", urb->status); |
Malcolm Priestley | e8152bf | 2014-02-19 21:53:35 +0000 | [diff] [blame] | 619 | break; |
| 620 | } |
| 621 | |
Malcolm Priestley | 21aa212 | 2014-02-19 21:54:45 +0000 | [diff] [blame] | 622 | if (!netif_device_present(priv->dev)) |
| 623 | return; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 624 | |
Malcolm Priestley | 21aa212 | 2014-02-19 21:54:45 +0000 | [diff] [blame] | 625 | if (CONTEXT_DATA_PACKET == context_type) { |
Malcolm Priestley | 30a05b3 | 2014-05-15 22:49:11 +0100 | [diff] [blame] | 626 | if (context->skb != NULL) { |
| 627 | dev_kfree_skb_irq(context->skb); |
| 628 | context->skb = NULL; |
Malcolm Priestley | 21aa212 | 2014-02-19 21:54:45 +0000 | [diff] [blame] | 629 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO |
Malcolm Priestley | 30a05b3 | 2014-05-15 22:49:11 +0100 | [diff] [blame] | 630 | "tx %d bytes\n", context->buf_len); |
Malcolm Priestley | 21aa212 | 2014-02-19 21:54:45 +0000 | [diff] [blame] | 631 | } |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 632 | |
Malcolm Priestley | 21aa212 | 2014-02-19 21:54:45 +0000 | [diff] [blame] | 633 | priv->dev->trans_start = jiffies; |
Malcolm Priestley | 21aa212 | 2014-02-19 21:54:45 +0000 | [diff] [blame] | 634 | } |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 635 | |
Malcolm Priestley | 21aa212 | 2014-02-19 21:54:45 +0000 | [diff] [blame] | 636 | if (priv->bLinkPass == true) { |
| 637 | if (netif_queue_stopped(priv->dev)) |
| 638 | netif_wake_queue(priv->dev); |
| 639 | } |
| 640 | |
Malcolm Priestley | 30a05b3 | 2014-05-15 22:49:11 +0100 | [diff] [blame] | 641 | context->in_use = false; |
Malcolm Priestley | 21aa212 | 2014-02-19 21:54:45 +0000 | [diff] [blame] | 642 | |
| 643 | return; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 644 | } |