24
24
#include "sm_cache.h"
25
25
#include "sm_report.h"
26
26
#include "wifi_hal.h"
27
+ #include "wifi_ctrl.h"
27
28
#include "wifi_mgr.h"
28
29
#include "wifi_sm.h"
29
30
#include "const.h"
30
31
#include "sm_utils.h"
31
32
32
33
#define DCA_TO_APP 1
33
34
#define APP_TO_DCA 2
35
+ #define BUS_SM_APP_ENABLE "Device.X_RDK_MeshAgent.SM_APP.Enable"
34
36
35
37
typedef struct {
36
38
sta_data_t assoc_stats [BSS_MAX_NUM_STATIONS ];
@@ -43,6 +45,9 @@ typedef struct {
43
45
unsigned int req_stats_vap_mask ;
44
46
} client_assoc_stats_t ;
45
47
48
+ static int sm_stats_to_monitor_set (wifi_app_t * app , bool enable );
49
+ static void sm_events_subscribe (void );
50
+
46
51
client_assoc_stats_t client_assoc_stats [MAX_NUM_RADIOS ];
47
52
48
53
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)
556
561
wifi_mgr_t * g_wifi_mgr = get_wifimgr_obj ();
557
562
stats_config_t * cur_stats_cfg = NULL ;
558
563
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 ;
560
565
561
566
wifi_util_dbg_print (WIFI_SM , "inside %s:%d off_scan_rfc:%d\n" ,__func__ , __LINE__ ,off_scan_rfc );
562
567
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)
583
588
cur_stats_cfg = hash_map_get_next (cur_app_stats_cfg_map , cur_stats_cfg );
584
589
}
585
590
}
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
+ }
586
602
}
587
603
return RETURN_OK ;
588
604
}
@@ -797,14 +813,66 @@ int sm_event(wifi_app_t *app, wifi_event_t *event)
797
813
monitor_event_sm (app , event );
798
814
break ;
799
815
case wifi_event_type_command :
800
- handle_sm_command_event (app ,event );
816
+ handle_sm_command_event (app , event );
801
817
break ;
802
818
default :
803
819
break ;
804
820
}
805
821
return RETURN_OK ;
806
822
}
807
823
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
+ }
808
876
809
877
int sm_init (wifi_app_t * app , unsigned int create_flag )
810
878
{
@@ -814,14 +882,16 @@ int sm_init(wifi_app_t *app, unsigned int create_flag)
814
882
}
815
883
816
884
dpp_init ();
885
+ sm_events_subscribe ();
817
886
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 ();
820
889
821
890
memset (client_assoc_stats , 0 , sizeof (client_assoc_stats ));
822
891
rc = sm_report_init (app );
823
892
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" );
825
895
826
896
return rc ;
827
897
}
0 commit comments