diff --git a/src/diagnostic.h b/src/diagnostic.h new file mode 100644 index 00000000..a4fc5361 --- /dev/null +++ b/src/diagnostic.h @@ -0,0 +1,49 @@ +/* + * + * Wireless daemon for Linux + * + * Copyright (C) 2021 Intel Corporation. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +enum diagnostic_mcs_type { + DIAGNOSTIC_MCS_TYPE_NONE, + DIAGNOSTIC_MCS_TYPE_HT, + DIAGNOSTIC_MCS_TYPE_VHT, + DIAGNOSTIC_MCS_TYPE_HE, +}; + +struct diagnostic_station_info { + uint8_t addr[6]; + int8_t cur_rssi; + + enum diagnostic_mcs_type rx_mcs_type; + uint32_t rx_bitrate; + uint8_t rx_mcs; + enum diagnostic_mcs_type tx_mcs_type; + 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; +}; diff --git a/src/netdev.c b/src/netdev.c index e3ce270a..a19270c0 100644 --- a/src/netdev.c +++ b/src/netdev.c @@ -61,6 +61,7 @@ #include "src/fils.h" #include "src/auth-proto.h" #include "src/frame-xchg.h" +#include "src/diagnostic.h" #ifndef ENOTSUPP #define ENOTSUPP 524 @@ -369,7 +370,7 @@ int netdev_set_powered(struct netdev *netdev, bool powered, } static bool netdev_parse_bitrate(struct l_genl_attr *attr, - enum netdev_mcs_type *type_out, + enum diagnostic_mcs_type *type_out, uint32_t *rate_out, uint8_t *mcs_out) { @@ -377,7 +378,7 @@ static bool netdev_parse_bitrate(struct l_genl_attr *attr, const void *data; uint32_t rate = 0; uint8_t mcs = 0; - enum netdev_mcs_type mcs_type = NETDEV_MCS_TYPE_NONE; + enum diagnostic_mcs_type mcs_type = DIAGNOSTIC_MCS_TYPE_NONE; while (l_genl_attr_next(attr, &type, &len, &data)) { switch (type) { @@ -394,7 +395,7 @@ static bool netdev_parse_bitrate(struct l_genl_attr *attr, return false; mcs = l_get_u8(data); - mcs_type = NETDEV_MCS_TYPE_HT; + mcs_type = DIAGNOSTIC_MCS_TYPE_HT; break; @@ -403,7 +404,7 @@ static bool netdev_parse_bitrate(struct l_genl_attr *attr, return false; mcs = l_get_u8(data); - mcs_type = NETDEV_MCS_TYPE_VHT; + mcs_type = DIAGNOSTIC_MCS_TYPE_VHT; break; @@ -412,7 +413,7 @@ static bool netdev_parse_bitrate(struct l_genl_attr *attr, return false; mcs = l_get_u8(data); - mcs_type = NETDEV_MCS_TYPE_HE; + mcs_type = DIAGNOSTIC_MCS_TYPE_HE; break; } @@ -424,14 +425,14 @@ static bool netdev_parse_bitrate(struct l_genl_attr *attr, *type_out = mcs_type; *rate_out = rate; - if (mcs_type != NETDEV_MCS_TYPE_NONE) + if (mcs_type != DIAGNOSTIC_MCS_TYPE_NONE) *mcs_out = mcs; return true; } static bool netdev_parse_sta_info(struct l_genl_attr *attr, - struct netdev_station_info *info) + struct diagnostic_station_info *info) { uint16_t type, len; const void *data; @@ -458,7 +459,7 @@ static bool netdev_parse_sta_info(struct l_genl_attr *attr, info->have_rx_bitrate = true; - if (info->rx_mcs_type != NETDEV_MCS_TYPE_NONE) + if (info->rx_mcs_type != DIAGNOSTIC_MCS_TYPE_NONE) info->have_rx_mcs = true; break; @@ -474,7 +475,7 @@ static bool netdev_parse_sta_info(struct l_genl_attr *attr, info->have_tx_bitrate = true; - if (info->tx_mcs_type != NETDEV_MCS_TYPE_NONE) + if (info->tx_mcs_type != DIAGNOSTIC_MCS_TYPE_NONE) info->have_tx_mcs = true; break; @@ -511,7 +512,7 @@ static void netdev_rssi_poll_cb(struct l_genl_msg *msg, void *user_data) uint16_t type, len; const void *data; bool found; - struct netdev_station_info info; + struct diagnostic_station_info info; uint8_t prev_rssi_level_idx = netdev->cur_rssi_level_idx; netdev->rssi_poll_cmd_id = 0; @@ -4156,7 +4157,7 @@ static void netdev_get_station_cb(struct l_genl_msg *msg, void *user_data) struct l_genl_attr attr, nested; uint16_t type, len; const void *data; - struct netdev_station_info info; + struct diagnostic_station_info info; netdev->get_station_cmd_id = 0; diff --git a/src/netdev.h b/src/netdev.h index e7a1c060..d5adcf09 100644 --- a/src/netdev.h +++ b/src/netdev.h @@ -27,6 +27,7 @@ struct scan_bss; struct handshake_state; struct eapol_sm; struct mmpdu_header; +struct diagnostic_station_info; enum netdev_result { NETDEV_RESULT_OK, @@ -114,36 +115,9 @@ 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; - - 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, - void *user_data); +typedef void (*netdev_get_station_cb_t)( + const struct diagnostic_station_info *info, + void *user_data); struct wiphy *netdev_get_wiphy(struct netdev *netdev); const uint8_t *netdev_get_address(struct netdev *netdev); diff --git a/src/station.c b/src/station.c index 558ecf9a..95dea92b 100644 --- a/src/station.c +++ b/src/station.c @@ -54,6 +54,7 @@ #include "src/netconfig.h" #include "src/anqp.h" #include "src/anqputil.h" +#include "src/diagnostic.h" static struct l_queue *station_list; static uint32_t netdev_watch; @@ -3459,8 +3460,9 @@ 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) +static void station_get_diagnostic_cb( + const struct diagnostic_station_info *info, + void *user_data) { struct station *station = user_data; struct l_dbus_message *reply; @@ -3488,19 +3490,19 @@ static void station_get_diagnostic_cb(const struct netdev_station_info *info, if (info->have_rx_mcs) { switch (info->rx_mcs_type) { - case NETDEV_MCS_TYPE_HT: + case DIAGNOSTIC_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: + case DIAGNOSTIC_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: + case DIAGNOSTIC_MCS_TYPE_HE: dbus_append_dict_basic(builder, "RxMode", 's', "802.11ax"); dbus_append_dict_basic(builder, "RxMCS", 'y', @@ -3513,19 +3515,19 @@ static void station_get_diagnostic_cb(const struct netdev_station_info *info, if (info->have_tx_mcs) { switch (info->tx_mcs_type) { - case NETDEV_MCS_TYPE_HT: + case DIAGNOSTIC_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: + case DIAGNOSTIC_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: + case DIAGNOSTIC_MCS_TYPE_HE: dbus_append_dict_basic(builder, "TxMode", 's', "802.11ax"); dbus_append_dict_basic(builder, "TxMCS", 'y',