All of lore.kernel.org
 help / color / mirror / Atom feed
From: James Prestwood <prestwoj@gmail.com>
To: iwd@lists.linux.dev
Cc: James Prestwood <prestwoj@gmail.com>
Subject: [PATCH 1/3] station: Add Utilization/SNR/LastSeen to station diagnostics
Date: Thu,  9 Jul 2026 14:45:44 -0700	[thread overview]
Message-ID: <20260709214546.659971-1-prestwoj@gmail.com> (raw)

For metric gathering and general debugging its convenient to query
the last known utilization and/or SNR from the currently connected
BSS. In addition another property was added, "BssLastSeen" which is
the seconds since the last scan returned the BSS. Since the
BSS's beacon info (like utilization/SNR) are only updated upon
getting scan results we need to also advertise the "age" of the
data so any consumers can decide whether or not to ignore these
values if they are too old.
---
 src/station.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/src/station.c b/src/station.c
index 8fcf8c70..05ed043e 100644
--- a/src/station.c
+++ b/src/station.c
@@ -5337,6 +5337,14 @@ static void station_destroy_interface(void *user_data)
 	station_free(station);
 }
 
+/* Gets the time in seconds since the BSS was last seen */
+static uint32_t bss_last_seen_time(const struct scan_bss *bss)
+{
+	uint64_t diff = l_time_diff(bss->time_stamp, l_time_now());
+
+	return (uint32_t)l_time_to_secs(diff);
+}
+
 static void station_get_diagnostic_cb(
 				const struct diagnostic_station_info *info,
 				void *user_data)
@@ -5346,6 +5354,7 @@ static void station_get_diagnostic_cb(
 	struct l_dbus_message_builder *builder;
 	struct handshake_state *hs = netdev_get_handshake(station->netdev);
 	uint16_t channel_num;
+	uint32_t last_seen;
 
 	if (!info) {
 		reply = dbus_error_aborted(station->get_station_pending);
@@ -5388,6 +5397,23 @@ static void station_get_diagnostic_cb(
 						's', str);
 	}
 
+	if (station->connected_bss->have_utilization) {
+		uint8_t percent =
+			(station->connected_bss->utilization * 100) / 255;
+		dbus_append_dict_basic(builder, "ChannelUtilization", 'y',
+			&percent);
+	}
+
+	if (station->connected_bss->have_snr) {
+		uint8_t snr = (uint8_t)station->connected_bss->snr;
+		dbus_append_dict_basic(builder, "SignalNoiseRatio", 'y', &snr);
+	}
+
+	last_seen = bss_last_seen_time(station->connected_bss);
+
+	dbus_append_dict_basic(builder, "BssLastSeen", 'u',
+			&last_seen);
+
 	diagnostic_info_to_dict(info, builder);
 
 	l_dbus_message_builder_leave_array(builder);
-- 
2.34.1


             reply	other threads:[~2026-07-09 21:45 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-09 21:45 James Prestwood [this message]
2026-07-09 21:45 ` [PATCH 2/3] client: support ChannelUtilization/SignalNoiseRatio/BssLastSeen James Prestwood
2026-07-09 21:45 ` [PATCH 3/3] doc: Document new station diagnostic values James Prestwood

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260709214546.659971-1-prestwoj@gmail.com \
    --to=prestwoj@gmail.com \
    --cc=iwd@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.