view src/g23m-gprs/llc/llc_irxs.c @ 600:8f50b202e81f

board preprocessor conditionals: prep for more FC hw in the future This change eliminates the CONFIG_TARGET_FCDEV3B preprocessor symbol and all preprocessor conditionals throughout the code base that tested for it, replacing them with CONFIG_TARGET_FCFAM or CONFIG_TARGET_FCMODEM. These new symbols are specified as follows: CONFIG_TARGET_FCFAM is intended to cover all hardware designs created by Mother Mychaela under the FreeCalypso trademark. This family will include modem products (repackagings of the FCDEV3B, possibly with RFFE or even RF transceiver changes), and also my desired FreeCalypso handset product. CONFIG_TARGET_FCMODEM is intended to cover all FreeCalypso modem products (which will be firmware-compatible with the FCDEV3B if they use TI Rita transceiver, or will require a different fw build if we switch to one of Silabs Aero transceivers), but not the handset product. Right now this CONFIG_TARGET_FCMODEM preprocessor symbol is used to conditionalize everything dealing with MCSI. At the present moment the future of FC hardware evolution is still unknown: it is not known whether we will ever have any beyond-FCDEV3B hardware at all (contingent on uncertain funding), and if we do produce further FC hardware designs, it is not known whether they will retain the same FIC modem core (triband), if we are going to have a quadband design that still retains the classic Rita transceiver, or if we are going to switch to Silabs Aero II or some other transceiver. If we produce a quadband modem that still uses Rita, it will run exactly the same fw as the FCDEV3B thanks to the way we define TSPACT signals for the RF_FAM=12 && CONFIG_TARGET_FCFAM combination, and the current fcdev3b build target will be renamed to fcmodem. OTOH, if that putative quadband modem will be Aero-based, then it will require a different fw build target, the fcdev3b target will stay as it is, and the two targets will both define CONFIG_TARGET_FCFAM and CONFIG_TARGET_FCMODEM, but will have different RF_FAM numbers. But no matter which way we are going to evolve, it is not right to have conditionals on CONFIG_TARGET_FCDEV3B in places like ACI, and the present change clears the way for future evolution.
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 01 Apr 2019 01:05:24 +0000
parents 219afcfc6250
children
line wrap: on
line source

/* 
+----------------------------------------------------------------------------- 
|  Project :  
|  Modul   :  
+----------------------------------------------------------------------------- 
|  Copyright 2002 Texas Instruments Berlin, AG 
|                 All rights reserved. 
| 
|                 This file is confidential and a trade secret of Texas 
|                 Instruments Berlin, AG 
|                 The receipt of or possession of this file does not convey 
|                 any rights to reproduce or disclose its contents or to 
|                 manufacture, use, or sell anything it may describe, in 
|                 whole, or in part, without the specific written consent of 
|                 Texas Instruments Berlin, AG. 
+----------------------------------------------------------------------------- 
|  Purpose :  This modul is part of the entity LLC and implements all 
|             functions to handles the incoming process internal signals as  
|             described in the SDL-documentation (IRX-statemachine)
+----------------------------------------------------------------------------- 
*/ 

#ifndef LLC_IRXS_C
#define LLC_IRXS_C
#endif

#define ENTITY_LLC

/*==== INCLUDES =============================================================*/

#include "typedefs.h"   /* to get Condat data types */
#include "vsi.h"        /* to get a lot of macros */
#include "macdef.h"
#include "gprs.h"
#include "gsm.h"        /* to get a lot of macros */
#include "cnf_llc.h"    /* to get cnf-definitions */
#include "mon_llc.h"    /* to get mon-definitions */
#include "prim.h"       /* to get the definitions of used SAP and directions */
#include "llc.h"        /* to get the global entity definitions */

#include "llc_irxf.h"    /* to get IRX helper functions */
#include "llc_irxl.h"    /* to get IRX label functions */
#include "llc_itxs.h"    /* to get IRX/ITX signals */
#include "llc_us.h"      /* to get U signals */


/*==== CONST ================================================================*/

/*==== LOCAL VARS ===========================================================*/

/*==== PRIVATE FUNCTIONS ====================================================*/

/*==== PUBLIC FUNCTIONS =====================================================*/



/*
+------------------------------------------------------------------------------
| Function    : sig_llme_irx_assign_req
+------------------------------------------------------------------------------
| Description : Handles the internal signal SIG_LLME_IRX_ASSIGN_REQ
|
| Parameters  : 
|
+------------------------------------------------------------------------------
*/
GLOBAL void sig_llme_irx_assign_req (void)
{ 
  TRACE_ISIG( "sig_llme_irx_assign_req" );
  
  switch (GET_STATE(IRX))
  {
    case IRX_TLLI_UNASSIGNED:
      /*
       * Initialise current incarnation.
       */
      irx_init_sapi();
      SET_STATE (IRX, IRX_TLLI_ASSIGNED);
      break;

    default:
      TRACE_ERROR( "SIG_LLME_IRX_ASSIGN_REQ unexpected" );
      break;
  }
} /* sig_llme_irx_assign_req() */


