comparison src/g23m-fad/l2r/l2r.h @ 174:90eb61ecd093

src/g23m-fad: initial import from TCS3.2/LoCosto
author Mychaela Falconia <falcon@freecalypso.org>
date Wed, 12 Oct 2016 05:40:46 +0000
parents
children
comparison
equal deleted inserted replaced
173:bf64d785238a 174:90eb61ecd093
1 /*
2 +-----------------------------------------------------------------------------
3 | Project : CSD (8411)
4 | Modul : l2r.h
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 Entity
18 | L2R
19 +-----------------------------------------------------------------------------
20 */
21
22 #ifndef L2R_H
23 #define L2R_H
24
25 /*
26 * Conditional Compiling
27 */
28
29 #define L2R_TRACE_FLOW
30
31 /*
32 * instance management
33 */
34 #define GET_INSTANCE(p) &l2r_data_base[0]
35 #define L2R_INSTANCES 1
36
37 /*
38 * Types
39 */
40
41 typedef enum
42 {
43 NONTRANSP = 0,
44 TRANSP = 1
45 } T_MODE;
46
47 /*
48 * Constants
49 */
50
51 /*
52 * information for dti library
53 */
54 #define L2R_DTI_UP_INTERFACE 0
55 #define L2R_DTI_UP_CHANNEL 0
56 #define L2R_DTI_UP_DEF_INSTANCE 0
57 #define L2R_DTI_UPLINK_QUEUE_SIZE 0
58 #define L2R_BREAK_LEN 2
59
60 #define TIMER_TUP_SND 1
61
62 /*
63 * global unchangeable constants
64 */
65
66 #define DATA_SIZE_SHORT 25 /* num of data bytes in l2r frame (short format) */
67 #define DATA_SIZE_LONG 67 /* num of data bytes in l2r frame (long format)*/
68
69 #define LL_TO TUP_SND_VALUE /* default value for timer UP_SND (lower layer waiting for data) */
70
71 /*
72 * derived constants
73 */
74 #define HEADER_LEN (RLP_HEADER_LEN/8) /* 16 / 8 = 2 */
75 #define TRAILER_LEN 0 /* No CRC -> no trailer */
76 #define HT_LEN (HEADER_LEN + TRAILER_LEN)
77
78 #define RLP_FRAME_SIZE_SHORT (DATA_SIZE_SHORT + HT_LEN)
79 #define RLP_FRAME_SIZE_LONG (DATA_SIZE_LONG + HT_LEN)
80
81 #define L2R_FRAMES_PER_PRIM_MAX ((L2R_BYTES_PER_PRIM_MAX + RLP_FRAME_SIZE_SHORT - 1) / RLP_FRAME_SIZE_SHORT)
82
83 #define L2R_ENCODING_OFFSET (HEADER_LEN) /* Offset L2R frame in RLP frame in bytes */
84
85 #define MAX_UP_REMAP_QUEUE_SIZE (MAX_UP_PRIMS + L2R_K_MS_IWF_MAX + 1)
86 #define UP_REMAP_BUFFER_SIZE 20
87
88 /* global user specific constants */
89
90 #define MAX_UP_PRIMS 17 /* Maximum number of primitives, which L2R holds for sending, */
91 #define MAX_DL_PRIMS 17 /* Maximum number of primitives, which L2R holds for receiving */
92 /* 17 prims * 10 Frames * 25 Bytes * 8 Bit = 34000 Bit (>32kBit)*/
93 /* if there are less than 10 frames per primitive, then the maximum */
94 /* buffer size will be smaller. */
95
96 #define UP_RIBU_PREALLOC 2 /* Number of primitives to be preallocated (minimum: 2) */
97 #define MIN_RIBU_SIZE 3 /* Minimum ring buffer size (send and receive) */
98 /* minimum: UP_RIBU_PREALLOC+1 */
99
100 /* constants for L2RCOP status octets */
101
102 #define SO_ADR_MASK 0x1F /* 0b00011111 */
103 #define SO_ADR_MASK_TWO_OCT 0x7F /* 0b01111111 */
104
105 #define SO_TWO_OCTET 27 /* 0b11011 */
106 #define SO_BREAK_ACK 28 /* 0b11100 */
107 #define SO_BREAK_REQ 29 /* 0b11101 */
108 #define SO_END_FULL 30 /* 0b11110 */
109 #define SO_END_EMPTY 31 /* 0b11111 */
110
111 #define SO_SA_BIT 7
112 #define SO_SB_BIT 6
113 #define SO_X_BIT 5
114
115 #define SO_SA_BIT_MASK 0x80
116 #define SO_SB_BIT_MASK 0x40
117 #define SO_X_BIT_MASK 0x20
118
119 #define SO_STATUS_BITS_MASK (SO_SA_BIT_MASK + SO_SB_BIT_MASK)
120
121 #define GET_SO_SA_BIT(oct) (((oct) & SO_SA_BIT_MASK) >> SO_SA_BIT)
122 #define GET_SO_SB_BIT(oct) (((oct) & SO_SB_BIT_MASK) >> SO_SB_BIT)
123 #define GET_SO_X_BIT(oct) (((oct) & SO_X_BIT_MASK) >> SO_X_BIT)
124
125 /*
126 #define CLR_BIT(oct, bit) (oct &= ~(1<<bit))
127 */
128 #define SET_BIT(oct, bit) (oct |= (1<<bit))
129
130 /*
131 * Bitoffset for encoding/decoding
132 */
133 #define ENCODE_OFFSET 0
134
135 #ifndef NTRACE
136
137 /* for trace purposes */
138
139 #define SERVICE_NAME_DTI "DTI"
140 #define SERVICE_NAME_MGT "MGT"
141 #define SERVICE_NAME_CONIND "CONIND"
142 #define SERVICE_NAME_BREAK "BREAK"
143 #define SERVICE_NAME_UP "UP"
144 #define SERVICE_NAME_UP_UL "UP_UL"
145 #define SERVICE_NAME_UP_LL "UP_LL"
146 #define SERVICE_NAME_DN "DN"
147 #define SERVICE_NAME_DN_UL "DN_UL"
148 #define SERVICE_NAME_DN_LL "DN_LL"
149
150 #endif
151
152 #define DTI dti.
153
154 #define MGT mgt.
155 #define CONIND mgt.ConIndState.
156 #define BREAK mgt.BreakState.
157
158 #define UP up.
159 #define UP_UL up.UL_State.
160 #define UP_LL up.LL_State.
161
162 #define DN dn.
163 #define DN_UL dn.UL_State.
164 #define DN_LL dn.LL_State.
165
166 /*
167 * States of the entity process MGT
168 */
169 #define MGT_DETACHED 0
170 #define MGT_PENDING_ATTACH 1
171 #define MGT_ATTACHED 2
172 #define MGT_PENDING_CONNECT 3
173 #define MGT_CONNECTED 4
174 #define MGT_DISCONNECT_INITIATED 5
175 #define MGT_PENDING_DETACH 6
176 #define MGT_PERMANENT_ERROR 7
177
178 /*
179 * States of the entity process DN
180 */
181 #define DN_DISCONNECTED 0
182 #define DN_CONNECTED 1
183 #define DN_WAIT_FIRST_DATA 2
184
185 /*
186 * States of the entity process UP
187 */
188 #define UP_DISCONNECTED 0
189 #define UP_CONNECTED 1
190 #define UP_REMAP 2
191
192 /*==== TYPES ======================================================*/
193
194 /**********************************************************************************/
195 /*
196 * L2R global typedefs
197 */
198
199 #define IW_IDLE 0
200 #define IW_WAIT 1
201
202 #define ISW_IDLE 0
203 #define ISW_SEND 1
204 #define ISW_WAIT 2
205
206 #define FL_INACTIVE 0
207 #define FL_ACTIVE 1
208 #define FL_INVALID 2
209
210 typedef UBYTE T_FLOW;
211 typedef UBYTE T_BIT;
212 typedef UBYTE T_PRIM_INDEX;
213 typedef UBYTE T_UP_REMAP_PRIM_INDEX;
214 typedef UBYTE* T_P_UBYTE;
215 /*
216 typedef UBYTE T_L2R_FRAME_SHORT[DATA_SIZE_SHORT];
217 */
218 typedef UBYTE T_L2R_FRAME_LONG[DATA_SIZE_LONG];
219
220 typedef T_L2R_FRAME_LONG* T_P_L2R_FRAME;
221 typedef T_P_L2R_FRAME T_ADR_VECTOR[L2R_FRAMES_PER_PRIM_MAX];
222 typedef T_ADR_VECTOR* T_P_ADR_VECTOR;
223 typedef T_RLP_REMAP_DATA_IND* T_P_RLP_REMAP_DATA_IND;
224
225 typedef struct
226 {
227 T_PRIM_INDEX nFr; /* number of entries in vectors */
228 T_ADR_VECTOR adr; /* array of adress vectors */
229 T_PRIM_INDEX index; /* vector index of current frame */
230 UBYTE offset; /* offset in current frame */
231 UBYTE off_status; /* offset of status octet in current frame */
232 T_P_RLP_REMAP_DATA_IND prim; /* pointer to primitive (for FREE etc.) */
233 } T_RPRIM_DESCRIPTOR; /* remap primitive descriptor */
234
235 /**********************************************************************************/
236 /*
237 * Process downlink specific types
238 */
239
240 typedef T_RLP_DATA_IND* T_P_RLP_DATA_IND;
241
242 typedef struct
243 {
244 T_PRIM_INDEX nFr; /* number of entries in vectors */
245 T_P_ADR_VECTOR dadr; /* pointer to adress vector */
246 T_PRIM_INDEX index; /* vector index of current frame */
247 UBYTE offset; /* offset in current frame */
248 UBYTE off_status; /* offset of status octet in current frame */
249 T_P_RLP_DATA_IND prim; /* pointer to primitive (for FREE etc.) */
250 } T_DPRIM_DESCRIPTOR;
251
252 typedef T_DPRIM_DESCRIPTOR* T_P_DPRIM_DESCRIPTOR;
253
254 typedef UBYTE T_PRIM_DESC_RIBU_INDEX;
255 typedef UBYTE T_PRIM_DESC_RIBU_SIZE;
256
257 /*
258 * D o w n l i n k R i n g B u f f e r
259 *
260 * The Downlink Ring Buffer is an ordinary ring buffer. The L2RCOP entity
261 * writes received primitives into the buffer, the relay entity reads them
262 * from the buffer, and then the L2RCOP entity frees the primitive.
263 */
264
265
266 /*
267 * Ring buffer is by one bigger than max. number of prims,
268 * because it needs always one empty entry
269 */
270 #define MAX_DPRIM_RIBU_SIZE (MAX_DL_PRIMS + 1)
271
272 typedef struct
273 {
274 /*
275 The field read may be written only by the relay entity.
276 The other fields may be written only by the L2RCOP entity.
277 If the relay entity finds a NULL pointer at the read position,
278 then it doesn't read any data.
279 */
280 T_PRIM_DESC_RIBU_INDEX free; /* current free index in primDesc array */
281 T_RIBU idx;
282 T_P_DPRIM_DESCRIPTOR _primDesc[MAX_DPRIM_RIBU_SIZE];
283 } T_DPRIM_DESC_RIBU;
284
285
286 /**********************************************************************************/
287 /*
288 * Process uplink specific types
289 */
290
291 typedef T_RLP_DATA_REQ* T_P_RLP_DATA_REQ;
292
293 typedef struct
294 {
295 /* The fields index, offset and full may be written only by the relay entity */
296 /* The other fields may be written only by the L2RCOP entity */
297
298 T_PRIM_INDEX nFr; /* number of entries in vectors */
299 T_P_ADR_VECTOR adr; /* pointer to adress vector */
300 T_PRIM_INDEX index; /* vector index of current frame */
301 UBYTE offset; /* offset in current frame */
302 UBYTE off_status; /* offset of status octet in current frame */
303 BOOL full; /* primitive is filled up and ready for sending */
304 T_FLOW sa; /* last sa bit in this primitive */
305 T_FLOW sb; /* last sb bit in this primitive */
306 T_P_RLP_DATA_REQ prim; /* pointer to primitive (for FREE etc.) */
307 } T_UPRIM_DESCRIPTOR;
308
309 typedef T_UPRIM_DESCRIPTOR* T_P_UPRIM_DESCRIPTOR;
310
311 /*
312 * U p l i n k R i n g B u f f e r
313 *
314 * The L2RCOP entity can take a primitive away from the relay entity. This
315 * happens, when there are not enough data to be sent and the timer expires.
316 * In this case the L2RCOP entity takes the half ready primitive and sends
317 * it to RLP
318 *
319 * The handling of the ring buffer is as follows:
320 *
321 * * The L2RCOP entity allocates a number of primitives. The slot in which
322 * the next primitive has to be allocated is indicated by the alloc index.
323 * Besides the primitive, which is just beeing filled by the relay
324 * entity, there should be one complete empty primitive ready. This
325 * means that the alloc index is at least by two greater than the write
326 * index, unless the L2RCOP entity can not provide new primitives quick
327 * enough.
328 * * The relay entity writes data into the primitive indicated by the write
329 * index.
330 * * When a primitive is filled up, the relay advances the write pointer and
331 * sends a DTI2_DATA_REQ primitive to the L2RCOP entity.
332 * * When the L2RCOP entity receives the DTI2_DATA_REQ primitive it takes the
333 * primitive at the read position (which usually is identical with the
334 * previous write position), and advances the read index.
335 * Then it sends the primitive to the lower layer,
336 * and checks, if a new primitive has to be allocated.
337 * * When a timeout occurs, the L2RCOP entity locks the complete buffer.
338 * If no primitive is in the ring buffer (i.e read = write = alloc), a
339 * new primitive is allocated and sent as an empty primitive to the lower
340 * layer. If a completely filled primitive is in the buffer (i.e write /=
341 * read), this primitive is sent in the regular way. Otherwise there is
342 * a partial filled or empty primitive in the buffer (write /= alloc).
343 * Then this primitive is sent and the write index is incremented. In the
344 * case of a partial filled primitive the last uncompleted L2R status
345 * octet has to be finished before sending the primitive. Finally it
346 * is checked, if a new primitive has to be allocated.
347 * * When a break is requested from the upper layer, the data are discarded
348 * and a BREAK signal is put into a new primitive and sent to the lower layer.
349 * Then the buffer is new initialised.
350 */
351
352 /*
353 * Ring buffer is by one bigger than max. number of prims, because it
354 * needs always one empty entry
355 */
356 #define MAX_UPRIM_RIBU_SIZE (MAX_UP_PRIMS+1)
357
358 typedef struct
359 {
360 /*
361 The field write may be written only by the relay entity.
362 The other fields may be written only by the L2RCOP entity.
363 If the relay entity finds a NULL pointer at the write position,
364 then it doesn't write any data.
365 */
366 T_PRIM_DESC_RIBU_INDEX alloc; /* current alloc index in primDesc array */
367 T_RIBU idx;
368 T_P_UPRIM_DESCRIPTOR primDesc[MAX_UPRIM_RIBU_SIZE];
369 } T_UPRIM_DESC_RIBU;
370
371
372 /**********************************************************************************/
373 /*
374 * Relay entity specific types
375 */
376
377
378 /**********************************************************************************/
379 /*
380 * process global data
381 */
382
383 /**********************************************************************************/
384
385 typedef struct
386 {
387 UBYTE state;
388 #ifndef NTRACE
389 char *name;
390 char *state_name;
391 #endif
392 } T_SUB_STATE;
393
394 /*
395 * data for process management
396 */
397
398 typedef struct
399 {
400 UBYTE state;
401 #ifndef NTRACE
402 char *name;
403 char *state_name;
404 #endif
405
406 T_SUB_STATE BreakState;
407 T_SUB_STATE ConIndState; /* IW_WAIT: RLP_CONNECT_IND is pending during MGT_PENDING_ATTACH*/
408
409 BOOL Connected; /* Indicates, that L2R is in the connected state */
410 BOOL FlowCtrlUsed; /* Flow Control is used (no COPnoFlCt) */
411
412 T_PRIM_DESC_RIBU_SIZE RiBuSize; /* Size of ring buffers (number of primitives) */
413
414 ULONG link_id; /* Channel identifier */
415 UBYTE InstID; /* instance identifier */
416 USHORT FrameSize; /* Size of frame, (RLP_FRAME_SIZE_LONG or RLP_FRAME_SIZE_SHORT) */
417 UBYTE FramesPerPrim; /* Number of frames per primitive */
418 ULONG ConnectPrimType;/* {L2R_CONNECT_CNF, L2R_CONNECT_IND} */
419 } T_MGT;
420
421 /**********************************************************************************/
422 /*
423 * data for process downlink
424 */
425
426 typedef struct
427 {
428 UBYTE state;
429 #ifndef NTRACE
430 char *name;
431 char *state_name;
432 #endif
433
434 T_SUB_STATE UL_State; /* State of upper layer (only for test environment) */
435 /* WAIT: Upper layer is waiting for data from L2R */
436
437 T_SUB_STATE LL_State; /* State of lower layer */
438 /* WAIT: L2R has requested data from LL and is still waiting for it */
439
440 BOOL FlowCtrlUsed; /* Flow control is used */
441 UBYTE InstID; /* instance number */
442 ULONG link_id; /* Channel identifier */
443 BOOL DtiConnected; /* DTI is connected */
444 T_FLOW DnFlow; /* Flow control state for downlink data transfer */
445 T_FLOW UpFlow; /* Flow control state for uplink data transfer */
446 T_FLOW ULFlow; /* Flow control state of upper layer */
447 T_FLOW LLFlow; /* Flow control state of lower layer */
448 T_FLOW MrgFlow; /* Merged flow control state = LLFlow + UpFlow */
449 #ifdef L2R_TRACE_FLOW
450 T_FLOW LastSentFlow; /* Last flow control state, sent to DTI */
451 #endif
452 BOOL ReportMrgFlow;/* Merged flow has changed and must be reported to upper layer */
453 T_PRIM_DESC_RIBU_INDEX FlowThresh; /* Threshold for flow control */
454 UBYTE LastState; /* Last received state (sa, sb, x as in status octet) */
455
456 T_DTI2_DATA_IND *Brk_dti_data_ind; /* data indication for relaying break indication */
457
458 T_DPRIM_DESC_RIBU RiBu;
459 T_DPRIM_DESCRIPTOR PrimDesc[MAX_DPRIM_RIBU_SIZE];
460 T_ADR_VECTOR AdrVec[MAX_DPRIM_RIBU_SIZE];
461
462 } T_DN;
463
464 /**********************************************************************************/
465 /*
466 * data for process uplink
467 */
468
469 typedef struct
470 {
471 UBYTE state;
472 #ifndef NTRACE
473 char *name;
474 char *state_name;
475 #endif
476
477 T_SUB_STATE UL_State; /* State of upper layer (only for test environment) */
478 /* IW_'WAIT': L2R is waiting for data from upper layer*/
479
480 T_SUB_STATE LL_State; /* State of lower layer */
481 /* ISW_WAIT: LL has requested data and is still waiting for it */
482 /* ISW_SEND: data are ready for sending, but no request from LL */
483
484 BOOL FlowCtrlUsed; /* Flow control is used */
485 UBYTE InstID; /* instance number */
486 ULONG link_id; /* Channel identifier */
487 BOOL DtiConnected; /* DTI is connected */
488 T_FLOW DnFlow; /* Flow control state for downlink data transfer */
489 T_FLOW UpFlow; /* Flow control state for uplink data transfer */
490 T_FLOW ULFlow; /* Flow control state of upper layer */
491 T_FLOW LLFlow; /* Flow control state of lower layer */
492 T_FLOW MrgFlow; /* Merged flow control state = UP_ULFlow + UP_DNFlow */
493 T_PRIM_DESC_RIBU_INDEX FlowThreshLo; /* Low Threshold for flow control */
494 T_PRIM_DESC_RIBU_INDEX FlowThreshHi; /* High Threshold for flow control */
495 USHORT DataSize; /* Size of data, (calculated from FrameSize) */
496 USHORT FrameSize; /* Size of frame, (RLP_FRAME_SIZE_LONG or RLP_FRAME_SIZE_SHORT) */
497 USHORT OldFrameSize; /* Size of RLP frame (before REMAP command) */
498 UBYTE FramesPerPrim;
499 UBYTE LastRcvdSa; /* Last received value of sa */
500 UBYTE LastRcvdSb; /* Last received value of sb */
501 UBYTE LastSentSa; /* Last sent value of sa */
502 UBYTE LastSentSb; /* Last sent value of sb */
503 T_FLOW LastSentFlow; /* Last sent value of flow control */
504
505 T_DTI2_DATA_REQ *Prim; /* For DTI interface to hold last received primitive */
506
507 T_UPRIM_DESC_RIBU RiBu;
508 T_UPRIM_DESCRIPTOR PrimDesc[MAX_UPRIM_RIBU_SIZE];
509 T_ADR_VECTOR AdrVec[MAX_UPRIM_RIBU_SIZE];
510
511 BOOL StoreDataActive; /* prevents recursive calls of up_store_data */
512 BOOL UrgentMsg; /* A BREAK primitive is waiting to be sent */
513 BOOL DiscardRemapData;/* Data in RLP_REMAP_DATA_IND have to be discarded */
514 T_RPRIM_DESCRIPTOR QRemapPrimDesc;
515 T_P_RLP_REMAP_DATA_IND QRemap[MAX_UP_REMAP_QUEUE_SIZE]; /* Queue for primitives, which have to be remapped */
516 T_UP_REMAP_PRIM_INDEX QRemapRead; /* Read index for REMAP Queue */
517 T_UP_REMAP_PRIM_INDEX QRemapWrite; /* Write index for REMAP Queue */
518 UBYTE BRemap[UP_REMAP_BUFFER_SIZE]; /* Char. buffer for copying data from REMAP Queue */
519 T_P_UBYTE BRemapAdr; /* Start address in remap buffer */
520 USHORT BRemapLen; /* Number of bytes in remap buffer */
521 UBYTE BRemapSa; /* Value of SA in remap buffer */
522 UBYTE BRemapSb; /* Value of SB in remap buffer */
523 UBYTE BRemapLastState; /* Last state in remap buffer (sa, sb, x as in status octet) */
524 } T_UP;
525
526 /**********************************************************************************/
527 /*
528 * data for relay entity
529 */
530
531 /*
532 * entity data for each L2R instance
533 */
534
535 typedef struct
536 {
537 T_SUB_STATE dti; /* state variable for DTI library */
538 T_MGT mgt; /* process management */
539 T_DN dn; /* process downlink */
540 T_UP up; /* process uplink */
541 } T_L2R_DATA;
542
543
544 /*==== EXPORT =====================================================*/
545 /*
546 * data base
547 */
548
549 EXTERN T_L2R_DATA l2r_data_base [];
550 EXTERN T_L2R_DATA *l2r_data;
551 EXTERN ULONG l2r_data_magic_num;
552
553 #define L2R_DATA_MAGIC_NUM (('L'<<24) + ('2'<<16) + ('R'<<8)) /* "L2R",NUL */
554
555 #define ENTITY_DATA l2r_data
556
557 /*
558 * Prototypes
559 *
560 * L2R MANAGEMENT
561 *
562 * MANAGEMENT primitive processing
563 */
564
565
566 #ifdef OPTION_MULTITHREAD
567 #define mgt_l2r_connect_cnf _ENTITY_PREFIXED(mgt_l2r_connect_cnf)
568 #define mgt_l2r_activate_req _ENTITY_PREFIXED(mgt_l2r_activate_req)
569 #define mgt_l2r_deactivate_req _ENTITY_PREFIXED(mgt_l2r_deactivate_req)
570 #define mgt_l2r_connect_req _ENTITY_PREFIXED(mgt_l2r_connect_req)
571 #define mgt_l2r_disc_req _ENTITY_PREFIXED(mgt_l2r_disc_req)
572 #define mgt_l2r_dti_req _ENTITY_PREFIXED(mgt_l2r_dti_req)
573
574 #define mgt_rlp_detach_cnf _ENTITY_PREFIXED(mgt_rlp_detach_cnf)
575 #define mgt_rlp_connect_ind _ENTITY_PREFIXED(mgt_rlp_connect_ind)
576 #define mgt_rlp_connect_cnf _ENTITY_PREFIXED(mgt_rlp_connect_cnf)
577 #define mgt_rlp_disc_ind _ENTITY_PREFIXED(mgt_rlp_disc_ind)
578 #define mgt_rlp_disc_cnf _ENTITY_PREFIXED(mgt_rlp_disc_cnf)
579 #define mgt_rlp_reset_ind _ENTITY_PREFIXED(mgt_rlp_reset_ind)
580 #define mgt_rlp_reset_cnf _ENTITY_PREFIXED(mgt_rlp_reset_cnf)
581 #define mgt_rlp_ui_ind _ENTITY_PREFIXED(mgt_rlp_ui_ind)
582 #define mgt_rlp_xid_ind _ENTITY_PREFIXED(mgt_rlp_xid_ind)
583 #define mgt_rlp_error_ind _ENTITY_PREFIXED(mgt_rlp_error_ind)
584 #define mgt_rlp_statistic_ind _ENTITY_PREFIXED(mgt_rlp_statistic_ind)
585 #endif
586
587 EXTERN void mgt_l2r_connect_cnf (UBYTE nack);
588 EXTERN void mgt_l2r_activate_req (T_L2R_ACTIVATE_REQ *l2r_activate_req);
589 EXTERN void mgt_l2r_deactivate_req (T_L2R_DEACTIVATE_REQ *l2r_deactivate_req);
590 EXTERN void mgt_l2r_connect_req (T_L2R_CONNECT_REQ *l2r_connect_req);
591 EXTERN void mgt_l2r_disc_req (T_L2R_DISC_REQ *l2r_disc_req);
592 EXTERN void mgt_l2r_dti_req (T_L2R_DTI_REQ *l2r_dti_req);
593
594 EXTERN void mgt_rlp_detach_cnf (T_RLP_DETACH_CNF *rlp_detach_cnf);
595 EXTERN void mgt_rlp_connect_ind (T_RLP_CONNECT_IND *rlp_connect_ind);
596 EXTERN void mgt_rlp_connect_cnf (T_RLP_CONNECT_CNF *rlp_connect_cnf);
597 EXTERN void mgt_rlp_disc_ind (T_RLP_DISC_IND *rlp_disc_ind);
598 EXTERN void mgt_rlp_disc_cnf (T_RLP_DISC_CNF *rlp_disc_cnf);
599 EXTERN void mgt_rlp_reset_ind (T_RLP_RESET_IND *rlp_reset_ind);
600 EXTERN void mgt_rlp_reset_cnf (T_RLP_RESET_CNF *rlp_reset_cnf);
601 EXTERN void mgt_rlp_ui_ind (T_RLP_UI_IND *rlp_ui_ind);
602 EXTERN void mgt_rlp_xid_ind (T_RLP_XID_IND *rlp_xid_ind);
603 EXTERN void mgt_rlp_error_ind (T_RLP_ERROR_IND *rlp_error_ind);
604 EXTERN void mgt_rlp_statistic_ind (T_RLP_STATISTIC_IND *rlp_statistic_ind);
605
606
607 /*
608 * MANAGEMENT signal processing
609 */
610 #ifdef OPTION_MULTITHREAD
611 #define sig_dn_mgt_break_ind _ENTITY_PREFIXED(sig_dn_mgt_break_ind)
612 #define sig_dn_mgt_first_data_ind _ENTITY_PREFIXED(sig_dn_mgt_first_data_ind)
613 #define sig_up_mgt_break_ind _ENTITY_PREFIXED(sig_up_mgt_break_ind)
614 #endif
615
616 EXTERN void sig_dn_mgt_break_ind(T_BIT sa, T_BIT sb, T_FLOW flow);
617 EXTERN void sig_dn_mgt_first_data_ind(void);
618 EXTERN void sig_up_mgt_break_ind(T_DTI2_DATA_REQ *dti_data_req);
619
620 /*
621 * MANAGEMENT procedures
622 */
623
624 #ifdef OPTION_MULTITHREAD
625 #define mgt_init _ENTITY_PREFIXED(mgt_init )
626 #define mgt_checkpar _ENTITY_PREFIXED(mgt_checkpar )
627 #define mgt_deinit_connection _ENTITY_PREFIXED(mgt_deinit_connection )
628 #define mgt_init_connection _ENTITY_PREFIXED(mgt_init_connection )
629 #define mgt_send_l2r_error_ind _ENTITY_PREFIXED(mgt_send_l2r_error_ind)
630 #endif
631
632 EXTERN void mgt_init(T_MGT *dmgt);
633 EXTERN BOOL mgt_checkpar(T_L2R_ACTIVATE_REQ *ar);
634 EXTERN void mgt_deinit_connection(void);
635 EXTERN void mgt_init_connection(BOOL indication);
636 EXTERN void mgt_send_l2r_error_ind(USHORT cause);
637
638 /*
639 * L2R DN
640 *
641 * DN primitive processing
642 */
643
644 #ifdef OPTION_MULTITHREAD
645 #define dn_rlp_data_ind _ENTITY_PREFIXED(dn_rlp_data_ind)
646 #endif
647
648 EXTERN void dn_rlp_data_ind (T_RLP_DATA_IND *rlp_data_ind);
649
650 /*
651 * DN signal processing
652 */
653
654 #ifdef OPTION_MULTITHREAD
655 #define sig_mgt_dn_conn_req _ENTITY_PREFIXED(sig_mgt_dn_conn_req)
656 #define sig_mgt_dn_disc_req _ENTITY_PREFIXED(sig_mgt_dn_disc_req)
657 #define sig_mgt_dn_break_req _ENTITY_PREFIXED(sig_mgt_dn_break_req)
658 #define sig_mgt_dn_clear_req _ENTITY_PREFIXED(sig_mgt_dn_clear_req)
659 #define sig_mgt_dn_reconn_req _ENTITY_PREFIXED(sig_mgt_dn_reconn_req)
660 #define sig_mgt_dn_dti_conn_setup _ENTITY_PREFIXED(sig_mgt_dn_dti_conn_setup)
661 #define sig_up_dn_flow _ENTITY_PREFIXED(sig_up_dn_flow)
662 #define sig_up_dn_ul_flow _ENTITY_PREFIXED(sig_up_dn_ul_flow)
663 #define sig_mgt_dn_send_break_req _ENTITY_PREFIXED(sig_mgt_dn_send_break_req)
664 #endif
665
666 EXTERN void sig_mgt_dn_conn_req(BOOL flowCtrlUsed, T_PRIM_DESC_RIBU_SIZE riBuSize, UBYTE inst_id);
667
668 EXTERN void sig_mgt_dn_disc_req (void);
669 EXTERN void sig_mgt_dn_break_req (void);
670 EXTERN void sig_mgt_dn_clear_req (void);
671 EXTERN void sig_mgt_dn_reconn_req (void);
672 EXTERN void sig_mgt_dn_dti_conn_setup (ULONG link_id);
673 EXTERN void sig_up_dn_flow (T_FLOW); /* Flow Control Active */
674 EXTERN void sig_up_dn_ul_flow (T_FLOW); /* Flow Control Active */
675 EXTERN void sig_mgt_dn_send_break_req();
676
677 /*
678 * DN procedures
679 */
680
681 #ifdef OPTION_MULTITHREAD
682 #define dn_init _ENTITY_PREFIXED(dn_init )
683 #define dn_check_flow _ENTITY_PREFIXED(dn_check_flow )
684 #define dn_send_data_ind _ENTITY_PREFIXED(dn_send_data_ind )
685 #define dn_scan_break_req _ENTITY_PREFIXED(dn_scan_break_req )
686 #define dn_free_all_prims _ENTITY_PREFIXED(dn_free_all_prims )
687 #define dn_cond_free_prims _ENTITY_PREFIXED(dn_cond_free_prims )
688 #define dn_store_prim _ENTITY_PREFIXED(dn_store_prim )
689 #define dn_cond_report_status _ENTITY_PREFIXED(dn_cond_report_status )
690 #define dn_init_ribu _ENTITY_PREFIXED(dn_init_ribu )
691 #define dn_cond_req_data _ENTITY_PREFIXED(dn_cond_req_data )
692 #define dn_merge_flow _ENTITY_PREFIXED(dn_merge_flow )
693 #define dn_store_status _ENTITY_PREFIXED(dn_store_status )
694 #define dn_cond_report_status _ENTITY_PREFIXED(dn_cond_report_status )
695 #endif
696
697 EXTERN void dn_init(T_DN *ddn);
698 EXTERN void dn_check_flow(void);
699 EXTERN void dn_send_data_ind(void);
700
701 EXTERN void dn_scan_break_req
702 (
703 T_P_RLP_DATA_IND data_ind,
704 BOOL *found,
705 T_PRIM_INDEX *index,
706 T_PRIM_INDEX *frames,
707 T_PRIM_INDEX *emptyfr,
708 T_BIT *sa,
709 T_BIT *sb,
710 T_FLOW *flow_brk,
711 T_FLOW *flow_gen
712 );
713
714 EXTERN void dn_store_prim
715 (
716 T_P_RLP_DATA_IND data_ind,
717 T_PRIM_INDEX index
718 );
719
720 EXTERN void dn_free_all_prims
721 (
722 void
723 );
724
725 EXTERN void dn_cond_free_prims
726 (
727 void
728 );
729
730 EXTERN void dn_init_ribu
731 (
732 void
733 );
734
735 GLOBAL void dn_cond_report_status
736 (
737 void
738 );
739
740 EXTERN void dn_cond_req_data
741 (
742 void
743 );
744
745 EXTERN void dn_store_status
746 (
747 T_FLOW flow
748 );
749
750 EXTERN void dn_merge_flow
751 (
752 void
753 );
754
755 EXTERN void dn_cond_report_status
756 (
757 void
758 );
759
760 /*
761 * L2R UP
762 *
763 * UP primitive processing
764 */
765
766 #ifdef OPTION_MULTITHREAD
767 #define up_rlp_ready_ind _ENTITY_PREFIXED(up_rlp_ready_ind)
768 #endif
769
770 EXTERN void up_rlp_ready_ind (T_RLP_READY_IND *rlp_ready_ind);
771
772 /*
773 * UP signal processing
774 */
775 #ifdef OPTION_MULTITHREAD
776 #define sig_mgt_up_conn_req _ENTITY_PREFIXED(sig_mgt_up_conn_req)
777 #define sig_mgt_up_disc_req _ENTITY_PREFIXED(sig_mgt_up_disc_req)
778 #define sig_mgt_up_break_req _ENTITY_PREFIXED(sig_mgt_up_break_req)
779 #define sig_mgt_up_clear_req _ENTITY_PREFIXED(sig_mgt_up_clear_req)
780 #define sig_mgt_up_dti_conn_setup _ENTITY_PREFIXED(sig_mgt_up_dti_conn_setup)
781 #define sig_mgt_up_dti_conn_open _ENTITY_PREFIXED(sig_mgt_up_dti_conn_open)
782 #define sig_dn_up_flow _ENTITY_PREFIXED(sig_dn_up_flow)
783 #define sig_dn_up_ll_flow _ENTITY_PREFIXED(sig_dn_up_ll_flow)
784 #endif
785
786
787 EXTERN void sig_mgt_up_conn_req
788 (
789 UBYTE framesPerPrim,
790 USHORT frameSize,
791 BOOL flowCtrlUsed,
792 T_PRIM_DESC_RIBU_SIZE riBufferSize,
793 UBYTE inst_id
794 );
795
796 EXTERN void sig_mgt_up_disc_req
797 (
798 void
799 );
800
801 EXTERN void sig_mgt_up_break_req
802 (
803 T_BIT sa,
804 T_BIT sb,
805 T_FLOW flow
806 );
807
808 EXTERN void sig_mgt_up_clear_req
809 (
810 void
811 );
812
813 EXTERN void sig_mgt_up_dti_conn_setup (ULONG link_id);
814
815 EXTERN void sig_mgt_up_dti_conn_open();
816
817 EXTERN void sig_dn_up_flow
818 (
819 T_FLOW flow
820 );
821
822 EXTERN void sig_dn_up_ll_flow
823 (
824 T_FLOW flow
825 );
826
827 /*
828 * UP procedures
829 */
830
831 #ifdef OPTION_MULTITHREAD
832 #define up_init _ENTITY_PREFIXED(up_init )
833 #define up_send_prim_timeout _ENTITY_PREFIXED(up_send_prim_timeout )
834 #define up_check_alloc _ENTITY_PREFIXED(up_check_alloc )
835 #define up_check_flow _ENTITY_PREFIXED(up_check_flow )
836 #define up_store_data _ENTITY_PREFIXED(up_store_data )
837 #define up_send_ready _ENTITY_PREFIXED(up_send_ready )
838 #define up_deinit_ribu _ENTITY_PREFIXED(up_deinit_ribu )
839 #define up_send_current_prim _ENTITY_PREFIXED(up_send_current_prim )
840 #define up_send_prim_cond _ENTITY_PREFIXED(up_send_prim_cond )
841 #define up_init_ribu _ENTITY_PREFIXED(up_init_ribu )
842 #define up_store_status _ENTITY_PREFIXED(up_store_status )
843 #define up_send_empty_frame _ENTITY_PREFIXED(up_send_empty_frame )
844 #define up_send_status _ENTITY_PREFIXED(up_send_status )
845 #define up_merge_flow _ENTITY_PREFIXED(up_merge_flow )
846 #define up_rq_init _ENTITY_PREFIXED(up_rq_init )
847 #define up_some_data_to_send _ENTITY_PREFIXED(up_some_data_to_send )
848 #endif
849
850 #define sig_dti_mgt_connection_opened_ind \
851 _ENTITY_PREFIXED(sig_dti_mgt_connection_opened_ind)
852 #define sig_dti_mgt_connection_closed_ind \
853 _ENTITY_PREFIXED(sig_dti_mgt_connection_closed_ind)
854 #define sig_dti_dn_tx_buffer_full_ind \
855 _ENTITY_PREFIXED(sig_dti_dn_tx_buffer_full_ind )
856 #define sig_dti_dn_tx_buffer_ready_ind \
857 _ENTITY_PREFIXED(sig_dti_dn_tx_buffer_ready_ind )
858 #define sig_dti_up_data_received_ind \
859 _ENTITY_PREFIXED(sig_dti_up_data_received_ind )
860
861
862 EXTERN void up_init(T_UP *dup);
863
864 EXTERN void up_send_prim_timeout
865 (
866 void
867 );
868
869 EXTERN void up_check_alloc
870 (
871 void
872 );
873
874 EXTERN void up_check_flow
875 (
876 void
877 );
878
879 EXTERN void up_store_data
880 (
881 void
882 );
883
884 EXTERN void up_send_ready
885 (
886 void
887 );
888
889 EXTERN void up_deinit_ribu
890 (
891 void
892 );
893
894 EXTERN void up_send_current_prim
895 (
896 void
897 );
898
899 EXTERN void up_send_prim_cond
900 (
901 void
902 );
903
904 EXTERN void up_init_ribu
905 (
906 void
907 );
908
909 EXTERN void up_store_status
910 (
911 T_BIT sa,
912 T_BIT sb,
913 T_FLOW flow
914 );
915
916 EXTERN void up_send_empty_frame
917 (
918 T_BIT sa,
919 T_BIT sb,
920 T_FLOW flow
921 );
922
923 EXTERN void up_send_status
924 (
925 T_BIT sa,
926 T_BIT sb,
927 T_FLOW flow,
928 UBYTE adr
929 );
930
931 EXTERN void up_merge_flow
932 (
933 void
934 );
935
936 EXTERN void up_rq_init
937 (
938 void
939 );
940
941 EXTERN BOOL up_some_data_to_send
942 (
943 void
944 );
945
946 /*
947 * these functions are called by pei_sig_callback
948 */
949 EXTERN void sig_dti_mgt_connection_opened_ind();
950 EXTERN void sig_dti_mgt_connection_closed_ind();
951
952 EXTERN void sig_dti_dn_tx_buffer_full_ind();
953 EXTERN void sig_dti_dn_tx_buffer_ready_ind();
954
955 EXTERN void sig_dti_up_data_received_ind
956 (
957 T_DTI2_DATA_REQ *dti_data_req
958 );
959
960 /*
961 * timer
962 */
963 #define TIMERSTART(i,v) vsi_t_start (VSI_CALLER i, v)
964 #define TIMERSTOP(i) vsi_t_stop (VSI_CALLER i);
965
966 /*
967 * Communication handles
968 */
969
970 #ifdef OPTION_MULTITHREAD
971 #define hCommCTRL _ENTITY_PREFIXED(hCommCTRL)
972 #define hCommRLP _ENTITY_PREFIXED(hCommRLP)
973 #ifdef _SIMULATION_
974 #define hCommRA _ENTITY_PREFIXED(hCommRA)
975 #endif
976 #endif /* OPTION_MULTITHREAD */
977
978 EXTERN DTI_HANDLE l2r_hDTI; /* DTI connection handle for DTI library */
979
980 EXTERN T_HANDLE l2r_handle;
981 EXTERN T_HANDLE hCommCTRL; /* Controller Communication */
982 EXTERN T_HANDLE hCommRLP; /* RLP Communication */
983
984 #ifdef _SIMULATION_
985 EXTERN T_HANDLE hCommRA; /* RA Communication */
986 #endif
987
988 EXTERN T_MODE l2r_data_mode;
989
990 /*
991 * MALLOC / FREE for old frame
992 */
993
994 #endif