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 schActvTsk (Pst *, Buffer *);
50 uint8_t schActvInit(Ent, Inst, Region, Reason);
51 uint8_t lwrMacActvTsk(Pst *, Buffer *);
52 uint8_t lwrMacActvInit(Ent, Inst, Region, Reason);
54 uint8_t phyStubActvTsk(Pst *, Buffer *);
55 uint8_t phyStubActvInit(Ent, Inst, Region, Reason);
59 DuCfgParams duCfgParam;
62 extern NRCellDU cellParams;
65 /*******************************************************************
67 * @brief Initializes DU APP
71 * Function : duAppInit
74 * - Registers and attaches TAPA tasks belonging to
77 * @params[in] system task ID
78 * @return ROK - success
81 * ****************************************************************/
82 uint8_t duAppInit(SSTskId sysTskId)
84 /* Register DU APP TAPA Task for DU */
85 if(ODU_REG_TTSK((Ent)ENTDUAPP, (Inst)DU_INST, (Ttype)TTNORM, (Prior)PRIOR0,
86 duActvInit, (ActvTsk)duActvTsk) != ROK)
90 /* Attach DU APP TAPA Task for DU */
91 if (ODU_ATTACH_TTSK((Ent)ENTDUAPP, (Inst)0, sysTskId)!= ROK)
96 DU_LOG("\nINFO --> DU_APP : DU APP created and registered \
97 to %d sys task", sysTskId);
103 /*******************************************************************
105 * @brief update Rrm Policy at DU and process the slice cfg request
109 * Function : setRrmPolicy
112 * - update Rrm Policy at DU and process the slice cfg request
114 * @params[in] RrmPolicy rrmPolicy[], uint8_t policyNum, uint8_t memberList
115 * @return true - success
118 * ****************************************************************/
120 uint8_t setRrmPolicy(RrmPolicyList rrmPolicy[], uint8_t policyNum)
122 DU_LOG("\nINFO --> DU_APP : DU APP RRM number of policy %d,", \
124 for(uint8_t i=0; i<policyNum ; i++)
126 DU_LOG("\nINFO --> DU_APP : DU APP id = %s",rrmPolicy[i].id);
127 DU_LOG("\nINFO --> DU_APP : DU APP resourceType = %d", \
128 rrmPolicy[i].resourceType);
129 DU_LOG("\nINFO --> DU_APP : DU APP rRMPolicyMaxRatio = %d", \
130 rrmPolicy[i].rRMPolicyMaxRatio);
131 DU_LOG("\nINFO --> DU_APP : DU APP rRMPolicyMinRatio = %d", \
132 rrmPolicy[i].rRMPolicyMinRatio);
133 DU_LOG("\nINFO --> DU_APP : DU APP rRMPolicyDedicatedRatio = %d", \
134 rrmPolicy[i].rRMPolicyDedicatedRatio);
135 DU_LOG("\nINFO --> DU_APP : DU APP rRMMemberNum = %d", \
136 rrmPolicy[i].rRMMemberNum);
137 for(uint8_t j=0; j<rrmPolicy[i].rRMMemberNum ; j++)
139 DU_LOG("\nINFO --> DU_APP : DU APP mcc = %d%d%d", \
140 rrmPolicy[i].rRMPolicyMemberList[j].mcc[0], \
141 rrmPolicy[i].rRMPolicyMemberList[j].mcc[1], \
142 rrmPolicy[i].rRMPolicyMemberList[j].mcc[2]);
143 DU_LOG("\nINFO --> DU_APP : DU APP mnc = %d%d%d", \
144 rrmPolicy[i].rRMPolicyMemberList[j].mnc[0], \
145 rrmPolicy[i].rRMPolicyMemberList[j].mnc[1], \
146 rrmPolicy[i].rRMPolicyMemberList[j].mnc[2]);
148 DU_LOG("\nINFO --> DU_APP : DU APP sd = %d%d%d", \
149 rrmPolicy[i].rRMPolicyMemberList[j].sd[0], \
150 rrmPolicy[i].rRMPolicyMemberList[j].sd[1], \
151 rrmPolicy[i].rRMPolicyMemberList[j].sd[2]);
153 DU_LOG("\nINFO --> DU_APP : DU APP sst = %d\n", \
154 rrmPolicy[i].rRMPolicyMemberList[j].sst);
158 DuCellCb *cellCb = NULLP;
160 cpyRrmPolicyInDuCfgParams(rrmPolicy, policyNum, &duCfgParam.tempSliceCfg);
161 cellCb = duCb.actvCellLst[0];
165 if(cellCb->cellStatus == ACTIVATED)
167 if(duCb.sliceState == SLICE_INFO_NOT_AVAILABLE)
169 BuildAndSendSliceConfigReq();
173 BuildAndSendSliceRecfgReq();
180 /*******************************************************************
182 * @brief Bring the cell Up
186 * Function : bringCellUp
189 * - Bring the cell Up when requested from OAM
191 * @params[in] Cell Id
192 * @return true - success
195 * ****************************************************************/
197 bool bringCellUp(uint16_t cellId)
200 BuildAndSendF1SetupReq();
204 /*******************************************************************
206 * @brief configure cell parameters
210 * Function : configurecell
213 * - configure cell parameters
215 * @params[in] Cell Id
216 * @return true - success
219 * ****************************************************************/
221 uint8_t setCellParam()
223 //Read all the configs from smo edit-config into cellParams
224 DU_LOG("\nO1 configurecell du_app enterd");
225 DU_LOG("\nDU_APP configurecell cellLocalId value:%d",cellParams.cellLocalId);
226 DU_LOG("\nDU_APP configurecell operationalState value:%d", \
227 cellParams.operationalState);
228 DU_LOG("\nDU_APP configurecell administrativeState value:%d", \
229 cellParams.administrativeState);
230 DU_LOG("\nDU_APP configurecell cellState value:%d",cellParams.cellState);
231 DU_LOG("\nDU_APP configurecell nRPCI value:%d",cellParams.nRPCI);
232 DU_LOG("\nDU_APP configurecell nRTAC value:%d",cellParams.nRTAC);
233 DU_LOG("\nDU_APP configurecell arfcnDL value:%d",cellParams.arfcnDL);
234 DU_LOG("\nDU_APP configurecell arfcnUL value:%d",cellParams.arfcnUL);
235 DU_LOG("\nDU_APP configurecell arfcnSUL value:%d",cellParams.arfcnSUL);
236 DU_LOG("\nDU_APP configurecell ssbFrequency value:%d",cellParams.ssbFrequency);
237 DU_LOG("\nDU_APP configurecell ssbPeriodicity value:%d", \
238 cellParams.ssbPeriodicity);
239 DU_LOG("\nDU_APP configurecell ssbSubCarrierSpacing value:%d", \
240 cellParams.ssbSubCarrierSpacing);
241 DU_LOG("\nDU_APP configurecell ssbOffset value:%d",cellParams.ssbOffset);
242 DU_LOG("\nDU_APP configurecell ssbDuration value:%d",cellParams.ssbDuration);
243 DU_LOG("\nDU_APP configurecell bSChannelBwUL value:%d", \
244 cellParams.bSChannelBwUL);
245 DU_LOG("\nDU_APP configurecell bSChannelBwDL value:%d", \
246 cellParams.bSChannelBwDL);
247 DU_LOG("\nDU_APP configurecell bSChannelBwSUL value:%d", \
248 cellParams.bSChannelBwSUL);
249 for (int i=0 ; i<MAX_SUPPORTED_PLMN; i++)
252 DU_LOG("\nINFO --> DU_APP : DU APP mcellParams.plmnList[%d].mcc = %d%d%d", i,\
253 cellParams.plmnList[i].mcc[0], \
254 cellParams.plmnList[i].mcc[1], \
255 cellParams.plmnList[i].mcc[2]);
256 DU_LOG("\nINFO --> DU_APP : DU APP cellParams.plmnList[%d].mnc = %d%d%d", i,\
257 cellParams.plmnList[i].mnc[0], \
258 cellParams.plmnList[i].mnc[1], \
259 cellParams.plmnList[i].mnc[2]);
261 DU_LOG("\nINFO --> DU_APP : DU APP cellParams.plmnList[%d].sd = %d%d%d", i,\
262 cellParams.plmnList[i].sd[0], \
263 cellParams.plmnList[i].sd[1], \
264 cellParams.plmnList[i].sd[2]);
266 DU_LOG("\nINFO --> DU_APP : DU APP cellParams.plmnList[%d].sst = %d\n", i,\
267 cellParams.plmnList[i].sst);
274 /*******************************************************************
276 * @brief Bring the cell Down
280 * Function : bringCellDown
283 * - Bring the cell Down when requested from OAM
285 * @params[in] Cell Id
286 * @return true - success
289 * ****************************************************************/
291 bool bringCellDown(uint16_t cellId)
293 BuildAndSendDUConfigUpdate(SERV_CELL_TO_DELETE);
298 /*******************************************************************
300 * @brief Initializes EGTP
304 * Function : egtpInit
307 * - Registers and attaches TAPA tasks belonging to
310 * @params[in] system task ID
311 * @return ROK - success
314 * ****************************************************************/
315 uint8_t egtpInit(SSTskId sysTskId)
317 /* Register DU APP TAPA Task for DU */
318 if(ODU_REG_TTSK((Ent)ENTEGTP, (Inst)EGTP_INST, (Ttype)TTNORM, (Prior)PRIOR0,
319 egtpActvInit, (ActvTsk)egtpActvTsk) != ROK)
323 /* Attach DU APP TAPA Task for DU */
324 if (ODU_ATTACH_TTSK((Ent)ENTEGTP, (Inst)0, sysTskId)!= ROK)
329 DU_LOG("\nINFO --> DU_APP : EGTP created and registered \
330 to %d sys task", sysTskId);
335 /*******************************************************************
337 * @brief Initializes SCTP task
341 * Function : sctpInit
344 * - Registers and attaches TAPA tasks for SCTP receiver
346 * @params[in] system task ID
347 * @return ROK - success
350 * ****************************************************************/
351 uint8_t sctpInit(SSTskId sysTskId)
353 /* Register SCTP TAPA Task */
354 if(ODU_REG_TTSK((Ent)ENTSCTP, (Inst)0, (Ttype)TTNORM, (Prior)PRIOR0,
355 sctpActvInit, (ActvTsk)sctpActvTsk) != ROK)
359 /* Attach SCTP TAPA Task */
360 if (ODU_ATTACH_TTSK((Ent)ENTSCTP, (Inst)SCTP_INST, sysTskId)!= ROK)
365 DU_LOG("\nINFO --> DU_APP : SCTP TAPA task created and registered to %d sys task",
370 /*******************************************************************
372 * @brief Initializes RLC DL, MAC TAPA task
376 * Function : rlcDlInit
379 * - Registers and attaches TAPA tasks for MAC and RLC DL
381 * @params[in] system task ID
382 * @return ROK - success
385 * ****************************************************************/
386 uint8_t rlcDlInit(SSTskId sysTskId)
388 /* Register RLC DL TAPA Task */
389 if(ODU_REG_TTSK((Ent)ENTRLC, (Inst)1, (Ttype)TTNORM, (Prior)PRIOR0,
390 rlcDlActvInit, (ActvTsk)rlcDlActvTsk) != ROK)
394 /* Attach RLC DL Task */
395 if (ODU_ATTACH_TTSK((Ent)ENTRLC, (Inst)1, sysTskId)!= ROK)
400 /* Register MAC TAPA Task */
401 if(ODU_REG_TTSK((Ent)ENTMAC, (Inst)0, (Ttype)TTNORM, (Prior)PRIOR0,
402 macActvInit, (ActvTsk)macActvTsk) != ROK)
406 /* Attach MAC Task */
407 if (ODU_ATTACH_TTSK((Ent)ENTMAC, (Inst)0, sysTskId)!= ROK)
413 /*******************************************************************
415 * @brief Initializes SCH TAPA task
422 * - Registers and attaches TAPA tasks for SCH
424 * @params[in] system task ID
425 * @return ROK - success
428 * ****************************************************************/
429 uint8_t schInit(SSTskId sysTskId)
431 /* Register SCH TAPA Task */
432 if(ODU_REG_TTSK((Ent)ENTMAC, (Inst)SCH_INST_START, (Ttype)TTNORM, (Prior)PRIOR0,
433 schActvInit, (ActvTsk)schActvTsk) != ROK)
437 /* Attach SCH Task */
438 if (ODU_ATTACH_TTSK((Ent)ENTMAC, (Inst)SCH_INST_START, sysTskId)!= ROK)
444 DU_LOG("\nINFO --> DU_APP : SCH TAPA task created and registered to \
445 %d sys task", sysTskId);
449 /*******************************************************************
451 * @brief Initializes RLC UL TAPA task
455 * Function : rlcUlInit
458 * - Registers and attaches TAPA task for RLC UL
460 * @params[in] system task ID
461 * @return ROK - success
464 * ****************************************************************/
465 uint8_t rlcUlInit(SSTskId sysTskId)
467 /* Register RLC UL TAPA Task */
468 if(ODU_REG_TTSK((Ent)ENTRLC, (Inst)0, (Ttype)TTNORM, (Prior)PRIOR0,
469 rlcUlActvInit, (ActvTsk)rlcUlActvTsk) != ROK)
473 /* Attach RLC DL Task */
474 if (ODU_ATTACH_TTSK((Ent)ENTRLC, (Inst)0, sysTskId)!= ROK)
478 DU_LOG("\nINFO --> DU_APP : RLC UL TAPA task created and registered to \
479 %d sys task", sysTskId);
483 /*******************************************************************
485 * @brief Initializes Lower MAC receiver task
489 * Function : lwrMacInit
492 * - Registers and attaches TAPA tasks for Lower MAC receiver
494 * @params[in] system task ID
495 * @return ROK - success
498 * ****************************************************************/
499 uint8_t lwrMacInit(SSTskId sysTskId)
501 /* Register SCTP TAPA Task */
502 if(ODU_REG_TTSK((Ent)ENTLWRMAC, (Inst)0, (Ttype)TTNORM, (Prior)PRIOR0,
503 lwrMacActvInit, (ActvTsk)lwrMacActvTsk) != ROK)
507 /* Attach SCTP TAPA Task */
508 if (ODU_ATTACH_TTSK((Ent)ENTLWRMAC, (Inst)0, sysTskId)!= ROK)
513 DU_LOG("\nINFO --> DU_APP : LWR MAC TAPA task created and registered to %d sys task",
518 #ifndef INTEL_WLS_MEM
519 /*******************************************************************
521 * @brief Initializes Phy stub slot indication generator task
525 * Function : phyStubInit
528 * - Registers and attaches TAPA tasks for Phy stub's slot
529 * indication generator
531 * @params[in] system task ID
532 * @return ROK - success
535 * ****************************************************************/
536 uint8_t phyStubInit(SSTskId sysTskId)
538 /* Register PHY stub slot indication TAPA Task */
539 if(ODU_REG_TTSK((Ent)ENTPHYSTUB, (Inst)0, (Ttype)TTNORM, (Prior)PRIOR0,
540 phyStubActvInit, (ActvTsk)phyStubActvTsk) != ROK)
544 /* Attach Phy stub slot indication TAPA Task */
545 if (ODU_ATTACH_TTSK((Ent)ENTPHYSTUB, (Inst)0, sysTskId)!= ROK)
550 DU_LOG("\nINFO --> DU_APP : PHY stub slot indication TAPA task created and registered to %d sys task",
556 /*******************************************************************
558 * @brief Initializes system and TAPA tasks
562 * Function : commonInit
565 * - Registers and attaches system and TAPA tasks
568 * @return ROK - success
571 * ****************************************************************/
574 /* Declare system task Ids */
575 SSTskId du_app_stsk, egtp_stsk, sctp_stsk, rlc_ul_stsk, rlc_mac_cl_stsk, sch_stsk, lwr_mac_stsk, phy_stub_slot_ind_stsk;
579 ODU_SET_PROC_ID(DU_PROC);
581 /* Intel L1 using core 0-15. ODU-High using 16-21 */
582 /* system task for DU APP */
583 if(ODU_CREATE_TASK(PRIOR0, &du_app_stsk) != ROK)
585 DU_LOG("\nERROR --> DU_APP : System Task creation for DU APP failed");
588 ODU_SET_THREAD_AFFINITY(&du_app_stsk, SS_AFFINITY_MODE_EXCL, 16, 0);
590 /* system task for EGTP */
591 if(ODU_CREATE_TASK(PRIOR0, &egtp_stsk) != ROK)
593 DU_LOG("\nERROR --> DU_APP : System Task creation for EGTP failed");
596 ODU_SET_THREAD_AFFINITY(&egtp_stsk, SS_AFFINITY_MODE_EXCL, 27, 0);
598 /* system task for RLC_DL and MAC */
599 if(ODU_CREATE_TASK(PRIOR0, &rlc_mac_cl_stsk) != ROK)
601 DU_LOG("\nERROR --> DU_APP : System Task creation for RLC DL/MAC failed");
604 pthread_attr_init(&attr);
605 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
606 ODU_SET_THREAD_AFFINITY(&rlc_mac_cl_stsk, SS_AFFINITY_MODE_EXCL, 18, 0);
608 /* system task for RLC UL */
609 if(ODU_CREATE_TASK(PRIOR1, &rlc_ul_stsk) != ROK)
611 DU_LOG("\nERROR --> DU_APP : System Task creation for RLC UL failed");
614 ODU_SET_THREAD_AFFINITY(&rlc_ul_stsk, SS_AFFINITY_MODE_EXCL, 22, 0);
616 /* system task for SCH */
617 if(ODU_CREATE_TASK(PRIOR1, &sch_stsk) != ROK)
619 DU_LOG("\nERROR --> DU_APP : System Task creation for SCH failed");
622 ODU_SET_THREAD_AFFINITY(&sch_stsk, SS_AFFINITY_MODE_EXCL, 22, 0);
624 /* system task for SCTP receiver thread */
625 if(ODU_CREATE_TASK(PRIOR0, &sctp_stsk) != ROK)
627 DU_LOG("\nERROR --> DU_APP : System Task creation for SCTP failed");
630 ODU_SET_THREAD_AFFINITY(&sctp_stsk, SS_AFFINITY_MODE_EXCL, 25, 0);
632 /* system task for lower-mac receiver thread */
633 if(ODU_CREATE_TASK(PRIOR0, &lwr_mac_stsk) != ROK)
635 DU_LOG("\nERROR --> DU_APP : System Task creation for Lower MAC failed");
638 ODU_SET_THREAD_AFFINITY(&lwr_mac_stsk, SS_AFFINITY_MODE_EXCL, 21, 0);
640 #ifndef INTEL_WLS_MEM
641 /* system task for phy stub's slot indication generator thread */
642 if(ODU_CREATE_TASK(PRIOR0, &phy_stub_slot_ind_stsk) != ROK)
644 DU_LOG("\nERROR --> DU_APP : System Task creation for Phy stub slot indication generator failed. MAX STSK [%d]", SS_MAX_STSKS);
650 /* Create TAPA tasks */
651 if(duAppInit(du_app_stsk) != ROK)
653 DU_LOG("\nERROR --> DU_APP : DU APP TAPA Task initialization failed");
657 if(egtpInit(egtp_stsk) != ROK)
659 DU_LOG("\nERROR --> DU_APP : EGTP TAPA Task initialization failed");
663 if(sctpInit(sctp_stsk) != ROK)
665 DU_LOG("\nERROR --> DU_APP : SCTP TAPA Task initialization failed");
669 if(rlcDlInit(rlc_mac_cl_stsk) != ROK)
671 DU_LOG("\nERROR --> DU_APP : RLC DL Tapa Task initialization failed");
675 if(rlcUlInit(rlc_ul_stsk) != ROK)
677 DU_LOG("\nERROR --> DU_APP : RLC UL Tapa Task initialization failed");
681 if(schInit(sch_stsk) != ROK)
683 DU_LOG("\nERROR --> DU_APP : SCH Tapa Task initialization failed");
687 if(lwrMacInit(lwr_mac_stsk) != ROK)
689 DU_LOG("\nERROR --> DU_APP : Lower MAC Tapa Task initialization failed");
693 #ifndef INTEL_WLS_MEM
694 if(phyStubInit(phy_stub_slot_ind_stsk) != ROK)
696 DU_LOG("\nERROR --> DU_APP : PHY stub slot indication Tapa Task initialization failed");
705 /*******************************************************************
707 * @brief Initializes the DU
715 * - Registers DU Layers
718 * @return ROK - success
721 * ****************************************************************/
725 if(commonInit() != ROK)
734 openlog("ODU",LOG_CONS | LOG_PID | LOG_NDELAY, LOG_LOCAL1);
737 /*******************************************************************
739 * @brief Entry point for the DU APP
746 * - Read config params into duCfgParams
747 * - Initiate the init functions
750 * @return ROK - success
753 * ****************************************************************/
758 if(start_O1_module() != ROK)
761 //Initialize TAPA layers
767 //Read all the configs from du_utils.c into duCfgParams
773 //Send VES PNF registration message to SMO
774 sendPnfRegistration();
781 /**********************************************************************
783 **********************************************************************/