/*
+------------------------------------------------------------------------------
| Function    : sig_llme_irx_unassign_req
+------------------------------------------------------------------------------
| Description : Handles the internal signal SIG_LLME_IRX_UNASSIGN_REQ
|
| Parameters  : 
|
+------------------------------------------------------------------------------
*/
GLOBAL void sig_llme_irx_unassign_req (void)
{ 
  TRACE_ISIG( "sig_llme_irx_unassign_req" );
  
  switch (GET_STATE(IRX))
  {
    case IRX_TLLI_UNASSIGNED:
      /*
       * Ignore unexpected signal
       */
      break;

    default:
      /*
       * Delete stored I frames and change to state TLLI_UNASSIGNED
       */
      irx_queue_clean();
      irx_init_sapi();
      SET_STATE (IRX, IRX_TLLI_UNASSIGNED);
      break;
  }
} /* sig_llme_irx_unassign_req() */


/*
+------------------------------------------------------------------------------
| Function    : sig_llme_irx_reset_req
+------------------------------------------------------------------------------
| Description : Handles the internal signal SIG_LLME_IRX_RESET_REQ
|
| Parameters  : 
|
+------------------------------------------------------------------------------
*/
GLOBAL void sig_llme_irx_reset_req (void)
{ 
  TRACE_ISIG( "sig_llme_irx_reset_req" );

 
  switch (GET_STATE(IRX))
  {
    case IRX_TLLI_UNASSIGNED:
    case IRX_TLLI_ASSIGNED:
      /*
       * Ignore signal.
       */
      break;

    case IRX_ABM:
    case IRX_ABM_BUSY:
      /*
       * Delete stored I frames and change to state TLLI_UNASSIGNED
       */
      irx_queue_clean();
      irx_init_sapi();
      SET_STATE (IRX, IRX_TLLI_ASSIGNED);
      break;

    default:
      TRACE_ERROR( "SIG_LLME_IRX_RESET_REQ unexpected" );
      break;
  }
} /* sig_llme_irx_reset_req() */



/*
+------------------------------------------------------------------------------
| Function    : sig_llme_irx_abmest_req
+------------------------------------------------------------------------------
| Description : Handles the internal signal SIG_LLME_IRX_ABMEST_REQ
|
| Parameters  : 
|
+------------------------------------------------------------------------------
*/
GLOBAL void sig_llme_irx_abmest_req (void)
{ 
  TRACE_ISIG( "sig_llme_irx_abmest_req" );

  switch (GET_STATE(IRX))
  {
    case IRX_TLLI_ASSIGNED:
      /*
       * Initialize ABM operation
       */
      irx_init_abm();
      SET_STATE (IRX, IRX_ABM);
      break;

    case IRX_ABM:
    case IRX_ABM_BUSY:
      /*
       * Delete stored I frames and re-initialize ABM operation
       */
      irx_queue_clean();
      irx_init_abm();
      SET_STATE (IRX, IRX_ABM);
      break;

    default:
      TRACE_ERROR( "SIG_LLME_IRX_ABMEST_REQ unexpected" );
      break;
  }
} /* sig_llme_irx_abmest_req() */



/*
+------------------------------------------------------------------------------
| Function    : sig_llme_irx_abmrel_req
+------------------------------------------------------------------------------
| Description : Handles the internal signal SIG_LLME_IRX_ABMREL_REQ
|
| Parameters  : 
|
+------------------------------------------------------------------------------
*/
GLOBAL void sig_llme_irx_abmrel_req (void)
{ 
  TRACE_ISIG( "sig_llme_irx_abmrel_req" );
 
  switch (GET_STATE(IRX))
  {
    case IRX_ABM:
    case IRX_ABM_BUSY:
      /*
       * Delete stored I frames and end ABM operation
       */
      irx_queue_clean();
      irx_init_sapi();
      SET_STATE (IRX, IRX_TLLI_ASSIGNED);
      break;

    default:
      /* TRACE_ERROR( "SIG_LLME_IRX_ABMREL_REQ unexpected" ); but ok */
      break;
  }
} /* sig_llme_irx_abmrel_req() */



