FreeCalypso > hg > fc-magnetite
comparison src/g23m-gprs/llc/llc_uirxs.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 (UIRX-statemachine) | |
20 +----------------------------------------------------------------------------- | |
21 */ | |
22 | |
23 #ifndef LLC_UIRXS_C | |
24 #define LLC_UIRXS_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_uirxf.h" /* to get local UIRX functions */ | |
42 | |
43 /*==== CONST ================================================================*/ | |
44 | |
45 /*==== LOCAL VARS ===========================================================*/ | |
46 | |
47 /*==== PRIVATE FUNCTIONS ====================================================*/ | |
48 | |
49 /*==== PUBLIC FUNCTIONS =====================================================*/ | |
50 | |
51 | |
52 | |
53 /* | |
54 +------------------------------------------------------------------------------ | |
55 | Function : sig_llme_uirx_assign_req | |
56 +------------------------------------------------------------------------------ | |
57 | Description : Handles the internal signal SIG_LLME_UIRX_ASSIGN_REQ | |
58 | | |
59 | Parameters : | |
60 | | |
61 +------------------------------------------------------------------------------ | |
62 */ | |
63 #ifndef CF_FAST_EXEC | |
64 | |
65 GLOBAL void sig_llme_uirx_assign_req (void) | |
66 { | |
67 TRACE_ISIG( "sig_llme_uirx_assign_req" ); | |
68 | |
69 switch (GET_STATE(UIRX)) | |
70 { | |
71 case UIRX_TLLI_UNASSIGNED_NOT_READY: | |
72 SET_STATE (UIRX, UIRX_ADM_NOT_READY); | |
73 /* | |
74 * Initialise current incarnation. | |
75 */ | |
76 uirx_init_sapi(); | |
77 break; | |
78 case UIRX_TLLI_UNASSIGNED_READY: | |
79 SET_STATE (UIRX, UIRX_ADM_READY); | |
80 /* | |
81 * Initialise current incarnation. | |
82 */ | |
83 uirx_init_sapi(); | |
84 break; | |
85 default: | |
86 TRACE_ERROR( "SIG_LLME_UIRX_ASSIGN_REQ unexpected" ); | |
87 break; | |
88 } | |
89 } /* sig_llme_uirx_assign_req() */ | |
90 | |
91 #endif /* CF_FAST_EXEC */ | |
92 | |
93 /* | |
94 +------------------------------------------------------------------------------ | |
95 | Function : sig_llme_uirx_unassign_req | |
96 +------------------------------------------------------------------------------ | |
97 | Description : Handles the internal signal SIG_LLME_UIRX_UNASSIGN_REQ | |
98 | | |
99 | Parameters : | |
100 | | |
101 +------------------------------------------------------------------------------ | |
102 */ | |
103 #ifndef CF_FAST_EXEC | |
104 | |
105 GLOBAL void sig_llme_uirx_unassign_req (void) | |
106 { | |
107 TRACE_ISIG( "sig_llme_uirx_unassign_req" ); | |
108 | |
109 switch (GET_STATE(UIRX)) | |
110 { | |
111 case UIRX_ADM_NOT_READY: | |
112 SET_STATE (UIRX, UIRX_TLLI_UNASSIGNED_NOT_READY); | |
113 break; | |
114 case UIRX_ADM_READY: | |
115 SET_STATE (UIRX, UIRX_TLLI_UNASSIGNED_READY); | |
116 break; | |
117 default: | |
118 TRACE_ERROR( "SIG_LLME_UIRX_UNASSIGN_REQ unexpected" ); | |
119 break; | |
120 } | |
121 } /* sig_llme_uirx_unassign_req() */ | |
122 | |
123 #endif /* CF_FAST_EXEC */ | |
124 | |
125 | |
126 /* | |
127 +------------------------------------------------------------------------------ | |
128 | Function : sig_llme_uirx_reset_req | |
129 +------------------------------------------------------------------------------ | |
130 | Description : Handles the internal signal SIG_LLME_UIRX_RESET_REQ | |
131 | | |
132 | Parameters : | |
133 | | |
134 +------------------------------------------------------------------------------ | |
135 */ | |
136 #ifndef CF_FAST_EXEC | |
137 | |
138 GLOBAL void sig_llme_uirx_reset_req (void) | |
139 { | |
140 TRACE_ISIG( "sig_llme_uirx_reset_req" ); | |
141 | |
142 switch (GET_STATE(UIRX)) | |
143 { | |
144 case UIRX_TLLI_UNASSIGNED_NOT_READY: | |
145 /* | |
146 * No break! | |
147 */ | |
148 case UIRX_TLLI_UNASSIGNED_READY: | |
149 /* | |
150 * No break! | |
151 */ | |
152 case UIRX_ADM_NOT_READY: | |
153 /* | |
154 * No break! | |
155 */ | |
156 case UIRX_ADM_READY: | |
157 /* | |
158 * Only use this procedure as long as it initalises only the requested | |
159 * variables on reset (V(UR) as of V6.4.0). | |
160 */ | |
161 uirx_init_sapi(); | |
162 break; | |
163 default: | |
164 TRACE_ERROR( "SIG_LLME_UIRX_RESET_REQ unexpected" ); | |
165 break; | |
166 } | |
167 } /* sig_llme_uirx_reset_req() */ | |
168 | |
169 #endif /* CF_FAST_EXEC */ | |
170 | |
171 | |
172 | |
173 /* | |
174 +------------------------------------------------------------------------------ | |
175 | Function : sig_rx_uirx_data_ind | |
176 +------------------------------------------------------------------------------ | |
177 | Description : Handles the internal signal SIG_RX_UIRX_DATA_IND | |
178 | | |
179 | Parameters : ll_unitdata_ind - a valid pointer to an LL-UNITDATA-IND | |
180 | primitive | |
181 | nu - N(U) of the received UI frame | |
182 | | |
183 +------------------------------------------------------------------------------ | |
184 */ | |
185 /*#if defined(CF_FAST_EXEC) || defined(_SIMULATION_) || \ | |
186 !defined(REL99) || defined(LL_2to1) */ | |
187 | |
188 GLOBAL void sig_rx_uirx_data_ind (T_LL_UNITDATA_IND *ll_unitdata_ind, | |
189 T_FRAME_NUM nu) | |
190 { | |
191 USHORT diff; | |
192 | |
193 TRACE_ISIG( "sig_rx_uirx_data_ind" ); | |
194 | |
195 /* | |
196 * SAPI has already been checked by service RX. | |
197 */ | |
198 | |
199 switch (GET_STATE(UIRX)) | |
200 { | |
201 case UIRX_ADM_NOT_READY: | |
202 /* | |
203 * Calculate relative difference of V(UR) and N(U): add 512 to V(UR), | |
204 * subtract N(U), apply modulo 512 to get back into the valid range | |
205 */ | |
206 diff = (((llc_data->sapi->vur + | |
207 (MAX_SEQUENCE_NUMBER+1)) - nu) % (MAX_SEQUENCE_NUMBER+1)); | |
208 | |
209 /* | |
210 * Original formula: | |
211 * V(UR)-32 <= N(U) < V(UR) | |
212 * Translated: | |
213 * the relative difference must be maximally 32, and minimally 1 | |
214 */ | |
215 if ((diff > 0) AND (diff <= 32)) | |
216 { | |
217 /* | |
218 * We've got an retranmitted frame. Check if we got it already. | |
219 */ | |
220 if (uirx_check_nu (nu, llc_data->sapi->vur) == TRUE) | |
221 { | |
222 /* | |
223 * N(U) already received. Discard frame without any futher action. | |
224 */ | |
225 PFREE (ll_unitdata_ind); | |
226 TRACE_0_INFO("Duplicate frame number ignored"); | |
227 return; | |
228 } | |
229 } | |
230 else | |
231 { | |
232 /* | |
233 * We've got a new, not retransmitted, frame. Set V(UR) to the new value. | |
234 */ | |
235 uirx_set_new_vur ((T_FRAME_NUM)(nu + 1)); | |
236 } | |
237 | |
238 /* | |
239 * Store the N(U) of the frame to be already received. | |
240 */ | |
241 uirx_store_nu (nu, llc_data->sapi->vur); | |
242 | |
243 /* | |
244 * We are not ready to send data. Store frame in UIRX queue, | |
245 * if possible. | |
246 */ | |
247 uirx_queue_store (ll_unitdata_ind); | |
248 break; | |
249 | |
250 case UIRX_ADM_READY: | |
251 /* | |
252 * Calculate relative difference of V(UR) and N(U): add 512 to V(UR), | |
253 * subtract N(U), apply modulo 512 to get back into the valid range | |
254 */ | |
255 diff = (((llc_data->sapi->vur + | |
256 (MAX_SEQUENCE_NUMBER+1)) - nu) % (MAX_SEQUENCE_NUMBER+1)); | |
257 | |
258 /* | |
259 * Original formula: | |
260 * V(UR)-32 <= N(U) < V(UR) | |
261 * Translated: | |
262 * the relative difference must be maximally 32, and minimally 1 | |
263 */ | |
264 if ((diff > 0) AND (diff <= 32)) | |
265 { | |
266 /* | |
267 * We've got an retranmitted frame. Check if we got it already. | |
268 */ | |
269 if (uirx_check_nu (nu, llc_data->sapi->vur) == TRUE) | |
270 { | |
271 /* | |
272 * N(U) already received. Discard frame without any futher action. | |
273 */ | |
274 PFREE (ll_unitdata_ind); | |
275 TRACE_0_INFO("Duplicated frame number ignored"); | |
276 return; | |
277 } | |
278 } | |
279 else | |
280 { | |
281 /* | |
282 * We've got a new, not retransmitted, frame. Set V(UR) to the new value. | |
283 */ | |
284 uirx_set_new_vur ((T_FRAME_NUM)(nu + 1)); | |
285 } | |
286 | |
287 /* | |
288 * Store the N(U) of the frame to be already received. | |
289 */ | |
290 uirx_store_nu (nu, llc_data->sapi->vur); | |
291 | |
292 /* | |
293 * Label S_UNITDATA | |
294 */ | |
295 | |
296 /* | |
297 * No flow control for SAPI 1. | |
298 */ | |
299 if (llc_data->current_sapi != LL_SAPI_1) | |
300 { | |
301 /* | |
302 * Transit to state ADM_NOT_READY. | |
303 */ | |
304 SET_STATE (UIRX, UIRX_ADM_NOT_READY); | |
305 } | |
306 | |
307 /* | |
308 * Send primitive LL-UNITDATA-IND to either GMM, SNDCP, or GSMS, | |
309 * depending on the SAPI. | |
310 */ | |
311 switch (ll_unitdata_ind->sapi) | |
312 { | |
313 case LL_SAPI_1: | |
314 TRACE_PRIM_TO("GMM"); | |
315 TRACE_3_OUT_PARA("s:%d len:%d c:%d", ll_unitdata_ind->sapi, | |
316 BYTELEN(ll_unitdata_ind->sdu.l_buf), | |
317 ll_unitdata_ind->cipher); | |
318 PSEND (hCommGMM, ll_unitdata_ind); | |
319 break; | |
320 | |
321 case LL_SAPI_3: | |
322 case LL_SAPI_5: | |
323 case LL_SAPI_9: | |
324 case LL_SAPI_11: | |
325 TRACE_3_OUT_PARA("s:%d len:%d c:%d", ll_unitdata_ind->sapi, | |
326 BYTELEN(ll_unitdata_ind->sdu.l_buf), | |
327 ll_unitdata_ind->cipher); | |
328 PSEND (hCommSNDCP, ll_unitdata_ind); | |
329 break; | |
330 | |
331 case LL_SAPI_7: | |
332 #ifdef LL_2to1 | |
333 TRACE_PRIM_TO("MM"); | |
334 TRACE_3_OUT_PARA("s:%d len:%d c:%d", ll_unitdata_ind->sapi, | |
335 BYTELEN(ll_unitdata_ind->sdu.l_buf), | |
336 ll_unitdata_ind->cipher); | |
337 PSEND (hCommMM, ll_unitdata_ind); | |
338 #else | |
339 TRACE_PRIM_TO("GSMS"); | |
340 TRACE_3_OUT_PARA("s:%d len:%d c:%d", ll_unitdata_ind->sapi, | |
341 BYTELEN(ll_unitdata_ind->sdu.l_buf), | |
342 ll_unitdata_ind->cipher); | |
343 PSEND (hCommGSMS, ll_unitdata_ind); | |
344 #endif | |
345 break; | |
346 | |
347 default: | |
348 PFREE (ll_unitdata_ind); | |
349 TRACE_ERROR ("invalid global SAPI value"); | |
350 break; | |
351 } | |
352 break; | |
353 | |
354 default: | |
355 PFREE (ll_unitdata_ind); | |
356 TRACE_ERROR( "SIG_RX_UIRX_DATA_IND unexpected" ); | |
357 break; | |
358 } | |
359 } /* sig_rx_uirx_data_ind() */ | |
360 | |
361 /*#endif */ /* CF_FAST_EXEC || _SIMULATION_ */ | |
362 | |
363 |