0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083
0084
0085
0086
0087
0088
0089
0090
0091
0092
0093
0094
0095
0096
0097
0098
0099
0100
0101
0102
0103
0104
0105
0106
0107
0108
0109
0110
0111
0112
0113
0114 #include <linux/module.h>
0115 #include <linux/kernel.h>
0116 #include <linux/sched.h>
0117 #include <linux/types.h>
0118 #include <linux/slab.h>
0119 #include <linux/wireless.h>
0120 #include <linux/netdevice.h>
0121 #include <linux/timer.h>
0122 #include <linux/io.h>
0123 #include <linux/delay.h>
0124 #include <asm/byteorder.h>
0125 #include <linux/bitops.h>
0126 #include <linux/list.h>
0127 #include <linux/usb.h>
0128 #include <linux/byteorder/generic.h>
0129
0130 #include "p80211types.h"
0131 #include "p80211hdr.h"
0132 #include "p80211mgmt.h"
0133 #include "p80211conv.h"
0134 #include "p80211msg.h"
0135 #include "p80211netdev.h"
0136 #include "p80211req.h"
0137 #include "p80211metadef.h"
0138 #include "p80211metastruct.h"
0139 #include "hfa384x.h"
0140 #include "prism2mgmt.h"
0141
0142 enum cmd_mode {
0143 DOWAIT = 0,
0144 DOASYNC
0145 };
0146
0147 #define THROTTLE_JIFFIES (HZ / 8)
0148 #define URB_ASYNC_UNLINK 0
0149 #define USB_QUEUE_BULK 0
0150
0151 #define ROUNDUP64(a) (((a) + 63) & ~63)
0152
0153 #ifdef DEBUG_USB
0154 static void dbprint_urb(struct urb *urb);
0155 #endif
0156
0157 static void hfa384x_int_rxmonitor(struct wlandevice *wlandev,
0158 struct hfa384x_usb_rxfrm *rxfrm);
0159
0160 static void hfa384x_usb_defer(struct work_struct *data);
0161
0162 static int submit_rx_urb(struct hfa384x *hw, gfp_t flags);
0163
0164 static int submit_tx_urb(struct hfa384x *hw, struct urb *tx_urb, gfp_t flags);
0165
0166
0167
0168 static void hfa384x_usbout_callback(struct urb *urb);
0169 static void hfa384x_ctlxout_callback(struct urb *urb);
0170 static void hfa384x_usbin_callback(struct urb *urb);
0171
0172 static void
0173 hfa384x_usbin_txcompl(struct wlandevice *wlandev, union hfa384x_usbin *usbin);
0174
0175 static void hfa384x_usbin_rx(struct wlandevice *wlandev, struct sk_buff *skb);
0176
0177 static void hfa384x_usbin_info(struct wlandevice *wlandev,
0178 union hfa384x_usbin *usbin);
0179
0180 static void hfa384x_usbin_ctlx(struct hfa384x *hw, union hfa384x_usbin *usbin,
0181 int urb_status);
0182
0183
0184
0185
0186 static void hfa384x_usbctlxq_run(struct hfa384x *hw);
0187
0188 static void hfa384x_usbctlx_reqtimerfn(struct timer_list *t);
0189
0190 static void hfa384x_usbctlx_resptimerfn(struct timer_list *t);
0191
0192 static void hfa384x_usb_throttlefn(struct timer_list *t);
0193
0194 static void hfa384x_usbctlx_completion_task(struct work_struct *work);
0195
0196 static void hfa384x_usbctlx_reaper_task(struct work_struct *work);
0197
0198 static int hfa384x_usbctlx_submit(struct hfa384x *hw,
0199 struct hfa384x_usbctlx *ctlx);
0200
0201 static void unlocked_usbctlx_complete(struct hfa384x *hw,
0202 struct hfa384x_usbctlx *ctlx);
0203
0204 struct usbctlx_completor {
0205 int (*complete)(struct usbctlx_completor *completor);
0206 };
0207
0208 static int
0209 hfa384x_usbctlx_complete_sync(struct hfa384x *hw,
0210 struct hfa384x_usbctlx *ctlx,
0211 struct usbctlx_completor *completor);
0212
0213 static int
0214 unlocked_usbctlx_cancel_async(struct hfa384x *hw, struct hfa384x_usbctlx *ctlx);
0215
0216 static void hfa384x_cb_status(struct hfa384x *hw,
0217 const struct hfa384x_usbctlx *ctlx);
0218
0219 static int
0220 usbctlx_get_status(const struct hfa384x_usb_statusresp *cmdresp,
0221 struct hfa384x_cmdresult *result);
0222
0223 static void
0224 usbctlx_get_rridresult(const struct hfa384x_usb_rridresp *rridresp,
0225 struct hfa384x_rridresult *result);
0226
0227
0228
0229 static inline int
0230 hfa384x_docmd(struct hfa384x *hw,
0231 struct hfa384x_metacmd *cmd);
0232
0233 static int
0234 hfa384x_dorrid(struct hfa384x *hw,
0235 enum cmd_mode mode,
0236 u16 rid,
0237 void *riddata,
0238 unsigned int riddatalen,
0239 ctlx_cmdcb_t cmdcb, ctlx_usercb_t usercb, void *usercb_data);
0240
0241 static int
0242 hfa384x_dowrid(struct hfa384x *hw,
0243 enum cmd_mode mode,
0244 u16 rid,
0245 void *riddata,
0246 unsigned int riddatalen,
0247 ctlx_cmdcb_t cmdcb, ctlx_usercb_t usercb, void *usercb_data);
0248
0249 static int
0250 hfa384x_dormem(struct hfa384x *hw,
0251 u16 page,
0252 u16 offset,
0253 void *data,
0254 unsigned int len);
0255
0256 static int
0257 hfa384x_dowmem(struct hfa384x *hw,
0258 u16 page,
0259 u16 offset,
0260 void *data,
0261 unsigned int len);
0262
0263 static int hfa384x_isgood_pdrcode(u16 pdrcode);
0264
0265 static inline const char *ctlxstr(enum ctlx_state s)
0266 {
0267 static const char * const ctlx_str[] = {
0268 "Initial state",
0269 "Complete",
0270 "Request failed",
0271 "Request pending",
0272 "Request packet submitted",
0273 "Request packet completed",
0274 "Response packet completed"
0275 };
0276
0277 return ctlx_str[s];
0278 };
0279
0280 static inline struct hfa384x_usbctlx *get_active_ctlx(struct hfa384x *hw)
0281 {
0282 return list_entry(hw->ctlxq.active.next, struct hfa384x_usbctlx, list);
0283 }
0284
0285 #ifdef DEBUG_USB
0286 void dbprint_urb(struct urb *urb)
0287 {
0288 pr_debug("urb->pipe=0x%08x\n", urb->pipe);
0289 pr_debug("urb->status=0x%08x\n", urb->status);
0290 pr_debug("urb->transfer_flags=0x%08x\n", urb->transfer_flags);
0291 pr_debug("urb->transfer_buffer=0x%08x\n",
0292 (unsigned int)urb->transfer_buffer);
0293 pr_debug("urb->transfer_buffer_length=0x%08x\n",
0294 urb->transfer_buffer_length);
0295 pr_debug("urb->actual_length=0x%08x\n", urb->actual_length);
0296 pr_debug("urb->setup_packet(ctl)=0x%08x\n",
0297 (unsigned int)urb->setup_packet);
0298 pr_debug("urb->start_frame(iso/irq)=0x%08x\n", urb->start_frame);
0299 pr_debug("urb->interval(irq)=0x%08x\n", urb->interval);
0300 pr_debug("urb->error_count(iso)=0x%08x\n", urb->error_count);
0301 pr_debug("urb->context=0x%08x\n", (unsigned int)urb->context);
0302 pr_debug("urb->complete=0x%08x\n", (unsigned int)urb->complete);
0303 }
0304 #endif
0305
0306
0307
0308
0309
0310
0311
0312
0313
0314
0315
0316
0317
0318
0319
0320
0321
0322
0323 static int submit_rx_urb(struct hfa384x *hw, gfp_t memflags)
0324 {
0325 struct sk_buff *skb;
0326 int result;
0327
0328 skb = dev_alloc_skb(sizeof(union hfa384x_usbin));
0329 if (!skb) {
0330 result = -ENOMEM;
0331 goto done;
0332 }
0333
0334
0335 usb_fill_bulk_urb(&hw->rx_urb, hw->usb,
0336 hw->endp_in,
0337 skb->data, sizeof(union hfa384x_usbin),
0338 hfa384x_usbin_callback, hw->wlandev);
0339
0340 hw->rx_urb_skb = skb;
0341
0342 result = -ENOLINK;
0343 if (!hw->wlandev->hwremoved &&
0344 !test_bit(WORK_RX_HALT, &hw->usb_flags)) {
0345 result = usb_submit_urb(&hw->rx_urb, memflags);
0346
0347
0348 if (result == -EPIPE) {
0349 netdev_warn(hw->wlandev->netdev,
0350 "%s rx pipe stalled: requesting reset\n",
0351 hw->wlandev->netdev->name);
0352 if (!test_and_set_bit(WORK_RX_HALT, &hw->usb_flags))
0353 schedule_work(&hw->usb_work);
0354 }
0355 }
0356
0357
0358 if (result != 0) {
0359 dev_kfree_skb(skb);
0360 hw->rx_urb_skb = NULL;
0361 }
0362
0363 done:
0364 return result;
0365 }
0366
0367
0368
0369
0370
0371
0372
0373
0374
0375
0376
0377
0378
0379
0380
0381
0382
0383
0384
0385
0386 static int submit_tx_urb(struct hfa384x *hw, struct urb *tx_urb, gfp_t memflags)
0387 {
0388 struct net_device *netdev = hw->wlandev->netdev;
0389 int result;
0390
0391 result = -ENOLINK;
0392 if (netif_running(netdev)) {
0393 if (!hw->wlandev->hwremoved &&
0394 !test_bit(WORK_TX_HALT, &hw->usb_flags)) {
0395 result = usb_submit_urb(tx_urb, memflags);
0396
0397
0398 if (result == -EPIPE) {
0399 netdev_warn(hw->wlandev->netdev,
0400 "%s tx pipe stalled: requesting reset\n",
0401 netdev->name);
0402 set_bit(WORK_TX_HALT, &hw->usb_flags);
0403 schedule_work(&hw->usb_work);
0404 } else if (result == 0) {
0405 netif_stop_queue(netdev);
0406 }
0407 }
0408 }
0409
0410 return result;
0411 }
0412
0413
0414
0415
0416
0417
0418
0419
0420
0421
0422
0423
0424
0425
0426
0427
0428
0429
0430 static void hfa384x_usb_defer(struct work_struct *data)
0431 {
0432 struct hfa384x *hw = container_of(data, struct hfa384x, usb_work);
0433 struct net_device *netdev = hw->wlandev->netdev;
0434
0435
0436
0437
0438 if (hw->wlandev->hwremoved)
0439 return;
0440
0441
0442 if (test_bit(WORK_RX_HALT, &hw->usb_flags)) {
0443 int ret;
0444
0445 usb_kill_urb(&hw->rx_urb);
0446
0447 ret = usb_clear_halt(hw->usb, hw->endp_in);
0448 if (ret != 0) {
0449 netdev_err(hw->wlandev->netdev,
0450 "Failed to clear rx pipe for %s: err=%d\n",
0451 netdev->name, ret);
0452 } else {
0453 netdev_info(hw->wlandev->netdev, "%s rx pipe reset complete.\n",
0454 netdev->name);
0455 clear_bit(WORK_RX_HALT, &hw->usb_flags);
0456 set_bit(WORK_RX_RESUME, &hw->usb_flags);
0457 }
0458 }
0459
0460
0461 if (test_bit(WORK_RX_RESUME, &hw->usb_flags)) {
0462 int ret;
0463
0464 ret = submit_rx_urb(hw, GFP_KERNEL);
0465 if (ret != 0) {
0466 netdev_err(hw->wlandev->netdev,
0467 "Failed to resume %s rx pipe.\n",
0468 netdev->name);
0469 } else {
0470 clear_bit(WORK_RX_RESUME, &hw->usb_flags);
0471 }
0472 }
0473
0474
0475 if (test_bit(WORK_TX_HALT, &hw->usb_flags)) {
0476 int ret;
0477
0478 usb_kill_urb(&hw->tx_urb);
0479 ret = usb_clear_halt(hw->usb, hw->endp_out);
0480 if (ret != 0) {
0481 netdev_err(hw->wlandev->netdev,
0482 "Failed to clear tx pipe for %s: err=%d\n",
0483 netdev->name, ret);
0484 } else {
0485 netdev_info(hw->wlandev->netdev, "%s tx pipe reset complete.\n",
0486 netdev->name);
0487 clear_bit(WORK_TX_HALT, &hw->usb_flags);
0488 set_bit(WORK_TX_RESUME, &hw->usb_flags);
0489
0490
0491
0492
0493
0494 hfa384x_usbctlxq_run(hw);
0495 }
0496 }
0497
0498
0499 if (test_and_clear_bit(WORK_TX_RESUME, &hw->usb_flags))
0500 netif_wake_queue(hw->wlandev->netdev);
0501 }
0502
0503
0504
0505
0506
0507
0508
0509
0510
0511
0512
0513
0514
0515
0516
0517
0518
0519
0520
0521
0522
0523
0524
0525 void hfa384x_create(struct hfa384x *hw, struct usb_device *usb)
0526 {
0527 hw->usb = usb;
0528
0529
0530 init_waitqueue_head(&hw->cmdq);
0531
0532
0533 spin_lock_init(&hw->ctlxq.lock);
0534 INIT_LIST_HEAD(&hw->ctlxq.pending);
0535 INIT_LIST_HEAD(&hw->ctlxq.active);
0536 INIT_LIST_HEAD(&hw->ctlxq.completing);
0537 INIT_LIST_HEAD(&hw->ctlxq.reapable);
0538
0539
0540 skb_queue_head_init(&hw->authq);
0541
0542 INIT_WORK(&hw->reaper_bh, hfa384x_usbctlx_reaper_task);
0543 INIT_WORK(&hw->completion_bh, hfa384x_usbctlx_completion_task);
0544 INIT_WORK(&hw->link_bh, prism2sta_processing_defer);
0545 INIT_WORK(&hw->usb_work, hfa384x_usb_defer);
0546
0547 timer_setup(&hw->throttle, hfa384x_usb_throttlefn, 0);
0548
0549 timer_setup(&hw->resptimer, hfa384x_usbctlx_resptimerfn, 0);
0550
0551 timer_setup(&hw->reqtimer, hfa384x_usbctlx_reqtimerfn, 0);
0552
0553 usb_init_urb(&hw->rx_urb);
0554 usb_init_urb(&hw->tx_urb);
0555 usb_init_urb(&hw->ctlx_urb);
0556
0557 hw->link_status = HFA384x_LINK_NOTCONNECTED;
0558 hw->state = HFA384x_STATE_INIT;
0559
0560 INIT_WORK(&hw->commsqual_bh, prism2sta_commsqual_defer);
0561 timer_setup(&hw->commsqual_timer, prism2sta_commsqual_timer, 0);
0562 }
0563
0564
0565
0566
0567
0568
0569
0570
0571
0572
0573
0574
0575
0576
0577
0578
0579
0580
0581
0582
0583
0584
0585
0586
0587 void hfa384x_destroy(struct hfa384x *hw)
0588 {
0589 struct sk_buff *skb;
0590
0591 if (hw->state == HFA384x_STATE_RUNNING)
0592 hfa384x_drvr_stop(hw);
0593 hw->state = HFA384x_STATE_PREINIT;
0594
0595 kfree(hw->scanresults);
0596 hw->scanresults = NULL;
0597
0598
0599 while ((skb = skb_dequeue(&hw->authq)))
0600 dev_kfree_skb(skb);
0601 }
0602
0603 static struct hfa384x_usbctlx *usbctlx_alloc(void)
0604 {
0605 struct hfa384x_usbctlx *ctlx;
0606
0607 ctlx = kzalloc(sizeof(*ctlx),
0608 in_interrupt() ? GFP_ATOMIC : GFP_KERNEL);
0609 if (ctlx)
0610 init_completion(&ctlx->done);
0611
0612 return ctlx;
0613 }
0614
0615 static int
0616 usbctlx_get_status(const struct hfa384x_usb_statusresp *cmdresp,
0617 struct hfa384x_cmdresult *result)
0618 {
0619 result->status = le16_to_cpu(cmdresp->status);
0620 result->resp0 = le16_to_cpu(cmdresp->resp0);
0621 result->resp1 = le16_to_cpu(cmdresp->resp1);
0622 result->resp2 = le16_to_cpu(cmdresp->resp2);
0623
0624 pr_debug("cmdresult:status=0x%04x resp0=0x%04x resp1=0x%04x resp2=0x%04x\n",
0625 result->status, result->resp0, result->resp1, result->resp2);
0626
0627 return result->status & HFA384x_STATUS_RESULT;
0628 }
0629
0630 static void
0631 usbctlx_get_rridresult(const struct hfa384x_usb_rridresp *rridresp,
0632 struct hfa384x_rridresult *result)
0633 {
0634 result->rid = le16_to_cpu(rridresp->rid);
0635 result->riddata = rridresp->data;
0636 result->riddata_len = ((le16_to_cpu(rridresp->frmlen) - 1) * 2);
0637 }
0638
0639
0640
0641
0642
0643
0644
0645 struct usbctlx_cmd_completor {
0646 struct usbctlx_completor head;
0647
0648 const struct hfa384x_usb_statusresp *cmdresp;
0649 struct hfa384x_cmdresult *result;
0650 };
0651
0652 static inline int usbctlx_cmd_completor_fn(struct usbctlx_completor *head)
0653 {
0654 struct usbctlx_cmd_completor *complete;
0655
0656 complete = (struct usbctlx_cmd_completor *)head;
0657 return usbctlx_get_status(complete->cmdresp, complete->result);
0658 }
0659
0660 static inline struct usbctlx_completor *
0661 init_cmd_completor(struct usbctlx_cmd_completor *completor,
0662 const struct hfa384x_usb_statusresp *cmdresp,
0663 struct hfa384x_cmdresult *result)
0664 {
0665 completor->head.complete = usbctlx_cmd_completor_fn;
0666 completor->cmdresp = cmdresp;
0667 completor->result = result;
0668 return &completor->head;
0669 }
0670
0671
0672
0673
0674
0675
0676
0677 struct usbctlx_rrid_completor {
0678 struct usbctlx_completor head;
0679
0680 const struct hfa384x_usb_rridresp *rridresp;
0681 void *riddata;
0682 unsigned int riddatalen;
0683 };
0684
0685 static int usbctlx_rrid_completor_fn(struct usbctlx_completor *head)
0686 {
0687 struct usbctlx_rrid_completor *complete;
0688 struct hfa384x_rridresult rridresult;
0689
0690 complete = (struct usbctlx_rrid_completor *)head;
0691 usbctlx_get_rridresult(complete->rridresp, &rridresult);
0692
0693
0694 if (rridresult.riddata_len != complete->riddatalen) {
0695 pr_warn("RID len mismatch, rid=0x%04x hlen=%d fwlen=%d\n",
0696 rridresult.rid,
0697 complete->riddatalen, rridresult.riddata_len);
0698 return -ENODATA;
0699 }
0700
0701 memcpy(complete->riddata, rridresult.riddata, complete->riddatalen);
0702 return 0;
0703 }
0704
0705 static inline struct usbctlx_completor *
0706 init_rrid_completor(struct usbctlx_rrid_completor *completor,
0707 const struct hfa384x_usb_rridresp *rridresp,
0708 void *riddata,
0709 unsigned int riddatalen)
0710 {
0711 completor->head.complete = usbctlx_rrid_completor_fn;
0712 completor->rridresp = rridresp;
0713 completor->riddata = riddata;
0714 completor->riddatalen = riddatalen;
0715 return &completor->head;
0716 }
0717
0718
0719
0720
0721
0722
0723 #define init_wrid_completor init_cmd_completor
0724
0725
0726
0727
0728
0729
0730 #define init_wmem_completor init_cmd_completor
0731
0732
0733
0734
0735
0736
0737 struct usbctlx_rmem_completor {
0738 struct usbctlx_completor head;
0739
0740 const struct hfa384x_usb_rmemresp *rmemresp;
0741 void *data;
0742 unsigned int len;
0743 };
0744
0745 static int usbctlx_rmem_completor_fn(struct usbctlx_completor *head)
0746 {
0747 struct usbctlx_rmem_completor *complete =
0748 (struct usbctlx_rmem_completor *)head;
0749
0750 pr_debug("rmemresp:len=%d\n", complete->rmemresp->frmlen);
0751 memcpy(complete->data, complete->rmemresp->data, complete->len);
0752 return 0;
0753 }
0754
0755 static inline struct usbctlx_completor *
0756 init_rmem_completor(struct usbctlx_rmem_completor *completor,
0757 struct hfa384x_usb_rmemresp *rmemresp,
0758 void *data,
0759 unsigned int len)
0760 {
0761 completor->head.complete = usbctlx_rmem_completor_fn;
0762 completor->rmemresp = rmemresp;
0763 completor->data = data;
0764 completor->len = len;
0765 return &completor->head;
0766 }
0767
0768
0769
0770
0771
0772
0773
0774
0775
0776
0777
0778
0779
0780
0781
0782
0783
0784
0785
0786
0787
0788
0789
0790 static void hfa384x_cb_status(struct hfa384x *hw,
0791 const struct hfa384x_usbctlx *ctlx)
0792 {
0793 if (ctlx->usercb) {
0794 struct hfa384x_cmdresult cmdresult;
0795
0796 if (ctlx->state != CTLX_COMPLETE) {
0797 memset(&cmdresult, 0, sizeof(cmdresult));
0798 cmdresult.status =
0799 HFA384x_STATUS_RESULT_SET(HFA384x_CMD_ERR);
0800 } else {
0801 usbctlx_get_status(&ctlx->inbuf.cmdresp, &cmdresult);
0802 }
0803
0804 ctlx->usercb(hw, &cmdresult, ctlx->usercb_data);
0805 }
0806 }
0807
0808
0809
0810
0811
0812
0813
0814
0815
0816
0817
0818
0819
0820
0821
0822
0823
0824
0825
0826
0827
0828 int hfa384x_cmd_initialize(struct hfa384x *hw)
0829 {
0830 int result = 0;
0831 int i;
0832 struct hfa384x_metacmd cmd;
0833
0834 cmd.cmd = HFA384x_CMDCODE_INIT;
0835 cmd.parm0 = 0;
0836 cmd.parm1 = 0;
0837 cmd.parm2 = 0;
0838
0839 result = hfa384x_docmd(hw, &cmd);
0840
0841 pr_debug("cmdresp.init: status=0x%04x, resp0=0x%04x, resp1=0x%04x, resp2=0x%04x\n",
0842 cmd.result.status,
0843 cmd.result.resp0, cmd.result.resp1, cmd.result.resp2);
0844 if (result == 0) {
0845 for (i = 0; i < HFA384x_NUMPORTS_MAX; i++)
0846 hw->port_enabled[i] = 0;
0847 }
0848
0849 hw->link_status = HFA384x_LINK_NOTCONNECTED;
0850
0851 return result;
0852 }
0853
0854
0855
0856
0857
0858
0859
0860
0861
0862
0863
0864
0865
0866
0867
0868
0869
0870
0871
0872
0873
0874
0875 int hfa384x_cmd_disable(struct hfa384x *hw, u16 macport)
0876 {
0877 struct hfa384x_metacmd cmd;
0878
0879 cmd.cmd = HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_DISABLE) |
0880 HFA384x_CMD_MACPORT_SET(macport);
0881 cmd.parm0 = 0;
0882 cmd.parm1 = 0;
0883 cmd.parm2 = 0;
0884
0885 return hfa384x_docmd(hw, &cmd);
0886 }
0887
0888
0889
0890
0891
0892
0893
0894
0895
0896
0897
0898
0899
0900
0901
0902
0903
0904
0905
0906
0907
0908
0909 int hfa384x_cmd_enable(struct hfa384x *hw, u16 macport)
0910 {
0911 struct hfa384x_metacmd cmd;
0912
0913 cmd.cmd = HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_ENABLE) |
0914 HFA384x_CMD_MACPORT_SET(macport);
0915 cmd.parm0 = 0;
0916 cmd.parm1 = 0;
0917 cmd.parm2 = 0;
0918
0919 return hfa384x_docmd(hw, &cmd);
0920 }
0921
0922
0923
0924
0925
0926
0927
0928
0929
0930
0931
0932
0933
0934
0935
0936
0937
0938
0939
0940
0941
0942
0943
0944
0945
0946
0947
0948
0949
0950
0951
0952 int hfa384x_cmd_monitor(struct hfa384x *hw, u16 enable)
0953 {
0954 struct hfa384x_metacmd cmd;
0955
0956 cmd.cmd = HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_MONITOR) |
0957 HFA384x_CMD_AINFO_SET(enable);
0958 cmd.parm0 = 0;
0959 cmd.parm1 = 0;
0960 cmd.parm2 = 0;
0961
0962 return hfa384x_docmd(hw, &cmd);
0963 }
0964
0965
0966
0967
0968
0969
0970
0971
0972
0973
0974
0975
0976
0977
0978
0979
0980
0981
0982
0983
0984
0985
0986
0987
0988
0989
0990
0991
0992
0993
0994
0995
0996
0997
0998
0999
1000
1001
1002
1003
1004 int hfa384x_cmd_download(struct hfa384x *hw, u16 mode, u16 lowaddr,
1005 u16 highaddr, u16 codelen)
1006 {
1007 struct hfa384x_metacmd cmd;
1008
1009 pr_debug("mode=%d, lowaddr=0x%04x, highaddr=0x%04x, codelen=%d\n",
1010 mode, lowaddr, highaddr, codelen);
1011
1012 cmd.cmd = (HFA384x_CMD_CMDCODE_SET(HFA384x_CMDCODE_DOWNLD) |
1013 HFA384x_CMD_PROGMODE_SET(mode));
1014
1015 cmd.parm0 = lowaddr;
1016 cmd.parm1 = highaddr;
1017 cmd.parm2 = codelen;
1018
1019 return hfa384x_docmd(hw, &cmd);
1020 }
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046 int hfa384x_corereset(struct hfa384x *hw, int holdtime,
1047 int settletime, int genesis)
1048 {
1049 int result;
1050
1051 result = usb_reset_device(hw->usb);
1052 if (result < 0) {
1053 netdev_err(hw->wlandev->netdev, "usb_reset_device() failed, result=%d.\n",
1054 result);
1055 }
1056
1057 return result;
1058 }
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085 static int hfa384x_usbctlx_complete_sync(struct hfa384x *hw,
1086 struct hfa384x_usbctlx *ctlx,
1087 struct usbctlx_completor *completor)
1088 {
1089 unsigned long flags;
1090 int result;
1091
1092 result = wait_for_completion_interruptible(&ctlx->done);
1093
1094 spin_lock_irqsave(&hw->ctlxq.lock, flags);
1095
1096
1097
1098
1099
1100 cleanup:
1101 if (hw->wlandev->hwremoved) {
1102 spin_unlock_irqrestore(&hw->ctlxq.lock, flags);
1103 result = -ENODEV;
1104 } else if (result != 0) {
1105 int runqueue = 0;
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116 if (ctlx == get_active_ctlx(hw)) {
1117 spin_unlock_irqrestore(&hw->ctlxq.lock, flags);
1118
1119 del_singleshot_timer_sync(&hw->reqtimer);
1120 del_singleshot_timer_sync(&hw->resptimer);
1121 hw->req_timer_done = 1;
1122 hw->resp_timer_done = 1;
1123 usb_kill_urb(&hw->ctlx_urb);
1124
1125 spin_lock_irqsave(&hw->ctlxq.lock, flags);
1126
1127 runqueue = 1;
1128
1129
1130
1131
1132
1133 if (hw->wlandev->hwremoved)
1134 goto cleanup;
1135 }
1136
1137
1138
1139
1140
1141
1142 ctlx->reapable = 1;
1143 ctlx->state = CTLX_REQ_FAILED;
1144 list_move_tail(&ctlx->list, &hw->ctlxq.completing);
1145
1146 spin_unlock_irqrestore(&hw->ctlxq.lock, flags);
1147
1148 if (runqueue)
1149 hfa384x_usbctlxq_run(hw);
1150 } else {
1151 if (ctlx->state == CTLX_COMPLETE) {
1152 result = completor->complete(completor);
1153 } else {
1154 netdev_warn(hw->wlandev->netdev, "CTLX[%d] error: state(%s)\n",
1155 le16_to_cpu(ctlx->outbuf.type),
1156 ctlxstr(ctlx->state));
1157 result = -EIO;
1158 }
1159
1160 list_del(&ctlx->list);
1161 spin_unlock_irqrestore(&hw->ctlxq.lock, flags);
1162 kfree(ctlx);
1163 }
1164
1165 return result;
1166 }
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196 static inline int
1197 hfa384x_docmd(struct hfa384x *hw,
1198 struct hfa384x_metacmd *cmd)
1199 {
1200 int result;
1201 struct hfa384x_usbctlx *ctlx;
1202
1203 ctlx = usbctlx_alloc();
1204 if (!ctlx) {
1205 result = -ENOMEM;
1206 goto done;
1207 }
1208
1209
1210 ctlx->outbuf.cmdreq.type = cpu_to_le16(HFA384x_USB_CMDREQ);
1211 ctlx->outbuf.cmdreq.cmd = cpu_to_le16(cmd->cmd);
1212 ctlx->outbuf.cmdreq.parm0 = cpu_to_le16(cmd->parm0);
1213 ctlx->outbuf.cmdreq.parm1 = cpu_to_le16(cmd->parm1);
1214 ctlx->outbuf.cmdreq.parm2 = cpu_to_le16(cmd->parm2);
1215
1216 ctlx->outbufsize = sizeof(ctlx->outbuf.cmdreq);
1217
1218 pr_debug("cmdreq: cmd=0x%04x parm0=0x%04x parm1=0x%04x parm2=0x%04x\n",
1219 cmd->cmd, cmd->parm0, cmd->parm1, cmd->parm2);
1220
1221 ctlx->reapable = DOWAIT;
1222 ctlx->cmdcb = NULL;
1223 ctlx->usercb = NULL;
1224 ctlx->usercb_data = NULL;
1225
1226 result = hfa384x_usbctlx_submit(hw, ctlx);
1227 if (result != 0) {
1228 kfree(ctlx);
1229 } else {
1230 struct usbctlx_cmd_completor cmd_completor;
1231 struct usbctlx_completor *completor;
1232
1233 completor = init_cmd_completor(&cmd_completor,
1234 &ctlx->inbuf.cmdresp,
1235 &cmd->result);
1236
1237 result = hfa384x_usbctlx_complete_sync(hw, ctlx, completor);
1238 }
1239
1240 done:
1241 return result;
1242 }
1243
1244
1245
1246
1247
1248
1249
1250
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 static int
1282 hfa384x_dorrid(struct hfa384x *hw,
1283 enum cmd_mode mode,
1284 u16 rid,
1285 void *riddata,
1286 unsigned int riddatalen,
1287 ctlx_cmdcb_t cmdcb, ctlx_usercb_t usercb, void *usercb_data)
1288 {
1289 int result;
1290 struct hfa384x_usbctlx *ctlx;
1291
1292 ctlx = usbctlx_alloc();
1293 if (!ctlx) {
1294 result = -ENOMEM;
1295 goto done;
1296 }
1297
1298
1299 ctlx->outbuf.rridreq.type = cpu_to_le16(HFA384x_USB_RRIDREQ);
1300 ctlx->outbuf.rridreq.frmlen =
1301 cpu_to_le16(sizeof(ctlx->outbuf.rridreq.rid));
1302 ctlx->outbuf.rridreq.rid = cpu_to_le16(rid);
1303
1304 ctlx->outbufsize = sizeof(ctlx->outbuf.rridreq);
1305
1306 ctlx->reapable = mode;
1307 ctlx->cmdcb = cmdcb;
1308 ctlx->usercb = usercb;
1309 ctlx->usercb_data = usercb_data;
1310
1311
1312 result = hfa384x_usbctlx_submit(hw, ctlx);
1313 if (result != 0) {
1314 kfree(ctlx);
1315 } else if (mode == DOWAIT) {
1316 struct usbctlx_rrid_completor completor;
1317
1318 result =
1319 hfa384x_usbctlx_complete_sync(hw, ctlx,
1320 init_rrid_completor
1321 (&completor,
1322 &ctlx->inbuf.rridresp,
1323 riddata, riddatalen));
1324 }
1325
1326 done:
1327 return result;
1328 }
1329
1330
1331
1332
1333
1334
1335
1336
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 static int
1364 hfa384x_dowrid(struct hfa384x *hw,
1365 enum cmd_mode mode,
1366 u16 rid,
1367 void *riddata,
1368 unsigned int riddatalen,
1369 ctlx_cmdcb_t cmdcb, ctlx_usercb_t usercb, void *usercb_data)
1370 {
1371 int result;
1372 struct hfa384x_usbctlx *ctlx;
1373
1374 ctlx = usbctlx_alloc();
1375 if (!ctlx) {
1376 result = -ENOMEM;
1377 goto done;
1378 }
1379
1380
1381 ctlx->outbuf.wridreq.type = cpu_to_le16(HFA384x_USB_WRIDREQ);
1382 ctlx->outbuf.wridreq.frmlen = cpu_to_le16((sizeof
1383 (ctlx->outbuf.wridreq.rid) +
1384 riddatalen + 1) / 2);
1385 ctlx->outbuf.wridreq.rid = cpu_to_le16(rid);
1386 memcpy(ctlx->outbuf.wridreq.data, riddata, riddatalen);
1387
1388 ctlx->outbufsize = sizeof(ctlx->outbuf.wridreq.type) +
1389 sizeof(ctlx->outbuf.wridreq.frmlen) +
1390 sizeof(ctlx->outbuf.wridreq.rid) + riddatalen;
1391
1392 ctlx->reapable = mode;
1393 ctlx->cmdcb = cmdcb;
1394 ctlx->usercb = usercb;
1395 ctlx->usercb_data = usercb_data;
1396
1397
1398 result = hfa384x_usbctlx_submit(hw, ctlx);
1399 if (result != 0) {
1400 kfree(ctlx);
1401 } else if (mode == DOWAIT) {
1402 struct usbctlx_cmd_completor completor;
1403 struct hfa384x_cmdresult wridresult;
1404
1405 result = hfa384x_usbctlx_complete_sync(hw,
1406 ctlx,
1407 init_wrid_completor
1408 (&completor,
1409 &ctlx->inbuf.wridresp,
1410 &wridresult));
1411 }
1412
1413 done:
1414 return result;
1415 }
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446 static int
1447 hfa384x_dormem(struct hfa384x *hw,
1448 u16 page,
1449 u16 offset,
1450 void *data,
1451 unsigned int len)
1452 {
1453 int result;
1454 struct hfa384x_usbctlx *ctlx;
1455
1456 ctlx = usbctlx_alloc();
1457 if (!ctlx) {
1458 result = -ENOMEM;
1459 goto done;
1460 }
1461
1462
1463 ctlx->outbuf.rmemreq.type = cpu_to_le16(HFA384x_USB_RMEMREQ);
1464 ctlx->outbuf.rmemreq.frmlen =
1465 cpu_to_le16(sizeof(ctlx->outbuf.rmemreq.offset) +
1466 sizeof(ctlx->outbuf.rmemreq.page) + len);
1467 ctlx->outbuf.rmemreq.offset = cpu_to_le16(offset);
1468 ctlx->outbuf.rmemreq.page = cpu_to_le16(page);
1469
1470 ctlx->outbufsize = sizeof(ctlx->outbuf.rmemreq);
1471
1472 pr_debug("type=0x%04x frmlen=%d offset=0x%04x page=0x%04x\n",
1473 ctlx->outbuf.rmemreq.type,
1474 ctlx->outbuf.rmemreq.frmlen,
1475 ctlx->outbuf.rmemreq.offset, ctlx->outbuf.rmemreq.page);
1476
1477 pr_debug("pktsize=%zd\n", ROUNDUP64(sizeof(ctlx->outbuf.rmemreq)));
1478
1479 ctlx->reapable = DOWAIT;
1480 ctlx->cmdcb = NULL;
1481 ctlx->usercb = NULL;
1482 ctlx->usercb_data = NULL;
1483
1484 result = hfa384x_usbctlx_submit(hw, ctlx);
1485 if (result != 0) {
1486 kfree(ctlx);
1487 } else {
1488 struct usbctlx_rmem_completor completor;
1489
1490 result =
1491 hfa384x_usbctlx_complete_sync(hw, ctlx,
1492 init_rmem_completor
1493 (&completor,
1494 &ctlx->inbuf.rmemresp, data,
1495 len));
1496 }
1497
1498 done:
1499 return result;
1500 }
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532 static int
1533 hfa384x_dowmem(struct hfa384x *hw,
1534 u16 page,
1535 u16 offset,
1536 void *data,
1537 unsigned int len)
1538 {
1539 int result;
1540 struct hfa384x_usbctlx *ctlx;
1541
1542 pr_debug("page=0x%04x offset=0x%04x len=%d\n", page, offset, len);
1543
1544 ctlx = usbctlx_alloc();
1545 if (!ctlx) {
1546 result = -ENOMEM;
1547 goto done;
1548 }
1549
1550
1551 ctlx->outbuf.wmemreq.type = cpu_to_le16(HFA384x_USB_WMEMREQ);
1552 ctlx->outbuf.wmemreq.frmlen =
1553 cpu_to_le16(sizeof(ctlx->outbuf.wmemreq.offset) +
1554 sizeof(ctlx->outbuf.wmemreq.page) + len);
1555 ctlx->outbuf.wmemreq.offset = cpu_to_le16(offset);
1556 ctlx->outbuf.wmemreq.page = cpu_to_le16(page);
1557 memcpy(ctlx->outbuf.wmemreq.data, data, len);
1558
1559 ctlx->outbufsize = sizeof(ctlx->outbuf.wmemreq.type) +
1560 sizeof(ctlx->outbuf.wmemreq.frmlen) +
1561 sizeof(ctlx->outbuf.wmemreq.offset) +
1562 sizeof(ctlx->outbuf.wmemreq.page) + len;
1563
1564 ctlx->reapable = DOWAIT;
1565 ctlx->cmdcb = NULL;
1566 ctlx->usercb = NULL;
1567 ctlx->usercb_data = NULL;
1568
1569 result = hfa384x_usbctlx_submit(hw, ctlx);
1570 if (result != 0) {
1571 kfree(ctlx);
1572 } else {
1573 struct usbctlx_cmd_completor completor;
1574 struct hfa384x_cmdresult wmemresult;
1575
1576 result = hfa384x_usbctlx_complete_sync(hw,
1577 ctlx,
1578 init_wmem_completor
1579 (&completor,
1580 &ctlx->inbuf.wmemresp,
1581 &wmemresult));
1582 }
1583
1584 done:
1585 return result;
1586 }
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611 int hfa384x_drvr_disable(struct hfa384x *hw, u16 macport)
1612 {
1613 int result = 0;
1614
1615 if ((!hw->isap && macport != 0) ||
1616 (hw->isap && !(macport <= HFA384x_PORTID_MAX)) ||
1617 !(hw->port_enabled[macport])) {
1618 result = -EINVAL;
1619 } else {
1620 result = hfa384x_cmd_disable(hw, macport);
1621 if (result == 0)
1622 hw->port_enabled[macport] = 0;
1623 }
1624 return result;
1625 }
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650 int hfa384x_drvr_enable(struct hfa384x *hw, u16 macport)
1651 {
1652 int result = 0;
1653
1654 if ((!hw->isap && macport != 0) ||
1655 (hw->isap && !(macport <= HFA384x_PORTID_MAX)) ||
1656 (hw->port_enabled[macport])) {
1657 result = -EINVAL;
1658 } else {
1659 result = hfa384x_cmd_enable(hw, macport);
1660 if (result == 0)
1661 hw->port_enabled[macport] = 1;
1662 }
1663 return result;
1664 }
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688 int hfa384x_drvr_flashdl_enable(struct hfa384x *hw)
1689 {
1690 int result = 0;
1691 int i;
1692
1693
1694 for (i = 0; i < HFA384x_PORTID_MAX; i++) {
1695 if (hw->port_enabled[i]) {
1696 pr_debug("called when port enabled.\n");
1697 return -EINVAL;
1698 }
1699 }
1700
1701
1702 if (hw->dlstate != HFA384x_DLSTATE_DISABLED)
1703 return -EINVAL;
1704
1705
1706 result = hfa384x_drvr_getconfig(hw, HFA384x_RID_DOWNLOADBUFFER,
1707 &hw->bufinfo, sizeof(hw->bufinfo));
1708 if (result)
1709 return result;
1710
1711 le16_to_cpus(&hw->bufinfo.page);
1712 le16_to_cpus(&hw->bufinfo.offset);
1713 le16_to_cpus(&hw->bufinfo.len);
1714 result = hfa384x_drvr_getconfig16(hw, HFA384x_RID_MAXLOADTIME,
1715 &hw->dltimeout);
1716 if (result)
1717 return result;
1718
1719 le16_to_cpus(&hw->dltimeout);
1720
1721 pr_debug("flashdl_enable\n");
1722
1723 hw->dlstate = HFA384x_DLSTATE_FLASHENABLED;
1724
1725 return result;
1726 }
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748 int hfa384x_drvr_flashdl_disable(struct hfa384x *hw)
1749 {
1750
1751 if (hw->dlstate != HFA384x_DLSTATE_FLASHENABLED)
1752 return -EINVAL;
1753
1754 pr_debug("flashdl_enable\n");
1755
1756
1757
1758 hfa384x_cmd_download(hw, HFA384x_PROGMODE_DISABLE, 0, 0, 0);
1759 hw->dlstate = HFA384x_DLSTATE_DISABLED;
1760
1761 return 0;
1762 }
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794 int hfa384x_drvr_flashdl_write(struct hfa384x *hw, u32 daddr,
1795 void *buf, u32 len)
1796 {
1797 int result = 0;
1798 u32 dlbufaddr;
1799 int nburns;
1800 u32 burnlen;
1801 u32 burndaddr;
1802 u16 burnlo;
1803 u16 burnhi;
1804 int nwrites;
1805 u8 *writebuf;
1806 u16 writepage;
1807 u16 writeoffset;
1808 u32 writelen;
1809 int i;
1810 int j;
1811
1812 pr_debug("daddr=0x%08x len=%d\n", daddr, len);
1813
1814
1815 if (hw->dlstate != HFA384x_DLSTATE_FLASHENABLED)
1816 return -EINVAL;
1817
1818 netdev_info(hw->wlandev->netdev,
1819 "Download %d bytes to flash @0x%06x\n", len, daddr);
1820
1821
1822
1823 dlbufaddr =
1824 HFA384x_ADDR_AUX_MKFLAT(hw->bufinfo.page, hw->bufinfo.offset);
1825 pr_debug("dlbuf.page=0x%04x dlbuf.offset=0x%04x dlbufaddr=0x%08x\n",
1826 hw->bufinfo.page, hw->bufinfo.offset, dlbufaddr);
1827
1828
1829
1830
1831
1832
1833
1834
1835 nburns = len / hw->bufinfo.len;
1836 nburns += (len % hw->bufinfo.len) ? 1 : 0;
1837
1838
1839 nwrites = hw->bufinfo.len / HFA384x_USB_RWMEM_MAXLEN;
1840 nwrites += (hw->bufinfo.len % HFA384x_USB_RWMEM_MAXLEN) ? 1 : 0;
1841
1842
1843 for (i = 0; i < nburns; i++) {
1844
1845 burnlen = (len - (hw->bufinfo.len * i)) > hw->bufinfo.len ?
1846 hw->bufinfo.len : (len - (hw->bufinfo.len * i));
1847 burndaddr = daddr + (hw->bufinfo.len * i);
1848 burnlo = HFA384x_ADDR_CMD_MKOFF(burndaddr);
1849 burnhi = HFA384x_ADDR_CMD_MKPAGE(burndaddr);
1850
1851 netdev_info(hw->wlandev->netdev, "Writing %d bytes to flash @0x%06x\n",
1852 burnlen, burndaddr);
1853
1854
1855 result = hfa384x_cmd_download(hw, HFA384x_PROGMODE_NV,
1856 burnlo, burnhi, burnlen);
1857 if (result) {
1858 netdev_err(hw->wlandev->netdev,
1859 "download(NV,lo=%x,hi=%x,len=%x) cmd failed, result=%d. Aborting d/l\n",
1860 burnlo, burnhi, burnlen, result);
1861 goto exit_proc;
1862 }
1863
1864
1865 for (j = 0; j < nwrites; j++) {
1866 writebuf = buf +
1867 (i * hw->bufinfo.len) +
1868 (j * HFA384x_USB_RWMEM_MAXLEN);
1869
1870 writepage = HFA384x_ADDR_CMD_MKPAGE(dlbufaddr +
1871 (j * HFA384x_USB_RWMEM_MAXLEN));
1872 writeoffset = HFA384x_ADDR_CMD_MKOFF(dlbufaddr +
1873 (j * HFA384x_USB_RWMEM_MAXLEN));
1874
1875 writelen = burnlen - (j * HFA384x_USB_RWMEM_MAXLEN);
1876 writelen = writelen > HFA384x_USB_RWMEM_MAXLEN ?
1877 HFA384x_USB_RWMEM_MAXLEN : writelen;
1878
1879 result = hfa384x_dowmem(hw,
1880 writepage,
1881 writeoffset,
1882 writebuf, writelen);
1883 }
1884
1885
1886 result = hfa384x_cmd_download(hw,
1887 HFA384x_PROGMODE_NVWRITE,
1888 0, 0, 0);
1889 if (result) {
1890 netdev_err(hw->wlandev->netdev,
1891 "download(NVWRITE,lo=%x,hi=%x,len=%x) cmd failed, result=%d. Aborting d/l\n",
1892 burnlo, burnhi, burnlen, result);
1893 goto exit_proc;
1894 }
1895
1896
1897 }
1898
1899 exit_proc:
1900
1901
1902
1903
1904
1905 return result;
1906 }
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934 int hfa384x_drvr_getconfig(struct hfa384x *hw, u16 rid, void *buf, u16 len)
1935 {
1936 return hfa384x_dorrid(hw, DOWAIT, rid, buf, len, NULL, NULL, NULL);
1937 }
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963 int
1964 hfa384x_drvr_setconfig_async(struct hfa384x *hw,
1965 u16 rid,
1966 void *buf,
1967 u16 len, ctlx_usercb_t usercb, void *usercb_data)
1968 {
1969 return hfa384x_dowrid(hw, DOASYNC, rid, buf, len, hfa384x_cb_status,
1970 usercb, usercb_data);
1971 }
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992 int hfa384x_drvr_ramdl_disable(struct hfa384x *hw)
1993 {
1994
1995 if (hw->dlstate != HFA384x_DLSTATE_RAMENABLED)
1996 return -EINVAL;
1997
1998 pr_debug("ramdl_disable()\n");
1999
2000
2001
2002 hfa384x_cmd_download(hw, HFA384x_PROGMODE_DISABLE, 0, 0, 0);
2003 hw->dlstate = HFA384x_DLSTATE_DISABLED;
2004
2005 return 0;
2006 }
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033 int hfa384x_drvr_ramdl_enable(struct hfa384x *hw, u32 exeaddr)
2034 {
2035 int result = 0;
2036 u16 lowaddr;
2037 u16 hiaddr;
2038 int i;
2039
2040
2041 for (i = 0; i < HFA384x_PORTID_MAX; i++) {
2042 if (hw->port_enabled[i]) {
2043 netdev_err(hw->wlandev->netdev,
2044 "Can't download with a macport enabled.\n");
2045 return -EINVAL;
2046 }
2047 }
2048
2049
2050 if (hw->dlstate != HFA384x_DLSTATE_DISABLED) {
2051 netdev_err(hw->wlandev->netdev,
2052 "Download state not disabled.\n");
2053 return -EINVAL;
2054 }
2055
2056 pr_debug("ramdl_enable, exeaddr=0x%08x\n", exeaddr);
2057
2058
2059 lowaddr = HFA384x_ADDR_CMD_MKOFF(exeaddr);
2060 hiaddr = HFA384x_ADDR_CMD_MKPAGE(exeaddr);
2061
2062 result = hfa384x_cmd_download(hw, HFA384x_PROGMODE_RAM,
2063 lowaddr, hiaddr, 0);
2064
2065 if (result == 0) {
2066
2067 hw->dlstate = HFA384x_DLSTATE_RAMENABLED;
2068 } else {
2069 pr_debug("cmd_download(0x%04x, 0x%04x) failed, result=%d.\n",
2070 lowaddr, hiaddr, result);
2071 }
2072
2073 return result;
2074 }
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103 int hfa384x_drvr_ramdl_write(struct hfa384x *hw, u32 daddr, void *buf, u32 len)
2104 {
2105 int result = 0;
2106 int nwrites;
2107 u8 *data = buf;
2108 int i;
2109 u32 curraddr;
2110 u16 currpage;
2111 u16 curroffset;
2112 u16 currlen;
2113
2114
2115 if (hw->dlstate != HFA384x_DLSTATE_RAMENABLED)
2116 return -EINVAL;
2117
2118 netdev_info(hw->wlandev->netdev, "Writing %d bytes to ram @0x%06x\n",
2119 len, daddr);
2120
2121
2122 nwrites = len / HFA384x_USB_RWMEM_MAXLEN;
2123 nwrites += len % HFA384x_USB_RWMEM_MAXLEN ? 1 : 0;
2124
2125
2126 for (i = 0; i < nwrites; i++) {
2127
2128 curraddr = daddr + (i * HFA384x_USB_RWMEM_MAXLEN);
2129 currpage = HFA384x_ADDR_CMD_MKPAGE(curraddr);
2130 curroffset = HFA384x_ADDR_CMD_MKOFF(curraddr);
2131 currlen = len - (i * HFA384x_USB_RWMEM_MAXLEN);
2132 if (currlen > HFA384x_USB_RWMEM_MAXLEN)
2133 currlen = HFA384x_USB_RWMEM_MAXLEN;
2134
2135
2136 result = hfa384x_dowmem(hw,
2137 currpage,
2138 curroffset,
2139 data + (i * HFA384x_USB_RWMEM_MAXLEN),
2140 currlen);
2141
2142 if (result)
2143 break;
2144
2145
2146 }
2147
2148 return result;
2149 }
2150
2151
2152
2153
2154
2155
2156
2157
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 int hfa384x_drvr_readpda(struct hfa384x *hw, void *buf, unsigned int len)
2184 {
2185 int result = 0;
2186 __le16 *pda = buf;
2187 int pdaok = 0;
2188 int morepdrs = 1;
2189 int currpdr = 0;
2190 size_t i;
2191 u16 pdrlen;
2192 u16 pdrcode;
2193 u16 currpage;
2194 u16 curroffset;
2195 struct pdaloc {
2196 u32 cardaddr;
2197 u16 auxctl;
2198 } pdaloc[] = {
2199 {
2200 HFA3842_PDA_BASE, 0}, {
2201 HFA3841_PDA_BASE, 0}, {
2202 HFA3841_PDA_BOGUS_BASE, 0}
2203 };
2204
2205
2206 for (i = 0; i < ARRAY_SIZE(pdaloc); i++) {
2207
2208 currpage = HFA384x_ADDR_CMD_MKPAGE(pdaloc[i].cardaddr);
2209 curroffset = HFA384x_ADDR_CMD_MKOFF(pdaloc[i].cardaddr);
2210
2211
2212 result = hfa384x_dormem(hw, currpage, curroffset, buf,
2213 len);
2214
2215 if (result) {
2216 netdev_warn(hw->wlandev->netdev,
2217 "Read from index %zd failed, continuing\n",
2218 i);
2219 continue;
2220 }
2221
2222
2223 pdaok = 1;
2224 morepdrs = 1;
2225 while (pdaok && morepdrs) {
2226 pdrlen = le16_to_cpu(pda[currpdr]) * 2;
2227 pdrcode = le16_to_cpu(pda[currpdr + 1]);
2228
2229 if (pdrlen > HFA384x_PDR_LEN_MAX || pdrlen == 0) {
2230 netdev_err(hw->wlandev->netdev,
2231 "pdrlen invalid=%d\n", pdrlen);
2232 pdaok = 0;
2233 break;
2234 }
2235
2236 if (!hfa384x_isgood_pdrcode(pdrcode)) {
2237 netdev_err(hw->wlandev->netdev, "pdrcode invalid=%d\n",
2238 pdrcode);
2239 pdaok = 0;
2240 break;
2241 }
2242
2243 if (pdrcode == HFA384x_PDR_END_OF_PDA)
2244 morepdrs = 0;
2245
2246
2247 if (morepdrs) {
2248
2249 currpdr += le16_to_cpu(pda[currpdr]) + 1;
2250 }
2251 }
2252 if (pdaok) {
2253 netdev_info(hw->wlandev->netdev,
2254 "PDA Read from 0x%08x in %s space.\n",
2255 pdaloc[i].cardaddr,
2256 pdaloc[i].auxctl == 0 ? "EXTDS" :
2257 pdaloc[i].auxctl == 1 ? "NV" :
2258 pdaloc[i].auxctl == 2 ? "PHY" :
2259 pdaloc[i].auxctl == 3 ? "ICSRAM" :
2260 "<bogus auxctl>");
2261 break;
2262 }
2263 }
2264 result = pdaok ? 0 : -ENODATA;
2265
2266 if (result)
2267 pr_debug("Failure: pda is not okay\n");
2268
2269 return result;
2270 }
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294 int hfa384x_drvr_setconfig(struct hfa384x *hw, u16 rid, void *buf, u16 len)
2295 {
2296 return hfa384x_dowrid(hw, DOWAIT, rid, buf, len, NULL, NULL, NULL);
2297 }
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319 int hfa384x_drvr_start(struct hfa384x *hw)
2320 {
2321 int result, result1, result2;
2322 u16 status;
2323
2324 might_sleep();
2325
2326
2327
2328
2329
2330
2331 result =
2332 usb_get_std_status(hw->usb, USB_RECIP_ENDPOINT, hw->endp_in,
2333 &status);
2334 if (result < 0) {
2335 netdev_err(hw->wlandev->netdev, "Cannot get bulk in endpoint status.\n");
2336 goto done;
2337 }
2338 if ((status == 1) && usb_clear_halt(hw->usb, hw->endp_in))
2339 netdev_err(hw->wlandev->netdev, "Failed to reset bulk in endpoint.\n");
2340
2341 result =
2342 usb_get_std_status(hw->usb, USB_RECIP_ENDPOINT, hw->endp_out,
2343 &status);
2344 if (result < 0) {
2345 netdev_err(hw->wlandev->netdev, "Cannot get bulk out endpoint status.\n");
2346 goto done;
2347 }
2348 if ((status == 1) && usb_clear_halt(hw->usb, hw->endp_out))
2349 netdev_err(hw->wlandev->netdev, "Failed to reset bulk out endpoint.\n");
2350
2351
2352 usb_kill_urb(&hw->rx_urb);
2353
2354
2355 result = submit_rx_urb(hw, GFP_KERNEL);
2356 if (result != 0) {
2357 netdev_err(hw->wlandev->netdev,
2358 "Fatal, failed to submit RX URB, result=%d\n",
2359 result);
2360 goto done;
2361 }
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373 result1 = hfa384x_cmd_initialize(hw);
2374 msleep(1000);
2375 result = hfa384x_cmd_initialize(hw);
2376 result2 = result;
2377 if (result1 != 0) {
2378 if (result2 != 0) {
2379 netdev_err(hw->wlandev->netdev,
2380 "cmd_initialize() failed on two attempts, results %d and %d\n",
2381 result1, result2);
2382 usb_kill_urb(&hw->rx_urb);
2383 goto done;
2384 } else {
2385 pr_debug("First cmd_initialize() failed (result %d),\n",
2386 result1);
2387 pr_debug("but second attempt succeeded. All should be ok\n");
2388 }
2389 } else if (result2 != 0) {
2390 netdev_warn(hw->wlandev->netdev, "First cmd_initialize() succeeded, but second attempt failed (result=%d)\n",
2391 result2);
2392 netdev_warn(hw->wlandev->netdev,
2393 "Most likely the card will be functional\n");
2394 goto done;
2395 }
2396
2397 hw->state = HFA384x_STATE_RUNNING;
2398
2399 done:
2400 return result;
2401 }
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423 int hfa384x_drvr_stop(struct hfa384x *hw)
2424 {
2425 int i;
2426
2427 might_sleep();
2428
2429
2430
2431
2432 if (!hw->wlandev->hwremoved) {
2433
2434 hfa384x_cmd_initialize(hw);
2435
2436
2437 usb_kill_urb(&hw->rx_urb);
2438 }
2439
2440 hw->link_status = HFA384x_LINK_NOTCONNECTED;
2441 hw->state = HFA384x_STATE_INIT;
2442
2443 del_timer_sync(&hw->commsqual_timer);
2444
2445
2446 for (i = 0; i < HFA384x_NUMPORTS_MAX; i++)
2447 hw->port_enabled[i] = 0;
2448
2449 return 0;
2450 }
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474 int hfa384x_drvr_txframe(struct hfa384x *hw, struct sk_buff *skb,
2475 struct p80211_hdr *p80211_hdr,
2476 struct p80211_metawep *p80211_wep)
2477 {
2478 int usbpktlen = sizeof(struct hfa384x_tx_frame);
2479 int result;
2480 int ret;
2481 char *ptr;
2482
2483 if (hw->tx_urb.status == -EINPROGRESS) {
2484 netdev_warn(hw->wlandev->netdev, "TX URB already in use\n");
2485 result = 3;
2486 goto exit;
2487 }
2488
2489
2490
2491 memset(&hw->txbuff.txfrm.desc, 0, sizeof(hw->txbuff.txfrm.desc));
2492
2493
2494 hw->txbuff.type = cpu_to_le16(HFA384x_USB_TXFRM);
2495
2496
2497 hw->txbuff.txfrm.desc.sw_support = 0x0123;
2498
2499
2500
2501
2502
2503 #if defined(DOBOTH)
2504 hw->txbuff.txfrm.desc.tx_control =
2505 HFA384x_TX_MACPORT_SET(0) | HFA384x_TX_STRUCTYPE_SET(1) |
2506 HFA384x_TX_TXEX_SET(1) | HFA384x_TX_TXOK_SET(1);
2507 #elif defined(DOEXC)
2508 hw->txbuff.txfrm.desc.tx_control =
2509 HFA384x_TX_MACPORT_SET(0) | HFA384x_TX_STRUCTYPE_SET(1) |
2510 HFA384x_TX_TXEX_SET(1) | HFA384x_TX_TXOK_SET(0);
2511 #else
2512 hw->txbuff.txfrm.desc.tx_control =
2513 HFA384x_TX_MACPORT_SET(0) | HFA384x_TX_STRUCTYPE_SET(1) |
2514 HFA384x_TX_TXEX_SET(0) | HFA384x_TX_TXOK_SET(0);
2515 #endif
2516 cpu_to_le16s(&hw->txbuff.txfrm.desc.tx_control);
2517
2518
2519 hw->txbuff.txfrm.desc.hdr = *p80211_hdr;
2520
2521
2522 if (p80211_wep->data) {
2523 hw->txbuff.txfrm.desc.data_len = cpu_to_le16(skb->len + 8);
2524 usbpktlen += 8;
2525 } else {
2526 hw->txbuff.txfrm.desc.data_len = cpu_to_le16(skb->len);
2527 }
2528
2529 usbpktlen += skb->len;
2530
2531
2532 ptr = hw->txbuff.txfrm.data;
2533 if (p80211_wep->data) {
2534 memcpy(ptr, p80211_wep->iv, sizeof(p80211_wep->iv));
2535 ptr += sizeof(p80211_wep->iv);
2536 memcpy(ptr, p80211_wep->data, skb->len);
2537 } else {
2538 memcpy(ptr, skb->data, skb->len);
2539 }
2540
2541 ptr += skb->len;
2542
2543
2544 if (p80211_wep->data)
2545 memcpy(ptr, p80211_wep->icv, sizeof(p80211_wep->icv));
2546
2547
2548 usb_fill_bulk_urb(&hw->tx_urb, hw->usb,
2549 hw->endp_out,
2550 &hw->txbuff, ROUNDUP64(usbpktlen),
2551 hfa384x_usbout_callback, hw->wlandev);
2552 hw->tx_urb.transfer_flags |= USB_QUEUE_BULK;
2553
2554 result = 1;
2555 ret = submit_tx_urb(hw, &hw->tx_urb, GFP_ATOMIC);
2556 if (ret != 0) {
2557 netdev_err(hw->wlandev->netdev,
2558 "submit_tx_urb() failed, error=%d\n", ret);
2559 result = 3;
2560 }
2561
2562 exit:
2563 return result;
2564 }
2565
2566 void hfa384x_tx_timeout(struct wlandevice *wlandev)
2567 {
2568 struct hfa384x *hw = wlandev->priv;
2569 unsigned long flags;
2570
2571 spin_lock_irqsave(&hw->ctlxq.lock, flags);
2572
2573 if (!hw->wlandev->hwremoved) {
2574 int sched;
2575
2576 sched = !test_and_set_bit(WORK_TX_HALT, &hw->usb_flags);
2577 sched |= !test_and_set_bit(WORK_RX_HALT, &hw->usb_flags);
2578 if (sched)
2579 schedule_work(&hw->usb_work);
2580 }
2581
2582 spin_unlock_irqrestore(&hw->ctlxq.lock, flags);
2583 }
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599 static void hfa384x_usbctlx_reaper_task(struct work_struct *work)
2600 {
2601 struct hfa384x *hw = container_of(work, struct hfa384x, reaper_bh);
2602 struct hfa384x_usbctlx *ctlx, *temp;
2603 unsigned long flags;
2604
2605 spin_lock_irqsave(&hw->ctlxq.lock, flags);
2606
2607
2608
2609
2610 list_for_each_entry_safe(ctlx, temp, &hw->ctlxq.reapable, list) {
2611 list_del(&ctlx->list);
2612 kfree(ctlx);
2613 }
2614
2615 spin_unlock_irqrestore(&hw->ctlxq.lock, flags);
2616 }
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633 static void hfa384x_usbctlx_completion_task(struct work_struct *work)
2634 {
2635 struct hfa384x *hw = container_of(work, struct hfa384x, completion_bh);
2636 struct hfa384x_usbctlx *ctlx, *temp;
2637 unsigned long flags;
2638
2639 int reap = 0;
2640
2641 spin_lock_irqsave(&hw->ctlxq.lock, flags);
2642
2643
2644
2645
2646 list_for_each_entry_safe(ctlx, temp, &hw->ctlxq.completing, list) {
2647
2648
2649
2650 if (ctlx->cmdcb) {
2651 spin_unlock_irqrestore(&hw->ctlxq.lock, flags);
2652 ctlx->cmdcb(hw, ctlx);
2653 spin_lock_irqsave(&hw->ctlxq.lock, flags);
2654
2655
2656
2657
2658 ctlx->cmdcb = NULL;
2659
2660
2661
2662
2663 if (hw->wlandev->hwremoved) {
2664 reap = 0;
2665 break;
2666 }
2667 }
2668
2669
2670
2671
2672
2673
2674 if (ctlx->reapable) {
2675
2676
2677
2678
2679
2680 list_move_tail(&ctlx->list, &hw->ctlxq.reapable);
2681 reap = 1;
2682 }
2683
2684 complete(&ctlx->done);
2685 }
2686 spin_unlock_irqrestore(&hw->ctlxq.lock, flags);
2687
2688 if (reap)
2689 schedule_work(&hw->reaper_bh);
2690 }
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710 static int unlocked_usbctlx_cancel_async(struct hfa384x *hw,
2711 struct hfa384x_usbctlx *ctlx)
2712 {
2713 int ret;
2714
2715
2716
2717
2718
2719
2720 hw->ctlx_urb.transfer_flags |= URB_ASYNC_UNLINK;
2721 ret = usb_unlink_urb(&hw->ctlx_urb);
2722
2723 if (ret != -EINPROGRESS) {
2724
2725
2726
2727
2728
2729
2730 ctlx->state = CTLX_REQ_FAILED;
2731 unlocked_usbctlx_complete(hw, ctlx);
2732 ret = 0;
2733 }
2734
2735 return ret;
2736 }
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761 static void unlocked_usbctlx_complete(struct hfa384x *hw,
2762 struct hfa384x_usbctlx *ctlx)
2763 {
2764
2765
2766
2767
2768 list_move_tail(&ctlx->list, &hw->ctlxq.completing);
2769 schedule_work(&hw->completion_bh);
2770
2771 switch (ctlx->state) {
2772 case CTLX_COMPLETE:
2773 case CTLX_REQ_FAILED:
2774
2775 break;
2776
2777 default:
2778 netdev_err(hw->wlandev->netdev, "CTLX[%d] not in a terminating state(%s)\n",
2779 le16_to_cpu(ctlx->outbuf.type),
2780 ctlxstr(ctlx->state));
2781 break;
2782 }
2783 }
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802 static void hfa384x_usbctlxq_run(struct hfa384x *hw)
2803 {
2804 unsigned long flags;
2805
2806
2807 spin_lock_irqsave(&hw->ctlxq.lock, flags);
2808
2809
2810
2811
2812
2813
2814
2815
2816 if (!list_empty(&hw->ctlxq.active) ||
2817 test_bit(WORK_TX_HALT, &hw->usb_flags) || hw->wlandev->hwremoved)
2818 goto unlock;
2819
2820 while (!list_empty(&hw->ctlxq.pending)) {
2821 struct hfa384x_usbctlx *head;
2822 int result;
2823
2824
2825 head = list_entry(hw->ctlxq.pending.next,
2826 struct hfa384x_usbctlx, list);
2827
2828
2829 list_move_tail(&head->list, &hw->ctlxq.active);
2830
2831
2832 usb_fill_bulk_urb(&hw->ctlx_urb, hw->usb,
2833 hw->endp_out,
2834 &head->outbuf, ROUNDUP64(head->outbufsize),
2835 hfa384x_ctlxout_callback, hw);
2836 hw->ctlx_urb.transfer_flags |= USB_QUEUE_BULK;
2837
2838
2839 result = usb_submit_urb(&hw->ctlx_urb, GFP_ATOMIC);
2840 if (result == 0) {
2841
2842 head->state = CTLX_REQ_SUBMITTED;
2843
2844
2845 hw->req_timer_done = 0;
2846 hw->reqtimer.expires = jiffies + HZ;
2847 add_timer(&hw->reqtimer);
2848
2849
2850 hw->resp_timer_done = 0;
2851 hw->resptimer.expires = jiffies + 2 * HZ;
2852 add_timer(&hw->resptimer);
2853
2854 break;
2855 }
2856
2857 if (result == -EPIPE) {
2858
2859
2860
2861
2862 netdev_warn(hw->wlandev->netdev,
2863 "%s tx pipe stalled: requesting reset\n",
2864 hw->wlandev->netdev->name);
2865 list_move(&head->list, &hw->ctlxq.pending);
2866 set_bit(WORK_TX_HALT, &hw->usb_flags);
2867 schedule_work(&hw->usb_work);
2868 break;
2869 }
2870
2871 if (result == -ESHUTDOWN) {
2872 netdev_warn(hw->wlandev->netdev, "%s urb shutdown!\n",
2873 hw->wlandev->netdev->name);
2874 break;
2875 }
2876
2877 netdev_err(hw->wlandev->netdev, "Failed to submit CTLX[%d]: error=%d\n",
2878 le16_to_cpu(head->outbuf.type), result);
2879 unlocked_usbctlx_complete(hw, head);
2880 }
2881
2882 unlock:
2883 spin_unlock_irqrestore(&hw->ctlxq.lock, flags);
2884 }
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903 static void hfa384x_usbin_callback(struct urb *urb)
2904 {
2905 struct wlandevice *wlandev = urb->context;
2906 struct hfa384x *hw;
2907 union hfa384x_usbin *usbin;
2908 struct sk_buff *skb = NULL;
2909 int result;
2910 int urb_status;
2911 u16 type;
2912
2913 enum USBIN_ACTION {
2914 HANDLE,
2915 RESUBMIT,
2916 ABORT
2917 } action;
2918
2919 if (!wlandev || !wlandev->netdev || wlandev->hwremoved)
2920 goto exit;
2921
2922 hw = wlandev->priv;
2923 if (!hw)
2924 goto exit;
2925
2926 skb = hw->rx_urb_skb;
2927 if (!skb || (skb->data != urb->transfer_buffer)) {
2928 WARN_ON(1);
2929 return;
2930 }
2931
2932 hw->rx_urb_skb = NULL;
2933
2934
2935 switch (urb->status) {
2936 case 0:
2937 action = HANDLE;
2938
2939
2940 if (urb->actual_length == 0) {
2941 wlandev->netdev->stats.rx_errors++;
2942 wlandev->netdev->stats.rx_length_errors++;
2943 action = RESUBMIT;
2944 }
2945 break;
2946
2947 case -EPIPE:
2948 netdev_warn(hw->wlandev->netdev, "%s rx pipe stalled: requesting reset\n",
2949 wlandev->netdev->name);
2950 if (!test_and_set_bit(WORK_RX_HALT, &hw->usb_flags))
2951 schedule_work(&hw->usb_work);
2952 wlandev->netdev->stats.rx_errors++;
2953 action = ABORT;
2954 break;
2955
2956 case -EILSEQ:
2957 case -ETIMEDOUT:
2958 case -EPROTO:
2959 if (!test_and_set_bit(THROTTLE_RX, &hw->usb_flags) &&
2960 !timer_pending(&hw->throttle)) {
2961 mod_timer(&hw->throttle, jiffies + THROTTLE_JIFFIES);
2962 }
2963 wlandev->netdev->stats.rx_errors++;
2964 action = ABORT;
2965 break;
2966
2967 case -EOVERFLOW:
2968 wlandev->netdev->stats.rx_over_errors++;
2969 action = RESUBMIT;
2970 break;
2971
2972 case -ENODEV:
2973 case -ESHUTDOWN:
2974 pr_debug("status=%d, device removed.\n", urb->status);
2975 action = ABORT;
2976 break;
2977
2978 case -ENOENT:
2979 case -ECONNRESET:
2980 pr_debug("status=%d, urb explicitly unlinked.\n", urb->status);
2981 action = ABORT;
2982 break;
2983
2984 default:
2985 pr_debug("urb status=%d, transfer flags=0x%x\n",
2986 urb->status, urb->transfer_flags);
2987 wlandev->netdev->stats.rx_errors++;
2988 action = RESUBMIT;
2989 break;
2990 }
2991
2992
2993 urb_status = urb->status;
2994 usbin = (union hfa384x_usbin *)urb->transfer_buffer;
2995
2996 if (action != ABORT) {
2997
2998 result = submit_rx_urb(hw, GFP_ATOMIC);
2999
3000 if (result != 0) {
3001 netdev_err(hw->wlandev->netdev,
3002 "Fatal, failed to resubmit rx_urb. error=%d\n",
3003 result);
3004 }
3005 }
3006
3007
3008
3009
3010
3011 type = le16_to_cpu(usbin->type);
3012 if (HFA384x_USB_ISRXFRM(type)) {
3013 if (action == HANDLE) {
3014 if (usbin->txfrm.desc.sw_support == 0x0123) {
3015 hfa384x_usbin_txcompl(wlandev, usbin);
3016 } else {
3017 skb_put(skb, sizeof(*usbin));
3018 hfa384x_usbin_rx(wlandev, skb);
3019 skb = NULL;
3020 }
3021 }
3022 goto exit;
3023 }
3024 if (HFA384x_USB_ISTXFRM(type)) {
3025 if (action == HANDLE)
3026 hfa384x_usbin_txcompl(wlandev, usbin);
3027 goto exit;
3028 }
3029 switch (type) {
3030 case HFA384x_USB_INFOFRM:
3031 if (action == ABORT)
3032 goto exit;
3033 if (action == HANDLE)
3034 hfa384x_usbin_info(wlandev, usbin);
3035 break;
3036
3037 case HFA384x_USB_CMDRESP:
3038 case HFA384x_USB_WRIDRESP:
3039 case HFA384x_USB_RRIDRESP:
3040 case HFA384x_USB_WMEMRESP:
3041 case HFA384x_USB_RMEMRESP:
3042
3043 hfa384x_usbin_ctlx(hw, usbin, urb_status);
3044 break;
3045
3046 case HFA384x_USB_BUFAVAIL:
3047 pr_debug("Received BUFAVAIL packet, frmlen=%d\n",
3048 usbin->bufavail.frmlen);
3049 break;
3050
3051 case HFA384x_USB_ERROR:
3052 pr_debug("Received USB_ERROR packet, errortype=%d\n",
3053 usbin->usberror.errortype);
3054 break;
3055
3056 default:
3057 pr_debug("Unrecognized USBIN packet, type=%x, status=%d\n",
3058 usbin->type, urb_status);
3059 break;
3060 }
3061
3062 exit:
3063
3064 if (skb)
3065 dev_kfree_skb(skb);
3066 }
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089 static void hfa384x_usbin_ctlx(struct hfa384x *hw, union hfa384x_usbin *usbin,
3090 int urb_status)
3091 {
3092 struct hfa384x_usbctlx *ctlx;
3093 int run_queue = 0;
3094 unsigned long flags;
3095
3096 retry:
3097 spin_lock_irqsave(&hw->ctlxq.lock, flags);
3098
3099
3100
3101
3102
3103 if (list_empty(&hw->ctlxq.active))
3104 goto unlock;
3105
3106
3107
3108
3109
3110
3111
3112 if (del_timer(&hw->resptimer) == 0) {
3113 if (hw->resp_timer_done == 0) {
3114 spin_unlock_irqrestore(&hw->ctlxq.lock, flags);
3115 goto retry;
3116 }
3117 } else {
3118 hw->resp_timer_done = 1;
3119 }
3120
3121 ctlx = get_active_ctlx(hw);
3122
3123 if (urb_status != 0) {
3124
3125
3126
3127
3128
3129 if (unlocked_usbctlx_cancel_async(hw, ctlx) == 0)
3130 run_queue = 1;
3131 } else {
3132 const __le16 intype = (usbin->type & ~cpu_to_le16(0x8000));
3133
3134
3135
3136
3137 if (ctlx->outbuf.type != intype) {
3138 netdev_warn(hw->wlandev->netdev,
3139 "Expected IN[%d], received IN[%d] - ignored.\n",
3140 le16_to_cpu(ctlx->outbuf.type),
3141 le16_to_cpu(intype));
3142 goto unlock;
3143 }
3144
3145
3146 memcpy(&ctlx->inbuf, usbin, sizeof(ctlx->inbuf));
3147
3148 switch (ctlx->state) {
3149 case CTLX_REQ_SUBMITTED:
3150
3151
3152
3153
3154
3155 pr_debug("Causality violation: please reboot Universe\n");
3156 ctlx->state = CTLX_RESP_COMPLETE;
3157 break;
3158
3159 case CTLX_REQ_COMPLETE:
3160
3161
3162
3163
3164
3165 ctlx->state = CTLX_COMPLETE;
3166 unlocked_usbctlx_complete(hw, ctlx);
3167 run_queue = 1;
3168 break;
3169
3170 default:
3171
3172
3173
3174 netdev_err(hw->wlandev->netdev,
3175 "Matched IN URB, CTLX[%d] in invalid state(%s). Discarded.\n",
3176 le16_to_cpu(ctlx->outbuf.type),
3177 ctlxstr(ctlx->state));
3178 if (unlocked_usbctlx_cancel_async(hw, ctlx) == 0)
3179 run_queue = 1;
3180 break;
3181 }
3182 }
3183
3184 unlock:
3185 spin_unlock_irqrestore(&hw->ctlxq.lock, flags);
3186
3187 if (run_queue)
3188 hfa384x_usbctlxq_run(hw);
3189 }
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209 static void hfa384x_usbin_txcompl(struct wlandevice *wlandev,
3210 union hfa384x_usbin *usbin)
3211 {
3212 u16 status;
3213
3214 status = le16_to_cpu(usbin->type);
3215
3216
3217 if (HFA384x_TXSTATUS_ISERROR(status))
3218 prism2sta_ev_txexc(wlandev, status);
3219 else
3220 prism2sta_ev_tx(wlandev, status);
3221 }
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241 static void hfa384x_usbin_rx(struct wlandevice *wlandev, struct sk_buff *skb)
3242 {
3243 union hfa384x_usbin *usbin = (union hfa384x_usbin *)skb->data;
3244 struct hfa384x *hw = wlandev->priv;
3245 int hdrlen;
3246 struct p80211_rxmeta *rxmeta;
3247 u16 data_len;
3248 u16 fc;
3249 u16 status;
3250
3251
3252 le16_to_cpus(&usbin->rxfrm.desc.status);
3253 le32_to_cpus(&usbin->rxfrm.desc.time);
3254
3255
3256 status = HFA384x_RXSTATUS_MACPORT_GET(usbin->rxfrm.desc.status);
3257
3258 switch (status) {
3259 case 0:
3260 fc = le16_to_cpu(usbin->rxfrm.desc.hdr.frame_control);
3261
3262
3263 if ((wlandev->hostwep & HOSTWEP_EXCLUDEUNENCRYPTED) &&
3264 !WLAN_GET_FC_ISWEP(fc)) {
3265 break;
3266 }
3267
3268 data_len = le16_to_cpu(usbin->rxfrm.desc.data_len);
3269
3270
3271 hdrlen = p80211_headerlen(fc);
3272
3273
3274 skb_pull(skb, sizeof(struct hfa384x_rx_frame));
3275
3276
3277
3278
3279 memmove(skb_push(skb, hdrlen),
3280 &usbin->rxfrm.desc.hdr, hdrlen);
3281
3282 skb->dev = wlandev->netdev;
3283
3284
3285 skb_trim(skb, data_len + hdrlen);
3286
3287
3288 memset(skb_put(skb, WLAN_CRC_LEN), 0xff, WLAN_CRC_LEN);
3289
3290 skb_reset_mac_header(skb);
3291
3292
3293 p80211skb_rxmeta_attach(wlandev, skb);
3294 rxmeta = p80211skb_rxmeta(skb);
3295 rxmeta->mactime = usbin->rxfrm.desc.time;
3296 rxmeta->rxrate = usbin->rxfrm.desc.rate;
3297 rxmeta->signal = usbin->rxfrm.desc.signal - hw->dbmadjust;
3298 rxmeta->noise = usbin->rxfrm.desc.silence - hw->dbmadjust;
3299
3300 p80211netdev_rx(wlandev, skb);
3301
3302 break;
3303
3304 case 7:
3305 if (!HFA384x_RXSTATUS_ISFCSERR(usbin->rxfrm.desc.status)) {
3306
3307 hfa384x_int_rxmonitor(wlandev, &usbin->rxfrm);
3308 dev_kfree_skb(skb);
3309 } else {
3310 pr_debug("Received monitor frame: FCSerr set\n");
3311 }
3312 break;
3313
3314 default:
3315 netdev_warn(hw->wlandev->netdev,
3316 "Received frame on unsupported port=%d\n",
3317 status);
3318 break;
3319 }
3320 }
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344 static void hfa384x_int_rxmonitor(struct wlandevice *wlandev,
3345 struct hfa384x_usb_rxfrm *rxfrm)
3346 {
3347 struct hfa384x_rx_frame *rxdesc = &rxfrm->desc;
3348 unsigned int hdrlen = 0;
3349 unsigned int datalen = 0;
3350 unsigned int skblen = 0;
3351 u8 *datap;
3352 u16 fc;
3353 struct sk_buff *skb;
3354 struct hfa384x *hw = wlandev->priv;
3355
3356
3357
3358 fc = le16_to_cpu(rxdesc->hdr.frame_control);
3359 hdrlen = p80211_headerlen(fc);
3360 datalen = le16_to_cpu(rxdesc->data_len);
3361
3362
3363 skblen = sizeof(struct p80211_caphdr) + hdrlen + datalen + WLAN_CRC_LEN;
3364
3365
3366 if (skblen >
3367 (sizeof(struct p80211_caphdr) +
3368 WLAN_HDR_A4_LEN + WLAN_DATA_MAXLEN + WLAN_CRC_LEN)) {
3369 pr_debug("overlen frm: len=%zd\n",
3370 skblen - sizeof(struct p80211_caphdr));
3371
3372 return;
3373 }
3374
3375 skb = dev_alloc_skb(skblen);
3376 if (!skb)
3377 return;
3378
3379
3380 if ((wlandev->netdev->type == ARPHRD_IEEE80211_PRISM) &&
3381 (hw->sniffhdr != 0)) {
3382 struct p80211_caphdr *caphdr;
3383
3384 datap = skb_put(skb, sizeof(struct p80211_caphdr));
3385 caphdr = (struct p80211_caphdr *)datap;
3386
3387 caphdr->version = htonl(P80211CAPTURE_VERSION);
3388 caphdr->length = htonl(sizeof(struct p80211_caphdr));
3389 caphdr->mactime = __cpu_to_be64(rxdesc->time * 1000);
3390 caphdr->hosttime = __cpu_to_be64(jiffies);
3391 caphdr->phytype = htonl(4);
3392 caphdr->channel = htonl(hw->sniff_channel);
3393 caphdr->datarate = htonl(rxdesc->rate);
3394 caphdr->antenna = htonl(0);
3395 caphdr->priority = htonl(0);
3396 caphdr->ssi_type = htonl(3);
3397 caphdr->ssi_signal = htonl(rxdesc->signal);
3398 caphdr->ssi_noise = htonl(rxdesc->silence);
3399 caphdr->preamble = htonl(0);
3400 caphdr->encoding = htonl(1);
3401 }
3402
3403
3404
3405
3406 skb_put_data(skb, &rxdesc->hdr.frame_control, hdrlen);
3407
3408
3409 if (datalen > 0) {
3410 datap = skb_put_data(skb, rxfrm->data, datalen);
3411
3412
3413 if (*(datap - hdrlen + 1) & 0x40)
3414 if ((*(datap) == 0xaa) && (*(datap + 1) == 0xaa))
3415
3416 *(datap - hdrlen + 1) &= 0xbf;
3417 }
3418
3419 if (hw->sniff_fcs) {
3420
3421 datap = skb_put(skb, WLAN_CRC_LEN);
3422 memset(datap, 0xff, WLAN_CRC_LEN);
3423 }
3424
3425
3426 p80211netdev_rx(wlandev, skb);
3427 }
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447 static void hfa384x_usbin_info(struct wlandevice *wlandev,
3448 union hfa384x_usbin *usbin)
3449 {
3450 le16_to_cpus(&usbin->infofrm.info.framelen);
3451 prism2sta_ev_info(wlandev, &usbin->infofrm.info);
3452 }
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471 static void hfa384x_usbout_callback(struct urb *urb)
3472 {
3473 struct wlandevice *wlandev = urb->context;
3474
3475 #ifdef DEBUG_USB
3476 dbprint_urb(urb);
3477 #endif
3478
3479 if (wlandev && wlandev->netdev) {
3480 switch (urb->status) {
3481 case 0:
3482 prism2sta_ev_alloc(wlandev);
3483 break;
3484
3485 case -EPIPE: {
3486 struct hfa384x *hw = wlandev->priv;
3487
3488 netdev_warn(hw->wlandev->netdev,
3489 "%s tx pipe stalled: requesting reset\n",
3490 wlandev->netdev->name);
3491 if (!test_and_set_bit(WORK_TX_HALT, &hw->usb_flags))
3492 schedule_work(&hw->usb_work);
3493 wlandev->netdev->stats.tx_errors++;
3494 break;
3495 }
3496
3497 case -EPROTO:
3498 case -ETIMEDOUT:
3499 case -EILSEQ: {
3500 struct hfa384x *hw = wlandev->priv;
3501
3502 if (!test_and_set_bit(THROTTLE_TX, &hw->usb_flags) &&
3503 !timer_pending(&hw->throttle)) {
3504 mod_timer(&hw->throttle,
3505 jiffies + THROTTLE_JIFFIES);
3506 }
3507 wlandev->netdev->stats.tx_errors++;
3508 netif_stop_queue(wlandev->netdev);
3509 break;
3510 }
3511
3512 case -ENOENT:
3513 case -ESHUTDOWN:
3514
3515 break;
3516
3517 default:
3518 netdev_info(wlandev->netdev, "unknown urb->status=%d\n",
3519 urb->status);
3520 wlandev->netdev->stats.tx_errors++;
3521 break;
3522 }
3523 }
3524 }
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543 static void hfa384x_ctlxout_callback(struct urb *urb)
3544 {
3545 struct hfa384x *hw = urb->context;
3546 int delete_resptimer = 0;
3547 int timer_ok = 1;
3548 int run_queue = 0;
3549 struct hfa384x_usbctlx *ctlx;
3550 unsigned long flags;
3551
3552 pr_debug("urb->status=%d\n", urb->status);
3553 #ifdef DEBUG_USB
3554 dbprint_urb(urb);
3555 #endif
3556 if ((urb->status == -ESHUTDOWN) ||
3557 (urb->status == -ENODEV) || !hw)
3558 return;
3559
3560 retry:
3561 spin_lock_irqsave(&hw->ctlxq.lock, flags);
3562
3563
3564
3565
3566
3567
3568
3569 if (list_empty(&hw->ctlxq.active)) {
3570 spin_unlock_irqrestore(&hw->ctlxq.lock, flags);
3571 return;
3572 }
3573
3574
3575
3576
3577
3578 if (del_timer(&hw->reqtimer) == 0) {
3579 if (hw->req_timer_done == 0) {
3580
3581
3582
3583
3584
3585 spin_unlock_irqrestore(&hw->ctlxq.lock, flags);
3586 goto retry;
3587 }
3588 } else {
3589 hw->req_timer_done = 1;
3590 }
3591
3592 ctlx = get_active_ctlx(hw);
3593
3594 if (urb->status == 0) {
3595
3596 switch (ctlx->state) {
3597 case CTLX_REQ_SUBMITTED:
3598
3599 ctlx->state = CTLX_REQ_COMPLETE;
3600 break;
3601
3602 case CTLX_RESP_COMPLETE:
3603
3604
3605
3606 ctlx->state = CTLX_COMPLETE;
3607 unlocked_usbctlx_complete(hw, ctlx);
3608 run_queue = 1;
3609 break;
3610
3611 default:
3612
3613 netdev_err(hw->wlandev->netdev,
3614 "Illegal CTLX[%d] success state(%s, %d) in OUT URB\n",
3615 le16_to_cpu(ctlx->outbuf.type),
3616 ctlxstr(ctlx->state), urb->status);
3617 break;
3618 }
3619 } else {
3620
3621 if ((urb->status == -EPIPE) &&
3622 !test_and_set_bit(WORK_TX_HALT, &hw->usb_flags)) {
3623 netdev_warn(hw->wlandev->netdev,
3624 "%s tx pipe stalled: requesting reset\n",
3625 hw->wlandev->netdev->name);
3626 schedule_work(&hw->usb_work);
3627 }
3628
3629
3630
3631
3632 ctlx->state = CTLX_REQ_FAILED;
3633 unlocked_usbctlx_complete(hw, ctlx);
3634 delete_resptimer = 1;
3635 run_queue = 1;
3636 }
3637
3638 delresp:
3639 if (delete_resptimer) {
3640 timer_ok = del_timer(&hw->resptimer);
3641 if (timer_ok != 0)
3642 hw->resp_timer_done = 1;
3643 }
3644
3645 spin_unlock_irqrestore(&hw->ctlxq.lock, flags);
3646
3647 if (!timer_ok && (hw->resp_timer_done == 0)) {
3648 spin_lock_irqsave(&hw->ctlxq.lock, flags);
3649 goto delresp;
3650 }
3651
3652 if (run_queue)
3653 hfa384x_usbctlxq_run(hw);
3654 }
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675 static void hfa384x_usbctlx_reqtimerfn(struct timer_list *t)
3676 {
3677 struct hfa384x *hw = from_timer(hw, t, reqtimer);
3678 unsigned long flags;
3679
3680 spin_lock_irqsave(&hw->ctlxq.lock, flags);
3681
3682 hw->req_timer_done = 1;
3683
3684
3685
3686
3687 if (!list_empty(&hw->ctlxq.active)) {
3688
3689
3690
3691
3692 hw->ctlx_urb.transfer_flags |= URB_ASYNC_UNLINK;
3693 if (usb_unlink_urb(&hw->ctlx_urb) == -EINPROGRESS) {
3694 struct hfa384x_usbctlx *ctlx = get_active_ctlx(hw);
3695
3696 ctlx->state = CTLX_REQ_FAILED;
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707 if (del_timer(&hw->resptimer) != 0)
3708 hw->resp_timer_done = 1;
3709 }
3710 }
3711
3712 spin_unlock_irqrestore(&hw->ctlxq.lock, flags);
3713 }
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734 static void hfa384x_usbctlx_resptimerfn(struct timer_list *t)
3735 {
3736 struct hfa384x *hw = from_timer(hw, t, resptimer);
3737 unsigned long flags;
3738
3739 spin_lock_irqsave(&hw->ctlxq.lock, flags);
3740
3741 hw->resp_timer_done = 1;
3742
3743
3744
3745
3746 if (!list_empty(&hw->ctlxq.active)) {
3747 struct hfa384x_usbctlx *ctlx = get_active_ctlx(hw);
3748
3749 if (unlocked_usbctlx_cancel_async(hw, ctlx) == 0) {
3750 spin_unlock_irqrestore(&hw->ctlxq.lock, flags);
3751 hfa384x_usbctlxq_run(hw);
3752 return;
3753 }
3754 }
3755 spin_unlock_irqrestore(&hw->ctlxq.lock, flags);
3756 }
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774 static void hfa384x_usb_throttlefn(struct timer_list *t)
3775 {
3776 struct hfa384x *hw = from_timer(hw, t, throttle);
3777 unsigned long flags;
3778
3779 spin_lock_irqsave(&hw->ctlxq.lock, flags);
3780
3781 pr_debug("flags=0x%lx\n", hw->usb_flags);
3782 if (!hw->wlandev->hwremoved) {
3783 bool rx_throttle = test_and_clear_bit(THROTTLE_RX, &hw->usb_flags) &&
3784 !test_and_set_bit(WORK_RX_RESUME, &hw->usb_flags);
3785 bool tx_throttle = test_and_clear_bit(THROTTLE_TX, &hw->usb_flags) &&
3786 !test_and_set_bit(WORK_TX_RESUME, &hw->usb_flags);
3787
3788
3789
3790
3791 if (rx_throttle | tx_throttle)
3792 schedule_work(&hw->usb_work);
3793 }
3794
3795 spin_unlock_irqrestore(&hw->ctlxq.lock, flags);
3796 }
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817 static int hfa384x_usbctlx_submit(struct hfa384x *hw,
3818 struct hfa384x_usbctlx *ctlx)
3819 {
3820 unsigned long flags;
3821
3822 spin_lock_irqsave(&hw->ctlxq.lock, flags);
3823
3824 if (hw->wlandev->hwremoved) {
3825 spin_unlock_irqrestore(&hw->ctlxq.lock, flags);
3826 return -ENODEV;
3827 }
3828
3829 ctlx->state = CTLX_PENDING;
3830 list_add_tail(&ctlx->list, &hw->ctlxq.pending);
3831 spin_unlock_irqrestore(&hw->ctlxq.lock, flags);
3832 hfa384x_usbctlxq_run(hw);
3833
3834 return 0;
3835 }
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854 static int hfa384x_isgood_pdrcode(u16 pdrcode)
3855 {
3856 switch (pdrcode) {
3857 case HFA384x_PDR_END_OF_PDA:
3858 case HFA384x_PDR_PCB_PARTNUM:
3859 case HFA384x_PDR_PDAVER:
3860 case HFA384x_PDR_NIC_SERIAL:
3861 case HFA384x_PDR_MKK_MEASUREMENTS:
3862 case HFA384x_PDR_NIC_RAMSIZE:
3863 case HFA384x_PDR_MFISUPRANGE:
3864 case HFA384x_PDR_CFISUPRANGE:
3865 case HFA384x_PDR_NICID:
3866 case HFA384x_PDR_MAC_ADDRESS:
3867 case HFA384x_PDR_REGDOMAIN:
3868 case HFA384x_PDR_ALLOWED_CHANNEL:
3869 case HFA384x_PDR_DEFAULT_CHANNEL:
3870 case HFA384x_PDR_TEMPTYPE:
3871 case HFA384x_PDR_IFR_SETTING:
3872 case HFA384x_PDR_RFR_SETTING:
3873 case HFA384x_PDR_HFA3861_BASELINE:
3874 case HFA384x_PDR_HFA3861_SHADOW:
3875 case HFA384x_PDR_HFA3861_IFRF:
3876 case HFA384x_PDR_HFA3861_CHCALSP:
3877 case HFA384x_PDR_HFA3861_CHCALI:
3878 case HFA384x_PDR_3842_NIC_CONFIG:
3879 case HFA384x_PDR_USB_ID:
3880 case HFA384x_PDR_PCI_ID:
3881 case HFA384x_PDR_PCI_IFCONF:
3882 case HFA384x_PDR_PCI_PMCONF:
3883 case HFA384x_PDR_RFENRGY:
3884 case HFA384x_PDR_HFA3861_MANF_TESTSP:
3885 case HFA384x_PDR_HFA3861_MANF_TESTI:
3886
3887 return 1;
3888 default:
3889 if (pdrcode < 0x1000) {
3890
3891 pr_debug("Encountered unknown PDR#=0x%04x, assuming it's ok.\n",
3892 pdrcode);
3893 return 1;
3894 }
3895 break;
3896 }
3897
3898 pr_debug("Encountered unknown PDR#=0x%04x, (>=0x1000), assuming it's bad.\n",
3899 pdrcode);
3900 return 0;
3901 }