drivers/net/wireless/mediatek/mt76/mt7996/mcu.c
Source file repositories/reference/linux-study-clean/drivers/net/wireless/mediatek/mt76/mt7996/mcu.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/wireless/mediatek/mt76/mt7996/mcu.c- Extension
.c- Size
- 138927 bytes
- Lines
- 5449
- 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/firmware.hlinux/fs.hmt7996.hmcu.hmac.heeprom.h
Detected Declarations
struct mt7996_patch_hdrstruct mt7996_patch_secstruct mt7996_fw_trailerstruct mt7996_fw_regionstruct mt7996_mcu_countdown_datastruct headerstruct req_hdrstruct req_tlvstruct cal_free_datastruct mt7996_mcu_thermalstruct tx_power_limit_table_ctrlfunction mt7996_mcu_get_sta_nssfunction mt7996_mcu_set_sta_he_mcsfunction mt7996_mcu_set_sta_vht_mcsfunction mt7996_mcu_set_sta_ht_mcsfunction mt7996_mcu_parse_responsefunction mt7996_mcu_set_timeoutfunction mt7996_mcu_send_messagefunction mt7996_mcu_wa_cmdfunction mt7996_mcu_csa_finishfunction for_each_set_bitfunction mt7996_mcu_cca_finishfunction for_each_set_bitfunction mt7996_mcu_ie_countdownfunction mt7996_mcu_rx_radar_detectedfunction mt7996_mcu_rx_log_messagefunction mt7996_mcu_update_tx_gifunction mt7996_mcu_rx_all_sta_info_eventfunction mt7996_mcu_rx_thermal_notifyfunction mt7996_mcu_rx_ext_eventfunction mt7996_mcu_rx_unsolicited_eventfunction mt7996_mcu_wed_rro_eventfunction mt7996_mcu_uni_rx_unsolicited_eventfunction mt7996_mcu_rx_eventfunction mt7996_mcu_add_uni_tlvfunction mt7996_mcu_bss_rfch_tlvfunction mt7996_mcu_bss_ra_tlvfunction mt7996_mcu_bss_he_tlvfunction mt7996_mcu_bss_mbssid_tlvfunction mt7996_mcu_bss_bmc_tlvfunction mt7996_mcu_bss_txcmd_tlvfunction mt7996_mcu_bss_mld_tlvfunction mt7996_mcu_bss_sec_tlvfunction mt7996_mcu_muar_configfunction mt7996_mcu_bss_ifs_timing_tlvfunction mt7996_mcu_bss_basic_tlvfunction __mt7996_mcu_alloc_bss_reqfunction mt7996_mcu_add_bss_info
Annotated Snippet
struct mt7996_patch_hdr {
char build_date[16];
char platform[4];
__be32 hw_sw_ver;
__be32 patch_ver;
__be16 checksum;
u16 reserved;
struct {
__be32 patch_ver;
__be32 subsys;
__be32 feature;
__be32 n_region;
__be32 crc;
u32 reserved[11];
} desc;
} __packed;
struct mt7996_patch_sec {
__be32 type;
__be32 offs;
__be32 size;
union {
__be32 spec[13];
struct {
__be32 addr;
__be32 len;
__be32 sec_key_idx;
__be32 align_len;
u32 reserved[9];
} info;
};
} __packed;
struct mt7996_fw_trailer {
u8 chip_id;
u8 eco_code;
u8 n_region;
u8 format_ver;
u8 format_flag;
u8 reserved[2];
char fw_ver[10];
char build_date[15];
u32 crc;
} __packed;
struct mt7996_fw_region {
__le32 decomp_crc;
__le32 decomp_len;
__le32 decomp_blk_sz;
u8 reserved[4];
__le32 addr;
__le32 len;
u8 feature_set;
u8 reserved1[15];
} __packed;
#define MCU_PATCH_ADDRESS 0x200000
#define HE_PHY(p, c) u8_get_bits(c, IEEE80211_HE_PHY_##p)
#define HE_MAC(m, c) u8_get_bits(c, IEEE80211_HE_MAC_##m)
#define EHT_PHY(p, c) u8_get_bits(c, IEEE80211_EHT_PHY_##p)
static bool sr_scene_detect = true;
module_param(sr_scene_detect, bool, 0644);
MODULE_PARM_DESC(sr_scene_detect, "Enable firmware scene detection algorithm");
static u8
mt7996_mcu_get_sta_nss(u16 mcs_map)
{
u8 nss;
for (nss = 8; nss > 0; nss--) {
u8 nss_mcs = (mcs_map >> (2 * (nss - 1))) & 3;
if (nss_mcs != IEEE80211_VHT_MCS_NOT_SUPPORTED)
break;
}
return nss - 1;
}
static void
mt7996_mcu_set_sta_he_mcs(struct ieee80211_link_sta *link_sta,
struct mt7996_vif_link *link,
__le16 *he_mcs, u16 mcs_map)
{
struct mt76_phy *mphy = mt76_vif_link_phy(&link->mt76);
int nss, max_nss = link_sta->rx_nss > 3 ? 4 : link_sta->rx_nss;
enum nl80211_band band;
const u16 *mask;
Annotation
- Immediate include surface: `linux/firmware.h`, `linux/fs.h`, `mt7996.h`, `mcu.h`, `mac.h`, `eeprom.h`.
- Detected declarations: `struct mt7996_patch_hdr`, `struct mt7996_patch_sec`, `struct mt7996_fw_trailer`, `struct mt7996_fw_region`, `struct mt7996_mcu_countdown_data`, `struct header`, `struct req_hdr`, `struct req_tlv`, `struct cal_free_data`, `struct mt7996_mcu_thermal`.
- 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.