From: Qu Shengyu <wiagn233@outlook.com>
To: Felix Fietkau <nbd@nbd.name>,
"lorenzo@kernel.org" <lorenzo@kernel.org>,
"ryder.lee@mediatek.com" <ryder.lee@mediatek.com>,
"shayne.chen@mediatek.com" <shayne.chen@mediatek.com>,
"sean.wang@mediatek.com" <sean.wang@mediatek.com>,
"kvalo@kernel.org" <kvalo@kernel.org>,
"matthias.bgg@gmail.com" <matthias.bgg@gmail.com>,
"angelogioacchino.delregno@collabora.com"
<angelogioacchino.delregno@collabora.com>,
"daniel@makrotopia.org" <daniel@makrotopia.org>,
"miriam.rachel.korenblit@intel.com"
<miriam.rachel.korenblit@intel.com>,
"money.wang@mediatek.com" <money.wang@mediatek.com>,
"StanleyYP.Wang@mediatek.com" <StanleyYP.Wang@mediatek.com>,
"meichia.chiu@mediatek.com" <meichia.chiu@mediatek.com>,
"chui-hao.chiu@mediatek.com" <chui-hao.chiu@mediatek.com>,
"johannes.berg@intel.com" <johannes.berg@intel.com>,
"quic_adisi@quicinc.com" <quic_adisi@quicinc.com>,
"sujuan.chen@mediatek.com" <sujuan.chen@mediatek.com>,
"allen.ye@mediatek.com" <allen.ye@mediatek.com>,
"linux-wireless@vger.kernel.org" <linux-wireless@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>
Cc: Bo Jiao <bo.jiao@mediatek.com>, Qu Shengyu <wiagn233@outlook.com>
Subject: Re: [PATCH v6] wifi: mt76: mt7915: add wds support when wed is enabled
Date: Mon, 2 Dec 2024 08:49:22 +0000 [thread overview]
Message-ID: <TYCPR01MB8437833F5213A2AEBF808FE098352@TYCPR01MB8437.jpnprd01.prod.outlook.com> (raw)
In-Reply-To: <TYCPR01MB843742DF3BB41BAC3B97C3C998982@TYCPR01MB8437.jpnprd01.prod.outlook.com>
Hello Felix,
Sorry to bother but any updates on this? I remember that you’ve agreed to take over this patch on IRC.
Best regards,
Shengyu
> 在 2024年9月9日,00:27,Shengyu Qu <wiagn233@outlook.com> 写道:
>
>
>>
>>> diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/main.c b/drivers/net/wireless/mediatek/mt76/mt7915/main.c
>>> index 049223df9beb1..dc4d87e004a0f 100644
>>> --- a/drivers/net/wireless/mediatek/mt76/mt7915/main.c
>>> +++ b/drivers/net/wireless/mediatek/mt76/mt7915/main.c
>>> @@ -745,8 +745,15 @@ int mt7915_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,
>>> bool ext_phy = mvif->phy != &dev->phy;
>>> int ret, idx;
>>> u32 addr;
>>> + u8 flags = MT76_WED_DEFAULT;
>>> - idx = mt76_wcid_alloc(dev->mt76.wcid_mask, MT7915_WTBL_STA);
>>> + if (mtk_wed_device_active(&dev->mt76.mmio.wed) &&
>>> + !is_mt7915(&dev->mt76)) {
>>> + flags = test_bit(MT_WCID_FLAG_4ADDR, &msta->wcid.flags) ?
>>> + MT76_WED_WDS_ACTIVE : MT76_WED_ACTIVE;
>>> + }
>>> +
>>> + idx = __mt76_wcid_alloc(mdev->wcid_mask, MT7915_WTBL_STA, flags);
>>> if (idx < 0)
>>> return -ENOSPC;
>> I'd prefer to replace the mt76_wcid_alloc flags argument with an explicit start offset argument.
>
> Hi Felix,
>
> I'm not really familiar with mt76 code, just a enthusiast that wants to
> make WDS+WED working. So I'm not sure how to do this correctly... Maybe
> it's better for you to take over this patch, sorry.
>
>>> @@ -1201,12 +1208,27 @@ static void mt7915_sta_set_4addr(struct ieee80211_hw *hw,
>>> {
>>> struct mt7915_dev *dev = mt7915_hw_dev(hw);
>>> struct mt7915_sta *msta = (struct mt7915_sta *)sta->drv_priv;
>>> + int min = MT76_WED_WDS_MIN, max = MT76_WED_WDS_MAX;
>>> if (enabled)
>>> set_bit(MT_WCID_FLAG_4ADDR, &msta->wcid.flags);
>>> else
>>> clear_bit(MT_WCID_FLAG_4ADDR, &msta->wcid.flags);
>>> + if (mtk_wed_device_active(&dev->mt76.mmio.wed) &&
>>> + !is_mt7915(&dev->mt76) &&
>>> + (msta->wcid.idx < min || msta->wcid.idx > max - 1)) {
>>> + struct ieee80211_sta *pre_sta;
>>> +
>>> + pre_sta = kzalloc(sizeof(*sta) + sizeof(*msta), GFP_KERNEL);
>>> + mt76_sta_pre_rcu_remove(hw, vif, sta);
>>> + memmove(pre_sta, sta, sizeof(*sta) + sizeof(*msta));
>>> + mt7915_sta_add(hw, vif, sta);
>>> + synchronize_rcu();
>>> + mt7915_sta_remove(hw, vif, pre_sta);
>>> + kfree(pre_sta);
>>> + }
>>> +
>>> mt76_connac_mcu_wtbl_update_hdr_trans(&dev->mt76, vif, sta);
>>> }
>>>
>> In order to update the code based on my latest changes and to fix potential race conditions on tx/rx packets during the transition, please change to this order:
>> 1. copy the sta
>> 2. allocate a new wcid
>> 3. change the wcid index in the copied sta to the newly allocated wcid
>> 4. call mcu functions on the duplicate sta for creating the new sta entry.
>> 5. use rcu_assign_pointer to point dev->wcid[new_idx] at &msta->wcid
>> 6. swap wcid index between real sta and duplicated sta
>> 7. rcu_assign_pointer(dev->wcid[orig_idx], NULL)
>> 8. synchronize_rcu()
>> 9. call mcu functions to delete the duplicate sta's entry (points to old wcid after the swap)
>> 10. free the duplicated sta
>
> Now, the mt7915_sta_set_4addr function looks like this(__mt76_wcid_alloc
> not modified), do you think it's acceptable?
>
> static void mt7915_sta_set_4addr(struct ieee80211_hw *hw,
> struct ieee80211_vif *vif,
> struct ieee80211_sta *sta,
> bool enabled)
> {
> struct mt7915_dev *dev = mt7915_hw_dev(hw);
> struct mt7915_sta *msta = (struct mt7915_sta *)sta->drv_priv;
> int min = MT76_WED_WDS_MIN, max = MT76_WED_WDS_MAX;
> struct ieee80211_sta *pre_sta;
> u8 flags = MT76_WED_DEFAULT;
> int temp_idx;
>
> if (enabled)
> set_bit(MT_WCID_FLAG_4ADDR, &msta->wcid.flags);
> else
> clear_bit(MT_WCID_FLAG_4ADDR, &msta->wcid.flags);
>
> if (!msta->wcid.sta)
> return;
>
> if (mtk_wed_device_active(&dev->mt76.mmio.wed) &&
> !is_mt7915(&dev->mt76) &&
> (msta->wcid.idx < min || msta->wcid.idx > max - 1)) {
> pre_sta = kzalloc(sizeof(*sta) + sizeof(*msta), GFP_KERNEL);
> memmove(pre_sta, sta, sizeof(*sta) + sizeof(*msta));
> if (mtk_wed_device_active(&dev->mt76.mmio.wed) &&
> !is_mt7915(&dev->mt76)) {
> flags = test_bit(MT_WCID_FLAG_4ADDR, &msta->wcid.flags) ?
> MT76_WED_WDS_ACTIVE : MT76_WED_ACTIVE;
> }
>
> temp_idx = __mt76_wcid_alloc(mdev->wcid_mask, MT7915_WTBL_STA, flags);
> ((struct mt7915_sta *)pre_sta->drv_priv)->wcid.idx = temp_idx;
> mt7915_sta_add(hw, vif, pre_sta);
> rcu_assign_pointer(dev->mt76.wcid[temp_idx], &msta->wcid);
> temp_idx = msta->wcid.idx;
> msta->wcid.idx = ((struct mt7915_sta *)pre_sta->drv_priv)->wcid.idx;
> ((struct mt7915_sta *)pre_sta->drv_priv)->wcid.idx = temp_idx;
> rcu_assign_pointer(dev->mt76.wcid[temp_idx], NULL);
> synchronize_rcu();
> mt7915_sta_remove(hw, vif, pre_sta);
> kfree(pre_sta);
> }
>
> mt76_connac_mcu_wtbl_update_hdr_trans(&dev->mt76, vif, sta);
> }
>
> Best regards,
> Shengyu
>
>> This should allow mgmt tx/rx to work while the sta is being migrated to the new wcid entry.
>> - Felix
> <OpenPGP_0xE3520CC91929C8E7.asc>
prev parent reply other threads:[~2024-12-02 8:49 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-05 12:43 Shengyu Qu
2024-08-14 18:55 ` Shengyu Qu
2024-09-05 12:31 ` Felix Fietkau
2024-09-05 17:10 ` Shengyu Qu
2024-09-05 17:23 ` Felix Fietkau
2024-09-08 16:27 ` Shengyu Qu
2024-12-02 8:49 ` Qu Shengyu [this message]
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=TYCPR01MB8437833F5213A2AEBF808FE098352@TYCPR01MB8437.jpnprd01.prod.outlook.com \
--to=wiagn233@outlook.com \
--cc=StanleyYP.Wang@mediatek.com \
--cc=allen.ye@mediatek.com \
--cc=angelogioacchino.delregno@collabora.com \
--cc=bo.jiao@mediatek.com \
--cc=chui-hao.chiu@mediatek.com \
--cc=daniel@makrotopia.org \
--cc=johannes.berg@intel.com \
--cc=kvalo@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=lorenzo@kernel.org \
--cc=matthias.bgg@gmail.com \
--cc=meichia.chiu@mediatek.com \
--cc=miriam.rachel.korenblit@intel.com \
--cc=money.wang@mediatek.com \
--cc=nbd@nbd.name \
--cc=quic_adisi@quicinc.com \
--cc=ryder.lee@mediatek.com \
--cc=sean.wang@mediatek.com \
--cc=shayne.chen@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®