Linux wireless drivers development
 help / color / mirror / Atom feed
* [RFC] mac80211: Add debugfs callbacks for station addition/removal
@ 2012-11-19  5:48 Sujith Manoharan
  2012-11-19 14:14 ` Johannes Berg
  0 siblings, 1 reply; 4+ messages in thread
From: Sujith Manoharan @ 2012-11-19  5:48 UTC (permalink / raw)
  To: Johannes Berg; +Cc: linux-wireless

From: Sujith Manoharan <c_manoha@qca.qualcomm.com>

Provide drivers with hooks to create debugfs files when
a new station is added. This would help drivers to take
advantage of mac80211's station list infrastructure and not maintain
tedious station management code internally.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
---
 include/net/mac80211.h     | 18 ++++++++++++++++++
 net/mac80211/debugfs_sta.c | 12 ++++++++++++
 2 files changed, 30 insertions(+)

diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index a789dd1..f697b28 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -2192,6 +2192,14 @@ enum ieee80211_rate_control_changed {
  * @sta_remove: Notifies low level driver about removal of an associated
  *	station, AP, IBSS/WDS/mesh peer etc. This callback can sleep.
  *
+ * @sta_add_debugfs: Drivers can use this callback to add debugfs files
+ *	when a station is added to mac80211's station list. This callback
+ *	and @sta_remove_debugfs should be within a CONFIG_MAC80211_DEBUGFS
+ *	conditional. This callback can sleep.
+ *
+ * @sta_remove_debugfs: Remove the debugfs files which were added using
+ *	@sta_add_debugfs. This callback can sleep.
+ *
  * @sta_notify: Notifies low level driver about power state transition of an
  *	associated station, AP,  IBSS/WDS/mesh peer etc. For a VIF operating
  *	in AP mode, this callback will not be called when the flag
@@ -2473,6 +2481,16 @@ struct ieee80211_ops {
 		       struct ieee80211_sta *sta);
 	int (*sta_remove)(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
 			  struct ieee80211_sta *sta);
+#ifdef CONFIG_MAC80211_DEBUGFS
+	void (*sta_add_debugfs)(struct ieee80211_hw *hw,
+				struct ieee80211_vif *vif,
+				struct ieee80211_sta *sta,
+				struct dentry *dir);
+	void (*sta_remove_debugfs)(struct ieee80211_hw *hw,
+				   struct ieee80211_vif *vif,
+				   struct ieee80211_sta *sta,
+				   struct dentry *dir);
+#endif
 	void (*sta_notify)(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
 			enum sta_notify_cmd, struct ieee80211_sta *sta);
 	int (*sta_state)(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
diff --git a/net/mac80211/debugfs_sta.c b/net/mac80211/debugfs_sta.c
index 5ccec2c..32a45ed 100644
--- a/net/mac80211/debugfs_sta.c
+++ b/net/mac80211/debugfs_sta.c
@@ -334,6 +334,8 @@ STA_OPS(ht_capa);
 
 void ieee80211_sta_debugfs_add(struct sta_info *sta)
 {
+	struct ieee80211_local *local = sta->local;
+	struct ieee80211_sub_if_data *sdata = sta->sdata;
 	struct dentry *stations_dir = sta->sdata->debugfs.subdir_stations;
 	u8 mac[3*ETH_ALEN];
 
@@ -379,10 +381,20 @@ void ieee80211_sta_debugfs_add(struct sta_info *sta)
 	DEBUGFS_ADD_COUNTER(tx_retry_failed, tx_retry_failed);
 	DEBUGFS_ADD_COUNTER(tx_retry_count, tx_retry_count);
 	DEBUGFS_ADD_COUNTER(wep_weak_iv_count, wep_weak_iv_count);
+
+	if (local->ops->sta_add_debugfs)
+		local->ops->sta_add_debugfs(&local->hw, &sdata->vif,
+					    &sta->sta, sta->debugfs.dir);
 }
 
 void ieee80211_sta_debugfs_remove(struct sta_info *sta)
 {
+	struct ieee80211_local *local = sta->local;
+	struct ieee80211_sub_if_data *sdata = sta->sdata;
+
+	if (local->ops->sta_remove_debugfs)
+		local->ops->sta_remove_debugfs(&local->hw, &sdata->vif,
+					       &sta->sta, sta->debugfs.dir);
 	debugfs_remove_recursive(sta->debugfs.dir);
 	sta->debugfs.dir = NULL;
 }
-- 
1.8.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [RFC] mac80211: Add debugfs callbacks for station addition/removal
  2012-11-19  5:48 [RFC] mac80211: Add debugfs callbacks for station addition/removal Sujith Manoharan
@ 2012-11-19 14:14 ` Johannes Berg
  2012-11-19 14:59   ` Sujith Manoharan
  0 siblings, 1 reply; 4+ messages in thread
From: Johannes Berg @ 2012-11-19 14:14 UTC (permalink / raw)
  To: Sujith Manoharan; +Cc: linux-wireless

On Mon, 2012-11-19 at 11:18 +0530, Sujith Manoharan wrote:
> From: Sujith Manoharan <c_manoha@qca.qualcomm.com>
> 
> Provide drivers with hooks to create debugfs files when
> a new station is added. This would help drivers to take
> advantage of mac80211's station list infrastructure and not maintain
> tedious station management code internally.

I guess this works, and we don't really need tracing for it.

Can the files stay across a firmware restart or suspend/resume? I guess
with suspend/resume nothing can access them, but accessing them during
firmware restart might be ... strange? Not that I'm too worried about
that.

johannes


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RFC] mac80211: Add debugfs callbacks for station addition/removal
  2012-11-19 14:14 ` Johannes Berg
