All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC/RFT v5 0/4] expected throughput from AQL airtime
@ 2022-07-19 12:35 Baligh Gasmi
  2022-07-19 12:35 ` [RFC/RFT v5 1/4] mac80211: use AQL airtime for expected throughput Baligh Gasmi
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: Baligh Gasmi @ 2022-07-19 12:35 UTC (permalink / raw)
  To: Johannes Berg
  Cc: David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	linux-wireless, netdev, linux-kernel, Felix Fietkau,
	Toke Hoiland-Jorgensen, Linus Lussing, Kalle Valo, Baligh Gasmi

v5:
- add busy time percent in NL80211 interface

v4:
- fix compilation error
- Take into acount current channel busy time percent

v3:
- update to new MLO sta struct

v2:
- total size overflow, use u64 instead of u32

v1:
- make one div after at least 100ms rather than one div each skb


Baligh Gasmi (4):
  mac80211: use AQL airtime for expected throughput.
  mac80211: add periodic monitor for channel busy time
  mac80211: add busy time factor into expected throughput
  mac80211: extend channel info with average busy time.

 include/net/cfg80211.h       |  1 +
 include/uapi/linux/nl80211.h |  2 ++
 net/mac80211/cfg.c           |  8 +++++
 net/mac80211/driver-ops.h    |  2 ++
 net/mac80211/ieee80211_i.h   |  6 ++++
 net/mac80211/iface.c         | 65 ++++++++++++++++++++++++++++++++++++
 net/mac80211/sta_info.c      | 46 +++++++++++++++++++++++++
 net/mac80211/sta_info.h      | 11 ++++++
 net/mac80211/status.c        |  2 ++
 net/mac80211/tx.c            |  8 ++++-
 net/wireless/nl80211.c       |  6 ++++
 11 files changed, 156 insertions(+), 1 deletion(-)

-- 
2.37.1


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

* [RFC/RFT v5 1/4] mac80211: use AQL airtime for expected throughput.
  2022-07-19 12:35 [RFC/RFT v5 0/4] expected throughput from AQL airtime Baligh Gasmi
@ 2022-07-19 12:35 ` Baligh Gasmi
  2022-08-25 13:31   ` Nicolas Escande
  2022-07-19 12:35 ` [RFC/RFT v5 2/4] mac80211: add periodic monitor for channel busy time Baligh Gasmi
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 11+ messages in thread
From: Baligh Gasmi @ 2022-07-19 12:35 UTC (permalink / raw)
  To: Johannes Berg
  Cc: David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	linux-wireless, netdev, linux-kernel, Felix Fietkau,
	Toke Hoiland-Jorgensen, Linus Lussing, Kalle Valo, Baligh Gasmi,
	kernel test robot

Since the integration of AQL, packet TX airtime estimation is
calculated and counted to be used for the dequeue limit.

Use this estimated airtime to compute expected throughput for
each station.

It will be a generic mac80211 implementation. that can be used if the
driver do not have get_expected_throughput implementation.

Useful for L2 routing protocols, like B.A.T.M.A.N.

Signed-off-by: Baligh Gasmi <gasmibal@gmail.com>
Reported-by: kernel test robot <lkp@intel.com>
CC: Felix Fietkau <nbd@nbd.name>
---
 net/mac80211/driver-ops.h |  2 ++
 net/mac80211/sta_info.c   | 39 +++++++++++++++++++++++++++++++++++++++
 net/mac80211/sta_info.h   | 11 +++++++++++
 net/mac80211/status.c     |  2 ++
 net/mac80211/tx.c         |  8 +++++++-
 5 files changed, 61 insertions(+), 1 deletion(-)

diff --git a/net/mac80211/driver-ops.h b/net/mac80211/driver-ops.h
index 4e2fc1a08681..fa9952154795 100644
--- a/net/mac80211/driver-ops.h
+++ b/net/mac80211/driver-ops.h
@@ -1142,6 +1142,8 @@ static inline u32 drv_get_expected_throughput(struct ieee80211_local *local,
 	trace_drv_get_expected_throughput(&sta->sta);
 	if (local->ops->get_expected_throughput && sta->uploaded)
 		ret = local->ops->get_expected_throughput(&local->hw, &sta->sta);
+	else
+		ret = ewma_avg_est_tp_read(&sta->deflink.status_stats.avg_est_tp);
 	trace_drv_return_u32(local, ret);
 
 	return ret;
diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c
index e04a0905e941..201aab465234 100644
--- a/net/mac80211/sta_info.c
+++ b/net/mac80211/sta_info.c
@@ -1993,6 +1993,45 @@ void ieee80211_sta_update_pending_airtime(struct ieee80211_local *local,
 			       tx_pending, 0);
 }
 
