Skip to content

Commit 192564c

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 192564c

File tree

5 files changed

+80
-5
lines changed

5 files changed

+80
-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: 76 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,16 @@
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"
36+
#define SM_APP_ENABLE_TIMER_INTERVAL_SEC 5
3437

3538
typedef struct {
3639
sta_data_t assoc_stats[BSS_MAX_NUM_STATIONS];
@@ -43,6 +46,9 @@ typedef struct {
4346
unsigned int req_stats_vap_mask;
4447
} client_assoc_stats_t;
4548

49+
static int sm_stats_to_monitor_set(wifi_app_t *app, bool enable);
50+
static void sm_events_subscribe(wifi_app_t *app);
51+
4652
client_assoc_stats_t client_assoc_stats[MAX_NUM_RADIOS];
4753

4854
int sm_survey_type_conversion(wifi_neighborScanMode_t *halw_scan_type, survey_type_t *app_stat_type, unsigned int conv_type)
@@ -556,7 +562,7 @@ int handle_sm_command_event(wifi_app_t *app, wifi_event_t *event)
556562
wifi_mgr_t *g_wifi_mgr = get_wifimgr_obj();
557563
stats_config_t *cur_stats_cfg = NULL;
558564
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;
565+
bool sm_app_enable, off_scan_rfc = g_wifi_mgr->rfc_dml_parameters.wifi_offchannelscan_sm_rfc;
560566

561567
wifi_util_dbg_print(WIFI_SM, "inside %s:%d off_scan_rfc:%d\n",__func__, __LINE__,off_scan_rfc);
562568
if (event->sub_type == wifi_event_type_wifi_offchannelscan_sm_rfc )
@@ -583,6 +589,17 @@ int handle_sm_command_event(wifi_app_t *app, wifi_event_t *event)
583589
cur_stats_cfg = hash_map_get_next(cur_app_stats_cfg_map, cur_stats_cfg);
584590
}
585591
}
592+
} else if (event->sub_type == wifi_event_type_sm_app_enable) {
593+
if (event->u.core_data.msg) {
594+
sm_app_enable = *(bool *)event->u.core_data.msg;
595+
wifi_util_dbg_print(WIFI_SM, "%s:%d: Received SM app enable event. sm_app_enable=%d\n",
596+
__func__, __LINE__, sm_app_enable);
597+
sm_stats_to_monitor_set(app, sm_app_enable);
598+
} else {
599+
wifi_util_error_print(WIFI_SM,
600+
"inside %s:%d sub_type: wifi_event_type_sm_app_enable sm_app_enable=NULL\n",
601+
__func__, __LINE__);
602+
}
586603
}
587604
return RETURN_OK;
588605
}
@@ -797,14 +814,66 @@ int sm_event(wifi_app_t *app, wifi_event_t *event)
797814
monitor_event_sm(app, event);
798815
break;
799816
case wifi_event_type_command:
800-
handle_sm_command_event(app,event);
817+
handle_sm_command_event(app, event);
801818
break;
802819
default:
803820
break;
804821
}
805822
return RETURN_OK;
806823
}
807824

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

809878
int sm_init(wifi_app_t *app, unsigned int create_flag)
810879
{
@@ -814,14 +883,16 @@ int sm_init(wifi_app_t *app, unsigned int create_flag)
814883
}
815884

816885
dpp_init();
886+
sm_events_subscribe(app);
817887

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();
888+
app->data.u.sm_data.sm_stats_config_map = hash_map_create();
889+
app->data.u.sm_data.report_tasks_map = hash_map_create();
820890

821891
memset(client_assoc_stats, 0, sizeof(client_assoc_stats));
822892
rc = sm_report_init(app);
823893

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

826897
return rc;
827898
}

source/apps/sm/wifi_sm.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ typedef struct {
3131
hash_map_t *report_tasks_map;
3232
unsigned int off_chan_report_counter[MAX_NUM_RADIOS];
3333
unsigned int on_chan_report_counter[MAX_NUM_RADIOS];
34+
bool sm_app_enable_subscribed;
3435
} sm_data_t;
3536

3637
typedef enum {

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)