diff mbox series

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

Message ID 20210105054124.5946-1-shayne.chen@mediatek.com
State New
Headers show
Series mt76: testmode: add support to set user-defined spe index | expand

Commit Message

Shayne Chen Jan. 5, 2021, 5:41 a.m. UTC
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: Shayne Chen <shayne.chen@mediatek.com>
---
 drivers/net/wireless/mediatek/mt76/mt76.h         |  1 +
 .../net/wireless/mediatek/mt76/mt7915/testmode.c  | 15 ++++++++++-----
 drivers/net/wireless/mediatek/mt76/testmode.c     |  4 ++++
 drivers/net/wireless/mediatek/mt76/testmode.h     |  2 ++
 4 files changed, 17 insertions(+), 5 deletions(-)

Comments

Felix Fietkau Jan. 14, 2021, 9:33 a.m. UTC | #1
On 2021-01-05 06:41, Shayne Chen wrote:
> 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: Shayne Chen <shayne.chen@mediatek.com>

> ---

>  drivers/net/wireless/mediatek/mt76/mt76.h         |  1 +

>  .../net/wireless/mediatek/mt76/mt7915/testmode.c  | 15 ++++++++++-----

>  drivers/net/wireless/mediatek/mt76/testmode.c     |  4 ++++

>  drivers/net/wireless/mediatek/mt76/testmode.h     |  2 ++

>  4 files changed, 17 insertions(+), 5 deletions(-)

> 

> index 7efad685a17c..f215b377d7fb 100644

> --- a/drivers/net/wireless/mediatek/mt76/testmode.h

> +++ b/drivers/net/wireless/mediatek/mt76/testmode.h

> @@ -29,6 +29,7 @@

>   * @MT76_TM_ATTR_TX_LTF: packet tx LTF, set 0 to 2 for 1x, 2x, and 4x LTF (u8)

>   *

>   * @MT76_TM_ATTR_TX_ANTENNA: tx antenna mask (u8)

> + * @MT76_TM_ATTR_TX_SPE_IDX: tx spatial extension index (u8)

>   * @MT76_TM_ATTR_TX_POWER_CONTROL: enable tx power control (u8)

>   * @MT76_TM_ATTR_TX_POWER: per-antenna tx power array (nested, u8 attrs)

>   *

> @@ -56,6 +57,7 @@ enum mt76_testmode_attr {

>  	MT76_TM_ATTR_TX_LTF,

>  

>  	MT76_TM_ATTR_TX_ANTENNA,

> +	MT76_TM_ATTR_TX_SPE_IDX,In order to avoid breaking the ABI, please only add new entries at the

end of the enum, above the "keep last" line.
I'll fix it up locally this time.

- Felix
diff mbox series

Patch

diff --git a/drivers/net/wireless/mediatek/mt76/mt76.h b/drivers/net/wireless/mediatek/mt76/mt76.h
index 10034c21f812..245a7197b017 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76.h
+++ b/drivers/net/wireless/mediatek/mt76/mt76.h
@@ -539,6 +539,7 @@  struct mt76_testmode_data {
 	u8 tx_ltf;
 
 	u8 tx_antenna_mask;
+	u8 tx_spe_idx;
 
 	u32 freq_offset;
 
diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/testmode.c b/drivers/net/wireless/mediatek/mt76/mt7915/testmode.c
index b58c91ea3fa5..278f279cc67b 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7915/testmode.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7915/testmode.c
@@ -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,17 +213,21 @@  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 (phy != &dev->phy)
-			tx_ant >>= 2;
-		phy->test.spe_idx = spe_idx_map[tx_ant];
+		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);
diff --git a/drivers/net/wireless/mediatek/mt76/testmode.c b/drivers/net/wireless/mediatek/mt76/testmode.c
index 8b14620e16fc..ad8edf137b36 100644
--- a/drivers/net/wireless/mediatek/mt76/testmode.c
+++ b/drivers/net/wireless/mediatek/mt76/testmode.c
@@ -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) &&
diff --git a/drivers/net/wireless/mediatek/mt76/testmode.h b/drivers/net/wireless/mediatek/mt76/testmode.h
index 7efad685a17c..f215b377d7fb 100644
--- a/drivers/net/wireless/mediatek/mt76/testmode.h
+++ b/drivers/net/wireless/mediatek/mt76/testmode.h
@@ -29,6 +29,7 @@ 
  * @MT76_TM_ATTR_TX_LTF: packet tx LTF, set 0 to 2 for 1x, 2x, and 4x LTF (u8)
  *
  * @MT76_TM_ATTR_TX_ANTENNA: tx antenna mask (u8)
+ * @MT76_TM_ATTR_TX_SPE_IDX: tx spatial extension index (u8)
  * @MT76_TM_ATTR_TX_POWER_CONTROL: enable tx power control (u8)
  * @MT76_TM_ATTR_TX_POWER: per-antenna tx power array (nested, u8 attrs)
  *
@@ -56,6 +57,7 @@  enum mt76_testmode_attr {
 	MT76_TM_ATTR_TX_LTF,
 
 	MT76_TM_ATTR_TX_ANTENNA,
+	MT76_TM_ATTR_TX_SPE_IDX,
 	MT76_TM_ATTR_TX_POWER_CONTROL,
 	MT76_TM_ATTR_TX_POWER,