Search Linux Wireless

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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Shengyu Qu <wiagn233@xxxxxxxxxxx> 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);
>  }
> 

[...]






[Index of Archives]     [Linux Host AP]     [ATH6KL]     [Linux Wireless Personal Area Network]     [Linux Bluetooth]     [Wireless Regulations]     [Linux Netdev]     [Kernel Newbies]     [Linux Kernel]     [IDE]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite Hiking]     [MIPS Linux]     [ARM Linux]     [Linux RAID]

  Powered by Linux