All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] mt7601u: update mac addr if different from eeprom one
@ 2018-02-08 22:08 Lorenzo Bianconi
  2018-02-08 22:08 ` [PATCH 1/2] mt7601u: move mt7601u_set_macaddr in mac related code Lorenzo Bianconi
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Lorenzo Bianconi @ 2018-02-08 22:08 UTC (permalink / raw)
  To: kubakici; +Cc: linux-wireless

Lorenzo Bianconi (2):
  mt7601u: move mt7601u_set_macaddr in mac related code
  mt7601u: set device mac address in mt7601u_add_interface()

 drivers/net/wireless/mediatek/mt7601u/eeprom.c | 24 ++----------------------
 drivers/net/wireless/mediatek/mt7601u/mac.c    | 16 ++++++++++++++++
 drivers/net/wireless/mediatek/mt7601u/mac.h    |  1 +
 drivers/net/wireless/mediatek/mt7601u/main.c   |  3 +++
 4 files changed, 22 insertions(+), 22 deletions(-)

-- 
2.14.3

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

* [PATCH 1/2] mt7601u: move mt7601u_set_macaddr in mac related code
  2018-02-08 22:08 [PATCH 0/2] mt7601u: update mac addr if different from eeprom one Lorenzo Bianconi
@ 2018-02-08 22:08 ` Lorenzo Bianconi
  2018-02-28 14:57   ` [1/2] " Kalle Valo
  2018-02-08 22:08 ` [PATCH 2/2] mt7601u: set device mac address in mt7601u_add_interface() Lorenzo Bianconi
  2018-02-09 17:57 ` [PATCH 0/2] mt7601u: update mac addr if different from eeprom one Jakub Kicinski
  2 siblings, 1 reply; 8+ messages in thread
From: Lorenzo Bianconi @ 2018-02-08 22:08 UTC (permalink / raw)
  To: kubakici; +Cc: linux-wireless

Remove static qualifier from mt7601u_set_macaddr routine and move it
in mac related code in order to be used to properly support vif with
different mac address respect to the default one

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
---
 drivers/net/wireless/mediatek/mt7601u/eeprom.c | 24 ++----------------------
 drivers/net/wireless/mediatek/mt7601u/mac.c    | 16 ++++++++++++++++
 drivers/net/wireless/mediatek/mt7601u/mac.h    |  1 +
 3 files changed, 19 insertions(+), 22 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt7601u/eeprom.c b/drivers/net/wireless/mediatek/mt7601u/eeprom.c
index da6faea092d6..05d729be0c65 100644
--- a/drivers/net/wireless/mediatek/mt7601u/eeprom.c
+++ b/drivers/net/wireless/mediatek/mt7601u/eeprom.c
@@ -19,6 +19,7 @@
 #include <asm/unaligned.h>
 #include "mt7601u.h"
 #include "eeprom.h"
+#include "mac.h"
 
 static bool
 field_valid(u8 val)
@@ -134,27 +135,6 @@ mt7601u_set_chip_cap(struct mt7601u_dev *dev, u8 *eeprom)
 			"Error: device has more than 1 RX/TX stream!\n");
 }
 
-static int
-mt7601u_set_macaddr(struct mt7601u_dev *dev, const u8 *eeprom)
-{
-	const void *src = eeprom + MT_EE_MAC_ADDR;
-
-	ether_addr_copy(dev->macaddr, src);
-
-	if (!is_valid_ether_addr(dev->macaddr)) {
-		eth_random_addr(dev->macaddr);
-		dev_info(dev->dev,
-			 "Invalid MAC address, using random address %pM\n",
-			 dev->macaddr);
-	}
-
-	mt76_wr(dev, MT_MAC_ADDR_DW0, get_unaligned_le32(dev->macaddr));
-	mt76_wr(dev, MT_MAC_ADDR_DW1, get_unaligned_le16(dev->macaddr + 4) |
-		FIELD_PREP(MT_MAC_ADDR_DW1_U2ME_MASK, 0xff));
-
-	return 0;
-}
-
 static void mt7601u_set_channel_target_power(struct mt7601u_dev *dev,
 					     u8 *eeprom, u8 max_pwr)
 {
@@ -400,7 +380,7 @@ mt7601u_eeprom_init(struct mt7601u_dev *dev)
 	dev_info(dev->dev, "EEPROM ver:%02hhx fae:%02hhx\n",
 		 eeprom[MT_EE_VERSION_EE], eeprom[MT_EE_VERSION_FAE]);
 
-	mt7601u_set_macaddr(dev, eeprom);
+	mt7601u_set_macaddr(dev, eeprom + MT_EE_MAC_ADDR);
 	mt7601u_set_chip_cap(dev, eeprom);
 	mt7601u_set_channel_power(dev, eeprom);
 	mt7601u_set_country_reg(dev, eeprom);
diff --git a/drivers/net/wireless/mediatek/mt7601u/mac.c b/drivers/net/wireless/mediatek/mt7601u/mac.c
index d6dc59bb00df..4d3077941138 100644
--- a/drivers/net/wireless/mediatek/mt7601u/mac.c
+++ b/drivers/net/wireless/mediatek/mt7601u/mac.c
@@ -16,6 +16,22 @@
 #include "trace.h"
 #include <linux/etherdevice.h>
 
+void mt7601u_set_macaddr(struct mt7601u_dev *dev, const u8 *addr)
+{
+	ether_addr_copy(dev->macaddr, addr);
+
+	if (!is_valid_ether_addr(dev->macaddr)) {
+		eth_random_addr(dev->macaddr);
+		dev_info(dev->dev,
+			 "Invalid MAC address, using random address %pM\n",
+			 dev->macaddr);
+	}
+
+	mt76_wr(dev, MT_MAC_ADDR_DW0, get_unaligned_le32(dev->macaddr));
+	mt76_wr(dev, MT_MAC_ADDR_DW1, get_unaligned_le16(dev->macaddr + 4) |
+		FIELD_PREP(MT_MAC_ADDR_DW1_U2ME_MASK, 0xff));
+}
+
 static void
 mt76_mac_process_tx_rate(struct ieee80211_tx_rate *txrate, u16 rate)
 {
diff --git a/drivers/net/wireless/mediatek/mt7601u/mac.h b/drivers/net/wireless/mediatek/mt7601u/mac.h
index 2c22d63c63a2..b7aa24656d0e 100644
--- a/drivers/net/wireless/mediatek/mt7601u/mac.h
+++ b/drivers/net/wireless/mediatek/mt7601u/mac.h
@@ -174,5 +174,6 @@ u16 mt76_mac_tx_rate_val(struct mt7601u_dev *dev,
 struct mt76_tx_status
 mt7601u_mac_fetch_tx_status(struct mt7601u_dev *dev);
 void mt76_send_tx_status(struct mt7601u_dev *dev, struct mt76_tx_status *stat);
+void mt7601u_set_macaddr(struct mt7601u_dev *dev, const u8 *addr);
 
 #endif
-- 
2.14.3

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

* [PATCH 2/2] mt7601u: set device mac address in mt7601u_add_interface()
  2018-02-08 22:08 [PATCH 0/2] mt7601u: update mac addr if different from eeprom one Lorenzo Bianconi
  2018-02-08 22:08 ` [PATCH 1/2] mt7601u: move mt7601u_set_macaddr in mac related code Lorenzo Bianconi
