All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mac80211: add vif debugfs driver callbacks
@ 2013-02-05 11:49 Johannes Berg
  2013-02-11 11:49 ` Johannes Berg
  0 siblings, 1 reply; 6+ messages in thread
From: Johannes Berg @ 2013-02-05 11:49 UTC (permalink / raw)
  To: linux-wireless; +Cc: Alexander Bondar

From: Alexander Bondar <alexander.bondar@intel.com>

Add debugfs driver callbacks so drivers can add
debugfs entries for interfaces. Note that they
_must_ remove the entries again as add/remove in
the driver doesn't correspond to add/remove in
debugfs; the former is up/down while the latter
is netdev create/destroy.

Signed-off-by: Alexander Bondar <alexander.bondar@intel.com>
Reviewed-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
---
 include/net/mac80211.h    | 18 ++++++++++++++++++
 net/mac80211/driver-ops.h | 37 +++++++++++++++++++++++++++++++++++++
 net/mac80211/iface.c      |  4 ++++
 3 files changed, 59 insertions(+)

diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index 7da1121..46e08ba 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -2167,6 +2167,18 @@ enum ieee80211_rate_control_changed {
  *	MAC address of the device going away.
  *	Hence, this callback must be implemented. It can sleep.
  *
+ * @add_interface_debugfs: Drivers can use this callback to add debugfs files
+ *	when a vif is added to mac80211. This callback and
+ *	@remove_interface_debugfs should be within a CONFIG_MAC80211_DEBUGFS
+ *	conditional. @remove_interface_debugfs must be provided for cleanup.
+ *	This callback can sleep.
+ *
+ * @remove_interface_debugfs: Remove the debugfs files which were added using
+ *	@add_interface_debugfs. This callback must remove all debugfs entries
+ *	that were added because mac80211 only removes interface debugfs when the
+ *	interface is destroyed, not when it is removed from the driver.
+ *	This callback can sleep.
+ *
  * @config: Handler for configuration requests. IEEE 802.11 code calls this
  *	function to change hardware configuration, e.g., channel.
  *	This function should never fail but returns a negative error code
@@ -2580,6 +2592,12 @@ struct ieee80211_ops {
 				   struct ieee80211_vif *vif,
 				   struct ieee80211_sta *sta,
 				   struct dentry *dir);
+	void (*add_interface_debugfs)(struct ieee80211_hw *hw,
+				      struct ieee80211_vif *vif,
+				      struct dentry *dir);
+	void (*remove_interface_debugfs)(struct ieee80211_hw *hw,
+					 struct ieee80211_vif *vif,
+					 struct dentry *dir);
 #endif
 	void (*sta_notify)(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
 			enum sta_notify_cmd, struct ieee80211_sta *sta);
diff --git a/net/mac80211/driver-ops.h b/net/mac80211/driver-ops.h
index 434b3c4..2b08b99 100644
--- a/net/mac80211/driver-ops.h
+++ b/net/mac80211/driver-ops.h
@@ -528,6 +528,43 @@ static inline void drv_sta_remove_debugfs(struct ieee80211_local *local,
 		local->ops->sta_remove_debugfs(&local->hw, &sdata->vif,
 					       sta, dir);
 }
+
+static inline
+void drv_add_interface_debugfs(struct ieee80211_local *local,
+			       struct ieee80211_sub_if_data *sdata)
+{
+	might_sleep();
+
+	check_sdata_in_driver(sdata);
+
+	if (!local->ops->add_interface_debugfs)
+		return;
+
+	local->ops->add_interface_debugfs(&local->hw, &sdata->vif,
+					  sdata->debugfs.dir);
+}
+
+static inline
+void drv_remove_interface_debugfs(struct ieee80211_local *local,
+				  struct ieee80211_sub_if_data *sdata)
+{
+	might_sleep();
+
+	check_sdata_in_driver(sdata);
+
+	if (!local->ops->remove_interface_debugfs)
+		return;
+
+	local->ops->remove_interface_debugfs(&local->hw, &sdata->vif,
+					     sdata->debugfs.dir);
+}
+#else
+static inline
+void drv_add_interface_debugfs(struct ieee80211_local *local,
+			       struct ieee80211_sub_if_data *sdata) {}
+static inline
+void drv_remove_interface_debugfs(struct ieee80211_local *local,
+				  struct ieee80211_sub_if_data *sdata) {}
 #endif
 
 static inline __must_check
diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
index 0a36dc6..deb78e8 100644
--- a/net/mac80211/iface.c
+++ b/net/mac80211/iface.c
@@ -621,6 +621,8 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
 				goto err_del_interface;
 		}
 
+		drv_add_interface_debugfs(local, sdata);
+
 		if (sdata->vif.type == NL80211_IFTYPE_AP) {
 			local->fif_pspoll++;
 			local->fif_probe_req++;
@@ -882,6 +884,8 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
 		 */
 		ieee80211_free_keys(sdata);
 
+		drv_remove_interface_debugfs(local, sdata);
+
 		if (going_down)
 			drv_remove_interface(local, sdata);
 	}
-- 
1.8.0


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

* Re: [PATCH] mac80211: add vif debugfs driver callbacks
  2013-02-05 11:49 [PATCH] mac80211: add vif debugfs driver callbacks Johannes Berg
@ 2013-02-11 11:49 ` Johannes Berg
  0 siblings, 0 replies; 6+ messages in thread