@ 2012-11-19 14:59   ` Sujith Manoharan
  2012-11-19 15:10     ` Johannes Berg
  0 siblings, 1 reply; 4+ messages in thread
From: Sujith Manoharan @ 2012-11-19 14:59 UTC (permalink / raw)
  To: Johannes Berg; +Cc: Sujith Manoharan, linux-wireless

Johannes Berg wrote:
> Can the files stay across a firmware restart or suspend/resume? I guess
> with suspend/resume nothing can access them, but accessing them during
> firmware restart might be ... strange? Not that I'm too worried about
> that.

As discussed in irc, leaving it to the drivers would be reasonable.

BTW, here are few warnings that I saw when doing a suspend/resume cycle:

linux-test kernel: WARNING: at /home/sujith/dev/wireless-testing/net/mac80211/chan.c:379 ieee80211_vif_release_channel+0x36/0x70 [mac80211]()
linux-test kernel: Hardware name: LIFEBOOK AH531
linux-test kernel: Pid: 4139, comm: pm-suspend Tainted: G        W  O 3.7.0-rc5-wl-debug #31
linux-test kernel: Call Trace:
linux-test kernel:  [<ffffffff8105697f>] warn_slowpath_common+0x7f/0xc0
linux-test kernel:  [<ffffffff810569da>] warn_slowpath_null+0x1a/0x20
linux-test kernel:  [<ffffffffa056e566>] ieee80211_vif_release_channel+0x36/0x70 [mac80211]
linux-test kernel:  [<ffffffffa059a3ca>] __ieee80211_suspend+0x45a/0xd10 [mac80211]
linux-test kernel:  [<ffffffff81388e27>] ? rtnl_lock+0x17/0x20
linux-test kernel:  [<ffffffffa055cbba>] ieee80211_suspend+0x1a/0x20 [mac80211]
linux-test kernel:  [<ffffffffa03d2945>] wiphy_suspend+0x95/0x180 [cfg80211]
linux-test kernel:  [<ffffffffa03d28b0>] ? wiphy_resume+0x180/0x180 [cfg80211]
linux-test kernel:  [<ffffffff8147852f>] legacy_suspend+0x2a/0x58
linux-test kernel:  [<ffffffff81324fec>] __device_suspend+0x1fc/0x210
linux-test kernel:  [<ffffffff81325a48>] dpm_suspend+0x68/0x240
linux-test kernel:  [<ffffffff81325ea7>] dpm_suspend_start+0x57/0x60
linux-test kernel:  [<ffffffff8109f9c1>] suspend_devices_and_enter+0x81/0x340
linux-test kernel:  [<ffffffff8109fe74>] pm_suspend+0x1f4/0x200
linux-test kernel:  [<ffffffff8109ed87>] state_store+0x87/0xf0
linux-test kernel:  [<ffffffff8124c2cf>] kobj_attr_store+0xf/0x20
linux-test kernel:  [<ffffffff811f73e0>] sysfs_write_file+0xe0/0x150
linux-test kernel:  [<ffffffff81182aa8>] vfs_write+0xa8/0x180
linux-test kernel:  [<ffffffff81182df2>] sys_write+0x52/0xa0
linux-test kernel:  [<ffffffff8147ef19>] system_call_fastpath+0x16/0x1b

and

