From 87a754eab14f7b0fc4fadf65ec28c2ecf5dc0177 Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Sat, 24 Jan 2026 19:16:57 +0100 Subject: [PATCH] statd: Add rx/tx bitrate to WiFi station operational data Extend the WiFi station mode with rx-speed and tx-speed leaves, mirroring what already exists for AP mode connected stations. Display bitrates in 'show interface ' detailed view. Also standardize speed units to kbps/Mbps across the YANG model. Signed-off-by: Joachim Wiberg --- src/confd/yang/confd/infix-if-wifi.yang | 50 +++++++++++++++---- src/statd/python/cli_pretty/cli_pretty.py | 8 ++- .../python/yanger/ietf_interfaces/wifi.py | 4 ++ 3 files changed, 51 insertions(+), 11 deletions(-) diff --git a/src/confd/yang/confd/infix-if-wifi.yang b/src/confd/yang/confd/infix-if-wifi.yang index c5d1615b..309c3e40 100644 --- a/src/confd/yang/confd/infix-if-wifi.yang +++ b/src/confd/yang/confd/infix-if-wifi.yang @@ -218,6 +218,36 @@ submodule infix-if-wifi { - Below -80 dBm: Very weak"; } + leaf rx-speed { + config false; + type uint32; + units "100 kbps"; + description + "Last received data rate from the access point in 100 kbps. + + Only available when connected. + + Examples: + - 10 = 1 Mbps + - 65 = 6.5 Mbps + - 866 = 86.6 Mbps"; + } + + leaf tx-speed { + config false; + type uint32; + units "100 kbps"; + description + "Last transmitted data rate to the access point in 100 kbps. + + Only available when connected. + + Examples: + - 10 = 1 Mbps + - 65 = 6.5 Mbps + - 866 = 86.6 Mbps"; + } + list scan-results { config false; key ssid; @@ -421,26 +451,26 @@ submodule infix-if-wifi { leaf rx-speed { type uint32; - units "100 kbit/s"; + units "100 kbps"; description - "Last received data rate from this client in 100 kbit/s. + "Last received data rate from this client in 100 kbps. Examples: - - 10 = 1 Mbit/s - - 65 = 6.5 Mbit/s - - 866 = 86.6 Mbit/s"; + - 10 = 1 Mbps + - 65 = 6.5 Mbps + - 866 = 86.6 Mbps"; } leaf tx-speed { type uint32; - units "100 kbit/s"; + units "100 kbps"; description - "Last transmitted data rate to this client in 100 kbit/s. + "Last transmitted data rate to this client in 100 kbps. Examples: - - 10 = 1 Mbit/s - - 65 = 6.5 Mbit/s - - 866 = 86.6 Mbit/s"; + - 10 = 1 Mbps + - 65 = 6.5 Mbps + - 866 = 86.6 Mbps"; } } } diff --git a/src/statd/python/cli_pretty/cli_pretty.py b/src/statd/python/cli_pretty/cli_pretty.py index f8fecba5..8a6c5d34 100755 --- a/src/statd/python/cli_pretty/cli_pretty.py +++ b/src/statd/python/cli_pretty/cli_pretty.py @@ -1295,7 +1295,7 @@ class Iface: rx_bytes = station.get("rx-bytes", 0) tx_bytes = station.get("tx-bytes", 0) - # Speed in 100 kbit/s units, convert to Mbps for display + # Speed in 100 kbps units, convert to Mbps for display rx_speed = station.get("rx-speed", 0) tx_speed = station.get("tx-speed", 0) rx_speed_str = f"{rx_speed / 10:.1f}" if rx_speed else "-" @@ -1640,6 +1640,12 @@ class Iface: if rssi is not None: signal_status = rssi_to_status(rssi) print(f"{'signal':<{20}}: {rssi} dBm ({signal_status})") + rx_speed = station.get('rx-speed') + tx_speed = station.get('tx-speed') + if rx_speed is not None: + print(f"{'rx bitrate':<{20}}: {rx_speed / 10:.1f} Mbps") + if tx_speed is not None: + print(f"{'tx bitrate':<{20}}: {tx_speed / 10:.1f} Mbps") if "scan-results" in station: self.pr_wifi_ssids() diff --git a/src/statd/python/yanger/ietf_interfaces/wifi.py b/src/statd/python/yanger/ietf_interfaces/wifi.py index f6af9069..56669a60 100644 --- a/src/statd/python/yanger/ietf_interfaces/wifi.py +++ b/src/statd/python/yanger/ietf_interfaces/wifi.py @@ -70,6 +70,10 @@ def wifi_station(ifname): station_data['ssid'] = link['ssid'] if link.get('rssi') is not None: station_data['rssi'] = link['rssi'] + if link.get('rx-speed') is not None: + station_data['rx-speed'] = link['rx-speed'] + if link.get('tx-speed') is not None: + station_data['tx-speed'] = link['tx-speed'] # Get scan results from wpa_supplicant (better scan support) try: