Skip to content
This repository has been archived by the owner on Sep 7, 2020. It is now read-only.

bwl: update basic radio capabilities #1065

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 29 additions & 20 deletions agent/src/beerocks/slave/ap_manager_thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,30 +33,30 @@ using namespace beerocks::net;
/////////////////////////// Local Module Functions ///////////////////////////
//////////////////////////////////////////////////////////////////////////////

static void copy_radio_supported_channels(std::shared_ptr<bwl::ap_wlan_hal> &ap_wlan_hal,
beerocks::message::sWifiChannel supported_channels[])
static void copy_radio_channels(
std::array<bwl::WiFiChannel, beerocks::message::RADIO_CHANNELS_LENGTH> radio_channels,
beerocks::message::sWifiChannel dest_channels[])
{
auto radio_channels = ap_wlan_hal->get_radio_info().supported_channels;

// Copy the channels
for (uint i = 0; i < beerocks::message::SUPPORTED_CHANNELS_LENGTH && i < radio_channels.size();
for (uint i = 0; i < beerocks::message::RADIO_CHANNELS_LENGTH && i < radio_channels.size();
i++) {

supported_channels[i].channel = radio_channels[i].channel;
supported_channels[i].noise = radio_channels[i].noise;
supported_channels[i].tx_pow = radio_channels[i].tx_pow;
supported_channels[i].bss_overlap = radio_channels[i].bss_overlap;
supported_channels[i].is_dfs_channel = radio_channels[i].is_dfs;
supported_channels[i].channel_bandwidth =
dest_channels[i].channel = radio_channels[i].channel;
dest_channels[i].noise = radio_channels[i].noise;
dest_channels[i].tx_pow = radio_channels[i].tx_pow;
dest_channels[i].bss_overlap = radio_channels[i].bss_overlap;
dest_channels[i].is_dfs_channel = radio_channels[i].is_dfs;
dest_channels[i].channel_bandwidth =
uint8_t(beerocks::utils::convert_bandwidth_to_enum(radio_channels[i].bandwidth));
}
}

static std::string
get_radio_supported_channels_string(std::shared_ptr<bwl::ap_wlan_hal> &ap_wlan_hal)
static std::string get_radio_channels_string(
std::array<bwl::WiFiChannel, beerocks::message::RADIO_CHANNELS_LENGTH> radio_channels)
{
std::ostringstream os;
for (auto val : ap_wlan_hal->get_radio_info().supported_channels) {
for (auto val : radio_channels) {
if (val.channel > 0) {
os << " ch = " << int(val.channel) << " | dfs = " << int(val.tx_pow)
<< " | tx_pow = " << int(val.is_dfs) << " | noise = " << int(val.noise)
Expand Down Expand Up @@ -786,8 +786,9 @@ bool ap_manager_thread::handle_cmdu(Socket *sd, ieee1905_1::CmduMessageRx &cmdu_
LOG(ERROR) << "Failed building message!";
return false;
}
auto tuple_supported_channels = response->supported_channels_list(0);
copy_radio_supported_channels(ap_wlan_hal, &std::get<1>(tuple_supported_channels));
auto tuple_preferred_channels = response->preferred_channels_list(0);
copy_radio_channels(ap_wlan_hal->get_radio_info().preferred_channels,
&std::get<1>(tuple_preferred_channels));

message_com::send_cmdu(slave_socket, cmdu_tx);
break;
Expand Down Expand Up @@ -1111,8 +1112,9 @@ bool ap_manager_thread::hal_event_handler(bwl::base_wlan_hal::hal_event_ptr_t ev
LOG(ERROR) << "Failed building message!";
return false;
}
auto tuple_supported_channels = notification->supported_channels_list(0);
copy_radio_supported_channels(ap_wlan_hal, &std::get<1>(tuple_supported_channels));
auto tuple_preferred_channels = notification->preferred_channels_list(0);
copy_radio_channels(ap_wlan_hal->get_radio_info().preferred_channels,
&std::get<1>(tuple_preferred_channels));
fill_cs_params(notification->cs_params());
acs_completed_vap_update = true;
} else {
Expand Down Expand Up @@ -1510,6 +1512,7 @@ void ap_manager_thread::handle_hostapd_attached()
{
LOG(DEBUG) << "handling enabled hostapd";

ap_wlan_hal->read_supported_channels();
itayx marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we read the supported channels here? we anyway read it from NL so why every time we attach to hostapd? This should be done only once.

if (acs_enabled) {
LOG(DEBUG) << "retrieving ACS report";
int read_acs_attempt = 0;
Expand All @@ -1525,7 +1528,7 @@ void ap_manager_thread::handle_hostapd_attached()
usleep(ACS_READ_SLEEP_USC);
}
} else {
ap_wlan_hal->read_supported_channels();
ap_wlan_hal->update_preference_channels_from_supported_channels();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No - the logic of how we choose the channel preference should be abstracted by the BWL.
So instead we should have a read_preferred_channels() API in BWL which internally will use the radio supported channels we read at boot if ACS is disabled.
So - this whole commit should be removed, and replaced with a simple clear API to read preferred channels exactly like the API to read supported channels.

}

auto notification =
Expand Down Expand Up @@ -1567,7 +1570,11 @@ void ap_manager_thread::handle_hostapd_attached()
beerocks::message::VHT_MCS_SET_SIZE, notification->params().vht_mcs_set);

// Copy the channels supported by the AP
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Copy the channels supported by the AP

copy_radio_supported_channels(ap_wlan_hal, notification->params().supported_channels);
auto tuple_supported_channels = notification->supported_channels(0);
copy_radio_channels(ap_wlan_hal->get_radio_info().supported_channels,
&std::get<1>(tuple_supported_channels));
copy_radio_channels(ap_wlan_hal->get_radio_info().preferred_channels,
notification->params().preferred_channels);

LOG(INFO) << "send ACTION_APMANAGER_JOINED_NOTIFICATION";
LOG(INFO) << " iface = " << ap_wlan_hal->get_iface_name();
Expand All @@ -1583,8 +1590,10 @@ void ap_manager_thread::handle_hostapd_attached()
LOG(INFO) << " ht_capability = " << std::hex << ap_wlan_hal->get_radio_info().ht_capability;
LOG(INFO) << " vht_supported = " << ap_wlan_hal->get_radio_info().vht_supported;
LOG(INFO) << " vht_capability = " << std::hex << ap_wlan_hal->get_radio_info().vht_capability;
LOG(INFO) << " preferred_channels = " << std::endl
<< get_radio_channels_string(ap_wlan_hal->get_radio_info().preferred_channels);
LOG(INFO) << " supported_channels = " << std::endl
<< get_radio_supported_channels_string(ap_wlan_hal);
<< get_radio_channels_string(ap_wlan_hal->get_radio_info().supported_channels);

// Send CMDU
message_com::send_cmdu(slave_socket, cmdu_tx);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1776,15 +1776,15 @@ bool backhaul_manager::handle_slave_backhaul_message(std::shared_ptr<sRadioInfo>
return false;
}

auto tuple_supported_channels = request->supported_channels_list(0);
if (!std::get<0>(tuple_supported_channels)) {
auto tuple_preferred_channels = request->preferred_channels_list(0);
if (!std::get<0>(tuple_preferred_channels)) {
LOG(ERROR) << "access to supported channels list failed!";
return false;
}

auto channels = &std::get<1>(tuple_supported_channels);
auto channels = &std::get<1>(tuple_preferred_channels);

std::copy_n(channels, beerocks::message::SUPPORTED_CHANNELS_LENGTH,
std::copy_n(channels, beerocks::message::RADIO_CHANNELS_LENGTH,
soc->supported_channels.begin());

soc->radio_mac = request->iface_mac();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ class backhaul_manager : public btl::transport_socket_thread {
vht_mcs_set; /**< 32-byte attribute containing the MCS set as defined in 802.11ac */
bool he_supported = false; /**< Is HE supported flag */
beerocks_message::sVapsList vaps_list; /**< List of VAPs in radio. */
std::array<beerocks::message::sWifiChannel, beerocks::message::SUPPORTED_CHANNELS_LENGTH>
std::array<beerocks::message::sWifiChannel, beerocks::message::RADIO_CHANNELS_LENGTH>
supported_channels; /**< Array of supported channels in radio. */
std::unordered_map<sMacAddr, associated_clients_t>
associated_clients_map; /**< Associated clients grouped by BSSID. */
Expand Down
33 changes: 18 additions & 15 deletions agent/src/beerocks/slave/son_slave_thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1626,6 +1626,9 @@ bool slave_thread::handle_cmdu_ap_manager_message(Socket *sd,
}
hostap_params = notification->params();
hostap_cs_params = notification->cs_params();
auto tuple_supported_channels = notification->supported_channels(0);
std::copy_n(&std::get<1>(tuple_supported_channels), message::RADIO_CHANNELS_LENGTH,
supported_channels);
if (slave_state == STATE_WAIT_FOR_AP_MANAGER_JOINED) {
slave_state = STATE_AP_MANAGER_JOINED;
} else {
Expand Down Expand Up @@ -1787,10 +1790,10 @@ bool slave_thread::handle_cmdu_ap_manager_message(Socket *sd,
return false;
}
notification_out->cs_params() = notification_in->cs_params();
auto tuple_in_supported_channels = notification_in->supported_channels_list(0);
auto tuple_out_supported_channels = notification_out->supported_channels(0);
std::copy_n(&std::get<1>(tuple_in_supported_channels), message::SUPPORTED_CHANNELS_LENGTH,
&std::get<1>(tuple_out_supported_channels));
auto tuple_in_preferred_channels = notification_in->preferred_channels_list(0);
auto tuple_out_preferred_channels = notification_out->preferred_channels(0);
std::copy_n(&std::get<1>(tuple_in_preferred_channels), message::RADIO_CHANNELS_LENGTH,
&std::get<1>(tuple_out_preferred_channels));
send_cmdu_to_controller(cmdu_tx);
send_operating_channel_report();
break;
Expand Down Expand Up @@ -2238,9 +2241,9 @@ bool slave_thread::handle_cmdu_ap_manager_message(Socket *sd,
return false;
}

auto tuple_supported_channels = response->supported_channels_list(0);
std::copy_n(&std::get<1>(tuple_supported_channels), message::SUPPORTED_CHANNELS_LENGTH,
hostap_params.supported_channels);
auto tuple_preferred_channels = response->preferred_channels_list(0);
std::copy_n(&std::get<1>(tuple_preferred_channels), message::RADIO_CHANNELS_LENGTH,
hostap_params.preferred_channels);

// build channel preference report
auto cmdu_tx_header = cmdu_tx.create(
Expand All @@ -2252,7 +2255,7 @@ bool slave_thread::handle_cmdu_ap_manager_message(Socket *sd,
}

auto preferences =
wireless_utils::get_channel_preferences(hostap_params.supported_channels);
wireless_utils::get_channel_preferences(hostap_params.preferred_channels);

auto channel_preference_tlv = cmdu_tx.addClass<wfa_map::tlvChannelPreference>();
if (!channel_preference_tlv) {
Expand Down Expand Up @@ -3252,14 +3255,14 @@ bool slave_thread::slave_fsm(bool &call_slave_select)
std::copy_n(hostap_params.vht_mcs_set, beerocks::message::VHT_MCS_SET_SIZE,
bh_enable->vht_mcs_set());

auto tuple_supported_channels = bh_enable->supported_channels_list(0);
if (!std::get<0>(tuple_supported_channels)) {
auto tuple_preferred_channels = bh_enable->preferred_channels_list(0);
if (!std::get<0>(tuple_preferred_channels)) {
LOG(ERROR) << "getting supported channels has failed!";
break;
}

std::copy_n(hostap_params.supported_channels, message::SUPPORTED_CHANNELS_LENGTH,
&std::get<1>(tuple_supported_channels));
std::copy_n(hostap_params.preferred_channels, message::RADIO_CHANNELS_LENGTH,
&std::get<1>(tuple_preferred_channels));

// Send the message
LOG(DEBUG) << "send ACTION_BACKHAUL_ENABLE for mac " << bh_enable->iface_mac();
Expand Down Expand Up @@ -3383,7 +3386,7 @@ bool slave_thread::slave_fsm(bool &call_slave_select)
return false;
}

std::array<beerocks::message::sWifiChannel, beerocks::message::SUPPORTED_CHANNELS_LENGTH>
std::array<beerocks::message::sWifiChannel, beerocks::message::RADIO_CHANNELS_LENGTH>
supported_channels;
std::copy_n(std::begin(hostap_params.supported_channels), supported_channels.size(),
supported_channels.begin());
Expand Down Expand Up @@ -4500,8 +4503,8 @@ beerocks::message::sWifiChannel slave_thread::channel_selection_select_channel()
if (preference.channels.empty()) {
continue;
}
for (uint8_t i = 0; i < beerocks::message::SUPPORTED_CHANNELS_LENGTH; i++) {
const auto &channel = hostap_params.supported_channels[i];
for (uint8_t i = 0; i < beerocks::message::RADIO_CHANNELS_LENGTH; i++) {
const auto &channel = hostap_params.preferred_channels[i];
auto operating_class = wireless_utils::get_operating_class_by_channel(channel);

// Skip DFS channels
Expand Down
1 change: 1 addition & 0 deletions agent/src/beerocks/slave/son_slave_thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ class slave_thread : public beerocks::socket_thread {
sSlaveBackhaulParams backhaul_params;
beerocks_message::sNodeHostap hostap_params;
beerocks_message::sApChannelSwitch hostap_cs_params;
std::vector<beerocks::message::sWifiChannel> supported_channels;
std::vector<wireless_utils::sChannelPreference> channel_preferences;

SocketClient *platform_manager_socket = nullptr;
Expand Down
2 changes: 1 addition & 1 deletion agent/src/beerocks/slave/tlvf_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ using namespace beerocks;

bool tlvf_utils::add_ap_radio_basic_capabilities(
ieee1905_1::CmduMessageTx &cmdu_tx, const sMacAddr &ruid,
const std::array<beerocks::message::sWifiChannel, beerocks::message::SUPPORTED_CHANNELS_LENGTH>
const std::array<beerocks::message::sWifiChannel, beerocks::message::RADIO_CHANNELS_LENGTH>
&supported_channels)
{
std::vector<uint8_t> operating_classes;
Expand Down
2 changes: 1 addition & 1 deletion agent/src/beerocks/slave/tlvf_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class tlvf_utils {
static bool add_ap_radio_basic_capabilities(
ieee1905_1::CmduMessageTx &cmdu_tx, const sMacAddr &ruid,
const std::array<beerocks::message::sWifiChannel,
beerocks::message::SUPPORTED_CHANNELS_LENGTH> &supported_channels);
beerocks::message::RADIO_CHANNELS_LENGTH> &supported_channels);
};

} // namespace beerocks
Expand Down
2 changes: 1 addition & 1 deletion common/beerocks/bcl/include/bcl/beerocks_defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ enum eStructsConsts {
VERSION_LENGTH = 16,
NODE_NAME_LENGTH = 32,
IFACE_NAME_LENGTH = 32 + 4, //need extra 1 byte for null termination + alignment
SUPPORTED_CHANNELS_LENGTH = 64, //support upto # channels, every channel item is 32-bit
RADIO_CHANNELS_LENGTH = 128, //support upto # channels, every channel item is 32-bit
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Why change to 128 by default?
  2. why change at all? it should be changed to supported channels length and when you add the preferred channels length we will use a new enum.
  3. The name is bad - NUM_SUPPORTED_CHANNELS and NUM_PREFERRED_CHANNELS is better.

HOSTAP_ERR_MSG_LENGTH = 64,
WIFI_DRIVER_VER_LENGTH = 32 + 4,
WIFI_SSID_MAX_LENGTH = 32 + 1 + 3, //need extra 1 byte for null termination + alignment
Expand Down
8 changes: 4 additions & 4 deletions common/beerocks/bcl/source/son/son_wireless_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,7 @@ wireless_utils::get_channel_preferences(const beerocks::message::sWifiChannel su

for (auto oper_class : operating_classes_list) {
std::vector<beerocks::message::sWifiChannel> radar_affected_channels;
for (uint8_t i = 0; i < beerocks::message::SUPPORTED_CHANNELS_LENGTH; i++) {
for (uint8_t i = 0; i < beerocks::message::RADIO_CHANNELS_LENGTH; i++) {
if (has_operating_class_channel(oper_class.second, supported_channels[i]) &&
supported_channels[i].radar_affected) {
radar_affected_channels.push_back(supported_channels[i]);
Expand Down Expand Up @@ -667,7 +667,7 @@ std::vector<uint8_t> wireless_utils::get_supported_operating_classes(
std::vector<uint8_t> operating_classes;
//TODO handle regulatory domain operating classes
for (auto oper_class : operating_classes_list) {
for (uint8_t i = 0; i < beerocks::message::SUPPORTED_CHANNELS_LENGTH; i++) {
for (uint8_t i = 0; i < beerocks::message::RADIO_CHANNELS_LENGTH; i++) {
if (has_operating_class_channel(oper_class.second, supported_channels[i])) {
operating_classes.push_back(oper_class.first);
break;
Expand All @@ -691,7 +691,7 @@ uint8_t wireless_utils::get_operating_class_max_tx_power(
uint8_t max_tx_power = 0;
auto oper_class = operating_classes_list.at(operating_class);

for (uint8_t i = 0; i < beerocks::message::SUPPORTED_CHANNELS_LENGTH; i++) {
for (uint8_t i = 0; i < beerocks::message::RADIO_CHANNELS_LENGTH; i++) {
if (has_operating_class_channel(oper_class, supported_channels[i])) {
max_tx_power = std::max(max_tx_power, supported_channels[i].tx_pow);
}
Expand Down Expand Up @@ -750,7 +750,7 @@ std::vector<uint8_t> wireless_utils::get_operating_class_non_oper_channels(

for (auto op_class_channel : oper_class.channels) {
uint8_t found = 0;
for (uint8_t i = 0; i < beerocks::message::SUPPORTED_CHANNELS_LENGTH; i++) {
for (uint8_t i = 0; i < beerocks::message::RADIO_CHANNELS_LENGTH; i++) {
if (op_class_channel == supported_channels[i].channel &&
oper_class.band == supported_channels[i].channel_bandwidth) {
found = 1;
Expand Down
2 changes: 1 addition & 1 deletion common/beerocks/bwl/common/base_wlan_hal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ base_wlan_hal::base_wlan_hal(HALType type, std::string iface_name, IfaceType ifa
}

// Initialize complex containers of the radio_info structure
m_radio_info.supported_channels.resize(128 /* TODO: Get real value */);
m_radio_info.preferred_channels.fill({});
}

base_wlan_hal::~base_wlan_hal()
Expand Down
54 changes: 53 additions & 1 deletion common/beerocks/bwl/dummy/ap_wlan_hal_dummy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,54 @@ bool ap_wlan_hal_dummy::restricted_channels_set(char *channel_list) { return tru
bool ap_wlan_hal_dummy::restricted_channels_get(char *channel_list) { return false; }

bool ap_wlan_hal_dummy::read_acs_report()
{
uint8_t idx = 0;
if (m_radio_info.is_5ghz == false) {
m_radio_info.channel = 1;
// 2.4G simulated report
for (uint16_t ch = 1; ch <= 11; ch++) {
m_radio_info.preferred_channels[idx].channel = ch;
m_radio_info.preferred_channels[idx].bandwidth = 20;
m_radio_info.preferred_channels[idx].bss_overlap = 10;
m_radio_info.preferred_channels[idx].is_dfs = 0;
idx++;
}
} else {
// 5G simulated report
m_radio_info.channel = 149;
for (uint16_t ch = 36; ch <= 64; ch += 4) {
for (uint16_t step = 0; step < 3; step++) {
m_radio_info.preferred_channels[idx].channel = ch;
m_radio_info.preferred_channels[idx].bandwidth = 20 + step * 20;
m_radio_info.preferred_channels[idx].bss_overlap = 10 + step * 10;
m_radio_info.preferred_channels[idx].is_dfs = (ch > 48) ? 1 : 0;
idx++;
}
}
for (uint16_t ch = 100; ch <= 144; ch += 4) {
for (uint16_t step = 0; step < 3; step++) {
m_radio_info.preferred_channels[idx].channel = ch;
m_radio_info.preferred_channels[idx].bandwidth = 20 + step * 20;
m_radio_info.preferred_channels[idx].bss_overlap = 10 + step * 10;
m_radio_info.preferred_channels[idx].is_dfs = 1;
idx++;
}
}
for (uint16_t ch = 149; ch <= 165; ch += 4) {
for (uint16_t step = 0; step < 3; step++) {
m_radio_info.preferred_channels[idx].channel = ch;
m_radio_info.preferred_channels[idx].bandwidth = 20 + step * 20;
m_radio_info.preferred_channels[idx].bss_overlap = 10 + step * 10;
m_radio_info.preferred_channels[idx].is_dfs = 0;
idx++;
}
}
}

return true;
}

bool ap_wlan_hal_dummy::read_supported_channels()
{
uint8_t idx = 0;
if (m_radio_info.is_5ghz == false) {
Expand Down Expand Up @@ -323,7 +371,11 @@ bool ap_wlan_hal_dummy::read_acs_report()
return true;
}

bool ap_wlan_hal_dummy::read_supported_channels() { return true; }
bool ap_wlan_hal_dummy::update_preference_channels_from_supported_channels()
{
m_radio_info.preferred_channels = m_radio_info.supported_channels;
return true;
}

bool ap_wlan_hal_dummy::set_tx_power_limit(int tx_pow_limit)
{
Expand Down
1 change: 1 addition & 0 deletions common/beerocks/bwl/dummy/ap_wlan_hal_dummy.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class ap_wlan_hal_dummy : public base_wlan_hal_dummy, public ap_wlan_hal {
virtual bool restricted_channels_get(char *channel_list) override;
virtual bool read_acs_report() override;
virtual bool read_supported_channels() override;
virtual bool update_preference_channels_from_supported_channels() override;
virtual bool set_tx_power_limit(int tx_pow_limit) override;
virtual std::string get_radio_driver_version() override;
virtual bool set_vap_enable(const std::string &iface_name, const bool enable) override;
Expand Down
Loading