b.a.t.m.a.n.lists.open-mesh.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] batman-adv: Use wifi rx/tx as fallback throughput
@ 2019-06-09 10:19 René Treffer
  2019-06-09 10:37 ` Sven Eckelmann
                   ` (2 more replies)
  0 siblings, 3 replies; 16+ messages in thread
From: René Treffer @ 2019-06-09 10:19 UTC (permalink / raw)
  To: b.a.t.m.a.n

From: rtreffer <treffer@measite.de>

Some wifi drivers (e.g. ath10k) provide per-station rx/tx values but no
estimated throughput. Setting a better estimate than the default 1MBit
makes these devices work well with BATMAN V.

Signed-off-by: René Treffer <treffer@measite.de>
---
 net/batman-adv/bat_v_elp.c | 23 +++++++++++++++++++----
 1 file changed, 19 insertions(+), 4 deletions(-)

diff --git a/net/batman-adv/bat_v_elp.c b/net/batman-adv/bat_v_elp.c
index 2614a9ca..ce3b52f1 100644
--- a/net/batman-adv/bat_v_elp.c
+++ b/net/batman-adv/bat_v_elp.c
@@ -68,7 +68,7 @@ static u32 batadv_v_elp_get_throughput(struct batadv_hardif_neigh_node *neigh)
 	struct ethtool_link_ksettings link_settings;
 	struct net_device *real_netdev;
 	struct station_info sinfo;
-	u32 throughput;
+	u32 throughput, rx, tx;
 	int ret;
 
 	/* if the user specified a customised value for this interface, then
@@ -107,10 +107,25 @@ static u32 batadv_v_elp_get_throughput(struct batadv_hardif_neigh_node *neigh)
 		}
 		if (ret)
 			goto default_throughput;
-		if (!(sinfo.filled & BIT(NL80211_STA_INFO_EXPECTED_THROUGHPUT)))
-			goto default_throughput;
 
-		return sinfo.expected_throughput / 100;
+		if (sinfo.filled & BIT(NL80211_STA_INFO_EXPECTED_THROUGHPUT)) {
+			return sinfo.expected_throughput / 100;
+		}
+
+		// try to estimate en expected throughput based on reported rx/tx rates
+		// 1/3 of tx or 1/3 of the average of rx and tx, whichever is smaller
+		if (sinfo.filled & BIT(NL80211_STA_INFO_TX_BITRATE)) {
+			tx = cfg80211_calculate_bitrate(&sinfo.txrate);
+			if (sinfo.filled & BIT(NL80211_STA_INFO_RX_BITRATE)) {
+				rx = cfg80211_calculate_bitrate(&sinfo.rxrate);
+				if (rx < tx) {
+					return (rx + tx) / 6;
+				}
+			}
+			return tx / 3;
+		}
+
+		goto default_throughput;
 	}
 
 	/* if not a wifi interface, check if this device provides data via
-- 
2.20.1


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

end of thread, other threads:[~2019-08-11 13:17 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-09 10:19 [PATCH] batman-adv: Use wifi rx/tx as fallback throughput René Treffer
2019-06-09 10:37 ` Sven Eckelmann
2019-06-09 11:40   ` Marek Lindner
2019-06-09 12:45     ` René Treffer
2019-06-10  3:31       ` Marek Lindner
2019-06-10  7:37         ` Кирилл Луконин
2019-06-12  6:39           ` Marek Lindner
2019-06-12 20:50             ` Кирилл Луконин
2019-06-25  8:26               ` Marek Lindner
2019-06-27 10:41                 ` Кирилл Луконин
2019-06-27 10:57                   ` Marek Lindner
2019-06-10 10:06         ` René Treffer
2019-08-11 12:50           ` Marek Lindner
     [not found]             ` <CALD2-cLnviLCav=Lui9T4Mzz1nnY93kN_0ypd-nhwFUhKNYRQg@mail.gmail.com>
2019-08-11 13:17               ` Marek Lindner
2019-06-09 10:41 ` Sven Eckelmann
2019-06-09 11:09 ` Sven Eckelmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).