wifi: mt76: mt762x: extend mt76_connac_mcu_sta_basic_tlv for per-link STA
authorSean Wang <sean.wang@mediatek.com>
Thu, 13 Jun 2024 03:02:31 +0000 (20:02 -0700)
committerFelix Fietkau <nbd@nbd.name>
Tue, 9 Jul 2024 21:01:57 +0000 (23:01 +0200)
Extend mt76_connac_mcu_sta_basic_tlv with the per-link STA configuration.

The patch we created is a prerequisite to enable the MLO function in the
driver. It is purely a refactoring patch so the functionality should
remain unchanged.

Co-developed-by: Ming Yen Hsieh <mingyen.hsieh@mediatek.com>
Signed-off-by: Ming Yen Hsieh <mingyen.hsieh@mediatek.com>
Co-developed-by: Deren Wu <deren.wu@mediatek.com>
Signed-off-by: Deren Wu <deren.wu@mediatek.com>
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Link: https://patch.msgid.link/20240613030241.5771-38-sean.wang@kernel.org
Signed-off-by: Felix Fietkau <nbd@nbd.name>
drivers/net/wireless/mediatek/mt76/mt7615/mcu.c
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h
drivers/net/wireless/mediatek/mt76/mt7915/mcu.c
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
drivers/net/wireless/mediatek/mt76/mt7996/mcu.c

