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"
26 #include "du_app_mac_inf.h"
27 #include "du_app_rlc_inf.h"
28 #include "du_e2ap_mgr.h"
31 #include "du_mgr_main.h"
34 #include "du_cell_mgr.h"
35 #include "du_f1ap_msg_hdl.h"
39 #include "O1Interface.h"
40 #include "CmInterface.h"
43 uint8_t rlcUlActvTsk (Pst *, Buffer *);
44 uint8_t rlcUlActvInit (Ent, Inst, Region, Reason);
45 uint8_t rlcDlActvTsk (Pst *, Buffer *);
46 uint8_t rlcDlActvInit (Ent, Inst, Region, Reason);
47 uint8_t macActvTsk (Pst *, Buffer *);
48 uint8_t macActvInit (Ent, Inst, Region, Reason);
49 uint8_t lwrMacActvTsk(Pst *, Buffer *);
50 uint8_t lwrMacActvInit(Ent, Inst, Region, Reason);
52 uint8_t phyStubActvTsk(Pst *, Buffer *);
53 uint8_t phyStubActvInit(Ent, Inst, Region, Reason);
57 DuCfgParams duCfgParam;
60 extern NRCellDU cellParams;
63 /*******************************************************************
65 * @brief Initializes DU APP
69 * Function : duAppInit
72 * - Registers and attaches TAPA tasks belonging to
75 * @params[in] system task ID
76 * @return ROK - success
79 * ****************************************************************/
80 uint8_t duAppInit(SSTskId sysTskId)
82 /* Register DU APP TAPA Task for DU */
83 if(ODU_REG_TTSK((Ent)ENTDUAPP, (Inst)DU_INST, (Ttype)TTNORM, (Prior)PRIOR0,
84 duActvInit, (ActvTsk)duActvTsk) != ROK)
88 /* Attach DU APP TAPA Task for DU */
89 if (ODU_ATTACH_TTSK((Ent)ENTDUAPP, (Inst)0, sysTskId)!= ROK)
94 DU_LOG("\nINFO --> DU_APP : DU APP created and registered \
95 to %d sys task", sysTskId);
101 /*******************************************************************
103 * @brief update Rrm Policy at DU and process the slice cfg request
107 * Function : setRrmPolicy
110 * - update Rrm Policy at DU and process the slice cfg request
112 * @params[in] RrmPolicy rrmPolicy[], uint8_t policyNum, uint8_t memberList
113 * @return true - success
116 * ****************************************************************/
118 uint8_t setRrmPolicy(RrmPolicyList rrmPolicy[], uint8_t policyNum)
120 DU_LOG("\nINFO --> DU_APP : DU APP RRM number of policy %d,", \
122 for(uint8_t i=0; i<policyNum ; i++)
124 DU_LOG("\nINFO --> DU_APP : DU APP id = %s",rrmPolicy[i].id);
125 DU_LOG("\nINFO --> DU_APP : DU APP resourceType = %d", \
126 rrmPolicy[i].resourceType);
127 DU_LOG("\nINFO --> DU_APP : DU APP rRMPolicyMaxRatio = %d", \
128 rrmPolicy[i].rRMPolicyMaxRatio);
129 DU_LOG("\nINFO --> DU_APP : DU APP rRMPolicyMinRatio = %d", \
130 rrmPolicy[i].rRMPolicyMinRatio);
131 DU_LOG("\nINFO --> DU_APP : DU APP rRMPolicyDedicatedRatio = %d", \
132 rrmPolicy[i].rRMPolicyDedicatedRatio);
133 DU_LOG("\nINFO --> DU_APP : DU APP rRMMemberNum = %d", \
134 rrmPolicy[i].rRMMemberNum);
135 for(uint8_t j=0; j<rrmPolicy[i].rRMMemberNum ; j++)
137 DU_LOG("\nINFO --> DU_APP : DU APP mcc = %d%d%d", \
138 rrmPolicy[i].rRMPolicyMemberList[j].mcc[0], \
139 rrmPolicy[i].rRMPolicyMemberList[j].mcc[1], \
140 rrmPolicy[i].rRMPolicyMemberList[j].mcc[2]);
141 DU_LOG("\nINFO --> DU_APP : DU APP mnc = %d%d%d", \
142 rrmPolicy[i].rRMPolicyMemberList[j].mnc[0], \
143 rrmPolicy[i].rRMPolicyMemberList[j].mnc[1], \
144 rrmPolicy[i].rRMPolicyMemberList[j].mnc[2]);
146 DU_LOG("\nINFO --> DU_APP : DU APP sd = %d%d%d", \
147 rrmPolicy[i].rRMPolicyMemberList[j].sd[0], \
148 rrmPolicy[i].rRMPolicyMemberList[j].sd[1], \
149 rrmPolicy[i].rRMPolicyMemberList[j].sd[2]);
151 DU_LOG("\nINFO --> DU_APP : DU APP sst = %d\n", \
152 rrmPolicy[i].rRMPolicyMemberList[j].sst);
156 DuCellCb *cellCb = NULLP;
158 cpyRrmPolicyInDuCfgParams(rrmPolicy, policyNum, &duCfgParam.tempSliceCfg);
159 cellCb = duCb.actvCellLst[0];
163 if(cellCb->cellStatus == ACTIVATED)
165 if(duCb.sliceState == SLICE_INFO_NOT_AVAILABLE)
167 BuildAndSendSliceConfigReq();
171 BuildAndSendSliceRecfgReq();
178 /*******************************************************************
180 * @brief Bring the cell Up
184 * Function : bringCellUp
187 * - Bring the cell Up when requested from OAM
189 * @params[in] Cell Id
190 * @return true - success
193 * ****************************************************************/
195 bool bringCellUp(uint16_t cellId)
198 BuildAndSendF1SetupReq();
202 /*******************************************************************
204 * @brief configure cell parameters
208 * Function : configurecell
211 * - configure cell parameters
213 * @params[in] Cell Id
214 * @return true - success
217 * ****************************************************************/
219 uint8_t setCellParam()
221 //Read all the configs from smo edit-config into cellParams
222 DU_LOG("\nO1 configurecell du_app enterd");
223 DU_LOG("\nDU_APP configurecell cellLocalId value:%d",cellParams.cellLocalId);
224 DU_LOG("\nDU_APP configurecell operationalState value:%d", \
225 cellParams.operationalState);
226 DU_LOG("\nDU_APP configurecell administrativeState value:%d", \
227 cellParams.administrativeState);
228 DU_LOG("\nDU_APP configurecell cellState value:%d",cellParams.cellState);
229 DU_LOG("\nDU_APP configurecell nRPCI value:%d",cellParams.nRPCI);
230 DU_LOG("\nDU_APP configurecell nRTAC value:%d",cellParams.nRTAC);
231 DU_LOG("\nDU_APP configurecell arfcnDL value:%d",cellParams.arfcnDL);
232 DU_LOG("\nDU_APP configurecell arfcnUL value:%d",cellParams.arfcnUL);
233 DU_LOG("\nDU_APP configurecell arfcnSUL value:%d",cellParams.arfcnSUL);
234 DU_LOG("\nDU_APP configurecell ssbFrequency value:%d",cellParams.ssbFrequency);
235 DU_LOG("\nDU_APP configurecell ssbPeriodicity value:%d", \
236 cellParams.ssbPeriodicity);
237 DU_LOG("\nDU_APP configurecell ssbSubCarrierSpacing value:%d", \
238 cellParams.ssbSubCarrierSpacing);
239 DU_LOG("\nDU_APP configurecell ssbOffset value:%d",cellParams.ssbOffset);
240 DU_LOG("\nDU_APP configurecell ssbDuration value:%d",cellParams.ssbDuration);
241 DU_LOG("\nDU_APP configurecell bSChannelBwUL value:%d", \
242 cellParams.bSChannelBwUL);
243 DU_LOG("\nDU_APP configurecell bSChannelBwDL value:%d", \
244 cellParams.bSChannelBwDL);
245 DU_LOG("\nDU_APP configurecell bSChannelBwSUL value:%d", \
246 cellParams.bSChannelBwSUL);
247 for (int i=0 ; i<MAX_SUPPORTED_PLMN; i++)
250 DU_LOG("\nINFO --> DU_APP : DU APP mcellParams.plmnList[%d].mcc = %d%d%d", i,\
251 cellParams.plmnList[i].mcc[0], \
252 cellParams.plmnList[i].mcc[1], \
253 cellParams.plmnList[i].mcc[2]);
254 DU_LOG("\nINFO --> DU_APP : DU APP cellParams.plmnList[%d].mnc = %d%d%d", i,\
255 cellParams.plmnList[i].mnc[0], \
256 cellParams.plmnList[i].mnc[1], \
257 cellParams.plmnList[i].mnc[2]);
259 DU_LOG("\nINFO --> DU_APP : DU APP cellParams.plmnList[%d].sd = %d%d%d", i,\
260 cellParams.plmnList[i].sd[0], \
261 cellParams.plmnList[i].sd[1], \
262 cellParams.plmnList[i].sd[2]);
264 DU_LOG("\nINFO --> DU_APP : DU APP cellParams.plmnList[%d].sst = %d\n", i,\
265 cellParams.plmnList[i].sst);
272 /*******************************************************************
274 * @brief Bring the cell Down
278 * Function : bringCellDown
281 * - Bring the cell Down when requested from OAM
283 * @params[in] Cell Id
284 * @return true - success
287 * ****************************************************************/
289 bool bringCellDown(uint16_t cellId)
291 BuildAndSendDUConfigUpdate(SERV_CELL_TO_DELETE);
296 /*******************************************************************
298 * @brief Initializes EGTP
302 * Function : egtpInit
305 * - Registers and attaches TAPA tasks belonging to
308 * @params[in] system task ID
309 * @return ROK - success
312 * ****************************************************************/
313 uint8_t egtpInit(SSTskId sysTskId)
315 /* Register DU APP TAPA Task for DU */
316 if(ODU_REG_TTSK((Ent)ENTEGTP, (Inst)EGTP_INST, (Ttype)TTNORM, (Prior)PRIOR0,
317 egtpActvInit, (ActvTsk)egtpActvTsk) != ROK)
321 /* Attach DU APP TAPA Task for DU */
322 if (ODU_ATTACH_TTSK((Ent)ENTEGTP, (Inst)0, sysTskId)!= ROK)
327 DU_LOG("\nINFO --> DU_APP : EGTP created and registered \
328 to %d sys task", sysTskId);
333 /*******************************************************************
335 * @brief Initializes SCTP task
339 * Function : sctpInit
342 * - Registers and attaches TAPA tasks for SCTP receiver
344 * @params[in] system task ID
345 * @return ROK - success
348 * ****************************************************************/
349 uint8_t sctpInit(SSTskId sysTskId)
351 /* Register SCTP TAPA Task */
352 if(ODU_REG_TTSK((Ent)ENTSCTP, (Inst)0, (Ttype)TTNORM, (Prior)PRIOR0,
353 sctpActvInit, (ActvTsk)sctpActvTsk) != ROK)
357 /* Attach SCTP TAPA Task */
358 if (ODU_ATTACH_TTSK((Ent)ENTSCTP, (Inst)SCTP_INST, sysTskId)!= ROK)
363 DU_LOG("\nINFO --> DU_APP : SCTP TAPA task created and registered to %d sys task",
367 /*******************************************************************
369 * @brief Initializes RLC DL, MAC TAPA task
373 * Function : rlcDlInit
376 * - Registers and attaches TAPA tasks for MAC and RLC DL
378 * @params[in] system task ID
379 * @return ROK - success
382 * ****************************************************************/
383 uint8_t rlcDlInit(SSTskId sysTskId)
385 /* Register RLC DL TAPA Task */
386 if(ODU_REG_TTSK((Ent)ENTRLC, (Inst)1, (Ttype)TTNORM, (Prior)PRIOR0,
387 rlcDlActvInit, (ActvTsk)rlcDlActvTsk) != ROK)
391 /* Attach RLC DL Task */
392 if (ODU_ATTACH_TTSK((Ent)ENTRLC, (Inst)1, sysTskId)!= ROK)
397 /* Register MAC TAPA Task */
398 if(ODU_REG_TTSK((Ent)ENTMAC, (Inst)0, (Ttype)TTNORM, (Prior)PRIOR0,
399 macActvInit, (ActvTsk)macActvTsk) != ROK)
403 /* Attach MAC Task */
404 if (ODU_ATTACH_TTSK((Ent)ENTMAC, (Inst)0, sysTskId)!= ROK)
409 DU_LOG("\nINFO --> DU_APP : RLC DL and MAC TAPA task created and registered to \
410 %d sys task", sysTskId);
414 /*******************************************************************
416 * @brief Initializes RLC UL TAPA task
420 * Function : rlcUlInit
423 * - Registers and attaches TAPA task for RLC UL
425 * @params[in] system task ID
426 * @return ROK - success
429 * ****************************************************************/
430 uint8_t rlcUlInit(SSTskId sysTskId)
432 /* Register RLC UL TAPA Task */
433 if(ODU_REG_TTSK((Ent)ENTRLC, (Inst)0, (Ttype)TTNORM, (Prior)PRIOR0,
434 rlcUlActvInit, (ActvTsk)rlcUlActvTsk) != ROK)
438 /* Attach RLC DL Task */
439 if (ODU_ATTACH_TTSK((Ent)ENTRLC, (Inst)0, sysTskId)!= ROK)
443 DU_LOG("\nINFO --> DU_APP : RLC UL TAPA task created and registered to \
444 %d sys task", sysTskId);
448 /*******************************************************************
450 * @brief Initializes Lower MAC receiver task
454 * Function : lwrMacInit
457 * - Registers and attaches TAPA tasks for Lower MAC receiver
459 * @params[in] system task ID
460 * @return ROK - success
463 * ****************************************************************/
464 uint8_t lwrMacInit(SSTskId sysTskId)
466 /* Register SCTP TAPA Task */
467 if(ODU_REG_TTSK((Ent)ENTLWRMAC, (Inst)0, (Ttype)TTNORM, (Prior)PRIOR0,
468 lwrMacActvInit, (ActvTsk)lwrMacActvTsk) != ROK)
472 /* Attach SCTP TAPA Task */
473 if (ODU_ATTACH_TTSK((Ent)ENTLWRMAC, (Inst)0, sysTskId)!= ROK)
478 DU_LOG("\nINFO --> DU_APP : LWR MAC TAPA task created and registered to %d sys task",
483 #ifndef INTEL_WLS_MEM
484 /*******************************************************************
486 * @brief Initializes Phy stub slot indication generator task
490 * Function : phyStubInit
493 * - Registers and attaches TAPA tasks for Phy stub's slot
494 * indication generator
496 * @params[in] system task ID
497 * @return ROK - success
500 * ****************************************************************/
501 uint8_t phyStubInit(SSTskId sysTskId)
503 /* Register PHY stub slot indication TAPA Task */
504 if(ODU_REG_TTSK((Ent)ENTPHYSTUB, (Inst)0, (Ttype)TTNORM, (Prior)PRIOR0,
505 phyStubActvInit, (ActvTsk)phyStubActvTsk) != ROK)
509 /* Attach Phy stub slot indication TAPA Task */
510 if (ODU_ATTACH_TTSK((Ent)ENTPHYSTUB, (Inst)0, sysTskId)!= ROK)
515 DU_LOG("\nINFO --> DU_APP : PHY stub slot indication TAPA task created and registered to %d sys task",
521 /*******************************************************************
523 * @brief Initializes system and TAPA tasks
527 * Function : commonInit
530 * - Registers and attaches system and TAPA tasks
533 * @return ROK - success
536 * ****************************************************************/
539 /* Declare system task Ids */
540 SSTskId du_app_stsk, egtp_stsk, sctp_stsk, rlc_ul_stsk, rlc_mac_cl_stsk, lwr_mac_stsk, phy_stub_slot_ind_stsk;
544 ODU_SET_PROC_ID(DU_PROC);
546 /* Intel L1 using core 0-15. ODU-High using 16-21 */
547 /* system task for DU APP */
548 if(ODU_CREATE_TASK(PRIOR0, &du_app_stsk) != ROK)
550 DU_LOG("\nERROR --> DU_APP : System Task creation for DU APP failed");
553 ODU_SET_THREAD_AFFINITY(&du_app_stsk, SS_AFFINITY_MODE_EXCL, 16, 0);
555 /* system task for EGTP */
556 if(ODU_CREATE_TASK(PRIOR0, &egtp_stsk) != ROK)
558 DU_LOG("\nERROR --> DU_APP : System Task creation for EGTP failed");
561 ODU_SET_THREAD_AFFINITY(&egtp_stsk, SS_AFFINITY_MODE_EXCL, 27, 0);
563 /* system task for RLC_DL and MAC */
564 if(ODU_CREATE_TASK(PRIOR0, &rlc_mac_cl_stsk) != ROK)
566 DU_LOG("\nERROR --> DU_APP : System Task creation for RLC DL/MAC failed");
569 pthread_attr_init(&attr);
570 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
571 ODU_SET_THREAD_AFFINITY(&rlc_mac_cl_stsk, SS_AFFINITY_MODE_EXCL, 18, 0);
573 /* system task for RLC UL */
574 if(ODU_CREATE_TASK(PRIOR1, &rlc_ul_stsk) != ROK)
576 DU_LOG("\nERROR --> DU_APP : System Task creation for RLC UL failed");
579 ODU_SET_THREAD_AFFINITY(&rlc_ul_stsk, SS_AFFINITY_MODE_EXCL, 22, 0);
581 /* system task for SCTP receiver thread */
582 if(ODU_CREATE_TASK(PRIOR0, &sctp_stsk) != ROK)
584 DU_LOG("\nERROR --> DU_APP : System Task creation for SCTP failed");
587 ODU_SET_THREAD_AFFINITY(&sctp_stsk, SS_AFFINITY_MODE_EXCL, 25, 0);
589 /* system task for lower-mac receiver thread */
590 if(ODU_CREATE_TASK(PRIOR0, &lwr_mac_stsk) != ROK)
592 DU_LOG("\nERROR --> DU_APP : System Task creation for Lower MAC failed");
595 ODU_SET_THREAD_AFFINITY(&lwr_mac_stsk, SS_AFFINITY_MODE_EXCL, 21, 0);
597 #ifndef INTEL_WLS_MEM
598 /* system task for phy stub's slot indication generator thread */
599 if(ODU_CREATE_TASK(PRIOR0, &phy_stub_slot_ind_stsk) != ROK)
601 DU_LOG("\nERROR --> DU_APP : System Task creation for Phy stub slot indication generator failed. MAX STSK [%d]", SS_MAX_STSKS);
607 /* Create TAPA tasks */
608 if(duAppInit(du_app_stsk) != ROK)
610 DU_LOG("\nERROR --> DU_APP : DU APP TAPA Task initialization failed");
614 if(egtpInit(egtp_stsk) != ROK)
616 DU_LOG("\nERROR --> DU_APP : EGTP TAPA Task initialization failed");
620 if(sctpInit(sctp_stsk) != ROK)
622 DU_LOG("\nERROR --> DU_APP : SCTP TAPA Task initialization failed");
626 if(rlcDlInit(rlc_mac_cl_stsk) != ROK)
628 DU_LOG("\nERROR --> DU_APP : RLC DL Tapa Task initialization failed");
632 if(rlcUlInit(rlc_ul_stsk) != ROK)
634 DU_LOG("\nERROR --> DU_APP : RLC UL Tapa Task initialization failed");
638 if(lwrMacInit(lwr_mac_stsk) != ROK)
640 DU_LOG("\nERROR --> DU_APP : Lower MAC Tapa Task initialization failed");
644 #ifndef INTEL_WLS_MEM
645 if(phyStubInit(phy_stub_slot_ind_stsk) != ROK)
647 DU_LOG("\nERROR --> DU_APP : PHY stub slot indication Tapa Task initialization failed");
656 /*******************************************************************
658 * @brief Initializes the DU
666 * - Registers DU Layers
669 * @return ROK - success
672 * ****************************************************************/
676 if(commonInit() != ROK)
685 openlog("ODU",LOG_CONS | LOG_PID | LOG_NDELAY, LOG_LOCAL1);
688 /*******************************************************************
690 * @brief Entry point for the DU APP
697 * - Read config params into duCfgParams
698 * - Initiate the init functions
701 * @return ROK - success
704 * ****************************************************************/
709 if(start_O1_module() != ROK)
712 //Initialize TAPA layers
718 //Read all the configs from du_utils.c into duCfgParams
724 //Send VES PNF registration message to SMO
725 sendPnfRegistration();
732 /**********************************************************************
734 **********************************************************************/