comparison src/g23m-aci/aci/cmh_l2rr.c @ 162:53929b40109c

src/g23m-aci: initial import from TCS3.2/LoCosto
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 11 Oct 2016 02:02:43 +0000
parents
children
comparison
equal deleted inserted replaced
161:4557e2a9c18e 162:53929b40109c
1 /*
2 +-----------------------------------------------------------------------------
3 | Project : GSM-PS (6147)
4 | Modul : CMH_L2RR
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 module defines the functions which are responsible
18 | for the responses of the protocol stack adapter for
19 | layer 2 relay.
20 +-----------------------------------------------------------------------------
21 */
22
23 #ifndef CMH_L2RR_C
24 #define CMH_L2RR_C
25 #endif
26
27 #include "aci_all.h"
28
29 /*==== INCLUDES ===================================================*/
30 #include "aci_cmh.h"
31 #include "ati_cmd.h"
32 #include "aci_cmd.h"
33 #include "aci_lst.h"
34 #include "dti.h" /* functionality of the dti library */
35
36 #include "aci_io.h"
37
38 #include "aci_fd.h"
39
40 #include "dti_conn_mng.h"
41 #include "dti_cntrl_mng.h"
42
43 #include "aci.h"
44 #include "psa.h"
45 #include "psa_l2r.h"
46 #include "psa_cc.h"
47 #include "cmh.h"
48 #include "psa_ra.h"
49 #include "cmh_ra.h"
50 #include "cmh_l2r.h"
51 #include "cmh_cc.h"
52
53 #include "psa_tra.h"
54
55
56 #include "cmh_ra.h"
57 #ifdef UART
58 #include "psa_uart.h"
59 #include "cmh_uart.h"
60 #endif
61
62 #ifdef FF_PSI
63 #include "psa_psi.h"
64 #include "cmh_psi.h"
65 #include "ati_src_psi.h"
66 #endif /*FF_PSI*/
67
68 #ifdef DTI
69 #include "sap_dti.h"
70 #endif
71
72 /*==== CONSTANTS ==================================================*/
73
74
75 /*==== TYPES ======================================================*/
76
77
78 /*==== EXPORT =====================================================*/
79
80 /*==== VARIABLES ==================================================*/
81
82 /*==== FUNCTIONS ==================================================*/
83
84 /*
85 +-------------------------------------------------------------------+
86 | PROJECT : GSM-PS (6147) MODULE : CMH_L2RR |
87 | ROUTINE : cmhL2R_TRA_Enabled |
88 +-------------------------------------------------------------------+
89
90 PURPOSE : L2R entity enabled, data mode
91
92 */
93
94 GLOBAL void cmhL2R_TRA_Enabled ( void )
95 {
96 SHORT cId; /* holds call id */
97
98 TRACE_FUNCTION ("cmhL2R_TRA_Enabled()");
99
100 /* find active call */
101 cId = psaCC_ctbFindCall( OWN_SRC_INV, CS_ACT, NO_VLD_CT );
102
103 if( cId NEQ NO_ENTRY AND psaCC_ctb(cId)->curCmd EQ AT_CMD_O )
104 {
105 cmhCC_PrepareCmdEnd (cId, NULL, NULL);
106 }
107 }
108 /*
109 +-------------------------------------------------------------------+
110 | PROJECT : GSM-PS (6147) MODULE : CMH_L2RR |
111 | ROUTINE : cmhL2R_Deactivated |
112 +-------------------------------------------------------------------+
113
114 PURPOSE : L2R entity deactivated, connection disconnected
115
116 */
117
118 GLOBAL void cmhL2R_Deactivated ( void )
119 {
120 TRACE_FUNCTION ("cmhL2R_Deactivated()");
121
122 cmhCC_L2R_or_TRA_Deactivated(raShrdPrm.cId); /* see issue 7527 why raShrdPrm.cId */
123
124 l2rEntStat.curCmd = AT_CMD_NONE;
125 }
126
127 /*
128 +-------------------------------------------------------------------+
129 | PROJECT : GSM-PS (6147) MODULE : CMH_L2RR |
130 | ROUTINE : cmhTRA_Deactivated |
131 +-------------------------------------------------------------------+
132
133 PURPOSE : TRA entity deactivated, connection disconnected
134
135 */
136
137 GLOBAL void cmhTRA_Deactivated ( void )
138 {
139 TRACE_FUNCTION ("cmhTRA_Deactivated()");
140
141 cmhCC_L2R_or_TRA_Deactivated(raShrdPrm.cId);
142 }
143
144 /*
145 +-------------------------------------------------------------------+
146 | PROJECT : GSM-PS (6147) MODULE : CMH_L2RR |
147 | ROUTINE : cmhL2R_TRA_Disabled |
148 +-------------------------------------------------------------------+
149
150 PURPOSE : L2R entity disabled, escape from data mode
151
152 */
153
154 GLOBAL void cmhL2R_TRA_Disabled ( T_DTI_ENTITY_ID entityId )
155 {
156 S8 source = psaCC_ctb(raShrdPrm.cId)->calOwn;
157
158 TRACE_FUNCTION ("cmhL2R_TRA_Disabled()");
159 switch (entityId)
160 {
161 #ifdef UART
162 case DTI_ENTITY_UART:
163 /* return to command mode */
164 if (uartShrdPrm.dtr_clearcall EQ FALSE)
165 {
166 R_AT( RAT_OK, (T_ACI_CMD_SRC)source )
167 ( AT_CMD_NONE );
168 }
169 break;
170 #endif
171 #if defined (FF_PSI) AND defined (DTI)
172 case DTI_ENTITY_PSI:
173 /* return to command mode */
174 if (psiShrdPrm.dtr_clearcall EQ FALSE)
175 {
176 R_AT( RAT_OK, (T_ACI_CMD_SRC)source )
177 ( AT_CMD_NONE );
178 }
179 break;
180 #endif /*FF_PSI*/
181 }
182 }
183
184 /*
185 +-------------------------------------------------------------------+
186 | PROJECT : GSM-PS (6147) MODULE : CMH_L2RR |
187 | ROUTINE : cmhL2R_Failure |
188 +-------------------------------------------------------------------+
189
190 PURPOSE : L2R entity failure, connection will be disconnected
191
192 */
193
194 GLOBAL void cmhL2R_Failure ( void )
195 {
196
197 TRACE_EVENT_P1("RLP ERROR: 0x%04x", l2rShrdPrm.set_prm[l2rShrdPrm.owner].err_cause );
198
199 /*
200 *-------------------------------------------------------------------
201 * general failure indication
202 *-------------------------------------------------------------------
203 */
204 cmhCC_L2R_Failed();
205 }
206
207
208
209 /*
210 +--------------------------------------------------------------------+
211 | PROJECT : GSM-F&D (8411) MODULE : CMH_L2RR |
212 | STATE : code ROUTINE : L2R_connect_dti_cb |
213 +--------------------------------------------------------------------+
214
215 PURPOSE : Callback for connection between L2R and UART.
216
217 */
218 #ifdef DTI
219 GLOBAL BOOL L2R_connect_dti_cb(UBYTE dti_id, T_DTI_CONN_STATE result_type)
220 {
221 T_ACI_DTI_PRC *srcInfos;
222 #ifdef FF_PSI
223 T_ACI_DTI_PRC_PSI *srcInfos_psi;
224 #endif /*FF_PSI*/
225 T_DTI_ENTITY_ID entityId = DTI_ENTITY_UART;
226 T_DTI_CNTRL info;
227
228 TRACE_FUNCTION("L2R_connect_dti_cb");
229
230
231 if (dti_cntrl_get_info_from_dti_id( dti_id, &info) EQ FALSE)
232 {
233 TRACE_EVENT_P1("cannot find info for dti_id=%d", dti_id);
234 return FALSE;
235 }
236
237 if ((srcInfos = find_element (uart_src_params, info.src_id, cmhUARTtest_srcId)) NEQ NULL)
238 entityId = DTI_ENTITY_UART;
239 #if defined (FF_PSI) AND defined (DTI)
240 if ((srcInfos_psi = find_element (psi_src_params, info.src_id, cmhPSItest_srcId)) NEQ NULL)
241 entityId = DTI_ENTITY_PSI;
242 else if (srcInfos EQ NULL AND srcInfos_psi EQ NULL)
243 #else
244 else if (srcInfos EQ NULL)
245 #endif /*FF_PSI*/
246 {
247 TRACE_EVENT_P1 ("[ERR] L2R_connect_dti_cb: srcId=%d not found", info.src_id);
248 return FALSE;
249 }
250
251 switch( result_type)
252 {
253 case(DTI_CONN_STATE_CONNECTED):
254 cmhL2R_TRA_Enabled();
255 break;
256
257 case(DTI_CONN_STATE_DISCONNECTED):
258
259 dti_cntrl_clear_conn_parms( dti_id );
260 #ifdef FF_PSI
261 if (srcInfos_psi EQ NULL)
262 {
263 TRACE_EVENT ("[ERR] L2R_connect_dti_cb: srcInfos_psi = NULL");
264 return FALSE;
265 }
266 #endif /*FF_PSI*/
267 if (srcInfos EQ NULL)
268 {
269 TRACE_EVENT ("[ERR] L2R_connect_dti_cb: srcInfos = NULL");
270 return FALSE;
271 }
272
273 if (l2rEntStat.isTempDisconnected)
274 {
275 #ifdef FF_PSI
276 if (entityId EQ DTI_ENTITY_PSI)
277 BITFIELD_SET (srcInfos_psi->data_cntr, UART_DTI_SB_BIT);
278 else
279 #endif /*FF_PSI*/
280 BITFIELD_SET (srcInfos->data_cntr, UART_DTI_SB_BIT);
281 l2rEntStat.isTempDisconnected = FALSE;
282 cmhL2R_TRA_Disabled(entityId);
283 }
284 else
285 {
286 /* action already initiated in psa_l2r */
287 /* cmhL2R_Deactivate(); */
288 #ifdef FF_PSI
289 if (entityId EQ DTI_ENTITY_PSI)
290 BITFIELD_CLEAR (srcInfos_psi->data_cntr, UART_DTI_SB_BIT);
291 else
292 #endif /*FF_PSI*/
293 BITFIELD_CLEAR (srcInfos->data_cntr, UART_DTI_SB_BIT);
294 }
295
296 if (dti_cntrl_is_dti_id_to_reconnect(dti_id))
297 {
298 T_DTI_ENTITY_ID entity_list[] = {DTI_ENTITY_ACI};
299 dti_cntrl_clear_dti_id_to_reconnect(dti_id);
300 #ifdef FF_PSI
301 if (entityId EQ DTI_ENTITY_PSI)
302 dti_cntrl_est_dpath_indirect ( info.src_id,
303 entity_list,
304 1,
305 SPLIT,
306 atiPSI_dti_cb,
307 DTI_CPBLTY_CMD,
308 DTI_CID_NOTPRESENT);
309
310 else
311 #endif /*FF_PSI*/
312 dti_cntrl_est_dpath_indirect ( info.src_id,
313 entity_list,
314 1,
315 SPLIT,
316 atiUART_dti_cb,
317 DTI_CPBLTY_CMD,
318 DTI_CID_NOTPRESENT);
319 }
320
321 break;
322
323 case(DTI_CONN_STATE_CONNECTING):
324 case(DTI_CONN_STATE_DISCONNECTING):
325 break;
326 case(DTI_CONN_STATE_ERROR):
327 dti_cntrl_close_dpath_from_dti_id( dti_id );
328 break;
329
330 default:
331 TRACE_EVENT("L2R_connect_dti_cb call with not awaited value");
332 break;
333 }
334 return TRUE;
335 }
336 #endif /* DTI */
337
338 /*
339 +--------------------------------------------------------------------+
340 | PROJECT : GSM-F&D (8411) MODULE : CMH_L2RR |
341 | STATE : code ROUTINE : TRA_connect_dti_cb |
342 +--------------------------------------------------------------------+
343
344 PURPOSE : Callback for connection between TRA and UART.
345
346 */
347
348 #ifdef DTI
349 GLOBAL BOOL TRA_connect_dti_cb(UBYTE dti_id, T_DTI_CONN_STATE result_type)
350 {
351 T_ACI_DTI_PRC *srcInfos;
352 #ifdef FF_PSI
353 T_ACI_DTI_PRC_PSI *srcInfos_psi;
354 #endif /*FF_PSI*/
355 T_DTI_ENTITY_ID entityId = DTI_ENTITY_UART;
356 T_DTI_CNTRL info;
357
358 TRACE_FUNCTION("TRA_connect_dti_cb");
359
360
361 if (dti_cntrl_get_info_from_dti_id( dti_id, &info) EQ FALSE)
362 {
363 TRACE_EVENT_P1("cannot find info for dti_id=%d", dti_id);
364 return FALSE;
365 }
366
367 if ((srcInfos = find_element (uart_src_params, info.src_id, cmhUARTtest_srcId)) NEQ NULL)
368 entityId = DTI_ENTITY_UART;
369 #if defined (FF_PSI) AND defined (DTI)
370 if((srcInfos_psi= find_element (psi_src_params, info.src_id, cmhPSItest_srcId)) NEQ NULL)
371 entityId = DTI_ENTITY_PSI;
372 else if (srcInfos EQ NULL AND srcInfos_psi EQ NULL)
373 #else
374 else if (srcInfos EQ NULL)
375 #endif /*FF_PSI*/
376 {
377 TRACE_EVENT_P1 ("[ERR] TRA_connect_dti_cb: srcId=%d not found", info.src_id);
378 return FALSE;
379 }
380
381 switch( result_type)
382 {
383 case(DTI_CONN_STATE_CONNECTED):
384 cmhL2R_TRA_Enabled();
385 break;
386
387 case(DTI_CONN_STATE_DISCONNECTED):
388
389 dti_cntrl_clear_conn_parms( dti_id );
390 #ifdef FF_PSI
391 if (srcInfos_psi EQ NULL)
392 {
393 TRACE_EVENT ("[ERR] L2R_connect_dti_cb: srcInfos_psi = NULL");
394 return FALSE;
395 }
396 #endif /*FF_PSI*/
397 if (srcInfos EQ NULL)
398 {
399 TRACE_EVENT ("[ERR] L2R_connect_dti_cb: srcInfos = NULL");
400 return FALSE;
401 }
402
403 if (raEntStat.isTempDisconnected)
404 {
405 #ifdef FF_PSI
406 if (entityId EQ DTI_ENTITY_PSI)
407 BITFIELD_SET (srcInfos_psi->data_cntr, UART_DTI_SB_BIT);
408 else
409 #endif /*FF_PSI*/
410 BITFIELD_SET (srcInfos->data_cntr, UART_DTI_SB_BIT);
411 raEntStat.isTempDisconnected = FALSE;
412 cmhL2R_TRA_Disabled(entityId);
413 }
414 else
415 {
416 #ifdef FF_PSI
417 if (entityId EQ DTI_ENTITY_PSI)
418 BITFIELD_CLEAR (srcInfos_psi->data_cntr, UART_DTI_SB_BIT);
419 else
420 #endif /*FF_PSI*/
421 BITFIELD_CLEAR (srcInfos->data_cntr, UART_DTI_SB_BIT);
422 /* psaTRA_Deactivate(); */ /* This is done in psa_trap later, otherwise TRA will crash! */
423 }
424 break;
425
426 case(DTI_CONN_STATE_CONNECTING):
427 case(DTI_CONN_STATE_DISCONNECTING):
428 break;
429 case(DTI_CONN_STATE_ERROR):
430 dti_cntrl_close_dpath_from_dti_id( dti_id );
431 break;
432
433 default:
434 TRACE_EVENT("TRA_connect_dti_cb call with not awaited value");
435 break;
436 }
437 return TRUE;
438 }
439 #endif /* DTI */
440
441 /*==== EOF ========================================================*/
442