+void ieee80211_sta_update_tp(struct ieee80211_local *local,
+			     struct sta_info *sta,
+			     struct sk_buff *skb,
+			     u16 tx_time_est,
+			     bool ack, int retry)
+{
+	unsigned long diff;
+	struct rate_control_ref *ref = NULL;
+
+	if (!skb || !sta || !tx_time_est)
+		return;
+
+	if (test_sta_flag(sta, WLAN_STA_RATE_CONTROL))
+		ref = sta->rate_ctrl;
+
+	if (ref && ref->ops->get_expected_throughput)
+		return;
+
+	if (local->ops->get_expected_throughput)
+		return;
+
+	tx_time_est += ack ? 4 : 0;
+	tx_time_est += retry ? retry * 2 : 2;
+
+	sta->deflink.tx_stats.tp_tx_size += (skb->len * 8) * 1000;
+	sta->deflink.tx_stats.tp_tx_time_est += tx_time_est;
+
+	diff = jiffies - sta->deflink.status_stats.last_tp_update;
+	if (diff > HZ / 10) {
+		ewma_avg_est_tp_add(&sta->deflink.status_stats.avg_est_tp,
+				    sta->deflink.tx_stats.tp_tx_size /
+				    sta->deflink.tx_stats.tp_tx_time_est);
+
+		sta->deflink.tx_stats.tp_tx_size = 0;
+		sta->deflink.tx_stats.tp_tx_time_est = 0;
+		sta->deflink.status_stats.last_tp_update = jiffies;
+	}
+}
+
 int sta_info_move_state(struct sta_info *sta,
 			enum ieee80211_sta_state new_state)
 {
diff --git a/net/mac80211/sta_info.h b/net/mac80211/sta_info.h
index 35c390bedfba..4200856fefcd 100644
--- a/net/mac80211/sta_info.h
+++ b/net/mac80211/sta_info.h
@@ -123,6 +123,7 @@ enum ieee80211_sta_info_flags {
 #define HT_AGG_STATE_STOP_CB		7
 #define HT_AGG_STATE_SENT_ADDBA		8
 
+DECLARE_EWMA(avg_est_tp, 8, 16)
 DECLARE_EWMA(avg_signal, 10, 8)
 enum ieee80211_agg_stop_reason {
 	AGG_STOP_DECLINED,
@@ -157,6 +158,12 @@ void ieee80211_register_airtime(struct ieee80211_txq *txq,
 
 struct sta_info;
 
+void ieee80211_sta_update_tp(struct ieee80211_local *local,
+			     struct sta_info *sta,
+			     struct sk_buff *skb,
+			     u16 tx_time_est,
+			     bool ack, int retry);
+
 /**
  * struct tid_ampdu_tx - TID aggregation information (Tx).
  *
@@ -549,6 +556,8 @@ struct link_sta_info {
 		s8 last_ack_signal;
 		bool ack_signal_filled;
 		struct ewma_avg_signal avg_ack_signal;
+		struct ewma_avg_est_tp avg_est_tp;
+		unsigned long last_tp_update;
 	} status_stats;
 
 	/* Updated from TX path only, no locking requirements */
@@ -558,6 +567,8 @@ struct link_sta_info {
 		struct ieee80211_tx_rate last_rate;
 		struct rate_info last_rate_info;
 		u64 msdu[IEEE80211_NUM_TIDS + 1];
+		u64 tp_tx_size;
+		u64 tp_tx_time_est;
 	} tx_stats;
 
 	enum ieee80211_sta_rx_bandwidth cur_max_bandwidth;
diff --git a/net/mac80211/status.c b/net/mac80211/status.c
index e69272139437..1fb93abc1709 100644
--- a/net/mac80211/status.c
+++ b/net/mac80211/status.c
@@ -1152,6 +1152,8 @@ void ieee80211_tx_status_ext(struct ieee80211_hw *hw,
 	ack_signal_valid =
 		!!(info->status.flags & IEEE80211_TX_STATUS_ACK_SIGNAL_VALID);
 
+	ieee80211_sta_update_tp(local, sta, skb, tx_time_est, acked, retry_count);
+
 	if (pubsta) {
 		struct ieee80211_sub_if_data *sdata = sta->sdata;
 
diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
index c425f4fb7c2e..beb79b04c287 100644
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -3617,6 +3617,7 @@ struct sk_buff *ieee80211_tx_dequeue(struct ieee80211_hw *hw,
 	struct ieee80211_tx_data tx;
 	ieee80211_tx_result r;
 	struct ieee80211_vif *vif = txq->vif;
+	struct rate_control_ref *ref = NULL;
 
 	WARN_ON_ONCE(softirq_count() == 0);
 
@@ -3775,8 +3776,13 @@ struct sk_buff *ieee80211_tx_dequeue(struct ieee80211_hw *hw,
 encap_out:
 	IEEE80211_SKB_CB(skb)->control.vif = vif;
 
+	if (tx.sta && test_sta_flag(tx.sta, WLAN_STA_RATE_CONTROL))
+		ref = tx.sta->rate_ctrl;
+
 	if (vif &&
-	    wiphy_ext_feature_isset(local->hw.wiphy, NL80211_EXT_FEATURE_AQL)) {
+	    ((!local->ops->get_expected_throughput &&
+	     (!ref || !ref->ops->get_expected_throughput)) ||
+	    wiphy_ext_feature_isset(local->hw.wiphy, NL80211_EXT_FEATURE_AQL))) {
 		bool ampdu = txq->ac != IEEE80211_AC_VO;
 		u32 airtime;
 
-- 
2.37.1


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

* [RFC/RFT v5 2/4] mac80211: add periodic monitor for channel busy time
  2022-07-19 12:35 [RFC/RFT v5 0/4] expected throughput from AQL airtime Baligh Gasmi
  2022-07-19 12:35 ` [RFC/RFT v5 1/4] mac80211: use AQL airtime for expected throughput Baligh Gasmi
@ 2022-07-19 12:35 ` Baligh Gasmi
  2022-08-25  8:58   ` Johannes Berg
  2022-08-25 13:35   ` Nicolas Escande
  2022-07-19 12:35 ` [RFC/RFT v5 3/4] mac80211: add busy time factor into expected throughput Baligh Gasmi
  2022-07-19 12:35 ` [RFC/RFT v5 4/4] mac80211: extend channel info with average busy time Baligh Gasmi
  3 siblings, 2 replies; 11+ messages in thread
From: Baligh Gasmi @ 2022-07-19 12:35 UTC (permalink / raw)
  To: Johannes Berg
  Cc: David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	linux-wireless, netdev, linux-kernel, Felix Fietkau,
	Toke Hoiland-Jorgensen, Linus Lussing, Kalle Valo, Baligh Gasmi

Add a worker scheduled periodicaly to calculate the busy time average of
the current channel.

This will be used in the estimation for expected throughput.

Signed-off-by: Baligh Gasmi <gasmibal@gmail.com>
---
 net/mac80211/ieee80211_i.h |  6 ++++
 net/mac80211/iface.c       | 65 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 71 insertions(+)

diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
index 86ef0a46a68c..2cb388335ce8 100644
--- a/net/mac80211/ieee80211_i.h
+++ b/net/mac80211/ieee80211_i.h
@@ -901,6 +901,7 @@ struct ieee80211_if_nan {
 	struct idr function_inst_ids;
 };
 
+DECLARE_EWMA(avg_busy, 8, 4)
 struct ieee80211_sub_if_data {
 	struct list_head list;
 
@@ -1024,6 +1025,11 @@ struct ieee80211_sub_if_data {
 	} debugfs;
 #endif
 
+	struct delayed_work monitor_work;
+	u64 last_time;
+	u64 last_time_busy;
+	struct ewma_avg_busy avg_busy;
+
 	/* must be last, dynamically sized area in this! */
 	struct ieee80211_vif vif;
 };
diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
index 15a73b7fdd75..e1b20964933c 100644
--- a/net/mac80211/iface.c
+++ b/net/mac80211/iface.c
@@ -1972,6 +1972,64 @@ static void ieee80211_assign_perm_addr(struct ieee80211_local *local,
 	mutex_unlock(&local->iflist_mtx);
 }
 
+#define DEFAULT_MONITOR_INTERVAL_MS 1000
+
+static void ieee80211_if_monitor_work(struct work_struct *work)
+{
+	struct delayed_work *delayed_work = to_delayed_work(work);
+	struct ieee80211_sub_if_data *sdata =
+		container_of(delayed_work, struct ieee80211_sub_if_data,
+				monitor_work);
+	struct survey_info survey;
+	struct ieee80211_local *local = sdata->local;
+	struct ieee80211_chanctx_conf *chanctx_conf;
+	struct ieee80211_channel *channel = NULL;
+	int q = 0;
+	u64 interval = DEFAULT_MONITOR_INTERVAL_MS;
+
+	rcu_read_lock();
+	chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
+	if (chanctx_conf)
+		channel = chanctx_conf->def.chan;
+	rcu_read_unlock();
+
+	if (!channel)
+		goto end;
+
+	if (!local->started)
+		goto end;
+
+	do {
+		survey.filled = 0;
+		if (drv_get_survey(local, q++, &survey) != 0) {
+			survey.filled = 0;
+			break;
+		}
+	} while (channel != survey.channel);
+
+	if (survey.filled & SURVEY_INFO_TIME) {
+		/* real interval */
+		interval = survey.time - sdata->last_time;
+		/* store last time */
+		sdata->last_time = survey.time;
+	}
+
+	if (survey.filled & SURVEY_INFO_TIME_BUSY) {
+		/* busy */
+		u64 busy = survey.time_busy < sdata->last_time_busy ? 0 :
+			survey.time_busy - sdata->last_time_busy;
+		/* average percent busy time */
+		ewma_avg_busy_add(&sdata->avg_busy,
+				(busy * 100) / interval);
+		/* store last busy time */
+		sdata->last_time_busy = survey.time_busy;
+	}
+
+end:
+	schedule_delayed_work(&sdata->monitor_work,
+			msecs_to_jiffies(DEFAULT_MONITOR_INTERVAL_MS));
+}
+
 int ieee80211_if_add(struct ieee80211_local *local, const char *name,
 		     unsigned char name_assign_type,
 		     struct wireless_dev **new_wdev, enum nl80211_iftype type,
@@ -2085,6 +2143,8 @@ int ieee80211_if_add(struct ieee80211_local *local, const char *name,
 			  ieee80211_dfs_cac_timer_work);
 	INIT_DELAYED_WORK(&sdata->dec_tailroom_needed_wk,
 			  ieee80211_delayed_tailroom_dec);
+	INIT_DELAYED_WORK(&sdata->monitor_work,
+			ieee80211_if_monitor_work);
 
 	for (i = 0; i < NUM_NL80211_BANDS; i++) {
 		struct ieee80211_supported_band *sband;
@@ -2156,6 +2216,9 @@ int ieee80211_if_add(struct ieee80211_local *local, const char *name,
 	list_add_tail_rcu(&sdata->list, &local->interfaces);
 	mutex_unlock(&local->iflist_mtx);
 
+	schedule_delayed_work(&sdata->monitor_work,
+			msecs_to_jiffies(DEFAULT_MONITOR_INTERVAL_MS));
+
 	if (new_wdev)
 		*new_wdev = &sdata->wdev;
 
@@ -2166,6 +2229,8 @@ void ieee80211_if_remove(struct ieee80211_sub_if_data *sdata)
 {
 	ASSERT_RTNL();
 
+	cancel_delayed_work_sync(&sdata->monitor_work);
+
 	mutex_lock(&sdata->local->iflist_mtx);
 	list_del_rcu(&sdata->list);
 	mutex_unlock(&sdata->local->iflist_mtx);
-- 
2.37.1


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

* [RFC/RFT v5 3/4] mac80211: add busy time factor into expected throughput
  2022-07-19 12:35 [RFC/RFT v5 0/4] expected throughput from AQL airtime Baligh Gasmi
  2022-07-19 12:35 ` [RFC/RFT v5 1/4] mac80211: use AQL airtime for expected throughput Baligh Gasmi
  2022-07-19 12:35 ` [RFC/RFT v5 2/4] mac80211: add periodic monitor for channel busy time Baligh Gasmi
@ 2022-07-19 12:35 ` Baligh Gasmi
  2022-08-25 13:36   ` Nicolas Escande
  2022-07-19 12:35 ` [RFC/RFT v5 4/4] mac80211: extend channel info with average busy time Baligh Gasmi
  3 siblings, 1 reply; 11+ messages in thread
From: Baligh Gasmi @ 2022-07-19 12:35 UTC (permalink / raw)
  To: Johannes Berg
  Cc: David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	linux-wireless, netdev, linux-kernel, Felix Fietkau,
	Toke Hoiland-Jorgensen, Linus Lussing, Kalle Valo, Baligh Gasmi

When estimating the expected throughput, take into account the busy time
of the current channel.

Signed-off-by: Baligh Gasmi <gasmibal@gmail.com>
---
 net/mac80211/sta_info.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c
index 201aab465234..7e32c06ae771 100644
--- a/net/mac80211/sta_info.c
+++ b/net/mac80211/sta_info.c
@@ -2000,6 +2000,8 @@ void ieee80211_sta_update_tp(struct ieee80211_local *local,
 			     bool ack, int retry)
 {
 	unsigned long diff;
+	struct ieee80211_sub_if_data *sdata;
+	u32 avg_busy;
 	struct rate_control_ref *ref = NULL;
 
 	if (!skb || !sta || !tx_time_est)
@@ -2014,6 +2016,7 @@ void ieee80211_sta_update_tp(struct ieee80211_local *local,
 	if (local->ops->get_expected_throughput)
 		return;
 
+	sdata = sta->sdata;
 	tx_time_est += ack ? 4 : 0;
 	tx_time_est += retry ? retry * 2 : 2;
 
@@ -2022,6 +2025,10 @@ void ieee80211_sta_update_tp(struct ieee80211_local *local,
 
 	diff = jiffies - sta->deflink.status_stats.last_tp_update;
 	if (diff > HZ / 10) {
+		avg_busy = ewma_avg_busy_read(&sdata->avg_busy) >> 1;
+		sta->deflink.tx_stats.tp_tx_time_est +=
+			(sta->deflink.tx_stats.tp_tx_time_est * avg_busy) / 100;
+
 		ewma_avg_est_tp_add(&sta->deflink.status_stats.avg_est_tp,
 				    sta->deflink.tx_stats.tp_tx_size /
 				    sta->deflink.tx_stats.tp_tx_time_est);
-- 
2.37.1


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

* [RFC/RFT v5 4/4] mac80211: extend channel info with average busy time.
  2022-07-19 12:35 [RFC/RFT v5 0/4] expected throughput from AQL airtime Baligh Gasmi
                   ` (2 preceding siblings ...)
  2022-07-19 12:35 ` [RFC/RFT v5 3/4] mac80211: add busy time factor into expected throughput Baligh Gasmi
@ 2022-07-19 12:35 ` Baligh Gasmi
  3 siblings, 0 replies; 11+ messages in thread
From: Baligh Gasmi @ 2022-07-19 12:35 UTC (permalink / raw)
  To: Johannes Berg
  Cc: David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	linux-wireless, netdev, linux-kernel, Felix Fietkau,
	Toke Hoiland-Jorgensen, Linus Lussing, Kalle Valo, Baligh Gasmi

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 --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:
-- 
2.37.1


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

* Re: [RFC/RFT v5 2/4] mac80211: add periodic monitor for channel busy time
  2022-07-19 12:35 ` [RFC/RFT v5 2/4] mac80211: add periodic monitor for channel busy time Baligh Gasmi
@ 2022-08-25  8:58   ` Johannes Berg
  2022-08-25  9:27     ` Baligh GASMI
  2022-08-25 13:35   ` Nicolas Escande
  1 sibling, 1 reply; 11+ messages in thread
From: Johannes Berg @ 2022-08-25  8:58 UTC (permalink / raw)
  To: Baligh Gasmi
  Cc: David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	linux-wireless, netdev, linux-kernel, Felix Fietkau,
	Toke Hoiland-Jorgensen, Linus Lussing, Kalle Valo

On Tue, 2022-07-19 at 14:35 +0200, Baligh Gasmi wrote:
> Add a worker scheduled periodicaly to calculate the busy time average of
> the current channel.
> 
> This will be used in the estimation for expected throughput.
> 

I really don't think you should/can do this - having a 1-second periodic
timer (for each interface even!) is going to be really bad for power
consumption.

Please find a way to inline the recalculation with statistics updates
and/or queries.

johannes

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

* Re: [RFC/RFT v5 2/4] mac80211: add periodic monitor for channel busy time
  2022-08-25  8:58   ` Johannes Berg
@ 2022-08-25  9:27     ` Baligh GASMI
  0 siblings, 0 replies; 11+ messages in thread
From: Baligh GASMI @ 2022-08-25  9:27 UTC (permalink / raw)
  To: Johannes Berg
  Cc: David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	open list:MAC80211, open list:NETWORKING [GENERAL],
	open list, Felix Fietkau, Toke Hoiland-Jorgensen, Linus Lussing,
	Kalle Valo

Ok, noted !
I will try to find a way or maybe remove this part, since the busy
time is not trivial to be used in the estimation, as I thought.
Thanks for your reply.


Le jeu. 25 août 2022 à 10:58, Johannes Berg
<johannes@sipsolutions.net> a écrit :
>
> On Tue, 2022-07-19 at 14:35 +0200, Baligh Gasmi wrote:
> > Add a worker scheduled periodicaly to calculate the busy time average of
> > the current channel.
> >
> > This will be used in the estimation for expected throughput.
> >
>
> I really don't think you should/can do this - having a 1-second periodic
> timer (for each interface even!) is going to be really bad for power
> consumption.
>
> Please find a way to inline the recalculation with statistics updates
> and/or queries.
>
> johannes

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

* Re: [RFC/RFT v5 1/4] mac80211: use AQL airtime for expected throughput.
  2022-07-19 12:35 ` [RFC/RFT v5 1/4] mac80211: use AQL airtime for expected throughput Baligh Gasmi
@ 2022-08-25 13:31   ` Nicolas Escande
  2022-08-25 14:17     ` Baligh GASMI
  0 siblings, 1 reply; 11+ messages in thread
From: Nicolas Escande @ 2022-08-25 13:31 UTC (permalink / raw)
  To: Baligh Gasmi, Johannes Berg
  Cc: David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	linux-wireless, netdev, linux-kernel, Felix Fietkau,
	Toke Hoiland-Jorgensen, Linus Lussing, Kalle Valo,
	kernel test robot

Hello Baligh,

On Tue Jul 19, 2022 at 2:35 PM CEST, Baligh Gasmi wrote:
> Since the integration of AQL, packet TX airtime estimation is
> calculated and counted to be used for the dequeue limit.
>
> Use this estimated airtime to compute expected throughput for
> each station.
>
> It will be a generic mac80211 implementation. that can be used if the
> driver do not have get_expected_throughput implementation.
>
> Useful for L2 routing protocols, like B.A.T.M.A.N.
>
> Signed-off-by: Baligh Gasmi <gasmibal@gmail.com>
> Reported-by: kernel test robot <lkp@intel.com>
> CC: Felix Fietkau <nbd@nbd.name>
> ---
>  net/mac80211/driver-ops.h |  2 ++
>  net/mac80211/sta_info.c   | 39 +++++++++++++++++++++++++++++++++++++++
>  net/mac80211/sta_info.h   | 11 +++++++++++
>  net/mac80211/status.c     |  2 ++
>  net/mac80211/tx.c         |  8 +++++++-
>  5 files changed, 61 insertions(+), 1 deletion(-)
>
> diff --git a/net/mac80211/driver-ops.h b/net/mac80211/driver-ops.h
> index 4e2fc1a08681..fa9952154795 100644
> --- a/net/mac80211/driver-ops.h
> +++ b/net/mac80211/driver-ops.h
> @@ -1142,6 +1142,8 @@ static inline u32 drv_get_expected_throughput(struct ieee80211_local *local,
>  	trace_drv_get_expected_throughput(&sta->sta);
>  	if (local->ops->get_expected_throughput && sta->uploaded)
>  		ret = local->ops->get_expected_throughput(&local->hw, &sta->sta);
> +	else
> +		ret = ewma_avg_est_tp_read(&sta->deflink.status_stats.avg_est_tp);
>  	trace_drv_return_u32(local, ret);
>
>  	return ret;
> diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c
> index e04a0905e941..201aab465234 100644
> --- a/net/mac80211/sta_info.c
> +++ b/net/mac80211/sta_info.c
> @@ -1993,6 +1993,45 @@ void ieee80211_sta_update_pending_airtime(struct ieee80211_local *local,
>  			       tx_pending, 0);
>  }
>
> +void ieee80211_sta_update_tp(struct ieee80211_local *local,
> +			     struct sta_info *sta,
> +			     struct sk_buff *skb,
> +			     u16 tx_time_est,
> +			     bool ack, int retry)
> +{
> +	unsigned long diff;
> +	struct rate_control_ref *ref = NULL;
> +
> +	if (!skb || !sta || !tx_time_est)
> +		return;
> +
> +	if (test_sta_flag(sta, WLAN_STA_RATE_CONTROL))
> +		ref = sta->rate_ctrl;
> +
> +	if (ref && ref->ops->get_expected_throughput)
> +		return;
> +
> +	if (local->ops->get_expected_throughput)
> +		return;
> +
> +	tx_time_est += ack ? 4 : 0;
> +	tx_time_est += retry ? retry * 2 : 2;
> +
> +	sta->deflink.tx_stats.tp_tx_size += (skb->len * 8) * 1000;
> +	sta->deflink.tx_stats.tp_tx_time_est += tx_time_est;
> +
> +	diff = jiffies - sta->deflink.status_stats.last_tp_update;
> +	if (diff > HZ / 10) {
> +		ewma_avg_est_tp_add(&sta->deflink.status_stats.avg_est_tp,
> +				    sta->deflink.tx_stats.tp_tx_size /
> +				    sta->deflink.tx_stats.tp_tx_time_est);
This needs a div_u64(), the arch may not have native 64 bits div support
> +
> +		sta->deflink.tx_stats.tp_tx_size = 0;
> +		sta->deflink.tx_stats.tp_tx_time_est = 0;
> +		sta->deflink.status_stats.last_tp_update = jiffies;
> +	}
> +}
> +
>  int sta_info_move_state(struct sta_info *sta,
>  			enum ieee80211_sta_state new_state)
>  {
> diff --git a/net/mac80211/sta_info.h b/net/mac80211/sta_info.h
> index 35c390bedfba..4200856fefcd 100644
> --- a/net/mac80211/sta_info.h
> +++ b/net/mac80211/sta_info.h
> @@ -123,6 +123,7 @@ enum ieee80211_sta_info_flags {
>  #define HT_AGG_STATE_STOP_CB		7
>  #define HT_AGG_STATE_SENT_ADDBA		8
>
> +DECLARE_EWMA(avg_est_tp, 8, 16)
>  DECLARE_EWMA(avg_signal, 10, 8)
>  enum ieee80211_agg_stop_reason {
>  	AGG_STOP_DECLINED,
> @@ -157,6 +158,12 @@ void ieee80211_register_airtime(struct ieee80211_txq *txq,
>
>  struct sta_info;
>
> +void ieee80211_sta_update_tp(struct ieee80211_local *local,
> +			     struct sta_info *sta,
> +			     struct sk_buff *skb,
> +			     u16 tx_time_est,
> +			     bool ack, int retry);
> +
>  /**
>   * struct tid_ampdu_tx - TID aggregation information (Tx).
>   *
> @@ -549,6 +556,8 @@ struct link_sta_info {
>  		s8 last_ack_signal;
>  		bool ack_signal_filled;
>  		struct ewma_avg_signal avg_ack_signal;
> +		struct ewma_avg_est_tp avg_est_tp;
> +		unsigned long last_tp_update;
>  	} status_stats;
>
>  	/* Updated from TX path only, no locking requirements */
> @@ -558,6 +567,8 @@ struct link_sta_info {
>  		struct ieee80211_tx_rate last_rate;
>  		struct rate_info last_rate_info;
>  		u64 msdu[IEEE80211_NUM_TIDS + 1];
> +		u64 tp_tx_size;
> +		u64 tp_tx_time_est;
>  	} tx_stats;
>
>  	enum ieee80211_sta_rx_bandwidth cur_max_bandwidth;
> diff --git a/net/mac80211/status.c b/net/mac80211/status.c
> index e69272139437..1fb93abc1709 100644
> --- a/net/mac80211/status.c
> +++ b/net/mac80211/status.c
> @@ -1152,6 +1152,8 @@ void ieee80211_tx_status_ext(struct ieee80211_hw *hw,
>  	ack_signal_valid >  		!!(info->status.flags & IEEE80211_TX_STATUS_ACK_SIGNAL_VALID);
>
> +	ieee80211_sta_update_tp(local, sta, skb, tx_time_est, acked, retry_count);
> +
>  	if (pubsta) {
>  		struct ieee80211_sub_if_data *sdata = sta->sdata;
>
> diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
> index c425f4fb7c2e..beb79b04c287 100644
> --- a/net/mac80211/tx.c
> +++ b/net/mac80211/tx.c
> @@ -3617,6 +3617,7 @@ struct sk_buff *ieee80211_tx_dequeue(struct ieee80211_hw *hw,
>  	struct ieee80211_tx_data tx;
>  	ieee80211_tx_result r;
>  	struct ieee80211_vif *vif = txq->vif;
> +	struct rate_control_ref *ref = NULL;
>
>  	WARN_ON_ONCE(softirq_count() == 0);
>
> @@ -3775,8 +3776,13 @@ struct sk_buff *ieee80211_tx_dequeue(struct ieee80211_hw *hw,
>  encap_out:
>  	IEEE80211_SKB_CB(skb)->control.vif = vif;
>
> +	if (tx.sta && test_sta_flag(tx.sta, WLAN_STA_RATE_CONTROL))
> +		ref = tx.sta->rate_ctrl;
> +
>  	if (vif &&
> -	    wiphy_ext_feature_isset(local->hw.wiphy, NL80211_EXT_FEATURE_AQL)) {
> +	    ((!local->ops->get_expected_throughput &&
> +	     (!ref || !ref->ops->get_expected_throughput)) ||
> +	    wiphy_ext_feature_isset(local->hw.wiphy, NL80211_EXT_FEATURE_AQL))) {
>  		bool ampdu = txq->ac != IEEE80211_AC_VO;
>  		u32 airtime;
>
> --
> 2.37.1


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

* Re: [RFC/RFT v5 2/4] mac80211: add periodic monitor for channel busy time
  2022-07-19 12:35 ` [RFC/RFT v5 2/4] mac80211: add periodic monitor for channel busy time Baligh Gasmi
  2022-08-25  8:58   ` Johannes Berg
@ 2022-08-25 13:35   ` Nicolas Escande
  1 sibling, 0 replies; 11+ messages in thread
From: Nicolas Escande @ 2022-08-25 13:35 UTC (permalink / raw)
  To: Baligh Gasmi, Johannes Berg
  Cc: David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	linux-wireless, netdev, linux-kernel, Felix Fietkau,
	Toke Hoiland-Jorgensen, Linus Lussing, Kalle Valo

On Tue Jul 19, 2022 at 2:35 PM CEST, Baligh Gasmi wrote:
> Add a worker scheduled periodicaly to calculate the busy time average of
> the current channel.
>
> This will be used in the estimation for expected throughput.
>
> Signed-off-by: Baligh Gasmi <gasmibal@gmail.com>
> ---
>  net/mac80211/ieee80211_i.h |  6 ++++
>  net/mac80211/iface.c       | 65 ++++++++++++++++++++++++++++++++++++++
>  2 files changed, 71 insertions(+)
>
> diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
> index 86ef0a46a68c..2cb388335ce8 100644
> --- a/net/mac80211/ieee80211_i.h
> +++ b/net/mac80211/ieee80211_i.h
> @@ -901,6 +901,7 @@ struct ieee80211_if_nan {
>  	struct idr function_inst_ids;
>  };
>
> +DECLARE_EWMA(avg_busy, 8, 4)
>  struct ieee80211_sub_if_data {
>  	struct list_head list;
>
> @@ -1024,6 +1025,11 @@ struct ieee80211_sub_if_data {
>  	} debugfs;
>  #endif
>
> +	struct delayed_work monitor_work;
> +	u64 last_time;
> +	u64 last_time_busy;
> +	struct ewma_avg_busy avg_busy;
> +
>  	/* must be last, dynamically sized area in this! */
>  	struct ieee80211_vif vif;
>  };
> diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
> index 15a73b7fdd75..e1b20964933c 100644
> --- a/net/mac80211/iface.c
> +++ b/net/mac80211/iface.c
> @@ -1972,6 +1972,64 @@ static void ieee80211_assign_perm_addr(struct ieee80211_local *local,
>  	mutex_unlock(&local->iflist_mtx);
>  }
>
> +#define DEFAULT_MONITOR_INTERVAL_MS 1000
> +
> +static void ieee80211_if_monitor_work(struct work_struct *work)
> +{
> +	struct delayed_work *delayed_work = to_delayed_work(work);
> +	struct ieee80211_sub_if_data *sdata > +		container_of(delayed_work, struct ieee80211_sub_if_data,
> +				monitor_work);
> +	struct survey_info survey;
> +	struct ieee80211_local *local = sdata->local;
> +	struct ieee80211_chanctx_conf *chanctx_conf;
> +	struct ieee80211_channel *channel = NULL;
> +	int q = 0;
> +	u64 interval = DEFAULT_MONITOR_INTERVAL_MS;
> +
> +	rcu_read_lock();
> +	chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
> +	if (chanctx_conf)
> +		channel = chanctx_conf->def.chan;
> +	rcu_read_unlock();
> +
> +	if (!channel)
> +		goto end;
> +
> +	if (!local->started)
> +		goto end;
> +
> +	do {
> +		survey.filled = 0;
> +		if (drv_get_survey(local, q++, &survey) != 0) {
> +			survey.filled = 0;
> +			break;
> +		}
> +	} while (channel != survey.channel);
> +
> +	if (survey.filled & SURVEY_INFO_TIME) {
> +		/* real interval */
> +		interval = survey.time - sdata->last_time;
> +		/* store last time */
> +		sdata->last_time = survey.time;
> +	}
> +
> +	if (survey.filled & SURVEY_INFO_TIME_BUSY) {
> +		/* busy */
> +		u64 busy = survey.time_busy < sdata->last_time_busy ? 0 :
> +			survey.time_busy - sdata->last_time_busy;
> +		/* average percent busy time */
> +		ewma_avg_busy_add(&sdata->avg_busy,
> +				(busy * 100) / interval);
This could use a div_u64()
> +		/* store last busy time */
> +		sdata->last_time_busy = survey.time_busy;
> +	}
> +
> +end:
> +	schedule_delayed_work(&sdata->monitor_work,
> +			msecs_to_jiffies(DEFAULT_MONITOR_INTERVAL_MS));
> +}
> +
>  int ieee80211_if_add(struct ieee80211_local *local, const char *name,
>  		     unsigned char name_assign_type,
>  		     struct wireless_dev **new_wdev, enum nl80211_iftype type,
> @@ -2085,6 +2143,8 @@ int ieee80211_if_add(struct ieee80211_local *local, const char *name,
>  			  ieee80211_dfs_cac_timer_work);
>  	INIT_DELAYED_WORK(&sdata->dec_tailroom_needed_wk,
>  			  ieee80211_delayed_tailroom_dec);
> +	INIT_DELAYED_WORK(&sdata->monitor_work,
> +			ieee80211_if_monitor_work);
>
>  	for (i = 0; i < NUM_NL80211_BANDS; i++) {
>  		struct ieee80211_supported_band *sband;
> @@ -2156,6 +2216,9 @@ int ieee80211_if_add(struct ieee80211_local *local, const char *name,
>  	list_add_tail_rcu(&sdata->list, &local->interfaces);
>  	mutex_unlock(&local->iflist_mtx);
>
> +	schedule_delayed_work(&sdata->monitor_work,
> +			msecs_to_jiffies(DEFAULT_MONITOR_INTERVAL_MS));
> +
>  	if (new_wdev)
>  		*new_wdev = &sdata->wdev;
>
> @@ -2166,6 +2229,8 @@ void ieee80211_if_remove(struct ieee80211_sub_if_data *sdata)
>  {
>  	ASSERT_RTNL();
>
> +	cancel_delayed_work_sync(&sdata->monitor_work);
> +
>  	mutex_lock(&sdata->local->iflist_mtx);
>  	list_del_rcu(&sdata->list);
>  	mutex_unlock(&sdata->local->iflist_mtx);
> --
> 2.37.1


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

* Re: [RFC/RFT v5 3/4] mac80211: add busy time factor into expected throughput
  2022-07-19 12:35 ` [RFC/RFT v5 3/4] mac80211: add busy time factor into expected throughput Baligh Gasmi
@ 2022-08-25 13:36   ` Nicolas Escande
  0 siblings, 0 replies; 11+ messages in thread
From: Nicolas Escande @ 2022-08-25 13:36 UTC (permalink / raw)
  To: Baligh Gasmi, Johannes Berg
  Cc: David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	linux-wireless, netdev, linux-kernel, Felix Fietkau,
	Toke Hoiland-Jorgensen, Linus Lussing, Kalle Valo

On Tue Jul 19, 2022 at 2:35 PM CEST, Baligh Gasmi wrote:
> When estimating the expected throughput, take into account the busy time
> of the current channel.
>
> Signed-off-by: Baligh Gasmi <gasmibal@gmail.com>
> ---
>  net/mac80211/sta_info.c | 7 +++++++
>  1 file changed, 7 insertions(+)
>
> diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c
> index 201aab465234..7e32c06ae771 100644
> --- a/net/mac80211/sta_info.c
> +++ b/net/mac80211/sta_info.c
> @@ -2000,6 +2000,8 @@ void ieee80211_sta_update_tp(struct ieee80211_local *local,
>  			     bool ack, int retry)
>  {
>  	unsigned long diff;
> +	struct ieee80211_sub_if_data *sdata;
> +	u32 avg_busy;
>  	struct rate_control_ref *ref = NULL;
>
>  	if (!skb || !sta || !tx_time_est)
> @@ -2014,6 +2016,7 @@ void ieee80211_sta_update_tp(struct ieee80211_local *local,
>  	if (local->ops->get_expected_throughput)
>  		return;
>
> +	sdata = sta->sdata;
>  	tx_time_est += ack ? 4 : 0;
>  	tx_time_est += retry ? retry * 2 : 2;
>
> @@ -2022,6 +2025,10 @@ void ieee80211_sta_update_tp(struct ieee80211_local *local,
>
>  	diff = jiffies - sta->deflink.status_stats.last_tp_update;
>  	if (diff > HZ / 10) {
> +		avg_busy = ewma_avg_busy_read(&sdata->avg_busy) >> 1;
> +		sta->deflink.tx_stats.tp_tx_time_est +> +			(sta->deflink.tx_stats.tp_tx_time_est * avg_busy) / 100;
Once again div_u64() ?
> +
>  		ewma_avg_est_tp_add(&sta->deflink.status_stats.avg_est_tp,
>  				    sta->deflink.tx_stats.tp_tx_size /
>  				    sta->deflink.tx_stats.tp_tx_time_est);
> --
> 2.37.1


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

* Re: [RFC/RFT v5 1/4] mac80211: use AQL airtime for expected throughput.
  2022-08-25 13:31   ` Nicolas Escande
@ 2022-08-25 14:17     ` Baligh GASMI
  0 siblings, 0 replies; 11+ messages in thread
From: Baligh GASMI @ 2022-08-25 14:17 UTC (permalink / raw)
  To: Nicolas Escande
  Cc: Johannes Berg, David S . Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, open list:MAC80211, open list:NETWORKING [GENERAL],
	open list, Felix Fietkau, Toke Hoiland-Jorgensen, Linus Lussing,
	Kalle Valo, kernel test robot

Hello Nicolas,

Yes, you are right.
I'll take it into account in the next version, and the other 64bits
divisions you detected on the other patches.

Thanks



Le jeu. 25 août 2022 à 15:49, Nicolas Escande <nico.escande@gmail.com> a écrit :
>
> Hello Baligh,
>
> On Tue Jul 19, 2022 at 2:35 PM CEST, Baligh Gasmi wrote:
> > Since the integration of AQL, packet TX airtime estimation is
> > calculated and counted to be used for the dequeue limit.
> >
> > Use this estimated airtime to compute expected throughput for
> > each station.
> >
> > It will be a generic mac80211 implementation. that can be used if the
> > driver do not have get_expected_throughput implementation.
> >
> > Useful for L2 routing protocols, like B.A.T.M.A.N.
> >
> > Signed-off-by: Baligh Gasmi <gasmibal@gmail.com>
> > Reported-by: kernel test robot <lkp@intel.com>
> > CC: Felix Fietkau <nbd@nbd.name>
> > ---
> >  net/mac80211/driver-ops.h |  2 ++
> >  net/mac80211/sta_info.c   | 39 +++++++++++++++++++++++++++++++++++++++
> >  net/mac80211/sta_info.h   | 11 +++++++++++
> >  net/mac80211/status.c     |  2 ++
> >  net/mac80211/tx.c         |  8 +++++++-
> >  5 files changed, 61 insertions(+), 1 deletion(-)
> >
> > diff --git a/net/mac80211/driver-ops.h b/net/mac80211/driver-ops.h
> > index 4e2fc1a08681..fa9952154795 100644
> > --- a/net/mac80211/driver-ops.h
> > +++ b/net/mac80211/driver-ops.h
> > @@ -1142,6 +1142,8 @@ static inline u32 drv_get_expected_throughput(struct ieee80211_local *local,
> >       trace_drv_get_expected_throughput(&sta->sta);
> >       if (local->ops->get_expected_throughput && sta->uploaded)
> >               ret = local->ops->get_expected_throughput(&local->hw, &sta->sta);
> > +     else
> > +             ret = ewma_avg_est_tp_read(&sta->deflink.status_stats.avg_est_tp);
> >       trace_drv_return_u32(local, ret);
> >
> >       return ret;
> > diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c
> > index e04a0905e941..201aab465234 100644
> > --- a/net/mac80211/sta_info.c
> > +++ b/net/mac80211/sta_info.c
> > @@ -1993,6 +1993,45 @@ void ieee80211_sta_update_pending_airtime(struct ieee80211_local *local,
> >                              tx_pending, 0);
> >  }
> >
> > +void ieee80211_sta_update_tp(struct ieee80211_local *local,
> > +                          struct sta_info *sta,
> > +                          struct sk_buff *skb,
> > +                          u16 tx_time_est,
> > +                          bool ack, int retry)
> > +{
> > +     unsigned long diff;
> > +     struct rate_control_ref *ref = NULL;
> > +
> > +     if (!skb || !sta || !tx_time_est)
> > +             return;
> > +
> > +     if (test_sta_flag(sta, WLAN_STA_RATE_CONTROL))
> > +             ref = sta->rate_ctrl;
> > +
> > +     if (ref && ref->ops->get_expected_throughput)
> > +             return;
> > +
> > +     if (local->ops->get_expected_throughput)
> > +             return;
> > +
> > +     tx_time_est += ack ? 4 : 0;
> > +     tx_time_est += retry ? retry * 2 : 2;
> > +
> > +     sta->deflink.tx_stats.tp_tx_size += (skb->len * 8) * 1000;
> > +     sta->deflink.tx_stats.tp_tx_time_est += tx_time_est;
> > +
> > +     diff = jiffies - sta->deflink.status_stats.last_tp_update;
> > +     if (diff > HZ / 10) {
> > +             ewma_avg_est_tp_add(&sta->deflink.status_stats.avg_est_tp,
> > +                                 sta->deflink.tx_stats.tp_tx_size /
> > +                                 sta->deflink.tx_stats.tp_tx_time_est);
> This needs a div_u64(), the arch may not have native 64 bits div support
> > +
> > +             sta->deflink.tx_stats.tp_tx_size = 0;
> > +             sta->deflink.tx_stats.tp_tx_time_est = 0;
> > +             sta->deflink.status_stats.last_tp_update = jiffies;
> > +     }
> > +}
> > +
> >  int sta_info_move_state(struct sta_info *sta,
> >                       enum ieee80211_sta_state new_state)
> >  {
> > diff --git a/net/mac80211/sta_info.h b/net/mac80211/sta_info.h
> > index 35c390bedfba..4200856fefcd 100644
> > --- a/net/mac80211/sta_info.h
> > +++ b/net/mac80211/sta_info.h
> > @@ -123,6 +123,7 @@ enum ieee80211_sta_info_flags {
> >  #define HT_AGG_STATE_STOP_CB         7
> >  #define HT_AGG_STATE_SENT_ADDBA              8
> >
> > +DECLARE_EWMA(avg_est_tp, 8, 16)
> >  DECLARE_EWMA(avg_signal, 10, 8)
> >  enum ieee80211_agg_stop_reason {
> >       AGG_STOP_DECLINED,
> > @@ -157,6 +158,12 @@ void ieee80211_register_airtime(struct ieee80211_txq *txq,
> >
> >  struct sta_info;
> >
> > +void ieee80211_sta_update_tp(struct ieee80211_local *local,
> > +                          struct sta_info *sta,
> > +                          struct sk_buff *skb,
> > +                          u16 tx_time_est,
> > +                          bool ack, int retry);
> > +
> >  /**
> >   * struct tid_ampdu_tx - TID aggregation information (Tx).
> >   *
> > @@ -549,6 +556,8 @@ struct link_sta_info {
> >               s8 last_ack_signal;
> >               bool ack_signal_filled;
> >               struct ewma_avg_signal avg_ack_signal;
> > +             struct ewma_avg_est_tp avg_est_tp;
> > +             unsigned long last_tp_update;
> >       } status_stats;
> >
> >       /* Updated from TX path only, no locking requirements */
> > @@ -558,6 +567,8 @@ struct link_sta_info {
> >               struct ieee80211_tx_rate last_rate;
> >               struct rate_info last_rate_info;
> >               u64 msdu[IEEE80211_NUM_TIDS + 1];
> > +             u64 tp_tx_size;
> > +             u64 tp_tx_time_est;
> >       } tx_stats;
> >
> >       enum ieee80211_sta_rx_bandwidth cur_max_bandwidth;
> > diff --git a/net/mac80211/status.c b/net/mac80211/status.c
> > index e69272139437..1fb93abc1709 100644
> > --- a/net/mac80211/status.c
> > +++ b/net/mac80211/status.c
> > @@ -1152,6 +1152,8 @@ void ieee80211_tx_status_ext(struct ieee80211_hw *hw,
> >       ack_signal_valid >              !!(info->status.flags & IEEE80211_TX_STATUS_ACK_SIGNAL_VALID);
> >
> > +     ieee80211_sta_update_tp(local, sta, skb, tx_time_est, acked, retry_count);
> > +
> >       if (pubsta) {
> >               struct ieee80211_sub_if_data *sdata = sta->sdata;
> >
> > diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
> > index c425f4fb7c2e..beb79b04c287 100644
> > --- a/net/mac80211/tx.c
> > +++ b/net/mac80211/tx.c
> > @@ -3617,6 +3617,7 @@ struct sk_buff *ieee80211_tx_dequeue(struct ieee80211_hw *hw,
> >       struct ieee80211_tx_data tx;
> >       ieee80211_tx_result r;
> >       struct ieee80211_vif *vif = txq->vif;
> > +     struct rate_control_ref *ref = NULL;
> >
> >       WARN_ON_ONCE(softirq_count() == 0);
> >
> > @@ -3775,8 +3776,13 @@ struct sk_buff *ieee80211_tx_dequeue(struct ieee80211_hw *hw,
> >  encap_out:
> >       IEEE80211_SKB_CB(skb)->control.vif = vif;
> >
> > +     if (tx.sta && test_sta_flag(tx.sta, WLAN_STA_RATE_CONTROL))
> > +             ref = tx.sta->rate_ctrl;
> > +
> >       if (vif &&
> > -         wiphy_ext_feature_isset(local->hw.wiphy, NL80211_EXT_FEATURE_AQL)) {
> > +         ((!local->ops->get_expected_throughput &&
> > +          (!ref || !ref->ops->get_expected_throughput)) ||
> > +         wiphy_ext_feature_isset(local->hw.wiphy, NL80211_EXT_FEATURE_AQL))) {
> >               bool ampdu = txq->ac != IEEE80211_AC_VO;
> >               u32 airtime;
> >
> > --
> > 2.37.1
>

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

end of thread, other threads:[~2022-08-25 14:17 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-19 12:35 [RFC/RFT v5 0/4] expected throughput from AQL airtime Baligh Gasmi
2022-07-19 12:35 ` [RFC/RFT v5 1/4] mac80211: use AQL airtime for expected throughput Baligh Gasmi
2022-08-25 13:31   ` Nicolas Escande
2022-08-25 14:17     ` Baligh GASMI
2022-07-19 12:35 ` [RFC/RFT v5 2/4] mac80211: add periodic monitor for channel busy time Baligh Gasmi
2022-08-25  8:58   ` Johannes Berg
2022-08-25  9:27     ` Baligh GASMI
2022-08-25 13:35   ` Nicolas Escande
2022-07-19 12:35 ` [RFC/RFT v5 3/4] mac80211: add busy time factor into expected throughput Baligh Gasmi
2022-08-25 13:36   ` Nicolas Escande
2022-07-19 12:35 ` [RFC/RFT v5 4/4] mac80211: extend channel info with average busy time Baligh Gasmi

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.