mt76: mt7915: rely on mt76_connac_mcu_wtbl_generic_tlv
authorLorenzo Bianconi <lorenzo@kernel.org>
Thu, 23 Dec 2021 12:07:36 +0000 (13:07 +0100)
committerFelix Fietkau <nbd@nbd.name>
Thu, 3 Feb 2022 12:57:57 +0000 (13:57 +0100)
Rely on mt76_connac_mcu_wtbl_generic_tlv routine in mt7915 and remove
duplicated code.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c
drivers/net/wireless/mediatek/mt76/mt7915/mcu.c

index 14bfbbb..b25f4ab 100644 (file)
@@ -530,7 +530,7 @@ void mt76_connac_mcu_wtbl_generic_tlv(struct mt76_dev *dev,
                generic->muar_idx = mvif->omac_idx;
                generic->qos = sta->wme;
        } else {
-               if (is_mt7921(dev) &&
+               if ((is_mt7921(dev) || is_mt7915(dev)) &&
                    vif->type == NL80211_IFTYPE_STATION)
                        memcpy(generic->peer_addr, vif->bss_conf.bssid,
                               ETH_ALEN);
@@ -548,7 +548,7 @@ void mt76_connac_mcu_wtbl_generic_tlv(struct mt76_dev *dev,
        rx->rca2 = 1;
        rx->rv = 1;
 
-       if (is_mt7921(dev))
+       if (is_mt7921(dev) || is_mt7915(dev))
                return;
 
        tlv = mt76_connac_mcu_add_nested_tlv(skb, WTBL_SPE, sizeof(*spe),
index ef81b3f..03deec4 100644 (file)
@@ -770,48 +770,6 @@ int mt7915_mcu_add_rx_ba(struct mt7915_dev *dev,
 }
 
 static void
-mt7915_mcu_wtbl_generic_tlv(struct sk_buff *skb, struct ieee80211_vif *vif,
-                           struct ieee80211_sta *sta, void *sta_wtbl,
-                           void *wtbl_tlv)
-{
-       struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv;
-       struct wtbl_generic *generic;
-       struct wtbl_rx *rx;
-       struct tlv *tlv;
-
-       tlv = mt76_connac_mcu_add_nested_tlv(skb, WTBL_GENERIC,
-                                            sizeof(*generic),
-                                            wtbl_tlv, sta_wtbl);
-       generic = (struct wtbl_generic *)tlv;
-
-       if (sta) {
-               if (vif->type == NL80211_IFTYPE_STATION)
-                       generic->partial_aid = cpu_to_le16(vif->bss_conf.aid);
-               else
-                       generic->partial_aid = cpu_to_le16(sta->aid);
-               memcpy(generic->peer_addr, sta->addr, ETH_ALEN);
-               generic->muar_idx = mvif->mt76.omac_idx;
-               generic->qos = sta->wme;
-       } else {
-               /* use BSSID in station mode */
-               if (vif->type == NL80211_IFTYPE_STATION)
-                       memcpy(generic->peer_addr, vif->bss_conf.bssid,
-                              ETH_ALEN);
-               else
-                       eth_broadcast_addr(generic->peer_addr);
-
-               generic->muar_idx = 0xe;
-       }
-
-       tlv = mt76_connac_mcu_add_nested_tlv(skb, WTBL_RX, sizeof(*rx),
-                                            wtbl_tlv, sta_wtbl);
-       rx = (struct wtbl_rx *)tlv;
-       rx->rca1 = sta ? vif->type != NL80211_IFTYPE_AP : 1;
-       rx->rca2 = 1;
-       rx->rv = 1;
-}
-
-static void
 mt7915_mcu_sta_basic_tlv(struct sk_buff *skb, struct ieee80211_vif *vif,
                         struct ieee80211_sta *sta, bool enable)
 {
@@ -1249,7 +1207,8 @@ mt7915_mcu_sta_wtbl_tlv(struct mt7915_dev *dev, struct sk_buff *skb,
        if (IS_ERR(wtbl_hdr))
                return PTR_ERR(wtbl_hdr);
 
-       mt7915_mcu_wtbl_generic_tlv(skb, vif, sta, tlv, wtbl_hdr);
+       mt76_connac_mcu_wtbl_generic_tlv(&dev->mt76, skb, vif, sta, tlv,
+                                        wtbl_hdr);
        mt7915_mcu_wtbl_hdr_trans_tlv(skb, vif, sta, tlv, wtbl_hdr);
 
        if (sta)