mt76: mt7921: introduce mt7921_mcu_sta_add routine
authorLorenzo Bianconi <lorenzo@kernel.org>
Mon, 19 Apr 2021 12:03:00 +0000 (14:03 +0200)
committerFelix Fietkau <nbd@nbd.name>
Wed, 21 Apr 2021 18:55:56 +0000 (20:55 +0200)
mt7921_mcu_sta_add will be used to add and remove wtbl entries.
Create broadcast wtbl entry after AP association

Co-developed-by: Deren Wu <deren.wu@mediatek.com>
Signed-off-by: Deren Wu <deren.wu@mediatek.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
drivers/net/wireless/mediatek/mt76/mt7921/main.c
drivers/net/wireless/mediatek/mt76/mt7921/mcu.c
drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h

index 3bbe731..f4c27aa 100644 (file)
@@ -622,8 +622,10 @@ static void mt7921_bss_info_changed(struct ieee80211_hw *hw,
        if (changed & BSS_CHANGED_PS)
                mt7921_mcu_uni_bss_ps(dev, vif);
 
-       if (changed & BSS_CHANGED_ASSOC)
+       if (changed & BSS_CHANGED_ASSOC) {
+               mt7921_mcu_sta_add(dev, NULL, vif, true);
                mt7921_bss_bcnft_apply(dev, vif, info->assoc);
+       }
 
        if (changed & BSS_CHANGED_ARP_FILTER) {
                struct mt7921_vif *mvif = (struct mt7921_vif *)vif->drv_priv;
@@ -641,15 +643,6 @@ int mt7921_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,
        struct mt7921_dev *dev = container_of(mdev, struct mt7921_dev, mt76);
        struct mt7921_sta *msta = (struct mt7921_sta *)sta->drv_priv;
        struct mt7921_vif *mvif = (struct mt7921_vif *)vif->drv_priv;
-       int rssi = -ewma_rssi_read(&mvif->rssi);
-       struct mt76_sta_cmd_info info = {
-               .sta = sta,
-               .vif = vif,
-               .enable = true,
-               .cmd = MCU_UNI_CMD_STA_REC_UPDATE,
-               .wcid = &msta->wcid,
-               .rcpi = to_rcpi(rssi),
-       };
        int ret, idx;
 
        idx = mt76_wcid_alloc(dev->mt76.wcid_mask, MT7921_WTBL_STA - 1);
@@ -676,7 +669,7 @@ int mt7921_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,
        mt7921_mac_wtbl_update(dev, idx,
                               MT_WTBL_UPDATE_ADM_COUNT_CLEAR);
 
-       ret = mt76_connac_mcu_add_sta_cmd(&dev->mphy, &info);
+       ret = mt7921_mcu_sta_add(dev, sta, vif, true);
        if (ret)
                return ret;
 
@@ -690,18 +683,11 @@ void mt7921_mac_sta_remove(struct mt76_dev *mdev, struct ieee80211_vif *vif,
 {
        struct mt7921_dev *dev = container_of(mdev, struct mt7921_dev, mt76);
        struct mt7921_sta *msta = (struct mt7921_sta *)sta->drv_priv;
-       struct mt76_sta_cmd_info info = {
-               .sta = sta,
-               .vif = vif,
-               .cmd = MCU_UNI_CMD_STA_REC_UPDATE,
-               .wcid = &msta->wcid,
-       };
 
        mt76_connac_free_pending_tx_skbs(&dev->pm, &msta->wcid);
        mt76_connac_pm_wake(&dev->mphy, &dev->pm);
 
-       mt76_connac_mcu_add_sta_cmd(&dev->mphy, &info);
-
+       mt7921_mcu_sta_add(dev, sta, vif, false);
        mt7921_mac_wtbl_update(dev, msta->wcid.idx,
                               MT_WTBL_UPDATE_ADM_COUNT_CLEAR);
 
index 35aaba7..43e3bf8 100644 (file)
@@ -1265,6 +1265,26 @@ int mt7921_mcu_set_bss_pm(struct mt7921_dev *dev, struct ieee80211_vif *vif,
                                 sizeof(req), false);
 }
 
+int mt7921_mcu_sta_add(struct mt7921_dev *dev, struct ieee80211_sta *sta,
+                      struct ieee80211_vif *vif, bool enable)
+{
+       struct mt7921_vif *mvif = (struct mt7921_vif *)vif->drv_priv;
+       int rssi = -ewma_rssi_read(&mvif->rssi);
+       struct mt76_sta_cmd_info info = {
+               .sta = sta,
+               .vif = vif,
+               .enable = enable,
+               .cmd = MCU_UNI_CMD_STA_REC_UPDATE,
+               .rcpi = to_rcpi(rssi),
+       };
+       struct mt7921_sta *msta;
+
+       msta = sta ? (struct mt7921_sta *)sta->drv_priv : NULL;
+       info.wcid = msta ? &msta->wcid : &mvif->sta.wcid;
+
+       return mt76_connac_mcu_add_sta_cmd(&dev->mphy, &info);
+}
+
 int mt7921_mcu_drv_pmctrl(struct mt7921_dev *dev)
 {
        struct mt76_phy *mphy = &dev->mt76.phy;
index aa34597..59862ea 100644 (file)
@@ -257,6 +257,8 @@ int mt7921_mcu_add_key(struct mt7921_dev *dev, struct ieee80211_vif *vif,
                       struct mt7921_sta *msta, struct ieee80211_key_conf *key,
                       enum set_key_cmd cmd);
 int mt7921_set_channel(struct mt7921_phy *phy);
+int mt7921_mcu_sta_add(struct mt7921_dev *dev, struct ieee80211_sta *sta,
+                      struct ieee80211_vif *vif, bool enable);
 int mt7921_mcu_set_chan_info(struct mt7921_phy *phy, int cmd);
 int mt7921_mcu_set_tx(struct mt7921_dev *dev, struct ieee80211_vif *vif);
 int mt7921_mcu_set_eeprom(struct mt7921_dev *dev);