comparison src/g23m-fad/l2r/l2r_ups.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 : CSD (8411)
4 | Modul : L2r_ups.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 defines the functions for processing
18 | of incomming signals for the component
19 | L2R of the base station
20 +-----------------------------------------------------------------------------
21 */
22
23
24 #ifndef L2R_UPS_C
25 #define L2R_UPS_C
26 #endif
27
28 #define ENTITY_L2R
29
30 /*==== INCLUDES ===================================================*/
31
32 #include <string.h>
33 #include "typedefs.h"
34 #include "pconst.cdg"
35 #include "vsi.h"
36 #include "macdef.h"
37 #include "custom.h"
38 #include "gsm.h"
39 #include "cus_l2r.h"
40 #include "cnf_l2r.h"
41 #include "mon_l2r.h"
42 #include "prim.h"
43 #include "pei.h"
44 #include "tok.h"
45 #include "dti.h" /* functionality of the dti library */
46
47 #include "cl_ribu.h"
48 #include "l2r.h"
49
50 /*==== CONST =======================================================*/
51
52 /*==== TYPES =======================================================*/
53
54 /*==== VAR EXPORT ==================================================*/
55
56 /*==== VAR LOCAL ===================================================*/
57
58 /*==== FUNCTIONS ===================================================*/
59
60 /*
61 +-------------------------------------------------------------------------------------
62 | Function : sig_mgt_up_conn_req
63 +-------------------------------------------------------------------------------------
64 | Description : Process signal SIG_MGT_UP_CONN_REQ received from process management.
65 |
66 | Parameters : framesPerPrim - Number of frames per primitive
67 | frameSize - Size of the frame
68 | flowCtrlUsed - Indicates wheather Flow Control is used or not.
69 | riBuSize - Size of the ring buffer
70 | inst_id - Instance Number
71 |
72 |
73 | Return : -
74 +-------------------------------------------------------------------------------------
75 */
76
77 GLOBAL void sig_mgt_up_conn_req
78 (
79 UBYTE framesPerPrim,
80 USHORT frameSize,
81 BOOL flowCtrlUsed,
82 T_PRIM_DESC_RIBU_SIZE riBuSize,
83 UBYTE inst_id
84 )
85 {
86 T_UP *dup = &l2r_data->up;
87
88 TRACE_FUNCTION ("sig_mgt_up_conn_req()");
89
90 switch (GET_STATE (UP))
91 {
92 case UP_DISCONNECTED:
93 dup->FramesPerPrim = framesPerPrim;
94 dup->FrameSize = frameSize;
95 dup->DataSize = frameSize - HT_LEN;
96 dup->FlowCtrlUsed = flowCtrlUsed;
97 dup->RiBu.idx.depth = riBuSize;
98 dup->FlowCtrlUsed = flowCtrlUsed;
99 dup->InstID = inst_id; /* ###jkaa: and what about this?? l2r_data->mgt.InstID */
100
101 up_rq_init();
102
103 dup->DiscardRemapData = FALSE;
104
105 if (dup->RiBu.idx.depth < UP_RIBU_PREALLOC + 1)
106 {
107 dup->RiBu.idx.depth = UP_RIBU_PREALLOC + 1;
108 }
109 if (dup->RiBu.idx.depth > MAX_UPRIM_RIBU_SIZE)
110 {
111 dup->RiBu.idx.depth = MAX_UPRIM_RIBU_SIZE;
112 }
113
114 dup->FlowThreshHi = 3 * dup->RiBu.idx.depth / 4;
115 dup->FlowThreshLo = dup->FlowThreshHi - 2;
116 if (dup->FlowThreshLo < 1)
117 {
118 dup->FlowThreshLo = 1;
119 }
120 dup->DnFlow = FL_INACTIVE;
121 dup->UpFlow = FL_INACTIVE;
122 dup->ULFlow = FL_INACTIVE;
123 dup->LLFlow = FL_INACTIVE;
124 up_merge_flow();
125
126 SET_STATE (UP_LL, ISW_IDLE);
127 SET_STATE (UP_UL, IW_IDLE);
128
129 up_init_ribu();
130 up_send_status( /* status must be sent after connecting */
131 dup->LastSentSa,
132 dup->LastSentSb,
133 dup->MrgFlow,
134 SO_END_EMPTY
135 );
136 up_send_prim_cond();
137 SET_STATE (UP, UP_CONNECTED);
138 break;
139 }
140 }
141
142 /*
143 +------------------------------------------------------------------------------
144 | Function : sig_mgt_up_disc_req
145 +------------------------------------------------------------------------------
146 | Description : Process signal SIG_MGT_UP_DISC_REQ received from
147 | process management.
148 |
149 | Parameters : -
150 |
151 |
152 | Return : -
153 +------------------------------------------------------------------------------
154 */
155
156
157 GLOBAL void sig_mgt_up_disc_req(void)
158 {
159 TRACE_FUNCTION ("sig_mgt_up_disc_req()");
160
161 switch (GET_STATE (UP))
162 {
163 case UP_CONNECTED:
164 case UP_REMAP:
165 up_deinit_ribu();
166 SET_STATE (UP, UP_DISCONNECTED);
167 break;
168 }
169 }
170
171 /*
172 +------------------------------------------------------------------------------
173 | Function : sig_mgt_up_break_req
174 +------------------------------------------------------------------------------
175 | Description : Process signal SIG_MGT_UP_BREAK_REQ received from process management.
176 |
177 | Parameters : sa - status bit ( general ready signal)
178 | sb - staus bit (data are valid or)
179 | flow - flow control staus (active or inactive)
180 |
181 | Return : -
182 +------------------------------------------------------------------------------
183 */
184
185
186 GLOBAL void sig_mgt_up_break_req
187 (
188 T_BIT sa,
189 T_BIT sb,
190 T_FLOW flow
191 )
192 {
193 TRACE_FUNCTION ("sig_mgt_up_break_req()");
194
195 switch (GET_STATE (UP))
196 {
197 case UP_CONNECTED:
198 case UP_REMAP:
199 up_deinit_ribu();
200 up_init_ribu();
201 up_store_status(sa, sb, flow);
202 up_send_status(sa, sb, l2r_data->up.MrgFlow, SO_BREAK_REQ); /*jk:030501*/
203 up_send_prim_cond();
204 break;
205 }
206 }
207
208
209 /*
210 +------------------------------------------------------------------------------
211 | Function : sig_mgt_up_clear_req
212 +------------------------------------------------------------------------------
213 | Description : Process signal SIG_MGT_UP_CLEAR_REQ received from
214 | process management.
215 |
216 | Parameters : -
217 |
218 |
219 | Return : -
220 +------------------------------------------------------------------------------
221 */
222
223
224 GLOBAL void sig_mgt_up_clear_req(void)
225 {
226 T_UP *dup = &l2r_data->up;
227
228 TRACE_FUNCTION ("sig_mgt_up_clear_req()");
229
230 switch (GET_STATE (UP))
231 {
232 case UP_CONNECTED:
233 case UP_REMAP:
234 up_deinit_ribu();
235 up_init_ribu();
236 /*
237 status must be sent after reset
238 */
239 up_send_status(dup->LastRcvdSa, dup->LastRcvdSb, dup->MrgFlow, SO_END_EMPTY);
240 up_send_prim_cond();
241 break;
242 }
243 }
244
245 /*
246 +------------------------------------------------------------------------------
247 | Function : sig_mgt_up_dti_conn_setup
248 +------------------------------------------------------------------------------
249 | Description : Process signal SIG_MGT_UP_DTI_CONN_SETUP
250 | received from process management.
251 |
252 | Parameters : link_id channel id of the link
253 |
254 | Return : -
255 +------------------------------------------------------------------------------
256 */
257
258 GLOBAL void sig_mgt_up_dti_conn_setup (ULONG link_id)
259 {
260 TRACE_FUNCTION ("sig_mgt_up_dti_conn_setup()");
261 l2r_data->up.link_id = link_id;
262 SET_STATE (UP_UL, IW_IDLE); /* jk: to IDLE in order to be able to respond with DTI_READY_IND */
263 /* when the next condition is fullfilled */
264 }
265
266 /*
267 +------------------------------------------------------------------------------
268 | Function : sig_mgt_up_dti_conn_open
269 +------------------------------------------------------------------------------
270 | Description : Process signal SIG_MGT_UP_DTI_CONN_OPEN
271 | received from process management.
272 |
273 | Parameters : -
274 | Return : -
275 +------------------------------------------------------------------------------
276 */
277
278 GLOBAL void sig_mgt_up_dti_conn_open()
279 {
280 T_UP *dup = &l2r_data->up;
281
282 TRACE_FUNCTION ("sig_mgt_up_dti_conn_open()");
283
284 dup->DtiConnected = TRUE;
285
286 /* jk: DTI_READY_IND only when the primitive is sent to UL */
287 if (dup->Prim EQ NULL)
288 {
289 up_send_ready();
290 }
291 else if (dup->Prim->desc_list2.first EQ 0)
292 {
293 PFREE (dup->Prim);
294 up_send_ready();
295 }
296 }
297
298 /*
299 +------------------------------------------------------------------------------
300 | Function : sig_dn_up_flow
301 +------------------------------------------------------------------------------
302 | Description :Process signal SIG_DN_UP_FLOW received from process management.
303 |
304 | Parameters : flow - flow control active or inactive
305 |
306 |
307 | Return : -
308 +------------------------------------------------------------------------------
309 */
310
311 GLOBAL void sig_dn_up_flow(T_FLOW flow)
312 {
313 T_UP *dup = &l2r_data->up;
314
315 T_FLOW oldFlow;
316
317 TRACE_FUNCTION ("sig_dn_up_flow()");
318
319 switch (GET_STATE (UP))
320 {
321 case UP_CONNECTED:
322 oldFlow = dup->DnFlow;
323 dup->DnFlow = flow;
324 if (flow EQ oldFlow)
325 return;
326
327 up_merge_flow();
328 if ((dup->LastSentFlow EQ dup->MrgFlow) OR (GET_STATE (UP_LL) NEQ ISW_WAIT))
329 return;
330
331 TIMERSTOP (TIMER_TUP_SND);
332 switch (dup->LLFlow)
333 {
334 case FL_INACTIVE:
335 up_send_prim_timeout();
336 break;
337
338 case FL_ACTIVE:
339 up_send_empty_frame(dup->LastSentSa, dup->LastSentSb, dup->MrgFlow);
340 break;
341 }
342
343 if (!dup->RiBu.idx.filled)
344 SET_STATE (UP_LL, ISW_IDLE)
345 else
346 SET_STATE (UP_LL, ISW_SEND)
347 break;
348
349 case UP_REMAP:
350 oldFlow = dup->DnFlow;
351 dup->DnFlow = flow;
352 if (flow NEQ oldFlow)
353 {
354 up_merge_flow();
355 }
356 break;
357 }
358 }
359
360 /*
361 +------------------------------------------------------------------------------
362 | Function : sig_dn_up_ll_flow
363 +------------------------------------------------------------------------------
364 | Description : Process signal SIG_DN_UP_LL_FLOW received from process management.
365 |
366 | Parameters : flow - flow control status (active - inactive)
367 |
368 |
369 | Return : -
370 +------------------------------------------------------------------------------
371 */
372
373 GLOBAL void sig_dn_up_ll_flow(T_FLOW flow)
374 {
375 T_UP *dup = &l2r_data->up;
376 TRACE_FUNCTION ("sig_dn_up_ll_flow()");
377
378 switch (GET_STATE (UP))
379 {
380 case UP_CONNECTED:
381 dup->LLFlow = flow;
382
383 if (dup->LLFlow EQ FL_INACTIVE AND GET_STATE (UP_LL) EQ ISW_WAIT AND dup->RiBu.idx.filled)
384 {
385 TIMERSTOP (TIMER_TUP_SND);
386 up_send_current_prim();
387
388 if (!dup->RiBu.idx.filled)
389 SET_STATE (UP_LL, ISW_IDLE)
390 else
391 SET_STATE (UP_LL, ISW_SEND)
392 }
393 break;
394
395 case UP_REMAP:
396 dup->LLFlow = flow;
397 break;
398 }
399 }