comparison gsm-fw/g23m-aci/aci/psa_psis.c @ 775:eedbf248bac0

gsm-fw/g23m-aci subtree: initial import from LoCosto source
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Sun, 12 Oct 2014 01:45:14 +0000
parents
children
comparison
equal deleted inserted replaced
774:40a721fd9854 775:eedbf248bac0
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 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
272 TRACE_FUNCTION("psa_psi_DTI_data_req()");
273
274 {
275 PALLOC_DESC2(dti_data_ind, DTI2_DATA_IND);
276
277 data_len = psi_get_desc_size (data);
278
279 dti_data_ind->desc_list2.list_len = data_len;
280 dti_data_ind->desc_list2.first = (ULONG)data;
281
282 dti_data_ind->parameters.p_id = 0; /*dummy_ubyte; */
283
284 if (BITFIELD_CHECK (src_infos->data_cntr, PSI_DTI_FLOW_OFF))
285 {
286 dti_data_ind->parameters.st_lines.st_flow = DTI_FLOW_OFF;
287 }
288 else
289 {
290 dti_data_ind->parameters.st_lines.st_flow = DTI_FLOW_ON;
291 }
292
293 if (BITFIELD_CHECK (src_infos->data_cntr, PSI_DTI_SB_BIT))
294 {
295 TRACE_EVENT("SB is ON");
296 dti_data_ind->parameters.st_lines.st_line_sb = DTI_SB_ON;
297 }
298 else
299 {
300 TRACE_EVENT("SB is OFF");
301 dti_data_ind->parameters.st_lines.st_line_sb = DTI_SB_OFF;
302 }
303
304 dti_data_ind->parameters.st_lines.st_line_sa = DTI_SA_ON;
305 dti_data_ind->parameters.st_lines.st_break_len = DTI_BREAK_OFF;
306
307 dti_send_data
308 (
309 aci_hDTI,
310 src_infos->srcId,
311 (UBYTE)peer_id,
312 ACI_DTI_DN_CHANNEL,
313 dti_data_ind
314 );
315 }
316 }
317
318 /*
319 +-------------------------------------------------------------------+
320 | PROJECT : GSM-PS (6147) MODULE : PSA_PSI |
321 | ROUTINE : psa_psi_DTI_getdata |
322 +-------------------------------------------------------------------+
323
324 PURPOSE :
325
326 */
327
328 GLOBAL void psa_psi_DTI_getdata( UBYTE src_id, T_DTI_ENTITY_ID peer_id)
329 {
330 T_ACI_DTI_PRC_PSI *src_infos = NULL;
331
332 TRACE_FUNCTION("psaDTI_getdata");
333
334 src_infos = find_element (psi_src_params, src_id, cmhPSItest_srcId);
335 if (src_infos EQ NULL)
336 {
337 TRACE_EVENT_P1("[ERR] psaDTI_getdata: link_id=%d not found", src_id) ;
338 return ;
339 }
340
341 if( src_infos->RecState NEQ RECEIVING)
342 {
343 src_infos->RecState = READY_REC;
344 }
345
346 {
347 dti_start
348 (
349 aci_hDTI,
350 src_id,
351 (UBYTE)peer_id,
352 ACI_DTI_DN_CHANNEL
353 );
354 }
355 }
356
357 #ifdef DTI
358 /*
359 +-------------------------------------------------------------------+
360 | PROJECT : GSM-PS (6147) MODULE : PSA_PSI |
361 | ROUTINE : psaPSI_DCDreq |
362 +-------------------------------------------------------------------+
363
364 PURPOSE :
365
366 */
367
368 GLOBAL void psaPSI_DCDreq( UBYTE c_Id, UBYTE line_state )
369 {
370 T_ACI_DTI_PRC_PSI *cmd = NULL;
371
372 TRACE_FUNCTION("psaPSI_DCDreq()");
373
374 cmd = find_element (psi_src_params, c_Id, cmhPSItest_srcId);
375 if (cmd EQ NULL)
376 {
377 TRACE_EVENT_P1("[ERR] psaPSI_DCDreq: c_Id=%d not found", c_Id) ;
378 return ;
379 }
380
381 {
382 PALLOC( psi_line_state_req, PSI_LINE_STATE_REQ);
383 psi_line_state_req -> devId = cmd->devId;
384 if( line_state EQ IO_DCD_ON )
385 {
386 psi_line_state_req -> line_state = LINE_STD_DCD_ON;
387 }
388 else if ( line_state EQ IO_DCD_OFF )
389 {
390 psi_line_state_req -> line_state = LINE_STD_DCD_OFF;
391 }
392
393 PSENDX( PSI, psi_line_state_req );
394 }
395 }
396
397 /*
398 +-------------------------------------------------------------------+
399 | PROJECT : GSM-PS (6147) MODULE : PSA_PSI |
400 | ROUTINE : psaPSI_ESCAPEreq |
401 +-------------------------------------------------------------------+
402
403 PURPOSE :
404
405 */
406
407 GLOBAL BOOL psaPSI_ESCAPEreq( UBYTE c_Id, UBYTE detection )
408 {
409 T_ACI_DEVICE_DCB_ENTRY *device_entry = cmhPSI_GetDeviceParOverSrcID( c_Id );
410 U32 device_type;
411 if ( device_entry EQ NULL )
412 {
413 TRACE_EVENT_P1("[ERR] cmhPSI_SetDataRate: device for source ID = %d not found", c_Id);
414 return (FALSE);
415 }
416
417 TRACE_FUNCTION("psaPSI_ESCAPEreq()");
418
419 device_type = device_entry->devId & DIO_TYPE_DAT_MASK;
420 cmhPSI_SetDcbParToUnchanged( device_entry );
421 if (device_type EQ DIO_DATA_SER)
422 {
423 if( detection EQ ESC_DETECTION_ON)
424 {
425 device_entry->dcbPar.dio_dcb_ser.guard_period = DIO_GUARD_PER_DEFAULT;
426 }
427 else
428 {
429 device_entry->dcbPar.dio_dcb_ser.guard_period = 0;
430 }
431 }
432 else if (device_type EQ DIO_DATA_MUX)
433 {
434 if( detection EQ ESC_DETECTION_ON)
435 {
436 device_entry->dcbPar.dio_dcb_ser_mux.guard_period = DIO_GUARD_PER_DEFAULT;
437 }
438 else
439 {
440 device_entry->dcbPar.dio_dcb_ser_mux.guard_period = 0;
441 }
442 }
443
444 else /* if (device_type EQ DIO_DATA_PKT)*/
445 {
446 return (FALSE);
447 }
448
449 psaPSI_SetConfReq(device_entry);
450
451 return (TRUE);
452
453 }
454
455 /*
456 +-------------------------------------------------------------------+
457 | PROJECT : GSM-PS (6147) MODULE : PSA_PSI |
458 | ROUTINE : psaPSI_RINGreq |
459 +-------------------------------------------------------------------+
460
461 PURPOSE :
462
463 */
464
465 GLOBAL void psaPSI_RINGreq( UBYTE c_Id, UBYTE line_state )
466 {
467 T_ACI_DTI_PRC_PSI *cmd = NULL;
468
469 TRACE_FUNCTION("psaPSI_RINGreq");
470
471 cmd = find_element (psi_src_params, c_Id, cmhPSItest_srcId);
472 if (cmd EQ NULL)
473 {
474 TRACE_EVENT_P1("[ERR] psaPSI_RINGreq: c_Id=%d not found", c_Id) ;
475 return ;
476 }
477
478 if (BITFIELD_CHECK (cmd->data_cntr, PSI_RING_RUNNING))
479 {
480 TRACE_EVENT_P2 ("[WRN] psaPSI_RINGreq(): no CNF for previous REQ (device: %d; dlci=%d)",
481 cmd->devId, cmd->dlci);
482 return;
483 }
484
485 /*
486 store that PSI_RING_REQ was send
487 this is important so that the primitive queue in the PSI entity not
488 overloaded if no PC is connected
489 */
490 BITFIELD_SET (cmd->data_cntr, PSI_RING_RUNNING);
491
492 {
493 PALLOC( psi_line_state_req, PSI_LINE_STATE_REQ);
494 psi_line_state_req -> devId = cmd->devId;
495
496 if( line_state EQ IO_RING_ON)
497 {
498 psi_line_state_req -> line_state = LINE_STD_RING_ON;
499 }
500 else if( line_state EQ IO_RING_OFF )
501 {
502 psi_line_state_req -> line_state = LINE_STD_RING_OFF;
503 }
504
505 PSENDX( PSI, psi_line_state_req);
506 }
507 }
508
509 /*
510 +------------------------------------------------------------------------+
511 | PROJECT : GSM-PS (6147) MODULE : PSA_PSI |
512 | ROUTINE : psaPSI_SetConfReq |
513 +------------------------------------------------------------------------+
514
515 PURPOSE :
516
517 */
518
519 GLOBAL void psaPSI_SetConfReq( T_ACI_DEVICE_DCB_ENTRY *dcbPar )
520 {
521 U32 device_type;
522 #ifdef _SIMULATION_
523 PALLOC(psi_setconf_req_test, PSI_SETCONF_REQ_TEST);
524
525 device_type = dcbPar->devId & DIO_TYPE_DAT_MASK;
526 psi_setconf_req_test->devId = dcbPar->devId;
527 switch (device_type)
528 {
529 case DIO_DATA_SER:
530 memcpy(&psi_setconf_req_test->DIO_DCB_UN.DIO_DCB_SER,&dcbPar->dcbPar.dio_dcb_ser,sizeof(T_DIO_DCB_SER));
531 break;
532 case DIO_DATA_PKT:
533 memcpy(&psi_setconf_req_test->DIO_DCB_UN.DIO_DCB_PKT,&dcbPar->dcbPar.dio_dcb_pkt,sizeof(T_DIO_DCB_PKT));
534 break;
535 case DIO_DATA_SER_MUX:
536 memcpy(&psi_setconf_req_test->DIO_DCB_UN.DIO_DCB_SER_MUX,&dcbPar->dcbPar.dio_dcb_ser_mux,sizeof(T_DIO_DCB_SER_MUX));
537 break;
538 default:
539 break;
540 }
541 PSENDX( PSI, psi_setconf_req_test );
542 #else
543 PALLOC(psi_setconf_req, PSI_SETCONF_REQ);
544
545 device_type = dcbPar->devId & DIO_TYPE_DAT_MASK;
546 psi_setconf_req->devId = dcbPar->devId;
547 switch (device_type)
548 {
549 case DIO_DATA_SER:
550 psi_setconf_req->ptr_DIO_DCB = (T_DIO_DCB *) &dcbPar->dcbPar.dio_dcb_ser;
551 break;
552 case DIO_DATA_PKT:
553 psi_setconf_req->ptr_DIO_DCB =(T_DIO_DCB *) &dcbPar->dcbPar.dio_dcb_pkt;
554 break;
555 case DIO_DATA_SER_MUX:
556 psi_setconf_req->ptr_DIO_DCB =(T_DIO_DCB *) &dcbPar->dcbPar.dio_dcb_ser_mux;
557 break;
558 default:
559 break;
560 }
561 PSENDX( PSI, psi_setconf_req );
562 #endif /* _SIMULATION_ */
563 }
564 #endif /* DTI */
565 #endif /*FF_PSI*/
566 /*==== EOF =======================================================*/
567