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"
36 /* global variables */
41 #include "O1Interface.h"
42 #include "CmInterface.h"
45 uint8_t rlcUlActvTsk (Pst *, Buffer *);
46 uint8_t rlcUlActvInit (Ent, Inst, Region, Reason);
47 uint8_t rlcDlActvTsk (Pst *, Buffer *);
48 uint8_t rlcDlActvInit (Ent, Inst, Region, Reason);
49 uint8_t macActvTsk (Pst *, Buffer *);
50 uint8_t macActvInit (Ent, Inst, Region, Reason);
51 uint8_t schActvTsk (Pst *, Buffer *);
52 uint8_t schActvInit(Ent, Inst, Region, Reason);
53 uint8_t lwrMacActvTsk(Pst *, Buffer *);
54 uint8_t lwrMacActvInit(Ent, Inst, Region, Reason);
56 uint8_t phyStubActvTsk(Pst *, Buffer *);
57 uint8_t phyStubActvInit(Ent, Inst, Region, Reason);
61 DuCfgParams duCfgParam;
64 extern NRCellDU cellParams;
67 /*******************************************************************
69 * @brief Initializes DU APP
73 * Function : duAppInit
76 * - Registers and attaches TAPA tasks belonging to
79 * @params[in] system task ID
80 * @return ROK - success
83 * ****************************************************************/
84 uint8_t duAppInit(SSTskId sysTskId)
86 /* Register DU APP TAPA Task for DU */
87 if(ODU_REG_TTSK((Ent)ENTDUAPP, (Inst)DU_INST, (Ttype)TTNORM, (Prior)PRIOR0,
88 duActvInit, (ActvTsk)duActvTsk) != ROK)
92 /* Attach DU APP TAPA Task for DU */
93 if (ODU_ATTACH_TTSK((Ent)ENTDUAPP, (Inst)0, sysTskId)!= ROK)
98 DU_LOG("\nINFO --> DU_APP : DU APP created and registered \
99 to %d sys task", sysTskId);
105 /*******************************************************************
107 * @brief update Rrm Policy at DU and process the slice cfg request
111 * Function : setRrmPolicy
114 * - update Rrm Policy at DU and process the slice cfg request
116 * @params[in] RrmPolicy rrmPolicy[], uint8_t policyNum, uint8_t memberList
117 * @return true - success
120 * ****************************************************************/
122 uint8_t setRrmPolicy(RrmPolicyList rrmPolicy[], uint8_t policyNum)
124 DU_LOG("\nINFO --> DU_APP : DU APP RRM number of policy %d,", \
126 for(uint8_t i=0; i<policyNum ; i++)
128 DU_LOG("\nINFO --> DU_APP : DU APP id = %s",rrmPolicy[i].id);
129 DU_LOG("\nINFO --> DU_APP : DU APP resourceType = %d", \
130 rrmPolicy[i].resourceType);
131 DU_LOG("\nINFO --> DU_APP : DU APP rRMPolicyMaxRatio = %d", \
132 rrmPolicy[i].rRMPolicyMaxRatio);
133 DU_LOG("\nINFO --> DU_APP : DU APP rRMPolicyMinRatio = %d", \
134 rrmPolicy[i].rRMPolicyMinRatio);
135 DU_LOG("\nINFO --> DU_APP : DU APP rRMPolicyDedicatedRatio = %d", \
136 rrmPolicy[i].rRMPolicyDedicatedRatio);
137 DU_LOG("\nINFO --> DU_APP : DU APP rRMMemberNum = %d", \
138 rrmPolicy[i].rRMMemberNum);
139 for(uint8_t j=0; j<rrmPolicy[i].rRMMemberNum ; j++)
141 DU_LOG("\nINFO --> DU_APP : DU APP mcc = %d%d%d", \
142 rrmPolicy[i].rRMPolicyMemberList[j].mcc[0], \
143 rrmPolicy[i].rRMPolicyMemberList[j].mcc[1], \
144 rrmPolicy[i].rRMPolicyMemberList[j].mcc[2]);
145 DU_LOG("\nINFO --> DU_APP : DU APP mnc = %d%d%d", \
146 rrmPolicy[i].rRMPolicyMemberList[j].mnc[0], \
147 rrmPolicy[i].rRMPolicyMemberList[j].mnc[1], \
148 rrmPolicy[i].rRMPolicyMemberList[j].mnc[2]);
150 DU_LOG("\nINFO --> DU_APP : DU APP sd = %d%d%d", \
151 rrmPolicy[i].rRMPolicyMemberList[j].sd[0], \
152 rrmPolicy[i].rRMPolicyMemberList[j].sd[1], \
153 rrmPolicy[i].rRMPolicyMemberList[j].sd[2]);
155 DU_LOG("\nINFO --> DU_APP : DU APP sst = %d\n", \
156 rrmPolicy[i].rRMPolicyMemberList[j].sst);
160 DuCellCb *cellCb = NULLP;
162 cpyRrmPolicyInDuCfgParams(rrmPolicy, policyNum, &duCfgParam.tempSliceCfg);
163 cellCb = duCb.actvCellLst[0];
167 if(cellCb->cellStatus == ACTIVATED)
169 if(duCb.sliceState == SLICE_INFO_NOT_AVAILABLE)
171 BuildAndSendSliceConfigReq();
175 BuildAndSendSliceRecfgReq();
182 /*******************************************************************
184 * @brief Bring the cell Up
188 * Function : bringCellUp
191 * - Bring the cell Up when requested from OAM
193 * @params[in] Cell Id
194 * @return true - success
197 * ****************************************************************/
199 bool bringCellUp(uint16_t cellId)
202 BuildAndSendF1SetupReq();
206 /*******************************************************************
208 * @brief configure cell parameters
212 * Function : configurecell
215 * - configure cell parameters
217 * @params[in] Cell Id
218 * @return true - success
221 * ****************************************************************/
223 uint8_t setCellParam()
225 //Read all the configs from smo edit-config into cellParams
226 DU_LOG("\nO1 configurecell du_app enterd");
227 DU_LOG("\nDU_APP configurecell cellLocalId value:%d",cellParams.cellLocalId);
228 DU_LOG("\nDU_APP configurecell operationalState value:%d", \
229 cellParams.operationalState);
230 DU_LOG("\nDU_APP configurecell administrativeState value:%d", \
231 cellParams.administrativeState);
232 DU_LOG("\nDU_APP configurecell cellState value:%d",cellParams.cellState);
233 DU_LOG("\nDU_APP configurecell nRPCI value:%d",cellParams.nRPCI);
234 DU_LOG("\nDU_APP configurecell nRTAC value:%d",cellParams.nRTAC);
235 DU_LOG("\nDU_APP configurecell arfcnDL value:%d",cellParams.arfcnDL);
236 DU_LOG("\nDU_APP configurecell arfcnUL value:%d",cellParams.arfcnUL);
237 DU_LOG("\nDU_APP configurecell arfcnSUL value:%d",cellParams.arfcnSUL);
238 DU_LOG("\nDU_APP configurecell ssbFrequency value:%d",cellParams.ssbFrequency);
239 DU_LOG("\nDU_APP configurecell ssbPeriodicity value:%d", \
240 cellParams.ssbPeriodicity);
241 DU_LOG("\nDU_APP configurecell ssbSubCarrierSpacing value:%d", \
242 cellParams.ssbSubCarrierSpacing);
243 DU_LOG("\nDU_APP configurecell ssbOffset value:%d",cellParams.ssbOffset);
244 DU_LOG("\nDU_APP configurecell ssbDuration value:%d",cellParams.ssbDuration);
245 DU_LOG("\nDU_APP configurecell bSChannelBwUL value:%d", \
246 cellParams.bSChannelBwUL);
247 DU_LOG("\nDU_APP configurecell bSChannelBwDL value:%d", \
248 cellParams.bSChannelBwDL);
249 DU_LOG("\nDU_APP configurecell bSChannelBwSUL value:%d", \
250 cellParams.bSChannelBwSUL);
251 for (int i=0 ; i<MAX_SUPPORTED_PLMN; i++)
254 DU_LOG("\nINFO --> DU_APP : DU APP mcellParams.plmnList[%d].mcc = %d%d%d", i,\
255 cellParams.plmnList[i].mcc[0], \
256 cellParams.plmnList[i].mcc[1], \
257 cellParams.plmnList[i].mcc[2]);
258 DU_LOG("\nINFO --> DU_APP : DU APP cellParams.plmnList[%d].mnc = %d%d%d", i,\
259 cellParams.plmnList[i].mnc[0], \
260 cellParams.plmnList[i].mnc[1], \
261 cellParams.plmnList[i].mnc[2]);
263 DU_LOG("\nINFO --> DU_APP : DU APP cellParams.plmnList[%d].sd = %d%d%d", i,\
264 cellParams.plmnList[i].sd[0], \
265 cellParams.plmnList[i].sd[1], \
266 cellParams.plmnList[i].sd[2]);
268 DU_LOG("\nINFO --> DU_APP : DU APP cellParams.plmnList[%d].sst = %d\n", i,\
269 cellParams.plmnList[i].sst);
276 /*******************************************************************
278 * @brief Bring the cell Down
282 * Function : bringCellDown
285 * - Bring the cell Down when requested from OAM
287 * @params[in] Cell Id
288 * @return true - success
291 * ****************************************************************/
293 bool bringCellDown(uint16_t cellId)
295 BuildAndSendDUConfigUpdate(SERV_CELL_TO_DELETE);
300 /*******************************************************************
302 * @brief Initializes EGTP
306 * Function : egtpInit
309 * - Registers and attaches TAPA tasks belonging to
312 * @params[in] system task ID
313 * @return ROK - success
316 * ****************************************************************/
317 uint8_t egtpInit(SSTskId sysTskId)
319 /* Register DU APP TAPA Task for DU */
320 if(ODU_REG_TTSK((Ent)ENTEGTP, (Inst)EGTP_INST, (Ttype)TTNORM, (Prior)PRIOR0,
321 egtpActvInit, (ActvTsk)egtpActvTsk) != ROK)
325 /* Attach DU APP TAPA Task for DU */
326 if (ODU_ATTACH_TTSK((Ent)ENTEGTP, (Inst)0, sysTskId)!= ROK)
331 DU_LOG("\nINFO --> DU_APP : EGTP created and registered \
332 to %d sys task", sysTskId);
337 /*******************************************************************
339 * @brief Initializes SCTP task
343 * Function : sctpInit
346 * - Registers and attaches TAPA tasks for SCTP receiver
348 * @params[in] system task ID
349 * @return ROK - success
352 * ****************************************************************/
353 uint8_t sctpInit(SSTskId sysTskId)
355 /* Register SCTP TAPA Task */
356 if(ODU_REG_TTSK((Ent)ENTSCTP, (Inst)0, (Ttype)TTNORM, (Prior)PRIOR0,
357 sctpActvInit, (ActvTsk)sctpActvTsk) != ROK)
361 /* Attach SCTP TAPA Task */
362 if (ODU_ATTACH_TTSK((Ent)ENTSCTP, (Inst)SCTP_INST, sysTskId)!= ROK)
367 DU_LOG("\nINFO --> DU_APP : SCTP TAPA task created and registered to %d sys task",
372 /*******************************************************************
374 * @brief Initializes RLC DL, MAC TAPA task
378 * Function : rlcDlInit
381 * - Registers and attaches TAPA tasks for MAC and RLC DL
383 * @params[in] system task ID
384 * @return ROK - success
387 * ****************************************************************/
388 uint8_t rlcDlInit(SSTskId sysTskId)
390 /* Register RLC DL TAPA Task */
391 if(ODU_REG_TTSK((Ent)ENTRLC, (Inst)1, (Ttype)TTNORM, (Prior)PRIOR0,
392 rlcDlActvInit, (ActvTsk)rlcDlActvTsk) != ROK)
396 /* Attach RLC DL Task */
397 if (ODU_ATTACH_TTSK((Ent)ENTRLC, (Inst)1, sysTskId)!= ROK)
402 /* Register MAC TAPA Task */
403 if(ODU_REG_TTSK((Ent)ENTMAC, (Inst)0, (Ttype)TTNORM, (Prior)PRIOR0,
404 macActvInit, (ActvTsk)macActvTsk) != ROK)
408 /* Attach MAC Task */
409 if (ODU_ATTACH_TTSK((Ent)ENTMAC, (Inst)0, sysTskId)!= ROK)
416 /*******************************************************************
418 * @brief Initializes SCH TAPA task
425 * - Registers and attaches TAPA tasks for SCH
427 * @params[in] system task ID
428 * @return ROK - success
431 * ****************************************************************/
432 uint8_t schInit(SSTskId sysTskId)
434 /* Register SCH TAPA Task */
435 if(ODU_REG_TTSK((Ent)ENTMAC, (Inst)SCH_INST_START, (Ttype)TTNORM, (Prior)PRIOR0,
436 schActvInit, (ActvTsk)schActvTsk) != ROK)
440 /* Attach SCH Task */
441 if (ODU_ATTACH_TTSK((Ent)ENTMAC, (Inst)SCH_INST_START, sysTskId)!= ROK)
447 DU_LOG("\nINFO --> DU_APP : SCH TAPA task created and registered to \
448 %d sys task", sysTskId);
452 /*******************************************************************
454 * @brief Initializes RLC UL TAPA task
458 * Function : rlcUlInit
461 * - Registers and attaches TAPA task for RLC UL
463 * @params[in] system task ID
464 * @return ROK - success
467 * ****************************************************************/
468 uint8_t rlcUlInit(SSTskId sysTskId)
470 /* Register RLC UL TAPA Task */
471 if(ODU_REG_TTSK((Ent)ENTRLC, (Inst)0, (Ttype)TTNORM, (Prior)PRIOR0,
472 rlcUlActvInit, (ActvTsk)rlcUlActvTsk) != ROK)
476 /* Attach RLC DL Task */
477 if (ODU_ATTACH_TTSK((Ent)ENTRLC, (Inst)0, sysTskId)!= ROK)
481 DU_LOG("\nINFO --> DU_APP : RLC UL TAPA task created and registered to \
482 %d sys task", sysTskId);
486 /*******************************************************************
488 * @brief Initializes Lower MAC receiver task
492 * Function : lwrMacInit
495 * - Registers and attaches TAPA tasks for Lower MAC receiver
497 * @params[in] system task ID
498 * @return ROK - success
501 * ****************************************************************/
502 uint8_t lwrMacInit(SSTskId sysTskId)
504 /* Register SCTP TAPA Task */
505 if(ODU_REG_TTSK((Ent)ENTLWRMAC, (Inst)0, (Ttype)TTNORM, (Prior)PRIOR0,
506 lwrMacActvInit, (ActvTsk)lwrMacActvTsk) != ROK)
510 /* Attach SCTP TAPA Task */
511 if (ODU_ATTACH_TTSK((Ent)ENTLWRMAC, (Inst)0, sysTskId)!= ROK)
516 DU_LOG("\nINFO --> DU_APP : LWR MAC TAPA task created and registered to %d sys task",
521 #ifndef INTEL_WLS_MEM
522 /*******************************************************************
524 * @brief Initializes Phy stub slot indication generator task
528 * Function : phyStubInit
531 * - Registers and attaches TAPA tasks for Phy stub's slot
532 * indication generator
534 * @params[in] system task ID
535 * @return ROK - success
538 * ****************************************************************/
539 uint8_t phyStubInit(SSTskId sysTskId)
541 /* Register PHY stub slot indication TAPA Task */
542 if(ODU_REG_TTSK((Ent)ENTPHYSTUB, (Inst)0, (Ttype)TTNORM, (Prior)PRIOR0,
543 phyStubActvInit, (ActvTsk)phyStubActvTsk) != ROK)
547 /* Attach Phy stub slot indication TAPA Task */
548 if (ODU_ATTACH_TTSK((Ent)ENTPHYSTUB, (Inst)0, sysTskId)!= ROK)
553 DU_LOG("\nINFO --> DU_APP : PHY stub slot indication TAPA task created and registered to %d sys task",
559 /*******************************************************************
561 * @brief Initializes system and TAPA tasks
565 * Function : commonInit
568 * - Registers and attaches system and TAPA tasks
571 * @return ROK - success
574 * ****************************************************************/
577 /* Declare system task Ids */
578 SSTskId phyStubSlotIndSTskId;
582 ODU_SET_PROC_ID(DU_PROC);
584 /* Intel L1 using core 0-15. ODU-High using 16-21 */
585 /* system task for DU APP */
586 if(ODU_CREATE_TASK(PRIOR0, &duCfgParam.threadInfo.duAppSTskId) != ROK)
588 DU_LOG("\nERROR --> DU_APP : System Task creation for DU APP failed");
592 /* system task for EGTP */
593 if(ODU_CREATE_TASK(PRIOR0, &duCfgParam.threadInfo.egtpSTskId) != ROK)
595 DU_LOG("\nERROR --> DU_APP : System Task creation for EGTP failed");
599 /* system task for RLC_DL and MAC */
600 if(ODU_CREATE_TASK(PRIOR0, &duCfgParam.threadInfo.rlcMacSTskId) != ROK)
602 DU_LOG("\nERROR --> DU_APP : System Task creation for RLC DL/MAC failed");
605 pthread_attr_init(&attr);
606 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
608 /* system task for RLC UL */
609 if(ODU_CREATE_TASK(PRIOR1, &duCfgParam.threadInfo.rlcUlSTskId) != ROK)
611 DU_LOG("\nERROR --> DU_APP : System Task creation for RLC UL failed");
615 /* system task for SCH */
616 if(ODU_CREATE_TASK(PRIOR1, &duCfgParam.threadInfo.schSTskId) != ROK)
618 DU_LOG("\nERROR --> DU_APP : System Task creation for SCH failed");
622 /* system task for SCTP receiver thread */
623 if(ODU_CREATE_TASK(PRIOR0, &duCfgParam.threadInfo.sctpSTskId) != ROK)
625 DU_LOG("\nERROR --> DU_APP : System Task creation for SCTP failed");
629 /* system task for lower-mac receiver thread */
630 if(ODU_CREATE_TASK(PRIOR0, &duCfgParam.threadInfo.lwrMacSTskId) != ROK)
632 DU_LOG("\nERROR --> DU_APP : System Task creation for Lower MAC failed");
636 #ifndef INTEL_WLS_MEM
637 /* system task for phy stub's slot indication generator thread */
638 if(ODU_CREATE_TASK(PRIOR0, &phyStubSlotIndSTskId) != ROK)
640 DU_LOG("\nERROR --> DU_APP : System Task creation for Phy stub slot indication generator failed. MAX STSK [%d]", SS_MAX_STSKS);
646 /* Create TAPA tasks */
647 if(duAppInit(duCfgParam.threadInfo.duAppSTskId) != ROK)
649 DU_LOG("\nERROR --> DU_APP : DU APP TAPA Task initialization failed");
653 if(egtpInit(duCfgParam.threadInfo.egtpSTskId) != ROK)
655 DU_LOG("\nERROR --> DU_APP : EGTP TAPA Task initialization failed");
659 if(sctpInit(duCfgParam.threadInfo.sctpSTskId) != ROK)
661 DU_LOG("\nERROR --> DU_APP : SCTP TAPA Task initialization failed");
665 if(rlcDlInit(duCfgParam.threadInfo.rlcMacSTskId) != ROK)
667 DU_LOG("\nERROR --> DU_APP : RLC DL Tapa Task initialization failed");
671 if(rlcUlInit(duCfgParam.threadInfo.rlcUlSTskId) != ROK)
673 DU_LOG("\nERROR --> DU_APP : RLC UL Tapa Task initialization failed");
677 if(schInit(duCfgParam.threadInfo.schSTskId) != ROK)
679 DU_LOG("\nERROR --> DU_APP : SCH Tapa Task initialization failed");
683 if(lwrMacInit(duCfgParam.threadInfo.lwrMacSTskId) != ROK)
685 DU_LOG("\nERROR --> DU_APP : Lower MAC Tapa Task initialization failed");
689 #ifndef INTEL_WLS_MEM
690 if(phyStubInit(phyStubSlotIndSTskId) != ROK)
692 DU_LOG("\nERROR --> DU_APP : PHY stub slot indication Tapa Task initialization failed");
701 /*******************************************************************
703 * @brief Initializes the DU
711 * - Registers DU Layers
714 * @return ROK - success
717 * ****************************************************************/
721 if(commonInit() != ROK)
730 openlog("ODU",LOG_CONS | LOG_PID | LOG_NDELAY, LOG_LOCAL1);
733 /*******************************************************************
735 * @brief Entry point for the DU APP
742 * - Read config params into duCfgParams
743 * - Initiate the init functions
746 * @return ROK - success
749 * ****************************************************************/
754 if(start_O1_module() != ROK)
758 memset(&duCfgParam, 0, sizeof(DuCfgParams));
760 //Initialize TAPA layers
766 //Read all the configs from du_utils.c into duCfgParams
772 //Send VES PNF registration message to SMO
773 sendPnfRegistration();
780 /**********************************************************************
782 **********************************************************************/