index 792ae41f7c69b0a4b1470a2f1fdb3eb2d5d507c8..d50d967828be0d3bb4ef9757e04b7ad90dd4bec5 100644 (file)
@@ -842,6 +842,7 @@ mt7615_mcu_wtbl_sta_add(struct mt7615_phy *phy, struct ieee80211_vif *vif,
 {
        struct mt7615_vif *mvif = (struct mt7615_vif *)vif->drv_priv;
        struct sk_buff *skb, *sskb, *wskb = NULL;
+       struct ieee80211_link_sta *link_sta;
        struct mt7615_dev *dev = phy->dev;
        struct wtbl_req_hdr *wtbl_hdr;
        struct mt7615_sta *msta;
@@ -849,6 +850,7 @@ mt7615_mcu_wtbl_sta_add(struct mt7615_phy *phy, struct ieee80211_vif *vif,
        int cmd, err;
 
        msta = sta ? (struct mt7615_sta *)sta->drv_priv : &mvif->sta;
+       link_sta = sta ? &sta->deflink : NULL;
 
        sskb = mt76_connac_mcu_alloc_sta_req(&dev->mt76, &mvif->mt76,
                                             &msta->wcid);
@@ -861,8 +863,8 @@ mt7615_mcu_wtbl_sta_add(struct mt7615_phy *phy, struct ieee80211_vif *vif,
                else
                        mvif->sta_added = true;
        }
-       mt76_connac_mcu_sta_basic_tlv(&dev->mt76, sskb, vif, sta, enable,
-                                     new_entry);
+       mt76_connac_mcu_sta_basic_tlv(&dev->mt76, sskb, vif, link_sta,
+                                     enable, new_entry);
        if (enable && sta)
                mt76_connac_mcu_sta_tlv(phy->mt76, sskb, sta, vif, 0,
                                        MT76_STA_INFO_STATE_ASSOC);
index 8e9078342429e6ec16e6197354727aca557ed486..4e3c8af98fe7c3dfa3c0cdf8618036d8bcc0a046 100644 (file)
@@ -370,7 +370,7 @@ EXPORT_SYMBOL_GPL(mt76_connac_mcu_bss_omac_tlv);
 
 void mt76_connac_mcu_sta_basic_tlv(struct mt76_dev *dev, struct sk_buff *skb,
                                   struct ieee80211_vif *vif,
-                                  struct ieee80211_sta *sta,
+                                  struct ieee80211_link_sta *link_sta,
                                   bool enable, bool newly)
 {
        struct sta_rec_basic *basic;
@@ -390,7 +390,7 @@ void mt76_connac_mcu_sta_basic_tlv(struct mt76_dev *dev, struct sk_buff *skb,
                basic->conn_state = CONN_STATE_DISCONNECT;
        }
 
-       if (!sta) {
+       if (!link_sta) {
                basic->conn_type = cpu_to_le32(CONNECTION_INFRA_BC);
 
                if (vif->type == NL80211_IFTYPE_STATION &&
@@ -411,7 +411,7 @@ void mt76_connac_mcu_sta_basic_tlv(struct mt76_dev *dev, struct sk_buff *skb,
                else
                        conn_type = CONNECTION_INFRA_STA;
                basic->conn_type = cpu_to_le32(conn_type);
-               basic->aid = cpu_to_le16(sta->aid);
+               basic->aid = cpu_to_le16(link_sta->sta->aid);
                break;
        case NL80211_IFTYPE_STATION:
                if (vif->p2p && !is_mt7921(dev))
@@ -423,15 +423,15 @@ void mt76_connac_mcu_sta_basic_tlv(struct mt76_dev *dev, struct sk_buff *skb,
                break;
        case NL80211_IFTYPE_ADHOC:
                basic->conn_type = cpu_to_le32(CONNECTION_IBSS_ADHOC);
-               basic->aid = cpu_to_le16(sta->aid);
+               basic->aid = cpu_to_le16(link_sta->sta->aid);
                break;
        default:
                WARN_ON(1);
                break;
        }
 
-       memcpy(basic->peer_addr, sta->addr, ETH_ALEN);
-       basic->qos = sta->wme;
+       memcpy(basic->peer_addr, link_sta->addr, ETH_ALEN);
+       basic->qos = link_sta->sta->wme;
 }
 EXPORT_SYMBOL_GPL(mt76_connac_mcu_sta_basic_tlv);
 
@@ -1046,6 +1046,7 @@ int mt76_connac_mcu_sta_cmd(struct mt76_phy *phy,
                            struct mt76_sta_cmd_info *info)
 {
        struct mt76_vif *mvif = (struct mt76_vif *)info->vif->drv_priv;
+       struct ieee80211_link_sta *link_sta;
        struct mt76_dev *dev = phy->dev;
        struct wtbl_req_hdr *wtbl_hdr;
        struct tlv *sta_wtbl;
@@ -1055,9 +1056,11 @@ int mt76_connac_mcu_sta_cmd(struct mt76_phy *phy,
        if (IS_ERR(skb))
                return PTR_ERR(skb);
 
+       link_sta = info->sta ? &info->sta->deflink : NULL;
        if (info->sta || !info->offload_fw)
-               mt76_connac_mcu_sta_basic_tlv(dev, skb, info->vif, info->sta,
-                                             info->enable, info->newly);
+               mt76_connac_mcu_sta_basic_tlv(dev, skb, info->vif,
+                                             link_sta, info->enable,
+                                             info->newly);
        if (info->sta && info->enable)
                mt76_connac_mcu_sta_tlv(phy, skb, info->sta,
                                        info->vif, info->rcpi,
index d4488b9cca464bced4aa79a8007339c07569e3ee..e636b033b87eb8e413dd7a6cb53010a352a0673d 100644 (file)
@@ -1886,8 +1886,8 @@ int mt76_connac_mcu_set_channel_domain(struct mt76_phy *phy);
 int mt76_connac_mcu_set_vif_ps(struct mt76_dev *dev, struct ieee80211_vif *vif);
 void mt76_connac_mcu_sta_basic_tlv(struct mt76_dev *dev, struct sk_buff *skb,
                                   struct ieee80211_vif *vif,
-                                  struct ieee80211_sta *sta, bool enable,
-                                  bool newly);
+                                  struct ieee80211_link_sta *link_sta,
+                                  bool enable, bool newly);
 void mt76_connac_mcu_wtbl_generic_tlv(struct mt76_dev *dev, struct sk_buff *skb,
                                      struct ieee80211_vif *vif,
                                      struct ieee80211_sta *sta, void *sta_wtbl,
index 590ee510eb7c79f1a25149311c0f3e1d74122154..2185cd24e2e1cd8e098e502bc03a25ab712e8674 100644 (file)
@@ -1656,11 +1656,13 @@ int mt7915_mcu_add_sta(struct mt7915_dev *dev, struct ieee80211_vif *vif,
                       struct ieee80211_sta *sta, bool enable)
 {
        struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv;
+       struct ieee80211_link_sta *link_sta;
        struct mt7915_sta *msta;
        struct sk_buff *skb;
        int ret;
 
        msta = sta ? (struct mt7915_sta *)sta->drv_priv : &mvif->sta;
+       link_sta = sta ? &sta->deflink : NULL;
 
        skb = mt76_connac_mcu_alloc_sta_req(&dev->mt76, &mvif->mt76,
                                            &msta->wcid);
@@ -1668,7 +1670,7 @@ int mt7915_mcu_add_sta(struct mt7915_dev *dev, struct ieee80211_vif *vif,
                return PTR_ERR(skb);
 
        /* starec basic */
-       mt76_connac_mcu_sta_basic_tlv(&dev->mt76, skb, vif, sta, enable,
+       mt76_connac_mcu_sta_basic_tlv(&dev->mt76, skb, vif, link_sta, enable,
                                      !rcu_access_pointer(dev->mt76.wcid[msta->wcid.idx]));
        if (!enable)
                goto out;
index 80b735cfbdc788b3368be9a80bec63f28626e6f4..bf2afaf4c0dca3830051e86dd67807fb34038b3a 100644 (file)
@@ -1645,7 +1645,7 @@ mt7925_mcu_sta_cmd(struct mt76_phy *phy,
 
        if (info->link_sta || !info->offload_fw)
                mt76_connac_mcu_sta_basic_tlv(dev, skb, info->vif,
-                                             info->link_sta->sta,
+                                             info->link_sta,
                                              info->enable, info->newly);
        if (info->link_sta && info->enable) {
                mt7925_mcu_sta_phy_tlv(skb, info->vif, info->link_sta);
index 15905c0bfa8ad1385dc5a98c23f6259a30daf3b3..2e4fa9f48dfbeeb4477e3ce97c4d835549a81300 100644 (file)
@@ -2157,11 +2157,13 @@ int mt7996_mcu_add_sta(struct mt7996_dev *dev, struct ieee80211_vif *vif,
                       struct ieee80211_sta *sta, bool enable, bool newly)
 {
        struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv;
+       struct ieee80211_link_sta *link_sta;
        struct mt7996_sta *msta;
        struct sk_buff *skb;
        int ret;
 
        msta = sta ? (struct mt7996_sta *)sta->drv_priv : &mvif->sta;
+       link_sta = sta ? &sta->deflink : NULL;
 
        skb = __mt76_connac_mcu_alloc_sta_req(&dev->mt76, &mvif->mt76,
                                              &msta->wcid,
@@ -2170,7 +2172,8 @@ int mt7996_mcu_add_sta(struct mt7996_dev *dev, struct ieee80211_vif *vif,
                return PTR_ERR(skb);
 
        /* starec basic */
-       mt76_connac_mcu_sta_basic_tlv(&dev->mt76, skb, vif, sta, enable, newly);
+       mt76_connac_mcu_sta_basic_tlv(&dev->mt76, skb, vif, link_sta,
+                                     enable, newly);
 
        if (!enable)
                goto out;