comparison src/g23m-fad/ppp/ppp_ftxs.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 PPP and implements all
18 | functions to handles the incoming process internal signals as
19 | described in the SDL-documentation (FTX-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 #include "gsm.h" /* to get a lot of macros */
32 /*lint -efile(766,cnf_ppp.h) */
33 #include "cnf_ppp.h" /* to get cnf-definitions */
34 /*lint -efile(766,mon_ppp.h) */
35 #include "mon_ppp.h" /* to get mon-definitions */
36 #include "prim.h" /* to get the definitions of used SAP and directions */
37 #include "dti.h" /* to get the DTILIB definitions */
38 #include "ppp.h" /* to get the global entity definitions */
39
40 #include "ppp_dti.h" /* to get local DTI definitions */
41 #include "ppp_ftxf.h" /* to get function interface from ftx */
42 #include "ppp_arbf.h" /* to get function interface from arb */
43 #include "ppp_prxs.h" /* to get signal interface from prx */
44 #include "ppp_ptxs.h" /* to get signal interface from prx */
45
46 /*==== CONST ================================================================*/
47
48 /*==== LOCAL VARS ===========================================================*/
49
50 /*==== PRIVATE FUNCTIONS ====================================================*/
51
52 /*==== PUBLIC FUNCTIONS =====================================================*/
53
54 /*
55 +------------------------------------------------------------------------------
56 | Function : sig_arb_ftx_parameters_req
57 +------------------------------------------------------------------------------
58 | Description : Handles the internal signal SIG_ARB_FTX_PARAMETERS_REQ. It sets
59 | the parameter of FTX service.
60 |
61 | Parameters : accm - Async Control Character Map
62 | pfc - Protocol Field Compression
63 | acfc - Address and Control Field Compression
64 |
65 +------------------------------------------------------------------------------
66 */
67 GLOBAL void sig_arb_ftx_parameters_req (ULONG accm, UBYTE pfc, UBYTE acfc)
68 {
69 UBYTE i;
70
71 TRACE_ISIG( "sig_arb_ftx_parameters_req" );
72
73 switch( GET_STATE( PPP_SERVICE_FTX ) )
74 {
75 case FTX_READY:
76 case FTX_BLOCKED_DTI_FULL:
77 case FTX_READY_DTI_FULL:
78 case FTX_BLOCKED:
79 case FTX_DEAD:
80 case FTX_DEAD_START_FLOW:
81 /*
82 * store accm in look up table
83 */
84 for(i=0; i < 0x20; i++)
85 {
86 ppp_data->ftx.accmtab[i] = (accm & (1UL << i)) ? 0xFF : 0x00;
87 }
88 ppp_data->ftx.pfc = pfc;
89 ppp_data->ftx.acfc = acfc;
90 break;
91
92 default:
93 TRACE_ERROR( "SIG_ARB_FTX_PARAMETERS_REQ unexpected" );
94 break;
95 }
96 } /* sig_arb_ftx_parameters_req() */
97
98
99
100 /*
101 +------------------------------------------------------------------------------
102 | Function : sig_arb_ftx_dead_mode_req
103 +------------------------------------------------------------------------------
104 | Description : Handles the internal signal SIG_ARB_FTX_DEAD_MODE_REQ. It stops
105 | any data tranfer and releases all still to send HDLC frames.
106 |
107 | Parameters : no parameters
108 |
109 +------------------------------------------------------------------------------
110 */
111 GLOBAL void sig_arb_ftx_dead_mode_req ()
112 {
113
114 TRACE_ISIG( "sig_arb_ftx_dead_mode_req" );
115
116 switch( GET_STATE( PPP_SERVICE_FTX ) )
117 {
118 case FTX_READY:
119 case FTX_TRANSPARENT:
120 sig_ftx_prx_stop_flow_req();
121 SET_STATE( PPP_SERVICE_FTX, FTX_DEAD );
122 break;
123
124 case FTX_BLOCKED_DTI_FULL:
125 case FTX_BLOCKED:
126 case FTX_READY_DTI_FULL:
127 SET_STATE( PPP_SERVICE_FTX, FTX_DEAD );
128 break;
129
130 default:
131 TRACE_ERROR( "SIG_ARB_FTX_DEAD_MODE_REQ unexpected" );
132 break;
133 }
134 /*
135 * Free also any buffered packet (awaiting the TE to wake up)
136 * and reset PRX
137 */
138 sig_ftx_prx_dead_mode_req();
139 } /* sig_arb_ftx_dead_mode_req() */
140
141
142
143 /*
144 +------------------------------------------------------------------------------
145 | Function : sig_arb_ftx_blocked_mode_req
146 +------------------------------------------------------------------------------
147 | Description : Handles the internal signal SIG_ARB_FTX_BLOCKED_MODE_REQ. That
148 | means PRX-FTX data transfer is not allowed, but ARB can still
149 | send packets.
150 |
151 | Parameters : no parameters
152 |
153 +------------------------------------------------------------------------------
154 */
155 GLOBAL void sig_arb_ftx_blocked_mode_req ()
156 {
157 TRACE_ISIG( "sig_arb_ftx_blocked_mode_req" );
158
159 switch( GET_STATE( PPP_SERVICE_FTX ) )
160 {
161 case FTX_DEAD:
162 /*
163 * Set FTX to blocked and do _not_ start data flow from prx
164 * since ARB wants to perform some action first.
165 * Mark FTX DTI queue as full until according tx_buffer_ready signal
166 * is received. This is necessary since FTX may be started without an
167 * open dti channel towards peer layer.
168 */
169 SET_STATE( PPP_SERVICE_FTX, FTX_BLOCKED_DTI_FULL);
170 sig_ftx_prx_ready_mode_req();
171 break;
172
173 case FTX_DEAD_START_FLOW:
174 /*
175 * Set FTX to blocked and do _not_ start data flow from prx
176 * since ARB wants to perform some action first.
177 * tx_buffer_ready was already received, so do not mark DTI as full
178 */
179 SET_STATE( PPP_SERVICE_FTX, FTX_BLOCKED);
180 sig_ftx_prx_ready_mode_req();
181 break;
182
183 case FTX_READY_DTI_FULL:
184 SET_STATE( PPP_SERVICE_FTX, FTX_BLOCKED_DTI_FULL );
185 break;
186
187 case FTX_READY:
188 SET_STATE( PPP_SERVICE_FTX, FTX_BLOCKED );
189 sig_ftx_prx_stop_flow_req();
190 break;
191
192 case FTX_TRANSPARENT:
193 SET_STATE( PPP_SERVICE_FTX, FTX_TRANSPARENT_DTI_FULL );
194 sig_ftx_prx_stop_flow_req();
195 break;
196
197 default:
198 TRACE_ERROR( "SIG_ARB_FTX_BLOCKED_MODE_REQ unexpected" );
199 break;
200 }
201 } /* sig_arb_ftx_blocked_mode_req() */
202
203 /*
204 +------------------------------------------------------------------------------
205 | Function : sig_arb_ftx_ready_mode_req
206 +------------------------------------------------------------------------------
207 | Description : Handles the internal signal SIG_ARB_FTX_READY_MODE_REQ. It
208 | starts PRX-FTX data transfer.
209 |
210 | Parameters : no parameters
211 |
212 +------------------------------------------------------------------------------
213 */
214 GLOBAL void sig_arb_ftx_ready_mode_req ()
215 {
216 TRACE_ISIG( "sig_arb_ftx_ready_mode_req" );
217
218 switch( GET_STATE( PPP_SERVICE_FTX ) )
219 {
220 /*
221 * Tranistion from FTX_DEAD means there is a newly opened dti connection
222 * with empty buffers so starting the data flow is the right thing to
223 * do here
224 */
225 case FTX_DEAD_START_FLOW:
226 SET_STATE( PPP_SERVICE_FTX, FTX_READY );
227 sig_ftx_prx_ready_mode_req();
228 sig_ftx_prx_start_flow_req();
229 sig_ftx_ptx_buffer_ready_ind();
230 break;
231
232 case FTX_DEAD:
233 SET_STATE( PPP_SERVICE_FTX, FTX_READY_DTI_FULL );
234 sig_ftx_prx_ready_mode_req();
235 break;
236
237 case FTX_BLOCKED:
238 SET_STATE( PPP_SERVICE_FTX, FTX_READY );
239 sig_ftx_prx_start_flow_req();
240 break;
241
242 case FTX_TRANSPARENT_DTI_FULL:
243 SET_STATE( PPP_SERVICE_FTX, FTX_TRANSPARENT );
244 sig_ftx_prx_start_flow_req();
245 break;
246
247 case FTX_BLOCKED_DTI_FULL:
248 /* now waiting for dti */
249 SET_STATE( PPP_SERVICE_FTX, FTX_READY_DTI_FULL);
250 break;
251
252 case FTX_READY:
253 case FTX_TRANSPARENT:
254 /* already in the requested state */
255 break;
256
257 default:
258 TRACE_ERROR( "SIG_ARB_FTX_READY_MODE_REQ unexpected" );
259 break;
260 }
261 } /* sig_arb_ftx_ready_mode_req() */
262
263
264 /*
265 +------------------------------------------------------------------------------
266 | Function : sig_arb_ftx_transparent_mode_req
267 +------------------------------------------------------------------------------
268 | Description : Handles the internal signal SIG_ARB_FTX_TRANSPARENT_MODE_REQ.
269 | It starts PRX-FTX transparent data transfer. That means we
270 | expect PPP frames from PRX and check just for the start and end
271 | HDLC flag.
272 |
273 | Parameters : no parameters
274 |
275 +------------------------------------------------------------------------------
276 */
277 GLOBAL void sig_arb_ftx_transparent_mode_req ()
278 {
279 TRACE_ISIG( "sig_arb_ftx_transparent_mode_req" );
280
281 switch( GET_STATE( PPP_SERVICE_FTX ) )
282 {
283 case FTX_DEAD:
284 case FTX_DEAD_START_FLOW:
285 /*
286 * Set ftx to transparent mode and enable incoming data flow.
287 * The dti connection has been newly opened so that its buffers
288 * are empty and data can be received
289 */
290 SET_STATE( PPP_SERVICE_FTX, FTX_TRANSPARENT );
291 sig_ftx_prx_ready_mode_req();
292 sig_ftx_prx_start_flow_req();
293 sig_ftx_ptx_buffer_ready_ind();
294 break;
295
296 default:
297 TRACE_ERROR( "SIG_ARB_FTX_TRANSPARENT_MODE_REQ unexpected" );
298 break;
299 }
300 } /* sig_arb_ftx_transparent_mode_req() */
301
302 /*
303 +------------------------------------------------------------------------------
304 | Function : sig_any_ftx_packet_req
305 +------------------------------------------------------------------------------
306 | Description : Handles the internal signal SIG_ANY_FTX_PACKET_REQ. It creates
307 | an HDLC frame and sends it if possible or stores it in the send
308 | queue.
309 |
310 | Parameters : ptype - type of packet
311 | packet - pointer to a generic data descriptor
312 |
313 +------------------------------------------------------------------------------
314 */
315 GLOBAL void sig_any_ftx_packet_req (USHORT ptype, T_desc2* packet)
316 {
317 TRACE_ISIG( "sig_any_ftx_packet_req" );
318
319 switch( GET_STATE( PPP_SERVICE_FTX ) )
320 {
321 case FTX_READY:
322 case FTX_BLOCKED_DTI_FULL:
323 case FTX_BLOCKED:
324 case FTX_READY_DTI_FULL:
325 {
326 /*
327 * create frame and send it
328 */
329 PALLOC_DESC2 (dti_data_ind, DTI2_DATA_IND);
330
331 ftx_get_frame (ptype, packet, &dti_data_ind->desc_list2);
332
333 sig_any_dti_data_ind(ppp_data->ppphDTI,
334 dti_data_ind,
335 PPP_INSTANCE, PEER_LAYER,
336 PEER_CHANNEL, DTI_PID_UOS);
337 break;
338 }
339
340 case FTX_TRANSPARENT:
341 /*
342 * check frame and send it
343 */
344 {
345 PALLOC_DESC2 (dti_data_ind, DTI2_DATA_IND);
346 dti_data_ind->desc_list2.first = (ULONG)packet;
347 ftx_check_frame (&dti_data_ind->desc_list2);
348
349 sig_any_dti_data_ind(ppp_data->ppphDTI,
350 dti_data_ind,
351 PPP_INSTANCE, PEER_LAYER,
352 PEER_CHANNEL, DTI_PID_UOS);
353 }
354 break;
355
356 default:
357 TRACE_ERROR( "SIG_ANY_FTX_PACKET_REQ unexpected" );
358 arb_discard_packet(packet);
359 break;
360 }
361 } /* sig_any_ftx_packet_req() */
362
363 /*
364 +------------------------------------------------------------------------------
365 | Function : sig_dti_ftx_tx_buffer_full_ind
366 +------------------------------------------------------------------------------
367 | Description : This function handle the signal sig_dti_ftx_tx_buffer_full_ind
368 |
369 | Parameters : no parameters
370 |
371 +------------------------------------------------------------------------------
372 */
373
374 GLOBAL void sig_dti_ftx_tx_buffer_full_ind ()
375 {
376 TRACE_FUNCTION ("sig_dti_ftx_tx_buffer_full_ind()");
377
378 switch( GET_STATE( PPP_SERVICE_FTX ) )
379 {
380 case FTX_READY:
381 SET_STATE( PPP_SERVICE_FTX, FTX_READY_DTI_FULL );
382 sig_ftx_prx_stop_flow_req();
383 sig_ftx_ptx_buffer_full_ind();
384 break;
385
386 case FTX_TRANSPARENT:
387 SET_STATE( PPP_SERVICE_FTX, FTX_TRANSPARENT_DTI_FULL );
388 sig_ftx_prx_stop_flow_req();
389 sig_ftx_ptx_buffer_full_ind();
390 break;
391
392 case FTX_BLOCKED:
393 /* now both ARB and dtilib want FTX to block */
394 SET_STATE( PPP_SERVICE_FTX, FTX_BLOCKED_DTI_FULL );
395 sig_ftx_ptx_buffer_full_ind();
396 break;
397
398 case FTX_BLOCKED_DTI_FULL:
399 case FTX_READY_DTI_FULL:
400 case FTX_TRANSPARENT_DTI_FULL:
401 /* prx has already been blocked, do nothing */
402 break;
403
404 case FTX_DEAD_START_FLOW:
405 SET_STATE( PPP_SERVICE_FTX, FTX_DEAD );
406 break;
407
408 default:
409 TRACE_ERROR("Wrong state");
410 break;
411 }
412 } /* sig_dti_ftx_tx_buffer_full_ind() */
413
414
415
416 /*
417 +------------------------------------------------------------------------------
418 | Function : sig_dti_ftx_tx_buffer_ready_ind
419 +------------------------------------------------------------------------------
420 | Description : Handles the signal sig_dti_ftx_tx_buffer_ready_ind
421 |
422 | Parameters : no parameter
423 |
424 +------------------------------------------------------------------------------
425 */
426 GLOBAL void sig_dti_ftx_tx_buffer_ready_ind ()
427 {
428 TRACE_FUNCTION( "sig_dti_ftx_tx_buffer_ready_ind" );
429
430 switch( GET_STATE( PPP_SERVICE_FTX ) )
431 {
432 case FTX_BLOCKED_DTI_FULL:
433 SET_STATE( PPP_SERVICE_FTX, FTX_BLOCKED );
434 sig_ftx_ptx_buffer_ready_ind();
435 break;
436
437 case FTX_READY_DTI_FULL:
438 SET_STATE( PPP_SERVICE_FTX, FTX_READY );
439 sig_ftx_prx_start_flow_req();
440 sig_ftx_ptx_buffer_ready_ind();
441 break;
442
443 case FTX_TRANSPARENT_DTI_FULL:
444 SET_STATE( PPP_SERVICE_FTX, FTX_TRANSPARENT );
445 sig_ftx_prx_start_flow_req();
446 sig_ftx_ptx_buffer_ready_ind();
447 break;
448
449 case FTX_DEAD:
450 SET_STATE( PPP_SERVICE_FTX, FTX_DEAD_START_FLOW );
451 /* wait for sig_arb_ftx_blocked/ready/transparent_mode_req */
452 break;
453
454 case FTX_READY:
455 case FTX_TRANSPARENT:
456 /* already in the requested state */
457 break;
458
459 default:
460 TRACE_ERROR( "Signal unexpected" );
461 break;
462 }
463 } /* sig_dti_ftx_tx_buffer_ready_ind() */