comparison src/g23m-fad/ppp/ppp_frxs.c @ 174:90eb61ecd093

src/g23m-fad: initial import from TCS3.2/LoCosto
author Mychaela Falconia <falcon@freecalypso.org>
date Wed, 12 Oct 2016 05:40:46 +0000
parents
children
comparison
equal deleted inserted replaced
173:bf64d785238a 174:90eb61ecd093
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 PPP and implements all
18 | functions to handles the incoming process internal signals as
19 | described in the SDL-documentation (FRX-statemachine)
20 +-----------------------------------------------------------------------------
21 */
22
23 #define ENTITY_PPP
24
25 /*==== INCLUDES =============================================================*/
26
27 #include "typedefs.h" /* to get Condat data types */
28 #include "vsi.h" /* to get a lot of macros */
29 #include "macdef.h" /* to get a lot of macros */
30 #include "custom.h" /* to get a lot of macros */
31 /*lint -efile(766,gsm.h) */
32 #include "gsm.h" /* to get a lot of macros */
33 /*lint -efile(766,cnf_ppp.h) */
34 #include "cnf_ppp.h" /* to get cnf-definitions */
35 /*lint -efile(766,mon_ppp.h) */
36 #include "mon_ppp.h" /* to get mon-definitions */
37 #include "prim.h" /* to get the definitions of used SAP and directions */
38 #include "dti.h" /* to get the DTILIB definitions */
39 #include "ppp.h" /* to get the global entity definitions */
40
41 #include "ppp_frxf.h" /* to get function interface from frx */
42 #include "ppp_arbf.h" /* to get function interface from arb */
43 #include "ppp_ptxs.h" /* to get signal interface from ptx */
44
45 /*==== CONST ================================================================*/
46
47 /*==== LOCAL VARS ===========================================================*/
48
49 /*==== PRIVATE FUNCTIONS ====================================================*/
50
51 /*==== PUBLIC FUNCTIONS =====================================================*/
52
53
54
55 /*
56 +------------------------------------------------------------------------------
57 | Function : sig_ptx_frx_dead_mode_req
58 +------------------------------------------------------------------------------
59 | Description : Handles the internal signal SIG_PTX_FRX_DEAD_MODE_REQ
60 |
61 | Parameters : no parameters
62 |
63 +------------------------------------------------------------------------------
64 */
65 GLOBAL void sig_ptx_frx_dead_mode_req ()
66 {
67 TRACE_ISIG( "sig_ptx_frx_dead_mode_req" );
68
69 arb_discard_packet(ppp_data->frx.received_data);
70 arb_discard_packet(ppp_data->frx.stored_packet);
71 ppp_data->frx.received_data = NULL;
72 ppp_data->frx.stored_packet = NULL;
73 ppp_data->frx.store_state = FRX_ADD_ERROR;
74 ppp_data->frx.frame_complete = FALSE;
75 ppp_data->frx.data_flow_state = FRX_DATA_FLOW_DEAD;
76
77 switch( GET_STATE( PPP_SERVICE_FRX ) )
78 {
79 case FRX_READY:
80 case FRX_READY_NDTI:
81 case FRX_TRANSPARENT:
82 case FRX_TRANSPARENT_NDTI:
83 SET_STATE( PPP_SERVICE_FRX, FRX_DEAD );
84 break;
85
86 default:
87 TRACE_ERROR( "SIG_PTX_FRX_DEAD_MODE_REQ unexpected" );
88 break;
89 }
90 } /* sig_ptx_frx_dead_mode_req() */
91
92 /*
93 +------------------------------------------------------------------------------
94 | Function : sig_ptx_frx_ready_mode_req
95 +------------------------------------------------------------------------------
96 | Description : Handles the internal signal SIG_PTX_FRX_READY_MODE_REQ
97 |
98 | Parameters : no parameters
99 |
100 +------------------------------------------------------------------------------
101 */
102 GLOBAL void sig_ptx_frx_ready_mode_req ()
103 {
104 TRACE_ISIG( "sig_ptx_frx_ready_mode_req" );
105
106 switch( GET_STATE( PPP_SERVICE_FRX ) )
107 {
108 case FRX_DEAD:
109 SET_STATE( PPP_SERVICE_FRX, FRX_READY_NDTI );
110 break;
111
112 case FRX_DEAD_DTI:
113 SET_STATE( PPP_SERVICE_FRX, FRX_READY );
114 break;
115
116 default:
117 TRACE_ERROR( "SIG_PTX_FRX_READY_MODE_REQ unexpected" );
118 break;
119 }
120 } /* sig_ptx_frx_ready_mode_req() */
121
122 /*
123 +------------------------------------------------------------------------------
124 | Function : sig_ptx_frx_transparent_mode_req
125 +------------------------------------------------------------------------------
126 | Description : Handles the internal signal SIG_PTX_FRX_TRANSPARENT_MODE_REQ
127 |
128 | Parameters : no parameters
129 |
130 +------------------------------------------------------------------------------
131 */
132 GLOBAL void sig_ptx_frx_transparent_mode_req ()
133 {
134 TRACE_ISIG( "sig_ptx_frx_transparent_mode_req" );
135
136 switch( GET_STATE( PPP_SERVICE_FRX ) )
137 {
138 case FRX_DEAD:
139 SET_STATE( PPP_SERVICE_FRX, FRX_TRANSPARENT_NDTI );
140 break;
141
142 case FRX_DEAD_DTI:
143 SET_STATE( PPP_SERVICE_FRX, FRX_TRANSPARENT );
144 break;
145
146 default:
147 TRACE_ERROR( "SIG_PTX_FRX_TRANSPARENT_MODE_REQ unexpected" );
148 break;
149 }
150 } /* sig_ptx_frx_transparent_mode_req() */
151
152 /*
153 +------------------------------------------------------------------------------
154 | Function : sig_ptx_frx_start_flow_req
155 +------------------------------------------------------------------------------
156 | Description : Handles the internal signal SIG_PTX_FRX_START_FLOW_REQ
157 |
158 | Parameters : no parameters
159 |
160 +------------------------------------------------------------------------------
161 */
162 GLOBAL void sig_ptx_frx_start_flow_req ()
163 {
164 TRACE_ISIG( "sig_ptx_frx_start_flow_req" );
165 /*
166 * set FRX PTX data flow state to ready.
167 */
168 ppp_data->frx.data_flow_state = FRX_DATA_FLOW_READY;
169
170 switch( GET_STATE( PPP_SERVICE_FRX ) )
171 {
172 case FRX_READY:
173 /*
174 * Send if necessary residuary packets from frame received before
175 */
176 frx_send_pack_ready_mode ();
177 /*
178 * check if all packet of frame were sent and start dti
179 */
180 if((ppp_data->frx.frame_complete EQ FALSE ) AND
181 (ppp_data->frx.data_flow_state EQ FRX_DATA_FLOW_READY))
182 {
183 /*
184 * Send a start signal to DTI
185 */
186 dti_start(ppp_data->ppphDTI, PPP_INSTANCE, PEER_LAYER, PEER_CHANNEL);
187 }
188 break;
189
190 case FRX_TRANSPARENT:
191 /*
192 * Send if necessary residuary packets from frame received before
193 */
194 frx_send_pack_transp_mode ();
195 /*
196 * check if all packet of frame were sent and start dti
197 */
198 if((ppp_data->frx.frame_complete EQ FALSE) AND
199 (ppp_data->frx.data_flow_state EQ FRX_DATA_FLOW_READY))
200 {
201 /*
202 * Send a start signal to DTI
203 */
204 dti_start(ppp_data->ppphDTI, PPP_INSTANCE, PEER_LAYER, PEER_CHANNEL);
205 }
206 break;
207 case FRX_READY_NDTI:
208 case FRX_TRANSPARENT_NDTI:
209 /*
210 * silently ignore duplicate signal..
211 */
212 break;
213
214 default:
215 TRACE_ERROR( "SIG_PTX_FRX_START_FLOW_REQ unexpected" );
216 break;
217 }
218
219 } /* sig_ptx_frx_start_flow_req() */
220
221
222 /*
223 +------------------------------------------------------------------------------
224 | Function : sig_ptx_frx_stop_flow_req
225 +------------------------------------------------------------------------------
226 | Description : Handles the internal signal SIG_PTX_FRX_STOP_FLOW_REQ
227 |
228 | Parameters : no parameters
229 |
230 +------------------------------------------------------------------------------
231 */
232 GLOBAL void sig_ptx_frx_stop_flow_req ()
233 {
234 TRACE_ISIG( "sig_ptx_frx_stop_flow_req" );
235
236 /*
237 * set FRX-PTX data flow state to dead.
238 */
239 ppp_data->frx.data_flow_state = FRX_DATA_FLOW_DEAD;
240
241 switch( GET_STATE( PPP_SERVICE_FRX ) )
242 {
243 case FRX_READY:
244 case FRX_TRANSPARENT:
245 /*
246 * Send a stop signal to DTI
247 */
248 dti_stop(ppp_data->ppphDTI, PPP_INSTANCE, PEER_LAYER, PEER_CHANNEL);
249 break;
250
251 case FRX_READY_NDTI:
252 case FRX_TRANSPARENT_NDTI:
253 /*
254 * silently ignore duplicate signal..
255 */
256 break;
257 default:
258 TRACE_ERROR( "SIG_PTX_FRX_STOP_FLOW_REQ unexpected" );
259 break;
260 }
261
262 } /* sig_ptx_frx_stop_flow_req() */
263
264 /*
265 +------------------------------------------------------------------------------
266 | Function : sig_arb_frx_dti_connected_req
267 +------------------------------------------------------------------------------
268 | Description : Handles the internal signal SIG_ARB_FRX_DTI_CONNECTED_REQ
269 |
270 | Parameters : no parameters
271 |
272 +------------------------------------------------------------------------------
273 */
274 GLOBAL void sig_arb_frx_dti_connected_req ()
275 {
276 TRACE_ISIG( "sig_arb_frx_dti_connected_req" );
277
278 switch( GET_STATE( PPP_SERVICE_FRX ) )
279 {
280 case FRX_DEAD:
281 SET_STATE( PPP_SERVICE_FRX, FRX_DEAD_DTI );
282 break;
283
284 case FRX_READY_NDTI:
285 SET_STATE( PPP_SERVICE_FRX, FRX_READY );
286 /*
287 * Send a start signal to DTI
288 */
289 dti_start(ppp_data->ppphDTI, PPP_INSTANCE, PEER_LAYER, PEER_CHANNEL);
290 break;
291
292 case FRX_TRANSPARENT_NDTI:
293 SET_STATE( PPP_SERVICE_FRX, FRX_TRANSPARENT );
294 /*
295 * Send a start signal to DTI
296 */
297 dti_start(ppp_data->ppphDTI, PPP_INSTANCE, PEER_LAYER, PEER_CHANNEL);
298 break;
299
300 default:
301 TRACE_ERROR( "SIG_ARB_FRX_DTI_CONNECTED_REQ unexpected" );
302 break;
303 }
304 } /* sig_arb_frx_dti_connected_req() */
305
306
307 /*
308 +------------------------------------------------------------------------------
309 | Function : sig_dti_frx_data_received_ind
310 +------------------------------------------------------------------------------
311 | Description : Handles the signal SIG_DTI_FRX_DATA_RECEIVED_IND
312 |
313 | Parameters : dti_data_ind - Ptr. to primitive payload
314 |
315 +------------------------------------------------------------------------------
316 */
317
318 GLOBAL void sig_dti_frx_data_received_ind (T_DTI2_DATA_IND *dti_data_ind)
319 {
320 TRACE_FUNCTION( "sig_dti_frx_data_received_ind" );
321
322 PACCESS(dti_data_ind);
323
324 #ifdef PPP_HDLC_TRACE
325 {
326 T_desc2* trace_desc;
327
328 trace_desc = (T_desc2*)dti_data_ind->desc_list2.first;
329 while(trace_desc)
330 {
331 if(trace_desc->len)
332 {
333 TRACE_EVENT_P4("new desc=0x%08x: first=0x%02x last=0x%02x len=%d",
334 trace_desc,
335 trace_desc->buffer[0],
336 trace_desc->buffer[trace_desc->len - 1],
337 trace_desc->len);
338 }
339 else
340 {
341 TRACE_EVENT_P1("new desc=0x%08x: len=0", trace_desc);
342 }
343 trace_desc = (T_desc2*)trace_desc->next;
344 }
345 }
346 #endif /* PPP_HDLC_TRACE */
347
348 switch( GET_STATE( PPP_SERVICE_FRX ) )
349 {
350 case FRX_READY:
351 ppp_data->frx.received_data = (T_desc2*)dti_data_ind->desc_list2.first;
352 ppp_data->frx.proceed_data = 0;
353
354 /*
355 * send as many packets to ptx as can be extracted
356 * from the one just received
357 */
358 frx_add_desc();
359 frx_send_pack_ready_mode();
360 break;
361
362 case FRX_TRANSPARENT:
363 ppp_data->frx.received_data = (T_desc2*)dti_data_ind->desc_list2.first;
364 ppp_data->frx.proceed_data = 0;
365
366 /*
367 * send as many packets to ptx as can be extracted
368 * from the one just received
369 */
370 frx_detect_frame();
371 frx_send_pack_transp_mode();
372 break;
373
374 default:
375 TRACE_ERROR( "DTI signal unexpected" );
376 /*
377 * free the data
378 */
379 arb_discard_packet((T_desc2*)dti_data_ind->desc_list2.first);
380 break;
381 }
382
383 /*
384 * free the primitive
385 */
386 PFREE(dti_data_ind);
387 } /* sig_dti_frx_data_received_ind() */
388
389
390