.. | .. |
---|
24 | 24 | * |
---|
25 | 25 | */ |
---|
26 | 26 | |
---|
27 | | -#include "int.h" |
---|
28 | 27 | #include "rxtx.h" |
---|
29 | | -#include "dpc.h" |
---|
30 | 28 | #include "desc.h" |
---|
31 | 29 | #include "device.h" |
---|
32 | 30 | #include "usbpipe.h" |
---|
| 31 | +#include "mac.h" |
---|
| 32 | +#include "rf.h" |
---|
33 | 33 | |
---|
34 | 34 | #define USB_CTL_WAIT 500 /* ms */ |
---|
35 | 35 | |
---|
36 | 36 | int vnt_control_out(struct vnt_private *priv, u8 request, u16 value, |
---|
37 | | - u16 index, u16 length, u8 *buffer) |
---|
| 37 | + u16 index, u16 length, const u8 *buffer) |
---|
38 | 38 | { |
---|
39 | | - int status = 0; |
---|
| 39 | + int ret = 0; |
---|
40 | 40 | u8 *usb_buffer; |
---|
41 | 41 | |
---|
42 | | - if (test_bit(DEVICE_FLAGS_DISCONNECTED, &priv->flags)) |
---|
43 | | - return STATUS_FAILURE; |
---|
| 42 | + if (test_bit(DEVICE_FLAGS_DISCONNECTED, &priv->flags)) { |
---|
| 43 | + ret = -EINVAL; |
---|
| 44 | + goto end; |
---|
| 45 | + } |
---|
44 | 46 | |
---|
45 | 47 | mutex_lock(&priv->usb_lock); |
---|
46 | 48 | |
---|
47 | 49 | usb_buffer = kmemdup(buffer, length, GFP_KERNEL); |
---|
48 | 50 | if (!usb_buffer) { |
---|
49 | | - mutex_unlock(&priv->usb_lock); |
---|
50 | | - return -ENOMEM; |
---|
| 51 | + ret = -ENOMEM; |
---|
| 52 | + goto end_unlock; |
---|
51 | 53 | } |
---|
52 | 54 | |
---|
53 | | - status = usb_control_msg(priv->usb, |
---|
54 | | - usb_sndctrlpipe(priv->usb, 0), |
---|
55 | | - request, 0x40, value, |
---|
56 | | - index, usb_buffer, length, USB_CTL_WAIT); |
---|
| 55 | + ret = usb_control_msg(priv->usb, |
---|
| 56 | + usb_sndctrlpipe(priv->usb, 0), |
---|
| 57 | + request, 0x40, value, |
---|
| 58 | + index, usb_buffer, length, USB_CTL_WAIT); |
---|
57 | 59 | |
---|
58 | 60 | kfree(usb_buffer); |
---|
59 | 61 | |
---|
| 62 | + if (ret == (int)length) |
---|
| 63 | + ret = 0; |
---|
| 64 | + else |
---|
| 65 | + ret = -EIO; |
---|
| 66 | + |
---|
| 67 | +end_unlock: |
---|
60 | 68 | mutex_unlock(&priv->usb_lock); |
---|
61 | | - |
---|
62 | | - if (status < (int)length) |
---|
63 | | - return STATUS_FAILURE; |
---|
64 | | - |
---|
65 | | - return STATUS_SUCCESS; |
---|
| 69 | +end: |
---|
| 70 | + return ret; |
---|
66 | 71 | } |
---|
67 | 72 | |
---|
68 | | -void vnt_control_out_u8(struct vnt_private *priv, u8 reg, u8 reg_off, u8 data) |
---|
| 73 | +int vnt_control_out_u8(struct vnt_private *priv, u8 reg, u8 reg_off, u8 data) |
---|
69 | 74 | { |
---|
70 | | - vnt_control_out(priv, MESSAGE_TYPE_WRITE, |
---|
71 | | - reg_off, reg, sizeof(u8), &data); |
---|
| 75 | + return vnt_control_out(priv, MESSAGE_TYPE_WRITE, |
---|
| 76 | + reg_off, reg, sizeof(u8), &data); |
---|
| 77 | +} |
---|
| 78 | + |
---|
| 79 | +int vnt_control_out_blocks(struct vnt_private *priv, |
---|
| 80 | + u16 block, u8 reg, u16 length, const u8 *data) |
---|
| 81 | +{ |
---|
| 82 | + int ret = 0, i; |
---|
| 83 | + |
---|
| 84 | + for (i = 0; i < length; i += block) { |
---|
| 85 | + u16 len = min_t(int, length - i, block); |
---|
| 86 | + |
---|
| 87 | + ret = vnt_control_out(priv, MESSAGE_TYPE_WRITE, |
---|
| 88 | + i, reg, len, data + i); |
---|
| 89 | + if (ret) |
---|
| 90 | + goto end; |
---|
| 91 | + } |
---|
| 92 | +end: |
---|
| 93 | + return ret; |
---|
72 | 94 | } |
---|
73 | 95 | |
---|
74 | 96 | int vnt_control_in(struct vnt_private *priv, u8 request, u16 value, |
---|
75 | 97 | u16 index, u16 length, u8 *buffer) |
---|
76 | 98 | { |
---|
77 | | - int status; |
---|
| 99 | + int ret = 0; |
---|
78 | 100 | u8 *usb_buffer; |
---|
79 | 101 | |
---|
80 | | - if (test_bit(DEVICE_FLAGS_DISCONNECTED, &priv->flags)) |
---|
81 | | - return STATUS_FAILURE; |
---|
| 102 | + if (test_bit(DEVICE_FLAGS_DISCONNECTED, &priv->flags)) { |
---|
| 103 | + ret = -EINVAL; |
---|
| 104 | + goto end; |
---|
| 105 | + } |
---|
82 | 106 | |
---|
83 | 107 | mutex_lock(&priv->usb_lock); |
---|
84 | 108 | |
---|
85 | 109 | usb_buffer = kmalloc(length, GFP_KERNEL); |
---|
86 | 110 | if (!usb_buffer) { |
---|
87 | | - mutex_unlock(&priv->usb_lock); |
---|
88 | | - return -ENOMEM; |
---|
| 111 | + ret = -ENOMEM; |
---|
| 112 | + goto end_unlock; |
---|
89 | 113 | } |
---|
90 | 114 | |
---|
91 | | - status = usb_control_msg(priv->usb, |
---|
92 | | - usb_rcvctrlpipe(priv->usb, 0), |
---|
93 | | - request, 0xc0, value, |
---|
94 | | - index, usb_buffer, length, USB_CTL_WAIT); |
---|
| 115 | + ret = usb_control_msg(priv->usb, |
---|
| 116 | + usb_rcvctrlpipe(priv->usb, 0), |
---|
| 117 | + request, 0xc0, value, |
---|
| 118 | + index, usb_buffer, length, USB_CTL_WAIT); |
---|
95 | 119 | |
---|
96 | | - if (status == length) |
---|
| 120 | + if (ret == length) |
---|
97 | 121 | memcpy(buffer, usb_buffer, length); |
---|
98 | 122 | |
---|
99 | 123 | kfree(usb_buffer); |
---|
100 | 124 | |
---|
| 125 | + if (ret == (int)length) |
---|
| 126 | + ret = 0; |
---|
| 127 | + else |
---|
| 128 | + ret = -EIO; |
---|
| 129 | + |
---|
| 130 | +end_unlock: |
---|
101 | 131 | mutex_unlock(&priv->usb_lock); |
---|
102 | | - |
---|
103 | | - if (status < (int)length) |
---|
104 | | - return STATUS_FAILURE; |
---|
105 | | - |
---|
106 | | - return STATUS_SUCCESS; |
---|
| 132 | +end: |
---|
| 133 | + return ret; |
---|
107 | 134 | } |
---|
108 | 135 | |
---|
109 | | -void vnt_control_in_u8(struct vnt_private *priv, u8 reg, u8 reg_off, u8 *data) |
---|
| 136 | +int vnt_control_in_u8(struct vnt_private *priv, u8 reg, u8 reg_off, u8 *data) |
---|
110 | 137 | { |
---|
111 | | - vnt_control_in(priv, MESSAGE_TYPE_READ, |
---|
112 | | - reg_off, reg, sizeof(u8), data); |
---|
| 138 | + return vnt_control_in(priv, MESSAGE_TYPE_READ, |
---|
| 139 | + reg_off, reg, sizeof(u8), data); |
---|
| 140 | +} |
---|
| 141 | + |
---|
| 142 | +static int vnt_int_report_rate(struct vnt_private *priv, u8 pkt_no, u8 tsr) |
---|
| 143 | +{ |
---|
| 144 | + struct vnt_usb_send_context *context; |
---|
| 145 | + struct ieee80211_tx_info *info; |
---|
| 146 | + u8 tx_retry = (tsr & 0xf0) >> 4; |
---|
| 147 | + s8 idx; |
---|
| 148 | + |
---|
| 149 | + if (pkt_no >= priv->num_tx_context) |
---|
| 150 | + return -EINVAL; |
---|
| 151 | + |
---|
| 152 | + context = priv->tx_context[pkt_no]; |
---|
| 153 | + |
---|
| 154 | + if (!context->skb) |
---|
| 155 | + return -EINVAL; |
---|
| 156 | + |
---|
| 157 | + info = IEEE80211_SKB_CB(context->skb); |
---|
| 158 | + idx = info->control.rates[0].idx; |
---|
| 159 | + |
---|
| 160 | + ieee80211_tx_info_clear_status(info); |
---|
| 161 | + |
---|
| 162 | + info->status.rates[0].count = tx_retry; |
---|
| 163 | + |
---|
| 164 | + if (!(tsr & TSR_TMO)) { |
---|
| 165 | + info->status.rates[0].idx = idx; |
---|
| 166 | + |
---|
| 167 | + if (!(info->flags & IEEE80211_TX_CTL_NO_ACK)) |
---|
| 168 | + info->flags |= IEEE80211_TX_STAT_ACK; |
---|
| 169 | + } |
---|
| 170 | + |
---|
| 171 | + ieee80211_tx_status_irqsafe(priv->hw, context->skb); |
---|
| 172 | + |
---|
| 173 | + context->in_use = false; |
---|
| 174 | + |
---|
| 175 | + return 0; |
---|
| 176 | +} |
---|
| 177 | + |
---|
| 178 | +static void vnt_int_process_data(struct vnt_private *priv) |
---|
| 179 | +{ |
---|
| 180 | + struct vnt_interrupt_data *int_data; |
---|
| 181 | + struct ieee80211_low_level_stats *low_stats = &priv->low_stats; |
---|
| 182 | + |
---|
| 183 | + dev_dbg(&priv->usb->dev, "---->s_nsInterruptProcessData\n"); |
---|
| 184 | + |
---|
| 185 | + int_data = (struct vnt_interrupt_data *)priv->int_buf.data_buf; |
---|
| 186 | + |
---|
| 187 | + if (int_data->tsr0 & TSR_VALID) |
---|
| 188 | + vnt_int_report_rate(priv, int_data->pkt0, int_data->tsr0); |
---|
| 189 | + |
---|
| 190 | + if (int_data->tsr1 & TSR_VALID) |
---|
| 191 | + vnt_int_report_rate(priv, int_data->pkt1, int_data->tsr1); |
---|
| 192 | + |
---|
| 193 | + if (int_data->tsr2 & TSR_VALID) |
---|
| 194 | + vnt_int_report_rate(priv, int_data->pkt2, int_data->tsr2); |
---|
| 195 | + |
---|
| 196 | + if (int_data->tsr3 & TSR_VALID) |
---|
| 197 | + vnt_int_report_rate(priv, int_data->pkt3, int_data->tsr3); |
---|
| 198 | + |
---|
| 199 | + if (!int_data->isr0) |
---|
| 200 | + return; |
---|
| 201 | + |
---|
| 202 | + if (int_data->isr0 & ISR_BNTX && priv->op_mode == NL80211_IFTYPE_AP) |
---|
| 203 | + vnt_schedule_command(priv, WLAN_CMD_BECON_SEND); |
---|
| 204 | + |
---|
| 205 | + priv->current_tsf = le64_to_cpu(int_data->tsf); |
---|
| 206 | + |
---|
| 207 | + low_stats->dot11RTSSuccessCount += int_data->rts_success; |
---|
| 208 | + low_stats->dot11RTSFailureCount += int_data->rts_fail; |
---|
| 209 | + low_stats->dot11ACKFailureCount += int_data->ack_fail; |
---|
| 210 | + low_stats->dot11FCSErrorCount += int_data->fcs_err; |
---|
113 | 211 | } |
---|
114 | 212 | |
---|
115 | 213 | static void vnt_start_interrupt_urb_complete(struct urb *urb) |
---|
.. | .. |
---|
124 | 222 | case -ECONNRESET: |
---|
125 | 223 | case -ENOENT: |
---|
126 | 224 | case -ESHUTDOWN: |
---|
127 | | - priv->int_buf.in_use = false; |
---|
128 | 225 | return; |
---|
129 | 226 | default: |
---|
130 | 227 | break; |
---|
131 | 228 | } |
---|
132 | 229 | |
---|
133 | | - if (status) { |
---|
134 | | - priv->int_buf.in_use = false; |
---|
135 | | - |
---|
| 230 | + if (status) |
---|
136 | 231 | dev_dbg(&priv->usb->dev, "%s status = %d\n", __func__, status); |
---|
137 | | - } else { |
---|
| 232 | + else |
---|
138 | 233 | vnt_int_process_data(priv); |
---|
139 | | - } |
---|
140 | 234 | |
---|
141 | 235 | status = usb_submit_urb(priv->interrupt_urb, GFP_ATOMIC); |
---|
142 | 236 | if (status) |
---|
143 | 237 | dev_dbg(&priv->usb->dev, "Submit int URB failed %d\n", status); |
---|
144 | | - else |
---|
145 | | - priv->int_buf.in_use = true; |
---|
146 | 238 | } |
---|
147 | 239 | |
---|
148 | 240 | int vnt_start_interrupt_urb(struct vnt_private *priv) |
---|
149 | 241 | { |
---|
150 | | - int status = STATUS_FAILURE; |
---|
| 242 | + int ret = 0; |
---|
151 | 243 | |
---|
152 | | - if (priv->int_buf.in_use) |
---|
153 | | - return STATUS_FAILURE; |
---|
154 | | - |
---|
155 | | - priv->int_buf.in_use = true; |
---|
| 244 | + dev_dbg(&priv->usb->dev, "---->Interrupt Polling Thread\n"); |
---|
156 | 245 | |
---|
157 | 246 | usb_fill_int_urb(priv->interrupt_urb, |
---|
158 | 247 | priv->usb, |
---|
.. | .. |
---|
163 | 252 | priv, |
---|
164 | 253 | priv->int_interval); |
---|
165 | 254 | |
---|
166 | | - status = usb_submit_urb(priv->interrupt_urb, GFP_ATOMIC); |
---|
167 | | - if (status) { |
---|
168 | | - dev_dbg(&priv->usb->dev, "Submit int URB failed %d\n", status); |
---|
169 | | - priv->int_buf.in_use = false; |
---|
| 255 | + ret = usb_submit_urb(priv->interrupt_urb, GFP_ATOMIC); |
---|
| 256 | + if (ret) |
---|
| 257 | + dev_dbg(&priv->usb->dev, "Submit int URB failed %d\n", ret); |
---|
| 258 | + |
---|
| 259 | + return ret; |
---|
| 260 | +} |
---|
| 261 | + |
---|
| 262 | +static int vnt_rx_data(struct vnt_private *priv, struct vnt_rcb *ptr_rcb, |
---|
| 263 | + unsigned long bytes_received) |
---|
| 264 | +{ |
---|
| 265 | + struct ieee80211_hw *hw = priv->hw; |
---|
| 266 | + struct ieee80211_supported_band *sband; |
---|
| 267 | + struct sk_buff *skb; |
---|
| 268 | + struct ieee80211_rx_status *rx_status; |
---|
| 269 | + struct vnt_rx_header *head; |
---|
| 270 | + struct vnt_rx_tail *tail; |
---|
| 271 | + u32 frame_size; |
---|
| 272 | + int ii; |
---|
| 273 | + u16 rx_bitrate, pay_load_with_padding; |
---|
| 274 | + u8 rate_idx = 0; |
---|
| 275 | + long rx_dbm; |
---|
| 276 | + |
---|
| 277 | + skb = ptr_rcb->skb; |
---|
| 278 | + rx_status = IEEE80211_SKB_RXCB(skb); |
---|
| 279 | + |
---|
| 280 | + /* [31:16]RcvByteCount ( not include 4-byte Status ) */ |
---|
| 281 | + head = (struct vnt_rx_header *)skb->data; |
---|
| 282 | + frame_size = head->wbk_status >> 16; |
---|
| 283 | + frame_size += 4; |
---|
| 284 | + |
---|
| 285 | + if (bytes_received != frame_size) { |
---|
| 286 | + dev_dbg(&priv->usb->dev, "------- WRONG Length 1\n"); |
---|
| 287 | + return false; |
---|
170 | 288 | } |
---|
171 | 289 | |
---|
172 | | - return status; |
---|
| 290 | + if ((bytes_received > 2372) || (bytes_received <= 40)) { |
---|
| 291 | + /* Frame Size error drop this packet.*/ |
---|
| 292 | + dev_dbg(&priv->usb->dev, "------ WRONG Length 2\n"); |
---|
| 293 | + return false; |
---|
| 294 | + } |
---|
| 295 | + |
---|
| 296 | + /* real Frame Size = USBframe_size -4WbkStatus - 4RxStatus */ |
---|
| 297 | + /* -8TSF - 4RSR - 4SQ3 - ?Padding */ |
---|
| 298 | + |
---|
| 299 | + /* if SQ3 the range is 24~27, if no SQ3 the range is 20~23 */ |
---|
| 300 | + |
---|
| 301 | + /*Fix hardware bug => PLCP_Length error */ |
---|
| 302 | + if (((bytes_received - head->pay_load_len) > 27) || |
---|
| 303 | + ((bytes_received - head->pay_load_len) < 24) || |
---|
| 304 | + (bytes_received < head->pay_load_len)) { |
---|
| 305 | + dev_dbg(&priv->usb->dev, "Wrong PLCP Length %x\n", |
---|
| 306 | + head->pay_load_len); |
---|
| 307 | + return false; |
---|
| 308 | + } |
---|
| 309 | + |
---|
| 310 | + sband = hw->wiphy->bands[hw->conf.chandef.chan->band]; |
---|
| 311 | + rx_bitrate = head->rx_rate * 5; /* rx_rate * 5 */ |
---|
| 312 | + |
---|
| 313 | + for (ii = 0; ii < sband->n_bitrates; ii++) { |
---|
| 314 | + if (sband->bitrates[ii].bitrate == rx_bitrate) { |
---|
| 315 | + rate_idx = ii; |
---|
| 316 | + break; |
---|
| 317 | + } |
---|
| 318 | + } |
---|
| 319 | + |
---|
| 320 | + if (ii == sband->n_bitrates) { |
---|
| 321 | + dev_dbg(&priv->usb->dev, "Wrong Rx Bit Rate %d\n", rx_bitrate); |
---|
| 322 | + return false; |
---|
| 323 | + } |
---|
| 324 | + |
---|
| 325 | + pay_load_with_padding = ((head->pay_load_len / 4) + |
---|
| 326 | + ((head->pay_load_len % 4) ? 1 : 0)) * 4; |
---|
| 327 | + |
---|
| 328 | + tail = (struct vnt_rx_tail *)(skb->data + |
---|
| 329 | + sizeof(*head) + pay_load_with_padding); |
---|
| 330 | + priv->tsf_time = le64_to_cpu(tail->tsf_time); |
---|
| 331 | + |
---|
| 332 | + if (tail->rsr & (RSR_IVLDTYP | RSR_IVLDLEN)) |
---|
| 333 | + return false; |
---|
| 334 | + |
---|
| 335 | + vnt_rf_rssi_to_dbm(priv, tail->rssi, &rx_dbm); |
---|
| 336 | + |
---|
| 337 | + priv->bb_pre_ed_rssi = (u8)-rx_dbm + 1; |
---|
| 338 | + priv->current_rssi = priv->bb_pre_ed_rssi; |
---|
| 339 | + |
---|
| 340 | + skb_pull(skb, sizeof(*head)); |
---|
| 341 | + skb_trim(skb, head->pay_load_len); |
---|
| 342 | + |
---|
| 343 | + rx_status->mactime = priv->tsf_time; |
---|
| 344 | + rx_status->band = hw->conf.chandef.chan->band; |
---|
| 345 | + rx_status->signal = rx_dbm; |
---|
| 346 | + rx_status->flag = 0; |
---|
| 347 | + rx_status->freq = hw->conf.chandef.chan->center_freq; |
---|
| 348 | + |
---|
| 349 | + if (!(tail->rsr & RSR_CRCOK)) |
---|
| 350 | + rx_status->flag |= RX_FLAG_FAILED_FCS_CRC; |
---|
| 351 | + |
---|
| 352 | + rx_status->rate_idx = rate_idx; |
---|
| 353 | + |
---|
| 354 | + if (tail->new_rsr & NEWRSR_DECRYPTOK) |
---|
| 355 | + rx_status->flag |= RX_FLAG_DECRYPTED; |
---|
| 356 | + |
---|
| 357 | + ieee80211_rx_irqsafe(priv->hw, skb); |
---|
| 358 | + |
---|
| 359 | + return true; |
---|
173 | 360 | } |
---|
174 | 361 | |
---|
175 | 362 | static void vnt_submit_rx_urb_complete(struct urb *urb) |
---|
.. | .. |
---|
193 | 380 | if (urb->actual_length) { |
---|
194 | 381 | if (vnt_rx_data(priv, rcb, urb->actual_length)) { |
---|
195 | 382 | rcb->skb = dev_alloc_skb(priv->rx_buf_sz); |
---|
196 | | - if (!rcb->skb) { |
---|
197 | | - rcb->in_use = false; |
---|
| 383 | + if (!rcb->skb) |
---|
198 | 384 | return; |
---|
199 | | - } |
---|
200 | 385 | } else { |
---|
201 | 386 | skb_push(rcb->skb, skb_headroom(rcb->skb)); |
---|
202 | 387 | skb_trim(rcb->skb, 0); |
---|
203 | 388 | } |
---|
204 | 389 | |
---|
205 | 390 | urb->transfer_buffer = skb_put(rcb->skb, |
---|
206 | | - skb_tailroom(rcb->skb)); |
---|
| 391 | + skb_tailroom(rcb->skb)); |
---|
207 | 392 | } |
---|
208 | 393 | |
---|
209 | | - if (usb_submit_urb(urb, GFP_ATOMIC)) { |
---|
| 394 | + if (usb_submit_urb(urb, GFP_ATOMIC)) |
---|
210 | 395 | dev_dbg(&priv->usb->dev, "Failed to re submit rx skb\n"); |
---|
211 | | - |
---|
212 | | - rcb->in_use = false; |
---|
213 | | - } |
---|
214 | 396 | } |
---|
215 | 397 | |
---|
216 | 398 | int vnt_submit_rx_urb(struct vnt_private *priv, struct vnt_rcb *rcb) |
---|
217 | 399 | { |
---|
218 | | - int status = 0; |
---|
| 400 | + int ret = 0; |
---|
219 | 401 | struct urb *urb = rcb->urb; |
---|
220 | 402 | |
---|
221 | 403 | if (!rcb->skb) { |
---|
222 | 404 | dev_dbg(&priv->usb->dev, "rcb->skb is null\n"); |
---|
223 | | - return status; |
---|
| 405 | + ret = -EINVAL; |
---|
| 406 | + goto end; |
---|
224 | 407 | } |
---|
225 | 408 | |
---|
226 | 409 | usb_fill_bulk_urb(urb, |
---|
.. | .. |
---|
231 | 414 | vnt_submit_rx_urb_complete, |
---|
232 | 415 | rcb); |
---|
233 | 416 | |
---|
234 | | - status = usb_submit_urb(urb, GFP_ATOMIC); |
---|
235 | | - if (status) { |
---|
236 | | - dev_dbg(&priv->usb->dev, "Submit Rx URB failed %d\n", status); |
---|
237 | | - return STATUS_FAILURE; |
---|
238 | | - } |
---|
239 | | - |
---|
240 | | - rcb->in_use = true; |
---|
241 | | - |
---|
242 | | - return status; |
---|
| 417 | + ret = usb_submit_urb(urb, GFP_ATOMIC); |
---|
| 418 | + if (ret) |
---|
| 419 | + dev_dbg(&priv->usb->dev, "Submit Rx URB failed %d\n", ret); |
---|
| 420 | +end: |
---|
| 421 | + return ret; |
---|
243 | 422 | } |
---|
244 | 423 | |
---|
245 | 424 | static void vnt_tx_context_complete(struct urb *urb) |
---|
.. | .. |
---|
249 | 428 | |
---|
250 | 429 | switch (urb->status) { |
---|
251 | 430 | case 0: |
---|
252 | | - dev_dbg(&priv->usb->dev, "Write %d bytes\n", context->buf_len); |
---|
| 431 | + dev_dbg(&priv->usb->dev, |
---|
| 432 | + "Write %d bytes\n", urb->actual_length); |
---|
253 | 433 | break; |
---|
254 | 434 | case -ECONNRESET: |
---|
255 | 435 | case -ENOENT: |
---|
.. | .. |
---|
274 | 454 | } |
---|
275 | 455 | |
---|
276 | 456 | int vnt_tx_context(struct vnt_private *priv, |
---|
277 | | - struct vnt_usb_send_context *context) |
---|
| 457 | + struct vnt_usb_send_context *context, |
---|
| 458 | + struct sk_buff *skb) |
---|
278 | 459 | { |
---|
| 460 | + struct vnt_tx_usb_header *usb; |
---|
| 461 | + struct urb *urb; |
---|
279 | 462 | int status; |
---|
280 | | - struct urb *urb = context->urb; |
---|
| 463 | + u16 count = skb->len; |
---|
| 464 | + |
---|
| 465 | + usb = skb_push(skb, sizeof(*usb)); |
---|
| 466 | + usb->tx_byte_count = cpu_to_le16(count); |
---|
| 467 | + usb->pkt_no = context->pkt_no; |
---|
| 468 | + usb->type = context->type; |
---|
281 | 469 | |
---|
282 | 470 | if (test_bit(DEVICE_FLAGS_DISCONNECTED, &priv->flags)) { |
---|
283 | 471 | context->in_use = false; |
---|
284 | | - return STATUS_RESOURCES; |
---|
| 472 | + return -ENODEV; |
---|
| 473 | + } |
---|
| 474 | + |
---|
| 475 | + if (skb->len > MAX_TOTAL_SIZE_WITH_ALL_HEADERS) { |
---|
| 476 | + context->in_use = false; |
---|
| 477 | + return -E2BIG; |
---|
| 478 | + } |
---|
| 479 | + |
---|
| 480 | + urb = usb_alloc_urb(0, GFP_ATOMIC); |
---|
| 481 | + if (!urb) { |
---|
| 482 | + context->in_use = false; |
---|
| 483 | + return -ENOMEM; |
---|
285 | 484 | } |
---|
286 | 485 | |
---|
287 | 486 | usb_fill_bulk_urb(urb, |
---|
288 | 487 | priv->usb, |
---|
289 | 488 | usb_sndbulkpipe(priv->usb, 3), |
---|
290 | | - context->data, |
---|
291 | | - context->buf_len, |
---|
| 489 | + skb->data, |
---|
| 490 | + skb->len, |
---|
292 | 491 | vnt_tx_context_complete, |
---|
293 | 492 | context); |
---|
| 493 | + |
---|
| 494 | + usb_anchor_urb(urb, &priv->tx_submitted); |
---|
294 | 495 | |
---|
295 | 496 | status = usb_submit_urb(urb, GFP_ATOMIC); |
---|
296 | 497 | if (status) { |
---|
297 | 498 | dev_dbg(&priv->usb->dev, "Submit Tx URB failed %d\n", status); |
---|
298 | | - |
---|
| 499 | + usb_unanchor_urb(urb); |
---|
299 | 500 | context->in_use = false; |
---|
300 | | - return STATUS_FAILURE; |
---|
301 | 501 | } |
---|
302 | 502 | |
---|
303 | | - return STATUS_PENDING; |
---|
| 503 | + usb_free_urb(urb); |
---|
| 504 | + |
---|
| 505 | + return status; |
---|
304 | 506 | } |
---|