aboutsummaryrefslogtreecommitdiffstats
path: root/net/mac80211/debugfs_netdev.c
diff options
context:
space:
mode:
authorJohannes Berg <johannes@sipsolutions.net>2009-10-27 07:59:03 -0400
committerJohn W. Linville <linville@tuxdriver.com>2009-10-30 16:49:18 -0400
commit7bcfaf2f431c09c51fe776fc06638b25d3b421c5 (patch)
tree27f767335566826f11f0134b97ee76b58d9bcf90 /net/mac80211/debugfs_netdev.c
parent2c0d6100da3ee9b0f0cc46add9bb8a8161299a92 (diff)
cfg80211/mac80211: use debugfs_remove_recursive
We can save a lot of code and pointers in the structs by using debugfs_remove_recursive(). First, change cfg80211 to use debugfs_remove_recursive() so that drivers do not need to clean up any files they added to the per-wiphy debugfs (if and only if they are ok to be accessed until after wiphy_unregister!). Then also make mac80211 use debugfs_remove_recursive() where necessary -- it need not remove per-wiphy files as cfg80211 now removes those, but netdev etc. files still need to be handled but can now be removed without needing struct dentry pointers to all of them. Signed-off-by: Johannes Berg <johannes@sipsolutions.net> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'net/mac80211/debugfs_netdev.c')
-rw-r--r--net/mac80211/debugfs_netdev.c174
1 files changed, 26 insertions, 148 deletions
diff --git a/net/mac80211/debugfs_netdev.c b/net/mac80211/debugfs_netdev.c
index 61234e79022b..8782264f49e7 100644
--- a/net/mac80211/debugfs_netdev.c
+++ b/net/mac80211/debugfs_netdev.c
@@ -152,9 +152,9 @@ IEEE80211_IF_FILE(min_discovery_timeout,
152#endif 152#endif
153 153
154 154
155#define DEBUGFS_ADD(name, type)\ 155#define DEBUGFS_ADD(name, type) \
156 sdata->debugfs.type.name = debugfs_create_file(#name, 0400,\ 156 debugfs_create_file(#name, 0400, sdata->debugfs.dir, \
157 sdata->debugfsdir, sdata, &name##_ops); 157 sdata, &name##_ops);
158 158
159static void add_sta_files(struct ieee80211_sub_if_data *sdata) 159static void add_sta_files(struct ieee80211_sub_if_data *sdata)
160{ 160{
@@ -199,30 +199,32 @@ static void add_monitor_files(struct ieee80211_sub_if_data *sdata)
199} 199}
200 200
201#ifdef CONFIG_MAC80211_MESH 201#ifdef CONFIG_MAC80211_MESH
202#define MESHSTATS_ADD(name)\
203 sdata->mesh_stats.name = debugfs_create_file(#name, 0400,\
204 sdata->mesh_stats_dir, sdata, &name##_ops);
205 202
206static void add_mesh_stats(struct ieee80211_sub_if_data *sdata) 203static void add_mesh_stats(struct ieee80211_sub_if_data *sdata)
207{ 204{
208 sdata->mesh_stats_dir = debugfs_create_dir("mesh_stats", 205 struct dentry *dir = debugfs_create_dir("mesh_stats",
209 sdata->debugfsdir); 206 sdata->debugfs.dir);
207
208#define MESHSTATS_ADD(name)\
209 debugfs_create_file(#name, 0400, dir, sdata, &name##_ops);
210
210 MESHSTATS_ADD(fwded_mcast); 211 MESHSTATS_ADD(fwded_mcast);
211 MESHSTATS_ADD(fwded_unicast); 212 MESHSTATS_ADD(fwded_unicast);
212 MESHSTATS_ADD(fwded_frames); 213 MESHSTATS_ADD(fwded_frames);
213 MESHSTATS_ADD(dropped_frames_ttl); 214 MESHSTATS_ADD(dropped_frames_ttl);
214 MESHSTATS_ADD(dropped_frames_no_route); 215 MESHSTATS_ADD(dropped_frames_no_route);
215 MESHSTATS_ADD(estab_plinks); 216 MESHSTATS_ADD(estab_plinks);
217#undef MESHSTATS_ADD
216} 218}
217 219
218#define MESHPARAMS_ADD(name)\
219 sdata->mesh_config.name = debugfs_create_file(#name, 0600,\
220 sdata->mesh_config_dir, sdata, &name##_ops);
221
222static void add_mesh_config(struct ieee80211_sub_if_data *sdata) 220static void add_mesh_config(struct ieee80211_sub_if_data *sdata)
223{ 221{
224 sdata->mesh_config_dir = debugfs_create_dir("mesh_config", 222 struct dentry *dir = debugfs_create_dir("mesh_config",
225 sdata->debugfsdir); 223 sdata->debugfs.dir);
224
225#define MESHPARAMS_ADD(name) \
226 debugfs_create_file(#name, 0600, dir, sdata, &name##_ops);
227
226 MESHPARAMS_ADD(dot11MeshMaxRetries); 228 MESHPARAMS_ADD(dot11MeshMaxRetries);
227 MESHPARAMS_ADD(dot11MeshRetryTimeout); 229 MESHPARAMS_ADD(dot11MeshRetryTimeout);
228 MESHPARAMS_ADD(dot11MeshConfirmTimeout); 230 MESHPARAMS_ADD(dot11MeshConfirmTimeout);
@@ -236,12 +238,14 @@ static void add_mesh_config(struct ieee80211_sub_if_data *sdata)
236 MESHPARAMS_ADD(dot11MeshHWMPmaxPREQretries); 238 MESHPARAMS_ADD(dot11MeshHWMPmaxPREQretries);
237 MESHPARAMS_ADD(path_refresh_time); 239 MESHPARAMS_ADD(path_refresh_time);
238 MESHPARAMS_ADD(min_discovery_timeout); 240 MESHPARAMS_ADD(min_discovery_timeout);
241
242#undef MESHPARAMS_ADD
239} 243}
240#endif 244#endif
241 245
242static void add_files(struct ieee80211_sub_if_data *sdata) 246static void add_files(struct ieee80211_sub_if_data *sdata)
243{ 247{
244 if (!sdata->debugfsdir) 248 if (!sdata->debugfs.dir)
245 return; 249 return;
246 250
247 switch (sdata->vif.type) { 251 switch (sdata->vif.type) {
@@ -274,134 +278,6 @@ static void add_files(struct ieee80211_sub_if_data *sdata)
274 } 278 }
275} 279}
276 280
277#define DEBUGFS_DEL(name, type) \
278 do { \
279 debugfs_remove(sdata->debugfs.type.name); \
280 sdata->debugfs.type.name = NULL; \
281 } while (0)
282
283static void del_sta_files(struct ieee80211_sub_if_data *sdata)
284{
285 DEBUGFS_DEL(drop_unencrypted, sta);
286 DEBUGFS_DEL(force_unicast_rateidx, sta);
287 DEBUGFS_DEL(max_ratectrl_rateidx, sta);
288
289 DEBUGFS_DEL(bssid, sta);
290 DEBUGFS_DEL(aid, sta);
291 DEBUGFS_DEL(capab, sta);
292}
293
294static void del_ap_files(struct ieee80211_sub_if_data *sdata)
295{
296 DEBUGFS_DEL(drop_unencrypted, ap);
297 DEBUGFS_DEL(force_unicast_rateidx, ap);
298 DEBUGFS_DEL(max_ratectrl_rateidx, ap);
299
300 DEBUGFS_DEL(num_sta_ps, ap);
301 DEBUGFS_DEL(dtim_count, ap);
302 DEBUGFS_DEL(num_buffered_multicast, ap);
303}
304
305static void del_wds_files(struct ieee80211_sub_if_data *sdata)
306{
307 DEBUGFS_DEL(drop_unencrypted, wds);
308 DEBUGFS_DEL(force_unicast_rateidx, wds);
309 DEBUGFS_DEL(max_ratectrl_rateidx, wds);
310
311 DEBUGFS_DEL(peer, wds);
312}
313
314static void del_vlan_files(struct ieee80211_sub_if_data *sdata)
315{
316 DEBUGFS_DEL(drop_unencrypted, vlan);
317 DEBUGFS_DEL(force_unicast_rateidx, vlan);
318 DEBUGFS_DEL(max_ratectrl_rateidx, vlan);
319}
320
321static void del_monitor_files(struct ieee80211_sub_if_data *sdata)
322{
323}
324
325#ifdef CONFIG_MAC80211_MESH
326#define MESHSTATS_DEL(name) \
327 do { \
328 debugfs_remove(sdata->mesh_stats.name); \
329 sdata->mesh_stats.name = NULL; \
330 } while (0)
331
332static void del_mesh_stats(struct ieee80211_sub_if_data *sdata)
333{
334 MESHSTATS_DEL(fwded_mcast);
335 MESHSTATS_DEL(fwded_unicast);
336 MESHSTATS_DEL(fwded_frames);
337 MESHSTATS_DEL(dropped_frames_ttl);
338 MESHSTATS_DEL(dropped_frames_no_route);
339 MESHSTATS_DEL(estab_plinks);
340 debugfs_remove(sdata->mesh_stats_dir);
341 sdata->mesh_stats_dir = NULL;
342}
343
344#define MESHPARAMS_DEL(name) \
345 do { \
346 debugfs_remove(sdata->mesh_config.name); \
347 sdata->mesh_config.name = NULL; \
348 } while (0)
349
350static void del_mesh_config(struct ieee80211_sub_if_data *sdata)
351{
352 MESHPARAMS_DEL(dot11MeshMaxRetries);
353 MESHPARAMS_DEL(dot11MeshRetryTimeout);
354 MESHPARAMS_DEL(dot11MeshConfirmTimeout);
355 MESHPARAMS_DEL(dot11MeshHoldingTimeout);
356 MESHPARAMS_DEL(dot11MeshTTL);
357 MESHPARAMS_DEL(auto_open_plinks);
358 MESHPARAMS_DEL(dot11MeshMaxPeerLinks);
359 MESHPARAMS_DEL(dot11MeshHWMPactivePathTimeout);
360 MESHPARAMS_DEL(dot11MeshHWMPpreqMinInterval);
361 MESHPARAMS_DEL(dot11MeshHWMPnetDiameterTraversalTime);
362 MESHPARAMS_DEL(dot11MeshHWMPmaxPREQretries);
363 MESHPARAMS_DEL(path_refresh_time);
364 MESHPARAMS_DEL(min_discovery_timeout);
365 debugfs_remove(sdata->mesh_config_dir);
366 sdata->mesh_config_dir = NULL;
367}
368#endif
369
370static void del_files(struct ieee80211_sub_if_data *sdata)
371{
372 if (!sdata->debugfsdir)
373 return;
374
375 switch (sdata->vif.type) {
376 case NL80211_IFTYPE_MESH_POINT:
377#ifdef CONFIG_MAC80211_MESH
378 del_mesh_stats(sdata);
379 del_mesh_config(sdata);
380#endif
381 break;
382 case NL80211_IFTYPE_STATION:
383 del_sta_files(sdata);
384 break;
385 case NL80211_IFTYPE_ADHOC:
386 /* XXX */
387 break;
388 case NL80211_IFTYPE_AP:
389 del_ap_files(sdata);
390 break;
391 case NL80211_IFTYPE_WDS:
392 del_wds_files(sdata);
393 break;
394 case NL80211_IFTYPE_MONITOR:
395 del_monitor_files(sdata);
396 break;
397 case NL80211_IFTYPE_AP_VLAN:
398 del_vlan_files(sdata);
399 break;
400 default:
401 break;
402 }
403}
404
405static int notif_registered; 281static int notif_registered;
406 282
407void ieee80211_debugfs_add_netdev(struct ieee80211_sub_if_data *sdata) 283void ieee80211_debugfs_add_netdev(struct ieee80211_sub_if_data *sdata)
@@ -412,16 +288,18 @@ void ieee80211_debugfs_add_netdev(struct ieee80211_sub_if_data *sdata)
412 return; 288 return;
413 289
414 sprintf(buf, "netdev:%s", sdata->dev->name); 290 sprintf(buf, "netdev:%s", sdata->dev->name);
415 sdata->debugfsdir = debugfs_create_dir(buf, 291 sdata->debugfs.dir = debugfs_create_dir(buf,
416 sdata->local->hw.wiphy->debugfsdir); 292 sdata->local->hw.wiphy->debugfsdir);
417 add_files(sdata); 293 add_files(sdata);
418} 294}
419 295
420void ieee80211_debugfs_remove_netdev(struct ieee80211_sub_if_data *sdata) 296void ieee80211_debugfs_remove_netdev(struct ieee80211_sub_if_data *sdata)
421{ 297{
422 del_files(sdata); 298 if (!sdata->debugfs.dir)
423 debugfs_remove(sdata->debugfsdir); 299 return;
424 sdata->debugfsdir = NULL; 300
301 debugfs_remove_recursive(sdata->debugfs.dir);
302 sdata->debugfs.dir = NULL;
425} 303}
426 304
427static int netdev_notify(struct notifier_block *nb, 305static int netdev_notify(struct notifier_block *nb,
@@ -444,7 +322,7 @@ static int netdev_notify(struct notifier_block *nb,
444 322
445 sdata = IEEE80211_DEV_TO_SUB_IF(dev); 323 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
446 324
447 dir = sdata->debugfsdir; 325 dir = sdata->debugfs.dir;
448 326
449 if (!dir) 327 if (!dir)
450 return 0; 328 return 0;