]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
wifi: mt76: mt7925: add mt7925_[assign,unassign]_vif_chanctx
authorSean Wang <sean.wang@mediatek.com>
Sat, 6 Jul 2024 08:28:05 +0000 (01:28 -0700)
committerFelix Fietkau <nbd@nbd.name>
Tue, 9 Jul 2024 21:02:07 +0000 (23:02 +0200)
add mt7925_[assign,unassign]_vif_chanctx to assign and unassign
chanctx to the specific link configuration. If the chctx is not
pass in the parameter, we will look up the channel information
from link_conf->chanreq.oper.

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/15261879a16cb12674d6dea7703410baa6883799.1720248331.git.sean.wang@kernel.org
Signed-off-by: Felix Fietkau <nbd@nbd.name>
drivers/net/wireless/mediatek/mt76/mt7925/main.c
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
drivers/net/wireless/mediatek/mt76/mt7925/mcu.h

index c25822e3a9432ef4bbddb4133c8b59bcbec29a4c..0627ef208641dbe5bff66c9db352cc8fd9c7c1f2 100644 (file)
@@ -1730,8 +1730,13 @@ mt7925_change_chanctx(struct ieee80211_hw *hw,
                        mconf = &mvif->bss_conf;
                }
 
-               if (mconf)
-                       mt7925_mcu_set_chctx(mvif->phy->mt76, &mconf->mt76, ctx);
+               if (mconf) {
+                       struct ieee80211_bss_conf *link_conf;
+
+                       link_conf = mt792x_vif_to_bss_conf(vif, mconf->link_id);
+                       mt7925_mcu_set_chctx(mvif->phy->mt76, &mconf->mt76,
+                                            link_conf, ctx);
+               }
        }
 
        mt792x_mutex_release(phy->dev);
@@ -1978,6 +1983,68 @@ out:
        return err;
 }
 
