drivers/net/wireless/mediatek/mt76/usb.c
Source file repositories/reference/linux-study-clean/drivers/net/wireless/mediatek/mt76/usb.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/wireless/mediatek/mt76/usb.c- Extension
.c- Size
- 25578 bytes
- Lines
- 1142
- Domain
- Driver Families
- Bucket
- drivers/net
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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
linux/module.hmt76.husb_trace.hdma.h
Detected Declarations
function __mt76u_vendor_requestfunction mt76u_vendor_requestfunction ___mt76u_rrfunction __mt76u_rrfunction mt76u_rrfunction ___mt76u_wrfunction __mt76u_wrfunction mt76u_wrfunction mt76u_rmwfunction mt76u_copyfunction mt76u_read_copyfunction mt76u_single_wrfunction mt76u_req_wr_rpfunction mt76u_wr_rpfunction mt76u_req_rd_rpfunction mt76u_rd_rpfunction mt76u_check_sgfunction mt76u_set_endpointsfunction mt76u_fill_rx_sgfunction mt76u_refill_rxfunction mt76u_urb_allocfunction mt76u_rx_urb_allocfunction mt76u_urb_freefunction mt76u_fill_bulk_urbfunction mt76u_get_next_rx_entryfunction mt76u_get_rx_entry_lenfunction mt76u_build_rx_skbfunction mt76u_process_rx_entryfunction mt76u_complete_rxfunction mt76u_submit_rx_buffunction mt76u_process_rx_queuefunction mt76u_rx_workerfunction mt76u_submit_rx_buffersfunction mt76u_alloc_rx_queuefunction mt76u_alloc_mcu_queuefunction mt76u_free_rx_queuefunction mt76u_free_rxfunction mt76u_stop_rxfunction mt76_for_each_q_rxfunction mt76u_resume_rxfunction mt76_for_each_q_rxfunction mt76u_status_workerfunction mt76u_tx_status_datafunction mt76u_complete_txfunction mt76u_tx_setup_buffersfunction mt76u_tx_queue_skbfunction mt76u_tx_kickfunction mt76u_ac_to_hwq
Annotated Snippet
if (count > 0) {
err = mt76u_refill_rx(dev, q, urb, count);
if (err < 0)
break;
}
mt76u_submit_rx_buf(dev, qid, urb);
}
if (qid == MT_RXQ_MAIN) {
local_bh_disable();
mt76_rx_poll_complete(dev, MT_RXQ_MAIN, NULL);
local_bh_enable();
}
}
static void mt76u_rx_worker(struct mt76_worker *w)
{
struct mt76_usb *usb = container_of(w, struct mt76_usb, rx_worker);
struct mt76_dev *dev = container_of(usb, struct mt76_dev, usb);
int i;
rcu_read_lock();
mt76_for_each_q_rx(dev, i)
mt76u_process_rx_queue(dev, &dev->q_rx[i]);
rcu_read_unlock();
}
static int
mt76u_submit_rx_buffers(struct mt76_dev *dev, enum mt76_rxq_id qid)
{
struct mt76_queue *q = &dev->q_rx[qid];
unsigned long flags;
int i, err = 0;
spin_lock_irqsave(&q->lock, flags);
for (i = 0; i < q->ndesc; i++) {
err = mt76u_submit_rx_buf(dev, qid, q->entry[i].urb);
if (err < 0)
break;
}
q->head = q->tail = 0;
q->queued = 0;
spin_unlock_irqrestore(&q->lock, flags);
return err;
}
static int
mt76u_alloc_rx_queue(struct mt76_dev *dev, enum mt76_rxq_id qid)
{
struct mt76_queue *q = &dev->q_rx[qid];
int i, err;
err = mt76_create_page_pool(dev, q);
if (err)
return err;
spin_lock_init(&q->lock);
q->entry = devm_kcalloc(dev->dev,
MT_NUM_RX_ENTRIES, sizeof(*q->entry),
GFP_KERNEL);
if (!q->entry)
return -ENOMEM;
q->ndesc = MT_NUM_RX_ENTRIES;
q->buf_size = PAGE_SIZE;
for (i = 0; i < q->ndesc; i++) {
err = mt76u_rx_urb_alloc(dev, q, &q->entry[i]);
if (err < 0)
return err;
}
return mt76u_submit_rx_buffers(dev, qid);
}
int mt76u_alloc_mcu_queue(struct mt76_dev *dev)
{
return mt76u_alloc_rx_queue(dev, MT_RXQ_MCU);
}
EXPORT_SYMBOL_GPL(mt76u_alloc_mcu_queue);
static void
mt76u_free_rx_queue(struct mt76_dev *dev, struct mt76_queue *q)
{
int i;
for (i = 0; i < q->ndesc; i++) {
if (!q->entry[i].urb)
continue;
Annotation
- Immediate include surface: `linux/module.h`, `mt76.h`, `usb_trace.h`, `dma.h`.
- Detected declarations: `function __mt76u_vendor_request`, `function mt76u_vendor_request`, `function ___mt76u_rr`, `function __mt76u_rr`, `function mt76u_rr`, `function ___mt76u_wr`, `function __mt76u_wr`, `function mt76u_wr`, `function mt76u_rmw`, `function mt76u_copy`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: integration 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.