changeset 197:2cf312e56ee7

src/g23m-gprs/upm: import from LoCosto source
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 14 Oct 2016 01:21:46 +0000
parents a04cde1fb771
children 0e4c6a7d2071
files src/g23m-gprs/upm/mon_upm.h src/g23m-gprs/upm/upm.c src/g23m-gprs/upm/upm.h src/g23m-gprs/upm/upm_aci_output_handler.c src/g23m-gprs/upm/upm_aci_output_handler.h src/g23m-gprs/upm/upm_debug.h src/g23m-gprs/upm/upm_dispatcher.c src/g23m-gprs/upm/upm_dispatcher.h src/g23m-gprs/upm/upm_dispatcher_gsm.c src/g23m-gprs/upm/upm_dispatcher_gsm.h src/g23m-gprs/upm/upm_link_control.c src/g23m-gprs/upm/upm_link_control.h src/g23m-gprs/upm/upm_mm_output_handler.c src/g23m-gprs/upm/upm_mm_output_handler.h src/g23m-gprs/upm/upm_pei.c src/g23m-gprs/upm/upm_sm_output_handler.c src/g23m-gprs/upm/upm_sm_output_handler.h src/g23m-gprs/upm/upm_sndcp_control.c src/g23m-gprs/upm/upm_sndcp_control.h src/g23m-gprs/upm/upm_sndcp_output_handler.c src/g23m-gprs/upm/upm_sndcp_output_handler.h
diffstat 21 files changed, 4651 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/g23m-gprs/upm/mon_upm.h	Fri Oct 14 01:21:46 2016 +0000
@@ -0,0 +1,37 @@
+/*----------------------------------------------------------------------------
+|  Project :  3G PS
+|  Module  :  UPM
++-----------------------------------------------------------------------------
+|             Copyright 2003 Texas Instruments.
+|             All rights reserved. 
+| 
+|             This file is confidential and a trade secret of Texas 
+|             Instruments .
+|             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. 
++-----------------------------------------------------------------------------
+| Purpose:    Monitoring definitions for the UPM entity.
+|             For design details, see:
+|             8010.939 UPM Detailed Specification
++---------------------------------------------------------------------------*/
+
+#ifndef MON_UPM_H
+#define MON_UPM_H
+
+/*==== INCLUDES =============================================================*/
+
+/*==== CONSTS ===============================================================*/
+
+/*==== TYPES ================================================================*/
+
+typedef struct
+{
+  /*@observer@*/char  *version;
+} T_MONITOR;
+
+/*==== EXPORTS ==============================================================*/
+
+#endif /* MON_UPM_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/g23m-gprs/upm/upm.c	Fri Oct 14 01:21:46 2016 +0000
@@ -0,0 +1,275 @@
+/*----------------------------------------------------------------------------
+|  Project :  3G PS
+|  Module  :  UPM
++-----------------------------------------------------------------------------
+|             Copyright 2003 Texas Instruments.
+|             All rights reserved. 
+| 
+|             This file is confidential and a trade secret of Texas 
+|             Instruments .
+|             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. 
++-----------------------------------------------------------------------------
+| Purpose:    Utility functions for the UPM entity.
+|             For design details, see:
+|             8010.939 UPM Detailed Specification
++---------------------------------------------------------------------------*/
+
+/*==== DECLARATION CONTROL =================================================*/
+
+/*==== INCLUDES ============================================================*/
+
+#include "upm.h"
+
+/*==== CONSTS ===============================================================*/
+
+/*==== TYPES ================================================================*/
+
+T_UPM_DATA upm_data;
+
+/*==== LOCALS ===============================================================*/
+
+/*==== PUBLIC FUNCTIONS =====================================================*/
+
+/*
++------------------------------------------------------------------------------
+| Function    : upm_pfree
++------------------------------------------------------------------------------
+| Description : PFREE macro replacement
+|
+| Parameters  : data                - memory to free
++------------------------------------------------------------------------------
+*/
+void upm_pfree(/*@only@*/ /*@null@*/ /*@out@*/ void *data)
+{
+  if (data != NULL)
+  {
+    vsi_c_pfree((T_VOID_STRUCT **)&data FILE_LINE_MACRO);
+  }
+}
+
+/*
++------------------------------------------------------------------------------
+| Function    : upm_mfree
++------------------------------------------------------------------------------
+| Description : Wrapper for MFREE macro.
+|
+| Parameters  : data                   - memory to free (NULL allowed)
++------------------------------------------------------------------------------
+*/
+void upm_mfree(/*@only@*/ /*@out@*/ /*@null@*/ void *data)
+{
+  if (data != NULL) {
+    MFREE(data);
+  }
+}
+
+/*
++------------------------------------------------------------------------------
+| Function    : upm_nsapi2nsapi_set
++------------------------------------------------------------------------------
+| Description : Return nsapi_set corresponding to NSAPI
+|
+| Parameters  : nsapi                  - NSAPI
++------------------------------------------------------------------------------
+*/
+U16 upm_nsapi2nsapi_set(int /*@alt U8@*/ nsapi) /*@*/
+{
+  TRACE_ASSERT ((T_NAS_nsapi)nsapi >= NAS_NSAPI_5 &&  nsapi <= NAS_NSAPI_15);
+
+  return (U16)(1UL << (U16)nsapi);
+}
+
+/*
++------------------------------------------------------------------------------
+| Function    : upm_get_context_data_from_nsapi
++------------------------------------------------------------------------------
+| Description : Returns context data structure associated with indicated NSAPI.
+|
+| Parameters  : nsapi                  - NSAPI index
++------------------------------------------------------------------------------
+*/
+/*@null@*/ /*@exposed@*/
+struct T_CONTEXT_DATA *upm_get_context_data_from_nsapi(int /*@alt U8@*/ nsapi)
+{
+  TRACE_ASSERT (((T_NAS_nsapi)nsapi >= NAS_NSAPI_5 && nsapi <= NAS_NSAPI_15));
+
+  /*lint -e{661} upm_context_array causes out of bounds access, it does not! */
+  return (upm_data.upm_context_array[nsapi - (int)NAS_NSAPI_5]);
+}
+
+/*
++------------------------------------------------------------------------------
+| Function    : upm_assign_context_data_to_nsapi
++------------------------------------------------------------------------------
+| Description : Assign context data structure to global context array.
+|
+| Parameters  : ptr_context_data       - Pointer to context data
+|               nsapi                  - NSAPI index
++------------------------------------------------------------------------------
+*/
+void upm_assign_context_data_to_nsapi(/*@keep@*/
+				      struct T_CONTEXT_DATA *ptr_context_data,
+				      int /*@alt U8@*/ nsapi)
+{
+  (void)TRACE_EVENT_P2("upm_assign_context_data_to_nsapi: NSAPI%3d = %p", nsapi, ptr_context_data);
+
+  TRACE_ASSERT ((T_NAS_nsapi)nsapi >= NAS_NSAPI_5 && nsapi <= NAS_NSAPI_15);
+
+  /*lint -e{661} upm_context_array causes out of bounds access, it does not! */
+  upm_data.upm_context_array[nsapi - (int)NAS_NSAPI_5] = ptr_context_data;
+  ptr_context_data->nsapi = nsapi;
+}
+
+/*
++------------------------------------------------------------------------------
+| Function    : upm_free_context_data
++------------------------------------------------------------------------------
+| Description : Free context data structure associated with indicated NSAPI.
+|
+| Parameters  : nsapi                  - NSAPI index
++------------------------------------------------------------------------------
+*/
+void upm_free_context_data(int /*@alt U8@*/ nsapi)
+{
+  TRACE_ASSERT ((T_NAS_nsapi)nsapi >= NAS_NSAPI_5 && nsapi <= NAS_NSAPI_15);
+
+  /*lint -e661 (upm_context_array causes out of bounds access, it does not!) */
+  if ( upm_data.upm_context_array[nsapi - (int)NAS_NSAPI_5] != NULL ) {
+    upm_mfree(upm_data.upm_context_array[nsapi - (int)NAS_NSAPI_5]);
+    upm_data.upm_context_array[nsapi - (int)NAS_NSAPI_5] = NULL;
+  /*lint +e661 (upm_context_array causes out of bounds access, it does not!) */	
+  }
+}
+
+/*
++------------------------------------------------------------------------------
+| Function    : upm_check_for_released_context_and_release
++------------------------------------------------------------------------------
+| Description : Check whether a context is released (both link and DTI
+|               connections released), and if so, freee context data structure
+|               associated with indicated NSAPI.
+|
+| Parameters  : nsapi                  - NSAPI index
++------------------------------------------------------------------------------
+*/
+void upm_check_for_released_context_and_release(struct T_CONTEXT_DATA *context)
+{
+  if (upm_is_link_released(context)
+#ifndef UPM_WITHOUT_USER_PLANE
+      && upm_is_dti_disconnected(context)
+#endif
+      )
+  {
+    U8 nsapi = context->nsapi;
+
+    upm_free_context_data(nsapi);
+    (void)TRACE_EVENT_P1("upm_check_for_released_context_and_release on NSAPI %d: Context data freed...", nsapi);
+  }
+}
+
+/*
++------------------------------------------------------------------------------
+| Function    : upm_get_current_rat
++------------------------------------------------------------------------------
+| Description : Returns the RAT in which UPM is currently active
+|
+| Parameters  : None
++------------------------------------------------------------------------------
+*/
+#ifdef TI_DUAL_MODE
+T_PS_rat upm_get_current_rat(void)
+{
+  return upm_data.upm_rat;
+}
+#endif /* TI_DUAL_MODE */
+
+/*
++------------------------------------------------------------------------------
+| Function    : upm_set_current_rat
++------------------------------------------------------------------------------
+| Description : Sets currently active RAT
+|
+| Parameters  : rat                    - RAT received from SM or MM
++------------------------------------------------------------------------------
+*/
+#ifdef TI_DUAL_MODE
+void upm_set_current_rat(T_PS_rat rat)
+     /*@modifies upm_data.upm_rat@*/
+{
+  upm_data.upm_rat = rat;
+}
+#endif /* TI_DUAL_MODE */
+
+/*
++------------------------------------------------------------------------------
+| Function    : upm_ll_entity_test
++------------------------------------------------------------------------------
+| Description : Returns TRUE if upm_ll_entity_test is set in UPM data struct
+|
+| Parameters  : None
++------------------------------------------------------------------------------
+*/
+BOOL upm_ll_entity_test(void)
+{
+  return upm_data.upm_ll_entity_test;
+}
+
+/*
++------------------------------------------------------------------------------
+| Function    : upm_activate_ll_entity_test
++------------------------------------------------------------------------------
+| Description : Enables lower layer stubs for entity test
+|
+| Parameters  : None
++------------------------------------------------------------------------------
+*/
+void upm_activate_ll_entity_test(void)
+{
+  upm_data.upm_ll_entity_test = TRUE;
+}
+
+/*
++------------------------------------------------------------------------------
+| Function    : upm_set_sequence_number
++------------------------------------------------------------------------------
+| Description : Stores the receive sequence number from MM for later retrieval
+|
+| Parameters  : ptr_context_data    - Context data
+|               seq_no              - Receive sequence number
++------------------------------------------------------------------------------
+*/
+void upm_set_sequence_number(struct T_CONTEXT_DATA *ptr_context_data, U8 seq_no)
+{
+  (void)TRACE_FUNCTION("upm_set_sequence_number");
+
+  ptr_context_data->seq_nos_valid = (U8)TRUE;
+  ptr_context_data->recv_seq_no   = seq_no;
+}
+
+/*
++------------------------------------------------------------------------------
+| Function    : upm_get_sequence_number
++------------------------------------------------------------------------------
+| Description : Retrieves the receive sequence number previously gotten from MM
+|
+| Parameters  : ptr_context_data    - Context data
++------------------------------------------------------------------------------
+*/
+U8 upm_get_sequence_number(struct T_CONTEXT_DATA *ptr_context_data)
+{
+  (void)TRACE_FUNCTION("upm_get_sequence_number");
+
+  if (ptr_context_data->seq_nos_valid != (U8)0)
+  {
+    ptr_context_data->seq_nos_valid = (U8)0;
+    return ptr_context_data->recv_seq_no;
+  } else {
+    return (U8)0;
+  }
+}
+
+/*==== END OF FILE ==========================================================*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/g23m-gprs/upm/upm.h	Fri Oct 14 01:21:46 2016 +0000
@@ -0,0 +1,257 @@
+/*----------------------------------------------------------------------------
+|  Project :  3G PS
+|  Module  :  UPM
++-----------------------------------------------------------------------------
+|             Copyright 2003 Texas Instruments.
+|             All rights reserved. 
+| 
+|             This file is confidential and a trade secret of Texas 
+|             Instruments .
+|             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. 
++-----------------------------------------------------------------------------
+| Purpose:    Global definitions for the User Plane Manager (UPM) Entity.
+|             For design details, see:
+|             8010.939 UPM Detailed Specification
++---------------------------------------------------------------------------*/
+
+/*==== DECLARATION CONTROL =================================================*/
+
+#ifndef _UPM_H
+#define _UPM_H
+
+/*#ifdef FF_EGPRS
+#ifndef UPM_EDGE
+#define UPM_EDGE
+#endif */ /*#ifndef UPM_EDGE*/
+/*#endif */ /*#ifdef FF_EGPRS*/
+
+/*#ifdef UPM_EDGE */
+#define ENTITY_UPM
+/*#endif */
+
+#ifdef WIN32
+#define DEBUG
+#endif
+
+/*==== INCLUDES =============================================================*/
+
+#include <string.h>
+#include <typedefs.h>
+#include <vsi.h>
+#include <gsm.h>
+#include <gprs.h>
+#include <prim.h>
+
+/*#ifndef UPM_EDGE
+#include <trace.h> 
+#endif *//*#ifndef UPM_EDGE*/
+
+#ifndef UPM_WITHOUT_USER_PLANE
+#include <dti.h>
+#endif /* UPM_WITHOUT_USER_PLANE */
+
+struct T_CONTEXT_DATA;
+typedef U32 T_MEM_HANDLE;
+
+#include "upm_debug.h"
+
+#ifndef UPM_WITHOUT_USER_PLANE
+#include "upm_dti_control.h"
+#include "upm_uplink_data_control.h"
+#include "upm_uplink_data_suspend.h"
+#include "upm_downlink_data_control.h"
+#endif /* UPM_WITHOUT_USER_PLANE */
+#include "upm_link_control.h"
+#ifdef TI_UMTS
+#include "upm_rab_control.h"
+#endif /* TI_UMTS */
+#ifdef TI_GPRS
+#include "upm_sndcp_control.h"
+#endif  /* TI_GPRS */
+#ifdef TI_DUAL_MODE
+#include "upm_rat_control.h"
+#endif /* TI_DUAL_MODE */
+
+/*==== CONSTS ===============================================================*/
+
+#define UPM_UPLINK_DATA_BUFFER_SIZE    16
+#define UPM_DOWNLINK_DATA_BUFFER_SIZE  16
+#define UPM_DTI_QUEUE_SIZE             1
+
+#define UPM_MAX_NSAPI_OFFSET (NAS_SIZE_NSAPI - (int)NAS_NSAPI_5)
+/*==== TYPES ================================================================*/
+
+#ifndef UPM_WITHOUT_USER_PLANE 
+struct T_UPM_desc_list_entry
+{
+  /*@null@*/ struct T_UPM_desc_list_entry *next;
+  T_desc2                                 *desc;
+};
+
+/*@abstract@*/ struct T_UPM_USER_PLANE_DATA
+{
+  T_UPM_DTI_UPPER_CONTROL_STATE     dti_upper_control_state;
+#ifdef TI_GPRS
+  T_UPM_DTI_LOWER_CONTROL_STATE     dti_lower_control_state;
+#endif /* TI_GPRS */
+  T_UPM_UPLINK_DATA_CONTROL_STATE   ul_data_state;
+  T_UPM_UPLINK_DATA_SUSPEND_STATE   ul_data_suspend_state;
+  T_UPM_DOWNLINK_DATA_CONTROL_STATE dl_data_state;
+
+  U8                                dti_flags[UPM_DTI_NUMBER_OF_INTERFACES];
+
+  U16                  	            ul_data_buffer_count;
+  U16                  	            dl_data_buffer_count;
+
+  U32                               ul_data_octets_transferred;
+  U32                               ul_data_packets_transferred;
+  U32                               dl_data_octets_transferred;
+  U32                               dl_data_packets_transferred;
+
+  U32                               ul_data_packets_dropped;
+  U32                               dl_data_packets_dropped;
+
+  /*@null@*/ /*@only@*/ /*@reldef@*/
+  struct T_UPM_desc_list_entry     *ul_data_buffer;
+  /*@null@*/ /*@only@*/ /*@reldef@*/
+  T_MEM_HANDLE                     *dl_data_buffer;
+};
+#endif  /* UPM_WITHOUT_USER_PLANE */
+
+#ifdef TI_GPRS
+/*@abstract@*/ struct T_UPM_CONTEXT_DATA_GPRS
+{
+  U8                                sndcp_delay;        /* R97 QoS */
+  U8                   	    	    sndcp_relclass;     /* R97 QoS */
+  U8                   	    	    sndcp_peak_bitrate; /* R97 QoS */
+  U8                   	    	    sndcp_preced;       /* R97 QoS */
+  U8                   	    	    sndcp_mean;         /* R97 QoS */
+
+  U8                                pkt_flow_id;        /* EDGE */
+  U8                   	    	    sndcp_radio_prio;
+  U8                   	    	    sndcp_llc_sapi;
+};
+#endif /* TI_GPRS */
+
+/*@abstract@*/ struct T_CONTEXT_DATA
+{
+  U8                                nsapi;
+
+  U8                                seq_nos_valid;
+  U8                                recv_seq_no;
+  U8                                send_seq_no;
+
+  T_UPM_LINK_CONTROL_STATE          link_control_state;
+#ifdef TI_UMTS
+  T_UPM_RAB_CONTROL_STATE   	    rab_control_state;
+#endif /* TI_UMTS */
+#ifdef TI_GPRS
+  T_UPM_SNDCP_CONTROL_STATE 	    sndcp_control_state;
+#endif /* TI_GPRS */
+
+#ifdef TI_UMTS
+  U8                                rab_qos_tc;
+  U8                   	    	    mem_user;
+  U16                  	    	    mem_space_before;
+#endif /* TI_UMTS */
+#ifdef TI_GPRS
+  struct T_UPM_CONTEXT_DATA_GPRS    gprs_data;
+#endif /* TI_GPRS */
+
+#ifndef UPM_WITHOUT_USER_PLANE
+  struct T_UPM_USER_PLANE_DATA      up_data;
+#endif /* UPM_WITHOUT_USER_PLANE */
+};
+
+typedef struct {
+#ifdef TI_DUAL_MODE
+  T_UPM_RAT_CONTROL_STATE          rat_control_state;
+  T_PS_rat                         upm_rat;
+#endif /* TI_DUAL_MODE */
+  BOOL                             upm_ll_entity_test;
+/* Communication handles */
+  T_HANDLE                         hCommACI;
+  T_HANDLE                         hCommSM;
+  T_HANDLE                         hCommMM;
+  T_HANDLE                         upm_handle;
+#ifdef TI_UMTS
+  T_HANDLE                         hCommPDCP;
+  T_HANDLE                         hCommRRC;
+#endif /* TI_UMTS */
+#ifdef TI_GPRS
+  T_HANDLE                         hCommSNDCP;
+  T_HANDLE                         hCommRR;
+#endif /* TI_GPRS */
+
+#ifndef UPM_WITHOUT_USER_PLANE
+  DTI_HANDLE                       upm_hDTI;
+#endif /* UPM_WITHOUT_USER_PLANE */
+  /*@only@*/ /*@reldef@*/
+  struct T_CONTEXT_DATA           *upm_context_array[UPM_MAX_NSAPI_OFFSET];
+} T_UPM_DATA;
+
+#ifdef DEBUG
+#define M_TRANSITION(_EVENT, _FUNC) {_EVENT, _FUNC}
+#else /* WIN32 */
+#define M_TRANSITION(_EVENT, _FUNC) {_FUNC}
+#endif /* WIN32 */
+
+/*==== EXPORTS ==============================================================*/
+
+extern T_UPM_DATA upm_data;
+
+void     upm_pfree(/*@null@*/ /*@only@*/ /*@out@*/void *data);
+void     upm_mfree(/*@null@*/ /*@only@*/ /*@out@*/void *data);
+
+U16      upm_nsapi2nsapi_set(int /*@alt U8@*/ nsapi) /*@*/;
+
+/*@null@*/ /*@exposed@*/
+struct T_CONTEXT_DATA *upm_get_context_data_from_nsapi(int /*@alt U8@*/ nsapi);
+void     upm_assign_context_data_to_nsapi(/*@keep@*/ struct T_CONTEXT_DATA *,
+					  int /*@alt U8@*/ nsapi);
+
+void     upm_free_context_data(int /*@alt U8@*/ nsapi);
+void     upm_check_for_released_context_and_release(struct T_CONTEXT_DATA *);
+
+BOOL     upm_ll_entity_test(void);
+void     upm_activate_ll_entity_test(void) /*@modifies upm_data.upm_ll_entity_test@*/;
+
+#ifdef TI_DUAL_MODE
+T_PS_rat upm_get_current_rat(void);
+void     upm_set_current_rat(T_PS_rat rat) /*@modifies upm_data.upm_rat@*/;
+#endif /* TI_DUAL_MODE */
+
+void     upm_set_sequence_number(struct T_CONTEXT_DATA *, U8);
+U8       upm_get_sequence_number(struct T_CONTEXT_DATA *);
+
+#define hCommACI    upm_data.hCommACI    /* Communication handle to ACI   */
+#define hCommMM     upm_data.hCommMM     /* Communication handle to MM    */
+#define hCommSM     upm_data.hCommSM     /* Communication handle to SM    */
+
+#ifdef TI_UMTS
+#define hCommPDCP   upm_data.hCommPDCP   /* Communication handle to PDCP  */
+#define hCommRRC    upm_data.hCommRRC    /* Communication handle to RRC   */
+#endif /* TI_UMTS */
+#ifdef TI_GPRS
+#define hCommSNDCP  upm_data.hCommSNDCP  /* Communication handle to SNDCP */
+#define hCommRR     upm_data.hCommRR     /* Communication handle to RR    */
+#endif /* TI_GPRS */
+#ifndef UPM_WITHOUT_USER_PLANE
+#define upm_hDTI    upm_data.upm_hDTI
+#endif /* UPM_WITHOUT_USER_PLANE */
+
+#define VSI_CALLER        upm_data.upm_handle,
+#define VSI_CALLER_SINGLE upm_data.upm_handle
+
+/* Uniquify pei_create() */
+#define pei_create upm_pei_create
+extern short upm_pei_create (T_PEI_INFO **info)
+     /*@modifies *info, internalState@*/ /*@globals internalState@*/;
+
+#endif /* _UPM_H */
+/*==== END OF FILE ==========================================================*/
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/g23m-gprs/upm/upm_aci_output_handler.c	Fri Oct 14 01:21:46 2016 +0000
@@ -0,0 +1,98 @@
+/*----------------------------------------------------------------------------
+|  Project :  3G PS
+|  Module  :  UPM
++-----------------------------------------------------------------------------
+|             Copyright 2003 Texas Instruments.
+|             All rights reserved. 
+| 
+|             This file is confidential and a trade secret of Texas 
+|             Instruments .
+|             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. 
++-----------------------------------------------------------------------------
+| Purpose:    Output functions for primitives from UPM to the ACI entity.
+|             For design details, see:
+|             8010.939 UPM Detailed Specification
++---------------------------------------------------------------------------*/
+
+/*==== DECLARATION CONTROL =================================================*/
+
+/*==== INCLUDES ============================================================*/
+
+#include "upm.h"
+
+#include "upm_aci_output_handler.h"
+
+/*==== CONSTS ===============================================================*/
+
+/*==== TYPES ================================================================*/
+
+/*==== LOCALS ===============================================================*/
+
+/*==== PUBLIC FUNCTIONS =====================================================*/
+
+/*
++------------------------------------------------------------------------------
+| Function    : send_upm_count_cnf
++------------------------------------------------------------------------------
+| Description : Allocate, pack and send UPM_COUNT_CNF primitive.
+|
+| Parameters  : nsapi            - NSAPI
+|               ul_bytecount     - number of uplink octets transferred
+|               ul_pktcount      - number of uplink packets transferred
+|               dl_bytecount     - number of downlink octets transferred
+|               dl_pktcount      - number of downlink packets transferred
++------------------------------------------------------------------------------
+*/
+void send_upm_count_cnf(U8 nsapi, U32 ul_bytecount, U32 dl_bytecount,
+                        U32 ul_pktcount, U32 dl_pktcount)
+{
+  (void)TRACE_FUNCTION("send_upm_count_cnf");
+
+  {
+    PALLOC(prim, UPM_COUNT_CNF);
+
+    TRACE_ASSERT(prim != NULL);
+
+  /*lint -e613 (Possible use of null pointer 'prim' in left argument to operator '->') */
+    prim->nsapi            = nsapi;
+    prim->octets_uplink    = ul_bytecount;
+    prim->octets_downlink  = dl_bytecount;
+    prim->packets_uplink   = ul_pktcount;
+    prim->packets_downlink = dl_pktcount;
+ /*lint +e613 (Possible use of null pointer 'prim' in left argument to operator '->') */
+
+    (void)PSEND(hCommACI, prim);
+  }
+}
+
+/*
++------------------------------------------------------------------------------
+| Function    : send_upm_dti_cnf
++------------------------------------------------------------------------------
+| Description : Allocate, pack and send UPM_DTI_CNF primitive.
+|
+| Parameters  : dti_linkid       - DTI link ID
+|               dti_conn         - connection type
++------------------------------------------------------------------------------
+*/
+void send_upm_dti_cnf(U32 dti_linkid, U8 dti_conn)
+{
+  (void)TRACE_FUNCTION("send_upm_dti_cnf");
+  {
+    PALLOC(prim, UPM_DTI_CNF);
+
+    TRACE_ASSERT(prim != NULL);
+  /*lint -e613 (Possible use of null pointer 'prim' in left argument to operator '->') */
+    prim->dti_linkid = dti_linkid;
+    prim->dti_conn   = dti_conn;
+  /*lint +e613 (Possible use of null pointer 'prim' in left argument to operator '->') */		
+
+    (void)PSEND(hCommACI, prim);
+  }
+}
+
+/*==== END OF FILE ==========================================================*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/g23m-gprs/upm/upm_aci_output_handler.h	Fri Oct 14 01:21:46 2016 +0000
@@ -0,0 +1,42 @@
+/*----------------------------------------------------------------------------
+|  Project :  3G PS
+|  Module  :  UPM
++-----------------------------------------------------------------------------
+|             Copyright 2003 Texas Instruments.
+|             All rights reserved. 
+| 
+|             This file is confidential and a trade secret of Texas 
+|             Instruments .
+|             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. 
++-----------------------------------------------------------------------------
+| Purpose:    Output functions for primitives from UPM to the ACI entity.
+|             For design details, see:
+|             8010.939 UPM Detailed Specification
++---------------------------------------------------------------------------*/
+
+/*==== DECLARATION CONTROL =================================================*/
+
+#ifndef UPM_ACI_OUTPUT_HANDLER_H
+#define UPM_ACI_OUTPUT_HANDLER_H
+
+/*==== INCLUDES =============================================================*/
+#include "typedefs.h"
+
+#include "upm.h"
+
+/*==== CONSTS ===============================================================*/
+
+/*==== TYPES ================================================================*/
+
+/*==== EXPORTS ==============================================================*/
+
+extern void send_upm_count_cnf(U8 nsapi, U32 ul_bytecount, U32 dl_bytecount,
+                               U32 ul_pktcount, U32 dl_pktcount);
+extern void send_upm_dti_cnf(U32 dti_linkid, U8 dti_conn);
+
+#endif /* UPM_ACI_OUTPUT_HANDLER_H */
+/*==== END OF FILE ==========================================================*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/g23m-gprs/upm/upm_debug.h	Fri Oct 14 01:21:46 2016 +0000
@@ -0,0 +1,138 @@
+/*----------------------------------------------------------------------------
+|  Project :  3G PS
+|  Module  :  SM
++-----------------------------------------------------------------------------
+|             Copyright 2003 Texas Instruments.
+|             All rights reserved. 
+| 
+|             This file is confidential and a trade secret of Texas 
+|             Instruments .
+|             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. 
++-----------------------------------------------------------------------------
+| Purpose:    Debug definitions for the User Plane Management (UPM) Entity.
+|             For design details, see:
+|             8010.939 UPM Detailed Specification
++---------------------------------------------------------------------------*/
+
+/*==== DECLARATION CONTROL =================================================*/
+
+#ifndef UPM_DEBUG_H
+#define UPM_DEBUG_H
+
+/*==== INCLUDES =============================================================*/
+
+/*==== CONSTS ===============================================================*/
+
+/*==== TYPES ================================================================*/
+
+#ifdef S_SPLINT_S  /* LINT code checker defines */
+#undef TRUE
+#undef FALSE
+typedef /*@only@*/ T_VOID_STRUCT *T_VOID_STRUCT_ONLY;
+#ifdef TI_UMTS
+typedef /*@null@*/ /*@only@*/
+T_MEM_uplink_buffer_users_info *lint_mem_user_info;
+#endif /* TI_UMTS */
+#ifndef UPM_WITHOUT_USER_PLANE
+typedef /*@null@*/ /*@only@*/ T_desc2 *lint_desc_ptr;
+/*@-redef@*/ /*@-matchfields@*/
+typedef struct
+{
+  /*@null@*/ U32 /*@alt lint_desc_ptr@*/ next;
+  U16                         offset;
+  U16                         len;
+  U16                         size;
+  /*@reldef@*/ U8             buffer[1];
+  /*@reldef@*//*@unused@*/ U8 zzz_align0;
+} T_desc2;
+typedef struct
+{
+  U16                         list_len;
+  /*@reldef@*//*@unused@*/ U8 zzz_align0;
+  /*@reldef@*//*@unused@*/ U8 zzz_align1;
+  U32 /*@alt lint_desc_ptr@*/ first;
+} T_desc_list2;
+/*@=redef@*/ /*@=matchfields@*/
+#endif /* UPM_WITHOUT_USER_PLANE */
+#endif /* S_SPLINT_S */
+
+/*==== EXPORTS ==============================================================*/
+
+#ifdef S_SPLINT_S  /* LINT code checker defines */
+/*@-incondefs@*/ /*@-redecl@*/
+T_HANDLE           vsi_c_open   (T_HANDLE Caller, /*@observer@*/ char *Name)
+     /*@globals internalState@*/ /*@modifies internalState@*/;
+int /*@alt void@*/ vsi_c_close  (T_HANDLE Caller, T_HANDLE ComHandle);
+
+int /*@alt void@*/ vsi_c_psend  (T_HANDLE ComHandle,
+                                 /*@only@*/ /*@out@*/T_VOID_STRUCT *ptr FILE_LINE_TYPE);
+
+/*@null@*/ /*@only@*/ /*@out@*/ T_VOID_STRUCT *
+                   vsi_c_pnew   (U32 /*@alt int@*/        Size,
+                                 U32 /*@alt int@*/        opc FILE_LINE_TYPE);
+/*@null@*/ /*@only@*/ /*@out@*/ T_VOID_STRUCT *
+                   vsi_c_new_sdu(U32 /*@alt int@*/        Size,
+                                 U32 /*@alt int@*/        opc,
+                                 U16 /*@alt int,size_t@*/ sdu_len, 
+                                 U16 /*@alt int,size_t@*/ sdu_offset,
+                                 U16 /*@alt int@*/        encode_offset
+                                 FILE_LINE_TYPE);
+int /*@alt void@*/ vsi_c_pfree   (/*@out@*/ /*@null@*/
+                                  T_VOID_STRUCT_ONLY     *Msg  FILE_LINE_TYPE);
+/*@null@*/ /*@only@*/ /*@out@*/ T_VOID_STRUCT *
+                   vsi_m_cnew   (U32 /*@alt int@*/        size,
+                                 U32 /*@alt int@*/        type FILE_LINE_TYPE)
+     /*@globals internalState@*/ /*@modifies internalState@*/;
+int /*@alt void@*/ vsi_m_cfree   (/*@out@*/ /*@null@*/
+                                  T_VOID_STRUCT_ONLY     *ptr  FILE_LINE_TYPE)
+     /*@globals internalState@*/ /*@modifies internalState@*/;
+
+#ifdef TI_UMTS
+void               mem_adjust_uplink_users_flow_control(/*@in@*/ lint_mem_user_info users_info[MEM_MAX_RAB_ID]);
+
+/*@owned@*/U8 *    mem_alloc    (U8 user_handle, U16 length,
+                                 /*@out@*/ U32           *ptr_handle);
+/*@owned@*/U8 *    mem_get_user_data(T_MEM_HANDLE         memory_handle,
+                                 /*@out@*/ U16           *ptr_length);
+#endif /* TI_UMTS */
+
+#ifndef UPM_WITHOUT_USER_PLANE
+DTI_HANDLE         dti_init     (U8  maximum_links, T_HANDLE handle,
+                                 U32 entity_options,
+/*@-type@*/                      void (*sig_callback)
+/*@=type@*/                      (U8 instance, U8 interfac, U8 channel, U8 reason,
+                                  /*@only@*/ /*@null@*/
+                                  T_DTI2_DATA_IND         *dti_data_ind))
+     /*@globals internalState@*/ /*@modifies internalState@*/;
+
+BOOL               dti_resolve_link_id(/*@observer@*/DTI_HANDLE hDTI,
+                                 U8 instance, U8 interfac, U8 channel,
+                                 /*@out@*/ U32 *link_id);
+
+void               mfree_desc   (DTI_HANDLE hDTI,
+                                 /*@null@*/ /*@out@*/
+                                 T_desc_list2 * desc_list2)
+     /*@ensures isnull desc_list2->first@*/
+     /*@globals internalState@*/ /*@modifies internalState@*/;
+
+void               dti_send_data(/*@observer@*/DTI_HANDLE hDTI,
+                                 U8 instance, U8 interfac, U8 channel,
+                                 /*@only@*/ /*@null@*/ /*@out@*/
+                                 T_DTI2_DATA_IND *dti_data_ind);
+#endif /* UPM_WITHOUT_USER_PLANE */
+
+T_CL_result /*@alt void@*/
+cl_qos_convert_r97_to_r99(/*@partial@*//*@in@*/T_PS_qos_r97 *src_qos_r97,
+                          /*@out@*/            T_PS_qos_r99 *dst_qos_r99);
+T_CL_result /*@alt void@*/
+cl_qos_convert_r99_to_r97(/*@partial@*//*@in@*/T_PS_qos_r99 *src_qos_r99,
+                          /*@out@*/            T_PS_qos_r97 *dst_qos_r97);
+/*@=incondefs@*/ /*@=redecl@*/
+#endif /* S_SPLINT_S */
+
+#endif /* UPM_DEBUG_H */
+/*==== END OF FILE ==========================================================*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/g23m-gprs/upm/upm_dispatcher.c	Fri Oct 14 01:21:46 2016 +0000
@@ -0,0 +1,186 @@
+/*----------------------------------------------------------------------------
+|  Project :  3G PS
+|  Module  :  UPM
++-----------------------------------------------------------------------------
+|             Copyright 2003 Texas Instruments.
+|             All rights reserved. 
+| 
+|             This file is confidential and a trade secret of Texas 
+|             Instruments .
+|             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. 
++-----------------------------------------------------------------------------
+| Purpose:    This module implements the process dispatcher
+|             for the User Plane Manager (UPM) entity.
+|             For design details, see:
+|             8010.939 UPM Detailed Specification
++---------------------------------------------------------------------------*/
+
+/*==== DECLARATION CONTROL =================================================*/
+
+/*==== INCLUDES =============================================================*/
+
+#include "upm.h"
+#include "upm_dispatcher.h"
+
+/*==== CONSTS ===============================================================*/
+
+/*==== TYPES ================================================================*/
+
+/*==== LOCALS ===============================================================*/
+
+/*==== PRIVATE FUNCTIONS ====================================================*/
+
+/*==== PUBLIC FUNCTIONS =====================================================*/
+
+/*
++------------------------------------------------------------------------------
+| Function    : upm_disp_sm_activate_started_ind
++------------------------------------------------------------------------------
+| Description : Dispatch SM_ACTIVATE_STARTED_IND
+|
+| Parameters  : sm_activate_started_ind   - received primitive
++------------------------------------------------------------------------------
+*/
+void upm_disp_sm_activate_started_ind(T_SM_ACTIVATE_STARTED_IND *prim)
+{
+  int                    nsapi;
+  struct T_CONTEXT_DATA *ptr_context_data;
+
+  (void)TRACE_FUNCTION("upm_disp_sm_activate_started_ind");
+
+  nsapi            = (int)prim->nsapi;
+  ptr_context_data = upm_get_context_data_from_nsapi(nsapi);
+
+  /* UPM_DTI_REQ arrived first (or activation override).  Use present data structures. */
+  if (ptr_context_data != NULL)
+  {
+#ifdef UPM_WITHOUT_USER_PLANE /*T_UPM_USER_PLANE_DATA is not visible for GPRS world*/
+    memset(ptr_context_data, 0, sizeof(struct T_CONTEXT_DATA)
+                 /* - sizeof(struct T_UPM_USER_PLANE_DATA)*/);
+#else /*#ifndef UPM_WITHOUT_USER_PLANE*/
+    memset(ptr_context_data, 0, sizeof(struct T_CONTEXT_DATA) 
+                       - sizeof(struct T_UPM_USER_PLANE_DATA));
+#endif /*#ifndef UPM_WITHOUT_USER_PLANE*/
+    ptr_context_data->nsapi = (U8)nsapi;
+  } else {
+    MALLOC(ptr_context_data, (U32)sizeof(struct T_CONTEXT_DATA));
+
+    if (ptr_context_data == NULL)
+    {
+      (void)TRACE_ERROR("Unable to allocate data structure for new context!");
+      return;
+    }
+
+    memset(ptr_context_data, 0, sizeof(struct T_CONTEXT_DATA));
+
+    upm_assign_context_data_to_nsapi(ptr_context_data, nsapi);
+  }
+
+  TRACE_ASSERT(ptr_context_data != NULL);
+
+  upm_link_control_init(ptr_context_data);
+#ifdef TI_UMTS
+  upm_rab_control_init(ptr_context_data);
+#endif /* TI_UMTS */
+#ifdef TI_GPRS
+  upm_sndcp_control_init(ptr_context_data);
+#endif /* TI_GPRS */
+#ifdef TI_DUAL_MODE
+  upm_rat_control_init( (T_PS_rat)prim->rat );
+#endif /* TI_DUAL_MODE */
+  upm_link_control(ptr_context_data, UPM_P_SM_ACTIVATE_STARTED_IND, prim);
+}
+
+/*
++------------------------------------------------------------------------------
+| Function    : upm_disp_sm_activate_ind
++------------------------------------------------------------------------------
+| Description : Dispatch SM_ACTIVATE_IND
+|
+| Parameters  : sm_activate_ind            - received primitive
++------------------------------------------------------------------------------
+*/
+void upm_disp_sm_activate_ind(T_SM_ACTIVATE_IND *sm_activate_ind)
+{
+  struct T_CONTEXT_DATA *ptr_context_data;
+
+  (void)TRACE_FUNCTION("upm_disp_sm_activate_ind");
+
+  ptr_context_data = upm_get_context_data_from_nsapi(sm_activate_ind->nsapi);
+  if (ptr_context_data != NULL)
+  {
+    upm_link_control(ptr_context_data, UPM_P_SM_ACTIVATE_IND, sm_activate_ind);
+  } else {
+    (void)TRACE_ERROR("Tried to complete activation of non-existent context!");
+  }
+}
+
+/*
++------------------------------------------------------------------------------
+| Function    : upm_disp_sm_modify_ind
++------------------------------------------------------------------------------
+| Description : Dispatch SM_MODIFY_IND
+|
+| Parameters  : sm_modify_ind              - received primitive
++------------------------------------------------------------------------------
+*/
+void upm_disp_sm_modify_ind (T_SM_MODIFY_IND *sm_modify_ind)
+{
+  struct T_CONTEXT_DATA *ptr_context_data;
+
+  (void)TRACE_FUNCTION("upm_disp_sm_modify_ind");
+
+  ptr_context_data = upm_get_context_data_from_nsapi(sm_modify_ind->nsapi);
+  if (ptr_context_data != NULL)
+  {
+    upm_link_control(ptr_context_data, UPM_P_SM_MODIFY_IND, sm_modify_ind);
+  } else {
+    (void)TRACE_ERROR("Tried to modify non-existent context!");
+  }
+}
+
+/*
++------------------------------------------------------------------------------
+| Function    : upm_disp_upm_count_req
++------------------------------------------------------------------------------
+| Description : Dispatch UPM_COUNT_REQ
+|
+| Parameters  : prim                       - received primitive
++------------------------------------------------------------------------------
+*/
+void upm_disp_upm_count_req (T_UPM_COUNT_REQ *prim)
+{
+  struct T_CONTEXT_DATA *ptr_context_data;
+
+  (void)TRACE_FUNCTION("upm_disp_upm_count_req");
+
+  ptr_context_data = upm_get_context_data_from_nsapi(prim->nsapi);
+
+  if (ptr_context_data != NULL) {
+#ifdef TI_GPRS
+#ifdef TI_DUAL_MODE
+    if (upm_get_current_rat() == PS_RAT_GSM)
+#endif /* TI_DUAL_MODE */
+    {
+      upm_sndcp_dispatch_upm_count_req(prim);
+    }
+#endif /* TI_GPRS */
+#ifdef TI_DUAL_MODE
+    else
+#endif /* TI_DUAL_MODE */
+#ifdef TI_UMTS
+    {
+      upm_dti_dispatch_upm_count_req(ptr_context_data, prim->reset);
+    }
+#endif
+  } else {
+    (void)TRACE_EVENT_P1("Warning: Received COUNT_REQ for undefined "
+                         "NSAPI/context; ignored...", prim->nsapi);
+  }
+}
+
+/*==== END OF FILE ==========================================================*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/g23m-gprs/upm/upm_dispatcher.h	Fri Oct 14 01:21:46 2016 +0000
@@ -0,0 +1,60 @@
+/*----------------------------------------------------------------------------
+|  Project :  3G PS
+|  Module  :  UPM
++-----------------------------------------------------------------------------
+|             Copyright 2003 Texas Instruments.
+|             All rights reserved. 
+| 
+|             This file is confidential and a trade secret of Texas 
+|             Instruments .
+|             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. 
++-----------------------------------------------------------------------------
+| Purpose:    Process dispatcher helper functions in the UPM entity.
+|             For design details, see:
+|             8010.939 UPM Detailed Specification
++---------------------------------------------------------------------------*/
+
+/*==== DECLARATION CONTROL =================================================*/
+
+#ifndef UPM_DISPATCHER_H
+#define UPM_DISPATCHER_H
+
+/*==== INCLUDES =============================================================*/
+#include "typedefs.h"
+
+#include "upm.h"
+
+#ifdef TI_UMTS
+#include "upm_dispatcher_umts.h"
+#endif
+
+#ifdef TI_GPRS
+#include "upm_dispatcher_gsm.h"
+#endif
+
+#ifdef TI_DUAL_MODE
+#include "upm_dispatcher_dual_mode.h"
+#endif
+
+#ifndef UPM_WITHOUT_USER_PLANE
+#include "upm_dispatcher_user_plane.h"
+#endif
+
+/*==== CONSTS ===============================================================*/
+
+/*==== TYPES ================================================================*/
+
+/*==== EXPORTS ==============================================================*/
+
+extern void upm_disp_sm_activate_started_ind (T_SM_ACTIVATE_STARTED_IND *prim);
+extern void upm_disp_sm_activate_ind (T_SM_ACTIVATE_IND *sm_activate_ind);
+extern void upm_disp_sm_modify_ind (T_SM_MODIFY_IND *sm_modify_ind);
+
+extern void upm_disp_upm_count_req (T_UPM_COUNT_REQ *prim);
+
+#endif /* UPM_DISPATCHER_H */
+/*==== END OF FILE ==========================================================*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/g23m-gprs/upm/upm_dispatcher_gsm.c	Fri Oct 14 01:21:46 2016 +0000
@@ -0,0 +1,162 @@
+/*----------------------------------------------------------------------------
+|  Project :  3G PS
+|  Module  :  UPM
++-----------------------------------------------------------------------------
+|             Copyright 2003 Texas Instruments.
+|             All rights reserved. 
+| 
+|             This file is confidential and a trade secret of Texas 
+|             Instruments .
+|             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. 
++-----------------------------------------------------------------------------
+| Purpose:    This module implements the process dispatcher for GSM primitives
+|             in the User Plane Manager (UPM) entity.
+|             For design details, see:
+|             8010.939 UPM Detailed Specification
++---------------------------------------------------------------------------*/
+
+/*==== DECLARATION CONTROL =================================================*/
+
+
+/*==== INCLUDES =============================================================*/
+
+#include "upm.h"
+
+#ifndef UPM_WITHOUT_USER_PLANE
+#include "upm_dti_output_handler.h"
+#endif
+
+/*==== CONSTS ===============================================================*/
+
+/*==== TYPES ================================================================*/
+
+/*==== LOCALS ===============================================================*/
+
+/*==== PRIVATE FUNCTIONS ====================================================*/
+
+/*==== PUBLIC FUNCTIONS =====================================================*/
+
+/*
++------------------------------------------------------------------------------
+| Function    : upm_disp_mmpm_sequence_ind
++------------------------------------------------------------------------------
+| Description : Dispatch MMPM_SEQUENCE_IND
+|
+| Parameters  : prim                         - received primitive
++------------------------------------------------------------------------------
+*/
+void upm_disp_mmpm_sequence_ind (T_MMPM_SEQUENCE_IND *prim)
+{
+  (void)TRACE_FUNCTION("upm_disp_mmpm_sequence_ind");
+
+  upm_sndcp_dispatch_mmpm_sequence_ind(prim);
+}
+
+/*
++------------------------------------------------------------------------------
+| Function    : upm_disp_sn_activate_cnf
++------------------------------------------------------------------------------
+| Description : Dispatch SN_ACTIVATE_CNF
+|
+| Parameters  : prim                       - received primitive
++------------------------------------------------------------------------------
+*/
+void upm_disp_sn_activate_cnf (T_SN_ACTIVATE_CNF *prim)
+{
+  struct T_CONTEXT_DATA *context;
+
+  (void)TRACE_FUNCTION("upm_disp_sn_activate_cnf");
+
+  /* Find context data using NSAPI as index */
+  context = upm_get_context_data_from_nsapi(prim->nsapi);
+
+  if (context != NULL) {
+    /* Forward primitive to SNDCP Control */
+    upm_sndcp_control(context, UPM_P_SN_ACTIVATE_CNF, prim);
+  } else {
+    (void)TRACE_ERROR("Received SN_ACTIVATE_CNF for non-existing context "
+                      "- discarded!");
+  }
+}
+
+/*
++------------------------------------------------------------------------------
+| Function    : upm_disp_sn_count_cnf
++------------------------------------------------------------------------------
+| Description : Dispatch SN_COUNT_CNF
+|
+| Parameters  : prim                       - received primitive
++------------------------------------------------------------------------------
+*/
+void upm_disp_sn_count_cnf (T_SN_COUNT_CNF *prim)
+{
+  struct T_CONTEXT_DATA *ptr_context_data;
+
+  (void)TRACE_FUNCTION("upm_disp_sn_count_cnf");
+
+  ptr_context_data = upm_get_context_data_from_nsapi(prim->nsapi);
+  if (ptr_context_data != NULL) {
+    /* Forward primitive to SNDCP Control */
+    upm_sndcp_dispatch_sn_count_cnf(prim);
+  } else {
+    (void)TRACE_ERROR("Received SN_COUNT_CNF for non-existing context "
+                      "- discarded!");
+  }
+}
+
+/*
++------------------------------------------------------------------------------
+| Function    : upm_disp_sn_deactivate_cnf
++------------------------------------------------------------------------------
+| Description : Dispatch SN_DEACTIVATE_CNF
+|
+| Parameters  : prim                       - received primitive
++------------------------------------------------------------------------------
+*/
+void upm_disp_sn_deactivate_cnf (T_SN_DEACTIVATE_CNF *prim)
+{
+  struct T_CONTEXT_DATA *ptr_context_data;
+
+  (void)TRACE_FUNCTION("upm_disp_sn_deactivate_cnf");
+
+  ptr_context_data = upm_get_context_data_from_nsapi(prim->nsapi);
+  if (ptr_context_data != NULL) {
+    /* Forward primitive to SNDCP Control */
+    upm_sndcp_control(ptr_context_data, UPM_P_SN_DEACTIVATE_CNF, NULL);
+
+    upm_check_for_released_context_and_release(ptr_context_data);
+  }
+}
+
+/*
++------------------------------------------------------------------------------
+| Function    : upm_disp_sn_modify_cnf
++------------------------------------------------------------------------------
+| Description : Dispatch SN_MODIFY_CNF
+|
+| Parameters  : prim                      - received primitive
++------------------------------------------------------------------------------
+*/
+void upm_disp_sn_modify_cnf (T_SN_MODIFY_CNF *prim)
+{
+  struct T_CONTEXT_DATA *context;
+
+  (void)TRACE_FUNCTION("upm_disp_sn_modify_cnf");
+
+  /* Find context data using NSAPI as index */
+  context = upm_get_context_data_from_nsapi(prim->nsapi);
+
+  if (context != NULL) {
+    /* Forward primitive to SNDCP Control */
+    upm_sndcp_control(context, UPM_P_SN_MODIFY_CNF, prim);
+  } else {
+    (void)TRACE_ERROR("Received SN_MODIFY_CNF for non-existing context "
+                      "- discarded!");
+  }
+}
+
+/*==== END OF FILE ==========================================================*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/g23m-gprs/upm/upm_dispatcher_gsm.h	Fri Oct 14 01:21:46 2016 +0000
@@ -0,0 +1,42 @@
+/*----------------------------------------------------------------------------
+|  Project :  3G PS
+|  Module  :  UPM
++-----------------------------------------------------------------------------
+|             Copyright 2003 Texas Instruments.
+|             All rights reserved. 
+| 
+|             This file is confidential and a trade secret of Texas 
+|             Instruments .
+|             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. 
++-----------------------------------------------------------------------------
+| Purpose:    Process dispatcher helper functions in the UPM entity.
+|             For design details, see:
+|             8010.939 UPM Detailed Specification
++---------------------------------------------------------------------------*/
+
+/*==== DECLARATION CONTROL =================================================*/
+
+#ifndef UPM_DISPATCHER_GSM_H
+#define UPM_DISPATCHER_GSM_H
+
+/*==== INCLUDES =============================================================*/
+
+#include "upm.h"
+
+/*==== CONSTS ===============================================================*/
+
+/*==== TYPES ================================================================*/
+
+/*==== EXPORTS ==============================================================*/
+
+extern void upm_disp_mmpm_sequence_ind (T_MMPM_SEQUENCE_IND *prim);
+extern void upm_disp_sn_activate_cnf   (T_SN_ACTIVATE_CNF   *prim);
+extern void upm_disp_sn_count_cnf      (T_SN_COUNT_CNF      *prim);
+extern void upm_disp_sn_deactivate_cnf (T_SN_DEACTIVATE_CNF *prim);
+extern void upm_disp_sn_modify_cnf     (T_SN_MODIFY_CNF     *prim);
+#endif /* UPM_DISPATCHER_GSM_H */
+/*==== END OF FILE ==========================================================*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/g23m-gprs/upm/upm_link_control.c	Fri Oct 14 01:21:46 2016 +0000
@@ -0,0 +1,1200 @@
+/*----------------------------------------------------------------------------
+|  Project :  3G PS
+|  Module  :  UPM
++-----------------------------------------------------------------------------
+|             Copyright 2003 Texas Instruments.
+|             All rights reserved. 
+| 
+|             This file is confidential and a trade secret of Texas 
+|             Instruments .
+|             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. 
++-----------------------------------------------------------------------------
+| Purpose:    Link Control state machine implementation in the UPM entity.
+|             For design details, see:
+|             8010.939 UPM Detailed Specification
++---------------------------------------------------------------------------*/
+
+/*==== DECLARATION CONTROL =================================================*/
+
+
+/*==== INCLUDES =============================================================*/
+
+#include "upm.h"
+
+#ifdef TI_UMTS
+#include "upm_rab_control.h"
+#endif /* TI_UMTS */
+
+#ifdef TI_GPRS
+#include "upm_sndcp_control.h"
+#endif /* TI_GPRS */
+
+#include "upm_sm_output_handler.h"
+
+/*==== CONSTS ===============================================================*/
+
+/*==== TYPES ================================================================*/
+
+typedef void (*T_UPM_LINK_CONTROL_TRANSITION_FUNC)(struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ void *data);
+
+typedef struct {
+#ifdef DEBUG
+  T_UPM_LINK_CONTROL_EVENT            event;
+#endif /* DEBUG */
+  T_UPM_LINK_CONTROL_TRANSITION_FUNC  func;
+} T_UPM_LINK_CONTROL_TRANSITION;
+
+/*==== LOCALS ===============================================================*/
+
+static void state_event_error                           (struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ void *data);
+static void ignored                                     (struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ void *data);
+static void handle_sm_activate_started_ind              (struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ void *data);
+static void handle_dti_closed                           (struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ void *data);
+#ifdef TI_UMTS
+static void go_to_S2                                    (struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ void *data);
+static void handle_sm_activate_ind_in_umts              (struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ void *data);
+static void handle_sm_modify_ind_in_umts                (struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ void *data);
+static void handle_deactivate_in_umts                   (struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ void *data);
+static void handle_rab_released_abnormal                (struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ void *data);
+static void handle_rab_released_normal                  (struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ void *data);
+#endif /* TI_UMTS */
+#ifdef TI_GPRS
+static void handle_sm_activate_ind_in_gsm               (struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ void *data);
+static void handle_llc_link_established                 (struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ void *data);
+static void handle_sm_modify_ind_in_gsm                 (struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ void *data);
+static void handle_modify_response_in_gsm               (struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ void *data);
+static void handle_deactivate_in_gsm                    (struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ void *data);
+static void handle_deactivate_without_link_in_gsm       (struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ void *data);
+static void handle_llc_release_normal                   (struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ void *data);
+static void handle_llc_release_abnormal                 (struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ void *data);
+static void handle_gsm_qos_store(struct T_CONTEXT_DATA *ptr_context_data,
+                                 U8 sapi, U8 radio_prio, U8 pkt_flow_id,
+                                 T_PS_ctrl_qos ctrl_qos, T_PS_qos *qos);
+#endif /* TI_GPRS */
+#ifdef TI_DUAL_MODE
+static void go_to_S8                                    (struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ void *data);
+static void handle_rat_change_to_gsm_without_context    (struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ void *data);
+static void handle_rat_change_to_gsm                    (struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ void *data);
+static void handle_rab_established_in_S6                (struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ void *data);
+static void handle_rat_change_to_umts_without_context   (struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ void *data);
+static void handle_rat_change_to_umts_while_establishing(struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ void *data);
+static void handle_rat_change_to_umts                   (struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ void *data);
+#else
+#define handle_rat_change_to_gsm_without_context        state_event_error
+#define handle_rat_change_to_gsm                        state_event_error
+#define handle_rat_change_to_umts_without_context       state_event_error
+#define handle_rat_change_to_umts_while_establishing    state_event_error
+#define handle_rat_change_to_umts                       state_event_error
+#endif /* TI_DUAL_MODE */
+static void upm_link_mark_nsapi_deactivated(U8 nsapi);
+
+/***********************************************************************
+ * State/Transition Table
+ */
+static const T_UPM_LINK_CONTROL_TRANSITION
+transition[UPM_LINK_CONTROL_NUMBER_OF_STATES]
+          [UPM_LINK_CONTROL_NUMBER_OF_EVENTS] =
+{
+  { /* S0: UPM_LINK_RELEASED */
+    M_TRANSITION(UPM_P_SM_ACTIVATE_STARTED_IND,    handle_sm_activate_started_ind),
+    M_TRANSITION(UPM_P_SM_ACTIVATE_IND,            state_event_error),
+    M_TRANSITION(UPM_P_SM_DEACTIVATE_IND,          state_event_error),
+    M_TRANSITION(UPM_P_SM_MODIFY_IND,              state_event_error),
+    M_TRANSITION(UPM_I_LINK_DTI_CLOSED,            state_event_error),
+    M_TRANSITION(UPM_I_RAB_ESTABLISHED,            state_event_error),
+    M_TRANSITION(UPM_I_RAB_RELEASED,               state_event_error),
+    M_TRANSITION(UPM_I_SNDCP_LLC_LINK_ESTABLISHED, state_event_error),
+    M_TRANSITION(UPM_I_SNDCP_LLC_LINK_MODIFIED,    state_event_error),
+    M_TRANSITION(UPM_I_SNDCP_LLC_LINK_RELEASED,    state_event_error),
+    M_TRANSITION(UPM_I_LINK_RAT_CHANGED,           state_event_error)
+  },
+#ifdef TI_UMTS
+  { /* S1: UPM_LINK_ESTABLISHING_RAB */
+    M_TRANSITION(UPM_P_SM_ACTIVATE_STARTED_IND,    state_event_error),
+    M_TRANSITION(UPM_P_SM_ACTIVATE_IND,            state_event_error),
+    M_TRANSITION(UPM_P_SM_DEACTIVATE_IND,          handle_deactivate_in_umts),
+    M_TRANSITION(UPM_P_SM_MODIFY_IND,              state_event_error),
+    M_TRANSITION(UPM_I_LINK_DTI_CLOSED,            handle_dti_closed),
+    M_TRANSITION(UPM_I_RAB_ESTABLISHED,            go_to_S2),
+    M_TRANSITION(UPM_I_RAB_RELEASED,               state_event_error),
+    M_TRANSITION(UPM_I_SNDCP_LLC_LINK_ESTABLISHED, state_event_error),
+    M_TRANSITION(UPM_I_SNDCP_LLC_LINK_MODIFIED,    state_event_error),
+    M_TRANSITION(UPM_I_SNDCP_LLC_LINK_RELEASED,    state_event_error),
+    M_TRANSITION(UPM_I_LINK_RAT_CHANGED,           handle_rat_change_to_gsm_without_context)
+  },
+  { /* S2: UPM_LINK_AWAITING_ACTIVATE_UMTS */
+    M_TRANSITION(UPM_P_SM_ACTIVATE_STARTED_IND,    state_event_error),
+    M_TRANSITION(UPM_P_SM_ACTIVATE_IND,            handle_sm_activate_ind_in_umts),
+    M_TRANSITION(UPM_P_SM_DEACTIVATE_IND,          handle_deactivate_in_umts),
+    M_TRANSITION(UPM_P_SM_MODIFY_IND,              state_event_error),
+    M_TRANSITION(UPM_I_LINK_DTI_CLOSED,            handle_dti_closed),
+    M_TRANSITION(UPM_I_RAB_ESTABLISHED,            state_event_error),
+    M_TRANSITION(UPM_I_RAB_RELEASED,               handle_rab_released_abnormal),
+    M_TRANSITION(UPM_I_SNDCP_LLC_LINK_ESTABLISHED, state_event_error),
+    M_TRANSITION(UPM_I_SNDCP_LLC_LINK_MODIFIED,    state_event_error),
+    M_TRANSITION(UPM_I_SNDCP_LLC_LINK_RELEASED,    state_event_error),
+    M_TRANSITION(UPM_I_LINK_RAT_CHANGED,           state_event_error)
+  },
+  { /* S3: UPM_LINK_RAB_ESTABLISHED */
+    M_TRANSITION(UPM_P_SM_ACTIVATE_STARTED_IND,    state_event_error),
+    M_TRANSITION(UPM_P_SM_ACTIVATE_IND,            state_event_error),
+    M_TRANSITION(UPM_P_SM_DEACTIVATE_IND,          handle_deactivate_in_umts),
+    M_TRANSITION(UPM_P_SM_MODIFY_IND,              handle_sm_modify_ind_in_umts),
+    M_TRANSITION(UPM_I_LINK_DTI_CLOSED,            handle_dti_closed),
+    M_TRANSITION(UPM_I_RAB_ESTABLISHED,            ignored),
+    M_TRANSITION(UPM_I_RAB_RELEASED,               handle_rab_released_abnormal),
+    M_TRANSITION(UPM_I_SNDCP_LLC_LINK_ESTABLISHED, state_event_error),
+    M_TRANSITION(UPM_I_SNDCP_LLC_LINK_MODIFIED,    state_event_error),
+    M_TRANSITION(UPM_I_SNDCP_LLC_LINK_RELEASED,    ignored),
+    M_TRANSITION(UPM_I_LINK_RAT_CHANGED,           handle_rat_change_to_gsm)
+  },
+  { /* S4: UPM_LINK_RELEASING_RAB */
+    M_TRANSITION(UPM_P_SM_ACTIVATE_STARTED_IND,    state_event_error),
+    M_TRANSITION(UPM_P_SM_ACTIVATE_IND,            state_event_error),
+    M_TRANSITION(UPM_P_SM_DEACTIVATE_IND,          state_event_error),
+    M_TRANSITION(UPM_P_SM_MODIFY_IND,              state_event_error),
+    M_TRANSITION(UPM_I_LINK_DTI_CLOSED,            state_event_error),
+    M_TRANSITION(UPM_I_RAB_ESTABLISHED,            state_event_error),
+    M_TRANSITION(UPM_I_RAB_RELEASED,               handle_rab_released_normal),
+    M_TRANSITION(UPM_I_SNDCP_LLC_LINK_ESTABLISHED, state_event_error),
+    M_TRANSITION(UPM_I_SNDCP_LLC_LINK_MODIFIED,    state_event_error),
+    M_TRANSITION(UPM_I_SNDCP_LLC_LINK_RELEASED,    state_event_error),
+    M_TRANSITION(UPM_I_LINK_RAT_CHANGED,           ignored)
+  },
+#endif /* TI_UMTS */
+#ifdef TI_DUAL_MODE
+  { /* S5: UPM_LINK_COMPLETING_RAT_CHANGE_TO_GSM */
+    M_TRANSITION(UPM_P_SM_ACTIVATE_STARTED_IND,    state_event_error),
+    M_TRANSITION(UPM_P_SM_ACTIVATE_IND,            state_event_error),
+    M_TRANSITION(UPM_P_SM_DEACTIVATE_IND,          handle_deactivate_in_gsm),
+    M_TRANSITION(UPM_P_SM_MODIFY_IND,              state_event_error),
+    M_TRANSITION(UPM_I_LINK_DTI_CLOSED,            handle_dti_closed),
+    M_TRANSITION(UPM_I_RAB_ESTABLISHED,            state_event_error),
+    M_TRANSITION(UPM_I_RAB_RELEASED,               ignored),
+    M_TRANSITION(UPM_I_SNDCP_LLC_LINK_ESTABLISHED, go_to_S8),
+    M_TRANSITION(UPM_I_SNDCP_LLC_LINK_MODIFIED,    state_event_error),
+    M_TRANSITION(UPM_I_SNDCP_LLC_LINK_RELEASED,    handle_llc_release_abnormal),
+    M_TRANSITION(UPM_I_LINK_RAT_CHANGED,           state_event_error)
+  },
+  { /* S6: UPM_LINK_COMPLETING_RAT_CHANGE_TO_UMTS_INITIAL */
+    M_TRANSITION(UPM_P_SM_ACTIVATE_STARTED_IND,    state_event_error),
+    M_TRANSITION(UPM_P_SM_ACTIVATE_IND,            state_event_error),
+    M_TRANSITION(UPM_P_SM_DEACTIVATE_IND,          handle_deactivate_in_umts),
+    M_TRANSITION(UPM_P_SM_MODIFY_IND,              state_event_error),
+    M_TRANSITION(UPM_I_LINK_DTI_CLOSED,            handle_dti_closed),
+    M_TRANSITION(UPM_I_RAB_ESTABLISHED,            handle_rab_established_in_S6),
+    M_TRANSITION(UPM_I_RAB_RELEASED,               state_event_error),
+    M_TRANSITION(UPM_I_SNDCP_LLC_LINK_ESTABLISHED, state_event_error),
+    M_TRANSITION(UPM_I_SNDCP_LLC_LINK_MODIFIED,    state_event_error),
+    M_TRANSITION(UPM_I_SNDCP_LLC_LINK_RELEASED,    ignored),
+    M_TRANSITION(UPM_I_LINK_RAT_CHANGED,           handle_rat_change_to_gsm)
+  },
+#endif /* TI_DUAL_MODE */
+#ifdef TI_GPRS
+  { /* S7: UPM_LINK_AWAITING_ACTIVATE_GSM */
+    M_TRANSITION(UPM_P_SM_ACTIVATE_STARTED_IND,    state_event_error),
+    M_TRANSITION(UPM_P_SM_ACTIVATE_IND,            handle_sm_activate_ind_in_gsm),
+    M_TRANSITION(UPM_P_SM_DEACTIVATE_IND,          handle_deactivate_without_link_in_gsm),
+    M_TRANSITION(UPM_P_SM_MODIFY_IND,              state_event_error),
+    M_TRANSITION(UPM_I_LINK_DTI_CLOSED,            handle_dti_closed),
+    M_TRANSITION(UPM_I_RAB_ESTABLISHED,            state_event_error),
+    M_TRANSITION(UPM_I_RAB_RELEASED,               state_event_error),
+    M_TRANSITION(UPM_I_SNDCP_LLC_LINK_ESTABLISHED, state_event_error),
+    M_TRANSITION(UPM_I_SNDCP_LLC_LINK_MODIFIED,    state_event_error),
+    M_TRANSITION(UPM_I_SNDCP_LLC_LINK_RELEASED,    state_event_error),
+    M_TRANSITION(UPM_I_LINK_RAT_CHANGED,           handle_rat_change_to_umts_without_context)
+  },
+  { /* S8: UPM_LINK_ESTABLISHING_LLC_LINK */
+    M_TRANSITION(UPM_P_SM_ACTIVATE_STARTED_IND,    state_event_error),
+    M_TRANSITION(UPM_P_SM_ACTIVATE_IND,            state_event_error),
+    M_TRANSITION(UPM_P_SM_DEACTIVATE_IND,          handle_deactivate_in_gsm),
+    M_TRANSITION(UPM_P_SM_MODIFY_IND,              state_event_error),
+    M_TRANSITION(UPM_I_LINK_DTI_CLOSED,            handle_dti_closed),
+    M_TRANSITION(UPM_I_RAB_ESTABLISHED,            ignored),
+    M_TRANSITION(UPM_I_RAB_RELEASED,               state_event_error),
+    M_TRANSITION(UPM_I_SNDCP_LLC_LINK_ESTABLISHED, handle_llc_link_established),
+    M_TRANSITION(UPM_I_SNDCP_LLC_LINK_MODIFIED,    state_event_error),
+    M_TRANSITION(UPM_I_SNDCP_LLC_LINK_RELEASED,    handle_llc_release_abnormal),
+    M_TRANSITION(UPM_I_LINK_RAT_CHANGED,           handle_rat_change_to_umts_while_establishing)
+  },
+  { /* S9: UPM_LINK_LLC_LINK_ESTABLISHED */
+    M_TRANSITION(UPM_P_SM_ACTIVATE_STARTED_IND,    state_event_error),
+    M_TRANSITION(UPM_P_SM_ACTIVATE_IND,            state_event_error),
+    M_TRANSITION(UPM_P_SM_DEACTIVATE_IND,          handle_deactivate_in_gsm),
+    M_TRANSITION(UPM_P_SM_MODIFY_IND,              handle_sm_modify_ind_in_gsm),
+    M_TRANSITION(UPM_I_LINK_DTI_CLOSED,            handle_dti_closed),
+    M_TRANSITION(UPM_I_RAB_ESTABLISHED,            state_event_error),
+    M_TRANSITION(UPM_I_RAB_RELEASED,               state_event_error),
+    M_TRANSITION(UPM_I_SNDCP_LLC_LINK_ESTABLISHED, state_event_error),
+    M_TRANSITION(UPM_I_SNDCP_LLC_LINK_MODIFIED,    handle_modify_response_in_gsm),
+    M_TRANSITION(UPM_I_SNDCP_LLC_LINK_RELEASED,    handle_llc_release_abnormal),
+    M_TRANSITION(UPM_I_LINK_RAT_CHANGED,           handle_rat_change_to_umts)
+  },
+  { /* S10: UPM_LINK_RELEASING_LLC_LINK */
+    M_TRANSITION(UPM_P_SM_ACTIVATE_STARTED_IND,    state_event_error),
+    M_TRANSITION(UPM_P_SM_ACTIVATE_IND,            state_event_error),
+    M_TRANSITION(UPM_P_SM_DEACTIVATE_IND,          state_event_error),
+    M_TRANSITION(UPM_P_SM_MODIFY_IND,              state_event_error),
+    M_TRANSITION(UPM_I_LINK_DTI_CLOSED,            state_event_error),
+    M_TRANSITION(UPM_I_RAB_ESTABLISHED,            state_event_error),
+    M_TRANSITION(UPM_I_RAB_RELEASED,               state_event_error),
+    M_TRANSITION(UPM_I_SNDCP_LLC_LINK_ESTABLISHED, state_event_error),
+    M_TRANSITION(UPM_I_SNDCP_LLC_LINK_MODIFIED,    state_event_error),
+    M_TRANSITION(UPM_I_SNDCP_LLC_LINK_RELEASED,    handle_llc_release_normal),
+    M_TRANSITION(UPM_I_LINK_RAT_CHANGED,           ignored)
+  }
+#endif /* TI_GPRS */
+};
+
+/*==== PRIVATE FUNCTIONS ====================================================*/
+
+/*
++------------------------------------------------------------------------------
+| Function    : link_control_goto_state
++------------------------------------------------------------------------------
+| Description : Move to the state specified in the new_state parameter
+|
+| Parameters  : ptr_context_data - Context data
+|               new_state        - New state
++------------------------------------------------------------------------------
+*/
+static void link_control_goto_state(struct T_CONTEXT_DATA *ptr_context_data,
+                                    T_UPM_LINK_CONTROL_STATE new_state)
+{
+  ptr_context_data->link_control_state = new_state;
+}
+
+/*
++------------------------------------------------------------------------------
+| Function    : link_control_state
++------------------------------------------------------------------------------
+| Description : Return the state in which Link Control is in for this
+|               context instanse.
+|
+| Parameters  : ptr_context_data - Context data
++------------------------------------------------------------------------------
+*/
+static T_UPM_LINK_CONTROL_STATE
+link_control_state(struct T_CONTEXT_DATA *ptr_context_data)
+{
+  return ptr_context_data->link_control_state;
+}
+
+/*
++------------------------------------------------------------------------------
+| Function    : state_event_error
++------------------------------------------------------------------------------
+| Description : General function used to report state event errors.
+|
+| Parameters  : ptr_context_data - Not used
+|               data             - Not used
++------------------------------------------------------------------------------
+*/
+static void state_event_error(/*@unused@*/ struct T_CONTEXT_DATA *ptr_context_data, /*@unused@*/ /*@null@*/ void *data)
+{
+  (void)TRACE_ERROR("UPM Link Control: STATE EVENT ERROR!");
+}
+
+/*
++------------------------------------------------------------------------------
+| Function    : ignored
++------------------------------------------------------------------------------
+| Description : General function used for transitions that shall be ignored
+|
+| Parameters  : ptr_context_data - Not used
+|               data             - Not used
++------------------------------------------------------------------------------
+*/
+static void ignored(/*@unused@*/ struct T_CONTEXT_DATA *ptr_context_data, /*@unused@*/ /*@null@*/ void *data)
+{
+  (void)TRACE_FUNCTION("UPM Link Control: Event ignored.");
+}
+
+/*
++------------------------------------------------------------------------------
+| Function    : go_to_S*
++------------------------------------------------------------------------------
+| Description : General functions for simple state transitions
+|
+| Parameters  : ptr_context_data - Not used
+|               data             - Not used
++------------------------------------------------------------------------------
+*/
+#ifdef TI_UMTS
+static void go_to_S2(/*@unused@*/ struct T_CONTEXT_DATA *ptr_context_data, /*@unused@*/ /*@null@*/ void *data)
+{
+  /* (void)TRACE_FUNCTION("UPM Link Control: Transition to UPM LINK AWAITING ACTIVATE UMTS state"); */
+  link_control_goto_state(ptr_context_data, UPM_LINK_AWAITING_ACTIVATE_UMTS);
+}
+#endif /* TI_UMTS */
+
+#ifdef TI_DUAL_MODE
+static void go_to_S8(/*@unused@*/ struct T_CONTEXT_DATA *ptr_context_data, /*@unused@*/ /*@null@*/ void *data)
+{
+  /* (void)TRACE_FUNCTION("UPM Link Control: Transition to UPM LINK LLC LINK ESTABLISHED state"); */
+  link_control_goto_state(ptr_context_data, UPM_LINK_LLC_LINK_ESTABLISHED);
+}
+#endif /* TI_DUAL_MODE */
+
+/*
++------------------------------------------------------------------------------
+| Function    : handle_sm_activate_started_ind
++------------------------------------------------------------------------------
+| Description : Handle SM_ACTIVATE_STARTED_IND primitive.  Examines RAT,
+|               and moves to GSM or UTMS state. Starts RAB in UMTS.
+|
+| Parameters  : ptr_context_data - Context data
+|               data             - SM_ACTIVATE_STARTED_IND primitive (unused)
++------------------------------------------------------------------------------
+*/
+static void handle_sm_activate_started_ind(struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ /*@unused@*/ void *data)
+{
+  (void)TRACE_FUNCTION("UPM Link Control: handle_sm_activate_started_ind");
+
+#ifdef TI_DUAL_MODE
+  /* Examine RAT: */
+  if (upm_get_current_rat() == PS_RAT_GSM)
+#endif /* TI_DUAL_MODE */
+#ifdef TI_GPRS
+  {
+    /* GSM: Do nothing until SM_ACTIVATE_IND arrives.  Just change state. */
+    link_control_goto_state(ptr_context_data, UPM_LINK_AWAITING_ACTIVATE_GSM);
+  }
+#endif /* TI_GPRS */
+#ifdef TI_DUAL_MODE
+  else if (upm_get_current_rat() == PS_RAT_UMTS_FDD)
+#endif /* TI_DUAL_MODE */
+#ifdef TI_UMTS
+  {
+    /* UMTS: Order RAB Control to await RAB establishment, and change state. */
+    link_control_goto_state(ptr_context_data, UPM_LINK_ESTABLISHING_RAB);
+    upm_rab_control(ptr_context_data, UPM_I_RAB_AWAIT_INITIAL_ESTABLISH, NULL);
+  }
+#endif /* TI_UMTS */
+}
+
+/*
++------------------------------------------------------------------------------
+| Function    : handle_dti_closed
++------------------------------------------------------------------------------
+| Description : Handle UPM_I_LINK_DTI_CLOSED
+|
+| Parameters  : ptr_context_data - Context data
+|               data             - Not used
++------------------------------------------------------------------------------
+*/
+static void handle_dti_closed(struct T_CONTEXT_DATA *ptr_context_data, /*@unused@*/ /*@null@*/ void *data)
+{
+  T_PS_sapi  llc_sapi;
+
+  (void)TRACE_FUNCTION("UPM Link Control: handle_dti_closed");
+
+#ifdef TI_GPRS
+  llc_sapi = (T_PS_sapi)ptr_context_data->gprs_data.sndcp_llc_sapi;
+#else
+  llc_sapi = PS_SAPI_0; /* SAPI not assigned [3G 24.008, 6.1.3.1.1] */
+#endif /* TI_GPRS */
+
+  /* Send SM_STATUS_REQ, and expect control plane to take action. */
+  send_sm_status_req(upm_nsapi2nsapi_set(ptr_context_data->nsapi),
+                     llc_sapi,
+                     CAUSE_is_from_upm, (U16)CAUSE_UPM_DTI_DISCONNECT);
+}
+
+/*
++------------------------------------------------------------------------------
+| Function    : handle_sm_activate_ind_in_utms
++------------------------------------------------------------------------------
+| Description : Handle SM_ACTIVATE_IND primitive while in UMTS RAT.
+|
+| Parameters  : ptr_context_data - Context data
+|               data             - SM_ACTIVATE_IND primitive
++------------------------------------------------------------------------------
+*/
+#ifdef TI_UMTS
+static void handle_sm_activate_ind_in_umts(struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ void *data)
+{
+  T_SM_ACTIVATE_IND *prim = (T_SM_ACTIVATE_IND *)data;
+
+  (void)TRACE_FUNCTION("UPM Link Control: handle_sm_activate_ind_in_umts");
+
+  TRACE_ASSERT( data != NULL );
+
+#ifdef TI_DUAL_MODE
+  /* Store GSM-RAT relevant QoS parameters in ptr_context_data fields. */
+  handle_gsm_qos_store(ptr_context_data, prim->sapi, prim->radio_prio,
+                       (U8)prim->pkt_flow_id, prim->ctrl_qos, &prim->qos);
+#endif /* TI_DUAL_MODE */
+
+  /* Send SM_ACTIVATE_RES */
+  send_sm_activate_res(ptr_context_data, ((T_SN_ACTIVATE_CNF*)data));
+
+  /* Go to state UPM LINK RAB ESTABLISHED */
+  link_control_goto_state(ptr_context_data, UPM_LINK_RAB_ESTABLISHED);
+
+  /* Store QoS parameter as needed in RAB Control */
+  upm_rab_control(ptr_context_data, UPM_I_RAB_MODIFY, &(prim->qos.qos_r99));
+
+  /* Inform Uplink and Downlink state machines of link up. */
+  upm_uplink_data_control(ptr_context_data, UPM_I_UPLINK_DATA_LINK_UP, NULL);
+  upm_downlink_data_control(ptr_context_data, UPM_I_DOWNLINK_DATA_LINK_UP, NULL);
+}
+#endif /* TI_UMTS */
+
+/*
++------------------------------------------------------------------------------
+| Function    : handle_sm_modify_ind_in_utms
++------------------------------------------------------------------------------
+| Description : Handle SM_MODIFY_IND primitive while in UMTS RAT.
+|
+| Parameters  : ptr_context_data - Context data
+|               data             - SM_MODIFY_IND primitive
++------------------------------------------------------------------------------
+*/
+#ifdef TI_UMTS
+static void handle_sm_modify_ind_in_umts(struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ void *data)
+{
+  T_SM_MODIFY_IND *prim = (T_SM_MODIFY_IND *)data;
+
+  (void)TRACE_FUNCTION("UPM Link Control: handle_sm_modify_ind_in_umts");
+
+  TRACE_ASSERT( data != NULL );
+
+#ifdef TI_DUAL_MODE
+  /* Store GSM-RAT relevant QoS parameters in ptr_context_data fields. */
+  handle_gsm_qos_store(ptr_context_data, prim->sapi, prim->radio_prio,
+                       (U8)prim->pkt_flow_id, prim->ctrl_qos, &prim->qos);
+#endif
+
+  /* Store QoS parameter as needed in RAB Control */
+  upm_rab_control(ptr_context_data, UPM_I_RAB_MODIFY,
+                  &(prim->qos.qos_r99));
+
+  /* Send SM_MODIFY_RES */
+  send_sm_modify_res(ptr_context_data);
+}
+#endif /* TI_UMTS */
+
+/*
++------------------------------------------------------------------------------
+| Function    : handle_deactivate_in_umts
++------------------------------------------------------------------------------
+| Description : Handle SM_DEACTIVATE_IND primitive while in UMTS RAT.
+|
+| Parameters  : ptr_context_data - Context data
+|               data             - Local release flag (Not used in UMTS)
++------------------------------------------------------------------------------
+*/
+#ifdef TI_UMTS
+static void handle_deactivate_in_umts(struct T_CONTEXT_DATA *ptr_context_data, /*@unused@*/ /*@null@*/ void *data)
+{
+  (void)TRACE_FUNCTION("UPM Link Control: handle_deactivate_in_umts");
+
+  /* Go to state UPM LINK RELEASING RAB */
+  link_control_goto_state(ptr_context_data, UPM_LINK_RELEASING_RAB);
+
+  /* Terminate Uplink and Downlink state machines. */
+  upm_uplink_data_control(ptr_context_data, UPM_I_UPLINK_DATA_LINK_DOWN, NULL);
+  upm_downlink_data_control(ptr_context_data, UPM_I_DOWNLINK_DATA_LINK_DOWN, NULL);
+
+  /* Order RAB Control to await RAB release. */
+  upm_rab_control(ptr_context_data, UPM_I_RAB_AWAIT_RAB_RELEASE, NULL);
+}
+#endif /* TI_UMTS */
+
+/*
++------------------------------------------------------------------------------
+| Function    : handle_rab_released_abnormal
++------------------------------------------------------------------------------
+| Description : Handle UPM_I_RAB_RELEASED when not expected
+|
+| Parameters  : ptr_context_data - Context data
+|               data             - Not used
++------------------------------------------------------------------------------
+*/
+#ifdef TI_UMTS
+static void handle_rab_released_abnormal(struct T_CONTEXT_DATA *ptr_context_data, /*@unused@*/ /*@null@*/ void *data)
+{
+  (void)TRACE_FUNCTION("UPM Link Control: handle_rab_released_abnormal");
+
+  /* Go to state UPM LINK RELEASED */
+  link_control_goto_state(ptr_context_data, UPM_LINK_RELEASED);
+
+  /* Terminate Uplink and Downlink state machines. */
+  upm_uplink_data_control(ptr_context_data, UPM_I_UPLINK_DATA_LINK_DOWN, NULL);
+  upm_downlink_data_control(ptr_context_data, UPM_I_DOWNLINK_DATA_LINK_DOWN, NULL);
+}
+#endif /* TI_UMTS */
+
+/*
++------------------------------------------------------------------------------
+| Function    : handle_rab_released_normal
++------------------------------------------------------------------------------
+| Description : Handle UPM_I_RAB_RELEASED during normal deactivation
+|
+| Parameters  : ptr_context_data - Context data
+|               data             - Not used
++------------------------------------------------------------------------------
+*/
+#ifdef TI_UMTS
+static void handle_rab_released_normal(struct T_CONTEXT_DATA *ptr_context_data, /*@unused@*/ /*@null@*/ void *data)
+{
+  (void)TRACE_FUNCTION("UPM Link Control: handle_rab_released_normal");
+
+  /* SM_DEACTIVATE_RES sent from dispatcher; groups responses for all NSAPIs */
+  /* send_sm_deactivate_res( ... ); */
+  upm_link_mark_nsapi_deactivated(ptr_context_data->nsapi);
+
+  /* Go to state UPM LINK RELEASED */
+  link_control_goto_state(ptr_context_data, UPM_LINK_RELEASED);
+}
+#endif /* TI_UMTS */
+
+/*
++------------------------------------------------------------------------------
+| Function    : handle_sm_activate_ind_in_gsm
++------------------------------------------------------------------------------
+| Description : Handle SM_ACTIVATE_IND in S7
+|
+| Parameters  : ptr_context_data - Context data
+|               data             - Not used
++------------------------------------------------------------------------------
+*/
+#ifdef TI_GPRS
+static void handle_sm_activate_ind_in_gsm(struct T_CONTEXT_DATA *ptr_context_data, /*@unused@*/ /*@null@*/ void *data)
+{
+  T_SM_ACTIVATE_IND *prim = (T_SM_ACTIVATE_IND *)data;
+
+  (void)TRACE_FUNCTION("UPM Link Control: handle_sm_activate_ind_in_gsm");
+
+  TRACE_ASSERT(prim != NULL);
+
+  /*lint -e613 (Possible use of null pointer 'prim' in left argument to operator '->') */
+  /* Store GSM-RAT relevant QoS parameters in ptr_context_data fields. */
+  handle_gsm_qos_store(ptr_context_data, prim->sapi, prim->radio_prio,
+                       (U8)prim->pkt_flow_id, prim->ctrl_qos, &prim->qos);
+
+  /* Go to state UPM LINK ESTABLISHING LLC LINK */
+  link_control_goto_state(ptr_context_data, UPM_LINK_ESTABLISHING_LLC_LINK);
+
+  /* Order SNDCP Control to establish LLC link */
+
+  /* Pass compression parameter fields only if they are present */
+  if( (((T_SM_ACTIVATE_IND *)data)->v_comp_params == TRUE) )
+  {
+    upm_sndcp_control(ptr_context_data, UPM_I_SNDCP_ESTABLISH_LLC_LINK, 
+      &((T_SM_ACTIVATE_IND *)data)->comp_params);
+  } else {
+    upm_sndcp_control(ptr_context_data, UPM_I_SNDCP_ESTABLISH_LLC_LINK, NULL);
+  }
+}
+#endif /* TI_GPRS */
+
+/*
++------------------------------------------------------------------------------
+| Function    : handle_llc_link_established
++------------------------------------------------------------------------------
+| Description : Handle UPM_I_LLC_LINK_ESTABLISHED in S8
+|
+| Parameters  : ptr_context_data - Context data
+|               data             - Not used
++------------------------------------------------------------------------------
+*/
+#ifdef TI_GPRS
+static void handle_llc_link_established(struct T_CONTEXT_DATA *ptr_context_data, /*@unused@*/ /*@null@*/ void *data)
+{
+  (void)TRACE_FUNCTION("UPM Link Control: handle_llc_link_established");
+
+  send_sm_activate_res(ptr_context_data, ((T_SN_ACTIVATE_CNF*)data));
+
+  /* Go to state UPM LINK LLC LINK ESTABLISHED */
+  link_control_goto_state(ptr_context_data, UPM_LINK_LLC_LINK_ESTABLISHED);
+
+#ifndef UPM_WITHOUT_USER_PLANE
+  /* Report initial LINK UP to Uplink Data */
+  upm_uplink_data_control(ptr_context_data, UPM_I_UPLINK_DATA_LINK_UP, NULL);
+
+  /* Report link up to Downlink Data Control.  This triggers flow control
+   * initialization towards SNDCP. */
+  upm_downlink_data_control(ptr_context_data, UPM_I_DOWNLINK_DATA_LINK_UP, NULL);
+#endif /* UPM_WITHOUT_USER_PLANE */
+}
+#endif /* TI_GPRS */
+
+/*
++------------------------------------------------------------------------------
+| Function    : handle_sm_modify_ind_in_gsm
++------------------------------------------------------------------------------
+| Description : Handle SM_MODIFY_IND primitive while in GSM RAT.
+|
+| Parameters  : ptr_context_data - Context data
+|               data             - SM_MODIFY_IND primitive
++------------------------------------------------------------------------------
+*/
+#ifdef TI_GPRS
+static void handle_sm_modify_ind_in_gsm(struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ void *data)
+{
+  T_SM_MODIFY_IND *prim = (T_SM_MODIFY_IND *)data;
+
+  (void)TRACE_FUNCTION("UPM Link Control: handle_sm_modify_ind_in_gsm");
+
+  TRACE_ASSERT( data != NULL );
+  
+  /*lint -e613 (Possible use of null pointer 'unknown-name' in left argument to operator '->') */
+  /* Store GSM-RAT relevant QoS parameters in ptr_context_data fields. */
+  handle_gsm_qos_store(ptr_context_data, prim->sapi, prim->radio_prio,
+                       (U8)prim->pkt_flow_id, prim->ctrl_qos, &prim->qos);
+
+  /* SNDCP Control constructs a modify primitive to SNDCP */
+  upm_sndcp_control(ptr_context_data, UPM_I_SNDCP_MODIFY_LLC_LINK,
+                    &((T_SM_MODIFY_IND *)data)->qos.qos_r99);
+  /*lint +e613 (Possible use of null pointer 'unknown-name' in left argument to operator '->') */
+  
+}
+#endif /* TI_GPRS */
+
+/*
++------------------------------------------------------------------------------
+| Function    : handle_modify_response_in_gsm
++------------------------------------------------------------------------------
+| Description : Handle UPM_I_SNDCP_LLC_LINK_MODIFIED
+|
+| Parameters  : ptr_context_data - Context data
+|               data             - Not used
++------------------------------------------------------------------------------
+*/
+#ifdef TI_GPRS
+static void handle_modify_response_in_gsm(struct T_CONTEXT_DATA *ptr_context_data, /*@unused@*/ /*@null@*/ void *data)
+{
+  (void)TRACE_FUNCTION("UPM Link Control: handle_modify_response_in_gsm");
+
+  /* Send SM_MODIFY_RES */
+  send_sm_modify_res(ptr_context_data);
+}
+#endif /* TI_GPRS */
+
+/*
++------------------------------------------------------------------------------
+| Function    : handle_deactivate_in_gsm
++------------------------------------------------------------------------------
+| Description : Handle SM_DEACTIVATE_IND while active in GSM RAT
+|
+| Parameters  : ptr_context_data - Context data
+|               data             - Local flag (rel_ind)
++------------------------------------------------------------------------------
+*/
+#ifdef TI_GPRS
+static void handle_deactivate_in_gsm(struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ void *data)
+{
+  (void)TRACE_FUNCTION("UPM Link Control: handle_deactivate_in_gsm");
+
+  /* Go to state UPM LINK RELEASING LLC LINK */
+  link_control_goto_state(ptr_context_data, UPM_LINK_RELEASING_LLC_LINK);
+
+#ifndef UPM_WITHOUT_USER_PLANE
+  /* Terminate Uplink and Downlink state machines. */
+  upm_uplink_data_control(ptr_context_data, UPM_I_UPLINK_DATA_LINK_DOWN, NULL);
+  upm_downlink_data_control(ptr_context_data, UPM_I_DOWNLINK_DATA_LINK_DOWN, NULL);
+#endif /* UPM_WITHOUT_USER_PLANE */
+
+  /* SNDCP Control constructs a deactivate primitive for SNDCP */
+  upm_sndcp_control(ptr_context_data, UPM_I_SNDCP_RELEASE_LLC_LINK, data);
+}
+#endif /* TI_GPRS */
+
+/*
++------------------------------------------------------------------------------
+| Function    : handle_deactivate_without_link_in_gsm
++------------------------------------------------------------------------------
+| Description : Handle SM_DEACTIVATE_IND in GSM, when no link exists (S5)
+|
+| Parameters  : ptr_context_data - Context data
+|               data             - Not used
++------------------------------------------------------------------------------
+*/
+#ifdef TI_GPRS
+static void handle_deactivate_without_link_in_gsm(struct T_CONTEXT_DATA *ptr_context_data, /*@unused@*/ /*@null@*/ void *data)
+{
+  (void)TRACE_FUNCTION("UPM Link Control: handle_deactivate_without_link_in_gsm");
+
+  /* SM_DEACTIVATE_RES sent in dispatcher. One primitive for all NSAPIs. */
+  /* send_sm_deactivate_res( ... ); */
+  upm_link_mark_nsapi_deactivated(ptr_context_data->nsapi);
+
+  /* Go to state UPM LINK RELEASED */
+  link_control_goto_state(ptr_context_data, UPM_LINK_RELEASED);
+}
+#endif /* TI_GPRS */
+
+/*
++------------------------------------------------------------------------------
+| Function    : handle_llc_release_normal
++------------------------------------------------------------------------------
+| Description : Handle UPM_I_SNDCP_LLC_LINK_RELEASED in S10
+|
+| Parameters  : ptr_context_data - Context data
+|               data             - Not used
++------------------------------------------------------------------------------
+*/
+#ifdef TI_GPRS
+static void handle_llc_release_normal(struct T_CONTEXT_DATA *ptr_context_data, /*@unused@*/ /*@null@*/ void *data)
+{
+  (void)TRACE_FUNCTION("UPM Link Control: handle_llc_release_normal");
+
+  /* SM_DEACTIVATE_RES sent in dispatcher. One primitive for all NSAPIs. */
+  /* send_sm_deactivate_res( ... ); */
+  upm_link_mark_nsapi_deactivated(ptr_context_data->nsapi);
+
+  /* Go to state UPM LINK RELEASED */
+  link_control_goto_state(ptr_context_data, UPM_LINK_RELEASED);
+}
+#endif /* TI_GPRS */
+
+/*
++------------------------------------------------------------------------------
+| Function    : handle_llc_release_abnormal
++------------------------------------------------------------------------------
+| Description : Handle UPM_I_SNDCP_LLC_LINK_RELEASED in state other than S10
+|
+| Parameters  : ptr_context_data - Context data
+|               data             - SN_STATUS_IND primitive (unused)
++------------------------------------------------------------------------------
+*/
+#ifdef TI_GPRS
+static void handle_llc_release_abnormal(struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ /*@unused@*/ void *data)
+{
+  (void)TRACE_FUNCTION("UPM Link Control: handle_llc_release_abnormal");
+
+  /* SM_STATUS_REQ sent once for all affected NSAPIs in sndcp_control. */
+  /* send_sm_status_req(...) */
+
+  /* Go to state UPM LINK RELEASED */
+  link_control_goto_state(ptr_context_data, UPM_LINK_RELEASED);
+
+#ifndef UPM_WITHOUT_USER_PLANE
+  /* Terminate Uplink and Downlink state machines. */
+  upm_uplink_data_control(ptr_context_data, UPM_I_UPLINK_DATA_LINK_DOWN, NULL);
+  upm_downlink_data_control(ptr_context_data, UPM_I_DOWNLINK_DATA_LINK_DOWN, NULL);
+#endif /* UPM_WITHOUT_USER_PLANE */
+}
+#endif /* TI_GPRS */
+
+/*
++------------------------------------------------------------------------------
+| Function    : handle_rat_change_to_gsm_without_context
++------------------------------------------------------------------------------
+| Description : Handle UPM_I_LINK_RAT_CHANGED(GSM) in S1 or S2
+|
+| Parameters  : ptr_context_data - Context Data
+|               data             - GSM/UMTS
++------------------------------------------------------------------------------
+*/
+#ifdef TI_DUAL_MODE
+static void handle_rat_change_to_gsm_without_context(struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ void *data)
+{
+  (void)TRACE_FUNCTION("UPM Link Control: handle_rat_change_to_gsm_without_context");
+  TRACE_ASSERT( (T_PS_rat)data == PS_RAT_GSM );
+
+  /* Go to state UPM LINK AWAITING ACTIVATE GSM */
+  link_control_goto_state(ptr_context_data, UPM_LINK_AWAITING_ACTIVATE_GSM);
+
+  /* Order RAB Control to await RAB release,
+   * or to stop awaiting RAB establish */
+  upm_rab_control(ptr_context_data, UPM_I_RAB_AWAIT_RAB_RELEASE, NULL);
+}
+#endif /* TI_DUAL_MODE */
+
+/*
++------------------------------------------------------------------------------
+| Function    : handle_rat_change_to_gsm
++------------------------------------------------------------------------------
+| Description : Handle UPM_I_LINK_RAT_CHANGED(GSM) in S3
+|
+| Parameters  : ptr_context_data - Context data
+|               data             - GSM/UMTS
++------------------------------------------------------------------------------
+*/
+#ifdef TI_DUAL_MODE
+static void handle_rat_change_to_gsm(struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ void *data)
+{
+  (void)TRACE_FUNCTION("UPM Link Control: handle_rat_change_to_gsm");
+
+  TRACE_ASSERT( (T_PS_rat)data == PS_RAT_GSM );
+
+  /* Go to state UPM LINK COMPLETING RAT CHANGE TO GSM */
+  link_control_goto_state(ptr_context_data, UPM_LINK_COMPLETING_RAT_CHANGE_TO_GSM);
+
+  /* Order RAB Control to await RAB release */
+  upm_rab_control(ptr_context_data, UPM_I_RAB_AWAIT_RAB_RELEASE, NULL);
+
+  /* Order SNDCP Control to await LLC link establishment */
+  upm_sndcp_control(ptr_context_data, UPM_I_SNDCP_AWAIT_ESTABLISH, NULL);
+}
+#endif /* TI_DUAL_MODE */
+
+/*
++------------------------------------------------------------------------------
+| Function    : handle_rab_established_in_S6
++------------------------------------------------------------------------------
+| Description : Handle UPM_I_RAB_ESTABLISHED in S7
+|
+| Parameters  : ptr_context_data - Context data
+|               data             - Not used
++------------------------------------------------------------------------------
+*/
+#ifdef TI_DUAL_MODE
+static void handle_rab_established_in_S6(struct T_CONTEXT_DATA *ptr_context_data, /*@unused@*/ /*@null@*/ void *data)
+{
+  (void)TRACE_FUNCTION("UPM Link Control: handle_rab_established_in_S6");
+
+  /* Go to state UPM LINK RAB ESTABLISHED */
+  link_control_goto_state(ptr_context_data, UPM_LINK_RAB_ESTABLISHED);
+
+  /* Send SM_ACTIVATE_RES */
+  send_sm_activate_res(ptr_context_data, ((T_SN_ACTIVATE_CNF*)data));
+
+  /* Inform Uplink and Downlink state machines. */
+  upm_uplink_data_control(ptr_context_data, UPM_I_UPLINK_DATA_LINK_UP, NULL);
+  upm_downlink_data_control(ptr_context_data, UPM_I_DOWNLINK_DATA_LINK_UP, NULL);
+}
+#endif /* TI_DUAL_MODE */
+
+/*
++------------------------------------------------------------------------------
+| Function    : handle_rat_change_to_umts_without_context
++------------------------------------------------------------------------------
+| Description : Handle UPM_I_LINK_RAT_CHANGED(UMTS) in S7
+|
+| Parameters  : ptr_context_data - Context data
+|               data             - GSM/UMTS
++------------------------------------------------------------------------------
+*/
+#ifdef TI_DUAL_MODE
+static void handle_rat_change_to_umts_without_context(struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ void *data)
+{
+  (void)TRACE_FUNCTION("UPM Link Control: handle_rat_change_to_umts_without_context");
+
+  TRACE_ASSERT( (T_PS_rat)data == PS_RAT_UMTS_FDD );
+
+  /* Go to state UPM LINK ESTABLISHING RAB */
+  link_control_goto_state(ptr_context_data, UPM_LINK_ESTABLISHING_RAB);
+
+  /* Order RAB Control to await RAB establishment */
+  upm_rab_control(ptr_context_data, UPM_I_RAB_AWAIT_INITIAL_ESTABLISH, NULL);
+}
+#endif /* TI_DUAL_MODE */
+
+/*
++------------------------------------------------------------------------------
+| Function    : handle_rat_change_to_umts_without_context
++------------------------------------------------------------------------------
+| Description : Handle UPM_I_LINK_RAT_CHANGED(UMTS) in S8
+|
+| Parameters  : ptr_context_data - Context data
+|               data             - GSM/UMTS
++------------------------------------------------------------------------------
+*/
+#ifdef TI_DUAL_MODE
+static void handle_rat_change_to_umts_while_establishing(struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ void *data)
+{
+  (void)TRACE_FUNCTION("UPM Link Control: handle_rat_change_to_umts_while_establishing");
+
+  TRACE_ASSERT( (T_PS_rat)data == PS_RAT_UMTS_FDD );
+
+  /* Go to state UPM LINK COMPLETING RAT CHANGE TO UMTS INITIAL */
+  link_control_goto_state(ptr_context_data, UPM_LINK_COMPLETING_RAT_CHANGE_TO_UMTS_INITIAL);
+
+  /* Order RAB Control to await RAB establishment */
+  upm_rab_control(ptr_context_data, UPM_I_RAB_AWAIT_INITIAL_ESTABLISH, NULL);
+}
+#endif /* TI_DUAL_MODE */
+
+/*
++------------------------------------------------------------------------------
+| Function    : handle_rat_change_to_umts
++------------------------------------------------------------------------------
+| Description : Handle UPM_I_LINK_RAT_CHANGED(UMTS) in S9
+|
+| Parameters  : ptr_context_data - Context data
+|               data             - GSM/UMTS
++------------------------------------------------------------------------------
+*/
+#ifdef TI_DUAL_MODE
+static void handle_rat_change_to_umts(struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ void *data)
+{
+  (void)TRACE_FUNCTION("UPM Link Control: handle_rat_change_to_umts");
+
+  TRACE_ASSERT( (T_PS_rat)data == PS_RAT_UMTS_FDD );
+
+  /* Go to state UPM LINK RAB ESTABLISHED*/
+  link_control_goto_state(ptr_context_data, UPM_LINK_RAB_ESTABLISHED);
+
+  /* Order RAB Control to await RAB establishment */
+  upm_rab_control(ptr_context_data, UPM_I_RAB_AWAIT_RAB_ESTABLISH, NULL);
+}
+#endif /* TI_DUAL_MODE */
+
+/*
++------------------------------------------------------------------------------
+| Function    : handle_gsm_qos_store
++------------------------------------------------------------------------------
+| Description : Store GSM-RAT relevant QoS parameters for the NSAPI
+|
+| Parameters  : ptr_context_data - Context data
+|               qos              - R99 format QoS data
++------------------------------------------------------------------------------
+*/
+#ifdef TI_GPRS
+static void handle_gsm_qos_store(struct T_CONTEXT_DATA *ptr_context_data,
+                                 U8 sapi, U8 radio_prio, U8 pkt_flow_id,
+                                 T_PS_ctrl_qos ctrl_qos, T_PS_qos *qos)
+{
+  struct T_UPM_CONTEXT_DATA_GPRS *gprs_data = &ptr_context_data->gprs_data;
+
+  (void)TRACE_FUNCTION("UPM Link Control: handle_gsm_qos_store");
+
+  gprs_data->sndcp_llc_sapi   = sapi;
+  gprs_data->sndcp_radio_prio = radio_prio;
+
+  /* [3G 24.008] version 6 says to keep PFI if omitted. */
+  if (pkt_flow_id != (U8)PS_PKT_FLOW_ID_NOT_PRES) {
+    gprs_data->pkt_flow_id      = pkt_flow_id;
+  }
+
+  if (ctrl_qos == PS_is_R97)
+  {
+    gprs_data->sndcp_delay        = qos->qos_r97.delay;
+    gprs_data->sndcp_relclass     = qos->qos_r97.relclass;
+    gprs_data->sndcp_peak_bitrate = qos->qos_r97.peak;
+    gprs_data->sndcp_preced       = qos->qos_r97.preced;
+    gprs_data->sndcp_mean         = qos->qos_r97.mean;
+  } else if (ctrl_qos == PS_is_R99) {
+    T_PS_qos_r97 temp_qos_r97;
+
+    cl_qos_convert_r99_to_r97(&qos->qos_r99, &temp_qos_r97);
+
+    gprs_data->sndcp_delay        = temp_qos_r97.delay;
+    gprs_data->sndcp_relclass     = temp_qos_r97.relclass;
+    gprs_data->sndcp_peak_bitrate = temp_qos_r97.peak;
+    gprs_data->sndcp_preced       = temp_qos_r97.preced;
+    gprs_data->sndcp_mean         = temp_qos_r97.mean;
+  } else {
+    (void)TRACE_ERROR("Link Control (handle_gsm_qos_store): Invalid QoS union controller!");
+  }
+}
+#endif /* TI_GPRS */
+/*
++------------------------------------------------------------------------------
+| Function    : upm_link_mark_nsapi_deactivated
++------------------------------------------------------------------------------
+| Description : Helper function to group nsapis in SM_DEACTIVATE_RES
+|
+| Parameters  : nsapi            - NSAPI        
++------------------------------------------------------------------------------
+*/
+static U16 nsapis_to_deactivate = 0, nsapis_currently_deactivated = 0;
+
+static void upm_link_mark_nsapi_deactivated(U8 nsapi)
+{
+  (void)TRACE_FUNCTION("UPM Link Control: upm_link_mark_nsapi_deactivated");
+
+  nsapis_currently_deactivated |= upm_nsapi2nsapi_set(nsapi);
+
+  if (nsapis_currently_deactivated == nsapis_to_deactivate)
+  {
+    send_sm_deactivate_res(nsapis_to_deactivate);
+    /* All context requested deactivated have been deactivated */
+    /* Zero out store */
+    nsapis_to_deactivate = 0;
+    nsapis_currently_deactivated = 0;
+  }
+}
+
+/*==== PUBLIC FUNCTIONS =====================================================*/
+
+/*
++------------------------------------------------------------------------------
+| Function    : upm_is_link_released
++------------------------------------------------------------------------------
+| Description : Link Control state query function. Return TRUE if Link Control
+|               is in state UPM LINK RELEASED; returns FALSE otherwise.
+|
+| Parameters  : ptr_context_data - Pointer to context data
++------------------------------------------------------------------------------
+*/
+BOOL upm_is_link_released(struct T_CONTEXT_DATA *ptr_context_data)
+{
+  TRACE_ASSERT(ptr_context_data != NULL);
+
+  if (link_control_state(ptr_context_data) == UPM_LINK_RELEASED)
+  {
+    (void)TRACE_FUNCTION("UPM Link Control: upm_is_link_released (TRUE)");
+    return TRUE;
+  } else {
+    (void)TRACE_FUNCTION("UPM Link Control: upm_is_link_released (FALSE)");
+    return FALSE;
+  }
+}
+
+/*
++------------------------------------------------------------------------------
+| Function    : upm_link_dispatch_sm_deactivate_ind
++------------------------------------------------------------------------------
+| Description : Dispatch SM_DEACTIVATE_IND
+|
+| Parameters  : sm_deactivate_ind          - received primitive
++------------------------------------------------------------------------------
+*/
+void upm_link_dispatch_sm_deactivate_ind(T_SM_DEACTIVATE_IND *sm_deactivate_ind)
+{
+  int                    nsapi;
+  struct T_CONTEXT_DATA *ptr_context_data;
+
+  (void)TRACE_FUNCTION("UPM Link Control: upm_link_dispatch_sm_deactivate_ind");
+
+  /* Add NSAPI to nsapi_set to deactivate */
+  nsapis_to_deactivate         |= sm_deactivate_ind->nsapi_set;
+
+  for (nsapi = (int)NAS_NSAPI_5; nsapi < NAS_SIZE_NSAPI; nsapi++)
+  {
+    if ( (sm_deactivate_ind->nsapi_set & upm_nsapi2nsapi_set(nsapi)) != 0)
+    {
+      ptr_context_data = upm_get_context_data_from_nsapi(nsapi);
+      if (ptr_context_data != NULL)
+      {
+        if (upm_is_link_released(ptr_context_data))
+        {
+          nsapis_currently_deactivated |= upm_nsapi2nsapi_set(nsapi);
+        } else {
+          upm_link_control(ptr_context_data, UPM_P_SM_DEACTIVATE_IND,
+                           (void *)sm_deactivate_ind->rel_ind);
+        }
+
+        upm_check_for_released_context_and_release(ptr_context_data);
+      } else {
+        (void)TRACE_ERROR("Tried to deactivate non-existent context!");
+      }
+    }
+  } /* for */
+}
+
+/*
++------------------------------------------------------------------------------
+| Function    : upm_link_control_init
++------------------------------------------------------------------------------
+| Description : Link Control state machine initialization function
+|
+| Parameters  : ptr_context_data - Pointer to context data
++------------------------------------------------------------------------------
+*/
+void upm_link_control_init(struct T_CONTEXT_DATA *ptr_context_data)
+{
+  (void)TRACE_FUNCTION("UPM Link Control: upm_link_control_init");
+
+  TRACE_ASSERT(ptr_context_data != NULL);
+
+  link_control_goto_state(ptr_context_data, UPM_LINK_RELEASED);
+
+  /* Zero out store for deactivation synchronization */
+  nsapis_to_deactivate                 = 0;
+  nsapis_currently_deactivated         = 0;
+}
+
+/*
++------------------------------------------------------------------------------
+| Function    : upm_link_control_exit
++------------------------------------------------------------------------------
+| Description : Link Control state machine exit function
+|
+| Parameters  : ptr_context_data - Pointer to context data
++------------------------------------------------------------------------------
+*/
+void upm_link_control_exit(struct T_CONTEXT_DATA *ptr_context_data)
+{
+  (void)TRACE_FUNCTION("UPM Link Control: upm_link_control_exit");
+
+  TRACE_ASSERT(ptr_context_data != NULL);
+
+  link_control_goto_state(ptr_context_data, UPM_LINK_RELEASED);
+}
+
+/*
++------------------------------------------------------------------------------
+| Function    : upm_link_control
++------------------------------------------------------------------------------
+| Description : Link Control state machine
+|
+| Parameters  : ptr_context_data - Pointer to context data
+|               event            - Internal event (see upm_link_control.h)
+|               data             - Event dependent parameter
++------------------------------------------------------------------------------
+*/
+void upm_link_control (struct T_CONTEXT_DATA *ptr_context_data,
+                      T_UPM_LINK_CONTROL_EVENT event,
+                      /*@null@*/ void *data)
+{
+#ifdef DEBUG
+  T_UPM_LINK_CONTROL_STATE old_state;
+  /*@observer@*/ /*@notnull@*/
+  static const char *state_name[UPM_LINK_CONTROL_NUMBER_OF_STATES] = {
+    "S0_UPM_LINK_RELEASED",
+#ifdef TI_UMTS
+    "S1_UPM_LINK_ESTABLISHING_RAB",
+    "S2_UPM_LINK_AWAITING_ACTIVATE_UMTS",
+    "S3_UPM_LINK_RAB_ESTABLISHED",
+    "S4_UPM_LINK_RELEASING_RAB",
+#endif /* TI_UMTS */
+#ifdef TI_DUAL_MODE
+    "S5_UPM_LINK_COMPLETING_RAT_CHANGE_TO_GSM",
+    "S6_UPM_LINK_COMPLETING_RAT_CHANGE_TO_UMTS_INITIAL",
+#endif /* TI_DUAL_MODE */
+#ifdef TI_GPRS
+    "S7_UPM_LINK_AWAITING_ACTIVATE_GSM",
+    "S8_UPM_LINK_ESTABLISHING_LLC_LINK",
+    "S9_UPM_LINK_LLC_LINK_ESTABLISHED",
+    "S10_UPM_LINK_RELEASING_LLC_LINK"
+#endif /* TI_GPRS */
+  };
+  /*@observer@*/ /*@notnull@*/
+  static const char *event_name[UPM_LINK_CONTROL_NUMBER_OF_EVENTS] = {
+    "UPM_P_SM_ACTIVATE_STARTED_IND",
+    "UPM_P_SM_ACTIVATE_IND",
+    "UPM_P_SM_DEACTIVATE_IND",
+    "UPM_P_SM_MODIFY_IND",
+    "UPM_I_LINK_DTI_CLOSED",
+    "UPM_I_RAB_ESTABLISHED",
+    "UPM_I_RAB_RELEASED",
+    "UPM_I_SNDCP_LLC_LINK_ESTABLISHED",
+    "UPM_I_SNDCP_LLC_LINK_MODIFIED",
+    "UPM_I_SNDCP_LLC_LINK_RELEASED",
+    "UPM_I_LINK_RAT_CHANGED"
+  };
+
+  TRACE_ASSERT(ptr_context_data != NULL);
+  TRACE_ASSERT(event < UPM_LINK_CONTROL_NUMBER_OF_EVENTS);
+
+  old_state = link_control_state(ptr_context_data);
+  TRACE_ASSERT(old_state < UPM_LINK_CONTROL_NUMBER_OF_STATES);
+
+  if (transition[(U16)old_state][(U16)event].event != event)
+  {
+    (void)TRACE_ERROR("Event table error in upm_link_control!");
+  }
+#endif /* DEBUG */
+
+  transition[(U16)link_control_state(ptr_context_data)][(U16)event].func(ptr_context_data, data);
+
+#ifdef DEBUG
+  (void)TRACE_EVENT_P4("LINK  #%d: %s => %s to %s",
+                       ptr_context_data->nsapi,
+                       event_name[(U16)event],
+                       state_name[(U16)old_state],
+                       state_name[(U16)link_control_state(ptr_context_data)]);
+#endif /* DEBUG */
+}
+
+/*==== END OF FILE ==========================================================*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/g23m-gprs/upm/upm_link_control.h	Fri Oct 14 01:21:46 2016 +0000
@@ -0,0 +1,90 @@
+/*----------------------------------------------------------------------------
+|  Project :  3G PS
+|  Module  :  UPM
++-----------------------------------------------------------------------------
+|             Copyright 2003 Texas Instruments.
+|             All rights reserved. 
+| 
+|             This file is confidential and a trade secret of Texas 
+|             Instruments .
+|             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. 
++-----------------------------------------------------------------------------
+| Purpose:    Link Control state machine definitions in the UPM entity.
+|             For design details, see:
+|             8010.939 UPM Detailed Specification
++---------------------------------------------------------------------------*/
+
+/*==== DECLARATION CONTROL =================================================*/
+
+#ifndef _UPM_LINK_CONTROL_H
+#define _UPM_LINK_CONTROL_H
+
+/*==== INCLUDES =============================================================*/
+
+/*==== CONSTS ===============================================================*/
+
+/*==== TYPES ================================================================*/
+
+typedef enum
+{
+  /* Incoming primitives */
+  UPM_P_SM_ACTIVATE_STARTED_IND,
+  UPM_P_SM_ACTIVATE_IND,
+  UPM_P_SM_DEACTIVATE_IND,
+  UPM_P_SM_MODIFY_IND,
+  /* Events from DTI Control */
+  UPM_I_LINK_DTI_CLOSED,
+  /* Events from RAB Control */
+  UPM_I_RAB_ESTABLISHED,
+  UPM_I_RAB_RELEASED,
+  /* Events from SNDCP Control */
+  UPM_I_SNDCP_LLC_LINK_ESTABLISHED,
+  UPM_I_SNDCP_LLC_LINK_MODIFIED,
+  UPM_I_SNDCP_LLC_LINK_RELEASED,
+  /* Events from RAT Change Control */
+  UPM_I_LINK_RAT_CHANGED,
+  /* Number of events */
+  UPM_LINK_CONTROL_NUMBER_OF_EVENTS
+} T_UPM_LINK_CONTROL_EVENT;
+
+typedef enum
+{
+  UPM_LINK_RELEASED,
+#ifdef TI_UMTS
+  UPM_LINK_ESTABLISHING_RAB,
+  UPM_LINK_AWAITING_ACTIVATE_UMTS,
+  UPM_LINK_RAB_ESTABLISHED,
+  UPM_LINK_RELEASING_RAB,
+#endif /* TI_UMTS */
+#ifdef TI_DUAL_MODE
+  UPM_LINK_COMPLETING_RAT_CHANGE_TO_GSM,
+  UPM_LINK_COMPLETING_RAT_CHANGE_TO_UMTS_INITIAL,
+#endif /* TI_DUAL_MODE */
+#ifdef TI_GPRS
+  UPM_LINK_AWAITING_ACTIVATE_GSM,
+  UPM_LINK_ESTABLISHING_LLC_LINK,
+  UPM_LINK_LLC_LINK_ESTABLISHED,
+  UPM_LINK_RELEASING_LLC_LINK,
+#endif /* TI_GPRS */
+  UPM_LINK_CONTROL_NUMBER_OF_STATES
+} T_UPM_LINK_CONTROL_STATE;
+
+/*==== EXPORTS ==============================================================*/
+extern void upm_link_control_init(struct T_CONTEXT_DATA *ptr_context_data);
+
+extern void upm_link_control_exit(struct T_CONTEXT_DATA *ptr_context_data);
+
+extern void upm_link_control(struct T_CONTEXT_DATA *ptr_context_data,
+			     T_UPM_LINK_CONTROL_EVENT event,
+			     /*@null@*/ void *data);
+
+extern BOOL upm_is_link_released(struct T_CONTEXT_DATA *ptr_context_data);
+
+extern void upm_link_dispatch_sm_deactivate_ind(T_SM_DEACTIVATE_IND *);
+
+#endif /* _UPM_LINK_CONTROL_H */
+/*==== END OF FILE ==========================================================*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/g23m-gprs/upm/upm_mm_output_handler.c	Fri Oct 14 01:21:46 2016 +0000
@@ -0,0 +1,112 @@
+/*----------------------------------------------------------------------------
+|  Project :  3G PS
+|  Module  :  UPM
++-----------------------------------------------------------------------------
+|             Copyright 2003 Texas Instruments.
+|             All rights reserved. 
+| 
+|             This file is confidential and a trade secret of Texas 
+|             Instruments .
+|             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. 
++-----------------------------------------------------------------------------
+| Purpose:    Output functions for primitives from UPM to the MM entity.
+|             For design details, see:
+|             8010.939 UPM Detailed Specification
++---------------------------------------------------------------------------*/
+
+/*==== DECLARATION CONTROL =================================================*/
+
+/*==== INCLUDES ============================================================*/
+
+#include "upm.h"
+
+#include "upm_mm_output_handler.h"
+
+/*==== CONSTS ===============================================================*/
+
+/*==== TYPES ================================================================*/
+
+/*==== LOCALS ===============================================================*/
+
+/*==== PUBLIC FUNCTIONS =====================================================*/
+
+/*
++------------------------------------------------------------------------------
+| Function    : send_mmpm_reestablish_req
++------------------------------------------------------------------------------
+| Description : Allocate, pack and send MMPM_REESTABLISH_RES primitive.
+|
+| Parameters  : None
++------------------------------------------------------------------------------
+*/
+#ifdef TI_UMTS
+void send_mmpm_reestablish_req(U8 most_demanding)
+{
+  U8  establish_cause;
+  (void)TRACE_FUNCTION("send_mmpm_reestablish_req");
+
+  switch ((T_PS_tc)most_demanding) {
+  case PS_TC_CONV:
+    establish_cause = (U8)MMPM_CAUSE_ESTABL_ORIG_CONVERSATIONAL;
+    break;
+  case PS_TC_STREAM:
+    establish_cause = (U8)MMPM_CAUSE_ESTABL_ORIG_STREAMING;
+    break;
+  case PS_TC_INTER:
+    establish_cause = (U8)MMPM_CAUSE_ESTABL_ORIG_INTERACTIVE;
+    break;
+  case PS_TC_BG:
+    establish_cause = (U8)MMPM_CAUSE_ESTABL_ORIG_BACKGROUND;
+    break;
+  case PS_TC_SUB:
+    establish_cause = (U8)MMPM_CAUSE_ESTABL_ORIG_BACKGROUND;
+    break;
+  }
+
+  {
+    PALLOC(prim, MMPM_REESTABLISH_REQ);
+
+    prim->establish_cause = establish_cause;
+
+    (void)PSEND(hCommMM, prim);
+  }
+}
+#endif /* TI_UMTS */
+
+/*
++------------------------------------------------------------------------------
+| Function    : send_mmpm_sequence_res
++------------------------------------------------------------------------------
+| Description : Allocate, pack and send MMPM_SEQUENCE_RES primitive.
+|
+| Parameters  : sn_sequence_cnf   - SN_SEQUENCE_CNF primitive
++------------------------------------------------------------------------------
+*/
+#ifdef TI_GPRS
+void send_mmpm_sequence_res(T_SN_SEQUENCE_CNF *sn_sequence_cnf)
+{
+  U16  index;
+  (void)TRACE_FUNCTION("send_mmpm_sequence_res");
+  {
+    PALLOC(prim, MMPM_SEQUENCE_RES);
+
+  /*lint -e613 (Possible use of null pointer 'prim' in left argument to operator '->') */
+    prim->c_npdu_list = sn_sequence_cnf->c_receive_no_list;
+
+    memcpy(&prim->npdu_list, sn_sequence_cnf->receive_no_list,
+	   (size_t)sn_sequence_cnf->c_receive_no_list * sizeof(T_MMPM_npdu_list));
+    for (index = 0; index < (U16)sn_sequence_cnf->c_receive_no_list; index++)
+    {
+      prim->npdu_list[index].nsapi                    = sn_sequence_cnf->receive_no_list[index].nsapi;
+      prim->npdu_list[index].receive_n_pdu_number_val = sn_sequence_cnf->receive_no_list[index].receive_no;
+    }
+  /*lint +e613 (Possible use of null pointer 'prim' in left argument to operator '->') */
+   (void)PSEND(hCommMM, prim);
+  }
+}
+#endif /* TI_GPRS */
+/*==== END OF FILE ==========================================================*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/g23m-gprs/upm/upm_mm_output_handler.h	Fri Oct 14 01:21:46 2016 +0000
@@ -0,0 +1,46 @@
+/*----------------------------------------------------------------------------
+|  Project :  3G PS
+|  Module  :  UPM
++-----------------------------------------------------------------------------
+|             Copyright 2003 Texas Instruments.
+|             All rights reserved. 
+| 
+|             This file is confidential and a trade secret of Texas 
+|             Instruments .
+|             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. 
++-----------------------------------------------------------------------------
+| Purpose:    Output functions for primitives from UPM to the MM entity.
+|             For design details, see:
+|             8010.939 UPM Detailed Specification
++---------------------------------------------------------------------------*/
+
+/*==== DECLARATION CONTROL =================================================*/
+
+#ifndef UPM_MM_OUTPUT_HANDLER_H
+#define UPM_MM_OUTPUT_HANDLER_H
+
+/*==== INCLUDES =============================================================*/
+#include "typedefs.h"
+
+#include "upm.h"
+
+/*==== CONSTS ===============================================================*/
+
+/*==== TYPES ================================================================*/
+
+/*==== EXPORTS ==============================================================*/
+
+#ifdef TI_UMTS
+extern void send_mmpm_reestablish_req(U8 most_demanding);
+#endif /* TI_UMTS */
+
+#ifdef TI_GPRS
+extern void send_mmpm_sequence_res(T_SN_SEQUENCE_CNF *);
+#endif /* TI_GPRS */
+
+#endif /* UPM_MM_OUTPUT_HANDLER_H */
+/*==== END OF FILE ==========================================================*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/g23m-gprs/upm/upm_pei.c	Fri Oct 14 01:21:46 2016 +0000
@@ -0,0 +1,727 @@
+/*----------------------------------------------------------------------------
+|  Project :  3G PS
+|  Module  :  UPM
++-----------------------------------------------------------------------------
+|             Copyright 2003 Texas Instruments.
+|             All rights reserved. 
+| 
+|             This file is confidential and a trade secret of Texas 
+|             Instruments .
+|             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. 
++-----------------------------------------------------------------------------
+| Purpose:    This module implements the process body interface
+|             for the User Plane Manager (UPM) entity.
+|             For design details, see:
+|             8010.939 UPM Detailed Specification
++---------------------------------------------------------------------------*/
+
+/*==== DECLARATION CONTROL =================================================*/
+
+#ifndef UPM_PEI_C
+#define UPM_PEI_C
+#endif
+
+/*==== INCLUDES =============================================================*/
+
+#include "upm.h"
+
+#include <pei.h>
+#include <custom.h>
+
+#include "upm_dispatcher.h"
+
+#include "mon_upm.h"
+
+/*==== CONSTS ===============================================================*/
+
+/*==== TYPES ================================================================*/
+
+/*==== LOCALS ===============================================================*/
+
+static T_MONITOR upm_mon;
+static BOOL first_access = TRUE;
+
+/*==== PRIVATE FUNCTIONS ====================================================*/
+
+/*
++------------------------------------------------------------------------------
+| Function              : pei_primitive
++------------------------------------------------------------------------------
+| Description   :  This function is called by the frame when a primitive is
+|                  received and needs to be processed.
+|
+|                                 |
+|                                 |                                 UPPER LAYER
+|                                 v
+|  +---------------------------(DTI SAP)--------------------------+
+|  |                                                              |
+|  |                             UPM                              |
+|  |                                                              |
+|  +-^---------^---------^---------^--------^---------^---------^-+
+|    |         |         |         |        |         |         |
+|    |         |         |         |        |         |         |   LOWER LAYER
+| (SM SAP) (MMPM SAP) (RR SAP) (RRC SAP) (SN SAP) (PDCP SAP) (MEM SAP)
+|
+| Parameters  : prim      - Pointer to the received primitive
+|
+| Return      : PEI_OK    - function succeeded
+|               PEI_ERROR - function failed
++------------------------------------------------------------------------------
+*/
+static short pei_primitive (void *primitive)
+     /*@globals upm_data@*/
+{
+  (void)TRACE_FUNCTION("UPM pei_primitive");
+
+  if (primitive != NULL)
+  {
+    T_PRIM_HEADER *prim;
+    U32 opc;
+
+    opc = P_OPC(primitive);
+
+/*@i1@*/(void)PTRACE_IN (opc);
+
+    prim = (T_PRIM_HEADER *)&((T_PRIM *)primitive)->data;
+
+    /* Memory supervision ? */
+    VSI_PPM_RCV (primitive);
+
+    switch (opc)
+    {
+#ifndef UPM_WITHOUT_USER_PLANE
+      /* DTI SAP */
+#ifdef DTI2
+      case DTI2_CONNECT_REQ:
+        upm_disp_dti_connect_req((T_DTI2_CONNECT_REQ *)(prim));
+        /* PFREE is called in the DTILIB */
+        break;
+
+      case DTI2_CONNECT_CNF:
+        upm_disp_dti_connect_cnf ((T_DTI2_CONNECT_CNF *)(prim));
+        /* PFREE is called in the DTILIB */
+        break;
+
+      case DTI2_CONNECT_IND:
+        upm_disp_dti_connect_ind ((T_DTI2_CONNECT_IND *)(prim));
+        /* PFREE is called in the DTILIB */
+        break;
+
+      case DTI2_CONNECT_RES:
+        upm_disp_dti_connect_res((T_DTI2_CONNECT_RES *)(prim));
+        /* PFREE is called in the DTILIB */
+        break;
+
+      case DTI2_DISCONNECT_IND:
+        upm_disp_dti_disconnect_ind((T_DTI2_DISCONNECT_IND *)(prim));
+        /* PFREE is called in the DTILIB */
+        break;
+
+      case DTI2_DISCONNECT_REQ:
+        upm_disp_dti_disconnect_req((T_DTI2_DISCONNECT_REQ *)(prim));
+        /* PFREE is called in the DTILIB */
+        break;
+#endif /* DTI2 */
+
+      case DTI2_GETDATA_REQ:
+        upm_disp_dti_getdata_req((T_DTI2_GETDATA_REQ *)(prim));
+        /* PFREE is called in the DTILIB */
+        break;
+
+      case DTI2_READY_IND:
+        upm_disp_dti_ready_ind ((T_DTI2_READY_IND *)(prim));
+        /* PFREE is called in the DTILIB */
+        break;
+
+      case DTI2_DATA_REQ:
+        upm_disp_dti_data_req((T_DTI2_DATA_REQ *)(prim));
+        /* PFREE is called in the upm_sig_callback function in upm_dti_handler.c */
+        break;
+
+      case DTI2_DATA_IND:
+        upm_disp_dti_data_ind ((T_DTI2_DATA_IND *)(prim));
+        /* PFREE is called in the upm_sig_callback function in upm_dti_handler.c */
+        break;
+
+#ifdef DEBUG
+      case DTI2_DATA_TEST_REQ:
+        upm_disp_dti_data_test_req((T_DTI2_DATA_TEST_REQ *)(prim));
+        /* PFREE is called in the DTILIB */
+        break;
+      case DTI2_DATA_TEST_IND:
+        upm_disp_dti_data_test_ind((T_DTI2_DATA_TEST_IND *)(prim));
+        /* PFREE is called in the DTILIB */
+        break;
+#endif /* DEBUG */
+
+#endif /* UPM_WITHOUT_USER_PLANE */
+
+      /* SM SAP */
+      case SM_ACTIVATE_STARTED_IND:
+        upm_disp_sm_activate_started_ind((T_SM_ACTIVATE_STARTED_IND *)(prim));
+        PFREE(prim);
+        break;
+
+      case SM_ACTIVATE_IND:
+        upm_disp_sm_activate_ind((T_SM_ACTIVATE_IND *)(prim));
+        PFREE(prim);
+        break;
+
+      case SM_DEACTIVATE_IND:
+        upm_link_dispatch_sm_deactivate_ind((T_SM_DEACTIVATE_IND *)(prim));
+        PFREE(prim);
+        break;
+
+      case SM_MODIFY_IND:
+        upm_disp_sm_modify_ind((T_SM_MODIFY_IND *)(prim));
+        PFREE(prim);
+        break;
+
+#ifndef UPM_WITHOUT_USER_PLANE
+      /* MMPM SAP */
+      case MMPM_SUSPEND_IND:
+        upm_disp_mmpm_suspend_ind((T_MMPM_SUSPEND_IND *)(prim));
+        PFREE(prim);
+        break;
+
+      case MMPM_RESUME_IND:
+        upm_disp_mmpm_resume_ind((T_MMPM_RESUME_IND *)(prim));
+        PFREE(prim);
+        break;
+#endif /* UPM_WITHOUT_USER_PLANE */
+
+#ifdef TI_UMTS
+      case MMPM_REESTABLISH_CNF:
+        upm_disp_mmpm_reestablish_cnf((T_MMPM_REESTABLISH_CNF *)(prim));
+        PFREE(prim);
+        break;
+
+      case MMPM_REESTABLISH_REJ:
+        upm_disp_mmpm_reestablish_rej((T_MMPM_REESTABLISH_REJ *)(prim));
+        PFREE(prim);
+        break;
+#endif /* TI_UMTS */
+#ifdef TI_GPRS
+      case MMPM_SEQUENCE_IND:
+        upm_disp_mmpm_sequence_ind((T_MMPM_SEQUENCE_IND *)(prim));
+        PFREE(prim);
+        break;
+#endif /* TI_GPRS */
+#ifdef TI_DUAL_MODE
+      case MMPM_RAT_CHANGE_COMPLETED_IND:
+        upm_disp_mmpm_rat_change_completed_ind((T_MMPM_RAT_CHANGE_COMPLETED_IND *)(prim));
+        PFREE(prim);
+        break;
+
+      case MMPM_RAT_CHANGE_IND:
+        upm_disp_mmpm_rat_change_ind((T_MMPM_RAT_CHANGE_IND *)(prim));
+        PFREE(prim);
+        break;
+#endif /* TI_DUAL_MODE */
+
+#ifdef TI_UMTS
+      /* PDCP SAP */
+      case PDCP_DATA_IND:
+        upm_disp_pdcp_data_ind((T_PDCP_DATA_IND *)(prim));
+        PFREE(prim);
+        break;
+
+#ifdef DEBUG
+      case PDCP_TEST_DATA_IND:
+        upm_disp_pdcp_test_data_ind((T_PDCP_TEST_DATA_IND *)(prim));
+        PFREE(prim);
+        break;
+#endif /* DEBUG */
+
+#ifdef TI_DUAL_MODE
+      case PDCP_AM_GET_PENDING_PDU_CNF:
+        upm_disp_pdcp_get_pending_pdu_cnf((T_PDCP_AM_GET_PENDING_PDU_CNF *)(prim));
+        PFREE(prim);
+        break;
+
+#ifdef DEBUG
+      case PDCP_TEST_AM_GET_PENDING_PDU_CNF:
+        upm_disp_pdcp_test_am_get_pending_pdu_cnf((T_PDCP_TEST_AM_GET_PENDING_PDU_CNF *)(prim));
+        PFREE(prim);
+        break;
+#endif
+
+      /* RRC SAP */
+      case RRC_MOVE_USER_DATA_IND:
+        upm_disp_rrc_move_user_data_ind((T_RRC_MOVE_USER_DATA_IND *)(prim));
+        PFREE(prim);
+        break;
+#endif /* TI_DUAL_MODE */
+      case RRC_RAB_ESTABLISH_IND:
+        upm_disp_rrc_rab_establish_ind((T_RRC_RAB_ESTABLISH_IND *)(prim));
+        PFREE(prim);
+        break;
+      case RRC_RAB_ESTABLISH_COMPLETE_IND:
+        upm_disp_rrc_rab_establish_complete_ind((T_RRC_RAB_ESTABLISH_COMPLETE_IND *)(prim));
+        PFREE(prim);
+        break;
+      case RRC_RAB_RELEASE_IND:
+        upm_disp_rrc_rab_release_ind((T_RRC_RAB_RELEASE_IND *)(prim));
+        PFREE(prim);
+        break;
+
+      /* MEM SAP */
+      case MEM_READY_IND:
+        upm_disp_mem_ready_ind((T_MEM_READY_IND *)(prim));
+        PFREE(prim);
+        break;
+#endif /* TI_UMTS */
+
+#ifdef TI_GPRS
+      /* SN SAP */
+      case SN_ACTIVATE_CNF:
+        upm_disp_sn_activate_cnf((T_SN_ACTIVATE_CNF *)(prim));
+        PFREE(prim);
+        break;
+
+      case SN_COUNT_CNF:
+        upm_disp_sn_count_cnf((T_SN_COUNT_CNF *)(prim));
+        PFREE(prim);
+        break;
+
+      case SN_MODIFY_CNF:
+        upm_disp_sn_modify_cnf((T_SN_MODIFY_CNF *)(prim));
+        PFREE(prim);
+        break;
+
+      case SN_DEACTIVATE_CNF:
+        upm_disp_sn_deactivate_cnf((T_SN_DEACTIVATE_CNF *)(prim));
+        PFREE(prim);
+        break;
+
+      case SN_STATUS_IND:
+        /* May affect multiple contexts.  Special dispatch handling. */
+        upm_sndcp_dispatch_sn_status_ind((T_SN_STATUS_IND *)(prim));
+        PFREE(prim);
+        break;
+
+      case SN_SEQUENCE_CNF:
+        /* May affect multiple contexts.  Special dispatch handling. */
+        upm_sndcp_dispatch_sn_sequence_cnf((T_SN_SEQUENCE_CNF *)(prim));
+        PFREE(prim);
+        break;
+
+#ifdef TI_DUAL_MODE
+      case SN_GET_PENDING_PDU_CNF:
+        upm_disp_sn_get_pending_pdu_cnf((T_SN_GET_PENDING_PDU_CNF *)(prim));
+        PFREE(prim);
+        break;
+
+#ifdef DEBUG
+      case SN_TEST_GET_PENDING_PDU_CNF:
+        upm_disp_sn_test_get_pending_pdu_cnf((T_SN_TEST_GET_PENDING_PDU_CNF *)(prim));
+        PFREE(prim);
+        break;
+#endif /* DEBUG */
+
+      /* RR SAP */
+      case RR_MOVE_USER_DATA_IND:
+        upm_disp_rr_move_user_data_ind((T_RR_MOVE_USER_DATA_IND *)(prim));
+        PFREE(prim);
+        break;
+#endif /* TI_DUAL_MODE */
+#endif /* TI_GPRS */
+
+      /* UPM SAP */
+      case UPM_COUNT_REQ:
+        upm_disp_upm_count_req((T_UPM_COUNT_REQ *)(prim));
+        PFREE(prim);
+        break;
+
+#ifndef UPM_WITHOUT_USER_PLANE
+      case UPM_DTI_REQ:
+        upm_disp_upm_dti_req((T_UPM_DTI_REQ *)(prim));
+        PFREE(prim);
+        break;
+#endif /* UPM_WITHOUT_USER_PLANE */
+
+      default:
+        /* forward sys primitives to the environment */
+        if ( (opc & SYS_MASK) != 0) {
+          (void)vsi_c_primitive(VSI_CALLER primitive);
+          return (short)PEI_OK;
+        } else {
+          PFREE(prim);
+          return (short)PEI_ERROR;
+        }
+    } /* switch */
+  } /* if (prim != NULL) */
+
+  return PEI_OK;
+}
+
+/*
++------------------------------------------------------------------------------
+| Function      : pei_init
++------------------------------------------------------------------------------
+| Description   : This function is called by the frame. It is used
+|                 to initialise the entity.
+|
+| Parameters    : handle            - task handle
+|
+| Return        : PEI_OK            - entity initialised
+|                 PEI_ERROR         - entity not (yet) initialised
++------------------------------------------------------------------------------
+*/
+static short pei_init (T_HANDLE handle)
+  /*@globals undef upm_data@*/
+  /*@modifies upm_data@*/
+{
+  (void)TRACE_FUNCTION ("UPM pei_init");
+
+  /* Clear static entity data store */
+  memset(&upm_data, 0, sizeof(upm_data));
+
+  /*
+   * Initialize task handles
+   */
+  upm_data.upm_handle = handle;
+  hCommACI   = VSI_ERROR;
+  hCommSM    = VSI_ERROR;
+  hCommMM    = VSI_ERROR;
+#ifdef TI_UMTS
+  hCommPDCP  = VSI_ERROR;
+  hCommRRC   = VSI_ERROR;
+#endif /* TI_UMTS */
+#ifdef TI_GPRS
+  hCommSNDCP = VSI_ERROR;
+  hCommRR    = VSI_ERROR;
+#endif /* TI_GPRS */
+
+  /*
+   * Open communication channels
+   */
+  if (hCommACI < VSI_OK)
+  {
+    if ((hCommACI = vsi_c_open(VSI_CALLER ACI_NAME)) < VSI_OK)
+    {
+      return (short)PEI_ERROR;
+    }
+  }
+
+  if (hCommSM < VSI_OK)
+  {
+    if ((hCommSM = vsi_c_open(VSI_CALLER SM_NAME)) < VSI_OK)
+    {
+      return (short)PEI_ERROR;
+    }
+  }
+
+  if (hCommMM < VSI_OK)
+  {
+/*#ifdef UPM_EDGE */
+    if ((hCommMM = vsi_c_open(VSI_CALLER GMM_NAME)) < VSI_OK)
+/*#else */ /*#ifdef UPM_EDGE*/
+/*    if ((hCommMM = vsi_c_open(VSI_CALLER MM_NAME)) < VSI_OK)
+#endif */ /*#ifdef UPM_EDGE*/
+    {
+      return (short)PEI_ERROR;
+    }
+  }
+
+
+#ifdef TI_UMTS
+  if (hCommPDCP < VSI_OK)
+  {
+    if ((hCommPDCP = vsi_c_open(VSI_CALLER PDCP_NAME)) < VSI_OK)
+    {
+      return (short)PEI_ERROR;
+    }
+  }
+
+  if (hCommRRC < VSI_OK)
+  {
+    if ((hCommRRC = vsi_c_open(VSI_CALLER RRC_NAME)) < VSI_OK)
+    {
+      return (short)PEI_ERROR;
+    }
+  }
+#endif /* TI_UMTS */
+
+#ifdef TI_GPRS
+  if (hCommSNDCP < VSI_OK)
+  {
+    if ((hCommSNDCP = vsi_c_open (VSI_CALLER SNDCP_NAME)) < VSI_OK)
+    {
+      return (short)PEI_ERROR;
+    }
+  }
+
+  if (hCommRR < VSI_OK)
+  {
+    if ((hCommRR = vsi_c_open (VSI_CALLER RR_NAME)) < VSI_OK)
+    {
+      return (short)PEI_ERROR;
+    }
+  }
+#endif /* TI_GPRS */
+
+  /*
+   * Initialize entity data (call init functions)
+   */
+
+#ifdef TI_UMTS
+  mem_init();
+#endif /* TI_UMTS */
+
+  /*
+   * Initialize DTI
+   */
+#ifndef UPM_WITHOUT_USER_PLANE
+  assert (upm_hDTI == NULL);
+  upm_hDTI = dti_init((U8)NAS_SIZE_NSAPI, upm_data.upm_handle,
+                      DTI_DEFAULT_OPTIONS, upm_sig_callback);
+#endif /* UPM_WITHOUT_USER_PLANE */
+
+  return (short)PEI_OK;
+}
+
+/*
++------------------------------------------------------------------------------
+| Function      : pei_exit
++------------------------------------------------------------------------------
+| Description   : This function is called by the frame when the entity
+|                 is terminated. All open resources are freed.
+|
+| Parameters    : -
+|
+| Return        : PEI_OK            - exit sucessful
+|                 PEI_ERROR         - exit not successful
++------------------------------------------------------------------------------
+*/
+static short pei_exit (void)
+{
+  int nsapi;
+  (void)TRACE_FUNCTION ("UPM pei_exit");
+
+  /*
+   * Clean up entity data
+   */
+
+  for (nsapi = (int)NAS_NSAPI_5; nsapi < NAS_SIZE_NSAPI; nsapi++) {
+    struct T_CONTEXT_DATA *ptr_context_data;
+
+    ptr_context_data = upm_get_context_data_from_nsapi(nsapi);
+    if (ptr_context_data != NULL) {
+#ifdef TI_GPRS
+      upm_sndcp_control_exit        (ptr_context_data);
+#endif /* TI_GPRS */
+#ifdef TI_UMTS
+      upm_rab_control_exit          (ptr_context_data);
+#endif
+      upm_link_control_exit         (ptr_context_data);
+#ifndef UPM_WITHOUT_USER_PLANE
+      upm_downlink_data_control_exit(ptr_context_data);
+      upm_uplink_data_control_exit  (ptr_context_data);
+      upm_dti_control_exit          (ptr_context_data);
+#endif /* UPM_WITHOUT_USER_PLANE */
+
+#ifdef DEBUG
+ #ifdef TI_UMTS
+      upm_free_mem_buffer(ptr_context_data);
+ #endif
+#endif
+      upm_free_context_data(nsapi);
+    }
+  }
+#ifdef TI_DUAL_MODE
+  upm_rat_control_exit();
+#endif
+
+#ifndef UPM_WITHOUT_USER_PLANE
+  /*
+   * Clean-up DTILIB
+   */
+  dti_deinit(upm_hDTI);
+
+  /* Disable forced DTI neighbor routing */
+#ifdef DEBUG
+  upm_disp_force_neighbor(NULL);
+#endif
+#endif /* UPM_WITHOUT_USER_PLANE */
+
+  /*
+   * Close communication channels
+   */
+  (void)vsi_c_close(VSI_CALLER hCommACI);
+  hCommACI   = VSI_ERROR;
+
+  (void)vsi_c_close(VSI_CALLER hCommSM);
+  hCommSM    = VSI_ERROR;
+
+  (void)vsi_c_close(VSI_CALLER hCommMM);
+  hCommMM    = VSI_ERROR;
+
+#ifdef TI_UMTS
+  (void)vsi_c_close(VSI_CALLER hCommPDCP);
+  hCommPDCP  = VSI_ERROR;
+
+  (void)vsi_c_close(VSI_CALLER hCommRRC);
+  hCommRRC   = VSI_ERROR;
+#endif /* TI_UMTS */
+
+#ifdef TI_GPRS
+  (void)vsi_c_close(VSI_CALLER hCommSNDCP);
+  hCommSNDCP = VSI_ERROR;
+
+  (void)vsi_c_close(VSI_CALLER hCommRR);
+  hCommRR    = VSI_ERROR;
+#endif /* TI_GPRS */
+
+  return PEI_OK;
+}
+
+/*
++------------------------------------------------------------------------------
+| Function              : pei_config
++------------------------------------------------------------------------------
+| Description   : This function is called by the frame when a primitive is
+|                 received indicating dynamic configuration.
+|
+|                 This function is not used in this entity.
+|
+| Parameters    :       handle            - Communication handle
+|
+| Return      : PEI_OK            - sucessful
+|               PEI_ERROR         - not successful
++------------------------------------------------------------------------------
+*/
+static short pei_config (char *inString)
+{
+#ifdef DEBUG
+  const size_t neighbor_strlen = strlen("NEIGHBOR_ENTITY");
+#endif
+  (void)TRACE_FUNCTION ("UPM pei_config");
+  (void)TRACE_FUNCTION (inString);
+
+#ifdef DEBUG
+
+#ifdef TI_UMTS
+  if ( strcmp(inString, "MEM_FLOW_CONTROL ON") == 0)
+  {
+    upm_disp_adjust_mem_flow_control(TRUE);
+  }
+  else if ( strcmp(inString, "MEM_FLOW_CONTROL OFF") == 0)
+  {
+    upm_disp_adjust_mem_flow_control(FALSE);
+  }
+  else if ( strncmp(inString, "NEIGHBOR_ENTITY", neighbor_strlen) == 0)
+  {
+    if (strncmp(&inString[neighbor_strlen + 1], "CLEAR", sizeof("CLEAR")) != 0)
+    {
+      upm_disp_force_neighbor(&inString[neighbor_strlen + 1]);
+    } else {
+      upm_disp_force_neighbor(NULL);
+    }
+  } else
+#endif /* TI_UMTS */
+  if ( strcmp(inString, "LL_ENTITY_TEST") == 0)
+  {
+    upm_activate_ll_entity_test();
+  }
+#endif /* DEBUG */
+
+  return PEI_OK;
+}
+
+/*
++------------------------------------------------------------------------------
+| Function      : pei_monitor
++------------------------------------------------------------------------------
+| Description   : This function is called by the frame in case sudden entity
+|                 specific data is requested (e.g. entity Version).
+|
+| Parameters    :  out_monitor       - return the address of the data to be
+|                                      monitoredCommunication handle
+|
+| Return        :  PEI_OK            - sucessful (address in out_monitor is valid)
+|                  PEI_ERROR         - not successful
++------------------------------------------------------------------------------
+*/
+/*@-compdef@*/ /*@-mods@*/
+static short pei_monitor (void **out_monitor) /*@globals undef upm_mon@*/
+{
+  (void)TRACE_FUNCTION ("UPM pei_monitor");
+
+  /*
+   * Version = "0.S" (S = Step).
+   */
+  upm_mon.version = "UPM 0.1";
+  *out_monitor = &upm_mon;
+
+  return PEI_OK;
+}
+/*@=compdef@*/ /*@=mods@*/
+
+/*==== PUBLIC FUNCTIONS =====================================================*/
+
+/*
++------------------------------------------------------------------------------
+| Function              : pei_create
++------------------------------------------------------------------------------
+| Description   :  This function is called by the frame when the process is 
+|                  created.
+|
+| Parameters    :  out_name          - Pointer to the buffer in which to locate
+|                                      the name of this entity
+|
+| Return        :  PEI_OK            - entity created successfuly
+|                  PEI_ERROR         - entity could not be created
+|
++------------------------------------------------------------------------------
+*/
+short pei_create (T_PEI_INFO **info)
+     /*@globals first_access@*/ /*@modifies first_access@*/
+{
+/*@-nullassign@*/
+static T_PEI_INFO pei_info =
+              {
+/*@i1@*/       UPM_NAME,      /* name */
+               {              /* pei-table */
+                 pei_init,
+                 pei_exit,
+                 pei_primitive,
+                 NULL,        /* no pei_timeout function */
+                 NULL,        /* no pei_signal function */
+                 NULL,        /* no pei_run function */
+                 pei_config,
+                 pei_monitor
+               },
+               (U32)1024,     /* stack size */
+               (U16)20,       /* queue entries */
+               (U16)216,      /* priority (1->low, 255->high) */
+               (U16)0,        /* number of timers */
+               (U8)0x03       /* flags: bit 0   active(0) body/passive(1) */
+              };              /*        bit 1   com by copy(0)/reference(1) */
+/*@+nullassign@*/
+
+  (void)TRACE_FUNCTION ("UPM pei_create");
+
+  /*
+   * Close Resources if open
+   */
+  if (first_access)
+  {
+    first_access = FALSE;
+  } else {
+    (void)pei_exit();
+  }
+
+  /*
+   * Export startup configuration data
+   */
+  *info = &pei_info;
+
+  return PEI_OK;
+}
+
+/*==== END OF FILE ==========================================================*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/g23m-gprs/upm/upm_sm_output_handler.c	Fri Oct 14 01:21:46 2016 +0000
@@ -0,0 +1,143 @@
+/*----------------------------------------------------------------------------
+|  Project :  3G PS
+|  Module  :  UPM
++-----------------------------------------------------------------------------
+|             Copyright 2003 Texas Instruments.
+|             All rights reserved. 
+| 
+|             This file is confidential and a trade secret of Texas 
+|             Instruments .
+|             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. 
++-----------------------------------------------------------------------------
+| Purpose:    Output functions for primitives from UPM to the SM entity.
+|             For design details, see:
+|             8010.939 UPM Detailed Specification
++---------------------------------------------------------------------------*/
+
+/*==== DECLARATION CONTROL ==================================================*/
+
+/*==== INCLUDES =============================================================*/
+
+#include "upm.h"
+
+/*==== CONSTS ===============================================================*/
+
+/*==== TYPES ================================================================*/
+
+/*==== LOCALS ===============================================================*/
+
+/*==== PUBLIC FUNCTIONS =====================================================*/
+
+/*
++------------------------------------------------------------------------------
+| Function    : send_sm_activate_res
++------------------------------------------------------------------------------
+| Description : Allocate, pack and send SM_ACTIVATE_RES primitive.
+|
+| Parameters  : ptr_context_data - Pointer to context data
++------------------------------------------------------------------------------
+*/
+
+void send_sm_activate_res(struct T_CONTEXT_DATA *ptr_context_data, void* data)
+{
+  (void)TRACE_FUNCTION("send_sm_activate_res");
+
+  {
+    PALLOC(prim, SM_ACTIVATE_RES);
+
+    prim->nsapi = ptr_context_data->nsapi;
+
+    if (data == NULL) /*Possible for UMTS*/
+    {
+      prim->v_comp_params = (U8)FALSE;
+    } else {
+      if( (((T_SN_ACTIVATE_CNF*)data)->comp_params.dcomp != 0) ||
+          (((T_SN_ACTIVATE_CNF*)data)->comp_params.hcomp != 0)   )
+      {
+        prim->v_comp_params = (U8)TRUE;
+        prim->comp_params.dcomp = ((T_SN_ACTIVATE_CNF*)data)->comp_params.dcomp;
+        prim->comp_params.hcomp = ((T_SN_ACTIVATE_CNF*)data)->comp_params.hcomp;
+        prim->comp_params.msid = ((T_SN_ACTIVATE_CNF*)data)->comp_params.msid;
+      } else {
+        prim->v_comp_params = (U8)FALSE;
+      }
+    }
+
+    (void)PSEND(hCommSM, prim);
+  }
+}
+
+/*
++------------------------------------------------------------------------------
+| Function    : send_sm_modify_res
++------------------------------------------------------------------------------
+| Description : Allocate, pack and send SM_MODIFY_RES primitive.
+|
+| Parameters  : ptr_context_data - Pointer to context data
++------------------------------------------------------------------------------
+*/
+void send_sm_modify_res(struct T_CONTEXT_DATA *ptr_context_data)
+{
+  (void)TRACE_FUNCTION("send_sm_modify_res");
+
+  {
+    PALLOC(prim, SM_MODIFY_RES);
+
+    /*lint !e613 (Warning -- Possible use of null pointer) */
+    prim->nsapi = ptr_context_data->nsapi;
+
+    (void)PSEND(hCommSM, prim);
+  }
+}
+
+/*
++------------------------------------------------------------------------------
+| Function    : send_sm_deactivate_res
++------------------------------------------------------------------------------
+| Description : Allocate, pack and send SM_DEACTIVATE_RES primitive.
+|
+| Parameters  : ptr_context_data - Pointer to context data
++------------------------------------------------------------------------------
+*/
+void send_sm_deactivate_res(U16 nsapi_set)
+{
+  (void)TRACE_FUNCTION("send_sm_deactivate_res");
+
+  {
+    PALLOC(prim, SM_DEACTIVATE_RES);
+
+    prim->nsapi_set = nsapi_set;
+
+    (void)PSEND(hCommSM, prim);
+  }
+}
+
+/*
++------------------------------------------------------------------------------
+| Function    : send_sm_status_req
++------------------------------------------------------------------------------
+| Description : Allocate, pack and send SM_STATUS_REQ primitive.
+|
+| Parameters  : ptr_context_data - Pointer to context data
++------------------------------------------------------------------------------
+*/
+void send_sm_status_req(U16 nsapi_set, T_PS_sapi llc_sapi,
+			T_CAUSE_ctrl_value ctrl, U16 cause)
+{
+  (void)TRACE_FUNCTION("send_sm_status_req");
+
+  {
+    PALLOC(prim, SM_STATUS_REQ);
+
+    prim->nsapi_set                = nsapi_set;
+    prim->sapi                     = (U8)llc_sapi;
+    prim->ps_cause.ctrl_value      = ctrl;
+    prim->ps_cause.value.upm_cause = cause;
+
+    (void)PSEND(hCommSM, prim);
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/g23m-gprs/upm/upm_sm_output_handler.h	Fri Oct 14 01:21:46 2016 +0000
@@ -0,0 +1,44 @@
+/*----------------------------------------------------------------------------
+|  Project :  3G PS
+|  Module  :  UPM
++-----------------------------------------------------------------------------
+|             Copyright 2003 Texas Instruments.
+|             All rights reserved. 
+| 
+|             This file is confidential and a trade secret of Texas 
+|             Instruments .
+|             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. 
++-----------------------------------------------------------------------------
+| Purpose:    Output functions for primitives from UPM to the SM entity.
+|             For design details, see:
+|             8010.939 UPM Detailed Specification
++---------------------------------------------------------------------------*/
+
+/*==== DECLARATION CONTROL =================================================*/
+
+#ifndef _UPM_SM_OUTPUT_HANDLER_H
+#define _UPM_SM_OUTPUT_HANDLER_H
+
+/*==== INCLUDES =============================================================*/
+#include "typedefs.h"
+
+#include "upm.h"
+
+/*==== CONSTS ===============================================================*/
+
+/*==== TYPES ================================================================*/
+
+/*==== EXPORTS ==============================================================*/
+ 
+extern void send_sm_activate_res    (struct T_CONTEXT_DATA *, void* data);
+extern void send_sm_modify_res      (struct T_CONTEXT_DATA *);
+extern void send_sm_deactivate_res  (U16 nsapi_set);
+extern void send_sm_status_req      (U16 nsapi_set, T_PS_sapi llc_sapi,
+				     T_CAUSE_ctrl_value ctrl, U16 cause);
+
+#endif /* _UPM_SM_OUTPUT_HANDLER_H */
+/*==== END OF FILE ==========================================================*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/g23m-gprs/upm/upm_sndcp_control.c	Fri Oct 14 01:21:46 2016 +0000
@@ -0,0 +1,648 @@
+/*----------------------------------------------------------------------------
+|  Project :  3G PS
+|  Module  :  UPM
++-----------------------------------------------------------------------------
+|             Copyright 2003 Texas Instruments.
+|             All rights reserved. 
+| 
+|             This file is confidential and a trade secret of Texas 
+|             Instruments .
+|             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. 
++-----------------------------------------------------------------------------
+| Purpose:    SNDCP Control state machine implementation in the UPM entity.
+|             For design details, see:
+|             8010.939 UPM Detailed Specification
++---------------------------------------------------------------------------*/
+
+/*==== DECLARATION CONTROL =================================================*/
+
+/*==== INCLUDES =============================================================*/
+
+#include "upm.h"
+
+#include "upm_sndcp_control.h"
+#include "upm_sndcp_output_handler.h"
+#include "upm_aci_output_handler.h"
+#include "upm_sm_output_handler.h"
+#include "upm_mm_output_handler.h"
+
+/*==== CONSTS ===============================================================*/
+
+/*==== TYPES ================================================================*/
+
+typedef void (*T_UPM_SNDCP_CONTROL_TRANSITION_FUNC)(struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ void *data);
+
+typedef struct {
+#ifdef DEBUG
+  T_UPM_SNDCP_CONTROL_EVENT            event;
+#endif /* DEBUG */
+  T_UPM_SNDCP_CONTROL_TRANSITION_FUNC  func;
+} T_UPM_SNDCP_CONTROL_TRANSITION;
+
+/*==== LOCALS ===============================================================*/
+
+static void state_event_error   (struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ void *data);
+static void ignored             (struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ void *data);
+static void handle_passive_activate(struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ void *data);
+static void handle_active_activate(struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ void *data);
+static void handle_passive_activate_cnf(struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ void *data);
+static void handle_active_activate_cnf(struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ void *data);
+static void handle_deactivate   (struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ void *data);
+static void handle_sn_deactivate_cnf(struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ void *data);
+static void handle_modify_llc_link(struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ void *data);
+static void handle_sn_modify_cnf(struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ void *data);
+static void handle_mmpm_sequence_ind(struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ void *data);
+static void handle_status_ind   (struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ void *data);
+
+/***********************************************************************
+ * State/Transition Table
+ */
+static const T_UPM_SNDCP_CONTROL_TRANSITION
+transition[UPM_SNDCP_CONTROL_NUMBER_OF_STATES]
+          [UPM_LINK_CONTROL_NUMBER_OF_EVENTS] =
+{
+  { /* S0: UPM SNDCP INACTIVE */
+    M_TRANSITION(UPM_P_SN_ACTIVATE_CNF,          state_event_error),
+    M_TRANSITION(UPM_P_SN_DEACTIVATE_CNF,        state_event_error),
+    M_TRANSITION(UPM_P_SN_MODIFY_CNF,            state_event_error),
+    M_TRANSITION(UPM_P_SN_STATUS_IND,            state_event_error),
+    M_TRANSITION(UPM_P_MMPM_SEQUENCE_IND,        state_event_error),
+    M_TRANSITION(UPM_I_SNDCP_AWAIT_ESTABLISH,    handle_passive_activate),
+    M_TRANSITION(UPM_I_SNDCP_ESTABLISH_LLC_LINK, handle_active_activate),
+    M_TRANSITION(UPM_I_SNDCP_MODIFY_LLC_LINK,    state_event_error),
+    M_TRANSITION(UPM_I_SNDCP_RELEASE_LLC_LINK,   state_event_error)
+  },
+  { /* S1: UPM SNDCP AWAIT ACTIVATE */
+    M_TRANSITION(UPM_P_SN_ACTIVATE_CNF,          handle_passive_activate_cnf),
+    M_TRANSITION(UPM_P_SN_DEACTIVATE_CNF,        state_event_error),
+    M_TRANSITION(UPM_P_SN_MODIFY_CNF,            state_event_error),
+    M_TRANSITION(UPM_P_SN_STATUS_IND,            handle_status_ind),
+    M_TRANSITION(UPM_P_MMPM_SEQUENCE_IND,        state_event_error),
+    M_TRANSITION(UPM_I_SNDCP_AWAIT_ESTABLISH,    state_event_error),
+    M_TRANSITION(UPM_I_SNDCP_ESTABLISH_LLC_LINK, state_event_error),
+    M_TRANSITION(UPM_I_SNDCP_MODIFY_LLC_LINK,    state_event_error),
+    M_TRANSITION(UPM_I_SNDCP_RELEASE_LLC_LINK,   handle_deactivate)
+  },
+  { /* S2: UPM SNDCP ACTIVATING */
+    M_TRANSITION(UPM_P_SN_ACTIVATE_CNF,          handle_active_activate_cnf),
+    M_TRANSITION(UPM_P_SN_DEACTIVATE_CNF,        state_event_error),
+    M_TRANSITION(UPM_P_SN_MODIFY_CNF,            state_event_error),
+    M_TRANSITION(UPM_P_SN_STATUS_IND,            handle_status_ind),
+    M_TRANSITION(UPM_P_MMPM_SEQUENCE_IND,        state_event_error),
+    M_TRANSITION(UPM_I_SNDCP_AWAIT_ESTABLISH,    state_event_error),
+    M_TRANSITION(UPM_I_SNDCP_ESTABLISH_LLC_LINK, state_event_error),
+    M_TRANSITION(UPM_I_SNDCP_MODIFY_LLC_LINK,    state_event_error),
+    M_TRANSITION(UPM_I_SNDCP_RELEASE_LLC_LINK,   handle_deactivate)
+  },
+  { /* S3: UPM SNDCP ACTIVE */
+    M_TRANSITION(UPM_P_SN_ACTIVATE_CNF,          state_event_error),
+    M_TRANSITION(UPM_P_SN_DEACTIVATE_CNF,        state_event_error),
+    M_TRANSITION(UPM_P_SN_MODIFY_CNF,            state_event_error),
+    M_TRANSITION(UPM_P_SN_STATUS_IND,            handle_status_ind),
+    M_TRANSITION(UPM_P_MMPM_SEQUENCE_IND,        handle_mmpm_sequence_ind),
+    M_TRANSITION(UPM_I_SNDCP_AWAIT_ESTABLISH,    state_event_error),
+    M_TRANSITION(UPM_I_SNDCP_ESTABLISH_LLC_LINK, state_event_error),
+    M_TRANSITION(UPM_I_SNDCP_MODIFY_LLC_LINK,    handle_modify_llc_link),
+    M_TRANSITION(UPM_I_SNDCP_RELEASE_LLC_LINK,   handle_deactivate)
+  },
+  { /* S4: UPM SNDCP MODIFYING */
+    M_TRANSITION(UPM_P_SN_ACTIVATE_CNF,          state_event_error),
+    M_TRANSITION(UPM_P_SN_DEACTIVATE_CNF,        state_event_error),
+    M_TRANSITION(UPM_P_SN_MODIFY_CNF,            handle_sn_modify_cnf),
+    M_TRANSITION(UPM_P_SN_STATUS_IND,            handle_status_ind),
+    M_TRANSITION(UPM_P_MMPM_SEQUENCE_IND,        handle_mmpm_sequence_ind),
+    M_TRANSITION(UPM_I_SNDCP_AWAIT_ESTABLISH,    state_event_error),
+    M_TRANSITION(UPM_I_SNDCP_ESTABLISH_LLC_LINK, state_event_error),
+    M_TRANSITION(UPM_I_SNDCP_MODIFY_LLC_LINK,    state_event_error),
+    M_TRANSITION(UPM_I_SNDCP_RELEASE_LLC_LINK,   handle_deactivate)
+  },
+  { /* S5: UPM SNDCP DEACTIVATING */
+    M_TRANSITION(UPM_P_SN_ACTIVATE_CNF,          state_event_error),
+    M_TRANSITION(UPM_P_SN_DEACTIVATE_CNF,        handle_sn_deactivate_cnf),
+    M_TRANSITION(UPM_P_SN_MODIFY_CNF,            ignored),
+    M_TRANSITION(UPM_P_SN_STATUS_IND,            handle_status_ind),
+    M_TRANSITION(UPM_P_MMPM_SEQUENCE_IND,        state_event_error),
+    M_TRANSITION(UPM_I_SNDCP_AWAIT_ESTABLISH,    state_event_error),
+    M_TRANSITION(UPM_I_SNDCP_ESTABLISH_LLC_LINK, state_event_error),
+    M_TRANSITION(UPM_I_SNDCP_MODIFY_LLC_LINK,    state_event_error),
+    M_TRANSITION(UPM_I_SNDCP_RELEASE_LLC_LINK,   ignored)
+  }
+};
+
+/*==== PRIVATE FUNCTIONS ====================================================*/
+
+/*
++------------------------------------------------------------------------------
+| Function    : state_event_error
++------------------------------------------------------------------------------
+| Description : General function used to report state event errors.
+|
+| Parameters  : ptr_context_data - Not used
+|               data             - Not used
++------------------------------------------------------------------------------
+*/
+static void state_event_error(/*@unused@*/ struct T_CONTEXT_DATA *ptr_context_data, /*@unused@*/ /*@null@*/ void* data)
+{
+  (void)TRACE_ERROR("UPM SNDCP Control: STATE EVENT ERROR!");
+}
+
+/*
++------------------------------------------------------------------------------
+| Function    : ignored
++------------------------------------------------------------------------------
+| Description : General function used for transitions that shall be ignored
+|
+| Parameters  : ptr_context_data - Not used
+|               data             - Not used
++------------------------------------------------------------------------------
+*/
+static void ignored (/*@unused@*/ struct T_CONTEXT_DATA *ptr_context_data, /*@unused@*/ /*@null@*/ void* data)
+{
+  (void)TRACE_FUNCTION("UPM SNDCP Control: Event ignored.");
+}
+
+/*
++------------------------------------------------------------------------------
+| Function    : handle_passive_activate
++------------------------------------------------------------------------------
+| Description : Handle UPM_I_SNDCP_AWAIT_ESTABLISH in S0
+|
+| Parameters  : ptr_context_data - Context data
+|               data             - Pointer to compression parameters
++------------------------------------------------------------------------------
+*/
+static void handle_passive_activate(struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ void* data)
+{
+  (void)TRACE_FUNCTION("handle_passive_activate");
+
+  /* Send SN_ACTIVATE_REQ with establish flag == FALSE */
+  send_sn_activate_req(ptr_context_data, (T_NAS_comp_params *)data, FALSE);
+
+  /* Go to state UPM SNDCP AWAIT ACTIVATE */
+  ptr_context_data->sndcp_control_state = UPM_SNDCP_AWAIT_ACTIVATE;
+
+#ifndef UPM_WITHOUT_USER_PLANE
+  /* Suspend Uplink Data */
+  upm_uplink_data_control(ptr_context_data, UPM_I_UPLINK_DATA_SUSPEND,
+                          (void *)UPM_LINK);
+#endif /* UPM_WITHOUT_USER_PLANE */
+}
+
+/*
++------------------------------------------------------------------------------
+| Function    : handle_active_activate
++------------------------------------------------------------------------------
+| Description : Handle UPM_I_SNDCP_ESTABLISH_LLC_LINK in S0
+|
+| Parameters  : ptr_context_data - Context data
+|               data             - Pointer to compression parameters
++------------------------------------------------------------------------------
+*/
+static void handle_active_activate(struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ void* data)
+{
+  (void)TRACE_FUNCTION("handle_active_activate");
+
+  /* Send SN_ACTIVATE_REQ with establish flag == TRUE */
+  send_sn_activate_req(ptr_context_data, (T_NAS_comp_params *)data, TRUE);
+
+  /* Go to state UPM SNDCP ACTIVATING */
+  ptr_context_data->sndcp_control_state = UPM_SNDCP_ACTIVATING;
+}
+
+/*
++------------------------------------------------------------------------------
+| Function    : handle_passive_activate_cnf
++------------------------------------------------------------------------------
+| Description : Handle UPM_P_SN_ACTIVATE_CNF in S1
+|
+| Parameters  : ptr_context_data - Context data
+|               data             - Not used
++------------------------------------------------------------------------------
+*/
+static void handle_passive_activate_cnf(struct T_CONTEXT_DATA *ptr_context_data, /*@unused@*/ /*@null@*/ void* data)
+{
+  (void)TRACE_FUNCTION("handle_passive_activate_cnf");
+
+  /* Go to state UPM SNDCP ACTIVE */
+  ptr_context_data->sndcp_control_state = UPM_SNDCP_ACTIVE;
+
+#ifndef UPM_WITHOUT_USER_PLANE
+  /* Resume Uplink Data */
+  upm_uplink_data_control(ptr_context_data, UPM_I_UPLINK_DATA_RESUME,
+                          (void *)UPM_LINK);
+#endif /* UPM_WITHOUT_USER_PLANE */
+
+  /* Report link establishment to Link Control */
+  upm_link_control(ptr_context_data, UPM_I_SNDCP_LLC_LINK_ESTABLISHED, NULL);
+}
+
+/*
++------------------------------------------------------------------------------
+| Function    : handle_active_activate_cnf
++------------------------------------------------------------------------------
+| Description : Handle UPM_P_SN_ACTIVATE_CNF in S2
+|
+| Parameters  : ptr_context_data - Context data
+|               data             - Not used
++------------------------------------------------------------------------------
+*/
+static void handle_active_activate_cnf(struct T_CONTEXT_DATA *ptr_context_data, /*@unused@*/ /*@null@*/ void* data)
+{
+  (void)TRACE_FUNCTION("handle_active_activate_cnf");
+
+  /* Go to state UPM SNDCP ACTIVE */
+  ptr_context_data->sndcp_control_state = UPM_SNDCP_ACTIVE;
+
+  /* Report link establishment to Link Control */ 
+  upm_link_control(ptr_context_data, UPM_I_SNDCP_LLC_LINK_ESTABLISHED, 
+    ((T_SN_ACTIVATE_CNF*)data)); /*To pass comp params*/
+}
+
+/*
++------------------------------------------------------------------------------
+| Function    : handle_deactivate
++------------------------------------------------------------------------------
+| Description : Handle UPM_I_SNDCP_RELEASE_LLC_LINK in S1, S2, S3, or S4.
+|
+| Parameters  : ptr_context_data - Context data
+|               data             - Local flag (rel_ind)
++------------------------------------------------------------------------------
+*/
+static void handle_deactivate(struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ void *data)
+{
+  U32  rel_ind = (U32)data;
+  (void)TRACE_FUNCTION("handle_deactivate");
+
+  /* SN_DEACTIVATE_REQ no longer sent in dispatcher function, so send here. */
+  send_sn_deactivate_req( ptr_context_data->nsapi, (U8)rel_ind);
+
+  /* Go to state UPM SNDCP DEACTIVATING */
+  ptr_context_data->sndcp_control_state = UPM_SNDCP_DEACTIVATING;
+}
+
+/*
++------------------------------------------------------------------------------
+| Function    : handle_sn_deactivate_cnf
++------------------------------------------------------------------------------
+| Description : Handle UPM_P_SN_DEACTIVATE_CNF in S5
+|
+| Parameters  : ptr_context_data - Context data
+|               data             - Not used
++------------------------------------------------------------------------------
+*/
+static void handle_sn_deactivate_cnf(struct T_CONTEXT_DATA *ptr_context_data, /*@unused@*/ /*@null@*/ void* data)
+{
+  (void)TRACE_FUNCTION("handle_sn_deactivate_cnf");
+
+  /* Go to state UPM SNDCP INACTIVE */
+  ptr_context_data->sndcp_control_state = UPM_SNDCP_INACTIVE;
+
+  /* Report LLC link release to Link Control */
+  upm_link_control(ptr_context_data, UPM_I_SNDCP_LLC_LINK_RELEASED, NULL);
+}
+
+/*
++------------------------------------------------------------------------------
+| Function    : handle_modify_llc_link
++------------------------------------------------------------------------------
+| Description : Handle UPM_I_SNDCP_MODIFY_LLC_LINK
+|
+| Parameters  : ptr_context_data - Context data
+|               data             - Not used
++------------------------------------------------------------------------------
+*/
+static void handle_modify_llc_link(struct T_CONTEXT_DATA *ptr_context_data, /*@unused@*/ /*@null@*/ void* data)
+{
+  (void)TRACE_FUNCTION("handle_modify_llc_link");
+
+  /* At this point, relevant flags in Context Data have been set by Link Control */
+
+  /* Send SN_MODIFY_REQ */
+  send_sn_modify_req(ptr_context_data);
+
+  /* Go to state UPM SNDCP MODIFYING */
+  ptr_context_data->sndcp_control_state = UPM_SNDCP_MODIFYING;
+}
+
+/*
++------------------------------------------------------------------------------
+| Function    : handle_sn_modify_cnf
++------------------------------------------------------------------------------
+| Description : Handle UPM_P_SN_MODIFY_CNF in S4
+|
+| Parameters  : ptr_context_data - Context data
+|               data             - Not used
++------------------------------------------------------------------------------
+*/
+static void handle_sn_modify_cnf(struct T_CONTEXT_DATA *ptr_context_data, /*@unused@*/ /*@null@*/ void* data)
+{
+  (void)TRACE_FUNCTION("handle_sn_modify_cnf");
+
+  /* Go to state UPM SNDCP ACTIVE */
+  ptr_context_data->sndcp_control_state = UPM_SNDCP_ACTIVE;
+
+  /* Report LLC link modification completion to Link Control */
+  upm_link_control(ptr_context_data, UPM_I_SNDCP_LLC_LINK_MODIFIED, NULL);
+}
+
+
+/*
++------------------------------------------------------------------------------
+| Function    : handle_mmpm_sequence_ind
++------------------------------------------------------------------------------
+| Description : Handle UPM_P_MMPM_SEQUENCE_IND
+|
+| Parameters  : ptr_context_data - Context data
+|               data             - sequence number
++------------------------------------------------------------------------------
+*/
+static void handle_mmpm_sequence_ind(struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ void* data)
+{
+  U32  seq_no = (U32)data;
+  (void)TRACE_FUNCTION("handle_mmpm_sequence_ind");
+
+  /* Set sequence number for this NSAPI */
+  upm_set_sequence_number(ptr_context_data, (U8)seq_no);
+
+#ifndef UPM_WITHOUT_USER_PLANE
+  /* Uplink Data Control should discard data older than the sequence number
+   * given in data for this NSAPI. */
+  upm_uplink_data_control(ptr_context_data, UPM_I_UPLINK_DATA_DISCARD,
+                          data);
+#endif /* UPM_WITHOUT_USER_PLANE */
+}
+
+/*
++------------------------------------------------------------------------------
+| Function    : handle_status_ind
++------------------------------------------------------------------------------
+| Description : Handle UPM_P_SN_STATUS_IND
+|
+| Parameters  : ptr_context_data - Context data
+|               data             - SN_STATUS_IND primitive
++------------------------------------------------------------------------------
+*/
+static void handle_status_ind(struct T_CONTEXT_DATA *ptr_context_data, /*@null@*/ void* data)
+{
+  (void)TRACE_FUNCTION("handle_status_ind");
+
+  TRACE_ASSERT( data != NULL );
+
+  /* If cause is any other than NO_PEER_RESPONSE, SNDCP Control should
+   * deactivate SNDCP. */
+  /*lint -e613 (Possible use of null pointer 'unknown-name' in left argument to operator '->') */
+  if ( (((T_SN_STATUS_IND *)data)->ps_cause.ctrl_value != CAUSE_is_from_llc ||
+        ((T_SN_STATUS_IND *)data)->ps_cause.value.llc_cause 
+                                 !=(U16)CAUSE_LLC_NO_PEER_RES ) &&
+       (((T_SN_STATUS_IND *)data)->ps_cause.ctrl_value != CAUSE_is_from_sndcp ||
+        ((T_SN_STATUS_IND *)data)->ps_cause.value.sn_cause 
+                                 != (U16)CAUSE_SN_NO_PEER_RESPONSE )  )
+  {
+    /* Go to state UPM SNDCP INACTIVE */
+    ptr_context_data->sndcp_control_state = UPM_SNDCP_INACTIVE;
+
+   /*lint +e613 (Possible use of null pointer 'unknown-name' in left argument to operator '->') */
+    /* Report link release to Link Control */
+    upm_link_control(ptr_context_data, UPM_I_SNDCP_LLC_LINK_RELEASED, data);
+  }
+}
+
+/*==== PUBLIC FUNCTIONS =====================================================*/
+
+/*
++------------------------------------------------------------------------------
+| Function    : upm_sndcp_dispatch_mmpm_sequence_ind
++------------------------------------------------------------------------------
+| Description : Helper function for Dispatcher. Dispatches MMPM_SEQUENCE_IND
+|
+| Parameters  : ptr_prim_data    - Pointer to primitive
++------------------------------------------------------------------------------
+*/
+void upm_sndcp_dispatch_mmpm_sequence_ind(T_MMPM_SEQUENCE_IND *ptr_prim_data)
+{
+  int               entries;
+  T_MMPM_npdu_list *entry;
+
+  (void)TRACE_FUNCTION("upm_sndcp_dispatch_mmpm_sequence_ind");
+
+  entries = (int)ptr_prim_data->c_npdu_list;
+  entry   = ptr_prim_data->npdu_list;
+
+  /* Loop over NSAPIs in primitive, and store sequence numbers. */
+  while (entries > 0) {
+    struct T_CONTEXT_DATA *context;
+
+    context = upm_get_context_data_from_nsapi(entry->nsapi);
+    if (context != NULL) {
+      upm_sndcp_control(context, UPM_P_MMPM_SEQUENCE_IND,
+                        (void *)entry->receive_n_pdu_number_val);
+    } else {
+      (void)TRACE_ERROR("Received sequence numbers for non-existent context!");
+    }
+
+    entries--;
+  }
+
+  send_sn_sequence_req(ptr_prim_data);
+}
+
+/*
++------------------------------------------------------------------------------
+| Function    : upm_sndcp_dispatch_sn_status_ind
++------------------------------------------------------------------------------
+| Description : Helper function for Dispatcher. Dispatches SN_STATUS_IND
+|
+| Parameters  : ptr_prim_data    - Pointer to primitive
++------------------------------------------------------------------------------
+*/
+void upm_sndcp_dispatch_sn_status_ind(T_SN_STATUS_IND *prim)
+{
+  int                     nsapi;
+  struct T_CONTEXT_DATA  *context;
+
+  (void)TRACE_FUNCTION("upm_sndcp_dispatch_sn_status_ind");
+
+  /* If cause is any other than NO_PEER_RESPONSE, SNDCP Control should
+   * deactivate SNDCP and inform Session Management. */
+  if ( (prim->ps_cause.ctrl_value != CAUSE_is_from_llc ||
+        prim->ps_cause.value.llc_cause != (U16)CAUSE_LLC_NO_PEER_RES ) &&
+       (prim->ps_cause.ctrl_value != CAUSE_is_from_sndcp ||
+        prim->ps_cause.value.sn_cause != (U16)CAUSE_SN_NO_PEER_RESPONSE ) 
+     ) {
+    /* Alert state machine */
+    for (nsapi = (int)NAS_NSAPI_5; nsapi < NAS_SIZE_NSAPI; nsapi++) {
+      if ( (prim->nsapi_set & upm_nsapi2nsapi_set(nsapi)) != 0 ) {
+        context = upm_get_context_data_from_nsapi(nsapi);
+	if (context != NULL) {
+	  upm_sndcp_control(context, UPM_P_SN_STATUS_IND, prim);
+
+          /* Release context data if applicable (link and DTI both down) */
+          upm_check_for_released_context_and_release(context);
+	}
+      }
+    }
+
+    /* Inform Session Management -- Once for all NSAPIs affected */
+    send_sm_status_req(prim->nsapi_set, (T_PS_sapi)prim->sapi,
+                       prim->ps_cause.ctrl_value, prim->ps_cause.value.sn_cause);
+  }
+  /* No action if cause is NO_PEER_RESPONSE */
+}
+
+/*
++------------------------------------------------------------------------------
+| Function    : upm_sndcp_dispatch_sn_sequence_cnf
++------------------------------------------------------------------------------
+| Description : Helper function for Dispatcher. Dispatches SN_SEQUENCE_CNF
+|
+| Parameters  : ptr_prim_data    - Pointer to primitive
++------------------------------------------------------------------------------
+*/
+void upm_sndcp_dispatch_sn_sequence_cnf(T_SN_SEQUENCE_CNF *prim)
+{
+  (void)TRACE_FUNCTION("upm_sndcp_dispatch_sn_sequence_cnf");
+
+  /* No action needed but forwarding sequence numbers to MM */
+  send_mmpm_sequence_res(prim);
+}
+
+/*
++------------------------------------------------------------------------------
+| Function    : upm_sndcp_dispatch_sn_count_cnf
++------------------------------------------------------------------------------
+| Description : Helper function for Dispatcher. Dispatches SN_COUNT_CNF
+|
+| Parameters  : prim             - Pointer to primitive
++------------------------------------------------------------------------------
+*/
+void upm_sndcp_dispatch_sn_count_cnf(T_SN_COUNT_CNF *prim)
+{
+  (void)TRACE_FUNCTION("upm_sndcp_dispatch_sn_count_cnf");
+
+  /* No action needed but forwarding as UPM_COUNT_CNF */
+  send_upm_count_cnf(prim->nsapi, prim->octets_uplink, prim->octets_downlink,
+                     prim->packets_uplink, prim->packets_downlink);
+}
+
+/*
++------------------------------------------------------------------------------
+| Function    : upm_sndcp_dispatch_upm_count_req
++------------------------------------------------------------------------------
+| Description : Helper function for Dispatcher. Dispatches UPM_COUNT_REQ
+|
+| Parameters  : prim             - Pointer to primitive
++------------------------------------------------------------------------------
+*/
+void upm_sndcp_dispatch_upm_count_req(T_UPM_COUNT_REQ *prim)
+{
+  (void)TRACE_FUNCTION("upm_sndcp_dispatch_upm_count_req");
+
+  /* No action needed but forwarding as SN_COUNT_REQ */
+  send_sn_count_req(prim->nsapi, prim->reset);
+}
+
+/*
++------------------------------------------------------------------------------
+| Function    : upm_sndcp_control_init
++------------------------------------------------------------------------------
+| Description : SNDCP Control state machine initialization function
+|
+| Parameters  : ptr_context_data - Pointer to context data
++------------------------------------------------------------------------------
+*/
+void upm_sndcp_control_init(struct T_CONTEXT_DATA *ptr_context_data)
+{
+  (void)TRACE_FUNCTION("upm_sndcp_control_init");
+
+  TRACE_ASSERT(ptr_context_data != NULL);
+  /*lint -e613 (Possible use of null pointer 'ptr_context_data' in left argument to operator '->') */
+  ptr_context_data->sndcp_control_state   = UPM_SNDCP_INACTIVE;
+  ptr_context_data->gprs_data.pkt_flow_id = (U8)PS_PKT_FLOW_ID_NOT_PRES; 
+  /*lint +e613 (Possible use of null pointer 'ptr_context_data' in left argument to operator '->') */ 	
+}
+
+/*
++------------------------------------------------------------------------------
+| Function    : upm_sndcp_control_exit
++------------------------------------------------------------------------------
+| Description : SNDCP Control state machine exit function
+|
+| Parameters  : ptr_context_data - Pointer to context data
++------------------------------------------------------------------------------
+*/
+void upm_sndcp_control_exit(struct T_CONTEXT_DATA *ptr_context_data)
+{
+  (void)TRACE_FUNCTION("upm_sndcp_control_exit");
+
+  TRACE_ASSERT(ptr_context_data != NULL);
+/*lint -e613 (Possible use of null pointer 'ptr_context_data' in left argument to operator '->') */
+  ptr_context_data->sndcp_control_state   = UPM_SNDCP_INACTIVE;
+  ptr_context_data->gprs_data.pkt_flow_id = (U8)PS_PKT_FLOW_ID_NOT_PRES;
+  /*lint +e613 (Possible use of null pointer 'ptr_context_data' in left argument to operator '->') */
+}
+
+/*
++------------------------------------------------------------------------------
+| Function    : upm_sndcp_control
++------------------------------------------------------------------------------
+| Description : SNDCP Control state machine
+|
+| Parameters  : ptr_context_data - Pointer to context data
+|               event            - Internal event (see upm_sndcp_control.h)
+|               data             - Event dependent parameter
++------------------------------------------------------------------------------
+*/
+void upm_sndcp_control (struct T_CONTEXT_DATA *ptr_context_data,
+                        T_UPM_SNDCP_CONTROL_EVENT event,
+                        /*@null@*/ void* data)
+{
+#ifdef DEBUG
+  T_UPM_SNDCP_CONTROL_STATE old_state;
+  /*@observer@*/
+  static const char *state_name[UPM_SNDCP_CONTROL_NUMBER_OF_STATES] = {
+    "S0_UPM_SNDCP_INACTIVE",
+    "S1_UPM_SNDCP_AWAIT_ACTIVATE",
+    "S2_UPM_SNDCP_ACTIVATING",
+    "S3_UPM_SNDCP_ACTIVE",
+    "S4_UPM_SNDCP_MODIFYING",
+    "S5_UPM_SNDCP_DEACTIVATING"
+  };
+  /*@observer@*/
+  static const char *event_name[UPM_LINK_CONTROL_NUMBER_OF_EVENTS] = {
+    "UPM_P_SN_ACTIVATE_CNF",
+    "UPM_P_SN_DEACTIVATE_CNF",
+    "UPM_P_SN_MODIFY_CNF",
+    "UPM_P_SN_STATUS_IND",
+    "UPM_P_MMPM_SEQUENCE_IND",
+    "UPM_I_SNDCP_AWAIT_ESTABLISH",
+    "UPM_I_SNDCP_ESTABLISH_LLC_LINK",
+    "UPM_I_SNDCP_MODIFY_LLC_LINK",
+    "UPM_I_SNDCP_RELEASE_LLC_LINK"
+  };
+
+  TRACE_ASSERT(ptr_context_data != NULL);
+  TRACE_ASSERT(event < UPM_SNDCP_CONTROL_NUMBER_OF_EVENTS);
+
+  old_state = ptr_context_data->sndcp_control_state;
+
+  if (transition[(U16)old_state][(U16)event].event != event) {
+    (void)TRACE_ERROR("Event table error in upm_sndcp_control!");
+  }
+#endif /* DEBUG */
+
+  transition[(U16)ptr_context_data->sndcp_control_state][(U16)event].func(ptr_context_data, data);
+
+#ifdef DEBUG
+  (void)TRACE_EVENT_P4("SNDCP #%d: %s => %s to %s",
+                       ptr_context_data->nsapi,
+                       event_name[(U16)event],
+                       state_name[(U16)old_state],
+                       state_name[(U16)ptr_context_data->sndcp_control_state]);
+#endif /* DEBUG */
+}
+
+/*==== END OF FILE ==========================================================*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/g23m-gprs/upm/upm_sndcp_control.h	Fri Oct 14 01:21:46 2016 +0000
@@ -0,0 +1,78 @@
+/*----------------------------------------------------------------------------
+|  Project :  3G PS
+|  Module  :  UPM
++-----------------------------------------------------------------------------
+|             Copyright 2003 Texas Instruments.
+|             All rights reserved. 
+| 
+|             This file is confidential and a trade secret of Texas 
+|             Instruments .
+|             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. 
++-----------------------------------------------------------------------------
+| Purpose:    SNDCP Control state machine definitions in the UPM entity.
+|             For design details, see:
+|             8010.939 UPM Detailed Specification
++---------------------------------------------------------------------------*/
+
+/*==== DECLARATION CONTROL =================================================*/
+
+#ifndef _UPM_SNDCP_CONTROL_H
+#define _UPM_SNDCP_CONTROL_H
+
+/*==== INCLUDES =============================================================*/
+
+#include "upm.h"
+
+/*==== CONSTS ===============================================================*/
+
+/*==== TYPES ================================================================*/
+typedef enum
+{
+  /* Incoming primitives */
+  UPM_P_SN_ACTIVATE_CNF,
+  UPM_P_SN_DEACTIVATE_CNF,
+  UPM_P_SN_MODIFY_CNF,
+  UPM_P_SN_STATUS_IND,
+  UPM_P_MMPM_SEQUENCE_IND,
+  /* Events from Link Control */
+  UPM_I_SNDCP_AWAIT_ESTABLISH,
+  UPM_I_SNDCP_ESTABLISH_LLC_LINK,
+  UPM_I_SNDCP_MODIFY_LLC_LINK,
+  UPM_I_SNDCP_RELEASE_LLC_LINK,
+  /* Number of events */
+  UPM_SNDCP_CONTROL_NUMBER_OF_EVENTS
+} T_UPM_SNDCP_CONTROL_EVENT;
+
+typedef enum
+{
+  UPM_SNDCP_INACTIVE,
+  UPM_SNDCP_AWAIT_ACTIVATE,
+  UPM_SNDCP_ACTIVATING,
+  UPM_SNDCP_ACTIVE,
+  UPM_SNDCP_MODIFYING,
+  UPM_SNDCP_DEACTIVATING,
+  UPM_SNDCP_CONTROL_NUMBER_OF_STATES
+} T_UPM_SNDCP_CONTROL_STATE;
+
+/*==== EXPORTS ==============================================================*/
+extern void upm_sndcp_control_init(struct T_CONTEXT_DATA *ptr_context_data);
+
+extern void upm_sndcp_control_exit(struct T_CONTEXT_DATA *ptr_context_data);
+
+extern void upm_sndcp_control(struct T_CONTEXT_DATA *ptr_context_data,
+			      T_UPM_SNDCP_CONTROL_EVENT event,
+			      /*@null@*/ void *data);
+
+extern void upm_sndcp_dispatch_sn_count_cnf      (T_SN_COUNT_CNF *);
+extern void upm_sndcp_dispatch_sn_status_ind     (T_SN_STATUS_IND *);
+extern void upm_sndcp_dispatch_sn_sequence_cnf   (T_SN_SEQUENCE_CNF *);
+
+extern void upm_sndcp_dispatch_mmpm_sequence_ind (T_MMPM_SEQUENCE_IND *);
+
+extern void upm_sndcp_dispatch_upm_count_req     (T_UPM_COUNT_REQ *);
+#endif /* _UPM_SNDCP_CONTROL_H */
+/*==== END OF FILE ==========================================================*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/g23m-gprs/upm/upm_sndcp_output_handler.c	Fri Oct 14 01:21:46 2016 +0000
@@ -0,0 +1,217 @@
+/*----------------------------------------------------------------------------
+|  Project :  3G PS
+|  Module  :  UPM
++-----------------------------------------------------------------------------
+|             Copyright 2003 Texas Instruments.
+|             All rights reserved. 
+| 
+|             This file is confidential and a trade secret of Texas 
+|             Instruments .
+|             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. 
++-----------------------------------------------------------------------------
+| Purpose:    Output functions for primitives from UPM to the MM entity.
+|             For design details, see:
+|             8010.939 UPM Detailed Specification
++---------------------------------------------------------------------------*/
+
+/*==== DECLARATION CONTROL =================================================*/
+
+/*==== INCLUDES ============================================================*/
+
+#include "upm.h"
+
+#include "upm_sndcp_output_handler.h"
+#include "upm_mm_output_handler.h"
+#ifndef UPM_WITHOUT_USER_PLANE
+#include "upm_dti_output_handler.h"
+#endif /* UPM_WITHOUT_USER_PLANE */
+
+/*==== CONSTS ===============================================================*/
+
+/*==== TYPES ================================================================*/
+
+/*==== LOCALS ===============================================================*/
+
+/*==== PUBLIC FUNCTIONS =====================================================*/
+
+/*
++------------------------------------------------------------------------------
+| Function    : send_sn_activate_req
++------------------------------------------------------------------------------
+| Description : Allocate, pack and send SN_ACTIVATE_REQ primitive.
+|
+| Parameters  : ptr_context_data - context data
+|               active           - active/passive establishment flag to SNDCP
++------------------------------------------------------------------------------
+*/
+void send_sn_activate_req(struct T_CONTEXT_DATA *ptr_context_data,
+                          T_NAS_comp_params *comp_params, BOOL active)
+{
+  (void)TRACE_FUNCTION("send_sn_activate_req");
+  
+  {
+    struct T_UPM_CONTEXT_DATA_GPRS *gprs_data = &ptr_context_data->gprs_data;
+    PALLOC(prim, SN_ACTIVATE_REQ);
+
+/*lint -e613 (Possible use of null pointer 'prim' in left argument to operator '->') */
+    prim->nsapi             = ptr_context_data->nsapi;
+    prim->sapi              = gprs_data->sndcp_llc_sapi;
+    prim->radio_prio        = gprs_data->sndcp_radio_prio;
+    prim->snsm_qos.delay    = gprs_data->sndcp_delay;
+    prim->snsm_qos.relclass = gprs_data->sndcp_relclass;
+    prim->snsm_qos.peak     = gprs_data->sndcp_peak_bitrate;
+    prim->snsm_qos.preced   = gprs_data->sndcp_preced;
+    prim->snsm_qos.mean     = gprs_data->sndcp_mean;
+
+    prim->establish         = (active ? (U8)SN_ACTIVE_ESTABLISHMENT :
+                                        (U8)SN_PASSIVE_ESTABLISHMENT);
+    if (comp_params != NULL)
+    {
+      memcpy(&prim->comp_params, comp_params, sizeof(T_NAS_comp_params));
+    } else {
+      memset(&prim->comp_params, 0, sizeof(T_NAS_comp_params));
+    }
+    prim->pkt_flow_id       = (U16)gprs_data->pkt_flow_id;
+/*lint +e613 (Possible use of null pointer 'prim' in left argument to operator '->') */
+    (void)PSEND(hCommSNDCP, prim);
+  }
+}
+
+/*
++------------------------------------------------------------------------------
+| Function    : send_sn_count_req
++------------------------------------------------------------------------------
+| Description : Allocate, pack and send SN_COUNT_REQ primitive.
+|
+| Parameters  : nsapi            - NSAPI
+|               reset            - Reset indicator
++------------------------------------------------------------------------------
+*/
+void send_sn_count_req(U8 nsapi, U8 reset)
+{
+  (void)TRACE_FUNCTION("send_sn_count_req");
+
+  {
+    PALLOC(prim, SN_COUNT_REQ);
+/*lint -e613 (Possible use of null pointer 'prim' in left argument to operator '->') */
+    prim->nsapi = nsapi;
+    prim->reset = reset;
+
+/*lint +e613 (Possible use of null pointer 'prim' in left argument to operator '->') */
+    (void)PSEND(hCommSNDCP, prim);
+  }
+}
+
+/*
++------------------------------------------------------------------------------
+| Function    : send_sn_deactivate_req
++------------------------------------------------------------------------------
+| Description : Allocate, pack and send SN_DEACTIVATE_REQ primitive.
+|
+| Parameters  : nsapi            - NSAPI to deactivate
+|               rel_ind          - local release indicator for SNDCP
++------------------------------------------------------------------------------
+*/
+void send_sn_deactivate_req(U8 nsapi, U8 rel_ind)
+{
+  (void)TRACE_FUNCTION("send_sn_deactivate_req");
+
+  {
+    PALLOC(prim, SN_DEACTIVATE_REQ);
+/*lint -e613 (Possible use of null pointer 'prim' in left argument to operator '->') */
+    prim->nsapi     = nsapi;
+    prim->rel_ind   = rel_ind;
+/*lint +e613 (Possible use of null pointer 'prim' in left argument to operator '->') */
+    (void)PSEND(hCommSNDCP, prim);
+  }
+}
+
+/*
++------------------------------------------------------------------------------
+| Function    : send_sn_modify_req
++------------------------------------------------------------------------------
+| Description : Allocate, pack and send SN_MODIFY_REQ primitive.
+|
+| Parameters  : ptr_context_data - context data
++------------------------------------------------------------------------------
+*/
+void send_sn_modify_req(struct T_CONTEXT_DATA *ptr_context_data)
+{
+  (void)TRACE_FUNCTION("send_sn_modify_req");
+
+  {
+    struct T_UPM_CONTEXT_DATA_GPRS *gprs_data = &ptr_context_data->gprs_data;
+    PALLOC(prim, SN_MODIFY_REQ);
+	
+/*lint -e613 (Possible use of null pointer 'prim' in left argument to operator '->') */
+    prim->nsapi             = ptr_context_data->nsapi;
+    prim->sapi              = gprs_data->sndcp_llc_sapi;
+    prim->radio_prio        = gprs_data->sndcp_radio_prio;
+    prim->snsm_qos.delay    = gprs_data->sndcp_delay;
+    prim->snsm_qos.relclass = gprs_data->sndcp_relclass;
+    prim->snsm_qos.peak     = gprs_data->sndcp_peak_bitrate;
+    prim->snsm_qos.preced   = gprs_data->sndcp_preced;
+    prim->snsm_qos.mean     = gprs_data->sndcp_mean;
+    prim->pkt_flow_id       = (U16)gprs_data->pkt_flow_id;
+/*lint +e613 (Possible use of null pointer 'prim' in left argument to operator '->') */
+    (void)PSEND(hCommSNDCP, prim);
+  }
+}
+
+/*
++------------------------------------------------------------------------------
+| Function    : send_sn_sequence_req
++------------------------------------------------------------------------------
+| Description : Allocate, pack and send SN_SEQUENCE_REQ primitive.
+|
+| Parameters  : mmpm_sequence_ind - MMPM primitive containing sequence numbers
++------------------------------------------------------------------------------
+*/
+void send_sn_sequence_req(T_MMPM_SEQUENCE_IND *mmpm_sequence_ind)
+{
+  U16  index;
+  (void)TRACE_FUNCTION("send_sn_sequence_req");
+
+  {
+    PALLOC(prim, SN_SEQUENCE_REQ);
+/*lint -e613 (Possible use of null pointer 'prim' in left argument to operator '->') */
+    prim->c_receive_no_list = mmpm_sequence_ind->c_npdu_list;
+
+    for (index = 0; index < (U16)mmpm_sequence_ind->c_npdu_list; index++)
+    {
+      prim->receive_no_list[index].nsapi      = mmpm_sequence_ind->npdu_list[index].nsapi;
+      prim->receive_no_list[index].receive_no = mmpm_sequence_ind->npdu_list[index].receive_n_pdu_number_val;
+    }
+/*lint +e613 (Possible use of null pointer 'prim' in left argument to operator '->') */
+    (void)PSEND(hCommSNDCP, prim);
+  }
+}
+
+/*
++------------------------------------------------------------------------------
+| Function    : send_sn_get_pending_pdu_req
++------------------------------------------------------------------------------
+| Description : Allocate, pack and send SN_GET_PENDING_PDU_REQ primitive.
+|
+| Parameters  : None
++------------------------------------------------------------------------------
+*/
+#ifdef TI_DUAL_MODE
+void send_sn_get_pending_pdu_req(void)
+{
+  (void)TRACE_FUNCTION("send_sn_get_pending_pdu_req");
+
+  {
+    PALLOC(prim, SN_GET_PENDING_PDU_REQ);
+	
+/*lint +e613 (Possible use of null pointer 'prim' in left argument to operator '->') */
+    (void)PSEND(hCommSNDCP, prim);
+  }
+}
+#endif /* TI_DUAL_MODE */
+
+/*==== END OF FILE ==========================================================*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/g23m-gprs/upm/upm_sndcp_output_handler.h	Fri Oct 14 01:21:46 2016 +0000
@@ -0,0 +1,49 @@
+/*----------------------------------------------------------------------------
+|  Project :  3G PS
+|  Module  :  UPM
++-----------------------------------------------------------------------------
+|             Copyright 2003 Texas Instruments.
+|             All rights reserved. 
+| 
+|             This file is confidential and a trade secret of Texas 
+|             Instruments .
+|             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. 
++-----------------------------------------------------------------------------
+| Purpose:    Output functions for primitives from UPM to the MM entity.
+|             For design details, see:
+|             8010.939 UPM Detailed Specification
++---------------------------------------------------------------------------*/
+
+/*==== DECLARATION CONTROL =================================================*/
+
+#ifndef UPM_SNDCP_OUTPUT_HANDLER_H
+#define UPM_SNDCP_OUTPUT_HANDLER_H
+
+/*==== INCLUDES =============================================================*/
+#include "typedefs.h"
+
+#include "upm.h"
+
+/*==== CONSTS ===============================================================*/
+
+/*==== TYPES ================================================================*/
+
+/*==== EXPORTS ==============================================================*/
+
+extern void send_sn_activate_req       (struct T_CONTEXT_DATA *,
+                                        /*@null@*/ T_NAS_comp_params *, BOOL);
+extern void send_sn_count_req          (U8 nsapi, U8 reset);
+extern void send_sn_deactivate_req     (U8 nsapi, U8 rel_ind);
+extern void send_sn_modify_req         (struct T_CONTEXT_DATA *);
+extern void send_sn_sequence_req       (T_MMPM_SEQUENCE_IND *);
+
+#ifdef TI_DUAL_MODE
+extern void send_sn_get_pending_pdu_req(void);
+#endif /* TI_DUAL_MODE */
+
+#endif /* UPM_SNDCP_OUTPUT_HANDLER_H */
+/*==== END OF FILE ==========================================================*/