diff mbox series

[RFC/RFT,v5,4/4] mac80211: extend channel info with average busy time.

Message ID 20220719123525.3448926-5-gasmibal@gmail.com (mailing list archive)
State Changes Requested
Delegated to: Johannes Berg
Headers show
Series expected throughput from AQL airtime | expand

Commit Message

Baligh GASMI July 19, 2022, 12:35 p.m. UTC
Add the average busy time of the channel in the nl80211.

Signed-off-by: Baligh Gasmi <gasmibal@gmail.com>
---
 include/net/cfg80211.h       | 1 +
 include/uapi/linux/nl80211.h | 2 ++
 net/mac80211/cfg.c           | 8 ++++++++
 net/wireless/nl80211.c       | 6 ++++++
 4 files changed, 17 insertions(+)
diff mbox series

Patch

diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 80f41446b1f0..38bafcaf3446 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -4494,6 +4494,7 @@  struct cfg80211_ops {
 				struct cfg80211_fils_aad *fils_aad);
 	int	(*set_radar_background)(struct wiphy *wiphy,
 					struct cfg80211_chan_def *chandef);
+	int     (*get_avg_busy_time)(struct wiphy *wiphy, struct net_device *dev);
 };
 
 /*
diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
index d9490e3062a7..4e625f656bd6 100644
--- a/include/uapi/linux/nl80211.h
+++ b/include/uapi/linux/nl80211.h
@@ -3177,6 +3177,8 @@  enum nl80211_attrs {
 
 	NL80211_ATTR_DISABLE_EHT,
 
+	NL80211_ATTR_WIPHY_AVG_BUSY_TIME,
+
 	/* add attributes here, update the policy in nl80211.c */
 
 	__NL80211_ATTR_AFTER_LAST,
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index 4ddf297f40f2..21a9d0b37ff5 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -4536,6 +4536,13 @@  ieee80211_set_radar_background(struct wiphy *wiphy,
 	return local->ops->set_radar_background(&local->hw, chandef);
 }
 
+static int ieee80211_get_avg_busy_time(struct wiphy *wiphy,
+				       struct net_device *dev)
+{
+	struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
+	return ewma_avg_busy_read(&sdata->avg_busy);
+}
+
 const struct cfg80211_ops mac80211_config_ops = {
 	.add_virtual_intf = ieee80211_add_iface,
 	.del_virtual_intf = ieee80211_del_iface,
@@ -4641,4 +4648,5 @@  const struct cfg80211_ops mac80211_config_ops = {
 	.set_sar_specs = ieee80211_set_sar_specs,
 	.color_change = ieee80211_color_change,
 	.set_radar_background = ieee80211_set_radar_background,
+	.get_avg_busy_time = ieee80211_get_avg_busy_time,
 };
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 740b29481bc6..eeb3d85fd506 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -3717,6 +3717,12 @@  static int nl80211_send_iface(struct sk_buff *msg, u32 portid, u32 seq, int flag
 			goto nla_put_failure;
 	}
 
+	if (rdev->ops->get_avg_busy_time) {
+		int busy = rdev->ops->get_avg_busy_time(&rdev->wiphy, dev);
+		nla_put_u32(msg, NL80211_ATTR_WIPHY_AVG_BUSY_TIME,
+			   busy);
+	}
+
 	wdev_lock(wdev);
 	switch (wdev->iftype) {
 	case NL80211_IFTYPE_AP: