wifi: iwlwifi: mvm: rework debugfs handling
authorJohannes Berg <johannes.berg@intel.com>
Wed, 4 Oct 2023 09:36:23 +0000 (12:36 +0300)
committerJohannes Berg <johannes.berg@intel.com>
Mon, 23 Oct 2023 10:21:47 +0000 (12:21 +0200)
mac80211 added a new callback to add a vif debugfs.
Implement it instead of adding the debugfs directly,
which will make it properly preserved over switching
the vif from non-MLD/MLD and back.

This requires some rework so that we still have the
symlink but trust mac80211 to add/remove the debugfs.

Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://lore.kernel.org/r/20231004123422.818810e242e6.I805a28f9fbef5c52a3a575d04e7a6a909ecf9078@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
drivers/net/wireless/intel/iwlwifi/mvm/debugfs-vif.c
drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
drivers/net/wireless/intel/iwlwifi/mvm/mld-mac80211.c
drivers/net/wireless/intel/iwlwifi/mvm/mvm.h

index cb4ecad..3a42fb3 100644 (file)
@@ -699,19 +699,11 @@ MVM_DEBUGFS_READ_WRITE_FILE_OPS(rx_phyinfo, 10);
 MVM_DEBUGFS_READ_WRITE_FILE_OPS(quota_min, 32);
 MVM_DEBUGFS_READ_FILE_OPS(os_device_timediff);
 
