FreeCalypso > hg > fc-magnetite
comparison src/g23m-gprs/sndcp/sndcp_suas.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 : GPRS (8441) | |
4 | Modul : sndcp_suas.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 is part of the entity SNDCP and implements all | |
18 | functions to handles the incoming process internal signals as | |
19 | described in the SDL-documentation (SUA-statemachine) | |
20 +----------------------------------------------------------------------------- | |
21 */ | |
22 | |
23 | |
24 #define ENTITY_SNDCP | |
25 | |
26 /*==== INCLUDES =============================================================*/ | |
27 | |
28 #include "typedefs.h" /* to get Condat data types */ | |
29 #include "vsi.h" /* to get a lot of macros */ | |
30 #include "macdef.h" | |
31 #include "gsm.h" /* to get a lot of macros */ | |
32 #include "prim.h" /* to get the definitions of used SAP and directions */ | |
33 #include <string.h> /* to get memcpy() */ | |
34 #include "dti.h" | |
35 #include "sndcp.h" /* to get the global entity definitions */ | |
36 #include "sndcp_f.h" /* to get the functions to access the global arrays*/ | |
37 #include "sndcp_suaf.h" /* to get internal functions of service sua */ | |
38 #include "sndcp_nus.h" /* to get signal functions to service nu */ | |
39 #include "sndcp_cias.h" /* to get signal functions to service cia */ | |
40 | |
41 /*==== CONST ================================================================*/ | |
42 | |
43 /*==== LOCAL VARS ===========================================================*/ | |
44 | |
45 /*==== PRIVATE FUNCTIONS ====================================================*/ | |
46 #ifdef _SNDCP_DTI_2_ | |
47 /* | |
48 +------------------------------------------------------------------------------ | |
49 | Function : sua_add_ll_desc_req_params | |
50 +------------------------------------------------------------------------------ | |
51 | Description : sets the parameters of the given ll_desc_req | |
52 | | |
53 | Parameters : pdu_ref, ll_desc_req* | |
54 | | |
55 +------------------------------------------------------------------------------ | |
56 */ | |
57 LOCAL void sua_add_ll_desc_req_params (T_pdu_ref pdu_ref, | |
58 T_LL_DESC_REQ* ll_desc_req) | |
59 { | |
60 T_snsm_qos snsm_qos; /* initialized later with getter */ | |
61 | |
62 TRACE_FUNCTION( "sua_add_ll_desc_req_params" ); | |
63 | |
64 /* | |
65 * Set quality of service. | |
66 */ | |
67 sndcp_get_nsapi_qos(pdu_ref.ref_nsapi, &snsm_qos); | |
68 sndcp_snsm_qos_to_ll_qos(snsm_qos, &ll_desc_req->ll_qos); | |
69 /* | |
70 * Set radio prio. | |
71 */ | |
72 sndcp_get_nsapi_prio(pdu_ref.ref_nsapi, | |
73 &ll_desc_req->radio_prio); | |
74 #ifdef REL99 | |
75 sndcp_get_nsapi_pktflowid(pdu_ref.ref_nsapi, | |
76 (U16 *)&ll_desc_req->pkt_flow_id); | |
77 #endif /*REL99*/ | |
78 /* | |
79 * Set pdu_ref. | |
80 */ | |
81 ll_desc_req->reference1.ref_nsapi = pdu_ref.ref_nsapi; | |
82 ll_desc_req->reference1.ref_npdu_num = (UBYTE)pdu_ref.ref_npdu_num; | |
83 ll_desc_req->reference1.ref_seg_num = pdu_ref.ref_seg_num; | |
84 | |
85 } /* sua_add_ll_desc_req_params() */ | |
86 #else /* _SNDCP_DTI_2_ */ | |
87 /* | |
88 +------------------------------------------------------------------------------ | |
89 | Function : sua_add_ll_data_req_params | |
90 +------------------------------------------------------------------------------ | |
91 | Description : sets the parameters of the given ll_data_req | |
92 | | |
93 | Parameters : pdu_ref, ll_data_req* | |
94 | | |
95 +------------------------------------------------------------------------------ | |
96 */ | |
97 LOCAL void sua_add_ll_data_req_params (T_pdu_ref pdu_ref, | |
98 T_LL_DATA_REQ* ll_data_req) | |
99 { | |
100 T_snsm_qos snsm_qos; /* initialized later with getter */ | |
101 | |
102 TRACE_FUNCTION( "sua_add_ll_data_req_params" ); | |
103 | |
104 /* | |
105 * Set quality of service. | |
106 */ | |
107 sndcp_get_nsapi_qos(pdu_ref.ref_nsapi, &snsm_qos); | |
108 sndcp_snsm_qos_to_ll_qos(snsm_qos, &ll_data_req->ll_qos); | |
109 /* | |
110 * Set radio prio. | |
111 */ | |
112 sndcp_get_nsapi_prio(pdu_ref.ref_nsapi, | |
113 &ll_data_req->radio_prio); | |
114 #ifdef REL99 | |
115 sndcp_get_nsapi_pktflowid(pdu_ref.ref_nsapi, | |
116 &ll_data_req->pkt_flow_id); | |
117 #endif /*REL99*/ | |
118 | |
119 /* | |
120 * Set pdu_ref. | |
121 */ | |
122 ll_data_req->reference1.ref_nsapi = pdu_ref.ref_nsapi; | |
123 ll_data_req->reference1.ref_npdu_num = (UBYTE)pdu_ref.ref_npdu_num; | |
124 ll_data_req->reference1.ref_seg_num = pdu_ref.ref_seg_num; | |
125 | |
126 } /* sua_add_ll_data_req_params() */ | |
127 #endif /* _SNDCP_DTI_2_ */ | |
128 #ifdef _SNDCP_DTI_2_ | |
129 /* | |
130 +------------------------------------------------------------------------------ | |
131 | Function : sua_add_sn_header | |
132 +------------------------------------------------------------------------------ | |
133 | Description : sets the segment header in the given ll_desc_req | |
134 | | |
135 | Parameters : first and/or last segment , ll_desc_req*, packet type. | |
136 | | |
137 +------------------------------------------------------------------------------ | |
138 */ | |
139 LOCAL void sua_add_sn_header (U8 seg_pos, | |
140 T_pdu_ref pdu_ref, | |
141 T_LL_DESC_REQ* ll_desc_req, | |
142 U8 packet_type) | |
143 { | |
144 USHORT offset = ENCODE_OFFSET_BYTE; | |
145 BOOL compressed = FALSE; | |
146 T_desc3* desc3 = NULL; | |
147 U8* sndcp_header = NULL; | |
148 U8 sapi_index = 0; | |
149 | |
150 TRACE_FUNCTION( "sua_add_sn_header" ); | |
151 | |
152 /* Get the descriptor describing the memory area with the sndcp header */ | |
153 desc3 = (T_desc3*)ll_desc_req->desc_list3.first; | |
154 sndcp_header = (U8*)desc3->buffer; | |
155 sndcp_header[offset] = 0; | |
156 | |
157 sndcp_get_sapi_index(ll_desc_req->sapi, &sapi_index); | |
158 /* | |
159 * Octet 1, F bit. | |
160 */ | |
161 if ((seg_pos & SEG_POS_FIRST) > 0) | |
162 { | |
163 sndcp_header[offset] += (1 << 6); | |
164 } | |
165 /* | |
166 * Octet 1, 0 for SN_DATA, i.e. nothing. | |
167 */ | |
168 | |
169 /* | |
170 * Octet 1, M bit. | |
171 */ | |
172 if ((seg_pos & SEG_POS_LAST) == 0) | |
173 { | |
174 sndcp_header[offset] += (1 << 4); | |
175 } | |
176 /* | |
177 * Octet 1, NSAPI number. | |
178 */ | |
179 sndcp_header[offset] += pdu_ref.ref_nsapi; | |
180 | |
181 offset ++; | |
182 if ((seg_pos & SEG_POS_FIRST) > 0) | |
183 { | |
184 sndcp_header[offset] = 0; | |
185 /* | |
186 * This is the first bit. | |
187 * Find d/pcomp values and set them. | |
188 */ | |
189 /* | |
190 * Octet 2, dcomp | |
191 */ | |
192 sndcp_header[offset] += | |
193 (U8)(sndcp_data->mg.cur_xid_block[sapi_index].v42.dcomp << 4); | |
194 /* | |
195 * Octet 2, pcomp | |
196 */ | |
197 sndcp_is_nsapi_header_compressed(pdu_ref.ref_nsapi, &compressed); | |
198 if (compressed) { | |
199 if (packet_type == TYPE_UNCOMPRESSED_TCP) | |
200 { | |
201 /* | |
202 * Uncompressed TCP. | |
203 */ | |
204 sndcp_header[offset] = | |
205 sndcp_data->mg.cur_xid_block[sapi_index].vj.pcomp1; | |
206 } | |
207 else if (packet_type == TYPE_IP) | |
208 { | |
209 /* | |
210 * IP. | |
211 */ | |
212 sndcp_header[offset] = 0; | |
213 } | |
214 else | |
215 { | |
216 /* | |
217 * Compressed TCP. | |
218 */ | |
219 sndcp_header[offset] = | |
220 sndcp_data->mg.cur_xid_block[sapi_index].vj.pcomp2; | |
221 } | |
222 } | |
223 | |
224 offset ++; | |
225 } | |
226 | |
227 /* | |
228 * Octet 3, N-PDU number, if F bit set to 1. | |
229 */ | |
230 if ((seg_pos & SEG_POS_FIRST) > 0) | |
231 { | |
232 sndcp_header[offset] = (U8)pdu_ref.ref_npdu_num; | |
233 } | |
234 | |
235 | |
236 } /* sua_add_sn_header() */ | |
237 #else /* _SNDCP_DTI_2_ */ | |
238 /* | |
239 +------------------------------------------------------------------------------ | |
240 | Function : sua_add_sn_header | |
241 +------------------------------------------------------------------------------ | |
242 | Description : sets the segment header in the given ll_data_req | |
243 | | |
244 | Parameters : first and/or last segment , ll_data_req*, packet type. | |
245 | | |
246 +------------------------------------------------------------------------------ | |
247 */ | |
248 LOCAL void sua_add_sn_header (UBYTE seg_pos, | |
249 T_pdu_ref pdu_ref, | |
250 T_LL_DATA_REQ* ll_data_req, | |
251 UBYTE packet_type) | |
252 { | |
253 USHORT offset = ll_data_req->sdu.o_buf / 8; | |
254 BOOL compressed = FALSE; | |
255 | |
256 TRACE_FUNCTION( "sua_add_sn_header" ); | |
257 | |
258 ll_data_req->sdu.buf[offset] = 0; | |
259 /* | |
260 * Octet 1, F bit. | |
261 */ | |
262 if ((seg_pos & SEG_POS_FIRST) > 0) { | |
263 ll_data_req->sdu.buf[offset] += (1 << 6); | |
264 } | |
265 /* | |
266 * Octet 1, 0 for SN_DATA, i.e. nothing. | |
267 */ | |
268 | |
269 /* | |
270 * Octet 1, M bit. | |
271 */ | |
272 if ((seg_pos & SEG_POS_LAST) == 0) { | |
273 ll_data_req->sdu.buf[offset] += (1 << 4); | |
274 } | |
275 /* | |
276 * Octet 1, NSAPI number. | |
277 */ | |
278 ll_data_req->sdu.buf[offset] += pdu_ref.ref_nsapi; | |
279 | |
280 offset ++; | |
281 if ((seg_pos & SEG_POS_FIRST) > 0) { | |
282 ll_data_req->sdu.buf[offset] = 0; | |
283 /* | |
284 * This is the first bit. | |
285 * Find d/pcomp values and set them. | |
286 */ | |
287 /* | |
288 * Octet 2, dcomp | |
289 */ | |
290 ll_data_req->sdu.buf[offset] += | |
291 (UBYTE)(sndcp_data->su->cur_xid_block.v42.dcomp << 4); | |
292 /* | |
293 * Octet 2, pcomp | |
294 */ | |
295 sndcp_is_nsapi_header_compressed(pdu_ref.ref_nsapi, &compressed); | |
296 if (compressed) { | |
297 if (packet_type == TYPE_UNCOMPRESSED_TCP) { | |
298 /* | |
299 * Uncompressed TCP. | |
300 */ | |
301 ll_data_req->sdu.buf[offset] = | |
302 sndcp_data->sua->cur_xid_block.vj.pcomp1; | |
303 } else if (packet_type == TYPE_IP) { | |
304 /* | |
305 * IP. | |
306 */ | |
307 ll_data_req->sdu.buf[offset] = 0; | |
308 } else { | |
309 /* | |
310 * Compressed TCP. | |
311 */ | |
312 ll_data_req->sdu.buf[offset] = | |
313 sndcp_data->sua->cur_xid_block.vj.pcomp2; | |
314 } | |
315 } | |
316 | |
317 offset ++; | |
318 } | |
319 | |
320 /* | |
321 * Octet 3, N-PDU number, if F bit set to 1. | |
322 */ | |
323 if ((seg_pos & SEG_POS_FIRST) > 0) { | |
324 ll_data_req->sdu.buf[offset] = (UBYTE)pdu_ref.ref_npdu_num; | |
325 } | |
326 | |
327 | |
328 } /* sua_add_sn_header() */ | |
329 #endif /* _SNDCP_DTI_2_ */ | |
330 | |
331 /*==== PUBLIC FUNCTIONS =====================================================*/ | |
332 #ifdef _SNDCP_DTI_2_ | |
333 /* | |
334 +------------------------------------------------------------------------------ | |
335 | Function : sig_cia_sua_cia_comp_ind | |
336 +------------------------------------------------------------------------------ | |
337 | Description : Handles the internal signal SIG_CIA_SUA_CIA_COMP_IND | |
338 | | |
339 | Parameters : cia_comp_ind* | |
340 | | |
341 +------------------------------------------------------------------------------ | |
342 */ | |
343 GLOBAL void sig_cia_sua_cia_comp_ind (T_CIA_COMP_IND* cia_comp_ind) | |
344 { | |
345 U8 sapi_index = 0; | |
346 | |
347 TRACE_ISIG( "sig_cia_cia_sua_comp_ind" ); | |
348 | |
349 /* | |
350 * Set service instance according to sapi in signal. | |
351 */ | |
352 sndcp_get_sapi_index(cia_comp_ind->sapi, &sapi_index); | |
353 sndcp_data->sua = & sndcp_data->sua_base[sapi_index]; | |
354 /* | |
355 * Mark segment as transmitted for later acknowledgement. | |
356 */ | |
357 sua_mark_segment((U8)cia_comp_ind->pdu_ref.ref_npdu_num, | |
358 cia_comp_ind->pdu_ref.ref_nsapi); | |
359 | |
360 switch( GET_STATE( SUA ) ) | |
361 { | |
362 case SUA_LLC_RECEPTIVE_SUSPEND: | |
363 case SUA_LLC_NOT_RECEPTIVE: | |
364 case SUA_LLC_NOT_RECEPTIVE_SUSPEND: | |
365 { | |
366 | |
367 /* | |
368 * Save seg_pos and pdu_ref from cia_comp_ind. | |
369 */ | |
370 U8 seg_pos = cia_comp_ind->seg_pos; | |
371 T_pdu_ref pdu_ref = cia_comp_ind->pdu_ref; | |
372 | |
373 PALLOC(ll_desc_req, LL_DESC_REQ); | |
374 ll_desc_req->sapi = cia_comp_ind->sapi; | |
375 ll_desc_req->tlli = cia_comp_ind->tlli; | |
376 /* Single parameter copy qos needed due to different SAPs */ | |
377 ll_desc_req->ll_qos.delay = cia_comp_ind->cia_qos.delay; | |
378 ll_desc_req->ll_qos.relclass = cia_comp_ind->cia_qos.relclass; | |
379 ll_desc_req->ll_qos.peak = cia_comp_ind->cia_qos.peak; | |
380 ll_desc_req->ll_qos.preced = cia_comp_ind->cia_qos.preced; | |
381 ll_desc_req->ll_qos.mean = cia_comp_ind->cia_qos.mean; | |
382 /* radio_prio not defined, handled in separate function later */ | |
383 ll_desc_req->reserved_data_req1 = cia_comp_ind->comp_inst; | |
384 ll_desc_req->reference1.ref_nsapi = cia_comp_ind->pdu_ref.ref_nsapi; | |
385 ll_desc_req->reference1.ref_npdu_num = cia_comp_ind->pdu_ref.ref_npdu_num; | |
386 ll_desc_req->reference1.ref_seg_num = cia_comp_ind->pdu_ref.ref_seg_num; | |
387 ll_desc_req->seg_pos = cia_comp_ind->seg_pos; | |
388 /* attached_counter not copied */ | |
389 /* cipher not copied */ | |
390 ll_desc_req->desc_list3.list_len = cia_comp_ind->desc_list3.list_len; | |
391 ll_desc_req->desc_list3.first = cia_comp_ind->desc_list3.first; | |
392 | |
393 sua_add_ll_desc_req_params(cia_comp_ind->pdu_ref, | |
394 ll_desc_req); | |
395 sua_add_sn_header(seg_pos, pdu_ref, ll_desc_req, cia_comp_ind->packet_type); | |
396 | |
397 /* All information has been transferred remove the compression primitive */ | |
398 MFREE(cia_comp_ind); | |
399 | |
400 /* | |
401 * Write the ll_desc_req prim to ll_desc_q, | |
402 * increment write pointer. | |
403 */ | |
404 sndcp_data->sua->ll_desc_q[sndcp_data->sua->ll_desc_q_write] = | |
405 ll_desc_req; | |
406 sndcp_data->sua->ll_desc_q_write = | |
407 (sndcp_data->sua->ll_desc_q_write + 1) % SNDCP_SEGMENT_NUMBERS_ACK; | |
408 } | |
409 break; | |
410 case SUA_LLC_RECEPTIVE: | |
411 { | |
412 /* | |
413 * Save seg_pos and pdu_ref from cia_comp_ind. | |
414 */ | |
415 U8 ll_desc_seg_pos; | |
416 U8 ll_desc_nsapi; | |
417 U8 ll_desc_sapi; | |
418 | |
419 U8 seg_pos = cia_comp_ind->seg_pos; | |
420 T_pdu_ref pdu_ref = cia_comp_ind->pdu_ref; | |
421 | |
422 PALLOC(ll_desc_req, LL_DESC_REQ); | |
423 ll_desc_req->sapi = cia_comp_ind->sapi; | |
424 ll_desc_req->tlli = cia_comp_ind->tlli; | |
425 ll_desc_req->ll_qos.delay = cia_comp_ind->cia_qos.delay; | |
426 ll_desc_req->ll_qos.relclass = cia_comp_ind->cia_qos.relclass; | |
427 ll_desc_req->ll_qos.peak = cia_comp_ind->cia_qos.peak; | |
428 ll_desc_req->ll_qos.preced = cia_comp_ind->cia_qos.preced; | |
429 ll_desc_req->ll_qos.mean = cia_comp_ind->cia_qos.mean; | |
430 /* radio_prio not defined, handled in separate function later */ | |
431 ll_desc_req->reserved_data_req1 = cia_comp_ind->comp_inst; | |
432 ll_desc_req->reference1.ref_nsapi = cia_comp_ind->pdu_ref.ref_nsapi; | |
433 ll_desc_req->reference1.ref_npdu_num = cia_comp_ind->pdu_ref.ref_npdu_num; | |
434 ll_desc_req->reference1.ref_seg_num = cia_comp_ind->pdu_ref.ref_seg_num; | |
435 ll_desc_req->seg_pos = cia_comp_ind->seg_pos; | |
436 /* attached_counter not copied */ | |
437 /* cipher not copied */ | |
438 ll_desc_req->desc_list3.list_len = cia_comp_ind->desc_list3.list_len; | |
439 ll_desc_req->desc_list3.first = cia_comp_ind->desc_list3.first; | |
440 | |
441 sua_add_ll_desc_req_params(cia_comp_ind->pdu_ref, | |
442 ll_desc_req); | |
443 sua_add_sn_header(seg_pos, pdu_ref, ll_desc_req, cia_comp_ind->packet_type); | |
444 | |
445 /* All information has been transferred remove the compression primitive */ | |
446 MFREE(cia_comp_ind); | |
447 | |
448 ll_desc_seg_pos = ll_desc_req->seg_pos; | |
449 ll_desc_sapi = ll_desc_req->sapi; | |
450 ll_desc_nsapi = sua_get_nsapi(ll_desc_req); | |
451 | |
452 #ifdef _SIMULATION_ | |
453 | |
454 #ifndef MULTI_LAYER | |
455 su_send_ll_data_req_test(ll_desc_req); | |
456 #else | |
457 PSEND(hCommLLC, ll_desc_req); | |
458 #endif /* MULTI_LAYER */ | |
459 #else /* _SIMULATION_ */ | |
460 PSEND(hCommLLC, ll_desc_req); | |
461 #endif /* _SIMULATION_ */ | |
462 | |
463 SET_STATE(SUA, SUA_LLC_NOT_RECEPTIVE); | |
464 | |
465 if ((ll_desc_seg_pos & SEG_POS_LAST) > 0) { | |
466 sig_sua_nu_ready_ind( ll_desc_nsapi ); | |
467 sua_next_sn_data_req( ll_desc_sapi ); | |
468 sndcp_data->sua->cia_state = CIA_IDLE; | |
469 } | |
470 } | |
471 break; | |
472 default: | |
473 TRACE_ERROR( "SIG_CIA_SUA_CIA_COMP_IND unexpected" ); | |
474 sndcp_cl_desc3_free((T_desc3 *)cia_comp_ind->desc_list3.first); | |
475 MFREE(cia_comp_ind); | |
476 break; | |
477 } | |
478 } /* sig_cia_sua_cia_comp_ind() */ | |
479 #else /* _SNDCP_DTI_2_ */ | |
480 /* | |
481 +------------------------------------------------------------------------------ | |
482 | Function : sig_cia_sua_cia_comp_ind | |
483 +------------------------------------------------------------------------------ | |
484 | Description : Handles the internal signal SIG_CIA_SUA_CIA_COMP_IND | |
485 | | |
486 | Parameters : cia_comp_ind* | |
487 | | |
488 +------------------------------------------------------------------------------ | |
489 */ | |
490 GLOBAL void sig_cia_sua_cia_comp_ind (T_CIA_COMP_IND* cia_comp_ind) | |
491 { | |
492 UBYTE sapi_index = 0; | |
493 | |
494 TRACE_ISIG( "sig_cia_cia_sua_comp_ind" ); | |
495 | |
496 /* | |
497 * Set service instance according to sapi in signal. | |
498 */ | |
499 sndcp_get_sapi_index(cia_comp_ind->sapi, &sapi_index); | |
500 sndcp_data->sua = & sndcp_data->sua_base[sapi_index]; | |
501 /* | |
502 * Mark segment as transmitted for later acknowledgement. | |
503 */ | |
504 sua_mark_segment((UBYTE)cia_comp_ind->pdu_ref.ref_npdu_num, | |
505 cia_comp_ind->pdu_ref.ref_nsapi); | |
506 | |
507 switch( GET_STATE( SUA ) ) | |
508 { | |
509 case SUA_LLC_RECEPTIVE_SUSPEND: | |
510 case SUA_LLC_NOT_RECEPTIVE: | |
511 case SUA_LLC_NOT_RECEPTIVE_SUSPEND: | |
512 { | |
513 | |
514 /* | |
515 * Save seg_pos and pdu_ref from cia_comp_ind. | |
516 */ | |
517 UBYTE seg_pos = cia_comp_ind->seg_pos; | |
518 T_pdu_ref pdu_ref = cia_comp_ind->pdu_ref; | |
519 | |
520 PPASS(cia_comp_ind, ll_data_req, LL_DATA_REQ); | |
521 | |
522 sua_add_ll_data_req_params(cia_comp_ind->pdu_ref, | |
523 ll_data_req); | |
524 sua_add_sn_header(seg_pos, pdu_ref, ll_data_req, cia_comp_ind->packet_type); | |
525 /* | |
526 * Write the ll_data_req prim to ll_data_q, | |
527 * increment write pointer. | |
528 */ | |
529 sndcp_data->sua->ll_data_q[sndcp_data->sua->ll_data_q_write] = | |
530 ll_data_req; | |
531 sndcp_data->sua->ll_data_q_write = | |
532 (sndcp_data->sua->ll_data_q_write + 1) % SNDCP_SEGMENT_NUMBERS_ACK; | |
533 } | |
534 break; | |
535 case SUA_LLC_RECEPTIVE: | |
536 { | |
537 /* | |
538 * Save seg_pos and pdu_ref from cia_comp_ind. | |
539 */ | |
540 UBYTE ll_data_seg_pos; | |
541 UBYTE ll_data_nsapi; | |
542 UBYTE ll_data_sapi; | |
543 | |
544 UBYTE seg_pos = cia_comp_ind->seg_pos; | |
545 T_pdu_ref pdu_ref = cia_comp_ind->pdu_ref; | |
546 | |
547 PPASS(cia_comp_ind, ll_data_req, LL_DATA_REQ); | |
548 | |
549 sua_add_ll_data_req_params(cia_comp_ind->pdu_ref, | |
550 ll_data_req); | |
551 sua_add_sn_header(seg_pos, pdu_ref, ll_data_req, cia_comp_ind->packet_type); | |
552 | |
553 ll_data_seg_pos = ll_data_req->seg_pos; | |
554 ll_data_sapi = ll_data_req->sapi; | |
555 ll_data_nsapi = sua_get_nsapi(ll_data_req); | |
556 | |
557 PSEND(hCommLLC, ll_data_req); | |
558 | |
559 SET_STATE(SUA, SUA_LLC_NOT_RECEPTIVE); | |
560 | |
561 if ((ll_data_seg_pos & SEG_POS_LAST) > 0) { | |
562 sig_sua_nu_ready_ind( ll_data_nsapi ); | |
563 sua_next_sn_data_req( ll_data_sapi ); | |
564 sndcp_data->sua->cia_state = CIA_IDLE; | |
565 } | |
566 } | |
567 break; | |
568 default: | |
569 TRACE_ERROR( "SIG_CIA_SUA_CIA_COMP_IND unexpected" ); | |
570 break; | |
571 } | |
572 } /* sig_cia_sua_cia_comp_ind() */ | |
573 #endif /* _SNDCP_DTI_2_ */ | |
574 /* | |
575 +------------------------------------------------------------------------------ | |
576 | Function : sig_mg_sua_delete_pdus | |
577 +------------------------------------------------------------------------------ | |
578 | Description : Handles the internal signal SIG_MG_SUA_DELETE_PDUS | |
579 | The same as the one in service su, but everything is in the | |
580 | acknowledged version here. | |
581 | cia_state is set to CIA_IDLE. | |
582 | | |
583 | Parameters : UBYTE nsapi the affected nsapi, UBYTE sapi the affected sapi, | |
584 | BOOL destroy defines if data pay load must be freed. | |
585 | | |
586 +------------------------------------------------------------------------------ | |
587 */ | |
588 GLOBAL void sig_mg_sua_delete_pdus (U8 nsapi, U8 sapi, BOOL destroy) | |
589 { | |
590 U8 sapi_index; | |
591 BOOL ll_q_affected = FALSE; | |
592 | |
593 TRACE_ISIG( "sig_mg_sua_delete_pdus" ); | |
594 | |
595 /* | |
596 * Set service instance according to sapi in signal. | |
597 */ | |
598 sndcp_get_sapi_index(sapi, &sapi_index); | |
599 sndcp_data->sua = & sndcp_data->sua_base[sapi_index]; | |
600 | |
601 sndcp_data->sua->cia_state = CIA_IDLE; | |
602 | |
603 switch( GET_STATE( SUA ) ) | |
604 { | |
605 case SUA_LLC_NOT_RECEPTIVE_SUSPEND: | |
606 case SUA_LLC_RECEPTIVE_SUSPEND: | |
607 case SUA_LLC_NOT_RECEPTIVE: | |
608 case SUA_LLC_RECEPTIVE: | |
609 { | |
610 /* | |
611 * Delete affected N-PDUS from sn_data_q. | |
612 */ | |
613 BOOL still = TRUE; | |
614 U8 index = sndcp_data->sua->sn_data_q_read; | |
615 | |
616 while (still) { | |
617 if (index == sndcp_data->sua->sn_data_q_write) { | |
618 break; | |
619 } | |
620 if (sndcp_data->sua->sn_data_q[index]->nsapi == nsapi) { | |
621 /* | |
622 * The index for the prims to be shifted when 1 entry is deleted. | |
623 */ | |
624 U8 i = 0; | |
625 if (destroy) { | |
626 #ifdef _SNDCP_DTI_2_ | |
627 MFREE_PRIM(sndcp_data->sua->sn_data_q[index]); | |
628 #else /*_SNDCP_DTI_2_*/ | |
629 PFREE_DESC(sndcp_data->sua->sn_data_q[index]); | |
630 #endif /*_SNDCP_DTI_2_*/ | |
631 } | |
632 sndcp_data->sua->sn_data_q[index] = NULL; | |
633 | |
634 for (i = index; | |
635 i != sndcp_data->sua->sn_data_q_write; | |
636 i = (i + 1) % SN_DATA_Q_LEN) { | |
637 | |
638 | |
639 sndcp_data->sua->sn_data_q[i] = | |
640 sndcp_data->sua->sn_data_q[(i + 1) % SN_DATA_Q_LEN]; | |
641 sndcp_data->sua->sn_data_q[(i + 1) % SN_DATA_Q_LEN] = NULL; | |
642 | |
643 } | |
644 sndcp_data->sua->sn_data_q_write = | |
645 (sndcp_data->sua->sn_data_q_write - 1 | |
646 + SN_DATA_Q_LEN) % SN_DATA_Q_LEN; | |
647 if (index == sndcp_data->sua->sn_data_q_write) { | |
648 break; | |
649 } | |
650 } else { | |
651 index = (index + 1) % SN_DATA_Q_LEN; | |
652 } /* if (sndcp_data->su->sn_unitdata_q[index]->nsapi == nsapi) */ | |
653 | |
654 } | |
655 #ifdef _SNDCP_DTI_2_ | |
656 /* | |
657 * Delete affected SN-PDUS from ll_desc_q. | |
658 */ | |
659 still = TRUE; | |
660 index = sndcp_data->sua->ll_desc_q_read; | |
661 while (still) { | |
662 if (index == sndcp_data->sua->ll_desc_q_write) { | |
663 break; | |
664 } | |
665 if (sua_get_nsapi(sndcp_data->sua->ll_desc_q[index]) == nsapi) { | |
666 /* | |
667 * The index for the prims to be shifted when 1 entry is deleted. | |
668 */ | |
669 U8 i = 0; | |
670 | |
671 ll_q_affected = TRUE; | |
672 /* | |
673 * Free the deleted primitive. | |
674 */ | |
675 if (sndcp_data->sua->ll_desc_q[index] != NULL) { | |
676 T_desc3 *free_help, *help = | |
677 (T_desc3 *)sndcp_data->sua->ll_desc_q[index]->desc_list3.first; | |
678 while(help != NULL) | |
679 { | |
680 if (destroy) { | |
681 sndcp_cl_desc3_free(help);/* free help->buffer */ | |
682 } | |
683 free_help = help; | |
684 help = (T_desc3 *)free_help->next; | |
685 MFREE(free_help); | |
686 } | |
687 | |
688 PFREE(sndcp_data->sua->ll_desc_q[index]); | |
689 sndcp_data->sua->ll_desc_q[index] = NULL; | |
690 } | |
691 | |
692 for (i = index; | |
693 i != sndcp_data->sua->ll_desc_q_write; | |
694 i = (i + 1) % SNDCP_SEGMENT_NUMBERS_ACK) { | |
695 | |
696 sndcp_data->sua->ll_desc_q[i] = | |
697 sndcp_data->sua->ll_desc_q | |
698 [(i + 1) % SNDCP_SEGMENT_NUMBERS_ACK]; | |
699 sndcp_data->sua->ll_desc_q | |
700 [(i + 1) % SNDCP_SEGMENT_NUMBERS_ACK] = NULL; | |
701 | |
702 } | |
703 sndcp_data->sua->ll_desc_q_write = | |
704 (sndcp_data->sua->ll_desc_q_write - 1 | |
705 + SNDCP_SEGMENT_NUMBERS_ACK) % SNDCP_SEGMENT_NUMBERS_ACK; | |
706 if (index == sndcp_data->sua->ll_desc_q_write) { | |
707 break; | |
708 } | |
709 } else { | |
710 index = (index + 1) % SNDCP_SEGMENT_NUMBERS_ACK; | |
711 } /* if (sndcp_data->sua->sn_data_q[index]->nsapi == nsapi) { */ | |
712 | |
713 } | |
714 #else /* _SNDCP_DTI_2_ */ | |
715 /* | |
716 * Delete affected SN-PDUS from ll_data_q. | |
717 */ | |
718 still = TRUE; | |
719 index = sndcp_data->sua->ll_data_q_read; | |
720 while (still) | |
721 { | |
722 if (index == sndcp_data->sua->ll_data_q_write) { | |
723 break; | |
724 } | |
725 if (sua_get_nsapi(sndcp_data->sua->ll_data_q[index]) == nsapi) { | |
726 /* | |
727 * The index for the prims to be shifted when 1 entry is deleted. | |
728 */ | |
729 UBYTE i = 0; | |
730 | |
731 ll_q_affected = TRUE; | |
732 /* | |
733 * Free the deleted primitive. | |
734 */ | |
735 if (sndcp_data->sua->ll_data_q[index] != NULL) { | |
736 PFREE(sndcp_data->sua->ll_data_q[index]); | |
737 sndcp_data->sua->ll_data_q[index] = NULL; | |
738 } | |
739 | |
740 for (i = index; | |
741 i != sndcp_data->sua->ll_data_q_write; | |
742 i = (i + 1) % SNDCP_SEGMENT_NUMBERS_ACK) { | |
743 | |
744 sndcp_data->sua->ll_data_q[i] = | |
745 sndcp_data->sua->ll_data_q | |
746 [(i + 1) % SNDCP_SEGMENT_NUMBERS_ACK]; | |
747 sndcp_data->sua->ll_data_q | |
748 [(i + 1) % SNDCP_SEGMENT_NUMBERS_ACK] = NULL; | |
749 | |
750 } | |
751 sndcp_data->sua->ll_data_q_write = | |
752 (sndcp_data->sua->ll_data_q_write - 1 | |
753 + SNDCP_SEGMENT_NUMBERS_ACK) % SNDCP_SEGMENT_NUMBERS_ACK; | |
754 if (index == sndcp_data->sua->ll_data_q_write) { | |
755 break; | |
756 } | |
757 } else { | |
758 index = (index + 1) % SNDCP_SEGMENT_NUMBERS_ACK; | |
759 } /* if (sndcp_data->sua->sn_data_q[index]->nsapi == nsapi) { */ | |
760 | |
761 } | |
762 #endif /* _SNDCP_DTI_2_ */ | |
763 } | |
764 /* | |
765 * if the segments in LL queue were from the affected nsapi then the | |
766 * next N-PDU is directed to cia. | |
767 */ | |
768 if (ll_q_affected) { | |
769 sua_next_sn_data_req (sapi); | |
770 } | |
771 | |
772 /* | |
773 * Delete the segment informations. | |
774 */ | |
775 { | |
776 T_SEG_INFO* help = sndcp_data->sua->first_seg_info; | |
777 while (help != NULL) { | |
778 T_SEG_INFO* help_next = help->next; | |
779 if (help->nsapi == nsapi) { | |
780 if(sndcp_data->sua->first_seg_info == help) | |
781 sndcp_data->sua->first_seg_info = help_next; | |
782 MFREE(help); | |
783 } | |
784 help = help_next; | |
785 } | |
786 } | |
787 | |
788 break; | |
789 default: | |
790 TRACE_ERROR( "SIG_MG_SUA_DELETE_PDUS unexpected" ); | |
791 break; | |
792 } | |
793 } /* sig_mg_sua_delete_pdus() */ | |
794 | |
795 /* | |
796 +------------------------------------------------------------------------------ | |
797 | Function : sig_mg_sua_n201 | |
798 +------------------------------------------------------------------------------ | |
799 | Description : Handles the internal signal SIG_MG_SUA_N201 | |
800 | | |
801 | Parameters : UBYTE sapi the affected sapi, USHORT n201 | |
802 | | |
803 +------------------------------------------------------------------------------ | |
804 */ | |
805 GLOBAL void sig_mg_sua_n201 (UBYTE sapi, | |
806 USHORT n201) | |
807 { | |
808 UBYTE sapi_index = 0; | |
809 | |
810 TRACE_ISIG( "sig_mg_sua_n201" ); | |
811 | |
812 /* | |
813 * Set service instance according to sapi in signal. | |
814 */ | |
815 sndcp_get_sapi_index(sapi, &sapi_index); | |
816 sndcp_data->sua = & sndcp_data->sua_base[sapi_index]; | |
817 | |
818 switch( GET_STATE( SUA ) ) | |
819 { | |
820 case SUA_LLC_NOT_RECEPTIVE_SUSPEND: | |
821 case SUA_LLC_RECEPTIVE_SUSPEND: | |
822 case SUA_LLC_NOT_RECEPTIVE: | |
823 case SUA_LLC_RECEPTIVE: | |
824 sndcp_data->sua->n201_i = n201; | |
825 break; | |
826 default: | |
827 TRACE_ERROR( "SIG_MG_SUA_N201 unexpected" ); | |
828 break; | |
829 } | |
830 } /* sig_mg_sua_n201() */ | |
831 | |
832 /* | |
833 +------------------------------------------------------------------------------ | |
834 | Function : sig_mg_sua_reset_ind | |
835 +------------------------------------------------------------------------------ | |
836 | Description : Handles the internal signal SIG_MG_SUA_RESET_IND | |
837 | | |
838 | Parameters : UBYTE sapi the affected sapi | |
839 | | |
840 +------------------------------------------------------------------------------ | |
841 */ | |
842 GLOBAL void sig_mg_sua_reset_ind (UBYTE sapi) | |
843 { | |
844 UBYTE sapi_index = 0; | |
845 | |
846 TRACE_ISIG( "sig_mg_sua_reset_ind" ); | |
847 | |
848 /* | |
849 * Set service instance according to sapi in signal. | |
850 */ | |
851 sndcp_get_sapi_index(sapi, &sapi_index); | |
852 sndcp_data->sua = & sndcp_data->sua_base[sapi_index]; | |
853 | |
854 switch( GET_STATE( SUA ) ) | |
855 { | |
856 case SUA_LLC_NOT_RECEPTIVE_SUSPEND: | |
857 case SUA_LLC_RECEPTIVE_SUSPEND: | |
858 case SUA_LLC_NOT_RECEPTIVE: | |
859 case SUA_LLC_RECEPTIVE: | |
860 /* | |
861 * This is only here: | |
862 */ | |
863 SET_STATE(SUA, SUA_LLC_NOT_RECEPTIVE); | |
864 | |
865 break; | |
866 default: | |
867 TRACE_ERROR( "SIG_MG_SUA_RESET_IND unexpected" ); | |
868 break; | |
869 } | |
870 } /* sig_mg_sua_reset_ind() */ | |
871 | |
872 #ifdef _SNDCP_DTI_2_ | |
873 /* | |
874 +------------------------------------------------------------------------------ | |
875 | Function : sig_mg_sua_resume | |
876 +------------------------------------------------------------------------------ | |
877 | Description : Handles the internal signal SIG_MG_SU_RESUME | |
878 | | |
879 | Parameters : UBYTE sapi the affected sapi | |
880 | | |
881 +------------------------------------------------------------------------------ | |
882 */ | |
883 GLOBAL void sig_mg_sua_resume (U8 sapi) | |
884 { | |
885 U8 sapi_index = 0; | |
886 | |
887 TRACE_ISIG( "sig_mg_sua_resume" ); | |
888 | |
889 /* | |
890 * Set service instance according to sapi in signal. | |
891 */ | |
892 sndcp_get_sapi_index(sapi, &sapi_index); | |
893 sndcp_data->sua = & sndcp_data->sua_base[sapi_index]; | |
894 | |
895 switch( GET_STATE( SUA ) ) | |
896 { | |
897 case SUA_LLC_NOT_RECEPTIVE_SUSPEND: | |
898 SET_STATE (SUA, SUA_LLC_NOT_RECEPTIVE); | |
899 break; | |
900 case SUA_LLC_RECEPTIVE_SUSPEND: | |
901 /* | |
902 * Is queue with LL_DESC_REQ empty? | |
903 */ | |
904 if (sndcp_data->sua->ll_desc_q_write == | |
905 sndcp_data->sua->ll_desc_q_read) { | |
906 SET_STATE(SUA, SUA_LLC_RECEPTIVE); | |
907 } else { | |
908 /* | |
909 * Get next segment from queue and send it. | |
910 */ | |
911 T_LL_DESC_REQ* ll_desc_req = | |
912 sndcp_data->sua->ll_desc_q[sndcp_data->sua->ll_desc_q_read]; | |
913 | |
914 U8 ll_desc_seg_pos = ll_desc_req->seg_pos; | |
915 U8 ll_desc_nsapi = sua_get_nsapi(ll_desc_req); | |
916 U8 ll_desc_sapi = ll_desc_req->sapi; | |
917 | |
918 sndcp_data->sua->ll_desc_q[sndcp_data->sua->ll_desc_q_read] = NULL; | |
919 | |
920 sndcp_data->sua->ll_desc_q_read = | |
921 (sndcp_data->sua->ll_desc_q_read + 1) % SNDCP_SEGMENT_NUMBERS_ACK; | |
922 | |
923 #ifdef _SIMULATION_ | |
924 su_send_ll_data_req_test(ll_desc_req); | |
925 #else /* _SIMULATION_ */ | |
926 PSEND(hCommLLC, ll_desc_req); | |
927 #endif /* _SIMULATION_ */ | |
928 | |
929 SET_STATE(SUA, SUA_LLC_NOT_RECEPTIVE); | |
930 if ((ll_desc_seg_pos & SEG_POS_LAST) > 0) { | |
931 sig_sua_nu_ready_ind( ll_desc_nsapi ); | |
932 sua_next_sn_data_req( ll_desc_sapi ); | |
933 sndcp_data->sua->cia_state = CIA_IDLE; | |
934 } | |
935 } | |
936 break; | |
937 case SUA_LLC_NOT_RECEPTIVE: | |
938 break; | |
939 case SUA_LLC_RECEPTIVE: | |
940 break; | |
941 default: | |
942 TRACE_ERROR( "SIG_MG_SUA_RESUME unexpected" ); | |
943 break; | |
944 } | |
945 } /* sig_mg_sua_resume() */ | |
946 #else /* _SNDCP_DTI_2_ */ | |
947 /* | |
948 +------------------------------------------------------------------------------ | |
949 | Function : sig_mg_sua_resume | |
950 +------------------------------------------------------------------------------ | |
951 | Description : Handles the internal signal SIG_MG_SU_RESUME | |
952 | | |
953 | Parameters : UBYTE sapi the affected sapi | |
954 | | |
955 +------------------------------------------------------------------------------ | |
956 */ | |
957 GLOBAL void sig_mg_sua_resume (UBYTE sapi) | |
958 { | |
959 UBYTE sapi_index = 0; | |
960 | |
961 TRACE_ISIG( "sig_mg_sua_resume" ); | |
962 | |
963 /* | |
964 * Set service instance according to sapi in signal. | |
965 */ | |
966 sndcp_get_sapi_index(sapi, &sapi_index); | |
967 sndcp_data->sua = & sndcp_data->sua_base[sapi_index]; | |
968 | |
969 switch( GET_STATE( SUA ) ) | |
970 { | |
971 case SUA_LLC_NOT_RECEPTIVE_SUSPEND: | |
972 SET_STATE (SUA, SUA_LLC_NOT_RECEPTIVE); | |
973 break; | |
974 case SUA_LLC_RECEPTIVE_SUSPEND: | |
975 /* | |
976 * Is queue with LL_DATA_REQ empty? | |
977 */ | |
978 if (sndcp_data->sua->ll_data_q_write == | |
979 sndcp_data->sua->ll_data_q_read) { | |
980 SET_STATE(SUA, SUA_LLC_RECEPTIVE); | |
981 } else { | |
982 /* | |
983 * Get next segment from queue and send it. | |
984 */ | |
985 T_LL_DATA_REQ* ll_data_req = | |
986 sndcp_data->sua->ll_data_q[sndcp_data->sua->ll_data_q_read]; | |
987 | |
988 UBYTE ll_data_seg_pos = ll_data_req->seg_pos; | |
989 UBYTE ll_data_nsapi = sua_get_nsapi(ll_data_req); | |
990 UBYTE ll_data_sapi = ll_data_req->sapi; | |
991 | |
992 sndcp_data->sua->ll_data_q[sndcp_data->sua->ll_data_q_read] = NULL; | |
993 | |
994 sndcp_data->sua->ll_data_q_read = | |
995 (sndcp_data->sua->ll_data_q_read + 1) % SNDCP_SEGMENT_NUMBERS_ACK; | |
996 | |
997 PSEND(hCommLLC, ll_data_req); | |
998 | |
999 SET_STATE(SUA, SUA_LLC_NOT_RECEPTIVE); | |
1000 if ((ll_data_seg_pos & SEG_POS_LAST) > 0) { | |
1001 sig_sua_nu_ready_ind( ll_data_nsapi ); | |
1002 sua_next_sn_data_req( ll_data_sapi ); | |
1003 sndcp_data->sua->cia_state = CIA_IDLE; | |
1004 } | |
1005 } | |
1006 break; | |
1007 case SUA_LLC_NOT_RECEPTIVE: | |
1008 break; | |
1009 case SUA_LLC_RECEPTIVE: | |
1010 break; | |
1011 default: | |
1012 TRACE_ERROR( "SIG_MG_SUA_RESUME unexpected" ); | |
1013 break; | |
1014 } | |
1015 } /* sig_mg_sua_resume() */ | |
1016 #endif /* _SNDCP_DTI_2_ */ | |
1017 | |
1018 | |
1019 /* | |
1020 +------------------------------------------------------------------------------ | |
1021 | Function : sig_mg_sua_suspend | |
1022 +------------------------------------------------------------------------------ | |
1023 | Description : Handles the internal signal SIG_NU_SUA_SUSPEND | |
1024 | | |
1025 | Parameters : SAPI | |
1026 | | |
1027 +------------------------------------------------------------------------------ | |
1028 */ | |
1029 GLOBAL void sig_mg_sua_suspend (UBYTE sapi) | |
1030 { | |
1031 UBYTE sapi_index = 0; | |
1032 | |
1033 TRACE_ISIG( "sig_mg_sua_suspend" ); | |
1034 | |
1035 /* | |
1036 * Set service instance according to sapi in signal. | |
1037 */ | |
1038 sndcp_get_sapi_index(sapi, &sapi_index); | |
1039 sndcp_data->sua = & sndcp_data->sua_base[sapi_index]; | |
1040 | |
1041 switch( GET_STATE( SUA ) ) | |
1042 { | |
1043 case SUA_LLC_NOT_RECEPTIVE_SUSPEND: | |
1044 break; | |
1045 case SUA_LLC_RECEPTIVE_SUSPEND: | |
1046 break; | |
1047 case SUA_LLC_NOT_RECEPTIVE: | |
1048 SET_STATE (SUA, SUA_LLC_NOT_RECEPTIVE_SUSPEND); | |
1049 break; | |
1050 case SUA_LLC_RECEPTIVE: | |
1051 SET_STATE (SUA, SUA_LLC_RECEPTIVE_SUSPEND); | |
1052 break; | |
1053 default: | |
1054 TRACE_ERROR( "SIG_MG_SUA_SUSPEND unexpected" ); | |
1055 break; | |
1056 } | |
1057 } /* sig_mg_sua_suspend() */ | |
1058 | |
1059 | |
1060 /* | |
1061 +------------------------------------------------------------------------------ | |
1062 | Function : sig_nu_sua_data_req | |
1063 +------------------------------------------------------------------------------ | |
1064 | Description : Handles the internal signal SIG_NU_SUA_DATA_REQ | |
1065 | | |
1066 | Parameters : SN_DATA_REQ primitive, N-PDU number, NSAPI, SAPI | |
1067 | | |
1068 +------------------------------------------------------------------------------ | |
1069 */ | |
1070 GLOBAL void sig_nu_sua_data_req (T_SN_DATA_REQ* sn_data_req, | |
1071 UBYTE npdu_number, | |
1072 UBYTE nsapi, | |
1073 UBYTE sapi | |
1074 ) | |
1075 { | |
1076 UBYTE sapi_index = 0; | |
1077 | |
1078 TRACE_ISIG( "sig_nu_sua_data_req" ); | |
1079 | |
1080 #ifdef _SNDCP_MEAN_TRACE_ | |
1081 #ifdef _SNDCP_DTI_2_ | |
1082 sndcp_mean_trace(nsapi, | |
1083 SNDCP_MEAN_UP, | |
1084 SNDCP_MEAN_ACK, | |
1085 sn_data_req->desc_list2.list_len); | |
1086 #else /*_SNDCP_DTI_2_*/ | |
1087 sndcp_mean_trace(nsapi, | |
1088 SNDCP_MEAN_UP, | |
1089 SNDCP_MEAN_ACK, | |
1090 sn_data_req->desc_list.list_len); | |
1091 #endif /*_SNDCP_DTI_2_*/ | |
1092 #endif /* _SNDCP_MEAN_TRACE_ */ | |
1093 | |
1094 /* | |
1095 * set service instance according to sapi in signal | |
1096 */ | |
1097 sndcp_get_sapi_index(sapi, &sapi_index); | |
1098 sndcp_data->sua = & sndcp_data->sua_base[sapi_index]; | |
1099 | |
1100 switch( GET_STATE( SUA ) ) | |
1101 { | |
1102 case SUA_LLC_RECEPTIVE_SUSPEND: | |
1103 case SUA_LLC_NOT_RECEPTIVE_SUSPEND: | |
1104 case SUA_LLC_NOT_RECEPTIVE: | |
1105 case SUA_LLC_RECEPTIVE: | |
1106 /* | |
1107 * If queue with NPDUs is empty, and cia is not busy, | |
1108 * send the NPDU to cia, else | |
1109 * add it to the queue. | |
1110 */ | |
1111 if ((sndcp_data->sua->sn_data_q_read == | |
1112 sndcp_data->sua->sn_data_q_write) && | |
1113 (sndcp_data->sua->ll_desc_q_read == | |
1114 sndcp_data->sua->ll_desc_q_write) && | |
1115 sndcp_data->sua->cia_state == CIA_IDLE) { | |
1116 /* | |
1117 * Send the NPDU to cia. | |
1118 */ | |
1119 sndcp_data->sua->cia_state = CIA_BUSY; | |
1120 sig_sua_cia_cia_comp_req(sn_data_req, | |
1121 npdu_number, | |
1122 nsapi, | |
1123 sapi); | |
1124 } else { /* Queue with NPDUs is not empty or cia is busy. */ | |
1125 /* | |
1126 * Write the sn_data_req prim to sn_data_q, | |
1127 * increment write pointer. | |
1128 */ | |
1129 sndcp_data->sua->sn_data_q[sndcp_data->sua->sn_data_q_write] = | |
1130 sn_data_req; | |
1131 sndcp_data->sua->npdu_number_q[sndcp_data->sua->sn_data_q_write] = | |
1132 npdu_number; | |
1133 sndcp_data->sua->sn_data_q_write = | |
1134 (sndcp_data->sua->sn_data_q_write + 1) % SN_DATA_Q_LEN; | |
1135 } /* Queue with NPDUs is not empty or cia is busy. */ | |
1136 break; | |
1137 default: | |
1138 TRACE_ERROR( "SIG_NU_SUA_DATA_REQ unexpected" ); | |
1139 #ifdef _SNDCP_DTI_2_ | |
1140 MFREE_PRIM(sn_data_req); | |
1141 #else /*_SNDCP_DTI_2_*/ | |
1142 PFREE_DESC(sn_data_req); | |
1143 #endif /*_SNDCP_DTI_2_*/ | |
1144 break; | |
1145 } | |
1146 } /* sig_nu_sua_data_req() */ | |
1147 | |
1148 #ifdef _SIMULATION_ | |
1149 #ifdef _SNDCP_DTI_2_ | |
1150 /* | |
1151 +------------------------------------------------------------------------------ | |
1152 | Function : su_send_ll_data_req_test | |
1153 +------------------------------------------------------------------------------ | |
1154 | Description : Only for test purposes. | |
1155 | The given LL_DESC_REQ is copied to an | |
1156 | LL_DATA_REQ and sent for the simulated test environment. | |
1157 | | |
1158 | Parameters : T_LL_DESC_REQ* pointer descriptor data. | |
1159 | | |
1160 +------------------------------------------------------------------------------ | |
1161 */ | |
1162 void su_send_ll_data_req_test(T_LL_DESC_REQ* ll_desc_req) | |
1163 { | |
1164 T_desc3* descriptor = NULL; | |
1165 U8* p_data = NULL; | |
1166 U16 offset = ENCODE_OFFSET_BYTE; | |
1167 | |
1168 PALLOC_SDU(ll_data_req, LL_DATA_REQ, (U16)( ll_desc_req->desc_list3.list_len* 8)); | |
1169 | |
1170 /* | |
1171 * Set parameters in ll_data_req primitive | |
1172 */ | |
1173 ll_data_req->sapi = ll_desc_req->sapi; | |
1174 ll_data_req->tlli = ll_desc_req->tlli; | |
1175 ll_data_req->ll_qos = ll_desc_req->ll_qos; | |
1176 ll_data_req->radio_prio = ll_desc_req->radio_prio; | |
1177 ll_data_req->reserved_data_req1 = ll_desc_req->reserved_data_req1; | |
1178 ll_data_req->reference1 = ll_desc_req->reference1; | |
1179 ll_data_req->seg_pos = ll_desc_req->seg_pos; | |
1180 ll_data_req->attached_counter = ll_desc_req->attached_counter; | |
1181 ll_data_req->reserved_data_req4 = ll_desc_req->reserved_data_req4; | |
1182 #ifdef REL99 | |
1183 ll_data_req->pkt_flow_id = ll_desc_req->pkt_flow_id; | |
1184 #endif /*REL99*/ | |
1185 /* | |
1186 * Set the ENCODE_OFFSET in the uplink sdu to 0, set sdu.l_buf | |
1187 */ | |
1188 ll_data_req->sdu.o_buf = ENCODE_OFFSET; | |
1189 ll_data_req->sdu.l_buf = ll_desc_req->desc_list3.list_len* 8; | |
1190 /* | |
1191 * Copy the data. | |
1192 */ | |
1193 descriptor = (T_desc3*)ll_desc_req->desc_list3.first; | |
1194 while (descriptor != NULL) | |
1195 { | |
1196 T_desc3* help = descriptor; | |
1197 p_data = (U8*)descriptor->buffer; | |
1198 if (descriptor->len>0) | |
1199 { | |
1200 memcpy(&ll_data_req->sdu.buf[offset], | |
1201 &p_data[descriptor->offset], | |
1202 descriptor->len); | |
1203 } | |
1204 offset += descriptor->len; | |
1205 descriptor = (T_desc3*)descriptor->next; | |
1206 sndcp_cl_desc3_free(help); | |
1207 MFREE(help); | |
1208 help = NULL; | |
1209 } | |
1210 | |
1211 PSEND(hCommLLC, ll_data_req); | |
1212 | |
1213 PFREE(ll_desc_req); // MAYBE REMEMBER is this the correct free? | |
1214 | |
1215 } | |
1216 #endif /* _SNDCP_DTI_2_ */ | |
1217 #endif /* _SIMULATION_ */ | |
1218 | |
1219 | |
1220 |