comparison src/g23m-fad/l2r/tra_dnp.c @ 1:d393cd9bb723

src/g23m-*: initial import from Magnetite
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 15 Jul 2018 04:40:46 +0000
parents
children
comparison
equal deleted inserted replaced
0:b6a5e36de839 1:d393cd9bb723
1 /*
2 +-----------------------------------------------------------------------------
3 | Project : CSD (8411)
4 | Modul : tra_dnp.c
5 +-----------------------------------------------------------------------------
6 | Copyright 2002 Texas Instruments Berlin, AG
7 | All rights reserved.
8 |
9 | This file is confidential and a trade secret of Texas
10 | Instruments Berlin, AG
11 | The receipt of or possession of this file does not convey
12 | any rights to reproduce or disclose its contents or to
13 | manufacture, use, or sell anything it may describe, in
14 | whole, or in part, without the specific written consent of
15 | Texas Instruments Berlin, AG.
16 +-----------------------------------------------------------------------------
17 | Purpose : This Modul defines the functions for processing
18 | of incomming primitives for the component TRA
19 +-----------------------------------------------------------------------------
20 */
21
22 #ifndef TRA_DNP_C
23 #define TRA_DNP_C
24 #endif
25
26 #define ENTITY_L2R
27
28 /*==== INCLUDES ===================================================*/
29
30 #include <string.h>
31
32 #include "typedefs.h"
33 #include "pconst.cdg"
34 #include "vsi.h"
35 #include "macdef.h"
36 #include "custom.h"
37 #include "gsm.h"
38 #include "prim.h"
39 #include "pei.h"
40 #include "tok.h"
41 #include "dti.h"
42
43 #include "cl_ribu.h"
44 #include "tra_pei.h"
45 #include "tra.h"
46
47 /*==== CONST =======================================================*/
48
49 /*==== TYPES =======================================================*/
50
51 /*==== VAR EXPORT ==================================================*/
52
53 /*==== VAR LOCAL ===================================================*/
54
55 /*==== FUNCTIONS ===================================================*/
56
57 /*
58 +------------------------------------------------------------------------------
59 | Function : sig_dti_tra_dn_tx_buffer_ready_ind
60 +------------------------------------------------------------------------------
61 | Description : Process signal DTI_REASON_TX_BUFFER_READY received from
62 | dti library callback function.
63 |
64 | Parameters : -
65 |
66 | Return : -
67 +------------------------------------------------------------------------------
68 */
69 GLOBAL void sig_dti_tra_dn_tx_buffer_ready_ind()
70 {
71 TRACE_FUNCTION ("sig_dti_tra_dn_tx_buffer_ready_ind()");
72
73 if (tra_data->dn.Brk_dti_data_ind NEQ NULL)
74 {
75 /*
76 * if there is a pending break indication to be sent via DTI,
77 * send it now
78 */
79 sig_any_tra_dn_send_break_req();
80 return;
81 }
82
83 switch (GET_STATE (DN))
84 {
85 case DN_IDLE:
86 {
87 SET_STATE (DN, DN_WAIT);
88 break;
89 }
90 case DN_SEND:
91 {
92 if (dl_send_data_ind())
93 {
94 SET_STATE (DN, DN_IDLE);
95 }
96 break;
97 }
98 }
99 }
100
101 /*
102 +------------------------------------------------------------------------------
103 | Function : sig_dti_tra_dn_tx_buffer_full_ind
104 +------------------------------------------------------------------------------
105 | Description : Process signal DTI_REASON_TX_BUFFER_FULL received from
106 | dti library callback function.
107 |
108 | Parameters : -
109 |
110 | Return : -
111 +------------------------------------------------------------------------------
112
113 The buffer function of DTILIB is not used.
114 So there is nothing to be done here yet...
115
116 */
117
118 GLOBAL void sig_dti_tra_dn_tx_buffer_full_ind()
119 {
120 TRACE_FUNCTION ("sig_dti_tra_dn_tx_buffer_full_ind()");
121 }
122
123
124 /*
125 +------------------------------------------------------------------------------
126 | Function : rcv_ra_data_ind
127 +------------------------------------------------------------------------------
128 | Description : Process primitive RA_DATA_IND received from RA.
129 | This function is called if the primitive RA_DATA_IND is
130 | received or from the signal processing in l2r_pei (tra).
131 |
132 | Parameters : ra_data_ind -
133 |
134 |
135 | Return : -
136 +------------------------------------------------------------------------------
137 */
138
139 GLOBAL void rcv_ra_data_ind(T_RA_DATA_IND *ra_data_ind)
140 {
141 T_TRA_DN *ddl = &tra_data->dn;
142 T_FD *pFD = NULL;
143
144 TRACE_FUNCTION("rcv_ra_data_ind()");
145
146 if (GET_STATE (MGT) NEQ MGT_IDLE)
147 {
148 TRACE_EVENT ("data rcvd while not in state MGT_IDLE");
149
150 while (cl_ribu_data_avail(ddl->ribu))
151 {
152 cl_ribu_get(ddl->ribu);
153 }
154
155 #ifdef _SIMULATION_
156 PFREE (ra_data_ind);
157 #endif
158 return;
159 }
160
161 #ifdef _SIMULATION_
162 PACCESS (ra_data_ind);
163 if (ra_data_ind->sdu.l_buf)
164 {
165 pFD = tra_get_next_FrameDesc();
166 TRACE_EVENT_P2("put - wi=%d - ri=%d", ddl->ribu->idx.wi, ddl->ribu->idx.ri);
167 memcpy(pFD->buf, ra_data_ind->sdu.buf, ra_data_ind->sdu.l_buf >> 3);
168 pFD->len = ra_data_ind->sdu.l_buf >> 3;
169 }
170 #endif
171
172 ddl->sa = 0;
173 ddl->sb = 0;
174 ddl->x = 0;
175
176 if (ra_data_ind->status & ST_SA)
177 ddl->sa = DTI_SA_OFF;
178 if (ra_data_ind->status & ST_SB)
179 ddl->sb = DTI_SB_OFF;
180 if (ra_data_ind->status & ST_X)
181 ddl->x = DTI_FLOW_OFF;
182
183 if (ddl->ribu->idx.filled > 1)
184 TRACE_EVENT_P3("RIBU ddl: filled=%d; wi=%d; ri=%d", ddl->ribu->idx.filled, ddl->ribu->idx.wi, ddl->ribu->idx.ri);
185
186 while (cl_ribu_data_avail(ddl->ribu))
187 {
188 pFD = cl_ribu_get(ddl->ribu);
189 dl_prep_data_ind(pFD);
190 }
191
192 switch (GET_STATE (DN))
193 {
194 case DN_SEND:
195 break;
196
197 case DN_IDLE:
198 if (pFD NEQ NULL)
199 {
200 SET_STATE (DN, DN_SEND);
201 }
202 break;
203
204 case DN_WAIT:
205 if (dl_send_data_ind())
206 {
207 SET_STATE (DN, DN_IDLE);
208 }
209 break;
210
211 default:
212 break;
213 }
214 #ifdef _SIMULATION_
215 PFREE (ra_data_ind);
216 #endif
217 }