Skip to content
Draft
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
1 change: 1 addition & 0 deletions build/openwrt/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,7 @@ ifdef EM_APP
$(ONE_WIFI_HOME)/source/webconfig/wifi_webconfig_em_ap_metrics_report.c
endif
WEBCONFIG_SOURCES += $(ONE_WIFI_HOME)/source/webconfig/wifi_webconfig_link_report.c
WEBCONFIG_SOURCES += $(ONE_WIFI_HOME)/source/webconfig/wifi_webconfig_dfs_event.c

ifdef WIFI_SENSING_APP_SUPPORT
CSOURCES += $(wildcard $(ONE_WIFI_HOME)/source/apps/wifi_sensing/src/*.c)
Expand Down
1 change: 1 addition & 0 deletions include/wifi_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ extern "C" {
#define WIFI_LINK_QUALITY_DATA "Device.WiFi.LinkQualityData"
#define WIFI_LINK_QUALITY_FLAGS "Device.WiFi.LinkQualityFlags"
#define WIFI_IGNITE_STATUS "Device.WiFi.EndPoint.1.LinkQualityStatus"
#define WIFI_DFS_EVENT "Device.WiFi.EM.DFSEvent"

#ifndef MAX_NUM_MLD_LINKS
#define MAX_NUM_MLD_LINKS 15
Expand Down
28 changes: 28 additions & 0 deletions include/wifi_webconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ typedef enum {
webconfig_subdoc_type_memwraptool,
webconfig_subdoc_type_link_report,
webconfig_subdoc_type_ignite,
webconfig_subdoc_type_dfs_event,
webconfig_subdoc_type_max
} webconfig_subdoc_type_t;

Expand Down Expand Up @@ -176,6 +177,7 @@ typedef enum {
webconfig_subdoc_object_type_em_sta_link_metrics,
webconfig_subdoc_object_type_em_ap_metrics_report,
webconfig_subdoc_object_type_link_report,
webconfig_subdoc_object_type_dfs_event,

webconfig_subdoc_object_max
} webconfig_subdoc_object_type_t;
Expand Down Expand Up @@ -210,6 +212,23 @@ typedef struct {
void *stats;
} collect_subscribed_stats_t;

typedef enum {
em_dfs_evnt_type_started = 0,
em_dfs_evnt_type_finished,
em_dfs_evnt_type_radar_detected,
em_dfs_evnt_type_aborted,
em_dfs_evnt_type_nop_finished
} em_dfs_evnt_type_t;

typedef struct __attribute__((packed)) {
em_dfs_evnt_type_t event_type;
unsigned char radio_index;
unsigned char op_class;
unsigned char channel;
unsigned short sec_remain_non_occ_dur;
unsigned char status;
} em_bus_event_type_dfs_evnt_params_t;

typedef struct {
wifi_global_config_t config;
wifi_hal_capability_t hal_cap;
Expand All @@ -235,6 +254,7 @@ typedef struct {
em_ap_metrics_report_t em_ap_metrics_report;
#endif
report_batch_t *qmgr_report;
em_bus_event_type_dfs_evnt_params_t dfs_event;
} webconfig_subdoc_decoded_data_t;

typedef char * webconfig_subdoc_encoded_raw_t;
Expand Down Expand Up @@ -700,6 +720,14 @@ webconfig_error_t encode_link_report_subdoc(webconfig_t *config, webconfig
webconfig_error_t translate_to_link_report_subdoc(webconfig_t *config, webconfig_subdoc_data_t *data);
webconfig_error_t translate_from_link_report_subdoc(webconfig_t *config, webconfig_subdoc_data_t *data);

// CAC EVENT
webconfig_error_t init_dfs_event_subdoc(webconfig_subdoc_t *doc);
webconfig_error_t access_check_dfs_event_subdoc(webconfig_t *config, webconfig_subdoc_data_t *data);
webconfig_error_t decode_dfs_event_subdoc(webconfig_t *config, webconfig_subdoc_data_t *data);
webconfig_error_t encode_dfs_event_subdoc(webconfig_t *config, webconfig_subdoc_data_t *data);
webconfig_error_t translate_to_dfs_event_subdoc(webconfig_t *config, webconfig_subdoc_data_t *data);
webconfig_error_t translate_from_dfs_event_subdoc(webconfig_t *config, webconfig_subdoc_data_t *data);

#ifdef __cplusplus
}
#endif
Expand Down
1 change: 1 addition & 0 deletions source/apps/analytics/wifi_analytics.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ const char *subdoc_type_to_string(webconfig_subdoc_type_t type)
DOC2S(webconfig_subdoc_type_em_channel_stats)
#endif
DOC2S(webconfig_subdoc_type_link_report)
DOC2S(webconfig_subdoc_type_dfs_event)
default:
wifi_util_error_print(WIFI_APPS, "%s:%d: event not handle[%d]\r\n", __func__, __LINE__,
type);
Expand Down
34 changes: 34 additions & 0 deletions source/apps/em/wifi_em.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "wifi_hal.h"
#include "wifi_hal_ap.h"
#include "wifi_mgr.h"
#include "wifi_hal_rdk_framework.h"
#include <stdbool.h>
#include <stdint.h>

Expand Down Expand Up @@ -1622,6 +1623,33 @@ static int em_handle_disassoc_device(wifi_app_t *app, void *arg)
return 0;
}

static int em_handle_hal_channel_change(wifi_app_t *app, void *data)
{
wifi_channel_change_event_t *ch_chg = (wifi_channel_change_event_t *)data;

if (ch_chg == NULL) {
wifi_util_error_print(WIFI_CTRL, "%s:%d: NULL channel change data!\n", __func__, __LINE__);
return RETURN_ERR;
}

wifi_ctrl_t *wifi_ctrl = get_wifictrl_obj();
raw_data_t rdata = {0};
rdata.raw_data.bytes = malloc(sizeof(wifi_channel_change_event_t));

if (rdata.raw_data.bytes == NULL) {
wifi_util_error_print(WIFI_CTRL, "%s:%d: Could not allocate for wifi_channel_change_event_t\n", __func__, __LINE__);
return RETURN_ERR;
}

rdata.data_type = bus_data_type_bytes;
memcpy(rdata.raw_data.bytes, ch_chg, sizeof(wifi_channel_change_event_t));
rdata.raw_data_len = sizeof(wifi_channel_change_event_t);
get_bus_descriptor()->bus_event_publish_fn(&wifi_ctrl->handle, WIFI_EM_HAL_CHANNEL_CHANGE, &rdata);
free(rdata.raw_data.bytes);

return RETURN_OK;
}

static int em_handle_sta_conn_status(wifi_app_t *app, void *data)
{
rdk_sta_data_t *sta_data = (rdk_sta_data_t *)data;
Expand Down Expand Up @@ -3056,6 +3084,12 @@ int handle_em_hal_event(wifi_app_t *app, wifi_event_subtype_t sub_type, void *da
em_handle_wnm_action_frame(app, data);
break;

case wifi_event_hal_channel_change:
wifi_util_info_print(WIFI_EM, "%s:%d: case wifi_event_hal_channel_change \n", __func__,
__LINE__);
em_handle_hal_channel_change(app, data);
break;

default:
wifi_util_dbg_print(WIFI_EM, "%s:%d app sub_event:%s not handled\r\n", __func__, __LINE__,
wifi_event_subtype_to_string(sub_type));
Expand Down
1 change: 1 addition & 0 deletions source/apps/em/wifi_em.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ extern "C" {
#define WIFI_EM_CLIENT_ASSOC_CTRL_REQ "Device.WiFi.EM.ClientAssocCtrlRequest"
#define WIFI_EM_UNASSOC_STA_LINK_METRICS_RESP "Device.WiFi.EM.NaStaResponse"
#define WIFI_EM_FAILED_CONNECTION "Device.WiFi.EM.FailedConnection"
#define WIFI_EM_HAL_CHANNEL_CHANGE "Device.WiFi.EM.HALChannelChange"

#define WNM_CATEGORY 10
#define IEEE80211_HDRLEN 24
Expand Down
106 changes: 106 additions & 0 deletions source/core/wifi_ctrl_queue_handlers.c
Original file line number Diff line number Diff line change
Expand Up @@ -3620,6 +3620,64 @@ int dfs_nop_finish_timer(void *args)
return TIMER_TASK_COMPLETE;
}

static void publish_dfs_event(wifi_ctrl_t *ctrl, unsigned char radio_index,
wifi_radio_operationParam_t *radio_params,
wifi_channel_change_event_t *ch_chg,
em_dfs_evnt_type_t event_type,
unsigned short sec_remain_non_occ_dur)
{
webconfig_subdoc_data_t *data;
raw_data_t rdata;
bus_error_t rc;

wifi_util_error_print(WIFI_CTRL, "%s:%d: Start*****\n", __func__, __LINE__);

data = (webconfig_subdoc_data_t *)malloc(sizeof(webconfig_subdoc_data_t));
if (data == NULL) {
wifi_util_error_print(WIFI_CTRL, "%s:%d: malloc failed\n", __func__, __LINE__);
return;
}

if (radio_params == NULL) {
wifi_util_error_print(WIFI_CTRL, "%s:%d: radio_params NULL\n", __func__, __LINE__);
return;
}

// Populate the CAC event structure
data->u.decoded.dfs_event.event_type = event_type;
data->u.decoded.dfs_event.radio_index = radio_index;
data->u.decoded.dfs_event.op_class = radio_params->operatingClass;
data->u.decoded.dfs_event.channel = ch_chg->channel;
data->u.decoded.dfs_event.sec_remain_non_occ_dur = sec_remain_non_occ_dur;
data->u.decoded.dfs_event.status = 0;

// Encode to JSON using WebConfig
if (webconfig_encode(&ctrl->webconfig, data, webconfig_subdoc_type_dfs_event) != webconfig_error_none) {
wifi_util_error_print(WIFI_CTRL, "%s:%d: Error encoding DFS event\n", __func__, __LINE__);
webconfig_data_free(data);
free(data);
return;
}

memset(&rdata, 0, sizeof(raw_data_t));
rdata.data_type = bus_data_type_string;
rdata.raw_data.bytes = (void *)data->u.encoded.raw;
rdata.raw_data_len = strlen(data->u.encoded.raw) + 1;
wifi_util_dbg_print(WIFI_WEBCONFIG,"raw data=%s\n",(char*)rdata.raw_data.bytes);

rc = get_bus_descriptor()->bus_event_publish_fn(&ctrl->handle, WIFI_DFS_EVENT, &rdata);
if (rc != bus_error_success) {
wifi_util_error_print(WIFI_CTRL, "%s:%d: Failed to publish DFS event, error: %d\n",
__func__, __LINE__, rc);
}
else {
wifi_util_dbg_print(WIFI_CTRL, "%s:%d: Published DFS event, type: %d,",__func__, __LINE__, event_type);
}

webconfig_data_free(data);
free(data);
}

void process_channel_change_event(wifi_channel_change_event_t *ch_chg, bool is_nop_start_reboot, unsigned int dfs_timer_secs)
{
wifi_radio_operationParam_t *radio_params = NULL;
Expand Down Expand Up @@ -3747,6 +3805,28 @@ void process_channel_change_event(wifi_channel_change_event_t *ch_chg, bool is_n
goto cleanup;
}

// Get radio MAC address
mac_address_t radio_mac;
radio_interface_mapping_t *radio_iface_map = NULL;
wifi_platform_property_t *wifi_prop = &g_wifidb->hal_cap.wifi_prop;
bool radio_mac_valid = false;

for (unsigned int k = 0; k < (sizeof(wifi_prop->radio_interface_map) / sizeof(radio_interface_mapping_t)); k++) {
if (wifi_prop->radio_interface_map[k].radio_index == ch_chg->radioIndex) {
radio_iface_map = &(wifi_prop->radio_interface_map[k]);
break;
}
}

if (radio_iface_map != NULL) {
if (mac_address_from_name(radio_iface_map->interface_name, radio_mac) == 0) {
radio_mac_valid = true;
mac_addr_str_t mac_str;
to_mac_str(radio_mac, mac_str);
wifi_util_dbg_print(WIFI_CTRL, "%s:%d: Radio MAC: %s\n", __func__, __LINE__, mac_str);
}
}

switch (ch_chg->sub_event)
{
case WIFI_EVENT_RADAR_DETECTED :
Expand All @@ -3755,6 +3835,12 @@ void process_channel_change_event(wifi_channel_change_event_t *ch_chg, bool is_n
/* Ignore the duplicate radar events for the same channel triggered within 2 seconds */
break;
}

if (radio_mac_valid) {
unsigned short sec_remain = 1800;
publish_dfs_event(ctrl, ch_chg->radioIndex, radio_params, ch_chg, em_dfs_evnt_type_radar_detected, sec_remain);
}

unsigned int channel_index = 0;
l_radio->radarInfo.last_channel = ch_chg->channel;
l_radio->radarInfo.num_detected++;
Expand Down Expand Up @@ -3786,9 +3872,17 @@ void process_channel_change_event(wifi_channel_change_event_t *ch_chg, bool is_n
break;
case WIFI_EVENT_RADAR_CAC_FINISHED :
chan_state = CHAN_STATE_DFS_CAC_COMPLETED;
if (radio_mac_valid) {
publish_dfs_event(ctrl, ch_chg->radioIndex, radio_params, ch_chg, em_dfs_evnt_type_finished, 0);
}

break;
case WIFI_EVENT_RADAR_CAC_ABORTED :
chan_state = CHAN_STATE_DFS_CAC_COMPLETED;
if (radio_mac_valid) {
publish_dfs_event(ctrl, ch_chg->radioIndex, radio_params, ch_chg, em_dfs_evnt_type_aborted, 0);
}

break;
case WIFI_EVENT_RADAR_NOP_FINISHED :
if( (unsigned int)l_radio->radarInfo.last_channel == ch_chg->channel && (time_now - l_radio->radarInfo.timestamp >= 1800)) {
Expand Down Expand Up @@ -3819,12 +3913,24 @@ void process_channel_change_event(wifi_channel_change_event_t *ch_chg, bool is_n
}
}
chan_state = CHAN_STATE_DFS_NOP_FINISHED;
if (radio_mac_valid) {
publish_dfs_event(ctrl, ch_chg->radioIndex, radio_params, ch_chg, em_dfs_evnt_type_nop_finished, 0);
}

break;
case WIFI_EVENT_RADAR_PRE_CAC_EXPIRED :
chan_state = CHAN_STATE_DFS_NOP_FINISHED;
if (radio_mac_valid) {
publish_dfs_event(ctrl, ch_chg->radioIndex, radio_params, ch_chg, em_dfs_evnt_type_nop_finished, 0);
}

break;
case WIFI_EVENT_RADAR_CAC_STARTED :
chan_state = CHAN_STATE_DFS_CAC_START;
if (radio_mac_valid) {
publish_dfs_event(ctrl, ch_chg->radioIndex, radio_params, ch_chg, em_dfs_evnt_type_started, 0);
}

break;
}

Expand Down
6 changes: 6 additions & 0 deletions source/core/wifi_ctrl_rbus_handlers.c
Original file line number Diff line number Diff line change
Expand Up @@ -4438,6 +4438,12 @@ void bus_register_handlers(wifi_ctrl_t *ctrl)
{ WIFI_CSA_BEACON_FRAME_RECEIVED, bus_element_type_event,
{ NULL, NULL, NULL, NULL, eventSubHandler, NULL}, high_speed, ZERO_TABLE,
{ bus_data_type_bytes, false, 0, 0, 0, NULL } },
{ WIFI_DFS_EVENT, bus_element_type_event,
{ NULL, NULL, NULL, NULL, eventSubHandler, NULL}, high_speed, ZERO_TABLE,
{ bus_data_type_bytes, false, 0, 0, 0, NULL } },
{ WIFI_EM_HAL_CHANNEL_CHANGE, bus_element_type_event,
{ NULL, NULL, NULL, NULL, eventSubHandler, NULL}, high_speed, ZERO_TABLE,
{ bus_data_type_bytes, false, 0, 0, 0, NULL } },
{ WIFI_LINK_QUALITY_DATA, bus_element_type_method,
{ wifi_get_link_quality_data, NULL, NULL, NULL, NULL, NULL }, slow_speed, ZERO_TABLE,
{ bus_data_type_string, false, 0, 0, 0, NULL } },
Expand Down
8 changes: 8 additions & 0 deletions source/core/wifi_ctrl_webconfig.c
Original file line number Diff line number Diff line change
Expand Up @@ -3187,6 +3187,14 @@ webconfig_error_t webconfig_ctrl_apply(webconfig_subdoc_t *doc, webconfig_subdoc
}
break;