linux-test kernel: WARNING: at /home/sujith/dev/wireless-testing/net/mac80211/ieee80211_i.h:1503 ieee80211_send_nullfunc+0xfe/0x130 [mac80211]()
linux-test kernel: Hardware name: LIFEBOOK AH531
linux-test kernel: Pid: 4139, comm: pm-suspend Tainted: G        W  O 3.7.0-rc5-wl-debug #31
linux-test kernel: Call Trace:
linux-test kernel:  [<ffffffff8105697f>] warn_slowpath_common+0x7f/0xc0
linux-test kernel:  [<ffffffff810569da>] warn_slowpath_null+0x1a/0x20
linux-test kernel:  [<ffffffffa058501e>] ieee80211_send_nullfunc+0xfe/0x130 [mac80211]
linux-test kernel:  [<ffffffffa0584f81>] ? ieee80211_send_nullfunc+0x61/0x130 [mac80211]
linux-test kernel:  [<ffffffffa05858a5>] ? ieee80211_recalc_ps+0x1e5/0x230 [mac80211]
linux-test kernel:  [<ffffffffa056be8c>] ieee80211_reconfig+0x15ac/0x1c00 [mac80211]
linux-test kernel:  [<ffffffffa055acbd>] ieee80211_resume+0x2d/0x70 [mac80211]
linux-test kernel:  [<ffffffffa03d27c9>] wiphy_resume+0x99/0x180 [cfg80211]
linux-test kernel:  [<ffffffffa03d2730>] ? index_show+0x30/0x30 [cfg80211]
linux-test kernel:  [<ffffffff8132437b>] dpm_run_callback.isra.4+0x3b/0x70
linux-test kernel:  [<ffffffff8132515c>] device_resume+0xbc/0x150
linux-test kernel:  [<ffffffff81325694>] dpm_resume+0x114/0x250
linux-test kernel:  [<ffffffff813259c5>] dpm_resume_end+0x15/0x30
linux-test kernel:  [<ffffffff812a8069>] ? acpi_suspend_begin_old+0x2d/0x2d
linux-test kernel:  [<ffffffff8109f9f6>] suspend_devices_and_enter+0xb6/0x340
linux-test kernel:  [<ffffffff8109fe74>] pm_suspend+0x1f4/0x200
linux-test kernel:  [<ffffffff8109ed87>] state_store+0x87/0xf0
linux-test kernel:  [<ffffffff8124c2cf>] kobj_attr_store+0xf/0x20
linux-test kernel:  [<ffffffff811f73e0>] sysfs_write_file+0xe0/0x150
linux-test kernel:  [<ffffffff81182aa8>] vfs_write+0xa8/0x180
linux-test kernel:  [<ffffffff81182df2>] sys_write+0x52/0xa0
linux-test kernel:  [<ffffffff8147ef19>] system_call_fastpath+0x16/0x1b


Sujith

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RFC] mac80211: Add debugfs callbacks for station addition/removal
  2012-11-19 14:59   ` Sujith Manoharan
@ 2012-11-19 15:10     ` Johannes Berg
  0 siblings, 0 replies; 4+ messages in thread
From: Johannes Berg @ 2012-11-19 15:10 UTC (permalink / raw)
  To: Sujith Manoharan; +Cc: linux-wireless

On Mon, 2012-11-19 at 20:29 +0530, Sujith Manoharan wrote:
> 
> BTW, here are few warnings that I saw when doing a suspend/resume cycle:
> 
> linux-test kernel: WARNING: at /home/sujith/dev/wireless-testing/net/mac80211/chan.c:379 ieee80211_vif_release_channel+0x36/0x70 [mac80211]()
> linux-test kernel: Hardware name: LIFEBOOK AH531
> linux-test kernel: Pid: 4139, comm: pm-suspend Tainted: G        W  O 3.7.0-rc5-wl-debug #31
> linux-test kernel: Call Trace:
> linux-test kernel:  [<ffffffff8105697f>] warn_slowpath_common+0x7f/0xc0
> linux-test kernel:  [<ffffffff810569da>] warn_slowpath_null+0x1a/0x20
> linux-test kernel:  [<ffffffffa056e566>] ieee80211_vif_release_channel+0x36/0x70 [mac80211]
> linux-test kernel:  [<ffffffffa059a3ca>] __ieee80211_suspend+0x45a/0xd10 [mac80211]

Oops. I should fix this.

> linux-test kernel: WARNING: at /home/sujith/dev/wireless-testing/net/mac80211/ieee80211_i.h:1503 ieee80211_send_nullfunc+0xfe/0x130 [mac80211]()
> linux-test kernel: Hardware name: LIFEBOOK AH531
> linux-test kernel: Pid: 4139, comm: pm-suspend Tainted: G        W  O 3.7.0-rc5-wl-debug #31
> linux-test kernel: Call Trace:
> linux-test kernel:  [<ffffffff8105697f>] warn_slowpath_common+0x7f/0xc0
> linux-test kernel:  [<ffffffff810569da>] warn_slowpath_null+0x1a/0x20
> linux-test kernel:  [<ffffffffa058501e>] ieee80211_send_nullfunc+0xfe/0x130 [mac80211]

This is already fixed, but the fix is in wireless while the WARN was
only introduced in -next, so we need to have some patience.

johannes


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-11-19 15:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-19  5:48 [RFC] mac80211: Add debugfs callbacks for station addition/removal Sujith Manoharan
2012-11-19 14:14 ` Johannes Berg
2012-11-19 14:59   ` Sujith Manoharan
2012-11-19 15:10     ` Johannes Berg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox