drivers/net/wireless/mediatek/mt76/mt76x02_util.c
Source file repositories/reference/linux-study-clean/drivers/net/wireless/mediatek/mt76/mt76x02_util.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/wireless/mediatek/mt76/mt76x02_util.c- Extension
.c- Size
- 19501 bytes
- Lines
- 700
- 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/module.hmt76x02.h
Detected Declarations
function Copyrightfunction mt76x02_led_set_configfunction mt76x02_led_set_blinkfunction mt76x02_led_set_brightnessfunction mt76x02_init_devicefunction mt76x02_configure_filterfunction mt76x02_sta_addfunction mt76x02_sta_removefunction mt76x02_vif_initfunction mt76x02_add_interfacefunction mt76x02_remove_interfacefunction mt76x02_ampdu_actionfunction mt76x02_set_keyfunction mt76x02_conf_txfunction mt76x02_set_tx_acktofunction mt76x02_set_coverage_classfunction mt76x02_set_rts_thresholdfunction mt76x02_sta_rate_tbl_updatefunction mt76x02_remove_hdr_padfunction mt76x02_sw_scan_completefunction mt76x02_sta_psfunction mt76x02_bss_info_changedfunction mt76x02_config_mac_addr_listexport mt76x02_ratesexport mt76x02_init_deviceexport mt76x02_configure_filterexport mt76x02_sta_addexport mt76x02_sta_removeexport mt76x02_add_interfaceexport mt76x02_remove_interfaceexport mt76x02_ampdu_actionexport mt76x02_set_keyexport mt76x02_conf_txexport mt76x02_set_tx_acktoexport mt76x02_set_coverage_classexport mt76x02_set_rts_thresholdexport mt76x02_sta_rate_tbl_updateexport mt76x02_remove_hdr_padexport mt76x02_sw_scan_completeexport mt76x02_sta_psexport mt76x02_bss_info_changedexport mt76x02_config_mac_addr_list
Annotated Snippet
if (IS_ENABLED(CONFIG_MT76_LEDS)) {
dev->mphy.leds.cdev.brightness_set =
mt76x02_led_set_brightness;
dev->mphy.leds.cdev.blink_set = mt76x02_led_set_blink;
}
}
wiphy_ext_feature_set(wiphy, NL80211_EXT_FEATURE_VHT_IBSS);
hw->sta_data_size = sizeof(struct mt76x02_sta);
hw->vif_data_size = sizeof(struct mt76x02_vif);
ieee80211_hw_set(hw, SUPPORTS_HT_CCK_RATES);
ieee80211_hw_set(hw, HOST_BROADCAST_PS_BUFFERING);
ieee80211_hw_set(hw, NEEDS_UNIQUE_STA_ADDR);
dev->mt76.global_wcid.idx = 255;
dev->mt76.global_wcid.hw_key_idx = -1;
dev->slottime = 9;
if (is_mt76x2(dev)) {
dev->mphy.sband_2g.sband.ht_cap.cap |=
IEEE80211_HT_CAP_LDPC_CODING;
dev->mphy.sband_5g.sband.ht_cap.cap |=
IEEE80211_HT_CAP_LDPC_CODING;
dev->mphy.chainmask = 0x202;
dev->mphy.antenna_mask = 3;
} else {
dev->mphy.chainmask = 0x101;
dev->mphy.antenna_mask = 1;
}
return 0;
}
EXPORT_SYMBOL_GPL(mt76x02_init_device);
void mt76x02_configure_filter(struct ieee80211_hw *hw,
unsigned int changed_flags,
unsigned int *total_flags, u64 multicast)
{
struct mt76x02_dev *dev = hw->priv;
u32 flags = 0;
#define MT76_FILTER(_flag, _hw) do { \
flags |= *total_flags & FIF_##_flag; \
dev->mt76.rxfilter &= ~(_hw); \
dev->mt76.rxfilter |= !(flags & FIF_##_flag) * (_hw); \
} while (0)
mutex_lock(&dev->mt76.mutex);
dev->mt76.rxfilter &= ~MT_RX_FILTR_CFG_OTHER_BSS;
MT76_FILTER(FCSFAIL, MT_RX_FILTR_CFG_CRC_ERR);
MT76_FILTER(PLCPFAIL, MT_RX_FILTR_CFG_PHY_ERR);
MT76_FILTER(CONTROL, MT_RX_FILTR_CFG_ACK |
MT_RX_FILTR_CFG_CTS |
MT_RX_FILTR_CFG_CFEND |
MT_RX_FILTR_CFG_CFACK |
MT_RX_FILTR_CFG_BA |
MT_RX_FILTR_CFG_CTRL_RSV);
MT76_FILTER(PSPOLL, MT_RX_FILTR_CFG_PSPOLL);
*total_flags = flags;
mt76_wr(dev, MT_RX_FILTR_CFG, dev->mt76.rxfilter);
mutex_unlock(&dev->mt76.mutex);
}
EXPORT_SYMBOL_GPL(mt76x02_configure_filter);
int mt76x02_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,
struct ieee80211_sta *sta)
{
struct mt76x02_dev *dev = container_of(mdev, struct mt76x02_dev, mt76);
struct mt76x02_sta *msta = (struct mt76x02_sta *)sta->drv_priv;
struct mt76x02_vif *mvif = (struct mt76x02_vif *)vif->drv_priv;
int idx = 0;
memset(msta, 0, sizeof(*msta));
idx = mt76_wcid_alloc(dev->mt76.wcid_mask, MT76x02_N_WCIDS);
if (idx < 0)
return -ENOSPC;
msta->vif = mvif;
msta->wcid.sta = 1;
msta->wcid.idx = idx;
msta->wcid.hw_key_idx = -1;
mt76x02_mac_wcid_setup(dev, idx, mvif->idx, sta->addr);
mt76x02_mac_wcid_set_drop(dev, idx, false);
Annotation
- Immediate include surface: `linux/module.h`, `mt76x02.h`.
- Detected declarations: `function Copyright`, `function mt76x02_led_set_config`, `function mt76x02_led_set_blink`, `function mt76x02_led_set_brightness`, `function mt76x02_init_device`, `function mt76x02_configure_filter`, `function mt76x02_sta_add`, `function mt76x02_sta_remove`, `function mt76x02_vif_init`, `function mt76x02_add_interface`.
- 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.