comparison src/g23m-gprs/llc/llc_uitxs.c @ 1:d393cd9bb723

src/g23m-*: initial import from Magnetite
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 15 Jul 2018 04:40:46 +0000
parents
children
comparison
equal deleted inserted replaced
0:b6a5e36de839 1:d393cd9bb723
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 (UITX-statemachine)
20 +-----------------------------------------------------------------------------
21 */
22
23 #ifndef LLC_UITXS_C
24 #define LLC_UITXS_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 #include "llc_f.h" /* to get llc-functions */
41 #include "llc_uitxf.h" /* to get local UITX functions */
42 #include "llc_txs.h" /* to get signal interface to TX */
43
44 /*==== CONST ================================================================*/
45
46 /*==== LOCAL VARS ===========================================================*/
47
48 /*==== PRIVATE FUNCTIONS ====================================================*/
49
50 /*==== PUBLIC FUNCTIONS =====================================================*/
51
52
53
54 /*
55 +------------------------------------------------------------------------------
56 | Function : sig_llme_uitx_assign_req
57 +------------------------------------------------------------------------------
58 | Description : Handles the internal signal SIG_LLME_UITX_ASSIGN_REQ
59 |
60 | Parameters :
61 |
62 +------------------------------------------------------------------------------
63 */
64 GLOBAL void sig_llme_uitx_assign_req (void)
65 {
66 TRACE_ISIG( "sig_llme_uitx_assign_req" );
67
68 switch (GET_STATE(UITX))
69 {
70 case UITX_TLLI_UNASSIGNED_NOT_READY:
71 /*
72 * <R.LLC.TLLI_ASS.A.007>, <R.LLC.TLLI_ASS.A.008>
73 */
74 uitx_init_sapi();
75
76 /*
77 * <R.LLC.TLLI_ASS.A.006>
78 */
79 SET_STATE (UITX, UITX_ADM_NOT_READY);
80 break;
81 case UITX_TLLI_UNASSIGNED_READY:
82 /*
83 * <R.LLC.TLLI_ASS.A.007>, <R.LLC.TLLI_ASS.A.008>
84 */
85 uitx_init_sapi();
86
87 /*
88 * <R.LLC.TLLI_ASS.A.006>
89 */
90 SET_STATE (UITX, UITX_ADM_READY);
91 break;
92 default:
93 TRACE_ERROR( "SIG_LLME_UITX_ASSIGN_REQ unexpected" );
94 break;
95 }
96 } /* sig_llme_uitx_assign_req() */
97
98
99
100 /*
101 +------------------------------------------------------------------------------
102 | Function : sig_llme_uitx_unassign_req
103 +------------------------------------------------------------------------------
104 | Description : Handles the internal signal SIG_LLME_UITX_UNASSIGN_REQ
105 |
106 | Parameters :
107 |
108 +------------------------------------------------------------------------------
109 */
110 GLOBAL void sig_llme_uitx_unassign_req (void)
111 {
112 TRACE_ISIG( "sig_llme_uitx_unassign_req" );
113
114 switch (GET_STATE(UITX))
115 {
116 case UITX_ADM_NOT_READY:
117 SET_STATE (UITX, UITX_TLLI_UNASSIGNED_NOT_READY);
118 break;
119 case UITX_ADM_READY:
120 SET_STATE (UITX, UITX_TLLI_UNASSIGNED_READY);
121 break;
122 default:
123 TRACE_ERROR( "SIG_LLME_UITX_UNASSIGN_REQ unexpected" );
124 break;
125 }
126 } /* sig_llme_uitx_unassign_req() */
127
128
129
130 /*
131 +------------------------------------------------------------------------------
132 | Function : sig_llme_uitx_reset_req
133 +------------------------------------------------------------------------------
134 | Description : Handles the internal signal SIG_LLME_UITX_RESET_REQ
135 |
136 | Parameters :
137 |
138 +------------------------------------------------------------------------------
139 */
140 GLOBAL void sig_llme_uitx_reset_req (void)
141 {
142 TRACE_ISIG( "sig_llme_uitx_reset_req" );
143
144 switch (GET_STATE(UITX))
145 {
146 case UITX_ADM_NOT_READY:
147 /*
148 * No break!
149 */
150 case UITX_ADM_READY:
151 /*
152 * ATTENTION:
153 * Only use this procedure as long as it initialises only the requested
154 * variables on reset (V(U) as of V6.4.0).
155 */
156 uitx_init_sapi();
157 break;
158 default:
159 TRACE_ERROR( "SIG_LLME_UITX_RESET_REQ unexpected" );
160 break;
161 }
162 } /* sig_llme_uitx_reset_req() */
163
164
165
166 /*
167 +------------------------------------------------------------------------------
168 | Function : sig_tx_uitx_ready_ind
169 +------------------------------------------------------------------------------
170 | Description : Handles the internal signal SIG_TX_UITX_READY_IND
171 |
172 | Parameters :
173 |
174 +------------------------------------------------------------------------------
175 */
176 GLOBAL void sig_tx_uitx_ready_ind (void)
177 {
178 TRACE_ISIG( "sig_tx_uitx_ready_ind" );
179
180 switch (GET_STATE(UITX))
181 {
182 case UITX_TLLI_UNASSIGNED_NOT_READY:
183 /*
184 * This case should not be necessary, however, it depends on the assign
185 * order within LLME if this case is executed.
186 */
187 SET_STATE (UITX, UITX_TLLI_UNASSIGNED_READY);
188
189 /*
190 * No flow control for SAPI 1.
191 */
192 if (llc_data->current_sapi != LL_SAPI_1)
193 {
194 PALLOC (ll_unitready_ind, LL_UNITREADY_IND);
195
196 ll_unitready_ind->sapi = llc_data->current_sapi;
197
198 /*
199 * Send primitive LL-UNITREADY-IND to either SNDCP or GSMS,
200 * depending on the SAPI.
201 */
202 switch (llc_data->current_sapi)
203 {
204 case LL_SAPI_3:
205 case LL_SAPI_5:
206 case LL_SAPI_9:
207 case LL_SAPI_11:
208 TRACE_1_OUT_PARA("s:%d", ll_unitready_ind->sapi);
209 PSEND (hCommSNDCP, ll_unitready_ind);
210 break;
211 case LL_SAPI_7:
212 #ifndef LL_2to1
213 TRACE_PRIM_TO("GSMS");
214 TRACE_1_OUT_PARA("s:%d", ll_unitready_ind->sapi);
215 PSEND (hCommGSMS, ll_unitready_ind);
216 #else
217 PFREE (ll_unitready_ind);
218 #endif
219 break;
220 default:
221 PFREE (ll_unitready_ind);
222 TRACE_ERROR ("invalid global SAPI value");
223 break;
224 }
225 } /* end of validity range of ll_unitready_ind */
226 break;
227 case UITX_TLLI_UNASSIGNED_READY:
228 /*
229 * NOTE: This signal is always send when enough space for one more
230 * frame is available in the local transmit buffer queue of TX.
231 * Therefore it can be safely ignored if UITX is already in
232 * state *_READY.
233 */
234 break;
235 case UITX_ADM_NOT_READY:
236 SET_STATE (UITX, UITX_ADM_READY);
237
238 if (llc_data->current_sapi != LL_SAPI_1)
239 {
240 PALLOC (ll_unitready_ind, LL_UNITREADY_IND);
241
242 ll_unitready_ind->sapi = llc_data->current_sapi;
243
244 /*
245 * Send primitive LL-UNITREADY-IND to either SNDCP or GSMS,
246 * depending on the SAPI.
247 */
248 switch (llc_data->current_sapi)
249 {
250 case LL_SAPI_3:
251 case LL_SAPI_5:
252 case LL_SAPI_9:
253 case LL_SAPI_11:
254 TRACE_1_OUT_PARA("s:%d", ll_unitready_ind->sapi);
255 PSEND (hCommSNDCP, ll_unitready_ind);
256 break;
257 case LL_SAPI_7:
258 #ifndef LL_2to1
259 TRACE_PRIM_TO("GSMS");
260 TRACE_1_OUT_PARA("s:%d", ll_unitready_ind->sapi);
261 PSEND (hCommGSMS, ll_unitready_ind);
262 #else
263 PFREE (ll_unitready_ind);
264 #endif
265 break;
266 default:
267 PFREE (ll_unitready_ind);
268 TRACE_ERROR ("invalid global SAPI");
269 break;
270 }
271 } /* end of validity range of ll_unitready_ind */
272 break;
273 case UITX_ADM_READY:
274 /*
275 * NOTE: This signal is always send when enough space for one more
276 * frame is available in the local transmit buffer queue of TX.
277 * Therefore it can be safely ignored if UITX is already in
278 * state *_READY.
279 */
280 break;
281 default:
282 TRACE_ERROR( "SIG_TX_UITX_READY_IND unexpected" );
283 break;
284 }
285 } /* sig_tx_uitx_ready_ind() */
286
287
288 /*
289 +------------------------------------------------------------------------------
290 | Function : sig_tx_uitx_trigger_ind
291 +------------------------------------------------------------------------------
292 | Description : Handles the internal signal SIG_TX_UITX_TRIGGER_IND
293 |
294 | Parameters : cause - trigger cause
295 |
296 +------------------------------------------------------------------------------
297 */
298 GLOBAL void sig_tx_uitx_trigger_ind (UBYTE cause)
299 {
300 T_FRAME_NUM used_nu;
301 ULONG used_oc;
302 UBYTE cipher_mode;
303 #ifdef LL_DESC
304 T_desc3 *desc3;
305 #endif
306
307
308 TRACE_ISIG( "sig_tx_uitx_trigger_ind" );
309
310 switch (GET_STATE(UITX))
311 {
312 case UITX_ADM_READY:
313 /*
314 * NOTE: llc_current_sapi is assumed to be LL_SAPI_1, when this signal
315 * is being received. Thus it is an error if UITX is not in state
316 * ADM_READY, because that means that the local transmit queue in TX for
317 * SAPI 1 is not big enough!
318 */
319 {
320
321 #ifndef LL_DESC
322 PALLOC_SDU (ll_unitdesc_req, LL_UNITDATA_REQ, UI_FRAME_MIN_OCTETS*8);
323
324 #else
325 PALLOC (ll_unitdesc_req, LL_UNITDESC_REQ);
326 desc3 = llc_palloc_desc(0, UI_FRAME_MIN_OCTETS);
327 #endif
328
329 ll_unitdesc_req->sapi = llc_data->current_sapi;
330 ll_unitdesc_req->tlli = llc_data->tlli_new;
331 ll_unitdesc_req->ll_qos.delay = LL_DELAY_SUB;
332 ll_unitdesc_req->ll_qos.relclass = LL_NO_REL;
333 ll_unitdesc_req->ll_qos.peak = LL_PEAK_SUB;
334 ll_unitdesc_req->ll_qos.preced = LL_PRECED_SUB;
335 ll_unitdesc_req->ll_qos.mean = LL_MEAN_SUB;
336 ll_unitdesc_req->radio_prio = LL_RADIO_PRIO_1;
337
338 #ifdef REL99
339 /*
340 * From 24.008 & 23.060 it is interpreted that for all signalling data, a
341 * predefined PFI LL_PFI_SIGNALING shall be used.
342 */
343 ll_unitdesc_req->pkt_flow_id = LL_PFI_SIGNALING;
344 #endif /* REL99 */
345
346 cipher_mode = LL_CIPHER_OFF;
347
348 #ifndef LL_DESC
349
350 /*
351 * No attach to primitive necessary. There is no retransmission.
352 */
353 ll_unitdesc_req->attached_counter = CCI_NO_ATTACHE;
354
355 ll_unitdesc_req->sdu.l_buf = 0;
356 ll_unitdesc_req->sdu.o_buf = UI_CTRL_MIN_OCTETS * 8;
357
358 /*
359 * uitx_build_ui_header expects SDU to already contain data. The
360 * header is inserted _before_ sdu.o_buf, so set o_but to the length
361 * of the header.
362 */
363 uitx_build_ui_header (&ll_unitdesc_req->sdu, MS_COMMAND,
364 llc_data->current_sapi, llc_data->uitx->vu, cipher_mode,
365 ll_unitdesc_req->ll_qos.relclass);
366 #else
367 ll_unitdesc_req->attached_counter = CCI_NO_ATTACHE;
368 ll_unitdesc_req->desc_list3.first = (ULONG)desc3;
369 ll_unitdesc_req->desc_list3.list_len = desc3->len;
370
371 uitx_build_ui_header (&ll_unitdesc_req->desc_list3, MS_COMMAND,
372 llc_data->current_sapi, llc_data->uitx->vu, cipher_mode,
373 ll_unitdesc_req->ll_qos.relclass);
374 #endif
375 used_nu = llc_data->uitx->vu;
376 used_oc = llc_data->sapi->oc_ui_tx;
377
378 llc_data->uitx->vu ++;
379
380 if (llc_data->uitx->vu > MAX_SEQUENCE_NUMBER)
381 {
382 llc_data->uitx->vu = 0;
383 llc_data->sapi->oc_ui_tx += (MAX_SEQUENCE_NUMBER+1);
384 }
385 sig_uitx_tx_data_req (ll_unitdesc_req, cipher_mode, cause, used_nu, used_oc);
386 }
387 break;
388
389 default:
390 TRACE_ERROR( "SIG_TX_UITX_TRIGGER_IND unexpected" );
391 break;
392 }
393
394
395
396 } /* sig_tx_uitx_trigger_ind() */