drivers/net/wireless/mediatek/mt76/mt7921/mac.c
Source file repositories/reference/linux-study-clean/drivers/net/wireless/mediatek/mt76/mt7921/mac.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/wireless/mediatek/mt76/mt7921/mac.c- Extension
.c- Size
- 22277 bytes
- Lines
- 875
- 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/devcoredump.hlinux/etherdevice.hlinux/timekeeping.hmt7921.h../dma.h../mt76_connac2_mac.hregd.hmcu.h
Detected Declarations
function mt7921_mac_wtbl_updatefunction mt7921_mac_wtbl_lmac_addrfunction mt7921_mac_sta_pollfunction mt7921_mac_fill_rxfunction mt7921_mac_add_txsfunction mt7921_mac_tx_freefunction list_for_each_entry_safefunction mt7921_rx_checkfunction mt7921_queue_rx_skbfunction mt7921_vif_connect_iterfunction mt7921_mac_reset_workfunction mt7921_coredump_workfunction mt7921_usb_sdio_write_txwifunction mt7921_usb_sdio_tx_prepare_skbfunction mt7921_usb_sdio_tx_complete_skbfunction mt7921_usb_sdio_tx_status_datafunction mt7921_set_ipv6_ns_workexport mt7921_rx_checkexport mt7921_queue_rx_skbexport mt7921_usb_sdio_tx_prepare_skbexport mt7921_usb_sdio_tx_complete_skbexport mt7921_usb_sdio_tx_status_data
Annotated Snippet
if (list_empty(&sta_poll_list)) {
spin_unlock_bh(&dev->mt76.sta_poll_lock);
break;
}
mlink = list_first_entry(&sta_poll_list,
struct mt792x_link_sta,
wcid.poll_list);
msta = container_of(mlink, struct mt792x_sta, deflink);
list_del_init(&mlink->wcid.poll_list);
spin_unlock_bh(&dev->mt76.sta_poll_lock);
idx = mlink->wcid.idx;
addr = mt7921_mac_wtbl_lmac_addr(idx, MT_WTBL_AC0_CTT_OFFSET);
for (i = 0; i < IEEE80211_NUM_ACS; i++) {
u32 tx_last = mlink->airtime_ac[i];
u32 rx_last = mlink->airtime_ac[i + 4];
mlink->airtime_ac[i] = mt76_rr(dev, addr);
mlink->airtime_ac[i + 4] = mt76_rr(dev, addr + 4);
tx_time[i] = mlink->airtime_ac[i] - tx_last;
rx_time[i] = mlink->airtime_ac[i + 4] - rx_last;
if ((tx_last | rx_last) & BIT(30))
clear = true;
addr += 8;
}
if (clear) {
mt7921_mac_wtbl_update(dev, idx,
MT_WTBL_UPDATE_ADM_COUNT_CLEAR);
memset(mlink->airtime_ac, 0, sizeof(mlink->airtime_ac));
}
if (!mlink->wcid.sta)
continue;
sta = container_of((void *)msta, struct ieee80211_sta,
drv_priv);
for (i = 0; i < IEEE80211_NUM_ACS; i++) {
u8 q = mt76_connac_lmac_mapping(i);
u32 tx_cur = tx_time[q];
u32 rx_cur = rx_time[q];
u8 tid = ac_to_tid[i];
if (!tx_cur && !rx_cur)
continue;
ieee80211_sta_register_airtime(sta, tid, tx_cur,
rx_cur);
}
/* We don't support reading GI info from txs packets.
* For accurate tx status reporting and AQL improvement,
* we need to make sure that flags match so polling GI
* from per-sta counters directly.
*/
rate = &mlink->wcid.rate;
addr = mt7921_mac_wtbl_lmac_addr(idx,
MT_WTBL_TXRX_CAP_RATE_OFFSET);
val = mt76_rr(dev, addr);
switch (rate->bw) {
case RATE_INFO_BW_160:
bw = IEEE80211_STA_RX_BW_160;
break;
case RATE_INFO_BW_80:
bw = IEEE80211_STA_RX_BW_80;
break;
case RATE_INFO_BW_40:
bw = IEEE80211_STA_RX_BW_40;
break;
default:
bw = IEEE80211_STA_RX_BW_20;
break;
}
if (rate->flags & RATE_INFO_FLAGS_HE_MCS) {
u8 offs = MT_WTBL_TXRX_RATE_G2_HE + 2 * bw;
rate->he_gi = (val & (0x3 << offs)) >> offs;
} else if (rate->flags &
(RATE_INFO_FLAGS_VHT_MCS | RATE_INFO_FLAGS_MCS)) {
if (val & BIT(MT_WTBL_TXRX_RATE_G2 + bw))
rate->flags |= RATE_INFO_FLAGS_SHORT_GI;
else
rate->flags &= ~RATE_INFO_FLAGS_SHORT_GI;
}
Annotation
- Immediate include surface: `linux/devcoredump.h`, `linux/etherdevice.h`, `linux/timekeeping.h`, `mt7921.h`, `../dma.h`, `../mt76_connac2_mac.h`, `regd.h`, `mcu.h`.
- Detected declarations: `function mt7921_mac_wtbl_update`, `function mt7921_mac_wtbl_lmac_addr`, `function mt7921_mac_sta_poll`, `function mt7921_mac_fill_rx`, `function mt7921_mac_add_txs`, `function mt7921_mac_tx_free`, `function list_for_each_entry_safe`, `function mt7921_rx_check`, `function mt7921_queue_rx_skb`, `function mt7921_vif_connect_iter`.
- 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.