wlan_bearer/wlanengine/wlan_common/wlanengine_common_3.1/src/core_operation_handle_delete_ts.cpp
changeset 0 c40eb8fe8501
child 12 af3fb27c7511
equal deleted inserted replaced
-1:000000000000 0:c40eb8fe8501
       
     1 /*
       
     2 * Copyright (c) 2006-2010 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 handling traffic stream deletion from network side.
       
    15 *
       
    16 */
       
    17 
       
    18 /*
       
    19 * %version: 9 %
       
    20 */
       
    21 
       
    22 #include "core_operation_handle_delete_ts.h"
       
    23 #include "core_operation_update_tx_rate_policies.h"
       
    24 #include "core_tools.h"
       
    25 #include "core_server.h"
       
    26 #include "core_traffic_stream_list_iter.h"
       
    27 #include "core_virtual_traffic_stream_list_iter.h"
       
    28 #include "am_debug.h"
       
    29 
       
    30 // ======== MEMBER FUNCTIONS ========
       
    31 
       
    32 // ---------------------------------------------------------------------------
       
    33 // ---------------------------------------------------------------------------
       
    34 //
       
    35 core_operation_handle_delete_ts_c::core_operation_handle_delete_ts_c(
       
    36     u32_t request_id,
       
    37     core_server_c* server,
       
    38     abs_core_driverif_c* drivers,
       
    39     abs_core_server_callback_c* adaptation,
       
    40     u8_t tid ) :
       
    41     core_operation_base_c( core_operation_handle_delete_ts, request_id, server, drivers, adaptation, 
       
    42         core_base_flag_none ),
       
    43     tid_m( tid )
       
    44     {
       
    45     DEBUG( "core_operation_handle_delete_ts_c::core_operation_handle_delete_ts_c()" );
       
    46     }
       
    47 
       
    48 // ---------------------------------------------------------------------------
       
    49 // ---------------------------------------------------------------------------
       
    50 //
       
    51 core_operation_handle_delete_ts_c::~core_operation_handle_delete_ts_c()
       
    52     {
       
    53     DEBUG( "core_operation_handle_delete_ts_c::~core_operation_handle_delete_ts_c()" );
       
    54     }
       
    55     
       
    56 // ---------------------------------------------------------------------------
       
    57 // ---------------------------------------------------------------------------
       
    58 //
       
    59 core_error_e core_operation_handle_delete_ts_c::next_state()
       
    60     {
       
    61     DEBUG( "core_operation_handle_delete_ts_c::next_state()" );
       
    62 
       
    63     switch ( operation_state_m )
       
    64         {              
       
    65         case core_state_init:
       
    66             {
       
    67             operation_state_m = core_base_state_parameters_set;
       
    68 
       
    69             if ( !server_m->get_core_settings().is_connected() )
       
    70                 {
       
    71                 DEBUG( "core_operation_handle_delete_ts_c::next_state() - not connected, nothing to do" );
       
    72 
       
    73                 return core_error_general;
       
    74                 }
       
    75 
       
    76             DEBUG1( "core_operation_handle_delete_ts_c::next_state() - network has requested deletion of TID %u",
       
    77                 tid_m );
       
    78 
       
    79             core_traffic_stream_list_c& ts_list(
       
    80                 server_m->get_connection_data()->traffic_stream_list() );
       
    81             core_virtual_traffic_stream_list_c& virtual_ts_list(
       
    82                 server_m->get_connection_data()->virtual_traffic_stream_list() );
       
    83             core_traffic_stream_list_iter_c ts_iter( ts_list );
       
    84 
       
    85             virtual_ts_list.print_contents();
       
    86             ts_list.print_contents();
       
    87 
       
    88             core_traffic_stream_c* stream = NULL;
       
    89             core_traffic_stream_c* iter = ts_iter.first();
       
    90             while( iter )
       
    91                 {
       
    92                 if ( iter->tid() == tid_m )
       
    93                     {
       
    94                     stream = iter;
       
    95 
       
    96                     iter = NULL;
       
    97                     }
       
    98                 else
       
    99                     {
       
   100                     iter = ts_iter.next();
       
   101                     }
       
   102                 }
       
   103 
       
   104             if ( !stream )
       
   105                 {
       
   106                 DEBUG1( "core_operation_handle_delete_ts_c::next_state() - no traffic stream with TID %u found",
       
   107                     tid_m );
       
   108 
       
   109                 return core_error_not_found;
       
   110                 }
       
   111 
       
   112             u8_t user_priority = stream->user_priority();
       
   113             core_traffic_stream_direction_e direction = stream->direction();
       
   114 
       
   115             /**
       
   116              * Send a status update to all affected virtual traffic streams. 
       
   117              */
       
   118             set_virtual_traffic_stream_inactive_by_tid(
       
   119                 tid_m,
       
   120                 core_traffic_stream_status_inactive_deleted_by_ap );
       
   121 
       
   122             /**
       
   123              * Delete the actual traffic stream.
       
   124              */
       
   125             server_m->get_wpx_adaptation_instance().handle_ts_delete(
       
   126                 tid_m, user_priority );           
       
   127             ts_iter.remove();
       
   128 
       
   129             if( direction == core_traffic_stream_direction_uplink ||
       
   130                 direction == core_traffic_stream_direction_bidirectional )
       
   131                 {
       
   132                 server_m->get_connection_data()->set_ac_traffic_status(
       
   133                     core_tools_c::convert_user_priority_to_ac( user_priority ),
       
   134                     core_access_class_traffic_status_not_admitted );
       
   135 
       
   136                 /**
       
   137                  * Send an indication to notify clients that this access class
       
   138                  * is no longer admitted.
       
   139                  * 
       
   140                  * We don't have to the check the ACM bits since the traffic
       
   141                  * stream wouldn't exist if the AP didn't require admission
       
   142                  * control.  
       
   143                  */
       
   144                 DEBUG( "core_operation_handle_delete_ts_c::next_state() - traffic no longer admitted on this AC, notifying clients" );
       
   145 
       
   146                 u8_t buf[5];
       
   147                 buf[0] = static_cast<u8_t>( 
       
   148                     core_tools_c::convert_user_priority_to_ac( user_priority ) );
       
   149                 buf[1] = static_cast<u8_t>(
       
   150                     core_access_class_traffic_status_not_admitted );
       
   151                 adaptation_m->notify(
       
   152                     core_notification_ac_traffic_status_changed,
       
   153                     sizeof( buf ),
       
   154                     buf );
       
   155 
       
   156                 /**
       
   157                  * Reset TX queue parameters back to default values.
       
   158                  */
       
   159                 DEBUG( "core_operation_delete_ts_c::next_state() - resetting tx queue parameters" ); 
       
   160 
       
   161                 drivers_m->set_tx_queue_parameters(
       
   162                     request_id_m,
       
   163                     core_tools_c::convert_user_priority_to_ac( user_priority ),
       
   164                     0,
       
   165                     server_m->get_device_settings().max_tx_msdu_life_time );
       
   166                 }
       
   167             else
       
   168                 {
       
   169                 /**
       
   170                  * Since TX queue parameters apply only to uplink, there is nothing
       
   171                  * more to do on downlink streams.
       
   172                  */
       
   173                 return core_error_ok; 
       
   174                 }            
       
   175 
       
   176             break;
       
   177             }
       
   178         case core_base_state_parameters_set:
       
   179             {
       
   180             DEBUG( "core_operation_handle_delete_ts_c::next_state() - tx queue parameters reset" );
       
   181 
       
   182             return core_error_ok;
       
   183             }
       
   184         default:
       
   185             {
       
   186             ASSERT( false_t );
       
   187             }
       
   188         }
       
   189 
       
   190     return core_error_request_pending;
       
   191     }
       
   192 
       
   193 void core_operation_handle_delete_ts_c::set_virtual_traffic_stream_inactive_by_tid(
       
   194     u8_t tid,
       
   195     core_traffic_stream_status_e stream_status )
       
   196     {
       
   197     DEBUG( "core_operation_handle_delete_ts_c::set_virtual_traffic_stream_inactive_by_tid()" );
       
   198 
       
   199     core_virtual_traffic_stream_list_c& virtual_ts_list(
       
   200         server_m->get_connection_data()->virtual_traffic_stream_list() );
       
   201     core_virtual_traffic_stream_list_iter_c virtual_ts_iter( virtual_ts_list );
       
   202 
       
   203     core_virtual_traffic_stream_c* virtual_iter = virtual_ts_iter.first();
       
   204     while( virtual_iter )
       
   205         {
       
   206         if( virtual_iter->tid() == tid )
       
   207             {
       
   208             u32_t id( virtual_iter->id() );
       
   209 
       
   210             /**
       
   211              * The virtual traffic stream is no longer mapped to any actual
       
   212              * traffic stream.
       
   213              */
       
   214             virtual_iter->set_tid(
       
   215                 TRAFFIC_STREAM_TID_NONE );
       
   216             virtual_iter->set_status(
       
   217                 stream_status );
       
   218 
       
   219             DEBUG1( "core_operation_handle_delete_ts_c::set_virtual_traffic_stream_inactive_by_tid() - virtual traffic stream with ID %u is now inactive",
       
   220                 id );
       
   221 
       
   222             u8_t buf[5];                    
       
   223             core_tools_c::copy(
       
   224                 &buf[0],
       
   225                 reinterpret_cast<u8_t*>( &id ),
       
   226                 sizeof( u32_t ) );
       
   227             buf[4] = static_cast<u8_t>( stream_status );
       
   228 
       
   229             adaptation_m->notify(
       
   230                 core_notification_ts_status_changed,
       
   231                 sizeof( buf ),
       
   232                 buf );                    
       
   233             }
       
   234 
       
   235         virtual_iter = virtual_ts_iter.next();
       
   236         }
       
   237     }