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"
27 #include "du_e2ap_mgr.h"
30 #include "du_mgr_main.h"
33 #include "du_cell_mgr.h"
34 #include "du_f1ap_msg_hdl.h"
38 #include "O1Interface.h"
39 #include "CmInterface.h"
42 uint8_t rlcUlActvTsk (Pst *, Buffer *);
43 uint8_t rlcUlActvInit (Ent, Inst, Region, Reason);
44 uint8_t rlcDlActvTsk (Pst *, Buffer *);
45 uint8_t rlcDlActvInit (Ent, Inst, Region, Reason);
46 uint8_t macActvTsk (Pst *, Buffer *);
47 uint8_t macActvInit (Ent, Inst, Region, Reason);
48 uint8_t lwrMacActvTsk(Pst *, Buffer *);
49 uint8_t lwrMacActvInit(Ent, Inst, Region, Reason);
51 uint8_t phyStubActvTsk(Pst *, Buffer *);
52 uint8_t phyStubActvInit(Ent, Inst, Region, Reason);
56 DuCfgParams duCfgParam;
59 extern NRCellDU cellParams;
62 /*******************************************************************
64 * @brief Initializes DU APP
68 * Function : duAppInit
71 * - Registers and attaches TAPA tasks belonging to
74 * @params[in] system task ID
75 * @return ROK - success
78 * ****************************************************************/
79 uint8_t duAppInit(SSTskId sysTskId)
81 /* Register DU APP TAPA Task for DU */
82 if(ODU_REG_TTSK((Ent)ENTDUAPP, (Inst)DU_INST, (Ttype)TTNORM, (Prior)PRIOR0,
83 duActvInit, (ActvTsk)duActvTsk) != ROK)
87 /* Attach DU APP TAPA Task for DU */
88 if (ODU_ATTACH_TTSK((Ent)ENTDUAPP, (Inst)0, sysTskId)!= ROK)
93 DU_LOG("\nINFO --> DU_APP : DU APP created and registered \
94 to %d sys task", sysTskId);
100 /*******************************************************************
102 * @brief update Rrm Policy at DU and process the slice cfg request
106 * Function : setRrmPolicy
109 * - update Rrm Policy at DU and process the slice cfg request
111 * @params[in] RrmPolicy rrmPolicy[], uint8_t policyNum, uint8_t memberList
112 * @return true - success
115 * ****************************************************************/
117 uint8_t setRrmPolicy(RrmPolicyList rrmPolicy[], uint8_t policyNum)
119 DU_LOG("\nINFO --> DU_APP : DU APP RRM number of policy %d,", \
121 for(uint8_t i=0; i<policyNum ; i++)
123 DU_LOG("\nINFO --> DU_APP : DU APP id = %s",rrmPolicy[i].id);
124 DU_LOG("\nINFO --> DU_APP : DU APP resourceType = %d", \
125 rrmPolicy[i].resourceType);
126 DU_LOG("\nINFO --> DU_APP : DU APP rRMPolicyMaxRatio = %d", \
127 rrmPolicy[i].rRMPolicyMaxRatio);
128 DU_LOG("\nINFO --> DU_APP : DU APP rRMPolicyMinRatio = %d", \
129 rrmPolicy[i].rRMPolicyMinRatio);
130 DU_LOG("\nINFO --> DU_APP : DU APP rRMPolicyDedicatedRatio = %d", \
131 rrmPolicy[i].rRMPolicyDedicatedRatio);
132 DU_LOG("\nINFO --> DU_APP : DU APP rRMMemberNum = %d", \
133 rrmPolicy[i].rRMMemberNum);
134 for(uint8_t j=0; j<rrmPolicy[i].rRMMemberNum ; j++)
136 DU_LOG("\nINFO --> DU_APP : DU APP mcc = %d%d%d", \
137 rrmPolicy[i].rRMPolicyMemberList[j].mcc[0], \
138 rrmPolicy[i].rRMPolicyMemberList[j].mcc[1], \
139 rrmPolicy[i].rRMPolicyMemberList[j].mcc[2]);
140 DU_LOG("\nINFO --> DU_APP : DU APP mnc = %d%d%d", \
141 rrmPolicy[i].rRMPolicyMemberList[j].mnc[0], \
142 rrmPolicy[i].rRMPolicyMemberList[j].mnc[1], \
143 rrmPolicy[i].rRMPolicyMemberList[j].mnc[2]);
145 DU_LOG("\nINFO --> DU_APP : DU APP sd = %d%d%d", \
146 rrmPolicy[i].rRMPolicyMemberList[j].sd[0], \
147 rrmPolicy[i].rRMPolicyMemberList[j].sd[1], \
148 rrmPolicy[i].rRMPolicyMemberList[j].sd[2]);
150 DU_LOG("\nINFO --> DU_APP : DU APP sst = %d\n", \
151 rrmPolicy[i].rRMPolicyMemberList[j].sst);
155 DuCellCb *cellCb = NULLP;
157 cpyRrmPolicyInDuCfgParams(rrmPolicy, policyNum, &duCfgParam.tempSliceCfg);
158 cellCb = duCb.actvCellLst[0];
162 if(cellCb->cellStatus == ACTIVATED)
164 if(duCb.sliceState == SLICE_INFO_NOT_AVAILABLE)
166 BuildAndSendSliceConfigReq();
170 BuildAndSendSliceRecfgReq();
177 /*******************************************************************
179 * @brief Bring the cell Up
183 * Function : bringCellUp
186 * - Bring the cell Up when requested from OAM
188 * @params[in] Cell Id
189 * @return true - success
192 * ****************************************************************/
194 bool bringCellUp(uint16_t cellId)
197 BuildAndSendF1SetupReq();
201 /*******************************************************************
203 * @brief configure cell parameters
207 * Function : configurecell
210 * - configure cell parameters
212 * @params[in] Cell Id
213 * @return true - success
216 * ****************************************************************/
218 uint8_t setCellParam()
220 //Read all the configs from smo edit-config into cellParams
221 DU_LOG("\nO1 configurecell du_app enterd");
222 DU_LOG("\nDU_APP configurecell cellLocalId value:%d",cellParams.cellLocalId);
223 DU_LOG("\nDU_APP configurecell operationalState value:%d", \
224 cellParams.operationalState);
225 DU_LOG("\nDU_APP configurecell administrativeState value:%d", \
226 cellParams.administrativeState);
227 DU_LOG("\nDU_APP configurecell cellState value:%d",cellParams.cellState);
228 DU_LOG("\nDU_APP configurecell nRPCI value:%d",cellParams.nRPCI);
229 DU_LOG("\nDU_APP configurecell nRTAC value:%d",cellParams.nRTAC);
230 DU_LOG("\nDU_APP configurecell arfcnDL value:%d",cellParams.arfcnDL);
231 DU_LOG("\nDU_APP configurecell arfcnUL value:%d",cellParams.arfcnUL);
232 DU_LOG("\nDU_APP configurecell arfcnSUL value:%d",cellParams.arfcnSUL);
233 DU_LOG("\nDU_APP configurecell ssbFrequency value:%d",cellParams.ssbFrequency);
234 DU_LOG("\nDU_APP configurecell ssbPeriodicity value:%d", \
235 cellParams.ssbPeriodicity);
236 DU_LOG("\nDU_APP configurecell ssbSubCarrierSpacing value:%d", \
237 cellParams.ssbSubCarrierSpacing);
238 DU_LOG("\nDU_APP configurecell ssbOffset value:%d",cellParams.ssbOffset);
239 DU_LOG("\nDU_APP configurecell ssbDuration value:%d",cellParams.ssbDuration);
240 DU_LOG("\nDU_APP configurecell bSChannelBwUL value:%d", \
241 cellParams.bSChannelBwUL);
242 DU_LOG("\nDU_APP configurecell bSChannelBwDL value:%d", \
243 cellParams.bSChannelBwDL);
244 DU_LOG("\nDU_APP configurecell bSChannelBwSUL value:%d", \
245 cellParams.bSChannelBwSUL);
246 for (int i=0 ; i<MAX_SUPPORTED_PLMN; i++)
249 DU_LOG("\nINFO --> DU_APP : DU APP mcellParams.plmnList[%d].mcc = %d%d%d", i,\
250 cellParams.plmnList[i].mcc[0], \
251 cellParams.plmnList[i].mcc[1], \
252 cellParams.plmnList[i].mcc[2]);
253 DU_LOG("\nINFO --> DU_APP : DU APP cellParams.plmnList[%d].mnc = %d%d%d", i,\
254 cellParams.plmnList[i].mnc[0], \
255 cellParams.plmnList[i].mnc[1], \
256 cellParams.plmnList[i].mnc[2]);
258 DU_LOG("\nINFO --> DU_APP : DU APP cellParams.plmnList[%d].sd = %d%d%d", i,\
259 cellParams.plmnList[i].sd[0], \
260 cellParams.plmnList[i].sd[1], \
261 cellParams.plmnList[i].sd[2]);
263 DU_LOG("\nINFO --> DU_APP : DU APP cellParams.plmnList[%d].sst = %d\n", i,\
264 cellParams.plmnList[i].sst);
271 /*******************************************************************
273 * @brief Bring the cell Down
277 * Function : bringCellDown
280 * - Bring the cell Down when requested from OAM
282 * @params[in] Cell Id
283 * @return true - success
286 * ****************************************************************/
288 bool bringCellDown(uint16_t cellId)
290 BuildAndSendDUConfigUpdate(SERV_CELL_TO_DELETE);
295 /*******************************************************************
297 * @brief Initializes EGTP
301 * Function : egtpInit
304 * - Registers and attaches TAPA tasks belonging to
307 * @params[in] system task ID
308 * @return ROK - success
311 * ****************************************************************/
312 uint8_t egtpInit(SSTskId sysTskId)
314 /* Register DU APP TAPA Task for DU */
315 if(ODU_REG_TTSK((Ent)ENTEGTP, (Inst)EGTP_INST, (Ttype)TTNORM, (Prior)PRIOR0,
316 egtpActvInit, (ActvTsk)egtpActvTsk) != ROK)
320 /* Attach DU APP TAPA Task for DU */
321 if (ODU_ATTACH_TTSK((Ent)ENTEGTP, (Inst)0, sysTskId)!= ROK)
326 DU_LOG("\nINFO --> DU_APP : EGTP created and registered \
327 to %d sys task", sysTskId);
332 /*******************************************************************
334 * @brief Initializes SCTP task
338 * Function : sctpInit
341 * - Registers and attaches TAPA tasks for SCTP receiver
343 * @params[in] system task ID
344 * @return ROK - success
347 * ****************************************************************/
348 uint8_t sctpInit(SSTskId sysTskId)
350 /* Register SCTP TAPA Task */
351 if(ODU_REG_TTSK((Ent)ENTSCTP, (Inst)0, (Ttype)TTNORM, (Prior)PRIOR0,
352 sctpActvInit, (ActvTsk)sctpActvTsk) != ROK)
356 /* Attach SCTP TAPA Task */
357 if (ODU_ATTACH_TTSK((Ent)ENTSCTP, (Inst)SCTP_INST, sysTskId)!= ROK)
362 DU_LOG("\nINFO --> DU_APP : SCTP TAPA task created and registered to %d sys task",
366 /*******************************************************************
368 * @brief Initializes RLC DL, MAC TAPA task
372 * Function : rlcDlInit
375 * - Registers and attaches TAPA tasks for MAC and RLC DL
377 * @params[in] system task ID
378 * @return ROK - success
381 * ****************************************************************/
382 uint8_t rlcDlInit(SSTskId sysTskId)
384 /* Register RLC DL TAPA Task */
385 if(ODU_REG_TTSK((Ent)ENTRLC, (Inst)1, (Ttype)TTNORM, (Prior)PRIOR0,
386 rlcDlActvInit, (ActvTsk)rlcDlActvTsk) != ROK)
390 /* Attach RLC DL Task */
391 if (ODU_ATTACH_TTSK((Ent)ENTRLC, (Inst)1, sysTskId)!= ROK)
396 /* Register MAC TAPA Task */
397 if(ODU_REG_TTSK((Ent)ENTMAC, (Inst)0, (Ttype)TTNORM, (Prior)PRIOR0,
398 macActvInit, (ActvTsk)macActvTsk) != ROK)
402 /* Attach MAC Task */
403 if (ODU_ATTACH_TTSK((Ent)ENTMAC, (Inst)0, sysTskId)!= ROK)
408 DU_LOG("\nINFO --> DU_APP : RLC DL and MAC TAPA task created and registered to \
409 %d sys task", sysTskId);
413 /*******************************************************************
415 * @brief Initializes RLC UL TAPA task
419 * Function : rlcUlInit
422 * - Registers and attaches TAPA task for RLC UL
424 * @params[in] system task ID
425 * @return ROK - success
428 * ****************************************************************/
429 uint8_t rlcUlInit(SSTskId sysTskId)
431 /* Register RLC UL TAPA Task */
432 if(ODU_REG_TTSK((Ent)ENTRLC, (Inst)0, (Ttype)TTNORM, (Prior)PRIOR0,
433 rlcUlActvInit, (ActvTsk)rlcUlActvTsk) != ROK)
437 /* Attach RLC DL Task */
438 if (ODU_ATTACH_TTSK((Ent)ENTRLC, (Inst)0, sysTskId)!= ROK)
442 DU_LOG("\nINFO --> DU_APP : RLC UL TAPA task created and registered to \
443 %d sys task", sysTskId);
447 /*******************************************************************
449 * @brief Initializes Lower MAC receiver task
453 * Function : lwrMacInit
456 * - Registers and attaches TAPA tasks for Lower MAC receiver
458 * @params[in] system task ID
459 * @return ROK - success
462 * ****************************************************************/
463 uint8_t lwrMacInit(SSTskId sysTskId)
465 /* Register SCTP TAPA Task */
466 if(ODU_REG_TTSK((Ent)ENTLWRMAC, (Inst)0, (Ttype)TTNORM, (Prior)PRIOR0,
467 lwrMacActvInit, (ActvTsk)lwrMacActvTsk) != ROK)
471 /* Attach SCTP TAPA Task */
472 if (ODU_ATTACH_TTSK((Ent)ENTLWRMAC, (Inst)0, sysTskId)!= ROK)
477 DU_LOG("\nINFO --> DU_APP : LWR MAC TAPA task created and registered to %d sys task",
482 #ifndef INTEL_WLS_MEM
483 /*******************************************************************
485 * @brief Initializes Phy stub slot indication generator task
489 * Function : phyStubInit
492 * - Registers and attaches TAPA tasks for Phy stub's slot
493 * indication generator
495 * @params[in] system task ID
496 * @return ROK - success
499 * ****************************************************************/
500 uint8_t phyStubInit(SSTskId sysTskId)
502 /* Register PHY stub slot indication TAPA Task */
503 if(ODU_REG_TTSK((Ent)ENTPHYSTUB, (Inst)0, (Ttype)TTNORM, (Prior)PRIOR0,
504 phyStubActvInit, (ActvTsk)phyStubActvTsk) != ROK)
508 /* Attach Phy stub slot indication TAPA Task */
509 if (ODU_ATTACH_TTSK((Ent)ENTPHYSTUB, (Inst)0, sysTskId)!= ROK)
514 DU_LOG("\nINFO --> DU_APP : PHY stub slot indication TAPA task created and registered to %d sys task",
520 /*******************************************************************
522 * @brief Initializes system and TAPA tasks
526 * Function : commonInit
529 * - Registers and attaches system and TAPA tasks
532 * @return ROK - success
535 * ****************************************************************/
538 /* Declare system task Ids */
539 SSTskId du_app_stsk, egtp_stsk, sctp_stsk, rlc_ul_stsk, rlc_mac_cl_stsk, lwr_mac_stsk, phy_stub_slot_ind_stsk;
543 ODU_SET_PROC_ID(DU_PROC);
545 /* Intel L1 using core 0-15. ODU-High using 16-21 */
546 /* system task for DU APP */
547 if(ODU_CREATE_TASK(PRIOR0, &du_app_stsk) != ROK)
549 DU_LOG("\nERROR --> DU_APP : System Task creation for DU APP failed");
552 ODU_SET_THREAD_AFFINITY(&du_app_stsk, SS_AFFINITY_MODE_EXCL, 16, 0);
554 /* system task for EGTP */
555 if(ODU_CREATE_TASK(PRIOR0, &egtp_stsk) != ROK)
557 DU_LOG("\nERROR --> DU_APP : System Task creation for EGTP failed");
560 ODU_SET_THREAD_AFFINITY(&egtp_stsk, SS_AFFINITY_MODE_EXCL, 27, 0);
562 /* system task for RLC_DL and MAC */
563 if(ODU_CREATE_TASK(PRIOR0, &rlc_mac_cl_stsk) != ROK)
565 DU_LOG("\nERROR --> DU_APP : System Task creation for RLC DL/MAC failed");
568 pthread_attr_init(&attr);
569 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
570 ODU_SET_THREAD_AFFINITY(&rlc_mac_cl_stsk, SS_AFFINITY_MODE_EXCL, 18, 0);
572 /* system task for RLC UL */
573 if(ODU_CREATE_TASK(PRIOR1, &rlc_ul_stsk) != ROK)
575 DU_LOG("\nERROR --> DU_APP : System Task creation for RLC UL failed");
578 ODU_SET_THREAD_AFFINITY(&rlc_ul_stsk, SS_AFFINITY_MODE_EXCL, 22, 0);
580 /* system task for SCTP receiver thread */
581 if(ODU_CREATE_TASK(PRIOR0, &sctp_stsk) != ROK)
583 DU_LOG("\nERROR --> DU_APP : System Task creation for SCTP failed");
586 ODU_SET_THREAD_AFFINITY(&sctp_stsk, SS_AFFINITY_MODE_EXCL, 25, 0);
588 /* system task for lower-mac receiver thread */
589 if(ODU_CREATE_TASK(PRIOR0, &lwr_mac_stsk) != ROK)
591 DU_LOG("\nERROR --> DU_APP : System Task creation for Lower MAC failed");
594 ODU_SET_THREAD_AFFINITY(&lwr_mac_stsk, SS_AFFINITY_MODE_EXCL, 21, 0);
596 #ifndef INTEL_WLS_MEM
597 /* system task for phy stub's slot indication generator thread */
598 if(ODU_CREATE_TASK(PRIOR0, &phy_stub_slot_ind_stsk) != ROK)
600 DU_LOG("\nERROR --> DU_APP : System Task creation for Phy stub slot indication generator failed. MAX STSK [%d]", SS_MAX_STSKS);
606 /* Create TAPA tasks */
607 if(duAppInit(du_app_stsk) != ROK)
609 DU_LOG("\nERROR --> DU_APP : DU APP TAPA Task initialization failed");
613 if(egtpInit(egtp_stsk) != ROK)
615 DU_LOG("\nERROR --> DU_APP : EGTP TAPA Task initialization failed");
619 if(sctpInit(sctp_stsk) != ROK)
621 DU_LOG("\nERROR --> DU_APP : SCTP TAPA Task initialization failed");
625 if(rlcDlInit(rlc_mac_cl_stsk) != ROK)
627 DU_LOG("\nERROR --> DU_APP : RLC DL Tapa Task initialization failed");
631 if(rlcUlInit(rlc_ul_stsk) != ROK)
633 DU_LOG("\nERROR --> DU_APP : RLC UL Tapa Task initialization failed");
637 if(lwrMacInit(lwr_mac_stsk) != ROK)
639 DU_LOG("\nERROR --> DU_APP : Lower MAC Tapa Task initialization failed");
643 #ifndef INTEL_WLS_MEM
644 if(phyStubInit(phy_stub_slot_ind_stsk) != ROK)
646 DU_LOG("\nERROR --> DU_APP : PHY stub slot indication Tapa Task initialization failed");
655 /*******************************************************************
657 * @brief Initializes the DU
665 * - Registers DU Layers
668 * @return ROK - success
671 * ****************************************************************/
675 if(commonInit() != ROK)
684 openlog("ODU",LOG_CONS | LOG_PID | LOG_NDELAY, LOG_LOCAL1);
687 /*******************************************************************
689 * @brief Entry point for the DU APP
696 * - Read config params into duCfgParams
697 * - Initiate the init functions
700 * @return ROK - success
703 * ****************************************************************/
708 if(start_O1_module() != ROK)
711 //Initialize TAPA layers
717 //Read all the configs from du_utils.c into duCfgParams
723 //Send VES PNF registration message to SMO
724 sendPnfRegistration();
731 /**********************************************************************
733 **********************************************************************/