FreeCalypso > hg > fc-magnetite
comparison src/g23m-fad/rlp/rlp_kerf.c @ 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 : GSM-F&D (8411) | |
4 | Modul : RLP_KERF | |
5 +----------------------------------------------------------------------------- | |
6 | Copyright 2002 Texas Instruments Berlin, AG | |
7 | All rights reserved. | |
8 | | |
9 | This file is confidential and a trade secret of Texas | |
10 | Instruments Berlin, AG | |
11 | The receipt of or possession of this file does not convey | |
12 | any rights to reproduce or disclose its contents or to | |
13 | manufacture, use, or sell anything it may describe, in | |
14 | whole, or in part, without the specific written consent of | |
15 | Texas Instruments Berlin, AG. | |
16 +----------------------------------------------------------------------------- | |
17 | Purpose : This Modul defines the procedures and functions for | |
18 | the component Radio Link Protocol of the mobile station | |
19 +----------------------------------------------------------------------------- | |
20 */ | |
21 | |
22 #ifndef RLP_KERF_C | |
23 #define RLP_KERF_C | |
24 #endif | |
25 | |
26 #define ENTITY_RLP | |
27 | |
28 /*==== INCLUDES ===================================================*/ | |
29 | |
30 #include <string.h> | |
31 #include "typedefs.h" | |
32 #include "pconst.cdg" | |
33 #include "vsi.h" | |
34 #include "macdef.h" | |
35 #include "pconst.cdg" | |
36 #include "custom.h" | |
37 #include "gsm.h" | |
38 #include "cnf_rlp.h" | |
39 #include "mon_rlp.h" | |
40 #include "prim.h" | |
41 #include "pei.h" | |
42 #include "tok.h" | |
43 #include "ccdapi.h" | |
44 #include "rlp.h" | |
45 | |
46 /*==== CONST =======================================================*/ | |
47 | |
48 /*==== TYPES =======================================================*/ | |
49 | |
50 /*==== VAR EXPORT ==================================================*/ | |
51 | |
52 /*==== VAR LOCAL ===================================================*/ | |
53 | |
54 /*==== FUNCTIONS ===================================================*/ | |
55 | |
56 /* | |
57 +--------------------------------------------------------------------+ | |
58 | PROJECT : GSM-F&D (8411) MODULE : RLP_KERF | | |
59 | STATE : code ROUTINE : ker_initTRCVS | | |
60 +--------------------------------------------------------------------+ | |
61 | |
62 PURPOSE : Initialise the TCRVS table | |
63 | |
64 */ | |
65 | |
66 LOCAL void ker_initTRCVS(T_RCVS_ENTRY *rcvsTab) | |
67 { | |
68 T_FRAME_NUM lookUp; | |
69 | |
70 TRACE_FUNCTION ("ker_initTRCVS()"); | |
71 | |
72 for (lookUp = 0; lookUp < MAX_SREJ_COUNT; lookUp++) | |
73 { | |
74 rcvsTab[lookUp].isFree = TRUE; | |
75 rcvsTab[lookUp].slot = INVALID_IDX; | |
76 rcvsTab[lookUp].trcvs_running = FALSE; | |
77 } | |
78 } | |
79 | |
80 /* | |
81 +--------------------------------------------------------------------+ | |
82 | PROJECT : GSM-F&D (8411) MODULE : RLP_KERF | | |
83 | STATE : code ROUTINE : ker_init | | |
84 +--------------------------------------------------------------------+ | |
85 | |
86 PURPOSE : initialise the rlp data for the kernel process | |
87 | |
88 */ | |
89 | |
90 GLOBAL void ker_init(void) | |
91 { | |
92 TRACE_FUNCTION ("ker_init()"); | |
93 | |
94 rlp_data->tul_rcv_running = FALSE; | |
95 | |
96 ker_initTRCVS(rlp_data->ker.rcvsTab); | |
97 | |
98 rlp_data->ker.DM_State = IS_IDLE; | |
99 rlp_data->ker.DM_FBit = 0; | |
100 | |
101 rbm_reset(&rlp_data->rbm); | |
102 | |
103 INIT_STATE(KER, RLP_ADM_AND_DETACHED); | |
104 INIT_STATE(KERXID_C, ISW_IDLE); | |
105 } | |
106 | |
107 /* | |
108 +--------------------------------------------------------------------+ | |
109 | PROJECT : GSM-F&D (8411) MODULE : RLP_KERF | | |
110 | STATE : code ROUTINE : ker_get_xid_data | | |
111 +--------------------------------------------------------------------+ | |
112 | |
113 PURPOSE : | |
114 | |
115 */ | |
116 | |
117 GLOBAL void ker_get_xid_data | |
118 ( | |
119 T_RLP_FRAMEDATA *raw_data, | |
120 UBYTE index, | |
121 T_RLP_XID_IND *xid_data, | |
122 BOOL ms_is_initiator, | |
123 ULONG *used_flags | |
124 ) | |
125 { | |
126 UBYTE p_type; | |
127 UBYTE length; | |
128 UBYTE comp_request; | |
129 | |
130 #ifdef _SIMULATION_ | |
131 USHORT rcvd; | |
132 char trc_buf[80]; | |
133 UBYTE i, idx; | |
134 | |
135 strcpy (trc_buf, "get XID "); | |
136 idx = strlen(trc_buf); | |
137 #endif | |
138 | |
139 TRACE_FUNCTION ("ker_get_xid_data()"); | |
140 | |
141 rlp_data->ker.Rlp_Vers = DEF_RLP_VERS; | |
142 rlp_data->ker.K_ms_iwf = DEF_K_MS_IWF; | |
143 rlp_data->ker.K_iwf_ms = DEF_K_IWF_MS; | |
144 rlp_data->ker.T1 = rlp_data->ker.Def_T1; | |
145 rlp_data->ker.T2 = DEF_T2; | |
146 rlp_data->ker.N2 = DEF_N2; | |
147 rlp_data->ker.Pt = DEF_PT; | |
148 rlp_data->ker.P0 = DEF_P0; | |
149 rlp_data->ker.P1 = DEF_P1; | |
150 rlp_data->ker.P2 = DEF_P2; | |
151 | |
152 *used_flags = 0L; | |
153 | |
154 while (index < rlp_data->ker.FrameSize - HEADER_LEN - TRAILER_LEN) | |
155 { | |
156 length = raw_data[index] % 16; | |
157 p_type = (raw_data[index] - length) / 16; | |
158 | |
159 if (p_type EQ XID_T_NULL) | |
160 break; | |
161 | |
162 #ifdef _SIMULATION_ | |
163 for (i = 0; i < length+1; i++) | |
164 { | |
165 /*lint -e661 : Possible access of out-of-bounds pointer (1 beyond end of data) by operator 'unary * */ | |
166 HEX_BYTE (raw_data[index+i], &trc_buf[idx]); | |
167 /*lint +e661 */ | |
168 idx+=2; | |
169 } | |
170 #endif | |
171 | |
172 switch (p_type) | |
173 { | |
174 | |
175 case XID_T_T1: | |
176 rlp_data->ker.T1 = TIME_EXT2INT(raw_data[index+1]); | |
177 #ifdef _SIMULATION_ | |
178 rcvd = rlp_data->ker.T1; | |
179 #endif | |
180 if (rlp_data->ker.T1 < rlp_data->ker.Orig_T1) | |
181 rlp_data->ker.T1 = rlp_data->ker.Orig_T1; | |
182 *used_flags |= UF_SET_T1; | |
183 | |
184 #ifdef _SIMULATION_ | |
185 TRACE_EVENT_P2("RCVD XID T1 : %d -> %d", rcvd, rlp_data->ker.T1); | |
186 #endif | |
187 break; | |
188 | |
189 case XID_T_RLP_VERS: | |
190 rlp_data->ker.Rlp_Vers = raw_data[index+1]; | |
191 #ifdef _SIMULATION_ | |
192 rcvd = rlp_data->ker.Rlp_Vers; | |
193 #endif | |
194 if (rlp_data->ker.Rlp_Vers > ORIG_RLP_VERS) | |
195 rlp_data->ker.Rlp_Vers = ORIG_RLP_VERS; | |
196 | |
197 *used_flags |= UF_SET_RLP_VERS; | |
198 #ifdef _SIMULATION_ | |
199 TRACE_EVENT_P2("RCVD XID RLPV : %d -> %d", rcvd, rlp_data->ker.Rlp_Vers); | |
200 #endif | |
201 break; | |
202 | |
203 case XID_T_T2: | |
204 rlp_data->ker.T2 = TIME_EXT2INT(raw_data[index+1]); | |
205 #ifdef _SIMULATION_ | |
206 rcvd = rlp_data->ker.T2; | |
207 #endif | |
208 if (rlp_data->ker.T2 < rlp_data->ker.Orig_T2) | |
209 rlp_data->ker.T2 = rlp_data->ker.Orig_T2; | |
210 | |
211 *used_flags |= UF_SET_T2; | |
212 #ifdef _SIMULATION_ | |
213 TRACE_EVENT_P2("RCVD XID T2 : %d -> %d", rcvd, rlp_data->ker.T2); | |
214 #endif | |
215 break; | |
216 | |
217 case XID_T_K_MS_IWF: | |
218 rlp_data->ker.K_ms_iwf = raw_data[index+1]; | |
219 #ifdef _SIMULATION_ | |
220 rcvd = rlp_data->ker.K_ms_iwf; | |
221 #endif | |
222 if (rlp_data->ker.K_ms_iwf > rlp_data->ker.Orig_K_ms_iwf) | |
223 rlp_data->ker.K_ms_iwf = rlp_data->ker.Orig_K_ms_iwf; | |
224 | |
225 if (rlp_data->ker.Connected) | |
226 sbm_set_wind_size (rlp_data->ker.K_ms_iwf); | |
227 | |
228 *used_flags |= UF_SET_K_MS_IWF; | |
229 #ifdef _SIMULATION_ | |
230 TRACE_EVENT_P2("RCVD XID KMI : %d -> %d", rcvd, rlp_data->ker.K_ms_iwf); | |
231 #endif | |
232 break; | |
233 | |
234 case XID_T_N2: | |
235 rlp_data->ker.N2 = raw_data[index+1]; | |
236 #ifdef _SIMULATION_ | |
237 rcvd = rlp_data->ker.N2; | |
238 #endif | |
239 if (rlp_data->ker.N2 < rlp_data->ker.Orig_N2) | |
240 rlp_data->ker.N2 = rlp_data->ker.Orig_N2; | |
241 | |
242 sbm_set_retrans (rlp_data->ker.N2); | |
243 *used_flags |= UF_SET_N2; | |
244 #ifdef _SIMULATION_ | |
245 TRACE_EVENT_P2("RCVD XID N2 : %d -> %d", rcvd, rlp_data->ker.N2); | |
246 #endif | |
247 break; | |
248 | |
249 case XID_T_K_IWF_MS: | |
250 rlp_data->ker.K_iwf_ms = raw_data[index+1]; | |
251 #ifdef _SIMULATION_ | |
252 rcvd = rlp_data->ker.K_iwf_ms; | |
253 #endif | |
254 if (rlp_data->ker.K_iwf_ms > rlp_data->ker.Orig_K_iwf_ms) | |
255 rlp_data->ker.K_iwf_ms = rlp_data->ker.Orig_K_iwf_ms; | |
256 | |
257 if (rlp_data->ker.Connected) | |
258 if (rbm_set_wind_size (rlp_data->ker.K_iwf_ms)) | |
259 { | |
260 ker_reset_all_t_rcvs (); | |
261 srm_reset(); | |
262 } | |
263 | |
264 *used_flags |= UF_SET_K_IWF_MS; | |
265 #ifdef _SIMULATION_ | |
266 TRACE_EVENT_P2("RCVD XID KIM : %d -> %d", rcvd, rlp_data->ker.K_iwf_ms); | |
267 #endif | |
268 break; | |
269 | |
270 case XID_T_COMPR: | |
271 comp_request = raw_data[index+1] % 16; | |
272 rlp_data->ker.Pt = (raw_data[index+1] - comp_request) / 16; | |
273 #ifdef _SIMULATION_ | |
274 TRACE_EVENT_P1("RCVD XID PT : %d", rlp_data->ker.Pt); | |
275 #endif | |
276 | |
277 switch (comp_request) | |
278 { | |
279 case 0: | |
280 rlp_data->ker.P0 = RLP_COMP_DIR_NONE; | |
281 break; | |
282 | |
283 case 1: | |
284 if (ms_is_initiator) | |
285 { | |
286 if (rlp_data->ker.Orig_P0 EQ RLP_COMP_DIR_RECEIVE | |
287 OR rlp_data->ker.Orig_P0 EQ RLP_COMP_DIR_NONE) | |
288 rlp_data->ker.P0 = RLP_COMP_DIR_NONE; | |
289 else | |
290 rlp_data->ker.P0 = RLP_COMP_DIR_TRANSMIT; | |
291 } | |
292 else | |
293 { | |
294 if (rlp_data->ker.Orig_P0 EQ RLP_COMP_DIR_TRANSMIT | |
295 OR rlp_data->ker.Orig_P0 EQ RLP_COMP_DIR_NONE) | |
296 rlp_data->ker.P0 = RLP_COMP_DIR_NONE; | |
297 else | |
298 rlp_data->ker.P0 = RLP_COMP_DIR_RECEIVE; | |
299 } | |
300 break; | |
301 | |
302 case 2: | |
303 if (ms_is_initiator) | |
304 { | |
305 if (rlp_data->ker.Orig_P0 EQ RLP_COMP_DIR_TRANSMIT | |
306 OR rlp_data->ker.Orig_P0 EQ RLP_COMP_DIR_NONE) | |
307 rlp_data->ker.P0 = RLP_COMP_DIR_NONE; | |
308 else | |
309 rlp_data->ker.P0 = RLP_COMP_DIR_RECEIVE; | |
310 } | |
311 else | |
312 { | |
313 if (rlp_data->ker.Orig_P0 EQ RLP_COMP_DIR_RECEIVE | |
314 OR rlp_data->ker.Orig_P0 EQ RLP_COMP_DIR_NONE) | |
315 rlp_data->ker.P0 = RLP_COMP_DIR_NONE; | |
316 else | |
317 rlp_data->ker.P0 = RLP_COMP_DIR_TRANSMIT; | |
318 } | |
319 break; | |
320 | |
321 case 3: | |
322 rlp_data->ker.P0 = rlp_data->ker.Orig_P0; | |
323 break; | |
324 | |
325 } | |
326 | |
327 #ifdef _SIMULATION_ | |
328 TRACE_EVENT_P2("RCVD XID P0: %d -> %d", comp_request, rlp_data->ker.P0); | |
329 #endif | |
330 rlp_data->ker.P1 = (raw_data[index+3] * 256) + raw_data[index+2]; | |
331 #ifdef _SIMULATION_ | |
332 rcvd = rlp_data->ker.P1; | |
333 #endif | |
334 if (rlp_data->ker.P1 > rlp_data->ker.Orig_P1) | |
335 rlp_data->ker.P1 = rlp_data->ker.Orig_P1; | |
336 | |
337 #ifdef _SIMULATION_ | |
338 TRACE_EVENT_P2("RCVD XID P1: %d -> %d", rcvd, rlp_data->ker.P1); | |
339 #endif | |
340 | |
341 rlp_data->ker.P2 = raw_data[index+4]; | |
342 #ifdef _SIMULATION_ | |
343 rcvd = rlp_data->ker.P2; | |
344 #endif | |
345 if (rlp_data->ker.P2 > rlp_data->ker.Orig_P2) | |
346 rlp_data->ker.P2 = rlp_data->ker.Orig_P2; | |
347 | |
348 *used_flags |= UF_SET_COMPR; | |
349 #ifdef _SIMULATION_ | |
350 TRACE_EVENT_P2("RCVD XID P2 : %d -> %d", rcvd, rlp_data->ker.P2); | |
351 #endif | |
352 break; | |
353 } | |
354 index += (length+1); | |
355 } | |
356 | |
357 xid_data->rlp_vers = rlp_data->ker.Rlp_Vers; | |
358 xid_data->k_ms_iwf = rlp_data->ker.K_ms_iwf; | |
359 xid_data->k_iwf_ms = rlp_data->ker.K_iwf_ms; | |
360 | |
361 xid_data->t1 = TIME_INT2EXT (rlp_data->ker.T1); | |
362 xid_data->t2 = TIME_INT2EXT (rlp_data->ker.T2); | |
363 | |
364 xid_data->n2 = rlp_data->ker.N2; | |
365 xid_data->pt = rlp_data->ker.Pt; | |
366 xid_data->p0 = rlp_data->ker.P0; | |
367 xid_data->p1 = rlp_data->ker.P1; | |
368 xid_data->p2 = rlp_data->ker.P2; | |
369 | |
370 #ifdef _SIMULATION_ | |
371 trc_buf[idx] = '\0'; | |
372 TRACE_EVENT (trc_buf); | |
373 #endif | |
374 } | |
375 | |
376 /* | |
377 +--------------------------------------------------------------------+ | |
378 | PROJECT : GSM-F&D (8411) MODULE : RLP_KERF | | |
379 | STATE : code ROUTINE : ker_put_xid_data | | |
380 +--------------------------------------------------------------------+ | |
381 | |
382 PURPOSE : | |
383 | |
384 */ | |
385 | |
386 GLOBAL void ker_put_xid_data | |
387 ( | |
388 T_RLP_FRAMEPTR l_Data, /* buffer for data */ | |
389 UBYTE index, /* start index in buffer */ | |
390 ULONG l_uf, /* valid parameters */ | |
391 BOOL ms_is_initiator, /* MS is sending XID*/ | |
392 UBYTE l_rlp_version, /* negotiated vers. */ | |
393 T_FRAME_NUM l_k_iwf_ms, /* winSize ms->iwf */ | |
394 T_FRAME_NUM l_k_ms_iwf, /* winSize iwf->ms */ | |
395 USHORT l_t1, /* ack timer value */ | |
396 UBYTE l_n2, /* num restransmiss */ | |
397 USHORT l_t2, /* reply delay */ | |
398 UBYTE l_pt, /* type data compr. */ | |
399 UBYTE l_p0, /* v42bis comp. req */ | |
400 USHORT l_p1, /* num possible code*/ | |
401 UBYTE l_p2 /* max encod. strlen*/ | |
402 ) | |
403 { | |
404 register ULONG i; | |
405 | |
406 TRACE_FUNCTION ("ker_put_xid_data()"); | |
407 | |
408 i = index; | |
409 | |
410 if (((l_uf & UF_SET_RLP_VERS) EQ 0) OR (l_rlp_version < 1)) | |
411 { | |
412 l_uf &= ~UF_SET_COMPR; | |
413 } | |
414 | |
415 if (l_uf & UF_SET_RLP_VERS) | |
416 { | |
417 l_Data[i] = (XID_T_RLP_VERS * 16) + XID_L_RLP_VERS; | |
418 l_Data[i+1] = l_rlp_version; | |
419 #ifdef _SIMULATION_ | |
420 TRACE_EVENT_P1("SEND XID RLPV : %d", l_rlp_version); | |
421 #endif | |
422 i += (XID_L_RLP_VERS + 1); | |
423 } | |
424 | |
425 if (l_uf & UF_SET_K_IWF_MS) | |
426 { | |
427 l_Data[i] = (XID_T_K_IWF_MS * 16) + XID_L_K_IWF_MS; | |
428 l_Data[i+1] = (UBYTE) l_k_iwf_ms; | |
429 #ifdef _SIMULATION_ | |
430 TRACE_EVENT_P1("SEND XID KIM : %d", l_k_iwf_ms); | |
431 #endif | |
432 i += (XID_L_K_IWF_MS + 1); | |
433 } | |
434 | |
435 if (l_uf & UF_SET_K_MS_IWF) | |
436 { | |
437 l_Data[i] = (XID_T_K_MS_IWF * 16) + XID_L_K_MS_IWF; | |
438 l_Data[i+1] = (UBYTE) l_k_ms_iwf; | |
439 #ifdef _SIMULATION_ | |
440 TRACE_EVENT_P1("SEND XID KMI : %d", l_k_ms_iwf); | |
441 #endif | |
442 i += (XID_L_K_MS_IWF + 1); | |
443 } | |
444 | |
445 if (l_uf & UF_SET_T1) | |
446 { | |
447 l_Data[i] = (XID_T_T1 * 16) + XID_L_T1; | |
448 l_Data[i+1] = TIME_INT2EXT (l_t1); | |
449 #ifdef _SIMULATION_ | |
450 TRACE_EVENT_P1("SEND XID T1 : %d", l_t1); | |
451 #endif | |
452 i += (XID_L_T1 + 1); | |
453 } | |
454 | |
455 if (l_uf & UF_SET_N2) | |
456 { | |
457 l_Data[i] = (XID_T_N2 * 16) + XID_L_N2; | |
458 l_Data[i+1] = l_n2; | |
459 #ifdef _SIMULATION_ | |
460 TRACE_EVENT_P1("SEND XID N2 : %d", l_n2); | |
461 #endif | |
462 i += (XID_L_N2 + 1); | |
463 } | |
464 | |
465 if (l_uf & UF_SET_T2) | |
466 { | |
467 l_Data[i] = (XID_T_T2 * 16) + XID_L_T2; | |
468 l_Data[i+1] = TIME_INT2EXT (l_t2); | |
469 #ifdef _SIMULATION_ | |
470 TRACE_EVENT_P1("SEND XID T2 : %d", l_t2); | |
471 #endif | |
472 i += (XID_L_T2 + 1); | |
473 } | |
474 | |
475 if ( (l_uf & UF_SET_COMPR) AND !rlp_data->ker.Connected) | |
476 { | |
477 l_Data[i] = (XID_T_COMPR * 16) + XID_L_COMPR; | |
478 | |
479 switch (l_p0) | |
480 { | |
481 case RLP_COMP_DIR_NONE: | |
482 l_Data[i+1] = l_pt * 16; | |
483 break; | |
484 | |
485 case RLP_COMP_DIR_TRANSMIT: | |
486 if (ms_is_initiator) | |
487 l_Data[i+1] = (l_pt*16) + 1; | |
488 else | |
489 l_Data[i+1] = (l_pt*16) + 2; | |
490 break; | |
491 | |
492 case RLP_COMP_DIR_RECEIVE: | |
493 if (ms_is_initiator) | |
494 l_Data[i+1] = (l_pt*16) + 2; | |
495 else | |
496 l_Data[i+1] = (l_pt*16) + 1; | |
497 break; | |
498 | |
499 case RLP_COMP_DIR_BOTH: | |
500 l_Data[i+1] = (l_pt*16) + 3; | |
501 break; | |
502 } | |
503 l_Data[i+2] = (l_p1 % 256); | |
504 l_Data[i+3] = (l_p1 / 256); | |
505 l_Data[i+4] = l_p2; | |
506 #ifdef _SIMULATION_ | |
507 TRACE_EVENT_P1("SEND XID PT: %d", l_pt); | |
508 TRACE_EVENT_P2("SEND XID P0: %d -> %d", l_p0, l_Data[i+1] % 4); | |
509 TRACE_EVENT_P1("SEND XID P1: %d", l_p1); | |
510 TRACE_EVENT_P1("SEND XID P2: %d", l_p2); | |
511 #endif | |
512 i += (XID_L_COMPR + 1); | |
513 } | |
514 | |
515 #ifdef _SIMULATION_ | |
516 { | |
517 char trc_buf[80]; | |
518 U8 j, k; | |
519 | |
520 strcpy (trc_buf, "put XID "); | |
521 k = strlen(trc_buf); | |
522 for (j = index; j < i; j++) | |
523 { | |
524 /*lint -e661 : Possible access of out-of-bounds pointer (1 beyond end of data) by operator 'unary * */ | |
525 HEX_BYTE (l_Data[j], &trc_buf[k]); | |
526 /*lint +e661 */ | |
527 k += 2; | |
528 } | |
529 trc_buf[k] = '\0'; | |
530 TRACE_EVENT (trc_buf); | |
531 } | |
532 #endif | |
533 | |
534 } | |
535 | |
536 /* | |
537 +--------------------------------------------------------------------+ | |
538 | PROJECT : GSM-F&D (8411) MODULE : RLP_KERF | | |
539 | STATE : code ROUTINE : ker_check_low_water | | |
540 +--------------------------------------------------------------------+ | |
541 | |
542 PURPOSE : | |
543 | |
544 */ | |
545 | |
546 LOCAL void ker_check_low_water(void) | |
547 { | |
548 TRACE_FUNCTION ("ker_check_low_water()"); | |
549 | |
550 if (sbm_space_in_buf () >= rlp_data->ker.FramesPerPrim) | |
551 { | |
552 if (rlp_data->ker.UL_Snd_State EQ IW_IDLE) | |
553 { | |
554 PALLOC (rlp_ready_ind, RLP_READY_IND); | |
555 | |
556 PSENDX (L2R, rlp_ready_ind); | |
557 rlp_data->ker.UL_Snd_State = IW_WAIT; | |
558 } | |
559 } | |
560 } | |
561 | |
562 /* | |
563 +--------------------------------------------------------------------+ | |
564 | PROJECT : GSM-F&D (8411) MODULE : RLP_KERF | | |
565 | STATE : code ROUTINE : ker_get_send_frame | | |
566 +--------------------------------------------------------------------+ | |
567 | |
568 PURPOSE : | |
569 | |
570 */ | |
571 | |
572 LOCAL void ker_get_send_frame | |
573 ( | |
574 T_FRAME_DESC *frameDesc, | |
575 T_FRAME_NUM *frameNo, | |
576 BOOL *frameFound | |
577 ) | |
578 { | |
579 BOOL framesCouldBeSent; | |
580 | |
581 TRACE_FUNCTION ("ker_get_send_frame()"); | |
582 | |
583 if (rlp_data->ker.RRReady) | |
584 { | |
585 sbm_get_frame | |
586 ( | |
587 frameDesc, | |
588 frameNo, | |
589 &framesCouldBeSent, | |
590 frameFound | |
591 ); | |
592 | |
593 if (framesCouldBeSent) | |
594 ker_check_low_water (); | |
595 } | |
596 else | |
597 { | |
598 /* | |
599 * remote receiver can not accept data | |
600 */ | |
601 *frameFound = FALSE; | |
602 } | |
603 } | |
604 | |
605 /* | |
606 +--------------------------------------------------------------------+ | |
607 | PROJECT : GSM-F&D (8411) MODULE : RLP_KERF | | |
608 | STATE : code ROUTINE : ker_startTRCVS | | |
609 +--------------------------------------------------------------------+ | |
610 | |
611 PURPOSE : Start the timer TRCVS for a slot | |
612 | |
613 */ | |
614 | |
615 LOCAL void ker_startTRCVS(T_FRAME_NUM slot) | |
616 { | |
617 T_FRAME_NUM lookUp; | |
618 | |
619 TRACE_FUNCTION ("ker_startTRCVS()"); | |
620 | |
621 for (lookUp = 0; lookUp < MAX_SREJ_COUNT; lookUp++) | |
622 { | |
623 if (rlp_data->ker.rcvsTab[lookUp].isFree) | |
624 { | |
625 rlp_data->ker.rcvsTab[lookUp].slot = slot; | |
626 TIMERSTART(lookUp, rlp_data->ker.T1); | |
627 rlp_data->ker.rcvsTab[lookUp].trcvs_running = TRUE; | |
628 rlp_data->ker.rcvsTab[lookUp].isFree = FALSE; | |
629 return; | |
630 } | |
631 } | |
632 } | |
633 | |
634 /* | |
635 +--------------------------------------------------------------------+ | |
636 | PROJECT : GSM-F&D (8411) MODULE : RLP_KERF | | |
637 | STATE : code ROUTINE : ker_send_srej_sreji_cmd | | |
638 +--------------------------------------------------------------------+ | |
639 | |
640 PURPOSE : | |
641 | |
642 */ | |
643 | |
644 LOCAL void ker_send_srej_sreji_cmd(T_FRAME_NUM slot) | |
645 { | |
646 T_FRAME_DESC frameDesc; | |
647 T_FRAME_NUM frame; | |
648 BOOL frameFound; | |
649 | |
650 | |
651 rlp_data->ker.DTX_SF = DTX_N; | |
652 | |
653 TRACE_FUNCTION ("ker_send_srej_sreji_cmd()"); | |
654 | |
655 if (rlp_data->ker.Poll_xchg NEQ IW_WAIT | |
656 AND rlp_data->ker.Poll_State EQ ISW_SEND) | |
657 { | |
658 sig_ker_snd_srej_req (1, 1, slot); | |
659 rbm_set_rslot_wait (slot); | |
660 | |
661 ker_startTRCVS (slot); | |
662 | |
663 srm_count (slot); | |
664 | |
665 rlp_data->ker.SREJ_Count++; | |
666 rlp_data->ker.Poll_Count++; | |
667 rlp_data->ker.Poll_State = ISW_WAIT; | |
668 rlp_data->ker.Poll_xchg = IW_WAIT; | |
669 | |
670 TIMERSTART (TT_HANDLE, rlp_data->ker.T1); | |
671 } | |
672 else | |
673 { | |
674 ker_get_send_frame (&frameDesc, &frame, &frameFound); | |
675 | |
676 if (frameFound) | |
677 { | |
678 sig_ker_snd_srej_i_req (1, 0, slot, frame, &frameDesc); | |
679 | |
680 rbm_set_rslot_wait (slot); | |
681 | |
682 ker_startTRCVS (slot); | |
683 | |
684 srm_count (slot); | |
685 | |
686 rlp_data->ker.SREJ_Count++; | |
687 | |
688 TIMERSTART (TT_HANDLE, rlp_data->ker.T1); | |
689 } | |
690 else | |
691 { | |
692 sig_ker_snd_srej_req (1, 0, slot); | |
693 | |
694 rbm_set_rslot_wait (slot); | |
695 | |
696 ker_startTRCVS (slot); | |
697 | |
698 srm_count (slot); | |
699 | |
700 rlp_data->ker.SREJ_Count++; | |
701 } | |
702 } | |
703 } | |
704 | |
705 /* | |
706 +--------------------------------------------------------------------+ | |
707 | PROJECT : GSM-F&D (8411) MODULE : RLP_KERF | | |
708 | STATE : code ROUTINE : ker_send_rej_reji_cmd | | |
709 +--------------------------------------------------------------------+ | |
710 | |
711 PURPOSE : | |
712 | |
713 */ | |
714 | |
715 LOCAL void ker_send_rej_reji_cmd | |
716 ( | |
717 T_FRAME_NUM vr | |
718 ) | |
719 { | |
720 T_FRAME_DESC frameDesc; | |
721 T_FRAME_NUM frame; | |
722 BOOL frameFound; | |
723 | |
724 TRACE_FUNCTION ("ker_send_rej_reji_cmd()"); | |
725 | |
726 rlp_data->ker.DTX_SF = DTX_N; | |
727 | |
728 if (rlp_data->ker.Poll_xchg NEQ IW_WAIT AND rlp_data->ker.Poll_State EQ ISW_SEND) | |
729 { | |
730 sig_ker_snd_rej_req (1, 1, vr); | |
731 | |
732 rlp_data->ker.Ackn_State = IS_IDLE; | |
733 rlp_data->ker.REJ_State = ISW_WAIT; | |
734 | |
735 TIMERSTART | |
736 ( | |
737 TRCVR_HANDLE, | |
738 rlp_data->ker.T1 | |
739 ); | |
740 rlp_data->ker.Poll_Count++; | |
741 rlp_data->ker.Poll_State = ISW_WAIT; | |
742 rlp_data->ker.Poll_xchg = IW_WAIT; | |
743 | |
744 TIMERSTART (TT_HANDLE, rlp_data->ker.T1); | |
745 } | |
746 else | |
747 { | |
748 ker_get_send_frame (&frameDesc, &frame, &frameFound); | |
749 | |
750 if (frameFound) | |
751 { | |
752 sig_ker_snd_rej_i_req (1, 0, vr, frame, &frameDesc); | |
753 | |
754 TIMERSTART (TT_HANDLE, rlp_data->ker.T1); | |
755 } | |
756 else | |
757 sig_ker_snd_rej_req (1, 0, vr); | |
758 | |
759 TIMERSTART(TRCVR_HANDLE, rlp_data->ker.T1); | |
760 rlp_data->ker.Ackn_State = IS_IDLE; | |
761 rlp_data->ker.REJ_State = ISW_WAIT; | |
762 } | |
763 } | |
764 | |
765 /* | |
766 +--------------------------------------------------------------------+ | |
767 | PROJECT : GSM-F&D (8411) MODULE : RLP_KERF | | |
768 | STATE : code ROUTINE : ker_send_rnr_rnri_cmd | | |
769 +--------------------------------------------------------------------+ | |
770 | |
771 PURPOSE : | |
772 | |
773 */ | |
774 | |
775 LOCAL void ker_send_rnr_rnri_cmd | |
776 ( | |
777 T_FRAME_NUM vr | |
778 ) | |
779 { | |
780 T_FRAME_DESC frameDesc; | |
781 T_FRAME_NUM frame; | |
782 BOOL frameFound; | |
783 | |
784 TRACE_FUNCTION ("ker_send_rnr_rnri_cmd()"); | |
785 | |
786 if (rlp_data->ker.Poll_xchg NEQ IW_WAIT | |
787 AND rlp_data->ker.Poll_State EQ ISW_SEND) | |
788 { | |
789 sig_ker_snd_rnr_req (1, 1, vr, 0); | |
790 | |
791 rlp_data->ker.Ackn_State = IS_IDLE; | |
792 rlp_data->ker.Poll_Count++; | |
793 rlp_data->ker.Poll_State = ISW_WAIT; | |
794 rlp_data->ker.Poll_xchg = IW_WAIT; | |
795 | |
796 rlp_data->ker.DTX_SF = DTX_N; | |
797 | |
798 TIMERSTART (TT_HANDLE, rlp_data->ker.T1); | |
799 } | |
800 else | |
801 { | |
802 ker_get_send_frame (&frameDesc, &frame, &frameFound); | |
803 | |
804 if (frameFound) | |
805 { | |
806 sig_ker_snd_rnr_i_req (1, 0, vr, frame, &frameDesc); | |
807 | |
808 rlp_data->ker.Ackn_State = IS_IDLE; | |
809 | |
810 rlp_data->ker.DTX_SF = DTX_N; | |
811 | |
812 TIMERSTART (TT_HANDLE, rlp_data->ker.T1); | |
813 } | |
814 else | |
815 { | |
816 if (rlp_data->ker.Ackn_State EQ IS_IDLE | |
817 AND rlp_data->ker.DTX_SF EQ DTX_RNR | |
818 AND rlp_data->ker.DTX_VR EQ vr) | |
819 { | |
820 sig_ker_snd_rnr_req (1, 0, vr, 1); | |
821 } | |
822 else | |
823 { | |
824 sig_ker_snd_rnr_req (1, 0, vr, 0); | |
825 | |
826 rlp_data->ker.Ackn_State = IS_IDLE; | |
827 rlp_data->ker.DTX_SF = DTX_RNR; | |
828 rlp_data->ker.DTX_VR = vr; | |
829 } | |
830 } | |
831 } | |
832 } | |
833 | |
834 /* | |
835 +--------------------------------------------------------------------+ | |
836 | PROJECT : GSM-F&D (8411) MODULE : RLP_KERF | | |
837 | STATE : code ROUTINE : ker_send_rr_rri_cmd | | |
838 +--------------------------------------------------------------------+ | |
839 | |
840 PURPOSE : | |
841 | |
842 */ | |
843 | |
844 LOCAL void ker_send_rr_rri_cmd | |
845 ( | |
846 T_FRAME_NUM vr | |
847 ) | |
848 { | |
849 T_FRAME_DESC frameDesc; | |
850 T_FRAME_NUM frame; | |
851 BOOL frameFound; | |
852 | |
853 TRACE_FUNCTION ("ker_send_rr_rri_cmd()"); | |
854 | |
855 if (rlp_data->ker.Poll_xchg NEQ IW_WAIT AND rlp_data->ker.Poll_State EQ ISW_SEND) | |
856 { | |
857 | |
858 #ifdef ENABLE_DTX | |
859 sig_ker_snd_rr_req (1, 1, vr, 0); | |
860 #else | |
861 sig_ker_snd_rr_req (1, 1, vr); | |
862 #endif | |
863 | |
864 rlp_data->ker.Ackn_State = IS_IDLE; | |
865 rlp_data->ker.Poll_Count++; | |
866 rlp_data->ker.Poll_State = ISW_WAIT; | |
867 rlp_data->ker.Poll_xchg = IW_WAIT; | |
868 | |
869 rlp_data->ker.DTX_SF = DTX_N; | |
870 | |
871 TIMERSTART (TT_HANDLE, rlp_data->ker.T1); | |
872 } | |
873 else | |
874 { | |
875 ker_get_send_frame (&frameDesc, &frame, &frameFound); | |
876 | |
877 if (frameFound) | |
878 { | |
879 sig_ker_snd_rr_i_req (1, 0, vr, frame, &frameDesc); | |
880 | |
881 rlp_data->ker.Ackn_State = IS_IDLE; | |
882 | |
883 TIMERSTART (TT_HANDLE, rlp_data->ker.T1); | |
884 rlp_data->ker.DTX_SF = DTX_N; | |
885 | |
886 } | |
887 else | |
888 { | |
889 if (rlp_data->ker.Ackn_State EQ IS_IDLE | |
890 AND rlp_data->ker.DTX_SF EQ DTX_RR | |
891 AND rlp_data->ker.DTX_VR EQ vr) | |
892 { | |
893 #ifdef ENABLE_DTX | |
894 sig_ker_snd_rr_req (1, 0, vr, 1); | |
895 #else | |
896 sig_ker_snd_rr_req (1, 0, vr); | |
897 #endif | |
898 } | |
899 else | |
900 { | |
901 #ifdef ENABLE_DTX | |
902 sig_ker_snd_rr_req (1, 0, vr, 0); | |
903 #else | |
904 sig_ker_snd_rr_req (1, 0, vr); | |
905 #endif | |
906 rlp_data->ker.Ackn_State = IS_IDLE; | |
907 rlp_data->ker.DTX_SF = DTX_RR; | |
908 rlp_data->ker.DTX_VR = vr; | |
909 } | |
910 } | |
911 } | |
912 } | |
913 | |
914 /* | |
915 +--------------------------------------------------------------------+ | |
916 | PROJECT : GSM-F&D (8411) MODULE : RLP_KERF | | |
917 | STATE : code ROUTINE : ker_send_rnr_rnri_resp | | |
918 +--------------------------------------------------------------------+ | |
919 | |
920 PURPOSE : | |
921 | |
922 */ | |
923 | |
924 LOCAL void ker_send_rnr_rnri_resp | |
925 ( | |
926 T_FRAME_NUM vr | |
927 ) | |
928 { | |
929 | |
930 TRACE_FUNCTION ("ker_send_rnr_rnri_resp()"); | |
931 | |
932 sig_ker_snd_rnr_req (0, 1, vr, 0); | |
933 | |
934 rlp_data->ker.Ackn_State = IS_IDLE; | |
935 rlp_data->ker.Ackn_FBit = 0; | |
936 rlp_data->ker.DTX_SF = DTX_N; | |
937 } | |
938 | |
939 /* | |
940 +--------------------------------------------------------------------+ | |
941 | PROJECT : GSM-F&D (8411) MODULE : RLP_KERF | | |
942 | STATE : code ROUTINE : ker_send_rr_rri_resp | | |
943 +--------------------------------------------------------------------+ | |
944 | |
945 PURPOSE : | |
946 | |
947 */ | |
948 | |
949 LOCAL void ker_send_rr_rri_resp(T_FRAME_NUM vr) | |
950 { | |
951 | |
952 TRACE_FUNCTION ("ker_send_rr_rri_resp()"); | |
953 | |
954 #ifdef ENABLE_DTX | |
955 sig_ker_snd_rr_req (0, 1, vr, 0); | |
956 #else | |
957 sig_ker_snd_rr_req (0, 1, vr); | |
958 #endif | |
959 | |
960 rlp_data->ker.Ackn_State = IS_IDLE; | |
961 rlp_data->ker.Ackn_FBit = 0; | |
962 rlp_data->ker.DTX_SF = DTX_N; | |
963 | |
964 } | |
965 | |
966 /* | |
967 +--------------------------------------------------------------------+ | |
968 | PROJECT : GSM-F&D (8411) MODULE : RLP_KERF | | |
969 | STATE : code ROUTINE : ker_copy_frame_to_sdu | | |
970 +--------------------------------------------------------------------+ | |
971 | |
972 PURPOSE : | |
973 | |
974 */ | |
975 | |
976 GLOBAL void ker_copy_frame_to_sdu | |
977 ( | |
978 T_RLP_FRAMEPTR frame, | |
979 T_sdu *sdu | |
980 ) | |
981 { | |
982 TRACE_FUNCTION ("ker_copy_frame_to_sdu()"); | |
983 | |
984 memcpy (sdu->buf+(sdu->o_buf>>3), frame, rlp_data->ker.FrameSize); | |
985 } | |
986 | |
987 /* | |
988 +--------------------------------------------------------------------+ | |
989 | PROJECT : GSM-F&D (8411) MODULE : RLP_KERF | | |
990 | STATE : code ROUTINE : ker_copy_sdu_to_frame | | |
991 +--------------------------------------------------------------------+ | |
992 | |
993 PURPOSE : | |
994 | |
995 */ | |
996 | |
997 GLOBAL void ker_copy_sdu_to_frame(T_sdu *sdu, T_RLP_FRAMEPTR frame, USHORT n) | |
998 { | |
999 TRACE_FUNCTION ("ker_copy_sdu_to_frame()"); | |
1000 | |
1001 memcpy(frame, sdu->buf + (sdu->o_buf>>3) + (n * rlp_data->ker.FrameSize), | |
1002 rlp_data->ker.FrameSize); | |
1003 } | |
1004 | |
1005 /* | |
1006 +--------------------------------------------------------------------+ | |
1007 | PROJECT : GSM-F&D (8411) MODULE : RLP_KERF | | |
1008 | STATE : code ROUTINE : ker_get_frame_desc | | |
1009 +--------------------------------------------------------------------+ | |
1010 | |
1011 PURPOSE : | |
1012 | |
1013 */ | |
1014 | |
1015 GLOBAL void ker_get_frame_desc | |
1016 ( | |
1017 T_RLP_FRAMEPTR frame, | |
1018 T_FRAME_DESC *frameDesc | |
1019 ) | |
1020 { | |
1021 TRACE_FUNCTION ("ker_get_frame_desc()"); | |
1022 | |
1023 frameDesc->Adr[0] = frame; | |
1024 frameDesc->Len[0] = rlp_data->ker.FrameSize; | |
1025 frameDesc->Adr[1] = (UBYTE *) NULL; | |
1026 frameDesc->Len[1] = 0; | |
1027 } | |
1028 | |
1029 /* | |
1030 +--------------------------------------------------------------------+ | |
1031 | PROJECT : GSM-F&D (8411) MODULE : RLP_KERF | | |
1032 | STATE : code ROUTINE : ker_handle_prim_send | | |
1033 +--------------------------------------------------------------------+ | |
1034 | |
1035 PURPOSE : | |
1036 | |
1037 */ | |
1038 | |
1039 LOCAL void ker_handle_prim_send(void) | |
1040 { | |
1041 TRACE_FUNCTION ("ker_handle_prim_send()"); | |
1042 | |
1043 if (rlp_data->ker.UL_Rcv_State EQ IW_WAIT) | |
1044 { | |
1045 T_RLP_DATA_IND *rlp_data_ind; | |
1046 | |
1047 rbm_get_prim(&rlp_data_ind, &rlp_data->ker.LRReady, &rlp_data->ker.LRFull); | |
1048 | |
1049 PSENDX (L2R, rlp_data_ind); | |
1050 rlp_data->ker.UL_Rcv_State = IW_IDLE; | |
1051 TIMERSTOP (TUL_RCV_HANDLE); | |
1052 rlp_data->tul_rcv_running = FALSE; | |
1053 } | |
1054 } | |
1055 | |
1056 /* | |
1057 +--------------------------------------------------------------------+ | |
1058 | PROJECT : GSM-F&D (8411) MODULE : RLP_KERF | | |
1059 | STATE : code ROUTINE : ker_stopTRCVS | | |
1060 +--------------------------------------------------------------------+ | |
1061 | |
1062 PURPOSE : search the rcvs entry for a given timer handle. The | |
1063 function stops the timer and returns the corresponding | |
1064 slot. | |
1065 | |
1066 */ | |
1067 | |
1068 LOCAL void ker_stopTRCVS | |
1069 ( | |
1070 T_FRAME_NUM slot | |
1071 ) | |
1072 { | |
1073 T_FRAME_NUM lookUp; | |
1074 | |
1075 TRACE_FUNCTION ("ker_stopTRCVS()"); | |
1076 | |
1077 for (lookUp = 0; lookUp < MAX_SREJ_COUNT; lookUp++) | |
1078 { | |
1079 if (!rlp_data->ker.rcvsTab[lookUp].isFree AND rlp_data->ker.rcvsTab[lookUp].slot EQ slot) | |
1080 { | |
1081 TIMERSTOP(lookUp); | |
1082 rlp_data->ker.rcvsTab[lookUp].trcvs_running = FALSE; | |
1083 rlp_data->ker.rcvsTab[lookUp].isFree = TRUE; | |
1084 return; | |
1085 } | |
1086 } | |
1087 } | |
1088 | |
1089 /* | |
1090 +--------------------------------------------------------------------+ | |
1091 | PROJECT : GSM-F&D (8411) MODULE : RLP_KERF | | |
1092 | STATE : code ROUTINE : ker_i_handler | | |
1093 +--------------------------------------------------------------------+ | |
1094 | |
1095 PURPOSE : | |
1096 | |
1097 */ | |
1098 | |
1099 GLOBAL BOOL ker_i_handler(T_FRAME_NUM ns) | |
1100 { | |
1101 TRACE_FUNCTION ("ker_i_handler()"); | |
1102 | |
1103 if (rlp_data->ker.LRFull) | |
1104 { | |
1105 /* | |
1106 * ignore improper frame | |
1107 * cBit and fBit are not considered | |
1108 * at this stage | |
1109 */ | |
1110 return TRUE; | |
1111 } | |
1112 else | |
1113 { | |
1114 BOOL valid, expected, resetTimer, primToSend; | |
1115 T_FRAME_NUM count; | |
1116 | |
1117 rbm_ns_check (ns, &valid, &expected); | |
1118 | |
1119 /* | |
1120 * ns not within window? | |
1121 */ | |
1122 if (!valid) | |
1123 { | |
1124 /* | |
1125 * ignore improper frame | |
1126 */ | |
1127 return TRUE; | |
1128 } | |
1129 | |
1130 TIMERSTOP (TUL_RCV_HANDLE); /* optimisation trial... */ | |
1131 /* | |
1132 TRACE_EVENT("TIMERSTART TUL_RCV ker_i_handler"); | |
1133 */ | |
1134 TIMERSTART(TUL_RCV_HANDLE, rlp_data->ker.T_ul); | |
1135 | |
1136 if (expected) | |
1137 { | |
1138 rbm_accept_current_frame (); | |
1139 rbm_set_rslot_rcvd (ns, &resetTimer); | |
1140 | |
1141 if (resetTimer) | |
1142 { | |
1143 ker_stopTRCVS (ns); | |
1144 rlp_data->ker.SREJ_Count--; | |
1145 srm_clear (ns); | |
1146 } | |
1147 | |
1148 rbm_buffer_all_in_sequence_frames | |
1149 ( | |
1150 ns, | |
1151 &primToSend, | |
1152 &rlp_data->ker.LRReady, | |
1153 &rlp_data->ker.LRFull | |
1154 ); | |
1155 | |
1156 if (primToSend) | |
1157 ker_handle_prim_send (); | |
1158 | |
1159 rlp_data->ker.REJ_State = ISW_IDLE; | |
1160 TIMERSTOP (TRCVR_HANDLE); | |
1161 rlp_data->ker.Ackn_State = IS_SEND; | |
1162 return FALSE; | |
1163 } | |
1164 else | |
1165 { | |
1166 if (rlp_data->ker.REJ_State NEQ ISW_IDLE) | |
1167 return TRUE; | |
1168 /* | |
1169 * ignore out of sequence frames | |
1170 */ | |
1171 | |
1172 rbm_count_missing_i_frames (ns, &count); | |
1173 | |
1174 if (rlp_data->ker.SREJ_Count + (count-1) <=MAX_SREJ_COUNT) | |
1175 { | |
1176 rbm_move_current_frame (ns); | |
1177 rbm_set_rslot_rcvd (ns, &resetTimer); | |
1178 | |
1179 if (resetTimer) | |
1180 { | |
1181 ker_stopTRCVS (ns); | |
1182 rlp_data->ker.SREJ_Count--; | |
1183 srm_clear (ns); | |
1184 } | |
1185 | |
1186 rbm_mark_missing_i_frames_srej (ns); | |
1187 | |
1188 return FALSE; | |
1189 } | |
1190 else | |
1191 { | |
1192 rlp_data->ker.REJ_State = ISW_SEND; | |
1193 return FALSE; | |
1194 } | |
1195 } | |
1196 } | |
1197 } | |
1198 | |
1199 /* | |
1200 +--------------------------------------------------------------------+ | |
1201 | PROJECT : GSM-F&D (8411) MODULE : RLP_KERF | | |
1202 | STATE : code ROUTINE : ker_init_link_vars | | |
1203 +--------------------------------------------------------------------+ | |
1204 | |
1205 PURPOSE : | |
1206 | |
1207 */ | |
1208 | |
1209 GLOBAL void ker_init_link_vars | |
1210 ( | |
1211 void | |
1212 ) | |
1213 { | |
1214 TRACE_FUNCTION ("ker_init_link_vars()"); | |
1215 | |
1216 rlp_data->ker.UL_Rcv_State = IW_IDLE; | |
1217 rlp_data->ker.UL_Snd_State = IW_IDLE; | |
1218 rlp_data->ker.Ackn_State = IS_IDLE; | |
1219 rlp_data->ker.Poll_State = ISW_IDLE; | |
1220 rlp_data->ker.Poll_Count = 0; | |
1221 rlp_data->ker.Poll_xchg = IW_IDLE; | |
1222 rlp_data->ker.REJ_State = ISW_IDLE; | |
1223 rlp_data->ker.SABM_State = ISW_IDLE; | |
1224 rlp_data->ker.DISC_State = ISW_IDLE; | |
1225 rlp_data->ker.RRReady = TRUE; | |
1226 rlp_data->ker.LRReady = TRUE; | |
1227 rlp_data->ker.LRFull = FALSE; | |
1228 rlp_data->ker.SREJ_Count = 0; | |
1229 rlp_data->ker.Connected = TRUE; | |
1230 rlp_data->ker.DTX_SF = DTX_N; | |
1231 | |
1232 sbm_init | |
1233 ( | |
1234 rlp_data->ker.K_ms_iwf, | |
1235 rlp_data->ker.FrameSize, | |
1236 rlp_data->ker.N2 | |
1237 ); | |
1238 | |
1239 rbm_init | |
1240 ( | |
1241 rlp_data->ker.K_iwf_ms, | |
1242 rlp_data->ker.FrameSize, | |
1243 rlp_data->ker.FramesPerPrim | |
1244 ); | |
1245 | |
1246 srm_init (); | |
1247 | |
1248 } | |
1249 | |
1250 /* | |
1251 +--------------------------------------------------------------------+ | |
1252 | PROJECT : GSM-F&D (8411) MODULE : RLP_KERF | | |
1253 | STATE : code ROUTINE : ker_requestxid | | |
1254 +--------------------------------------------------------------------+ | |
1255 | |
1256 PURPOSE : This function is invoked to request an XID command. | |
1257 Some variables are set, so that with next RA_READY_IND | |
1258 a XID command is sent. | |
1259 | |
1260 */ | |
1261 | |
1262 LOCAL void ker_requestxid(void) | |
1263 { | |
1264 TRACE_FUNCTION ("ker_requestxid()"); | |
1265 | |
1266 SET_STATE(KERXID_C, ISW_SEND); | |
1267 rlp_data->ker.XID_Count = 0; | |
1268 rlp_data->ker.XID_C_PBit = 1; | |
1269 | |
1270 ker_put_xid_data | |
1271 ( | |
1272 rlp_data->ker.XID_C_Frame + HEADER_LEN, | |
1273 0, | |
1274 UF_ALL, | |
1275 TRUE, | |
1276 ORIG_RLP_VERS, | |
1277 rlp_data->ker.Orig_K_iwf_ms, | |
1278 rlp_data->ker.Orig_K_ms_iwf, | |
1279 rlp_data->ker.Orig_T1, | |
1280 rlp_data->ker.Orig_N2, | |
1281 rlp_data->ker.Orig_T2, | |
1282 rlp_data->ker.Orig_Pt, | |
1283 rlp_data->ker.Orig_P0, | |
1284 rlp_data->ker.Orig_P1, | |
1285 rlp_data->ker.Orig_P2 | |
1286 ); | |
1287 } | |
1288 | |
1289 /* | |
1290 +--------------------------------------------------------------------+ | |
1291 | PROJECT : GSM-F&D (8411) MODULE : RLP_KERP | | |
1292 | STATE : code ROUTINE : ker_init_xid_data | | |
1293 +--------------------------------------------------------------------+ | |
1294 | |
1295 PURPOSE : initialize XID data from attach request | |
1296 | |
1297 */ | |
1298 | |
1299 GLOBAL void ker_init_xid_data | |
1300 ( | |
1301 T_RLP_ATTACH_REQ *rlp_attach_req | |
1302 ) | |
1303 { | |
1304 TRACE_FUNCTION ("ker_init_xid_data()"); | |
1305 | |
1306 rlp_data->ker.Orig_K_ms_iwf = (U8)rlp_attach_req->k_ms_iwf; | |
1307 rlp_data->ker.K_ms_iwf = DEF_K_MS_IWF; | |
1308 | |
1309 rlp_data->ker.Orig_K_iwf_ms = (U8)rlp_attach_req->k_iwf_ms; | |
1310 rlp_data->ker.K_iwf_ms = DEF_K_IWF_MS; | |
1311 | |
1312 rlp_data->ker.Orig_T1 = TIME_EXT2INT (rlp_attach_req->t1); | |
1313 rlp_data->ker.T1 = rlp_data->ker.Def_T1; | |
1314 | |
1315 /* | |
1316 * >>>> According to GSM 11.10 V4.17.1 and V5.4.0 the default value must be used. | |
1317 * >>>> Later versions specify, that the value is used, which MS wants to negotiate. | |
1318 */ | |
1319 /* use t1 immediately without negotiation, if it is greater than the default */ | |
1320 /* | |
1321 if (rlp_data->ker.Orig_T1 > rlp_data->ker.T1) | |
1322 { | |
1323 rlp_data->ker.T1 = rlp_data->ker.Orig_T1; | |
1324 } | |
1325 */ | |
1326 /* | |
1327 rlp_data->ker.Orig_T2 = TIME_EXT2INT (rlp_attach_req->t2); | |
1328 */ | |
1329 rlp_data->ker.Orig_T2 = 200; | |
1330 rlp_data->ker.T2 = DEF_T2; | |
1331 | |
1332 rlp_data->ker.Orig_N2 = rlp_attach_req->n2; | |
1333 rlp_data->ker.N2 = DEF_N2; | |
1334 | |
1335 rlp_data->ker.Orig_Pt = rlp_attach_req->pt; | |
1336 rlp_data->ker.Pt = DEF_PT; | |
1337 | |
1338 rlp_data->ker.Orig_P0 = rlp_attach_req->p0; | |
1339 rlp_data->ker.P0 = DEF_P0; | |
1340 | |
1341 rlp_data->ker.Orig_P1 = rlp_attach_req->p1; | |
1342 rlp_data->ker.P1 = DEF_P1; | |
1343 | |
1344 rlp_data->ker.Orig_P2 = rlp_attach_req->p2; | |
1345 rlp_data->ker.P2 = DEF_P2; | |
1346 | |
1347 rlp_data->ker.Rlp_Vers = ORIG_RLP_VERS; | |
1348 | |
1349 | |
1350 if( !(rlp_data->ker.Orig_P0 EQ RLP_COMP_DIR_NONE AND | |
1351 rlp_data->ker.Orig_K_ms_iwf EQ DEF_K_MS_IWF AND | |
1352 rlp_data->ker.Orig_K_iwf_ms EQ DEF_K_IWF_MS AND | |
1353 rlp_data->ker.Orig_T1 EQ rlp_data->ker.Def_T1 AND | |
1354 /* | |
1355 rlp_data->ker.Orig_T2 EQ DEF_T2 AND | |
1356 */ | |
1357 rlp_data->ker.Orig_N2 EQ DEF_N2 AND | |
1358 rlp_data->ker.Orig_Pt EQ DEF_PT AND | |
1359 rlp_data->ker.Orig_P0 EQ DEF_P0 AND | |
1360 rlp_data->ker.Orig_P1 EQ DEF_P1 AND | |
1361 rlp_data->ker.Orig_P2 EQ DEF_P2 )) | |
1362 { | |
1363 ker_requestxid (); | |
1364 } | |
1365 else | |
1366 { | |
1367 PALLOC (rlp_xid_ind, RLP_XID_IND); | |
1368 | |
1369 rlp_xid_ind->rlp_vers = rlp_data->ker.Rlp_Vers; | |
1370 rlp_xid_ind->k_ms_iwf = rlp_data->ker.K_ms_iwf; | |
1371 rlp_xid_ind->k_iwf_ms = rlp_data->ker.K_iwf_ms; | |
1372 rlp_xid_ind->t1 = TIME_INT2EXT (rlp_data->ker.T1); | |
1373 rlp_xid_ind->t2 = TIME_INT2EXT (rlp_data->ker.T2); | |
1374 rlp_xid_ind->n2 = rlp_data->ker.N2; | |
1375 rlp_xid_ind->pt = rlp_data->ker.Pt; | |
1376 rlp_xid_ind->p0 = rlp_data->ker.P0; | |
1377 rlp_xid_ind->p1 = rlp_data->ker.P1; | |
1378 rlp_xid_ind->p2 = rlp_data->ker.P2; | |
1379 | |
1380 PSENDX (L2R, rlp_xid_ind); | |
1381 } | |
1382 | |
1383 } | |
1384 | |
1385 /* | |
1386 +--------------------------------------------------------------------+ | |
1387 | PROJECT : GSM-F&D (8411) MODULE : RLP_KERF | | |
1388 | STATE : code ROUTINE : ker_trace_rlp_frame | | |
1389 +--------------------------------------------------------------------+ | |
1390 | |
1391 PURPOSE : traces the elements from the given RLP frame | |
1392 | |
1393 */ | |
1394 | |
1395 #ifdef TRACE_RLP_FRAME | |
1396 | |
1397 GLOBAL void ker_trace_rlp_frame | |
1398 ( | |
1399 T_RLP_FRAMEPTR frame | |
1400 ) | |
1401 { | |
1402 T_BIT cBit; | |
1403 T_BIT pFBit; | |
1404 T_FRAME_NUM nr; | |
1405 T_FRAME_NUM ns; | |
1406 | |
1407 T_RLP_DEBUG *deb = &rlp_data->deb; | |
1408 | |
1409 TRACE_FUNCTION ("ker_trace_rlp_frame()"); | |
1410 | |
1411 cBit = (T_BIT) (frame[0] & 1); | |
1412 ns = (T_FRAME_NUM) ((frame[0] >> 3) | ((frame[1] & 1)<<5)); | |
1413 pFBit = (T_BIT) ((frame[1] & 2)>>1); | |
1414 | |
1415 | |
1416 deb->idx=0; | |
1417 | |
1418 deb->trc_buf[deb->idx++] = 'U'; | |
1419 deb->trc_buf[deb->idx++] = ':'; | |
1420 | |
1421 switch (ns) | |
1422 { | |
1423 case 62: /* S-Frame */ | |
1424 { | |
1425 T_SF sFrame; | |
1426 | |
1427 nr = (T_FRAME_NUM) ((frame[1]>>2) & 0x3f); | |
1428 | |
1429 deb->trc_buf[deb->idx++] = 'S'; | |
1430 deb->trc_buf[deb->idx++] = 'r'; | |
1431 DEC_BYTE (nr, &deb->trc_buf[deb->idx]); deb->idx+=3; | |
1432 deb->trc_buf[deb->idx++] = ' '; | |
1433 | |
1434 sFrame = (T_SF) ((frame[0]>>1) & 0x03); | |
1435 | |
1436 /* | |
1437 * maybe optimize with a table!! | |
1438 */ | |
1439 switch (sFrame) | |
1440 { | |
1441 case SF_RR: | |
1442 memcpy(&deb->trc_buf[deb->idx], "RR ",3); | |
1443 break; | |
1444 | |
1445 case SF_RNR: | |
1446 memcpy(&deb->trc_buf[deb->idx], "RNR",3); | |
1447 break; | |
1448 case SF_REJ: | |
1449 memcpy(&deb->trc_buf[deb->idx], "REJ",3); | |
1450 break; | |
1451 case SF_SREJ: | |
1452 memcpy(&deb->trc_buf[deb->idx], "SRJ",3); | |
1453 break; | |
1454 default: | |
1455 memcpy(&deb->trc_buf[deb->idx], "***",3); | |
1456 break; | |
1457 | |
1458 } | |
1459 deb->idx+=3; | |
1460 break; | |
1461 } | |
1462 | |
1463 case 63: /* U-Frame */ | |
1464 { | |
1465 T_UF uFrame; | |
1466 uFrame = (T_UF) ((frame[1]>>2) & 0x1f); | |
1467 | |
1468 deb->trc_buf[deb->idx++] = 'U'; | |
1469 deb->trc_buf[deb->idx++] = ' '; | |
1470 | |
1471 /* | |
1472 * maybe optimize with a table!! | |
1473 */ | |
1474 switch (uFrame) | |
1475 { | |
1476 case UF_NULL: | |
1477 return; | |
1478 | |
1479 case UF_UI: | |
1480 memcpy(&deb->trc_buf[deb->idx], "UI ",4); | |
1481 break; | |
1482 | |
1483 case UF_DM: | |
1484 memcpy(&deb->trc_buf[deb->idx], "DM ",4); | |
1485 break; | |
1486 | |
1487 case UF_SABM: | |
1488 memcpy(&deb->trc_buf[deb->idx], "SABM",4); | |
1489 break; | |
1490 | |
1491 case UF_DISC: | |
1492 memcpy(&deb->trc_buf[deb->idx], "DISC",4); | |
1493 break; | |
1494 | |
1495 case UF_UA: | |
1496 memcpy(&deb->trc_buf[deb->idx], "UA ",4); | |
1497 break; | |
1498 | |
1499 case UF_XID: | |
1500 memcpy(&deb->trc_buf[deb->idx], "XID ",4); | |
1501 break; | |
1502 | |
1503 case UF_TEST: | |
1504 memcpy(&deb->trc_buf[deb->idx], "TEST",4); | |
1505 break; | |
1506 | |
1507 case UF_REMAP: | |
1508 memcpy(&deb->trc_buf[deb->idx], "RMAP",4); | |
1509 break; | |
1510 | |
1511 default: | |
1512 memcpy(&deb->trc_buf[deb->idx], "****",4); | |
1513 break; | |
1514 } | |
1515 nr = 0; | |
1516 deb->idx += 4; | |
1517 break; | |
1518 } | |
1519 | |
1520 default: /* I+S-Frame */ | |
1521 { | |
1522 T_SF sFrame; | |
1523 | |
1524 nr = (T_FRAME_NUM) ((frame[1]>>2) & 0x3f); | |
1525 | |
1526 sFrame = (T_SF) ((frame[0]>>1) & 0x03); | |
1527 | |
1528 deb->trc_buf[deb->idx++] = 'I'; | |
1529 deb->trc_buf[deb->idx++] = 'r'; | |
1530 DEC_BYTE (nr, &deb->trc_buf[deb->idx]); deb->idx+=3; | |
1531 deb->trc_buf[deb->idx++] = 's'; | |
1532 DEC_BYTE (ns, &deb->trc_buf[deb->idx]); deb->idx+=3; | |
1533 deb->trc_buf[deb->idx++] = ' '; | |
1534 | |
1535 /* | |
1536 * maybe optimize with a table!! | |
1537 */ | |
1538 switch (sFrame) | |
1539 { | |
1540 case SF_RR: | |
1541 memcpy(&deb->trc_buf[deb->idx], "RR ",3); | |
1542 break; | |
1543 | |
1544 case SF_RNR: | |
1545 memcpy(&deb->trc_buf[deb->idx], "RNR",3); | |
1546 break; | |
1547 case SF_REJ: | |
1548 memcpy(&deb->trc_buf[deb->idx], "REJ",3); | |
1549 break; | |
1550 case SF_SREJ: | |
1551 memcpy(&deb->trc_buf[deb->idx], "SRJ",3); | |
1552 break; | |
1553 default: | |
1554 memcpy(&deb->trc_buf[deb->idx], "***",3); | |
1555 break; | |
1556 } | |
1557 deb->idx += 3; | |
1558 break; | |
1559 } | |
1560 } | |
1561 deb->trc_buf[deb->idx++] = ' '; | |
1562 deb->trc_buf[deb->idx++] = ((cBit) ? 'C' : 'R'); | |
1563 deb->trc_buf[deb->idx++] = ((cBit) ? 'P' : 'F'); | |
1564 deb->trc_buf[deb->idx++] = ' '; | |
1565 HEX_BYTE (frame[1], &deb->trc_buf[deb->idx]); deb->idx+=2; | |
1566 HEX_BYTE (frame[0], &deb->trc_buf[deb->idx]); deb->idx+=2; | |
1567 deb->trc_buf[deb->idx++] = ' '; | |
1568 HEX_BYTE (frame[2], &deb->trc_buf[deb->idx]); deb->idx+=2; | |
1569 HEX_BYTE (frame[3], &deb->trc_buf[deb->idx]); deb->idx+=2; | |
1570 | |
1571 deb->trc_buf[deb->idx] = '\0'; | |
1572 TRACE_EVENT (deb->trc_buf); | |
1573 } | |
1574 #endif | |
1575 | |
1576 /* | |
1577 +--------------------------------------------------------------------+ | |
1578 | PROJECT : GSM-F&D (8411) MODULE : RLP_KERF | | |
1579 | STATE : code ROUTINE : ker_resetTRCVS | | |
1580 +--------------------------------------------------------------------+ | |
1581 | |
1582 PURPOSE : Resets all running timer in the TCRVS table | |
1583 | |
1584 */ | |
1585 | |
1586 LOCAL void ker_resetTRCVS | |
1587 ( | |
1588 void | |
1589 ) | |
1590 { | |
1591 T_FRAME_NUM lookUp; | |
1592 | |
1593 TRACE_FUNCTION ("ker_resetTRCVS()"); | |
1594 | |
1595 for (lookUp = 0; lookUp < MAX_SREJ_COUNT; lookUp++) | |
1596 { | |
1597 if (!rlp_data->ker.rcvsTab[lookUp].isFree AND rlp_data->ker.rcvsTab[lookUp].trcvs_running) | |
1598 { | |
1599 TIMERSTOP (lookUp); | |
1600 rlp_data->ker.rcvsTab[lookUp].trcvs_running = FALSE; | |
1601 rlp_data->ker.rcvsTab[lookUp].isFree = TRUE; | |
1602 rlp_data->ker.rcvsTab[lookUp].slot = INVALID_IDX; | |
1603 } | |
1604 } | |
1605 } | |
1606 | |
1607 /* | |
1608 +--------------------------------------------------------------------+ | |
1609 | PROJECT : GSM-F&D (8411) MODULE : RLP_KERF | | |
1610 | STATE : code ROUTINE : ker_reset_all_t_rcvs | | |
1611 +--------------------------------------------------------------------+ | |
1612 | |
1613 PURPOSE : Resets the timer for each rcvs slot. | |
1614 | |
1615 */ | |
1616 | |
1617 GLOBAL void ker_reset_all_t_rcvs | |
1618 ( | |
1619 void | |
1620 ) | |
1621 { | |
1622 TRACE_FUNCTION ("ker_reset_all_t_rcvs()"); | |
1623 | |
1624 ker_resetTRCVS (); | |
1625 | |
1626 rlp_data->ker.SREJ_Count = 0; | |
1627 | |
1628 srm_reset (); | |
1629 } | |
1630 | |
1631 /* | |
1632 +--------------------------------------------------------------------+ | |
1633 | PROJECT : GSM-F&D (8411) MODULE : RLP_KERF | | |
1634 | STATE : code ROUTINE : ker_s_handler | | |
1635 +--------------------------------------------------------------------+ | |
1636 | |
1637 PURPOSE : | |
1638 | |
1639 */ | |
1640 | |
1641 GLOBAL void ker_s_handler | |
1642 ( | |
1643 T_BIT cBit, | |
1644 T_BIT pFBit, | |
1645 T_SF sf, | |
1646 T_FRAME_NUM nr, | |
1647 BOOL *retransError | |
1648 ) | |
1649 { | |
1650 BOOL allFramesAck = FALSE; | |
1651 | |
1652 TRACE_FUNCTION ("ker_s_handler()"); | |
1653 | |
1654 *retransError = FALSE; | |
1655 | |
1656 if (cBit EQ 1 AND pFBit EQ 1) | |
1657 { | |
1658 rlp_data->ker.Ackn_State = IS_SEND; | |
1659 rlp_data->ker.Ackn_FBit = 1; | |
1660 | |
1661 rbm_reset_all_r_states (); | |
1662 ker_reset_all_t_rcvs (); | |
1663 rlp_data->ker.REJ_State = ISW_IDLE; | |
1664 | |
1665 TIMERSTOP (TRCVR_HANDLE); | |
1666 } | |
1667 | |
1668 if (rlp_data->ker.Poll_State NEQ ISW_IDLE) | |
1669 { | |
1670 if (pFBit EQ 0 OR sf EQ SF_REJ OR sf EQ SF_SREJ ) | |
1671 return; | |
1672 | |
1673 sbm_rej_from_n (nr, retransError); | |
1674 rlp_data->ker.Poll_State = ISW_IDLE; | |
1675 rlp_data->ker.Poll_xchg = IW_IDLE; | |
1676 rlp_data->ker.Poll_Count = 0; | |
1677 | |
1678 if (*retransError) | |
1679 { | |
1680 ker_reset_all_t_rcvs (); | |
1681 rbm_reset_srej_slots (); | |
1682 | |
1683 TIMERSTOP (TRCVR_HANDLE); | |
1684 TIMERSTOP (TT_HANDLE); | |
1685 | |
1686 rlp_data->ker.DISC_State = ISW_SEND; | |
1687 rlp_data->ker.DISC_Count = 0; | |
1688 | |
1689 | |
1690 if (rlp_data->ker.Poll_xchg EQ IW_IDLE) | |
1691 rlp_data->ker.DISC_PBit = 1; | |
1692 else | |
1693 rlp_data->ker.DISC_PBit = 0; | |
1694 | |
1695 ker_deinit_link_vars(); | |
1696 rlp_data->ker.DISC_Ind = TRUE; | |
1697 | |
1698 return; | |
1699 } | |
1700 } | |
1701 | |
1702 switch (sf) | |
1703 { | |
1704 case SF_RR: | |
1705 allFramesAck = sbm_ack_upto_n(nr); | |
1706 if (rlp_data->ker.RRReady EQ FALSE) | |
1707 { | |
1708 TRACE_EVENT ("Remote RR"); | |
1709 } | |
1710 rlp_data->ker.RRReady = TRUE; | |
1711 break; | |
1712 | |
1713 case SF_RNR: | |
1714 allFramesAck = sbm_ack_upto_n(nr); | |
1715 if (rlp_data->ker.RRReady EQ TRUE) | |
1716 { | |
1717 TRACE_EVENT ("Remote RNR"); | |
1718 } | |
1719 rlp_data->ker.RRReady = FALSE; | |
1720 break; | |
1721 | |
1722 case SF_REJ: | |
1723 allFramesAck = sbm_ack_upto_n(nr); | |
1724 sbm_rej_from_n (nr, retransError); | |
1725 | |
1726 if(*retransError) | |
1727 { | |
1728 ker_reset_all_t_rcvs (); | |
1729 rbm_reset_srej_slots (); | |
1730 | |
1731 TIMERSTOP (TRCVR_HANDLE); | |
1732 TIMERSTOP (TT_HANDLE); | |
1733 | |
1734 rlp_data->ker.DISC_State = ISW_SEND; | |
1735 rlp_data->ker.DISC_Count = 0; | |
1736 | |
1737 if (rlp_data->ker.Poll_xchg EQ IW_IDLE) | |
1738 rlp_data->ker.DISC_PBit = 1; | |
1739 else | |
1740 rlp_data->ker.DISC_PBit = 0; | |
1741 | |
1742 ker_deinit_link_vars(); | |
1743 rlp_data->ker.DISC_Ind = TRUE; | |
1744 | |
1745 return; | |
1746 } | |
1747 | |
1748 if (rlp_data->ker.RRReady EQ FALSE) | |
1749 { | |
1750 TRACE_EVENT ("Remote RR"); | |
1751 } | |
1752 rlp_data->ker.RRReady = TRUE; | |
1753 break; | |
1754 | |
1755 case SF_SREJ: | |
1756 sbm_srej_frame (nr); | |
1757 TIMERSTOP (TT_HANDLE); | |
1758 return; | |
1759 } | |
1760 | |
1761 if (allFramesAck) | |
1762 { | |
1763 TIMERSTOP (TT_HANDLE); | |
1764 } | |
1765 | |
1766 } | |
1767 | |
1768 /* | |
1769 +--------------------------------------------------------------------+ | |
1770 | PROJECT : GSM-F&D (8411) MODULE : RLP_KERF | | |
1771 | STATE : code ROUTINE : ker_send_data | | |
1772 +--------------------------------------------------------------------+ | |
1773 | |
1774 PURPOSE : | |
1775 */ | |
1776 | |
1777 GLOBAL void ker_send_data(void) | |
1778 { | |
1779 T_EXT_FRAME_NUM slot; | |
1780 T_FRAME_NUM vr; | |
1781 | |
1782 TRACE_FUNCTION ("ker_send_data()"); | |
1783 | |
1784 if (rlp_data->ker.UA_State EQ IS_SEND) | |
1785 { | |
1786 sig_ker_snd_ua_req (rlp_data->ker.UA_FBit); | |
1787 rlp_data->ker.UA_State = IS_IDLE; | |
1788 } | |
1789 else | |
1790 { | |
1791 vr = rbm_get_vr(); | |
1792 if (rlp_data->ker.Ackn_FBit EQ 1) | |
1793 { | |
1794 if (rlp_data->ker.LRReady) | |
1795 ker_send_rr_rri_resp (vr); | |
1796 else | |
1797 ker_send_rnr_rnri_resp (vr); | |
1798 } | |
1799 else | |
1800 { | |
1801 switch (rlp_data->ker.REJ_State) | |
1802 { | |
1803 case ISW_SEND: | |
1804 ker_send_rej_reji_cmd (vr); | |
1805 break; | |
1806 | |
1807 default: | |
1808 slot = rbm_check_slots_srej(); | |
1809 if (slot EQ INVALID_IDX) | |
1810 { | |
1811 if (rlp_data->ker.LRReady) | |
1812 ker_send_rr_rri_cmd (vr); | |
1813 else | |
1814 ker_send_rnr_rnri_cmd (vr); | |
1815 } | |
1816 else | |
1817 ker_send_srej_sreji_cmd (slot); | |
1818 break; | |
1819 } | |
1820 } | |
1821 } | |
1822 } | |
1823 | |
1824 /* | |
1825 +--------------------------------------------------------------------+ | |
1826 | PROJECT : GSM-F&D (8411) MODULE : RLP_KERF | | |
1827 | STATE : code ROUTINE : ker_send_txu | | |
1828 +--------------------------------------------------------------------+ | |
1829 | |
1830 PURPOSE : | |
1831 | |
1832 */ | |
1833 | |
1834 GLOBAL BOOL ker_send_txu | |
1835 ( | |
1836 void | |
1837 ) | |
1838 { | |
1839 TRACE_FUNCTION ("ker_send_txu()"); | |
1840 | |
1841 if (rlp_data->ker.TEST_R_State EQ IS_SEND) | |
1842 { | |
1843 sig_ker_snd_test_req | |
1844 ( | |
1845 0, | |
1846 rlp_data->ker.TEST_R_FBit, | |
1847 &rlp_data->ker.TEST_R_FrameDesc | |
1848 ); | |
1849 rlp_data->ker.TEST_R_State = IS_IDLE; | |
1850 return TRUE; | |
1851 } | |
1852 | |
1853 if (rlp_data->ker.XID_R_State EQ IS_SEND) | |
1854 { | |
1855 TRACE_EVENT ("Snd XID R"); | |
1856 sig_ker_snd_xid_req | |
1857 ( | |
1858 0, | |
1859 1, | |
1860 &rlp_data->ker.XID_R_FrameDesc | |
1861 ); | |
1862 | |
1863 rlp_data->ker.XID_R_State = IS_IDLE; | |
1864 return TRUE; | |
1865 } | |
1866 | |
1867 if (GET_STATE(KERXID_C) EQ ISW_SEND) | |
1868 { | |
1869 if (rlp_data->ker.Poll_xchg NEQ IW_WAIT) | |
1870 { | |
1871 TRACE_EVENT ("Snd XID C"); | |
1872 sig_ker_snd_xid_req | |
1873 ( | |
1874 1, | |
1875 1, | |
1876 &rlp_data->ker.XID_C_FrameDesc | |
1877 ); | |
1878 SET_STATE(KERXID_C, ISW_WAIT); | |
1879 | |
1880 TIMERSTART(TXID_HANDLE, rlp_data->ker.T1); | |
1881 rlp_data->ker.Poll_xchg = IW_WAIT; | |
1882 return TRUE; | |
1883 } | |
1884 } | |
1885 | |
1886 if (rlp_data->ker.UI_State EQ IS_SEND) | |
1887 { | |
1888 sig_ker_snd_ui_req | |
1889 ( | |
1890 1, | |
1891 0, | |
1892 &rlp_data->ker.UI_FrameDesc | |
1893 ); | |
1894 rlp_data->ker.UI_State = IS_IDLE; | |
1895 return TRUE; | |
1896 } | |
1897 | |
1898 return FALSE; | |
1899 } | |
1900 | |
1901 /* | |
1902 +--------------------------------------------------------------------+ | |
1903 | PROJECT : GSM-F&D (8411) MODULE : RLP_KERF | | |
1904 | STATE : code ROUTINE : ker_deinit_link_vars | | |
1905 +--------------------------------------------------------------------+ | |
1906 | |
1907 PURPOSE : deinitialize send/receive buffer manager, | |
1908 | |
1909 */ | |
1910 | |
1911 GLOBAL void ker_deinit_link_vars | |
1912 ( | |
1913 void | |
1914 ) | |
1915 { | |
1916 | |
1917 TRACE_FUNCTION ("ker_deinit_link_vars()"); | |
1918 | |
1919 rlp_data->ker.Connected = FALSE; | |
1920 | |
1921 sbm_deinit (); | |
1922 | |
1923 rbm_deinit (); | |
1924 | |
1925 srm_deinit (); | |
1926 | |
1927 } | |
1928 | |
1929 /* | |
1930 +--------------------------------------------------------------------+ | |
1931 | PROJECT : GSM-F&D (8411) MODULE : RLP_KERF | | |
1932 | STATE : code ROUTINE : ker_send_rlp_error_ind | | |
1933 +--------------------------------------------------------------------+ | |
1934 | |
1935 PURPOSE : send a error cause to L2R | |
1936 | |
1937 */ | |
1938 | |
1939 GLOBAL void ker_send_rlp_error_ind(USHORT cause) | |
1940 { | |
1941 PALLOC (rlp_error_ind, RLP_ERROR_IND); | |
1942 | |
1943 TRACE_FUNCTION ("ker_send_rlp_error_ind()"); | |
1944 TRACE_EVENT_P1("RLP Error : %d", cause); | |
1945 | |
1946 rlp_error_ind->cause = cause; | |
1947 PSENDX (L2R, rlp_error_ind); | |
1948 ker_deinit_link_vars (); | |
1949 } | |
1950 | |
1951 /* | |
1952 +--------------------------------------------------------------------+ | |
1953 | PROJECT : GSM-F&D (8411) MODULE : RLP_KERF | | |
1954 | STATE : code ROUTINE : ker_getSlotTRCVS | | |
1955 +--------------------------------------------------------------------+ | |
1956 | |
1957 PURPOSE : search the rcvs entry for a given timer handle. The | |
1958 function returns the corresponding slot. The entry | |
1959 is freed. This function is used in the timeout handling | |
1960 functions of the entity. | |
1961 | |
1962 */ | |
1963 GLOBAL T_FRAME_NUM ker_getSlotTRCVS (USHORT index) | |
1964 { | |
1965 rlp_data->ker.rcvsTab[index].trcvs_running = FALSE; | |
1966 rlp_data->ker.rcvsTab[index].isFree = TRUE; | |
1967 | |
1968 return rlp_data->ker.rcvsTab[index].slot; | |
1969 } | |
1970 | |
1971 /* | |
1972 +--------------------------------------------------------------------+ | |
1973 | PROJECT : GSM-F&D (8411) MODULE : RLP_KERF | | |
1974 | STATE : code ROUTINE : ker_fill_remap_frame | | |
1975 +--------------------------------------------------------------------+ | |
1976 | |
1977 PURPOSE : | |
1978 | |
1979 */ | |
1980 | |
1981 GLOBAL void ker_fill_remap_frame | |
1982 ( | |
1983 T_FRAME_NUM vr | |
1984 ) | |
1985 { | |
1986 | |
1987 TRACE_FUNCTION ("ker_fill_remap_frame()"); | |
1988 | |
1989 rlp_data->ker.REMAP_Frame[HEADER_LEN + 0] = vr * 4; | |
1990 rlp_data->ker.REMAP_Frame[HEADER_LEN + 1] = 0; | |
1991 | |
1992 ker_put_xid_data | |
1993 ( | |
1994 rlp_data->ker.REMAP_Frame + HEADER_LEN, | |
1995 2, | |
1996 UF_ALL, | |
1997 TRUE, | |
1998 ORIG_RLP_VERS, | |
1999 rlp_data->ker.Orig_K_iwf_ms, | |
2000 rlp_data->ker.Orig_K_ms_iwf, | |
2001 rlp_data->ker.Orig_T1, | |
2002 rlp_data->ker.Orig_N2, | |
2003 rlp_data->ker.Orig_T2, | |
2004 rlp_data->ker.Orig_Pt, | |
2005 rlp_data->ker.Orig_P0, | |
2006 rlp_data->ker.Orig_P1, | |
2007 rlp_data->ker.Orig_P2 | |
2008 ); | |
2009 | |
2010 } | |
2011 | |
2012 /* | |
2013 +--------------------------------------------------------------------+ | |
2014 | PROJECT : GSM-F&D (8411) MODULE : RLP_KERF | | |
2015 | STATE : code ROUTINE : ker_send_remap_data | | |
2016 +--------------------------------------------------------------------+ | |
2017 | |
2018 PURPOSE : | |
2019 | |
2020 */ | |
2021 | |
2022 GLOBAL BOOL ker_send_remap_data | |
2023 ( | |
2024 void | |
2025 ) | |
2026 { | |
2027 T_RLP_DATA_REQ *prim; | |
2028 | |
2029 TRACE_FUNCTION ("ker_send_remap_data()"); | |
2030 | |
2031 if (sbm_recall_prim (&prim)) | |
2032 { | |
2033 PPASS (prim, rlp_remap_data_ind, RLP_REMAP_DATA_IND); | |
2034 rlp_remap_data_ind->data_size = rlp_data->ker.OldFrameSize - HEADER_LEN - TRAILER_LEN; | |
2035 PSENDX (L2R, rlp_remap_data_ind); | |
2036 return TRUE; | |
2037 } | |
2038 return FALSE; | |
2039 } | |
2040 | |
2041 /* | |
2042 +--------------------------------------------------------------------+ | |
2043 | PROJECT : GSM-F&D (8411) MODULE : RLP_KERF | | |
2044 | STATE : code ROUTINE : ker_set_frame_size | | |
2045 +--------------------------------------------------------------------+ | |
2046 | |
2047 PURPOSE : | |
2048 | |
2049 */ | |
2050 | |
2051 GLOBAL void ker_set_frame_size | |
2052 ( | |
2053 UBYTE rate | |
2054 ) | |
2055 { | |
2056 | |
2057 TRACE_FUNCTION ("ker_set_frame_size()"); | |
2058 | |
2059 switch(rate) | |
2060 { | |
2061 case RLP_FULLRATE_14400: | |
2062 rlp_data->ker.Def_T1 = DEF_T1_FR14400; | |
2063 rlp_data->ker.FrameSize = FRAME_SIZE_LONG; | |
2064 break; | |
2065 case RLP_FULLRATE_9600: | |
2066 rlp_data->ker.Def_T1 = DEF_T1_FR9600; | |
2067 rlp_data->ker.FrameSize = FRAME_SIZE_SHORT; | |
2068 break; | |
2069 case RLP_FULLRATE_4800: | |
2070 rlp_data->ker.Def_T1 = DEF_T1_FR4800; | |
2071 rlp_data->ker.FrameSize = FRAME_SIZE_SHORT; | |
2072 break; | |
2073 case RLP_HALFRATE_4800: | |
2074 rlp_data->ker.Def_T1 = DEF_T1_HR4800; | |
2075 rlp_data->ker.FrameSize = FRAME_SIZE_SHORT; | |
2076 break; | |
2077 } | |
2078 | |
2079 rlp_data->ker.FramesPerPrim = | |
2080 (rlp_data->ker.BytesPerPrim + rlp_data->ker.FrameSize - 1) / | |
2081 rlp_data->ker.FrameSize; | |
2082 | |
2083 sig_ker_snd_set_frame_size_req (rlp_data->ker.FrameSize); | |
2084 | |
2085 } | |
2086 |