From: Johannes Berg @ 2013-02-11 11:49 UTC (permalink / raw)
  To: linux-wireless; +Cc: Alexander Bondar

On Tue, 2013-02-05 at 12:49 +0100, Johannes Berg wrote:
> From: Alexander Bondar <alexander.bondar@intel.com>
> 
> Add debugfs driver callbacks so drivers can add
> debugfs entries for interfaces. Note that they
> _must_ remove the entries again as add/remove in
> the driver doesn't correspond to add/remove in
> debugfs; the former is up/down while the latter
> is netdev create/destroy.

Applied.

johannes


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

* Re: [PATCH] mac80211: Add vif debugfs driver callbacks
  2013-01-24 17:51   ` Johannes Berg
@ 2013-01-29  9:00     ` Johannes Berg
  0 siblings, 0 replies; 6+ messages in thread
From: Johannes Berg @ 2013-01-29  9:00 UTC (permalink / raw)
  To: linux-wireless; +Cc: Alexander Bondar

On Thu, 2013-01-24 at 18:51 +0100, Johannes Berg wrote:

> > > Add debugfs driver callbacks to be called upon interface addition,
> > > removal and type change.
> > 
> > Never mind, apparently this doesn't work. I haven't tried myself yet.
> 
> The issue is that the driver might rely on mac80211 removing the dir
> (recursively), but that only happens when the interface is destroyed.
> However, add/remove here happens when the interface is added to/removed
> from the driver, which is up/down not create/destroy.

So the issue is that mac80211 cannot remove the debugfs entries the
driver creates here, because it only removes the interface debugfs when
the interface is destroyed, not when it is taken down.

The driver, OTOH, gets add/remove when the interface goes up/down.

Would anyone complain if we just document that and require that the
driver actually remove its entries when the new remove_interface_debugfs
callback is called? That'd be a bit unlike other debugfs dirs where
everything just gets cleaned up in mac80211.

johannes


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

* Re: [PATCH] mac80211: Add vif debugfs driver callbacks
  2013-01-24 13:08 ` Johannes Berg
@ 2013-01-24 17:51   ` Johannes Berg
  2013-01-29  9:00     ` Johannes Berg
  0 siblings, 1 reply; 6+ messages in thread
From: Johannes Berg @ 2013-01-24 17:51 UTC (permalink / raw)
  To: linux-wireless; +Cc: Alexander Bondar

On Thu, 2013-01-24 at 14:08 +0100, Johannes Berg wrote:
> On Thu, 2013-01-24 at 13:01 +0100, Johannes Berg wrote:
> > From: Alexander Bondar <alexander.bondar@intel.com>
> > 
> > Add debugfs driver callbacks to be called upon interface addition,
> > removal and type change.
> 
> Never mind, apparently this doesn't work. I haven't tried myself yet.

The issue is that the driver might rely on mac80211 removing the dir
(recursively), but that only happens when the interface is destroyed.
However, add/remove here happens when the interface is added to/removed
from the driver, which is up/down not create/destroy.

johannes


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

* Re: [PATCH] mac80211: Add vif debugfs driver callbacks
  2013-01-24 12:01 [PATCH] mac80211: Add " Johannes Berg
@ 2013-01-24 13:08 ` Johannes Berg
  2013-01-24 17:51   ` Johannes Berg
  0 siblings, 1 reply; 6+ messages in thread
From: Johannes Berg @ 2013-01-24 13:08 UTC (permalink / raw)
  To: linux-wireless; +Cc: Alexander Bondar

On Thu, 2013-01-24 at 13:01 +0100, Johannes Berg wrote:
> From: Alexander Bondar <alexander.bondar@intel.com>
> 
> Add debugfs driver callbacks to be called upon interface addition,
> removal and type change.

Never mind, apparently this doesn't work. I haven't tried myself yet.

johannes


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

* [PATCH] mac80211: Add vif debugfs driver callbacks
@ 2013-01-24 12:01 Johannes Berg
  2013-01-24 13:08 ` Johannes Berg
  0 siblings, 1 reply; 6+ messages in thread
From: Johannes Berg @ 2013-01-24 12:01 UTC (permalink / raw)
  To: linux-wireless; +Cc: Alexander Bondar

From: Alexander Bondar <alexander.bondar@intel.com>

Add debugfs driver callbacks to be called upon interface addition,
removal and type change.

