]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
wifi: mt76: mt792x: add struct mt792x_chanctx
authorDeren Wu <deren.wu@mediatek.com>
Thu, 13 Jun 2024 03:01:57 +0000 (20:01 -0700)
committerFelix Fietkau <nbd@nbd.name>
Tue, 9 Jul 2024 21:01:47 +0000 (23:01 +0200)
We are introducing a new structure, mt792x_chanctx, to quickly identify
the linked BSS it is working on. This eliminates the need to search in
mt7921_ctx_iter() or mt7925_ctx_iter() when the channel context changes.

Co-developed-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Deren Wu <deren.wu@mediatek.com>
Link: https://patch.msgid.link/20240613030241.5771-4-sean.wang@kernel.org
Signed-off-by: Felix Fietkau <nbd@nbd.name>
drivers/net/wireless/mediatek/mt76/mt7921/main.c
drivers/net/wireless/mediatek/mt76/mt7925/main.c
drivers/net/wireless/mediatek/mt76/mt792x.h
drivers/net/wireless/mediatek/mt76/mt792x_core.c

index f83cb45957d28f853e4cbfb225776b41157df547..5dd9a7507f0b6b92d7b79138abb947eebeef83ef 100644 (file)
@@ -1346,32 +1346,27 @@ mt7921_remove_chanctx(struct ieee80211_hw *hw,
 {
 }
 
-static void mt7921_ctx_iter(void *priv, u8 *mac,
-                           struct ieee80211_vif *vif)
-{
-       struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
-       struct ieee80211_chanctx_conf *ctx = priv;
-
-       if (ctx != mvif->bss_conf.mt76.ctx)
-               return;
-
-       if (vif->type == NL80211_IFTYPE_MONITOR)
-               mt7921_mcu_config_sniffer(mvif, ctx);
-       else
-               mt76_connac_mcu_uni_set_chctx(mvif->phy->mt76, &mvif->bss_conf.mt76, ctx);
-}
-
 static void
 mt7921_change_chanctx(struct ieee80211_hw *hw,
                      struct ieee80211_chanctx_conf *ctx,
                      u32 changed)
 {
+       struct mt792x_chanctx *mctx = (struct mt792x_chanctx *)ctx->drv_priv;
        struct mt792x_phy *phy = mt792x_hw_phy(hw);
+       struct ieee80211_vif *vif;
+       struct mt792x_vif *mvif;
+
+       if (!mctx->bss_conf)
+               return;
+
+       mvif = container_of(mctx->bss_conf, struct mt792x_vif, bss_conf);
+       vif = container_of((void *)mvif, struct ieee80211_vif, drv_priv);
 
        mt792x_mutex_acquire(phy->dev);
-       ieee80211_iterate_active_interfaces(phy->mt76->hw,
-                                           IEEE80211_IFACE_ITER_ACTIVE,
-                                           mt7921_ctx_iter, ctx);
+       if (vif->type == NL80211_IFTYPE_MONITOR)
+               mt7921_mcu_config_sniffer(mvif, ctx);
+       else
+               mt76_connac_mcu_uni_set_chctx(mvif->phy->mt76, &mvif->bss_conf.mt76, ctx);
        mt792x_mutex_release(phy->dev);
 }
 
index 504c2ecc38453992e4b6aee0bd74330b084f712c..91edbe076c22754772fd4ce1c79a13a2e2c77389 100644 (file)
@@ -1354,34 +1354,29 @@ mt7925_remove_chanctx(struct ieee80211_hw *hw,
 {
 }
 
-static void mt7925_ctx_iter(void *priv, u8 *mac,
-                           struct ieee80211_vif *vif)
+static void
+mt7925_change_chanctx(struct ieee80211_hw *hw,
+                     struct ieee80211_chanctx_conf *ctx,
+                     u32 changed)
 {
-       struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
-       struct ieee80211_chanctx_conf *ctx = priv;
+       struct mt792x_chanctx *mctx = (struct mt792x_chanctx *)ctx->drv_priv;
+       struct mt792x_phy *phy = mt792x_hw_phy(hw);
+       struct ieee80211_vif *vif;
+       struct mt792x_vif *mvif;
 
-       if (ctx != mvif->bss_conf.mt76.ctx)
+       if (!mctx->bss_conf)
                return;
 
+       mvif = container_of(mctx->bss_conf, struct mt792x_vif, bss_conf);
+       vif = container_of((void *)mvif, struct ieee80211_vif, drv_priv);
+
+       mt792x_mutex_acquire(phy->dev);
        if (vif->type == NL80211_IFTYPE_MONITOR) {
                mt7925_mcu_set_sniffer(mvif->phy->dev, vif, true);
                mt7925_mcu_config_sniffer(mvif, ctx);
        } else {
                mt7925_mcu_set_chctx(mvif->phy->mt76, &mvif->bss_conf.mt76, ctx);
        }
-}
-
-static void
-mt7925_change_chanctx(struct ieee80211_hw *hw,
-                     struct ieee80211_chanctx_conf *ctx,
-                     u32 changed)
-{
-       struct mt792x_phy *phy = mt792x_hw_phy(hw);
-
-       mt792x_mutex_acquire(phy->dev);
-       ieee80211_iterate_active_interfaces(phy->mt76->hw,
-                                           IEEE80211_IFACE_ITER_ACTIVE,
-                                           mt7925_ctx_iter, ctx);
        mt792x_mutex_release(phy->dev);
 }
 
index 97865404444d7f297c52bd3d4467ff4d0a0d62d2..eee872aa010804f25b0cc70297445f91b383dedd 100644 (file)
@@ -102,6 +102,10 @@ struct mt792x_sta {
 
 DECLARE_EWMA(rssi, 10, 8);
 
+struct mt792x_chanctx {
+       struct mt792x_bss_conf *bss_conf;
+};
+
 struct mt792x_bss_conf {
        struct mt76_vif mt76; /* must be first */
        struct ewma_rssi rssi;
index dbe98d4dbf9437276ea87f89233a1be4a3adc854..4d0e2def1c1db05d1e5430fa25e9a60659af1dd5 100644 (file)
@@ -261,11 +261,13 @@ int mt792x_assign_vif_chanctx(struct ieee80211_hw *hw,
                              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);
 
        mutex_lock(&dev->mt76.mutex);
        mvif->bss_conf.mt76.ctx = ctx;
+       mctx->bss_conf = &mvif->bss_conf;
        mutex_unlock(&dev->mt76.mutex);
 
        return 0;
@@ -277,10 +279,12 @@ void mt792x_unassign_vif_chanctx(struct ieee80211_hw *hw,
                                 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);
 
        mutex_lock(&dev->mt76.mutex);
+       mctx->bss_conf = NULL;
        mvif->bss_conf.mt76.ctx = NULL;
        mutex_unlock(&dev->mt76.mutex);
 }
@@ -556,6 +560,7 @@ int mt792x_init_wiphy(struct ieee80211_hw *hw)
 
        hw->sta_data_size = sizeof(struct mt792x_sta);
        hw->vif_data_size = sizeof(struct mt792x_vif);
+       hw->chanctx_data_size = sizeof(struct mt792x_chanctx);
 
        if (dev->fw_features & MT792x_FW_CAP_CNM) {
                wiphy->flags |= WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL;