comparison gsm-fw/g23m-aci/dti/dti_kerf.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 ac329f4627ac
comparison
equal deleted inserted replaced
774:40a721fd9854 775:eedbf248bac0
1 /*
2 +-----------------------------------------------------------------------------
3 | Project : DTILIB
4 | Modul : DTI
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 : Definitions for the Protocol Stack Library
18 | DTI
19 +-----------------------------------------------------------------------------
20 */
21
22 /*
23 * Version 1.6
24 */
25
26 #ifndef DTI_KERF_C
27 #define DTI_KERF_C
28 #endif
29
30
31 /*==== CONST =======================================================*/
32
33 #include <string.h>
34 #include "typedefs.h"
35 #include "pconst.cdg"
36 #include "vsi.h"
37 #include "custom.h"
38 #include "gsm.h"
39 #include "prim.h"
40 #include "dti.h"
41 #include "dti_int_def.h"
42 #include "dti_int_prot.h"
43
44 #ifdef FF_TCP_IP
45 #include "atp/atp_api.h"
46 #include "atp/atp_messages.h"
47 #include "aaa.h"
48 #include "dti_atp.h"
49 #include "gprs.h"
50 #include "dti_conn_mng.h" /* for getting EXTRACT_DTI_ID */
51 #endif
52
53 /*==== LOCALS ================================================================*/
54
55 #ifdef _SIMULATION_
56 LOCAL void send_data_test_req_or_ind
57 (
58 DTI_HANDLE hDTI,
59 DTI_LINK *link,
60 T_DTI2_DATA_IND *dti_data_ind
61 );
62 #endif /* _SIMULATION_ */
63
64
65 #ifdef FF_TCP_IP
66 static BOOL ATP_used_flag;
67 #endif
68
69 /*==== GLOBALS ===============================================================*/
70
71 /*
72 +--------------------------------------------------------------------+
73 | PROJECT : DTILIB MODULE : DTI_KERF |
74 | STATE : code ROUTINE : dti_init |
75 +--------------------------------------------------------------------+
76 *
77 * Malloc and set default parameters and specified entity_options for the database
78 *
79 */
80
81 GLOBAL DTI_HANDLE dti_init(
82 U8 maximum_links,
83 T_HANDLE handle,
84 U32 entity_options,
85 void (sig_callback(
86 U8 instance,
87 U8 interfac,
88 U8 channel,
89 U8 reason,
90 T_DTI2_DATA_IND *dti_data_ind)
91 )
92 )
93 {
94 U16 i;
95 DTI_HANDLE hDTI;
96 DTI_LINK *link, *last_link;
97
98 trace_function(handle, "dti_init()", entity_options);
99
100 #if defined ALLOCATE_DATABASE_BLOCK
101
102 /*
103 * Allocate all needed memory for the DTI Database in one block.
104 */
105 MALLOC( hDTI, (U16)
106 /* Database */
107 (sizeof(temp_mem_1) - sizeof(DTI_LINK) +
108 /* Every links */
109 ((sizeof(temp_mem_2) - sizeof(temp_mem_1))* maximum_links)));
110
111 /*
112 * Set defaults to the Database.
113 */
114 set_default_para_data_base(hDTI);
115
116 /*
117 * Number of links in the Data Base (DTI_DATA_BASE).
118 */
119 hDTI->max_links = maximum_links;
120 hDTI->handle = handle;
121 hDTI->entity_options = entity_options;
122
123 /*
124 * Cast the links and init them.
125 */
126 {
127 U32 link_addr_offset = 0;
128 for(i = 0; i < maximum_links; i++)
129 {
130 if(i == 0)
131 {
132 hDTI->first_link = ((U32) &((temp_mem_1*) hDTI)->tmp_link[i]);
133 link = (DTI_LINK*)hDTI->first_link;
134 init_link_table(link);
135 link_addr_offset = ((U32) &((temp_mem_2*) hDTI)->tmp_link[1]) - ((U32) link);
136 }
137 else
138 {
139 link = link + link_addr_offset;
140 init_link_table(link);
141 }
142 }
143 }
144 #else
145
146 /*
147 * Allocate the memory over separate blocks.
148 */
149 MALLOC (hDTI, (U16)(sizeof(DTI_DATA_BASE) - 1));
150
151 /*
152 * Set defaults
153 */
154 set_default_para_data_base(hDTI);
155
156 /*
157 * Number of links in the Data Base (DTI_DATA_BASE).
158 */
159 hDTI->max_links = maximum_links;
160 hDTI->handle = handle;
161 hDTI->entity_options = entity_options;
162
163 /*
164 * Allocate LINK_TABLE for maximum_links and set default parameters
165 */
166 if(maximum_links > 0)
167 {
168 MALLOC (link, (U16) sizeof(DTI_LINK));
169 init_link_table(link);
170 hDTI->first_link = (U32) link;
171 for(i = 1; i < maximum_links; i++)
172 {
173 last_link = link;
174 MALLOC (link, (U16) sizeof(DTI_LINK));
175 init_link_table(link);
176 last_link->next_link = (U32) link;
177 }
178 }
179 #endif
180
181 #ifdef FF_TCP_IP
182 if (!ATP_used_flag) /* initialise array of references to ATP links */
183 {
184 for ( i=0; i<MAX_ATP_LINKS; i++)
185 {
186 atp_links[i]= D_LINK;
187 }
188 }
189 #endif
190
191 /*
192 * Set the callback function for the entity / instance
193 */
194 hDTI->sig_callback = sig_callback;
195 return hDTI;
196 } /* dti_init() */
197 /*
198 +--------------------------------------------------------------------+
199 | PROJECT : DTILIB MODULE : DTI_KERF |
200 | STATE : code ROUTINE : dti_deinit |
201 +--------------------------------------------------------------------+
202
203 *
204 * Malloc and set default parameter for the Data Base
205 *
206 */
207
208 GLOBAL void dti_deinit( DTI_HANDLE hDTI)
209 {
210 trace_function(hDTI->handle, "dti_deinit()", hDTI->entity_options);
211
212 if(hDTI EQ D_NO_DATA_BASE)
213 return;
214
215 #if defined ALLOCATE_DATABASE_BLOCK
216
217 /*
218 * Free the datablock as a block.
219 */
220
221 MFREE (hDTI);
222
223 #else
224
225 /*
226 * Free the links of the link table with DTI queue
227 */
228
229 free_dti_link_structure(hDTI);
230
231 /*
232 * Free the DTI_DATA_BASE
233 */
234
235 MFREE (hDTI);
236
237 #endif
238 } /* dti_deinit() */
239
240 /*
241 +--------------------------------------------------------------------+
242 | PROJECT : DTILIB MODULE : DTI_KERF |
243 | STATE : code ROUTINE : acquire_link |
244 +--------------------------------------------------------------------+
245
246 *
247 * This function acquires a link
248 */
249 LOCAL DTI_RESULT acquire_link(DTI_HANDLE hDTI,
250 U32 link_id,
251 U8 direction,
252 DTI_LINK **link)
253 {
254 trace_function(hDTI->handle,
255 "acquire_link()",
256 hDTI->entity_options);
257
258 if((*link = get_pointer_link_table(hDTI, link_id, direction)) NEQ NULL)
259 return DTI_S_FOUND;
260
261 if((*link=get_pointer_free_link(hDTI)) NEQ NULL)
262 {
263 set_default_para_link_table (hDTI, *link, link_id, direction);
264 return DTI_S_CREATED_NEW;
265 }
266
267 /*
268 * No free link and so no connection possible.
269 */
270 trace_message_link_id(hDTI->handle,
271 "DTI ERROR: No link free in dtilib",
272 link_id,
273 hDTI->entity_options);
274 return DTI_E_FAIL;
275 }
276
277
278 /*
279 +--------------------------------------------------------------------+
280 | PROJECT : DTILIB MODULE : dti_kerf.c |
281 | STATE : code ROUTINE : send_connect_req_or_ind |
282 +--------------------------------------------------------------------+
283
284 * PURPOSE: Send a Connect primitive depending on the direction.
285 */
286
287 LOCAL void send_connect_req_or_ind (DTI_HANDLE hDTI, DTI_LINK *link)
288 {
289 #define VSI_CALLER hDTI->handle,
290 /*
291 * Check if the link is upwards or downwards
292 * and send the according connect primitive.
293 */
294 switch(link->direction)
295 {
296 case DTI_CHANNEL_TO_HIGHER_LAYER:
297 {
298 PALLOC (dti_connect_ind, DTI2_CONNECT_IND);
299 dti_connect_ind->link_id = link->link_id;
300 dti_connect_ind->version = link->version;
301 if(hDTI->entity_options & DTI_NO_TRACE)
302 {
303 PSEND_NTRACE(link->link_handle, dti_connect_ind);
304 }
305 else
306 {
307 PSEND(link->link_handle, dti_connect_ind);
308 trace_message_link_id(hDTI->handle,
309 "OUT: DTI2_CONNECT_IND",
310 link->link_id,
311 hDTI->entity_options);
312 }
313 }
314 break;
315
316 case DTI_CHANNEL_TO_LOWER_LAYER:
317 {
318 PALLOC (dti_connect_req, DTI2_CONNECT_REQ);
319 dti_connect_req->link_id = link->link_id;
320 dti_connect_req->version = link->version;
321 if(hDTI->entity_options & DTI_NO_TRACE)
322 {
323 PSEND_NTRACE(link->link_handle, dti_connect_req);
324 }
325 else
326 {
327 PSEND(link->link_handle, dti_connect_req);
328 trace_message_link_id(hDTI->handle,
329 "OUT: DTI2_CONNECT_REQ",
330 link->link_id,
331 hDTI->entity_options);
332 }
333 }
334 break;
335
336 default:
337 /*
338 * no known channel type open so do not send anything
339 */
340 break;
341 }
342 #undef VSI_CALLER
343 } /* send_connect_req_or_ind() */
344
345
346
347 /*
348 +--------------------------------------------------------------------+
349 | PROJECT : DTILIB MODULE : dti_kerf.c |
350 | STATE : code ROUTINE : send_connect_res_or_cnf |
351 +--------------------------------------------------------------------+
352
353 * PURPOSE: Send a Connect Confirm primitive depending on the direction.
354 */
355
356 LOCAL void send_connect_res_or_cnf (DTI_HANDLE hDTI, DTI_LINK *link)
357 {
358 #define VSI_CALLER hDTI->handle,
359 /*
360 * Check if the link is upwards or downwards
361 * and send the according connect primitive.
362 */
363 switch(link->direction)
364 {
365 case DTI_CHANNEL_TO_HIGHER_LAYER:
366 {
367 PALLOC (dti_connect_cnf, DTI2_CONNECT_CNF);
368 dti_connect_cnf->link_id = link->link_id;
369 dti_connect_cnf->version = link->version;
370 if(hDTI->entity_options & DTI_NO_TRACE)
371 {
372 PSEND_NTRACE(link->link_handle, dti_connect_cnf);
373 }
374 else
375 {
376 PSEND(link->link_handle, dti_connect_cnf);
377 trace_message_link_id(hDTI->handle,
378 "OUT: DTI2_CONNECT_CNF",
379 link->link_id,
380 hDTI->entity_options);
381 }
382 }
383 break;
384
385 case DTI_CHANNEL_TO_LOWER_LAYER:
386 {
387 PALLOC (dti_connect_res, DTI2_CONNECT_RES);
388 dti_connect_res->link_id = link->link_id;
389 dti_connect_res->version = link->version;
390 if(hDTI->entity_options & DTI_NO_TRACE)
391 {
392 PSEND_NTRACE(link->link_handle, dti_connect_res);
393 }
394 else
395 {
396 PSEND(link->link_handle, dti_connect_res);
397 trace_message_link_id(hDTI->handle,
398 "OUT: DTI2_CONNECT_RES",
399 link->link_id,
400 hDTI->entity_options);
401 }
402 }
403 break;
404
405 default:
406 /*
407 * no known channel type open so do not send anything
408 */
409 break;
410 }
411 #undef VSI_CALLER
412 } /* send_connect_res_or_cnf() */
413
414
415
416 /*
417 +-------------------------------------------------------------------------+
418 | PROJECT : DTILIB MODULE : DTI_KERF |
419 | STATE : code ROUTINE : send_open_ready_callback |
420 +-------------------------------------------------------------------------+
421
422 *
423 * Activate connection_opened and tx_buffer_ready callback funktions.
424 */
425
426 LOCAL void send_open_ready_callback(DTI_HANDLE hDTI, DTI_LINK *link)
427 {
428 #ifdef FF_TCP_IP
429 /*
430 * trigger DTI Primitive transmission separatly, because it can not be done by ATP
431 */
432 if(link->link_type EQ RIVIERA_ATP_LINK)
433 {
434 PALLOC(dti_ready_ind, DTI2_READY_IND);
435 dti_ready_ind->link_id = link->link_id;
436 #define VSI_CALLER 0,
437 PSEND_NTRACE(link->link_handle, dti_ready_ind);
438 #undef VSI_CALLER
439 /*
440 * stop ATP reception Flow Control
441 */
442 TRACE_EVENT("initial: ATP_RX_FLOW_OFF");
443 atp_set_signal(hDTI->entity_id_p,
444 link->port_nb,
445 ATP_RX_FLOW_OFF,
446 ATP_RX_FLOW_UNMASK);
447 }
448 #endif /* FF_TCP_IP */
449 /*
450 * send indication for the open connection
451 */
452 hDTI->sig_callback(
453 link->instance,
454 link->interfac,
455 link->channel,
456 DTI_REASON_CONNECTION_OPENED,
457 NULL);
458
459 /*
460 * Call the callback function with the signal tx_buffer_ready
461 * if the queue is used and not full
462 */
463 if((link->direction EQ DTI_NULL_LINK) OR
464 ((link->queue_len < link->queue_size) OR
465 (link->link_options EQ DTI_QUEUE_UNBOUNDED)))
466 {
467 link->tx_state = DTI_TX_IDLE;
468 hDTI->sig_callback(
469 link->instance,
470 link->interfac,
471 link->channel,
472 DTI_REASON_TX_BUFFER_READY,
473 NULL
474 );
475 }
476 } /* send_open_ready_callback() */
477
478
479
480 /*
481 +--------------------------------------------------------------------+
482 | PROJECT : DTILIB MODULE : DTI_KERF |
483 | STATE : code ROUTINE : dti_open |
484 +--------------------------------------------------------------------+
485
486 *
487 * This function opens or resets a DTI connection.
488 *
489 */
490
491 GLOBAL BOOL dti_open (DTI_HANDLE hDTI,
492 U8 instance,
493 U8 interfac,
494 U8 channel,
495 U8 queue_size,
496 U8 direction,
497 U32 link_options,
498 U32 version,
499 U8 *neighbor_entity,
500 U32 link_id)
501 {
502 DTI_LINK *link;
503 BOOL send_req_or_ind = FALSE;
504 BOOL send_res_or_cnf = FALSE;
505 BOOL open_vsi_channel = FALSE;
506 BOOL riviera_atp_channel = FALSE; /* came by DAA hack */
507 #ifdef BT_ADAPTER
508 BOOL riviera_bt_channel = FALSE; /* came by dirty BT interface hack */
509 #endif /* riviera_bt_channel */
510 U8 signal = DTI_NO_SIGNAL;
511
512 trace_function(hDTI->handle,
513 "dti_open()",
514 hDTI->entity_options);
515
516 trace_message_l_e(hDTI->handle,
517 "open connection",
518 link_id,
519 (char*)neighbor_entity,
520 hDTI->entity_options);
521
522 #ifdef BT_ADAPTER
523 /*
524 * Check if open with a riviera entity.
525 */
526 if (strcmp ((CHAR*)neighbor_entity, BTI_NAME) EQ 0)
527 {
528 riviera_bt_channel = TRUE;
529 }
530 #endif /* BT_ADAPTER */
531
532 #ifdef FF_TCP_IP
533 TRACE_EVENT_P5 ("dti_open: QS:%d DIR:%d LOPT:%d NE:%s LID:%d V:4", queue_size, direction, link_options, neighbor_entity, link_id);
534 if (strcmp ((CHAR*)neighbor_entity, RIV_NAME) EQ 0)
535 {
536 riviera_atp_channel = TRUE;
537 TRACE_EVENT("Riviera link to be opened!");
538 }
539 #endif /* FF_TCP_IP */
540
541 /*
542 * Validate and correct passed parameters
543 */
544 if(validate_open_parameters(hDTI,
545 link_id,
546 &queue_size,
547 &direction,
548 &link_options,
549 version,
550 neighbor_entity) EQ DTI_E_FAIL)
551 {
552 return FALSE;
553 }
554
555 /*
556 * Find a link with the given link_id and direction
557 */
558 switch (acquire_link (hDTI, link_id, direction, &link) )
559 {
560 case DTI_S_FOUND:
561 /*
562 * Found already existing link
563 */
564 switch (link->connect_state)
565 {
566 case DTI_CLOSING:
567 link->connect_state = DTI_IDLE;
568 /* fall through */
569
570 case DTI_IDLE:
571 /*
572 * Reset the link and set the parameter.
573 */
574 trace_message(hDTI->handle,
575 "existing DTI connection is being reset!",
576 hDTI->entity_options);
577
578 set_open_para_link_table(hDTI,
579 link,
580 version,
581 link_options,
582 instance,
583 interfac,
584 channel,
585 queue_size,
586 DTI_IDLE);
587 /*
588 * Send a confirm primitive if we use SAP DTI2.DOC. Then also set the parameter.
589 */
590 send_req_or_ind = TRUE;
591 signal = DTI_REASON_CONNECTION_OPENED;
592 if (link->direction NEQ DTI_NULL_LINK)
593 {
594 /*
595 * Close the old channel.
596 */
597 vsi_c_close (hDTI->handle, link->link_handle);
598 }
599
600 /*
601 * Set the flag to open a new channel.
602 */
603 open_vsi_channel = TRUE;
604
605 break;
606
607 case DTI_SETUP:
608 /*
609 * Collision of DTI2_CONNECT_REQ and DTI2_CONNECT_IND. The parameters
610 * have been set in dti_open before. They stay in this state.
611 */
612 break;
613
614 case DTI_CLOSED:
615 /*
616 * Start with connecting
617 */
618
619 set_open_para_link_table
620 (
621 hDTI, link, version, link_options,
622 instance, interfac, channel, queue_size, DTI_SETUP
623 );
624
625 link->connect_state = DTI_SETUP;
626 send_req_or_ind = TRUE;
627 open_vsi_channel = TRUE;
628 break;
629
630 case DTI_CONNECTING:
631 /*
632 * Got a connecting primitive, send a confirm primitive and set the parameter.
633 */
634 set_open_para_link_table
635 (
636 hDTI, link, version, link_options,
637 instance, interfac, channel, queue_size, DTI_IDLE
638 );
639
640 send_res_or_cnf = TRUE;
641 signal = DTI_REASON_CONNECTION_OPENED;
642 open_vsi_channel = TRUE;
643 break;
644
645 default:
646 /*
647 * Wrong state
648 */
649 trace_message_link_id(hDTI->handle,
650 "DTI ERROR: Wrong state of dtilib",
651 link_id,
652 hDTI->entity_options);
653 break;
654 }
655 break;
656
657 /*
658 * Created new link
659 */
660 case DTI_S_CREATED_NEW:
661 /*
662 * Open the requested channel and send a req/ind primitive.
663 */
664 open_vsi_channel = TRUE;
665
666 /*
667 * DTILIB can handle DTI SAP DTI.DOC and DTI2.DOC. By using DTI.DOC (the old
668 * SAP) the parameter are set but the connect primitives are not supported.
669 *
670 * SAP DTI.DOC does also not support a queue. So the queue len is set to
671 * 0 in the function set_link_parameter().
672 */
673 set_open_para_link_table
674 (
675 hDTI, link, version, link_options,
676 instance, interfac, channel, queue_size, DTI_SETUP
677 );
678 send_req_or_ind = TRUE;
679 break;
680
681 default:
682 /*
683 * No free link - no connection possible.
684 */
685 return FALSE;
686 } /*lint !e788 enum constant not used */
687
688 /* in case of RIV link, get parameters from AAA */
689 #ifdef FF_TCP_IP
690 if( riviera_atp_channel)
691 {
692 link->link_type = RIVIERA_ATP_LINK;
693 link->entity_db = hDTI; /* remember the entity the link belongs to */
694 link->dti_id = EXTRACT_DTI_ID(link_id);
695 /* link->link_options = FLOW_CNTRL_DISABLED; */ /* to avoid the full DTI state machine */
696
697 /* get the parameters valid within RIV environment from AAA */
698 if(!aaa_get_connection_data( link->dti_id, &(link->port_nb), &(hDTI->entity_id_p), &(hDTI->own_name)))
699 {
700 TRACE_ERROR("aaa_get_connection_data() failed!");
701 }
702 else
703 {
704 TRACE_EVENT_P2("got connection_data: name: %s, link_id: %d", (char*) (hDTI->own_name), link->link_id);
705 }
706
707 if(hDTI->handle EQ PEI_ERROR)
708 {
709 TRACE_ERROR("error getting my own entity handle!");
710 }
711 }
712 #endif
713
714 /* mark links connection type */
715 if( !riviera_atp_channel
716 #ifdef BT_ADAPTER
717 AND !riviera_bt_channel
718 #endif
719 ) /*lint !e774 (Info -- Boolean within 'if' always evaluates to True), only used for FF_TCP_IP/BT */
720 {
721 link->link_type = ENTITY_LINK;
722 }
723
724 /*
725 * link to BlueTooth
726 */
727 #ifdef BT_ADAPTER
728 if(riviera_bt_channel)
729 {
730 link->link_type = RIVIERA_BT_LINK;
731 }
732 #endif
733
734 /*
735 * Open a channel to VSI. If it is not possible to open, return FALSE to the entity
736 * so that the entity can try again.
737 */
738 if(open_vsi_channel)
739 {
740 /*
741 * If NULL device then disable flow control
742 */
743 if(direction EQ DTI_NULL_LINK)
744 {
745 trace_message(hDTI->handle,
746 "DTI connection is to be opened for NULL device",
747 hDTI->entity_options);
748 /*
749 * it is not exactly necessary to set this here,
750 * but only a logical consequence
751 */
752 link->link_options = DTI_FLOW_CNTRL_DISABLED;
753 link->link_type = NULL_LINK;
754 link->connect_state = DTI_IDLE;
755 /*
756 * Activate callback function with reason_connection_opened
757 * and, additionally, signal tx_buffer_ready if the queue is used.
758 */
759 send_open_ready_callback(hDTI, link);
760 return TRUE;
761 }
762
763 if (link->link_type EQ ENTITY_LINK) /* check for connection within GPF */
764 {
765 open_comm_channel(hDTI->handle,
766 &link->link_handle,
767 (char *) neighbor_entity,
768 hDTI->entity_options);
769 }
770
771 #ifdef FF_TCP_IP
772 else if (link->link_type EQ RIVIERA_ATP_LINK) /* check for connection towards Riv */
773 {
774 link->dti_data_ind = NULL;
775 link->connect_state = DTI_IDLE; /* we don't use connect prims here, */
776 /* so set it by hand */
777 signal = DTI_REASON_CONNECTION_OPENED;
778 send_res_or_cnf = FALSE;
779 send_req_or_ind = FALSE;
780
781 open_comm_channel( hDTI->handle, /* open com handle to hDTI-entity */
782 &link->link_handle,
783 (char *) hDTI->own_name,
784 hDTI->entity_options);
785
786 /* the port has already been opened by AAA, so only remember link as leading to ATP,
787 * for sending data or events 'backwards' to that entity
788 */
789 if(link->link_handle >= VSI_OK)
790 {
791 if(atp_links[link->port_nb] EQ D_LINK)
792 {
793 atp_links[link->port_nb] = link;
794 ATP_used_flag = TRUE;
795 }
796 else
797 {
798 TRACE_ERROR("link reference could not be saved for DAA");
799 }
800 }
801 }
802 #endif
803
804 if(link->link_handle < VSI_OK)
805 {
806 trace_message_link_id(hDTI->handle,
807 "DTI ERROR: open a comm channel not possible",
808 link_id,
809 hDTI->entity_options);
810
811 set_default_para_link_table(hDTI, link, D_FREE_LINK_ID, D_DIRECTION);
812 return FALSE;
813 }
814
815 #ifdef BT_ADAPTER
816 if(link->link_type EQ RIVIERA_BT_LINK) /* connection links into RIV environment */
817 {
818 /*
819 xxxx: handle new BT link
820 */
821 }
822 #endif
823 } /* if(open_channel) */
824
825 if(send_res_or_cnf) /* shouldn't happen for ATP links! */
826 {
827 /* Send DTI2_CONNECT_RES or DTI2_CONNECT_CNF
828 */
829 send_connect_res_or_cnf (hDTI, link);
830 }
831 else if(send_req_or_ind) /* is supposed to happen for ATP links??? */
832 {
833 /* Send DTI2_CONNECT_REQ or DTI_CONNECT_IND.
834 */
835 if(link->link_type EQ ENTITY_LINK)
836 {
837 send_connect_req_or_ind (hDTI, link);
838 }
839 }
840 /*
841 * Activate the callback function to the entity.
842 */
843 if(signal EQ DTI_REASON_CONNECTION_OPENED)
844 {
845 if (!(hDTI->entity_options & DTI_NO_TRACE) )
846 {
847 trace_message_l_e(hDTI->handle,
848 "DTI connection opened", /*lint !e605 Increase in pointer capability */
849 link_id,
850 (char*)neighbor_entity,
851 hDTI->entity_options);
852 }
853
854 /*
855 * Activate callback function with reason_connection_opened
856 * and, additionally, signal tx_buffer_ready if the queue is used.
857 */
858 send_open_ready_callback (hDTI, link);
859 }
860 return TRUE;
861 }
862
863 /*
864 +--------------------------------------------------------------------+
865 | PROJECT : DTILIB MODULE : dti_kerf.c |
866 | STATE : code ROUTINE : send_disconnect_req_or_ind |
867 +--------------------------------------------------------------------+
868
869 * PURPOSE: Send a Disconnect primitive depending on the direction.
870 */
871
872 LOCAL void send_disconnect_req_or_ind (DTI_HANDLE hDTI,
873 DTI_LINK* link,
874 U8 cause)
875 {
876 #define VSI_CALLER hDTI->handle,
877 /*
878 * Check if the link is upwards or downwards
879 * and send the according disconnect primitive.
880 */
881 switch (link->direction)
882 {
883 case DTI_CHANNEL_TO_HIGHER_LAYER:
884 {
885 PALLOC (dti_disconnect_ind, DTI2_DISCONNECT_IND);
886 dti_disconnect_ind->link_id = link->link_id;
887 dti_disconnect_ind->cause = cause;
888 if(hDTI->entity_options & DTI_NO_TRACE)
889 {
890 PSEND_NTRACE(link->link_handle, dti_disconnect_ind);
891 }
892 else
893 {
894 PSEND(link->link_handle, dti_disconnect_ind);
895 trace_message_link_id(hDTI->handle,
896 "OUT: DTI2_DISCONNECT_IND",
897 link->link_id,
898 hDTI->entity_options);
899 }
900 }
901 break;
902
903 case DTI_CHANNEL_TO_LOWER_LAYER:
904 {
905 PALLOC (dti_disconnect_req, DTI2_DISCONNECT_REQ);
906 dti_disconnect_req->link_id = link->link_id;
907 dti_disconnect_req->cause = cause;
908 if(hDTI->entity_options & DTI_NO_TRACE)
909 {
910 PSEND_NTRACE(link->link_handle, dti_disconnect_req);
911 }
912 else
913 {
914 PSEND(link->link_handle, dti_disconnect_req);
915 trace_message_link_id(hDTI->handle,
916 "OUT: DTI2_DISCONNECT_REQ",
917 link->link_id,
918 hDTI->entity_options);
919 }
920 }
921 break;
922
923 default:
924 /*
925 * no known channel type open so do not send anything
926 */
927 break;
928 }
929 #undef VSI_CALLER
930 } /* send_disconnect_req_or_ind() */
931
932
933
934 /*
935 +--------------------------------------------------------------------+
936 | PROJECT : DTILIB MODULE : dti_kerf.c |
937 | STATE : code ROUTINE : send_ready_req_or_ind |
938 +--------------------------------------------------------------------+
939
940 * PURPOSE: Send a Flow Control primitive depending on the direction.
941 */
942
943 LOCAL void send_ready_req_or_ind (DTI_HANDLE hDTI, DTI_LINK *link)
944 {
945 #define VSI_CALLER hDTI->handle,
946
947 #ifdef FF_TCP_IP
948 /*
949 * do not send flow control primitives in case of riviera link
950 * but send a Data primitive to trigger next data reception
951 * this is needed because ATP may has sent data
952 * where DTILIB was not initialized yet
953 */
954 if(link->link_type EQ RIVIERA_ATP_LINK)
955 {
956 PALLOC(dti_data_ind, DTI2_DATA_IND);
957 dti_data_ind->link_id = link->link_id;
958 dti_data_ind->desc_list2.list_len = 0;
959 dti_data_ind->desc_list2.first = (U32)NULL;
960 PSEND(link->link_handle, dti_data_ind);
961 return;
962 }
963 #endif /* FF_TCP_IP */
964 /*
965 * Check if the link is upwards or downwards
966 * and send the according connect primitive.
967 */
968 switch (link->direction)
969 {
970 case DTI_CHANNEL_TO_HIGHER_LAYER:
971 #ifdef BT_ADAPTER
972 if(link->link_type EQ RIVIERA_BT_LINK)
973 {
974 btidti_getdata_req(link_id);
975 }
976 else
977 #endif /* BT_ADAPTER */
978 {
979 if(link->link_type EQ ENTITY_LINK)
980 {
981 PALLOC (dti_ready_ind, DTI2_READY_IND);
982 dti_ready_ind->link_id = link->link_id;
983 if(hDTI->entity_options & DTI_NO_TRACE)
984 {
985 PSEND_NTRACE(link->link_handle, dti_ready_ind);
986 }
987 else
988 {
989 PSEND(link->link_handle, dti_ready_ind);
990 trace_message_link_id(hDTI->handle,
991 "OUT: DTI2_READY_IND",
992 link->link_id,
993 hDTI->entity_options);
994 }
995 }
996 }
997 break;
998
999 case DTI_CHANNEL_TO_LOWER_LAYER:
1000 #ifdef BT_ADAPTER
1001 if(link->link_type EQ RIVIERA_BT_LINK)
1002 {
1003 btidti_getdata_req(link_id);
1004 }
1005 else
1006 #endif /* BT_ADAPTER */
1007 {
1008 if(link->link_type EQ ENTITY_LINK)
1009 {
1010 PALLOC (dti_getdata_req, DTI2_GETDATA_REQ);
1011 dti_getdata_req->link_id = link->link_id;
1012 if(hDTI->entity_options & DTI_NO_TRACE)
1013 {
1014 PSEND_NTRACE(link->link_handle, dti_getdata_req);
1015 }
1016 else
1017 {
1018 PSEND(link->link_handle, dti_getdata_req);
1019 trace_message_link_id(hDTI->handle,
1020 "OUT: DTI2_GETDATA_REQ",
1021 link->link_id,
1022 hDTI->entity_options);
1023 }
1024 }
1025 }
1026 break;
1027
1028 default:
1029 /*
1030 * no known channel type open so do not send anything
1031 */
1032 break;
1033 }
1034 #undef VSI_CALLER
1035 } /* send_ready_req_or_ind() */
1036
1037
1038
1039 /*
1040 +--------------------------------------------------------------------+
1041 | PROJECT : DTILIB MODULE : DTI_KERF |
1042 | STATE : code ROUTINE : dti_close |
1043 +--------------------------------------------------------------------+
1044
1045 *
1046 * The function searchs a link in the databank link list and closes it.
1047 * Then it calls the callback function with the signal DTI_REASON_CONNECTION_CLOSED.
1048 */
1049
1050 GLOBAL void dti_close (DTI_HANDLE hDTI,
1051 U8 instance,
1052 U8 interfac,
1053 U8 channel,
1054 BOOL flush)
1055 {
1056 DTI_LINK *link;
1057
1058 trace_function( hDTI->handle,
1059 "dti_close()",
1060 hDTI->entity_options);
1061
1062 /*
1063 * Find the link in the database
1064 */
1065
1066 if((link = get_pointer_link_table_channel(hDTI,
1067 instance,
1068 interfac,
1069 channel)) NEQ NULL)
1070 {
1071
1072 trace_message_link_id(hDTI->handle,
1073 "closing DTI connection", /*lint !e605 Increase in pointer capability */
1074 link->link_id,
1075 hDTI->entity_options);
1076
1077 if (link->direction EQ DTI_NULL_LINK)
1078 {
1079 set_default_para_link_table(hDTI, link, D_FREE_LINK_ID, D_DIRECTION);
1080 return;
1081 }
1082
1083 switch (link->connect_state)
1084 {
1085 /*
1086 * The link is already closed
1087 */
1088
1089 case DTI_CLOSED:
1090 trace_message_link_id(hDTI->handle,
1091 "Link is already closed for this entity",
1092 link->link_id,
1093 hDTI->entity_options);
1094 return;
1095
1096 /*
1097 * In all other states the entity sends a disconnect primitive
1098 */
1099 default:
1100 /*
1101 * exit only after send queue has been emptied?
1102 */
1103 if(flush EQ TRUE)
1104 {
1105 /*
1106 * if it is not empty, wait for data flow primitives
1107 * from the peer entity
1108 */
1109 if(link->queue_len NEQ 0)
1110 {
1111 link->connect_state = DTI_CLOSING;
1112 return;
1113 }
1114 else
1115 {
1116 /*
1117 * call the callback function right now.
1118 */
1119 hDTI->sig_callback(
1120 link->instance,
1121 link->interfac,
1122 link->channel,
1123 DTI_REASON_CONNECTION_CLOSED,
1124 NULL
1125 );
1126 }
1127 }
1128
1129 if (link->link_type NEQ RIVIERA_ATP_LINK)
1130 /* check for connection towards ATP. The NULL_LINK case is handled
1131 * above, already.
1132 */
1133 {
1134 send_disconnect_req_or_ind (hDTI, link, DTI_CAUSE_NORMAL_CLOSE);
1135 }
1136 #ifdef FF_TCP_IP
1137 else /* the links goes towards Riviera */
1138 {
1139 U8 i;
1140 atp_links[link->port_nb] = D_LINK;
1141 ATP_used_flag = FALSE;
1142 for (i=0; i<MAX_ATP_LINKS; i++)
1143 {
1144 if(atp_links[i] NEQ D_LINK)
1145 {
1146 ATP_used_flag = TRUE;
1147 TRACE_EVENT("there are still open ATP links!");
1148 break;
1149 }
1150 }
1151 }
1152 #endif /* FF_TCP_IP */
1153
1154 /*
1155 * close the communication channel
1156 */
1157 vsi_c_close (hDTI->handle, link->link_handle);
1158 /*
1159 * Set the default parameter. The channel is closed in the neighbour entity.
1160 */
1161 set_default_para_link_table(hDTI,link, D_FREE_LINK_ID, D_DIRECTION);
1162
1163 /*
1164 * Note: Flow control and data primitives are silently discarded.
1165 */
1166
1167 break;
1168 }
1169 }
1170 else
1171 {
1172 /*
1173 * there is no link to be found in the table
1174 */
1175 trace_message_iic(hDTI->handle,
1176 "DTI link is alredy closed",
1177 instance,
1178 interfac,
1179 channel,
1180 hDTI->entity_options);
1181 }
1182 }
1183
1184
1185
1186 /*
1187 +--------------------------------------------------------------------+
1188 | PROJECT : DTILIB MODULE : DTI_KERF |
1189 | STATE : code ROUTINE : dti_start |
1190 +--------------------------------------------------------------------+
1191
1192 *
1193 * If the entity wants to receive data primitives, this function must be
1194 * called.
1195 */
1196
1197 GLOBAL void dti_start( DTI_HANDLE hDTI, U8 instance, U8 interfac, U8 channel)
1198 {
1199 DTI_LINK *link;
1200
1201 trace_function( hDTI->handle,
1202 "dti_start()",
1203 hDTI->entity_options);
1204
1205 /*
1206 * Find the link in the database.
1207 */
1208 link = get_pointer_link_table_channel(hDTI, instance, interfac, channel);
1209 if(link EQ NULL)
1210 {
1211 /*
1212 * Link id is not in the table.
1213 */
1214 trace_message_iic(hDTI->handle,
1215 "DTI ERROR: dti_start() - No link id in the database",
1216 instance,
1217 interfac,
1218 channel,
1219 hDTI->entity_options);
1220 return;
1221 }
1222 /*
1223 * Is the entity connected ?
1224 */
1225 if(link->connect_state NEQ DTI_IDLE)
1226 {
1227 trace_message_link_id(hDTI->handle,
1228 "DTI ERROR: link is not connected",
1229 link->link_id,
1230 hDTI->entity_options);
1231 return;
1232 }
1233 /*
1234 * Check if the flow control is not used but do nothing.
1235 */
1236 if(link->link_options EQ DTI_FLOW_CNTRL_DISABLED)
1237 return;
1238 /*
1239 * Handle the states
1240 */
1241 switch(link->rx_state)
1242 {
1243 case DTI_RX_IDLE:
1244 /*
1245 * Change the state to indicate ready to receive data.
1246 */
1247 link->rx_state = DTI_RX_READY;
1248 /*
1249 * No flow control primitive was sent. So send one now.
1250 * NOTE: The parameter link->direction gives information about the
1251 * direction for sending the data.
1252 */
1253 send_ready_req_or_ind (hDTI, link);
1254 break;
1255
1256 case DTI_RX_STOPPED:
1257 /*
1258 * The entity has stopped the flow control.
1259 * The flow control was sent already.
1260 * So change state to DTI_RX_READY.
1261 */
1262 link->rx_state = DTI_RX_READY;
1263 break;
1264
1265 case DTI_RX_READY:
1266 /*
1267 * dti_start() was already called.
1268 */
1269 break;
1270
1271 default:
1272 /*
1273 * Unexpected state - set ERROR.
1274 */
1275 trace_message_link_id(hDTI->handle,
1276 "DTI ERROR: wrong state",
1277 link->link_id,
1278 hDTI->entity_options);
1279 break;
1280 }
1281 } /* dti_start() */
1282
1283
1284
1285 /*
1286 +--------------------------------------------------------------------+
1287 | PROJECT : DTILIB MODULE : DTI_KERF |
1288 | STATE : code ROUTINE : dti_stop |
1289 +--------------------------------------------------------------------+
1290
1291 *
1292 * This function is called if the entity wants to stop receiving of data
1293 * primitives.
1294 */
1295
1296 GLOBAL void dti_stop( DTI_HANDLE hDTI, U8 instance, U8 interfac, U8 channel)
1297 {
1298 DTI_LINK *link;
1299
1300 trace_function( hDTI->handle,
1301 "dti_stop()",
1302 hDTI->entity_options);
1303
1304 /*
1305 * Find the link in the databank.
1306 */
1307 link = get_pointer_link_table_channel(hDTI, instance, interfac, channel);
1308 /*
1309 * It is link id in the table ?
1310 */
1311 if(link EQ NULL)
1312 {
1313 trace_message_iic(hDTI->handle,
1314 "DTI ERROR: dti_stop() - No link id in the database",
1315 instance,
1316 interfac,
1317 channel,
1318 hDTI->entity_options);
1319 return;
1320 }
1321 /*
1322 * Is the entity connected ?
1323 */
1324 if(link->connect_state NEQ DTI_IDLE)
1325 {
1326 trace_message_link_id(hDTI->handle,
1327 "DTI ERROR: dti_stop() - link is not connected",
1328 link->link_id,
1329 hDTI->entity_options);
1330 return;
1331 }
1332 /*
1333 * Check if the flow control is not used - then do nothing
1334 */
1335 if(link->link_options EQ DTI_FLOW_CNTRL_DISABLED)
1336 return;
1337 /*
1338 * Handle the states
1339 */
1340 switch(link->rx_state)
1341 {
1342 case DTI_RX_READY:
1343 /*
1344 * The flow control was already sent therefor change to stop state.
1345 */
1346 link->rx_state = DTI_RX_STOPPED;
1347 break;
1348
1349 case DTI_RX_STOPPED:
1350 case DTI_RX_IDLE:
1351 /*
1352 * dti_stop() was already called.
1353 * So there is no need to change state.
1354 */
1355 break;
1356
1357 default:
1358 /*
1359 * Other state - ERROR
1360 */
1361 trace_message_link_id(hDTI->handle,
1362 "DTI ERROR: dti_stop() - wrong state",
1363 link->link_id,
1364 hDTI->entity_options);
1365 break;
1366 }
1367 } /* dti_stop() */
1368
1369
1370
1371 #ifdef _SIMULATION_
1372 /*
1373 +--------------------------------------------------------------------+
1374 | PROJECT : DTILIB MODULE : dti_kerf.c |
1375 | STATE : code ROUTINE : send_data_test_req_or_ind |
1376 +--------------------------------------------------------------------+
1377
1378 * PURPOSE: Get a DTI_DATA_IND and translate it to DTI_DATA_TEST_IND
1379 * and send it.
1380 */
1381
1382 LOCAL void send_data_test_req_or_ind (DTI_HANDLE hDTI,
1383 DTI_LINK* link,
1384 T_DTI2_DATA_IND* dti_data_ind)
1385 {
1386 #define VSI_CALLER hDTI->handle,
1387 U16 len_buf_bits;
1388 U16 i;
1389 U16 len;
1390 U16 j;
1391 T_desc2 *p_desc;
1392
1393 trace_function(hDTI->handle,
1394 "send_data_test_req_or_ind()",
1395 hDTI->entity_options);
1396
1397 len_buf_bits = dti_data_ind->desc_list2.list_len * 8;
1398
1399 /*
1400 * Build the SDU primitive and send it
1401 */
1402 {
1403 PALLOC_SDU (dti_data_test_ind, DTI2_DATA_TEST_IND, len_buf_bits);
1404 memset (dti_data_test_ind, 0, sizeof (T_DTI2_DATA_TEST_IND));
1405
1406 dti_data_test_ind->link_id = dti_data_ind->link_id;
1407 dti_data_test_ind->parameters = dti_data_ind->parameters;
1408
1409 dti_data_test_ind->sdu.l_buf = len_buf_bits;
1410 dti_data_test_ind->sdu.o_buf = 0;
1411
1412 /*
1413 * Copy the descs into sdu structure.
1414 */
1415 if(len_buf_bits > 0)
1416 {
1417 j = 0;
1418 p_desc = (T_desc2*)(dti_data_ind->desc_list2.first);
1419 while(p_desc NEQ NULL)
1420 {
1421 len = p_desc->len;
1422 for(i=0; i < len; i++)
1423 {
1424 dti_data_test_ind->sdu.buf[j] = p_desc->buffer[i];
1425 j++;
1426 }
1427 p_desc = (T_desc2*)(p_desc->next);
1428 }
1429 }
1430
1431 /*
1432 * Check if the link is upwards or downwards
1433 * and send the according disconnect primitive.
1434 */
1435 switch (link->direction)
1436 {
1437 case DTI_CHANNEL_TO_HIGHER_LAYER:
1438 if(hDTI->entity_options & DTI_NO_TRACE)
1439 {
1440 PSEND_NTRACE(link->link_handle, dti_data_test_ind);
1441 }
1442 else
1443 {
1444 PSEND(link->link_handle, dti_data_test_ind);
1445 trace_message_l_dl(hDTI->handle,
1446 "OUT: DTI2_DATA_TEST_IND",
1447 dti_data_ind->link_id,
1448 dti_data_ind->desc_list2.list_len,
1449 hDTI->entity_options);
1450 }
1451 break;
1452
1453 case DTI_CHANNEL_TO_LOWER_LAYER:
1454 if(hDTI->entity_options & DTI_NO_TRACE)
1455 {
1456 PPASS_NTRACE(dti_data_test_ind,
1457 dti_data_test_req,
1458 DTI2_DATA_TEST_REQ);
1459 PSEND_NTRACE(link->link_handle, dti_data_test_req);
1460 }
1461 else
1462 {
1463 PPASS(dti_data_test_ind, dti_data_test_req, DTI2_DATA_TEST_REQ);
1464 PSEND(link->link_handle, dti_data_test_req);
1465 trace_message_l_dl(hDTI->handle,
1466 "OUT: DTI2_DATA_TEST_REQ",
1467 dti_data_ind->link_id,
1468 dti_data_ind->desc_list2.list_len,
1469 hDTI->entity_options);
1470 }
1471 break;
1472
1473 default:
1474 /*
1475 * no known channel type open so do not send anything
1476 */
1477 break;
1478 }
1479 }
1480 /*
1481 * Free the dti_data_ind primitive and the descs in the linked list.
1482 */
1483 mfree_desc(hDTI, &dti_data_ind->desc_list2);
1484 PFREE (dti_data_ind);
1485 #undef VSI_CALLER
1486 } /* send_data_test_req_or_ind() */
1487 #endif /* _SIMULATION_ */
1488
1489
1490
1491 /*
1492 +--------------------------------------------------------------------+
1493 | PROJECT : DTILIB MODULE : dti_kerf.c |
1494 | STATE : code ROUTINE : send_data_req_or_ind |
1495 +--------------------------------------------------------------------+
1496
1497 * PURPOSE: Send a Data primitive depending on the direction.
1498 */
1499
1500 LOCAL void send_data_req_or_ind (DTI_HANDLE hDTI,
1501 DTI_LINK* link,
1502 T_DTI2_DATA_IND* dti_data_ind)
1503 {
1504 #ifndef _SIMULATION_
1505 U32 link_id;
1506 U16 list_len;
1507 #endif /* !_SIMULATION_ */
1508 #ifdef BT_ADAPTER
1509 if(link->link_type EQ RIVIERA_BT_LINK)
1510 {
1511 btidti_data_req(dti_data_ind);
1512 }
1513 else
1514 #endif /* BT_ADAPTER */
1515 /*
1516 * Check if the primitive is directed to a GPF or ATP entity, and send it.
1517 */
1518 #ifdef FF_TCP_IP
1519 if(link->link_type EQ RIVIERA_ATP_LINK)
1520 {
1521 dti_send_data_to_atp(hDTI, link, dti_data_ind);
1522 return;
1523 }
1524 #endif /* FF_TCP_IP */
1525
1526 #ifdef _SIMULATION_
1527 send_data_test_req_or_ind(hDTI, link, dti_data_ind);
1528 #else /* _SIMULATION_ */
1529 #define VSI_CALLER hDTI->handle,
1530 /*
1531 * Check if the link is upwards or downwards
1532 * and send the according disconnect primitive.
1533 */
1534 switch (link->direction)
1535 {
1536 case DTI_CHANNEL_TO_HIGHER_LAYER:
1537 #ifdef BT_ADAPTER
1538 if(link->link_type EQ RIVIERA_LINK)
1539 {
1540 btidti_data_req(dti_data_ind);
1541 }
1542 else
1543 #endif /* BT_ADAPTER */
1544 {
1545 if(hDTI->entity_options & DTI_NO_TRACE)
1546 {
1547 PSEND_NTRACE(link->link_handle, dti_data_ind);
1548 }
1549 else
1550 {
1551 link_id = dti_data_ind->link_id;
1552 list_len = dti_data_ind->desc_list2.list_len;
1553 PSEND(link->link_handle, dti_data_ind);
1554 trace_message_l_dl(hDTI->handle,
1555 "OUT: DTI2_DATA_IND",
1556 link_id,
1557 list_len,
1558 hDTI->entity_options);
1559 }
1560 }
1561 break;
1562
1563 case DTI_CHANNEL_TO_LOWER_LAYER:
1564 if(hDTI->entity_options & DTI_NO_TRACE)
1565 {
1566 PPASS_NTRACE(dti_data_ind, dti_data_req, DTI2_DATA_REQ);
1567 PSEND_NTRACE(link->link_handle, dti_data_req);
1568 }
1569 else
1570 {
1571 PPASS(dti_data_ind, dti_data_req, DTI2_DATA_REQ);
1572 link_id = dti_data_req->link_id;
1573 list_len = dti_data_req->desc_list2.list_len;
1574 PSEND(link->link_handle, dti_data_req);
1575 trace_message_l_dl(hDTI->handle,
1576 "OUT: DTI2_DATA_REQ",
1577 link_id,
1578 list_len,
1579 hDTI->entity_options);
1580 }
1581 break;
1582
1583 default:
1584 /*
1585 * no known channel type open so do not send anything
1586 */
1587 break;
1588 }
1589 #undef VSI_CALLER
1590 #endif /* else _SIMULATION_ */
1591 } /* send_data_req_or_ind() */
1592
1593
1594
1595 /*
1596 +--------------------------------------------------------------------+
1597 | PROJECT : DTILIB MODULE : DTI_KERF |
1598 | STATE : code ROUTINE : dti_send_data |
1599 +--------------------------------------------------------------------+
1600
1601 *
1602 * This function sends data. If the database direction is set to
1603 * DTI_UPLINK then it sends a dti_data_req primitive otherwise a DTI_DATA_IND
1604 * primitive.
1605 */
1606
1607 GLOBAL void dti_send_data (DTI_HANDLE hDTI,
1608 U8 instance,
1609 U8 interfac,
1610 U8 channel,
1611 T_DTI2_DATA_IND *dti_data_ind)
1612 {
1613 DTI_LINK *link;
1614 T_DTI2_DATA_IND *hlp_data_ind;
1615
1616 trace_function(hDTI->handle,
1617 "dti_send_data()",
1618 hDTI->entity_options);
1619
1620 /*
1621 * Find the link in the database.
1622 */
1623 link = get_pointer_link_table_channel(hDTI, instance, interfac, channel);
1624 if(link EQ NULL)
1625 {
1626 /*
1627 * link_id is not in the table.
1628 */
1629 trace_message_iic(hDTI->handle,
1630 "DTI ERROR: dti_send_data() - No link id in the database",
1631 instance,
1632 interfac,
1633 channel,
1634 hDTI->entity_options);
1635 mfree_desc(hDTI, &dti_data_ind->desc_list2);
1636 PFREE (dti_data_ind);
1637 return;
1638 }
1639
1640 /*
1641 * Is the entity connected ?
1642 */
1643 if(link->connect_state NEQ DTI_IDLE)
1644 {
1645 trace_message_link_id(hDTI->handle,
1646 "DTI ERROR: dti_send_data() - link is not connected",
1647 link->link_id,
1648 hDTI->entity_options);
1649 mfree_desc(hDTI, &dti_data_ind->desc_list2);
1650 PFREE (dti_data_ind);
1651 return;
1652 }
1653
1654 /*
1655 * If link is a NULL device then just free the message
1656 */
1657 if (link->direction EQ DTI_NULL_LINK)
1658 {
1659 mfree_desc (hDTI, &dti_data_ind->desc_list2);
1660 PFREE (dti_data_ind);
1661 return;
1662 }
1663
1664 /*
1665 * There is no flow control, so the primitive doesn't get into the queue
1666 * and has to get sent at once.
1667 */
1668 if(link->link_options EQ DTI_FLOW_CNTRL_DISABLED)
1669 {
1670 send_data_req_or_ind(hDTI, link, dti_data_ind);
1671 return;
1672 }
1673
1674 switch (link->tx_state)
1675 {
1676 case DTI_TX_IDLE:
1677 case DTI_TX_BUFFER_FULL:
1678 /*
1679 * While waiting for a flow control primitive no sending is possible.
1680 * Put the primitive dti_data_ind in the queue.
1681 */
1682 put_dti_data_ind_in_queue_managed (hDTI, link, dti_data_ind);
1683 break;
1684
1685 case DTI_TX_FLOW:
1686 /*
1687 * The flow control primitive is already received.
1688 * So just send Data primitive and change state.
1689 * Because of ATP links there might be still a prim in the queue
1690 * therefore we have to use the queue for this
1691 */
1692 put_dti_data_ind_in_queue(hDTI, link, dti_data_ind);
1693 /*
1694 * Read the last packet from the queue and send it.
1695 */
1696 {
1697 hlp_data_ind = get_dti_data_ind_from_queue(hDTI, link);
1698 hlp_data_ind->link_id = link->link_id;
1699 /*
1700 * The packet will be sent. Now change the state to DTI_TX_IDLE.
1701 */
1702 link->tx_state = DTI_TX_IDLE;
1703 /*
1704 * Send the primitive depending on its direction.
1705 */
1706 send_data_req_or_ind(hDTI, link, hlp_data_ind);
1707 }
1708 break;
1709
1710 default:
1711 /*
1712 * Unknown state..
1713 */
1714 trace_message_link_id(hDTI->handle,
1715 "DTI ERROR: dti_send_data() - wrong state",
1716 link->link_id,
1717 hDTI->entity_options);
1718 mfree_desc(hDTI, &dti_data_ind->desc_list2);
1719 PFREE (dti_data_ind);
1720 break;
1721 }
1722 /*
1723 * if queue is full now, send a warning callback
1724 */
1725 if((link->queue_len >= link->queue_size) AND
1726 (link->link_options NEQ DTI_QUEUE_UNBOUNDED))
1727 {
1728 link->tx_state = DTI_TX_BUFFER_FULL;
1729 hDTI->sig_callback(link->instance,
1730 link->interfac,
1731 link->channel,
1732 DTI_REASON_TX_BUFFER_FULL,
1733 NULL);
1734 }
1735 } /* dti_send_data() */
1736
1737
1738
1739 /*
1740 +--------------------------------------------------------------------------+
1741 | PROJECT : DTILIB MODULE : DTI_KERF |
1742 | STATE : code ROUTINE : flow_control_prim_received |
1743 +--------------------------------------------------------------------------+
1744
1745 PURPOSE : Process primitives DTI_GETDATA_REQ and DTI_READY_IND
1746 received from neighbour DTI
1747 */
1748
1749 GLOBAL void flow_control_prim_received (DTI_HANDLE hDTI,
1750 U32 link_id,
1751 U8 direction)
1752 {
1753 DTI_LINK* link;
1754 T_DTI2_DATA_IND* dti_data_ind;
1755
1756 trace_function(hDTI->handle,
1757 "flow_control_prim_received()",
1758 hDTI->entity_options);
1759
1760 /*
1761 * get link pointer
1762 */
1763 link = get_pointer_link_table(hDTI, link_id, direction);
1764 if(link EQ NULL)
1765 {
1766 /*
1767 * There is no link_id which requested to the link_id in the link_table.
1768 */
1769 trace_message_link_id(hDTI->handle,
1770 "DTI ERROR: fc_prim - No link in data base",
1771 link_id,
1772 hDTI->entity_options);
1773 return;
1774 }
1775
1776 /*
1777 * check for valid link
1778 * the link is valid if it is in IDLE or CLOSING state
1779 * Flow Control primitives are unexpected if Flow Control is disabled
1780 */
1781 if(((link->connect_state NEQ DTI_IDLE) AND
1782 (link->connect_state NEQ DTI_CLOSING)) OR
1783 (link->link_options EQ DTI_FLOW_CNTRL_DISABLED))
1784 {
1785 TRACE_EVENT_P4("HORST=7, weil: connect_state %d, link_options %d, link_id %u, direction %d",
1786 link->connect_state, link->link_options, link_id, direction);
1787 return;
1788 }
1789 /*
1790 * get next prim from queue
1791 */
1792 dti_data_ind = get_dti_data_ind_from_queue(hDTI, link);
1793 /*
1794 * Select the state.
1795 */
1796 switch (link->tx_state)
1797 {
1798 case DTI_TX_IDLE:
1799 case DTI_TX_FLOW:
1800 /*
1801 * A flow control primitive is received. Send a data packet
1802 * if there is any in the queue or change the state.
1803 * In case of an RIVIERA_ATP_LINK it is necessary to check the send queue
1804 * also in DTI_TX_FLOW state
1805 */
1806 if(dti_data_ind NEQ NULL)
1807 {
1808 /*
1809 * Select link_id and send data.
1810 */
1811 dti_data_ind->link_id = link->link_id;
1812 send_data_req_or_ind(hDTI, link, dti_data_ind);
1813
1814 /*
1815 * Stay in this state.
1816 */
1817 }
1818 else
1819 {
1820 /*
1821 * Change the state because there is a flow control primitive
1822 * and no packet has been sent.
1823 */
1824 link->tx_state = DTI_TX_FLOW;
1825 }
1826 break;
1827
1828 case DTI_TX_BUFFER_FULL:
1829 /*
1830 * The buffer had been full. Send packets from queue and signal ready
1831 */
1832 if(dti_data_ind NEQ NULL)
1833 {
1834 /*
1835 * Select link_id and send data.
1836 */
1837 dti_data_ind->link_id = link->link_id;
1838 send_data_req_or_ind(hDTI, link, dti_data_ind);
1839 /*
1840 * Change the state if the queue is ready
1841 * to get the next data from the entity
1842 */
1843 if(link->queue_len < link->queue_size)
1844 {
1845 link->tx_state = DTI_TX_IDLE;
1846 }
1847 }
1848 else
1849 {
1850 /*
1851 * Change the state because there is a flow control primitive
1852 * and no packet has been sent.
1853 */
1854 link->tx_state = DTI_TX_FLOW;
1855 }
1856 /*
1857 * Signal to the callback function that the buffer is ready.
1858 */
1859 if((link->connect_state NEQ DTI_CLOSING) AND
1860 (link->tx_state NEQ DTI_TX_BUFFER_FULL))
1861 {
1862 hDTI->sig_callback(link->instance,
1863 link->interfac,
1864 link->channel,
1865 DTI_REASON_TX_BUFFER_READY,
1866 NULL);
1867 }
1868 break;
1869
1870 default:
1871 trace_message_link_id(hDTI->handle,
1872 "DTI ERROR: Wrong state for flow control primitive",
1873 link->link_id,
1874 hDTI->entity_options);
1875 /*
1876 * free whole prim, incl. descs
1877 */
1878 if(dti_data_ind NEQ NULL)
1879 {
1880 mfree_desc(hDTI, (T_desc_list2*) &(dti_data_ind->desc_list2));
1881 PFREE(dti_data_ind);
1882 }
1883 break;
1884 }
1885
1886 /*
1887 * if the connection is to be closed and the send queue is empty
1888 * then close the connection now
1889 */
1890 if((link->queue_len EQ 0) AND
1891 (link->connect_state EQ DTI_CLOSING))
1892 {
1893 send_disconnect_req_or_ind(hDTI, link, DTI_CAUSE_NORMAL_CLOSE);
1894 close_link_with_signal(hDTI, link);
1895 }
1896 } /* flow_control_prim_received() */
1897
1898
1899
1900 /*
1901 +--------------------------------------------------------------------------+
1902 | PROJECT : DTILIB MODULE : DTI_KERF |
1903 | STATE : code ROUTINE : connect_init_prim_received |
1904 +--------------------------------------------------------------------------+
1905
1906 PURPOSE : Process primitives DTI_CONNECT_REQ and DTI_CONNECT_IND
1907 received from neighbour DTI
1908 */
1909
1910 GLOBAL void connect_init_prim_received (DTI_HANDLE hDTI,
1911 U32 link_id,
1912 U32 version,
1913 U8 direction)
1914 {
1915 DTI_LINK* link;
1916 BOOL send_cnf = FALSE;
1917 BOOL send_disc = FALSE;
1918 U8 signal = DTI_NO_SIGNAL;
1919
1920 trace_function( hDTI->handle,
1921 "connect_init_prim_received()",
1922 hDTI->entity_options);
1923
1924 /*
1925 * Check version of peer dtilib
1926 */
1927 if(check_dti_version(hDTI, version) EQ FALSE)
1928 {
1929 trace_message_link_id(hDTI->handle,
1930 "DTI ERROR: init_prim - Wrong DTI version",
1931 link_id,
1932 hDTI->entity_options);
1933 /*
1934 * Inform peer dtilib that connection failed
1935 */
1936 link = get_pointer_link_table(hDTI, link_id, direction);
1937 if(link NEQ NULL)
1938 {
1939 send_disconnect_req_or_ind (hDTI, link, DTI_CAUSE_UNSUPPORTED_VERSION);
1940 close_link_with_signal(hDTI, link);
1941 }
1942 return;
1943 }
1944
1945 switch (acquire_link (hDTI, link_id, direction, &link) )
1946 {
1947 case DTI_S_FOUND:
1948 /*
1949 * Entry for link_id found, continue connecting procedure
1950 */
1951 break;
1952
1953 case DTI_S_CREATED_NEW:
1954 /*
1955 * There is no entry with the requested link_id in the link_table yet.
1956 * Wait for call of dti_open().
1957 * The remaining parameters are set in dti_open(). Then the response
1958 * primitive will be sent.
1959 */
1960 link->connect_state = DTI_CONNECTING;
1961 return;
1962
1963 default:
1964 /*
1965 * No free link
1966 */
1967 return;
1968 }
1969
1970 /*
1971 * Start up connecting.
1972 */
1973 switch (link->connect_state)
1974 {
1975 case DTI_IDLE:
1976 /*
1977 * Reset the link and send a response primitive, free the data packets,
1978 * and call the callback funktion.
1979 */
1980 set_reset_req_para_link_table(hDTI, link);
1981 send_cnf = TRUE;
1982 signal = DTI_REASON_CONNECTION_OPENED;
1983 trace_message_link_id(hDTI->handle,
1984 "DTI connection opened",
1985 link->link_id,
1986 hDTI->entity_options);
1987 break;
1988
1989 case DTI_SETUP:
1990 /*
1991 * Collision ! The neighbour entity has sent a dti_connect_ind
1992 * primitive as well which means the neighbor enitiy is willing to connect as well.
1993 * So we send a response and open the connection.
1994 */
1995 link->connect_state = DTI_IDLE;
1996 send_cnf = TRUE;
1997 signal = DTI_REASON_CONNECTION_OPENED;
1998 link->rx_state = DTI_RX_IDLE;
1999 trace_message_link_id(hDTI->handle,
2000 "DTI connection opened",
2001 link->link_id,
2002 hDTI->entity_options);
2003 break;
2004
2005 case DTI_CLOSING:
2006 /*
2007 * because of the connect request, internal buffers
2008 * are being reset. Thus, the send queue is empty now
2009 * and the connection can be closed down.
2010 * there has to be a confirmation for the connect
2011 * primitive anyway
2012 */
2013 send_disc = TRUE;
2014 send_cnf = TRUE;
2015 break;
2016
2017 case DTI_CLOSED:
2018 /*
2019 * dti_open() is not called yet. The confirm primitive will
2020 * be sent then and the parameter will be set.
2021 */
2022 link->connect_state = DTI_CONNECTING;
2023 break;
2024
2025 default:
2026 trace_message_link_id(hDTI->handle,
2027 "DTI ERROR: init_prim - Wrong state dtilib",
2028 link_id,
2029 hDTI->entity_options);
2030 break;
2031 }
2032
2033 /*
2034 * Send the confirm primitive.
2035 */
2036 if (send_cnf)
2037 {
2038 send_connect_res_or_cnf (hDTI, link);
2039 }
2040
2041 /*
2042 * Send the disconnect primitive.
2043 */
2044 if (send_disc)
2045 {
2046 send_disconnect_req_or_ind (hDTI, link, DTI_CAUSE_NORMAL_CLOSE);
2047 close_link_with_signal(hDTI, link);
2048 /*
2049 * No more signals to be sent in this case..
2050 */
2051 return;
2052 }
2053
2054 /*
2055 * Activate callback function with reason_connection_opened
2056 * and, additionally, signal tx_buffer_ready if the queue is used.
2057 */
2058 if(signal EQ DTI_REASON_CONNECTION_OPENED)
2059 {
2060 send_open_ready_callback (hDTI, link);
2061 }
2062 } /* connect_init_prim_received() */
2063
2064
2065
2066 /*
2067 +--------------------------------------------------------------------------+
2068 | PROJECT : DTILIB MODULE : DTI_KERF |
2069 | STATE : code ROUTINE : connect_confirm_prim_received |
2070 +--------------------------------------------------------------------------+
2071
2072 PURPOSE : Process primitives DTI_CONNECT_RES and DTI_CONNECT_CNF
2073 received from neighbour DTI
2074 */
2075
2076 GLOBAL void connect_confirm_prim_received (DTI_HANDLE hDTI,
2077 U32 link_id,
2078 U32 version,
2079 U8 direction)
2080 {
2081 DTI_LINK* link;
2082 U8 signal = DTI_NO_SIGNAL;
2083
2084 trace_function(hDTI->handle,
2085 "connect_confirm_prim_received()",
2086 hDTI->entity_options);
2087
2088 /*
2089 * Note: No need to check the version because this has already been done
2090 * by the primitives dti_connect_req and dti_connect_ind.
2091 */
2092 if((link = get_pointer_link_table(hDTI, link_id, direction)) EQ NULL)
2093 {
2094 trace_message_link_id(hDTI->handle,
2095 "DTI ERROR: cnf_prim - No link in dtilib",
2096 link_id,
2097 hDTI->entity_options);
2098 return;
2099 }
2100
2101 /*
2102 * The link is in the list so check the state.
2103 */
2104 switch (link->connect_state)
2105 {
2106 case DTI_SETUP:
2107 /*
2108 * The entity can now enter the final state. The entity connection
2109 * is established.
2110 */
2111 link->connect_state = DTI_IDLE;
2112 signal = DTI_REASON_CONNECTION_OPENED;
2113 link->rx_state = DTI_RX_IDLE;
2114 trace_message_link_id(hDTI->handle,
2115 "DTI connection opened",
2116 link->link_id,
2117 hDTI->entity_options);
2118 break;
2119
2120 case DTI_CLOSED:
2121 case DTI_IDLE:
2122 /*
2123 * We are already in the final state. So there is nothing to do here.
2124 */
2125 break;
2126
2127 default:
2128 trace_message_link_id(hDTI->handle,
2129 "DTI ERROR: cnf_prim - Wrong state dtilib",
2130 link_id,
2131 hDTI->entity_options);
2132 break;
2133 }
2134
2135 /*
2136 * Activate callback function with reason_connection_opened
2137 * and, additionally, signal tx_buffer_ready if the queue is used.
2138 */
2139 if(signal EQ DTI_REASON_CONNECTION_OPENED)
2140 {
2141 send_open_ready_callback (hDTI, link);
2142 }
2143 } /* connect_confirm_prim_received() */
2144
2145
2146
2147 /*
2148 +--------------------------------------------------------------------------+
2149 | PROJECT : DTILIB MODULE : DTI_KERF |
2150 | STATE : code ROUTINE : disconnect_prim_received |
2151 +--------------------------------------------------------------------------+
2152
2153 PURPOSE : Process primitives DTI_DISCONNECT_IND and DTI_DISCONNECT_REQ
2154 received from neighbour DTI
2155 */
2156
2157 GLOBAL void disconnect_prim_received (DTI_HANDLE hDTI,
2158 U32 link_id,
2159 U8 direction)
2160 {
2161
2162 DTI_LINK *link;
2163
2164 trace_function(hDTI->handle,
2165 "disconnect_prim_received()",
2166 hDTI->entity_options);
2167
2168 /*
2169 * Is the link in the link list ?
2170 */
2171 if((link = get_pointer_link_table(
2172 hDTI,
2173 link_id,
2174 direction)
2175 ) NEQ NULL)
2176 {
2177 switch (link->connect_state)
2178 {
2179 /*
2180 * Link is already closed.
2181 */
2182 case DTI_CLOSED:
2183 trace_message_link_id(hDTI->handle,
2184 "DTI link alredy closed",
2185 link->link_id,
2186 hDTI->entity_options);
2187 break;
2188
2189 /*
2190 * Close the link.
2191 */
2192 default:
2193 close_link_with_signal(hDTI, link);
2194
2195 break;
2196 }
2197 }
2198
2199 }
2200
2201
2202
2203 /*
2204 +--------------------------------------------------------------------+
2205 | PROJECT : DTILIB MODULE : DTI_KERP |
2206 | STATE : code ROUTINE : data_prim_received |
2207 +--------------------------------------------------------------------+
2208
2209 *
2210 * Process primitives DTI_DATA_REQ and DTI_DATA_IND received from DTI peer
2211 */
2212
2213 GLOBAL void data_prim_received(DTI_HANDLE hDTI,
2214 T_DTI2_DATA_IND *dti_data_ind,
2215 U8 direction)
2216 {
2217 DTI_LINK *link;
2218 U32 link_id;
2219
2220 trace_function(hDTI->handle,
2221 "data_prim_received()",
2222 hDTI->entity_options);
2223
2224 /*
2225 * Check if old or new SAP is supported.
2226 */
2227 link_id = dti_data_ind->link_id;
2228
2229 /*
2230 * Is the link in the link list ?
2231 */
2232 link = get_pointer_link_table(hDTI, link_id, direction);
2233 if(link EQ NULL)
2234 {
2235 /*
2236 * The link_id is not in the list of ids.
2237 */
2238 trace_message_link_id(hDTI->handle,
2239 "DTI ERROR: data_prim - No link in data base",
2240 link_id,
2241 hDTI->entity_options);
2242 /*
2243 * Just ignore the received data primitive.
2244 */
2245 mfree_desc(hDTI, &dti_data_ind->desc_list2);
2246 PFREE(dti_data_ind);
2247 return;
2248 }
2249 /*
2250 * If there is no connection silently discard primitive.
2251 */
2252 if(link->connect_state NEQ DTI_IDLE)
2253 {
2254 trace_message_link_id(hDTI->handle,
2255 "DTI ERROR: data_prim_received() - link is not connected",
2256 link->link_id,
2257 hDTI->entity_options);
2258 /*
2259 * Just ignore the received data primitive.
2260 */
2261 mfree_desc(hDTI, &dti_data_ind->desc_list2);
2262 PFREE(dti_data_ind);
2263 return;
2264 }
2265 /*
2266 * Check if no flow control should be supported. Pass the primitive at once
2267 * to the entity over the callback function.
2268 */
2269 if(link->link_options EQ DTI_FLOW_CNTRL_DISABLED)
2270 {
2271 hDTI->sig_callback(link->instance,
2272 link->interfac,
2273 link->channel,
2274 DTI_REASON_DATA_RECEIVED,
2275 dti_data_ind);
2276 return;
2277 }
2278
2279 #ifdef FF_TCP_IP
2280 /*
2281 * Get primitive content in case it is a RIVIERA_ATP_LINK
2282 */
2283 if(link->link_type EQ RIVIERA_ATP_LINK)
2284 {
2285 if((link->rx_state EQ DTI_RX_READY) OR
2286 (link->rx_state EQ DTI_RX_STOPPED))
2287 {
2288 /*
2289 * DTI does not really know if there is data available
2290 * In case there is no ATP data the list_len value is set to 0
2291 */
2292 get_data_from_atp(hDTI, link, dti_data_ind);
2293
2294 if(dti_data_ind->desc_list2.list_len EQ 0)
2295 {
2296 /*
2297 * there is no data in the ATP buffer any more
2298 * so release the primitive and start ATP flow control again
2299 */
2300 mfree_desc(hDTI, &dti_data_ind->desc_list2);
2301 PFREE (dti_data_ind);
2302 TRACE_EVENT("atp_set_signal: ATP_RX_FLOW_ON");
2303 atp_set_signal(hDTI->entity_id_p,
2304 link->port_nb,
2305 ATP_RX_FLOW_ON,
2306 ATP_RX_FLOW_UNMASK);
2307 return;
2308 }
2309 }
2310 else
2311 {
2312 /*
2313 * the entity has stopped data flow
2314 * currently it is not allowed to receive data
2315 */
2316 mfree_desc(hDTI, &dti_data_ind->desc_list2);
2317 PFREE (dti_data_ind);
2318 return;
2319 }
2320 }
2321 #endif /* FF_TCP_IP */
2322
2323 /*
2324 * Handle the states.
2325 */
2326 switch(link->rx_state)
2327 {
2328 case DTI_RX_READY:
2329 /*
2330 * Receive dti_data_ind, give a signal and send flow control primitive.
2331 */
2332 hDTI->sig_callback(link->instance,
2333 link->interfac,
2334 link->channel,
2335 DTI_REASON_DATA_RECEIVED,
2336 dti_data_ind);
2337 /*
2338 * Check if the entity has stoped during the callback.
2339 * If yes do not send a flow control.
2340 */
2341 if(link->rx_state EQ DTI_RX_READY)
2342 {
2343 send_ready_req_or_ind(hDTI, link);
2344 }
2345 else
2346 {
2347 link->rx_state = DTI_RX_IDLE;
2348 }
2349 break;
2350
2351 case DTI_RX_STOPPED:
2352 /*
2353 * The entity has stoped the communication but the flow control primitive to
2354 * the neighbour entity was sent. The last dti_data_ind signal must be sended
2355 * to the entity. DTILIB change to DTI_RX_IDLE.
2356 */
2357 link->rx_state = DTI_RX_IDLE;
2358 hDTI->sig_callback(link->instance,
2359 link->interfac,
2360 link->channel,
2361 DTI_REASON_DATA_RECEIVED,
2362 dti_data_ind);
2363 break;
2364
2365 default:
2366 trace_message_link_id(hDTI->handle,
2367 "DTI ERROR: Wrong state for dti_data_ind primitive",
2368 link_id,
2369 hDTI->entity_options);
2370 mfree_desc(hDTI, &dti_data_ind->desc_list2);
2371 PFREE (dti_data_ind);
2372 break;
2373 }
2374 } /* data_prim_received() */
2375
2376
2377
2378 #ifdef _SIMULATION_
2379 /*
2380 +--------------------------------------------------------------------+
2381 | PROJECT : DTILIB MODULE : DTI_KERP |
2382 | STATE : code ROUTINE : data_test_prim_received |
2383 +--------------------------------------------------------------------+
2384
2385 PURPOSE : Process primitives DTI_DATA_TEST_REQ and DTI_DATA_TEST_IND
2386 received from neighbour DTI
2387 */
2388
2389 GLOBAL void data_test_prim_received (DTI_HANDLE hDTI,
2390 T_DTI2_DATA_TEST_IND *dti_data_test_ind,
2391 U8 direction)
2392 {
2393 USHORT len_buff, offset, i;
2394 T_desc2 *test_desc;
2395
2396 trace_function(hDTI->handle,
2397 "data_test_prim_received()",
2398 hDTI->entity_options);
2399
2400 /*
2401 * Fill in dti_data_ind the structure.
2402 */
2403 {
2404 PALLOC (dti_data_ind, DTI2_DATA_IND);
2405
2406 dti_data_ind->link_id = dti_data_test_ind->link_id;
2407 dti_data_ind->parameters = dti_data_test_ind->parameters;
2408
2409 len_buff = dti_data_test_ind->sdu.l_buf>>3;
2410 offset = dti_data_test_ind->sdu.o_buf>>3;
2411
2412 /*
2413 * Build a new desc and fill in the parameter.
2414 */
2415 dti_make_new_desc(hDTI, &test_desc, len_buff, TRUE);
2416
2417 for(i=0; i < len_buff; i++)
2418 test_desc->buffer[i] = dti_data_test_ind->sdu.buf[i+offset];
2419
2420 dti_data_ind->desc_list2.list_len = len_buff;
2421 dti_data_ind->desc_list2.first = (ULONG) test_desc;
2422
2423 /*
2424 * Handle the primitive.
2425 */
2426 PFREE (dti_data_test_ind);
2427
2428 data_prim_received (hDTI, dti_data_ind, direction);
2429 }
2430 }
2431
2432 #endif /* _SIMULATION_ */
2433
2434
2435 /*
2436 +-------------------------------------------------------------------------+
2437 | PROJECT : DTILIB MODULE : DTI_KERF |
2438 | STATE : code ROUTINE : vsi_c_psend_ntrace |
2439 +-------------------------------------------------------------------------+
2440
2441 *
2442 * vsi_c_psend without traces
2443 */
2444
2445 #ifdef MEMORY_SUPERVISION
2446 GLOBAL SHORT vsi_c_psend_ntrace ( T_HANDLE Caller, T_HANDLE ComHandle,
2447 T_VOID_STRUCT *ptr, ULONG MsgLen, const char *file, int line )
2448 #else /* MEMORY_SUPERVISION */
2449 GLOBAL SHORT vsi_c_psend_ntrace ( T_HANDLE Caller, T_HANDLE ComHandle,
2450 T_VOID_STRUCT *ptr, ULONG MsgLen )
2451 #endif /* MEMORY_SUPERVISION */
2452 {
2453 T_QMSG QMsg;
2454
2455 QMsg.Msg.Primitive.Prim = (T_VOID_STRUCT*)(D2P(ptr));
2456 QMsg.Msg.Primitive.PrimLen = MsgLen;
2457 QMsg.MsgType = MSG_PRIMITIVE;
2458
2459 #ifdef MEMORY_SUPERVISION
2460 return ( vsi_c_send ( Caller, ComHandle, &QMsg, file, line) );
2461 #else
2462 return ( vsi_c_send ( Caller, ComHandle, &QMsg) );
2463 #endif /* MEMORY_SUPERVISION */
2464 }