All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/7] mt76x02: Beacon support for USB
@ 2019-01-24 15:44 Stanislaw Gruszka
  2019-01-24 15:44 ` [PATCH 1/7] mt76x02: use mask for vifs Stanislaw Gruszka
                   ` (6 more replies)
  0 siblings, 7 replies; 27+ messages in thread
From: Stanislaw Gruszka @ 2019-01-24 15:44 UTC (permalink / raw)
  To: Felix Fietkau; +Cc: linux-wireless, Lorenzo Bianconi

We can configure beaconing, but without TBTT interrupt we
can not support PS buffering. This can be added later using
kernel hrtimer, if we can keep with device timer with sync.

I tested AP and IBSS modes.

Stanislaw Gruszka (7):
  mt76x02: use mask for vifs
  mt76x02: use commmon add interface for mt76x2u
  mt76x02: initialize mutli bss mode when set up address
  mt76x02: minor beaconing init changes
  mt76x02: init beacon config for mt76x2u
  mt76: beaconing fixes for USB
  mt76x02: enable support for IBSS, AP and MESH

 drivers/net/wireless/mediatek/mt76/mac80211.c      |  3 +-
 drivers/net/wireless/mediatek/mt76/mt76x0/pci.c    |  7 ++
 drivers/net/wireless/mediatek/mt76/mt76x02.h       |  5 +-
 drivers/net/wireless/mediatek/mt76/mt76x02_mac.c   | 39 +++++++++--
 drivers/net/wireless/mediatek/mt76/mt76x02_mac.h   |  4 +-
 drivers/net/wireless/mediatek/mt76/mt76x02_util.c  | 76 +++++++++++-----------
 .../net/wireless/mediatek/mt76/mt76x2/pci_init.c   | 12 +++-
 .../net/wireless/mediatek/mt76/mt76x2/usb_init.c   |  6 +-
 .../net/wireless/mediatek/mt76/mt76x2/usb_main.c   | 15 +----
 9 files changed, 97 insertions(+), 70 deletions(-)

-- 
1.9.3


^ permalink raw reply	[flat|nested] 27+ messages in thread

* [PATCH 1/7] mt76x02: use mask for vifs
  2019-01-24 15:44 [PATCH 0/7] mt76x02: Beacon support for USB Stanislaw Gruszka
@ 2019-01-24 15:44 ` Stanislaw Gruszka
  2019-01-24 16:12   ` Lorenzo Bianconi
  2019-01-24 15:44 ` [PATCH 2/7] mt76x02: use commmon add interface for mt76x2u Stanislaw Gruszka
                   ` (5 subsequent siblings)
  6 siblings, 1 reply; 27+ messages in thread
From: Stanislaw Gruszka @ 2019-01-24 15:44 UTC (permalink / raw)
  To: Felix Fietkau; +Cc: linux-wireless, Lorenzo Bianconi

Use vif_mask to count interfaces to allow to set mac address
if there is only one interface and support more STA vifs in
the future.

Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
---
 drivers/net/wireless/mediatek/mt76/mt76x02.h      |  2 ++
 drivers/net/wireless/mediatek/mt76/mt76x02_util.c | 18 +++++++++++++-----
 2 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02.h b/drivers/net/wireless/mediatek/mt76/mt76x02.h
