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"
25 #include "du_app_mac_inf.h"
26 #include "du_app_rlc_inf.h"
29 #include "du_mgr_main.h"
32 #include "du_cell_mgr.h"
33 #include "du_f1ap_msg_hdl.h"
37 #include "O1Interface.h"
38 #include "CmInterface.h"
41 uint8_t rlcUlActvTsk (Pst *, Buffer *);
42 uint8_t rlcUlActvInit (Ent, Inst, Region, Reason);
43 uint8_t rlcDlActvTsk (Pst *, Buffer *);
44 uint8_t rlcDlActvInit (Ent, Inst, Region, Reason);
45 uint8_t macActvTsk (Pst *, Buffer *);
46 uint8_t macActvInit (Ent, Inst, Region, Reason);
47 uint8_t lwrMacActvTsk(Pst *, Buffer *);
48 uint8_t lwrMacActvInit(Ent, Inst, Region, Reason);
50 uint8_t phyStubActvTsk(Pst *, Buffer *);
51 uint8_t phyStubActvInit(Ent, Inst, Region, Reason);
55 DuCfgParams duCfgParam;
58 extern NRCellDU cellParams;
61 /*******************************************************************
63 * @brief Initializes DU APP
67 * Function : duAppInit
70 * - Registers and attaches TAPA tasks belonging to
73 * @params[in] system task ID
74 * @return ROK - success
77 * ****************************************************************/
78 uint8_t duAppInit(SSTskId sysTskId)
80 /* Register DU APP TAPA Task for DU */
81 if(ODU_REG_TTSK((Ent)ENTDUAPP, (Inst)DU_INST, (Ttype)TTNORM, (Prior)PRIOR0,
82 duActvInit, (ActvTsk)duActvTsk) != ROK)
86 /* Attach DU APP TAPA Task for DU */
87 if (ODU_ATTACH_TTSK((Ent)ENTDUAPP, (Inst)0, sysTskId)!= ROK)
92 DU_LOG("\nINFO --> DU_APP : DU APP created and registered \
93 to %d sys task", sysTskId);
99 /*******************************************************************
101 * @brief update Rrm Policy at DU and process the slice cfg request
105 * Function : setRrmPolicy
108 * - update Rrm Policy at DU and process the slice cfg request
110 * @params[in] RrmPolicy rrmPolicy[], uint8_t policyNum, uint8_t memberList
111 * @return true - success
114 * ****************************************************************/
116 uint8_t setRrmPolicy(RrmPolicyList rrmPolicy[], uint8_t policyNum)
118 DU_LOG("\nINFO --> DU_APP : DU APP RRM number of policy %d,", \
120 for(uint8_t i=0; i<policyNum ; i++)
122 DU_LOG("\nINFO --> DU_APP : DU APP id = %s",rrmPolicy[i].id);
123 DU_LOG("\nINFO --> DU_APP : DU APP resourceType = %d", \
124 rrmPolicy[i].resourceType);
125 DU_LOG("\nINFO --> DU_APP : DU APP rRMPolicyMaxRatio = %d", \
126 rrmPolicy[i].rRMPolicyMaxRatio);
127 DU_LOG("\nINFO --> DU_APP : DU APP rRMPolicyMinRatio = %d", \
128 rrmPolicy[i].rRMPolicyMinRatio);
129 DU_LOG("\nINFO --> DU_APP : DU APP rRMPolicyDedicatedRatio = %d", \
130 rrmPolicy[i].rRMPolicyDedicatedRatio);
131 DU_LOG("\nINFO --> DU_APP : DU APP rRMMemberNum = %d", \
132 rrmPolicy[i].rRMMemberNum);
133 for(uint8_t j=0; j<rrmPolicy[i].rRMMemberNum ; j++)
135 DU_LOG("\nINFO --> DU_APP : DU APP mcc = %d%d%d", \
136 rrmPolicy[i].rRMPolicyMemberList[j].mcc[0], \
137 rrmPolicy[i].rRMPolicyMemberList[j].mcc[1], \
138 rrmPolicy[i].rRMPolicyMemberList[j].mcc[2]);
139 DU_LOG("\nINFO --> DU_APP : DU APP mnc = %d%d%d", \
140 rrmPolicy[i].rRMPolicyMemberList[j].mnc[0], \
141 rrmPolicy[i].rRMPolicyMemberList[j].mnc[1], \
142 rrmPolicy[i].rRMPolicyMemberList[j].mnc[2]);
144 DU_LOG("\nINFO --> DU_APP : DU APP sd = %d%d%d", \
145 rrmPolicy[i].rRMPolicyMemberList[j].sd[0], \
146 rrmPolicy[i].rRMPolicyMemberList[j].sd[1], \
147 rrmPolicy[i].rRMPolicyMemberList[j].sd[2]);
149 DU_LOG("\nINFO --> DU_APP : DU APP sst = %d\n", \
150 rrmPolicy[i].rRMPolicyMemberList[j].sst);
154 DuCellCb *cellCb = NULLP;
156 cpyRrmPolicyInDuCfgParams(rrmPolicy, policyNum, &duCfgParam.tempSliceCfg);
157 cellCb = duCb.actvCellLst[0];
161 if(cellCb->cellStatus == ACTIVATED)
163 if(duCb.sliceState == SLICE_INFO_NOT_AVAILABLE)
165 BuildAndSendSliceConfigReq();
169 BuildAndSendSliceRecfgReq();
176 /*******************************************************************
178 * @brief Bring the cell Up
182 * Function : bringCellUp
185 * - Bring the cell Up when requested from OAM
187 * @params[in] Cell Id
188 * @return true - success
191 * ****************************************************************/
193 bool bringCellUp(uint16_t cellId)
196 BuildAndSendF1SetupReq();
200 /*******************************************************************
202 * @brief configure cell parameters
206 * Function : configurecell
209 * - configure cell parameters
211 * @params[in] Cell Id
212 * @return true - success
215 * ****************************************************************/
217 uint8_t setCellParam()
219 //Read all the configs from smo edit-config into cellParams
220 DU_LOG("\nO1 configurecell du_app enterd");
221 DU_LOG("\nDU_APP configurecell cellLocalId value:%d",cellParams.cellLocalId);
222 DU_LOG("\nDU_APP configurecell operationalState value:%d", \
223 cellParams.operationalState);
224 DU_LOG("\nDU_APP configurecell administrativeState value:%d", \
225 cellParams.administrativeState);
226 DU_LOG("\nDU_APP configurecell cellState value:%d",cellParams.cellState);
227 DU_LOG("\nDU_APP configurecell nRPCI value:%d",cellParams.nRPCI);
228 DU_LOG("\nDU_APP configurecell nRTAC value:%d",cellParams.nRTAC);
229 DU_LOG("\nDU_APP configurecell arfcnDL value:%d",cellParams.arfcnDL);
230 DU_LOG("\nDU_APP configurecell arfcnUL value:%d",cellParams.arfcnUL);
231 DU_LOG("\nDU_APP configurecell arfcnSUL value:%d",cellParams.arfcnSUL);
232 DU_LOG("\nDU_APP configurecell ssbFrequency value:%d",cellParams.ssbFrequency);
233 DU_LOG("\nDU_APP configurecell ssbPeriodicity value:%d", \
234 cellParams.ssbPeriodicity);
235 DU_LOG("\nDU_APP configurecell ssbSubCarrierSpacing value:%d", \
236 cellParams.ssbSubCarrierSpacing);
237 DU_LOG("\nDU_APP configurecell ssbOffset value:%d",cellParams.ssbOffset);
238 DU_LOG("\nDU_APP configurecell ssbDuration value:%d",cellParams.ssbDuration);
239 DU_LOG("\nDU_APP configurecell bSChannelBwUL value:%d", \
240 cellParams.bSChannelBwUL);
241 DU_LOG("\nDU_APP configurecell bSChannelBwDL value:%d", \
242 cellParams.bSChannelBwDL);
243 DU_LOG("\nDU_APP configurecell bSChannelBwSUL value:%d", \
244 cellParams.bSChannelBwSUL);
245 for (int i=0 ; i<MAX_SUPPORTED_PLMN; i++)
248 DU_LOG("\nINFO --> DU_APP : DU APP mcellParams.plmnList[%d].mcc = %d%d%d", i,\
249 cellParams.plmnList[i].mcc[0], \
250 cellParams.plmnList[i].mcc[1], \
251 cellParams.plmnList[i].mcc[2]);
252 DU_LOG("\nINFO --> DU_APP : DU APP cellParams.plmnList[%d].mnc = %d%d%d", i,\
253 cellParams.plmnList[i].mnc[0], \
254 cellParams.plmnList[i].mnc[1], \
255 cellParams.plmnList[i].mnc[2]);
257 DU_LOG("\nINFO --> DU_APP : DU APP cellParams.plmnList[%d].sd = %d%d%d", i,\
258 cellParams.plmnList[i].sd[0], \
259 cellParams.plmnList[i].sd[1], \
260 cellParams.plmnList[i].sd[2]);
262 DU_LOG("\nINFO --> DU_APP : DU APP cellParams.plmnList[%d].sst = %d\n", i,\
263 cellParams.plmnList[i].sst);
270 /*******************************************************************
272 * @brief Bring the cell Down
276 * Function : bringCellDown
279 * - Bring the cell Down when requested from OAM
281 * @params[in] Cell Id
282 * @return true - success
285 * ****************************************************************/
287 bool bringCellDown(uint16_t cellId)
289 BuildAndSendDUConfigUpdate(SERV_CELL_TO_DELETE);
294 /*******************************************************************
296 * @brief Initializes EGTP
300 * Function : egtpInit
303 * - Registers and attaches TAPA tasks belonging to
306 * @params[in] system task ID
307 * @return ROK - success
310 * ****************************************************************/
311 uint8_t egtpInit(SSTskId sysTskId)
313 /* Register DU APP TAPA Task for DU */
314 if(ODU_REG_TTSK((Ent)ENTEGTP, (Inst)EGTP_INST, (Ttype)TTNORM, (Prior)PRIOR0,
315 egtpActvInit, (ActvTsk)egtpActvTsk) != ROK)
319 /* Attach DU APP TAPA Task for DU */
320 if (ODU_ATTACH_TTSK((Ent)ENTEGTP, (Inst)0, sysTskId)!= ROK)
325 DU_LOG("\nINFO --> DU_APP : EGTP created and registered \
326 to %d sys task", sysTskId);
331 /*******************************************************************
333 * @brief Initializes SCTP task
337 * Function : sctpInit
340 * - Registers and attaches TAPA tasks for SCTP receiver
342 * @params[in] system task ID
343 * @return ROK - success
346 * ****************************************************************/
347 uint8_t sctpInit(SSTskId sysTskId)
349 /* Register SCTP TAPA Task */
350 if(ODU_REG_TTSK((Ent)ENTSCTP, (Inst)0, (Ttype)TTNORM, (Prior)PRIOR0,
351 sctpActvInit, (ActvTsk)sctpActvTsk) != ROK)
355 /* Attach SCTP TAPA Task */
356 if (ODU_ATTACH_TTSK((Ent)ENTSCTP, (Inst)SCTP_INST, sysTskId)!= ROK)
361 DU_LOG("\nINFO --> DU_APP : SCTP TAPA task created and registered to %d sys task",
365 /*******************************************************************
367 * @brief Initializes RLC DL, MAC TAPA task
371 * Function : rlcDlInit
374 * - Registers and attaches TAPA tasks for MAC and RLC DL
376 * @params[in] system task ID
377 * @return ROK - success
380 * ****************************************************************/
381 uint8_t rlcDlInit(SSTskId sysTskId)
383 /* Register RLC DL TAPA Task */
384 if(ODU_REG_TTSK((Ent)ENTRLC, (Inst)1, (Ttype)TTNORM, (Prior)PRIOR0,
385 rlcDlActvInit, (ActvTsk)rlcDlActvTsk) != ROK)
389 /* Attach RLC DL Task */
390 if (ODU_ATTACH_TTSK((Ent)ENTRLC, (Inst)1, sysTskId)!= ROK)
395 /* Register MAC TAPA Task */
396 if(ODU_REG_TTSK((Ent)ENTMAC, (Inst)0, (Ttype)TTNORM, (Prior)PRIOR0,
397 macActvInit, (ActvTsk)macActvTsk) != ROK)
401 /* Attach MAC Task */
402 if (ODU_ATTACH_TTSK((Ent)ENTMAC, (Inst)0, sysTskId)!= ROK)
407 DU_LOG("\nINFO --> DU_APP : RLC DL and MAC TAPA task created and registered to \
408 %d sys task", sysTskId);
412 /*******************************************************************
414 * @brief Initializes RLC UL TAPA task
418 * Function : rlcUlInit
421 * - Registers and attaches TAPA task for RLC UL
423 * @params[in] system task ID
424 * @return ROK - success
427 * ****************************************************************/
428 uint8_t rlcUlInit(SSTskId sysTskId)
430 /* Register RLC UL TAPA Task */
431 if(ODU_REG_TTSK((Ent)ENTRLC, (Inst)0, (Ttype)TTNORM, (Prior)PRIOR0,
432 rlcUlActvInit, (ActvTsk)rlcUlActvTsk) != ROK)
436 /* Attach RLC DL Task */
437 if (ODU_ATTACH_TTSK((Ent)ENTRLC, (Inst)0, sysTskId)!= ROK)
441 DU_LOG("\nINFO --> DU_APP : RLC UL TAPA task created and registered to \
442 %d sys task", sysTskId);
446 /*******************************************************************
448 * @brief Initializes Lower MAC receiver task
452 * Function : lwrMacInit
455 * - Registers and attaches TAPA tasks for Lower MAC receiver
457 * @params[in] system task ID
458 * @return ROK - success
461 * ****************************************************************/
462 uint8_t lwrMacInit(SSTskId sysTskId)
464 /* Register SCTP TAPA Task */
465 if(ODU_REG_TTSK((Ent)ENTLWRMAC, (Inst)0, (Ttype)TTNORM, (Prior)PRIOR0,
466 lwrMacActvInit, (ActvTsk)lwrMacActvTsk) != ROK)
470 /* Attach SCTP TAPA Task */
471 if (ODU_ATTACH_TTSK((Ent)ENTLWRMAC, (Inst)0, sysTskId)!= ROK)
476 DU_LOG("\nINFO --> DU_APP : LWR MAC TAPA task created and registered to %d sys task",
481 #ifndef INTEL_WLS_MEM
482 /*******************************************************************
484 * @brief Initializes Phy stub slot indication generator task
488 * Function : phyStubInit
491 * - Registers and attaches TAPA tasks for Phy stub's slot
492 * indication generator
494 * @params[in] system task ID
495 * @return ROK - success
498 * ****************************************************************/
499 uint8_t phyStubInit(SSTskId sysTskId)
501 /* Register PHY stub slot indication TAPA Task */
502 if(ODU_REG_TTSK((Ent)ENTPHYSTUB, (Inst)0, (Ttype)TTNORM, (Prior)PRIOR0,
503 phyStubActvInit, (ActvTsk)phyStubActvTsk) != ROK)
507 /* Attach Phy stub slot indication TAPA Task */
508 if (ODU_ATTACH_TTSK((Ent)ENTPHYSTUB, (Inst)0, sysTskId)!= ROK)
513 DU_LOG("\nINFO --> DU_APP : PHY stub slot indication TAPA task created and registered to %d sys task",
519 /*******************************************************************
521 * @brief Initializes system and TAPA tasks
525 * Function : commonInit
528 * - Registers and attaches system and TAPA tasks
531 * @return ROK - success
534 * ****************************************************************/
537 /* Declare system task Ids */
538 SSTskId du_app_stsk, egtp_stsk, sctp_stsk, rlc_ul_stsk, rlc_mac_cl_stsk, lwr_mac_stsk, phy_stub_slot_ind_stsk;
542 ODU_SET_PROC_ID(DU_PROC);
544 /* Intel L1 using core 0-15. ODU-High using 16-21 */
545 /* system task for DU APP */
546 if(ODU_CREATE_TASK(PRIOR0, &du_app_stsk) != ROK)
548 DU_LOG("\nERROR --> DU_APP : System Task creation for DU APP failed");
551 //ODU_SET_THREAD_AFFINITY(&du_app_stsk, SS_AFFINITY_MODE_EXCL, 16, 0);
553 /* system task for EGTP */
554 if(ODU_CREATE_TASK(PRIOR0, &egtp_stsk) != ROK)
556 DU_LOG("\nERROR --> DU_APP : System Task creation for EGTP failed");
559 //ODU_SET_THREAD_AFFINITY(&egtp_stsk, SS_AFFINITY_MODE_EXCL, 27, 0);
561 /* system task for RLC_DL and MAC */
562 if(ODU_CREATE_TASK(PRIOR0, &rlc_mac_cl_stsk) != ROK)
564 DU_LOG("\nERROR --> DU_APP : System Task creation for RLC DL/MAC failed");
567 pthread_attr_init(&attr);
568 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
569 //ODU_SET_THREAD_AFFINITY(&rlc_mac_cl_stsk, SS_AFFINITY_MODE_EXCL, 18, 0);
571 /* system task for RLC UL */
572 if(ODU_CREATE_TASK(PRIOR1, &rlc_ul_stsk) != ROK)
574 DU_LOG("\nERROR --> DU_APP : System Task creation for RLC UL failed");
577 //ODU_SET_THREAD_AFFINITY(&rlc_ul_stsk, SS_AFFINITY_MODE_EXCL, 22, 0);
579 /* system task for SCTP receiver thread */
580 if(ODU_CREATE_TASK(PRIOR0, &sctp_stsk) != ROK)
582 DU_LOG("\nERROR --> DU_APP : System Task creation for SCTP failed");
585 //ODU_SET_THREAD_AFFINITY(&sctp_stsk, SS_AFFINITY_MODE_EXCL, 25, 0);
587 /* system task for lower-mac receiver thread */
588 if(ODU_CREATE_TASK(PRIOR0, &lwr_mac_stsk) != ROK)
590 DU_LOG("\nERROR --> DU_APP : System Task creation for Lower MAC failed");
593 //ODU_SET_THREAD_AFFINITY(&lwr_mac_stsk, SS_AFFINITY_MODE_EXCL, 21, 0);
595 #ifndef INTEL_WLS_MEM
596 /* system task for phy stub's slot indication generator thread */
597 if(ODU_CREATE_TASK(PRIOR0, &phy_stub_slot_ind_stsk) != ROK)
599 DU_LOG("\nERROR --> DU_APP : System Task creation for Phy stub slot indication generator failed. MAX STSK [%d]", SS_MAX_STSKS);
605 /* Create TAPA tasks */
606 if(duAppInit(du_app_stsk) != ROK)
608 DU_LOG("\nERROR --> DU_APP : DU APP TAPA Task initialization failed");
612 if(egtpInit(egtp_stsk) != ROK)
614 DU_LOG("\nERROR --> DU_APP : EGTP TAPA Task initialization failed");
618 if(sctpInit(sctp_stsk) != ROK)
620 DU_LOG("\nERROR --> DU_APP : SCTP TAPA Task initialization failed");
624 if(rlcDlInit(rlc_mac_cl_stsk) != ROK)
626 DU_LOG("\nERROR --> DU_APP : RLC DL Tapa Task initialization failed");
630 if(rlcUlInit(rlc_ul_stsk) != ROK)
632 DU_LOG("\nERROR --> DU_APP : RLC UL Tapa Task initialization failed");
636 if(lwrMacInit(lwr_mac_stsk) != ROK)
638 DU_LOG("\nERROR --> DU_APP : Lower MAC Tapa Task initialization failed");
642 #ifndef INTEL_WLS_MEM
643 if(phyStubInit(phy_stub_slot_ind_stsk) != ROK)
645 DU_LOG("\nERROR --> DU_APP : PHY stub slot indication Tapa Task initialization failed");
654 /*******************************************************************
656 * @brief Initializes the DU
664 * - Registers DU Layers
667 * @return ROK - success
670 * ****************************************************************/
674 if(commonInit() != ROK)
683 openlog("ODU",LOG_CONS | LOG_PID | LOG_NDELAY, LOG_LOCAL1);
686 /*******************************************************************
688 * @brief Entry point for the DU APP
695 * - Read config params into duCfgParams
696 * - Initiate the init functions
699 * @return ROK - success
702 * ****************************************************************/
707 if(start_O1_module() != ROK)
710 //Initialize TAPA layers
716 //Read all the configs from du_utils.c into duCfgParams
722 //Send VES PNF registration message to SMO
723 sendPnfRegistration();
730 /**********************************************************************
732 **********************************************************************/