wifi: iwlwifi: mvm: add a per-link debugfs
authorMiri Korenblit <miriam.rachel.korenblit@intel.com>
Wed, 4 Oct 2023 09:36:24 +0000 (12:36 +0300)
committerJohannes Berg <johannes.berg@intel.com>
Mon, 23 Oct 2023 10:21:47 +0000 (12:21 +0200)
Add a per-link debugfs entry in iwlmvm level so we can read/write link
related parameters.
Do it by implementing the link_add_debugfs API introduced by mac80211.

Each entry will have a path like this:
.../netdev:wlan0/link-X/iwlmvm/<file_name>
for each link X.

For non-MLD vifs this callback is called when the original vif
debugfs dir is also created, so handle that case by not creating
the 'iwlmvm' directory again.

Note that we don't have to worry about the cleaning the iwlmvm/*
directory as it is already done by mac80211 when removing the link
(or netdev).

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.6a161f021ae8.Ic8f40f2b4682270c94036e3c11c3996ae34266fa@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/debugfs.h
drivers/net/wireless/intel/iwlwifi/mvm/mld-mac80211.c
drivers/net/wireless/intel/iwlwifi/mvm/mvm.h

index 3a42fb38b32f9a24314769e1ea42d40ef7962b50..e8b881596baf12372f4807d86dd68fb88346744b 100644 (file)
@@ -761,3 +761,49 @@ void iwl_mvm_vif_dbgfs_rm_link(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
        debugfs_remove(mvmvif->dbgfs_slink);
        mvmvif->dbgfs_slink = NULL;
 }
+
+#define MVM_DEBUGFS_WRITE_LINK_FILE_OPS(name, bufsz)                   \
+       _MVM_DEBUGFS_WRITE_FILE_OPS(link_##name, bufsz,                 \
+                                   struct ieee80211_bss_conf)
+#define MVM_DEBUGFS_READ_WRITE_LINK_FILE_OPS(name, bufsz)              \
+       _MVM_DEBUGFS_READ_WRITE_FILE_OPS(link_##name, bufsz,            \
+                                        struct ieee80211_bss_conf)
+#define MVM_DEBUGFS_ADD_LINK_FILE(name, parent, mode)                  \
+       debugfs_create_file(#name, mode, parent, link_conf,             \
+                           &iwl_dbgfs_link_##name##_ops)
+
+static void iwl_mvm_debugfs_add_link_files(struct ieee80211_vif *vif,
+                                          struct ieee80211_bss_conf *link_conf,
+                                          struct dentry *mvm_dir)
+{
+       /* Add per-link files here*/
+}
+
+void iwl_mvm_link_add_debugfs(struct ieee80211_hw *hw,
+                             struct ieee80211_vif *vif,
+                             struct ieee80211_bss_conf *link_conf,
+                             struct dentry *dir)
+{
+       struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
+       struct iwl_mvm *mvm = mvmvif->mvm;
+       unsigned int link_id = link_conf->link_id;
+       struct iwl_mvm_vif_link_info *link_info = mvmvif->link[link_id];
+       struct dentry *mvm_dir;
+
+       if (WARN_ON(!link_info) || !dir)
+               return;
+
+       if (dir == vif->debugfs_dir) {
+               WARN_ON(!mvmvif->dbgfs_dir);
+               mvm_dir = mvmvif->dbgfs_dir;
+       } else {
+               mvm_dir = debugfs_create_dir("iwlmvm", dir);
+               if (IS_ERR_OR_NULL(mvm_dir)) {
+                       IWL_ERR(mvm, "Failed to create debugfs directory under %pd\n",
+                               dir);
+                       return;
+               }
+       }
+
+       iwl_mvm_debugfs_add_link_files(vif, link_conf, mvm_dir);
+}
index 0711ab689c48e0aed0335bf4582621b62c5b9f5b..cc2c45b45ddc35341c02b30f84a5bb3c8019389f 100644 (file)
@@ -1,5 +1,6 @@
 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
 /*
+ * Copyright (C) 2023 Intel Corporation
  * Copyright (C) 2012-2014 Intel Corporation
  * Copyright (C) 2013-2014 Intel Mobile Communications GmbH
  */
index 9c943dc283baee21be569a41a928b4247eec33ec..fd303ee78385b8ab221acd8957fb8ee2f650ab49 100644 (file)
@@ -1210,6 +1210,7 @@ const struct ieee80211_ops iwl_mvm_mld_hw_ops = {
 
 #ifdef CONFIG_IWLWIFI_DEBUGFS
        .vif_add_debugfs = iwl_mvm_vif_add_debugfs,
+       .link_add_debugfs = iwl_mvm_link_add_debugfs,
        .link_sta_add_debugfs = iwl_mvm_link_sta_add_debugfs,
 #endif
        .set_hw_timestamp = iwl_mvm_set_hw_timestamp,
index 5ec79bea5af1717c20c3a4a52d9a1499103ca53e..f8b95693bd98de33d5a64b11890a37dcd2b03410 100644 (file)
@@ -2406,6 +2406,10 @@ void iwl_mvm_link_sta_add_debugfs(struct ieee80211_hw *hw,
                                  struct ieee80211_vif *vif,
                                  struct ieee80211_link_sta *link_sta,
                                  struct dentry *dir);
+void iwl_mvm_link_add_debugfs(struct ieee80211_hw *hw,
+                             struct ieee80211_vif *vif,
+                             struct ieee80211_bss_conf *link_conf,
+                             struct dentry *dir);
 #endif
 
 /* new MLD related APIs */