Skip to content

Commit

Permalink
Fix for multi radio implementation
Browse files Browse the repository at this point in the history
Testing Steps:
1)Run agent, Controller and Onewifi.
2)Agent should come up with 2 radios and also channel configuration has to completed in the controller side.

Contributor: AswiniViswanathan and abhijithtk17
  • Loading branch information
abhijithtk17 authored and soumyasmunshi committed Dec 13, 2024
1 parent 0dc0a1c commit 1a9cbe0
Show file tree
Hide file tree
Showing 11 changed files with 327 additions and 208 deletions.
4 changes: 4 additions & 0 deletions inc/dm_easy_mesh.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ class dm_easy_mesh_t {
dm_tid_to_link_t m_tid_to_link;

public:
static em_e4_table_t m_e4_table[];
static em_freq_band_t get_freq_band_by_op_class(int op_class);
em_bss_info_t *get_bss_info_with_mac(mac_address_t mac);
static em_bss_info_t *get_bss_info_with_mac(void *dm, mac_address_t mac) { return ((dm_easy_mesh_t *)dm)->get_bss_info_with_mac(mac); }
virtual int analyze_dev_init(em_bus_event_t *evt, em_cmd_t *pcmd[]);
int analyze_radio_config(em_bus_event_t *evt, em_cmd_t *pcmd[]);
int analyze_vap_config(em_bus_event_t *evt, em_cmd_t *pcmd[]);
Expand Down
13 changes: 13 additions & 0 deletions inc/em_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#define EM_MAC_STR_LEN 17
#define EM_MAX_COLS 32
#define EM_MAX_DM_CHILDREN 32
#define EM_MAX_E4_TABLE_CHANNEL 32

#define EM_PROTO_TOUT 1
#define EM_MGR_TOUT 1
Expand Down Expand Up @@ -1719,6 +1720,7 @@ typedef enum {
em_state_ctrl_topo_sync_pending,
em_state_ctrl_topo_synchronized,
em_state_ctrl_channel_query_pending,
em_state_ctrl_channel_pref_report_pending,
em_state_ctrl_channel_queried,
em_state_ctrl_channel_select_pending,
em_state_ctrl_channel_selected,
Expand Down Expand Up @@ -2446,11 +2448,22 @@ typedef struct{
mac_address_t mac;
unsigned int key_wrap_authenticator;
bool enable;
em_freq_band_t freq;
}m2ctrl_vapconfig;

typedef struct{
int op_class;
em_freq_band_t band;
int channel_spacing;
int num_channels;
int channels[EM_MAX_E4_TABLE_CHANNEL];
}em_e4_table_t;

typedef struct{
unsigned int num;
em_op_class_info_t op_class_info[EM_MAX_OP_CLASS];
em_tx_power_limit_t tx_power;
em_freq_band_t freq_band;
}op_class_channel_sel;

typedef struct {
Expand Down
1 change: 1 addition & 0 deletions inc/em_channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ class em_channel_t {

unsigned int m_channel_pref_query_tx_cnt;
unsigned int m_channel_sel_req_tx_cnt;
virtual em_freq_band_t get_band() = 0;

em_channel_t();
~em_channel_t();
Expand Down
126 changes: 75 additions & 51 deletions src/agent/dm_easy_mesh_agent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,8 @@ void dm_easy_mesh_agent_t::translate_onewifi_dml_data (char *str)

webconfig_proto_easymesh_init(&ext, this, NULL, get_num_radios, set_num_radios,
get_num_op_class, set_num_op_class, get_num_bss, set_num_bss,
get_device_info, get_network_info, get_radio_info, get_ieee_1905_security_info, get_bss_info, get_op_class_info, get_first_sta_info, get_next_sta_info, get_sta_info, put_sta_info);
get_device_info, get_network_info, get_radio_info, get_ieee_1905_security_info, get_bss_info, get_op_class_info,
get_first_sta_info, get_next_sta_info, get_sta_info, put_sta_info, get_bss_info_with_mac);

config.initializer = webconfig_initializer_onewifi;
config.apply_data = webconfig_dummy_apply;
Expand All @@ -206,27 +207,39 @@ int dm_easy_mesh_agent_t::analyze_m2ctrl_configuration(em_bus_event_t *evt, wifi
{
em_event_t bus;
webconfig_external_easymesh_t dev_data;
webconfig_subdoc_type_t type = webconfig_subdoc_type_private;
webconfig_subdoc_type_t type;
webconfig_apply_data_t temp;
webconfig_t config;
static char *webconfig_easymesh_raw_data_ptr;
dm_easy_mesh_agent_t dm;
dm_easy_mesh_agent_t dm = *this;
raw_data_t l_bus_data;
unsigned int index = 0;
m2ctrl_vapconfig *vapconfig;
m2ctrl_vapconfig m2ctrl;
em_freq_band_t freq_band;
mac_addr_str_t mac_str;

vapconfig = (m2ctrl_vapconfig *)evt->u.raw_buff;
freq_band = vapconfig->freq;
if (freq_band == em_freq_band_24) {
type = webconfig_subdoc_type_vap_24G;
} else if (vapconfig->freq == em_freq_band_5) {
type = webconfig_subdoc_type_vap_5G;
} else {
type = webconfig_subdoc_type_vap_6G;
}
memcpy(m2ctrl.ssid, vapconfig->ssid, sizeof(m2ctrl.ssid));
m2ctrl.authtype = vapconfig->authtype;
memcpy(m2ctrl.password, vapconfig->password, sizeof(m2ctrl.password));
m2ctrl.enable = vapconfig->enable;
printf("%s:%d New configuration SSID=%s Security mode=%d passphrase=%s \n",__func__,__LINE__,m2ctrl.ssid,m2ctrl.authtype,m2ctrl.password);
memcpy(m2ctrl.mac, vapconfig->mac, sizeof(mac_address_t));
printf("%s:%d New configuration SSID=%s Security mode=%d passphrase=%s radiomac=%s\n",
__func__,__LINE__, m2ctrl.ssid, m2ctrl.authtype, m2ctrl.password, mac_str);

webconfig_proto_easymesh_init(&dev_data, &dm, &m2ctrl, get_num_radios, set_num_radios,
get_num_op_class, set_num_op_class, get_num_bss, set_num_bss,
get_device_info, get_network_info, get_radio_info, get_ieee_1905_security_info, get_bss_info, get_op_class_info,
get_first_sta_info, get_next_sta_info, get_sta_info, put_sta_info);
get_first_sta_info, get_next_sta_info, get_sta_info, put_sta_info, get_bss_info_with_mac);

config.initializer = webconfig_initializer_onewifi;
config.apply_data = webconfig_dummy_apply;
Expand Down Expand Up @@ -264,12 +277,13 @@ int dm_easy_mesh_agent_t::analyze_onewifi_private_cb(em_bus_event_t *evt, em_cmd
webconfig_external_easymesh_t ext;
webconfig_subdoc_type_t type;
int num = 0;
unsigned int i = 0, j = 0;
dm_easy_mesh_agent_t dm;
unsigned int i = 0, j = 0, index = 0;
dm_easy_mesh_agent_t dm, radio_dm;
em_cmd_t *tmp;
webconfig_proto_easymesh_init(&ext, &dm, NULL, get_num_radios, set_num_radios,
get_num_op_class, set_num_op_class, get_num_bss, set_num_bss,
get_device_info, get_network_info, get_radio_info, get_ieee_1905_security_info, get_bss_info, get_op_class_info, get_first_sta_info, get_next_sta_info, get_sta_info, put_sta_info);
get_device_info, get_network_info, get_radio_info, get_ieee_1905_security_info, get_bss_info,
get_op_class_info, get_first_sta_info, get_next_sta_info, get_sta_info, put_sta_info, get_bss_info_with_mac);
config.initializer = webconfig_initializer_onewifi;
config.apply_data = webconfig_dummy_apply;
if (webconfig_init(&config) != webconfig_error_none) {
Expand All @@ -285,22 +299,23 @@ int dm_easy_mesh_agent_t::analyze_onewifi_private_cb(em_bus_event_t *evt, em_cmd

for (i = 0; i < m_num_bss; i++) {
for (j = 0; j < dm.m_num_bss; j++) {
if (memcmp(get_bss(i)->get_bss_info()->ruid.mac, dm.get_bss(j)->get_bss_info()->ruid.mac, sizeof(mac_address_t)) == 0) {
if (memcmp(get_bss(i)->get_bss_info()->bssid.mac, dm.get_bss(j)->get_bss_info()->bssid.mac, sizeof(mac_address_t)) == 0) {
commit_bss_config(dm, j);
}
}
}
if ((memcmp(get_bss(i)->get_bss_info()->ruid.mac, dm.get_bss(j)->get_bss_info()->ruid.mac, sizeof(mac_address_t)) == 0) &&
(memcmp(get_bss(i)->get_bss_info()->bssid.mac, dm.get_bss(j)->get_bss_info()->bssid.mac, sizeof(mac_address_t)) == 0)) {
commit_bss_config(dm, j);
memcpy(radio_dm.get_radio(index)->get_radio_info()->id.mac, dm.get_bss(j)->get_bss_info()->ruid.mac, sizeof(mac_address_t));
radio_dm.m_num_radios = 1;
pcmd[num] = new em_cmd_ow_cb_t(evt->params, radio_dm);
tmp = pcmd[num];
num++;

while ((pcmd[num] = tmp->clone_for_next()) != NULL) {
tmp = pcmd[num];
num++;
}
}
}
}

pcmd[num] = new em_cmd_ow_cb_t(evt->params, dm);
tmp = pcmd[num];
num++;

while ((pcmd[num] = tmp->clone_for_next()) != NULL) {
tmp = pcmd[num];
num++;
}
return num;
}

Expand All @@ -311,14 +326,15 @@ int dm_easy_mesh_agent_t::analyze_onewifi_radio_cb(em_bus_event_t *evt, em_cmd_t
webconfig_subdoc_type_t type;
int num = 0;
mac_addr_str_t mac_str;
unsigned int i = 0, j = 0;
dm_easy_mesh_agent_t dm;
unsigned int i = 0, j = 0, index = 0;
dm_easy_mesh_agent_t dm, radio_dm;
em_cmd_t *tmp;
em_commit_target_t cm_config;

webconfig_proto_easymesh_init(&ext, &dm, NULL, get_num_radios, set_num_radios,
get_num_op_class, set_num_op_class, get_num_bss, set_num_bss,
get_device_info, get_network_info, get_radio_info, get_ieee_1905_security_info, get_bss_info, get_op_class_info, get_first_sta_info, get_next_sta_info, get_sta_info, put_sta_info);
get_device_info, get_network_info, get_radio_info, get_ieee_1905_security_info, get_bss_info, get_op_class_info,
get_first_sta_info, get_next_sta_info, get_sta_info, put_sta_info, get_bss_info_with_mac);

config.initializer = webconfig_initializer_onewifi;
config.apply_data = webconfig_dummy_apply;
Expand All @@ -332,26 +348,28 @@ int dm_easy_mesh_agent_t::analyze_onewifi_radio_cb(em_bus_event_t *evt, em_cmd_t
} else {
printf("%s:%d Radio subdoc decode fail\n",__func__, __LINE__);
}
for (i = 0; i < m_num_radios; i++) {
for (j = 0; j < dm.m_num_radios; j++) {
if (memcmp(get_radio(i)->get_radio_info()->id.mac, dm.get_radio(j)->get_radio_info()->id.mac, sizeof(mac_address_t)) == 0) {
dm_easy_mesh_t::macbytes_to_string(get_radio(i)->get_radio_info()->id.mac, mac_str);
cm_config.type = em_commit_target_radio;
snprintf((char *)cm_config.params,sizeof(cm_config.params),(char*)"%s",mac_str);
commit_config(dm, cm_config);
for (i = 0; i < m_num_radios; i++) {
for (j = 0; j < dm.m_num_radios; j++) {
if (memcmp(get_radio(i)->get_radio_info()->id.mac, dm.get_radio(j)->get_radio_info()->id.mac, sizeof(mac_address_t)) == 0) {
dm_easy_mesh_t::macbytes_to_string(get_radio(i)->get_radio_info()->id.mac, mac_str);
cm_config.type = em_commit_target_radio;
snprintf((char *)cm_config.params,sizeof(cm_config.params),(char*)"%s",mac_str);
commit_config(dm, cm_config);
memcpy(radio_dm.get_radio(index)->get_radio_info()->id.mac, dm.get_radio(j)->get_radio_info()->id.mac, sizeof(mac_address_t));
radio_dm.m_num_radios = 1;
pcmd[num] = new em_cmd_op_channel_report_t(evt->params, radio_dm);
tmp = pcmd[num];
num++;

while ((pcmd[num] = tmp->clone_for_next()) != NULL) {
tmp = pcmd[num];
num++;
}
}
}
}
pcmd[num] = new em_cmd_op_channel_report_t(evt->params, dm);
tmp = pcmd[num];
num++;

while ((pcmd[num] = tmp->clone_for_next()) != NULL) {
tmp = pcmd[num];
num++;
}
return num;


return num;
}


Expand All @@ -371,7 +389,7 @@ void dm_easy_mesh_agent_t::translate_onewifi_stats_data(char *str)
webconfig_proto_easymesh_init(&extdata, this, NULL, get_num_radios, set_num_radios,
get_num_op_class, set_num_op_class, get_num_bss, set_num_bss,
get_device_info, get_network_info, get_radio_info, get_ieee_1905_security_info, get_bss_info, get_op_class_info,
get_first_sta_info, get_next_sta_info, get_sta_info, put_sta_info);
get_first_sta_info, get_next_sta_info, get_sta_info, put_sta_info, get_bss_info_with_mac);

config.initializer = webconfig_initializer_onewifi;
config.apply_data = webconfig_dummy_apply;
Expand Down Expand Up @@ -403,7 +421,6 @@ int dm_easy_mesh_agent_t::analyze_channel_pref_query(em_bus_event_t *evt, em_cmd
memcpy(&radio->id.mac, &params->mac, sizeof(mac_address_t));
}
dm.set_msg_id(params->msg_id);
dm.print_config();
pcmd[num] = new em_cmd_channel_pref_query_t(em_service_type_agent, evt->params, dm);
num++;

Expand All @@ -414,7 +431,7 @@ int dm_easy_mesh_agent_t::analyze_channel_sel_req(em_bus_event_t *evt, wifi_bus_
{
em_event_t bus;
webconfig_external_easymesh_t dev_data;
webconfig_subdoc_type_t type = webconfig_subdoc_type_radio;
webconfig_subdoc_type_t type;
webconfig_apply_data_t temp;
webconfig_t config;
static char *webconfig_easymesh_raw_data_ptr;
Expand All @@ -429,14 +446,23 @@ int dm_easy_mesh_agent_t::analyze_channel_sel_req(em_bus_event_t *evt, wifi_bus_

channel_sel = (op_class_channel_sel*) evt->u.raw_buff;
printf("%s:%d No of opclass=%d\n", __func__, __LINE__,channel_sel->num);
tx_power_limit = (em_tx_power_limit_t*) ((unsigned char *)channel_sel + channel_sel->num * sizeof(em_op_class_info_t));
tx_power_limit = (em_tx_power_limit_t*) &channel_sel->tx_power;
spatial_reuse_req = (em_spatial_reuse_req_t*) ((unsigned char *)tx_power_limit + channel_sel->num * sizeof(em_op_class_info_t));

noofopclass = dm.get_num_op_class();

if (channel_sel->freq_band == em_freq_band_24) {
type = webconfig_subdoc_type_radio_24G;
} else if (channel_sel->freq_band == em_freq_band_5) {
type = webconfig_subdoc_type_radio_5G;
} else {
type = webconfig_subdoc_type_radio_6G;
}

//TODO Select the right op class and number and configure
for (i = 0; i < noofopclass; i++) {
dm_op_class = dm.get_op_class_info(i);
if ((memcmp(dm_op_class->id.ruid, &channel_sel->op_class_info[0].id.ruid, sizeof(mac_address_t)) == 0) &&
if ((memcmp(&dm_op_class->id.ruid, &channel_sel->op_class_info[0].id.ruid, sizeof(mac_address_t)) == 0) &&
(dm_op_class->id.type == channel_sel->op_class_info[0].id.type)) {
dm_op_class->channel = channel_sel->op_class_info[0].channels[0];
dm_op_class->op_class = channel_sel->op_class_info[0].op_class;
Expand Down Expand Up @@ -471,12 +497,10 @@ int dm_easy_mesh_agent_t::analyze_channel_sel_req(em_bus_event_t *evt, wifi_bus_
memcpy(radio_info->srg_bss_color_bitmap, spatial_reuse_req->srg_bss_color_bitmap, sizeof(radio_info->srg_bss_color_bitmap));
memcpy(radio_info->srg_partial_bssid_bitmap, spatial_reuse_req->srg_partial_bssid_bitmap, sizeof(radio_info->srg_partial_bssid_bitmap));

dm.print_config();

webconfig_proto_easymesh_init(&dev_data, &dm, NULL, get_num_radios, set_num_radios,
get_num_op_class, set_num_op_class, get_num_bss, set_num_bss,
get_device_info, get_network_info, get_radio_info, get_ieee_1905_security_info, get_bss_info, get_op_class_info,
get_first_sta_info, get_next_sta_info, get_sta_info, put_sta_info);
get_first_sta_info, get_next_sta_info, get_sta_info, put_sta_info, get_bss_info_with_mac);

config.initializer = webconfig_initializer_onewifi;
config.apply_data = webconfig_dummy_apply;
Expand Down Expand Up @@ -526,7 +550,7 @@ int dm_easy_mesh_agent_t::analyze_sta_link_metrics(em_bus_event_t *evt, em_cmd_t
webconfig_proto_easymesh_init(&extdata, this, NULL, get_num_radios, set_num_radios,
get_num_op_class, set_num_op_class, get_num_bss, set_num_bss,
get_device_info, get_network_info, get_radio_info, get_ieee_1905_security_info, get_bss_info, get_op_class_info,
get_first_sta_info, get_next_sta_info, get_sta_info, put_sta_info);
get_first_sta_info, get_next_sta_info, get_sta_info, put_sta_info, get_bss_info_with_mac);

config.initializer = webconfig_initializer_onewifi;
config.apply_data = webconfig_dummy_apply;
Expand Down
6 changes: 4 additions & 2 deletions src/agent/em_agent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -470,13 +470,15 @@ int em_agent_t::onewifi_cb(char *event_name, raw_data_t *data)
} else {
cJSON *subdoc_name = cJSON_GetObjectItemCaseSensitive(json, "SubDocName");
if (cJSON_IsString(subdoc_name) && (subdoc_name->valuestring != NULL)) {
if (strcmp(subdoc_name->valuestring, "private") == 0) {
if ((strcmp(subdoc_name->valuestring, "private") == 0) || (strcmp(subdoc_name->valuestring, "Vap_5G") == 0) ||
(strcmp(subdoc_name->valuestring, "Vap_2.4G") == 0)) {
printf("%s:%d Found SubDocName: private\n", __func__, __LINE__);
bevt = &evt.u.bevt;
bevt->type = em_bus_event_type_onewifi_private_cb;
memcpy(bevt->u.raw_buff, data->raw_data.bytes, data->raw_data_len);

} else if (strcmp(subdoc_name->valuestring, "radio") == 0) {
} else if ((strcmp(subdoc_name->valuestring, "radio") == 0) || (strcmp(subdoc_name->valuestring, "radio_5G") == 0) ||
(strcmp(subdoc_name->valuestring, "radio_2.4G") == 0)) {
printf("%s:%d Found SubDocName: radio\n", __func__, __LINE__);
bevt = &evt.u.bevt;
bevt->type = em_bus_event_type_onewifi_radio_cb;
Expand Down
Loading

0 comments on commit 1a9cbe0

Please sign in to comment.