+static int mt7925_assign_vif_chanctx(struct ieee80211_hw *hw,
+                                    struct ieee80211_vif *vif,
+                                    struct ieee80211_bss_conf *link_conf,
+                                    struct ieee80211_chanctx_conf *ctx)
+{
+       struct mt792x_chanctx *mctx = (struct mt792x_chanctx *)ctx->drv_priv;
+       struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
+       struct mt792x_dev *dev = mt792x_hw_dev(hw);
+       struct ieee80211_bss_conf *pri_link_conf;
+       struct mt792x_bss_conf *mconf;
+
+       mutex_lock(&dev->mt76.mutex);
+
+       if (ieee80211_vif_is_mld(vif)) {
+               mconf = mt792x_vif_to_link(mvif, link_conf->link_id);
+               pri_link_conf = mt792x_vif_to_bss_conf(vif, mvif->deflink_id);
+
+               if (vif->type == NL80211_IFTYPE_STATION &&
+                   mconf == &mvif->bss_conf)
+                       mt7925_mcu_add_bss_info(&dev->phy, NULL, pri_link_conf,
+                                               NULL, true);
+       } else {
+               mconf = &mvif->bss_conf;
+       }
+
+       mconf->mt76.ctx = ctx;
+       mctx->bss_conf = mconf;
+       mutex_unlock(&dev->mt76.mutex);
+
+       return 0;
+}
+
+static void mt7925_unassign_vif_chanctx(struct ieee80211_hw *hw,
+                                       struct ieee80211_vif *vif,
+                                       struct ieee80211_bss_conf *link_conf,
+                                       struct ieee80211_chanctx_conf *ctx)
+{
+       struct mt792x_chanctx *mctx = (struct mt792x_chanctx *)ctx->drv_priv;
+       struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
+       struct mt792x_dev *dev = mt792x_hw_dev(hw);
+       struct ieee80211_bss_conf *pri_link_conf;
+       struct mt792x_bss_conf *mconf;
+
+       mutex_lock(&dev->mt76.mutex);
+
+       if (ieee80211_vif_is_mld(vif)) {
+               mconf = mt792x_vif_to_link(mvif, link_conf->link_id);
+               pri_link_conf = mt792x_vif_to_bss_conf(vif, mvif->deflink_id);
+
+               if (vif->type == NL80211_IFTYPE_STATION &&
+                   mconf == &mvif->bss_conf)
+                       mt7925_mcu_add_bss_info(&dev->phy, NULL, pri_link_conf,
+                                               NULL, false);
+       } else {
+               mconf = &mvif->bss_conf;
+       }
+
+       mctx->bss_conf = NULL;
+       mconf->mt76.ctx = NULL;
+       mutex_unlock(&dev->mt76.mutex);
+}
+
 const struct ieee80211_ops mt7925_ops = {
        .tx = mt792x_tx,
        .start = mt7925_start,
@@ -2030,8 +2097,8 @@ const struct ieee80211_ops mt7925_ops = {
        .add_chanctx = mt7925_add_chanctx,
        .remove_chanctx = mt7925_remove_chanctx,
        .change_chanctx = mt7925_change_chanctx,
-       .assign_vif_chanctx = mt792x_assign_vif_chanctx,
-       .unassign_vif_chanctx = mt792x_unassign_vif_chanctx,
+       .assign_vif_chanctx = mt7925_assign_vif_chanctx,
+       .unassign_vif_chanctx = mt7925_unassign_vif_chanctx,
        .mgd_prepare_tx = mt7925_mgd_prepare_tx,
        .mgd_complete_tx = mt7925_mgd_complete_tx,
        .vif_cfg_changed = mt7925_vif_cfg_changed,
index 2dbe9362efcf948567d49ecea7a450ae5cd5b794..da3192bd82cdbaf2f13439efb882cc1ec354f58b 100644 (file)
@@ -2083,9 +2083,11 @@ mt7925_mcu_uni_add_beacon_offload(struct mt792x_dev *dev,
 
 static
 void mt7925_mcu_bss_rlm_tlv(struct sk_buff *skb, struct mt76_phy *phy,
+                           struct ieee80211_bss_conf *link_conf,
                            struct ieee80211_chanctx_conf *ctx)
 {
-       struct cfg80211_chan_def *chandef = ctx ? &ctx->def : &phy->chandef;
+       struct cfg80211_chan_def *chandef = ctx ? &ctx->def :
+                                                 &link_conf->chanreq.oper;
        int freq1 = chandef->center_freq1, freq2 = chandef->center_freq2;
        enum nl80211_band band = chandef->chan->band;
        struct bss_rlm_tlv *req;
@@ -2152,6 +2154,7 @@ __mt7925_mcu_alloc_bss_req(struct mt76_dev *dev, struct mt76_vif *mvif, int len)
 }
 
 int mt7925_mcu_set_chctx(struct mt76_phy *phy, struct mt76_vif *mvif,
+                        struct ieee80211_bss_conf *link_conf,
                         struct ieee80211_chanctx_conf *ctx)
 {
        struct sk_buff *skb;
@@ -2161,7 +2164,7 @@ int mt7925_mcu_set_chctx(struct mt76_phy *phy, struct mt76_vif *mvif,
        if (IS_ERR(skb))
                return PTR_ERR(skb);
 
-       mt7925_mcu_bss_rlm_tlv(skb, phy, ctx);
+       mt7925_mcu_bss_rlm_tlv(skb, phy, link_conf, ctx);
 
        return mt76_mcu_skb_send_msg(phy->dev, skb,
                                     MCU_UNI_CMD(BSS_INFO_UPDATE), true);
@@ -2223,7 +2226,8 @@ mt7925_mcu_bss_basic_tlv(struct sk_buff *skb,
 {
        struct ieee80211_vif *vif = link_conf->vif;
        struct mt792x_bss_conf *mconf = mt792x_link_conf_to_mconf(link_conf);
-       struct cfg80211_chan_def *chandef = ctx ? &ctx->def : &phy->chandef;
+       struct cfg80211_chan_def *chandef = ctx ? &ctx->def :
+                                                 &link_conf->chanreq.oper;
        enum nl80211_band band = chandef->chan->band;
        struct mt76_connac_bss_basic_tlv *basic_req;
        struct mt792x_link_sta *mlink;
@@ -2348,7 +2352,8 @@ mt7925_mcu_bss_bmc_tlv(struct sk_buff *skb, struct mt792x_phy *phy,
                       struct ieee80211_chanctx_conf *ctx,
                       struct ieee80211_bss_conf *link_conf)
 {
-       struct cfg80211_chan_def *chandef = ctx ? &ctx->def : &phy->mt76->chandef;
+       struct cfg80211_chan_def *chandef = ctx ? &ctx->def :
+                                                 &link_conf->chanreq.oper;
        struct mt792x_bss_conf *mconf = mt792x_link_conf_to_mconf(link_conf);
        enum nl80211_band band = chandef->chan->band;
        struct mt76_vif *mvif = &mconf->mt76;
@@ -2488,8 +2493,6 @@ int mt7925_mcu_add_bss_info(struct mt792x_phy *phy,
                            int enable)
 {
        struct mt792x_vif *mvif = (struct mt792x_vif *)link_conf->vif->drv_priv;
-       struct mt792x_bss_conf *mconf = mt792x_vif_to_link(mvif,
-                                                          link_conf->link_id);
        struct mt792x_dev *dev = phy->dev;
        struct sk_buff *skb;
 
@@ -2513,7 +2516,7 @@ int mt7925_mcu_add_bss_info(struct mt792x_phy *phy,
                mt7925_mcu_bss_color_tlv(skb, link_conf, enable);
        }
 
-       mt7925_mcu_bss_rlm_tlv(skb, phy->mt76, mconf->mt76.ctx);
+       mt7925_mcu_bss_rlm_tlv(skb, phy->mt76, link_conf, ctx);
 
        return mt76_mcu_skb_send_msg(&dev->mt76, skb,
                                     MCU_UNI_CMD(BSS_INFO_UPDATE), true);
index 7fb46cad915706a42085b01e2e9bd0e15d69c500..6ae5286385d90e9d906b433aea5caff26f547e73 100644 (file)
@@ -623,6 +623,7 @@ int mt7925_mcu_set_deep_sleep(struct mt792x_dev *dev, bool enable);
 int mt7925_mcu_set_channel_domain(struct mt76_phy *phy);
 int mt7925_mcu_set_radio_en(struct mt792x_phy *phy, bool enable);
 int mt7925_mcu_set_chctx(struct mt76_phy *phy, struct mt76_vif *mvif,
+                        struct ieee80211_bss_conf *link_conf,
                         struct ieee80211_chanctx_conf *ctx);
 int mt7925_mcu_set_rate_txpower(struct mt76_phy *phy);
 int mt7925_mcu_update_arp_filter(struct mt76_dev *dev,