2021-11-18 16:46:02

by Ben Greear

[permalink] [raw]
Subject: [PATCH 1/8] mt76: mt7915: cache sgi in wcid.

From: Ben Greear <[email protected]>

Explicitly cache short_gi and he_gi in wcid, don't try to store
it in the wcid.rate object. Slightly less confusing and less fragile
when TXS starts parsing lots of frames.

Signed-off-by: Ben Greear <[email protected]>
---

This is actually the first series, not that one I posted a few minutes
ago. txs, tx overrides and other things. Rebased on top of 5.16

drivers/net/wireless/mediatek/mt76/mt76.h | 5 +++++
drivers/net/wireless/mediatek/mt76/mt7915/mac.c | 17 +++++++++++++----
2 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt76.h b/drivers/net/wireless/mediatek/mt76/mt76.h
index e2da720a91b6..7234703b3c60 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76.h
+++ b/drivers/net/wireless/mediatek/mt76/mt76.h
@@ -245,7 +245,12 @@ struct mt76_wcid {
struct ewma_signal rssi;
int inactive_count;

+ /* cached rate, updated from mac_sta_poll() and from TXS callback logic,
+ * in 7915 at least.
+ */
struct rate_info rate;
+ bool rate_short_gi; /* cached HT/VHT short_gi, from mac_sta_poll() */
+ u8 rate_he_gi; /* cached HE GI, from mac_sta_poll() */

u16 idx;
u8 hw_key_idx;
diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
index 5fcf35f2d9fb..61ade279b35d 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
@@ -206,13 +206,19 @@ static void mt7915_mac_sta_poll(struct mt7915_dev *dev)
u8 offs = 24 + 2 * bw;

rate->he_gi = (val & (0x3 << offs)) >> offs;
+ msta->wcid.rate_he_gi = rate->he_gi; /* cache for later */
} else if (rate->flags &
(RATE_INFO_FLAGS_VHT_MCS | RATE_INFO_FLAGS_MCS)) {
- if (val & BIT(12 + bw))
+ if (val & BIT(12 + bw)) {
rate->flags |= RATE_INFO_FLAGS_SHORT_GI;
- else
+ msta->wcid.rate_short_gi = 1;
+ }
+ else {
rate->flags &= ~RATE_INFO_FLAGS_SHORT_GI;
+ msta->wcid.rate_short_gi = 0;
+ }
}
+ /* TODO: Deal with HT_MCS */
}