Change-Id: Iaf95ba5b2a6a3fca7d3dd7484de94127d23b8448
Signed-off-by: Alexander Bondar <alexander.bondar@intel.com>
Reviewed-on: http://musxgits01.imu.intel.com:8080/8761
Tested-by: IWL Jenkins
Reviewed-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Reviewed-by: Johannes Berg <johannes.berg@intel.com>
---
 include/net/mac80211.h    | 16 ++++++++++++++++
 net/mac80211/driver-ops.h | 37 +++++++++++++++++++++++++++++++++++++
 net/mac80211/iface.c      |  3 +++
 3 files changed, 56 insertions(+)

diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index f10fe9f..4273e83 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -2165,6 +2165,16 @@ enum ieee80211_rate_control_changed {
  *	MAC address of the device going away.
  *	Hence, this callback must be implemented. It can sleep.
  *
+ * @add_interface_debugfs: Drivers can use this callback to add debugfs files
+ *	when a vif is added to mac80211. This callback and
+ *	@remove_interface_debugfs should be within a CONFIG_MAC80211_DEBUGFS
+ *	conditional. This callback can sleep.
+ *
+ * @remove_interface_debugfs: Remove the debugfs files which were added using
+ *	@add_interface_debugfs. Even if add_interface_debufs is implemented,
+ *	this callback is optional, since all the directory will be removed
+ *	recursively. This callback can sleep.
+ *
  * @config: Handler for configuration requests. IEEE 802.11 code calls this
  *	function to change hardware configuration, e.g., channel.
  *	This function should never fail but returns a negative error code
@@ -2580,6 +2590,12 @@ struct ieee80211_ops {
 				   struct ieee80211_vif *vif,
 				   struct ieee80211_sta *sta,
 				   struct dentry *dir);
+	void (*add_interface_debugfs)(struct ieee80211_hw *hw,
+				      struct ieee80211_vif *vif,
+				      struct dentry *dir);
+	void (*remove_interface_debugfs)(struct ieee80211_hw *hw,
+					 struct ieee80211_vif *vif,
+					 struct dentry *dir);
 #endif
 	void (*sta_notify)(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
 			enum sta_notify_cmd, struct ieee80211_sta *sta);
diff --git a/net/mac80211/driver-ops.h b/net/mac80211/driver-ops.h
index 4ce8d34..c6eef63 100644
--- a/net/mac80211/driver-ops.h
+++ b/net/mac80211/driver-ops.h
@@ -542,6 +542,43 @@ static inline void drv_sta_remove_debugfs(struct ieee80211_local *local,
 		local->ops->sta_remove_debugfs(&local->hw, &sdata->vif,
 					       sta, dir);
 }
+
+static inline
+void drv_add_interface_debugfs(struct ieee80211_local *local,
+			       struct ieee80211_sub_if_data *sdata)
+{
+	might_sleep();
+
+	check_sdata_in_driver(sdata);
+
+	if (!local->ops->add_interface_debugfs)
+		return;
+
+	local->ops->add_interface_debugfs(&local->hw, &sdata->vif,
+					  sdata->debugfs.dir);
+}
+
+static inline
+void drv_remove_interface_debugfs(struct ieee80211_local *local,
+				  struct ieee80211_sub_if_data *sdata)
+{
+	might_sleep();
+
+	check_sdata_in_driver(sdata);
+
+	if (!local->ops->remove_interface_debugfs)
+		return;
+
+	local->ops->remove_interface_debugfs(&local->hw, &sdata->vif,
+					     sdata->debugfs.dir);
+}
+#else
+static inline
+void drv_add_interface_debugfs(struct ieee80211_local *local,
+			       struct ieee80211_sub_if_data *sdata) {}
+static inline
+void drv_remove_interface_debugfs(struct ieee80211_local *local,
+				  struct ieee80211_sub_if_data *sdata) {}
 #endif
 
 static inline __must_check
diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
index 02a3ec6..8bfc2fb 100644
--- a/net/mac80211/iface.c
+++ b/net/mac80211/iface.c
@@ -621,6 +621,8 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
 				goto err_del_interface;
 		}
 
+		drv_add_interface_debugfs(local, sdata);
+
 		if (sdata->vif.type == NL80211_IFTYPE_AP) {
 			local->fif_pspoll++;
 			local->fif_probe_req++;
@@ -887,6 +889,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
 		 */
 		ieee80211_free_keys(sdata);
 
+		drv_remove_interface_debugfs(local, sdata);
 		if (going_down)
 			drv_remove_interface(local, sdata);
 	}
-- 
1.8.0


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

end of thread, other threads:[~2013-02-11 11:49 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-05 11:49 [PATCH] mac80211: add vif debugfs driver callbacks Johannes Berg
2013-02-11 11:49 ` Johannes Berg
  -- strict thread matches above, loose matches on Subject: below --
2013-01-24 12:01 [PATCH] mac80211: Add " Johannes Berg
2013-01-24 13:08 ` Johannes Berg
2013-01-24 17:51   ` Johannes Berg
2013-01-29  9:00     ` Johannes Berg

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.