drivers/net/wireless/mediatek/mt76/mt7915/testmode.c
Source file repositories/reference/linux-study-clean/drivers/net/wireless/mediatek/mt76/mt7915/testmode.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/wireless/mediatek/mt76/mt7915/testmode.c- Extension
.c- Size
- 19662 bytes
- Lines
- 791
- 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
mt7915.hmac.hmcu.htestmode.h
Detected Declarations
struct reg_bandfunction mt7915_tm_set_tx_powerfunction mt7915_tm_set_freq_offsetfunction mt7915_tm_mode_ctrlfunction mt7915_tm_set_trxfunction mt7915_tm_clean_hwqfunction mt7915_tm_set_slot_timefunction mt7915_tm_set_tam_arbfunction mt7915_tm_set_wmm_qidfunction mt7915_tm_set_ipg_paramsfunction mt7915_tm_set_tx_lenfunction mt7915_tm_reg_backup_restorefunction mt7915_tm_initfunction mt7915_tm_update_channelfunction mt7915_tm_set_tx_framesfunction mt7915_tm_set_rx_framesfunction mt7915_tm_rf_switch_modefunction mt7915_tm_set_tx_contfunction mt7915_tm_update_paramsfunction mt7915_tm_set_statefunction mt7915_tm_set_paramsfunction mt7915_tm_dump_stats
Annotated Snippet
struct reg_band {
u32 band[2];
};
#define REG_BAND(_list, _reg) \
{ _list.band[0] = MT_##_reg(0); \
_list.band[1] = MT_##_reg(1); }
#define REG_BAND_IDX(_list, _reg, _idx) \
{ _list.band[0] = MT_##_reg(0, _idx); \
_list.band[1] = MT_##_reg(1, _idx); }
#define TM_REG_MAX_ID 17
static struct reg_band reg_backup_list[TM_REG_MAX_ID];
static int
mt7915_tm_set_tx_power(struct mt7915_phy *phy)
{
struct mt7915_dev *dev = phy->dev;
struct mt76_phy *mphy = phy->mt76;
struct cfg80211_chan_def *chandef = &mphy->chandef;
int freq = chandef->center_freq1;
int ret;
struct {
u8 format_id;
u8 band_idx;
s8 tx_power;
u8 ant_idx; /* Only 0 is valid */
u8 center_chan;
u8 rsv[3];
} __packed req = {
.format_id = 0xf,
.band_idx = phy->mt76->band_idx,
.center_chan = ieee80211_frequency_to_channel(freq),
};
u8 *tx_power = NULL;
if (phy->mt76->test.state != MT76_TM_STATE_OFF)
tx_power = phy->mt76->test.tx_power;
/* Tx power of the other antennas are the same as antenna 0 */
if (tx_power && tx_power[0])
req.tx_power = tx_power[0];
ret = mt76_mcu_send_msg(&dev->mt76,
MCU_EXT_CMD(TX_POWER_FEATURE_CTRL),
&req, sizeof(req), false);
return ret;
}
static int
mt7915_tm_set_freq_offset(struct mt7915_phy *phy, bool en, u32 val)
{
struct mt7915_dev *dev = phy->dev;
struct mt7915_tm_cmd req = {
.testmode_en = en,
.param_idx = MCU_ATE_SET_FREQ_OFFSET,
.param.freq.band = phy->mt76->band_idx,
.param.freq.freq_offset = cpu_to_le32(val),
};
return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(ATE_CTRL), &req,
sizeof(req), false);
}
static int
mt7915_tm_mode_ctrl(struct mt7915_dev *dev, bool enable)
{
struct {
u8 format_id;
bool enable;
u8 rsv[2];
} __packed req = {
.format_id = 0x6,
.enable = enable,
};
return mt76_mcu_send_msg(&dev->mt76,
MCU_EXT_CMD(TX_POWER_FEATURE_CTRL),
&req, sizeof(req), false);
}
static int
mt7915_tm_set_trx(struct mt7915_phy *phy, int type, bool en)
{
struct mt7915_dev *dev = phy->dev;
struct mt7915_tm_cmd req = {
.testmode_en = 1,
.param_idx = MCU_ATE_SET_TRX,
Annotation
- Immediate include surface: `mt7915.h`, `mac.h`, `mcu.h`, `testmode.h`.
- Detected declarations: `struct reg_band`, `function mt7915_tm_set_tx_power`, `function mt7915_tm_set_freq_offset`, `function mt7915_tm_mode_ctrl`, `function mt7915_tm_set_trx`, `function mt7915_tm_clean_hwq`, `function mt7915_tm_set_slot_time`, `function mt7915_tm_set_tam_arb`, `function mt7915_tm_set_wmm_qid`, `function mt7915_tm_set_ipg_params`.
- 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.