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 */
21 #include "du_mgr_main.h"
24 extern S16 kwUlActvTsk (Pst *, Buffer *);
25 extern S16 kwUlActvInit (Ent, Inst, Region, Reason);
26 extern S16 kwDlActvTsk (Pst *, Buffer *);
27 extern S16 kwDlActvInit (Ent, Inst, Region, Reason);
28 extern S16 rgActvTsk (Pst *, Buffer *);
29 extern S16 rgActvInit (Ent, Inst, Region, Reason);
31 /*******************************************************************
33 * @brief Initializes DU APP
37 * Function : duAppInit
40 * - Registers and attaches TAPA tasks belonging to
43 * @params[in] system task ID
44 * @return ROK - success
47 * ****************************************************************/
48 S16 duAppInit(SSTskId sysTskId)
50 /* Register DU APP TAPA Task for DU */
51 if(SRegTTsk((Ent)ENTDUAPP, (Inst)DU_INST, (Ttype)TTNORM, (Prior)PRIOR0,
52 duActvInit, (ActvTsk)duActvTsk) != ROK)
56 /* Attach DU APP TAPA Task for DU */
57 if (SAttachTTsk((Ent)ENTDUAPP, (Inst)0, sysTskId)!= ROK)
62 printf("\nDU APP created and registered \
63 to %d sys task\n", sysTskId);
66 /*******************************************************************
68 * @brief Initializes SCTP task
75 * - Registers and attaches TAPA tasks for SCTP receiver
77 * @params[in] system task ID
78 * @return ROK - success
81 * ****************************************************************/
82 S16 sctpInit(SSTskId sysTskId)
84 /* Register SCTP TAPA Task */
85 if(SRegTTsk((Ent)ENTSCTP, (Inst)0, (Ttype)TTNORM, (Prior)PRIOR0,
86 sctpActvInit, (ActvTsk)sctpActvTsk) != ROK)
90 /* Attach SCTP TAPA Task */
91 if (SAttachTTsk((Ent)ENTSCTP, (Inst)SCTP_INST, sysTskId)!= ROK)
96 printf("\nSCTP TAPA task created and registered to %d sys task\n",
100 /*******************************************************************
102 * @brief Initializes RLC DL, MAC TAPA task
106 * Function : rlcDlInit
109 * - Registers and attaches TAPA tasks for MAC and RLC DL
111 * @params[in] system task ID
112 * @return ROK - success
115 * ****************************************************************/
116 S16 rlcDlInit(SSTskId sysTskId)
118 /* Register RLC DL TAPA Task */
119 if(SRegTTsk((Ent)ENTKW, (Inst)1, (Ttype)TTNORM, (Prior)PRIOR0,
120 kwDlActvInit, (ActvTsk)kwDlActvTsk) != ROK)
124 /* Attach RLC DL Task */
125 if (SAttachTTsk((Ent)ENTKW, (Inst)1, sysTskId)!= ROK)
130 /* Register MAC TAPA Task */
131 if(SRegTTsk((Ent)ENTRG, (Inst)0, (Ttype)TTNORM, (Prior)PRIOR0,
132 rgActvInit, (ActvTsk)rgActvTsk) != ROK)
136 /* Attach MAC Task */
137 if (SAttachTTsk((Ent)ENTRG, (Inst)0, sysTskId)!= ROK)
142 printf("\nRLC DL and MAC TAPA task created and registered to \
143 %d sys task\n", sysTskId);
147 /*******************************************************************
149 * @brief Initializes RLC UL TAPA task
153 * Function : rlcUlInit
156 * - Registers and attaches TAPA task for RLC UL
158 * @params[in] system task ID
159 * @return ROK - success
162 * ****************************************************************/
163 S16 rlcUlInit(SSTskId sysTskId)
165 /* Register RLC UL TAPA Task */
166 if(SRegTTsk((Ent)ENTKW, (Inst)0, (Ttype)TTNORM, (Prior)PRIOR0,
167 kwUlActvInit, (ActvTsk)kwUlActvTsk) != ROK)
171 /* Attach RLC DL Task */
172 if (SAttachTTsk((Ent)ENTKW, (Inst)0, sysTskId)!= ROK)
176 printf("\nRLC UL TAPA task created and registered to \
177 %d sys task\n", sysTskId);
181 /*******************************************************************
183 * @brief Initializes system and TAPA tasks
187 * Function : commonInit
190 * - Registers and attaches system and TAPA tasks
193 * @return ROK - success
196 * ****************************************************************/
199 /* Declare system task Ids */
200 SSTskId du_app_stsk, sctp_stsk, rlc_ul_stsk, rlc_mac_cl_stsk;
206 /* system task for DU APP */
207 SCreateSTsk(PRIOR0, &du_app_stsk);
209 /* system task for RLC_DL and MAC */
210 SCreateSTsk(PRIOR0, &rlc_mac_cl_stsk);
211 pthread_attr_init(&attr);
212 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
214 /* system task for RLC UL */
215 SCreateSTsk(PRIOR1, &rlc_ul_stsk);
217 /* system task for SCTP receiver thread */
218 SCreateSTsk(PRIOR0, &sctp_stsk);
220 /* Create TAPA tasks */
221 if(duAppInit(du_app_stsk) != ROK)
223 printf("\nDU APP TAPA Task initialization failed");
227 if(sctpInit(sctp_stsk) != ROK)
229 printf("\nSCTP TAPA Task initialization failed");
233 if(rlcDlInit(rlc_mac_cl_stsk) != ROK)
235 printf("\nRLC DL Tapa Task initialization failed");
239 if(rlcUlInit(rlc_ul_stsk) != ROK)
241 printf("\nRLC UL Tapa Task initialization failed");
247 /*******************************************************************
249 * @brief Initializes the DU
257 * - Registers DU Layers
260 * @return ROK - success
263 * ****************************************************************/
267 if(commonInit() != ROK)
275 /*******************************************************************
277 * @brief Entry point for the DU APP
284 * - Read config params into duCfgParams
285 * - Initiate the init functions
288 * @return ROK - success
291 * ****************************************************************/
295 //Initialize TAPA layers
301 //Read all the configs from du_utils.c into duCfgParams
305 //Establish SCTP connection
308 printf("\nEstablishing SCTP link with CU... \n");
309 //ret = establishSctp(); //To be implemeted in du_sctp.c
315 /**********************************************************************
317 **********************************************************************/