Skip to content

Commit

Permalink
RDKBWIFI-6: Add available spectrum inquiry request
Browse files Browse the repository at this point in the history
  • Loading branch information
smucognizant authored and soumyasmunshi committed Jan 14, 2025
1 parent e7fa693 commit c45cb18
Show file tree
Hide file tree
Showing 4 changed files with 110 additions and 0 deletions.
13 changes: 13 additions & 0 deletions inc/em_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,7 @@ typedef enum {
em_msg_type_ap_mld_config_resp,
em_msg_type_bsta_mld_config_req,
em_msg_type_bsta_mld_config_resp,
em_msg_type_avail_spectrum_inquiry = 0x8049,
} em_msg_type_t;

typedef enum {
Expand Down Expand Up @@ -550,6 +551,8 @@ typedef enum {
em_tlv_type_assoc_sta_mld_conf_rep = 0xe2,
em_tlv_type_tid_to_link_map_policy = 0xe6,
em_tlv_eht_operations = 0xe7,
em_tlv_type_avail_spectrum_inquiry_reg = 0xe8,
em_tlv_type_avail_spectrum_inquiry_rsp = 0xe9,
em_tlv_vendor_sta_metrics = 0xf1,

// RDK Proprietary TLV values
Expand Down Expand Up @@ -1552,6 +1555,14 @@ typedef struct {
em_eht_operations_radio_t radios[EM_MAX_RADIO_PER_AGENT];
} __attribute__((__packed__)) em_eht_operations_t;

typedef struct {
unsigned char *avail_spectrum_inquiry_req_obj;
} __attribute__((__packed__)) em_avail_spectrum_inquiry_req_t;

typedef struct {
unsigned char *avail_spectrum_inquiry_rsp_obj;
} __attribute__((__packed__)) em_avail_spectrum_inquiry_rsp_t;

typedef struct {
em_radio_id_t ruid;
unsigned char boot_only : 1;
Expand Down Expand Up @@ -1815,6 +1826,7 @@ typedef enum {
em_state_ctrl_set_policy_pending,
em_state_ctrl_ap_mld_config_pending,
em_state_ctrl_ap_mld_configured,
em_state_ctrl_avail_spectrum_inquiry_pending,

em_state_max,
} em_state_t;
Expand Down Expand Up @@ -1857,6 +1869,7 @@ typedef enum {
em_cmd_type_sta_disassoc,
em_cmd_type_get_policy,
em_cmd_type_set_policy,
em_cmd_type_avail_spectrum_inquiry,
em_cmd_type_max,
} em_cmd_type_t;

Expand Down
1 change: 1 addition & 0 deletions inc/em_channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class em_channel_t {
int send_operating_channel_report_msg();
int send_channel_pref_query_msg();
int send_channel_pref_report_msg();
int send_available_spectrum_inquiry_msg();

int handle_channel_pref_rprt(unsigned char *buff, unsigned int len);
int handle_channel_pref_query(unsigned char *buff, unsigned int len);
Expand Down
91 changes: 91 additions & 0 deletions src/em/channel/em_channel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1051,6 +1051,90 @@ int em_channel_t::send_channel_pref_report_msg()
return len;
}

int em_channel_t::send_available_spectrum_inquiry_msg()
{
unsigned char buff[MAX_EM_BUFF_SZ];
char *errors[EM_MAX_TLV_MEMBERS] = {0};
unsigned short msg_id = em_msg_type_avail_spectrum_inquiry;
int len = 0;
em_cmdu_t *cmdu;
em_tlv_t *tlv;
short sz = 0;
unsigned char *tmp = buff;
unsigned short type = htons(ETH_P_1905);
dm_easy_mesh_t *dm;

dm = get_data_model();

memcpy(tmp, dm->get_ctl_mac(), sizeof(mac_address_t));
tmp += sizeof(mac_address_t);
len += sizeof(mac_address_t);

memcpy(tmp, dm->get_agent_al_interface_mac(), sizeof(mac_address_t));
tmp += sizeof(mac_address_t);
len += sizeof(mac_address_t);

memcpy(tmp, (unsigned char *)&type, sizeof(unsigned short));
tmp += sizeof(unsigned short);
len += sizeof(unsigned short);

cmdu = (em_cmdu_t *)tmp;

memset(tmp, 0, sizeof(em_cmdu_t));
cmdu->type = htons(msg_id);
cmdu->id = htons(msg_id);
cmdu->last_frag_ind = 1;
cmdu->relay_ind = 0;

tmp += sizeof(em_cmdu_t);
len += sizeof(em_cmdu_t);

// Zero or more Channel Preference TLVs (see section 17.2.13).
tlv = (em_tlv_t *)tmp;
tlv->type = em_tlv_type_channel_pref;
sz = create_channel_pref_tlv(tlv->value);
tlv->len = htons(sz);

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

// One Available Spectrum Inquiry Request TLV (see section 17.2.104)
tlv = (em_tlv_t *)tmp;
tlv->type = em_tlv_type_avail_spectrum_inquiry_reg;
tlv->len = htons(sizeof(em_avail_spectrum_inquiry_req_t));

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

// One Available Spectrum Inquiry Response TLV (see section 17.2.105)
tlv = (em_tlv_t *)tmp;
tlv->type = em_tlv_type_avail_spectrum_inquiry_rsp;
tlv->len = htons(sizeof(em_avail_spectrum_inquiry_rsp_t));

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

// End of message
tlv = (em_tlv_t *)tmp;
tlv->type = em_tlv_type_eom;
tlv->len = 0;

tmp += (sizeof (em_tlv_t));
len += (sizeof (em_tlv_t));
if (em_msg_t(em_msg_type_avail_spectrum_inquiry, em_profile_type_3, buff, len).validate(errors) == 0) {
printf("Available Spectrum Inquiry msg failed validation in tnx end\n");
return -1;
}

if (send_frame(buff, len) < 0) {
printf("%s:%d: Available Spectrum Inquiry msg failed, error:%d\n", __func__, __LINE__, errno);
return -1;
}

return len;

}

int em_channel_t::handle_op_channel_report(unsigned char *buff, unsigned int len)
{
dm_easy_mesh_t *dm;
Expand Down Expand Up @@ -1463,6 +1547,12 @@ void em_channel_t::process_msg(unsigned char *data, unsigned int len)
}
break;

case em_msg_type_avail_spectrum_inquiry:
if (get_service_type() == em_service_type_agent) {
send_available_spectrum_inquiry_msg();
}
break;

default:
break;
}
Expand Down Expand Up @@ -1501,6 +1591,7 @@ void em_channel_t::process_ctrl_state()
break;

case em_state_ctrl_channel_select_pending:
case em_state_ctrl_avail_spectrum_inquiry_pending:
if(get_service_type() == em_service_type_ctrl) {
send_channel_sel_request_msg();
}
Expand Down
5 changes: 5 additions & 0 deletions src/em/em.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,10 @@ void em_t::orch_execute(em_cmd_t *pcmd)
case em_cmd_type_set_policy:
set_state(em_state_ctrl_set_policy_pending);
break;

case em_cmd_type_avail_spectrum_inquiry:
m_sm.set_state(em_state_ctrl_avail_spectrum_inquiry_pending);
break;
}
}

Expand Down Expand Up @@ -212,6 +216,7 @@ void em_t::proto_process(unsigned char *data, unsigned int len)
case em_msg_type_channel_sel_req:
case em_msg_type_channel_sel_rsp:
case em_msg_type_op_channel_rprt:
case em_msg_type_avail_spectrum_inquiry:
em_channel_t::process_msg(data, len);
break;

Expand Down

0 comments on commit c45cb18

Please sign in to comment.