@ 2018-02-08 22:08 ` Lorenzo Bianconi
  2018-02-08 23:01   ` Jakub Kicinski
  2018-02-09 17:57 ` [PATCH 0/2] mt7601u: update mac addr if different from eeprom one Jakub Kicinski
  2 siblings, 1 reply; 8+ messages in thread
From: Lorenzo Bianconi @ 2018-02-08 22:08 UTC (permalink / raw)
  To: kubakici; +Cc: linux-wireless

If mac80211 adds a vif with a different mac address respect to
the eeprom one, the device will not be able to connect to the ap
since the hw address has not been updated.
Fix the issue updating hw mac address in mt7601u_add_interface routine

BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=1516935
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
---
 drivers/net/wireless/mediatek/mt7601u/main.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/wireless/mediatek/mt7601u/main.c b/drivers/net/wireless/mediatek/mt7601u/main.c
index 43ebd460ba86..3c9ea40d9584 100644
--- a/drivers/net/wireless/mediatek/mt7601u/main.c
+++ b/drivers/net/wireless/mediatek/mt7601u/main.c
@@ -64,6 +64,9 @@ static int mt7601u_add_interface(struct ieee80211_hw *hw,
 	 */
 	mvif->idx = idx;
 
+	if (!ether_addr_equal(dev->macaddr, vif->addr))
+		mt7601u_set_macaddr(dev, vif->addr);
+
 	if (dev->wcid_mask[wcid / BITS_PER_LONG] & BIT(wcid % BITS_PER_LONG))
 		return -ENOSPC;
 	dev->wcid_mask[wcid / BITS_PER_LONG] |= BIT(wcid % BITS_PER_LONG);
-- 
2.14.3

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

* Re: [PATCH 2/2] mt7601u: set device mac address in mt7601u_add_interface()
  2018-02-08 22:08 ` [PATCH 2/2] mt7601u: set device mac address in mt7601u_add_interface() Lorenzo Bianconi
