drivers/net/wireless/marvell/libertas_tf/if_usb.c
Source file repositories/reference/linux-study-clean/drivers/net/wireless/marvell/libertas_tf/if_usb.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/wireless/marvell/libertas_tf/if_usb.c- Extension
.c- Size
- 22883 bytes
- Lines
- 917
- Domain
- Driver Families
- Bucket
- drivers/net
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
libertas_tf.hif_usb.hlinux/delay.hlinux/module.hlinux/firmware.hlinux/netdevice.hlinux/slab.hlinux/usb.h
Detected Declarations
function if_usb_write_bulk_callbackfunction if_usb_freefunction if_usb_setup_firmwarefunction if_usb_fw_timeofunction if_usb_probefunction if_usb_disconnectfunction if_usb_send_fw_pktfunction if_usb_reset_devicefunction usb_tx_blockfunction __if_usb_submit_rx_urbfunction if_usb_submit_rx_urb_fwloadfunction if_usb_submit_rx_urbfunction if_usb_receive_fwloadfunction process_cmdtypedatafunction process_cmdrequestfunction if_usb_receivefunction if_usb_host_to_cardfunction if_usb_issue_boot_commandfunction check_fwfile_formatfunction if_usb_prog_firmware
Annotated Snippet
if (le16_to_cpu(cardp->udev->descriptor.bcdDevice) < 0x3106) {
kfree_skb(skb);
if_usb_submit_rx_urb_fwload(cardp);
cardp->bootcmdresp = 1;
/* Received valid boot command response */
lbtf_deb_usbd(&cardp->udev->dev,
"Received valid boot command response\n");
lbtf_deb_leave(LBTF_DEB_USB);
return;
}
if (bcmdresp.magic != cpu_to_le32(BOOT_CMD_MAGIC_NUMBER)) {
if (bcmdresp.magic == cpu_to_le32(CMD_TYPE_REQUEST) ||
bcmdresp.magic == cpu_to_le32(CMD_TYPE_DATA) ||
bcmdresp.magic == cpu_to_le32(CMD_TYPE_INDICATION)) {
if (!cardp->bootcmdresp)
pr_info("Firmware already seems alive; resetting\n");
cardp->bootcmdresp = -1;
} else {
pr_info("boot cmd response wrong magic number (0x%x)\n",
le32_to_cpu(bcmdresp.magic));
}
} else if (bcmdresp.cmd != BOOT_CMD_FW_BY_USB) {
pr_info("boot cmd response cmd_tag error (%d)\n",
bcmdresp.cmd);
} else if (bcmdresp.result != BOOT_CMD_RESP_OK) {
pr_info("boot cmd response result error (%d)\n",
bcmdresp.result);
} else {
cardp->bootcmdresp = 1;
lbtf_deb_usbd(&cardp->udev->dev,
"Received valid boot command response\n");
}
kfree_skb(skb);
if_usb_submit_rx_urb_fwload(cardp);
lbtf_deb_leave(LBTF_DEB_USB);
return;
}
syncfwheader = kmemdup(skb->data, sizeof(struct fwsyncheader),
GFP_ATOMIC);
if (!syncfwheader) {
lbtf_deb_usbd(&cardp->udev->dev,
"Failure to allocate syncfwheader\n");
kfree_skb(skb);
lbtf_deb_leave(LBTF_DEB_USB);
return;
}
if (!syncfwheader->cmd) {
lbtf_deb_usb2(&cardp->udev->dev,
"FW received Blk with correct CRC\n");
lbtf_deb_usb2(&cardp->udev->dev,
"FW received Blk seqnum = %d\n",
le32_to_cpu(syncfwheader->seqnum));
cardp->CRC_OK = 1;
} else {
lbtf_deb_usbd(&cardp->udev->dev,
"FW received Blk with CRC error\n");
cardp->CRC_OK = 0;
}
kfree_skb(skb);
/* reschedule timer for 200ms hence */
mod_timer(&cardp->fw_timeout, jiffies + (HZ/5));
if (cardp->fwfinalblk) {
cardp->fwdnldover = 1;
goto exit;
}
if_usb_send_fw_pkt(cardp);
exit:
if_usb_submit_rx_urb_fwload(cardp);
kfree(syncfwheader);
lbtf_deb_leave(LBTF_DEB_USB);
}
#define MRVDRV_MIN_PKT_LEN 30
static inline void process_cmdtypedata(int recvlength, struct sk_buff *skb,
struct if_usb_card *cardp,
struct lbtf_private *priv)
{
if (recvlength > MRVDRV_ETH_RX_PACKET_BUFFER_SIZE + MESSAGE_HEADER_LEN
|| recvlength < MRVDRV_MIN_PKT_LEN) {
Annotation
- Immediate include surface: `libertas_tf.h`, `if_usb.h`, `linux/delay.h`, `linux/module.h`, `linux/firmware.h`, `linux/netdevice.h`, `linux/slab.h`, `linux/usb.h`.
- Detected declarations: `function if_usb_write_bulk_callback`, `function if_usb_free`, `function if_usb_setup_firmware`, `function if_usb_fw_timeo`, `function if_usb_probe`, `function if_usb_disconnect`, `function if_usb_send_fw_pkt`, `function if_usb_reset_device`, `function usb_tx_block`, `function __if_usb_submit_rx_urb`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.