Skip to content

Commit 0e227e6

Browse files
HollowMaxMaksym Holovatyi
authored andcommitted
RDKB-58244: SMApp update based on status of the Mesh.Enable and HCM
Reason for change: SMApp continues to run when Mesh is disabled. Test Procedure: 1. Disable getv Device.DeviceInfo.X_RDKCENTRAL-COM_xOpsDeviceMgmt.Mesh.Enable and Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.MeshWifiOptimization.Mode 2. Check if SM_APP is still running. Risks: Low Priority: P2 Signed-off-by: Maksym Holovatyi <[email protected]>
1 parent db7b158 commit 0e227e6

File tree

5 files changed

+79
-5
lines changed

5 files changed

+79
-5
lines changed

include/wifi_events.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ typedef enum {
164164
wifi_event_type_sta_client_info,
165165
wifi_event_type_start_sta_channel_scan,
166166
wifi_event_type_csi_analytics_rfc,
167+
wifi_event_type_sm_app_enable,
167168
wifi_event_command_max,
168169

169170
wifi_event_monitor_diagnostics = wifi_event_type_base

source/apps/sm/wifi_sm.c

Lines changed: 75 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,15 @@
2424
#include "sm_cache.h"
2525
#include "sm_report.h"
2626
#include "wifi_hal.h"
27+
#include "wifi_ctrl.h"
2728
#include "wifi_mgr.h"
2829
#include "wifi_sm.h"
2930
#include "const.h"
3031
#include "sm_utils.h"
3132

3233
#define DCA_TO_APP 1
3334
#define APP_TO_DCA 2
35+
#define BUS_SM_APP_ENABLE "Device.X_RDK_MeshAgent.SM_APP.Enable"
3436

3537
typedef struct {
3638
sta_data_t assoc_stats[BSS_MAX_NUM_STATIONS];
@@ -43,6 +45,9 @@ typedef struct {
4345
unsigned int req_stats_vap_mask;
4446
} client_assoc_stats_t;
4547

48+
static int sm_stats_to_monitor_set(wifi_app_t *app, bool enable);
49+
static void sm_events_subscribe(void);
50+
4651
client_assoc_stats_t client_assoc_stats[MAX_NUM_RADIOS];
4752

4853
int sm_survey_type_conversion(wifi_neighborScanMode_t *halw_scan_type, survey_type_t *app_stat_type, unsigned int conv_type)
@@ -556,7 +561,7 @@ int handle_sm_command_event(wifi_app_t *app, wifi_event_t *event)
556561
wifi_mgr_t *g_wifi_mgr = get_wifimgr_obj();
557562
stats_config_t *cur_stats_cfg = NULL;
558563
hash_map_t *cur_app_stats_cfg_map = app->data.u.sm_data.sm_stats_config_map;
559-
bool off_scan_rfc = g_wifi_mgr->rfc_dml_parameters.wifi_offchannelscan_sm_rfc;
564+
bool sm_app_enable, off_scan_rfc = g_wifi_mgr->rfc_dml_parameters.wifi_offchannelscan_sm_rfc;
560565

561566
wifi_util_dbg_print(WIFI_SM, "inside %s:%d off_scan_rfc:%d\n",__func__, __LINE__,off_scan_rfc);
562567
if (event->sub_type == wifi_event_type_wifi_offchannelscan_sm_rfc )
@@ -583,6 +588,17 @@ int handle_sm_command_event(wifi_app_t *app, wifi_event_t *event)
583588
cur_stats_cfg = hash_map_get_next(cur_app_stats_cfg_map, cur_stats_cfg);
584589
}
585590
}
591+
} else if (event->sub_type == wifi_event_type_sm_app_enable) {
592+
if (event->u.core_data.msg) {
593+
sm_app_enable = *(bool *)event->u.core_data.msg;
594+
wifi_util_dbg_print(WIFI_SM, "%s:%d: Received SM app enable event. sm_app_enable=%d\n",
595+
__func__, __LINE__, sm_app_enable);
596+
sm_stats_to_monitor_set(app, sm_app_enable);
597+
} else {
598+
wifi_util_error_print(WIFI_SM,
599+
"inside %s:%d sub_type: wifi_event_type_sm_app_enable sm_app_enable=NULL\n",
600+
__func__, __LINE__);
601+
}
586602
}
587603
return RETURN_OK;
588604
}
@@ -797,14 +813,66 @@ int sm_event(wifi_app_t *app, wifi_event_t *event)
797813
monitor_event_sm(app, event);
798814
break;
799815
case wifi_event_type_command:
800-
handle_sm_command_event(app,event);
816+
handle_sm_command_event(app, event);
801817
break;
802818
default:
803819
break;
804820
}
805821
return RETURN_OK;
806822
}
807823

