netdev: parse rates in netdev_get_station
PATCH v5 1/5 netdev: parse rates in netdev_get_station
--- src/netdev.c | 94 ++++++++++++++++++++++++++++++++++++++++++++++++++++ src/netdev.h | 18 ++++++++++ 2 files changed, 112 insertions(+)
v5:
* Renamed some station_info members
src/netdev.c +94 -0
@@ -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 ; } }
src/netdev.h +18 -0
@@ -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,
Signature · 1 line
2.26.2
PATCH v5 2/5 netdev: parse expected throughput in netdev_get_station
--- src/netdev.c | 9 +++++++++ src/netdev.h | 3 +++ 2 files changed, 12 insertions(+)
src/netdev.c +9 -0
@@ -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 ; } }
src/netdev.h +3 -0
@@ -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,
Signature · 1 line
2.26.2
PATCH v5 3/5 station: create StationDiagnostic interface
In reply to James PrestwoodThis 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.
src/station.c +155 -0
@@ -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 );
Signature · 1 line
2.26.2
Denis Kenzior
AppliedRe: [PATCH v5 3/5] station: create StationDiagnostic interface
Hi James,
Quoted 12 lines · James Prestwood
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
PATCH v5 4/5 test: update get-diagnostics with Rx/TxMode
In reply to James Prestwood--- test/get-diagnostics | 2 ++ 1 file changed, 2 insertions(+)
test/get-diagnostics +2 -0
@@ -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"
Signature · 1 line
2.26.2
Denis Kenzior
AppliedRe: [PATCH v5 4/5] test: update get-diagnostics with Rx/TxMode
Hi James,
Quoted 4 lines · James Prestwood
--- test/get-diagnostics | 2 ++ 1 file changed, 2 insertions(+)
Applied, thanks.
Regards,
-Denis
PATCH v5 5/5 doc: add RateType's on diagnostic interface
In reply to James Prestwood--- doc/diagnostics.txt | 6 ++++++ 1 file changed, 6 insertions(+)
doc/diagnostics.txt +6 -0
@@ -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
Signature · 1 line
2.26.2
Re: [PATCH v5 5/5] doc: add RateType's on diagnostic interface
Hi James,
Quoted 4 lines · James Prestwood
--- doc/diagnostics.txt | 6 ++++++ 1 file changed, 6 insertions(+)
Applied after rewording the commit header
Hi James,
Quoted 8 lines · James Prestwood
--- src/netdev.c | 94 ++++++++++++++++++++++++++++++++++++++++++++++++++++ src/netdev.h | 18 ++++++++++ 2 files changed, 112 insertions(+)v5:
* Renamed somestation_infomembers
Patch 1 & 2 applied, thanks.
Regards,
-Denis