From: Lorenzo Bianconi <lorenzo@kernel.org>
To: Sujuan Chen <sujuan.chen@mediatek.com>
Cc: Felix Fietkau <nbd@nbd.name>,
linux-wireless <linux-wireless@vger.kernel.org>,
Ryder Lee <ryder.lee@mediatek.com>,
Evelyn Tsai <evelyn.tsai@mediatek.com>,
Bo Jiao <bo.jiao@mediatek.com>,
linux-mediatek@lists.infradead.org
Subject: Re: [PATCH] wifi: mt76: mt7915: add wds support when wed is enabled
Date: Mon, 21 Nov 2022 14:42:08 +0100 [thread overview]
Message-ID: <Y3uAMEfCxQhC46Hm@lore-desk> (raw)
In-Reply-To: <af04db938bf9633225c4358058a39aa3be0e218e.1669022945.git.sujuan.chen@mediatek.com>
[-- Attachment #1: Type: text/plain, Size: 5511 bytes --]
[...]
> };
>
> enum mcu_mmps_mode {
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mmio.c b/drivers/net/wireless/mediatek/mt76/mt7915/mmio.c
> index 1fcf34f57a16..d90793d082b8 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7915/mmio.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mmio.c
> @@ -773,6 +773,9 @@ int mt7915_mmio_wed_init(struct mt7915_dev *dev, void *pdev_ptr,
>
> dev->mt76.rx_token_size = wed->wlan.rx_npkt;
>
> + if (!is_mt7915(&dev->mt76))
> + wed->wlan.wcid_512 = true;
I forgot to say this is already in this patch:
https://patchwork.kernel.org/project/linux-wireless/patch/c6a2a58cdd42b47b4c22137a40e357dd74ba8014.1668267241.git.lorenzo@kernel.org/
Regards,
Lorenzo
> +
> if (mtk_wed_device_attach(wed))
> return 0;
>
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/init.c b/drivers/net/wireless/mediatek/mt76/mt7921/init.c
> index 79b8055ce4c4..702ff300f8f7 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7921/init.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt7921/init.c
> @@ -283,7 +283,7 @@ static int mt7921_init_wcid(struct mt7921_dev *dev)
> int idx;
>
> /* Beacon and mgmt frames should occupy wcid 0 */
> - idx = mt76_wcid_alloc(dev->mt76.wcid_mask, MT7921_WTBL_STA - 1);
> + idx = mt76_wcid_alloc(dev->mt76.wcid_mask, MT7921_WTBL_STA - 1, 0);
> if (idx)
> return -ENOSPC;
>
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/main.c b/drivers/net/wireless/mediatek/mt76/mt7921/main.c
> index 41df17efdb3a..3d8771fcb847 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7921/main.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt7921/main.c
> @@ -814,7 +814,7 @@ int mt7921_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,
> struct mt7921_vif *mvif = (struct mt7921_vif *)vif->drv_priv;
> int ret, idx;
>
> - idx = mt76_wcid_alloc(dev->mt76.wcid_mask, MT7921_WTBL_STA - 1);
> + idx = mt76_wcid_alloc(dev->mt76.wcid_mask, MT7921_WTBL_STA - 1, 0);
> if (idx < 0)
> return -ENOSPC;
>
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/init.c b/drivers/net/wireless/mediatek/mt76/mt7996/init.c
> index cd1657e3585d..4cf055040519 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7996/init.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt7996/init.c
> @@ -433,7 +433,7 @@ static int mt7996_init_hardware(struct mt7996_dev *dev)
> return ret;
>
> /* Beacon and mgmt frames should occupy wcid 0 */
> - idx = mt76_wcid_alloc(dev->mt76.wcid_mask, MT7996_WTBL_STA);
> + idx = mt76_wcid_alloc(dev->mt76.wcid_mask, MT7996_WTBL_STA, 0);
> if (idx)
> return -ENOSPC;
>
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/main.c b/drivers/net/wireless/mediatek/mt76/mt7996/main.c
> index 21dea3fa7dc1..fd40b515cc5b 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7996/main.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt7996/main.c
> @@ -579,7 +579,7 @@ int mt7996_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,
> u8 band_idx = mvif->phy->mt76->band_idx;
> int ret, idx;
>
> - idx = mt76_wcid_alloc(dev->mt76.wcid_mask, MT7996_WTBL_STA);
> + idx = mt76_wcid_alloc(dev->mt76.wcid_mask, MT7996_WTBL_STA, 0);
> if (idx < 0)
> return -ENOSPC;
>
> diff --git a/drivers/net/wireless/mediatek/mt76/util.c b/drivers/net/wireless/mediatek/mt76/util.c
> index 581964425468..0850149f4200 100644
> --- a/drivers/net/wireless/mediatek/mt76/util.c
> +++ b/drivers/net/wireless/mediatek/mt76/util.c
> @@ -42,9 +42,14 @@ bool __mt76_poll_msec(struct mt76_dev *dev, u32 offset, u32 mask, u32 val,
> }
> EXPORT_SYMBOL_GPL(__mt76_poll_msec);
>
> -int mt76_wcid_alloc(u32 *mask, int size)
> +int mt76_wcid_alloc(u32 *mask, int size, u8 flag)
> {
> +#define MT76_WED_WDS_MIN 256
> +#define MT76_WED_WDS_CNT 16
> +
> int i, idx = 0, cur;
> + int min = MT76_WED_WDS_MIN;
> + int max = min + MT76_WED_WDS_CNT;
>
> for (i = 0; i < DIV_ROUND_UP(size, 32); i++) {
> idx = ffs(~mask[i]);
> @@ -53,13 +58,46 @@ int mt76_wcid_alloc(u32 *mask, int size)
>
> idx--;
> cur = i * 32 + idx;
> - if (cur >= size)
> +
> + switch (flag) {
> + case MT76_WED_DISABLED:
> + if (cur >= size)
> + goto error;
> +
> break;
> + case MT76_WED_ACTIVE:
> + if (cur >= min && cur < max)
> + continue;
> +
> + if (cur >= size) {
> + u32 end = MT76_WED_WDS_CNT - 1;
> +
> + i = min / 32;
> + idx = ffs(~mask[i] & GENMASK(end, 0));
> + if (!idx)
> + goto error;
> + idx--;
> + cur = min + idx;
> + }
> +
> + break;
> + case MT76_WED_WDS_ACTIVE:
> + if (cur < min)
> + continue;
> + if (cur >= max)
> + goto error;
> +
> + break;
> + default:
> + WARN_ON(1);
> + break;
> + }
>
> mask[i] |= BIT(idx);
> return cur;
> }
>
> +error:
> return -1;
> }
> EXPORT_SYMBOL_GPL(mt76_wcid_alloc);
> diff --git a/drivers/net/wireless/mediatek/mt76/util.h b/drivers/net/wireless/mediatek/mt76/util.h
> index 260965dde94c..c72460e78389 100644
> --- a/drivers/net/wireless/mediatek/mt76/util.h
> +++ b/drivers/net/wireless/mediatek/mt76/util.h
> @@ -27,7 +27,7 @@ enum {
> #define MT76_INCR(_var, _size) \
> (_var = (((_var) + 1) % (_size)))
>
> -int mt76_wcid_alloc(u32 *mask, int size);
> +int mt76_wcid_alloc(u32 *mask, int size, u8 flag);
>
> static inline void
> mt76_wcid_mask_set(u32 *mask, int idx)
> --
> 2.18.0
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
next prev parent reply other threads:[~2022-11-21 13:42 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-21 11:37 [PATCH] wifi: mt76: mt7915: add wds support when wed is enabled Sujuan Chen
2022-11-21 13:29 ` Lorenzo Bianconi
2022-11-22 10:03 ` Sujuan Chen (陈素娟)
2022-12-06 3:17 ` Sujuan Chen (陈素娟)
2022-12-06 3:17 ` Sujuan Chen (陈素娟)
2022-11-21 13:42 ` Lorenzo Bianconi [this message]
2022-11-22 6:27 ` Sujuan Chen (陈素娟)
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=Y3uAMEfCxQhC46Hm@lore-desk \
--to=lorenzo@kernel.org \
--cc=bo.jiao@mediatek.com \
--cc=evelyn.tsai@mediatek.com \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux-wireless@vger.kernel.org \
--cc=nbd@nbd.name \
--cc=ryder.lee@mediatek.com \
--cc=sujuan.chen@mediatek.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 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.