Skip to content

Commit

Permalink
mt7915: update the testmode support to the latest upstream patch
Browse files Browse the repository at this point in the history
Fixes warning with testmode support disabled

Signed-off-by: Felix Fietkau <nbd@nbd.name>
  • Loading branch information
nbd168 committed Jan 4, 2021
1 parent 36a745d commit a453976
Showing 1 changed file with 28 additions and 40 deletions.
68 changes: 28 additions & 40 deletions mt7915/mac.c
Expand Up @@ -600,51 +600,16 @@ void mt7915_mac_fill_rx_vector(struct mt7915_dev *dev, struct sk_buff *skb)
}
#endif

static u16
mt7915_mac_tx_rate_val(struct mt76_phy *mphy, u8 mode, u8 rate_idx,
u8 nss, u8 stbc, u8 *bw)
{
u16 rateval = 0;

switch (mphy->chandef.width) {
case NL80211_CHAN_WIDTH_40:
*bw = 1;
break;
case NL80211_CHAN_WIDTH_80:
*bw = 2;
break;
case NL80211_CHAN_WIDTH_80P80:
case NL80211_CHAN_WIDTH_160:
*bw = 3;
break;
default:
*bw = 0;
break;
}

if (mode == MT_PHY_TYPE_HT || mode == MT_PHY_TYPE_HT_GF)
nss = 1 + (rate_idx >> 3);

if (stbc && nss == 1) {
nss++;
rateval |= MT_TX_RATE_STBC;
}

rateval |= FIELD_PREP(MT_TX_RATE_IDX, rate_idx) |
FIELD_PREP(MT_TX_RATE_MODE, mode) |
FIELD_PREP(MT_TX_RATE_NSS, nss - 1);

return rateval;
}

static void
mt7915_mac_write_txwi_tm(struct mt7915_dev *dev, struct mt76_phy *mphy,
__le32 *txwi, struct sk_buff *skb)
{
#ifdef CONFIG_NL80211_TESTMODE
struct mt76_testmode_data *td = &dev->mt76.test;
u8 rate_idx = td->tx_rate_idx;
u8 nss = td->tx_rate_nss;
u8 bw, mode;
u16 rateval;
u16 rateval = 0;
u32 val;

if (skb != dev->mt76.test.tx_skb)
Expand All @@ -655,6 +620,7 @@ mt7915_mac_write_txwi_tm(struct mt7915_dev *dev, struct mt76_phy *mphy,
mode = MT_PHY_TYPE_CCK;
break;
case MT76_TM_TX_MODE_HT:
nss = 1 + (rate_idx >> 3);
mode = MT_PHY_TYPE_HT;
break;
case MT76_TM_TX_MODE_VHT:
Expand All @@ -678,8 +644,30 @@ mt7915_mac_write_txwi_tm(struct mt7915_dev *dev, struct mt76_phy *mphy,
break;
}

rateval = mt7915_mac_tx_rate_val(mphy, mode, td->tx_rate_idx,
td->tx_rate_nss, td->tx_rate_stbc, &bw);
switch (mphy->chandef.width) {
case NL80211_CHAN_WIDTH_40:
bw = 1;
break;
case NL80211_CHAN_WIDTH_80:
bw = 2;
break;
case NL80211_CHAN_WIDTH_80P80:
case NL80211_CHAN_WIDTH_160:
bw = 3;
break;
default:
bw = 0;
break;
}

if (td->tx_rate_stbc && nss == 1) {
nss++;
rateval |= MT_TX_RATE_STBC;
}

rateval |= FIELD_PREP(MT_TX_RATE_IDX, rate_idx) |
FIELD_PREP(MT_TX_RATE_MODE, mode) |
FIELD_PREP(MT_TX_RATE_NSS, nss - 1);

txwi[2] |= cpu_to_le32(MT_TXD2_FIX_RATE);

Expand Down

0 comments on commit a453976

Please sign in to comment.