Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RDKBWIFI-6: Add spatial reuse tlv handle #69

Merged
merged 1 commit into from
Dec 12, 2024
Merged
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
15 changes: 14 additions & 1 deletion inc/em_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -1387,7 +1387,8 @@ typedef struct {
unsigned char mu_edca : 1;
unsigned char twt_req : 1;
unsigned char twt_resp : 1;
unsigned char reserved : 2;
unsigned char spatial_reuse : 1;
unsigned char reserved : 1;
} __attribute__((__packed__)) em_radio_wifi6_cap_data_t;

typedef struct {
Expand Down Expand Up @@ -2128,6 +2129,18 @@ typedef struct {
bool ap_metrics_wifi6;
em_device_inventory_t inventory_info;
int transmit_power_limit;
unsigned char partial_bss_color;
unsigned char bss_color;
bool hesiga_spatial_reuse_value15_allowed;
bool srg_information_valid;
bool non_srg_offset_valid;
bool psr_disallowed;
unsigned char non_srg_obsspd_max_offset;
unsigned char srg_obsspd_min_offset;
unsigned char srg_obsspd_max_offset;
unsigned char srg_bss_color_bitmap[8];
unsigned char srg_partial_bssid_bitmap[8];
unsigned char neigh_bss_color_in_use_bitmap[8];
} em_radio_info_t;

typedef struct {
Expand Down
3 changes: 3 additions & 0 deletions inc/em_channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,13 @@ class em_channel_t {
short create_channel_scan_req_tlv(unsigned char *buff);
short create_channel_pref_tlv(unsigned char *buff);
short create_operating_channel_report_tlv(unsigned char *buff);
short create_spatial_reuse_report_tlv(unsigned char *buff);
short create_radio_op_restriction_tlv(unsigned char *buff);
short create_cac_complete_report_tlv(unsigned char *buff);
short create_cac_status_report_tlv(unsigned char *buff);
short create_channel_pref_tlv_agent(unsigned char *buff);
short create_transmit_power_limit_tlv(unsigned char *buff);
short create_spatial_reuse_req_tlv(unsigned char *buff);

int send_channel_scan_request_msg();
int send_channel_sel_request_msg();
Expand All @@ -59,6 +61,7 @@ class em_channel_t {
int handle_channel_pref_tlv(unsigned char *buff, op_class_channel_sel *op_class);
int handle_channel_pref_tlv_ctrl(unsigned char *buff, unsigned int len);
int handle_op_channel_report(unsigned char *buff, unsigned int len);
int handle_spatial_reuse_report(unsigned char *buff, unsigned int len);

int get_channel_pref_query_tx_count() { return m_channel_pref_query_tx_cnt; }
void set_channel_pref_query_tx_count(unsigned int cnt) { m_channel_pref_query_tx_cnt = cnt; }
Expand Down
17 changes: 16 additions & 1 deletion src/agent/dm_easy_mesh_agent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -425,10 +425,12 @@ int dm_easy_mesh_agent_t::analyze_channel_sel_req(em_bus_event_t *evt, wifi_bus_
op_class_channel_sel *channel_sel;
em_op_class_info_t *dm_op_class;
em_tx_power_limit_t *tx_power_limit;
em_spatial_reuse_req_t *spatial_reuse_req;

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 *)evt->u.raw_buff + channel_sel->num * sizeof(em_op_class_info_t));
tx_power_limit = (em_tx_power_limit_t*) ((unsigned char *)channel_sel + channel_sel->num * sizeof(em_op_class_info_t));
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();
//TODO Select the right op class and number and configure
Expand Down Expand Up @@ -456,6 +458,19 @@ int dm_easy_mesh_agent_t::analyze_channel_sel_req(em_bus_event_t *evt, wifi_bus_
radio_info->transmit_power_limit = tx_power_limit->tx_power_eirp;
}

dm_radio_t* radio = dm.get_radio(tx_power_limit->ruid);
em_radio_info_t* radio_info = radio->get_radio_info();
radio_info->bss_color = spatial_reuse_req->bss_color;
radio_info->hesiga_spatial_reuse_value15_allowed = spatial_reuse_req->hesiga_spatial_reuse_value15_allowed;
radio_info->srg_information_valid = spatial_reuse_req->srg_info_valid;
radio_info->non_srg_offset_valid = spatial_reuse_req->non_srg_offset_valid;
radio_info->psr_disallowed = spatial_reuse_req->psr_disallowed;
radio_info->non_srg_obsspd_max_offset = spatial_reuse_req->non_srg_obsspd_max_offset;
radio_info->srg_obsspd_min_offset = spatial_reuse_req->srg_obsspd_min_offset;
radio_info->srg_obsspd_max_offset = spatial_reuse_req->srg_obsspd_max_offset;
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,
Expand Down
125 changes: 121 additions & 4 deletions src/em/channel/em_channel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,31 @@ int em_channel_t::send_channel_scan_request_msg()
return len;

}
short em_channel_t::create_spatial_reuse_req_tlv(unsigned char *buff)
{
int len = 0;
em_spatial_reuse_req_t *spatial_reuse_req;

spatial_reuse_req = (em_spatial_reuse_req_t *)buff;
memcpy(spatial_reuse_req->ruid, get_radio_interface_mac(), sizeof(em_radio_id_t));

dm_radio_t *radio = get_data_model()->get_radio(get_radio_interface_mac());
em_radio_info_t *radio_info = radio->get_radio_info();
spatial_reuse_req->bss_color = radio_info->bss_color;
spatial_reuse_req->hesiga_spatial_reuse_value15_allowed = radio_info->hesiga_spatial_reuse_value15_allowed;
spatial_reuse_req->srg_info_valid = radio_info->srg_information_valid;
spatial_reuse_req->non_srg_offset_valid = (unsigned char)radio_info->non_srg_offset_valid;
spatial_reuse_req->psr_disallowed = (unsigned char)radio_info->psr_disallowed;
spatial_reuse_req->non_srg_obsspd_max_offset = (unsigned char)radio_info->non_srg_obsspd_max_offset;
spatial_reuse_req->srg_obsspd_min_offset = (unsigned char)radio_info->srg_obsspd_min_offset;
spatial_reuse_req->srg_obsspd_max_offset = (unsigned char)radio_info->srg_obsspd_max_offset;
memcpy(spatial_reuse_req->srg_bss_color_bitmap, radio_info->srg_bss_color_bitmap, sizeof(spatial_reuse_req->srg_bss_color_bitmap));
memcpy(spatial_reuse_req->srg_partial_bssid_bitmap, radio_info->srg_partial_bssid_bitmap, sizeof(spatial_reuse_req->srg_partial_bssid_bitmap));

len += sizeof(em_spatial_reuse_req_t);

return len;
}

int em_channel_t::send_channel_sel_request_msg()
{
Expand Down Expand Up @@ -329,7 +354,14 @@ int em_channel_t::send_channel_sel_request_msg()
tmp += (sizeof(em_tlv_t) + sz);
len += (sizeof(em_tlv_t) + sz);

// Zero or more Spatial Reuse Request TLVs (see section 17.2.89).
// Zero or more Spatial Reuse Request TLVs (see section 17.2.89).
tlv = (em_tlv_t *)tmp;
tlv->type = em_tlv_type_spatial_reuse_req;
sz = create_spatial_reuse_req_tlv(tlv->value);
tlv->len = htons(sz);

tmp += (sizeof(em_tlv_t) + sz);
len += (sizeof(em_tlv_t) + sz);

// End of message
tlv = (em_tlv_t *)tmp;
Expand Down Expand Up @@ -402,7 +434,15 @@ int em_channel_t::send_channel_sel_response_msg(em_chan_sel_resp_code_type_t cod
len += (sizeof(em_tlv_t) + sizeof(em_channel_sel_rsp_t));

// Zero or more Spatial Reuse Config Response TLVs (see section 17.2.91)
tlv = (em_tlv_t *)tmp;
tlv->type = em_tlv_type_spatial_reuse_cfg_rsp;
tlv->len = htons(sizeof(em_spatial_reuse_cfg_rsp_t));
resp = (em_channel_sel_rsp_t *)tlv->value;
memcpy(resp->ruid, get_radio_interface_mac(), sizeof(em_radio_id_t));
memcpy(&resp->response_code, (unsigned char *)&code, sizeof(unsigned char));

tmp += (sizeof(em_tlv_t) + sizeof(em_channel_sel_rsp_t));
len += (sizeof(em_tlv_t) + sizeof(em_channel_sel_rsp_t));
// End of message
tlv = (em_tlv_t *)tmp;
tlv->type = em_tlv_type_eom;
Expand Down Expand Up @@ -465,6 +505,39 @@ short em_channel_t::create_operating_channel_report_tlv(unsigned char *buff)
return len;
}

short em_channel_t::create_spatial_reuse_report_tlv(unsigned char *buff)
{
short len = 0;
unsigned int i;
dm_easy_mesh_t *dm;
em_spatial_reuse_rprt_t *rprt_spatial_reuse;
unsigned char *tmp;

dm = get_data_model();

rprt_spatial_reuse = (em_spatial_reuse_rprt_t *)buff;
memcpy(rprt_spatial_reuse->ruid, get_radio_interface_mac(), sizeof(em_radio_id_t));

dm_radio_t *radio = dm->get_radio(get_radio_interface_mac());
em_radio_info_t *radio_info = radio->get_radio_info();
rprt_spatial_reuse->partial_bss_color = radio_info->partial_bss_color;
rprt_spatial_reuse->bss_color = radio_info->bss_color;
rprt_spatial_reuse->hesiga_spatial_reuse_value15_allowed = radio_info->hesiga_spatial_reuse_value15_allowed;
rprt_spatial_reuse->srg_info_valid = radio_info->srg_information_valid;
rprt_spatial_reuse->non_srg_offset_valid = (unsigned char)radio_info->non_srg_offset_valid;
rprt_spatial_reuse->psr_disallowed = (unsigned char)radio_info->psr_disallowed;
rprt_spatial_reuse->non_srg_obsspd_max_offset = (unsigned char)radio_info->non_srg_obsspd_max_offset;
rprt_spatial_reuse->srg_obsspd_min_offset = (unsigned char)radio_info->srg_obsspd_min_offset;
rprt_spatial_reuse->srg_obsspd_max_offset = (unsigned char)radio_info->srg_obsspd_max_offset;
memcpy(rprt_spatial_reuse->srg_bss_color_bitmap, radio_info->srg_bss_color_bitmap, sizeof(rprt_spatial_reuse->srg_bss_color_bitmap));
memcpy(rprt_spatial_reuse->srg_partial_bssid_bitmap, radio_info->srg_partial_bssid_bitmap, sizeof(rprt_spatial_reuse->srg_partial_bssid_bitmap));
memcpy(rprt_spatial_reuse->neigh_bss_color_in_use_bitmap, radio_info->neigh_bss_color_in_use_bitmap, sizeof(rprt_spatial_reuse->neigh_bss_color_in_use_bitmap));

len += sizeof(em_spatial_reuse_rprt_t);

return len;
}

int em_channel_t::send_operating_channel_report_msg()
{
unsigned char buff[MAX_EM_BUFF_SZ];
Expand Down Expand Up @@ -513,6 +586,13 @@ int em_channel_t::send_operating_channel_report_msg()
len += (sizeof(em_tlv_t) + sz);

// Zero or more Spatial Reuse Report TLVs (see section 17.2.90)
tlv = (em_tlv_t *)tmp;
tlv->type = em_tlv_type_spatial_reuse_rep;
sz = create_spatial_reuse_report_tlv(tlv->value);
tlv->len = htons(sz);

tmp += (sizeof(em_tlv_t) + sz);
len += (sizeof(em_tlv_t) + sz);

// End of message
tlv = (em_tlv_t *)tmp;
Expand Down Expand Up @@ -914,6 +994,31 @@ int em_channel_t::handle_op_channel_report(unsigned char *buff, unsigned int len
return 0;
}

int em_channel_t::handle_spatial_reuse_report(unsigned char *buff, unsigned int len)
{
dm_easy_mesh_t *dm;
unsigned int db_cfg_type = 0, i = 0, found = 0;
em_spatial_reuse_rprt_t *rpt = (em_spatial_reuse_rprt_t *) buff;
dm = get_data_model();

dm_radio_t *radio = dm->get_radio(get_radio_interface_mac());
em_radio_info_t *radio_info = radio->get_radio_info();
radio_info->partial_bss_color = rpt->partial_bss_color;
radio_info->bss_color = rpt->bss_color;
radio_info->hesiga_spatial_reuse_value15_allowed = rpt->hesiga_spatial_reuse_value15_allowed;
radio_info->srg_information_valid = rpt->srg_info_valid;
radio_info->non_srg_offset_valid = (unsigned char)rpt->non_srg_offset_valid;
radio_info->psr_disallowed = (unsigned char)rpt->psr_disallowed;
radio_info->non_srg_obsspd_max_offset = (unsigned char)rpt->non_srg_obsspd_max_offset;
radio_info->srg_obsspd_min_offset = (unsigned char)rpt->srg_obsspd_min_offset;
radio_info->srg_obsspd_max_offset = (unsigned char)rpt->srg_obsspd_max_offset;
memcpy(radio_info->srg_bss_color_bitmap, rpt->srg_bss_color_bitmap, sizeof(radio_info->srg_bss_color_bitmap));
memcpy(radio_info->srg_partial_bssid_bitmap, rpt->srg_partial_bssid_bitmap, sizeof(radio_info->srg_partial_bssid_bitmap));
memcpy(radio_info->neigh_bss_color_in_use_bitmap, rpt->neigh_bss_color_in_use_bitmap, sizeof(radio_info->neigh_bss_color_in_use_bitmap));

return 0;
}


int em_channel_t::handle_channel_pref_tlv_ctrl(unsigned char *buff, unsigned int len)
{
Expand Down Expand Up @@ -1056,9 +1161,11 @@ int em_channel_t::handle_channel_sel_req(unsigned char *buff, unsigned int len)

op_class_channel_sel *op_class;
em_tx_power_limit_t *tx_power_limit;
em_spatial_reuse_req_t *spatial_reuse_req;

em_event_t ev;
em_bus_event_t *bev;
unsigned char* tmp = (unsigned char *) &ev.u.bevt.u.raw_buff;

ev.type = em_event_type_bus;
bev = &ev.u.bevt;
Expand All @@ -1070,12 +1177,20 @@ int em_channel_t::handle_channel_sel_req(unsigned char *buff, unsigned int len)

while ((tlv->type != em_tlv_type_eom) && (len > 0)) {
if (tlv->type == em_tlv_type_channel_pref) {
op_class = (op_class_channel_sel *)&bev->u.raw_buff;
op_class = (op_class_channel_sel *)tmp;
handle_channel_pref_tlv(tlv->value, op_class);
tmp = (unsigned char *)tmp + op_class->num * sizeof(em_op_class_info_t);
}
if (tlv->type == em_tlv_type_tx_power) {
tx_power_limit = (em_tx_power_limit_t *)((unsigned char *)&bev->u.raw_buff + op_class->num * sizeof(em_op_class_info_t));
tx_power_limit = (em_tx_power_limit_t *)tmp;
memcpy(tx_power_limit, tlv->value, sizeof(em_tx_power_limit_t));
tmp = (unsigned char *)tmp + sizeof(em_tx_power_limit_t);
}
if (tlv->type == em_tlv_type_spatial_reuse_req)
{
spatial_reuse_req = (em_spatial_reuse_req_t *)tmp;
memcpy(spatial_reuse_req, tlv->value, sizeof(em_spatial_reuse_req_t));
tmp = (unsigned char *)tmp + sizeof(em_spatial_reuse_req_t);
}

tlv_len -= (sizeof(em_tlv_t) + htons(tlv->len));
Expand Down Expand Up @@ -1105,7 +1220,9 @@ int em_channel_t::handle_operating_channel_rprt(unsigned char *buff, unsigned in
while ((tlv->type != em_tlv_type_eom) && (len > 0)) {
if (tlv->type == em_tlv_type_op_channel_report) {
handle_op_channel_report(tlv->value, htons(tlv->len));
break;
}
if (tlv->type == em_tlv_type_spatial_reuse_rep) {
handle_spatial_reuse_report(tlv->value, htons(tlv->len));
}

tlv_len -= (sizeof(em_tlv_t) + htons(tlv->len));
Expand Down
Loading