diff mbox series

[7/7] wifi: mac80211: Add support for interface usage notification

Message ID 20240605135233.4d602acf0e65.I01fecab3b41961038f37ca6e0e3039c5fe9bb6bf@changeid
State New
Headers show
Series cfg80211/mac80211 patches from our internal tree 2024-06-05 | expand

Commit Message

Miri Korenblit June 5, 2024, 10:57 a.m. UTC
From: Ilan Peer <ilan.peer@intel.com>

When user space indicates the intended usage of a network interface,
propagate the information to the driver.

Signed-off-by: Ilan Peer <ilan.peer@intel.com>
Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
---
 include/net/mac80211.h    |  4 ++++
 net/mac80211/cfg.c        | 12 ++++++++++++
 net/mac80211/driver-ops.h | 14 ++++++++++++++
 net/mac80211/trace.h      | 23 +++++++++++++++++++++++
 4 files changed, 53 insertions(+)
diff mbox series

Patch

diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index ecfa65ade226..047dce69e79b 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -4438,6 +4438,7 @@  struct ieee80211_prep_tx_info {
  *	if the requested TID-To-Link mapping can be accepted or not.
  *	If it's not accepted the driver may suggest a preferred mapping and
  *	modify @ttlm parameter with the suggested TID-to-Link mapping.
+ * @iface_usage: notify about intended usage of added interfaces.
  */
 struct ieee80211_ops {
 	void (*tx)(struct ieee80211_hw *hw,
@@ -4822,6 +4823,9 @@  struct ieee80211_ops {
 	enum ieee80211_neg_ttlm_res
 	(*can_neg_ttlm)(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
 			struct ieee80211_neg_ttlm *ttlm);
+
+	void (*iface_usage)(struct ieee80211_hw *hw,
+			    struct cfg80211_iface_usage *iface_usage);
 };
 
 /**
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index 890590146fa4..b121fc65eb09 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -5104,6 +5104,17 @@  ieee80211_set_ttlm(struct wiphy *wiphy, struct net_device *dev,
 	return ieee80211_req_neg_ttlm(sdata, params);
 }
 
+static void
+ieee80211_iface_usage(struct wiphy *wiphy, struct net_device *dev,
+		      struct cfg80211_iface_usage *iface_usage)
+{
+	struct ieee80211_local *local = wiphy_priv(wiphy);
+
+	lockdep_assert_wiphy(wiphy);
+
+	drv_iface_usage(local, iface_usage);
+}
+
 const struct cfg80211_ops mac80211_config_ops = {
 	.add_virtual_intf = ieee80211_add_iface,
 	.del_virtual_intf = ieee80211_del_iface,
@@ -5217,4 +5228,5 @@  const struct cfg80211_ops mac80211_config_ops = {
 	.del_link_station = ieee80211_del_link_station,
 	.set_hw_timestamp = ieee80211_set_hw_timestamp,
 	.set_ttlm = ieee80211_set_ttlm,
+	.iface_usage = ieee80211_iface_usage,
 };
diff --git a/net/mac80211/driver-ops.h b/net/mac80211/driver-ops.h
index d4e73d3630e0..ccc697bd98ff 100644
--- a/net/mac80211/driver-ops.h
+++ b/net/mac80211/driver-ops.h
@@ -1728,4 +1728,18 @@  drv_can_neg_ttlm(struct ieee80211_local *local,
 
 	return res;
 }
+
+static inline void drv_iface_usage(struct ieee80211_local *local,
+				   struct cfg80211_iface_usage *iface_usage)
+{
+	might_sleep();
+
+	lockdep_assert_wiphy(local->hw.wiphy);
+
+	trace_drv_iface_usage(local, iface_usage);
+	if (local->ops->iface_usage)
+		local->ops->iface_usage(&local->hw, iface_usage);
+
+	trace_drv_return_void(local);
+}
 #endif /* __MAC80211_DRIVER_OPS */
diff --git a/net/mac80211/trace.h b/net/mac80211/trace.h
index 8e758b5074bd..b2f2588c7f82 100644
--- a/net/mac80211/trace.h
+++ b/net/mac80211/trace.h
@@ -3145,6 +3145,29 @@  TRACE_EVENT(drv_neg_ttlm_res,
 		  LOCAL_PR_ARG, VIF_PR_ARG, __entry->res
 	)
 );
+
+TRACE_EVENT(drv_iface_usage,
+	TP_PROTO(struct ieee80211_local *local,
+		 struct cfg80211_iface_usage *iface_usage),
+
+	TP_ARGS(local, iface_usage),
+
+	TP_STRUCT__entry(
+		LOCAL_ENTRY
+		__field(u32, types_mask)
+	),
+
+	TP_fast_assign(
+		LOCAL_ASSIGN;
+		__entry->types_mask = iface_usage->types_mask;
+	),
+
+	TP_printk(
+		LOCAL_PR_FMT " types_mask=0x%x",
+		LOCAL_PR_ARG, __entry->types_mask
+	)
+);
+
 #endif /* !__MAC80211_DRIVER_TRACE || TRACE_HEADER_MULTI_READ */
 
 #undef TRACE_INCLUDE_PATH