/*
+------------------------------------------------------------------------------
| Function    : sig_rx_irx_data_ind
+------------------------------------------------------------------------------
| Description : Handles the internal signal SIG_RX_IRX_DATA_IND
|
| Parameters  : ll_unitdata_ind - a valid pointer to an LL-UNITDATA-IND 
|                                 primitive
|               command    - contains the command within the primitive
|               frame_type - type of PDU (I or S frame)
|               cr_bit     - setting of the CR bit
|               a_bit      - setting of the A bit
|               ns         - send sequence number of the frame 
|               nr         - receive sequence number of the frame
|
+------------------------------------------------------------------------------
*/
GLOBAL void sig_rx_irx_data_ind (T_LL_UNITDATA_IND *ll_unitdata_ind,
                                 T_COMMAND         command, 
                                 T_PDU_TYPE        frame_type,
                                 T_BIT             cr_bit,
                                 T_BIT             a_bit,
                                 T_FRAME_NUM       ns, 
                                 T_FRAME_NUM       nr)
{
  UBYTE     state;

  TRACE_ISIG( "sig_rx_irx_data_ind" );
  
#ifdef TRACE_EVE
    {
      static char* sf[] = { "RR", "ACK", "RNR", "SACK" };

      if(command <= 3)
      {
        if(frame_type == I_FRAME)
        {
          TRACE_4_INFO("got %s I-Frame NS:%d NR:%d A:%d", sf[command], ns, nr, a_bit);
        }
        else
        {
          TRACE_3_INFO("got %s S-Frame NR:%d A:%d", sf[command], nr, a_bit);
        }
      }
    }
#endif

  llc_data->u->current_tlli = ll_unitdata_ind->tlli;

  switch ( (state = GET_STATE(IRX)) )
  {
    case IRX_TLLI_ASSIGNED:
      /*
       * Send a DM response to any valid command received, that 
       * cannot be handeled (GSM 4.64 Release 6.7.0 Chapter 6.4.1.4)
       */
      TRACE_0_INFO("S- or I/S-Frame received in unexpected state");
      
      PFREE (ll_unitdata_ind);

      sig_irx_u_no_frame_expected_ind();
      break;

    case IRX_ABM:
    case IRX_ABM_BUSY:
      /*
       * va <= nr <= vs 
       */
      if ( FRAME_NUM_VALID (llc_data->sapi->va, nr, llc_data->sapi->vs) )
      {
        /*
         * frame valid
         */
        irx_ack_all_to ((T_FRAME_NUM)(nr - 1));

        switch (command)
        {
          case I_RR:
            /*
             * Label IRX_RR
             */
            sig_irx_itx_peer_ready_ind();
            break;

          case I_ACK:
            /*
             * Label IRX_ACK
             */
            sig_irx_itx_ack_ind (FALSE, nr );
            sig_irx_itx_ack_ind (TRUE, (T_FRAME_NUM)(nr + 1));
            sig_irx_itx_cnf_l3data_req ();
            sig_irx_itx_peer_ready_ind ();
            break;

          case I_SACK:
            /*
             * Label IRX_SACK
             */
            sig_irx_itx_ack_ind (FALSE, nr);
            irx_handle_sack (nr, ll_unitdata_ind, frame_type);
            sig_irx_itx_peer_ready_ind();
            break;

          case I_RNR:
            /*
             * Label IRX_RNR
             */
            sig_irx_itx_peer_busy_ind();
            break;

          default:
            TRACE_ERROR( "Unexpected command received" );
            break;
        }
      }
         
      if (frame_type == I_FRAME)
      {
        irx_label_if (ll_unitdata_ind, ns, a_bit, state);
      }
      else /*  S_FRAME */
      {
        if (state == IRX_ABM)
        {
          irx_send_ack (a_bit);
          PFREE (ll_unitdata_ind);
        }
        else
        {
          irx_send_rnr ();
          PFREE (ll_unitdata_ind);
        }
      }
      break;

    default:
      /*
       * Free unexpected data
       */
      PFREE (ll_unitdata_ind);
      TRACE_ERROR( "SIG_RX_IRX_DATA_IND unexpected" );
      break;
  }
} /* sig_rx_irx_data_ind() */



/*
+------------------------------------------------------------------------------
| Function    : sig_itx_irx_s_frame_req
+------------------------------------------------------------------------------
| Description : Handles the internal signal SIG_ITX_IRX_S_FRAME_REQ
|
| Parameters  : 
|
+------------------------------------------------------------------------------
*/
GLOBAL void sig_itx_irx_s_frame_req (T_ABIT_REQ_TYPE req)
{ 
  TRACE_ISIG( "sig_itx_irx_s_frame_req" );
  
  switch (GET_STATE(IRX))
  {
    case IRX_ABM:
      /*
       * Send an S frame appropriate for the current state
       */
      if ( llc_data->irx->last_ns == NS_EQUAL_VR )
      {
        sig_irx_itx_send_rr_req (req);
      }
      else if ( llc_data->irx->last_ns == NS_EQUAL_VR_PLUS_1 )
      {
        sig_irx_itx_send_ack_req (req);
      }
      else
      {
        T_SACK_BITMAP bitmap;

        irx_build_sack_bitmap( &bitmap );
        sig_irx_itx_send_sack_req (req, &bitmap);
      }
      /* SET_STATE (IRX, SAME_STATE); */
      break;
  

    case IRX_ABM_BUSY:
      /*
       * The appropriate S frame in state busy anytime is an RNR
       */
      sig_irx_itx_send_rnr_req (req);
      /* SET_STATE (IRX, SAME_STATE); */
      break;

    default:
      TRACE_ERROR( "SIG_ITX_IRX_S_FRAME_REQ unexpected" );
      break;
  }
} /* sig_itx_irx_s_frame_req() */