Skip to content

Commit

Permalink
wifi: mac80211: add a driver callback to add vif debugfs
Browse files Browse the repository at this point in the history
Add a callback which the driver can use to add the vif debugfs.
We used to have this back until commit d260ff1 ("mac80211:
remove vif debugfs driver callbacks") where we thought that it
will be easier to just add them during interface add/remove.

However, now with multi-link, we want to have proper debugfs
for drivers for multi-link where some files might be in the
netdev for non-MLO connections, and in the links for MLO ones,
so we need to do some reconstruction when switching the mode.

Moving to this new call enables that and MLO drivers will have
to use it for proper debugfs operation.

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/20230928172905.ac38913f6ab7.Iee731d746bb08fcc628fa776f337016a12dc62ac@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
  • Loading branch information
Miriam-Rachel authored and jmberg-intel committed Oct 23, 2023
1 parent 822cab1 commit a1f5dcb
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 3 deletions.
6 changes: 6 additions & 0 deletions include/net/mac80211.h
Original file line number Diff line number Diff line change
Expand Up @@ -3869,6 +3869,10 @@ struct ieee80211_prep_tx_info {
* the station. See @sta_pre_rcu_remove if needed.
* This callback can sleep.
*
* @vif_add_debugfs: Drivers can use this callback to add a debugfs vif
* directory with its files. This callback should be within a
* CONFIG_MAC80211_DEBUGFS conditional. This callback can sleep.
*
* @link_add_debugfs: Drivers can use this callback to add debugfs files
* when a link is added to a mac80211 vif. This callback should be within
* a CONFIG_MAC80211_DEBUGFS conditional. This callback can sleep.
Expand Down Expand Up @@ -4368,6 +4372,8 @@ struct ieee80211_ops {
int (*sta_remove)(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
struct ieee80211_sta *sta);
#ifdef CONFIG_MAC80211_DEBUGFS
void (*vif_add_debugfs)(struct ieee80211_hw *hw,
struct ieee80211_vif *vif);
void (*link_add_debugfs)(struct ieee80211_hw *hw,
struct ieee80211_vif *vif,
struct ieee80211_bss_conf *link_conf,
Expand Down
11 changes: 8 additions & 3 deletions net/mac80211/driver-ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,15 @@ int drv_add_interface(struct ieee80211_local *local,
ret = local->ops->add_interface(&local->hw, &sdata->vif);
trace_drv_return_int(local, ret);

if (ret == 0)
sdata->flags |= IEEE80211_SDATA_IN_DRIVER;
if (ret)
return ret;

return ret;
sdata->flags |= IEEE80211_SDATA_IN_DRIVER;

if (!local->in_reconfig)
drv_vif_add_debugfs(local, sdata);

return 0;
}

int drv_change_interface(struct ieee80211_local *local,
Expand Down
23 changes: 23 additions & 0 deletions net/mac80211/driver-ops.h
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,23 @@ static inline void drv_sta_remove(struct ieee80211_local *local,
}

#ifdef CONFIG_MAC80211_DEBUGFS
static inline void drv_vif_add_debugfs(struct ieee80211_local *local,
struct ieee80211_sub_if_data *sdata)
{
might_sleep();

if (sdata->vif.type == NL80211_IFTYPE_MONITOR ||
WARN_ON(!sdata->vif.debugfs_dir))
return;

sdata = get_bss_sdata(sdata);
if (!check_sdata_in_driver(sdata))
return;

if (local->ops->vif_add_debugfs)
local->ops->vif_add_debugfs(&local->hw, &sdata->vif);
}

static inline void drv_link_add_debugfs(struct ieee80211_local *local,
struct ieee80211_sub_if_data *sdata,
struct ieee80211_bss_conf *link_conf,
Expand Down Expand Up @@ -539,6 +556,12 @@ static inline void drv_link_sta_add_debugfs(struct ieee80211_local *local,
local->ops->link_sta_add_debugfs(&local->hw, &sdata->vif,
link_sta, dir);
}
#else
static inline void drv_vif_add_debugfs(struct ieee80211_local *local,
struct ieee80211_sub_if_data *sdata)
{
might_sleep();
}
#endif

static inline void drv_sta_pre_rcu_remove(struct ieee80211_local *local,
Expand Down

0 comments on commit a1f5dcb

Please sign in to comment.