@ 2018-02-08 23:01   ` Jakub Kicinski
  2018-02-09  9:49     ` Lorenzo Bianconi
  0 siblings, 1 reply; 8+ messages in thread
From: Jakub Kicinski @ 2018-02-08 23:01 UTC (permalink / raw)
  To: Lorenzo Bianconi; +Cc: linux-wireless

On Thu,  8 Feb 2018 23:08:09 +0100, Lorenzo Bianconi wrote:
> If mac80211 adds a vif with a different mac address respect to
> the eeprom one, the device will not be able to connect to the ap
> since the hw address has not been updated.
> Fix the issue updating hw mac address in mt7601u_add_interface routine
> 
> BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=1516935
> Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
> ---
>  drivers/net/wireless/mediatek/mt7601u/main.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/net/wireless/mediatek/mt7601u/main.c b/drivers/net/wireless/mediatek/mt7601u/main.c
> index 43ebd460ba86..3c9ea40d9584 100644
> --- a/drivers/net/wireless/mediatek/mt7601u/main.c
> +++ b/drivers/net/wireless/mediatek/mt7601u/main.c
> @@ -64,6 +64,9 @@ static int mt7601u_add_interface(struct ieee80211_hw *hw,
>  	 */
>  	mvif->idx = idx;
>  
> +	if (!ether_addr_equal(dev->macaddr, vif->addr))
> +		mt7601u_set_macaddr(dev, vif->addr);
> +
>  	if (dev->wcid_mask[wcid / BITS_PER_LONG] & BIT(wcid % BITS_PER_LONG))
>  		return -ENOSPC;
>  	dev->wcid_mask[wcid / BITS_PER_LONG] |= BIT(wcid % BITS_PER_LONG);

Sorry, my recollection of mac80211 code is waning, but can't we have
more than one vif as long as they are on the same channel?

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

* Re: [PATCH 2/2] mt7601u: set device mac address in mt7601u_add_interface()
  2018-02-08 23:01   ` Jakub Kicinski
@ 2018-02-09  9:49     ` Lorenzo Bianconi
  2018-02-09 17:56       ` Jakub Kicinski
  0 siblings, 1 reply; 8+ messages in thread
From: Lorenzo Bianconi @ 2018-02-09  9:49 UTC (permalink / raw)
  To: Jakub Kicinski; +Cc: linux-wireless

On Feb 08, Jakub Kicinski wrote:
> On Thu,  8 Feb 2018 23:08:09 +0100, Lorenzo Bianconi wrote:
> > If mac80211 adds a vif with a different mac address respect to
> > the eeprom one, the device will not be able to connect to the ap
> > since the hw address has not been updated.
> > Fix the issue updating hw mac address in mt7601u_add_interface routine
> > 
> > BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=1516935
> > Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
> > ---
> >  drivers/net/wireless/mediatek/mt7601u/main.c | 3 +++
> >  1 file changed, 3 insertions(+)
> > 
> > diff --git a/drivers/net/wireless/mediatek/mt7601u/main.c b/drivers/net/wireless/mediatek/mt7601u/main.c
> > index 43ebd460ba86..3c9ea40d9584 100644
> > --- a/drivers/net/wireless/mediatek/mt7601u/main.c
> > +++ b/drivers/net/wireless/mediatek/mt7601u/main.c
> > @@ -64,6 +64,9 @@ static int mt7601u_add_interface(struct ieee80211_hw *hw,
> >  	 */
> >  	mvif->idx = idx;
> >  
> > +	if (!ether_addr_equal(dev->macaddr, vif->addr))
> > +		mt7601u_set_macaddr(dev, vif->addr);
> > +
> >  	if (dev->wcid_mask[wcid / BITS_PER_LONG] & BIT(wcid % BITS_PER_LONG))
> >  		return -ENOSPC;
> >  	dev->wcid_mask[wcid / BITS_PER_LONG] |= BIT(wcid % BITS_PER_LONG);
> 
> Sorry, my recollection of mac80211 code is waning, but can't we have
> more than one vif as long as they are on the same channel?

Hi Jakub,

yep, you are right, but according to my understanding (please correct me if
it is wrong) current implementation supports just one interface in sta mode
(i.e. mvif->idx is always 0) so my patchset just fixes the issue highlighted
in the bugzilla since I do not know if the hw supports multiple concurrent vifs
in client mode. If so, I can extend the support to multiple client vifs if it is
a way to properly configure the rx filters to allow reception from multiple mac
addresses.

Regards,
Lorenzo

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

* Re: [PATCH 2/2] mt7601u: set device mac address in mt7601u_add_interface()
  2018-02-09  9:49     ` Lorenzo Bianconi
@ 2018-02-09 17:56       ` Jakub Kicinski
  0 siblings, 0 replies; 8+ messages in thread
From: Jakub Kicinski @ 2018-02-09 17:56 UTC (permalink / raw)
  To: Lorenzo Bianconi; +Cc: linux-wireless

On Fri, 9 Feb 2018 10:49:21 +0100, Lorenzo Bianconi wrote:
> On Feb 08, Jakub Kicinski wrote:
> > On Thu,  8 Feb 2018 23:08:09 +0100, Lorenzo Bianconi wrote:  
> > > If mac80211 adds a vif with a different mac address respect to
> > > the eeprom one, the device will not be able to connect to the ap
> > > since the hw address has not been updated.
> > > Fix the issue updating hw mac address in mt7601u_add_interface routine
> > > 
> > > BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=1516935
> > > Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
> > > ---
> > >  drivers/net/wireless/mediatek/mt7601u/main.c | 3 +++
> > >  1 file changed, 3 insertions(+)
> > > 
> > > diff --git a/drivers/net/wireless/mediatek/mt7601u/main.c b/drivers/net/wireless/mediatek/mt7601u/main.c
> > > index 43ebd460ba86..3c9ea40d9584 100644
> > > --- a/drivers/net/wireless/mediatek/mt7601u/main.c
> > > +++ b/drivers/net/wireless/mediatek/mt7601u/main.c
> > > @@ -64,6 +64,9 @@ static int mt7601u_add_interface(struct ieee80211_hw *hw,
> > >  	 */
> > >  	mvif->idx = idx;
> > >  
> > > +	if (!ether_addr_equal(dev->macaddr, vif->addr))
> > > +		mt7601u_set_macaddr(dev, vif->addr);
> > > +
> > >  	if (dev->wcid_mask[wcid / BITS_PER_LONG] & BIT(wcid % BITS_PER_LONG))
> > >  		return -ENOSPC;
> > >  	dev->wcid_mask[wcid / BITS_PER_LONG] |= BIT(wcid % BITS_PER_LONG);  
> > 
> > Sorry, my recollection of mac80211 code is waning, but can't we have
> > more than one vif as long as they are on the same channel?  
> 
> Hi Jakub,
> 
> yep, you are right, but according to my understanding (please correct me if
> it is wrong) current implementation supports just one interface in sta mode
> (i.e. mvif->idx is always 0) so my patchset just fixes the issue highlighted
> in the bugzilla since I do not know if the hw supports multiple concurrent vifs
> in client mode. If so, I can extend the support to multiple client vifs if it is
> a way to properly configure the rx filters to allow reception from multiple mac
> addresses.

Ah, you're probably right, perhaps we would have one vif but multiple
stas.

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

* Re: [PATCH 0/2] mt7601u: update mac addr if different from eeprom one
  2018-02-08 22:08 [PATCH 0/2] mt7601u: update mac addr if different from eeprom one Lorenzo Bianconi
  2018-02-08 22:08 ` [PATCH 1/2] mt7601u: move mt7601u_set_macaddr in mac related code Lorenzo Bianconi
  2018-02-08 22:08 ` [PATCH 2/2] mt7601u: set device mac address in mt7601u_add_interface() Lorenzo Bianconi
@ 2018-02-09 17:57 ` Jakub Kicinski
  2 siblings, 0 replies; 8+ messages in thread
From: Jakub Kicinski @ 2018-02-09 17:57 UTC (permalink / raw)
  To: Lorenzo Bianconi; +Cc: linux-wireless

On Thu,  8 Feb 2018 23:08:07 +0100, Lorenzo Bianconi wrote:
> Lorenzo Bianconi (2):
>   mt7601u: move mt7601u_set_macaddr in mac related code
>   mt7601u: set device mac address in mt7601u_add_interface()
> 
>  drivers/net/wireless/mediatek/mt7601u/eeprom.c | 24 ++----------------------
>  drivers/net/wireless/mediatek/mt7601u/mac.c    | 16 ++++++++++++++++
>  drivers/net/wireless/mediatek/mt7601u/mac.h    |  1 +
>  drivers/net/wireless/mediatek/mt7601u/main.c   |  3 +++
>  4 files changed, 22 insertions(+), 22 deletions(-)
> 

Acked-by: Jakub Kicinski <kubakici@wp.pl>

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

* Re: [1/2] mt7601u: move mt7601u_set_macaddr in mac related code
  2018-02-08 22:08 ` [PATCH 1/2] mt7601u: move mt7601u_set_macaddr in mac related code Lorenzo Bianconi
@ 2018-02-28 14:57   ` Kalle Valo
  0 siblings, 0 replies; 8+ messages in thread
From: Kalle Valo @ 2018-02-28 14:57 UTC (permalink / raw)
  To: Lorenzo Bianconi; +Cc: kubakici, linux-wireless

Lorenzo Bianconi <lorenzo.bianconi@redhat.com> wrote:

> Remove static qualifier from mt7601u_set_macaddr routine and move it
> in mac related code in order to be used to properly support vif with
> different mac address respect to the default one
> 
> Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>

2 patches applied to wireless-drivers-next.git, thanks.

e96826bde3db mt7601u: move mt7601u_set_macaddr in mac related code
032a552e8dc9 mt7601u: set device mac address in mt7601u_add_interface()

-- 
https://patchwork.kernel.org/patch/10208071/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches

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

end of thread, other threads:[~2018-02-28 14:57 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-08 22:08 [PATCH 0/2] mt7601u: update mac addr if different from eeprom one Lorenzo Bianconi
2018-02-08 22:08 ` [PATCH 1/2] mt7601u: move mt7601u_set_macaddr in mac related code Lorenzo Bianconi
2018-02-28 14:57   ` [1/2] " Kalle Valo
2018-02-08 22:08 ` [PATCH 2/2] mt7601u: set device mac address in mt7601u_add_interface() Lorenzo Bianconi
2018-02-08 23:01   ` Jakub Kicinski
2018-02-09  9:49     ` Lorenzo Bianconi
2018-02-09 17:56       ` Jakub Kicinski
2018-02-09 17:57 ` [PATCH 0/2] mt7601u: update mac addr if different from eeprom one Jakub Kicinski

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.