index 6d96766a6ed3..be077443bdb0 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x02.h
+++ b/drivers/net/wireless/mediatek/mt76/mt76x02.h
@@ -73,6 +73,8 @@ struct mt76x02_dev {
 
 	struct mutex phy_mutex;
 
+	u16 vif_mask;
+
 	u8 txdone_seq;
 	DECLARE_KFIFO_PTR(txstatus_fifo, struct mt76x02_tx_status);
 
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_util.c b/drivers/net/wireless/mediatek/mt76/mt76x02_util.c
index 062614ad0d51..1a949453dc25 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x02_util.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x02_util.c
@@ -288,10 +288,7 @@ void mt76x02_vif_init(struct mt76x02_dev *dev, struct ieee80211_vif *vif,
 mt76x02_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
 {
 	struct mt76x02_dev *dev = hw->priv;
-	unsigned int idx = 0;
-
-	if (vif->addr[0] & BIT(1))
-		idx = 1 + (((dev->mt76.macaddr[0] ^ vif->addr[0]) >> 2) & 7);
+	unsigned int idx, offset = 0;
 
 	/*
 	 * Client mode typically only has one configurable BSSID register,
@@ -307,7 +304,16 @@ void mt76x02_vif_init(struct mt76x02_dev *dev, struct ieee80211_vif *vif,
 	 * The resulting bssidx mismatch for unicast frames is ignored by hw.
 	 */
 	if (vif->type == NL80211_IFTYPE_STATION)
-		idx += 8;
+		offset = 8;
+
+	idx = ffs(~(dev->vif_mask >> offset)) - 1;
+	idx += offset;
+
+	/* Allow to change address is only one interface. */
+	if (!dev->vif_mask && (!ether_addr_equal(dev->mt76.macaddr, vif->addr)))
+                mt76x02_mac_setaddr(dev, vif->addr);
+
+	dev->vif_mask |= BIT(idx);
 
 	mt76x02_vif_init(dev, vif, idx);
 	return 0;
@@ -318,8 +324,10 @@ void mt76x02_remove_interface(struct ieee80211_hw *hw,
 			      struct ieee80211_vif *vif)
 {
 	struct mt76x02_dev *dev = hw->priv;
+	struct mt76x02_vif *mvif = (struct mt76x02_vif *)vif->drv_priv;
 
 	mt76_txq_remove(&dev->mt76, vif->txq);
+	dev->vif_mask &= ~BIT(mvif->idx);
 }
 EXPORT_SYMBOL_GPL(mt76x02_remove_interface);
 
-- 
1.9.3


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH 2/7] mt76x02: use commmon add interface for mt76x2u
  2019-01-24 15:44 [PATCH 0/7] mt76x02: Beacon support for USB Stanislaw Gruszka
  2019-01-24 15:44 ` [PATCH 1/7] mt76x02: use mask for vifs Stanislaw Gruszka
@ 2019-01-24 15:44 ` Stanislaw Gruszka
  2019-01-24 15:44 ` [PATCH 3/7] mt76x02: initialize mutli bss mode when set up address Stanislaw Gruszka
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 27+ messages in thread
From: Stanislaw Gruszka @ 2019-01-24 15:44 UTC (permalink / raw)
  To: Felix Fietkau; +Cc: linux-wireless, Lorenzo Bianconi

Since we now support mt76x2u feature to allow set mac address
when creating interface in common code we can use it for
mt76x2u.

Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
---
 drivers/net/wireless/mediatek/mt76/mt76x02.h         |  3 +--
 drivers/net/wireless/mediatek/mt76/mt76x02_util.c    |  6 +++---
 drivers/net/wireless/mediatek/mt76/mt76x2/usb_main.c | 15 +--------------
 3 files changed, 5 insertions(+), 19 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02.h b/drivers/net/wireless/mediatek/mt76/mt76x02.h
index be077443bdb0..6d9d9ddacc32 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x02.h
+++ b/drivers/net/wireless/mediatek/mt76/mt76x02.h
@@ -130,8 +130,7 @@ void mt76x02_sta_remove(struct mt76_dev *mdev, struct ieee80211_vif *vif,
 			struct ieee80211_sta *sta);
 
 void mt76x02_config_mac_addr_list(struct mt76x02_dev *dev);
-void mt76x02_vif_init(struct mt76x02_dev *dev, struct ieee80211_vif *vif,
-		      unsigned int idx);
+
 int mt76x02_add_interface(struct ieee80211_hw *hw,
 			 struct ieee80211_vif *vif);
 void mt76x02_remove_interface(struct ieee80211_hw *hw,
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_util.c b/drivers/net/wireless/mediatek/mt76/mt76x02_util.c
index 1a949453dc25..3f326cb70434 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x02_util.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x02_util.c
@@ -268,8 +268,9 @@ void mt76x02_sta_remove(struct mt76_dev *mdev, struct ieee80211_vif *vif,
 }
 EXPORT_SYMBOL_GPL(mt76x02_sta_remove);
 
-void mt76x02_vif_init(struct mt76x02_dev *dev, struct ieee80211_vif *vif,
-		      unsigned int idx)
+static void
+mt76x02_vif_init(struct mt76x02_dev *dev, struct ieee80211_vif *vif,
+		 unsigned int idx)
 {
 	struct mt76x02_vif *mvif = (struct mt76x02_vif *)vif->drv_priv;
 	struct mt76_txq *mtxq;
@@ -282,7 +283,6 @@ void mt76x02_vif_init(struct mt76x02_dev *dev, struct ieee80211_vif *vif,
 
 	mt76_txq_init(&dev->mt76, vif->txq);
 }
-EXPORT_SYMBOL_GPL(mt76x02_vif_init);
 
 int
 mt76x02_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2/usb_main.c b/drivers/net/wireless/mediatek/mt76/mt76x2/usb_main.c
index 286c7f451090..5256c6f879a7 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x2/usb_main.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x2/usb_main.c
@@ -46,19 +46,6 @@ static void mt76x2u_stop(struct ieee80211_hw *hw)
 	mutex_unlock(&dev->mt76.mutex);
 }
 
-static int mt76x2u_add_interface(struct ieee80211_hw *hw,
-				 struct ieee80211_vif *vif)
-{
-	struct mt76x02_dev *dev = hw->priv;
-	unsigned int idx = 8;
-
-	if (!ether_addr_equal(dev->mt76.macaddr, vif->addr))
-		mt76x02_mac_setaddr(dev, vif->addr);
-
-	mt76x02_vif_init(dev, vif, idx);
-	return 0;
-}
-
 static int
 mt76x2u_set_channel(struct mt76x02_dev *dev,
 		    struct cfg80211_chan_def *chandef)
@@ -125,7 +112,7 @@ static int mt76x2u_add_interface(struct ieee80211_hw *hw,
 	.tx = mt76x02_tx,
 	.start = mt76x2u_start,
 	.stop = mt76x2u_stop,
-	.add_interface = mt76x2u_add_interface,
+	.add_interface = mt76x02_add_interface,
 	.remove_interface = mt76x02_remove_interface,
 	.sta_state = mt76_sta_state,
 	.set_key = mt76x02_set_key,
-- 
1.9.3


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH 3/7] mt76x02: initialize mutli bss mode when set up address
  2019-01-24 15:44 [PATCH 0/7] mt76x02: Beacon support for USB Stanislaw Gruszka
  2019-01-24 15:44 ` [PATCH 1/7] mt76x02: use mask for vifs Stanislaw Gruszka
  2019-01-24 15:44 ` [PATCH 2/7] mt76x02: use commmon add interface for mt76x2u Stanislaw Gruszka
@ 2019-01-24 15:44 ` Stanislaw Gruszka
  2019-01-24 15:44 ` [PATCH 4/7] mt76x02: minor beaconing init changes Stanislaw Gruszka
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 27+ messages in thread
From: Stanislaw Gruszka @ 2019-01-24 15:44 UTC (permalink / raw)
  To: Felix Fietkau; +Cc: linux-wireless, Lorenzo Bianconi

BSSID is not strtirct related with beaconing (for example we can have
2 STA vifs) and more related with MAC address, so initaize BSSID when
setting MAC address.

Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
---
 drivers/net/wireless/mediatek/mt76/mt76x02_mac.c     | 15 ++++++++++++++-
 drivers/net/wireless/mediatek/mt76/mt76x02_mac.h     |  2 +-
 drivers/net/wireless/mediatek/mt76/mt76x02_util.c    | 13 ++-----------
 drivers/net/wireless/mediatek/mt76/mt76x2/pci_init.c |  4 +---
 4 files changed, 18 insertions(+), 16 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_mac.c b/drivers/net/wireless/mediatek/mt76/mt76x02_mac.c
index 63fa27d2c404..ae1727e433f3 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x02_mac.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x02_mac.c
@@ -548,8 +548,11 @@ void mt76x02_send_tx_status(struct mt76x02_dev *dev,
 	return 0;
 }
 
-void mt76x02_mac_setaddr(struct mt76x02_dev *dev, u8 *addr)
+void mt76x02_mac_setaddr(struct mt76x02_dev *dev, const u8 *addr)
 {
+	static const u8 null_addr[ETH_ALEN] = {};
+	int i;
+
 	ether_addr_copy(dev->mt76.macaddr, addr);
 
 	if (!is_valid_ether_addr(dev->mt76.macaddr)) {
@@ -563,6 +566,16 @@ void mt76x02_mac_setaddr(struct mt76x02_dev *dev, u8 *addr)
 	mt76_wr(dev, MT_MAC_ADDR_DW1,
 		get_unaligned_le16(dev->mt76.macaddr + 4) |
 		FIELD_PREP(MT_MAC_ADDR_DW1_U2ME_MASK, 0xff));
+
+	mt76_wr(dev, MT_MAC_BSSID_DW0,
+		get_unaligned_le32(dev->mt76.macaddr));
+	mt76_wr(dev, MT_MAC_BSSID_DW1,
+		get_unaligned_le16(dev->mt76.macaddr + 4) |
+		FIELD_PREP(MT_MAC_BSSID_DW1_MBSS_MODE, 3) | /* 8 APs + 8 STAs */
+		MT_MAC_BSSID_DW1_MBSS_LOCAL_BIT);
+
+	for (i = 0; i < 16; i++)
+		mt76x02_mac_set_bssid(dev, i, null_addr);
 }
 EXPORT_SYMBOL_GPL(mt76x02_mac_setaddr);
 
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_mac.h b/drivers/net/wireless/mediatek/mt76/mt76x02_mac.h
index 940c07f665cd..76e564b8f5da 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x02_mac.h
+++ b/drivers/net/wireless/mediatek/mt76/mt76x02_mac.h
@@ -191,7 +191,7 @@ int mt76x02_mac_process_rx(struct mt76x02_dev *dev, struct sk_buff *skb,
 void mt76x02_mac_set_tx_protection(struct mt76x02_dev *dev, bool legacy_prot,
 				   int ht_mode);
 void mt76x02_mac_set_rts_thresh(struct mt76x02_dev *dev, u32 val);
-void mt76x02_mac_setaddr(struct mt76x02_dev *dev, u8 *addr);
+void mt76x02_mac_setaddr(struct mt76x02_dev *dev, const u8 *addr);
 void mt76x02_mac_write_txwi(struct mt76x02_dev *dev, struct mt76x02_txwi *txwi,
 			    struct sk_buff *skb, struct mt76_wcid *wcid,
 			    struct ieee80211_sta *sta, int len);
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_util.c b/drivers/net/wireless/mediatek/mt76/mt76x02_util.c
index 3f326cb70434..02139dce4800 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x02_util.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x02_util.c
@@ -665,16 +665,8 @@ static void mt76x02_set_beacon_offsets(struct mt76x02_dev *dev)
 
 void mt76x02_init_beacon_config(struct mt76x02_dev *dev)
 {
-	static const u8 null_addr[ETH_ALEN] = {};
 	int i;
 
-	mt76_wr(dev, MT_MAC_BSSID_DW0,
-		get_unaligned_le32(dev->mt76.macaddr));
-	mt76_wr(dev, MT_MAC_BSSID_DW1,
-		get_unaligned_le16(dev->mt76.macaddr + 4) |
-		FIELD_PREP(MT_MAC_BSSID_DW1_MBSS_MODE, 3) | /* 8 beacons */
-		MT_MAC_BSSID_DW1_MBSS_LOCAL_BIT);
-
 	/* Fire a pre-TBTT interrupt 8 ms before TBTT */
 	mt76_rmw_field(dev, MT_INT_TIMER_CFG, MT_INT_TIMER_CFG_PRE_TBTT,
 		       8 << 4);
@@ -684,10 +676,9 @@ void mt76x02_init_beacon_config(struct mt76x02_dev *dev)
 
 	mt76_wr(dev, MT_BCN_BYPASS_MASK, 0xffff);
 
-	for (i = 0; i < 8; i++) {
-		mt76x02_mac_set_bssid(dev, i, null_addr);
+	for (i = 0; i < 8; i++)
 		mt76x02_mac_set_beacon(dev, i, NULL);
-	}
+
 	mt76x02_set_beacon_offsets(dev);
 }
 EXPORT_SYMBOL_GPL(mt76x02_init_beacon_config);
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2/pci_init.c b/drivers/net/wireless/mediatek/mt76/mt76x2/pci_init.c
index 4347d5e7a915..0ccaa64d97ec 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x2/pci_init.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x2/pci_init.c
@@ -119,9 +119,7 @@ static int mt76x2_mac_reset(struct mt76x02_dev *dev, bool hard)
 	mt76_wr(dev, MT_MCU_CLOCK_CTL, 0x1401);
 	mt76_clear(dev, MT_FCE_L2_STUFF, MT_FCE_L2_STUFF_WR_MPDU_LEN_EN);
 
-	mt76_wr(dev, MT_MAC_ADDR_DW0, get_unaligned_le32(macaddr));
-	mt76_wr(dev, MT_MAC_ADDR_DW1, get_unaligned_le16(macaddr + 4));
-
+	mt76x02_mac_setaddr(dev, macaddr);
 	mt76x02_init_beacon_config(dev);
 	if (!hard)
 		return 0;
-- 
1.9.3


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH 4/7] mt76x02: minor beaconing init changes
  2019-01-24 15:44 [PATCH 0/7] mt76x02: Beacon support for USB Stanislaw Gruszka
                   ` (2 preceding siblings ...)
  2019-01-24 15:44 ` [PATCH 3/7] mt76x02: initialize mutli bss mode when set up address Stanislaw Gruszka
@ 2019-01-24 15:44 ` Stanislaw Gruszka
  2019-01-24 22:32   ` Lorenzo Bianconi
  2019-01-24 15:44 ` [PATCH 5/7] mt76x02: init beacon config for mt76x2u Stanislaw Gruszka
                   ` (2 subsequent siblings)
  6 siblings, 1 reply; 27+ messages in thread
From: Stanislaw Gruszka @ 2019-01-24 15:44 UTC (permalink / raw)
  To: Felix Fietkau; +Cc: linux-wireless, Lorenzo Bianconi

Disable BEACON timer during init and remove interrupt registers
initialization form generic code since they are PCIe specific.

Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
---
 drivers/net/wireless/mediatek/mt76/mt76x0/pci.c      |  7 +++++++
 drivers/net/wireless/mediatek/mt76/mt76x02_util.c    | 11 ++++-------
 drivers/net/wireless/mediatek/mt76/mt76x2/pci_init.c |  8 ++++++++
 3 files changed, 19 insertions(+), 7 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/pci.c b/drivers/net/wireless/mediatek/mt76/mt76x0/pci.c
index 1472c8699b29..cb68af5b7478 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x0/pci.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x0/pci.c
@@ -128,6 +128,13 @@ static int mt76x0e_register_device(struct mt76x02_dev *dev)
 	if (err < 0)
 		return err;
 
+	/* Beaconing: fire a pre-TBTT interrupt 8 ms before TBTT */
+	mt76_rmw_field(dev, MT_INT_TIMER_CFG, MT_INT_TIMER_CFG_PRE_TBTT,
+		       8 << 4);
+	mt76_rmw_field(dev, MT_INT_TIMER_CFG, MT_INT_TIMER_CFG_GP_TIMER,
+		       MT_DFS_GP_INTERVAL);
+	mt76_wr(dev, MT_INT_TIMER_EN, 0);
+
 	if (mt76_chip(&dev->mt76) == 0x7610) {
 		u16 val;
 
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_util.c b/drivers/net/wireless/mediatek/mt76/mt76x02_util.c
index 02139dce4800..741ecd723b8e 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x02_util.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x02_util.c
@@ -667,13 +667,10 @@ void mt76x02_init_beacon_config(struct mt76x02_dev *dev)
 {
 	int i;
 
-	/* Fire a pre-TBTT interrupt 8 ms before TBTT */
-	mt76_rmw_field(dev, MT_INT_TIMER_CFG, MT_INT_TIMER_CFG_PRE_TBTT,
-		       8 << 4);
-	mt76_rmw_field(dev, MT_INT_TIMER_CFG, MT_INT_TIMER_CFG_GP_TIMER,
-		       MT_DFS_GP_INTERVAL);
-	mt76_wr(dev, MT_INT_TIMER_EN, 0);
-
+	mt76_clear(dev, MT_BEACON_TIME_CFG, (MT_BEACON_TIME_CFG_TIMER_EN |
+					     MT_BEACON_TIME_CFG_SYNC_MODE |
+					     MT_BEACON_TIME_CFG_TBTT_EN |
+					     MT_BEACON_TIME_CFG_BEACON_TX));
 	mt76_wr(dev, MT_BCN_BYPASS_MASK, 0xffff);
 
 	for (i = 0; i < 8; i++)
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2/pci_init.c b/drivers/net/wireless/mediatek/mt76/mt76x2/pci_init.c
index 0ccaa64d97ec..f86ff035fa7f 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x2/pci_init.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x2/pci_init.c
@@ -121,6 +121,14 @@ static int mt76x2_mac_reset(struct mt76x02_dev *dev, bool hard)
 
 	mt76x02_mac_setaddr(dev, macaddr);
 	mt76x02_init_beacon_config(dev);
+
+	/* Fire a pre-TBTT interrupt 8 ms before TBTT */
+	mt76_rmw_field(dev, MT_INT_TIMER_CFG, MT_INT_TIMER_CFG_PRE_TBTT,
+		       8 << 4);
+	mt76_rmw_field(dev, MT_INT_TIMER_CFG, MT_INT_TIMER_CFG_GP_TIMER,
+		       MT_DFS_GP_INTERVAL);
+	mt76_wr(dev, MT_INT_TIMER_EN, 0);
+
 	if (!hard)
 		return 0;
 
-- 
1.9.3


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH 5/7] mt76x02: init beacon config for mt76x2u
  2019-01-24 15:44 [PATCH 0/7] mt76x02: Beacon support for USB Stanislaw Gruszka
                   ` (3 preceding siblings ...)
  2019-01-24 15:44 ` [PATCH 4/7] mt76x02: minor beaconing init changes Stanislaw Gruszka
@ 2019-01-24 15:44 ` Stanislaw Gruszka
  2019-01-24 22:33   ` Lorenzo Bianconi
  2019-01-24 15:44 ` [PATCH 6/7] mt76: beaconing fixes for USB Stanislaw Gruszka
  2019-01-24 15:44 ` [PATCH 7/7] mt76x02: enable support for IBSS, AP and MESH Stanislaw Gruszka
  6 siblings, 1 reply; 27+ messages in thread
From: Stanislaw Gruszka @ 2019-01-24 15:44 UTC (permalink / raw)
  To: Felix Fietkau; +Cc: linux-wireless, Lorenzo Bianconi

Initialize beaconing also on mt76x2u.

Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
---
 drivers/net/wireless/mediatek/mt76/mt76x2/usb_init.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2/usb_init.c b/drivers/net/wireless/mediatek/mt76/mt76x2/usb_init.c
index 0be3784f44fb..3737e9fa8295 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x2/usb_init.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x2/usb_init.c
@@ -207,11 +207,7 @@ int mt76x2u_init_hardware(struct mt76x02_dev *dev)
 			mt76x02_mac_shared_key_setup(dev, i, k, NULL);
 	}
 
-	mt76_clear(dev, MT_BEACON_TIME_CFG,
-		   MT_BEACON_TIME_CFG_TIMER_EN |
-		   MT_BEACON_TIME_CFG_SYNC_MODE |
-		   MT_BEACON_TIME_CFG_TBTT_EN |
-		   MT_BEACON_TIME_CFG_BEACON_TX);
+	mt76x02_init_beacon_config(dev);
 
 	mt76_rmw(dev, MT_US_CYC_CFG, MT_US_CYC_CNT, 0x1e);
 	mt76_wr(dev, MT_TXOP_CTRL_CFG, 0x583f);
-- 
1.9.3


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH 6/7] mt76: beaconing fixes for USB
  2019-01-24 15:44 [PATCH 0/7] mt76x02: Beacon support for USB Stanislaw Gruszka
                   ` (4 preceding siblings ...)
  2019-01-24 15:44 ` [PATCH 5/7] mt76x02: init beacon config for mt76x2u Stanislaw Gruszka
@ 2019-01-24 15:44 ` Stanislaw Gruszka
  2019-01-24 22:50   ` Lorenzo Bianconi
  2019-01-24 15:44 ` [PATCH 7/7] mt76x02: enable support for IBSS, AP and MESH Stanislaw Gruszka
  6 siblings, 1 reply; 27+ messages in thread
From: Stanislaw Gruszka @ 2019-01-24 15:44 UTC (permalink / raw)
  To: Felix Fietkau; +Cc: linux-wireless, Lorenzo Bianconi

Configure beaconing on USB devices without PS buffering support.

Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
---
 drivers/net/wireless/mediatek/mt76/mac80211.c     |  3 ++-
 drivers/net/wireless/mediatek/mt76/mt76x02_mac.c  | 24 ++++++++++++++++++++---
 drivers/net/wireless/mediatek/mt76/mt76x02_mac.h  |  2 +-
 drivers/net/wireless/mediatek/mt76/mt76x02_util.c |  8 +++++---
 4 files changed, 29 insertions(+), 8 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mac80211.c b/drivers/net/wireless/mediatek/mt76/mac80211.c
index ee3b65a14870..65433d9aca83 100644
--- a/drivers/net/wireless/mediatek/mt76/mac80211.c
+++ b/drivers/net/wireless/mediatek/mt76/mac80211.c
@@ -317,7 +317,6 @@ int mt76_register_device(struct mt76_dev *dev, bool vht,
 
 	ieee80211_hw_set(hw, SIGNAL_DBM);
 	ieee80211_hw_set(hw, PS_NULLFUNC_STACK);
-	ieee80211_hw_set(hw, HOST_BROADCAST_PS_BUFFERING);
 	ieee80211_hw_set(hw, AMPDU_AGGREGATION);
 	ieee80211_hw_set(hw, SUPPORTS_RC_TABLE);
 	ieee80211_hw_set(hw, SUPPORT_FAST_XMIT);
@@ -329,6 +328,8 @@ int mt76_register_device(struct mt76_dev *dev, bool vht,
 	ieee80211_hw_set(hw, AP_LINK_PS);
 	ieee80211_hw_set(hw, REPORTS_TX_ACK_STATUS);
 	ieee80211_hw_set(hw, NEEDS_UNIQUE_STA_ADDR);
+	if (dev->bus->type == MT76_BUS_MMIO)
+		ieee80211_hw_set(hw, HOST_BROADCAST_PS_BUFFERING);
 
 	wiphy->flags |= WIPHY_FLAG_IBSS_RSN;
 
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_mac.c b/drivers/net/wireless/mediatek/mt76/mt76x02_mac.c
index ae1727e433f3..632c76acbbda 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x02_mac.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x02_mac.c
@@ -1060,8 +1060,9 @@ int mt76x02_mac_set_beacon(struct mt76x02_dev *dev, u8 vif_idx,
 	return 0;
 }
 
-void mt76x02_mac_set_beacon_enable(struct mt76x02_dev *dev,
-				   u8 vif_idx, bool val)
+static void
+__mt76x02_mac_set_beacon_enable(struct mt76x02_dev *dev, u8 vif_idx,
+			        bool val, struct sk_buff *skb)
 {
 	u8 old_mask = dev->beacon_mask;
 	bool en;
@@ -1069,6 +1070,8 @@ void mt76x02_mac_set_beacon_enable(struct mt76x02_dev *dev,
 
 	if (val) {
 		dev->beacon_mask |= BIT(vif_idx);
+		if (skb)
+			mt76x02_mac_set_beacon(dev, vif_idx, skb);
 	} else {
 		dev->beacon_mask &= ~BIT(vif_idx);
 		mt76x02_mac_set_beacon(dev, vif_idx, NULL);
@@ -1079,14 +1082,29 @@ void mt76x02_mac_set_beacon_enable(struct mt76x02_dev *dev,
 
 	en = dev->beacon_mask;
 
-	mt76_rmw_field(dev, MT_INT_TIMER_EN, MT_INT_TIMER_EN_PRE_TBTT_EN, en);
 	reg = MT_BEACON_TIME_CFG_BEACON_TX |
 	      MT_BEACON_TIME_CFG_TBTT_EN |
 	      MT_BEACON_TIME_CFG_TIMER_EN;
 	mt76_rmw(dev, MT_BEACON_TIME_CFG, reg, reg * en);
 
+	if (mt76_is_usb(dev))
+		return;
+
+	mt76_rmw_field(dev, MT_INT_TIMER_EN, MT_INT_TIMER_EN_PRE_TBTT_EN, en);
 	if (en)
 		mt76x02_irq_enable(dev, MT_INT_PRE_TBTT | MT_INT_TBTT);
 	else
 		mt76x02_irq_disable(dev, MT_INT_PRE_TBTT | MT_INT_TBTT);
 }
+
+void mt76x02_mac_set_beacon_enable(struct mt76x02_dev *dev, u8 vif_idx,
+			           bool val, struct sk_buff *skb)
+{
+	if (mt76_is_mmio(dev))
+		tasklet_disable(&dev->pre_tbtt_tasklet);
+
+	__mt76x02_mac_set_beacon_enable(dev, vif_idx, val, skb);
+
+	if (mt76_is_mmio(dev))
+		tasklet_enable(&dev->pre_tbtt_tasklet);
+}
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_mac.h b/drivers/net/wireless/mediatek/mt76/mt76x02_mac.h
index 76e564b8f5da..a15fc71e3d55 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x02_mac.h
+++ b/drivers/net/wireless/mediatek/mt76/mt76x02_mac.h
@@ -205,7 +205,7 @@ void mt76x02_tx_complete_skb(struct mt76_dev *mdev, struct mt76_queue *q,
 int mt76x02_mac_set_beacon(struct mt76x02_dev *dev, u8 vif_idx,
 			   struct sk_buff *skb);
 void mt76x02_mac_set_beacon_enable(struct mt76x02_dev *dev, u8 vif_idx,
-				   bool val);
+				   bool val, struct sk_buff *skb);
 
 void mt76x02_edcca_init(struct mt76x02_dev *dev);
 #endif
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_util.c b/drivers/net/wireless/mediatek/mt76/mt76x02_util.c
index 741ecd723b8e..8732e07c01ad 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x02_util.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x02_util.c
@@ -687,6 +687,7 @@ void mt76x02_bss_info_changed(struct ieee80211_hw *hw,
 {
 	struct mt76x02_vif *mvif = (struct mt76x02_vif *)vif->drv_priv;
 	struct mt76x02_dev *dev = hw->priv;
+	struct sk_buff *skb;
 
 	mutex_lock(&dev->mt76.mutex);
 
@@ -694,10 +695,11 @@ void mt76x02_bss_info_changed(struct ieee80211_hw *hw,
 		mt76x02_mac_set_bssid(dev, mvif->idx, info->bssid);
 
 	if (changed & BSS_CHANGED_BEACON_ENABLED) {
-		tasklet_disable(&dev->pre_tbtt_tasklet);
+		skb = NULL;
+		if (info->enable_beacon && mt76_is_usb(dev))
+			skb = ieee80211_beacon_get(hw, vif);
 		mt76x02_mac_set_beacon_enable(dev, mvif->idx,
-					      info->enable_beacon);
-		tasklet_enable(&dev->pre_tbtt_tasklet);
+					      info->enable_beacon, skb);
 	}
 
 	if (changed & BSS_CHANGED_HT || changed & BSS_CHANGED_ERP_CTS_PROT)
-- 
1.9.3


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH 7/7] mt76x02: enable support for IBSS, AP and MESH
  2019-01-24 15:44 [PATCH 0/7] mt76x02: Beacon support for USB Stanislaw Gruszka
                   ` (5 preceding siblings ...)
  2019-01-24 15:44 ` [PATCH 6/7] mt76: beaconing fixes for USB Stanislaw Gruszka
@ 2019-01-24 15:44 ` Stanislaw Gruszka
  6 siblings, 0 replies; 27+ messages in thread
From: Stanislaw Gruszka @ 2019-01-24 15:44 UTC (permalink / raw)
  To: Felix Fietkau; +Cc: linux-wireless, Lorenzo Bianconi

Since we implement beconing on USB now, similar interfaces should be
supported for USB as are for MMIO. Tested only for AP and IBSS modes.

Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
---
 drivers/net/wireless/mediatek/mt76/mt76x02_util.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_util.c b/drivers/net/wireless/mediatek/mt76/mt76x02_util.c
index 8732e07c01ad..3880caa0c64a 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x02_util.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x02_util.c
@@ -150,16 +150,6 @@ void mt76x02_init_device(struct mt76x02_dev *dev)
 		mt76x02_dfs_init_detector(dev);
 
 		wiphy->reg_notifier = mt76x02_regd_notifier;
-		wiphy->iface_combinations = mt76x02_if_comb;
-		wiphy->n_iface_combinations = ARRAY_SIZE(mt76x02_if_comb);
-		wiphy->interface_modes =
-			BIT(NL80211_IFTYPE_STATION) |
-			BIT(NL80211_IFTYPE_AP) |
-#ifdef CONFIG_MAC80211_MESH
-			BIT(NL80211_IFTYPE_MESH_POINT) |
-#endif
-			BIT(NL80211_IFTYPE_ADHOC);
-
 		wiphy->flags |= WIPHY_FLAG_HAS_CHANNEL_SWITCH;
 
 		wiphy_ext_feature_set(wiphy, NL80211_EXT_FEATURE_VHT_IBSS);
@@ -172,6 +162,16 @@ void mt76x02_init_device(struct mt76x02_dev *dev)
 		}
 	}
 
+	wiphy->iface_combinations = mt76x02_if_comb;
+	wiphy->n_iface_combinations = ARRAY_SIZE(mt76x02_if_comb);
+	wiphy->interface_modes =
+			BIT(NL80211_IFTYPE_STATION) |
+			BIT(NL80211_IFTYPE_AP) |
+#ifdef CONFIG_MAC80211_MESH
+			BIT(NL80211_IFTYPE_MESH_POINT) |
+#endif
+			BIT(NL80211_IFTYPE_ADHOC);
+
 	hw->sta_data_size = sizeof(struct mt76x02_sta);
 	hw->vif_data_size = sizeof(struct mt76x02_vif);
 
-- 
1.9.3


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* Re: [PATCH 1/7] mt76x02: use mask for vifs
  2019-01-24 15:44 ` [PATCH 1/7] mt76x02: use mask for vifs Stanislaw Gruszka
@ 2019-01-24 16:12   ` Lorenzo Bianconi
  2019-01-24 16:20     ` Stanislaw Gruszka
  0 siblings, 1 reply; 27+ messages in thread
From: Lorenzo Bianconi @ 2019-01-24 16:12 UTC (permalink / raw)
  To: Stanislaw Gruszka; +Cc: Felix Fietkau, linux-wireless

> Use vif_mask to count interfaces to allow to set mac address
> if there is only one interface and support more STA vifs in
> the future.
> 
> Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
> ---
>  drivers/net/wireless/mediatek/mt76/mt76x02.h      |  2 ++
>  drivers/net/wireless/mediatek/mt76/mt76x02_util.c | 18 +++++++++++++-----
>  2 files changed, 15 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02.h b/drivers/net/wireless/mediatek/mt76/mt76x02.h
> index 6d96766a6ed3..be077443bdb0 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt76x02.h
> +++ b/drivers/net/wireless/mediatek/mt76/mt76x02.h
> @@ -73,6 +73,8 @@ struct mt76x02_dev {
>  
>  	struct mutex phy_mutex;
>  
> +	u16 vif_mask;
> +
>  	u8 txdone_seq;
>  	DECLARE_KFIFO_PTR(txstatus_fifo, struct mt76x02_tx_status);
>  
> diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_util.c b/drivers/net/wireless/mediatek/mt76/mt76x02_util.c
> index 062614ad0d51..1a949453dc25 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt76x02_util.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt76x02_util.c
> @@ -288,10 +288,7 @@ void mt76x02_vif_init(struct mt76x02_dev *dev, struct ieee80211_vif *vif,
>  mt76x02_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
>  {
>  	struct mt76x02_dev *dev = hw->priv;
> -	unsigned int idx = 0;
> -
> -	if (vif->addr[0] & BIT(1))
> -		idx = 1 + (((dev->mt76.macaddr[0] ^ vif->addr[0]) >> 2) & 7);
> +	unsigned int idx, offset = 0;
>  
>  	/*
>  	 * Client mode typically only has one configurable BSSID register,
> @@ -307,7 +304,16 @@ void mt76x02_vif_init(struct mt76x02_dev *dev, struct ieee80211_vif *vif,
>  	 * The resulting bssidx mismatch for unicast frames is ignored by hw.
>  	 */
>  	if (vif->type == NL80211_IFTYPE_STATION)
> -		idx += 8;
> +		offset = 8;
> +
> +	idx = ffs(~(dev->vif_mask >> offset)) - 1;
> +	idx += offset;
> +
> +	/* Allow to change address is only one interface. */
> +	if (!dev->vif_mask && (!ether_addr_equal(dev->mt76.macaddr, vif->addr)))
> +                mt76x02_mac_setaddr(dev, vif->addr);

I guess this does not work if you add 2 vifs and then you remove the first one
(you will end up with a wrong configuration in MT_MAC_ADDR_DW{0,1}). I guess
the hw will not work well if MT_MAC_ADDR_DW{0,1} is not properly configured

Regards,
Lorenzo

> +
> +	dev->vif_mask |= BIT(idx);
>  
>  	mt76x02_vif_init(dev, vif, idx);
>  	return 0;
> @@ -318,8 +324,10 @@ void mt76x02_remove_interface(struct ieee80211_hw *hw,
>  			      struct ieee80211_vif *vif)
>  {
>  	struct mt76x02_dev *dev = hw->priv;
> +	struct mt76x02_vif *mvif = (struct mt76x02_vif *)vif->drv_priv;
>  
>  	mt76_txq_remove(&dev->mt76, vif->txq);
> +	dev->vif_mask &= ~BIT(mvif->idx);
>  }
>  EXPORT_SYMBOL_GPL(mt76x02_remove_interface);
>  
> -- 
> 1.9.3
> 

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 1/7] mt76x02: use mask for vifs
  2019-01-24 16:12   ` Lorenzo Bianconi
@ 2019-01-24 16:20     ` Stanislaw Gruszka
  2019-01-24 16:35       ` Lorenzo Bianconi
  0 siblings, 1 reply; 27+ messages in thread
From: Stanislaw Gruszka @ 2019-01-24 16:20 UTC (permalink / raw)
  To: Lorenzo Bianconi; +Cc: Felix Fietkau, linux-wireless

On Thu, Jan 24, 2019 at 05:12:37PM +0100, Lorenzo Bianconi wrote:
> > Use vif_mask to count interfaces to allow to set mac address
> > if there is only one interface and support more STA vifs in
> > the future.
> > 
> > Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
> > ---
> >  drivers/net/wireless/mediatek/mt76/mt76x02.h      |  2 ++
> >  drivers/net/wireless/mediatek/mt76/mt76x02_util.c | 18 +++++++++++++-----
> >  2 files changed, 15 insertions(+), 5 deletions(-)
> > 
> > diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02.h b/drivers/net/wireless/mediatek/mt76/mt76x02.h
> > index 6d96766a6ed3..be077443bdb0 100644
> > --- a/drivers/net/wireless/mediatek/mt76/mt76x02.h
> > +++ b/drivers/net/wireless/mediatek/mt76/mt76x02.h
> > @@ -73,6 +73,8 @@ struct mt76x02_dev {
> >  
> >  	struct mutex phy_mutex;
> >  
> > +	u16 vif_mask;
> > +
> >  	u8 txdone_seq;
> >  	DECLARE_KFIFO_PTR(txstatus_fifo, struct mt76x02_tx_status);
> >  
> > diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_util.c b/drivers/net/wireless/mediatek/mt76/mt76x02_util.c
> > index 062614ad0d51..1a949453dc25 100644
> > --- a/drivers/net/wireless/mediatek/mt76/mt76x02_util.c
> > +++ b/drivers/net/wireless/mediatek/mt76/mt76x02_util.c
> > @@ -288,10 +288,7 @@ void mt76x02_vif_init(struct mt76x02_dev *dev, struct ieee80211_vif *vif,
> >  mt76x02_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
> >  {
> >  	struct mt76x02_dev *dev = hw->priv;
> > -	unsigned int idx = 0;
> > -
> > -	if (vif->addr[0] & BIT(1))
> > -		idx = 1 + (((dev->mt76.macaddr[0] ^ vif->addr[0]) >> 2) & 7);
> > +	unsigned int idx, offset = 0;
> >  
> >  	/*
> >  	 * Client mode typically only has one configurable BSSID register,
> > @@ -307,7 +304,16 @@ void mt76x02_vif_init(struct mt76x02_dev *dev, struct ieee80211_vif *vif,
> >  	 * The resulting bssidx mismatch for unicast frames is ignored by hw.
> >  	 */
> >  	if (vif->type == NL80211_IFTYPE_STATION)
> > -		idx += 8;
> > +		offset = 8;
> > +
> > +	idx = ffs(~(dev->vif_mask >> offset)) - 1;
> > +	idx += offset;
> > +
> > +	/* Allow to change address is only one interface. */
> > +	if (!dev->vif_mask && (!ether_addr_equal(dev->mt76.macaddr, vif->addr)))
> > +                mt76x02_mac_setaddr(dev, vif->addr);
> 
> I guess this does not work if you add 2 vifs and then you remove the first one
> (you will end up with a wrong configuration in MT_MAC_ADDR_DW{0,1}). I guess
> the hw will not work well if MT_MAC_ADDR_DW{0,1} is not properly configured

This is only done when when vif_mask is 0 i.e. no interfaces. When
some interface is already created, changing MAC address will now work
anyway.

Thanks
Stanislaw

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 1/7] mt76x02: use mask for vifs
  2019-01-24 16:20     ` Stanislaw Gruszka
@ 2019-01-24 16:35       ` Lorenzo Bianconi
  2019-01-24 22:20         ` Lorenzo Bianconi
  0 siblings, 1 reply; 27+ messages in thread
From: Lorenzo Bianconi @ 2019-01-24 16:35 UTC (permalink / raw)
  To: Stanislaw Gruszka; +Cc: Felix Fietkau, linux-wireless

> On Thu, Jan 24, 2019 at 05:12:37PM +0100, Lorenzo Bianconi wrote:
> > > Use vif_mask to count interfaces to allow to set mac address
> > > if there is only one interface and support more STA vifs in
> > > the future.
> > > 
> > > Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
> > > ---
> > >  drivers/net/wireless/mediatek/mt76/mt76x02.h      |  2 ++
> > >  drivers/net/wireless/mediatek/mt76/mt76x02_util.c | 18 +++++++++++++-----
> > >  2 files changed, 15 insertions(+), 5 deletions(-)
> > > 
> > > diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02.h b/drivers/net/wireless/mediatek/mt76/mt76x02.h
> > > index 6d96766a6ed3..be077443bdb0 100644
> > > --- a/drivers/net/wireless/mediatek/mt76/mt76x02.h
> > > +++ b/drivers/net/wireless/mediatek/mt76/mt76x02.h
> > > @@ -73,6 +73,8 @@ struct mt76x02_dev {
> > >  
> > >  	struct mutex phy_mutex;
> > >  
> > > +	u16 vif_mask;
> > > +
> > >  	u8 txdone_seq;
> > >  	DECLARE_KFIFO_PTR(txstatus_fifo, struct mt76x02_tx_status);
> > >  
> > > diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_util.c b/drivers/net/wireless/mediatek/mt76/mt76x02_util.c
> > > index 062614ad0d51..1a949453dc25 100644
> > > --- a/drivers/net/wireless/mediatek/mt76/mt76x02_util.c
> > > +++ b/drivers/net/wireless/mediatek/mt76/mt76x02_util.c
> > > @@ -288,10 +288,7 @@ void mt76x02_vif_init(struct mt76x02_dev *dev, struct ieee80211_vif *vif,
> > >  mt76x02_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
> > >  {
> > >  	struct mt76x02_dev *dev = hw->priv;
> > > -	unsigned int idx = 0;
> > > -
> > > -	if (vif->addr[0] & BIT(1))
> > > -		idx = 1 + (((dev->mt76.macaddr[0] ^ vif->addr[0]) >> 2) & 7);
> > > +	unsigned int idx, offset = 0;
> > >  
> > >  	/*
> > >  	 * Client mode typically only has one configurable BSSID register,
> > > @@ -307,7 +304,16 @@ void mt76x02_vif_init(struct mt76x02_dev *dev, struct ieee80211_vif *vif,
> > >  	 * The resulting bssidx mismatch for unicast frames is ignored by hw.
> > >  	 */
> > >  	if (vif->type == NL80211_IFTYPE_STATION)
> > > -		idx += 8;
> > > +		offset = 8;
> > > +
> > > +	idx = ffs(~(dev->vif_mask >> offset)) - 1;
> > > +	idx += offset;
> > > +
> > > +	/* Allow to change address is only one interface. */
> > > +	if (!dev->vif_mask && (!ether_addr_equal(dev->mt76.macaddr, vif->addr)))
> > > +                mt76x02_mac_setaddr(dev, vif->addr);
> > 
> > I guess this does not work if you add 2 vifs and then you remove the first one
> > (you will end up with a wrong configuration in MT_MAC_ADDR_DW{0,1}). I guess
> > the hw will not work well if MT_MAC_ADDR_DW{0,1} is not properly configured

Maybe I am missing something, but let's assume you add the interface vif0 with address
00:11:22:33:44:55 (MT_MAC_ADDR_DW{0,1} will be set to 00:11:22:33:44:55) and
then you add vif1 with address 00:aa:bb:cc:dd:ee. If at some point you remove
vif0 MT_MAC_ADDR_DW{0,1} will not be properly reconfigured. The problem will
be more complex if you have more interfaces

> 
> This is only done when when vif_mask is 0 i.e. no interfaces. When
> some interface is already created, changing MAC address will now work
> anyway.
> 
> Thanks
> Stanislaw

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 1/7] mt76x02: use mask for vifs
  2019-01-24 16:35       ` Lorenzo Bianconi
@ 2019-01-24 22:20         ` Lorenzo Bianconi
  2019-01-25  8:25           ` Stanislaw Gruszka
  0 siblings, 1 reply; 27+ messages in thread
From: Lorenzo Bianconi @ 2019-01-24 22:20 UTC (permalink / raw)
  To: Stanislaw Gruszka; +Cc: Felix Fietkau, linux-wireless

> > > 
> > > I guess this does not work if you add 2 vifs and then you remove the first one
> > > (you will end up with a wrong configuration in MT_MAC_ADDR_DW{0,1}). I guess
> > > the hw will not work well if MT_MAC_ADDR_DW{0,1} is not properly configured
> 
> Maybe I am missing something, but let's assume you add the interface vif0 with address
> 00:11:22:33:44:55 (MT_MAC_ADDR_DW{0,1} will be set to 00:11:22:33:44:55) and
> then you add vif1 with address 00:aa:bb:cc:dd:ee. If at some point you remove
> vif0 MT_MAC_ADDR_DW{0,1} will not be properly reconfigured. The problem will
> be more complex if you have more interfaces

Moreover if you add 2 vif, vif0 with address 00:11:22:33:44:55 and vif1 with
address 00:aa:bb:cc:dd:ee, have you double-checked you are able to get the same
tpt on both interfaces? In the past IIRC there were issues if we use multibss
with completely different mac addresses

Regards,
Lorenzo

> 
> > 
> > This is only done when when vif_mask is 0 i.e. no interfaces. When
> > some interface is already created, changing MAC address will now work
> > anyway.
> > 
> > Thanks
> > Stanislaw

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 4/7] mt76x02: minor beaconing init changes
  2019-01-24 15:44 ` [PATCH 4/7] mt76x02: minor beaconing init changes Stanislaw Gruszka
@ 2019-01-24 22:32   ` Lorenzo Bianconi
  0 siblings, 0 replies; 27+ messages in thread
From: Lorenzo Bianconi @ 2019-01-24 22:32 UTC (permalink / raw)
  To: Stanislaw Gruszka; +Cc: Felix Fietkau, linux-wireless

> Disable BEACON timer during init and remove interrupt registers
> initialization form generic code since they are PCIe specific.
> 
> Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
> ---
>  drivers/net/wireless/mediatek/mt76/mt76x0/pci.c      |  7 +++++++
>  drivers/net/wireless/mediatek/mt76/mt76x02_util.c    | 11 ++++-------
>  drivers/net/wireless/mediatek/mt76/mt76x2/pci_init.c |  8 ++++++++
>  3 files changed, 19 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/pci.c b/drivers/net/wireless/mediatek/mt76/mt76x0/pci.c
> index 1472c8699b29..cb68af5b7478 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt76x0/pci.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt76x0/pci.c
> @@ -128,6 +128,13 @@ static int mt76x0e_register_device(struct mt76x02_dev *dev)
>  	if (err < 0)
>  		return err;
>  
> +	/* Beaconing: fire a pre-TBTT interrupt 8 ms before TBTT */
> +	mt76_rmw_field(dev, MT_INT_TIMER_CFG, MT_INT_TIMER_CFG_PRE_TBTT,
> +		       8 << 4);
> +	mt76_rmw_field(dev, MT_INT_TIMER_CFG, MT_INT_TIMER_CFG_GP_TIMER,
> +		       MT_DFS_GP_INTERVAL);
> +	mt76_wr(dev, MT_INT_TIMER_EN, 0);

What about having a dedicated routine for that configuration since we need it
for mt76x2 and mt76x0 drivers?

> +
>  	if (mt76_chip(&dev->mt76) == 0x7610) {
>  		u16 val;
>  
> diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_util.c b/drivers/net/wireless/mediatek/mt76/mt76x02_util.c
> index 02139dce4800..741ecd723b8e 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt76x02_util.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt76x02_util.c
> @@ -667,13 +667,10 @@ void mt76x02_init_beacon_config(struct mt76x02_dev *dev)
>  {
>  	int i;
>  
> -	/* Fire a pre-TBTT interrupt 8 ms before TBTT */
> -	mt76_rmw_field(dev, MT_INT_TIMER_CFG, MT_INT_TIMER_CFG_PRE_TBTT,
> -		       8 << 4);
> -	mt76_rmw_field(dev, MT_INT_TIMER_CFG, MT_INT_TIMER_CFG_GP_TIMER,
> -		       MT_DFS_GP_INTERVAL);
> -	mt76_wr(dev, MT_INT_TIMER_EN, 0);
> -
> +	mt76_clear(dev, MT_BEACON_TIME_CFG, (MT_BEACON_TIME_CFG_TIMER_EN |
> +					     MT_BEACON_TIME_CFG_SYNC_MODE |
> +					     MT_BEACON_TIME_CFG_TBTT_EN |
> +					     MT_BEACON_TIME_CFG_BEACON_TX));
>  	mt76_wr(dev, MT_BCN_BYPASS_MASK, 0xffff);
>  
>  	for (i = 0; i < 8; i++)
> diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2/pci_init.c b/drivers/net/wireless/mediatek/mt76/mt76x2/pci_init.c
> index 0ccaa64d97ec..f86ff035fa7f 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt76x2/pci_init.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt76x2/pci_init.c
> @@ -121,6 +121,14 @@ static int mt76x2_mac_reset(struct mt76x02_dev *dev, bool hard)
>  
>  	mt76x02_mac_setaddr(dev, macaddr);
>  	mt76x02_init_beacon_config(dev);
> +
> +	/* Fire a pre-TBTT interrupt 8 ms before TBTT */
> +	mt76_rmw_field(dev, MT_INT_TIMER_CFG, MT_INT_TIMER_CFG_PRE_TBTT,
> +		       8 << 4);
> +	mt76_rmw_field(dev, MT_INT_TIMER_CFG, MT_INT_TIMER_CFG_GP_TIMER,
> +		       MT_DFS_GP_INTERVAL);
> +	mt76_wr(dev, MT_INT_TIMER_EN, 0);
> +
>  	if (!hard)
>  		return 0;
>  
> -- 
> 1.9.3
> 

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 5/7] mt76x02: init beacon config for mt76x2u
  2019-01-24 15:44 ` [PATCH 5/7] mt76x02: init beacon config for mt76x2u Stanislaw Gruszka
@ 2019-01-24 22:33   ` Lorenzo Bianconi
  0 siblings, 0 replies; 27+ messages in thread
From: Lorenzo Bianconi @ 2019-01-24 22:33 UTC (permalink / raw)
  To: Stanislaw Gruszka; +Cc: Felix Fietkau, linux-wireless

> Initialize beaconing also on mt76x2u.
> 
> Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
> ---
>  drivers/net/wireless/mediatek/mt76/mt76x2/usb_init.c | 6 +-----
>  1 file changed, 1 insertion(+), 5 deletions(-)
> 
> diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2/usb_init.c b/drivers/net/wireless/mediatek/mt76/mt76x2/usb_init.c
> index 0be3784f44fb..3737e9fa8295 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt76x2/usb_init.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt76x2/usb_init.c
> @@ -207,11 +207,7 @@ int mt76x2u_init_hardware(struct mt76x02_dev *dev)
>  			mt76x02_mac_shared_key_setup(dev, i, k, NULL);
>  	}
>  
> -	mt76_clear(dev, MT_BEACON_TIME_CFG,
> -		   MT_BEACON_TIME_CFG_TIMER_EN |
> -		   MT_BEACON_TIME_CFG_SYNC_MODE |
> -		   MT_BEACON_TIME_CFG_TBTT_EN |
> -		   MT_BEACON_TIME_CFG_BEACON_TX);
> +	mt76x02_init_beacon_config(dev);
>  
>  	mt76_rmw(dev, MT_US_CYC_CFG, MT_US_CYC_CNT, 0x1e);
>  	mt76_wr(dev, MT_TXOP_CTRL_CFG, 0x583f);
> -- 
> 1.9.3
> 

I think this can be squashed with 4/7

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 6/7] mt76: beaconing fixes for USB
  2019-01-24 15:44 ` [PATCH 6/7] mt76: beaconing fixes for USB Stanislaw Gruszka
@ 2019-01-24 22:50   ` Lorenzo Bianconi
  2019-01-28  8:30     ` Stanislaw Gruszka
  0 siblings, 1 reply; 27+ messages in thread
From: Lorenzo Bianconi @ 2019-01-24 22:50 UTC (permalink / raw)
  To: Stanislaw Gruszka; +Cc: Felix Fietkau, linux-wireless

On Jan 24, Stanislaw Gruszka wrote:
> Configure beaconing on USB devices without PS buffering support.
> 
> Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
> ---
>  drivers/net/wireless/mediatek/mt76/mac80211.c     |  3 ++-
>  drivers/net/wireless/mediatek/mt76/mt76x02_mac.c  | 24 ++++++++++++++++++++---
>  drivers/net/wireless/mediatek/mt76/mt76x02_mac.h  |  2 +-
>  drivers/net/wireless/mediatek/mt76/mt76x02_util.c |  8 +++++---
>  4 files changed, 29 insertions(+), 8 deletions(-)
> 

[...]

> +
> +void mt76x02_mac_set_beacon_enable(struct mt76x02_dev *dev, u8 vif_idx,
> +			           bool val, struct sk_buff *skb)
> +{
> +	if (mt76_is_mmio(dev))
> +		tasklet_disable(&dev->pre_tbtt_tasklet);
> +
> +	__mt76x02_mac_set_beacon_enable(dev, vif_idx, val, skb);
> +
> +	if (mt76_is_mmio(dev))
> +		tasklet_enable(&dev->pre_tbtt_tasklet);
> +}
> diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_mac.h b/drivers/net/wireless/mediatek/mt76/mt76x02_mac.h
> index 76e564b8f5da..a15fc71e3d55 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt76x02_mac.h
> +++ b/drivers/net/wireless/mediatek/mt76/mt76x02_mac.h
> @@ -205,7 +205,7 @@ void mt76x02_tx_complete_skb(struct mt76_dev *mdev, struct mt76_queue *q,
>  int mt76x02_mac_set_beacon(struct mt76x02_dev *dev, u8 vif_idx,
>  			   struct sk_buff *skb);
>  void mt76x02_mac_set_beacon_enable(struct mt76x02_dev *dev, u8 vif_idx,
> -				   bool val);
> +				   bool val, struct sk_buff *skb);
>  
>  void mt76x02_edcca_init(struct mt76x02_dev *dev);
>  #endif
> diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_util.c b/drivers/net/wireless/mediatek/mt76/mt76x02_util.c
> index 741ecd723b8e..8732e07c01ad 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt76x02_util.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt76x02_util.c
> @@ -687,6 +687,7 @@ void mt76x02_bss_info_changed(struct ieee80211_hw *hw,
>  {
>  	struct mt76x02_vif *mvif = (struct mt76x02_vif *)vif->drv_priv;
>  	struct mt76x02_dev *dev = hw->priv;
> +	struct sk_buff *skb;
>  
>  	mutex_lock(&dev->mt76.mutex);
>  
> @@ -694,10 +695,11 @@ void mt76x02_bss_info_changed(struct ieee80211_hw *hw,
>  		mt76x02_mac_set_bssid(dev, mvif->idx, info->bssid);
>  
>  	if (changed & BSS_CHANGED_BEACON_ENABLED) {
> -		tasklet_disable(&dev->pre_tbtt_tasklet);
> +		skb = NULL;
> +		if (info->enable_beacon && mt76_is_usb(dev))
> +			skb = ieee80211_beacon_get(hw, vif);

What about moving this in mt76x02_mac_set_beacon_enable(), I guess the code
will be more readable. Moreover you can move skb pointer declaration in
if (changed & BSS_CHANGED_BEACON_ENABLED) block

Regards,
Lorenzo

>  		mt76x02_mac_set_beacon_enable(dev, mvif->idx,
> -					      info->enable_beacon);
> -		tasklet_enable(&dev->pre_tbtt_tasklet);
> +					      info->enable_beacon, skb);
>  	}
>  
>  	if (changed & BSS_CHANGED_HT || changed & BSS_CHANGED_ERP_CTS_PROT)
> -- 
> 1.9.3
> 

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 1/7] mt76x02: use mask for vifs
  2019-01-24 22:20         ` Lorenzo Bianconi
@ 2019-01-25  8:25           ` Stanislaw Gruszka
  2019-01-25  9:02             ` Lorenzo Bianconi
  0 siblings, 1 reply; 27+ messages in thread
From: Stanislaw Gruszka @ 2019-01-25  8:25 UTC (permalink / raw)
  To: Lorenzo Bianconi; +Cc: Felix Fietkau, linux-wireless

On Thu, Jan 24, 2019 at 11:20:42PM +0100, Lorenzo Bianconi wrote:
> > > > 
> > > > I guess this does not work if you add 2 vifs and then you remove the first one
> > > > (you will end up with a wrong configuration in MT_MAC_ADDR_DW{0,1}). I guess
> > > > the hw will not work well if MT_MAC_ADDR_DW{0,1} is not properly configured
> > 
> > Maybe I am missing something, but let's assume you add the interface vif0 with address
> > 00:11:22:33:44:55 (MT_MAC_ADDR_DW{0,1} will be set to 00:11:22:33:44:55) and
> > then you add vif1 with address 00:aa:bb:cc:dd:ee. If at some point you remove
> > vif0 MT_MAC_ADDR_DW{0,1} will not be properly reconfigured. The problem will
> > be more complex if you have more interfaces

Ok, so in remove_interface extra code can be added to implement that.

> Moreover if you add 2 vif, vif0 with address 00:11:22:33:44:55 and vif1 with
> address 00:aa:bb:cc:dd:ee, have you double-checked you are able to get the same
> tpt on both interfaces? In the past IIRC there were issues if we use multibss
> with completely different mac addresses

I haven't check that. But what I can tell multi vif STA does not work, if
we do not enable PROMISC on rx filter. But this is not diffrent from MMIO
version, which mark multi vif support.

Regards
Stanislaw

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 1/7] mt76x02: use mask for vifs
  2019-01-25  8:25           ` Stanislaw Gruszka
@ 2019-01-25  9:02             ` Lorenzo Bianconi
  2019-01-25  9:06               ` Stanislaw Gruszka
  2019-01-25  9:47               ` Stanislaw Gruszka
  0 siblings, 2 replies; 27+ messages in thread
From: Lorenzo Bianconi @ 2019-01-25  9:02 UTC (permalink / raw)
  To: Stanislaw Gruszka; +Cc: Felix Fietkau, linux-wireless

> On Thu, Jan 24, 2019 at 11:20:42PM +0100, Lorenzo Bianconi wrote:
> > > > > 
> > > > > I guess this does not work if you add 2 vifs and then you remove the first one
> > > > > (you will end up with a wrong configuration in MT_MAC_ADDR_DW{0,1}). I guess
> > > > > the hw will not work well if MT_MAC_ADDR_DW{0,1} is not properly configured
> > > 
> > > Maybe I am missing something, but let's assume you add the interface vif0 with address
> > > 00:11:22:33:44:55 (MT_MAC_ADDR_DW{0,1} will be set to 00:11:22:33:44:55) and
> > > then you add vif1 with address 00:aa:bb:cc:dd:ee. If at some point you remove
> > > vif0 MT_MAC_ADDR_DW{0,1} will not be properly reconfigured. The problem will
> > > be more complex if you have more interfaces
> 
> Ok, so in remove_interface extra code can be added to implement that.
> 
> > Moreover if you add 2 vif, vif0 with address 00:11:22:33:44:55 and vif1 with
> > address 00:aa:bb:cc:dd:ee, have you double-checked you are able to get the same
> > tpt on both interfaces? In the past IIRC there were issues if we use multibss
> > with completely different mac addresses
> 
> I haven't check that. But what I can tell multi vif STA does not work, if
> we do not enable PROMISC on rx filter. But this is not diffrent from MMIO
> version, which mark multi vif support.

Since this is not strictly related to AP/IBSS support I guess we can just use
mt76x02_add_interface for mt76x2u or modify mt76x2u_add_interface in order to
use ap_cli registers for sta mode and drop this patch. I think we can address it
later after more testing

Regards,
Lorenzo

> 
> Regards
> Stanislaw

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 1/7] mt76x02: use mask for vifs
  2019-01-25  9:02             ` Lorenzo Bianconi
@ 2019-01-25  9:06               ` Stanislaw Gruszka
  2019-01-25  9:47               ` Stanislaw Gruszka
  1 sibling, 0 replies; 27+ messages in thread
From: Stanislaw Gruszka @ 2019-01-25  9:06 UTC (permalink / raw)
  To: Lorenzo Bianconi; +Cc: Felix Fietkau, linux-wireless

On Fri, Jan 25, 2019 at 10:02:38AM +0100, Lorenzo Bianconi wrote:
> > On Thu, Jan 24, 2019 at 11:20:42PM +0100, Lorenzo Bianconi wrote:
> > > > > > 
> > > > > > I guess this does not work if you add 2 vifs and then you remove the first one
> > > > > > (you will end up with a wrong configuration in MT_MAC_ADDR_DW{0,1}). I guess
> > > > > > the hw will not work well if MT_MAC_ADDR_DW{0,1} is not properly configured
> > > > 
> > > > Maybe I am missing something, but let's assume you add the interface vif0 with address
> > > > 00:11:22:33:44:55 (MT_MAC_ADDR_DW{0,1} will be set to 00:11:22:33:44:55) and
> > > > then you add vif1 with address 00:aa:bb:cc:dd:ee. If at some point you remove
> > > > vif0 MT_MAC_ADDR_DW{0,1} will not be properly reconfigured. The problem will
> > > > be more complex if you have more interfaces
> > 
> > Ok, so in remove_interface extra code can be added to implement that.
> > 
> > > Moreover if you add 2 vif, vif0 with address 00:11:22:33:44:55 and vif1 with
> > > address 00:aa:bb:cc:dd:ee, have you double-checked you are able to get the same
> > > tpt on both interfaces? In the past IIRC there were issues if we use multibss
> > > with completely different mac addresses
> > 
> > I haven't check that. But what I can tell multi vif STA does not work, if
> > we do not enable PROMISC on rx filter. But this is not diffrent from MMIO
> > version, which mark multi vif support.
> 
> Since this is not strictly related to AP/IBSS support I guess we can just use
> mt76x02_add_interface for mt76x2u or modify mt76x2u_add_interface in order to
> use ap_cli registers for sta mode and drop this patch. I think we can address it
> later after more testing

I do not see the reason of dropping the patch.

Thanks
Stanislaw

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 1/7] mt76x02: use mask for vifs
  2019-01-25  9:02             ` Lorenzo Bianconi
  2019-01-25  9:06               ` Stanislaw Gruszka
@ 2019-01-25  9:47               ` Stanislaw Gruszka
  2019-01-25 10:25                 ` Lorenzo Bianconi
  1 sibling, 1 reply; 27+ messages in thread
From: Stanislaw Gruszka @ 2019-01-25  9:47 UTC (permalink / raw)
  To: Lorenzo Bianconi; +Cc: Felix Fietkau, linux-wireless

On Fri, Jan 25, 2019 at 10:02:38AM +0100, Lorenzo Bianconi wrote:
> > On Thu, Jan 24, 2019 at 11:20:42PM +0100, Lorenzo Bianconi wrote:
> > > > > > 
> > > > > > I guess this does not work if you add 2 vifs and then you remove the first one
> > > > > > (you will end up with a wrong configuration in MT_MAC_ADDR_DW{0,1}). I guess
> > > > > > the hw will not work well if MT_MAC_ADDR_DW{0,1} is not properly configured
> > > > 
> > > > Maybe I am missing something, but let's assume you add the interface vif0 with address
> > > > 00:11:22:33:44:55 (MT_MAC_ADDR_DW{0,1} will be set to 00:11:22:33:44:55) and
> > > > then you add vif1 with address 00:aa:bb:cc:dd:ee. If at some point you remove
> > > > vif0 MT_MAC_ADDR_DW{0,1} will not be properly reconfigured. The problem will
> > > > be more complex if you have more interfaces
> > 
> > Ok, so in remove_interface extra code can be added to implement that.

Something like this should address the issue you raised:

diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_util.c b/drivers/net/wireless/mediatek/mt76/mt76x02_util.c
index 3880caa0c64a..44b4af928a4e 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x02_util.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x02_util.c
@@ -320,6 +320,15 @@ void mt76x02_sta_remove(struct mt76_dev *mdev, struct ieee80211_vif *vif,
 }
 EXPORT_SYMBOL_GPL(mt76x02_add_interface);
 
+static void mt76x02_setaddr_iterator(void *data, u8 *mac,
+                                     struct ieee80211_vif *vif)
+{
+	struct mt76x02_dev *dev = data;
+
+	if (!ether_addr_equal(dev->mt76.macaddr, vif->addr))
+                mt76x02_mac_setaddr(dev, vif->addr);
+}
+
 void mt76x02_remove_interface(struct ieee80211_hw *hw,
 			      struct ieee80211_vif *vif)
 {
@@ -328,6 +337,10 @@ void mt76x02_remove_interface(struct ieee80211_hw *hw,
 
 	mt76_txq_remove(&dev->mt76, vif->txq);
 	dev->vif_mask &= ~BIT(mvif->idx);
+
+	if (hweight16(dev->vif_mask) == 1)
+		ieee80211_iterate_interfaces(hw, 0, mt76x02_setaddr_iterator,
+					     dev);
 }
 EXPORT_SYMBOL_GPL(mt76x02_remove_interface);

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* Re: [PATCH 1/7] mt76x02: use mask for vifs
  2019-01-25  9:47               ` Stanislaw Gruszka
@ 2019-01-25 10:25                 ` Lorenzo Bianconi
  2019-01-25 12:41                   ` Stanislaw Gruszka
  0 siblings, 1 reply; 27+ messages in thread
From: Lorenzo Bianconi @ 2019-01-25 10:25 UTC (permalink / raw)
  To: Stanislaw Gruszka; +Cc: Felix Fietkau, linux-wireless

> On Fri, Jan 25, 2019 at 10:02:38AM +0100, Lorenzo Bianconi wrote:
> > > On Thu, Jan 24, 2019 at 11:20:42PM +0100, Lorenzo Bianconi wrote:
> > > > > > > 
> > > > > > > I guess this does not work if you add 2 vifs and then you remove the first one
> > > > > > > (you will end up with a wrong configuration in MT_MAC_ADDR_DW{0,1}). I guess
> > > > > > > the hw will not work well if MT_MAC_ADDR_DW{0,1} is not properly configured
> > > > > 
> > > > > Maybe I am missing something, but let's assume you add the interface vif0 with address
> > > > > 00:11:22:33:44:55 (MT_MAC_ADDR_DW{0,1} will be set to 00:11:22:33:44:55) and
> > > > > then you add vif1 with address 00:aa:bb:cc:dd:ee. If at some point you remove
> > > > > vif0 MT_MAC_ADDR_DW{0,1} will not be properly reconfigured. The problem will
> > > > > be more complex if you have more interfaces
> > > 
> > > Ok, so in remove_interface extra code can be added to implement that.
> 
> Something like this should address the issue you raised:
> 
> diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_util.c b/drivers/net/wireless/mediatek/mt76/mt76x02_util.c
> index 3880caa0c64a..44b4af928a4e 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt76x02_util.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt76x02_util.c
> @@ -320,6 +320,15 @@ void mt76x02_sta_remove(struct mt76_dev *mdev, struct ieee80211_vif *vif,
>  }
>  EXPORT_SYMBOL_GPL(mt76x02_add_interface);
>  
> +static void mt76x02_setaddr_iterator(void *data, u8 *mac,
> +                                     struct ieee80211_vif *vif)
> +{
> +	struct mt76x02_dev *dev = data;
> +
> +	if (!ether_addr_equal(dev->mt76.macaddr, vif->addr))
> +                mt76x02_mac_setaddr(dev, vif->addr);

This will end-up with multiple configurations if we have more than two
interfaces, right?

> +}
> +
>  void mt76x02_remove_interface(struct ieee80211_hw *hw,
>  			      struct ieee80211_vif *vif)
>  {
> @@ -328,6 +337,10 @@ void mt76x02_remove_interface(struct ieee80211_hw *hw,
>  
>  	mt76_txq_remove(&dev->mt76, vif->txq);
>  	dev->vif_mask &= ~BIT(mvif->idx);
> +
> +	if (hweight16(dev->vif_mask) == 1)
> +		ieee80211_iterate_interfaces(hw, 0, mt76x02_setaddr_iterator,
> +					     dev);

I guess we have the same issue if we have more than two interfaces and we
remove the first one that has been configured.
Moreover I am a little worried about tpt regressions with this patch.
Are you sure that if you use complete different mac addresses on a multivif scenario
you can get the same tpt on all the interfaces? Could you please provide some
tpt results?
Vendor driver relies on a strict scheme for mac addresses in multi-bss. If tpt is
nice I am ok with this patch

Regards,
Lorenzo

>  }
>  EXPORT_SYMBOL_GPL(mt76x02_remove_interface);

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 1/7] mt76x02: use mask for vifs
  2019-01-25 10:25                 ` Lorenzo Bianconi
@ 2019-01-25 12:41                   ` Stanislaw Gruszka
  2019-01-28  8:41                     ` Felix Fietkau
  0 siblings, 1 reply; 27+ messages in thread
From: Stanislaw Gruszka @ 2019-01-25 12:41 UTC (permalink / raw)
  To: Lorenzo Bianconi; +Cc: Felix Fietkau, linux-wireless

On Fri, Jan 25, 2019 at 11:25:46AM +0100, Lorenzo Bianconi wrote:
> > On Fri, Jan 25, 2019 at 10:02:38AM +0100, Lorenzo Bianconi wrote:
> > > > On Thu, Jan 24, 2019 at 11:20:42PM +0100, Lorenzo Bianconi wrote:
> > > > > > > > 
> > > > > > > > I guess this does not work if you add 2 vifs and then you remove the first one
> > > > > > > > (you will end up with a wrong configuration in MT_MAC_ADDR_DW{0,1}). I guess
> > > > > > > > the hw will not work well if MT_MAC_ADDR_DW{0,1} is not properly configured
> > > > > > 
> > > > > > Maybe I am missing something, but let's assume you add the interface vif0 with address
> > > > > > 00:11:22:33:44:55 (MT_MAC_ADDR_DW{0,1} will be set to 00:11:22:33:44:55) and
> > > > > > then you add vif1 with address 00:aa:bb:cc:dd:ee. If at some point you remove
> > > > > > vif0 MT_MAC_ADDR_DW{0,1} will not be properly reconfigured. The problem will
> > > > > > be more complex if you have more interfaces
> > > > 
> > > > Ok, so in remove_interface extra code can be added to implement that.
> > 
> > Something like this should address the issue you raised:
> > 
> > diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_util.c b/drivers/net/wireless/mediatek/mt76/mt76x02_util.c
> > index 3880caa0c64a..44b4af928a4e 100644
> > --- a/drivers/net/wireless/mediatek/mt76/mt76x02_util.c
> > +++ b/drivers/net/wireless/mediatek/mt76/mt76x02_util.c
> > @@ -320,6 +320,15 @@ void mt76x02_sta_remove(struct mt76_dev *mdev, struct ieee80211_vif *vif,
> >  }
> >  EXPORT_SYMBOL_GPL(mt76x02_add_interface);
> >  
> > +static void mt76x02_setaddr_iterator(void *data, u8 *mac,
> > +                                     struct ieee80211_vif *vif)
> > +{
> > +	struct mt76x02_dev *dev = data;
> > +
> > +	if (!ether_addr_equal(dev->mt76.macaddr, vif->addr))
> > +                mt76x02_mac_setaddr(dev, vif->addr);
> 
> This will end-up with multiple configurations if we have more than two
> interfaces, right?

No. It is called only when number of vifs change from 2 to 1 . But there
should be additional check 'dev->vif_mask & BIT(mvif->idx)' since we can
have removing interface still present in mac80211.

> >  void mt76x02_remove_interface(struct ieee80211_hw *hw,
> >  			      struct ieee80211_vif *vif)
> >  {
> > @@ -328,6 +337,10 @@ void mt76x02_remove_interface(struct ieee80211_hw *hw,
> >  
> >  	mt76_txq_remove(&dev->mt76, vif->txq);
> >  	dev->vif_mask &= ~BIT(mvif->idx);
> > +
> > +	if (hweight16(dev->vif_mask) == 1)
> > +		ieee80211_iterate_interfaces(hw, 0, mt76x02_setaddr_iterator,
> > +					     dev);
> 
> I guess we have the same issue if we have more than two interfaces and we
> remove the first one that has been configured.

We can not configure more than one MAC address without using MT_MAC_ADDR_EXT
registers. If there are more than one vif, there is no point to set MT_MAC_ADDR.

> Moreover I am a little worried about tpt regressions with this patch.
> Are you sure that if you use complete different mac addresses on a multivif scenario
> you can get the same tpt on all the interfaces? Could you please provide some
> tpt results?

How exactly posted patch can cause tpt regression ?

Posted patch just add possibility to configure HW MAC address
by this:

iw dev wlan0 del
iw phy phy0 interface add wlan0 type managed addr 00:11:22:33:44:55

what is feature of mt76x2u. Patch just extend that possibly to other
mt76x02 devices and allow to remove custom mt76x2u add_interfacea
callback.

Thanks
Stanislaw



^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 6/7] mt76: beaconing fixes for USB
  2019-01-24 22:50   ` Lorenzo Bianconi
@ 2019-01-28  8:30     ` Stanislaw Gruszka
  0 siblings, 0 replies; 27+ messages in thread
From: Stanislaw Gruszka @ 2019-01-28  8:30 UTC (permalink / raw)
  To: Lorenzo Bianconi; +Cc: Felix Fietkau, linux-wireless

On Thu, Jan 24, 2019 at 11:50:49PM +0100, Lorenzo Bianconi wrote:
> >  	if (changed & BSS_CHANGED_BEACON_ENABLED) {
> > -		tasklet_disable(&dev->pre_tbtt_tasklet);
> > +		skb = NULL;
> > +		if (info->enable_beacon && mt76_is_usb(dev))
> > +			skb = ieee80211_beacon_get(hw, vif);
> 
> What about moving this in mt76x02_mac_set_beacon_enable(), I guess the code
> will be more readable. Moreover you can move skb pointer declaration in
> if (changed & BSS_CHANGED_BEACON_ENABLED) block

Ok, make sense.

Regarding your other remarks, I do not see utility to address them.

Thanks
Stanislaw

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 1/7] mt76x02: use mask for vifs
  2019-01-25 12:41                   ` Stanislaw Gruszka
@ 2019-01-28  8:41                     ` Felix Fietkau
  2019-01-28  9:02                       ` Stanislaw Gruszka
  0 siblings, 1 reply; 27+ messages in thread
From: Felix Fietkau @ 2019-01-28  8:41 UTC (permalink / raw)
  To: Stanislaw Gruszka, Lorenzo Bianconi; +Cc: linux-wireless

On 2019-01-25 13:41, Stanislaw Gruszka wrote:
> On Fri, Jan 25, 2019 at 11:25:46AM +0100, Lorenzo Bianconi wrote:
>> > On Fri, Jan 25, 2019 at 10:02:38AM +0100, Lorenzo Bianconi wrote:
>> > > > On Thu, Jan 24, 2019 at 11:20:42PM +0100, Lorenzo Bianconi wrote:
>> > > > > > > > 
>> > > > > > > > I guess this does not work if you add 2 vifs and then you remove the first one
>> > > > > > > > (you will end up with a wrong configuration in MT_MAC_ADDR_DW{0,1}). I guess
>> > > > > > > > the hw will not work well if MT_MAC_ADDR_DW{0,1} is not properly configured
>> > > > > > 
>> > > > > > Maybe I am missing something, but let's assume you add the interface vif0 with address
>> > > > > > 00:11:22:33:44:55 (MT_MAC_ADDR_DW{0,1} will be set to 00:11:22:33:44:55) and
>> > > > > > then you add vif1 with address 00:aa:bb:cc:dd:ee. If at some point you remove
>> > > > > > vif0 MT_MAC_ADDR_DW{0,1} will not be properly reconfigured. The problem will
>> > > > > > be more complex if you have more interfaces
>> > > > 
>> > > > Ok, so in remove_interface extra code can be added to implement that.
>> > 
>> > Something like this should address the issue you raised:
>> > 
>> > diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_util.c b/drivers/net/wireless/mediatek/mt76/mt76x02_util.c
>> > index 3880caa0c64a..44b4af928a4e 100644
>> > --- a/drivers/net/wireless/mediatek/mt76/mt76x02_util.c
>> > +++ b/drivers/net/wireless/mediatek/mt76/mt76x02_util.c
>> > @@ -320,6 +320,15 @@ void mt76x02_sta_remove(struct mt76_dev *mdev, struct ieee80211_vif *vif,
>> >  }
>> >  EXPORT_SYMBOL_GPL(mt76x02_add_interface);
>> >  
>> > +static void mt76x02_setaddr_iterator(void *data, u8 *mac,
>> > +                                     struct ieee80211_vif *vif)
>> > +{
>> > +	struct mt76x02_dev *dev = data;
>> > +
>> > +	if (!ether_addr_equal(dev->mt76.macaddr, vif->addr))
>> > +                mt76x02_mac_setaddr(dev, vif->addr);
>> 
>> This will end-up with multiple configurations if we have more than two
>> interfaces, right?
> 
> No. It is called only when number of vifs change from 2 to 1 . But there
> should be additional check 'dev->vif_mask & BIT(mvif->idx)' since we can
> have removing interface still present in mac80211.
> 
>> >  void mt76x02_remove_interface(struct ieee80211_hw *hw,
>> >  			      struct ieee80211_vif *vif)
>> >  {
>> > @@ -328,6 +337,10 @@ void mt76x02_remove_interface(struct ieee80211_hw *hw,
>> >  
>> >  	mt76_txq_remove(&dev->mt76, vif->txq);
>> >  	dev->vif_mask &= ~BIT(mvif->idx);
>> > +
>> > +	if (hweight16(dev->vif_mask) == 1)
>> > +		ieee80211_iterate_interfaces(hw, 0, mt76x02_setaddr_iterator,
>> > +					     dev);
>> 
>> I guess we have the same issue if we have more than two interfaces and we
>> remove the first one that has been configured.
> 
> We can not configure more than one MAC address without using MT_MAC_ADDR_EXT
> registers. If there are more than one vif, there is no point to set MT_MAC_ADDR.
> 
>> Moreover I am a little worried about tpt regressions with this patch.
>> Are you sure that if you use complete different mac addresses on a multivif scenario
>> you can get the same tpt on all the interfaces? Could you please provide some
>> tpt results?
> 
> How exactly posted patch can cause tpt regression ?
> 
> Posted patch just add possibility to configure HW MAC address
> by this:
> 
> iw dev wlan0 del
> iw phy phy0 interface add wlan0 type managed addr 00:11:22:33:44:55
> 
> what is feature of mt76x2u. Patch just extend that possibly to other
> mt76x02 devices and allow to remove custom mt76x2u add_interfacea
> callback.
The main part that could cause issues is that you're changing the way
that the vif index is calculated. Without the patch, it's calculated
from the MAC address in a way consistent with what the hardware expects.
With the patch, it's just allocated from a mask.
The vif index ends up being passed down to the hardware as a BSS index
WCID attribute in mt76x02_mac_wcid_setup.
We would have to run some tests with multiple AP interfaces, bringing up
secondary interfaces in a different order to see if there are any
regressions there if the BSS index no longer matches the MAC address
based index.

- Felix

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 1/7] mt76x02: use mask for vifs
  2019-01-28  8:41                     ` Felix Fietkau
@ 2019-01-28  9:02                       ` Stanislaw Gruszka
  2019-01-28 11:16                         ` Stanislaw Gruszka
  0 siblings, 1 reply; 27+ messages in thread
From: Stanislaw Gruszka @ 2019-01-28  9:02 UTC (permalink / raw)
  To: Felix Fietkau; +Cc: Lorenzo Bianconi, linux-wireless

On Mon, Jan 28, 2019 at 09:41:45AM +0100, Felix Fietkau wrote:
> >> Moreover I am a little worried about tpt regressions with this patch.
> >> Are you sure that if you use complete different mac addresses on a multivif scenario
> >> you can get the same tpt on all the interfaces? Could you please provide some
> >> tpt results?
> > 
> > How exactly posted patch can cause tpt regression ?
> > 
> > Posted patch just add possibility to configure HW MAC address
> > by this:
> > 
> > iw dev wlan0 del
> > iw phy phy0 interface add wlan0 type managed addr 00:11:22:33:44:55
> > 
> > what is feature of mt76x2u. Patch just extend that possibly to other
> > mt76x02 devices and allow to remove custom mt76x2u add_interfacea
> > callback.
> The main part that could cause issues is that you're changing the way
> that the vif index is calculated. Without the patch, it's calculated
> from the MAC address in a way consistent with what the hardware expects.
> With the patch, it's just allocated from a mask.
> The vif index ends up being passed down to the hardware as a BSS index
> WCID attribute in mt76x02_mac_wcid_setup.
> We would have to run some tests with multiple AP interfaces, bringing up
> secondary interfaces in a different order to see if there are any
> regressions there if the BSS index no longer matches the MAC address
> based index.

Ok, that objection make sense.  I'll check that.

Regards
Stanislaw

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 1/7] mt76x02: use mask for vifs
  2019-01-28  9:02                       ` Stanislaw Gruszka
@ 2019-01-28 11:16                         ` Stanislaw Gruszka
  2019-01-28 12:29                           ` Felix Fietkau
  0 siblings, 1 reply; 27+ messages in thread
From: Stanislaw Gruszka @ 2019-01-28 11:16 UTC (permalink / raw)
  To: Felix Fietkau; +Cc: Lorenzo Bianconi, linux-wireless

On Mon, Jan 28, 2019 at 10:02:01AM +0100, Stanislaw Gruszka wrote:
> On Mon, Jan 28, 2019 at 09:41:45AM +0100, Felix Fietkau wrote:
> > >> Moreover I am a little worried about tpt regressions with this patch.
> > >> Are you sure that if you use complete different mac addresses on a multivif scenario
> > >> you can get the same tpt on all the interfaces? Could you please provide some
> > >> tpt results?
> > > 
> > > How exactly posted patch can cause tpt regression ?
> > > 
> > > Posted patch just add possibility to configure HW MAC address
> > > by this:
> > > 
> > > iw dev wlan0 del
> > > iw phy phy0 interface add wlan0 type managed addr 00:11:22:33:44:55
> > > 
> > > what is feature of mt76x2u. Patch just extend that possibly to other
> > > mt76x02 devices and allow to remove custom mt76x2u add_interfacea
> > > callback.
> > The main part that could cause issues is that you're changing the way
> > that the vif index is calculated. Without the patch, it's calculated
> > from the MAC address in a way consistent with what the hardware expects.
> > With the patch, it's just allocated from a mask.
> > The vif index ends up being passed down to the hardware as a BSS index
> > WCID attribute in mt76x02_mac_wcid_setup.
> > We would have to run some tests with multiple AP interfaces, bringing up
> > secondary interfaces in a different order to see if there are any
> > regressions there if the BSS index no longer matches the MAC address
> > based index.
> 
> Ok, that objection make sense.  I'll check that.

I'm not sure if I'm doing something wrong or current code is
wrong. But when I configure multi bssid's is hostapd.conf like this:

02:aa:bb:cc:dd:e0
06:aa:bb:cc:dd:e0
0a:aa:bb:cc:dd:e0

hostapd fail with "Too many bits in the BSSID mask" error . To make hostapd
work, I have configure bssid's like this:

02:aa:bb:cc:dd:e0
02:aa:bb:cc:dd:e4
02:aa:bb:cc:dd:e8

But this ends up with the same index in mt76 for diffrent vif's. Seems like
calculating of the index should be fixed by:

        if (vif->addr[0] & BIT(1))
                idx = 1 + (((dev->mt76.macaddr[5] ^ vif->addr[5]) >> 2) & 7);

Regards
Stanislaw

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 1/7] mt76x02: use mask for vifs
  2019-01-28 11:16                         ` Stanislaw Gruszka
@ 2019-01-28 12:29                           ` Felix Fietkau
  2019-01-28 13:04                             ` Stanislaw Gruszka
  0 siblings, 1 reply; 27+ messages in thread
From: Felix Fietkau @ 2019-01-28 12:29 UTC (permalink / raw)
  To: Stanislaw Gruszka; +Cc: Lorenzo Bianconi, linux-wireless

On 2019-01-28 12:16, Stanislaw Gruszka wrote:
> On Mon, Jan 28, 2019 at 10:02:01AM +0100, Stanislaw Gruszka wrote:
>> On Mon, Jan 28, 2019 at 09:41:45AM +0100, Felix Fietkau wrote:
>> > >> Moreover I am a little worried about tpt regressions with this patch.
>> > >> Are you sure that if you use complete different mac addresses on a multivif scenario
>> > >> you can get the same tpt on all the interfaces? Could you please provide some
>> > >> tpt results?
>> > > 
>> > > How exactly posted patch can cause tpt regression ?
>> > > 
>> > > Posted patch just add possibility to configure HW MAC address
>> > > by this:
>> > > 
>> > > iw dev wlan0 del
>> > > iw phy phy0 interface add wlan0 type managed addr 00:11:22:33:44:55
>> > > 
>> > > what is feature of mt76x2u. Patch just extend that possibly to other
>> > > mt76x02 devices and allow to remove custom mt76x2u add_interfacea
>> > > callback.
>> > The main part that could cause issues is that you're changing the way
>> > that the vif index is calculated. Without the patch, it's calculated
>> > from the MAC address in a way consistent with what the hardware expects.
>> > With the patch, it's just allocated from a mask.
>> > The vif index ends up being passed down to the hardware as a BSS index
>> > WCID attribute in mt76x02_mac_wcid_setup.
>> > We would have to run some tests with multiple AP interfaces, bringing up
>> > secondary interfaces in a different order to see if there are any
>> > regressions there if the BSS index no longer matches the MAC address
>> > based index.
>> 
>> Ok, that objection make sense.  I'll check that.
> 
> I'm not sure if I'm doing something wrong or current code is
> wrong. But when I configure multi bssid's is hostapd.conf like this:
> 
> 02:aa:bb:cc:dd:e0
> 06:aa:bb:cc:dd:e0
> 0a:aa:bb:cc:dd:e0
> 
> hostapd fail with "Too many bits in the BSSID mask" error . To make hostapd
> work, I have configure bssid's like this:
Do you have a bssid mask set? I don't think the current code does that.
Also, in OpenWrt, I didn't see any issue like that.

> 02:aa:bb:cc:dd:e0
> 02:aa:bb:cc:dd:e4
> 02:aa:bb:cc:dd:e8
> 
> But this ends up with the same index in mt76 for diffrent vif's. Seems like
> calculating of the index should be fixed by:
> 
>         if (vif->addr[0] & BIT(1))
>                 idx = 1 + (((dev->mt76.macaddr[5] ^ vif->addr[5]) >> 2) & 7);
This MAC adddress allocation scheme will cause problems if you have
multiple devices next to each other that have consecutive MAC addresses.

While it may sound unlikely, I do know people that encountered this
issue (though with QCA based hardware), and it took us quite a while to
figure out what was messing up their network ;)

- Felix

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 1/7] mt76x02: use mask for vifs
  2019-01-28 12:29                           ` Felix Fietkau
@ 2019-01-28 13:04                             ` Stanislaw Gruszka
  0 siblings, 0 replies; 27+ messages in thread
From: Stanislaw Gruszka @ 2019-01-28 13:04 UTC (permalink / raw)
  To: Felix Fietkau; +Cc: Lorenzo Bianconi, linux-wireless

On Mon, Jan 28, 2019 at 01:29:27PM +0100, Felix Fietkau wrote:
> On 2019-01-28 12:16, Stanislaw Gruszka wrote:
> > On Mon, Jan 28, 2019 at 10:02:01AM +0100, Stanislaw Gruszka wrote:
> >> On Mon, Jan 28, 2019 at 09:41:45AM +0100, Felix Fietkau wrote:
> >> > >> Moreover I am a little worried about tpt regressions with this patch.
> >> > >> Are you sure that if you use complete different mac addresses on a multivif scenario
> >> > >> you can get the same tpt on all the interfaces? Could you please provide some
> >> > >> tpt results?
> >> > > 
> >> > > How exactly posted patch can cause tpt regression ?
> >> > > 
> >> > > Posted patch just add possibility to configure HW MAC address
> >> > > by this:
> >> > > 
> >> > > iw dev wlan0 del
> >> > > iw phy phy0 interface add wlan0 type managed addr 00:11:22:33:44:55
> >> > > 
> >> > > what is feature of mt76x2u. Patch just extend that possibly to other
> >> > > mt76x02 devices and allow to remove custom mt76x2u add_interfacea
> >> > > callback.
> >> > The main part that could cause issues is that you're changing the way
> >> > that the vif index is calculated. Without the patch, it's calculated
> >> > from the MAC address in a way consistent with what the hardware expects.
> >> > With the patch, it's just allocated from a mask.
> >> > The vif index ends up being passed down to the hardware as a BSS index
> >> > WCID attribute in mt76x02_mac_wcid_setup.
> >> > We would have to run some tests with multiple AP interfaces, bringing up
> >> > secondary interfaces in a different order to see if there are any
> >> > regressions there if the BSS index no longer matches the MAC address
> >> > based index.
> >> 
> >> Ok, that objection make sense.  I'll check that.
> > 
> > I'm not sure if I'm doing something wrong or current code is
> > wrong. But when I configure multi bssid's is hostapd.conf like this:
> > 
> > 02:aa:bb:cc:dd:e0
> > 06:aa:bb:cc:dd:e0
> > 0a:aa:bb:cc:dd:e0
> > 
> > hostapd fail with "Too many bits in the BSSID mask" error . To make hostapd
> > work, I have configure bssid's like this:
> Do you have a bssid mask set? I don't think the current code does that.
> Also, in OpenWrt, I didn't see any issue like that.

Not sure if there is bssid mask option , seems hostapd calculate that
from provided bssid= fields. However I realized there is

use_driver_iface_addr=1

and that make things work as expected.

Thanks
Stanislaw

^ permalink raw reply	[flat|nested] 27+ messages in thread

end of thread, other threads:[~2019-01-28 13:08 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-24 15:44 [PATCH 0/7] mt76x02: Beacon support for USB Stanislaw Gruszka
2019-01-24 15:44 ` [PATCH 1/7] mt76x02: use mask for vifs Stanislaw Gruszka
2019-01-24 16:12   ` Lorenzo Bianconi
2019-01-24 16:20     ` Stanislaw Gruszka
2019-01-24 16:35       ` Lorenzo Bianconi
2019-01-24 22:20         ` Lorenzo Bianconi
2019-01-25  8:25           ` Stanislaw Gruszka
2019-01-25  9:02             ` Lorenzo Bianconi
2019-01-25  9:06               ` Stanislaw Gruszka
2019-01-25  9:47               ` Stanislaw Gruszka
2019-01-25 10:25                 ` Lorenzo Bianconi
2019-01-25 12:41                   ` Stanislaw Gruszka
2019-01-28  8:41                     ` Felix Fietkau
2019-01-28  9:02                       ` Stanislaw Gruszka
2019-01-28 11:16                         ` Stanislaw Gruszka
2019-01-28 12:29                           ` Felix Fietkau
2019-01-28 13:04                             ` Stanislaw Gruszka
2019-01-24 15:44 ` [PATCH 2/7] mt76x02: use commmon add interface for mt76x2u Stanislaw Gruszka
2019-01-24 15:44 ` [PATCH 3/7] mt76x02: initialize mutli bss mode when set up address Stanislaw Gruszka
2019-01-24 15:44 ` [PATCH 4/7] mt76x02: minor beaconing init changes Stanislaw Gruszka
2019-01-24 22:32   ` Lorenzo Bianconi
2019-01-24 15:44 ` [PATCH 5/7] mt76x02: init beacon config for mt76x2u Stanislaw Gruszka
2019-01-24 22:33   ` Lorenzo Bianconi
2019-01-24 15:44 ` [PATCH 6/7] mt76: beaconing fixes for USB Stanislaw Gruszka
2019-01-24 22:50   ` Lorenzo Bianconi
2019-01-28  8:30     ` Stanislaw Gruszka
2019-01-24 15:44 ` [PATCH 7/7] mt76x02: enable support for IBSS, AP and MESH Stanislaw Gruszka

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.