comparison src/g23m-fad/rlp/rlp_tim.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 : CSD (8411)
4 | Modul : Rlp_tim.c
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 timer handling functions
18 | for the component Radio Link Protocol of the base station
19 +-----------------------------------------------------------------------------
20 */
21
22 #ifndef RLP_TIM_C
23 #define RLP_TIM_C
24 #endif
25
26 #define ENTITY_RLP
27
28 /*==== INCLUDES ===================================================*/
29
30 #include <string.h>
31 #include "typedefs.h"
32 #include "vsi.h"
33 #include "macdef.h"
34 #include "custom.h"
35 #include "gsm.h"
36 #include "cus_rlp.h"
37 #include "prim.h"
38 #include "tok.h"
39 #include "rlp.h"
40
41 /*==== EXPORT =====================================================*/
42
43 /*==== PRIVAT =====================================================*/
44
45 /*==== VARIABLES ==================================================*/
46
47 /*==== FUNCTIONS ==================================================*/
48
49 /*
50 +------------------------------------------------------------------------------
51 | Function : tim_tt
52 +------------------------------------------------------------------------------
53 | Description : Timeout of timer TT
54 |
55 | Parameters :
56 |
57 |
58 | Return :
59 +------------------------------------------------------------------------------
60 */
61
62
63 LOCAL void tim_tt (void)
64 {
65
66 BOOL retransError;
67
68 TRACE_FUNCTION ("tim_tt()");
69
70 switch (GET_STATE (KER))
71 {
72 case RLP_PENDING_CONNECT_REQ:
73 /*
74 * processing for state RLP_PENDING_CONNECT_REQ
75 */
76 rlp_data->ker.Poll_xchg = IW_IDLE;
77
78 if (rlp_data->ker.SABM_Count > rlp_data->ker.N2)
79 {
80 ker_send_rlp_error_ind (RLP_ERR_SABM_RETRANS);
81 SET_STATE (KER, RLP_PERMANENT_ERROR);
82 }
83 else
84 rlp_data->ker.SABM_State = ISW_SEND;
85 break;
86
87 case RLP_CONNECTION_ESTABLISHED:
88 /*
89 * processing for state RLP_CONNECTION_ESTABLISHED
90 */
91 rlp_data->ker.Poll_xchg = IW_IDLE;
92
93 sbm_check_rej_count(&retransError);
94
95 if (!retransError)
96 {
97 switch (rlp_data->ker.Poll_State)
98 {
99 case ISW_IDLE:
100 rlp_data->ker.Poll_State = ISW_SEND;
101 break;
102
103 case ISW_WAIT:
104 if (rlp_data->ker.Poll_Count <= rlp_data->ker.N2)
105 rlp_data->ker.Poll_State = ISW_SEND;
106
107 else
108 {
109 ker_reset_all_t_rcvs ();
110 rbm_reset_srej_slots();
111 TIMERSTOP (TRCVR_HANDLE);
112 rlp_data->ker.DISC_State = ISW_SEND;
113 rlp_data->ker.DISC_Count = 0;
114 rlp_data->ker.DISC_PBit = 1;
115
116 ker_deinit_link_vars ();
117 rlp_data->ker.DISC_Ind = TRUE;
118
119 SET_STATE (KER, RLP_DISCONNECT_INITIATED);
120 TRACE_EVENT("#10");
121 }
122 break;
123 }
124 }
125 else
126 {
127 ker_reset_all_t_rcvs ();
128 rbm_reset_srej_slots();
129 TIMERSTOP (TRCVR_HANDLE);
130
131 rlp_data->ker.DISC_State = ISW_SEND;
132 rlp_data->ker.DISC_Count = 0;
133 rlp_data->ker.DISC_PBit = 1;
134
135 ker_deinit_link_vars ();
136 rlp_data->ker.DISC_Ind = TRUE;
137
138 SET_STATE (KER, RLP_DISCONNECT_INITIATED);
139 TRACE_EVENT("#11");
140 }
141
142 break;
143
144 case RLP_DISCONNECT_INITIATED:
145 /*
146 * processing for state RLP_DISCONNECT_INITIATED
147 */
148 if (rlp_data->ker.DISC_PBit EQ 1)
149 rlp_data->ker.Poll_xchg = IW_IDLE;
150
151 if (rlp_data->ker.DISC_Count > rlp_data->ker.N2)
152 {
153 ker_send_rlp_error_ind (RLP_ERR_DISC_RETRANS);
154 SET_STATE (KER, RLP_PERMANENT_ERROR);
155 }
156 else
157 rlp_data->ker.DISC_State = ISW_SEND;
158 break;
159
160 case RLP_PENDING_RESET_REQ:
161 /*
162 * processing for state RLP_PENDING_RESET_REQ
163 */
164 rlp_data->ker.Poll_xchg = IW_IDLE;
165 if (rlp_data->ker.SABM_Count > rlp_data->ker.N2)
166 {
167 ker_send_rlp_error_ind (RLP_ERR_SABM_RETRANS);
168 SET_STATE (KER, RLP_PERMANENT_ERROR);
169 }
170 else
171 rlp_data->ker.SABM_State = ISW_SEND;
172 break;
173
174 case RLP_PENDING_REMAP_REQ:
175 /*
176 * processing for state RLP_PENDING_REMAP_REQ
177 */
178 rlp_data->ker.Poll_xchg = IW_IDLE;
179
180 ker_send_rlp_error_ind (RLP_ERR_REMAP_RETRANS);
181 SET_STATE (KER, RLP_PERMANENT_ERROR);
182 }
183 }
184
185 /*
186 +------------------------------------------------------------------------------
187 | Function : tim_tul_rcv
188 +------------------------------------------------------------------------------
189 | Description : Timeout of timer TUL_RCV
190 |
191 | Parameters : -
192 |
193 |
194 | Return : -
195 +------------------------------------------------------------------------------
196 */
197
198
199 LOCAL void tim_tul_rcv (void)
200 {
201 TRACE_FUNCTION ("tim_tul_rcv()");
202
203 switch (GET_STATE (KER))
204 {
205 case RLP_CONNECTION_ESTABLISHED:
206 case RLP_PENDING_REMAP_REQ:
207 case RLP_REMAP_DATA:
208 /*
209 * processing for states RLP_CONNECTION_ESTABLISHED
210 * RLP_PENDING_REMAP_REQ:
211 * RLP_REMAP_DATA:
212 */
213 switch (rlp_data->ker.UL_Rcv_State)
214 {
215 case IW_WAIT:
216 {
217 T_RLP_DATA_IND *rlp_data_ind;
218
219 if (rlp_data->rbm.CurrPrimCou > 0 )
220 {
221 /* if some data are there */
222 rlp_data_ind = rbm_get_curr_prim ();
223 /*
224 * send the waiting but not complete filled prim to L2R
225 */
226 PSENDX (L2R, rlp_data_ind);
227 rlp_data->ker.UL_Rcv_State = IW_IDLE;
228 }
229 else
230 {
231 TRACE_EVENT("no data to send!");
232 }
233 break;
234 }
235 }
236 break;
237 }
238 }
239
240 /*
241 +------------------------------------------------------------------------------
242 | Function : tim_trcvr
243 +------------------------------------------------------------------------------
244 | Description : Timeout of timer TRCVR
245 |
246 | Parameters : -
247 |
248 |
249 | Return : -
250 +------------------------------------------------------------------------------
251 */
252
253
254 LOCAL void tim_trcvr (void)
255 {
256 TRACE_FUNCTION ("tim_trcvr()");
257
258 switch (GET_STATE (KER))
259 {
260 case RLP_CONNECTION_ESTABLISHED:
261 /*
262 * processing for state RLP_CONNECTION_ESTABLISHED
263 */
264 switch (rlp_data->ker.REJ_State)
265 {
266 case ISW_WAIT:
267 ker_reset_all_t_rcvs();
268 rbm_reset_srej_slots();
269
270 TIMERSTOP(TT_HANDLE);
271 rlp_data->ker.REJ_State = ISW_IDLE; /* jk: acc. ETSI after timer reset IDLE */
272 /* in order to enable new REJ condition */
273 /*
274 * Don't disconnect
275 * a timeout of TRCVR can be ignored
276 * The network will get a timeout for the sent frames,
277 * which we have not received.
278 */
279 /*
280 rlp_data->ker.DISC_State = ISW_SEND;
281 rlp_data->ker.DISC_Count = 0;
282
283 switch(rlp_data->ker.Poll_xchg)
284 {
285 case IW_IDLE:
286 rlp_data->ker.DISC_PBit = 1;
287 break;
288
289 default:
290 rlp_data->ker.DISC_PBit = 0;
291 break;
292 }
293
294 ker_deinit_link_vars();
295 rlp_data->ker.DISC_Ind = TRUE;
296 SET_STATE (KER, RLP_DISCONNECT_INITIATED);
297 TRACE_EVENT("#12");
298 */
299 break;
300 }
301 break;
302 }
303 }
304
305 /*
306 +------------------------------------------------------------------------------
307 | Function : tim_trcvs
308 +------------------------------------------------------------------------------
309 | Description : Timeout of timer TRCVS
310 |
311 | Parameters : rcvs_slot
312 |
313 |
314 | Return : -
315 +------------------------------------------------------------------------------
316 */
317
318
319 LOCAL void tim_trcvs (T_FRAME_NUM rcvs_slot)
320 {
321 TRACE_FUNCTION ("tim_trcvs()");
322
323 TRACE_EVENT_P1 ("Timeout RCVS[%d]", rcvs_slot);
324
325 if (GET_STATE (KER) EQ RLP_CONNECTION_ESTABLISHED)
326 {
327 if (rbm_is_state_wait(rcvs_slot))
328 {
329 rlp_data->ker.SREJ_Count--;
330
331 if(srm_get_counter(rcvs_slot) > rlp_data->ker.N2)
332 {
333 ker_reset_all_t_rcvs();
334 rbm_reset_srej_slots();
335 TIMERSTOP(TT_HANDLE);
336 rlp_data->ker.DISC_State = ISW_SEND;
337 rlp_data->ker.DISC_Count = 0;
338
339 switch(rlp_data->ker.Poll_xchg)
340 {
341 case IW_IDLE:
342 rlp_data->ker.DISC_PBit = 1;
343 break;
344
345 default:
346 rlp_data->ker.DISC_PBit = 0;
347 break;
348 }
349 ker_deinit_link_vars();
350 rlp_data->ker.DISC_Ind = TRUE;
351 SET_STATE (KER, RLP_DISCONNECT_INITIATED);
352 TRACE_EVENT("#13");
353 }
354 else
355 {
356 rbm_set_rslot_wait2srej (rcvs_slot);
357 }
358 }
359 }
360 }
361
362 /*
363 +------------------------------------------------------------------------------
364 | Function : tim_txid
365 +------------------------------------------------------------------------------
366 | Description : Timeout of timer TXID
367 |
368 | Parameters : -
369 |
370 |
371 | Return : -
372 +------------------------------------------------------------------------------
373 */
374
375
376 LOCAL void tim_txid (void)
377 {
378 TRACE_FUNCTION ("tim_txid()");
379
380 switch (GET_STATE (KER))
381 {
382 case RLP_ADM_AND_DETACHED:
383 /*
384 * no processing for state RLP_ADM_AND_DETACHED
385 */
386 break;
387
388 default:
389 /*
390 * processing for all other kernel states
391 */
392 rlp_data->ker.Poll_xchg = IW_IDLE;
393 if (rlp_data->ker.XID_Count >= rlp_data->ker.N2)
394 {
395 ker_send_rlp_error_ind (RLP_ERR_XID_RETRANS);
396 SET_STATE (KER, RLP_PERMANENT_ERROR);
397 }
398 else
399 {
400 SET_STATE(KERXID_C, ISW_SEND);
401 rlp_data->ker.XID_Count++;
402 }
403 break;
404 }
405 }
406
407 /*
408 +------------------------------------------------------------------------------
409 | Function : rlp_exec_timeout
410 +------------------------------------------------------------------------------
411 | Description : execute timeout function depending on index
412 |
413 | Parameters : index
414 |
415 |
416 | Return : -
417 +------------------------------------------------------------------------------
418 */
419
420 GLOBAL void rlp_exec_timeout (USHORT index)
421 {
422 T_FRAME_NUM rcvs_slot;
423
424 TRACE_FUNCTION ("rlp_exec_timeout()");
425
426 switch (index)
427 {
428 case TT_HANDLE:
429 tim_tt ();
430 break;
431
432 case TUL_RCV_HANDLE:
433 tim_tul_rcv ();
434 break;
435
436 case TRCVR_HANDLE:
437 tim_trcvr ();
438 break;
439
440 case TXID_HANDLE:
441 tim_txid ();
442 break;
443
444 default:
445 if ( index < MAX_SREJ_COUNT )
446 {
447 /* case TRCVS_HANDLE: */
448 if ((rcvs_slot = ker_getSlotTRCVS (index)) NEQ INVALID_IDX)
449 {
450 /*
451 * store the index of the rcvs_timer
452 */
453 rlp_data->rcvs_slot = rcvs_slot;
454 tim_trcvs (rlp_data->rcvs_slot);
455 }
456 }
457 else
458 {
459 TRACE_EVENT ("UNDEFINED TIMEOUT");
460 }
461 break;
462 }
463 }
464
465