From f3526195f5b53faab2d964112bd6ea89d93b4eae Mon Sep 17 00:00:00 2001
From: Jakob Olsson <jakob.olsson@iopsys.eu>
Date: Mon, 28 Apr 2025 11:00:33 +0200
Subject: [PATCH] read tx/rx rates from correct ubus table

---
 src/wifi_ubus.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/wifi_ubus.c b/src/wifi_ubus.c
index b7efc90a0..18221870a 100644
--- a/src/wifi_ubus.c
+++ b/src/wifi_ubus.c
@@ -1759,8 +1759,6 @@ static int wifi_ubus_get_sta_stats(struct blob_attr *msg,
 		[4] = { .name = "rx_data_pkts", .type = BLOBMSG_TYPE_INT64 },
 		[5] = { .name = "rx_data_bytes", .type = BLOBMSG_TYPE_INT64 },
 		[6] = { .name = "rx_failures", .type = BLOBMSG_TYPE_INT64 },
-		[7] = { .name = "tx_rate_latest", .type = BLOBMSG_TYPE_TABLE },
-		[8] = { .name = "rx_rate_latest", .type = BLOBMSG_TYPE_TABLE },
 	};
 	struct blob_attr *tb[ARRAY_SIZE(stats_policy)];
 
@@ -1781,11 +1779,6 @@ static int wifi_ubus_get_sta_stats(struct blob_attr *msg,
 	stats->rx_bytes = blobmsg_get_u64(tb[5]);
 	stats->rx_fail_pkts = blobmsg_get_u64(tb[6]);
 
-	if (tb[7])
-		wifi_ubus_get_sta_rate(tb[7], &sta->tx_rate);
-	if (tb[8])
-		wifi_ubus_get_sta_rate(tb[8], &sta->rx_rate);
-
 	return 0;
 }
 
@@ -1810,6 +1803,8 @@ static int wifi_ubus_parse_sta(struct blob_attr *cur,
 			[13] = { .name = "est_rx_thput", .type = BLOBMSG_TYPE_INT32 },
 			[14] = { .name = "est_tx_thput", .type = BLOBMSG_TYPE_INT32 },
 			[15] = { .name = "rssi_avg", .type = BLOBMSG_TYPE_INT32 },
+			[16] = { .name = "tx_rate_latest", .type = BLOBMSG_TYPE_TABLE },
+			[17] = { .name = "rx_rate_latest", .type = BLOBMSG_TYPE_TABLE },
 		};
 		struct blob_attr *sta_tb[ARRAY_SIZE(sta_policy)];
 
@@ -1840,6 +1835,11 @@ static int wifi_ubus_parse_sta(struct blob_attr *cur,
 		wifi_ubus_get_sta_rssi(sta_tb[12], sta->rssi, sizeof(sta->rssi));
 		wifi_ubus_get_sta_caps(sta_tb[10], &sta->caps);
 		wifi_ubus_get_sta_stats(sta_tb[4], sta, &sta->stats);
+		if (sta_tb[16])
+			wifi_ubus_get_sta_rate(sta_tb[16], &sta->tx_rate);
+		if (sta_tb[17])
+			wifi_ubus_get_sta_rate(sta_tb[17], &sta->rx_rate);
+
 		return 0;
 }
 
-- 
GitLab