comparison src/g23m-fad/l2r/tra_dnf.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_dnf.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 procedures and functions for TRA
18 +-----------------------------------------------------------------------------
19 */
20
21 #ifndef TRA_DNF_C
22 #define TRA_DNF_C
23 #endif
24
25 #define ENTITY_L2R
26
27 /*==== INCLUDES ===================================================*/
28
29 #include <string.h>
30 #include "typedefs.h"
31 #include "pconst.cdg"
32 #include "vsi.h"
33 #include "macdef.h"
34 #include "custom.h"
35 #include "gsm.h"
36 #include "prim.h"
37 #include "pei.h"
38 #include "tok.h"
39 #include "dti.h"
40
41 #include "cl_ribu.h"
42 #include "tra_pei.h"
43 #include "tra.h"
44
45 /*==== CONST =======================================================*/
46
47 /*==== TYPES =======================================================*/
48
49 /*==== VAR EXPORT ==================================================*/
50
51 /*==== VAR LOCAL ===================================================*/
52
53 /*==== FUNCTIONS ===================================================*/
54
55 /*
56 +------------------------------------------------------------------------------
57 | Function : dl_init
58 +------------------------------------------------------------------------------
59 | Description : initialise the l2r data for the downlink process
60 |
61 | Parameters : T_TRA_DN *ddl
62 |
63 |
64 | Return : -
65 +------------------------------------------------------------------------------
66 */
67
68 GLOBAL void dl_init(T_TRA_DN *ddl)
69 {
70 TRACE_FUNCTION ("dl_init()");
71
72 ddl->sa = FL_INACTIVE;
73 ddl->sb = FL_INACTIVE;
74 ddl->x = FL_INACTIVE;
75 ddl->prim = NULL; /* meaning: no DTI2_DATA_IND allocated yet */
76 ddl->Brk_dti_data_ind = NULL;
77
78 SET_STATE (DN, DN_INACTIVE);
79 }
80
81 /*
82 +------------------------------------------------------------------------------
83 | Function : dl_send_data_ind
84 +------------------------------------------------------------------------------
85 | Description : This procedure copies data from the downlink ring buffer
86 | into a a dti_data_ind primitive and sends this primitive
87 | to the upper layer.
88 | (Just the SDU data are copied into the ring buffer by RA!)
89 | Parameters : -
90 |
91 |
92 | Return : -
93 +------------------------------------------------------------------------------
94 */
95
96 GLOBAL BOOL dl_send_data_ind(void)
97 {
98 T_TRA_DN *ddl = &tra_data->dn;
99
100 TRACE_FUNCTION ("dl_send_data_ind()");
101
102 if (ddl->prim NEQ NULL) /* check for existing dti_data_ind */
103 {
104 ddl->prim->parameters.st_lines.st_line_sa = ddl->sa;
105 ddl->prim->parameters.st_lines.st_line_sb = ddl->sb;
106 ddl->prim->parameters.st_lines.st_flow = ddl->x;
107 ddl->prim->parameters.st_lines.st_break_len = DTI_BREAK_OFF;
108
109 ddl->prim->parameters.p_id = DTI_PID_UOS;
110 ddl->prim->link_id = 0; /* dummy init */
111
112 dti_send_data (l2r_hDTI, TRA_DTI_UP_INSTANCE, TRA_DTI_UP_INTERFACE, TRA_DTI_UP_CHANNEL, ddl->prim);
113 ddl->prim = NULL;
114 return TRUE;
115 }
116 else
117 {
118 TRACE_EVENT("no prim to send");
119 }
120 return FALSE;
121 }
122
123 /*
124 +------------------------------------------------------------------------------
125 | Function : dl_prep_data_ind
126 +------------------------------------------------------------------------------
127 | Description : This procedure appends data from the downlink ring buffer
128 | to a already allocated dti_data_ind primitive
129 |
130 | Parameters : -
131 |
132 |
133 | Return : -
134 +------------------------------------------------------------------------------
135 */
136
137 GLOBAL void dl_prep_data_ind(T_FD *pFD)
138 {
139 T_desc2* desc; /* block to be copied to */
140 T_desc2* p_desc; /* prim to be copied to */
141
142 T_TRA_DN *ddl = &tra_data->dn;
143
144 TRACE_FUNCTION ("dl_prep_data_ind()");
145
146 if (ddl->prim EQ NULL) /* check for existing dti_data_ind */
147 {
148 PALLOC (dti_data_ind, DTI2_DATA_IND); /* start new prim */
149 ddl->prim = dti_data_ind;
150
151 ddl->prim->desc_list2.list_len = 0;
152
153 MALLOC (desc, TRA_DTI_BUF_SIZE); /* contains header bytes, too! */
154
155 dti_data_ind->desc_list2.first =(ULONG) desc;
156
157 p_desc = (T_desc2 *) dti_data_ind->desc_list2.first;
158 p_desc->len = 0;
159 p_desc->size = 0;
160 p_desc->offset = 0;
161 p_desc->next = 0;
162
163 ddl->list_end = desc; /* set flag for next entrance without sending */
164 }
165 else
166 {
167 p_desc = ddl->list_end; /* append to remembered list end */
168 }
169
170 if (!pFD) /* status bits changed; no data received */
171 {
172 return;
173 }
174
175 if ((TRA_DTI_BUF_SIZE - p_desc->len - sizeof(T_desc2) + 1) >= MAX_SDU_SIZE)
176 {
177 memcpy(&p_desc->buffer[p_desc->len], pFD->buf, pFD->len); /* copy data from ring buffer */
178 }
179 else /* start new block */
180 {
181 MALLOC (desc, (USHORT)TRA_DTI_BUF_SIZE);
182 p_desc->next = (ULONG) desc;
183
184 /* Initialize the new block's fields to zero */
185 p_desc = (T_desc2 *)p_desc->next;
186 p_desc->len = 0;
187 p_desc->next = 0;
188 p_desc->size = 0;
189 p_desc->offset = 0; /* temporary solution */
190
191 memcpy(&p_desc->buffer[p_desc->len], pFD->buf, pFD->len); /* copy data from ring buffer */
192 ddl->list_end = p_desc; /* write back start of last list */
193 }
194 p_desc->len += pFD->len;
195 p_desc->size = p_desc->len;
196 ddl->prim->desc_list2.list_len += pFD->len;
197 }
198
199 /*
200 +------------------------------------------------------------------------------
201 | Function : rbm_init
202 +------------------------------------------------------------------------------
203 | Description :
204 |
205 | Parameters :
206 |
207 | Return : -
208 +------------------------------------------------------------------------------
209 */
210
211 GLOBAL void rbm_init(T_TRA_DN *ddl)
212 {
213 TRACE_FUNCTION ("rbm_init()");
214
215 cl_ribu_create(&tra_data->dn.ribu, MAX_SDU_SIZE, TRA_DLR_DEPTH);
216 }
217
218 /*
219 +------------------------------------------------------------------------------
220 | Function : tra_get_next_FrameDesc
221 +------------------------------------------------------------------------------
222 | Description : This function is called from the RA.
223 | It returns the frame descriptor for that buffer,
224 | which the RA has to write in the received frame.
225 |
226 | WRAPPER: Get frame descriptor for Layer 1 (TI)
227 | Parameters : -
228 |
229 | Return : -
230 +------------------------------------------------------------------------------
231 */
232
233 GLOBAL T_FD *tra_get_next_FrameDesc(void)
234 {
235 return (cl_ribu_get_new_frame_desc(tra_data->dn.ribu));
236 }