comparison src/g23m-fad/l2r/tra_mgtp.c @ 1:fa8dc04885d8

src/g23m-*: import from Magnetite
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 16 Oct 2020 06:25:50 +0000
parents
children
comparison
equal deleted inserted replaced
0:4e78acac3d88 1:fa8dc04885d8
1 /*
2 +-----------------------------------------------------------------------------
3 | Project : CSD (8411)
4 | Modul : tra_mgtp.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 primitives for the component TRA
19 +-----------------------------------------------------------------------------
20 */
21
22 #ifndef TRA_MGTP_C
23 #define TRA_MGTP_C
24 #endif
25
26 #define ENTITY_L2R
27
28 /*==== INCLUDES ===================================================*/
29
30 #include <string.h>
31
32 #include "typedefs.h"
33 #include "pconst.cdg"
34 #include "vsi.h"
35 #include "macdef.h"
36 #include "custom.h"
37 #include "gsm.h"
38 #include "prim.h"
39 #include "pei.h"
40 #include "tok.h"
41 #include "dti.h"
42
43 #include "cl_ribu.h"
44 #include "tra_pei.h"
45 #include "tra.h"
46
47 #include "ra_l1int.h"
48
49 /*==== CONST =======================================================*/
50 /*==== TYPES =======================================================*/
51 /*==== VAR EXPORT ==================================================*/
52 /*==== VAR LOCAL ===================================================*/
53 /*==== FUNCTIONS ===================================================*/
54
55 /*
56 +------------------------------------------------------------------------------
57 | Function : mgt_tra_activate_req
58 +------------------------------------------------------------------------------
59 | Description : Process primitive TRA_ACTIVATE_REQ received from ACI
60 |
61 | Parameters : tra_activate_req
62 |
63 |
64 | Return : -
65 +------------------------------------------------------------------------------
66 */
67
68 GLOBAL void mgt_tra_activate_req(T_TRA_ACTIVATE_REQ *tra_activate_req)
69 {
70 TRACE_EVENT ("mgt_tra_activate_req()");
71 PACCESS (tra_activate_req);
72
73 /***************************************
74 *
75 * Initialize Shared Fax/Data memory *
76 *
77 ***************************************/
78
79 tra_data = tra_data_first_elem;
80 memset (tra_data, 0, sizeof (T_TRA_DATA));
81 tra_data->up.fd.buf = &tra_data->up.to_ra[0];
82 l2r_data_mode = TRANSP; /* global flag for mode */
83 rbm_init(&tra_data->dn);
84 INIT_STATE (MGT, MGT_ACTIVE);
85 INIT_STATE (DTI, DTI_CLOSED);
86 INIT_STATE (DN, DN_INACTIVE);
87 INIT_STATE (UP, UP_INACTIVE);
88
89 {
90 PPASS (tra_activate_req, tra_activate_cnf, TRA_ACTIVATE_CNF);
91 tra_activate_cnf->ack_flg = TRA_ACK;
92 PSENDX (CTRL, tra_activate_cnf);
93 }
94
95 }
96
97 /*
98 +------------------------------------------------------------------------------
99 | Function : mgt_tra_deactivate_req
100 +------------------------------------------------------------------------------
101 | Description : Process primitive TRA_DEACTIVATE_REQ received from ACI/MMI
102 |
103 | Parameters : tra_deactivate_req
104 |
105 |
106 | Return : -
107 +------------------------------------------------------------------------------
108 */
109
110 GLOBAL void mgt_tra_deactivate_req(T_TRA_DEACTIVATE_REQ *tra_deactivate_req)
111 {
112 TRACE_FUNCTION ("mgt_tra_deactivate_req()");
113 PACCESS (tra_deactivate_req);
114
115 switch (GET_STATE (MGT))
116 {
117 case MGT_IDLE:
118 sig_mgt_tra_up_dti_disc();
119 sig_mgt_tra_dn_dti_disc();
120 /* no break */
121 case MGT_ACTIVE:
122 {
123 cl_ribu_release(&tra_data->dn.ribu); /* frees downlink FIFO */
124 }
125 send_tra_deactivate_cnf();
126 SET_STATE (MGT, MGT_INACTIVE);
127 break;
128
129 case MGT_INACTIVE:
130 TRACE_EVENT("MGT was inactive!");
131 break;
132
133 default:
134 TRACE_EVENT("MGT state not recognized!");
135 break;
136 }
137 PFREE (tra_deactivate_req);
138
139 if (GET_STATE (DTI) NEQ DTI_CLOSED)
140 {
141 dti_close(l2r_hDTI, TRA_DTI_UP_INSTANCE, TRA_DTI_UP_INTERFACE, TRA_DTI_UP_CHANNEL, FALSE);
142 SET_STATE (DTI, DTI_CLOSED);
143 }
144 }
145
146 /*
147 +------------------------------------------------------------------------------
148 | Function : mgt_tra_dti_req
149 +------------------------------------------------------------------------------
150 | Description : Process primitive TRA_DTI_REQ received from ACI/MMI
151 |
152 | Parameters : tra_dti_req
153 |
154 |
155 | Return : -
156 +------------------------------------------------------------------------------
157 */
158
159
160 GLOBAL void mgt_tra_dti_req(T_TRA_DTI_REQ *tra_dti_req)
161 {
162 UBYTE isOK;
163
164 TRACE_FUNCTION ("mgt_tra_dti_req()");
165 PACCESS (tra_dti_req);
166
167 switch (GET_STATE (MGT))
168 {
169 case MGT_ACTIVE:
170 if (tra_dti_req->dti_conn EQ TRA_CONNECT_DTI)
171 {
172 if (GET_STATE(DTI) NEQ DTI_CLOSED)
173 {
174 dti_close(l2r_hDTI, TRA_DTI_UP_INSTANCE, TRA_DTI_UP_INTERFACE, TRA_DTI_UP_CHANNEL, FALSE);
175 SET_STATE (DTI, DTI_CLOSED);
176 }
177 /*
178 * open new dti library communication channel
179 */
180 SET_STATE (DTI, DTI_SETUP);
181
182 isOK = dti_open(
183 l2r_hDTI,
184 TRA_DTI_UP_INSTANCE,
185 TRA_DTI_UP_INTERFACE,
186 TRA_DTI_UP_CHANNEL,
187 0,
188 tra_dti_req->dti_direction,
189 DTI_QUEUE_UNUSED,
190 DTI_VERSION_10,
191 (U8*)tra_dti_req->entity_name,
192 tra_dti_req->link_id
193 );
194
195 if (isOK EQ FALSE)
196 {
197 PALLOC(tra_dti_cnf, TRA_DTI_CNF);
198 SET_STATE (DTI, DTI_CLOSED);
199 tra_dti_cnf->dti_conn = TRA_DISCONNECT_DTI;
200 tra_dti_cnf->link_id = tra_dti_req->link_id;
201 PSENDX (CTRL, tra_dti_cnf);
202 PFREE(tra_dti_req);
203 return;
204 }
205 sig_mgt_tra_dn_dti_conn_setup ();
206 sig_mgt_tra_up_dti_conn_setup ();
207 }
208 break;
209
210 case MGT_IDLE:
211 if (tra_dti_req->dti_conn EQ TRA_DISCONNECT_DTI)
212 {
213 sig_mgt_tra_up_dti_disc();
214 sig_mgt_tra_dn_dti_disc();
215 if (GET_STATE (DTI) NEQ DTI_CLOSED)
216 {
217 dti_close(l2r_hDTI, TRA_DTI_UP_INSTANCE, TRA_DTI_UP_INTERFACE, TRA_DTI_UP_CHANNEL, FALSE);
218 SET_STATE (DTI, DTI_CLOSED);
219 }
220 SET_STATE (MGT, MGT_ACTIVE);
221 send_tra_dti_cnf(tra_dti_req);
222 }
223 break;
224 }
225 PFREE (tra_dti_req);
226 }
227
228 /*
229 +------------------------------------------------------------------------------
230 | Function : rcv_ra_break_ind
231 +------------------------------------------------------------------------------
232 | Description : Process primitive RA_BREAK_IND received from RA.
233 | This function is called if the RA_BREAK_IND primtive
234 | is received or from the signal processing in l2r_pei.
235 |
236 | Parameters : ra_break_ind
237 |
238 | Return : -
239 +------------------------------------------------------------------------------
240 */
241
242 GLOBAL void rcv_ra_break_ind(T_RA_BREAK_IND *ra_break_ind)
243 {
244 U8 sa;
245 U8 sb;
246 U8 flow;
247 USHORT break_len = ra_break_ind->break_len;
248
249 TRACE_FUNCTION ("rcv_ra_break_ind()");
250
251 #ifdef _SIMULATION_
252 PACCESS (ra_break_ind);
253 #endif
254
255 /* xxxxx not properly initialized.. */
256
257 sa = tra_data->up.sa; /* last sa bit in this primitive */
258 sb = tra_data->up.sb; /* last sb bit in this primitive */
259 flow = tra_data->up.x; /* last x bit in this primitive */
260
261 #ifdef _SIMULATION_
262 PFREE(ra_break_ind);
263 #endif
264
265 /* Send signal to mgt and set BREAK dti_data prim */
266 sig_dn_tra_mgt_break_ind(sa, sb, flow, break_len);
267 }
268
269
270 /*
271 +------------------------------------------------------------------------------
272 | Function : sig_dti_tra_mgt_connection_opened_ind
273 +------------------------------------------------------------------------------
274 | Description : Handles the DTILIB callback call DTI_REASON_CONNECTION_OPENED
275 |
276 | This signal means that a dti connection has been opened
277 | successfully.
278 | Since it is called directly from the dtilib callback function
279 | it is handled like a primitive, here..
280 |
281 | Parameters : -
282 | Return : -
283 +------------------------------------------------------------------------------
284 */
285 GLOBAL void sig_dti_tra_mgt_connection_opened_ind()
286 {
287 TRACE_FUNCTION ("sig_dti_tra_mgt_connection_opened_ind()");
288
289 if (GET_STATE (DTI) EQ DTI_SETUP)
290 {
291 PALLOC (tra_dti_cnf, TRA_DTI_CNF);
292 TRACE_EVENT("MGT: DTI received from ACI");
293
294 SET_STATE (DTI, DTI_IDLE);
295 SET_STATE (MGT, MGT_IDLE);
296
297 sig_mgt_tra_dn_dti_conn_open ();
298 sig_mgt_tra_up_dti_conn_open ();
299
300 tra_dti_cnf->dti_conn = TRA_CONNECT_DTI;
301 if (dti_resolve_link_id (l2r_hDTI, TRA_DTI_UP_INSTANCE, TRA_DTI_UP_INTERFACE, TRA_DTI_UP_CHANNEL, &tra_dti_cnf->link_id) EQ FALSE)
302 {
303 TRACE_ERROR ("sig_dti_tra_mgt_connection_opened_ind(): link_id not found!");
304 return; /* error, no appropriate link_id found */
305 }
306 PSENDX (CTRL, tra_dti_cnf);
307 #ifdef _TARGET_
308 {
309 T_RA_DATATRANS_REQ RA_datatrans_req;
310 l1i_ra_datatrans_req(&RA_datatrans_req);
311 }
312 #endif
313 }
314 }
315
316 /*
317 +------------------------------------------------------------------------------
318 | Function : sig_dti_tra_mgt_connection_closed_ind
319 +------------------------------------------------------------------------------
320 | Description : Handles the DTILIB callback call DTI_REASON_CONNECTION_CLOSED
321 |
322 | This signal means that a dti connection has been closed
323 | Since it is called directly from the dtilib callback function
324 | it is handled like a primitive, here..
325 |
326 | Parameters : -
327 | Return : -
328 +------------------------------------------------------------------------------
329 */
330 GLOBAL void sig_dti_tra_mgt_connection_closed_ind()
331 {
332 TRACE_FUNCTION ("sig_dti_tra_mgt_connection_closed_ind()");
333
334 if (GET_STATE(DTI) NEQ DTI_CLOSED)
335 {
336 PALLOC (tra_dti_ind, TRA_DTI_IND);
337
338 SET_STATE (DTI, DTI_CLOSED);
339
340 sig_mgt_tra_up_dti_disc();
341 sig_mgt_tra_dn_dti_disc();
342
343 if (dti_resolve_link_id(l2r_hDTI, TRA_DTI_UP_INSTANCE, TRA_DTI_UP_INTERFACE, TRA_DTI_UP_CHANNEL, &tra_dti_ind->link_id) EQ FALSE)
344 {
345 TRACE_ERROR ("sig_dti_tra_mgt_connection_closed_ind(): link_id not found!");
346 return; /* error, no appropriate link_id found */
347 }
348 TRACE_EVENT("MGT: DTI passed to ACI");
349 PSENDX (CTRL, tra_dti_ind);
350 }
351 }
352