From: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
To: Stanislaw Gruszka <sgruszka@redhat.com>
Cc: Felix Fietkau <nbd@nbd.name>, linux-wireless@vger.kernel.org
Subject: Re: [PATCH v2 1/7] mt76x02: use mask for vifs
Date: Mon, 28 Jan 2019 14:35:39 +0100 [thread overview]
Message-ID: <20190128133537.GB9257@localhost.localdomain> (raw)
In-Reply-To: <1548678108-9526-2-git-send-email-sgruszka@redhat.com>
> Use vif_mask to count interfaces to allow to set mac address in HW
> if there is only one interface and report error if we create
> interface with wrong BSSID resulting in already used index.
>
> Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
> ---
> v2:
> - do not change vif index calculation
> - return error for already used index
>
> drivers/net/wireless/mediatek/mt76/mt76x02.h | 2 ++
> drivers/net/wireless/mediatek/mt76/mt76x02_util.c | 12 +++++++++++-
> 2 files changed, 13 insertions(+), 1 deletion(-)
>
> 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..2e805d5493de 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt76x02_util.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt76x02_util.c
> @@ -292,7 +292,6 @@ mt76x02_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
>
> if (vif->addr[0] & BIT(1))
> idx = 1 + (((dev->mt76.macaddr[0] ^ vif->addr[0]) >> 2) & 7);
> -
> /*
> * Client mode typically only has one configurable BSSID register,
> * which is used for bssidx=0. This is linked to the MAC address.
> @@ -309,6 +308,15 @@ mt76x02_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
> if (vif->type == NL80211_IFTYPE_STATION)
> idx += 8;
>
Maybe we shoud grub dev->mt76.mutex here, since we can have multiple processes trying
to add an interface
> + if (dev->vif_mask & BIT(idx))
> + return -EBUSY;
> +
> + /* Allow to change address in HW if we create first 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 +326,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);
If we are removing the first configured interface, should we have to update
MT_MAC_ADDR_DW{0,1} regs?
Regards,
Lorenzo
> }
> EXPORT_SYMBOL_GPL(mt76x02_remove_interface);
>
> --
> 2.19.2
>
next prev parent reply other threads:[~2019-01-28 13:35 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-28 12:21 [PATCH v2 0/7] mt76x02: Beacon support for USB Stanislaw Gruszka
2019-01-28 12:21 ` [PATCH v2 1/7] mt76x02: use mask for vifs Stanislaw Gruszka
2019-01-28 13:35 ` Lorenzo Bianconi [this message]
2019-01-28 14:23 ` Stanislaw Gruszka
2019-01-28 14:31 ` Lorenzo Bianconi
2019-01-28 12:21 ` [PATCH v2 2/7] mt76x02: use commmon add interface for mt76x2u Stanislaw Gruszka
2019-01-28 12:21 ` [PATCH v2 3/7] mt76x02: initialize mutli bss mode when set up address Stanislaw Gruszka
2019-01-28 12:21 ` [PATCH v2 4/7] mt76x02: minor beaconing init changes Stanislaw Gruszka
2019-01-28 12:21 ` [PATCH v2 5/7] mt76x02: init beacon config for mt76x2u Stanislaw Gruszka
2019-01-28 12:21 ` [PATCH v2 6/7] mt76: beaconing fixes for USB Stanislaw Gruszka
2019-01-28 13:44 ` Lorenzo Bianconi
2019-01-28 12:21 ` [PATCH v2 7/7] mt76x02: enable support for IBSS, AP and MESH Stanislaw Gruszka
2019-01-29 11:47 ` [PATCH v2 0/7] mt76x02: Beacon support for USB Kalle Valo
2019-01-29 11:49 ` Felix Fietkau
2019-01-29 12:07 ` Kalle Valo
2019-01-29 12:10 ` Felix Fietkau
2019-01-29 12:18 ` Kalle Valo
2019-01-29 12:40 ` Lorenzo Bianconi
2019-01-30 8:37 ` Stanislaw Gruszka
2019-01-30 9:16 ` Felix Fietkau
2019-01-30 10:07 ` Stanislaw Gruszka
2019-01-30 15:22 ` Stanislaw Gruszka
2019-02-05 14:58 ` Stanislaw Gruszka
2019-01-30 8:29 ` Stanislaw Gruszka
2019-01-30 9:25 ` Felix Fietkau
2019-01-30 10:27 ` Kalle Valo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190128133537.GB9257@localhost.localdomain \
--to=lorenzo.bianconi@redhat.com \
--cc=linux-wireless@vger.kernel.org \
--cc=nbd@nbd.name \
--cc=sgruszka@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).