wlan_bearer/wlanengine/wlan_common/wlanengine_common_3.1/src/core_sub_operation_load_drivers.cpp
changeset 0 c40eb8fe8501
child 7 0abc8c98be24
equal deleted inserted replaced
-1:000000000000 0:c40eb8fe8501
       
     1 /*
       
     2 * Copyright (c) 2005-2006 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Statemachine for loading the drivers
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "core_sub_operation_load_drivers.h"
       
    20 #include "core_operation_update_rxtx_parameters.h"
       
    21 #include "core_server.h"
       
    22 #include "am_debug.h"
       
    23 
       
    24 // ======== MEMBER FUNCTIONS ========
       
    25 
       
    26 // ---------------------------------------------------------------------------
       
    27 // ---------------------------------------------------------------------------
       
    28 //
       
    29 core_sub_operation_load_drivers_c::core_sub_operation_load_drivers_c(
       
    30     u32_t request_id,
       
    31     core_server_c* server,
       
    32     abs_core_driverif_c* drivers,
       
    33     abs_core_server_callback_c* adaptation ) :
       
    34     core_operation_base_c( core_operation_unspecified, request_id, server, drivers, adaptation,
       
    35         core_base_flag_none ),
       
    36     region_m( core_wlan_region_etsi ),
       
    37     mcc_known_m( false_t )
       
    38     {
       
    39     DEBUG( "core_sub_operation_load_drivers_c::core_sub_operation_load_drivers_c()" );
       
    40     }
       
    41 
       
    42 // ---------------------------------------------------------------------------
       
    43 // ---------------------------------------------------------------------------
       
    44 //
       
    45 core_sub_operation_load_drivers_c::~core_sub_operation_load_drivers_c()
       
    46     {
       
    47     DEBUG( "core_sub_operation_load_drivers_c::~core_sub_operation_load_drivers_c()" );
       
    48     }
       
    49 
       
    50 // ---------------------------------------------------------------------------
       
    51 // ---------------------------------------------------------------------------
       
    52 //
       
    53 core_error_e core_sub_operation_load_drivers_c::next_state()
       
    54     {
       
    55     DEBUG( "core_sub_operation_load_drivers_c::next_state()" );
       
    56 
       
    57     switch ( operation_state_m )
       
    58         {
       
    59         case core_state_init:
       
    60             {
       
    61             if ( !server_m->get_core_settings().is_wlan_enabled() )
       
    62                 {
       
    63                 DEBUG( "core_sub_operation_load_drivers_c::next_state() - WLAN is disabled, drivers cannot be loaded" );
       
    64                 return core_error_wlan_disabled;
       
    65                 }
       
    66 
       
    67             if ( server_m->get_core_settings().is_driver_loaded() )
       
    68                 {
       
    69                 DEBUG( "core_sub_operation_load_drivers_c::next_state() - drivers already loaded" );
       
    70                 return core_error_ok;
       
    71                 }
       
    72 
       
    73             DEBUG( "core_sub_operation_load_drivers_c::next_state() - requesting region" );
       
    74 
       
    75             operation_state_m = core_state_req_region;
       
    76 
       
    77             adaptation_m->get_regulatory_domain(
       
    78                 request_id_m,
       
    79                 region_m,
       
    80                 mcc_known_m );
       
    81 
       
    82             break;
       
    83             }
       
    84         case core_state_req_region:
       
    85             {            
       
    86             DEBUG1( "core_sub_operation_load_drivers_c::next_state() - current region %u",
       
    87                 region_m );
       
    88             server_m->get_core_settings().set_regional_domain(
       
    89                 region_m );
       
    90             server_m->get_core_settings().set_mcc_known( mcc_known_m );
       
    91 
       
    92             DEBUG( "core_sub_operation_load_drivers_c::next_state() - loading drivers" );
       
    93 
       
    94             operation_state_m = core_state_req_load_drivers;
       
    95             
       
    96             drivers_m->load_drivers(
       
    97                 request_id_m,
       
    98                 server_m->get_device_settings().rts,
       
    99                 server_m->get_device_settings().max_tx_msdu_life_time,
       
   100                 server_m->get_device_settings().qos_null_frame_entry_timeout,
       
   101                 server_m->get_device_settings().qos_null_frame_entry_tx_count,
       
   102                 server_m->get_device_settings().qos_null_frame_interval,
       
   103                 server_m->get_device_settings().qos_null_frame_exit_timeout,
       
   104                 server_m->get_device_settings().keep_alive_interval,
       
   105                 server_m->get_device_settings().sp_rcpi_target,
       
   106                 server_m->get_device_settings().sp_time_target,
       
   107                 server_m->get_device_settings().sp_min_indication_interval );
       
   108 
       
   109             break;
       
   110             }
       
   111         case core_state_req_load_drivers:
       
   112             {
       
   113             server_m->get_core_settings().set_driver_state( true_t );
       
   114 
       
   115             DEBUG1( "core_sub_operation_load_drivers_c::next_state() - setting tx power (%u)",
       
   116                 server_m->get_device_settings().tx_power_level );
       
   117 
       
   118             operation_state_m = core_state_req_set_tx_power;
       
   119 
       
   120             drivers_m->set_tx_power_level(
       
   121                 request_id_m,
       
   122                 server_m->get_device_settings().tx_power_level );
       
   123 
       
   124             break;
       
   125             }
       
   126         case core_state_req_set_tx_power:
       
   127             {
       
   128             DEBUG( "core_sub_operation_load_drivers_c::next_state() - setting power mode to CORE_POWER_MODE_CAM" );
       
   129 
       
   130             operation_state_m = core_state_req_set_rxtx_parameters;
       
   131 
       
   132             server_m->get_core_settings().set_power_mode(
       
   133                 CORE_POWER_MODE_CAM );
       
   134 
       
   135             drivers_m->set_power_mode(
       
   136                 request_id_m,
       
   137                 CORE_POWER_MODE_CAM );
       
   138 
       
   139             break;
       
   140             }
       
   141         case core_state_req_set_rxtx_parameters:
       
   142             {
       
   143             DEBUG( "core_sub_operation_load_drivers_c::next_state() - setting rxtx parameters" );
       
   144 
       
   145             operation_state_m = core_state_req_set_uapsd_settings;
       
   146 
       
   147             core_operation_base_c* operation = new core_operation_update_rxtx_parameters_c(
       
   148                 request_id_m,
       
   149                 server_m,
       
   150                 drivers_m,
       
   151                 adaptation_m );
       
   152 
       
   153             return run_sub_operation( operation );
       
   154             }            
       
   155         case core_state_req_set_uapsd_settings:
       
   156             {
       
   157             DEBUG( "core_sub_operation_load_drivers_c::next_state() - setting U-APSD settings" );
       
   158 
       
   159             operation_state_m = core_state_req_set_power_save_settings;
       
   160 
       
   161             const core_uapsd_settings_s& settings(
       
   162                 server_m->get_core_settings().uapsd_settings() );
       
   163 
       
   164             DEBUG1( "core_sub_operation_load_drivers_c::next_state() - max_service_period: %u",
       
   165                 settings.max_service_period );
       
   166             DEBUG1( "core_sub_operation_load_drivers_c::next_state() - uapsd_enabled_for_voice: %u",
       
   167                 settings.uapsd_enabled_for_voice );
       
   168             DEBUG1( "core_sub_operation_load_drivers_c::next_state() - uapsd_enabled_for_video: %u",
       
   169                 settings.uapsd_enabled_for_video );
       
   170             DEBUG1( "core_sub_operation_load_drivers_c::next_state() - uapsd_enabled_for_best_effort: %u",
       
   171                 settings.uapsd_enabled_for_best_effort );
       
   172             DEBUG1( "core_sub_operation_load_drivers_c::next_state() - uapsd_enabled_for_background: %u",
       
   173                 settings.uapsd_enabled_for_background );
       
   174 
       
   175             drivers_m->set_uapsd_settings(
       
   176                 request_id_m,
       
   177                 settings );
       
   178 
       
   179             break;
       
   180             }
       
   181         case core_state_req_set_power_save_settings:
       
   182             {
       
   183             DEBUG( "core_sub_operation_load_drivers_c::next_state() - setting power save settings" );
       
   184 
       
   185             operation_state_m = core_state_req_set_power_mode_mgmt_settings;
       
   186 
       
   187             const core_power_save_settings_s& settings(
       
   188                 server_m->get_core_settings().power_save_settings() );
       
   189 
       
   190             DEBUG1( "core_sub_operation_load_drivers_c::next_state() - stay_in_uapsd_power_save_for_voice: %u",
       
   191                 settings.stay_in_uapsd_power_save_for_voice );
       
   192             DEBUG1( "core_sub_operation_load_drivers_c::next_state() - stay_in_uapsd_power_save_for_video: %u",
       
   193                 settings.stay_in_uapsd_power_save_for_video );
       
   194             DEBUG1( "core_sub_operation_load_drivers_c::next_state() - stay_in_uapsd_power_save_for_best_effort: %u",
       
   195                 settings.stay_in_uapsd_power_save_for_best_effort );
       
   196             DEBUG1( "core_sub_operation_load_drivers_c::next_state() - stay_in_uapsd_power_save_for_background: %u",
       
   197                 settings.stay_in_uapsd_power_save_for_background );
       
   198 
       
   199             DEBUG1( "core_sub_operation_load_drivers_c::next_state() - stay_in_legacy_power_save_for_voice: %u",
       
   200                 settings.stay_in_legacy_power_save_for_voice );
       
   201             DEBUG1( "core_sub_operation_load_drivers_c::next_state() - stay_in_legacy_power_save_for_video: %u",
       
   202                 settings.stay_in_legacy_power_save_for_video );
       
   203             DEBUG1( "core_sub_operation_load_drivers_c::next_state() - stay_in_legacy_power_save_for_best_effort: %u",
       
   204                 settings.stay_in_legacy_power_save_for_best_effort );
       
   205             DEBUG1( "core_sub_operation_load_drivers_c::next_state() - stay_in_legacy_power_save_for_background: %u",
       
   206                 settings.stay_in_legacy_power_save_for_background );
       
   207 
       
   208             drivers_m->set_power_save_settings(
       
   209                 request_id_m,
       
   210                 settings );
       
   211 
       
   212             break;
       
   213             }
       
   214         case core_state_req_set_power_mode_mgmt_settings:
       
   215             {
       
   216             DEBUG( "core_sub_operation_load_drivers_c::next_state() - setting power mode mgmt settings" );
       
   217 
       
   218             operation_state_m = core_state_req_set_block_ack_usage;
       
   219 
       
   220             core_power_mode_mgmt_parameters_s settings;
       
   221             settings.active_to_light_timeout =
       
   222                 server_m->get_device_settings().ps_active_to_light_timeout;
       
   223             settings.active_to_light_threshold =
       
   224                 server_m->get_device_settings().ps_active_to_light_threshold;
       
   225             settings.light_to_active_timeout =
       
   226                 server_m->get_device_settings().ps_light_to_active_timeout;
       
   227             settings.light_to_active_threshold =
       
   228                 server_m->get_device_settings().ps_light_to_active_threshold;
       
   229             settings.light_to_deep_timeout =
       
   230                 server_m->get_device_settings().ps_light_to_deep_timeout;
       
   231             settings.light_to_deep_threshold =
       
   232                 server_m->get_device_settings().ps_light_to_deep_threshold;
       
   233             settings.uapsd_rx_frame_length_threshold =
       
   234                 server_m->get_device_settings().ps_uapsd_rx_frame_length;
       
   235 
       
   236             DEBUG1( "core_sub_operation_load_drivers_c::next_state() - active_to_light_timeout: %u",
       
   237                 settings.active_to_light_timeout );
       
   238             DEBUG1( "core_sub_operation_load_drivers_c::next_state() - active_to_light_threshold: %u",
       
   239                 settings.active_to_light_threshold );
       
   240             DEBUG1( "core_sub_operation_load_drivers_c::next_state() - light_to_active_timeout: %u",
       
   241                 settings.light_to_active_timeout );
       
   242             DEBUG1( "core_sub_operation_load_drivers_c::next_state() - light_to_active_threshold: %u",
       
   243                 settings.light_to_active_threshold );
       
   244             DEBUG1( "core_sub_operation_load_drivers_c::next_state() - light_to_deep_timeout: %u",
       
   245                 settings.light_to_deep_timeout );
       
   246             DEBUG1( "core_sub_operation_load_drivers_c::next_state() - light_to_deep_threshold: %u",
       
   247                 settings.light_to_deep_threshold );
       
   248             DEBUG1( "core_sub_operation_load_drivers_c::next_state() - uapsd_rx_frame_length_threshold: %u",
       
   249                 settings.uapsd_rx_frame_length_threshold );
       
   250 
       
   251             drivers_m->set_power_mode_mgmt_parameters(
       
   252                 request_id_m,
       
   253                 settings );
       
   254 
       
   255             break;
       
   256             }
       
   257         case core_state_req_set_block_ack_usage:
       
   258             {
       
   259             DEBUG( "core_sub_operation_load_drivers_c::next_state() - setting block ACK usage" );
       
   260 
       
   261             operation_state_m = core_state_req_set_wpx_settings;
       
   262 
       
   263             const core_block_ack_usage_s& usage(
       
   264                 server_m->get_core_settings().block_ack_usage() );
       
   265 
       
   266             DEBUG1( "core_sub_operation_load_drivers_c::next_state() - tx_usage: 0x%02X",
       
   267                 usage.tx_usage );
       
   268             DEBUG1( "core_sub_operation_load_drivers_c::next_state() - rx_usage: 0x%02X",
       
   269                 usage.rx_usage );
       
   270 
       
   271             drivers_m->set_block_ack_usage(
       
   272                 request_id_m,
       
   273                 usage );
       
   274 
       
   275             break;
       
   276             }
       
   277         case core_state_req_set_wpx_settings:
       
   278             {
       
   279             core_operation_base_c* operation =
       
   280                 server_m->get_wpx_adaptation_instance().get_wpx_load_drivers_operation();
       
   281             if( !operation )
       
   282                 {
       
   283                 return goto_state( core_state_done );
       
   284                 }
       
   285 
       
   286             DEBUG( "core_sub_operation_load_drivers_c::next_state() - setting WPX specific settings" );
       
   287 
       
   288             return run_sub_operation( operation, core_state_done );
       
   289             }
       
   290         case core_state_done:
       
   291             {
       
   292             DEBUG( "core_sub_operation_load_drivers_c::next_state() - all operations done" );
       
   293 
       
   294             return core_error_ok;  
       
   295             }
       
   296         case core_state_cancel_req_unload_drivers:
       
   297             {
       
   298             server_m->get_core_settings().set_driver_state( false_t );
       
   299 
       
   300             DEBUG( "core_sub_operation_load_drivers_c::next_state() - unloading done " );
       
   301 
       
   302             return failure_reason_m;
       
   303             }
       
   304         default:
       
   305             {
       
   306             ASSERT( false_t );
       
   307             }
       
   308         }
       
   309 
       
   310     return core_error_request_pending;
       
   311     }
       
   312 
       
   313 // ---------------------------------------------------------------------------
       
   314 // ---------------------------------------------------------------------------
       
   315 //
       
   316 void core_sub_operation_load_drivers_c::user_cancel(
       
   317     bool_t /* do_graceful_cancel */ )
       
   318     {
       
   319     DEBUG( "core_sub_operation_load_drivers_c::user_cancel()" );
       
   320     }
       
   321 
       
   322 // ---------------------------------------------------------------------------
       
   323 // ---------------------------------------------------------------------------
       
   324 //
       
   325 core_error_e core_sub_operation_load_drivers_c::cancel()
       
   326     {
       
   327     DEBUG( "core_sub_operation_load_drivers_c::cancel() " );
       
   328 
       
   329     switch ( operation_state_m )
       
   330         {
       
   331         case core_state_init:
       
   332             /** Falls through on purpose. */
       
   333         case core_state_req_region:
       
   334             /** Falls through on purpose. */
       
   335         case core_state_req_load_drivers:
       
   336             {
       
   337             /* Also in this case we need to make unload because it can happen that loading returns 
       
   338              * failure but there is still need to unload */
       
   339             
       
   340             DEBUG( "core_sub_operation_load_drivers_c::cancel() - unloading drivers, load failed" );
       
   341             
       
   342             operation_state_m = core_state_cancel_req_unload_drivers;
       
   343             
       
   344             drivers_m->unload_drivers(
       
   345                 request_id_m );
       
   346 
       
   347             break;
       
   348             }
       
   349         case core_state_cancel_req_unload_drivers:
       
   350             {
       
   351             DEBUG( "core_sub_operation_load_drivers_c::cancel() - unloading failed, ignoring " );
       
   352             
       
   353             return failure_reason_m;
       
   354             }
       
   355         default:
       
   356             {            
       
   357             ASSERT( server_m->get_core_settings().is_driver_loaded() );
       
   358             DEBUG( "core_sub_operation_load_drivers_c::cancel() - unloading drivers " );
       
   359             
       
   360             operation_state_m = core_state_cancel_req_unload_drivers;
       
   361             
       
   362             drivers_m->unload_drivers(
       
   363                 request_id_m );
       
   364 
       
   365             break;
       
   366             }
       
   367         }
       
   368 
       
   369     return core_error_request_pending;
       
   370     }