drivers/net/wireless/mediatek/mt76/mt76x02_mac.c
Source file repositories/reference/linux-study-clean/drivers/net/wireless/mediatek/mt76/mt76x02_mac.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/wireless/mediatek/mt76/mt76x02_mac.c- Extension
.c- Size
- 31708 bytes
- Lines
- 1239
- 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
mt76x02.hmt76x02_trace.htrace.h
Detected Declarations
function Copyrightfunction mt76x02_mac_get_key_infofunction mt76x02_mac_shared_key_setupfunction mt76x02_mac_wcid_sync_pnfunction mt76x02_mac_wcid_set_keyfunction mt76x02_mac_wcid_setupfunction mt76x02_mac_wcid_set_dropfunction mt76x02_mac_tx_rate_valfunction mt76x02_mac_wcid_set_ratefunction mt76x02_mac_set_short_preamblefunction mt76x02_mac_load_tx_statusfunction mt76x02_mac_process_tx_ratefunction mt76x02_mac_write_txwifunction mt76x02_tx_rate_fallbackfunction mt76x02_mac_fill_tx_statusfunction mt76x02_send_tx_statusfunction mt76x02_mac_process_ratefunction mt76x02_mac_setaddrfunction mt76x02_mac_get_rssifunction mt76x02_mac_process_rxfunction mt76x02_mac_poll_tx_statusfunction mt76x02_tx_complete_skbfunction mt76x02_mac_set_rts_threshfunction mt76x02_mac_set_tx_protectionfunction mt76x02_update_channelfunction mt76x02_check_mac_errfunction mt76x02_edcca_tx_enablefunction mt76x02_edcca_initfunction mt76x02_edcca_checkfunction time_is_after_jiffiesfunction mt76x02_mac_workfunction mt76x02_mac_cc_resetfunction mt76x02_mac_set_bssidexport mt76x02_mac_reset_countersexport mt76x02_mac_shared_key_setupexport mt76x02_mac_wcid_setupexport mt76x02_mac_write_txwiexport mt76x02_mac_setaddrexport mt76x02_tx_complete_skbexport mt76x02_update_channelexport mt76x02_edcca_initexport mt76x02_mac_cc_reset
Annotated Snippet
if (cipher >= MT76X02_CIPHER_TKIP) {
iv_data[3] |= 0x20;
put_unaligned_le32(pn >> 16, &iv_data[4]);
}
if (cipher == MT76X02_CIPHER_TKIP) {
iv_data[0] = (pn >> 8) & 0xff;
iv_data[1] = (iv_data[0] | 0x20) & 0x7f;
iv_data[2] = pn & 0xff;
} else if (cipher >= MT76X02_CIPHER_AES_CCMP) {
put_unaligned_le16((pn & 0xffff), &iv_data[0]);
}
}
mt76_wr_copy(dev, MT_WCID_IV(idx), iv_data, sizeof(iv_data));
return 0;
}
void mt76x02_mac_wcid_setup(struct mt76x02_dev *dev, u8 idx,
u8 vif_idx, u8 *mac)
{
struct mt76_wcid_addr addr = {};
u32 attr;
attr = FIELD_PREP(MT_WCID_ATTR_BSS_IDX, vif_idx & 7) |
FIELD_PREP(MT_WCID_ATTR_BSS_IDX_EXT, !!(vif_idx & 8));
mt76_wr(dev, MT_WCID_ATTR(idx), attr);
if (idx >= 128)
return;
if (mac)
memcpy(addr.macaddr, mac, ETH_ALEN);
mt76_wr_copy(dev, MT_WCID_ADDR(idx), &addr, sizeof(addr));
}
EXPORT_SYMBOL_GPL(mt76x02_mac_wcid_setup);
void mt76x02_mac_wcid_set_drop(struct mt76x02_dev *dev, u8 idx, bool drop)
{
u32 val = mt76_rr(dev, MT_WCID_DROP(idx));
u32 bit = MT_WCID_DROP_MASK(idx);
/* prevent unnecessary writes */
if ((val & bit) != (bit * drop))
mt76_wr(dev, MT_WCID_DROP(idx), (val & ~bit) | (bit * drop));
}
static u16
mt76x02_mac_tx_rate_val(struct mt76x02_dev *dev,
const struct ieee80211_tx_rate *rate, u8 *nss_val)
{
u8 phy, rate_idx, nss, bw = 0;
u16 rateval;
if (rate->flags & IEEE80211_TX_RC_VHT_MCS) {
rate_idx = rate->idx;
nss = 1 + (rate->idx >> 4);
phy = MT_PHY_TYPE_VHT;
if (rate->flags & IEEE80211_TX_RC_80_MHZ_WIDTH)
bw = 2;
else if (rate->flags & IEEE80211_TX_RC_40_MHZ_WIDTH)
bw = 1;
} else if (rate->flags & IEEE80211_TX_RC_MCS) {
rate_idx = rate->idx;
nss = 1 + (rate->idx >> 3);
phy = MT_PHY_TYPE_HT;
if (rate->flags & IEEE80211_TX_RC_GREEN_FIELD)
phy = MT_PHY_TYPE_HT_GF;
if (rate->flags & IEEE80211_TX_RC_40_MHZ_WIDTH)
bw = 1;
} else {
const struct ieee80211_rate *r;
int band = dev->mphy.chandef.chan->band;
u16 val;
r = &dev->mt76.hw->wiphy->bands[band]->bitrates[rate->idx];
if (rate->flags & IEEE80211_TX_RC_USE_SHORT_PREAMBLE)
val = r->hw_value_short;
else
val = r->hw_value;
phy = val >> 8;
rate_idx = val & 0xff;
nss = 1;
}
rateval = FIELD_PREP(MT_RXWI_RATE_INDEX, rate_idx);
Annotation
- Immediate include surface: `mt76x02.h`, `mt76x02_trace.h`, `trace.h`.
- Detected declarations: `function Copyright`, `function mt76x02_mac_get_key_info`, `function mt76x02_mac_shared_key_setup`, `function mt76x02_mac_wcid_sync_pn`, `function mt76x02_mac_wcid_set_key`, `function mt76x02_mac_wcid_setup`, `function mt76x02_mac_wcid_set_drop`, `function mt76x02_mac_tx_rate_val`, `function mt76x02_mac_wcid_set_rate`, `function mt76x02_mac_set_short_preamble`.
- 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.