public inbox for linux-wireless@vger.kernel.org
 help / color / mirror / Atom feed
From: Ping-Ke Shih <pkshih@realtek.com>
To: Shengyu Qu <wiagn233@outlook.com>, "nbd@nbd.name" <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>,
	"johannes@sipsolutions.net" <johannes@sipsolutions.net>,
	"matthias.bgg@gmail.com" <matthias.bgg@gmail.com>,
	"angelogioacchino.delregno@collabora.com"
	<angelogioacchino.delregno@collabora.com>,
	"miriam.rachel.korenblit@intel.com"
	<miriam.rachel.korenblit@intel.com>,
	"nicolas.cavallari@green-communications.fr"
	<nicolas.cavallari@green-communications.fr>,
	"howard-yh.hsu@mediatek.com" <howard-yh.hsu@mediatek.com>,
	"greearb@candelatech.com" <greearb@candelatech.com>,
	"christophe.jaillet@wanadoo.fr" <christophe.jaillet@wanadoo.fr>,
	"benjamin-jw.lin@mediatek.com" <benjamin-jw.lin@mediatek.com>,
	"mingyen.hsieh@mediatek.com" <mingyen.hsieh@mediatek.com>,
	"quic_adisi@quicinc.com" <quic_adisi@quicinc.com>,
	"deren.wu@mediatek.com" <deren.wu@mediatek.com>,
	"chui-hao.chiu@mediatek.com" <chui-hao.chiu@mediatek.com>,
	"gustavoars@kernel.org" <gustavoars@kernel.org>,
	"bo.jiao@mediatek.com" <bo.jiao@mediatek.com>,
	"sujuan.chen@mediatek.com" <sujuan.chen@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>,
	"linux-mediatek@lists.infradead.org"
	<linux-mediatek@lists.infradead.org>
Subject: RE: [PATCH v8] wifi: mt76: mt7915: add wds support when wed is enabled
Date: Thu, 6 Mar 2025 02:27:20 +0000	[thread overview]
Message-ID: <c56c9714c754451a8255ece79353da2b@realtek.com> (raw)
In-Reply-To: <TYCPR01MB84374EEAC0DDDA4223B8997298CB2@TYCPR01MB8437.jpnprd01.prod.outlook.com>

Shengyu Qu <wiagn233@outlook.com> wrote:

[...]

> @@ -1271,6 +1278,10 @@ 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;
> +       struct ieee80211_sta *pre_sta;
> +       u8 flags = MT76_WED_DEFAULT;
> +       int temp_idx;

In general 'temp' is short for temperature. 'tmp' is preferred.

> 
>         if (enabled)
>                 set_bit(MT_WCID_FLAG_4ADDR, &msta->wcid.flags);
> @@ -1280,6 +1291,30 @@ static void mt7915_sta_set_4addr(struct ieee80211_hw *hw,
>         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));

Seemingly, kmemdup() = kzalloc() + memmove().

> +
> +               flags = test_bit(MT_WCID_FLAG_4ADDR, &msta->wcid.flags) ?
> +                       MT76_WED_WDS_ACTIVE : MT76_WED_ACTIVE;
> +
> +               temp_idx = __mt76_wcid_alloc(dev->mt76.wcid_mask, MT7915_WTBL_STA, flags);

Since __mt76_wcid_alloc() could return -1 for error case, shouldn't you handle that?

> +               ((struct mt7915_sta *)pre_sta->drv_priv)->wcid.idx = (u16)temp_idx;

Define a local `struct mt7915_sta *pre_msta = (struct mt7915_sta *)pre_sta->drv_priv`
ahead. This statement would be simpler. Just `pre_msta-> wcid.idx = (u16)temp_idx`,
but casting of '(u16)' is still not very preferred.

> +               mt7915_mac_sta_add(&dev->mt76, 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 = (u16)temp_idx;
> +               rcu_assign_pointer(dev->mt76.wcid[temp_idx], NULL);
> +
> +               synchronize_rcu();
> +               mt7915_mac_sta_remove(&dev->mt76, vif, pre_sta);
> +               kfree(pre_sta);
> +       }
> +
>         mt76_connac_mcu_wtbl_update_hdr_trans(&dev->mt76, vif, sta);
>  }
> 

[...]


  reply	other threads:[~2025-03-06  2:28 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-05 11:09 [PATCH v8] wifi: mt76: mt7915: add wds support when wed is enabled Shengyu Qu
2025-03-06  2:27 ` Ping-Ke Shih [this message]
2025-03-06 18:07   ` Shengyu Qu

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=c56c9714c754451a8255ece79353da2b@realtek.com \
    --to=pkshih@realtek.com \
    --cc=angelogioacchino.delregno@collabora.com \
    --cc=benjamin-jw.lin@mediatek.com \
    --cc=bo.jiao@mediatek.com \
    --cc=christophe.jaillet@wanadoo.fr \
    --cc=chui-hao.chiu@mediatek.com \
    --cc=deren.wu@mediatek.com \
    --cc=greearb@candelatech.com \
    --cc=gustavoars@kernel.org \
    --cc=howard-yh.hsu@mediatek.com \
    --cc=johannes@sipsolutions.net \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=lorenzo@kernel.org \
    --cc=matthias.bgg@gmail.com \
    --cc=mingyen.hsieh@mediatek.com \
    --cc=miriam.rachel.korenblit@intel.com \
    --cc=nbd@nbd.name \
    --cc=nicolas.cavallari@green-communications.fr \
    --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 \
    --cc=wiagn233@outlook.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