drivers/net/wireless/mediatek/mt76/testmode.c
Source file repositories/reference/linux-study-clean/drivers/net/wireless/mediatek/mt76/testmode.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/wireless/mediatek/mt76/testmode.c- Extension
.c- Size
- 17207 bytes
- Lines
- 677
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/random.hmt76.h
Detected Declarations
function mt76_testmode_tx_pendingfunction mt76_testmode_max_mpdu_lenfunction mt76_testmode_free_skbfunction mt76_testmode_alloc_skbfunction mt76_testmode_tx_initfunction mt76_testmode_tx_startfunction mt76_testmode_tx_stopfunction mt76_testmode_param_setfunction mt76_testmode_param_presentfunction mt76_testmode_init_defaultsfunction __mt76_testmode_set_statefunction mt76_testmode_set_statefunction mt76_tm_get_u8function mt76_testmode_cmdfunction nla_for_each_nestedfunction nla_for_each_nestedfunction mt76_testmode_dump_statsfunction mt76_testmode_dumpexport mt76_tm_policyexport mt76_testmode_alloc_skbexport mt76_testmode_set_stateexport mt76_testmode_cmdexport mt76_testmode_dump
Annotated Snippet
if (!frag) {
mt76_testmode_free_skb(phy);
dev_kfree_skb(head);
return -ENOMEM;
}
get_random_bytes(__skb_put(frag, frag_len), frag_len);
head->len += frag->len;
head->data_len += frag->len;
*frag_tail = frag;
frag_tail = &(*frag_tail)->next;
}
mt76_testmode_free_skb(phy);
td->tx_skb = head;
return 0;
}
EXPORT_SYMBOL(mt76_testmode_alloc_skb);
static int
mt76_testmode_tx_init(struct mt76_phy *phy)
{
struct mt76_testmode_data *td = &phy->test;
struct ieee80211_tx_info *info;
struct ieee80211_tx_rate *rate;
u8 max_nss = hweight8(phy->antenna_mask);
int ret;
ret = mt76_testmode_alloc_skb(phy, td->tx_mpdu_len);
if (ret)
return ret;
if (td->tx_rate_mode > MT76_TM_TX_MODE_VHT)
goto out;
if (td->tx_antenna_mask)
max_nss = min_t(u8, max_nss, hweight8(td->tx_antenna_mask));
info = IEEE80211_SKB_CB(td->tx_skb);
rate = &info->control.rates[0];
rate->count = 1;
rate->idx = td->tx_rate_idx;
switch (td->tx_rate_mode) {
case MT76_TM_TX_MODE_CCK:
if (phy->chandef.chan->band != NL80211_BAND_2GHZ)
return -EINVAL;
if (rate->idx > 4)
return -EINVAL;
break;
case MT76_TM_TX_MODE_OFDM:
if (phy->chandef.chan->band != NL80211_BAND_2GHZ)
break;
if (rate->idx > 8)
return -EINVAL;
rate->idx += 4;
break;
case MT76_TM_TX_MODE_HT:
if (rate->idx > 8 * max_nss &&
!(rate->idx == 32 &&
phy->chandef.width >= NL80211_CHAN_WIDTH_40))
return -EINVAL;
rate->flags |= IEEE80211_TX_RC_MCS;
break;
case MT76_TM_TX_MODE_VHT:
if (rate->idx > 9)
return -EINVAL;
if (td->tx_rate_nss > max_nss)
return -EINVAL;
ieee80211_rate_set_vht(rate, td->tx_rate_idx, td->tx_rate_nss);
rate->flags |= IEEE80211_TX_RC_VHT_MCS;
break;
default:
break;
}
if (td->tx_rate_sgi)
rate->flags |= IEEE80211_TX_RC_SHORT_GI;
if (td->tx_rate_ldpc)
info->flags |= IEEE80211_TX_CTL_LDPC;
Annotation
- Immediate include surface: `linux/random.h`, `mt76.h`.
- Detected declarations: `function mt76_testmode_tx_pending`, `function mt76_testmode_max_mpdu_len`, `function mt76_testmode_free_skb`, `function mt76_testmode_alloc_skb`, `function mt76_testmode_tx_init`, `function mt76_testmode_tx_start`, `function mt76_testmode_tx_stop`, `function mt76_testmode_param_set`, `function mt76_testmode_param_present`, `function mt76_testmode_init_defaults`.
- 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.