This source file includes following definitions.
- ctlxstr
- get_active_ctlx
- dbprint_urb
- submit_rx_urb
- submit_tx_urb
- hfa384x_usb_defer
- hfa384x_create
- hfa384x_destroy
- usbctlx_alloc
- usbctlx_get_status
- usbctlx_get_rridresult
- usbctlx_cmd_completor_fn
- init_cmd_completor
- usbctlx_rrid_completor_fn
- init_rrid_completor
- usbctlx_rmem_completor_fn
- init_rmem_completor
- hfa384x_cb_status
- hfa384x_cmd_initialize
- hfa384x_cmd_disable
- hfa384x_cmd_enable
- hfa384x_cmd_monitor
- hfa384x_cmd_download
- hfa384x_corereset
- hfa384x_usbctlx_complete_sync
- hfa384x_docmd
- hfa384x_dorrid
- hfa384x_dowrid
- hfa384x_dormem
- hfa384x_dowmem
- hfa384x_drvr_disable
- hfa384x_drvr_enable
- hfa384x_drvr_flashdl_enable
- hfa384x_drvr_flashdl_disable
- hfa384x_drvr_flashdl_write
- hfa384x_drvr_getconfig
- hfa384x_drvr_setconfig_async
- hfa384x_drvr_ramdl_disable
- hfa384x_drvr_ramdl_enable
- hfa384x_drvr_ramdl_write
- hfa384x_drvr_readpda
- hfa384x_drvr_setconfig
- hfa384x_drvr_start
- hfa384x_drvr_stop
- hfa384x_drvr_txframe
- hfa384x_tx_timeout
- hfa384x_usbctlx_reaper_task
- hfa384x_usbctlx_completion_task
- unlocked_usbctlx_cancel_async
- unlocked_usbctlx_complete
- hfa384x_usbctlxq_run
- hfa384x_usbin_callback
- hfa384x_usbin_ctlx
- hfa384x_usbin_txcompl
- hfa384x_usbin_rx
- hfa384x_int_rxmonitor
- hfa384x_usbin_info
- hfa384x_usbout_callback
- hfa384x_ctlxout_callback
- hfa384x_usbctlx_reqtimerfn
- hfa384x_usbctlx_resptimerfn
- hfa384x_usb_throttlefn
- hfa384x_usbctlx_submit
- hfa384x_isgood_pdrcode
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114 #include <linux/module.h>
115 #include <linux/kernel.h>
116 #include <linux/sched.h>
117 #include <linux/types.h>
118 #include <linux/slab.h>
119 #include <linux/wireless.h>
120 #include <linux/netdevice.h>
121 #include <linux/timer.h>
122 #include <linux/io.h>
123 #include <linux/delay.h>
124 #include <asm/byteorder.h>
125 #include <linux/bitops.h>
126 #include <linux/list.h>
127 #include <linux/usb.h>
128 #include <linux/byteorder/generic.h>
129
130 #include "p80211types.h"
131 #include "p80211hdr.h"
132 #include "p80211mgmt.h"
133 #include "p80211conv.h"
134 #include "p80211msg.h"
135 #include "p80211netdev.h"
136 #include "p80211req.h"
137 #include "p80211metadef.h"
138 #include "p80211metastruct.h"
139 #include "hfa384x.h"
140 #include "prism2mgmt.h"
141
142 enum cmd_mode {
143 DOWAIT = 0,
144 DOASYNC
145 };
146
147 #define THROTTLE_JIFFIES (HZ / 8)
148 #define URB_ASYNC_UNLINK 0
149 #define USB_QUEUE_BULK 0
150
151 #define ROUNDUP64(a) (((a) + 63) & ~63)
152
153 #ifdef DEBUG_USB
154 static void dbprint_urb(struct urb *urb);
155 #endif
156
157 static void hfa384x_int_rxmonitor(struct wlandevice *wlandev,
158 struct hfa384x_usb_rxfrm *rxfrm);
159
160 static void hfa384x_usb_defer(struct work_struct *data);
161
162 static int submit_rx_urb(struct hfa384x *hw, gfp_t flags);
163
164 static int submit_tx_urb(struct hfa384x *hw, struct urb *tx_urb, gfp_t flags);
165
166
167
168 static void hfa384x_usbout_callback(struct urb *urb);
169 static void hfa384x_ctlxout_callback(struct urb *urb);
170 static void hfa384x_usbin_callback(struct urb *urb);
171
172 static void
173 hfa384x_usbin_txcompl(struct wlandevice *wlandev, union hfa384x_usbin *usbin);
174
175 static void hfa384x_usbin_rx(struct wlandevice *wlandev, struct sk_buff *skb);
176
177 static void hfa384x_usbin_info(struct wlandevice *wlandev,
178 union hfa384x_usbin *usbin);
179
180 static void hfa384x_usbin_ctlx(struct hfa384x *hw, union hfa384x_usbin *usbin,
181 int urb_status);
182
183
184
185
186 static void hfa384x_usbctlxq_run(struct hfa384x *hw);
187
188 static void hfa384x_usbctlx_reqtimerfn(struct timer_list *t);
189
190 static void hfa384x_usbctlx_resptimerfn(struct timer_list *t);
191
192 static void hfa384x_usb_throttlefn(struct timer_list *t);
193
194 static void hfa384x_usbctlx_completion_task(unsigned long data);
195
196 static void hfa384x_usbctlx_reaper_task(unsigned long data);
197
198 static int hfa384x_usbctlx_submit(struct hfa384x *hw,
199 struct hfa384x_usbctlx *ctlx);
200
201 static void unlocked_usbctlx_complete(struct hfa384x *hw,
202 struct hfa384x_usbctlx *ctlx);
203
204 struct usbctlx_completor {
205 int (*complete)(struct usbctlx_completor *completor);
206 };
207
208 static int
209 hfa384x_usbctlx_complete_sync(struct hfa384x *hw,
210 struct hfa384x_usbctlx *ctlx,
211 struct usbctlx_completor *completor);
212
213 static int
214 unlocked_usbctlx_cancel_async(struct hfa384x *hw, struct hfa384x_usbctlx *ctlx);
215
216 static void hfa384x_cb_status(struct hfa384x *hw,
217 const struct hfa384x_usbctlx *ctlx);
218
219 static int
220 usbctlx_get_status(const struct hfa384x_usb_statusresp *cmdresp,
221 struct hfa384x_cmdresult *result);
222
223 static void
224 usbctlx_get_rridresult(const struct hfa384x_usb_rridresp *rridresp,
225 struct hfa384x_rridresult *result);
226
227
228
229 static inline int
230 hfa384x_docmd(struct hfa384x *hw,
231 struct hfa384x_metacmd *cmd);
232
233 static int
234 hfa384x_dorrid(struct hfa384x *hw,
235 enum cmd_mode mode,
236 u16 rid,
237 void *riddata,
238 unsigned int riddatalen,
239 ctlx_cmdcb_t cmdcb, ctlx_usercb_t usercb, void *usercb_data);
240
241 static int
242 hfa384x_dowrid(struct hfa384x *hw,
243 enum cmd_mode mode,
244 u16 rid,
245 void *riddata,
246 unsigned int riddatalen,
247 ctlx_cmdcb_t cmdcb, ctlx_usercb_t usercb, void *usercb_data);
248
249 static int
250 hfa384x_dormem(struct hfa384x *hw,
251 u16 page,
252 u16 offset,
253 void *data,
254 unsigned int len);
255
256 static int
257 hfa384x_dowmem(struct hfa384x *hw,
258 u16 page,
259 u16 offset,
260 void *data,
261 unsigned int len);
262
263 static int hfa384x_isgood_pdrcode(u16 pdrcode);
264
265 static inline const char *ctlxstr(enum ctlx_state s)
266 {
267 static const char * const ctlx_str[] = {
268 "Initial state",
269 "Complete",
270 "Request failed",
271 "Request pending",
272 "Request packet submitted",
273 "Request packet completed",
274 "Response packet completed"
275 };
276
277 return ctlx_str[s];
278 };
279
280 static inline struct hfa384x_usbctlx *get_active_ctlx(struct hfa384x *hw)
281 {
282 return list_entry(hw->ctlxq.active.next, struct hfa384x_usbctlx, list);
283 }
284
285 #ifdef DEBUG_USB
286 void dbprint_urb(struct urb *urb)
287 {
288 pr_debug("urb->pipe=0x%08x\n", urb->pipe);
289 pr_debug("urb->status=0x%08x\n", urb->status);
290 pr_debug("urb->transfer_flags=0x%08x\n", urb->transfer_flags);
291 pr_debug("urb->transfer_buffer=0x%08x\n",
292 (unsigned int)urb->transfer_buffer);
293 pr_debug("urb->transfer_buffer_length=0x%08x\n",
294 urb->transfer_buffer_length);
295 pr_debug("urb->actual_length=0x%08x\n", urb->actual_length);
296 pr_debug("urb->bandwidth=0x%08x\n", urb->bandwidth);
297 pr_debug("urb->setup_packet(ctl)=0x%08x\n",
298 (unsigned int)urb->setup_packet);
299 pr_debug("urb->start_frame(iso/irq)=0x%08x\n", urb->start_frame);
300 pr_debug("urb->interval(irq)=0x%08x\n", urb->interval);
301 pr_debug("urb->error_count(iso)=0x%08x\n", urb->error_count);
302 pr_debug("urb->timeout=0x%08x\n", urb->timeout);
303 pr_debug("urb->context=0x%08x\n", (unsigned int)urb->context);
304 pr_debug("urb->complete=0x%08x\n", (unsigned int)urb->complete);
305 }
306 #endif
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325 static int submit_rx_urb(struct hfa384x *hw, gfp_t memflags)
326 {
327 struct sk_buff *skb;
328 int result;
329
330 skb = dev_alloc_skb(sizeof(union hfa384x_usbin));
331 if (!skb) {
332 result = -ENOMEM;
333 goto done;
334 }
335
336
337 usb_fill_bulk_urb(&hw->rx_urb, hw->usb,
338 hw->endp_in,
339 skb->data, sizeof(union hfa384x_usbin),
340 hfa384x_usbin_callback, hw->wlandev);
341
342 hw->rx_urb_skb = skb;
343
344 result = -ENOLINK;
345 if (!hw->wlandev->hwremoved &&
346 !test_bit(WORK_RX_HALT, &hw->usb_flags)) {
347 result = usb_submit_urb(&hw->rx_urb, memflags);
348
349
350 if (result == -EPIPE) {
351 netdev_warn(hw->wlandev->netdev,
352 "%s rx pipe stalled: requesting reset\n",
353 hw->wlandev->netdev->name);
354 if (!test_and_set_bit(WORK_RX_HALT, &hw->usb_flags))
355 schedule_work(&hw->usb_work);
356 }
357 }
358
359
360 if (result != 0) {
361 dev_kfree_skb(skb);
362 hw->rx_urb_skb = NULL;
363 }
364
365 done:
366 return result;
367 }
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388 static int submit_tx_urb(struct hfa384x *hw, struct urb *tx_urb, gfp_t memflags)
389 {
390 struct net_device *netdev = hw->wlandev->netdev;
391 int result;
392
393 result = -ENOLINK;
394 if (netif_running(netdev)) {
395 if (!hw->wlandev->hwremoved &&
396 !test_bit(WORK_TX_HALT, &hw->usb_flags)) {
397 result = usb_submit_urb(tx_urb, memflags);
398
399
400 if (result == -EPIPE) {
401 netdev_warn(hw->wlandev->netdev,
402 "%s tx pipe stalled: requesting reset\n",
403 netdev->name);
404 set_bit(WORK_TX_HALT, &hw->usb_flags);
405 schedule_work(&hw->usb_work);
406 } else if (result == 0) {
407 netif_stop_queue(netdev);
408 }
409 }
410 }
411
412 return result;
413 }
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432 static void hfa384x_usb_defer(struct work_struct *data)
433 {
434 struct hfa384x *hw = container_of(data, struct hfa384x, usb_work);
435 struct net_device *netdev = hw->wlandev->netdev;
436
437
438
439
440 if (hw->wlandev->hwremoved)
441 return;
442
443
444 if (test_bit(WORK_RX_HALT, &hw->usb_flags)) {
445 int ret;
446
447 usb_kill_urb(&hw->rx_urb);
448
449 ret = usb_clear_halt(hw->usb, hw->endp_in);
450 if (ret != 0) {
451 netdev_err(hw->wlandev->netdev,
452 "Failed to clear rx pipe for %s: err=%d\n",
453 netdev->name, ret);
454 } else {
455 netdev_info(hw->wlandev->netdev, "%s rx pipe reset complete.\n",
456 netdev->name);
457 clear_bit(WORK_RX_HALT, &hw->usb_flags);
458 set_bit(WORK_RX_RESUME, &hw->usb_flags);
459 }
460 }
461
462
463 if (test_bit(WORK_RX_RESUME, &hw->usb_flags)) {
464 int ret;
465
466 ret = submit_rx_urb(hw, GFP_KERNEL);
467 if (ret != 0) {
468 netdev_err(hw->wlandev->netdev,
469 "Failed to resume %s rx pipe.\n",
470 netdev->name);
471 } else {
472 clear_bit(WORK_RX_RESUME, &hw->usb_flags);
473 }
474 }
475
476
477 if (test_bit(WORK_TX_HALT, &hw->usb_flags)) {
478 int ret;
479
480 usb_kill_urb(&hw->tx_urb);
481 ret = usb_clear_halt(hw->usb, hw->endp_out);
482 if (ret != 0) {
483 netdev_err(hw->wlandev->netdev,
484 "Failed to clear tx pipe for %s: err=%d\n",
485 netdev->name, ret);
486 } else {
487 netdev_info(hw->wlandev->netdev, "%s tx pipe reset complete.\n",
488 netdev->name);
489 clear_bit(WORK_TX_HALT, &hw->usb_flags);
490 set_bit(WORK_TX_RESUME, &hw->usb_flags);
491
492
493
494
495
496 hfa384x_usbctlxq_run(hw);
497 }
498 }
499
500
501 if (test_and_clear_bit(WORK_TX_RESUME, &hw->usb_flags))
502 netif_wake_queue(hw->wlandev->netdev);
503 }
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527 void hfa384x_create(struct hfa384x *hw, struct usb_device *usb)
528 {
529 memset(hw, 0, sizeof(*hw));
530 hw->usb = usb;
531
532
533 hw->endp_in = usb_rcvbulkpipe(usb, 1);
534 hw->endp_out = usb_sndbulkpipe(usb, 2);
535
536
537 init_waitqueue_head(&hw->cmdq);
538
539
540 spin_lock_init(&hw->ctlxq.lock);
541 INIT_LIST_HEAD(&hw->ctlxq.pending);
542 INIT_LIST_HEAD(&hw->ctlxq.active);
543 INIT_LIST_HEAD(&hw->ctlxq.completing);
544 INIT_LIST_HEAD(&hw->ctlxq.reapable);
545
546
547 skb_queue_head_init(&hw->authq);
548
549 tasklet_init(&hw->reaper_bh,
550 hfa384x_usbctlx_reaper_task, (unsigned long)hw);
551 tasklet_init(&hw->completion_bh,
552 hfa384x_usbctlx_completion_task, (unsigned long)hw);
553 INIT_WORK(&hw->link_bh, prism2sta_processing_defer);
554 INIT_WORK(&hw->usb_work, hfa384x_usb_defer);
555
556 timer_setup(&hw->throttle, hfa384x_usb_throttlefn, 0);
557
558 timer_setup(&hw->resptimer, hfa384x_usbctlx_resptimerfn, 0);
559
560 timer_setup(&hw->reqtimer, hfa384x_usbctlx_reqtimerfn, 0);
561
562 usb_init_urb(&hw->rx_urb);
563 usb_init_urb(&hw->tx_urb);
564 usb_init_urb(&hw->ctlx_urb);
565
566 hw->link_status = HFA384x_LINK_NOTCONNECTED;
567 hw->state = HFA384x_STATE_INIT;
568
569 INIT_WORK(&hw->commsqual_bh, prism2sta_commsqual_defer);
570 timer_setup(&hw->commsqual_timer, prism2sta_commsqual_timer, 0);
571 }
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596 void hfa384x_destroy(struct hfa384x *hw)
597 {
598 struct sk_buff *skb;
599
600 if (hw->state == HFA384x_STATE_RUNNING)
601 hfa384x_drvr_stop(hw);
602 hw->state = HFA384x_STATE_PREINIT;
603
604 kfree(hw->scanresults);
605 hw->scanresults = NULL;
606
607
608 while ((skb = skb_dequeue(&hw->authq)))
609 dev_kfree_skb(skb);
610 }
611
612 static struct hfa384x_usbctlx *usbctlx_alloc(void)
613 {
614 struct hfa384x_usbctlx *ctlx;
615
616 ctlx = kzalloc(sizeof(*ctlx),
617 in_interrupt() ? GFP_ATOMIC : GFP_KERNEL);
618 if (ctlx)
619 init_completion(&ctlx->done);
620
621 return ctlx;
622 }
623
624 static int
625 usbctlx_get_status(const struct hfa384x_usb_statusresp *cmdresp,
626 struct hfa384x_cmdresult *result)
627 {
628 result->status = le16_to_cpu(cmdresp->status);
629 result->resp0 = le16_to_cpu(cmdresp->resp0);
630 result->resp1 = le16_to_cpu(cmdresp->resp1);
631 result->resp2 = le16_to_cpu(cmdresp->resp2);
632
633 pr_debug("cmdresult:status=0x%04x resp0=0x%04x resp1=0x%04x resp2=0x%04x\n",
634 result->status, result->resp0, result->resp1, result->resp2);
635
636 return result->status & HFA384x_STATUS_RESULT;
637 }
638
639 static void
640 usbctlx_get_rridresult(const struct hfa384x_usb_rridresp *rridresp,
641 struct hfa384x_rridresult *result)
642 {
643 result->rid = le16_to_cpu(rridresp->rid);
644 result->riddata = rridresp->data;
645 result->riddata_len = ((le16_to_cpu(rridresp->frmlen) - 1) * 2);
646 }
647
648
649
650
651
652
653
654 struct usbctlx_cmd_completor {
655 struct usbctlx_completor head;
656
657 const struct hfa384x_usb_statusresp *cmdresp;
658 struct hfa384x_cmdresult *result;
659 };
660
661 static inline int usbctlx_cmd_completor_fn(struct usbctlx_completor *head)
662 {
663 struct usbctlx_cmd_completor *complete;
664
665 complete = (struct usbctlx_cmd_completor *)head;
666 return usbctlx_get_status(complete->cmdresp, complete->result);
667 }
668
669 static inline struct usbctlx_completor *
670 init_cmd_completor(struct usbctlx_cmd_completor *completor,
671 const struct hfa384x_usb_statusresp *cmdresp,
672 struct hfa384x_cmdresult *result)
673 {
674 completor->head.complete = usbctlx_cmd_completor_fn;
675 completor->cmdresp = cmdresp;
676 completor->result = result;
677 return &completor->head;
678 }
679
680
681
682
683
684
685
686 struct usbctlx_rrid_completor {
687 struct usbctlx_completor head;
688
689 const struct hfa384x_usb_rridresp *rridresp;
690 void *riddata;
691 unsigned int riddatalen;
692 };
693
694 static int usbctlx_rrid_completor_fn(struct usbctlx_completor *head)
695 {
696 struct usbctlx_rrid_completor *complete;
697 struct hfa384x_rridresult rridresult;
698
699 complete = (struct usbctlx_rrid_completor *)head;
700 usbctlx_get_rridresult(complete->rridresp, &rridresult);
701
702
703 if (rridresult.riddata_len != complete->riddatalen) {
704 pr_warn("RID len mismatch, rid=0x%04x hlen=%d fwlen=%d\n",
705 rridresult.rid,
706 complete->riddatalen, rridresult.riddata_len);
707 return -ENODATA;
708 }
709
710 memcpy(complete->riddata, rridresult.riddata, complete->riddatalen);
711 return 0;
712 }
713
714 static inline struct usbctlx_completor *
715 init_rrid_completor(struct usbctlx_rrid_completor *completor,
716 const struct hfa384x_usb_rridresp *rridresp,
717 void *riddata,
718 unsigned int riddatalen)
719 {
720 completor->head.complete = usbctlx_rrid_completor_fn;
721 completor->rridresp = rridresp;
722 completor->riddata = riddata;
723 completor->riddatalen = riddatalen;
724 return &completor->head;
725 }
726
727
728
729
730
731
732 #define init_wrid_completor init_cmd_completor
733
734
735
736
737
738
739 #define init_wmem_completor init_cmd_completor
740
741
742
743
744
745
746 struct usbctlx_rmem_completor {
747 struct usbctlx_completor head;
748
749 const struct hfa384x_usb_rmemresp *rmemresp;
750 void *data;
751 unsigned int len;
752 };
753
754 static int usbctlx_rmem_completor_fn(struct usbctlx_completor *head)
755 {
756 struct usbctlx_rmem_completor *complete =
757 (struct usbctlx_rmem_completor *)head;
758
759 pr_debug("rmemresp:len=%d\n", complete->rmemresp->frmlen);
760 memcpy(complete->data, complete->rmemresp->data, complete->len);
761 return 0;
762 }
763
764 static inline struct usbctlx_completor *
765 init_rmem_completor(struct usbctlx_rmem_completor *completor,
766 struct hfa384x_usb_rmemresp *rmemresp,
767 void *data,
768 unsigned int len)
769 {
770 completor->head.complete = usbctlx_rmem_completor_fn;
771 completor->rmemresp = rmemresp;
772 completor->data = data;
773 completor->len = len;
774 return &completor->head;
775 }
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799 static void hfa384x_cb_status(struct hfa384x *hw,
800 const struct hfa384x_usbctlx *ctlx)
801 {
802 if (ctlx->usercb) {
803 struct hfa384x_cmdresult cmdresult;
804
805 if (ctlx->state != CTLX_COMPLETE) {
806 memset(&cmdresult, 0, sizeof(cmdresult));
807 cmdresult.status =
808 HFA384x_STATUS_RESULT_SET(HFA384x_CMD_ERR);
809 } else {
810 usbctlx_get_status(&ctlx->inbuf.cmdresp, &cmdresult);
811 }
812
813 ctlx->usercb(hw, &cmdresult, ctlx->usercb_data);
814 }
815 }
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837 int hfa384x_cmd_initialize(struct hfa384x *hw)
838 {
839 int result = 0;
840 int i;
841 struct hfa384x_metacmd cmd;
842
843 cmd.cmd = HFA384x_CMDCODE_INIT;
844 cmd.parm0 = 0;
845 cmd.parm1 = 0;
846 cmd.parm2 = 0;
847
848 result = hfa384x_docmd(hw, &cmd);
849
850 pr_debug("cmdresp.init: status=0x%04x, resp0=0x%04x, resp1=0x%04x, resp2=0x%04x\n",
851 cmd.result.status,
852 cmd.result.resp0, cmd.result.resp1, cmd.result.resp2);
853 if (result == 0) {
854 for (i = 0; i < HFA384x_NUMPORTS_MAX; i++)
855 hw->port_enabled[i] = 0;
856 }
857
858 hw->link_status = HFA384x_LINK_NOTCONNECTED;
859
860 return result;
861 }
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884 int hfa384x_cmd_disable(struct hfa384x *hw, u16 macport)
885 {
886 struct hfa384x_metacmd cmd;
887
888 cmd.cmd = HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_DISABLE) |
889 HFA384x_CMD_MACPORT_SET(macport);
890 cmd.parm0 = 0;
891 cmd.parm1 = 0;
892 cmd.parm2 = 0;
893
894 return hfa384x_docmd(hw, &cmd);
895 }
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918 int hfa384x_cmd_enable(struct hfa384x *hw, u16 macport)
919 {
920 struct hfa384x_metacmd cmd;
921
922 cmd.cmd = HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_ENABLE) |
923 HFA384x_CMD_MACPORT_SET(macport);
924 cmd.parm0 = 0;
925 cmd.parm1 = 0;
926 cmd.parm2 = 0;
927
928 return hfa384x_docmd(hw, &cmd);
929 }
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961 int hfa384x_cmd_monitor(struct hfa384x *hw, u16 enable)
962 {
963 struct hfa384x_metacmd cmd;
964
965 cmd.cmd = HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_MONITOR) |
966 HFA384x_CMD_AINFO_SET(enable);
967 cmd.parm0 = 0;
968 cmd.parm1 = 0;
969 cmd.parm2 = 0;
970
971 return hfa384x_docmd(hw, &cmd);
972 }
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013 int hfa384x_cmd_download(struct hfa384x *hw, u16 mode, u16 lowaddr,
1014 u16 highaddr, u16 codelen)
1015 {
1016 struct hfa384x_metacmd cmd;
1017
1018 pr_debug("mode=%d, lowaddr=0x%04x, highaddr=0x%04x, codelen=%d\n",
1019 mode, lowaddr, highaddr, codelen);
1020
1021 cmd.cmd = (HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_DOWNLD) |
1022 HFA384x_CMD_PROGMODE_SET(mode));
1023
1024 cmd.parm0 = lowaddr;
1025 cmd.parm1 = highaddr;
1026 cmd.parm2 = codelen;
1027
1028 return hfa384x_docmd(hw, &cmd);
1029 }
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055 int hfa384x_corereset(struct hfa384x *hw, int holdtime,
1056 int settletime, int genesis)
1057 {
1058 int result;
1059
1060 result = usb_reset_device(hw->usb);
1061 if (result < 0) {
1062 netdev_err(hw->wlandev->netdev, "usb_reset_device() failed, result=%d.\n",
1063 result);
1064 }
1065
1066 return result;
1067 }
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094 static int hfa384x_usbctlx_complete_sync(struct hfa384x *hw,
1095 struct hfa384x_usbctlx *ctlx,
1096 struct usbctlx_completor *completor)
1097 {
1098 unsigned long flags;
1099 int result;
1100
1101 result = wait_for_completion_interruptible(&ctlx->done);
1102
1103 spin_lock_irqsave(&hw->ctlxq.lock, flags);
1104
1105
1106
1107
1108
1109 cleanup:
1110 if (hw->wlandev->hwremoved) {
1111 spin_unlock_irqrestore(&hw->ctlxq.lock, flags);
1112 result = -ENODEV;
1113 } else if (result != 0) {
1114 int runqueue = 0;
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125 if (ctlx == get_active_ctlx(hw)) {
1126 spin_unlock_irqrestore(&hw->ctlxq.lock, flags);
1127
1128 del_singleshot_timer_sync(&hw->reqtimer);
1129 del_singleshot_timer_sync(&hw->resptimer);
1130 hw->req_timer_done = 1;
1131 hw->resp_timer_done = 1;
1132 usb_kill_urb(&hw->ctlx_urb);
1133
1134 spin_lock_irqsave(&hw->ctlxq.lock, flags);
1135
1136 runqueue = 1;
1137
1138
1139
1140
1141
1142 if (hw->wlandev->hwremoved)
1143 goto cleanup;
1144 }
1145
1146
1147
1148
1149
1150
1151 ctlx->reapable = 1;
1152 ctlx->state = CTLX_REQ_FAILED;
1153 list_move_tail(&ctlx->list, &hw->ctlxq.completing);
1154
1155 spin_unlock_irqrestore(&hw->ctlxq.lock, flags);
1156
1157 if (runqueue)
1158 hfa384x_usbctlxq_run(hw);
1159 } else {
1160 if (ctlx->state == CTLX_COMPLETE) {
1161 result = completor->complete(completor);
1162 } else {
1163 netdev_warn(hw->wlandev->netdev, "CTLX[%d] error: state(%s)\n",
1164 le16_to_cpu(ctlx->outbuf.type),
1165 ctlxstr(ctlx->state));
1166 result = -EIO;
1167 }
1168
1169 list_del(&ctlx->list);
1170 spin_unlock_irqrestore(&hw->ctlxq.lock, flags);
1171 kfree(ctlx);
1172 }
1173
1174 return result;
1175 }
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205 static inline int
1206 hfa384x_docmd(struct hfa384x *hw,
1207 struct hfa384x_metacmd *cmd)
1208 {
1209 int result;
1210 struct hfa384x_usbctlx *ctlx;
1211
1212 ctlx = usbctlx_alloc();
1213 if (!ctlx) {
1214 result = -ENOMEM;
1215 goto done;
1216 }
1217
1218
1219 ctlx->outbuf.cmdreq.type = cpu_to_le16(HFA384x_USB_CMDREQ);
1220 ctlx->outbuf.cmdreq.cmd = cpu_to_le16(cmd->cmd);
1221 ctlx->outbuf.cmdreq.parm0 = cpu_to_le16(cmd->parm0);
1222 ctlx->outbuf.cmdreq.parm1 = cpu_to_le16(cmd->parm1);
1223 ctlx->outbuf.cmdreq.parm2 = cpu_to_le16(cmd->parm2);
1224
1225 ctlx->outbufsize = sizeof(ctlx->outbuf.cmdreq);
1226
1227 pr_debug("cmdreq: cmd=0x%04x parm0=0x%04x parm1=0x%04x parm2=0x%04x\n",
1228 cmd->cmd, cmd->parm0, cmd->parm1, cmd->parm2);
1229
1230 ctlx->reapable = DOWAIT;
1231 ctlx->cmdcb = NULL;
1232 ctlx->usercb = NULL;
1233 ctlx->usercb_data = NULL;
1234
1235 result = hfa384x_usbctlx_submit(hw, ctlx);
1236 if (result != 0) {
1237 kfree(ctlx);
1238 } else {
1239 struct usbctlx_cmd_completor cmd_completor;
1240 struct usbctlx_completor *completor;
1241
1242 completor = init_cmd_completor(&cmd_completor,
1243 &ctlx->inbuf.cmdresp,
1244 &cmd->result);
1245
1246 result = hfa384x_usbctlx_complete_sync(hw, ctlx, completor);
1247 }
1248
1249 done:
1250 return result;
1251 }
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290 static int
1291 hfa384x_dorrid(struct hfa384x *hw,
1292 enum cmd_mode mode,
1293 u16 rid,
1294 void *riddata,
1295 unsigned int riddatalen,
1296 ctlx_cmdcb_t cmdcb, ctlx_usercb_t usercb, void *usercb_data)
1297 {
1298 int result;
1299 struct hfa384x_usbctlx *ctlx;
1300
1301 ctlx = usbctlx_alloc();
1302 if (!ctlx) {
1303 result = -ENOMEM;
1304 goto done;
1305 }
1306
1307
1308 ctlx->outbuf.rridreq.type = cpu_to_le16(HFA384x_USB_RRIDREQ);
1309 ctlx->outbuf.rridreq.frmlen =
1310 cpu_to_le16(sizeof(ctlx->outbuf.rridreq.rid));
1311 ctlx->outbuf.rridreq.rid = cpu_to_le16(rid);
1312
1313 ctlx->outbufsize = sizeof(ctlx->outbuf.rridreq);
1314
1315 ctlx->reapable = mode;
1316 ctlx->cmdcb = cmdcb;
1317 ctlx->usercb = usercb;
1318 ctlx->usercb_data = usercb_data;
1319
1320
1321 result = hfa384x_usbctlx_submit(hw, ctlx);
1322 if (result != 0) {
1323 kfree(ctlx);
1324 } else if (mode == DOWAIT) {
1325 struct usbctlx_rrid_completor completor;
1326
1327 result =
1328 hfa384x_usbctlx_complete_sync(hw, ctlx,
1329 init_rrid_completor
1330 (&completor,
1331 &ctlx->inbuf.rridresp,
1332 riddata, riddatalen));
1333 }
1334
1335 done:
1336 return result;
1337 }
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372 static int
1373 hfa384x_dowrid(struct hfa384x *hw,
1374 enum cmd_mode mode,
1375 u16 rid,
1376 void *riddata,
1377 unsigned int riddatalen,
1378 ctlx_cmdcb_t cmdcb, ctlx_usercb_t usercb, void *usercb_data)
1379 {
1380 int result;
1381 struct hfa384x_usbctlx *ctlx;
1382
1383 ctlx = usbctlx_alloc();
1384 if (!ctlx) {
1385 result = -ENOMEM;
1386 goto done;
1387 }
1388
1389
1390 ctlx->outbuf.wridreq.type = cpu_to_le16(HFA384x_USB_WRIDREQ);
1391 ctlx->outbuf.wridreq.frmlen = cpu_to_le16((sizeof
1392 (ctlx->outbuf.wridreq.rid) +
1393 riddatalen + 1) / 2);
1394 ctlx->outbuf.wridreq.rid = cpu_to_le16(rid);
1395 memcpy(ctlx->outbuf.wridreq.data, riddata, riddatalen);
1396
1397 ctlx->outbufsize = sizeof(ctlx->outbuf.wridreq.type) +
1398 sizeof(ctlx->outbuf.wridreq.frmlen) +
1399 sizeof(ctlx->outbuf.wridreq.rid) + riddatalen;
1400
1401 ctlx->reapable = mode;
1402 ctlx->cmdcb = cmdcb;
1403 ctlx->usercb = usercb;
1404 ctlx->usercb_data = usercb_data;
1405
1406
1407 result = hfa384x_usbctlx_submit(hw, ctlx);
1408 if (result != 0) {
1409 kfree(ctlx);
1410 } else if (mode == DOWAIT) {
1411 struct usbctlx_cmd_completor completor;
1412 struct hfa384x_cmdresult wridresult;
1413
1414 result = hfa384x_usbctlx_complete_sync(hw,
1415 ctlx,
1416 init_wrid_completor
1417 (&completor,
1418 &ctlx->inbuf.wridresp,
1419 &wridresult));
1420 }
1421
1422 done:
1423 return result;
1424 }
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455 static int
1456 hfa384x_dormem(struct hfa384x *hw,
1457 u16 page,
1458 u16 offset,
1459 void *data,
1460 unsigned int len)
1461 {
1462 int result;
1463 struct hfa384x_usbctlx *ctlx;
1464
1465 ctlx = usbctlx_alloc();
1466 if (!ctlx) {
1467 result = -ENOMEM;
1468 goto done;
1469 }
1470
1471
1472 ctlx->outbuf.rmemreq.type = cpu_to_le16(HFA384x_USB_RMEMREQ);
1473 ctlx->outbuf.rmemreq.frmlen =
1474 cpu_to_le16(sizeof(ctlx->outbuf.rmemreq.offset) +
1475 sizeof(ctlx->outbuf.rmemreq.page) + len);
1476 ctlx->outbuf.rmemreq.offset = cpu_to_le16(offset);
1477 ctlx->outbuf.rmemreq.page = cpu_to_le16(page);
1478
1479 ctlx->outbufsize = sizeof(ctlx->outbuf.rmemreq);
1480
1481 pr_debug("type=0x%04x frmlen=%d offset=0x%04x page=0x%04x\n",
1482 ctlx->outbuf.rmemreq.type,
1483 ctlx->outbuf.rmemreq.frmlen,
1484 ctlx->outbuf.rmemreq.offset, ctlx->outbuf.rmemreq.page);
1485
1486 pr_debug("pktsize=%zd\n", ROUNDUP64(sizeof(ctlx->outbuf.rmemreq)));
1487
1488 ctlx->reapable = DOWAIT;
1489 ctlx->cmdcb = NULL;
1490 ctlx->usercb = NULL;
1491 ctlx->usercb_data = NULL;
1492
1493 result = hfa384x_usbctlx_submit(hw, ctlx);
1494 if (result != 0) {
1495 kfree(ctlx);
1496 } else {
1497 struct usbctlx_rmem_completor completor;
1498
1499 result =
1500 hfa384x_usbctlx_complete_sync(hw, ctlx,
1501 init_rmem_completor
1502 (&completor,
1503 &ctlx->inbuf.rmemresp, data,
1504 len));
1505 }
1506
1507 done:
1508 return result;
1509 }
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541 static int
1542 hfa384x_dowmem(struct hfa384x *hw,
1543 u16 page,
1544 u16 offset,
1545 void *data,
1546 unsigned int len)
1547 {
1548 int result;
1549 struct hfa384x_usbctlx *ctlx;
1550
1551 pr_debug("page=0x%04x offset=0x%04x len=%d\n", page, offset, len);
1552
1553 ctlx = usbctlx_alloc();
1554 if (!ctlx) {
1555 result = -ENOMEM;
1556 goto done;
1557 }
1558
1559
1560 ctlx->outbuf.wmemreq.type = cpu_to_le16(HFA384x_USB_WMEMREQ);
1561 ctlx->outbuf.wmemreq.frmlen =
1562 cpu_to_le16(sizeof(ctlx->outbuf.wmemreq.offset) +
1563 sizeof(ctlx->outbuf.wmemreq.page) + len);
1564 ctlx->outbuf.wmemreq.offset = cpu_to_le16(offset);
1565 ctlx->outbuf.wmemreq.page = cpu_to_le16(page);
1566 memcpy(ctlx->outbuf.wmemreq.data, data, len);
1567
1568 ctlx->outbufsize = sizeof(ctlx->outbuf.wmemreq.type) +
1569 sizeof(ctlx->outbuf.wmemreq.frmlen) +
1570 sizeof(ctlx->outbuf.wmemreq.offset) +
1571 sizeof(ctlx->outbuf.wmemreq.page) + len;
1572
1573 ctlx->reapable = DOWAIT;
1574 ctlx->cmdcb = NULL;
1575 ctlx->usercb = NULL;
1576 ctlx->usercb_data = NULL;
1577
1578 result = hfa384x_usbctlx_submit(hw, ctlx);
1579 if (result != 0) {
1580 kfree(ctlx);
1581 } else {
1582 struct usbctlx_cmd_completor completor;
1583 struct hfa384x_cmdresult wmemresult;
1584
1585 result = hfa384x_usbctlx_complete_sync(hw,
1586 ctlx,
1587 init_wmem_completor
1588 (&completor,
1589 &ctlx->inbuf.wmemresp,
1590 &wmemresult));
1591 }
1592
1593 done:
1594 return result;
1595 }
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620 int hfa384x_drvr_disable(struct hfa384x *hw, u16 macport)
1621 {
1622 int result = 0;
1623
1624 if ((!hw->isap && macport != 0) ||
1625 (hw->isap && !(macport <= HFA384x_PORTID_MAX)) ||
1626 !(hw->port_enabled[macport])) {
1627 result = -EINVAL;
1628 } else {
1629 result = hfa384x_cmd_disable(hw, macport);
1630 if (result == 0)
1631 hw->port_enabled[macport] = 0;
1632 }
1633 return result;
1634 }
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659 int hfa384x_drvr_enable(struct hfa384x *hw, u16 macport)
1660 {
1661 int result = 0;
1662
1663 if ((!hw->isap && macport != 0) ||
1664 (hw->isap && !(macport <= HFA384x_PORTID_MAX)) ||
1665 (hw->port_enabled[macport])) {
1666 result = -EINVAL;
1667 } else {
1668 result = hfa384x_cmd_enable(hw, macport);
1669 if (result == 0)
1670 hw->port_enabled[macport] = 1;
1671 }
1672 return result;
1673 }
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697 int hfa384x_drvr_flashdl_enable(struct hfa384x *hw)
1698 {
1699 int result = 0;
1700 int i;
1701
1702
1703 for (i = 0; i < HFA384x_PORTID_MAX; i++) {
1704 if (hw->port_enabled[i]) {
1705 pr_debug("called when port enabled.\n");
1706 return -EINVAL;
1707 }
1708 }
1709
1710
1711 if (hw->dlstate != HFA384x_DLSTATE_DISABLED)
1712 return -EINVAL;
1713
1714
1715 result = hfa384x_drvr_getconfig(hw, HFA384x_RID_DOWNLOADBUFFER,
1716 &hw->bufinfo, sizeof(hw->bufinfo));
1717 if (result)
1718 return result;
1719
1720 le16_to_cpus(&hw->bufinfo.page);
1721 le16_to_cpus(&hw->bufinfo.offset);
1722 le16_to_cpus(&hw->bufinfo.len);
1723 result = hfa384x_drvr_getconfig16(hw, HFA384x_RID_MAXLOADTIME,
1724 &hw->dltimeout);
1725 if (result)
1726 return result;
1727
1728 le16_to_cpus(&hw->dltimeout);
1729
1730 pr_debug("flashdl_enable\n");
1731
1732 hw->dlstate = HFA384x_DLSTATE_FLASHENABLED;
1733
1734 return result;
1735 }
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757 int hfa384x_drvr_flashdl_disable(struct hfa384x *hw)
1758 {
1759
1760 if (hw->dlstate != HFA384x_DLSTATE_FLASHENABLED)
1761 return -EINVAL;
1762
1763 pr_debug("flashdl_enable\n");
1764
1765
1766
1767 hfa384x_cmd_download(hw, HFA384x_PROGMODE_DISABLE, 0, 0, 0);
1768 hw->dlstate = HFA384x_DLSTATE_DISABLED;
1769
1770 return 0;
1771 }
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803 int hfa384x_drvr_flashdl_write(struct hfa384x *hw, u32 daddr,
1804 void *buf, u32 len)
1805 {
1806 int result = 0;
1807 u32 dlbufaddr;
1808 int nburns;
1809 u32 burnlen;
1810 u32 burndaddr;
1811 u16 burnlo;
1812 u16 burnhi;
1813 int nwrites;
1814 u8 *writebuf;
1815 u16 writepage;
1816 u16 writeoffset;
1817 u32 writelen;
1818 int i;
1819 int j;
1820
1821 pr_debug("daddr=0x%08x len=%d\n", daddr, len);
1822
1823
1824 if (hw->dlstate != HFA384x_DLSTATE_FLASHENABLED)
1825 return -EINVAL;
1826
1827 netdev_info(hw->wlandev->netdev,
1828 "Download %d bytes to flash @0x%06x\n", len, daddr);
1829
1830
1831
1832 dlbufaddr =
1833 HFA384x_ADDR_AUX_MKFLAT(hw->bufinfo.page, hw->bufinfo.offset);
1834 pr_debug("dlbuf.page=0x%04x dlbuf.offset=0x%04x dlbufaddr=0x%08x\n",
1835 hw->bufinfo.page, hw->bufinfo.offset, dlbufaddr);
1836
1837
1838
1839
1840
1841
1842
1843
1844 nburns = len / hw->bufinfo.len;
1845 nburns += (len % hw->bufinfo.len) ? 1 : 0;
1846
1847
1848 nwrites = hw->bufinfo.len / HFA384x_USB_RWMEM_MAXLEN;
1849 nwrites += (hw->bufinfo.len % HFA384x_USB_RWMEM_MAXLEN) ? 1 : 0;
1850
1851
1852 for (i = 0; i < nburns; i++) {
1853
1854 burnlen = (len - (hw->bufinfo.len * i)) > hw->bufinfo.len ?
1855 hw->bufinfo.len : (len - (hw->bufinfo.len * i));
1856 burndaddr = daddr + (hw->bufinfo.len * i);
1857 burnlo = HFA384x_ADDR_CMD_MKOFF(burndaddr);
1858 burnhi = HFA384x_ADDR_CMD_MKPAGE(burndaddr);
1859
1860 netdev_info(hw->wlandev->netdev, "Writing %d bytes to flash @0x%06x\n",
1861 burnlen, burndaddr);
1862
1863
1864 result = hfa384x_cmd_download(hw, HFA384x_PROGMODE_NV,
1865 burnlo, burnhi, burnlen);
1866 if (result) {
1867 netdev_err(hw->wlandev->netdev,
1868 "download(NV,lo=%x,hi=%x,len=%x) cmd failed, result=%d. Aborting d/l\n",
1869 burnlo, burnhi, burnlen, result);
1870 goto exit_proc;
1871 }
1872
1873
1874 for (j = 0; j < nwrites; j++) {
1875 writebuf = buf +
1876 (i * hw->bufinfo.len) +
1877 (j * HFA384x_USB_RWMEM_MAXLEN);
1878
1879 writepage = HFA384x_ADDR_CMD_MKPAGE(dlbufaddr +
1880 (j * HFA384x_USB_RWMEM_MAXLEN));
1881 writeoffset = HFA384x_ADDR_CMD_MKOFF(dlbufaddr +
1882 (j * HFA384x_USB_RWMEM_MAXLEN));
1883
1884 writelen = burnlen - (j * HFA384x_USB_RWMEM_MAXLEN);
1885 writelen = writelen > HFA384x_USB_RWMEM_MAXLEN ?
1886 HFA384x_USB_RWMEM_MAXLEN : writelen;
1887
1888 result = hfa384x_dowmem(hw,
1889 writepage,
1890 writeoffset,
1891 writebuf, writelen);
1892 }
1893
1894
1895 result = hfa384x_cmd_download(hw,
1896 HFA384x_PROGMODE_NVWRITE,
1897 0, 0, 0);
1898 if (result) {
1899 netdev_err(hw->wlandev->netdev,
1900 "download(NVWRITE,lo=%x,hi=%x,len=%x) cmd failed, result=%d. Aborting d/l\n",
1901 burnlo, burnhi, burnlen, result);
1902 goto exit_proc;
1903 }
1904
1905
1906 }
1907
1908 exit_proc:
1909
1910
1911
1912
1913
1914 return result;
1915 }
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943 int hfa384x_drvr_getconfig(struct hfa384x *hw, u16 rid, void *buf, u16 len)
1944 {
1945 return hfa384x_dorrid(hw, DOWAIT, rid, buf, len, NULL, NULL, NULL);
1946 }
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972 int
1973 hfa384x_drvr_setconfig_async(struct hfa384x *hw,
1974 u16 rid,
1975 void *buf,
1976 u16 len, ctlx_usercb_t usercb, void *usercb_data)
1977 {
1978 return hfa384x_dowrid(hw, DOASYNC, rid, buf, len, hfa384x_cb_status,
1979 usercb, usercb_data);
1980 }
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001 int hfa384x_drvr_ramdl_disable(struct hfa384x *hw)
2002 {
2003
2004 if (hw->dlstate != HFA384x_DLSTATE_RAMENABLED)
2005 return -EINVAL;
2006
2007 pr_debug("ramdl_disable()\n");
2008
2009
2010
2011 hfa384x_cmd_download(hw, HFA384x_PROGMODE_DISABLE, 0, 0, 0);
2012 hw->dlstate = HFA384x_DLSTATE_DISABLED;
2013
2014 return 0;
2015 }
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042 int hfa384x_drvr_ramdl_enable(struct hfa384x *hw, u32 exeaddr)
2043 {
2044 int result = 0;
2045 u16 lowaddr;
2046 u16 hiaddr;
2047 int i;
2048
2049
2050 for (i = 0; i < HFA384x_PORTID_MAX; i++) {
2051 if (hw->port_enabled[i]) {
2052 netdev_err(hw->wlandev->netdev,
2053 "Can't download with a macport enabled.\n");
2054 return -EINVAL;
2055 }
2056 }
2057
2058
2059 if (hw->dlstate != HFA384x_DLSTATE_DISABLED) {
2060 netdev_err(hw->wlandev->netdev,
2061 "Download state not disabled.\n");
2062 return -EINVAL;
2063 }
2064
2065 pr_debug("ramdl_enable, exeaddr=0x%08x\n", exeaddr);
2066
2067
2068 lowaddr = HFA384x_ADDR_CMD_MKOFF(exeaddr);
2069 hiaddr = HFA384x_ADDR_CMD_MKPAGE(exeaddr);
2070
2071 result = hfa384x_cmd_download(hw, HFA384x_PROGMODE_RAM,
2072 lowaddr, hiaddr, 0);
2073
2074 if (result == 0) {
2075
2076 hw->dlstate = HFA384x_DLSTATE_RAMENABLED;
2077 } else {
2078 pr_debug("cmd_download(0x%04x, 0x%04x) failed, result=%d.\n",
2079 lowaddr, hiaddr, result);
2080 }
2081
2082 return result;
2083 }
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112 int hfa384x_drvr_ramdl_write(struct hfa384x *hw, u32 daddr, void *buf, u32 len)
2113 {
2114 int result = 0;
2115 int nwrites;
2116 u8 *data = buf;
2117 int i;
2118 u32 curraddr;
2119 u16 currpage;
2120 u16 curroffset;
2121 u16 currlen;
2122
2123
2124 if (hw->dlstate != HFA384x_DLSTATE_RAMENABLED)
2125 return -EINVAL;
2126
2127 netdev_info(hw->wlandev->netdev, "Writing %d bytes to ram @0x%06x\n",
2128 len, daddr);
2129
2130
2131 nwrites = len / HFA384x_USB_RWMEM_MAXLEN;
2132 nwrites += len % HFA384x_USB_RWMEM_MAXLEN ? 1 : 0;
2133
2134
2135 for (i = 0; i < nwrites; i++) {
2136
2137 curraddr = daddr + (i * HFA384x_USB_RWMEM_MAXLEN);
2138 currpage = HFA384x_ADDR_CMD_MKPAGE(curraddr);
2139 curroffset = HFA384x_ADDR_CMD_MKOFF(curraddr);
2140 currlen = len - (i * HFA384x_USB_RWMEM_MAXLEN);
2141 if (currlen > HFA384x_USB_RWMEM_MAXLEN)
2142 currlen = HFA384x_USB_RWMEM_MAXLEN;
2143
2144
2145 result = hfa384x_dowmem(hw,
2146 currpage,
2147 curroffset,
2148 data + (i * HFA384x_USB_RWMEM_MAXLEN),
2149 currlen);
2150
2151 if (result)
2152 break;
2153
2154
2155 }
2156
2157 return result;
2158 }
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192 int hfa384x_drvr_readpda(struct hfa384x *hw, void *buf, unsigned int len)
2193 {
2194 int result = 0;
2195 __le16 *pda = buf;
2196 int pdaok = 0;
2197 int morepdrs = 1;
2198 int currpdr = 0;
2199 size_t i;
2200 u16 pdrlen;
2201 u16 pdrcode;
2202 u16 currpage;
2203 u16 curroffset;
2204 struct pdaloc {
2205 u32 cardaddr;
2206 u16 auxctl;
2207 } pdaloc[] = {
2208 {
2209 HFA3842_PDA_BASE, 0}, {
2210 HFA3841_PDA_BASE, 0}, {
2211 HFA3841_PDA_BOGUS_BASE, 0}
2212 };
2213
2214
2215 for (i = 0; i < ARRAY_SIZE(pdaloc); i++) {
2216
2217 currpage = HFA384x_ADDR_CMD_MKPAGE(pdaloc[i].cardaddr);
2218 curroffset = HFA384x_ADDR_CMD_MKOFF(pdaloc[i].cardaddr);
2219
2220
2221 result = hfa384x_dormem(hw, currpage, curroffset, buf,
2222 len);
2223
2224 if (result) {
2225 netdev_warn(hw->wlandev->netdev,
2226 "Read from index %zd failed, continuing\n",
2227 i);
2228 continue;
2229 }
2230
2231
2232 pdaok = 1;
2233 morepdrs = 1;
2234 while (pdaok && morepdrs) {
2235 pdrlen = le16_to_cpu(pda[currpdr]) * 2;
2236 pdrcode = le16_to_cpu(pda[currpdr + 1]);
2237
2238 if (pdrlen > HFA384x_PDR_LEN_MAX || pdrlen == 0) {
2239 netdev_err(hw->wlandev->netdev,
2240 "pdrlen invalid=%d\n", pdrlen);
2241 pdaok = 0;
2242 break;
2243 }
2244
2245 if (!hfa384x_isgood_pdrcode(pdrcode)) {
2246 netdev_err(hw->wlandev->netdev, "pdrcode invalid=%d\n",
2247 pdrcode);
2248 pdaok = 0;
2249 break;
2250 }
2251
2252 if (pdrcode == HFA384x_PDR_END_OF_PDA)
2253 morepdrs = 0;
2254
2255
2256 if (morepdrs) {
2257
2258 currpdr += le16_to_cpu(pda[currpdr]) + 1;
2259 }
2260 }
2261 if (pdaok) {
2262 netdev_info(hw->wlandev->netdev,
2263 "PDA Read from 0x%08x in %s space.\n",
2264 pdaloc[i].cardaddr,
2265 pdaloc[i].auxctl == 0 ? "EXTDS" :
2266 pdaloc[i].auxctl == 1 ? "NV" :
2267 pdaloc[i].auxctl == 2 ? "PHY" :
2268 pdaloc[i].auxctl == 3 ? "ICSRAM" :
2269 "<bogus auxctl>");
2270 break;
2271 }
2272 }
2273 result = pdaok ? 0 : -ENODATA;
2274
2275 if (result)
2276 pr_debug("Failure: pda is not okay\n");
2277
2278 return result;
2279 }
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303 int hfa384x_drvr_setconfig(struct hfa384x *hw, u16 rid, void *buf, u16 len)
2304 {
2305 return hfa384x_dowrid(hw, DOWAIT, rid, buf, len, NULL, NULL, NULL);
2306 }
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328 int hfa384x_drvr_start(struct hfa384x *hw)
2329 {
2330 int result, result1, result2;
2331 u16 status;
2332
2333 might_sleep();
2334
2335
2336
2337
2338
2339
2340 result =
2341 usb_get_std_status(hw->usb, USB_RECIP_ENDPOINT, hw->endp_in,
2342 &status);
2343 if (result < 0) {
2344 netdev_err(hw->wlandev->netdev, "Cannot get bulk in endpoint status.\n");
2345 goto done;
2346 }
2347 if ((status == 1) && usb_clear_halt(hw->usb, hw->endp_in))
2348 netdev_err(hw->wlandev->netdev, "Failed to reset bulk in endpoint.\n");
2349
2350 result =
2351 usb_get_std_status(hw->usb, USB_RECIP_ENDPOINT, hw->endp_out,
2352 &status);
2353 if (result < 0) {
2354 netdev_err(hw->wlandev->netdev, "Cannot get bulk out endpoint status.\n");
2355 goto done;
2356 }
2357 if ((status == 1) && usb_clear_halt(hw->usb, hw->endp_out))
2358 netdev_err(hw->wlandev->netdev, "Failed to reset bulk out endpoint.\n");
2359
2360
2361 usb_kill_urb(&hw->rx_urb);
2362
2363
2364 result = submit_rx_urb(hw, GFP_KERNEL);
2365 if (result != 0) {
2366 netdev_err(hw->wlandev->netdev,
2367 "Fatal, failed to submit RX URB, result=%d\n",
2368 result);
2369 goto done;
2370 }
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382 result1 = hfa384x_cmd_initialize(hw);
2383 msleep(1000);
2384 result = hfa384x_cmd_initialize(hw);
2385 result2 = result;
2386 if (result1 != 0) {
2387 if (result2 != 0) {
2388 netdev_err(hw->wlandev->netdev,
2389 "cmd_initialize() failed on two attempts, results %d and %d\n",
2390 result1, result2);
2391 usb_kill_urb(&hw->rx_urb);
2392 goto done;
2393 } else {
2394 pr_debug("First cmd_initialize() failed (result %d),\n",
2395 result1);
2396 pr_debug("but second attempt succeeded. All should be ok\n");
2397 }
2398 } else if (result2 != 0) {
2399 netdev_warn(hw->wlandev->netdev, "First cmd_initialize() succeeded, but second attempt failed (result=%d)\n",
2400 result2);
2401 netdev_warn(hw->wlandev->netdev,
2402 "Most likely the card will be functional\n");
2403 goto done;
2404 }
2405
2406 hw->state = HFA384x_STATE_RUNNING;
2407
2408 done:
2409 return result;
2410 }
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432 int hfa384x_drvr_stop(struct hfa384x *hw)
2433 {
2434 int i;
2435
2436 might_sleep();
2437
2438
2439
2440
2441 if (!hw->wlandev->hwremoved) {
2442
2443 hfa384x_cmd_initialize(hw);
2444
2445
2446 usb_kill_urb(&hw->rx_urb);
2447 }
2448
2449 hw->link_status = HFA384x_LINK_NOTCONNECTED;
2450 hw->state = HFA384x_STATE_INIT;
2451
2452 del_timer_sync(&hw->commsqual_timer);
2453
2454
2455 for (i = 0; i < HFA384x_NUMPORTS_MAX; i++)
2456 hw->port_enabled[i] = 0;
2457
2458 return 0;
2459 }
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483 int hfa384x_drvr_txframe(struct hfa384x *hw, struct sk_buff *skb,
2484 union p80211_hdr *p80211_hdr,
2485 struct p80211_metawep *p80211_wep)
2486 {
2487 int usbpktlen = sizeof(struct hfa384x_tx_frame);
2488 int result;
2489 int ret;
2490 char *ptr;
2491
2492 if (hw->tx_urb.status == -EINPROGRESS) {
2493 netdev_warn(hw->wlandev->netdev, "TX URB already in use\n");
2494 result = 3;
2495 goto exit;
2496 }
2497
2498
2499
2500 memset(&hw->txbuff.txfrm.desc, 0, sizeof(hw->txbuff.txfrm.desc));
2501
2502
2503 hw->txbuff.type = cpu_to_le16(HFA384x_USB_TXFRM);
2504
2505
2506 hw->txbuff.txfrm.desc.sw_support = 0x0123;
2507
2508
2509
2510
2511
2512 #if defined(DOBOTH)
2513 hw->txbuff.txfrm.desc.tx_control =
2514 HFA384x_TX_MACPORT_SET(0) | HFA384x_TX_STRUCTYPE_SET(1) |
2515 HFA384x_TX_TXEX_SET(1) | HFA384x_TX_TXOK_SET(1);
2516 #elif defined(DOEXC)
2517 hw->txbuff.txfrm.desc.tx_control =
2518 HFA384x_TX_MACPORT_SET(0) | HFA384x_TX_STRUCTYPE_SET(1) |
2519 HFA384x_TX_TXEX_SET(1) | HFA384x_TX_TXOK_SET(0);
2520 #else
2521 hw->txbuff.txfrm.desc.tx_control =
2522 HFA384x_TX_MACPORT_SET(0) | HFA384x_TX_STRUCTYPE_SET(1) |
2523 HFA384x_TX_TXEX_SET(0) | HFA384x_TX_TXOK_SET(0);
2524 #endif
2525 cpu_to_le16s(&hw->txbuff.txfrm.desc.tx_control);
2526
2527
2528 memcpy(&hw->txbuff.txfrm.desc.frame_control, p80211_hdr,
2529 sizeof(union p80211_hdr));
2530
2531
2532 if (p80211_wep->data) {
2533 hw->txbuff.txfrm.desc.data_len = cpu_to_le16(skb->len + 8);
2534 usbpktlen += 8;
2535 } else {
2536 hw->txbuff.txfrm.desc.data_len = cpu_to_le16(skb->len);
2537 }
2538
2539 usbpktlen += skb->len;
2540
2541
2542 ptr = hw->txbuff.txfrm.data;
2543 if (p80211_wep->data) {
2544 memcpy(ptr, p80211_wep->iv, sizeof(p80211_wep->iv));
2545 ptr += sizeof(p80211_wep->iv);
2546 memcpy(ptr, p80211_wep->data, skb->len);
2547 } else {
2548 memcpy(ptr, skb->data, skb->len);
2549 }
2550
2551 ptr += skb->len;
2552
2553
2554 if (p80211_wep->data)
2555 memcpy(ptr, p80211_wep->icv, sizeof(p80211_wep->icv));
2556
2557
2558 usb_fill_bulk_urb(&hw->tx_urb, hw->usb,
2559 hw->endp_out,
2560 &hw->txbuff, ROUNDUP64(usbpktlen),
2561 hfa384x_usbout_callback, hw->wlandev);
2562 hw->tx_urb.transfer_flags |= USB_QUEUE_BULK;
2563
2564 result = 1;
2565 ret = submit_tx_urb(hw, &hw->tx_urb, GFP_ATOMIC);
2566 if (ret != 0) {
2567 netdev_err(hw->wlandev->netdev,
2568 "submit_tx_urb() failed, error=%d\n", ret);
2569 result = 3;
2570 }
2571
2572 exit:
2573 return result;
2574 }
2575
2576 void hfa384x_tx_timeout(struct wlandevice *wlandev)
2577 {
2578 struct hfa384x *hw = wlandev->priv;
2579 unsigned long flags;
2580
2581 spin_lock_irqsave(&hw->ctlxq.lock, flags);
2582
2583 if (!hw->wlandev->hwremoved) {
2584 int sched;
2585
2586 sched = !test_and_set_bit(WORK_TX_HALT, &hw->usb_flags);
2587 sched |= !test_and_set_bit(WORK_RX_HALT, &hw->usb_flags);
2588 if (sched)
2589 schedule_work(&hw->usb_work);
2590 }
2591
2592 spin_unlock_irqrestore(&hw->ctlxq.lock, flags);
2593 }
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609 static void hfa384x_usbctlx_reaper_task(unsigned long data)
2610 {
2611 struct hfa384x *hw = (struct hfa384x *)data;
2612 struct hfa384x_usbctlx *ctlx, *temp;
2613 unsigned long flags;
2614
2615 spin_lock_irqsave(&hw->ctlxq.lock, flags);
2616
2617
2618
2619
2620 list_for_each_entry_safe(ctlx, temp, &hw->ctlxq.reapable, list) {
2621 list_del(&ctlx->list);
2622 kfree(ctlx);
2623 }
2624
2625 spin_unlock_irqrestore(&hw->ctlxq.lock, flags);
2626 }
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643 static void hfa384x_usbctlx_completion_task(unsigned long data)
2644 {
2645 struct hfa384x *hw = (struct hfa384x *)data;
2646 struct hfa384x_usbctlx *ctlx, *temp;
2647 unsigned long flags;
2648
2649 int reap = 0;
2650
2651 spin_lock_irqsave(&hw->ctlxq.lock, flags);
2652
2653
2654
2655
2656 list_for_each_entry_safe(ctlx, temp, &hw->ctlxq.completing, list) {
2657
2658
2659
2660 if (ctlx->cmdcb) {
2661 spin_unlock_irqrestore(&hw->ctlxq.lock, flags);
2662 ctlx->cmdcb(hw, ctlx);
2663 spin_lock_irqsave(&hw->ctlxq.lock, flags);
2664
2665
2666
2667
2668 ctlx->cmdcb = NULL;
2669
2670
2671
2672
2673 if (hw->wlandev->hwremoved) {
2674 reap = 0;
2675 break;
2676 }
2677 }
2678
2679
2680
2681
2682
2683
2684 if (ctlx->reapable) {
2685
2686
2687
2688
2689
2690 list_move_tail(&ctlx->list, &hw->ctlxq.reapable);
2691 reap = 1;
2692 }
2693
2694 complete(&ctlx->done);
2695 }
2696 spin_unlock_irqrestore(&hw->ctlxq.lock, flags);
2697
2698 if (reap)
2699 tasklet_schedule(&hw->reaper_bh);
2700 }
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720 static int unlocked_usbctlx_cancel_async(struct hfa384x *hw,
2721 struct hfa384x_usbctlx *ctlx)
2722 {
2723 int ret;
2724
2725
2726
2727
2728
2729
2730 hw->ctlx_urb.transfer_flags |= URB_ASYNC_UNLINK;
2731 ret = usb_unlink_urb(&hw->ctlx_urb);
2732
2733 if (ret != -EINPROGRESS) {
2734
2735
2736
2737
2738
2739
2740 ctlx->state = CTLX_REQ_FAILED;
2741 unlocked_usbctlx_complete(hw, ctlx);
2742 ret = 0;
2743 }
2744
2745 return ret;
2746 }
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771 static void unlocked_usbctlx_complete(struct hfa384x *hw,
2772 struct hfa384x_usbctlx *ctlx)
2773 {
2774
2775
2776
2777
2778 list_move_tail(&ctlx->list, &hw->ctlxq.completing);
2779 tasklet_schedule(&hw->completion_bh);
2780
2781 switch (ctlx->state) {
2782 case CTLX_COMPLETE:
2783 case CTLX_REQ_FAILED:
2784
2785 break;
2786
2787 default:
2788 netdev_err(hw->wlandev->netdev, "CTLX[%d] not in a terminating state(%s)\n",
2789 le16_to_cpu(ctlx->outbuf.type),
2790 ctlxstr(ctlx->state));
2791 break;
2792 }
2793 }
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812 static void hfa384x_usbctlxq_run(struct hfa384x *hw)
2813 {
2814 unsigned long flags;
2815
2816
2817 spin_lock_irqsave(&hw->ctlxq.lock, flags);
2818
2819
2820
2821
2822
2823
2824
2825
2826 if (!list_empty(&hw->ctlxq.active) ||
2827 test_bit(WORK_TX_HALT, &hw->usb_flags) || hw->wlandev->hwremoved)
2828 goto unlock;
2829
2830 while (!list_empty(&hw->ctlxq.pending)) {
2831 struct hfa384x_usbctlx *head;
2832 int result;
2833
2834
2835 head = list_entry(hw->ctlxq.pending.next,
2836 struct hfa384x_usbctlx, list);
2837
2838
2839 list_move_tail(&head->list, &hw->ctlxq.active);
2840
2841
2842 usb_fill_bulk_urb(&hw->ctlx_urb, hw->usb,
2843 hw->endp_out,
2844 &head->outbuf, ROUNDUP64(head->outbufsize),
2845 hfa384x_ctlxout_callback, hw);
2846 hw->ctlx_urb.transfer_flags |= USB_QUEUE_BULK;
2847
2848
2849 result = usb_submit_urb(&hw->ctlx_urb, GFP_ATOMIC);
2850 if (result == 0) {
2851
2852 head->state = CTLX_REQ_SUBMITTED;
2853
2854
2855 hw->req_timer_done = 0;
2856 hw->reqtimer.expires = jiffies + HZ;
2857 add_timer(&hw->reqtimer);
2858
2859
2860 hw->resp_timer_done = 0;
2861 hw->resptimer.expires = jiffies + 2 * HZ;
2862 add_timer(&hw->resptimer);
2863
2864 break;
2865 }
2866
2867 if (result == -EPIPE) {
2868
2869
2870
2871
2872 netdev_warn(hw->wlandev->netdev,
2873 "%s tx pipe stalled: requesting reset\n",
2874 hw->wlandev->netdev->name);
2875 list_move(&head->list, &hw->ctlxq.pending);
2876 set_bit(WORK_TX_HALT, &hw->usb_flags);
2877 schedule_work(&hw->usb_work);
2878 break;
2879 }
2880
2881 if (result == -ESHUTDOWN) {
2882 netdev_warn(hw->wlandev->netdev, "%s urb shutdown!\n",
2883 hw->wlandev->netdev->name);
2884 break;
2885 }
2886
2887 netdev_err(hw->wlandev->netdev, "Failed to submit CTLX[%d]: error=%d\n",
2888 le16_to_cpu(head->outbuf.type), result);
2889 unlocked_usbctlx_complete(hw, head);
2890 }
2891
2892 unlock:
2893 spin_unlock_irqrestore(&hw->ctlxq.lock, flags);
2894 }
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913 static void hfa384x_usbin_callback(struct urb *urb)
2914 {
2915 struct wlandevice *wlandev = urb->context;
2916 struct hfa384x *hw;
2917 union hfa384x_usbin *usbin;
2918 struct sk_buff *skb = NULL;
2919 int result;
2920 int urb_status;
2921 u16 type;
2922
2923 enum USBIN_ACTION {
2924 HANDLE,
2925 RESUBMIT,
2926 ABORT
2927 } action;
2928
2929 if (!wlandev || !wlandev->netdev || wlandev->hwremoved)
2930 goto exit;
2931
2932 hw = wlandev->priv;
2933 if (!hw)
2934 goto exit;
2935
2936 skb = hw->rx_urb_skb;
2937 if (!skb || (skb->data != urb->transfer_buffer)) {
2938 WARN_ON(1);
2939 return;
2940 }
2941
2942 hw->rx_urb_skb = NULL;
2943
2944
2945 switch (urb->status) {
2946 case 0:
2947 action = HANDLE;
2948
2949
2950 if (urb->actual_length == 0) {
2951 wlandev->netdev->stats.rx_errors++;
2952 wlandev->netdev->stats.rx_length_errors++;
2953 action = RESUBMIT;
2954 }
2955 break;
2956
2957 case -EPIPE:
2958 netdev_warn(hw->wlandev->netdev, "%s rx pipe stalled: requesting reset\n",
2959 wlandev->netdev->name);
2960 if (!test_and_set_bit(WORK_RX_HALT, &hw->usb_flags))
2961 schedule_work(&hw->usb_work);
2962 wlandev->netdev->stats.rx_errors++;
2963 action = ABORT;
2964 break;
2965
2966 case -EILSEQ:
2967 case -ETIMEDOUT:
2968 case -EPROTO:
2969 if (!test_and_set_bit(THROTTLE_RX, &hw->usb_flags) &&
2970 !timer_pending(&hw->throttle)) {
2971 mod_timer(&hw->throttle, jiffies + THROTTLE_JIFFIES);
2972 }
2973 wlandev->netdev->stats.rx_errors++;
2974 action = ABORT;
2975 break;
2976
2977 case -EOVERFLOW:
2978 wlandev->netdev->stats.rx_over_errors++;
2979 action = RESUBMIT;
2980 break;
2981
2982 case -ENODEV:
2983 case -ESHUTDOWN:
2984 pr_debug("status=%d, device removed.\n", urb->status);
2985 action = ABORT;
2986 break;
2987
2988 case -ENOENT:
2989 case -ECONNRESET:
2990 pr_debug("status=%d, urb explicitly unlinked.\n", urb->status);
2991 action = ABORT;
2992 break;
2993
2994 default:
2995 pr_debug("urb status=%d, transfer flags=0x%x\n",
2996 urb->status, urb->transfer_flags);
2997 wlandev->netdev->stats.rx_errors++;
2998 action = RESUBMIT;
2999 break;
3000 }
3001
3002
3003 urb_status = urb->status;
3004 usbin = (union hfa384x_usbin *)urb->transfer_buffer;
3005
3006 if (action != ABORT) {
3007
3008 result = submit_rx_urb(hw, GFP_ATOMIC);
3009
3010 if (result != 0) {
3011 netdev_err(hw->wlandev->netdev,
3012 "Fatal, failed to resubmit rx_urb. error=%d\n",
3013 result);
3014 }
3015 }
3016
3017
3018
3019
3020
3021 type = le16_to_cpu(usbin->type);
3022 if (HFA384x_USB_ISRXFRM(type)) {
3023 if (action == HANDLE) {
3024 if (usbin->txfrm.desc.sw_support == 0x0123) {
3025 hfa384x_usbin_txcompl(wlandev, usbin);
3026 } else {
3027 skb_put(skb, sizeof(*usbin));
3028 hfa384x_usbin_rx(wlandev, skb);
3029 skb = NULL;
3030 }
3031 }
3032 goto exit;
3033 }
3034 if (HFA384x_USB_ISTXFRM(type)) {
3035 if (action == HANDLE)
3036 hfa384x_usbin_txcompl(wlandev, usbin);
3037 goto exit;
3038 }
3039 switch (type) {
3040 case HFA384x_USB_INFOFRM:
3041 if (action == ABORT)
3042 goto exit;
3043 if (action == HANDLE)
3044 hfa384x_usbin_info(wlandev, usbin);
3045 break;
3046
3047 case HFA384x_USB_CMDRESP:
3048 case HFA384x_USB_WRIDRESP:
3049 case HFA384x_USB_RRIDRESP:
3050 case HFA384x_USB_WMEMRESP:
3051 case HFA384x_USB_RMEMRESP:
3052
3053 hfa384x_usbin_ctlx(hw, usbin, urb_status);
3054 break;
3055
3056 case HFA384x_USB_BUFAVAIL:
3057 pr_debug("Received BUFAVAIL packet, frmlen=%d\n",
3058 usbin->bufavail.frmlen);
3059 break;
3060
3061 case HFA384x_USB_ERROR:
3062 pr_debug("Received USB_ERROR packet, errortype=%d\n",
3063 usbin->usberror.errortype);
3064 break;
3065
3066 default:
3067 pr_debug("Unrecognized USBIN packet, type=%x, status=%d\n",
3068 usbin->type, urb_status);
3069 break;
3070 }
3071
3072 exit:
3073
3074 if (skb)
3075 dev_kfree_skb(skb);
3076 }
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099 static void hfa384x_usbin_ctlx(struct hfa384x *hw, union hfa384x_usbin *usbin,
3100 int urb_status)
3101 {
3102 struct hfa384x_usbctlx *ctlx;
3103 int run_queue = 0;
3104 unsigned long flags;
3105
3106 retry:
3107 spin_lock_irqsave(&hw->ctlxq.lock, flags);
3108
3109
3110
3111
3112
3113 if (list_empty(&hw->ctlxq.active))
3114 goto unlock;
3115
3116
3117
3118
3119
3120
3121
3122 if (del_timer(&hw->resptimer) == 0) {
3123 if (hw->resp_timer_done == 0) {
3124 spin_unlock_irqrestore(&hw->ctlxq.lock, flags);
3125 goto retry;
3126 }
3127 } else {
3128 hw->resp_timer_done = 1;
3129 }
3130
3131 ctlx = get_active_ctlx(hw);
3132
3133 if (urb_status != 0) {
3134
3135
3136
3137
3138
3139 if (unlocked_usbctlx_cancel_async(hw, ctlx) == 0)
3140 run_queue = 1;
3141 } else {
3142 const __le16 intype = (usbin->type & ~cpu_to_le16(0x8000));
3143
3144
3145
3146
3147 if (ctlx->outbuf.type != intype) {
3148 netdev_warn(hw->wlandev->netdev,
3149 "Expected IN[%d], received IN[%d] - ignored.\n",
3150 le16_to_cpu(ctlx->outbuf.type),
3151 le16_to_cpu(intype));
3152 goto unlock;
3153 }
3154
3155
3156 memcpy(&ctlx->inbuf, usbin, sizeof(ctlx->inbuf));
3157
3158 switch (ctlx->state) {
3159 case CTLX_REQ_SUBMITTED:
3160
3161
3162
3163
3164
3165 pr_debug("Causality violation: please reboot Universe\n");
3166 ctlx->state = CTLX_RESP_COMPLETE;
3167 break;
3168
3169 case CTLX_REQ_COMPLETE:
3170
3171
3172
3173
3174
3175 ctlx->state = CTLX_COMPLETE;
3176 unlocked_usbctlx_complete(hw, ctlx);
3177 run_queue = 1;
3178 break;
3179
3180 default:
3181
3182
3183
3184 netdev_err(hw->wlandev->netdev,
3185 "Matched IN URB, CTLX[%d] in invalid state(%s). Discarded.\n",
3186 le16_to_cpu(ctlx->outbuf.type),
3187 ctlxstr(ctlx->state));
3188 if (unlocked_usbctlx_cancel_async(hw, ctlx) == 0)
3189 run_queue = 1;
3190 break;
3191 }
3192 }
3193
3194 unlock:
3195 spin_unlock_irqrestore(&hw->ctlxq.lock, flags);
3196
3197 if (run_queue)
3198 hfa384x_usbctlxq_run(hw);
3199 }
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219 static void hfa384x_usbin_txcompl(struct wlandevice *wlandev,
3220 union hfa384x_usbin *usbin)
3221 {
3222 u16 status;
3223
3224 status = le16_to_cpu(usbin->type);
3225
3226
3227 if (HFA384x_TXSTATUS_ISERROR(status))
3228 prism2sta_ev_txexc(wlandev, status);
3229 else
3230 prism2sta_ev_tx(wlandev, status);
3231 }
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251 static void hfa384x_usbin_rx(struct wlandevice *wlandev, struct sk_buff *skb)
3252 {
3253 union hfa384x_usbin *usbin = (union hfa384x_usbin *)skb->data;
3254 struct hfa384x *hw = wlandev->priv;
3255 int hdrlen;
3256 struct p80211_rxmeta *rxmeta;
3257 u16 data_len;
3258 u16 fc;
3259
3260
3261 le16_to_cpus(&usbin->rxfrm.desc.status);
3262 le32_to_cpus(&usbin->rxfrm.desc.time);
3263
3264
3265 switch (HFA384x_RXSTATUS_MACPORT_GET(usbin->rxfrm.desc.status)) {
3266 case 0:
3267 fc = le16_to_cpu(usbin->rxfrm.desc.frame_control);
3268
3269
3270 if ((wlandev->hostwep & HOSTWEP_EXCLUDEUNENCRYPTED) &&
3271 !WLAN_GET_FC_ISWEP(fc)) {
3272 break;
3273 }
3274
3275 data_len = le16_to_cpu(usbin->rxfrm.desc.data_len);
3276
3277
3278 hdrlen = p80211_headerlen(fc);
3279
3280
3281 skb_pull(skb, sizeof(struct hfa384x_rx_frame));
3282
3283
3284
3285
3286 memmove(skb_push(skb, hdrlen),
3287 &usbin->rxfrm.desc.frame_control, hdrlen);
3288
3289 skb->dev = wlandev->netdev;
3290
3291
3292 skb_trim(skb, data_len + hdrlen);
3293
3294
3295 memset(skb_put(skb, WLAN_CRC_LEN), 0xff, WLAN_CRC_LEN);
3296
3297 skb_reset_mac_header(skb);
3298
3299
3300 p80211skb_rxmeta_attach(wlandev, skb);
3301 rxmeta = p80211skb_rxmeta(skb);
3302 rxmeta->mactime = usbin->rxfrm.desc.time;
3303 rxmeta->rxrate = usbin->rxfrm.desc.rate;
3304 rxmeta->signal = usbin->rxfrm.desc.signal - hw->dbmadjust;
3305 rxmeta->noise = usbin->rxfrm.desc.silence - hw->dbmadjust;
3306
3307 p80211netdev_rx(wlandev, skb);
3308
3309 break;
3310
3311 case 7:
3312 if (!HFA384x_RXSTATUS_ISFCSERR(usbin->rxfrm.desc.status)) {
3313
3314 hfa384x_int_rxmonitor(wlandev, &usbin->rxfrm);
3315 dev_kfree_skb(skb);
3316 } else {
3317 pr_debug("Received monitor frame: FCSerr set\n");
3318 }
3319 break;
3320
3321 default:
3322 netdev_warn(hw->wlandev->netdev, "Received frame on unsupported port=%d\n",
3323 HFA384x_RXSTATUS_MACPORT_GET(usbin->rxfrm.desc.status));
3324 break;
3325 }
3326 }
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350 static void hfa384x_int_rxmonitor(struct wlandevice *wlandev,
3351 struct hfa384x_usb_rxfrm *rxfrm)
3352 {
3353 struct hfa384x_rx_frame *rxdesc = &rxfrm->desc;
3354 unsigned int hdrlen = 0;
3355 unsigned int datalen = 0;
3356 unsigned int skblen = 0;
3357 u8 *datap;
3358 u16 fc;
3359 struct sk_buff *skb;
3360 struct hfa384x *hw = wlandev->priv;
3361
3362
3363
3364 fc = le16_to_cpu(rxdesc->frame_control);
3365 hdrlen = p80211_headerlen(fc);
3366 datalen = le16_to_cpu(rxdesc->data_len);
3367
3368
3369 skblen = sizeof(struct p80211_caphdr) + hdrlen + datalen + WLAN_CRC_LEN;
3370
3371
3372 if (skblen >
3373 (sizeof(struct p80211_caphdr) +
3374 WLAN_HDR_A4_LEN + WLAN_DATA_MAXLEN + WLAN_CRC_LEN)) {
3375 pr_debug("overlen frm: len=%zd\n",
3376 skblen - sizeof(struct p80211_caphdr));
3377
3378 return;
3379 }
3380
3381 skb = dev_alloc_skb(skblen);
3382 if (!skb)
3383 return;
3384
3385
3386 if ((wlandev->netdev->type == ARPHRD_IEEE80211_PRISM) &&
3387 (hw->sniffhdr != 0)) {
3388 struct p80211_caphdr *caphdr;
3389
3390 datap = skb_put(skb, sizeof(struct p80211_caphdr));
3391 caphdr = (struct p80211_caphdr *)datap;
3392
3393 caphdr->version = htonl(P80211CAPTURE_VERSION);
3394 caphdr->length = htonl(sizeof(struct p80211_caphdr));
3395 caphdr->mactime = __cpu_to_be64(rxdesc->time * 1000);
3396 caphdr->hosttime = __cpu_to_be64(jiffies);
3397 caphdr->phytype = htonl(4);
3398 caphdr->channel = htonl(hw->sniff_channel);
3399 caphdr->datarate = htonl(rxdesc->rate);
3400 caphdr->antenna = htonl(0);
3401 caphdr->priority = htonl(0);
3402 caphdr->ssi_type = htonl(3);
3403 caphdr->ssi_signal = htonl(rxdesc->signal);
3404 caphdr->ssi_noise = htonl(rxdesc->silence);
3405 caphdr->preamble = htonl(0);
3406 caphdr->encoding = htonl(1);
3407 }
3408
3409
3410
3411
3412 skb_put_data(skb, &rxdesc->frame_control, hdrlen);
3413
3414
3415 if (datalen > 0) {
3416 datap = skb_put_data(skb, rxfrm->data, datalen);
3417
3418
3419 if (*(datap - hdrlen + 1) & 0x40)
3420 if ((*(datap) == 0xaa) && (*(datap + 1) == 0xaa))
3421
3422 *(datap - hdrlen + 1) &= 0xbf;
3423 }
3424
3425 if (hw->sniff_fcs) {
3426
3427 datap = skb_put(skb, WLAN_CRC_LEN);
3428 memset(datap, 0xff, WLAN_CRC_LEN);
3429 }
3430
3431
3432 p80211netdev_rx(wlandev, skb);
3433 }
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453 static void hfa384x_usbin_info(struct wlandevice *wlandev,
3454 union hfa384x_usbin *usbin)
3455 {
3456 le16_to_cpus(&usbin->infofrm.info.framelen);
3457 prism2sta_ev_info(wlandev, &usbin->infofrm.info);
3458 }
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477 static void hfa384x_usbout_callback(struct urb *urb)
3478 {
3479 struct wlandevice *wlandev = urb->context;
3480
3481 #ifdef DEBUG_USB
3482 dbprint_urb(urb);
3483 #endif
3484
3485 if (wlandev && wlandev->netdev) {
3486 switch (urb->status) {
3487 case 0:
3488 prism2sta_ev_alloc(wlandev);
3489 break;
3490
3491 case -EPIPE: {
3492 struct hfa384x *hw = wlandev->priv;
3493
3494 netdev_warn(hw->wlandev->netdev,
3495 "%s tx pipe stalled: requesting reset\n",
3496 wlandev->netdev->name);
3497 if (!test_and_set_bit(WORK_TX_HALT, &hw->usb_flags))
3498 schedule_work(&hw->usb_work);
3499 wlandev->netdev->stats.tx_errors++;
3500 break;
3501 }
3502
3503 case -EPROTO:
3504 case -ETIMEDOUT:
3505 case -EILSEQ: {
3506 struct hfa384x *hw = wlandev->priv;
3507
3508 if (!test_and_set_bit(THROTTLE_TX, &hw->usb_flags) &&
3509 !timer_pending(&hw->throttle)) {
3510 mod_timer(&hw->throttle,
3511 jiffies + THROTTLE_JIFFIES);
3512 }
3513 wlandev->netdev->stats.tx_errors++;
3514 netif_stop_queue(wlandev->netdev);
3515 break;
3516 }
3517
3518 case -ENOENT:
3519 case -ESHUTDOWN:
3520
3521 break;
3522
3523 default:
3524 netdev_info(wlandev->netdev, "unknown urb->status=%d\n",
3525 urb->status);
3526 wlandev->netdev->stats.tx_errors++;
3527 break;
3528 }
3529 }
3530 }
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549 static void hfa384x_ctlxout_callback(struct urb *urb)
3550 {
3551 struct hfa384x *hw = urb->context;
3552 int delete_resptimer = 0;
3553 int timer_ok = 1;
3554 int run_queue = 0;
3555 struct hfa384x_usbctlx *ctlx;
3556 unsigned long flags;
3557
3558 pr_debug("urb->status=%d\n", urb->status);
3559 #ifdef DEBUG_USB
3560 dbprint_urb(urb);
3561 #endif
3562 if ((urb->status == -ESHUTDOWN) ||
3563 (urb->status == -ENODEV) || !hw)
3564 return;
3565
3566 retry:
3567 spin_lock_irqsave(&hw->ctlxq.lock, flags);
3568
3569
3570
3571
3572
3573
3574
3575 if (list_empty(&hw->ctlxq.active)) {
3576 spin_unlock_irqrestore(&hw->ctlxq.lock, flags);
3577 return;
3578 }
3579
3580
3581
3582
3583
3584 if (del_timer(&hw->reqtimer) == 0) {
3585 if (hw->req_timer_done == 0) {
3586
3587
3588
3589
3590
3591 spin_unlock_irqrestore(&hw->ctlxq.lock, flags);
3592 goto retry;
3593 }
3594 } else {
3595 hw->req_timer_done = 1;
3596 }
3597
3598 ctlx = get_active_ctlx(hw);
3599
3600 if (urb->status == 0) {
3601
3602 switch (ctlx->state) {
3603 case CTLX_REQ_SUBMITTED:
3604
3605 ctlx->state = CTLX_REQ_COMPLETE;
3606 break;
3607
3608 case CTLX_RESP_COMPLETE:
3609
3610
3611
3612 ctlx->state = CTLX_COMPLETE;
3613 unlocked_usbctlx_complete(hw, ctlx);
3614 run_queue = 1;
3615 break;
3616
3617 default:
3618
3619 netdev_err(hw->wlandev->netdev,
3620 "Illegal CTLX[%d] success state(%s, %d) in OUT URB\n",
3621 le16_to_cpu(ctlx->outbuf.type),
3622 ctlxstr(ctlx->state), urb->status);
3623 break;
3624 }
3625 } else {
3626
3627 if ((urb->status == -EPIPE) &&
3628 !test_and_set_bit(WORK_TX_HALT, &hw->usb_flags)) {
3629 netdev_warn(hw->wlandev->netdev,
3630 "%s tx pipe stalled: requesting reset\n",
3631 hw->wlandev->netdev->name);
3632 schedule_work(&hw->usb_work);
3633 }
3634
3635
3636
3637
3638 ctlx->state = CTLX_REQ_FAILED;
3639 unlocked_usbctlx_complete(hw, ctlx);
3640 delete_resptimer = 1;
3641 run_queue = 1;
3642 }
3643
3644 delresp:
3645 if (delete_resptimer) {
3646 timer_ok = del_timer(&hw->resptimer);
3647 if (timer_ok != 0)
3648 hw->resp_timer_done = 1;
3649 }
3650
3651 spin_unlock_irqrestore(&hw->ctlxq.lock, flags);
3652
3653 if (!timer_ok && (hw->resp_timer_done == 0)) {
3654 spin_lock_irqsave(&hw->ctlxq.lock, flags);
3655 goto delresp;
3656 }
3657
3658 if (run_queue)
3659 hfa384x_usbctlxq_run(hw);
3660 }
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681 static void hfa384x_usbctlx_reqtimerfn(struct timer_list *t)
3682 {
3683 struct hfa384x *hw = from_timer(hw, t, reqtimer);
3684 unsigned long flags;
3685
3686 spin_lock_irqsave(&hw->ctlxq.lock, flags);
3687
3688 hw->req_timer_done = 1;
3689
3690
3691
3692
3693 if (!list_empty(&hw->ctlxq.active)) {
3694
3695
3696
3697
3698 hw->ctlx_urb.transfer_flags |= URB_ASYNC_UNLINK;
3699 if (usb_unlink_urb(&hw->ctlx_urb) == -EINPROGRESS) {
3700 struct hfa384x_usbctlx *ctlx = get_active_ctlx(hw);
3701
3702 ctlx->state = CTLX_REQ_FAILED;
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713 if (del_timer(&hw->resptimer) != 0)
3714 hw->resp_timer_done = 1;
3715 }
3716 }
3717
3718 spin_unlock_irqrestore(&hw->ctlxq.lock, flags);
3719 }
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740 static void hfa384x_usbctlx_resptimerfn(struct timer_list *t)
3741 {
3742 struct hfa384x *hw = from_timer(hw, t, resptimer);
3743 unsigned long flags;
3744
3745 spin_lock_irqsave(&hw->ctlxq.lock, flags);
3746
3747 hw->resp_timer_done = 1;
3748
3749
3750
3751
3752 if (!list_empty(&hw->ctlxq.active)) {
3753 struct hfa384x_usbctlx *ctlx = get_active_ctlx(hw);
3754
3755 if (unlocked_usbctlx_cancel_async(hw, ctlx) == 0) {
3756 spin_unlock_irqrestore(&hw->ctlxq.lock, flags);
3757 hfa384x_usbctlxq_run(hw);
3758 return;
3759 }
3760 }
3761 spin_unlock_irqrestore(&hw->ctlxq.lock, flags);
3762 }
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780 static void hfa384x_usb_throttlefn(struct timer_list *t)
3781 {
3782 struct hfa384x *hw = from_timer(hw, t, throttle);
3783 unsigned long flags;
3784
3785 spin_lock_irqsave(&hw->ctlxq.lock, flags);
3786
3787
3788
3789
3790
3791 pr_debug("flags=0x%lx\n", hw->usb_flags);
3792 if (!hw->wlandev->hwremoved &&
3793 ((test_and_clear_bit(THROTTLE_RX, &hw->usb_flags) &&
3794 !test_and_set_bit(WORK_RX_RESUME, &hw->usb_flags)) |
3795 (test_and_clear_bit(THROTTLE_TX, &hw->usb_flags) &&
3796 !test_and_set_bit(WORK_TX_RESUME, &hw->usb_flags))
3797 )) {
3798 schedule_work(&hw->usb_work);
3799 }
3800
3801 spin_unlock_irqrestore(&hw->ctlxq.lock, flags);
3802 }
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823 static int hfa384x_usbctlx_submit(struct hfa384x *hw,
3824 struct hfa384x_usbctlx *ctlx)
3825 {
3826 unsigned long flags;
3827
3828 spin_lock_irqsave(&hw->ctlxq.lock, flags);
3829
3830 if (hw->wlandev->hwremoved) {
3831 spin_unlock_irqrestore(&hw->ctlxq.lock, flags);
3832 return -ENODEV;
3833 }
3834
3835 ctlx->state = CTLX_PENDING;
3836 list_add_tail(&ctlx->list, &hw->ctlxq.pending);
3837 spin_unlock_irqrestore(&hw->ctlxq.lock, flags);
3838 hfa384x_usbctlxq_run(hw);
3839
3840 return 0;
3841 }
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860 static int hfa384x_isgood_pdrcode(u16 pdrcode)
3861 {
3862 switch (pdrcode) {
3863 case HFA384x_PDR_END_OF_PDA:
3864 case HFA384x_PDR_PCB_PARTNUM:
3865 case HFA384x_PDR_PDAVER:
3866 case HFA384x_PDR_NIC_SERIAL:
3867 case HFA384x_PDR_MKK_MEASUREMENTS:
3868 case HFA384x_PDR_NIC_RAMSIZE:
3869 case HFA384x_PDR_MFISUPRANGE:
3870 case HFA384x_PDR_CFISUPRANGE:
3871 case HFA384x_PDR_NICID:
3872 case HFA384x_PDR_MAC_ADDRESS:
3873 case HFA384x_PDR_REGDOMAIN:
3874 case HFA384x_PDR_ALLOWED_CHANNEL:
3875 case HFA384x_PDR_DEFAULT_CHANNEL:
3876 case HFA384x_PDR_TEMPTYPE:
3877 case HFA384x_PDR_IFR_SETTING:
3878 case HFA384x_PDR_RFR_SETTING:
3879 case HFA384x_PDR_HFA3861_BASELINE:
3880 case HFA384x_PDR_HFA3861_SHADOW:
3881 case HFA384x_PDR_HFA3861_IFRF:
3882 case HFA384x_PDR_HFA3861_CHCALSP:
3883 case HFA384x_PDR_HFA3861_CHCALI:
3884 case HFA384x_PDR_3842_NIC_CONFIG:
3885 case HFA384x_PDR_USB_ID:
3886 case HFA384x_PDR_PCI_ID:
3887 case HFA384x_PDR_PCI_IFCONF:
3888 case HFA384x_PDR_PCI_PMCONF:
3889 case HFA384x_PDR_RFENRGY:
3890 case HFA384x_PDR_HFA3861_MANF_TESTSP:
3891 case HFA384x_PDR_HFA3861_MANF_TESTI:
3892
3893 return 1;
3894 default:
3895 if (pdrcode < 0x1000) {
3896
3897 pr_debug("Encountered unknown PDR#=0x%04x, assuming it's ok.\n",
3898 pdrcode);
3899 return 1;
3900 }
3901 break;
3902 }
3903
3904 pr_debug("Encountered unknown PDR#=0x%04x, (>=0x1000), assuming it's bad.\n",
3905 pdrcode);
3906 return 0;
3907 }