824+
static void sm_app_enable_handler(char *event_name, raw_data_t *p_data)
825+
{
826+
bool sm_app_enable;
827+
828+
wifi_util_dbg_print(WIFI_SM, "%s:%d recvd event\n", __func__, __LINE__);
829+
830+
if ((strcmp(event_name, BUS_SM_APP_ENABLE) != 0) ||
831+
(p_data->data_type != bus_data_type_boolean)) {
832+
wifi_util_error_print(WIFI_SM, "%s:%d invalid event received,%s:%x\n", __func__, __LINE__,
833+
event_name, p_data->data_type);
834+
return;
835+
}
836+
837+
sm_app_enable = p_data->raw_data.b;
838+
839+
push_event_to_ctrl_queue(&sm_app_enable, sizeof(sm_app_enable), wifi_event_type_command,
840+
wifi_event_type_sm_app_enable, NULL);
841+
}
842+
843+
static int sm_events_timer_task(void *args)
844+
{
845+
sm_events_subscribe();
846+
return TIMER_TASK_COMPLETE;
847+
}
848+
849+
static void sm_events_subscribe(void)
850+
{
851+
wifi_ctrl_t *ctrl = (wifi_ctrl_t *)get_wifictrl_obj();
852+
wifi_bus_desc_t *bus_desc = get_bus_descriptor();
853+
static int task_id = 0;
854+
bool add_timer_task = false;
855+
856+
if (ctrl->sm_app_enable_subscribed == false) {
857+
if (bus_desc->bus_event_subs_fn(&ctrl->handle, BUS_SM_APP_ENABLE, sm_app_enable_handler,
858+
NULL, 0) != bus_error_success) {
859+
wifi_util_dbg_print(WIFI_SM, "%s:%d: event:%s subscribe failed\n", __FUNCTION__,
860+
__LINE__, BUS_SM_APP_ENABLE);
861+
add_timer_task = true;
862+
} else {
863+
ctrl->sm_app_enable_subscribed = true;
864+
wifi_util_info_print(WIFI_SM, "%s:%d: event:%s subscribe success\n", __FUNCTION__,
865+
__LINE__, BUS_SM_APP_ENABLE);
866+
}
867+
}
868+
869+
if (add_timer_task && task_id == 0) {
870+
scheduler_add_timer_task(ctrl->sched, FALSE, &task_id, sm_events_timer_task, NULL,
871+
(ctrl->poll_period * 1000), 0, FALSE);
872+
} else if (!add_timer_task && task_id != 0) {
873+
scheduler_cancel_timer_task(ctrl->sched, task_id);
874+
}
875+
}
808876

809877
int sm_init(wifi_app_t *app, unsigned int create_flag)
810878
{
@@ -814,14 +882,16 @@ int sm_init(wifi_app_t *app, unsigned int create_flag)
814882
}
815883

816884
dpp_init();
885+
sm_events_subscribe();
817886

818-
app->data.u.sm_data.sm_stats_config_map = hash_map_create();
819-
app->data.u.sm_data.report_tasks_map = hash_map_create();
887+
app->data.u.sm_data.sm_stats_config_map = hash_map_create();
888+
app->data.u.sm_data.report_tasks_map = hash_map_create();
820889

821890
memset(client_assoc_stats, 0, sizeof(client_assoc_stats));
822891
rc = sm_report_init(app);
823892

824-
wifi_util_info_print(WIFI_SM, "%s:%d: Init SM app %s\n", __func__, __LINE__, rc ? "failure" : "success");
893+
wifi_util_info_print(WIFI_SM, "%s:%d: Init SM app %s\n", __func__, __LINE__,
894+
rc ? "failure" : "success");
825895

826896
return rc;
827897
}

source/core/wifi_ctrl.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ typedef struct wifi_ctrl {
243243
bool marker_list_config_subscribed;
244244
bool wifi_sta_2g_status_subscribed;
245245
bool wifi_sta_5g_status_subscribed;
246+
bool sm_app_enable_subscribed;
246247
bool eth_bh_status_subscribed;
247248
bool mesh_keep_out_chans_subscribed;
248249
wifiapi_t wifiapi;

source/core/wifi_ctrl_queue_handlers.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3601,6 +3601,7 @@ void handle_command_event(wifi_ctrl_t *ctrl, void *data, unsigned int len,
36013601
case wifi_event_type_start_inst_msmt:
36023602
case wifi_event_type_stop_inst_msmt:
36033603
case wifi_event_type_xfinity_rrm:
3604+
case wifi_event_type_sm_app_enable:
36043605
// not handle here
36053606
break;
36063607
default:

source/core/wifi_events.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ const char *wifi_event_subtype_to_string(wifi_event_subtype_t type)
151151
DOC2S(wifi_event_type_start_channel_scan)
152152
DOC2S(wifi_event_type_rsn_override_rfc)
153153
DOC2S(wifi_event_type_sta_client_info)
154+
DOC2S(wifi_event_type_sm_app_enable)
154155
DOC2S(wifi_event_command_max)
155156
DOC2S(wifi_event_monitor_diagnostics)
156157
DOC2S(wifi_event_monitor_connect)

0 commit comments

Comments
 (0)