Linux wireless drivers development
 help / color / mirror / Atom feed
* [PATCH] mac80211: Add debugfs callbacks for station addition/removal
@ 2012-11-20  3:16 Sujith Manoharan
  2012-11-21 10:45 ` Johannes Berg
  0 siblings, 1 reply; 7+ messages in thread
From: Sujith Manoharan @ 2012-11-20  3:16 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 |  9 +++++++++
 net/mac80211/driver-ops.h  | 30 ++++++++++++++++++++++++++++++
 3 files changed, 57 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..b367d83 100644
--- a/net/mac80211/debugfs_sta.c
+++ b/net/mac80211/debugfs_sta.c
@@ -14,6 +14,7 @@
 #include "debugfs.h"
 #include "debugfs_sta.h"
 #include "sta_info.h"
+#include "driver-ops.h"
 
 /* sta attributtes */
 
@@ -334,6 +335,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 +382,16 @@ 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);
+
+	drv_sta_add_debugfs(local, sdata, &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;
+
+	drv_sta_remove_debugfs(local, sdata, &sta->sta, sta->debugfs.dir);
 	debugfs_remove_recursive(sta->debugfs.dir);
 	sta->debugfs.dir = NULL;
 }
diff --git a/net/mac80211/driver-ops.h b/net/mac80211/driver-ops.h
index 4dc2577..a6c2648 100644
--- a/net/mac80211/driver-ops.h
+++ b/net/mac80211/driver-ops.h
@@ -490,6 +490,36 @@ static inline void drv_sta_remove(struct ieee80211_local *local,
 	trace_drv_return_void(local);
 }
 
+static inline void drv_sta_add_debugfs(struct ieee80211_local *local,
+				       struct ieee80211_sub_if_data *sdata,
+				       struct ieee80211_sta *sta,
+				       struct dentry *dir)
+{
+	might_sleep();
+
+	sdata = get_bss_sdata(sdata);
+	check_sdata_in_driver(sdata);
+
+	if (local->ops->sta_add_debugfs)
+		local->ops->sta_add_debugfs(&local->hw, &sdata->vif,
+					    sta, dir);
+}
+
+static inline void drv_sta_remove_debugfs(struct ieee80211_local *local,
+					  struct ieee80211_sub_if_data *sdata,
+					  struct ieee80211_sta *sta,
+					  struct dentry *dir)
+{
+	might_sleep();
+
+	sdata = get_bss_sdata(sdata);
+	check_sdata_in_driver(sdata);
+
+	if (local->ops->sta_remove_debugfs)
+		local->ops->sta_remove_debugfs(&local->hw, &sdata->vif,
+					       sta, dir);
+}
+
 static inline __must_check
 int drv_sta_state(struct ieee80211_local *local,
 		  struct ieee80211_sub_if_data *sdata,
-- 
1.8.0


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

* Re: [PATCH] mac80211: Add debugfs callbacks for station addition/removal
  2012-11-20  3:16 [PATCH] mac80211: Add debugfs callbacks for station addition/removal Sujith Manoharan
@ 2012-11-21 10:45 ` Johannes Berg
  2012-11-21 11:11   ` Emmanuel Grumbach
  2012-11-22  4:57   ` Sujith Manoharan
  0 siblings, 2 replies; 7+ messages in thread
From: Johannes Berg @ 2012-11-21 10:45 UTC (permalink / raw)
  To: Sujith Manoharan; +Cc: linux-wireless

On Tue, 2012-11-20 at 08:46 +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.

Applied.

johannes


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

* Re: [PATCH] mac80211: Add debugfs callbacks for station addition/removal
  2012-11-21 10:45 ` Johannes Berg
@ 2012-11-21 11:11   ` Emmanuel Grumbach
  2012-11-21 13:46     ` Sujith Manoharan
  2012-11-22  4:57   ` Sujith Manoharan
  1 sibling, 1 reply; 7+ messages in thread
From: Emmanuel Grumbach @ 2012-11-21 11:11 UTC (permalink / raw)
  To: Johannes Berg; +Cc: Sujith Manoharan, linux-wireless

>>
>> 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.
>
> Applied.
>

Do you see value to add this for vif too?

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

* Re: [PATCH] mac80211: Add debugfs callbacks for station addition/removal
  2012-11-21 11:11   ` Emmanuel Grumbach
@ 2012-11-21 13:46     ` Sujith Manoharan
  2012-11-22 11:17       ` Emmanuel Grumbach
  0 siblings, 1 reply; 7+ messages in thread
From: Sujith Manoharan @ 2012-11-21 13:46 UTC (permalink / raw)
  To: Emmanuel Grumbach; +Cc: Johannes Berg, linux-wireless

Emmanuel Grumbach wrote:
> Do you see value to add this for vif too?

Not sure, mac80211 currently doesn't have a per-VIF debugfs area.
Also, we have ieee80211_iterate_active_interfaces(), which could be used
by drivers.

Sujith

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

* Re: [PATCH] mac80211: Add debugfs callbacks for station addition/removal
  2012-11-21 10:45 ` Johannes Berg
  2012-11-21 11:11   ` Emmanuel Grumbach
@ 2012-11-22  4:57   ` Sujith Manoharan
  1 sibling, 0 replies; 7+ messages in thread
From: Sujith Manoharan @ 2012-11-22  4:57 UTC (permalink / raw)
  To: Johannes Berg; +Cc: linux-wireless

Johannes Berg wrote:
> On Tue, 2012-11-20 at 08:46 +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.
> 
> Applied.

Thanks for fixing the ifdef oversight.

Sujith

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

* Re: [PATCH] mac80211: Add debugfs callbacks for station addition/removal
  2012-11-21 13:46     ` Sujith Manoharan
@ 2012-11-22 11:17       ` Emmanuel Grumbach
  2012-11-22 19:20         ` Sujith Manoharan
  0 siblings, 1 reply; 7+ messages in thread
From: Emmanuel Grumbach @ 2012-11-22 11:17 UTC (permalink / raw)
  To: Sujith Manoharan; +Cc: Johannes Berg, linux-wireless

> Emmanuel Grumbach wrote:
>> Do you see value to add this for vif too?
>
> Not sure, mac80211 currently doesn't have a per-VIF debugfs area.
> Also, we have ieee80211_iterate_active_interfaces(), which could be used
> by drivers.
>

Well it does: under sdata.
Anyway I added it internally. Patch will be posted soon :-)

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

* Re: [PATCH] mac80211: Add debugfs callbacks for station addition/removal
  2012-11-22 11:17       ` Emmanuel Grumbach
@ 2012-11-22 19:20         ` Sujith Manoharan
  0 siblings, 0 replies; 7+ messages in thread
From: Sujith Manoharan @ 2012-11-22 19:20 UTC (permalink / raw)
  To: Emmanuel Grumbach; +Cc: Johannes Berg, linux-wireless

Emmanuel Grumbach wrote:
> Well it does: under sdata.

Ouch, sorry. Of course mac80211 does..

Sujith

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

end of thread, other threads:[~2012-11-22 20:57 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-20  3:16 [PATCH] mac80211: Add debugfs callbacks for station addition/removal Sujith Manoharan
2012-11-21 10:45 ` Johannes Berg
2012-11-21 11:11   ` Emmanuel Grumbach
2012-11-21 13:46     ` Sujith Manoharan
2012-11-22 11:17       ` Emmanuel Grumbach
2012-11-22 19:20         ` Sujith Manoharan
2012-11-22  4:57   ` Sujith Manoharan

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