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