Commit fdc9c18e authored by Shayne Chen's avatar Shayne Chen Committed by Felix Fietkau
Browse files

mt76: testmode: add support to set user-defined spe index



Add spatial extension (spe) index as a configurable parameter in testmode.
This is used for specifically configuring TX path, such as different
WF TX priority, number of antennas and spatial streams.

If spe_idx is not set, TX path depends on tx_antenna_mask; otherwise,
both spe_idx and tx_antenna_mask are referenced to decide TX path.

Signed-off-by: default avatarShayne Chen <shayne.chen@mediatek.com>
Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
parent 1fdcc310
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -539,6 +539,7 @@ struct mt76_testmode_data {
	u8 tx_ltf;

	u8 tx_antenna_mask;
	u8 tx_spe_idx;

	u32 freq_offset;

+10 −5
Original line number Diff line number Diff line
@@ -205,6 +205,7 @@ mt7915_tm_set_tx_frames(struct mt7915_phy *phy, bool en)
{
	static const u8 spe_idx_map[] = {0, 0, 1, 0, 3, 2, 4, 0,
					 9, 8, 6, 10, 16, 12, 18, 0};
	struct mt76_testmode_data *td = &phy->mt76->test;
	struct sk_buff *skb = phy->mt76->test.tx_skb;
	struct mt7915_dev *dev = phy->dev;
	struct ieee80211_tx_info *info;
@@ -212,18 +213,22 @@ mt7915_tm_set_tx_frames(struct mt7915_phy *phy, bool en)
	mt7915_tm_set_trx(phy, TM_MAC_RX_RXV, false);

	if (en) {
		u8 tx_ant = phy->mt76->test.tx_antenna_mask;

		mutex_unlock(&dev->mt76.mutex);
		mt7915_set_channel(phy);
		mutex_lock(&dev->mt76.mutex);

		mt7915_mcu_set_chan_info(phy, MCU_EXT_CMD_SET_RX_PATH);

		if (td->tx_spe_idx) {
			phy->test.spe_idx = td->tx_spe_idx;
		} else {
			u8 tx_ant = td->tx_antenna_mask;

			if (phy != &dev->phy)
				tx_ant >>= 2;
			phy->test.spe_idx = spe_idx_map[tx_ant];
		}
	}

	mt7915_tm_set_trx(phy, TM_MAC_TX, en);

+4 −0
Original line number Diff line number Diff line
@@ -14,6 +14,7 @@ static const struct nla_policy mt76_tm_policy[NUM_MT76_TM_ATTRS] = {
	[MT76_TM_ATTR_TX_RATE_STBC] = { .type = NLA_U8 },
	[MT76_TM_ATTR_TX_LTF] = { .type = NLA_U8 },
	[MT76_TM_ATTR_TX_ANTENNA] = { .type = NLA_U8 },
	[MT76_TM_ATTR_TX_SPE_IDX] = { .type = NLA_U8 },
	[MT76_TM_ATTR_TX_POWER_CONTROL] = { .type = NLA_U8 },
	[MT76_TM_ATTR_TX_POWER] = { .type = NLA_NESTED },
	[MT76_TM_ATTR_FREQ_OFFSET] = { .type = NLA_U32 },
@@ -359,6 +360,7 @@ int mt76_testmode_cmd(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
	    mt76_tm_get_u8(tb[MT76_TM_ATTR_TX_LTF], &td->tx_ltf, 0, 2) ||
	    mt76_tm_get_u8(tb[MT76_TM_ATTR_TX_ANTENNA], &td->tx_antenna_mask,
			   1 << (ext_phy * 2), phy->antenna_mask << (ext_phy * 2)) ||
	    mt76_tm_get_u8(tb[MT76_TM_ATTR_TX_SPE_IDX], &td->tx_spe_idx, 0, 27) ||
	    mt76_tm_get_u8(tb[MT76_TM_ATTR_TX_POWER_CONTROL],
			   &td->tx_power_control, 0, 1))
		goto out;
@@ -499,6 +501,8 @@ int mt76_testmode_dump(struct ieee80211_hw *hw, struct sk_buff *msg,
	     nla_put_u8(msg, MT76_TM_ATTR_TX_LTF, td->tx_ltf)) ||
	    (mt76_testmode_param_present(td, MT76_TM_ATTR_TX_ANTENNA) &&
	     nla_put_u8(msg, MT76_TM_ATTR_TX_ANTENNA, td->tx_antenna_mask)) ||
	    (mt76_testmode_param_present(td, MT76_TM_ATTR_TX_SPE_IDX) &&
	     nla_put_u8(msg, MT76_TM_ATTR_TX_SPE_IDX, td->tx_spe_idx)) ||
	    (mt76_testmode_param_present(td, MT76_TM_ATTR_TX_POWER_CONTROL) &&
	     nla_put_u8(msg, MT76_TM_ATTR_TX_POWER_CONTROL, td->tx_power_control)) ||
	    (mt76_testmode_param_present(td, MT76_TM_ATTR_FREQ_OFFSET) &&
+4 −0
Original line number Diff line number Diff line
@@ -35,6 +35,8 @@
 * @MT76_TM_ATTR_FREQ_OFFSET: RF frequency offset (u32)
 *
 * @MT76_TM_ATTR_STATS: statistics (nested, see &enum mt76_testmode_stats_attr)
 *
 * @MT76_TM_ATTR_TX_SPE_IDX: tx spatial extension index (u8)
 */
enum mt76_testmode_attr {
	MT76_TM_ATTR_UNSPEC,
@@ -63,6 +65,8 @@ enum mt76_testmode_attr {

	MT76_TM_ATTR_STATS,

	MT76_TM_ATTR_TX_SPE_IDX,

	/* keep last */
	NUM_MT76_TM_ATTRS,
	MT76_TM_ATTR_MAX = NUM_MT76_TM_ATTRS - 1,