comparison src/g23m-aci/aci/cmh_l2rs.c @ 1:fa8dc04885d8

src/g23m-*: import from Magnetite
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 16 Oct 2020 06:25:50 +0000
parents
children
comparison
equal deleted inserted replaced
0:4e78acac3d88 1:fa8dc04885d8
1 /*
2 +-----------------------------------------------------------------------------
3 | Project : GSM-PS (6147)
4 | Modul : CMH_L2RS
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 provides the set functions related to the
18 | protocol stack adapter for L2R.
19 +-----------------------------------------------------------------------------
20 */
21 #ifdef DTI
22
23 #ifndef CMH_L2RS_C
24 #define CMH_L2RS_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 "dti.h" /* functionality of the dti library */
34
35 #include "aci.h"
36
37 #ifdef FAX_AND_DATA
38 #include "aci_fd.h"
39 #endif /* of #ifdef FAX_AND_DATA */
40
41 #include "dti_conn_mng.h"
42 #include "dti_cntrl_mng.h"
43
44 #include "psa.h"
45 #include "cmh.h"
46 #include "cmh_ra.h"
47 #include "psa_l2r.h"
48 #include "cmh_l2r.h"
49 #include "psa_ra.h"
50
51 #include "psa_tra.h"
52
53 #ifdef UART
54 #include "psa_uart.h"
55 #endif
56 #ifdef FF_PSI
57 #include "psa_psi.h"
58 #endif /*FF_PSI*/
59 /*==== CONSTANTS ==================================================*/
60
61 /*==== EXPORT =====================================================*/
62
63 /*==== VARIABLES ==================================================*/
64
65 /*==== FUNCTIONS ==================================================*/
66
67 /*
68 +--------------------------------------------------------------------+
69 | PROJECT : GSM-PS (6147) MODULE : CMH_L2RS |
70 | STATE : code ROUTINE : sAT_PlusCRLP |
71 +--------------------------------------------------------------------+
72
73 PURPOSE : This is the functional counterpart to the +CRLP AT command
74 which is responsible to set the radio link protocol
75 parameters for following asynchronous data transfer calls.
76
77 <iws>: IWF to MS window size.
78 <mws>: MS to IWF window size
79 <t1> : acknowledge timer
80 <n2> : retransmission attemps
81 */
82
83 GLOBAL T_ACI_RETURN sAT_PlusCRLP ( T_ACI_CMD_SRC srcId,
84 SHORT iws, SHORT mws,
85 SHORT t1, SHORT n2)
86 {
87 T_L2R_CMD_PRM * pL2RCmdPrm; /* points to L2R command parameters */
88
89 TRACE_FUNCTION ("sAT_PlusCRLP()");
90
91 /*
92 *-------------------------------------------------------------------
93 * check command source
94 *-------------------------------------------------------------------
95 */
96 if(!cmh_IsVldCmdSrc (srcId))
97 {
98 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
99 return( AT_FAIL );
100 }
101
102 pL2RCmdPrm = &fnd_cmhPrm[srcId].l2rCmdPrm;
103
104 /*
105 *-------------------------------------------------------------------
106 * process the iws parameter ( IWF to MS window size )
107 *-------------------------------------------------------------------
108 */
109 if( iws NEQ ACI_NumParmNotPresent )
110 {
111 if( iws > L2R_K_IWF_MS_MAX OR iws < L2R_K_IWF_MS_MIN )
112 {
113 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
114 return( AT_FAIL );
115 }
116 }
117 else
118
119 iws = pL2RCmdPrm -> CRLPiws;
120 /*
121 *-------------------------------------------------------------------
122 * process the mws parameter ( MS to IWF window size )
123 *-------------------------------------------------------------------
124 */
125 if( mws NEQ ACI_NumParmNotPresent )
126 {
127 if( mws > L2R_K_MS_IWF_MAX OR mws < L2R_K_MS_IWF_MIN )
128 {
129 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
130 return( AT_FAIL );
131 }
132 }
133 else
134
135 mws = pL2RCmdPrm -> CRLPmws;
136
137 /*
138 *-------------------------------------------------------------------
139 * process the t1 parameter ( acknowledge timer )
140 *-------------------------------------------------------------------
141 */
142 if( t1 NEQ ACI_NumParmNotPresent )
143 {
144 if( t1 > L2R_T1_MAX OR t1 < L2R_T1_MIN )
145 {
146 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
147 return( AT_FAIL );
148 }
149 }
150 else
151
152 t1 = pL2RCmdPrm -> CRLPt1;
153
154 /*
155 *-------------------------------------------------------------------
156 * process the n2 parameter ( retransmission attemps )
157 *-------------------------------------------------------------------
158 */
159 if( n2 NEQ ACI_NumParmNotPresent )
160 {
161 if( n2 > L2R_N2_MAX OR n2 < L2R_N2_MIN )
162 {
163 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
164 return( AT_FAIL );
165 }
166 }
167 else
168
169 n2 = pL2RCmdPrm -> CRLPn2;
170
171 /*
172 *-------------------------------------------------------------------
173 * assign the parameters
174 *-------------------------------------------------------------------
175 */
176 pL2RCmdPrm -> CRLPiws = iws;
177 pL2RCmdPrm -> CRLPmws = mws;
178 pL2RCmdPrm -> CRLPt1 = t1;
179 pL2RCmdPrm -> CRLPn2 = n2;
180
181 return( AT_CMPL );
182 }
183
184 /*
185 +--------------------------------------------------------------------+
186 | PROJECT : GSM-PS (6147) MODULE : CMH_L2RS |
187 | STATE : code ROUTINE : sAT_PlusDS |
188 +--------------------------------------------------------------------+
189
190 PURPOSE : This is the functional counterpart to the +DS AT command
191 which is responsible to set the data compression control
192 parameters for following asynchronous data transfer calls.
193
194 <dir> : desired direction of data compression.
195 <comp> : mode of continue
196 <maxDict> : maximum number of dictionary entries
197 <maxStr> : maximum string length
198 */
199
200 GLOBAL T_ACI_RETURN sAT_PlusDS ( T_ACI_CMD_SRC srcId,
201 T_ACI_DS_DIR dir,
202 T_ACI_DS_COMP comp,
203 LONG maxDict,
204 SHORT maxStr )
205 {
206 T_L2R_CMD_PRM * pL2RCmdPrm; /* points to L2R command parameters */
207
208 TRACE_FUNCTION ("sAT_PlusDS()");
209
210 /*
211 *-------------------------------------------------------------------
212 * check command source
213 *-------------------------------------------------------------------
214 */
215 if(!cmh_IsVldCmdSrc (srcId))
216 {
217 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
218 return( AT_FAIL );
219 }
220
221 pL2RCmdPrm = &fnd_cmhPrm[srcId].l2rCmdPrm;
222
223 /*
224 *-------------------------------------------------------------------
225 * process the dir parameter
226 *-------------------------------------------------------------------
227 */
228 switch( dir )
229 {
230 case( DS_DIR_NotPresent ):
231
232 dir = pL2RCmdPrm -> DSdir;
233 break;
234
235 case( DS_DIR_Negotiated ):
236 case( DS_DIR_TxOnly ):
237 case( DS_DIR_RxOnly ):
238 case( DS_DIR_Both ):
239
240 break;
241
242 default:
243
244 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
245 return( AT_FAIL );
246 }
247
248 /*
249 *-------------------------------------------------------------------
250 * process the comp parameter
251 *-------------------------------------------------------------------
252 */
253 switch( comp )
254 {
255 case( DS_COMP_NotPresent ):
256
257 comp = pL2RCmdPrm -> DScomp;
258 break;
259
260 case( DS_COMP_DoNotDisc ):
261 case( DS_COMP_Disc ):
262
263 break;
264
265 default:
266
267 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
268 return( AT_FAIL );
269 }
270
271 /*
272 *-------------------------------------------------------------------
273 * process the maxDict parameter
274 *-------------------------------------------------------------------
275 */
276 if( maxDict NEQ ACI_NumParmNotPresent )
277 {
278 if( maxDict > L2R_P1_MAX OR maxDict < L2R_P1_MIN )
279 {
280 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
281 return( AT_FAIL );
282 }
283 }
284 else
285
286 maxDict = pL2RCmdPrm -> DSmaxDict;
287
288 /*
289 *-------------------------------------------------------------------
290 * process the maxStr parameter
291 *-------------------------------------------------------------------
292 */
293 if( maxStr NEQ ACI_NumParmNotPresent )
294 {
295 if( maxStr > L2R_P2_MAX OR maxStr < L2R_P2_MIN )
296 {
297 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
298 return( AT_FAIL );
299 }
300 }
301 else
302
303 maxStr = pL2RCmdPrm -> DSmaxStr;
304
305 /*
306 *-------------------------------------------------------------------
307 * assign the parameters
308 *-------------------------------------------------------------------
309 */
310 pL2RCmdPrm -> DSdir = dir;
311 pL2RCmdPrm -> DScomp = comp;
312 pL2RCmdPrm -> DSmaxDict = maxDict;
313 pL2RCmdPrm -> DSmaxStr = maxStr;
314
315 return( AT_CMPL );
316
317 }
318
319 /*
320 +-------------------------------------------------------------------+
321 | PROJECT : GSM-PS (6147) MODULE : CMH_L2R |
322 | ROUTINE : cmhL2R_Activate |
323 +-------------------------------------------------------------------+
324
325 PURPOSE : set all nescessary parameters and activate L2R
326
327 */
328
329 GLOBAL T_ACI_RETURN cmhL2R_Activate ( T_ACI_CMD_SRC srcId,
330 T_ACI_AT_CMD cmdId,
331 SHORT cId )
332 {
333 T_L2R_CMD_PRM * pL2RCmdPrm; /* points to L2R command parameters */
334 T_L2R_SET_PRM * pL2RSetPrm; /* points to L2R parameter set */
335
336 TRACE_FUNCTION ("cmhL2R_Activate()");
337
338 /*
339 *-------------------------------------------------------------------
340 * check command source
341 *-------------------------------------------------------------------
342 */
343 if(!cmh_IsVldCmdSrc (srcId))
344
345 return( AT_FAIL );
346
347 pL2RCmdPrm = &fnd_cmhPrm[srcId].l2rCmdPrm;
348 pL2RSetPrm = &l2rShrdPrm.set_prm[srcId];
349
350 /*
351 *-------------------------------------------------------------------
352 * fill in activate parameters
353 *-------------------------------------------------------------------
354 */
355 pL2RSetPrm -> k_ms_iwf = pL2RCmdPrm -> CRLPmws;
356 pL2RSetPrm -> k_iwf_ms = pL2RCmdPrm -> CRLPiws;
357 pL2RSetPrm -> t1 = (UBYTE)pL2RCmdPrm -> CRLPt1;
358 pL2RSetPrm -> n2 = (UBYTE)pL2RCmdPrm -> CRLPn2;
359
360 pL2RSetPrm -> p0 = cmhL2R_SelCompDir( pL2RCmdPrm );
361 pL2RSetPrm -> p1 = (USHORT)pL2RCmdPrm -> DSmaxDict;
362 pL2RSetPrm -> p2 = (UBYTE)pL2RCmdPrm -> DSmaxStr;
363
364 pL2RSetPrm -> uil2p = L2R_ISO6429;
365 pL2RSetPrm -> rate = cmhL2R_SelChnRate();
366
367
368 l2rEntStat.curCmd = cmdId;
369 l2rEntStat.entOwn = srcId;
370
371 if( psaL2R_Activate((UBYTE)srcId ) < 0 ) /* activate L2R */
372 {
373 TRACE_EVENT( "FATAL RETURN psaL2R in cmhL2R_Activate" );
374 return( AT_FAIL );
375 }
376
377 return( AT_EXCT );
378
379 }
380
381 /*
382 +-------------------------------------------------------------------+
383 | PROJECT : GSM-PS (6147) MODULE : CMH_L2R |
384 | ROUTINE : cmhL2R_Deactivate |
385 +-------------------------------------------------------------------+
386
387 PURPOSE : set all nescessary parameters and deactivate L2R
388
389 */
390
391 GLOBAL T_ACI_RETURN cmhL2R_Deactivate ( void )
392 {
393 UBYTE src_id = raShrdPrm.owner;
394 UBYTE dti_id;
395 T_DTI_CNTRL info;
396
397 TRACE_FUNCTION ("cmhL2R_Deactivate()");
398
399
400 if (dti_cntrl_get_info_from_src_id( src_id, &info) EQ FALSE)
401 {
402 TRACE_EVENT_P1("cannot find info for src_id=%d", src_id);
403
404 if( psaL2R_Deactivate() < 0 ) /* deactivate L2R */
405 {
406 TRACE_EVENT( "FATAL RETURN psaL2R in cmhL2R_Deactivate" );
407 return( AT_FAIL );
408 }
409 return( AT_EXCT );
410 }
411
412 #if defined (FF_TCP_IP)
413 if( dti_cntrl_is_dti_channel_connected(DTI_ENTITY_AAA, info.dti_id) EQ TRUE )
414 {
415 if ( dti_cntrl_close_dpath_from_src_id(src_id) EQ TRUE )
416 {
417 return( AT_EXCT );
418 }
419 else
420 {
421 TRACE_EVENT("FATAL RETURN in dti_cntrl_close_dpath_from_src_id");
422 return( AT_FAIL );
423 }
424 }
425 #endif /* FF_TCP_IP */
426
427 dti_id = info.dti_id;
428
429 /* get the redirection of this src_id */
430 if (info.redirect_info.info.direction EQ DTI_DEV_IS_REDIRECTED)
431 {
432 T_DTI_CNTRL tmp_param;
433 if (BITFIELD_CHECK(info.redirect_info.info.capability, DTI_CPBLTY_SER))
434 {
435 dti_cntrl_get_first_redirection (info.src_id, DTI_CPBLTY_SER, &tmp_param);
436 src_id = tmp_param.src_id;
437 dti_id = tmp_param.dti_id;
438 }
439 else if (BITFIELD_CHECK(info.redirect_info.info.capability, DTI_CPBLTY_PKT))
440 {
441 dti_cntrl_get_first_redirection (info.src_id, DTI_CPBLTY_PKT, &tmp_param);
442 src_id = tmp_param.src_id;
443 dti_id = tmp_param.dti_id;
444 }
445 else
446 {
447 TRACE_EVENT("capability is not SER or PKT");
448 }
449 }
450 if( dti_cntrl_is_dti_channel_connected(DTI_ENTITY_L2R, dti_id) EQ TRUE AND
451 dti_cntrl_is_dti_channel_connected(DTI_ENTITY_UART, dti_id) EQ TRUE)
452 { /*no internal dti_id */
453 T_DTI_ENTITY_ID entity_list[] = {DTI_ENTITY_ACI};
454 if (dti_cntrl_est_dpath_indirect ( src_id,
455 entity_list,
456 1,
457 SPLIT,
458 atiUART_dti_cb,
459 DTI_CPBLTY_CMD,
460 DTI_CID_NOTPRESENT) EQ TRUE)
461 {
462 return( AT_EXCT );
463 }
464 else
465 {
466 /* deactivate */
467 if( psaL2R_Deactivate() < 0 ) /* deactivate L2R */
468 {
469 TRACE_EVENT( "FATAL RETURN psaL2R in cmhL2R_Deactivate" );
470 return( AT_FAIL );
471 }
472 }
473 }
474 #ifdef FF_PSI
475 if (dti_cntrl_is_dti_channel_connected(DTI_ENTITY_L2R, dti_id) AND
476 dti_cntrl_is_dti_channel_connected(DTI_ENTITY_PSI, dti_id))
477 {
478 T_DTI_ENTITY_ID entity_list[] = {DTI_ENTITY_ACI};
479 if (dti_cntrl_est_dpath_indirect ( src_id,
480 entity_list,
481 1,
482 SPLIT,
483 atiPSI_dti_cb,
484 DTI_CPBLTY_CMD,
485 DTI_CID_NOTPRESENT) EQ TRUE)
486
487 {
488 return( AT_EXCT );
489 }
490 else
491 {
492 /* deactivate */
493 if( psaL2R_Deactivate() < 0 ) /* deactivate L2R */
494 {
495 TRACE_EVENT( "FATAL RETURN psaL2R in cmhL2R_Deactivate" );
496 return( AT_FAIL );
497 }
498 }
499 }
500 #endif /*FF_PSI*/
501
502 else
503 {
504 if( psaL2R_Deactivate() < 0 ) /* deactivate L2R */
505 {
506 TRACE_EVENT( "FATAL RETURN psaL2R in cmhL2R_Deactivate" );
507 return( AT_FAIL );
508 }
509 }
510
511 return( AT_EXCT );
512 }
513
514 /*
515 +-------------------------------------------------------------------+
516 | PROJECT : GSM-PS (6147) MODULE : CMH_L2R |
517 | ROUTINE : cmhTRA_Deactivate |
518 +-------------------------------------------------------------------+
519
520 PURPOSE : set all nescessary parameters and deactivate TRA
521
522 */
523
524 GLOBAL T_ACI_RETURN cmhTRA_Deactivate ( void )
525 {
526 UBYTE src_id = raShrdPrm.owner;
527 UBYTE dti_id;
528 T_DTI_CNTRL info;
529
530 TRACE_FUNCTION ("cmhTRA_Deactivate()");
531
532
533 if (dti_cntrl_get_info_from_src_id( src_id, &info) EQ FALSE)
534 {
535 TRACE_EVENT_P1("cannot find info for src_id=%d", src_id);
536
537 psaTRA_Deactivate(); /* deactivate TRA */
538 return( AT_EXCT );
539 }
540
541 dti_id = info.dti_id;
542
543 /* get the redirection of this src_id */
544 if (info.redirect_info.info.direction EQ DTI_DEV_IS_REDIRECTED)
545 {
546 T_DTI_CNTRL tmp_param;
547 if (BITFIELD_CHECK(info.redirect_info.info.capability, DTI_CPBLTY_SER))
548 {
549 dti_cntrl_get_first_redirection (info.src_id, DTI_CPBLTY_SER, &tmp_param);
550 src_id = tmp_param.src_id;
551 dti_id = tmp_param.dti_id;
552 }
553 else if (BITFIELD_CHECK(info.redirect_info.info.capability, DTI_CPBLTY_PKT))
554 {
555 dti_cntrl_get_first_redirection (info.src_id, DTI_CPBLTY_PKT, &tmp_param);
556 src_id = tmp_param.src_id;
557 dti_id = tmp_param.dti_id;
558 }
559 else
560 {
561 TRACE_EVENT("capability is not SER or PKT");
562 }
563 }
564 if (dti_cntrl_is_dti_channel_connected(DTI_ENTITY_TRA, dti_id) AND
565 dti_cntrl_is_dti_channel_connected(DTI_ENTITY_UART, dti_id))
566 {
567 T_DTI_ENTITY_ID entity_list[] = {DTI_ENTITY_ACI};
568 if (dti_cntrl_est_dpath_indirect ( src_id,
569 entity_list,
570 1,
571 SPLIT,
572 atiUART_dti_cb,
573 DTI_CPBLTY_CMD,
574 DTI_CID_NOTPRESENT) EQ TRUE)
575 {
576 return( AT_EXCT );
577 }
578 else
579 {
580 /* deactivate */
581 psaTRA_Deactivate(); /* deactivate TRA */
582 }
583 }
584
585 #ifdef FF_PSI
586
587 if (dti_cntrl_is_dti_channel_connected(DTI_ENTITY_TRA, dti_id) AND
588 dti_cntrl_is_dti_channel_connected(DTI_ENTITY_PSI, dti_id))
589 {
590 T_DTI_ENTITY_ID entity_list[] = {DTI_ENTITY_ACI};
591 if (dti_cntrl_est_dpath_indirect ( src_id,
592 entity_list,
593 1,
594 SPLIT,
595 atiPSI_dti_cb,
596 DTI_CPBLTY_CMD,
597 DTI_CID_NOTPRESENT) EQ TRUE)
598
599 {
600 return( AT_EXCT );
601 }
602 else
603 {
604 /* deactivate */
605 psaTRA_Deactivate(); /* deactivate TRA */
606 }
607 }
608 #endif /*FF_PSI*/
609
610 else
611 {
612 psaTRA_Deactivate(); /* deactivate TRA */
613 }
614
615 return( AT_EXCT );
616 }
617 #endif /* DTI */
618 /*==== EOF ========================================================*/