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 DuCfgParams ducfgparam; //global variable to hold all configs
34 /*******************************************************************
36 * @brief Initializes DU APP
40 * Function : duAppInit
43 * - Registers and attaches TAPA tasks belonging to
46 * @params[in] system task ID
47 * @return ROK - success
50 * ****************************************************************/
51 S16 duAppInit(SSTskId sysTskId)
53 /* Register DU APP TAPA Task for DU */
54 if(SRegTTsk((Ent)ENTDUAPP, (Inst)0, (Ttype)TTNORM, (Prior)PRIOR0,
55 duActvInit, (ActvTsk)duActvTsk) != ROK)
59 /* Attach DU APP TAPA Task for DU */
60 if (SAttachTTsk((Ent)ENTDUAPP, (Inst)0, sysTskId)!= ROK)
65 printf("\nDU APP created and registered \
66 to %d sys task\n", sysTskId);
70 /*******************************************************************
72 * @brief Initializes SCTP task
79 * - Registers and attaches TAPA tasks for SCTP receiver
81 * @params[in] system task ID
82 * @return ROK - success
85 * ****************************************************************/
86 S16 sctpInit(SSTskId sysTskId)
88 /* Register SCTP TAPA Task */
89 if(SRegTTsk((Ent)ENTSCTP, (Inst)0, (Ttype)TTNORM, (Prior)PRIOR0,
90 sctpActvInit, (ActvTsk)sctpActvTsk) != ROK)
94 /* Attach SCTP TAPA Task */
95 if (SAttachTTsk((Ent)ENTSCTP, (Inst)0, sysTskId)!= ROK)
100 printf("\nSCTP TAPA task created and registered to %d sys task\n",
105 /*******************************************************************
107 * @brief Initializes RLC DL, MAC TAPA task
111 * Function : rlcDlInit
114 * - Registers and attaches TAPA tasks for MAC and RLC DL
116 * @params[in] system task ID
117 * @return ROK - success
120 * ****************************************************************/
121 S16 rlcDlInit(SSTskId sysTskId)
123 /* Register RLC DL TAPA Task */
124 if(SRegTTsk((Ent)ENTKW, (Inst)1, (Ttype)TTNORM, (Prior)PRIOR0,
125 kwDlActvInit, (ActvTsk)kwDlActvTsk) != ROK)
129 /* Attach RLC DL Task */
130 if (SAttachTTsk((Ent)ENTKW, (Inst)1, sysTskId)!= ROK)
135 /* Register MAC TAPA Task */
136 if(SRegTTsk((Ent)ENTRG, (Inst)0, (Ttype)TTNORM, (Prior)PRIOR0,
137 rgActvInit, (ActvTsk)rgActvTsk) != ROK)
141 /* Attach MAC Task */
142 if (SAttachTTsk((Ent)ENTRG, (Inst)0, sysTskId)!= ROK)
147 printf("\nRLC DL and MAC TAPA task created and registered to \
148 %d sys task\n", sysTskId);
152 /*******************************************************************
154 * @brief Initializes RLC UL TAPA task
158 * Function : rlcUlInit
161 * - Registers and attaches TAPA task for RLC UL
163 * @params[in] system task ID
164 * @return ROK - success
167 * ****************************************************************/
168 S16 rlcUlInit(SSTskId sysTskId)
170 /* Register RLC UL TAPA Task */
171 if(SRegTTsk((Ent)ENTKW, (Inst)0, (Ttype)TTNORM, (Prior)PRIOR0,
172 kwUlActvInit, (ActvTsk)kwUlActvTsk) != ROK)
176 /* Attach RLC DL Task */
177 if (SAttachTTsk((Ent)ENTKW, (Inst)0, sysTskId)!= ROK)
181 printf("\nRLC UL TAPA task created and registered to \
182 %d sys task\n", sysTskId);
186 /*******************************************************************
188 * @brief Initializes system and TAPA tasks
192 * Function : commonInit
195 * - Registers and attaches system and TAPA tasks
198 * @return ROK - success
201 * ****************************************************************/
204 /* Declare system task Ids */
205 SSTskId du_app_stsk, sctp_stsk, rlc_ul_stsk, rlc_mac_cl_stsk;
210 //TODO: check regarding cores and add info here
212 /* system task for DU APP */
213 SCreateSTsk(PRIOR0, &du_app_stsk);
214 //TODO: check core info to pin the above task to whcih core
216 /* system task for RLC_DL and MAC */
217 SCreateSTsk(PRIOR0, &rlc_mac_cl_stsk);
218 pthread_attr_init(&attr);
219 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
220 //TODO: check core info to pin the above task to whcih core
222 /* system task for RLC UL */
223 SCreateSTsk(PRIOR1, &rlc_ul_stsk);
224 //TODO: check core info to pin the above task to whcih core
226 /* system task for SCTP receiver thread */
227 SCreateSTsk(PRIOR3, &sctp_stsk);
228 //TODO: check core info to pin the above task to whcih core
230 /* Create TAPA tasks */
231 if(duAppInit(du_app_stsk) != ROK)
233 printf("\nDU APP TAPA Task initialization failed");
237 if(sctpInit(sctp_stsk) != ROK)
239 printf("\nSCTP TAPA Task initialization failed");
243 if(rlcDlInit(rlc_mac_cl_stsk) != ROK)
245 printf("\nRLC DL Tapa Task initialization failed");
249 if(rlcUlInit(rlc_ul_stsk) != ROK)
251 printf("\nRLC UL Tapa Task initialization failed");
257 /*******************************************************************
259 * @brief Initializes the DU
267 * - Registers DU Layers
270 * @return ROK - success
273 * ****************************************************************/
277 if(commonInit() != ROK)
285 /*******************************************************************
287 * @brief Entry point for the DU APP
294 * - Read config params into duCfgParams
295 * - Initiate the init functions
298 * @return ROK - success
301 * ****************************************************************/
305 //Initialize TAPA layers
311 //Read all the configs from du_utils.c into duCfgParams
315 //Establish SCTP connection
318 printf("\nEstablishing SCTP link with CU... \n");
319 //ret = establishSctp(); //To be implemeted in du_sctp.c
325 /**********************************************************************
327 **********************************************************************/