* [PATCH v5 1/5] netdev: parse rates in netdev_get_station
@ 2021-01-14 20:54 James Prestwood
2021-01-14 20:54 ` [PATCH v5 2/5] netdev: parse expected throughput " James Prestwood
` (4 more replies)
0 siblings, 5 replies; 9+ messages in thread
From: James Prestwood @ 2021-01-14 20:54 UTC (permalink / raw)
To: iwd
[-- Attachment #1: Type: text/plain, Size: 3656 bytes --]
---
src/netdev.c | 94 ++++++++++++++++++++++++++++++++++++++++++++++++++++
src/netdev.h | 18 ++++++++++
2 files changed, 112 insertions(+)
v5:
* Renamed some station_info members
diff --git a/src/netdev.c b/src/netdev.c
index 2c88e648..7d36eb77 100644
--- a/src/netdev.c
+++ b/src/netdev.c
@@ -368,11 +368,74 @@ int netdev_set_powered(struct netdev *netdev, bool powered,
return 0;
}
+static bool netdev_parse_bitrate(struct l_genl_attr *attr,
+ enum netdev_mcs_type *type_out,
+ uint32_t *rate_out,
+ uint8_t *mcs_out)
+{
+ uint16_t type, len;
+ const void *data;
+ uint32_t rate = 0;
+ uint8_t mcs = 0;
+ enum netdev_mcs_type mcs_type = NETDEV_MCS_TYPE_NONE;
+
+ while (l_genl_attr_next(attr, &type, &len, &data)) {
+ switch (type) {
+ case NL80211_RATE_INFO_BITRATE32:
+ if (len != 4)
+ return false;
+
+ rate = l_get_u32(data);
+
+ break;
+
+ case NL80211_RATE_INFO_MCS:
+ if (len != 1)
+ return false;
+
+ mcs = l_get_u8(data);
+ mcs_type = NETDEV_MCS_TYPE_HT;
+
+ break;
+
+ case NL80211_RATE_INFO_VHT_MCS:
+ if (len != 1)
+ return false;
+
+ mcs = l_get_u8(data);
+ mcs_type = NETDEV_MCS_TYPE_VHT;
+
+ break;
+
+ case NL80211_RATE_INFO_HE_MCS:
+ if (len != 1)
+ return false;
+
+ mcs = l_get_u8(data);
+ mcs_type = NETDEV_MCS_TYPE_HE;
+
+ break;
+ }
+ }
+
+ if (!rate)
+ return false;
+
+ *type_out = mcs_type;
+ *rate_out = rate;
+
+ if (mcs_type != NETDEV_MCS_TYPE_NONE)
+ *mcs_out = mcs;
+
+ return true;
+}
+
static bool netdev_parse_sta_info(struct l_genl_attr *attr,
struct netdev_station_info *info)
{
uint16_t type, len;
const void *data;
+ struct l_genl_attr nested;
while (l_genl_attr_next(attr, &type, &len, &data)) {
switch (type) {
@@ -383,6 +446,37 @@ static bool netdev_parse_sta_info(struct l_genl_attr *attr,
info->cur_rssi = *(const int8_t *) data;
info->have_cur_rssi = true;
+ break;
+ case NL80211_STA_INFO_RX_BITRATE:
+ if (!l_genl_attr_recurse(attr, &nested))
+ return false;
+
+ if (!netdev_parse_bitrate(&nested, &info->rx_mcs_type,
+ &info->rx_bitrate,
+ &info->rx_mcs))
+ return false;
+
+ info->have_rx_bitrate = true;
+
+ if (info->rx_mcs_type != NETDEV_MCS_TYPE_NONE)
+ info->have_rx_mcs = true;
+
+ break;
+
+ case NL80211_STA_INFO_TX_BITRATE:
+ if (!l_genl_attr_recurse(attr, &nested))
+ return false;
+
+ if (!netdev_parse_bitrate(&nested, &info->tx_mcs_type,
+ &info->tx_bitrate,
+ &info->tx_mcs))
+ return false;
+
+ info->have_tx_bitrate = true;
+
+ if (info->tx_mcs_type != NETDEV_MCS_TYPE_NONE)
+ info->have_tx_mcs = true;
+
break;
}
}
diff --git a/src/netdev.h b/src/netdev.h
index 8c2dfee3..daf10bb6 100644
--- a/src/netdev.h
+++ b/src/netdev.h
@@ -114,11 +114,29 @@ typedef void (*netdev_station_watch_func_t)(struct netdev *netdev,
const uint8_t *mac, bool added,
void *user_data);
+enum netdev_mcs_type {
+ NETDEV_MCS_TYPE_NONE,
+ NETDEV_MCS_TYPE_HT,
+ NETDEV_MCS_TYPE_VHT,
+ NETDEV_MCS_TYPE_HE,
+};
+
struct netdev_station_info {
uint8_t addr[6];
int8_t cur_rssi;
+ enum netdev_mcs_type rx_mcs_type;
+ uint32_t rx_bitrate;
+ uint8_t rx_mcs;
+ enum netdev_mcs_type tx_mcs_type;
+ uint32_t tx_bitrate;
+ uint8_t tx_mcs;
+
bool have_cur_rssi : 1;
+ bool have_rx_mcs : 1;
+ bool have_tx_mcs : 1;
+ bool have_rx_bitrate : 1;
+ bool have_tx_bitrate : 1;
};
typedef void (*netdev_get_station_cb_t)(const struct netdev_station_info *info,
--
2.26.2
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v5 2/5] netdev: parse expected throughput in netdev_get_station
2021-01-14 20:54 [PATCH v5 1/5] netdev: parse rates in netdev_get_station James Prestwood
@ 2021-01-14 20:54 ` James Prestwood
2021-01-14 20:54 ` [PATCH v5 3/5] station: create StationDiagnostic interface James Prestwood
` (3 subsequent siblings)
4 siblings, 0 replies; 9+ messages in thread
From: James Prestwood @ 2021-01-14 20:54 UTC (permalink / raw)
To: iwd
[-- Attachment #1: Type: text/plain, Size: 1079 bytes --]
---
src/netdev.c | 9 +++++++++
src/netdev.h | 3 +++
2 files changed, 12 insertions(+)
diff --git a/src/netdev.c b/src/netdev.c
index 7d36eb77..0fc0600a 100644
--- a/src/netdev.c
+++ b/src/netdev.c
@@ -478,6 +478,15 @@ static bool netdev_parse_sta_info(struct l_genl_attr *attr,
info->have_tx_mcs = true;
break;
+
+ case NL80211_STA_INFO_EXPECTED_THROUGHPUT:
+ if (len != 4)
+ return false;
+
+ info->expected_throughput = l_get_u32(data);
+ info->have_expected_throughput = true;
+
+ break;
}
}
diff --git a/src/netdev.h b/src/netdev.h
index daf10bb6..074dc61f 100644
--- a/src/netdev.h
+++ b/src/netdev.h
@@ -132,11 +132,14 @@ struct netdev_station_info {
uint32_t tx_bitrate;
uint8_t tx_mcs;
+ uint32_t expected_throughput;
+
bool have_cur_rssi : 1;
bool have_rx_mcs : 1;
bool have_tx_mcs : 1;
bool have_rx_bitrate : 1;
bool have_tx_bitrate : 1;
+ bool have_expected_throughput : 1;
};
typedef void (*netdev_get_station_cb_t)(const struct netdev_station_info *info,
--
2.26.2
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v5 3/5] station: create StationDiagnostic interface
2021-01-14 20:54 [PATCH v5 1/5] netdev: parse rates in netdev_get_station James Prestwood
2021-01-14 20:54 ` [PATCH v5 2/5] netdev: parse expected throughput " James Prestwood
@ 2021-01-14 20:54 ` James Prestwood
2021-01-14 21:14 ` Denis Kenzior
2021-01-14 20:54 ` [PATCH v5 4/5] test: update get-diagnostics with Rx/TxMode James Prestwood
` (2 subsequent siblings)
4 siblings, 1 reply; 9+ messages in thread
From: James Prestwood @ 2021-01-14 20:54 UTC (permalink / raw)
To: iwd
[-- Attachment #1: Type: text/plain, Size: 6261 bytes --]
This interface sits aside the regular station interface but
provides low level connection details for diagnostic and
testing purposes.
---
src/station.c | 155 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 155 insertions(+)
v5:
* Changed Rx/TxRateType to Rx/TxMode
* Removed 'legacy' terminology, the rate mode will not be included
if the AP is operating in legacy modes.
diff --git a/src/station.c b/src/station.c
index 1e3706af..2b79aaa7 100644
--- a/src/station.c
+++ b/src/station.c
@@ -77,6 +77,7 @@ struct station {
struct l_dbus_message *hidden_pending;
struct l_dbus_message *disconnect_pending;
struct l_dbus_message *scan_pending;
+ struct l_dbus_message *get_station_pending;
struct signal_agent *signal_agent;
uint32_t dbus_scan_id;
uint32_t quick_scan_id;
@@ -3333,6 +3334,9 @@ static struct station *station_create(struct netdev *netdev)
l_dbus_object_add_interface(dbus, netdev_get_path(netdev),
IWD_STATION_INTERFACE, station);
+ l_dbus_object_add_interface(dbus, netdev_get_path(netdev),
+ IWD_STATION_DIAGNOSTIC_INTERFACE,
+ station);
if (netconfig_enabled)
station->netconfig = netconfig_new(netdev_get_ifindex(netdev));
@@ -3455,6 +3459,150 @@ static void station_destroy_interface(void *user_data)
station_free(station);
}
+static void station_get_diagnostic_cb(const struct netdev_station_info *info,
+ void *user_data)
+{
+ struct station *station = user_data;
+ struct l_dbus_message *reply;
+ struct l_dbus_message_builder *builder;
+ int16_t rssi;
+
+ if (!info) {
+ reply = dbus_error_aborted(station->get_station_pending);
+ goto done;
+ }
+
+ reply = l_dbus_message_new_method_return(station->get_station_pending);
+
+ rssi = (int16_t)info->cur_rssi;
+
+ builder = l_dbus_message_builder_new(reply);
+
+ l_dbus_message_builder_enter_array(builder, "{sv}");
+
+ dbus_append_dict_basic(builder, "ConnectedBss", 's',
+ util_address_to_string(info->addr));
+
+ if (info->have_cur_rssi)
+ dbus_append_dict_basic(builder, "RSSI", 'n', &rssi);
+
+ if (info->have_rx_mcs) {
+ switch (info->rx_mcs_type) {
+ case NETDEV_MCS_TYPE_HT:
+ dbus_append_dict_basic(builder, "RxMode", 's',
+ "802.11n");
+ dbus_append_dict_basic(builder, "RxMCS", 'y',
+ &info->rx_mcs);
+ break;
+ case NETDEV_MCS_TYPE_VHT:
+ dbus_append_dict_basic(builder, "RxMode", 's',
+ "802.11ac");
+ dbus_append_dict_basic(builder, "RxMCS", 'y',
+ &info->rx_mcs);
+ break;
+ case NETDEV_MCS_TYPE_HE:
+ dbus_append_dict_basic(builder, "RxMode", 's',
+ "802.11ax");
+ dbus_append_dict_basic(builder, "RxMCS", 'y',
+ &info->rx_mcs);
+ break;
+ default:
+ break;
+ }
+ }
+
+ if (info->have_tx_mcs) {
+ switch (info->tx_mcs_type) {
+ case NETDEV_MCS_TYPE_HT:
+ dbus_append_dict_basic(builder, "TxMode", 's',
+ "802.11n");
+ dbus_append_dict_basic(builder, "TxMCS", 'y',
+ &info->tx_mcs);
+ break;
+ case NETDEV_MCS_TYPE_VHT:
+ dbus_append_dict_basic(builder, "TxMode", 's',
+ "802.11ac");
+ dbus_append_dict_basic(builder, "TxMCS", 'y',
+ &info->tx_mcs);
+ break;
+ case NETDEV_MCS_TYPE_HE:
+ dbus_append_dict_basic(builder, "TxMode", 's',
+ "802.11ax");
+ dbus_append_dict_basic(builder, "TxMCS", 'y',
+ &info->tx_mcs);
+ break;
+ default:
+ break;
+ }
+ }
+
+ if (info->have_tx_bitrate)
+ dbus_append_dict_basic(builder, "TxBitrate", 'u',
+ &info->tx_bitrate);
+
+ if (info->have_rx_bitrate)
+ dbus_append_dict_basic(builder, "RxBitrate", 'u',
+ &info->rx_bitrate);
+
+ if (info->have_expected_throughput)
+ dbus_append_dict_basic(builder, "ExpectedThroughput", 'u',
+ &info->expected_throughput);
+
+ l_dbus_message_builder_leave_array(builder);
+ l_dbus_message_builder_finalize(builder);
+ l_dbus_message_builder_destroy(builder);
+
+done:
+ dbus_pending_reply(&station->get_station_pending, reply);
+}
+
+static void station_get_diagnostic_destroy(void *user_data)
+{
+ struct station *station = user_data;
+ struct l_dbus_message *reply;
+
+ if (station->get_station_pending) {
+ reply = dbus_error_aborted(station->get_station_pending);
+ dbus_pending_reply(&station->get_station_pending, reply);
+ }
+}
+
+static struct l_dbus_message *station_get_diagnostics(struct l_dbus *dbus,
+ struct l_dbus_message *message,
+ void *user_data)
+{
+ struct station *station = user_data;
+ int ret;
+
+ /*
+ * At this time all values depend on a connected state.
+ */
+ if (station->state != STATION_STATE_CONNECTED)
+ return dbus_error_not_connected(message);
+
+ ret = netdev_get_current_station(station->netdev,
+ station_get_diagnostic_cb, station,
+ station_get_diagnostic_destroy);
+ if (ret < 0)
+ return dbus_error_from_errno(ret, message);
+
+ station->get_station_pending = l_dbus_message_ref(message);
+
+ return NULL;
+}
+
+static void station_setup_diagnostic_interface(
+ struct l_dbus_interface *interface)
+{
+ l_dbus_interface_method(interface, "GetDiagnostics", 0,
+ station_get_diagnostics, "a{sv}", "",
+ "diagnostics");
+}
+
+static void station_destroy_diagnostic_interface(void *user_data)
+{
+}
+
static void station_netdev_watch(struct netdev *netdev,
enum netdev_watch_event event, void *userdata)
{
@@ -3483,6 +3631,11 @@ static int station_init(void)
l_dbus_register_interface(dbus_get_bus(), IWD_STATION_INTERFACE,
station_setup_interface,
station_destroy_interface, false);
+ l_dbus_register_interface(dbus_get_bus(),
+ IWD_STATION_DIAGNOSTIC_INTERFACE,
+ station_setup_diagnostic_interface,
+ station_destroy_diagnostic_interface,
+ false);
if (!l_settings_get_uint(iwd_get_config(), "General",
"ManagementFrameProtection",
@@ -3521,6 +3674,8 @@ static int station_init(void)
static void station_exit(void)
{
+ l_dbus_unregister_interface(dbus_get_bus(),
+ IWD_STATION_DIAGNOSTIC_INTERFACE);
l_dbus_unregister_interface(dbus_get_bus(), IWD_STATION_INTERFACE);
netdev_watch_remove(netdev_watch);
l_queue_destroy(station_list, NULL);
--
2.26.2
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v5 4/5] test: update get-diagnostics with Rx/TxMode
2021-01-14 20:54 [PATCH v5 1/5] netdev: parse rates in netdev_get_station James Prestwood
2021-01-14 20:54 ` [PATCH v5 2/5] netdev: parse expected throughput " James Prestwood
2021-01-14 20:54 ` [PATCH v5 3/5] station: create StationDiagnostic interface James Prestwood
@ 2021-01-14 20:54 ` James Prestwood
2021-01-14 21:01 ` Denis Kenzior
2021-01-14 20:54 ` [PATCH v5 5/5] doc: add RateType's on diagnostic interface James Prestwood
2021-01-14 21:00 ` [PATCH v5 1/5] netdev: parse rates in netdev_get_station Denis Kenzior
4 siblings, 1 reply; 9+ messages in thread
From: James Prestwood @ 2021-01-14 20:54 UTC (permalink / raw)
To: iwd
[-- Attachment #1: Type: text/plain, Size: 609 bytes --]
---
test/get-diagnostics | 2 ++
1 file changed, 2 insertions(+)
diff --git a/test/get-diagnostics b/test/get-diagnostics
index 7cb777b3..98078be5 100755
--- a/test/get-diagnostics
+++ b/test/get-diagnostics
@@ -8,8 +8,10 @@ import dbus
unit_map = {
"ConnectedBss" : None,
"RSSI" : "dBm",
+ "RxMode" : None,
"RxBitrate" : lambda k : str(100 * int(k)) + ' Kbps',
"RxMCS" : lambda i : str(int(i)),
+ "TxMode" : None,
"TxBitrate" : lambda k : str(100 * int(k)) + ' Kbps',
"TxMCS" : lambda i : str(int(i)),
"ExpectedThroughput" : "Kbps"
--
2.26.2
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v5 5/5] doc: add RateType's on diagnostic interface
2021-01-14 20:54 [PATCH v5 1/5] netdev: parse rates in netdev_get_station James Prestwood
` (2 preceding siblings ...)
2021-01-14 20:54 ` [PATCH v5 4/5] test: update get-diagnostics with Rx/TxMode James Prestwood
@ 2021-01-14 20:54 ` James Prestwood
2021-01-14 21:01 ` Denis Kenzior
2021-01-14 21:00 ` [PATCH v5 1/5] netdev: parse rates in netdev_get_station Denis Kenzior
4 siblings, 1 reply; 9+ messages in thread
From: James Prestwood @ 2021-01-14 20:54 UTC (permalink / raw)
To: iwd
[-- Attachment #1: Type: text/plain, Size: 741 bytes --]
---
doc/diagnostics.txt | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/doc/diagnostics.txt b/doc/diagnostics.txt
index f94ef6f8..10bf470b 100644
--- a/doc/diagnostics.txt
+++ b/doc/diagnostics.txt
@@ -23,10 +23,16 @@ Methods dict GetDiagnostics()
RSSI [optional] - The RSSI of the currently connected BSS.
+ RxMode [optional] - The phy technology being used
+ (802.11n, 802.11ac or 802.11ax).
+
RxRate [optional] - Receive rate in 100kbit/s
RxMCS [optional] - Receiving MCS index
+ TxMode [optional] - Same meaning as RxMode, just for
+ transmission.
+
TxRate [optional] - Transmission rate in 100kbit/s
TxMCS [optional] - Transmitting MCS index
--
2.26.2
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH v5 1/5] netdev: parse rates in netdev_get_station
2021-01-14 20:54 [PATCH v5 1/5] netdev: parse rates in netdev_get_station James Prestwood
` (3 preceding siblings ...)
2021-01-14 20:54 ` [PATCH v5 5/5] doc: add RateType's on diagnostic interface James Prestwood
@ 2021-01-14 21:00 ` Denis Kenzior
4 siblings, 0 replies; 9+ messages in thread
From: Denis Kenzior @ 2021-01-14 21:00 UTC (permalink / raw)
To: iwd
[-- Attachment #1: Type: text/plain, Size: 322 bytes --]
Hi James,
On 1/14/21 2:54 PM, James Prestwood wrote:
> ---
> src/netdev.c | 94 ++++++++++++++++++++++++++++++++++++++++++++++++++++
> src/netdev.h | 18 ++++++++++
> 2 files changed, 112 insertions(+)
>
> v5:
> * Renamed some station_info members
>
Patch 1 & 2 applied, thanks.
Regards,
-Denis
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v5 5/5] doc: add RateType's on diagnostic interface
2021-01-14 20:54 ` [PATCH v5 5/5] doc: add RateType's on diagnostic interface James Prestwood
@ 2021-01-14 21:01 ` Denis Kenzior
0 siblings, 0 replies; 9+ messages in thread
From: Denis Kenzior @ 2021-01-14 21:01 UTC (permalink / raw)
To: iwd
[-- Attachment #1: Type: text/plain, Size: 186 bytes --]
Hi James,
On 1/14/21 2:54 PM, James Prestwood wrote:
> ---
> doc/diagnostics.txt | 6 ++++++
> 1 file changed, 6 insertions(+)
>
Applied after rewording the commit header
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v5 4/5] test: update get-diagnostics with Rx/TxMode
2021-01-14 20:54 ` [PATCH v5 4/5] test: update get-diagnostics with Rx/TxMode James Prestwood
@ 2021-01-14 21:01 ` Denis Kenzior
0 siblings, 0 replies; 9+ messages in thread
From: Denis Kenzior @ 2021-01-14 21:01 UTC (permalink / raw)
To: iwd
[-- Attachment #1: Type: text/plain, Size: 178 bytes --]
Hi James,
On 1/14/21 2:54 PM, James Prestwood wrote:
> ---
> test/get-diagnostics | 2 ++
> 1 file changed, 2 insertions(+)
>
Applied, thanks.
Regards,
-Denis
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v5 3/5] station: create StationDiagnostic interface
2021-01-14 20:54 ` [PATCH v5 3/5] station: create StationDiagnostic interface James Prestwood
@ 2021-01-14 21:14 ` Denis Kenzior
0 siblings, 0 replies; 9+ messages in thread
From: Denis Kenzior @ 2021-01-14 21:14 UTC (permalink / raw)
To: iwd
[-- Attachment #1: Type: text/plain, Size: 539 bytes --]
Hi James,
On 1/14/21 2:54 PM, James Prestwood wrote:
> This interface sits aside the regular station interface but
> provides low level connection details for diagnostic and
> testing purposes.
> ---
> src/station.c | 155 ++++++++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 155 insertions(+)
>
> v5:
> * Changed Rx/TxRateType to Rx/TxMode
> * Removed 'legacy' terminology, the rate mode will not be included
> if the AP is operating in legacy modes.
>
Applied, thanks.
Regards,
-Denis
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2021-01-14 21:14 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-01-14 20:54 [PATCH v5 1/5] netdev: parse rates in netdev_get_station James Prestwood
2021-01-14 20:54 ` [PATCH v5 2/5] netdev: parse expected throughput " James Prestwood
2021-01-14 20:54 ` [PATCH v5 3/5] station: create StationDiagnostic interface James Prestwood
2021-01-14 21:14 ` Denis Kenzior
2021-01-14 20:54 ` [PATCH v5 4/5] test: update get-diagnostics with Rx/TxMode James Prestwood
2021-01-14 21:01 ` Denis Kenzior
2021-01-14 20:54 ` [PATCH v5 5/5] doc: add RateType's on diagnostic interface James Prestwood
2021-01-14 21:01 ` Denis Kenzior
2021-01-14 21:00 ` [PATCH v5 1/5] netdev: parse rates in netdev_get_station Denis Kenzior
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.