rcu_read_unlock();
@@ -1411,7 +1417,7 @@ mt7915_mac_add_txs_skb(struct mt7915_dev *dev, struct mt76_wcid *wcid, int pid,
goto out;

rate.flags = RATE_INFO_FLAGS_MCS;
- if (wcid->rate.flags & RATE_INFO_FLAGS_SHORT_GI)
+ if (wcid->rate_short_gi)
rate.flags |= RATE_INFO_FLAGS_SHORT_GI;
break;
case MT_PHY_TYPE_VHT:
@@ -1419,6 +1425,8 @@ mt7915_mac_add_txs_skb(struct mt7915_dev *dev, struct mt76_wcid *wcid, int pid,
goto out;

rate.flags = RATE_INFO_FLAGS_VHT_MCS;
+ if (wcid->rate_short_gi)
+ rate.flags |= RATE_INFO_FLAGS_SHORT_GI;
break;
case MT_PHY_TYPE_HE_SU:
case MT_PHY_TYPE_HE_EXT_SU:
@@ -1427,11 +1435,12 @@ mt7915_mac_add_txs_skb(struct mt7915_dev *dev, struct mt76_wcid *wcid, int pid,
if (rate.mcs > 11)
goto out;

- rate.he_gi = wcid->rate.he_gi;
+ rate.he_gi = wcid->rate_he_gi;
rate.he_dcm = FIELD_GET(MT_TX_RATE_DCM, txrate);
rate.flags = RATE_INFO_FLAGS_HE_MCS;
break;
default:
+ WARN_ON_ONCE(true);
goto out;
}

--
2.20.1



2021-11-18 16:46:04

by Ben Greear

[permalink] [raw]
Subject: [PATCH 7/8] mt76: mt7915: add support for tx-overrides

From: Ben Greear <[email protected]>

Allow setting fix rate on transmit without using full testmode
logic.

txpower, dynbw, retry count is not currently supported.
And, probably later need additional logic to not apply this
txo to non-data frames and to smaller frames, to allow
ARP and such to go through while also forcing test data frames
to arbitrary tx-rates (rates which very well may not be
received by peer.)

Signed-off-by: Ben Greear <[email protected]>
---
drivers/net/wireless/mediatek/mt76/mt76.h | 4 +
.../wireless/mediatek/mt76/mt7915/debugfs.c | 224 ++++++++++++++++++
.../net/wireless/mediatek/mt76/mt7915/mac.c | 98 ++++++--
.../wireless/mediatek/mt76/mt7915/mt7915.h | 2 +
4 files changed, 302 insertions(+), 26 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt76.h b/drivers/net/wireless/mediatek/mt76/mt76.h
index 5a431b39d5c1..7bcdfef3c983 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76.h
+++ b/drivers/net/wireless/mediatek/mt76/mt76.h
@@ -577,6 +577,7 @@ struct mt76_testmode_ops {

struct mt76_testmode_data {
enum mt76_testmode_state state;
+ u8 txo_active; /* tx overrides are active */

u32 param_set[DIV_ROUND_UP(NUM_MT76_TM_ATTRS, 32)];
struct sk_buff *tx_skb;
@@ -591,6 +592,9 @@ struct mt76_testmode_data {
u8 tx_rate_ldpc;
u8 tx_rate_stbc;
u8 tx_ltf;
+ u8 txbw; /* specify TX bandwidth: 0 20Mhz, 1 40Mhz, 2 80Mhz, 3 160Mhz */
+ u8 tx_xmit_count; /* 0 means no-ack, 1 means one transmit, etc */
+ u8 tx_dynbw; /* 0: dynamic bw disabled, 1: dynamic bw enabled */

u8 tx_antenna_mask;
u8 tx_spe_idx;
diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c b/drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c
index c5ed02cd2afc..e3f6cd18e30a 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c
@@ -190,6 +190,228 @@ mt7915_fw_util_wa_show(struct seq_file *file, void *data)

DEFINE_SHOW_ATTRIBUTE(mt7915_fw_util_wa);

+struct mt7915_txo_worker_info {
+ char* buf;
+ int sofar;
+ int size;
+};
+
+static void mt7915_txo_worker(void *wi_data, struct ieee80211_sta *sta)
+{
+ struct mt7915_txo_worker_info *wi = wi_data;
+ struct mt7915_sta *msta = (struct mt7915_sta *)sta->drv_priv;
+ struct mt76_testmode_data *td = &msta->test;
+ struct ieee80211_vif *vif;
+ struct wireless_dev *wdev;
+
+ if (wi->sofar >= wi->size)
+ return; /* buffer is full */
+
+ vif = container_of((void *)msta->vif, struct ieee80211_vif, drv_priv);
+ wdev = ieee80211_vif_to_wdev(vif);
+
+ wi->sofar += scnprintf(wi->buf + wi->sofar, wi->size - wi->sofar,
+ "vdev (%s) active=%d tpc=%d sgi=%d mcs=%d nss=%d"
+ " pream=%d retries=%d dynbw=%d bw=%d\n",
+ wdev->netdev->name,
+ td->txo_active, td->tx_power[0],
+ td->tx_rate_sgi, td->tx_rate_idx,
+ td->tx_rate_nss, td->tx_rate_mode,
+ td->tx_xmit_count, td->tx_dynbw,
+ td->txbw);
+}
+
+static ssize_t mt7915_read_set_rate_override(struct file *file,
+ char __user *user_buf,
+ size_t count, loff_t *ppos)
+{
+ struct mt7915_dev *dev = file->private_data;
+ struct ieee80211_hw *hw = dev->mphy.hw;
+ char *buf2;
+ int size = 8000;
+ int rv, sofar;
+ struct mt7915_txo_worker_info wi;
+ const char buf[] =
+ "This allows specify specif tx rate parameters for all DATA"
+ " frames on a vdev\n"
+ "To set a value, you specify the dev-name and key-value pairs:\n"
+ "tpc=10 sgi=1 mcs=x nss=x pream=x retries=x dynbw=0|1 bw=x enable=0|1\n"
+ "pream: 0=cck, 1=ofdm, 2=HT, 3=VHT, 4=HE_SU\n"
+ "cck-mcs: 0=1Mbps, 1=2Mbps, 3=5.5Mbps, 3=11Mbps\n"
+ "ofdm-mcs: 0=6Mbps, 1=9Mbps, 2=12Mbps, 3=18Mbps, 4=24Mbps, 5=36Mbps,"
+ " 6=48Mbps, 7=54Mbps\n"
+ "tpc is not implemented currently, bw is 0-3 for 20-160\n"
+ " For example, wlan0:\n"
+ "echo \"wlan0 tpc=255 sgi=1 mcs=0 nss=1 pream=3 retries=1 dynbw=0 bw=0"
+ " active=1\" > ...mt76/set_rate_override\n";
+
+ buf2 = kzalloc(size, GFP_KERNEL);
+ if (!buf2)
+ return -ENOMEM;
+ strcpy(buf2, buf);
+ sofar = strlen(buf2);
+
+ wi.sofar = sofar;
+ wi.buf = buf2;
+ wi.size = size;
+
+ ieee80211_iterate_stations_atomic(hw, mt7915_txo_worker, &wi);
+
+ rv = simple_read_from_buffer(user_buf, count, ppos, buf2, wi.sofar);
+ kfree(buf2);
+ return rv;
+}
+
+/* Set the rates for specific types of traffic.
+ */
+static ssize_t mt7915_write_set_rate_override(struct file *file,
+ const char __user *user_buf,
+ size_t count, loff_t *ppos)
+{
+ struct mt7915_dev *dev = file->private_data;
+ struct mt7915_sta *msta;
+ struct ieee80211_vif *vif;
+ struct mt76_testmode_data *td = NULL;
+ struct wireless_dev *wdev;
+ struct mt76_wcid *wcid;
+ struct mt76_phy *mphy = &dev->mt76.phy;
+ char buf[180];
+ char tmp[20];
+ char *tok;
+ int ret, i, j;
+ unsigned int vdev_id = 0xFFFF;
+ char *bufptr = buf;
+ long rc;
+ char dev_name_match[IFNAMSIZ + 2];
+
+ memset(buf, 0, sizeof(buf));
+
+ simple_write_to_buffer(buf, sizeof(buf) - 1, ppos, user_buf, count);
+
+ /* make sure that buf is null terminated */
+ buf[sizeof(buf) - 1] = 0;
+
+ /* drop the possible '\n' from the end */
+ if (buf[count - 1] == '\n')
+ buf[count - 1] = 0;
+
+ mutex_lock(&mphy->dev->mutex);
+
+ /* Ignore empty lines, 'echo' appends them sometimes at least. */
+ if (buf[0] == 0) {
+ ret = count;
+ goto exit;
+ }
+
+ /* String starts with vdev name, ie 'wlan0' Find the proper vif that
+ * matches the name.
+ */
+ for (i = 0; i < ARRAY_SIZE(dev->mt76.wcid_mask); i++) {
+ u32 mask = dev->mt76.wcid_mask[i];
+ u32 phy_mask = dev->mt76.wcid_phy_mask[i];
+
+ if (!mask)
+ continue;
+
+ for (j = i * 32; mask; j++, mask >>= 1, phy_mask >>= 1) {
+ if (!(mask & 1))
+ continue;
+
+ wcid = rcu_dereference(dev->mt76.wcid[j]);
+ if (!wcid)
+ continue;
+
+ msta = container_of(wcid, struct mt7915_sta, wcid);
+
+ vif = container_of((void *)msta->vif, struct ieee80211_vif, drv_priv);
+
+ wdev = ieee80211_vif_to_wdev(vif);
+
+ if (!wdev)
+ continue;
+
+ snprintf(dev_name_match, sizeof(dev_name_match) - 1, "%s ",
+ wdev->netdev->name);
+
+ if (strncmp(dev_name_match, buf, strlen(dev_name_match)) == 0) {
+ vdev_id = j;
+ td = &msta->test;
+ bufptr = buf + strlen(dev_name_match) - 1;
+ break;
+ }
+ }
+ }
+
+ if (vdev_id == 0xFFFF) {
+ if (strstr(buf, "active=0")) {
+ /* Ignore, we are disabling it anyway */
+ ret = count;
+ goto exit;
+ } else {
+ dev_info(dev->mt76.dev,
+ "mt7915: set-rate-override, unknown netdev name: %s\n", buf);
+ }
+ ret = -EINVAL;
+ goto exit;
+ }
+
+#define MT7915_PARSE_LTOK(a, b) \
+ do { \
+ tok = strstr(bufptr, " " #a "="); \
+ if (tok) { \
+ char *tspace; \
+ tok += 1; /* move past initial space */ \
+ strncpy(tmp, tok + strlen(#a "="), sizeof(tmp) - 1); \
+ tmp[sizeof(tmp) - 1] = 0; \
+ tspace = strstr(tmp, " "); \
+ if (tspace) \
+ *tspace = 0; \
+ if (kstrtol(tmp, 0, &rc) != 0) \
+ dev_info(dev->mt76.dev, \
+ "mt7915: set-rate-override: " #a \
+ "= could not be parsed, tmp: %s\n", \
+ tmp); \
+ else \
+ td->b = rc; \
+ } \
+ } while (0)
+
+ /* TODO: Allow configuring LTF? */
+ td->tx_ltf = 1; /* 0: HTLTF 3.2us, 1: HELTF, 6.4us, 2 HELTF 12,8us */
+
+ MT7915_PARSE_LTOK(tpc, tx_power[0]);
+ MT7915_PARSE_LTOK(sgi, tx_rate_sgi);
+ MT7915_PARSE_LTOK(mcs, tx_rate_idx);
+ MT7915_PARSE_LTOK(nss, tx_rate_nss);
+ MT7915_PARSE_LTOK(pream, tx_rate_mode);
+ MT7915_PARSE_LTOK(retries, tx_xmit_count);
+ MT7915_PARSE_LTOK(dynbw, tx_dynbw);
+ MT7915_PARSE_LTOK(bw, txbw);
+ MT7915_PARSE_LTOK(active, txo_active);
+
+ dev_info(dev->mt76.dev,
+ "mt7915: set-rate-overrides, vdev %i(%s) active=%d tpc=%d sgi=%d mcs=%d"
+ " nss=%d pream=%d retries=%d dynbw=%d bw=%d\n",
+ vdev_id, dev_name_match,
+ td->txo_active, td->tx_power[0], td->tx_rate_sgi, td->tx_rate_idx,
+ td->tx_rate_nss, td->tx_rate_mode, td->tx_xmit_count, td->tx_dynbw,
+ td->txbw);
+
+ ret = count;
+
+exit:
+ mutex_unlock(&mphy->dev->mutex);
+ return ret;
+}
+
+static const struct file_operations fops_set_rate_override = {
+ .read = mt7915_read_set_rate_override,
+ .write = mt7915_write_set_rate_override,
+ .open = simple_open,
+ .owner = THIS_MODULE,
+ .llseek = default_llseek,
+};
+
static int
mt7915_txs_for_no_skb_set(void *data, u64 val)
{
@@ -577,6 +799,8 @@ int mt7915_init_debugfs(struct mt7915_phy *phy)
debugfs_create_file("radar_trigger", 0200, dir, dev,
&fops_radar_trigger);
}
+ debugfs_create_file("set_rate_override", 0600, dir,
+ dev, &fops_set_rate_override);

return 0;
}
diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
index 4f565a77770c..c3dfd22d4978 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
@@ -757,21 +757,31 @@ mt7915_mac_fill_rx_vector(struct mt7915_dev *dev, struct sk_buff *skb)
}

static void
-mt7915_mac_write_txwi_tm(struct mt7915_phy *phy, __le32 *txwi,
+mt7915_mac_write_txwi_tm(struct mt7915_phy *phy, struct mt76_wcid *wcid, __le32 *txwi,
struct sk_buff *skb)
{
-#ifdef CONFIG_NL80211_TESTMODE
- struct mt76_testmode_data *td = &phy->mt76->test;
+ struct mt76_testmode_data *td;
const struct ieee80211_rate *r;
- u8 bw, mode, nss = td->tx_rate_nss;
- u8 rate_idx = td->tx_rate_idx;
+ struct mt7915_sta *msta;
+ u8 bw, mode, nss;
+ u8 rate_idx;
u16 rateval = 0;
u32 val;
bool cck = false;
int band;

- if (skb != phy->mt76->test.tx_skb)
- return;
+ msta = container_of(wcid, struct mt7915_sta, wcid);
+
+ if (msta->test.txo_active) {
+ td = &msta->test;
+ } else {
+ if (skb != phy->mt76->test.tx_skb)
+ return;
+ td = &phy->mt76->test;
+ }
+
+ nss = td->tx_rate_nss;
+ rate_idx = td->tx_rate_idx;

switch (td->tx_rate_mode) {
case MT76_TM_TX_MODE_HT:
@@ -812,20 +822,24 @@ mt7915_mac_write_txwi_tm(struct mt7915_phy *phy, __le32 *txwi,
break;
}

- switch (phy->mt76->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 (msta->test.txo_active) {
+ bw = td->txbw;
+ } else {
+ switch (phy->mt76->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) {
@@ -837,12 +851,17 @@ mt7915_mac_write_txwi_tm(struct mt7915_phy *phy, __le32 *txwi,
FIELD_PREP(MT_TX_RATE_MODE, mode) |
FIELD_PREP(MT_TX_RATE_NSS, nss - 1);

+ /* TODO: Support per-skb txpower, p.15 of txpower doc, DW2 29:24. */
txwi[2] |= cpu_to_le32(MT_TXD2_FIX_RATE);

+ /* Looks like this sets tx attempt to exactly 1.
+ * TODO: Use td->tx_xmit_count, if in txo mode.
+ */
le32p_replace_bits(&txwi[3], 1, MT_TXD3_REM_TX_COUNT);
if (td->tx_rate_mode < MT76_TM_TX_MODE_HT)
txwi[3] |= cpu_to_le32(MT_TXD3_BA_DISABLE);

+ /* TODO: Take tx_dynbw into account in txo mode. */
val = MT_TXD6_FIXED_BW |
FIELD_PREP(MT_TXD6_BW, bw) |
FIELD_PREP(MT_TXD6_TX_RATE, rateval) |
@@ -866,9 +885,29 @@ mt7915_mac_write_txwi_tm(struct mt7915_phy *phy, __le32 *txwi,

txwi[3] &= ~cpu_to_le32(MT_TXD3_SN_VALID);
txwi[6] |= cpu_to_le32(val);
- txwi[7] |= cpu_to_le32(FIELD_PREP(MT_TXD7_SPE_IDX,
- phy->test.spe_idx));
-#endif
+
+ if (msta->test.txo_active) {
+ /* see mt7915_tm_set_tx_frames */
+ static const u8 spe_idx_map[] = {0, 0, 1, 0, 3, 2, 4, 0,
+ 9, 8, 6, 10, 16, 12, 18, 0};
+ u32 spe_idx;
+
+ if (td->tx_spe_idx) {
+ spe_idx = td->tx_spe_idx;
+ } else {
+ u8 tx_ant = td->tx_antenna_mask;
+
+ if (!tx_ant) {
+ /* use antenna mask that matches our nss */
+ tx_ant = GENMASK(nss - 1, 0);
+ }
+ spe_idx = spe_idx_map[tx_ant];
+ }
+ txwi[7] |= cpu_to_le32(FIELD_PREP(MT_TXD7_SPE_IDX, spe_idx));
+ } else {
+ txwi[7] |= cpu_to_le32(FIELD_PREP(MT_TXD7_SPE_IDX,
+ phy->test.spe_idx));
+ }
}

static void
@@ -1121,8 +1160,15 @@ void mt7915_mac_write_txwi(struct mt7915_dev *dev, __le32 *txwi,
txwi[3] |= cpu_to_le32(MT_TXD3_BA_DISABLE);
}

- if (mt76_testmode_enabled(mphy))
- mt7915_mac_write_txwi_tm(mphy->priv, txwi, skb);
+#ifdef CONFIG_NL80211_TESTMODE
+ {
+ struct mt7915_sta *msta;
+
+ msta = container_of(wcid, struct mt7915_sta, wcid);
+ if (mt76_testmode_enabled(mphy) || msta->test.txo_active)
+ mt7915_mac_write_txwi_tm(mphy->priv, wcid, txwi, skb);
+ }
+#endif
}

int mt7915_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr,
diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h b/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h
index 8b1d4664562a..86cd0fc8e9de 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h
+++ b/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h
@@ -103,6 +103,8 @@ struct mt7915_sta {

struct mt7915_sta_key_conf bip;

+ struct mt76_testmode_data test;
+
struct {
u8 flowid_mask;
struct mt7915_twt_flow flow[MT7915_MAX_STA_TWT_AGRT];
--
2.20.1


2021-11-18 16:46:11

by Ben Greear

[permalink] [raw]
Subject: [PATCH 8/8] mt76: mt7915: fix SGI reporting when using tx-overrides

From: Ben Greear <[email protected]>

The station wtbl logic to read rate-ctrl settings does not work when
fixed rates are used. So, read sgi settings from the txo configuration
in this case.

Signed-off-by: Ben Greear <[email protected]>
---
drivers/net/wireless/mediatek/mt76/mt7915/mac.c | 9 +++++++++
1 file changed, 9 insertions(+)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
index c3dfd22d4978..8e5b87af2efb 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
@@ -177,6 +177,15 @@ static void mt7915_mac_sta_poll(struct mt7915_dev *dev)
rx_cur);
}

+ /* If we are in tx-override mode, then wtbl doesn't provide useful report
+ * for the SGI/LGI stuff, so just get it from the override struct.
+ */
+ if (msta->test.txo_active) {
+ msta->wcid.rate_he_gi = msta->test.tx_rate_sgi;
+ msta->wcid.rate_short_gi = msta->test.tx_rate_sgi;
+ continue;
+ }
+
/*
* We don't support reading GI info from txs packets.
* For accurate tx status reporting and AQL improvement,
--
2.20.1


2021-11-18 16:46:22

by Ben Greear

[permalink] [raw]
Subject: [PATCH 5/8] mt76: mt7915: txfree status to show txcount instead of latency

From: Ben Greear <[email protected]>

Latency is not obviously that useful, but txcount can let us deduce
retries, which may be more interesting.

Signed-off-by: Ben Greear <[email protected]>
---
drivers/net/wireless/mediatek/mt76/mt7915/init.c | 3 +++
drivers/net/wireless/mediatek/mt76/mt7915/mac.h | 8 +++++---
drivers/net/wireless/mediatek/mt76/mt7915/regs.h | 8 ++++++++
3 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/init.c b/drivers/net/wireless/mediatek/mt76/mt7915/init.c
index 0c41ea23d6b3..3b35ea245b33 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7915/init.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7915/init.c
@@ -401,6 +401,9 @@ static void mt7915_mac_init(struct mt7915_dev *dev)
/* enable hardware de-agg */
mt76_set(dev, MT_MDP_DCR0, MT_MDP_DCR0_DAMSDU_EN);

+ /* disable Tx latency report to enable Tx count in txfree path */
+ mt76_clear(dev, MT_PLE_HOST_RPT0, MT_PLE_HOST_RPT0_TX_LATENCY);
+
for (i = 0; i < MT7915_WTBL_SIZE; i++)
mt7915_mac_wtbl_update(dev, i,
MT_WTBL_UPDATE_ADM_COUNT_CLEAR);
diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mac.h b/drivers/net/wireless/mediatek/mt76/mt7915/mac.h
index b66e740832e4..4ba5574cc6f3 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7915/mac.h
+++ b/drivers/net/wireless/mediatek/mt76/mt7915/mac.h
@@ -305,13 +305,15 @@ struct mt7915_tx_free {

#define MT_TX_FREE_MSDU_CNT GENMASK(9, 0)
#define MT_TX_FREE_WLAN_ID GENMASK(23, 14)
+/* when configured for txfree latency mode. See MT_PLE_HOST_RPT0_TX_LATENCY
+ * Not enabled by default now.
+ */
#define MT_TX_FREE_LATENCY GENMASK(12, 0)
-/* 0: success, others: dropped */
+/* when configured for txcount mode. See MT_PLE_HOST_RPT0_TX_LATENCY. */
+#define MT_TX_FREE_TXCNT GENMASK(12, 0)
#define MT_TX_FREE_STATUS GENMASK(14, 13)
#define MT_TX_FREE_MSDU_ID GENMASK(30, 16)
#define MT_TX_FREE_PAIR BIT(31)
-/* will support this field in further revision */
-#define MT_TX_FREE_RATE GENMASK(13, 0)

#define MT_TXS0_FIXED_RATE BIT(31)
#define MT_TXS0_BW GENMASK(30, 29)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/regs.h b/drivers/net/wireless/mediatek/mt76/mt7915/regs.h
index 59693535b098..d23c669cc933 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7915/regs.h
+++ b/drivers/net/wireless/mediatek/mt76/mt7915/regs.h
@@ -22,6 +22,14 @@
#define MT_PLE_BASE 0x8000
#define MT_PLE(ofs) (MT_PLE_BASE + (ofs))

+/* Modify whether txfree struct returns latency or txcount. */
+#define MT_PLE_HOST_RPT0 MT_PLE(0x030)
+#define MT_PLE_HOST_RPT0_TX_LATENCY BIT(3)
+
+#define MT_PLE_FL_Q0_CTRL MT_PLE(0x1b0)
+#define MT_PLE_FL_Q1_CTRL MT_PLE(0x1b4)
+#define MT_PLE_FL_Q2_CTRL MT_PLE(0x1b8)
+
#define MT_FL_Q_EMPTY 0x0b0
#define MT_FL_Q0_CTRL 0x1b0
#define MT_FL_Q2_CTRL 0x1b8
--
2.20.1


2021-11-18 17:06:31

by Ryder Lee

[permalink] [raw]
Subject: Re: [PATCH 1/8] mt76: mt7915: cache sgi in wcid.

On Thu, 2021-11-18 at 08:45 -0800, [email protected] wrote:
> From: Ben Greear <[email protected]>
>
> Explicitly cache short_gi and he_gi in wcid, don't try to store
> it in the wcid.rate object. Slightly less confusing and less fragile
> when TXS starts parsing lots of frames.
>
> Signed-off-by: Ben Greear <[email protected]>
> ---
>
> This is actually the first series, not that one I posted a few
> minutes
> ago. txs, tx overrides and other things. Rebased on top of 5.16
>
> drivers/net/wireless/mediatek/mt76/mt76.h | 5 +++++
> drivers/net/wireless/mediatek/mt76/mt7915/mac.c | 17 +++++++++++++
> ----
> 2 files changed, 18 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/net/wireless/mediatek/mt76/mt76.h
> b/drivers/net/wireless/mediatek/mt76/mt76.h
> index e2da720a91b6..7234703b3c60 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt76.h
> +++ b/drivers/net/wireless/mediatek/mt76/mt76.h
> @@ -245,7 +245,12 @@ struct mt76_wcid {
> struct ewma_signal rssi;
> int inactive_count;
>
> + /* cached rate, updated from mac_sta_poll() and from TXS
> callback logic,
> + * in 7915 at least.
> + */
> struct rate_info rate;
> + bool rate_short_gi; /* cached HT/VHT short_gi, from
> mac_sta_poll() */
> + u8 rate_he_gi; /* cached HE GI, from mac_sta_poll() */
>
> u16 idx;
> u8 hw_key_idx;
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
> b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
> index 5fcf35f2d9fb..61ade279b35d 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
> @@ -206,13 +206,19 @@ static void mt7915_mac_sta_poll(struct
> mt7915_dev *dev)
> u8 offs = 24 + 2 * bw;
>
> rate->he_gi = (val & (0x3 << offs)) >> offs;
> + msta->wcid.rate_he_gi = rate->he_gi; /* cache
> for later */
> } else if (rate->flags &
> (RATE_INFO_FLAGS_VHT_MCS |
> RATE_INFO_FLAGS_MCS)) {
> - if (val & BIT(12 + bw))
> + if (val & BIT(12 + bw)) {
> rate->flags |=
> RATE_INFO_FLAGS_SHORT_GI;
> - else
> + msta->wcid.rate_short_gi = 1;
> + }
> + else {
> rate->flags &=
> ~RATE_INFO_FLAGS_SHORT_GI;
> + msta->wcid.rate_short_gi = 0;
> + }
> }
> + /* TODO: Deal with HT_MCS */
> }
>
> rcu_read_unlock();
> @@ -1411,7 +1417,7 @@ mt7915_mac_add_txs_skb(struct mt7915_dev *dev,
> struct mt76_wcid *wcid, int pid,
> goto out;
>
> rate.flags = RATE_INFO_FLAGS_MCS;
> - if (wcid->rate.flags & RATE_INFO_FLAGS_SHORT_GI)
> + if (wcid->rate_short_gi)
> rate.flags |= RATE_INFO_FLAGS_SHORT_GI;
> break;
> case MT_PHY_TYPE_VHT:
> @@ -1419,6 +1425,8 @@ mt7915_mac_add_txs_skb(struct mt7915_dev *dev,
> struct mt76_wcid *wcid, int pid,
> goto out;
>
> rate.flags = RATE_INFO_FLAGS_VHT_MCS;
> + if (wcid->rate_short_gi)
> + rate.flags |= RATE_INFO_FLAGS_SHORT_GI;
> break;
> case MT_PHY_TYPE_HE_SU:
> case MT_PHY_TYPE_HE_EXT_SU:
> @@ -1427,11 +1435,12 @@ mt7915_mac_add_txs_skb(struct mt7915_dev
> *dev, struct mt76_wcid *wcid, int pid,
> if (rate.mcs > 11)
> goto out;
>
> - rate.he_gi = wcid->rate.he_gi;
> + rate.he_gi = wcid->rate_he_gi;
> rate.he_dcm = FIELD_GET(MT_TX_RATE_DCM, txrate);
> rate.flags = RATE_INFO_FLAGS_HE_MCS;
> break;
> default:
> + WARN_ON_ONCE(true);
> goto out;
> }

Maybe we can consider switching to use existing fixed-rate method in
debugfs? On th other hand, that's the only way to configure HE MU UL
fixed-rate.

Ryder


2021-11-18 17:15:48

by Ben Greear

[permalink] [raw]
Subject: Re: [PATCH 1/8] mt76: mt7915: cache sgi in wcid.

On 11/18/21 9:06 AM, Ryder Lee wrote:
> On Thu, 2021-11-18 at 08:45 -0800, [email protected] wrote:
>> From: Ben Greear <[email protected]>
>>
>> Explicitly cache short_gi and he_gi in wcid, don't try to store
>> it in the wcid.rate object. Slightly less confusing and less fragile
>> when TXS starts parsing lots of frames.
>>
>> Signed-off-by: Ben Greear <[email protected]>
>> ---
>>
>> This is actually the first series, not that one I posted a few
>> minutes
>> ago. txs, tx overrides and other things. Rebased on top of 5.16

>
> Maybe we can consider switching to use existing fixed-rate method in
> debugfs? On th other hand, that's the only way to configure HE MU UL
> fixed-rate.

This patch is to improve reported tx rates, not to control tx rates.

Thanks,
Ben

--
Ben Greear <[email protected]>
Candela Technologies Inc http://www.candelatech.com


2021-11-18 17:20:56

by Ryder Lee

[permalink] [raw]
Subject: Re: [PATCH 1/8] mt76: mt7915: cache sgi in wcid.

* On Thu, 2021-11-18 at 09:10 -0800, Ben Greear wrote:
> On 11/18/21 9:06 AM, Ryder Lee wrote:
> > On Thu, 2021-11-18 at 08:45 -0800, [email protected] wrote:
> > > From: Ben Greear <[email protected]>
> > >
> > > Explicitly cache short_gi and he_gi in wcid, don't try to store
> > > it in the wcid.rate object. Slightly less confusing and less
> > > fragile
> > > when TXS starts parsing lots of frames.
> > >
> > > Signed-off-by: Ben Greear <[email protected]>
> > > ---
> > >
> > > This is actually the first series, not that one I posted a few
> > > minutes
> > > ago. txs, tx overrides and other things. Rebased on top of 5.16
> >
> > Maybe we can consider switching to use existing fixed-rate method
> > in
> > debugfs? On th other hand, that's the only way to configure HE MU
> > UL
> > fixed-rate.
>
> This patch is to improve reported tx rates, not to control tx rates.
>

Ah. I shall reply [PATCH 8/8] mt76: mt7915: fix SGI reporting when
using tx-overrides.


2021-11-19 07:17:47

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH 7/8] mt76: mt7915: add support for tx-overrides

Hi,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on kvalo-wireless-drivers-next/master]
[also build test ERROR on v5.16-rc1 next-20211118]
[cannot apply to kvalo-wireless-drivers/master]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url: https://github.com/0day-ci/linux/commits/greearb-candelatech-com/mt76-mt7915-cache-sgi-in-wcid/20211119-005421
base: https://git.kernel.org/pub/scm/linux/kernel/git/kvalo/wireless-drivers-next.git master
config: microblaze-buildonly-randconfig-r005-20211119 (attached as .config)
compiler: microblaze-linux-gcc (GCC) 11.2.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/c742cd1ffffaeff7ab79835466b08fd5616cdce3
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review greearb-candelatech-com/mt76-mt7915-cache-sgi-in-wcid/20211119-005421
git checkout c742cd1ffffaeff7ab79835466b08fd5616cdce3
# save the attached .config to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=microblaze SHELL=/bin/bash drivers/net/wireless/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <[email protected]>

All errors (new ones prefixed by >>):

drivers/net/wireless/mediatek/mt76/mt7915/mac.c: In function 'mt7915_mac_write_txwi_tm':
>> drivers/net/wireless/mediatek/mt76/mt7915/mac.c:778:37: error: 'struct mt76_phy' has no member named 'test'
778 | if (skb != phy->mt76->test.tx_skb)
| ^~
drivers/net/wireless/mediatek/mt76/mt7915/mac.c:780:32: error: 'struct mt76_phy' has no member named 'test'
780 | td = &phy->mt76->test;
| ^~
In file included from include/linux/byteorder/little_endian.h:5,
from arch/microblaze/include/uapi/asm/byteorder.h:6,
from include/asm-generic/bitops/le.h:7,
from include/asm-generic/bitops.h:36,
from ./arch/microblaze/include/generated/asm/bitops.h:1,
from include/linux/bitops.h:33,
from include/linux/kernel.h:12,
from include/linux/skbuff.h:13,
from include/linux/if_ether.h:19,
from include/linux/etherdevice.h:20,
from drivers/net/wireless/mediatek/mt76/mt7915/mac.c:4:
>> drivers/net/wireless/mediatek/mt76/mt7915/mac.c:909:54: error: 'struct mt7915_phy' has no member named 'test'
909 | phy->test.spe_idx));
| ^~
include/uapi/linux/byteorder/little_endian.h:33:51: note: in definition of macro '__cpu_to_le32'
33 | #define __cpu_to_le32(x) ((__force __le32)(__u32)(x))
| ^
include/linux/compiler_types.h:310:9: note: in expansion of macro '__compiletime_assert'
310 | __compiletime_assert(condition, msg, prefix, suffix)
| ^~~~~~~~~~~~~~~~~~~~
include/linux/compiler_types.h:322:9: note: in expansion of macro '_compiletime_assert'
322 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
| ^~~~~~~~~~~~~~~~~~~
include/linux/build_bug.h:39:37: note: in expansion of macro 'compiletime_assert'
39 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
| ^~~~~~~~~~~~~~~~~~
include/linux/bitfield.h:49:17: note: in expansion of macro 'BUILD_BUG_ON_MSG'
49 | BUILD_BUG_ON_MSG(__builtin_constant_p(_val) ? \
| ^~~~~~~~~~~~~~~~
include/linux/bitfield.h:94:17: note: in expansion of macro '__BF_FIELD_CHECK'
94 | __BF_FIELD_CHECK(_mask, 0ULL, _val, "FIELD_PREP: "); \
| ^~~~~~~~~~~~~~~~
drivers/net/wireless/mediatek/mt76/mt7915/mac.c:908:40: note: in expansion of macro 'FIELD_PREP'
908 | txwi[7] |= cpu_to_le32(FIELD_PREP(MT_TXD7_SPE_IDX,
| ^~~~~~~~~~
>> drivers/net/wireless/mediatek/mt76/mt7915/mac.c:909:54: error: 'struct mt7915_phy' has no member named 'test'
909 | phy->test.spe_idx));
| ^~
include/uapi/linux/byteorder/little_endian.h:33:51: note: in definition of macro '__cpu_to_le32'
33 | #define __cpu_to_le32(x) ((__force __le32)(__u32)(x))
| ^
include/linux/compiler_types.h:310:9: note: in expansion of macro '__compiletime_assert'
310 | __compiletime_assert(condition, msg, prefix, suffix)
| ^~~~~~~~~~~~~~~~~~~~
include/linux/compiler_types.h:322:9: note: in expansion of macro '_compiletime_assert'
322 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
| ^~~~~~~~~~~~~~~~~~~
include/linux/build_bug.h:39:37: note: in expansion of macro 'compiletime_assert'
39 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
| ^~~~~~~~~~~~~~~~~~
include/linux/bitfield.h:49:17: note: in expansion of macro 'BUILD_BUG_ON_MSG'
49 | BUILD_BUG_ON_MSG(__builtin_constant_p(_val) ? \
| ^~~~~~~~~~~~~~~~
include/linux/bitfield.h:94:17: note: in expansion of macro '__BF_FIELD_CHECK'
94 | __BF_FIELD_CHECK(_mask, 0ULL, _val, "FIELD_PREP: "); \
| ^~~~~~~~~~~~~~~~
drivers/net/wireless/mediatek/mt76/mt7915/mac.c:908:40: note: in expansion of macro 'FIELD_PREP'
908 | txwi[7] |= cpu_to_le32(FIELD_PREP(MT_TXD7_SPE_IDX,
| ^~~~~~~~~~
>> drivers/net/wireless/mediatek/mt76/mt7915/mac.c:909:54: error: 'struct mt7915_phy' has no member named 'test'
909 | phy->test.spe_idx));
| ^~
include/uapi/linux/byteorder/little_endian.h:33:51: note: in definition of macro '__cpu_to_le32'
33 | #define __cpu_to_le32(x) ((__force __le32)(__u32)(x))
| ^
drivers/net/wireless/mediatek/mt76/mt7915/mac.c:908:40: note: in expansion of macro 'FIELD_PREP'
908 | txwi[7] |= cpu_to_le32(FIELD_PREP(MT_TXD7_SPE_IDX,
| ^~~~~~~~~~
At top level:
drivers/net/wireless/mediatek/mt76/mt7915/mac.c:760:1: warning: 'mt7915_mac_write_txwi_tm' defined but not used [-Wunused-function]
760 | mt7915_mac_write_txwi_tm(struct mt7915_phy *phy, struct mt76_wcid *wcid, __le32 *txwi,
| ^~~~~~~~~~~~~~~~~~~~~~~~


vim +778 drivers/net/wireless/mediatek/mt76/mt7915/mac.c

5d8a83f0994134 Shayne Chen 2020-10-22 758
aadf09537c575d Shayne Chen 2020-10-22 759 static void
c742cd1ffffaef Ben Greear 2021-11-18 760 mt7915_mac_write_txwi_tm(struct mt7915_phy *phy, struct mt76_wcid *wcid, __le32 *txwi,
c918c74d06457e Shayne Chen 2020-12-04 761 struct sk_buff *skb)
aadf09537c575d Shayne Chen 2020-10-22 762 {
c742cd1ffffaef Ben Greear 2021-11-18 763 struct mt76_testmode_data *td;
cc91747be98f2a Shayne Chen 2021-04-12 764 const struct ieee80211_rate *r;
c742cd1ffffaef Ben Greear 2021-11-18 765 struct mt7915_sta *msta;
c742cd1ffffaef Ben Greear 2021-11-18 766 u8 bw, mode, nss;
c742cd1ffffaef Ben Greear 2021-11-18 767 u8 rate_idx;
aadf09537c575d Shayne Chen 2020-10-22 768 u16 rateval = 0;
aadf09537c575d Shayne Chen 2020-10-22 769 u32 val;
cc91747be98f2a Shayne Chen 2021-04-12 770 bool cck = false;
cc91747be98f2a Shayne Chen 2021-04-12 771 int band;
aadf09537c575d Shayne Chen 2020-10-22 772
c742cd1ffffaef Ben Greear 2021-11-18 773 msta = container_of(wcid, struct mt7915_sta, wcid);
c742cd1ffffaef Ben Greear 2021-11-18 774
c742cd1ffffaef Ben Greear 2021-11-18 775 if (msta->test.txo_active) {
c742cd1ffffaef Ben Greear 2021-11-18 776 td = &msta->test;
c742cd1ffffaef Ben Greear 2021-11-18 777 } else {
c918c74d06457e Shayne Chen 2020-12-04 @778 if (skb != phy->mt76->test.tx_skb)
aadf09537c575d Shayne Chen 2020-10-22 779 return;
c742cd1ffffaef Ben Greear 2021-11-18 780 td = &phy->mt76->test;
c742cd1ffffaef Ben Greear 2021-11-18 781 }
c742cd1ffffaef Ben Greear 2021-11-18 782
c742cd1ffffaef Ben Greear 2021-11-18 783 nss = td->tx_rate_nss;
c742cd1ffffaef Ben Greear 2021-11-18 784 rate_idx = td->tx_rate_idx;
aadf09537c575d Shayne Chen 2020-10-22 785
aadf09537c575d Shayne Chen 2020-10-22 786 switch (td->tx_rate_mode) {
aadf09537c575d Shayne Chen 2020-10-22 787 case MT76_TM_TX_MODE_HT:
aadf09537c575d Shayne Chen 2020-10-22 788 nss = 1 + (rate_idx >> 3);
aadf09537c575d Shayne Chen 2020-10-22 789 mode = MT_PHY_TYPE_HT;
aadf09537c575d Shayne Chen 2020-10-22 790 break;
aadf09537c575d Shayne Chen 2020-10-22 791 case MT76_TM_TX_MODE_VHT:
aadf09537c575d Shayne Chen 2020-10-22 792 mode = MT_PHY_TYPE_VHT;
aadf09537c575d Shayne Chen 2020-10-22 793 break;
aadf09537c575d Shayne Chen 2020-10-22 794 case MT76_TM_TX_MODE_HE_SU:
aadf09537c575d Shayne Chen 2020-10-22 795 mode = MT_PHY_TYPE_HE_SU;
aadf09537c575d Shayne Chen 2020-10-22 796 break;
aadf09537c575d Shayne Chen 2020-10-22 797 case MT76_TM_TX_MODE_HE_EXT_SU:
aadf09537c575d Shayne Chen 2020-10-22 798 mode = MT_PHY_TYPE_HE_EXT_SU;
aadf09537c575d Shayne Chen 2020-10-22 799 break;
aadf09537c575d Shayne Chen 2020-10-22 800 case MT76_TM_TX_MODE_HE_TB:
aadf09537c575d Shayne Chen 2020-10-22 801 mode = MT_PHY_TYPE_HE_TB;
aadf09537c575d Shayne Chen 2020-10-22 802 break;
aadf09537c575d Shayne Chen 2020-10-22 803 case MT76_TM_TX_MODE_HE_MU:
aadf09537c575d Shayne Chen 2020-10-22 804 mode = MT_PHY_TYPE_HE_MU;
aadf09537c575d Shayne Chen 2020-10-22 805 break;
cc91747be98f2a Shayne Chen 2021-04-12 806 case MT76_TM_TX_MODE_CCK:
cc91747be98f2a Shayne Chen 2021-04-12 807 cck = true;
cc91747be98f2a Shayne Chen 2021-04-12 808 fallthrough;
aadf09537c575d Shayne Chen 2020-10-22 809 case MT76_TM_TX_MODE_OFDM:
cc91747be98f2a Shayne Chen 2021-04-12 810 band = phy->mt76->chandef.chan->band;
cc91747be98f2a Shayne Chen 2021-04-12 811 if (band == NL80211_BAND_2GHZ && !cck)
cc91747be98f2a Shayne Chen 2021-04-12 812 rate_idx += 4;
cc91747be98f2a Shayne Chen 2021-04-12 813
cc91747be98f2a Shayne Chen 2021-04-12 814 r = &phy->mt76->hw->wiphy->bands[band]->bitrates[rate_idx];
cc91747be98f2a Shayne Chen 2021-04-12 815 val = cck ? r->hw_value_short : r->hw_value;
cc91747be98f2a Shayne Chen 2021-04-12 816
cc91747be98f2a Shayne Chen 2021-04-12 817 mode = val >> 8;
cc91747be98f2a Shayne Chen 2021-04-12 818 rate_idx = val & 0xff;
cc91747be98f2a Shayne Chen 2021-04-12 819 break;
aadf09537c575d Shayne Chen 2020-10-22 820 default:
aadf09537c575d Shayne Chen 2020-10-22 821 mode = MT_PHY_TYPE_OFDM;
aadf09537c575d Shayne Chen 2020-10-22 822 break;
aadf09537c575d Shayne Chen 2020-10-22 823 }
aadf09537c575d Shayne Chen 2020-10-22 824
c742cd1ffffaef Ben Greear 2021-11-18 825 if (msta->test.txo_active) {
c742cd1ffffaef Ben Greear 2021-11-18 826 bw = td->txbw;
c742cd1ffffaef Ben Greear 2021-11-18 827 } else {
c918c74d06457e Shayne Chen 2020-12-04 828 switch (phy->mt76->chandef.width) {
aadf09537c575d Shayne Chen 2020-10-22 829 case NL80211_CHAN_WIDTH_40:
aadf09537c575d Shayne Chen 2020-10-22 830 bw = 1;
aadf09537c575d Shayne Chen 2020-10-22 831 break;
aadf09537c575d Shayne Chen 2020-10-22 832 case NL80211_CHAN_WIDTH_80:
aadf09537c575d Shayne Chen 2020-10-22 833 bw = 2;
aadf09537c575d Shayne Chen 2020-10-22 834 break;
aadf09537c575d Shayne Chen 2020-10-22 835 case NL80211_CHAN_WIDTH_80P80:
aadf09537c575d Shayne Chen 2020-10-22 836 case NL80211_CHAN_WIDTH_160:
aadf09537c575d Shayne Chen 2020-10-22 837 bw = 3;
aadf09537c575d Shayne Chen 2020-10-22 838 break;
aadf09537c575d Shayne Chen 2020-10-22 839 default:
aadf09537c575d Shayne Chen 2020-10-22 840 bw = 0;
aadf09537c575d Shayne Chen 2020-10-22 841 break;
aadf09537c575d Shayne Chen 2020-10-22 842 }
c742cd1ffffaef Ben Greear 2021-11-18 843 }
aadf09537c575d Shayne Chen 2020-10-22 844
aadf09537c575d Shayne Chen 2020-10-22 845 if (td->tx_rate_stbc && nss == 1) {
aadf09537c575d Shayne Chen 2020-10-22 846 nss++;
aadf09537c575d Shayne Chen 2020-10-22 847 rateval |= MT_TX_RATE_STBC;
aadf09537c575d Shayne Chen 2020-10-22 848 }
aadf09537c575d Shayne Chen 2020-10-22 849
aadf09537c575d Shayne Chen 2020-10-22 850 rateval |= FIELD_PREP(MT_TX_RATE_IDX, rate_idx) |
aadf09537c575d Shayne Chen 2020-10-22 851 FIELD_PREP(MT_TX_RATE_MODE, mode) |
aadf09537c575d Shayne Chen 2020-10-22 852 FIELD_PREP(MT_TX_RATE_NSS, nss - 1);
aadf09537c575d Shayne Chen 2020-10-22 853
c742cd1ffffaef Ben Greear 2021-11-18 854 /* TODO: Support per-skb txpower, p.15 of txpower doc, DW2 29:24. */
aadf09537c575d Shayne Chen 2020-10-22 855 txwi[2] |= cpu_to_le32(MT_TXD2_FIX_RATE);
aadf09537c575d Shayne Chen 2020-10-22 856
c742cd1ffffaef Ben Greear 2021-11-18 857 /* Looks like this sets tx attempt to exactly 1.
c742cd1ffffaef Ben Greear 2021-11-18 858 * TODO: Use td->tx_xmit_count, if in txo mode.
c742cd1ffffaef Ben Greear 2021-11-18 859 */
aadf09537c575d Shayne Chen 2020-10-22 860 le32p_replace_bits(&txwi[3], 1, MT_TXD3_REM_TX_COUNT);
aadf09537c575d Shayne Chen 2020-10-22 861 if (td->tx_rate_mode < MT76_TM_TX_MODE_HT)
aadf09537c575d Shayne Chen 2020-10-22 862 txwi[3] |= cpu_to_le32(MT_TXD3_BA_DISABLE);
aadf09537c575d Shayne Chen 2020-10-22 863
c742cd1ffffaef Ben Greear 2021-11-18 864 /* TODO: Take tx_dynbw into account in txo mode. */
aadf09537c575d Shayne Chen 2020-10-22 865 val = MT_TXD6_FIXED_BW |
aadf09537c575d Shayne Chen 2020-10-22 866 FIELD_PREP(MT_TXD6_BW, bw) |
aadf09537c575d Shayne Chen 2020-10-22 867 FIELD_PREP(MT_TXD6_TX_RATE, rateval) |
aadf09537c575d Shayne Chen 2020-10-22 868 FIELD_PREP(MT_TXD6_SGI, td->tx_rate_sgi);
aadf09537c575d Shayne Chen 2020-10-22 869
aadf09537c575d Shayne Chen 2020-10-22 870 /* for HE_SU/HE_EXT_SU PPDU
aadf09537c575d Shayne Chen 2020-10-22 871 * - 1x, 2x, 4x LTF + 0.8us GI
aadf09537c575d Shayne Chen 2020-10-22 872 * - 2x LTF + 1.6us GI, 4x LTF + 3.2us GI
aadf09537c575d Shayne Chen 2020-10-22 873 * for HE_MU PPDU
aadf09537c575d Shayne Chen 2020-10-22 874 * - 2x, 4x LTF + 0.8us GI
aadf09537c575d Shayne Chen 2020-10-22 875 * - 2x LTF + 1.6us GI, 4x LTF + 3.2us GI
aadf09537c575d Shayne Chen 2020-10-22 876 * for HE_TB PPDU
aadf09537c575d Shayne Chen 2020-10-22 877 * - 1x, 2x LTF + 1.6us GI
aadf09537c575d Shayne Chen 2020-10-22 878 * - 4x LTF + 3.2us GI
aadf09537c575d Shayne Chen 2020-10-22 879 */
aadf09537c575d Shayne Chen 2020-10-22 880 if (mode >= MT_PHY_TYPE_HE_SU)
aadf09537c575d Shayne Chen 2020-10-22 881 val |= FIELD_PREP(MT_TXD6_HELTF, td->tx_ltf);
aadf09537c575d Shayne Chen 2020-10-22 882
cc91747be98f2a Shayne Chen 2021-04-12 883 if (td->tx_rate_ldpc || (bw > 0 && mode >= MT_PHY_TYPE_HE_SU))
aadf09537c575d Shayne Chen 2020-10-22 884 val |= MT_TXD6_LDPC;
aadf09537c575d Shayne Chen 2020-10-22 885
cc91747be98f2a Shayne Chen 2021-04-12 886 txwi[3] &= ~cpu_to_le32(MT_TXD3_SN_VALID);
aadf09537c575d Shayne Chen 2020-10-22 887 txwi[6] |= cpu_to_le32(val);
c742cd1ffffaef Ben Greear 2021-11-18 888
c742cd1ffffaef Ben Greear 2021-11-18 889 if (msta->test.txo_active) {
c742cd1ffffaef Ben Greear 2021-11-18 890 /* see mt7915_tm_set_tx_frames */
c742cd1ffffaef Ben Greear 2021-11-18 891 static const u8 spe_idx_map[] = {0, 0, 1, 0, 3, 2, 4, 0,
c742cd1ffffaef Ben Greear 2021-11-18 892 9, 8, 6, 10, 16, 12, 18, 0};
c742cd1ffffaef Ben Greear 2021-11-18 893 u32 spe_idx;
c742cd1ffffaef Ben Greear 2021-11-18 894
c742cd1ffffaef Ben Greear 2021-11-18 895 if (td->tx_spe_idx) {
c742cd1ffffaef Ben Greear 2021-11-18 896 spe_idx = td->tx_spe_idx;
c742cd1ffffaef Ben Greear 2021-11-18 897 } else {
c742cd1ffffaef Ben Greear 2021-11-18 898 u8 tx_ant = td->tx_antenna_mask;
c742cd1ffffaef Ben Greear 2021-11-18 899
c742cd1ffffaef Ben Greear 2021-11-18 900 if (!tx_ant) {
c742cd1ffffaef Ben Greear 2021-11-18 901 /* use antenna mask that matches our nss */
c742cd1ffffaef Ben Greear 2021-11-18 902 tx_ant = GENMASK(nss - 1, 0);
c742cd1ffffaef Ben Greear 2021-11-18 903 }
c742cd1ffffaef Ben Greear 2021-11-18 904 spe_idx = spe_idx_map[tx_ant];
c742cd1ffffaef Ben Greear 2021-11-18 905 }
c742cd1ffffaef Ben Greear 2021-11-18 906 txwi[7] |= cpu_to_le32(FIELD_PREP(MT_TXD7_SPE_IDX, spe_idx));
c742cd1ffffaef Ben Greear 2021-11-18 907 } else {
aadf09537c575d Shayne Chen 2020-10-22 908 txwi[7] |= cpu_to_le32(FIELD_PREP(MT_TXD7_SPE_IDX,
78fc30a21cf117 Shayne Chen 2020-12-04 @909 phy->test.spe_idx));
c742cd1ffffaef Ben Greear 2021-11-18 910 }
aadf09537c575d Shayne Chen 2020-10-22 911 }
aadf09537c575d Shayne Chen 2020-10-22 912

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]


Attachments:
(No filename) (17.63 kB)
.config.gz (33.24 kB)
Download all attachments