comparison g23m/condat/ms/src/aci/psa_psis.c @ 0:509db1a7b7b8

initial import: leo2moko-r1
author Space Falcon <falcon@ivan.Harhan.ORG>
date Mon, 01 Jun 2015 03:24:05 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:509db1a7b7b8
1 /*
2 +-----------------------------------------------------------------------------
3 | Project : GSM-PS (6147)
4 | Modul : PSA_PSIS
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 processing functions for the
18 | primitives sent to the protocol stack adapter by the DTI
19 | interface.
20 +-----------------------------------------------------------------------------
21 */
22
23 #ifdef FF_PSI
24 #define PSA_PSIS_C
25
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 #include "aci_lst.h"
37 #include "dti_conn_mng.h"
38 #include "dti_cntrl_mng.h"
39 #include "psa_psi.h"
40 #include "cmh_psi.h"
41
42 #include "aci_mem.h"
43
44 #include "aci_io.h"
45
46 #include "sap_dti.h"
47
48
49
50 /*==== CONSTANTS ==================================================*/
51
52
53 /*==== TYPES ======================================================*/
54
55
56 /*==== EXPORT =====================================================*/
57
58 /*==== VARIABLES ==================================================*/
59
60
61 /*==== FUNCTIONS ==================================================*/
62
63 LOCAL USHORT psi_get_desc_size (T_desc2 *data)
64 {
65 USHORT size = 0;
66 T_desc2 *next_data;
67
68 next_data = data;
69 while (next_data NEQ NULL)
70 {
71 size += next_data->len;
72 next_data = (T_desc2*)next_data->next;
73 }
74
75 return (size);
76 }
77
78 #ifdef DTI
79
80 /*
81 +-------------------------------------------------------------------+
82 | PROJECT : GPRS (8441) MODULE : PSA_PSIS |
83 | STATE : finished ROUTINE : psaPSI_ConnectRej |
84 +-------------------------------------------------------------------+
85
86 PURPOSE : Indicates that ACI can not handle a DTI connection with PSI
87
88 */
89 GLOBAL void psaPSI_ConnRej ( U32 devId)
90 {
91 TRACE_FUNCTION ("psaPSI_ConnRej()");
92 {
93 PALLOC ( psi_conn_rej, PSI_CONN_REJ);
94 psi_conn_rej->devId = devId;
95 PSENDX (PSI, psi_conn_rej);
96 }
97 }
98
99 /*
100 +-------------------------------------------------------------------+
101 | PROJECT : GPRS (8441) MODULE : PSA_PSIS |
102 | STATE : finished ROUTINE : psaPSI_ConnectRes |
103 +-------------------------------------------------------------------+
104
105 PURPOSE : Response to PSI_CONN_IND sent by PSI with confirmed
106 DIO capabilities
107
108 */
109 GLOBAL void psaPSI_ConnRes ( U32 devId)
110 {
111 TRACE_FUNCTION ("psaPSI_ConnRes()");
112 {
113 PALLOC ( psi_conn_res, PSI_CONN_RES);
114 psi_conn_res->devId = devId;
115 PSENDX (PSI, psi_conn_res);
116 }
117 }
118
119 /*
120 +-------------------------------------------------------------------+
121 | PROJECT : GPRS (8441) MODULE : PSA_PSIS |
122 | STATE : finished ROUTINE : psaPSI_CloseReq |
123 +-------------------------------------------------------------------+
124
125 PURPOSE : Request closing of DTI connection with PSI
126
127 */
128 GLOBAL void psaPSI_CloseReq ( U32 devId)
129 {
130 TRACE_FUNCTION ("psaPSI_DTICloseReq()");
131 {
132 PALLOC ( psi_close_req, PSI_CLOSE_REQ);
133 psi_close_req->devId = devId;
134 PSENDX (PSI, psi_close_req);
135 }
136 }
137
138 /*
139 +-------------------------------------------------------------------+
140 | PROJECT : GPRS (8441) MODULE : PSA_PSIS |
141 | STATE : finished ROUTINE : psaPSI_DTICloseReq |
142 +-------------------------------------------------------------------+
143
144 PURPOSE : Request closing of DTI connection with PSI
145
146 */
147 GLOBAL void psaPSI_DTICloseReq ( U32 devId, U32 link_id)
148 {
149 TRACE_FUNCTION ("psaPSI_DTICloseReq()");
150 {
151 PALLOC ( psi_dti_close_req, PSI_DTI_CLOSE_REQ);
152 psi_dti_close_req->devId = devId;
153 psi_dti_close_req->link_id = link_id;
154 PSENDX (PSI, psi_dti_close_req);
155 }
156 }
157
158 /*
159 +-------------------------------------------------------------------+
160 | PROJECT : GPRS (8441) MODULE : PSA_PKTIOS |
161 | STATE : finished ROUTINE : psaPSI_DTIOpenReq |
162 +-------------------------------------------------------------------+
163
164 PURPOSE : Request opening of DTI connection with PSI
165
166 */
167 GLOBAL void psaPSI_DTIOpenReq ( U32 devId, char* peer_name,
168 ULONG link_id, UBYTE dti_direction)
169 {
170 TRACE_FUNCTION ("psaPSI_DTIOpenReq()");
171
172 /* if (dti_cntrl_set_conn_parms(link_id, DTI_ENTITY_PSI, (UBYTE)(devId&DIO_DEVICE_MASK),
173 UART_DLCI_NOT_MULTIPLEXED) EQ FALSE)
174 {
175 return;
176 }*/
177 {
178 PALLOC ( psi_dti_open_req, PSI_DTI_OPEN_REQ);
179 psi_dti_open_req->devId = devId;
180 memcpy( &(psi_dti_open_req->peer.name), peer_name, strlen(peer_name) + 1 );
181 psi_dti_open_req->link_id = link_id;
182 psi_dti_open_req->dti_direction = dti_direction;
183
184 PSENDX (PSI, psi_dti_open_req);
185 }
186 }
187
188 /*
189 +-------------------------------------------------------------------+
190 | PROJECT : GPRS (8441) MODULE : PSA_PSIS |
191 | STATE : finished ROUTINE : psaPSI_Dti_Req |
192 +-------------------------------------------------------------------+
193
194 PURPOSE : Request for DTI connection by DTI managment
195
196 */
197 GLOBAL void psaPSI_Dti_Req ( ULONG link_id, UBYTE peer,
198 T_DTI_MNG_PSI_MODE con_mode)
199 {
200 UBYTE device_no;
201 U32 devId;
202 char* peer_name;
203 T_DTI_CNTRL device_info;
204 U32 cpblty = DTI_CPBLTY_NO;
205
206 TRACE_FUNCTION ("psaPSI_Dti_Req()");
207
208 dti_cntrl_get_info_from_dti_id(EXTRACT_DTI_ID(link_id), &device_info);
209
210 device_no = device_info.dev_no;
211 switch (device_info.capability-DTI_CPBLTY_CMD )
212 {
213 case DTI_CPBLTY_CMD:
214 cpblty = DTI_CPBLTY_CMD;
215 break;
216 case DTI_CPBLTY_SER:
217 if (device_info.sub_no EQ 0)
218 {
219 cpblty = DIO_DATA_SER;
220 }
221 else
222 {
223 cpblty = DIO_DATA_SER_MUX;
224 }
225 break;
226 case DTI_CPBLTY_PKT:
227 cpblty = DIO_DATA_PKT;
228 break;
229 default:
230 break;
231 }
232 /*the mapping of capability between DTI and PSI should be done here, since devId relates
233 to the device type */
234 devId = ((device_info.driver_id & 0xff)<<24|
235 cpblty|
236 (device_info.dio_ctrl_id & 0xff)<<8|
237 device_no);
238 peer_name = dti_entity_name[peer].name;
239
240 if(con_mode EQ PSI_CONNECT_DTI)
241 {
242 dti_cntrl_set_conn_parms((T_DTI_CONN_LINK_ID)link_id, DTI_ENTITY_PSI,
243 device_info.dev_no, UART_DLCI_NOT_MULTIPLEXED);
244
245 psaPSI_DTIOpenReq (devId, peer_name, link_id, DTI_CHANNEL_TO_HIGHER_LAYER);
246 }
247 else
248 {
249 psaPSI_DTICloseReq(devId, link_id);
250 }
251 }
252 #endif /* DTI */
253
254 /*
255 +-------------------------------------------------------------------+
256 | PROJECT : GSM-PS (6147) MODULE : PSA_PSIS |
257 | ROUTINE : psa_psi_DTI_data_req |
258 +-------------------------------------------------------------------+
259
260 PURPOSE :
261
262 */
263
264 GLOBAL const void psa_psi_DTI_data_req (
265 T_desc2 *data,
266 T_ACI_DTI_PRC_PSI *src_infos,
267 T_DTI_ENTITY_ID peer_id
268 )
269 {
270 USHORT data_len = 0;
271 USHORT str_len = 0;
272
273 TRACE_FUNCTION("psa_psi_DTI_data_req()");
274
275 {
276 PALLOC_DESC2(dti_data_ind, DTI2_DATA_IND);
277
278 data_len = psi_get_desc_size (data);
279
280 dti_data_ind->desc_list2.list_len = data_len;
281 dti_data_ind->desc_list2.first = (ULONG)data;
282
283 dti_data_ind->parameters.p_id = 0; /*dummy_ubyte; */
284
285 if (BITFIELD_CHECK (src_infos->data_cntr, PSI_DTI_FLOW_OFF))
286 {
287 dti_data_ind->parameters.st_lines.st_flow = DTI_FLOW_OFF;
288 }
289 else
290 {
291 dti_data_ind->parameters.st_lines.st_flow = DTI_FLOW_ON;
292 }
293
294 if (BITFIELD_CHECK (src_infos->data_cntr, PSI_DTI_SB_BIT))
295 {
296 TRACE_EVENT("SB is ON");
297 dti_data_ind->parameters.st_lines.st_line_sb = DTI_SB_ON;
298 }
299 else
300 {
301 TRACE_EVENT("SB is OFF");
302 dti_data_ind->parameters.st_lines.st_line_sb = DTI_SB_OFF;
303 }
304
305 dti_data_ind->parameters.st_lines.st_line_sa = DTI_SA_ON;
306 dti_data_ind->parameters.st_lines.st_break_len = DTI_BREAK_OFF;
307
308 dti_send_data
309 (
310 aci_hDTI,
311 src_infos->srcId,
312 (UBYTE)peer_id,
313 ACI_DTI_DN_CHANNEL,
314 dti_data_ind
315 );
316 }
317 }
318
319 /*
320 +-------------------------------------------------------------------+
321 | PROJECT : GSM-PS (6147) MODULE : PSA_PSI |
322 | ROUTINE : psa_psi_DTI_getdata |
323 +-------------------------------------------------------------------+
324
325 PURPOSE :
326
327 */
328
329 GLOBAL const void psa_psi_DTI_getdata( UBYTE src_id, T_DTI_ENTITY_ID peer_id)
330 {
331 T_ACI_DTI_PRC_PSI *src_infos = NULL;
332
333 TRACE_FUNCTION("psaDTI_getdata");
334
335 src_infos = find_element (psi_src_params, src_id, cmhPSItest_srcId);
336 if (src_infos EQ NULL)
337 {
338 TRACE_EVENT_P1("[ERR] psaDTI_getdata: link_id=%d not found", src_id) ;
339 return ;
340 }
341
342 if( src_infos->RecState NEQ RECEIVING)
343 {
344 src_infos->RecState = READY_REC;
345 }
346
347 {
348 dti_start
349 (
350 aci_hDTI,
351 src_id,
352 (UBYTE)peer_id,
353 ACI_DTI_DN_CHANNEL
354 );
355 }
356 }
357
358 #ifdef DTI
359 /*
360 +-------------------------------------------------------------------+
361 | PROJECT : GSM-PS (6147) MODULE : PSA_PSI |
362 | ROUTINE : psaPSI_DCDreq |
363 +-------------------------------------------------------------------+
364
365 PURPOSE :
366
367 */
368
369 GLOBAL const void psaPSI_DCDreq( UBYTE c_Id, UBYTE line_state )
370 {
371 T_ACI_DTI_PRC_PSI *cmd = NULL;
372
373 TRACE_FUNCTION("psaPSI_DCDreq()");
374
375 cmd = find_element (psi_src_params, c_Id, cmhPSItest_srcId);
376 if (cmd EQ NULL)
377 {
378 TRACE_EVENT_P1("[ERR] psaPSI_DCDreq: c_Id=%d not found", c_Id) ;
379 return ;
380 }
381
382 {
383 PALLOC( psi_line_state_req, PSI_LINE_STATE_REQ);
384 psi_line_state_req -> devId = cmd->devId;
385 if( line_state EQ IO_DCD_ON )
386 {
387 psi_line_state_req -> line_state = LINE_STD_DCD_ON;
388 }
389 else if ( line_state EQ IO_DCD_OFF )
390 {
391 psi_line_state_req -> line_state = LINE_STD_DCD_OFF;
392 }
393
394 PSENDX( PSI, psi_line_state_req );
395 }
396 }
397
398 /*
399 +-------------------------------------------------------------------+
400 | PROJECT : GSM-PS (6147) MODULE : PSA_PSI |
401 | ROUTINE : psaPSI_ESCAPEreq |
402 +-------------------------------------------------------------------+
403
404 PURPOSE :
405
406 */
407
408 GLOBAL const BOOL psaPSI_ESCAPEreq( UBYTE c_Id, UBYTE detection )
409 {
410 T_ACI_DEVICE_DCB_ENTRY *device_entry = cmhPSI_GetDeviceParOverSrcID( c_Id );
411 U32 device_type;
412 if ( device_entry EQ NULL )
413 {
414 TRACE_EVENT_P1("[ERR] cmhPSI_SetDataRate: device for source ID = %d not found", c_Id);
415 return (FALSE);
416 }
417
418 TRACE_FUNCTION("psaPSI_ESCAPEreq()");
419
420 device_type = device_entry->devId & DIO_TYPE_DAT_MASK;
421 cmhPSI_SetDcbParToUnchanged( device_entry );
422 if (device_type EQ DIO_DATA_SER)
423 {
424 if( detection EQ ESC_DETECTION_ON)
425 {
426 device_entry->dcbPar.dio_dcb_ser.guard_period = DIO_GUARD_PER_DEFAULT;
427 }
428 else
429 {
430 device_entry->dcbPar.dio_dcb_ser.guard_period = 0;
431 }
432 }
433 else if (device_type EQ DIO_DATA_MUX)
434 {
435 if( detection EQ ESC_DETECTION_ON)
436 {
437 device_entry->dcbPar.dio_dcb_ser_mux.guard_period = DIO_GUARD_PER_DEFAULT;
438 }
439 else
440 {
441 device_entry->dcbPar.dio_dcb_ser_mux.guard_period = 0;
442 }
443 }
444
445 else /* if (device_type EQ DIO_DATA_PKT)*/
446 {
447 return (FALSE);
448 }
449
450 psaPSI_SetConfReq(device_entry);
451
452 return (TRUE);
453
454 }
455
456 /*
457 +-------------------------------------------------------------------+
458 | PROJECT : GSM-PS (6147) MODULE : PSA_PSI |
459 | ROUTINE : psaPSI_RINGreq |
460 +-------------------------------------------------------------------+
461
462 PURPOSE :
463
464 */
465
466 GLOBAL const void psaPSI_RINGreq( UBYTE c_Id, UBYTE line_state )
467 {
468 T_ACI_DTI_PRC_PSI *cmd = NULL;
469
470 TRACE_FUNCTION("psaPSI_RINGreq");
471
472 cmd = find_element (psi_src_params, c_Id, cmhPSItest_srcId);
473 if (cmd EQ NULL)
474 {
475 TRACE_EVENT_P1("[ERR] psaPSI_RINGreq: c_Id=%d not found", c_Id) ;
476 return ;
477 }
478
479 if (BITFIELD_CHECK (cmd->data_cntr, PSI_RING_RUNNING))
480 {
481 TRACE_EVENT_P2 ("[WRN] psaPSI_RINGreq(): no CNF for previous REQ (device: %d; dlci=%d)",
482 cmd->devId, cmd->dlci);
483 return;
484 }
485
486 /*
487 store that PSI_RING_REQ was send
488 this is important so that the primitive queue in the PSI entity not
489 overloaded if no PC is connected
490 */
491 BITFIELD_SET (cmd->data_cntr, PSI_RING_RUNNING);
492
493 {
494 PALLOC( psi_line_state_req, PSI_LINE_STATE_REQ);
495 psi_line_state_req -> devId = cmd->devId;
496
497 if( line_state EQ IO_RING_ON)
498 {
499 psi_line_state_req -> line_state = LINE_STD_RING_ON;
500 }
501 else if( line_state EQ IO_RING_OFF )
502 {
503 psi_line_state_req -> line_state = LINE_STD_RING_OFF;
504 }
505
506 PSENDX( PSI, psi_line_state_req);
507 }
508 }
509
510 /*
511 +------------------------------------------------------------------------+
512 | PROJECT : GSM-PS (6147) MODULE : PSA_PSI |
513 | ROUTINE : psaPSI_SetConfReq |
514 +------------------------------------------------------------------------+
515
516 PURPOSE :
517
518 */
519
520 GLOBAL const void psaPSI_SetConfReq( T_ACI_DEVICE_DCB_ENTRY *dcbPar )
521 {
522 U32 device_type;
523 #ifdef _SIMULATION_
524 PALLOC(psi_setconf_req_test, PSI_SETCONF_REQ_TEST);
525
526 device_type = dcbPar->devId & DIO_TYPE_DAT_MASK;
527 psi_setconf_req_test->devId = dcbPar->devId;
528 switch (device_type)
529 {
530 case DIO_DATA_SER:
531 memcpy(&psi_setconf_req_test->DIO_DCB_UN.DIO_DCB_SER,&dcbPar->dcbPar.dio_dcb_ser,sizeof(T_DIO_DCB_SER));
532 break;
533 case DIO_DATA_PKT:
534 memcpy(&psi_setconf_req_test->DIO_DCB_UN.DIO_DCB_PKT,&dcbPar->dcbPar.dio_dcb_pkt,sizeof(T_DIO_DCB_PKT));
535 break;
536 case DIO_DATA_SER_MUX:
537 memcpy(&psi_setconf_req_test->DIO_DCB_UN.DIO_DCB_SER_MUX,&dcbPar->dcbPar.dio_dcb_ser_mux,sizeof(T_DIO_DCB_SER_MUX));
538 break;
539 default:
540 break;
541 }
542 PSENDX( PSI, psi_setconf_req_test );
543 #else
544 PALLOC(psi_setconf_req, PSI_SETCONF_REQ);
545
546 device_type = dcbPar->devId & DIO_TYPE_DAT_MASK;
547 psi_setconf_req->devId = dcbPar->devId;
548 switch (device_type)
549 {
550 case DIO_DATA_SER:
551 psi_setconf_req->ptr_DIO_DCB = (T_DIO_DCB *) &dcbPar->dcbPar.dio_dcb_ser;
552 break;
553 case DIO_DATA_PKT:
554 psi_setconf_req->ptr_DIO_DCB =(T_DIO_DCB *) &dcbPar->dcbPar.dio_dcb_pkt;
555 break;
556 case DIO_DATA_SER_MUX:
557 psi_setconf_req->ptr_DIO_DCB =(T_DIO_DCB *) &dcbPar->dcbPar.dio_dcb_ser_mux;
558 break;
559 default:
560 break;
561 }
562 PSENDX( PSI, psi_setconf_req );
563 #endif /* _SIMULATION_ */
564 }
565 #endif /* DTI */
566 #endif /*FF_PSI*/
567 /*==== EOF =======================================================*/
568