From efb677ba93c028b977900b6b7ba080b0f57e4c97 Mon Sep 17 00:00:00 2001 From: Mario Maz Date: Fri, 3 Apr 2020 18:33:14 +0200 Subject: [PATCH 01/10] framework: tlvf: use fully qualified type when computing enum size Compiling autogenerated code fails if there is a field of an enum type from a different namespace. Reason is namespace is being trimmed off when computing enum size. To fix the problem, call sizeof() with fully qualified type name. Signed-off-by: Mario Maz --- framework/tlvf/tlvf.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/framework/tlvf/tlvf.py b/framework/tlvf/tlvf.py index e0da4d852f..15ad120524 100755 --- a/framework/tlvf/tlvf.py +++ b/framework/tlvf/tlvf.py @@ -136,7 +136,9 @@ def __init__(self, type_str): elif len(self.type_str) > 2 and (str(self.type_str[1]).isupper() or str(self.type_str[1]).isdigit()): if self.type_str[0] == "e": self.set_type(TypeInfo.ENUM) - self.swap_prefix = "tlvf_swap(8*sizeof(" + self.type_str + "), reinterpret_cast(" + self.swap_prefix = "tlvf_swap(8*sizeof(" + self.swap_prefix += type_str + self.swap_prefix += "), reinterpret_cast(" self.swap_suffix = "))" self.swap_needed = True elif self.type_str[0] == "s": From 99a3abd855ee0b7ae11be2c00e5fb8e58c22c99d Mon Sep 17 00:00:00 2001 From: Mario Maz Date: Fri, 3 Apr 2020 18:23:13 +0200 Subject: [PATCH 02/10] tlvf: add frequency_band and max_bandwidth fields MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add new fields frequency_band and max_bandwidth to struct sNodeHostap so they can be sent from ap_manager_thread to slave_thread inside ACTION_APMANAGER_JOINED_NOTIFICATION. Add those fields to message cACTION_BACKHAUL_ENABLE too so they can be sent from slave_thread to backhaul_manager. backhaul_manager stores those fields into m_radio_info_map to later compute MediaType as per IEEE Std 1905.1, Table 6-12—Media type (intfType). Signed-off-by: Mario Maz --- .../tlvf/yaml/beerocks/tlvf/beerocks_message_backhaul.yaml | 2 ++ .../tlvf/yaml/beerocks/tlvf/beerocks_message_common.yaml | 2 ++ 2 files changed, 4 insertions(+) diff --git a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_backhaul.yaml b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_backhaul.yaml index 6e2c84771b..543b59a9cf 100755 --- a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_backhaul.yaml +++ b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_backhaul.yaml @@ -59,6 +59,8 @@ cACTION_BACKHAUL_ENABLE: wireless_iface_type: uint8_t mem_only_psk: uint8_t backhaul_preferred_radio_band: uint8_t + frequency_band: beerocks::eFreqType + max_bandwidth: beerocks::eWiFiBandwidth supported_channels_list: _type: beerocks::message::sWifiChannel _length: [ "beerocks::message::SUPPORTED_CHANNELS_LENGTH" ] diff --git a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_common.yaml b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_common.yaml index f3321d55f2..21501a8a8d 100755 --- a/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_common.yaml +++ b/common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_common.yaml @@ -265,6 +265,8 @@ sNodeHostap: ant_num: uint8_t ant_gain: uint8_t tx_power: uint8_t + frequency_band: beerocks::eFreqType + max_bandwidth: beerocks::eWiFiBandwidth driver_version: _type: char _length: [ "beerocks::message::WIFI_DRIVER_VER_LENGTH" ] From dc09e97c990b53a02402465f6a45e31b69a4f68b Mon Sep 17 00:00:00 2001 From: Mario Maz Date: Tue, 31 Mar 2020 19:19:37 +0200 Subject: [PATCH 03/10] tlvf: add value IEEE_802_11AX to enum eMediaType MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit IEEE 802.11ax is not included in Table 6-12—Media type (intfType) in the IEEE 1905.1a standard. WiFi6 is specified to use 0x0108 in R2 Signed-off-by: Mario Maz --- framework/tlvf/yaml/tlvf/ieee_1905_1/eMediaType.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/framework/tlvf/yaml/tlvf/ieee_1905_1/eMediaType.yaml b/framework/tlvf/yaml/tlvf/ieee_1905_1/eMediaType.yaml index 0de5ffa8f2..3aeb679382 100755 --- a/framework/tlvf/yaml/tlvf/ieee_1905_1/eMediaType.yaml +++ b/framework/tlvf/yaml/tlvf/ieee_1905_1/eMediaType.yaml @@ -15,6 +15,7 @@ eMediaType: IEEE_802_11AC_5_GHZ: 0x0105 IEEE_802_11AD_60_GHZ: 0x0106 IEEE_802_11AF: 0x0107 + IEEE_802_11AX: 0x0108 IEEE_1901_WAVELET: 0x0200 IEEE_1901_FFT: 0x0201 MOCA_V1_1: 0x0300 From 15bc04dfa604777095abdc03908d3fa7e4830f61 Mon Sep 17 00:00:00 2001 From: Mario Maz Date: Tue, 31 Mar 2020 19:23:32 +0200 Subject: [PATCH 04/10] tlvf: update autogenerated files Signed-off-by: Mario Maz --- .../beerocks/tlvf/beerocks_message_backhaul.h | 4 ++++ .../beerocks/tlvf/beerocks_message_common.h | 4 ++++ .../tlvf/beerocks_message_backhaul.cpp | 22 +++++++++++++++++++ .../include/tlvf/ieee_1905_1/eMediaType.h | 1 + 4 files changed, 31 insertions(+) diff --git a/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_backhaul.h b/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_backhaul.h index 7101aa2ea8..5f630b7345 100644 --- a/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_backhaul.h +++ b/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_backhaul.h @@ -149,6 +149,8 @@ class cACTION_BACKHAUL_ENABLE : public BaseClass uint8_t& wireless_iface_type(); uint8_t& mem_only_psk(); uint8_t& backhaul_preferred_radio_band(); + beerocks::eFreqType& frequency_band(); + beerocks::eWiFiBandwidth& max_bandwidth(); std::tuple supported_channels_list(size_t idx); void class_swap() override; bool finalize() override; @@ -176,6 +178,8 @@ class cACTION_BACKHAUL_ENABLE : public BaseClass uint8_t* m_wireless_iface_type = nullptr; uint8_t* m_mem_only_psk = nullptr; uint8_t* m_backhaul_preferred_radio_band = nullptr; + beerocks::eFreqType* m_frequency_band = nullptr; + beerocks::eWiFiBandwidth* m_max_bandwidth = nullptr; beerocks::message::sWifiChannel* m_supported_channels_list = nullptr; size_t m_supported_channels_list_idx__ = 0; }; diff --git a/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_common.h b/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_common.h index 775de4ae4c..48bb313b48 100644 --- a/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_common.h +++ b/common/beerocks/tlvf/AutoGenerated/include/beerocks/tlvf/beerocks_message_common.h @@ -369,10 +369,14 @@ typedef struct sNodeHostap { uint8_t ant_num; uint8_t ant_gain; uint8_t tx_power; + beerocks::eFreqType frequency_band; + beerocks::eWiFiBandwidth max_bandwidth; char driver_version[beerocks::message::WIFI_DRIVER_VER_LENGTH]; beerocks::message::sWifiChannel supported_channels[beerocks::message::SUPPORTED_CHANNELS_LENGTH]; void struct_swap(){ iface_mac.struct_swap(); + tlvf_swap(8*sizeof(beerocks::eFreqType), reinterpret_cast(&frequency_band)); + tlvf_swap(8*sizeof(beerocks::eWiFiBandwidth), reinterpret_cast(&max_bandwidth)); for (size_t i = 0; i < beerocks::message::SUPPORTED_CHANNELS_LENGTH; i++){ (supported_channels[i]).struct_swap(); } diff --git a/common/beerocks/tlvf/AutoGenerated/src/beerocks/tlvf/beerocks_message_backhaul.cpp b/common/beerocks/tlvf/AutoGenerated/src/beerocks/tlvf/beerocks_message_backhaul.cpp index 56f21fa3bd..2cd0ce1bf8 100644 --- a/common/beerocks/tlvf/AutoGenerated/src/beerocks/tlvf/beerocks_message_backhaul.cpp +++ b/common/beerocks/tlvf/AutoGenerated/src/beerocks/tlvf/beerocks_message_backhaul.cpp @@ -506,6 +506,14 @@ uint8_t& cACTION_BACKHAUL_ENABLE::backhaul_preferred_radio_band() { return (uint8_t&)(*m_backhaul_preferred_radio_band); } +beerocks::eFreqType& cACTION_BACKHAUL_ENABLE::frequency_band() { + return (beerocks::eFreqType&)(*m_frequency_band); +} + +beerocks::eWiFiBandwidth& cACTION_BACKHAUL_ENABLE::max_bandwidth() { + return (beerocks::eWiFiBandwidth&)(*m_max_bandwidth); +} + std::tuple cACTION_BACKHAUL_ENABLE::supported_channels_list(size_t idx) { bool ret_success = ( (m_supported_channels_list_idx__ > 0) && (m_supported_channels_list_idx__ > idx) ); size_t ret_idx = ret_success ? idx : 0; @@ -521,6 +529,8 @@ void cACTION_BACKHAUL_ENABLE::class_swap() m_iface_mac->struct_swap(); tlvf_swap(32, reinterpret_cast(m_security_type)); m_preferred_bssid->struct_swap(); + tlvf_swap(8*sizeof(beerocks::eFreqType), reinterpret_cast(m_frequency_band)); + tlvf_swap(8*sizeof(beerocks::eWiFiBandwidth), reinterpret_cast(m_max_bandwidth)); for (size_t i = 0; i < beerocks::message::SUPPORTED_CHANNELS_LENGTH; i++){ m_supported_channels_list[i].struct_swap(); } @@ -569,6 +579,8 @@ size_t cACTION_BACKHAUL_ENABLE::get_initial_size() class_size += sizeof(uint8_t); // wireless_iface_type class_size += sizeof(uint8_t); // mem_only_psk class_size += sizeof(uint8_t); // backhaul_preferred_radio_band + class_size += sizeof(beerocks::eFreqType); // frequency_band + class_size += sizeof(beerocks::eWiFiBandwidth); // max_bandwidth class_size += beerocks::message::SUPPORTED_CHANNELS_LENGTH * sizeof(beerocks::message::sWifiChannel); // supported_channels_list return class_size; } @@ -651,6 +663,16 @@ bool cACTION_BACKHAUL_ENABLE::init() LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(uint8_t) << ") Failed!"; return false; } + m_frequency_band = (beerocks::eFreqType*)m_buff_ptr__; + if (!buffPtrIncrementSafe(sizeof(beerocks::eFreqType))) { + LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(beerocks::eFreqType) << ") Failed!"; + return false; + } + m_max_bandwidth = (beerocks::eWiFiBandwidth*)m_buff_ptr__; + if (!buffPtrIncrementSafe(sizeof(beerocks::eWiFiBandwidth))) { + LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(beerocks::eWiFiBandwidth) << ") Failed!"; + return false; + } m_supported_channels_list = (beerocks::message::sWifiChannel*)m_buff_ptr__; if (!buffPtrIncrementSafe(sizeof(beerocks::message::sWifiChannel) * (beerocks::message::SUPPORTED_CHANNELS_LENGTH))) { LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(beerocks::message::sWifiChannel) * (beerocks::message::SUPPORTED_CHANNELS_LENGTH) << ") Failed!"; diff --git a/framework/tlvf/AutoGenerated/include/tlvf/ieee_1905_1/eMediaType.h b/framework/tlvf/AutoGenerated/include/tlvf/ieee_1905_1/eMediaType.h index f26fd9273f..63df0998fd 100644 --- a/framework/tlvf/AutoGenerated/include/tlvf/ieee_1905_1/eMediaType.h +++ b/framework/tlvf/AutoGenerated/include/tlvf/ieee_1905_1/eMediaType.h @@ -30,6 +30,7 @@ enum eMediaType: uint16_t { IEEE_802_11AC_5_GHZ = 0x105, IEEE_802_11AD_60_GHZ = 0x106, IEEE_802_11AF = 0x107, + IEEE_802_11AX = 0x108, IEEE_1901_WAVELET = 0x200, IEEE_1901_FFT = 0x201, MOCA_V1_1 = 0x300, From d7bab1ae843d1ae54480f55c290899857fc4e2ab Mon Sep 17 00:00:00 2001 From: Mario Maz Date: Tue, 31 Mar 2020 19:28:31 +0200 Subject: [PATCH 05/10] bwl: add get_max_bandwidth method to band_info Add method to compute maximum supported bandwidth by all the channels in the band. This value is required to compute MediaType. Signed-off-by: Mario Maz --- .../beerocks/bwl/include/bwl/nl80211_client.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/common/beerocks/bwl/include/bwl/nl80211_client.h b/common/beerocks/bwl/include/bwl/nl80211_client.h index ed2464d3d5..7d1fb67bda 100644 --- a/common/beerocks/bwl/include/bwl/nl80211_client.h +++ b/common/beerocks/bwl/include/bwl/nl80211_client.h @@ -171,6 +171,23 @@ class nl80211_client { * @return True if this band is the 5GHz band and false otherwise. */ bool is_5ghz_band() const { return beerocks::eFreqType::FREQ_5G == get_frequency_band(); } + + /** + * @brief Gets the maximum supported bandwidth by all the channels in the band. + * + * @return Maximum supported bandwidth + */ + beerocks::eWiFiBandwidth get_max_bandwidth() const + { + beerocks::eWiFiBandwidth max_bandwith = beerocks::eWiFiBandwidth::BANDWIDTH_UNKNOWN; + + for (const auto &it : supported_channels) { + channel_info channel = it.second; + max_bandwith = std::max(max_bandwith, channel.get_max_bandwidth()); + } + + return max_bandwith; + } }; /** From 56118634a0b9df5e245088c9765e724027feac8e Mon Sep 17 00:00:00 2001 From: Mario Maz Date: Fri, 3 Apr 2020 19:16:16 +0200 Subject: [PATCH 06/10] bwl: get frequency band and maximum supported bandwidth using NL80211 Add new fields frequency band and maximum supported bandwidth to RadioInfo struct. Use nl80211_client::get_radio_info() to fill in the values for such new fields when getting radio info. Signed-off-by: Mario Maz --- .../bwl/dummy/base_wlan_hal_dummy.cpp | 8 +++++- .../bwl/dwpal/base_wlan_hal_dwpal.cpp | 17 ++++++++++++ .../bwl/include/bwl/base_wlan_hal_types.h | 27 ++++++++++--------- .../bwl/nl80211/base_wlan_hal_nl80211.cpp | 17 ++++++++++++ 4 files changed, 56 insertions(+), 13 deletions(-) diff --git a/common/beerocks/bwl/dummy/base_wlan_hal_dummy.cpp b/common/beerocks/bwl/dummy/base_wlan_hal_dummy.cpp index 0ab8dfeb4c..1c5d410f6e 100644 --- a/common/beerocks/bwl/dummy/base_wlan_hal_dummy.cpp +++ b/common/beerocks/bwl/dummy/base_wlan_hal_dummy.cpp @@ -292,9 +292,15 @@ bool base_wlan_hal_dummy::process_nl_events() bool base_wlan_hal_dummy::refresh_radio_info() { + m_radio_info.max_bandwidth = beerocks::eWiFiBandwidth::BANDWIDTH_40; + if (get_iface_name() == "wlan2") { - m_radio_info.is_5ghz = true; + m_radio_info.is_5ghz = true; + m_radio_info.frequency_band = beerocks::eFreqType::FREQ_5G; + } else { + m_radio_info.frequency_band = beerocks::eFreqType::FREQ_24G; } + std::string radio_mac; beerocks::net::network_utils::linux_iface_get_mac(m_radio_info.iface_name, radio_mac); for (int vap_id = 0; vap_id < predefined_vaps_num; vap_id++) { diff --git a/common/beerocks/bwl/dwpal/base_wlan_hal_dwpal.cpp b/common/beerocks/bwl/dwpal/base_wlan_hal_dwpal.cpp index e960151b09..e2b3586087 100644 --- a/common/beerocks/bwl/dwpal/base_wlan_hal_dwpal.cpp +++ b/common/beerocks/bwl/dwpal/base_wlan_hal_dwpal.cpp @@ -710,6 +710,23 @@ bool base_wlan_hal_dwpal::refresh_radio_info() { char *reply = nullptr; + /** + * Obtain frequency band and maximum supported bandwidth using NL80211. + * As this information does not change, this is required the first time this method is called + * only. + */ + if (beerocks::eFreqType::FREQ_UNKNOWN == m_radio_info.frequency_band) { + nl80211_client::radio_info radio_info; + if (m_nl80211_client->get_radio_info(get_iface_name(), radio_info)) { + if (!radio_info.bands.empty()) { + nl80211_client::band_info band_info = radio_info.bands.at(0); + + m_radio_info.frequency_band = band_info.get_frequency_band(); + m_radio_info.max_bandwidth = band_info.get_max_bandwidth(); + } + } + } + // TODO: Add radio_info get for station // Station HAL diff --git a/common/beerocks/bwl/include/bwl/base_wlan_hal_types.h b/common/beerocks/bwl/include/bwl/base_wlan_hal_types.h index 5347071382..23aa36cdd3 100644 --- a/common/beerocks/bwl/include/bwl/base_wlan_hal_types.h +++ b/common/beerocks/bwl/include/bwl/base_wlan_hal_types.h @@ -77,18 +77,21 @@ enum class WiFiSec { Invalid = 0, None, WEP_64, WEP_128, WPA_PSK, WPA2_PSK, WPA_ struct RadioInfo { std::string iface_name; - IfaceType iface_type = IfaceType::Unsupported; - bool radio_enabled = false; - int wifi_ctrl_enabled = 0; // Hostapd / wpa_supplicant - bool tx_enabled = false; - bool is_5ghz = false; - int channel = 0; - int bandwidth = 0; - int channel_ext_above = 0; - int vht_center_freq = 0; - bool is_dfs_channel = false; - int ant_num = 0; - int tx_power = 0; + IfaceType iface_type = IfaceType::Unsupported; + bool radio_enabled = false; + int wifi_ctrl_enabled = 0; // Hostapd / wpa_supplicant + bool tx_enabled = false; + bool is_5ghz = false; + int channel = 0; + int bandwidth = 0; + int channel_ext_above = 0; + int vht_center_freq = 0; + bool is_dfs_channel = false; + int ant_num = 0; + int tx_power = 0; + beerocks::eFreqType frequency_band = beerocks::eFreqType::FREQ_UNKNOWN; /**< Frequency band */ + beerocks::eWiFiBandwidth max_bandwidth = + beerocks::eWiFiBandwidth::BANDWIDTH_UNKNOWN; /**< Maximum supported bandwidth */ ChanSwReason last_csa_sw_reason = ChanSwReason::Unknown; std::vector supported_channels; std::unordered_map available_vaps; // key = vap_id diff --git a/common/beerocks/bwl/nl80211/base_wlan_hal_nl80211.cpp b/common/beerocks/bwl/nl80211/base_wlan_hal_nl80211.cpp index 5484b920a6..5a4f91cf5a 100644 --- a/common/beerocks/bwl/nl80211/base_wlan_hal_nl80211.cpp +++ b/common/beerocks/bwl/nl80211/base_wlan_hal_nl80211.cpp @@ -633,6 +633,23 @@ bool base_wlan_hal_nl80211::refresh_radio_info() { parsed_obj_map_t reply; + /** + * Obtain frequency band and maximum supported bandwidth using NL80211. + * As this information does not change, this is required the first time this method is called + * only. + */ + if (beerocks::eFreqType::FREQ_UNKNOWN == m_radio_info.frequency_band) { + nl80211_client::radio_info radio_info; + if (m_nl80211_client->get_radio_info(get_iface_name(), radio_info)) { + if (!radio_info.bands.empty()) { + nl80211_client::band_info band_info = radio_info.bands.at(0); + + m_radio_info.frequency_band = band_info.get_frequency_band(); + m_radio_info.max_bandwidth = band_info.get_max_bandwidth(); + } + } + } + if (!wpa_ctrl_send_msg("STATUS", reply)) { LOG(ERROR) << __func__ << " failed"; return false; From d22ded6d92f5ae494ffdfb6735a697b61569c0e8 Mon Sep 17 00:00:00 2001 From: Mario Maz Date: Fri, 3 Apr 2020 19:46:27 +0200 Subject: [PATCH 07/10] agent: send frequency band and max bandwidth from bwl to backhaul manager Reading radio info should only be done by the BWL backend. We read from hostapd whatever we can, and supplement what's missing with the nl80211_client. Backhaul manager needs frequency band and max bandwidth values to compute MediaType. These values must be sent from ap_manager_thread to slave_thread inside cACTION_APMANAGER_JOINED_NOTIFICATION and then to backhaul_manager inside cACTION_BACKHAUL_ENABLE where are saved into m_radio_info_map. Signed-off-by: Mario Maz --- agent/src/beerocks/slave/ap_manager_thread.cpp | 3 +++ .../slave/backhaul_manager/backhaul_manager_thread.cpp | 9 +++++++-- .../slave/backhaul_manager/backhaul_manager_thread.h | 9 ++++++++- agent/src/beerocks/slave/son_slave_thread.cpp | 3 +++ 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/agent/src/beerocks/slave/ap_manager_thread.cpp b/agent/src/beerocks/slave/ap_manager_thread.cpp index 4673fbd00e..122f0e921f 100644 --- a/agent/src/beerocks/slave/ap_manager_thread.cpp +++ b/agent/src/beerocks/slave/ap_manager_thread.cpp @@ -1555,6 +1555,9 @@ void ap_manager_thread::handle_hostapd_attached() notification->cs_params().bandwidth = uint8_t( beerocks::utils::convert_bandwidth_to_enum(ap_wlan_hal->get_radio_info().bandwidth)); + notification->params().frequency_band = ap_wlan_hal->get_radio_info().frequency_band; + notification->params().max_bandwidth = ap_wlan_hal->get_radio_info().max_bandwidth; + // Copy the channels supported by the AP copy_radio_supported_channels(ap_wlan_hal, notification->params().supported_channels); diff --git a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp index 246d81cd6e..f30026db3f 100644 --- a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp +++ b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp @@ -25,7 +25,6 @@ * move all these includes into a separate header because * over time this list is going to get very long */ -#include #include #include #include @@ -1781,6 +1780,12 @@ bool backhaul_manager::handle_slave_backhaul_message(std::shared_ptriface_mac()]; + + radio_info.interface_name = request->ap_iface(); + radio_info.frequency_band = request->frequency_band(); + radio_info.max_bandwidth = request->max_bandwidth(); + std::string mac = network_utils::mac_to_string(request->iface_mac()); auto tuple_supported_channels = request->supported_channels_list(0); @@ -1792,7 +1797,7 @@ bool backhaul_manager::handle_slave_backhaul_message(std::shared_ptr(tuple_supported_channels); std::copy_n(channels, beerocks::message::SUPPORTED_CHANNELS_LENGTH, - m_radio_info_map[request->iface_mac()].supported_channels.begin()); + radio_info.supported_channels.begin()); soc->radio_mac = mac; soc->freq_type = (request->iface_is_5ghz() ? beerocks::eFreqType::FREQ_5G diff --git a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.h b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.h index 15e3f714a2..90653ad9b8 100644 --- a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.h +++ b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.h @@ -21,6 +21,8 @@ #include +#include + #include "../agent_ucc_listener.h" #include @@ -263,7 +265,12 @@ class backhaul_manager : public btl::transport_socket_thread { * the TLVs to include in notification messages or responses to CDMU query messages. */ struct sRadioInfo { - beerocks_message::sVapsList vaps_list; /**< List of VAPs in radio. */ + std::string interface_name; /**< Name of the radio interface */ + beerocks::eFreqType frequency_band = + beerocks::eFreqType::FREQ_UNKNOWN; /**< Frequency band */ + beerocks::eWiFiBandwidth max_bandwidth = + beerocks::eWiFiBandwidth::BANDWIDTH_UNKNOWN; /**< Maximum supported bandwidth */ + beerocks_message::sVapsList vaps_list; /**< List of VAPs in radio. */ std::array supported_channels; /**< Array of supported channels in radio. */ std::unordered_map diff --git a/agent/src/beerocks/slave/son_slave_thread.cpp b/agent/src/beerocks/slave/son_slave_thread.cpp index fb3c5874a2..a0e7c3a179 100644 --- a/agent/src/beerocks/slave/son_slave_thread.cpp +++ b/agent/src/beerocks/slave/son_slave_thread.cpp @@ -3250,6 +3250,9 @@ bool slave_thread::slave_fsm(bool &call_slave_select) config.backhaul_wireless_iface.c_str(), message::IFACE_NAME_LENGTH); + bh_enable->frequency_band() = hostap_params.frequency_band; + bh_enable->max_bandwidth() = hostap_params.max_bandwidth; + auto tuple_supported_channels = bh_enable->supported_channels_list(0); if (!std::get<0>(tuple_supported_channels)) { LOG(ERROR) << "getting supported channels has failed!"; From b12a2f3c499d67dd2c6c1f25682d3ebd71b06ec5 Mon Sep 17 00:00:00 2001 From: Mario Maz Date: Tue, 31 Mar 2020 19:35:34 +0200 Subject: [PATCH 08/10] agent: backhaul: complete get_media_type for wireless interfaces MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Complete the get_media_type() method to compute MediaType field for IEEE_802_11 interfaces, according to Table 6-12—Media type (intfType) found in IEEE 1905.1 standard. Signed-off-by: Mario Maz --- .../backhaul_manager_thread.cpp | 153 +++++++++++------- .../backhaul_manager_thread.h | 27 ++++ 2 files changed, 122 insertions(+), 58 deletions(-) diff --git a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp index f30026db3f..30566831b8 100644 --- a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp +++ b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp @@ -82,71 +82,45 @@ namespace beerocks { const char *backhaul_manager::s_arrStates[] = {FOREACH_STATE(GENERATE_STRING)}; /** - * @brief Gets media type group for given interface. + * IEEE Std 1905.1, Table 6-12—Media type (intfType) * - * @param[in] interface_name Name of the local interface. - * @param[in, out] media_type_group The media type group of the connecting interface. - * - * @return True on success and false otherwise. + * Value and Description Frequency MaxBandwith Comments + * 0 IEEE 802.11b (2.4 GHz) 2.4 GHz 22 MHz Not supported + * 1 IEEE 802.11g (2.4 GHz) 2.4 GHz 20 MHz + * 2 IEEE 802.11a (5 GHz) 5 GHz 20 MHz + * 3 IEEE 802.11n (2.4 GHz) 2.4 GHz 40 MHz + * 4 IEEE 802.11n (5 GHz) 5 GHz 40 MHz + * 5 IEEE 802.11ac (5 GHz) 5 GHz 80 MHz + * 6 IEEE 802.11ad (60 GHz) 60 GHz 160 MHz Not supported + * 7 IEEE 802.11af (whitespace) Not supported + * 8 IEEE 802.11ax (2.4 GHz) 2.4 GHz 160 MHz Not included in Table 6-12—Media type (intfType), WiFi6 is specified to use 0x0108 in R2 + * 8 IEEE 802.11ax (5 GHz) 5 GHz 160 MHz Not included in Table 6-12—Media type (intfType), WiFi6 is specified to use 0x0108 in R2 */ -static bool get_media_type_group(const std::string &interface_name, - ieee1905_1::eMediaTypeGroup &media_type_group) -{ - // TODO: Currently, only Ethernet is supported - // When dealing with WiFi interfaces in task #792, use NL80211_CMD_GET_INTERFACE command to - // find out if media type group is WiFi - media_type_group = ieee1905_1::eMediaTypeGroup::IEEE_802_3; +static const std::vector> + table_6_12_media_type // + { + {eFreqType::FREQ_24G, eWiFiBandwidth::BANDWIDTH_20, // + ieee1905_1::eMediaType::IEEE_802_11G_2_4_GHZ}, - return true; -} + {eFreqType::FREQ_5G, eWiFiBandwidth::BANDWIDTH_20, // + ieee1905_1::eMediaType::IEEE_802_11A_5_GHZ}, -/** - * @brief Gets media type for given interface. - * - * The mechanism to use to obtain media type depends on the media type group: - * Ethernet, WiFi, MoCA, etc. - * - * @param[in] interface_name Name of the local interface. - * @param[in] media_type_group The media type group of the connecting interface. - * @param[in, out] media_type The underlying network technology of the connecting interface. - * - * @return True on success and false otherwise. - */ -static bool get_media_type(const std::string &interface_name, - ieee1905_1::eMediaTypeGroup media_type_group, - ieee1905_1::eMediaType &media_type) -{ - bool result = false; + {eFreqType::FREQ_24G, eWiFiBandwidth::BANDWIDTH_40, // + ieee1905_1::eMediaType::IEEE_802_11N_2_4_GHZ}, - if (ieee1905_1::eMediaTypeGroup::IEEE_802_3 == media_type_group) { - uint32_t speed; - if (network_utils::linux_iface_get_speed(interface_name, speed)) { - if (SPEED_100 == speed) { - media_type = ieee1905_1::eMediaType::IEEE_802_3U_FAST_ETHERNET; - } else if (SPEED_1000 <= speed) { - media_type = ieee1905_1::eMediaType::IEEE_802_3AB_GIGABIT_ETHERNET; - } else { - media_type = ieee1905_1::eMediaType::UNKNONWN_MEDIA; - } + {eFreqType::FREQ_5G, eWiFiBandwidth::BANDWIDTH_40, // + ieee1905_1::eMediaType::IEEE_802_11N_5_GHZ}, - result = true; - } - } else if (ieee1905_1::eMediaTypeGroup::IEEE_802_11 == media_type_group) { - // TODO: Not supported yet - LOG(ERROR) << "IEEE_802_11 media is not supported yet"; - } else if (ieee1905_1::eMediaTypeGroup::IEEE_1901 == media_type_group) { - // TODO: Not supported yet - LOG(ERROR) << "IEEE_1901 media is not supported yet"; - } else if (ieee1905_1::eMediaTypeGroup::MoCA == media_type_group) { - // TODO: Not supported yet - LOG(ERROR) << "MoCA media is not supported yet"; - } else { - media_type = ieee1905_1::eMediaType::UNKNONWN_MEDIA; - result = true; - } + {eFreqType::FREQ_5G, eWiFiBandwidth::BANDWIDTH_80, // + ieee1905_1::eMediaType::IEEE_802_11AC_5_GHZ}, - return result; -} + {eFreqType::FREQ_24G, eWiFiBandwidth::BANDWIDTH_160, // + ieee1905_1::eMediaType::IEEE_802_11AX}, + + {eFreqType::FREQ_5G, eWiFiBandwidth::BANDWIDTH_160, // + ieee1905_1::eMediaType::IEEE_802_11AX}, + + }; /** * @brief Adds link metrics to response message. @@ -3426,6 +3400,69 @@ std::shared_ptr backhaul_manager::get_wireless_hal(std::strin return slave_sk->second->sta_wlan_hal; } +bool backhaul_manager::get_media_type_group(const std::string &interface_name, + ieee1905_1::eMediaTypeGroup &media_type_group) +{ + // TODO: Currently, only Ethernet is supported + // When dealing with WiFi interfaces in task #792, use NL80211_CMD_GET_INTERFACE command to + // find out if media type group is WiFi + media_type_group = ieee1905_1::eMediaTypeGroup::IEEE_802_3; + + return true; +} + +bool backhaul_manager::get_media_type(const std::string &interface_name, + ieee1905_1::eMediaTypeGroup media_type_group, + ieee1905_1::eMediaType &media_type) +{ + bool result = false; + + if (ieee1905_1::eMediaTypeGroup::IEEE_802_3 == media_type_group) { + uint32_t speed; + if (network_utils::linux_iface_get_speed(interface_name, speed)) { + if (SPEED_100 == speed) { + media_type = ieee1905_1::eMediaType::IEEE_802_3U_FAST_ETHERNET; + } else if (SPEED_1000 <= speed) { + media_type = ieee1905_1::eMediaType::IEEE_802_3AB_GIGABIT_ETHERNET; + } else { + media_type = ieee1905_1::eMediaType::UNKNONWN_MEDIA; + } + + result = true; + } + } else if (ieee1905_1::eMediaTypeGroup::IEEE_802_11 == media_type_group) { + + for (const auto &radio_info_entry : m_radio_info_map) { + auto radio_info = radio_info_entry.second; + + if (interface_name == radio_info.interface_name) { + + for (const auto &tuple : table_6_12_media_type) { + if ((std::get<0>(tuple) == radio_info.frequency_band) && + (std::get<1>(tuple) == radio_info.max_bandwidth)) { + media_type = std::get<2>(tuple); + + break; + } + } + + break; + } + } + } else if (ieee1905_1::eMediaTypeGroup::IEEE_1901 == media_type_group) { + // TODO: Not supported yet + LOG(ERROR) << "IEEE_1901 media is not supported yet"; + } else if (ieee1905_1::eMediaTypeGroup::MoCA == media_type_group) { + // TODO: Not supported yet + LOG(ERROR) << "MoCA media is not supported yet"; + } else { + media_type = ieee1905_1::eMediaType::UNKNONWN_MEDIA; + result = true; + } + + return result; +} + bool backhaul_manager::get_neighbor_links( const sMacAddr &neighbor_mac_filter, std::map> &neighbor_links_map) diff --git a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.h b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.h index 90653ad9b8..420e7e2953 100644 --- a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.h +++ b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.h @@ -282,6 +282,33 @@ class backhaul_manager : public btl::transport_socket_thread { */ std::unordered_map m_radio_info_map; + /** + * @brief Gets media type group for given interface. + * + * @param[in] interface_name Name of the local interface. + * @param[in, out] media_type_group The media type group of the connecting interface. + * + * @return True on success and false otherwise. + */ + bool get_media_type_group(const std::string &interface_name, + ieee1905_1::eMediaTypeGroup &media_type_group); + + /** + * @brief Gets media type for given interface. + * + * The mechanism to use to obtain media type depends on the media type group: + * Ethernet, WiFi, MoCA, etc. + * + * @param[in] interface_name Name of the local interface. + * @param[in] media_type_group The media type group of the connecting interface. + * @param[in, out] media_type The underlying network technology of the connecting interface. + * + * @return True on success and false otherwise. + */ + bool get_media_type(const std::string &interface_name, + ieee1905_1::eMediaTypeGroup media_type_group, + ieee1905_1::eMediaType &media_type); + /** * @brief Gets the list of neighbor links from topology database. * From 768e7b2d89b7f2a19873d944d04da8cc01a4172c Mon Sep 17 00:00:00 2001 From: Mario Maz Date: Tue, 31 Mar 2020 19:40:38 +0200 Subject: [PATCH 09/10] agent: backhaul: compute MediaType for wireless interfaces in DeviceInformation TLV Use get_media_type() method to compute the MediaType field for wireless interfaces included in the DeviceInformation TLV of the Topology Response message. Signed-off-by: Mario Maz --- .../backhaul_manager_thread.cpp | 33 +++++++++---------- 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp index 30566831b8..9699b3712c 100644 --- a/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp +++ b/agent/src/beerocks/slave/backhaul_manager/backhaul_manager_thread.cpp @@ -2253,14 +2253,12 @@ bool backhaul_manager::handle_1905_topology_query(ieee1905_1::CmduMessageRx &cmd tlvDeviceInformation->add_local_interface_list(localInterfaceInfo); } - // TODO: Add a LocalInterfaceInfo field for each wireless interface. - // This is something that cannot be done at this moment because the MediaType field - // must be computed with information obtained through NL80211_CMD_GET_WIPHY command of DWPAL, - // which is currently not supported. See "Send standard NL80211 commands using DWPAL #782" - // For now, fill from radio data with dummy values based on information we have. + /** + * Add a LocalInterfaceInfo field for each wireless interface. + */ for (const auto &soc : slaves_sockets) { // Iterate on front radio iface and then switch to back radio iface - auto fill_radio_iface_info = [&](bool front_iface) { + auto fill_radio_iface_info = [&](ieee1905_1::eMediaType media_type, bool front_iface) { LOG(DEBUG) << "filling interface information on radio=" << (front_iface ? soc->radio_mac : soc->radio_mac + " backhaul"); @@ -2280,16 +2278,6 @@ bool backhaul_manager::handle_1905_topology_query(ieee1905_1::CmduMessageRx &cmd LOG(DEBUG) << "Added radio interface to tlvDeviceInformation: " << localInterfaceInfo->mac(); - ieee1905_1::eMediaType media_type = ieee1905_1::eMediaType::UNKNONWN_MEDIA; - if (soc->freq_type == beerocks::eFreqType::FREQ_24G) { - media_type = ieee1905_1::eMediaType::IEEE_802_11N_2_4_GHZ; - } else if (soc->freq_type == beerocks::eFreqType::FREQ_5G) { - media_type = ieee1905_1::eMediaType::IEEE_802_11AC_5_GHZ; - } else { - LOG(ERROR) << "Unsupported freq_type=" << int(soc->freq_type) - << ", iface=" << soc->hostap_iface; - return false; - } localInterfaceInfo->media_type() = media_type; ieee1905_1::s802_11SpecificInformation media_info = {}; @@ -2331,13 +2319,22 @@ bool backhaul_manager::handle_1905_topology_query(ieee1905_1::CmduMessageRx &cmd return true; }; - if (!fill_radio_iface_info(true)) { + std::string local_interface_name = soc->hostap_iface; + + ieee1905_1::eMediaTypeGroup media_type_group = ieee1905_1::eMediaTypeGroup::IEEE_802_11; + ieee1905_1::eMediaType media_type = ieee1905_1::eMediaType::UNKNONWN_MEDIA; + if (!get_media_type(local_interface_name, media_type_group, media_type)) { + LOG(ERROR) << "Unable to compute media type for interface " << local_interface_name; + return false; + } + + if (!fill_radio_iface_info(media_type, true)) { LOG(DEBUG) << "filling interface information on radio=" << soc->radio_mac << " has failed!"; return true; } - if (!fill_radio_iface_info(false)) { + if (!fill_radio_iface_info(media_type, false)) { LOG(DEBUG) << "filling interface information on radio=" << soc->radio_mac << " backhaul has failed!"; return true; From e6cd5377c0d24ad4b34e33b5afc13cce284ece88 Mon Sep 17 00:00:00 2001 From: Mario Maz Date: Tue, 31 Mar 2020 19:43:25 +0200 Subject: [PATCH 10/10] controller: use eMediaTypeGroup to check for wireless interfaces MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit eMediaTypeGroup is defined as the MSB of the eMediaType, according to Table 6-12—Media type (intfType) found in IEEE 1905.1a standard. Instead of using minimum and maximum values of eMediaType to check for wireless interfaces, use the value of eMediaTypeGroup. Resulting code is easier to maintain and while we are at it, we also include the newly created IEEE_802_11AX value. Signed-off-by: Mario Maz --- controller/src/beerocks/master/son_master_thread.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/controller/src/beerocks/master/son_master_thread.cpp b/controller/src/beerocks/master/son_master_thread.cpp index 5d2488475b..456409ff2d 100644 --- a/controller/src/beerocks/master/son_master_thread.cpp +++ b/controller/src/beerocks/master/son_master_thread.cpp @@ -1640,14 +1640,14 @@ bool master_thread::handle_cmdu_1905_topology_response(const std::string &src_ma const auto &iface_mac = iface_info.mac(); auto iface_mac_str = network_utils::mac_to_string(iface_mac); - const auto media_type = iface_info.media_type(); + const auto media_type = iface_info.media_type(); + const auto media_type_group = media_type >> 8; // For wireless interface it is defined on IEEE 1905.1 that the size of the media info // is n=10 octets, which the size of s802_11SpecificInformation struct. // For wired interface n=0. - if (media_type >= ieee1905_1::eMediaType::IEEE_802_11B_2_4_GHZ && - media_type <= ieee1905_1::eMediaType::IEEE_802_11AF && - iface_info.media_info_length() == 10) { + if ((ieee1905_1::eMediaTypeGroup::IEEE_802_11 == media_type_group) && + (iface_info.media_info_length() == 10)) { const auto media_info = reinterpret_cast( iface_info.media_info(0));