-
-void iwl_mvm_vif_dbgfs_register(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
+void iwl_mvm_vif_add_debugfs(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
 {
+       struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
        struct dentry *dbgfs_dir = vif->debugfs_dir;
        struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
-       char buf[100];
-
-       /*
-        * Check if debugfs directory already exist before creating it.
-        * This may happen when, for example, resetting hw or suspend-resume
-        */
-       if (!dbgfs_dir || mvmvif->dbgfs_dir)
-               return;
 
        mvmvif->dbgfs_dir = debugfs_create_dir("iwlmvm", dbgfs_dir);
        if (IS_ERR_OR_NULL(mvmvif->dbgfs_dir)) {
@@ -737,6 +729,17 @@ void iwl_mvm_vif_dbgfs_register(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
        if (vif->type == NL80211_IFTYPE_STATION && !vif->p2p &&
            mvmvif == mvm->bf_allowed_vif)
                MVM_DEBUGFS_ADD_FILE_VIF(bf_params, mvmvif->dbgfs_dir, 0600);
+}
+
+void iwl_mvm_vif_dbgfs_add_link(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
+{
+       struct dentry *dbgfs_dir = vif->debugfs_dir;
+       struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
+       char buf[100];
+
+       /* this will happen in monitor mode */
+       if (!dbgfs_dir)
+               return;
 
        /*
         * Create symlink for convenience pointing to interface specific
@@ -745,21 +748,16 @@ void iwl_mvm_vif_dbgfs_register(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
         * find
         * netdev:wlan0 -> ../../../ieee80211/phy0/netdev:wlan0/iwlmvm/
         */
-       snprintf(buf, 100, "../../../%pd3/%pd",
-                dbgfs_dir,
-                mvmvif->dbgfs_dir);
+       snprintf(buf, 100, "../../../%pd3/iwlmvm", dbgfs_dir);
 
        mvmvif->dbgfs_slink = debugfs_create_symlink(dbgfs_dir->d_name.name,
                                                     mvm->debugfs_dir, buf);
 }
 
-void iwl_mvm_vif_dbgfs_clean(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
+void iwl_mvm_vif_dbgfs_rm_link(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
 {
        struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
 
        debugfs_remove(mvmvif->dbgfs_slink);
        mvmvif->dbgfs_slink = NULL;
-
-       debugfs_remove_recursive(mvmvif->dbgfs_dir);
-       mvmvif->dbgfs_dir = NULL;
 }
index d342a53..56965d6 100644 (file)
@@ -1580,7 +1580,7 @@ static int iwl_mvm_mac_add_interface(struct ieee80211_hw *hw,
         */
        if (vif->type == NL80211_IFTYPE_AP ||
            vif->type == NL80211_IFTYPE_ADHOC) {
-               iwl_mvm_vif_dbgfs_register(mvm, vif);
+               iwl_mvm_vif_dbgfs_add_link(mvm, vif);
                ret = 0;
                goto out;
        }
@@ -1644,7 +1644,7 @@ static int iwl_mvm_mac_add_interface(struct ieee80211_hw *hw,
                        iwl_mvm_chandef_get_primary_80(&vif->bss_conf.chandef);
        }
 
-       iwl_mvm_vif_dbgfs_register(mvm, vif);
+       iwl_mvm_vif_dbgfs_add_link(mvm, vif);
 
        if (!test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status) &&
            vif->type == NL80211_IFTYPE_STATION && !vif->p2p &&
@@ -1732,7 +1732,7 @@ static bool iwl_mvm_mac_remove_interface_common(struct ieee80211_hw *hw,
        if (vif->bss_conf.ftm_responder)
                memset(&mvm->ftm_resp_stats, 0, sizeof(mvm->ftm_resp_stats));
 
-       iwl_mvm_vif_dbgfs_clean(mvm, vif);
+       iwl_mvm_vif_dbgfs_rm_link(mvm, vif);
 
        /*
         * For AP/GO interface, the tear down of the resources allocated to the
@@ -6324,6 +6324,7 @@ const struct ieee80211_ops iwl_mvm_hw_ops = {
 
        .can_aggregate_in_amsdu = iwl_mvm_mac_can_aggregate,
 #ifdef CONFIG_IWLWIFI_DEBUGFS
+       .vif_add_debugfs = iwl_mvm_vif_add_debugfs,
        .link_sta_add_debugfs = iwl_mvm_link_sta_add_debugfs,
 #endif
        .set_hw_timestamp = iwl_mvm_set_hw_timestamp,
index 6b4b32b..9c943dc 100644 (file)
@@ -107,7 +107,7 @@ static int iwl_mvm_mld_mac_add_interface(struct ieee80211_hw *hw,
                ieee80211_hw_set(mvm->hw, RX_INCLUDES_FCS);
        }
 
-       iwl_mvm_vif_dbgfs_register(mvm, vif);
+       iwl_mvm_vif_dbgfs_add_link(mvm, vif);
 
        if (!test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status) &&
            vif->type == NL80211_IFTYPE_STATION && !vif->p2p &&
@@ -168,7 +168,7 @@ static void iwl_mvm_mld_mac_remove_interface(struct ieee80211_hw *hw,
        if (vif->bss_conf.ftm_responder)
                memset(&mvm->ftm_resp_stats, 0, sizeof(mvm->ftm_resp_stats));
 
-       iwl_mvm_vif_dbgfs_clean(mvm, vif);
+       iwl_mvm_vif_dbgfs_rm_link(mvm, vif);
 
        /* For AP/GO interface, the tear down of the resources allocated to the
         * interface is be handled as part of the stop_ap flow.
@@ -1209,6 +1209,7 @@ const struct ieee80211_ops iwl_mvm_mld_hw_ops = {
        .abort_pmsr = iwl_mvm_abort_pmsr,
 
 #ifdef CONFIG_IWLWIFI_DEBUGFS
+       .vif_add_debugfs = iwl_mvm_vif_add_debugfs,
        .link_sta_add_debugfs = iwl_mvm_link_sta_add_debugfs,
 #endif
        .set_hw_timestamp = iwl_mvm_set_hw_timestamp,
index 74cb2f8..5ec79be 100644 (file)
@@ -2048,18 +2048,19 @@ void iwl_mvm_rx_umac_scan_iter_complete_notif(struct iwl_mvm *mvm,
 /* MVM debugfs */
 #ifdef CONFIG_IWLWIFI_DEBUGFS
 void iwl_mvm_dbgfs_register(struct iwl_mvm *mvm);
-void iwl_mvm_vif_dbgfs_register(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
-void iwl_mvm_vif_dbgfs_clean(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
+void iwl_mvm_vif_add_debugfs(struct ieee80211_hw *hw, struct ieee80211_vif *vif);
+void iwl_mvm_vif_dbgfs_add_link(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
+void iwl_mvm_vif_dbgfs_rm_link(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
 #else
 static inline void iwl_mvm_dbgfs_register(struct iwl_mvm *mvm)
 {
 }
 static inline void
-iwl_mvm_vif_dbgfs_register(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
+iwl_mvm_vif_dbgfs_add_link(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
 {
 }
 static inline void
-iwl_mvm_vif_dbgfs_clean(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
+iwl_mvm_vif_dbgfs_rm_link(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
 {
 }
 #endif /* CONFIG_IWLWIFI_DEBUGFS */