Lines Matching refs:cardp
44 static int usb_tx_block(struct if_usb_card *cardp, uint8_t *payload,
46 static void if_usb_free(struct if_usb_card *cardp);
47 static int if_usb_submit_rx_urb(struct if_usb_card *cardp);
72 static void if_usb_free(struct if_usb_card *cardp) in if_usb_free() argument
77 usb_kill_urb(cardp->tx_urb); in if_usb_free()
78 usb_kill_urb(cardp->rx_urb); in if_usb_free()
79 usb_kill_urb(cardp->cmd_urb); in if_usb_free()
81 usb_free_urb(cardp->tx_urb); in if_usb_free()
82 cardp->tx_urb = NULL; in if_usb_free()
84 usb_free_urb(cardp->rx_urb); in if_usb_free()
85 cardp->rx_urb = NULL; in if_usb_free()
87 usb_free_urb(cardp->cmd_urb); in if_usb_free()
88 cardp->cmd_urb = NULL; in if_usb_free()
90 kfree(cardp->ep_out_buf); in if_usb_free()
91 cardp->ep_out_buf = NULL; in if_usb_free()
98 struct if_usb_card *cardp = priv->card; in if_usb_setup_firmware() local
103 if_usb_submit_rx_urb(cardp); in if_usb_setup_firmware()
106 b2_cmd.version = cardp->boot2_version; in if_usb_setup_firmware()
116 struct if_usb_card *cardp = from_timer(cardp, t, fw_timeout); in if_usb_fw_timeo() local
119 if (!cardp->fwdnldover) { in if_usb_fw_timeo()
121 cardp->priv->surpriseremoved = 1; in if_usb_fw_timeo()
126 wake_up(&cardp->fw_wq); in if_usb_fw_timeo()
151 struct if_usb_card *cardp; in if_usb_probe() local
157 cardp = kzalloc(sizeof(struct if_usb_card), GFP_KERNEL); in if_usb_probe()
158 if (!cardp) in if_usb_probe()
161 timer_setup(&cardp->fw_timeout, if_usb_fw_timeo, 0); in if_usb_probe()
162 init_waitqueue_head(&cardp->fw_wq); in if_usb_probe()
164 cardp->udev = udev; in if_usb_probe()
177 cardp->ep_in_size = in if_usb_probe()
179 cardp->ep_in = usb_endpoint_num(endpoint); in if_usb_probe()
182 cardp->ep_in); in if_usb_probe()
184 cardp->ep_in_size); in if_usb_probe()
186 cardp->ep_out_size = in if_usb_probe()
188 cardp->ep_out = usb_endpoint_num(endpoint); in if_usb_probe()
191 cardp->ep_out); in if_usb_probe()
193 cardp->ep_out_size); in if_usb_probe()
196 if (!cardp->ep_out_size || !cardp->ep_in_size) { in if_usb_probe()
202 cardp->rx_urb = usb_alloc_urb(0, GFP_KERNEL); in if_usb_probe()
203 if (!cardp->rx_urb) in if_usb_probe()
206 cardp->tx_urb = usb_alloc_urb(0, GFP_KERNEL); in if_usb_probe()
207 if (!cardp->tx_urb) in if_usb_probe()
210 cardp->cmd_urb = usb_alloc_urb(0, GFP_KERNEL); in if_usb_probe()
211 if (!cardp->cmd_urb) in if_usb_probe()
214 cardp->ep_out_buf = kmalloc(MRVDRV_ETH_TX_PACKET_BUFFER_SIZE, in if_usb_probe()
216 if (!cardp->ep_out_buf) { in if_usb_probe()
221 cardp->boot2_version = udev->descriptor.bcdDevice; in if_usb_probe()
222 priv = lbtf_add_card(cardp, &udev->dev, &if_usb_ops); in if_usb_probe()
227 usb_set_intfdata(intf, cardp); in if_usb_probe()
232 if_usb_free(cardp); in if_usb_probe()
233 kfree(cardp); in if_usb_probe()
246 struct if_usb_card *cardp = usb_get_intfdata(intf); in if_usb_disconnect() local
247 struct lbtf_private *priv = cardp->priv; in if_usb_disconnect()
257 if_usb_free(cardp); in if_usb_disconnect()
258 kfree(cardp); in if_usb_disconnect()
273 static int if_usb_send_fw_pkt(struct if_usb_card *cardp) in if_usb_send_fw_pkt() argument
275 struct fwdata *fwdata = cardp->ep_out_buf; in if_usb_send_fw_pkt()
276 u8 *firmware = (u8 *) cardp->fw->data; in if_usb_send_fw_pkt()
282 if (!cardp->CRC_OK) { in if_usb_send_fw_pkt()
283 cardp->totalbytes = cardp->fwlastblksent; in if_usb_send_fw_pkt()
284 cardp->fwseqnum--; in if_usb_send_fw_pkt()
287 lbtf_deb_usb2(&cardp->udev->dev, "totalbytes = %d\n", in if_usb_send_fw_pkt()
288 cardp->totalbytes); in if_usb_send_fw_pkt()
294 memcpy(&fwdata->hdr, &firmware[cardp->totalbytes], in if_usb_send_fw_pkt()
297 cardp->fwlastblksent = cardp->totalbytes; in if_usb_send_fw_pkt()
298 cardp->totalbytes += sizeof(struct fwheader); in if_usb_send_fw_pkt()
300 memcpy(fwdata->data, &firmware[cardp->totalbytes], in if_usb_send_fw_pkt()
303 lbtf_deb_usb2(&cardp->udev->dev, "Data length = %d\n", in if_usb_send_fw_pkt()
306 fwdata->seqnum = cpu_to_le32(++cardp->fwseqnum); in if_usb_send_fw_pkt()
307 cardp->totalbytes += le32_to_cpu(fwdata->hdr.datalength); in if_usb_send_fw_pkt()
309 usb_tx_block(cardp, cardp->ep_out_buf, sizeof(struct fwdata) + in if_usb_send_fw_pkt()
313 lbtf_deb_usb2(&cardp->udev->dev, "There are data to follow\n"); in if_usb_send_fw_pkt()
314 lbtf_deb_usb2(&cardp->udev->dev, in if_usb_send_fw_pkt()
316 cardp->fwseqnum, cardp->totalbytes); in if_usb_send_fw_pkt()
318 lbtf_deb_usb2(&cardp->udev->dev, in if_usb_send_fw_pkt()
320 lbtf_deb_usb2(&cardp->udev->dev, "Downloading FW JUMP BLOCK\n"); in if_usb_send_fw_pkt()
325 cardp->fwfinalblk = 1; in if_usb_send_fw_pkt()
328 lbtf_deb_usb2(&cardp->udev->dev, "Firmware download done; size %d\n", in if_usb_send_fw_pkt()
329 cardp->totalbytes); in if_usb_send_fw_pkt()
337 struct if_usb_card *cardp = priv->card; in if_usb_reset_device() local
338 struct cmd_ds_802_11_reset *cmd = cardp->ep_out_buf + 4; in if_usb_reset_device()
343 *(__le32 *)cardp->ep_out_buf = cpu_to_le32(CMD_TYPE_REQUEST); in if_usb_reset_device()
350 usb_tx_block(cardp, cardp->ep_out_buf, in if_usb_reset_device()
354 ret = usb_reset_device(cardp->udev); in if_usb_reset_device()
372 static int usb_tx_block(struct if_usb_card *cardp, uint8_t *payload, in usb_tx_block() argument
380 if (cardp->priv->surpriseremoved) { in usb_tx_block()
381 lbtf_deb_usbd(&cardp->udev->dev, "Device removed\n"); in usb_tx_block()
386 urb = cardp->tx_urb; in usb_tx_block()
388 urb = cardp->cmd_urb; in usb_tx_block()
390 usb_fill_bulk_urb(urb, cardp->udev, in usb_tx_block()
391 usb_sndbulkpipe(cardp->udev, in usb_tx_block()
392 cardp->ep_out), in usb_tx_block()
393 payload, nb, if_usb_write_bulk_callback, cardp); in usb_tx_block()
398 lbtf_deb_usbd(&cardp->udev->dev, in usb_tx_block()
403 lbtf_deb_usb2(&cardp->udev->dev, "usb_submit_urb success\n"); in usb_tx_block()
412 static int __if_usb_submit_rx_urb(struct if_usb_card *cardp, in __if_usb_submit_rx_urb() argument
427 cardp->rx_skb = skb; in __if_usb_submit_rx_urb()
430 usb_fill_bulk_urb(cardp->rx_urb, cardp->udev, in __if_usb_submit_rx_urb()
431 usb_rcvbulkpipe(cardp->udev, cardp->ep_in), in __if_usb_submit_rx_urb()
433 MRVDRV_ETH_RX_PACKET_BUFFER_SIZE, callbackfn, cardp); in __if_usb_submit_rx_urb()
435 lbtf_deb_usb2(&cardp->udev->dev, "Pointer for rx_urb %p\n", in __if_usb_submit_rx_urb()
436 cardp->rx_urb); in __if_usb_submit_rx_urb()
437 ret = usb_submit_urb(cardp->rx_urb, GFP_ATOMIC); in __if_usb_submit_rx_urb()
439 lbtf_deb_usbd(&cardp->udev->dev, in __if_usb_submit_rx_urb()
442 cardp->rx_skb = NULL; in __if_usb_submit_rx_urb()
446 lbtf_deb_usb2(&cardp->udev->dev, "Submit Rx URB success\n"); in __if_usb_submit_rx_urb()
452 static int if_usb_submit_rx_urb_fwload(struct if_usb_card *cardp) in if_usb_submit_rx_urb_fwload() argument
454 return __if_usb_submit_rx_urb(cardp, &if_usb_receive_fwload); in if_usb_submit_rx_urb_fwload()
457 static int if_usb_submit_rx_urb(struct if_usb_card *cardp) in if_usb_submit_rx_urb() argument
459 return __if_usb_submit_rx_urb(cardp, &if_usb_receive); in if_usb_submit_rx_urb()
464 struct if_usb_card *cardp = urb->context; in if_usb_receive_fwload() local
465 struct sk_buff *skb = cardp->rx_skb; in if_usb_receive_fwload()
471 lbtf_deb_usbd(&cardp->udev->dev, in if_usb_receive_fwload()
478 if (cardp->fwdnldover) { in if_usb_receive_fwload()
485 wake_up(&cardp->fw_wq); in if_usb_receive_fwload()
489 if_usb_submit_rx_urb_fwload(cardp); in if_usb_receive_fwload()
495 if (cardp->bootcmdresp <= 0) { in if_usb_receive_fwload()
498 if (le16_to_cpu(cardp->udev->descriptor.bcdDevice) < 0x3106) { in if_usb_receive_fwload()
500 if_usb_submit_rx_urb_fwload(cardp); in if_usb_receive_fwload()
501 cardp->bootcmdresp = 1; in if_usb_receive_fwload()
503 lbtf_deb_usbd(&cardp->udev->dev, in if_usb_receive_fwload()
512 if (!cardp->bootcmdresp) in if_usb_receive_fwload()
514 cardp->bootcmdresp = -1; in if_usb_receive_fwload()
526 cardp->bootcmdresp = 1; in if_usb_receive_fwload()
527 lbtf_deb_usbd(&cardp->udev->dev, in if_usb_receive_fwload()
532 if_usb_submit_rx_urb_fwload(cardp); in if_usb_receive_fwload()
540 lbtf_deb_usbd(&cardp->udev->dev, in if_usb_receive_fwload()
548 lbtf_deb_usb2(&cardp->udev->dev, in if_usb_receive_fwload()
550 lbtf_deb_usb2(&cardp->udev->dev, in if_usb_receive_fwload()
553 cardp->CRC_OK = 1; in if_usb_receive_fwload()
555 lbtf_deb_usbd(&cardp->udev->dev, in if_usb_receive_fwload()
557 cardp->CRC_OK = 0; in if_usb_receive_fwload()
563 mod_timer(&cardp->fw_timeout, jiffies + (HZ/5)); in if_usb_receive_fwload()
565 if (cardp->fwfinalblk) { in if_usb_receive_fwload()
566 cardp->fwdnldover = 1; in if_usb_receive_fwload()
570 if_usb_send_fw_pkt(cardp); in if_usb_receive_fwload()
573 if_usb_submit_rx_urb_fwload(cardp); in if_usb_receive_fwload()
583 struct if_usb_card *cardp, in process_cmdtypedata() argument
588 lbtf_deb_usbd(&cardp->udev->dev, "Packet length is Invalid\n"); in process_cmdtypedata()
600 struct if_usb_card *cardp, in process_cmdrequest() argument
607 lbtf_deb_usbd(&cardp->udev->dev, in process_cmdrequest()
628 struct if_usb_card *cardp = urb->context; in if_usb_receive() local
629 struct sk_buff *skb = cardp->rx_skb; in if_usb_receive()
630 struct lbtf_private *priv = cardp->priv; in if_usb_receive()
640 lbtf_deb_usbd(&cardp->udev->dev, "RX URB failed: %d\n", in if_usb_receive()
648 lbtf_deb_usbd(&cardp->udev->dev, in if_usb_receive()
659 process_cmdtypedata(recvlength, skb, cardp, priv); in if_usb_receive()
663 process_cmdrequest(recvlength, recvbuff, skb, cardp, priv); in if_usb_receive()
670 lbtf_deb_usbd(&cardp->udev->dev, "**EVENT** 0x%X\n", in if_usb_receive()
686 lbtf_deb_usbd(&cardp->udev->dev, in if_usb_receive()
693 lbtf_deb_usbd(&cardp->udev->dev, in if_usb_receive()
700 if_usb_submit_rx_urb(cardp); in if_usb_receive()
717 struct if_usb_card *cardp = priv->card; in if_usb_host_to_card() local
720 lbtf_deb_usbd(&cardp->udev->dev, "*** type = %u\n", type); in if_usb_host_to_card()
721 lbtf_deb_usbd(&cardp->udev->dev, "size after = %d\n", nb); in if_usb_host_to_card()
724 *(__le32 *)cardp->ep_out_buf = cpu_to_le32(CMD_TYPE_REQUEST); in if_usb_host_to_card()
726 *(__le32 *)cardp->ep_out_buf = cpu_to_le32(CMD_TYPE_DATA); in if_usb_host_to_card()
730 memcpy((cardp->ep_out_buf + MESSAGE_HEADER_LEN), payload, nb); in if_usb_host_to_card()
732 return usb_tx_block(cardp, cardp->ep_out_buf, nb + MESSAGE_HEADER_LEN, in if_usb_host_to_card()
744 static int if_usb_issue_boot_command(struct if_usb_card *cardp, int ivalue) in if_usb_issue_boot_command() argument
746 struct bootcmd *bootcmd = cardp->ep_out_buf; in if_usb_issue_boot_command()
754 usb_tx_block(cardp, cardp->ep_out_buf, sizeof(*bootcmd), 0); in if_usb_issue_boot_command()
811 struct if_usb_card *cardp = priv->card; in if_usb_prog_firmware() local
818 cardp->priv = priv; in if_usb_prog_firmware()
821 ret = request_firmware(&cardp->fw, lbtf_fw_name, &cardp->udev->dev); in if_usb_prog_firmware()
830 if (check_fwfile_format(cardp->fw->data, cardp->fw->size)) in if_usb_prog_firmware()
834 if (if_usb_submit_rx_urb_fwload(cardp) < 0) { in if_usb_prog_firmware()
835 lbtf_deb_usbd(&cardp->udev->dev, "URB submission is failed\n"); in if_usb_prog_firmware()
840 cardp->bootcmdresp = 0; in if_usb_prog_firmware()
845 if_usb_issue_boot_command(cardp, BOOT_CMD_FW_BY_USB); in if_usb_prog_firmware()
850 } while (cardp->bootcmdresp == 0 && j < 10); in if_usb_prog_firmware()
851 } while (cardp->bootcmdresp == 0 && i < 5); in if_usb_prog_firmware()
853 if (cardp->bootcmdresp <= 0) { in if_usb_prog_firmware()
863 cardp->totalbytes = 0; in if_usb_prog_firmware()
864 cardp->fwlastblksent = 0; in if_usb_prog_firmware()
865 cardp->CRC_OK = 1; in if_usb_prog_firmware()
866 cardp->fwdnldover = 0; in if_usb_prog_firmware()
867 cardp->fwseqnum = -1; in if_usb_prog_firmware()
868 cardp->totalbytes = 0; in if_usb_prog_firmware()
869 cardp->fwfinalblk = 0; in if_usb_prog_firmware()
872 if_usb_send_fw_pkt(cardp); in if_usb_prog_firmware()
875 wait_event_interruptible(cardp->fw_wq, cardp->priv->surpriseremoved || in if_usb_prog_firmware()
876 cardp->fwdnldover); in if_usb_prog_firmware()
878 del_timer_sync(&cardp->fw_timeout); in if_usb_prog_firmware()
879 usb_kill_urb(cardp->rx_urb); in if_usb_prog_firmware()
881 if (!cardp->fwdnldover) { in if_usb_prog_firmware()
894 release_firmware(cardp->fw); in if_usb_prog_firmware()
895 cardp->fw = NULL; in if_usb_prog_firmware()
897 if_usb_setup_firmware(cardp->priv); in if_usb_prog_firmware()