[PATCH v8] wifi: mt76: mt7915: add wds support when wed is enabled

Shengyu Qu wiagn233 at outlook.com
Thu Mar 6 10:07:42 PST 2025


Hi,

Thanks for reply. I'll change the code in next version.

Best regards,
Shengyu

在 2025/3/6 10:27, Ping-Ke Shih 写道:
> Shengyu Qu <wiagn233 at 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);
>>   }
>>
> 
> [...]
> 

-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_0xE3520CC91929C8E7.asc
Type: application/pgp-keys
Size: 6868 bytes
Desc: OpenPGP public key
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20250307/2c48da54/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_signature.asc
Type: application/pgp-signature
Size: 840 bytes
Desc: OpenPGP digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20250307/2c48da54/attachment.sig>


More information about the linux-arm-kernel mailing list