Skip to content

Commit

Permalink
wifi: mt76: connac: introduce mt76_connac_spe_idx()
Browse files Browse the repository at this point in the history
Add mt76_connac_spe_idx() for antenna mask to spatial extension
index conversion. This is used to support flexible control of
tx antenna.

Signed-off-by: Shayne Chen <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
  • Loading branch information
csyuanc authored and nbd168 committed Oct 1, 2022
1 parent b0114a0 commit 6dee964
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
11 changes: 11 additions & 0 deletions mt76_connac.h
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,17 @@ mt76_connac_txwi_to_txp(struct mt76_dev *dev, struct mt76_txwi_cache *t)
return (void *)(txwi + MT_TXD_SIZE);
}

static inline u8 mt76_connac_spe_idx(u8 antenna_mask)
{
static const u8 ant_to_spe[] = {0, 0, 1, 0, 3, 2, 4, 0,
9, 8, 6, 10, 16, 12, 18, 0};

if (antenna_mask >= sizeof(ant_to_spe))
return 0;

return ant_to_spe[antenna_mask];
}

int mt76_connac_pm_wake(struct mt76_phy *phy, struct mt76_connac_pm *pm);
void mt76_connac_power_save_sched(struct mt76_phy *phy,
struct mt76_connac_pm *pm);
Expand Down
11 changes: 8 additions & 3 deletions mt76_connac_mac.c
Original file line number Diff line number Diff line change
Expand Up @@ -417,9 +417,6 @@ mt76_connac2_mac_write_txwi_80211(struct mt76_dev *dev, __le32 *txwi,
if (ieee80211_is_beacon(fc)) {
txwi[3] &= ~cpu_to_le32(MT_TXD3_SW_POWER_MGMT);
txwi[3] |= cpu_to_le32(MT_TXD3_REM_TX_COUNT);
if (!is_mt7921(dev))
txwi[7] |= cpu_to_le32(FIELD_PREP(MT_TXD7_SPE_IDX,
0x18));
}

if (info->flags & IEEE80211_TX_CTL_INJECTED) {
Expand Down Expand Up @@ -550,6 +547,14 @@ void mt76_connac2_mac_write_txwi(struct mt76_dev *dev, __le32 *txwi,
val |= FIELD_PREP(MT_TXD6_TX_RATE, rate);
txwi[6] |= cpu_to_le32(val);
txwi[3] |= cpu_to_le32(MT_TXD3_BA_DISABLE);

if (!is_mt7921(dev)) {
u8 spe_idx = mt76_connac_spe_idx(mphy->antenna_mask);

if (!spe_idx)
spe_idx = 24 + phy_idx;
txwi[7] |= cpu_to_le32(FIELD_PREP(MT_TXD7_SPE_IDX, spe_idx));
}
}
}
EXPORT_SYMBOL_GPL(mt76_connac2_mac_write_txwi);
Expand Down
2 changes: 1 addition & 1 deletion mt76_connac_mcu.h
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ struct sta_rec_ra_fixed {

struct sta_phy phy;

u8 spe_en;
u8 spe_idx;
u8 short_preamble;
u8 is_5g;
u8 mmps_mode;
Expand Down

0 comments on commit 6dee964

Please sign in to comment.