1 /*******************************************************************************
2 ################################################################################
3 # Copyright (c) [2017-2019] [Radisys] #
5 # Licensed under the Apache License, Version 2.0 (the "License"); #
6 # you may not use this file except in compliance with the License. #
7 # You may obtain a copy of the License at #
9 # http://www.apache.org/licenses/LICENSE-2.0 #
11 # Unless required by applicable law or agreed to in writing, software #
12 # distributed under the License is distributed on an "AS IS" BASIS, #
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
14 # See the License for the specific language governing permissions and #
15 # limitations under the License. #
16 ################################################################################
17 *******************************************************************************/
19 /* This file is the entry point for DU APP */
20 #include "common_def.h"
25 #include "du_app_mac_inf.h"
26 #include "du_app_rlc_inf.h"
29 #include "du_mgr_main.h"
35 #include "O1Interface.h"
39 uint8_t rlcUlActvTsk (Pst *, Buffer *);
40 uint8_t rlcUlActvInit (Ent, Inst, Region, Reason);
41 uint8_t rlcDlActvTsk (Pst *, Buffer *);
42 uint8_t rlcDlActvInit (Ent, Inst, Region, Reason);
43 uint8_t rgActvTsk (Pst *, Buffer *);
44 uint8_t rgActvInit (Ent, Inst, Region, Reason);
45 uint8_t lwrMacActvTsk(Pst *, Buffer *);
46 uint8_t lwrMacActvInit(Ent, Inst, Region, Reason);
49 DuCfgParams duCfgParam;
51 /*******************************************************************
53 * @brief Initializes DU APP
57 * Function : duAppInit
60 * - Registers and attaches TAPA tasks belonging to
63 * @params[in] system task ID
64 * @return ROK - success
67 * ****************************************************************/
68 uint8_t duAppInit(SSTskId sysTskId)
70 /* Register DU APP TAPA Task for DU */
71 if(ODU_REG_TTSK((Ent)ENTDUAPP, (Inst)DU_INST, (Ttype)TTNORM, (Prior)PRIOR0,
72 duActvInit, (ActvTsk)duActvTsk) != ROK)
76 /* Attach DU APP TAPA Task for DU */
77 if (ODU_ATTACH_TTSK((Ent)ENTDUAPP, (Inst)0, sysTskId)!= ROK)
82 DU_LOG("\nINFO --> DU_APP : DU APP created and registered \
83 to %d sys task", sysTskId);
87 /*******************************************************************
89 * @brief Initializes EGTP
96 * - Registers and attaches TAPA tasks belonging to
99 * @params[in] system task ID
100 * @return ROK - success
103 * ****************************************************************/
104 uint8_t egtpInit(SSTskId sysTskId)
106 /* Register DU APP TAPA Task for DU */
107 if(ODU_REG_TTSK((Ent)ENTEGTP, (Inst)EGTP_INST, (Ttype)TTNORM, (Prior)PRIOR0,
108 egtpActvInit, (ActvTsk)egtpActvTsk) != ROK)
112 /* Attach DU APP TAPA Task for DU */
113 if (ODU_ATTACH_TTSK((Ent)ENTEGTP, (Inst)0, sysTskId)!= ROK)
118 DU_LOG("\nINFO --> DU_APP : EGTP created and registered \
119 to %d sys task", sysTskId);
124 /*******************************************************************
126 * @brief Initializes SCTP task
130 * Function : sctpInit
133 * - Registers and attaches TAPA tasks for SCTP receiver
135 * @params[in] system task ID
136 * @return ROK - success
139 * ****************************************************************/
140 uint8_t sctpInit(SSTskId sysTskId)
142 /* Register SCTP TAPA Task */
143 if(ODU_REG_TTSK((Ent)ENTSCTP, (Inst)0, (Ttype)TTNORM, (Prior)PRIOR0,
144 sctpActvInit, (ActvTsk)sctpActvTsk) != ROK)
148 /* Attach SCTP TAPA Task */
149 if (ODU_ATTACH_TTSK((Ent)ENTSCTP, (Inst)SCTP_INST, sysTskId)!= ROK)
154 DU_LOG("\nINFO --> DU_APP : SCTP TAPA task created and registered to %d sys task",
158 /*******************************************************************
160 * @brief Initializes RLC DL, MAC TAPA task
164 * Function : rlcDlInit
167 * - Registers and attaches TAPA tasks for MAC and RLC DL
169 * @params[in] system task ID
170 * @return ROK - success
173 * ****************************************************************/
174 uint8_t rlcDlInit(SSTskId sysTskId)
176 /* Register RLC DL TAPA Task */
177 if(ODU_REG_TTSK((Ent)ENTRLC, (Inst)1, (Ttype)TTNORM, (Prior)PRIOR0,
178 rlcDlActvInit, (ActvTsk)rlcDlActvTsk) != ROK)
182 /* Attach RLC DL Task */
183 if (ODU_ATTACH_TTSK((Ent)ENTRLC, (Inst)1, sysTskId)!= ROK)
188 /* Register MAC TAPA Task */
189 if(ODU_REG_TTSK((Ent)ENTMAC, (Inst)0, (Ttype)TTNORM, (Prior)PRIOR0,
190 rgActvInit, (ActvTsk)rgActvTsk) != ROK)
194 /* Attach MAC Task */
195 if (ODU_ATTACH_TTSK((Ent)ENTMAC, (Inst)0, sysTskId)!= ROK)
200 DU_LOG("\nINFO --> DU_APP : RLC DL and MAC TAPA task created and registered to \
201 %d sys task", sysTskId);
205 /*******************************************************************
207 * @brief Initializes RLC UL TAPA task
211 * Function : rlcUlInit
214 * - Registers and attaches TAPA task for RLC UL
216 * @params[in] system task ID
217 * @return ROK - success
220 * ****************************************************************/
221 uint8_t rlcUlInit(SSTskId sysTskId)
223 /* Register RLC UL TAPA Task */
224 if(ODU_REG_TTSK((Ent)ENTRLC, (Inst)0, (Ttype)TTNORM, (Prior)PRIOR0,
225 rlcUlActvInit, (ActvTsk)rlcUlActvTsk) != ROK)
229 /* Attach RLC DL Task */
230 if (ODU_ATTACH_TTSK((Ent)ENTRLC, (Inst)0, sysTskId)!= ROK)
234 DU_LOG("\nINFO --> DU_APP : RLC UL TAPA task created and registered to \
235 %d sys task", sysTskId);
239 /*******************************************************************
241 * @brief Initializes Lower MAC receiver task
245 * Function : lwrMacInit
248 * - Registers and attaches TAPA tasks for Lower MAC receiver
250 * @params[in] system task ID
251 * @return ROK - success
254 * ****************************************************************/
255 uint8_t lwrMacInit(SSTskId sysTskId)
257 /* Register SCTP TAPA Task */
258 if(ODU_REG_TTSK((Ent)ENTLWRMAC, (Inst)0, (Ttype)TTNORM, (Prior)PRIOR0,
259 lwrMacActvInit, (ActvTsk)lwrMacActvTsk) != ROK)
263 /* Attach SCTP TAPA Task */
264 if (ODU_ATTACH_TTSK((Ent)ENTLWRMAC, (Inst)0, sysTskId)!= ROK)
269 DU_LOG("\nINFO --> DU_APP : LWR MAC TAPA task created and registered to %d sys task",
274 /*******************************************************************
276 * @brief Initializes system and TAPA tasks
280 * Function : commonInit
283 * - Registers and attaches system and TAPA tasks
286 * @return ROK - success
289 * ****************************************************************/
292 /* Declare system task Ids */
293 SSTskId du_app_stsk, egtp_stsk, sctp_stsk, rlc_ul_stsk, rlc_mac_cl_stsk, lwr_mac_stsk;
297 ODU_SET_PROC_ID(DU_PROC);
299 /* system task for DU APP */
300 if(ODU_CREATE_TASK(PRIOR0, &du_app_stsk) != ROK)
302 DU_LOG("\nERROR --> DU_APP : System Task creation for DU APP failed");
305 ODU_SET_THREAD_AFFINITY(&du_app_stsk, SS_AFFINITY_MODE_EXCL, 15, 0);
307 /* system task for EGTP */
308 if(ODU_CREATE_TASK(PRIOR0, &egtp_stsk) != ROK)
310 DU_LOG("\nERROR --> DU_APP : System Task creation for EGTP failed");
313 ODU_SET_THREAD_AFFINITY(&egtp_stsk, SS_AFFINITY_MODE_EXCL, 16, 0);
315 /* system task for RLC_DL and MAC */
316 if(ODU_CREATE_TASK(PRIOR0, &rlc_mac_cl_stsk) != ROK)
318 DU_LOG("\nERROR --> DU_APP : System Task creation for RLC DL/MAC failed");
321 pthread_attr_init(&attr);
322 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
323 ODU_SET_THREAD_AFFINITY(&rlc_mac_cl_stsk, SS_AFFINITY_MODE_EXCL, 17, 0);
325 /* system task for RLC UL */
326 if(ODU_CREATE_TASK(PRIOR1, &rlc_ul_stsk) != ROK)
328 DU_LOG("\nERROR --> DU_APP : System Task creation for RLC UL failed");
331 ODU_SET_THREAD_AFFINITY(&rlc_ul_stsk, SS_AFFINITY_MODE_EXCL, 18, 0);
333 /* system task for SCTP receiver thread */
334 if(ODU_CREATE_TASK(PRIOR0, &sctp_stsk) != ROK)
336 DU_LOG("\nERROR --> DU_APP : System Task creation for SCTP failed");
339 ODU_SET_THREAD_AFFINITY(&sctp_stsk, SS_AFFINITY_MODE_EXCL, 19, 0);
341 /* system task for lower-mac receiver thread */
342 if(ODU_CREATE_TASK(PRIOR0, &lwr_mac_stsk) != ROK)
344 DU_LOG("\nERROR --> DU_APP : System Task creation for Lower MAC failed");
347 ODU_SET_THREAD_AFFINITY(&lwr_mac_stsk, SS_AFFINITY_MODE_EXCL, 20, 0);
349 /* Create TAPA tasks */
350 if(duAppInit(du_app_stsk) != ROK)
352 DU_LOG("\nERROR --> DU_APP : DU APP TAPA Task initialization failed");
356 if(egtpInit(egtp_stsk) != ROK)
358 DU_LOG("\nERROR --> DU_APP : EGTP TAPA Task initialization failed");
362 if(sctpInit(sctp_stsk) != ROK)
364 DU_LOG("\nERROR --> DU_APP : SCTP TAPA Task initialization failed");
368 if(rlcDlInit(rlc_mac_cl_stsk) != ROK)
370 DU_LOG("\nERROR --> DU_APP : RLC DL Tapa Task initialization failed");
374 if(rlcUlInit(rlc_ul_stsk) != ROK)
376 DU_LOG("\nERROR --> DU_APP : RLC UL Tapa Task initialization failed");
380 if(lwrMacInit(lwr_mac_stsk) != ROK)
382 DU_LOG("\nERROR --> DU_APP : Lower MAC Tapa Task initialization failed");
389 /*******************************************************************
391 * @brief Initializes the DU
399 * - Registers DU Layers
402 * @return ROK - success
405 * ****************************************************************/
409 if(commonInit() != ROK)
418 openlog("ODU",LOG_CONS | LOG_PID | LOG_NDELAY, LOG_LOCAL1);
421 /*******************************************************************
423 * @brief Entry point for the DU APP
430 * - Read config params into duCfgParams
431 * - Initiate the init functions
434 * @return ROK - success
437 * ****************************************************************/
443 if(start_O1_module() != ROK)
447 //Initialize TAPA layers
453 //Read all the configs from du_utils.c into duCfgParams
459 /**********************************************************************
461 **********************************************************************/