drivers/net/wireless/mediatek/mt7601u/mac.c
Source file repositories/reference/linux-study-clean/drivers/net/wireless/mediatek/mt7601u/mac.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/wireless/mediatek/mt7601u/mac.c- Extension
.c- Size
- 15064 bytes
- Lines
- 594
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
mt7601u.htrace.hlinux/etherdevice.h
Detected Declarations
function Copyrightfunction mt76_mac_process_tx_ratefunction mt76_mac_fill_tx_statusfunction mt76_mac_tx_rate_valfunction mt76_mac_wcid_set_ratefunction mt7601u_mac_fetch_tx_statusfunction mt76_send_tx_statusfunction mt7601u_mac_set_protectionfunction mt7601u_mac_set_short_preamblefunction mt7601u_mac_config_tsffunction mt7601u_check_mac_errfunction mt7601u_mac_workfunction mt7601u_mac_wcid_setupfunction mt7601u_mac_set_ampdu_factorfunction mt76_mac_process_ratefunction mt7601u_rx_monitor_beaconfunction mt7601u_rx_is_our_beaconfunction mt76_mac_process_rxfunction mt76_mac_get_key_infofunction mt76_mac_wcid_set_keyfunction mt76_mac_shared_key_setup
Annotated Snippet
if (idx >= 8) {
idx -= 8;
status->enc_flags |= RX_ENC_FLAG_SHORTPRE;
}
if (WARN_ON(idx >= 4))
idx = 0;
status->rate_idx = idx;
return;
case MT_PHY_TYPE_HT_GF:
status->enc_flags |= RX_ENC_FLAG_HT_GF;
fallthrough;
case MT_PHY_TYPE_HT:
status->encoding = RX_ENC_HT;
status->rate_idx = idx;
break;
default:
WARN_ON(1);
return;
}
if (rate & MT_RXWI_RATE_SGI)
status->enc_flags |= RX_ENC_FLAG_SHORT_GI;
if (rate & MT_RXWI_RATE_STBC)
status->enc_flags |= 1 << RX_ENC_FLAG_STBC_SHIFT;
if (rate & MT_RXWI_RATE_BW)
status->bw = RATE_INFO_BW_40;
}
static void
mt7601u_rx_monitor_beacon(struct mt7601u_dev *dev, struct mt7601u_rxwi *rxwi,
u16 rate, int rssi)
{
dev->bcn_freq_off = rxwi->freq_off;
dev->bcn_phy_mode = FIELD_GET(MT_RXWI_RATE_PHY, rate);
ewma_rssi_add(&dev->avg_rssi, -rssi);
}
static int
mt7601u_rx_is_our_beacon(struct mt7601u_dev *dev, u8 *data)
{
struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)data;
return ieee80211_is_beacon(hdr->frame_control) &&
ether_addr_equal(hdr->addr2, dev->ap_bssid);
}
u32 mt76_mac_process_rx(struct mt7601u_dev *dev, struct sk_buff *skb,
u8 *data, void *rxi)
{
struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb);
struct mt7601u_rxwi *rxwi = rxi;
u32 len, ctl = le32_to_cpu(rxwi->ctl);
u16 rate = le16_to_cpu(rxwi->rate);
int rssi;
len = FIELD_GET(MT_RXWI_CTL_MPDU_LEN, ctl);
if (len < 10)
return 0;
if (rxwi->rxinfo & cpu_to_le32(MT_RXINFO_DECRYPT)) {
status->flag |= RX_FLAG_DECRYPTED;
status->flag |= RX_FLAG_MMIC_STRIPPED;
status->flag |= RX_FLAG_MIC_STRIPPED;
status->flag |= RX_FLAG_ICV_STRIPPED;
status->flag |= RX_FLAG_IV_STRIPPED;
}
/* let mac80211 take care of PN validation since apparently
* the hardware does not support it
*/
if (rxwi->rxinfo & cpu_to_le32(MT_RXINFO_PN_LEN))
status->flag &= ~RX_FLAG_IV_STRIPPED;
status->chains = BIT(0);
rssi = mt7601u_phy_get_rssi(dev, rxwi, rate);
status->chain_signal[0] = status->signal = rssi;
status->freq = dev->chandef.chan->center_freq;
status->band = dev->chandef.chan->band;
mt76_mac_process_rate(status, rate);
spin_lock_bh(&dev->con_mon_lock);
if (mt7601u_rx_is_our_beacon(dev, data))
mt7601u_rx_monitor_beacon(dev, rxwi, rate, rssi);
else if (rxwi->rxinfo & cpu_to_le32(MT_RXINFO_U2M))
ewma_rssi_add(&dev->avg_rssi, -rssi);
spin_unlock_bh(&dev->con_mon_lock);
Annotation
- Immediate include surface: `mt7601u.h`, `trace.h`, `linux/etherdevice.h`.
- Detected declarations: `function Copyright`, `function mt76_mac_process_tx_rate`, `function mt76_mac_fill_tx_status`, `function mt76_mac_tx_rate_val`, `function mt76_mac_wcid_set_rate`, `function mt7601u_mac_fetch_tx_status`, `function mt76_send_tx_status`, `function mt7601u_mac_set_protection`, `function mt7601u_mac_set_short_preamble`, `function mt7601u_mac_config_tsf`.
- 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.