drivers/net/wireless/mediatek/mt76/mt7996/mac.c
Source file repositories/reference/linux-study-clean/drivers/net/wireless/mediatek/mt76/mt7996/mac.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/wireless/mediatek/mt76/mt7996/mac.c- Extension
.c- Size
- 84425 bytes
- Lines
- 3251
- 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
linux/etherdevice.hlinux/timekeeping.hcoredump.hmt7996.h../dma.hmac.hmcu.h
Detected Declarations
function Copyrightfunction mt7996_mac_wtbl_updatefunction mt7996_mac_wtbl_lmac_addrfunction mt7996_mac_sta_pollfunction mt7996_reverse_frag0_hdr_transfunction mt7996_mac_fill_rx_ratefunction mt7996_wed_check_ppefunction mt7996_mac_fill_rxfunction mt7996_mac_write_txwi_8023function mt7996_mac_write_txwi_80211function mt7996_mac_write_txwifunction mt7996_tx_use_mgmtfunction mt7996_tx_prepare_skbfunction mt7996_wed_init_buffunction mt7996_tx_check_aggrfunction mt7996_txwi_freefunction mt7996_mac_tx_freefunction for_each_set_bitfunction list_for_each_entry_safefunction mt7996_mac_add_txs_skbfunction mt7996_mac_add_txsfunction mt7996_rx_checkfunction mt7996_queue_rx_skbfunction mt7996_msdu_page_get_from_cachefunction mt7996_msdu_page_put_to_cachefunction mt7996_msdu_page_free_cachefunction mt7996_msdu_page_hash_from_addrfunction mt7996_rro_msdu_page_getfunction list_for_each_entry_safefunction mt7996_rx_token_putfunction mt7996_rro_msdu_page_map_freefunction list_for_each_entry_safefunction mt7996_rro_msdu_page_addfunction mt7996_rro_addr_elem_getfunction mt7996_rro_rx_processfunction mt7996_mac_cca_stats_resetfunction mt7996_mac_reset_countersfunction mt7996_mac_set_coverage_classfunction mt7996_mac_enable_nffunction mt7996_phy_get_nffunction mt7996_update_channelfunction mt7996_wait_reset_statefunction mt7996_update_vif_beaconfunction for_each_vif_active_linkfunction mt7996_mac_update_beaconsfunction mt7996_update_beaconsfunction mt7996_tx_token_putfunction mt7996_mac_restart
Annotated Snippet
if (list_empty(&sta_poll_list)) {
spin_unlock_bh(&dev->mt76.sta_poll_lock);
break;
}
msta_link = list_first_entry(&sta_poll_list,
struct mt7996_sta_link,
wcid.poll_list);
msta = msta_link->sta;
wcid = &msta_link->wcid;
list_del_init(&wcid->poll_list);
spin_unlock_bh(&dev->mt76.sta_poll_lock);
idx = wcid->idx;
/* refresh peer's airtime reporting */
addr = mt7996_mac_wtbl_lmac_addr(dev, idx, 20);
for (i = 0; i < IEEE80211_NUM_ACS; i++) {
u32 tx_last = msta_link->airtime_ac[i];
u32 rx_last = msta_link->airtime_ac[i + 4];
msta_link->airtime_ac[i] = mt76_rr(dev, addr);
msta_link->airtime_ac[i + 4] = mt76_rr(dev, addr + 4);
tx_time[i] = msta_link->airtime_ac[i] - tx_last;
rx_time[i] = msta_link->airtime_ac[i + 4] - rx_last;
if ((tx_last | rx_last) & BIT(30))
clear = true;
addr += 8;
}
if (clear) {
mt7996_mac_wtbl_update(dev, idx,
MT_WTBL_UPDATE_ADM_COUNT_CLEAR);
memset(msta_link->airtime_ac, 0,
sizeof(msta_link->airtime_ac));
}
if (!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);
}
/* get signal strength of resp frames (CTS/BA/ACK) */
addr = mt7996_mac_wtbl_lmac_addr(dev, idx, 34);
val = mt76_rr(dev, addr);
rssi[0] = to_rssi(GENMASK(7, 0), val);
rssi[1] = to_rssi(GENMASK(15, 8), val);
rssi[2] = to_rssi(GENMASK(23, 16), val);
rssi[3] = to_rssi(GENMASK(31, 14), val);
mlink = rcu_dereference(msta->vif->mt76.link[wcid->link_id]);
if (mlink) {
struct mt76_phy *mphy = mt76_vif_link_phy(mlink);
if (mphy)
msta_link->ack_signal =
mt76_rx_signal(mphy->antenna_mask,
rssi);
}
ewma_avg_signal_add(&msta_link->avg_ack_signal,
-msta_link->ack_signal);
}
rcu_read_unlock();
}
/* The HW does not translate the mac header to 802.3 for mesh point */
static int mt7996_reverse_frag0_hdr_trans(struct sk_buff *skb, u16 hdr_gap)
{
struct mt76_rx_status *status = (struct mt76_rx_status *)skb->cb;
struct ethhdr *eth_hdr = (struct ethhdr *)(skb->data + hdr_gap);
struct mt7996_sta_link *msta_link = (void *)status->wcid;
struct mt7996_sta *msta = msta_link->sta;
Annotation
- Immediate include surface: `linux/etherdevice.h`, `linux/timekeeping.h`, `coredump.h`, `mt7996.h`, `../dma.h`, `mac.h`, `mcu.h`.
- Detected declarations: `function Copyright`, `function mt7996_mac_wtbl_update`, `function mt7996_mac_wtbl_lmac_addr`, `function mt7996_mac_sta_poll`, `function mt7996_reverse_frag0_hdr_trans`, `function mt7996_mac_fill_rx_rate`, `function mt7996_wed_check_ppe`, `function mt7996_mac_fill_rx`, `function mt7996_mac_write_txwi_8023`, `function mt7996_mac_write_txwi_80211`.
- 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.