drivers/net/wireless/mediatek/mt7601u/dma.c
Source file repositories/reference/linux-study-clean/drivers/net/wireless/mediatek/mt7601u/dma.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/wireless/mediatek/mt7601u/dma.c- Extension
.c- Size
- 12192 bytes
- Lines
- 552
- 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
mt7601u.hdma.husb.htrace.h
Detected Declarations
function ieee80211_get_hdrlen_from_buffunction mt7601u_rx_skb_from_segfunction mt7601u_rx_process_segfunction mt7601u_rx_next_seg_lenfunction mt7601u_rx_process_entryfunction mt7601u_rx_get_pending_entryfunction mt7601u_complete_rxfunction mt7601u_rx_taskletfunction mt7601u_complete_txfunction mt7601u_tx_taskletfunction mt7601u_dma_submit_txfunction q2epfunction ep2dmaqfunction mt7601u_dma_enqueue_txfunction mt7601u_kill_rxfunction mt7601u_submit_rx_buffunction mt7601u_submit_rxfunction mt7601u_free_rxfunction mt7601u_alloc_rxfunction mt7601u_free_tx_queuefunction mt7601u_free_txfunction mt7601u_alloc_tx_queuefunction mt7601u_alloc_txfunction mt7601u_dma_initfunction mt7601u_dma_cleanup
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright (C) 2015 Jakub Kicinski <kubakici@wp.pl>
*/
#include "mt7601u.h"
#include "dma.h"
#include "usb.h"
#include "trace.h"
static int mt7601u_submit_rx_buf(struct mt7601u_dev *dev,
struct mt7601u_dma_buf_rx *e, gfp_t gfp);
static unsigned int ieee80211_get_hdrlen_from_buf(const u8 *data, unsigned len)
{
const struct ieee80211_hdr *hdr = (const struct ieee80211_hdr *)data;
unsigned int hdrlen;
if (unlikely(len < 10))
return 0;
hdrlen = ieee80211_hdrlen(hdr->frame_control);
if (unlikely(hdrlen > len))
return 0;
return hdrlen;
}
static struct sk_buff *
mt7601u_rx_skb_from_seg(struct mt7601u_dev *dev, struct mt7601u_rxwi *rxwi,
void *data, u32 seg_len, u32 truesize, struct page *p)
{
struct sk_buff *skb;
u32 true_len, hdr_len = 0, copy, frag;
skb = alloc_skb(p ? 128 : seg_len, GFP_ATOMIC);
if (!skb)
return NULL;
true_len = mt76_mac_process_rx(dev, skb, data, rxwi);
if (!true_len || true_len > seg_len)
goto bad_frame;
hdr_len = ieee80211_get_hdrlen_from_buf(data, true_len);
if (!hdr_len)
goto bad_frame;
if (rxwi->rxinfo & cpu_to_le32(MT_RXINFO_L2PAD)) {
skb_put_data(skb, data, hdr_len);
data += hdr_len + 2;
true_len -= hdr_len;
hdr_len = 0;
}
/* If not doing paged RX allocated skb will always have enough space */
copy = (true_len <= skb_tailroom(skb)) ? true_len : hdr_len + 8;
frag = true_len - copy;
skb_put_data(skb, data, copy);
data += copy;
if (frag) {
skb_add_rx_frag(skb, 0, p, data - page_address(p),
frag, truesize);
get_page(p);
}
return skb;
bad_frame:
dev_err_ratelimited(dev->dev, "Error: incorrect frame len:%u hdr:%u\n",
true_len, hdr_len);
dev_kfree_skb(skb);
return NULL;
}
static void mt7601u_rx_process_seg(struct mt7601u_dev *dev, u8 *data,
u32 seg_len, struct page *p,
struct list_head *list)
{
struct sk_buff *skb;
struct mt7601u_rxwi *rxwi;
u32 fce_info, truesize = seg_len;
/* DMA_INFO field at the beginning of the segment contains only some of
* the information, we need to read the FCE descriptor from the end.
*/
fce_info = get_unaligned_le32(data + seg_len - MT_FCE_INFO_LEN);
seg_len -= MT_FCE_INFO_LEN;
data += MT_DMA_HDR_LEN;
Annotation
- Immediate include surface: `mt7601u.h`, `dma.h`, `usb.h`, `trace.h`.
- Detected declarations: `function ieee80211_get_hdrlen_from_buf`, `function mt7601u_rx_skb_from_seg`, `function mt7601u_rx_process_seg`, `function mt7601u_rx_next_seg_len`, `function mt7601u_rx_process_entry`, `function mt7601u_rx_get_pending_entry`, `function mt7601u_complete_rx`, `function mt7601u_rx_tasklet`, `function mt7601u_complete_tx`, `function mt7601u_tx_tasklet`.
- 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.