Search Linux Wireless

Re: [PATCH 1/7] mt76x02: use mask for vifs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> 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@xxxxxxxxxx>
> > > ---
> > >  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



[Index of Archives]     [Linux Host AP]     [ATH6KL]     [Linux Wireless Personal Area Network]     [Linux Bluetooth]     [Wireless Regulations]     [Linux Netdev]     [Kernel Newbies]     [Linux Kernel]     [IDE]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite Hiking]     [MIPS Linux]     [ARM Linux]     [Linux RAID]

  Powered by Linux