case webconfig_subdoc_type_dfs_event:
if (data->descriptor & webconfig_data_descriptor_encoded) {
ret = webconfig_bus_apply(ctrl, &data->u.encoded);
} else {
return webconfig_error_apply;
}
break;

default:
break;
}
Expand Down
6 changes: 5 additions & 1 deletion source/db/wifi_db.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ static int init_radio_config_default(int radio_index, wifi_radio_operationParam_
cfg.operatingClass = 128;
cfg.channel = 36;
cfg.channelWidth = WIFI_CHANNELBANDWIDTH_80MHZ;

#if defined (_HUB4_PRODUCT_REQ_) && !defined (_SR213_PRODUCT_REQ_)
cfg.variant = WIFI_80211_VARIANT_A | WIFI_80211_VARIANT_N | WIFI_80211_VARIANT_AC;
#else
Expand All @@ -121,16 +122,19 @@ static int init_radio_config_default(int radio_index, wifi_radio_operationParam_
#ifdef CONFIG_IEEE80211BE
cfg.variant |= WIFI_80211_VARIANT_BE;
#endif /* CONFIG_IEEE80211BE */
cfg.DfsEnabled = true;
cfg.DfsEnabledBootup = true;
break;
case WIFI_FREQUENCY_5H_BAND:
cfg.operatingClass = 128;
cfg.channel = 157;
cfg.channelWidth = WIFI_CHANNELBANDWIDTH_80MHZ;
cfg.variant = WIFI_80211_VARIANT_A | WIFI_80211_VARIANT_N | WIFI_80211_VARIANT_AC | WIFI_80211_VARIANT_AX;

#ifdef CONFIG_IEEE80211BE
cfg.variant |= WIFI_80211_VARIANT_BE;
#endif /* CONFIG_IEEE80211BE */
cfg.DfsEnabled = true;
cfg.DfsEnabledBootup = true;
break;
case WIFI_FREQUENCY_6_BAND:
cfg.operatingClass = 134;
Expand Down
4 changes: 4 additions & 0 deletions source/db/wifi_db_apis.c
Original file line number Diff line number Diff line change
Expand Up @@ -7347,6 +7347,8 @@ int wifidb_init_radio_config_default(int radio_index,wifi_radio_operationParam_t
#ifdef CONFIG_IEEE80211BE
cfg->variant |= WIFI_80211_VARIANT_BE;
#endif /* CONFIG_IEEE80211BE */
cfg->DfsEnabled = true;
cfg->DfsEnabledBootup = true;
break;
case WIFI_FREQUENCY_5H_BAND:
cfg->operatingClass = 128;
Expand All @@ -7363,6 +7365,8 @@ int wifidb_init_radio_config_default(int radio_index,wifi_radio_operationParam_t
#ifdef CONFIG_IEEE80211BE
cfg->variant |= WIFI_80211_VARIANT_BE;
#endif /* CONFIG_IEEE80211BE */
cfg->DfsEnabled = true;
cfg->DfsEnabledBootup = true;
break;
case WIFI_FREQUENCY_6_BAND:
cfg->operatingClass = 134;
Expand Down
2 changes: 1 addition & 1 deletion source/webconfig/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ libwifi_webconfig_la_CPPFLAGS += -I$(top_srcdir)/source/dml/wifi_ssp -I$(top_src

libwifi_webconfig_la_CFLAGS = $(SYSTEMD_CFLAGS)

libwifi_webconfig_la_SOURCES = wifi_webconfig.c wifi_encoder.c wifi_decoder.c wifi_webconfig_home.c wifi_webconfig_mesh.c wifi_webconfig_private.c wifi_webconfig_radio.c wifi_webconfig_xfinity.c wifi_webconfig_associated_client.c wifi_webconfig_wifiapi_radio.c wifi_webconfig_wifiapi_vap.c wifi_webconfig_macfilter.c wifi_webconfig_blaster.c wifi_webconfig_harvester.c wifi_webconfig_wifi_config.c wifi_webconfig_csi.c wifi_webconfig_mesh_sta.c wifi_webconfig_mesh_backhaul.c wifi_webconfig_null.c wifi_webconfig_stats_config.c wifi_webconfig_steering_config.c wifi_webconfig_steering_clients.c wifi_webconfig_lnf.c wifi_webconfig_vif_neighbors.c wifi_webconfig_mesh_backhaul_sta.c wifi_webconfig_dml.c wifi_webconfig_levl.c wifi_webconfig_cac.c wifi_webconfig_radio_stats.c wifi_webconfig_neighbor_stats.c wifi_webconfig_assocdevice_stats.c wifi_webconfig_radiodiag_stats.c wifi_webconfig_radio_temperature.c wifi_webconfig_multivap.c wifi_webconfig_easymesh_config.c wifi_webconfig_beacon_report.c wifi_webconfig_memwraptool.c wifi_webconfig_link_report.c wifi_webconfig_ignite.c
libwifi_webconfig_la_SOURCES = wifi_webconfig.c wifi_encoder.c wifi_decoder.c wifi_ovsdb_translator.c wifi_webconfig_home.c wifi_webconfig_mesh.c wifi_webconfig_private.c wifi_webconfig_radio.c wifi_webconfig_xfinity.c wifi_webconfig_associated_client.c wifi_webconfig_wifiapi_radio.c wifi_webconfig_wifiapi_vap.c wifi_webconfig_macfilter.c wifi_webconfig_blaster.c wifi_webconfig_harvester.c wifi_webconfig_wifi_config.c wifi_webconfig_csi.c wifi_webconfig_mesh_sta.c wifi_webconfig_mesh_backhaul.c wifi_webconfig_null.c wifi_webconfig_stats_config.c wifi_webconfig_steering_config.c wifi_webconfig_steering_clients.c wifi_webconfig_lnf.c wifi_webconfig_vif_neighbors.c wifi_webconfig_mesh_backhaul_sta.c wifi_webconfig_dml.c wifi_webconfig_levl.c wifi_webconfig_cac.c wifi_webconfig_radio_stats.c wifi_webconfig_neighbor_stats.c wifi_webconfig_assocdevice_stats.c wifi_webconfig_radiodiag_stats.c wifi_webconfig_radio_temperature.c wifi_webconfig_multivap.c wifi_webconfig_easymesh_config.c wifi_webconfig_beacon_report.c wifi_webconfig_memwraptool.c wifi_webconfig_link_report.c wifi_webconfig_ignite.c wifi_webconfig_dfs_event.c
if EM_APP_SUPPORT
libwifi_webconfig_la_SOURCES += wifi_webconfig_em_channel_stats.c wifi_webconfig_em_sta_link_metrics.c wifi_webconfig_em_ap_metrics_report.c
libwifi_webconfig_la_CFLAGS += $(EM_APP_FLAG)
Expand Down
Loading
Loading