linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Felix Fietkau <nbd@nbd.name>
To: linux-wireless@vger.kernel.org
Subject: [PATCH 25/29] mt76: mt7615: initialize dbdc settings on interface add
Date: Sat, 30 Nov 2019 16:30:41 +0100	[thread overview]
Message-ID: <20191130153045.28105-25-nbd@nbd.name> (raw)
In-Reply-To: <20191130153045.28105-1-nbd@nbd.name>

Use the first two WMM slots for the primary phy and the second two for the
secondary phy.

Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
 .../net/wireless/mediatek/mt76/mt7615/main.c  | 12 +++-
 .../net/wireless/mediatek/mt76/mt7615/mcu.c   | 59 +++++++++++++++++++
 .../net/wireless/mediatek/mt76/mt7615/mcu.h   | 13 ++++
 .../wireless/mediatek/mt76/mt7615/mt7615.h    |  2 +
 .../net/wireless/mediatek/mt76/mt7615/regs.h  |  9 +++
 5 files changed, 94 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/main.c b/drivers/net/wireless/mediatek/mt76/mt7615/main.c
index 4b23998957ca..f80fa045f549 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7615/main.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7615/main.c
@@ -121,7 +121,11 @@ static int mt7615_add_interface(struct ieee80211_hw *hw,
 	mvif->omac_idx = idx;
 
 	mvif->band_idx = ext_phy;
-	mvif->wmm_idx = mvif->idx % MT7615_MAX_WMM_SETS;
+	if (mt7615_ext_phy(dev))
+		mvif->wmm_idx = ext_phy * (MT7615_MAX_WMM_SETS / 2) +
+				mvif->idx % (MT7615_MAX_WMM_SETS / 2);
+	else
+		mvif->wmm_idx = mvif->idx % MT7615_MAX_WMM_SETS;
 
 	ret = mt7615_mcu_set_dev_info(dev, vif, 1);
 	if (ret)
@@ -129,6 +133,10 @@ static int mt7615_add_interface(struct ieee80211_hw *hw,
 
 	dev->vif_mask |= BIT(mvif->idx);
 	dev->omac_mask |= BIT(mvif->omac_idx);
+	phy->omac_mask |= BIT(mvif->omac_idx);
+
+	mt7615_mcu_set_dbdc(dev);
+
 	idx = MT7615_WTBL_RESERVED - mvif->idx;
 
 	INIT_LIST_HEAD(&mvif->sta.poll_list);
@@ -155,6 +163,7 @@ static void mt7615_remove_interface(struct ieee80211_hw *hw,
 	struct mt7615_vif *mvif = (struct mt7615_vif *)vif->drv_priv;
 	struct mt7615_sta *msta = &mvif->sta;
 	struct mt7615_dev *dev = mt7615_hw_dev(hw);
+	struct mt7615_phy *phy = mt7615_hw_phy(hw);
 	int idx = msta->wcid.idx;
 
 	/* TODO: disable beacon for the bss */
@@ -167,6 +176,7 @@ static void mt7615_remove_interface(struct ieee80211_hw *hw,
 	mutex_lock(&dev->mt76.mutex);
 	dev->vif_mask &= ~BIT(mvif->idx);
 	dev->omac_mask &= ~BIT(mvif->omac_idx);
+	phy->omac_mask &= ~BIT(mvif->omac_idx);
 	mutex_unlock(&dev->mt76.mutex);
 
 	spin_lock_bh(&dev->sta_poll_lock);
diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c
index a19c406c2231..9b09f2e742df 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c
@@ -717,6 +717,65 @@ int mt7615_mcu_ctrl_pm_state(struct mt7615_dev *dev, int band, int enter)
 				   &req, sizeof(req), true);
 }
 
+int mt7615_mcu_set_dbdc(struct mt7615_dev *dev)
+{
+	struct mt7615_phy *ext_phy = mt7615_ext_phy(dev);
+	struct dbdc_entry {
+		u8 type;
+		u8 index;
+		u8 band;
+		u8 _rsv;
+	};
+	struct {
+		u8 enable;
+		u8 num;
+		u8 _rsv[2];
+		struct dbdc_entry entry[64];
+	} req = {
+		.enable = !!ext_phy,
+	};
+	int i;
+
+	if (!ext_phy)
+		goto out;
+
+#define ADD_DBDC_ENTRY(_type, _idx, _band)		\
+	do { \
+		req.entry[req.num].type = _type;		\
+		req.entry[req.num].index = _idx;		\
+		req.entry[req.num++].band = _band;		\
+	} while (0)
+
+	for (i = 0; i < 4; i++) {
+		bool band = !!(ext_phy->omac_mask & BIT(i));
+
+		ADD_DBDC_ENTRY(DBDC_TYPE_BSS, i, band);
+	}
+
+	for (i = 0; i < 14; i++) {
+		bool band = !!(ext_phy->omac_mask & BIT(0x11 + i));
+
+		ADD_DBDC_ENTRY(DBDC_TYPE_MBSS, i, band);
+	}
+
+	ADD_DBDC_ENTRY(DBDC_TYPE_MU, 0, 1);
+
+	for (i = 0; i < 3; i++)
+		ADD_DBDC_ENTRY(DBDC_TYPE_BF, i, 1);
+
+	ADD_DBDC_ENTRY(DBDC_TYPE_WMM, 0, 0);
+	ADD_DBDC_ENTRY(DBDC_TYPE_WMM, 1, 0);
+	ADD_DBDC_ENTRY(DBDC_TYPE_WMM, 2, 1);
+	ADD_DBDC_ENTRY(DBDC_TYPE_WMM, 3, 1);
+
+	ADD_DBDC_ENTRY(DBDC_TYPE_MGMT, 0, 0);
+	ADD_DBDC_ENTRY(DBDC_TYPE_MGMT, 1, 1);
+
+out:
+	return __mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD_DBDC_CTRL,
+				   &req, sizeof(req), true);
+}
+
 int mt7615_mcu_set_dev_info(struct mt7615_dev *dev,
 			    struct ieee80211_vif *vif, bool enable)
 {
diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/mcu.h b/drivers/net/wireless/mediatek/mt76/mt7615/mcu.h
index f4781477fc9b..8d057c72366a 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7615/mcu.h
+++ b/drivers/net/wireless/mediatek/mt76/mt7615/mcu.h
@@ -148,6 +148,7 @@ enum {
 	MCU_EXT_CMD_WTBL_UPDATE = 0x32,
 	MCU_EXT_CMD_SET_RDD_CTRL = 0x3a,
 	MCU_EXT_CMD_PROTECT_CTRL = 0x3e,
+	MCU_EXT_CMD_DBDC_CTRL = 0x45,
 	MCU_EXT_CMD_MAC_INIT_CTRL = 0x46,
 	MCU_EXT_CMD_BCN_OFFLOAD = 0x49,
 	MCU_EXT_CMD_SET_RX_PATH = 0x4e,
@@ -202,6 +203,18 @@ enum {
 	DEV_INFO_MAX_NUM
 };
 
+enum {
+	DBDC_TYPE_WMM,
+	DBDC_TYPE_MGMT,
+	DBDC_TYPE_BSS,
+	DBDC_TYPE_MBSS,
+	DBDC_TYPE_REPEATER,
+	DBDC_TYPE_MU,
+	DBDC_TYPE_BF,
+	DBDC_TYPE_PTA,
+	__DBDC_TYPE_MAX,
+};
+
 struct bss_info_omac {
 	__le16 tag;
 	__le16 len;
diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/mt7615.h b/drivers/net/wireless/mediatek/mt76/mt7615/mt7615.h
index 64c8ad64733b..3323baa7cc0c 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7615/mt7615.h
+++ b/drivers/net/wireless/mediatek/mt76/mt7615/mt7615.h
@@ -88,6 +88,7 @@ struct mt7615_phy {
 	struct mt7615_dev *dev;
 
 	u32 rxfilter;
+	u32 omac_mask;
 
 	unsigned long last_cca_adj;
 	int false_cca_ofdm, false_cca_cck;
@@ -285,6 +286,7 @@ int mt7615_mac_wtbl_set_key(struct mt7615_dev *dev, struct mt76_wcid *wcid,
 			    struct ieee80211_key_conf *key,
 			    enum set_key_cmd cmd);
 
+int mt7615_mcu_set_dbdc(struct mt7615_dev *dev);
 int mt7615_mcu_set_eeprom(struct mt7615_dev *dev);
 int mt7615_mcu_init_mac(struct mt7615_dev *dev);
 int mt7615_mcu_set_rts_thresh(struct mt7615_phy *phy, u32 val);
diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/regs.h b/drivers/net/wireless/mediatek/mt76/mt7615/regs.h
index d0602a3b0ac1..cece061b1108 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7615/regs.h
+++ b/drivers/net/wireless/mediatek/mt76/mt7615/regs.h
@@ -121,6 +121,15 @@
 #define MT_CFG_CCR_MAC_D1_2X_GC_EN	BIT(30)
 #define MT_CFG_CCR_MAC_D0_2X_GC_EN	BIT(31)
 
+#define MT_DBDC_CTRL0			MT_WF_CFG(0x050)
+#define MT_DBDC_CTRL0_OMAC_00_04	GENMASK(4, 0)
+#define MT_DBDC_CTRL0_OMAC_11_1F	GENMASK(19, 5)
+#define MT_DBDC_CTRL0_MGMT		GENMASK(21, 20)
+#define MT_DBDC_CTRL0_WMM		GENMASK(25, 22)
+#define MT_DBDC_CTRL0_DBDC_EN		BIT(31)
+
+#define MT_DBDC_CTRL1			MT_WF_CFG(0x054)
+
 #define MT_WF_AGG_BASE			0x20a00
 #define MT_WF_AGG(ofs)			(MT_WF_AGG_BASE + (ofs))
 
-- 
2.24.0


  parent reply	other threads:[~2019-11-30 15:31 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-30 15:30 [PATCH 01/29] mt76: move initialization of some struct members to mt76_alloc_device Felix Fietkau
2019-11-30 15:30 ` [PATCH 02/29] mt76: introduce struct mt76_phy Felix Fietkau
2019-11-30 15:30 ` [PATCH 03/29] mt76: add support for an extra wiphy in the rx path Felix Fietkau
2019-11-30 15:30 ` [PATCH 04/29] mt76: add support for an extra wiphy in the main tx path Felix Fietkau
2019-11-30 15:30 ` [PATCH 05/29] mt76: add support for an extra wiphy in the tx status path Felix Fietkau
2019-11-30 15:30 ` [PATCH 06/29] mt76: add support for an extra wiphy in mt76_sta_state() Felix Fietkau
2019-11-30 15:30 ` [PATCH 07/29] mt76: move channel state to struct mt76_phy Felix Fietkau
2019-11-30 15:30 ` [PATCH 08/29] mt76: keep a set of software tx queues per phy Felix Fietkau
2019-11-30 15:30 ` [PATCH 09/29] mt76: move state from struct mt76_dev to mt76_phy Felix Fietkau
2019-11-30 15:30 ` [PATCH 10/29] mt76: move chainmask back to driver specific structs Felix Fietkau
2019-11-30 15:30 ` [PATCH 11/29] mt76: move txpower_conf " Felix Fietkau
2019-11-30 15:30 ` [PATCH 12/29] mt76: move txpower and antenna mask to struct mt76_phy Felix Fietkau
2019-11-30 15:30 ` [PATCH 13/29] mt76: add multiple wiphy support to mt76_get_min_avg_rssi Felix Fietkau
2019-11-30 15:30 ` [PATCH 14/29] mt76: add priv pointer to struct mt76_phy Felix Fietkau
2019-11-30 15:30 ` [PATCH 15/29] mt76: add function for allocating an external wiphy Felix Fietkau
2019-12-03 20:02   ` [PATCH v2 15/29] mt76: add function for allocating an extra wiphy Felix Fietkau
2019-11-30 15:30 ` [PATCH 16/29] mt76: add ext_phy field to struct mt76_wcid Felix Fietkau
2019-11-30 15:30 ` [PATCH 17/29] mt76: move ampdu_ref from mt76_dev to driver struct Felix Fietkau
2019-11-30 15:30 ` [PATCH 18/29] mt76: mt7615: add dual-phy support for mac80211 ops Felix Fietkau
2019-11-30 15:30 ` [PATCH 19/29] mt76: mt7615: add multiple wiphy support for smart carrier sense Felix Fietkau
2019-11-30 15:30 ` [PATCH 20/29] mt76: mt7615: add missing register init for dual-wiphy support Felix Fietkau
2019-11-30 15:30 ` [PATCH 21/29] mt76: mt7615: remove useless MT_HW_RDD0/1 enum Felix Fietkau
2019-11-30 15:30 ` [PATCH 22/29] mt76: mt7615: add multiple wiphy support to the dfs support code Felix Fietkau
2019-11-30 15:30 ` [PATCH 23/29] mt76: mt7615: rework chainmask handling Felix Fietkau
2019-11-30 15:30 ` [PATCH 24/29] mt76: mt7615: add multiple wiphy support to the rx path Felix Fietkau
2019-11-30 15:30 ` Felix Fietkau [this message]
2019-11-30 15:30 ` [PATCH 26/29] mt76: mt7615: move radio/mac initialization to .start/stop callbacks Felix Fietkau
2019-11-30 15:30 ` [PATCH 27/29] mt76: mt7615: select the correct tx queue for frames sent to the second phy Felix Fietkau
2019-11-30 15:30 ` [PATCH 28/29] mt76: mt7615: add support for registering a second wiphy via debugfs Felix Fietkau
2019-12-16 11:30   ` Kalle Valo
2020-01-20 11:03   ` [PATCH v2 " Felix Fietkau
2019-11-30 15:30 ` [PATCH 29/29] mt76: mt7615: update beacon contents on BSS_CHANGED_BEACON Felix Fietkau

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191130153045.28105-25-nbd@nbd.name \
    --to=nbd@nbd.name \
    --cc=linux-wireless@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).