comparison src/g23m-gprs/llc/llc_irxs.c @ 183:219afcfc6250

src/g23m-gprs: initial import from TCS3.2/LoCosto
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 13 Oct 2016 04:24:13 +0000
parents
children
comparison
equal deleted inserted replaced
182:f02d0a0e1849 183:219afcfc6250
1 /*
2 +-----------------------------------------------------------------------------
3 | Project :
4 | Modul :
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 is part of the entity LLC and implements all
18 | functions to handles the incoming process internal signals as
19 | described in the SDL-documentation (IRX-statemachine)
20 +-----------------------------------------------------------------------------
21 */
22
23 #ifndef LLC_IRXS_C
24 #define LLC_IRXS_C
25 #endif
26
27 #define ENTITY_LLC
28
29 /*==== INCLUDES =============================================================*/
30
31 #include "typedefs.h" /* to get Condat data types */
32 #include "vsi.h" /* to get a lot of macros */
33 #include "macdef.h"
34 #include "gprs.h"
35 #include "gsm.h" /* to get a lot of macros */
36 #include "cnf_llc.h" /* to get cnf-definitions */
37 #include "mon_llc.h" /* to get mon-definitions */
38 #include "prim.h" /* to get the definitions of used SAP and directions */
39 #include "llc.h" /* to get the global entity definitions */
40
41 #include "llc_irxf.h" /* to get IRX helper functions */
42 #include "llc_irxl.h" /* to get IRX label functions */
43 #include "llc_itxs.h" /* to get IRX/ITX signals */
44 #include "llc_us.h" /* to get U signals */
45
46
47 /*==== CONST ================================================================*/
48
49 /*==== LOCAL VARS ===========================================================*/
50
51 /*==== PRIVATE FUNCTIONS ====================================================*/
52
53 /*==== PUBLIC FUNCTIONS =====================================================*/
54
55
56
57 /*
58 +------------------------------------------------------------------------------
59 | Function : sig_llme_irx_assign_req
60 +------------------------------------------------------------------------------
61 | Description : Handles the internal signal SIG_LLME_IRX_ASSIGN_REQ
62 |
63 | Parameters :
64 |
65 +------------------------------------------------------------------------------
66 */
67 GLOBAL void sig_llme_irx_assign_req (void)
68 {
69 TRACE_ISIG( "sig_llme_irx_assign_req" );
70
71 switch (GET_STATE(IRX))
72 {
73 case IRX_TLLI_UNASSIGNED:
74 /*
75 * Initialise current incarnation.
76 */
77 irx_init_sapi();
78 SET_STATE (IRX, IRX_TLLI_ASSIGNED);
79 break;
80
81 default:
82 TRACE_ERROR( "SIG_LLME_IRX_ASSIGN_REQ unexpected" );
83 break;
84 }
85 } /* sig_llme_irx_assign_req() */
86
87
88 /*
89 +------------------------------------------------------------------------------
90 | Function : sig_llme_irx_unassign_req
91 +------------------------------------------------------------------------------
92 | Description : Handles the internal signal SIG_LLME_IRX_UNASSIGN_REQ
93 |
94 | Parameters :
95 |
96 +------------------------------------------------------------------------------
97 */
98 GLOBAL void sig_llme_irx_unassign_req (void)
99 {
100 TRACE_ISIG( "sig_llme_irx_unassign_req" );
101
102 switch (GET_STATE(IRX))
103 {
104 case IRX_TLLI_UNASSIGNED:
105 /*
106 * Ignore unexpected signal
107 */
108 break;
109
110 default:
111 /*
112 * Delete stored I frames and change to state TLLI_UNASSIGNED
113 */
114 irx_queue_clean();
115 irx_init_sapi();
116 SET_STATE (IRX, IRX_TLLI_UNASSIGNED);
117 break;
118 }
119 } /* sig_llme_irx_unassign_req() */
120
121
122 /*
123 +------------------------------------------------------------------------------
124 | Function : sig_llme_irx_reset_req
125 +------------------------------------------------------------------------------
126 | Description : Handles the internal signal SIG_LLME_IRX_RESET_REQ
127 |
128 | Parameters :
129 |
130 +------------------------------------------------------------------------------
131 */
132 GLOBAL void sig_llme_irx_reset_req (void)
133 {
134 TRACE_ISIG( "sig_llme_irx_reset_req" );
135
136
137 switch (GET_STATE(IRX))
138 {
139 case IRX_TLLI_UNASSIGNED:
140 case IRX_TLLI_ASSIGNED:
141 /*
142 * Ignore signal.
143 */
144 break;
145
146 case IRX_ABM:
147 case IRX_ABM_BUSY:
148 /*
149 * Delete stored I frames and change to state TLLI_UNASSIGNED
150 */
151 irx_queue_clean();
152 irx_init_sapi();
153 SET_STATE (IRX, IRX_TLLI_ASSIGNED);
154 break;
155
156 default:
157 TRACE_ERROR( "SIG_LLME_IRX_RESET_REQ unexpected" );
158 break;
159 }
160 } /* sig_llme_irx_reset_req() */
161
162
163
164 /*
165 +------------------------------------------------------------------------------
166 | Function : sig_llme_irx_abmest_req
167 +------------------------------------------------------------------------------
168 | Description : Handles the internal signal SIG_LLME_IRX_ABMEST_REQ
169 |
170 | Parameters :
171 |
172 +------------------------------------------------------------------------------
173 */
174 GLOBAL void sig_llme_irx_abmest_req (void)
175 {
176 TRACE_ISIG( "sig_llme_irx_abmest_req" );
177
178 switch (GET_STATE(IRX))
179 {
180 case IRX_TLLI_ASSIGNED:
181 /*
182 * Initialize ABM operation
183 */
184 irx_init_abm();
185 SET_STATE (IRX, IRX_ABM);
186 break;
187
188 case IRX_ABM:
189 case IRX_ABM_BUSY:
190 /*
191 * Delete stored I frames and re-initialize ABM operation
192 */
193 irx_queue_clean();
194 irx_init_abm();
195 SET_STATE (IRX, IRX_ABM);
196 break;
197
198 default:
199 TRACE_ERROR( "SIG_LLME_IRX_ABMEST_REQ unexpected" );
200 break;
201 }
202 } /* sig_llme_irx_abmest_req() */
203
204
205
206 /*
207 +------------------------------------------------------------------------------
208 | Function : sig_llme_irx_abmrel_req
209 +------------------------------------------------------------------------------
210 | Description : Handles the internal signal SIG_LLME_IRX_ABMREL_REQ
211 |
212 | Parameters :
213 |
214 +------------------------------------------------------------------------------
215 */
216 GLOBAL void sig_llme_irx_abmrel_req (void)
217 {
218 TRACE_ISIG( "sig_llme_irx_abmrel_req" );
219
220 switch (GET_STATE(IRX))
221 {
222 case IRX_ABM:
223 case IRX_ABM_BUSY:
224 /*
225 * Delete stored I frames and end ABM operation
226 */
227 irx_queue_clean();
228 irx_init_sapi();
229 SET_STATE (IRX, IRX_TLLI_ASSIGNED);
230 break;
231
232 default:
233 /* TRACE_ERROR( "SIG_LLME_IRX_ABMREL_REQ unexpected" ); but ok */
234 break;
235 }
236 } /* sig_llme_irx_abmrel_req() */
237
238
239
240 /*
241 +------------------------------------------------------------------------------
242 | Function : sig_rx_irx_data_ind
243 +------------------------------------------------------------------------------
244 | Description : Handles the internal signal SIG_RX_IRX_DATA_IND
245 |
246 | Parameters : ll_unitdata_ind - a valid pointer to an LL-UNITDATA-IND
247 | primitive
248 | command - contains the command within the primitive
249 | frame_type - type of PDU (I or S frame)
250 | cr_bit - setting of the CR bit
251 | a_bit - setting of the A bit
252 | ns - send sequence number of the frame
253 | nr - receive sequence number of the frame
254 |
255 +------------------------------------------------------------------------------
256 */
257 GLOBAL void sig_rx_irx_data_ind (T_LL_UNITDATA_IND *ll_unitdata_ind,
258 T_COMMAND command,
259 T_PDU_TYPE frame_type,
260 T_BIT cr_bit,
261 T_BIT a_bit,
262 T_FRAME_NUM ns,
263 T_FRAME_NUM nr)
264 {
265 UBYTE state;
266
267 TRACE_ISIG( "sig_rx_irx_data_ind" );
268
269 #ifdef TRACE_EVE
270 {
271 static char* sf[] = { "RR", "ACK", "RNR", "SACK" };
272
273 if(command <= 3)
274 {
275 if(frame_type == I_FRAME)
276 {
277 TRACE_4_INFO("got %s I-Frame NS:%d NR:%d A:%d", sf[command], ns, nr, a_bit);
278 }
279 else
280 {
281 TRACE_3_INFO("got %s S-Frame NR:%d A:%d", sf[command], nr, a_bit);
282 }
283 }
284 }
285 #endif
286
287 llc_data->u->current_tlli = ll_unitdata_ind->tlli;
288
289 switch ( (state = GET_STATE(IRX)) )
290 {
291 case IRX_TLLI_ASSIGNED:
292 /*
293 * Send a DM response to any valid command received, that
294 * cannot be handeled (GSM 4.64 Release 6.7.0 Chapter 6.4.1.4)
295 */
296 TRACE_0_INFO("S- or I/S-Frame received in unexpected state");
297
298 PFREE (ll_unitdata_ind);
299
300 sig_irx_u_no_frame_expected_ind();
301 break;
302
303 case IRX_ABM:
304 case IRX_ABM_BUSY:
305 /*
306 * va <= nr <= vs
307 */
308 if ( FRAME_NUM_VALID (llc_data->sapi->va, nr, llc_data->sapi->vs) )
309 {
310 /*
311 * frame valid
312 */
313 irx_ack_all_to ((T_FRAME_NUM)(nr - 1));
314
315 switch (command)
316 {
317 case I_RR:
318 /*
319 * Label IRX_RR
320 */
321 sig_irx_itx_peer_ready_ind();
322 break;
323
324 case I_ACK:
325 /*
326 * Label IRX_ACK
327 */
328 sig_irx_itx_ack_ind (FALSE, nr );
329 sig_irx_itx_ack_ind (TRUE, (T_FRAME_NUM)(nr + 1));
330 sig_irx_itx_cnf_l3data_req ();
331 sig_irx_itx_peer_ready_ind ();
332 break;
333
334 case I_SACK:
335 /*
336 * Label IRX_SACK
337 */
338 sig_irx_itx_ack_ind (FALSE, nr);
339 irx_handle_sack (nr, ll_unitdata_ind, frame_type);
340 sig_irx_itx_peer_ready_ind();
341 break;
342
343 case I_RNR:
344 /*
345 * Label IRX_RNR
346 */
347 sig_irx_itx_peer_busy_ind();
348 break;
349
350 default:
351 TRACE_ERROR( "Unexpected command received" );
352 break;
353 }
354 }
355
356 if (frame_type == I_FRAME)
357 {
358 irx_label_if (ll_unitdata_ind, ns, a_bit, state);
359 }
360 else /* S_FRAME */
361 {
362 if (state == IRX_ABM)
363 {
364 irx_send_ack (a_bit);
365 PFREE (ll_unitdata_ind);
366 }
367 else
368 {
369 irx_send_rnr ();
370 PFREE (ll_unitdata_ind);
371 }
372 }
373 break;
374
375 default:
376 /*
377 * Free unexpected data
378 */
379 PFREE (ll_unitdata_ind);
380 TRACE_ERROR( "SIG_RX_IRX_DATA_IND unexpected" );
381 break;
382 }
383 } /* sig_rx_irx_data_ind() */
384
385
386
387 /*
388 +------------------------------------------------------------------------------
389 | Function : sig_itx_irx_s_frame_req
390 +------------------------------------------------------------------------------
391 | Description : Handles the internal signal SIG_ITX_IRX_S_FRAME_REQ
392 |
393 | Parameters :
394 |
395 +------------------------------------------------------------------------------
396 */
397 GLOBAL void sig_itx_irx_s_frame_req (T_ABIT_REQ_TYPE req)
398 {
399 TRACE_ISIG( "sig_itx_irx_s_frame_req" );
400
401 switch (GET_STATE(IRX))
402 {
403 case IRX_ABM:
404 /*
405 * Send an S frame appropriate for the current state
406 */
407 if ( llc_data->irx->last_ns == NS_EQUAL_VR )
408 {
409 sig_irx_itx_send_rr_req (req);
410 }
411 else if ( llc_data->irx->last_ns == NS_EQUAL_VR_PLUS_1 )
412 {
413 sig_irx_itx_send_ack_req (req);
414 }
415 else
416 {
417 T_SACK_BITMAP bitmap;
418
419 irx_build_sack_bitmap( &bitmap );
420 sig_irx_itx_send_sack_req (req, &bitmap);
421 }
422 /* SET_STATE (IRX, SAME_STATE); */
423 break;
424
425
426 case IRX_ABM_BUSY:
427 /*
428 * The appropriate S frame in state busy anytime is an RNR
429 */
430 sig_irx_itx_send_rnr_req (req);
431 /* SET_STATE (IRX, SAME_STATE); */
432 break;
433
434 default:
435 TRACE_ERROR( "SIG_ITX_IRX_S_FRAME_REQ unexpected" );
436 break;
437 }
438 } /* sig_itx_irx_s_frame_req() */
439
440