Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mac80211: move sdata debugfs dir to vif

There is need create driver own per interface debugfs files. This is
currently done by drv_{add,remove}_interface_debugfs() callbacks. But it
is possible that after we remove interface from the driver (i.e.
on suspend) we call drv_remove_interface_debugfs() function. Fixing this
problem will require to add call drv_{add,remove}_interface_debugfs()
anytime we create and remove interface in mac80211. So it's better to
add debugfs dir dentry to vif structure to allow to create/remove
custom debugfs driver files on drv_{add,remove}_interface().

Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>

authored by

Stanislaw Gruszka and committed by
Johannes Berg
ddbfe860 488b366a

+25 -19
+7
include/net/mac80211.h
··· 1067 1067 * path needing to access it; even though the netdev carrier will always 1068 1068 * be off when it is %NULL there can still be races and packets could be 1069 1069 * processed after it switches back to %NULL. 1070 + * @debugfs_dir: debugfs dentry, can be used by drivers to create own per 1071 + * interface debug files. Note that it will be NULL for the virtual 1072 + * monitor interface (if that is requested.) 1070 1073 * @drv_priv: data area for driver use, will always be aligned to 1071 1074 * sizeof(void *). 1072 1075 */ ··· 1085 1082 struct ieee80211_chanctx_conf __rcu *chanctx_conf; 1086 1083 1087 1084 u32 driver_flags; 1085 + 1086 + #ifdef CONFIG_MAC80211_DEBUGFS 1087 + struct dentry *debugfs_dir; 1088 + #endif 1088 1089 1089 1090 /* must be last */ 1090 1091 u8 drv_priv[0] __aligned(sizeof(void *));
+5 -5
net/mac80211/debugfs_key.c
··· 295 295 char buf[50]; 296 296 struct ieee80211_key *key; 297 297 298 - if (!sdata->debugfs.dir) 298 + if (!sdata->vif.debugfs_dir) 299 299 return; 300 300 301 301 lockdep_assert_held(&sdata->local->key_mtx); ··· 311 311 sprintf(buf, "../keys/%d", key->debugfs.cnt); 312 312 sdata->debugfs.default_unicast_key = 313 313 debugfs_create_symlink("default_unicast_key", 314 - sdata->debugfs.dir, buf); 314 + sdata->vif.debugfs_dir, buf); 315 315 } 316 316 317 317 if (sdata->debugfs.default_multicast_key) { ··· 325 325 sprintf(buf, "../keys/%d", key->debugfs.cnt); 326 326 sdata->debugfs.default_multicast_key = 327 327 debugfs_create_symlink("default_multicast_key", 328 - sdata->debugfs.dir, buf); 328 + sdata->vif.debugfs_dir, buf); 329 329 } 330 330 } 331 331 ··· 334 334 char buf[50]; 335 335 struct ieee80211_key *key; 336 336 337 - if (!sdata->debugfs.dir) 337 + if (!sdata->vif.debugfs_dir) 338 338 return; 339 339 340 340 key = key_mtx_dereference(sdata->local, ··· 343 343 sprintf(buf, "../keys/%d", key->debugfs.cnt); 344 344 sdata->debugfs.default_mgmt_key = 345 345 debugfs_create_symlink("default_mgmt_key", 346 - sdata->debugfs.dir, buf); 346 + sdata->vif.debugfs_dir, buf); 347 347 } else 348 348 ieee80211_debugfs_key_remove_mgmt_default(sdata); 349 349 }
+11 -11
net/mac80211/debugfs_netdev.c
··· 521 521 #endif 522 522 523 523 #define DEBUGFS_ADD_MODE(name, mode) \ 524 - debugfs_create_file(#name, mode, sdata->debugfs.dir, \ 524 + debugfs_create_file(#name, mode, sdata->vif.debugfs_dir, \ 525 525 sdata, &name##_ops); 526 526 527 527 #define DEBUGFS_ADD(name) DEBUGFS_ADD_MODE(name, 0400) ··· 577 577 static void add_mesh_stats(struct ieee80211_sub_if_data *sdata) 578 578 { 579 579 struct dentry *dir = debugfs_create_dir("mesh_stats", 580 - sdata->debugfs.dir); 580 + sdata->vif.debugfs_dir); 581 581 #define MESHSTATS_ADD(name)\ 582 582 debugfs_create_file(#name, 0400, dir, sdata, &name##_ops); 583 583 ··· 594 594 static void add_mesh_config(struct ieee80211_sub_if_data *sdata) 595 595 { 596 596 struct dentry *dir = debugfs_create_dir("mesh_config", 597 - sdata->debugfs.dir); 597 + sdata->vif.debugfs_dir); 598 598 599 599 #define MESHPARAMS_ADD(name) \ 600 600 debugfs_create_file(#name, 0600, dir, sdata, &name##_ops); ··· 631 631 632 632 static void add_files(struct ieee80211_sub_if_data *sdata) 633 633 { 634 - if (!sdata->debugfs.dir) 634 + if (!sdata->vif.debugfs_dir) 635 635 return; 636 636 637 637 DEBUGFS_ADD(flags); ··· 673 673 char buf[10+IFNAMSIZ]; 674 674 675 675 sprintf(buf, "netdev:%s", sdata->name); 676 - sdata->debugfs.dir = debugfs_create_dir(buf, 676 + sdata->vif.debugfs_dir = debugfs_create_dir(buf, 677 677 sdata->local->hw.wiphy->debugfsdir); 678 - if (sdata->debugfs.dir) 678 + if (sdata->vif.debugfs_dir) 679 679 sdata->debugfs.subdir_stations = debugfs_create_dir("stations", 680 - sdata->debugfs.dir); 680 + sdata->vif.debugfs_dir); 681 681 add_files(sdata); 682 682 } 683 683 684 684 void ieee80211_debugfs_remove_netdev(struct ieee80211_sub_if_data *sdata) 685 685 { 686 - if (!sdata->debugfs.dir) 686 + if (!sdata->vif.debugfs_dir) 687 687 return; 688 688 689 - debugfs_remove_recursive(sdata->debugfs.dir); 690 - sdata->debugfs.dir = NULL; 689 + debugfs_remove_recursive(sdata->vif.debugfs_dir); 690 + sdata->vif.debugfs_dir = NULL; 691 691 } 692 692 693 693 void ieee80211_debugfs_rename_netdev(struct ieee80211_sub_if_data *sdata) ··· 695 695 struct dentry *dir; 696 696 char buf[10 + IFNAMSIZ]; 697 697 698 - dir = sdata->debugfs.dir; 698 + dir = sdata->vif.debugfs_dir; 699 699 700 700 if (!dir) 701 701 return;
+2 -2
net/mac80211/driver-ops.h
··· 560 560 return; 561 561 562 562 local->ops->add_interface_debugfs(&local->hw, &sdata->vif, 563 - sdata->debugfs.dir); 563 + sdata->vif.debugfs_dir); 564 564 } 565 565 566 566 static inline ··· 575 575 return; 576 576 577 577 local->ops->remove_interface_debugfs(&local->hw, &sdata->vif, 578 - sdata->debugfs.dir); 578 + sdata->vif.debugfs_dir); 579 579 } 580 580 #else 581 581 static inline
-1
net/mac80211/ieee80211_i.h
··· 758 758 759 759 #ifdef CONFIG_MAC80211_DEBUGFS 760 760 struct { 761 - struct dentry *dir; 762 761 struct dentry *subdir_stations; 763 762 struct dentry *default_unicast_key; 764 763 struct dentry *default_multicast_key;