[Epic-ID: ODUHIGH-516][Task-ID: 526] Implementation of ric service update
[o-du/l2.git] / src / du_app / du_cfg.c
1 /*******************************************************************************
2 ################################################################################
3 #   Copyright (c) [2017-2019] [Radisys]                                        #
4 #                                                                              #
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                                    #
8 #                                                                              #
9 #       http://www.apache.org/licenses/LICENSE-2.0                             #
10 #                                                                              #
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  *******************************************************************************/
18
19 /* This file contains all utility functions */
20 #include "common_def.h"
21 #include "du_tmr.h"
22 #include "legtp.h"
23 #include "lrg.h"
24 #include "lkw.x"
25 #include "lrg.x"
26 #include "du_app_mac_inf.h"
27 #include "du_app_rlc_inf.h"
28 #include "du_e2ap_mgr.h"
29 #include "du_cfg.h"
30 #include "du_mgr.h"
31 #include "du_utils.h"
32 #include "du_f1ap_conversions.h"
33 #include "OCTET_STRING.h"
34 #include "BIT_STRING.h"
35 #include "odu_common_codec.h"
36 #include "MIB.h"
37 #include "SearchSpace.h"
38 #include "SIB-TypeInfo.h"
39 #include "SchedulingInfo.h"
40 #include "SI-SchedulingInfo.h"
41 #include "ConnEstFailureControl.h"
42 #include "PLMN-IdentityInfo.h"
43 #include "PDSCH-TimeDomainResourceAllocation.h"
44 #include "BCCH-Config.h"
45 #include "PagingCycle.h"
46 #include "PCCH-Config.h"
47 #include "TimeAlignmentTimer.h"
48 #include "BCCH-DL-SCH-Message.h"
49 #include "RACH-ConfigGeneric.h"
50 #include "PUSCH-TimeDomainResourceAllocation.h"
51 #include "PUCCH-ConfigCommon.h"
52 #include "SubcarrierSpacing.h"
53 #include "TDD-UL-DL-Pattern.h"
54 #include "RACH-ConfigCommon.h"
55 #include "BWP-DownlinkCommon.h"
56 #include "BWP-UplinkCommon.h"
57 #include "TDD-UL-DL-ConfigCommon.h"
58 #include "du_sys_info_hdl.h"
59
60 #ifdef O1_ENABLE
61 #include "CmInterface.h"
62 extern StartupConfig g_cfg;
63 extern NRCellDU cellParams;
64 #endif
65
66 char encBuf[ENC_BUF_MAX_LEN];
67
68
69 /* Filling Slot configuration as :
70  * Slot Sym 0 Sym 1 Sym 2 Sym 3 Sym 4 Sym 5 Sym 6 Sym 7 Sym 8 Sym 9 Sym10 Sym11 Sym12 Sym13
71  *   0   DL    DL    DL    DL    DL    DL    DL    DL    DL    DL    DL    DL    DL    DL
72  *   1   DL    DL    DL    DL    DL    DL    DL    DL    DL    DL    DL    DL    DL    DL
73  *   2   DL    DL    DL    DL    DL    DL    DL    DL    DL    DL    DL    DL    DL    DL
74      3   DL    DL    DL    DL    DL    DL    DL    DL    DL    DL    DL    DL    DL    DL
75      4   DL    DL    DL    DL    DL    DL    DL    DL    DL    DL    DL    DL    DL    DL
76      5   DL    DL    DL    DL    DL    DL    DL    DL    DL    DL    DL    DL    DL    DL
77      6   DL    DL    DL    DL    DL    DL    DL    DL    DL    DL    DL    DL    DL    DL
78      7   DL    DL    DL    DL    DL    DL    DL    DL    DL    DL    DL    DL    F     UL
79      8   UL    UL    UL    UL    UL    UL    UL    UL    UL    UL    UL    UL    UL    UL
80      9   UL    UL    UL    UL    UL    UL    UL    UL    UL    UL    UL    UL    UL    UL  
81  */
82
83 /*******************************************************************
84  * @brief Reads the CL Configuration.
85  *
86  * @details
87  *
88  *    Function : readMacCfg
89  *
90  *    Functionality:
91  *       - Fills up the cell configuration for CL.
92  *       - Calls FillSlotConfig()  
93  *
94  * @params[in] void
95  * @return ROK     - success
96  *         RFAILED - failure
97  *
98  * ****************************************************************/
99
100 uint8_t readMacCfg()
101 {
102    uint8_t idx=0, sliceIdx=0,plmnIdx = 0;
103    F1TaiSliceSuppLst *taiSliceSuppLst;
104
105    /* DL carrier configuration */
106 #ifdef O1_ENABLE
107    duCfgParam.macCellCfg.cellId = cellParams.cellLocalId;
108    duCfgParam.macCellCfg.carrCfg.dlBw = cellParams.bSChannelBwDL;
109    duCfgParam.macCellCfg.carrCfg.dlFreq = convertArfcnToFreqKhz(cellParams.arfcnDL);
110 #else
111    duCfgParam.macCellCfg.cellId = NR_CELL_ID;
112    duCfgParam.macCellCfg.carrCfg.dlBw = NR_BANDWIDTH;
113    duCfgParam.macCellCfg.carrCfg.dlFreq = convertArfcnToFreqKhz(NR_DL_ARFCN);
114 #endif
115    duCfgParam.macCellCfg.carrCfg.numTxAnt = NUM_TX_ANT;
116    /* UL Carrier configuration */
117 #ifdef O1_ENABLE
118    duCfgParam.macCellCfg.carrCfg.ulBw = cellParams.bSChannelBwUL;
119    duCfgParam.macCellCfg.carrCfg.ulFreq = convertArfcnToFreqKhz(cellParams.arfcnUL);
120 #else   
121    duCfgParam.macCellCfg.carrCfg.ulBw = NR_BANDWIDTH;
122    duCfgParam.macCellCfg.carrCfg.ulFreq =  convertArfcnToFreqKhz(NR_UL_ARFCN);
123 #endif   
124    duCfgParam.macCellCfg.carrCfg.numRxAnt = NUM_RX_ANT;
125
126    /* Cell configuration */
127 #ifdef O1_ENABLE
128    duCfgParam.macCellCfg.cellCfg.opState    = cellParams.operationalState;
129    duCfgParam.macCellCfg.cellCfg.adminState = cellParams.administrativeState;
130    duCfgParam.macCellCfg.cellCfg.cellState  = cellParams.cellState;
131    duCfgParam.macCellCfg.cellCfg.phyCellId  = cellParams.nRPCI;
132    duCfgParam.macCellCfg.cellCfg.tac        = cellParams.nRTAC;
133    duCfgParam.macCellCfg.cellCfg.ssbFreq    = cellParams.ssbFrequency;
134 #else
135    duCfgParam.macCellCfg.cellCfg.opState    = OP_DISABLED; 
136    duCfgParam.macCellCfg.cellCfg.adminState = ADMIN_UNLOCKED;
137    duCfgParam.macCellCfg.cellCfg.cellState  = CELL_INACTIVE;
138    duCfgParam.macCellCfg.cellCfg.phyCellId  = NR_PCI;
139    duCfgParam.macCellCfg.cellCfg.tac        = DU_TAC; 
140    duCfgParam.macCellCfg.cellCfg.ssbFreq    = SSB_FREQUENCY;
141 #endif
142    /* Plmn And SNSSAI Configuration */
143    for(plmnIdx = 0; plmnIdx < MAX_PLMN; plmnIdx++)
144    {
145       memcpy(&duCfgParam.macCellCfg.cellCfg.plmnInfoList[plmnIdx].plmn, &duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.srvdPlmn[plmnIdx].plmn,\
146             sizeof(Plmn));
147       taiSliceSuppLst = &duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.srvdPlmn[plmnIdx].taiSliceSuppLst;
148       duCfgParam.macCellCfg.cellCfg.plmnInfoList[plmnIdx].numSupportedSlice = taiSliceSuppLst->numSupportedSlices;
149       if(taiSliceSuppLst->snssai)
150       {
151          DU_ALLOC_SHRABL_BUF(duCfgParam.macCellCfg.cellCfg.plmnInfoList[plmnIdx].snssai, (duCfgParam.macCellCfg.cellCfg.plmnInfoList[plmnIdx].numSupportedSlice) * sizeof(Snssai*));
152          if(duCfgParam.macCellCfg.cellCfg.plmnInfoList[plmnIdx].snssai == NULLP)
153          {
154             DU_LOG("\nERROR  --> DU_APP: Memory allocation failed at readMacCfg");
155             return RFAILED;
156          }
157       }
158       for(sliceIdx=0; sliceIdx < taiSliceSuppLst->numSupportedSlices; sliceIdx++)
159       {
160          if(taiSliceSuppLst->snssai[sliceIdx] != NULLP)
161          {
162             DU_ALLOC_SHRABL_BUF(duCfgParam.macCellCfg.cellCfg.plmnInfoList[plmnIdx].snssai[sliceIdx], sizeof(Snssai));
163             if(duCfgParam.macCellCfg.cellCfg.plmnInfoList[plmnIdx].snssai[sliceIdx] == NULLP)
164             {
165                DU_LOG("\nERROR  --> DU_APP: Memory allocation failed at readMacCfg");
166                return RFAILED;
167             }
168             memcpy(duCfgParam.macCellCfg.cellCfg.plmnInfoList[plmnIdx].snssai[sliceIdx], taiSliceSuppLst->snssai[sliceIdx], sizeof(Snssai));
169          }
170       }
171    }
172    duCfgParam.macCellCfg.cellCfg.subCarrSpacing = NR_SCS;
173    duCfgParam.macCellCfg.cellCfg.dupType    = DUPLEX_MODE;
174
175    /* SSB configuration */
176    duCfgParam.macCellCfg.ssbCfg.ssbPbchPwr = SSB_PBCH_PWR;
177    duCfgParam.macCellCfg.ssbCfg.bchPayloadFlag = BCH_PAYLOAD;
178    duCfgParam.macCellCfg.ssbCfg.ssbOffsetPointA = OFFSET_TO_POINT_A;
179    duCfgParam.macCellCfg.ssbCfg.betaPss = BETA_PSS;
180 #ifdef O1_ENABLE
181    duCfgParam.macCellCfg.ssbCfg.scsCmn = convertScsValToScsEnum(cellParams.ssbSubCarrierSpacing);
182    duCfgParam.macCellCfg.ssbCfg.ssbPeriod = convertSSBPeriodicityToEnum(cellParams.ssbPeriodicity);
183    duCfgParam.macCellCfg.ssbCfg.ssbScOffset = cellParams.ssbOffset;
184 #else
185    duCfgParam.macCellCfg.ssbCfg.scsCmn = NR_SCS;
186    duCfgParam.macCellCfg.ssbCfg.ssbPeriod = SSB_PRDCTY_MS_20;
187    duCfgParam.macCellCfg.ssbCfg.ssbScOffset = SSB_SUBCARRIER_OFFSET;
188 #endif
189    duCfgParam.macCellCfg.ssbCfg.ssbMask[0] = 1; /* only one SSB is transmitted */
190    if(BuildMibPdu() != ROK)
191    {
192       DU_LOG("\nERROR  -->  Failed to build MIB PDU");
193       memset(&duCfgParam.macCellCfg.ssbCfg.mibPdu, 0, 3*sizeof(uint8_t));
194    }
195    else
196    {
197       memcpy(&duCfgParam.macCellCfg.ssbCfg.mibPdu, encBuf,encBufSize);
198    }
199
200    /* PRACH configuration */
201    duCfgParam.macCellCfg.prachCfg.prachSeqLen = PRACH_SEQ_LEN;
202    duCfgParam.macCellCfg.prachCfg.prachSubcSpacing = convertScsEnumValToScsVal(PRACH_SUBCARRIER_SPACING);
203    duCfgParam.macCellCfg.prachCfg.prachCfgIdx = PRACH_CONFIG_IDX;
204    duCfgParam.macCellCfg.prachCfg.msg1Fdm = NUM_PRACH_FDM;
205    duCfgParam.macCellCfg.prachCfg.fdm[0].rootSeqIdx = ROOT_SEQ_IDX;
206    duCfgParam.macCellCfg.prachCfg.fdm[0].numRootSeq = NUM_ROOT_SEQ;
207    duCfgParam.macCellCfg.prachCfg.fdm[0].k1 = 0;
208    duCfgParam.macCellCfg.prachCfg.fdm[0].zeroCorrZoneCfg = ZERO_CORRELATION_ZONE_CFG;
209    duCfgParam.macCellCfg.prachCfg.prachRstSetCfg = PRACH_RESTRICTED_SET_CFG;
210    duCfgParam.macCellCfg.prachCfg.ssbPerRach = SSB_PER_RACH;
211    duCfgParam.macCellCfg.prachCfg.msg1FreqStart = PRACH_FREQ_START;
212
213    duCfgParam.macCellCfg.prachCfg.totalNumRaPreamble = NUM_RA_PREAMBLE;
214    duCfgParam.macCellCfg.prachCfg.numCbPreamblePerSsb = CB_PREAMBLE_PER_SSB;
215    duCfgParam.macCellCfg.prachCfg.raRspWindow = RA_RSP_WINDOW;
216    
217    /* TDD configuration */
218 #ifdef NR_TDD   
219    duCfgParam.macCellCfg.tddCfg.tddPeriod = TDD_PERIODICITY;
220    duCfgParam.macCellCfg.tddCfg.nrOfDlSlots = NUM_DL_SLOTS;
221    duCfgParam.macCellCfg.tddCfg.nrOfDlSymbols = NUM_DL_SYMBOLS;
222    duCfgParam.macCellCfg.tddCfg.nrOfUlSlots = NUM_UL_SLOTS;
223    duCfgParam.macCellCfg.tddCfg.nrOfUlSymbols = NUM_UL_SYMBOLS;
224
225    //FillSlotConfig();
226
227 #endif
228
229    /* fill SIB1 configuration */
230    duCfgParam.macCellCfg.cellCfg.sib1Cfg.sib1PduLen = duCfgParam.srvdCellLst[0].duSysInfo.sib1Len;
231    DU_ALLOC_SHRABL_BUF(duCfgParam.macCellCfg.cellCfg.sib1Cfg.sib1Pdu,duCfgParam.srvdCellLst[0].duSysInfo.sib1Len);
232    memcpy(duCfgParam.macCellCfg.cellCfg.sib1Cfg.sib1Pdu, duCfgParam.srvdCellLst[0].duSysInfo.sib1Msg, \
233          duCfgParam.srvdCellLst[0].duSysInfo.sib1Len);
234    duCfgParam.macCellCfg.cellCfg.sib1Cfg.pdcchCfgSib1.coresetZeroIndex = CORESET_0_INDEX;
235    duCfgParam.macCellCfg.cellCfg.sib1Cfg.pdcchCfgSib1.searchSpaceZeroIndex = SEARCHSPACE_0_INDEX;
236
237    duCfgParam.macCellCfg.cellCfg.sib1Cfg.pagingCfg.numPO = duCfgParam.sib1Params.srvCellCfgCommSib.dlCfg.pcchCfg.ns;
238    if((duCfgParam.sib1Params.srvCellCfgCommSib.dlCfg.pcchCfg.firstPDCCHMontioringType != \
239             PCCH_Config__firstPDCCH_MonitoringOccasionOfPO_PR_NOTHING) && (duCfgParam.macCellCfg.cellCfg.sib1Cfg.pagingCfg.numPO != 0))
240    {
241       duCfgParam.macCellCfg.cellCfg.sib1Cfg.pagingCfg.poPresent = TRUE;
242       memcpy(duCfgParam.macCellCfg.cellCfg.sib1Cfg.pagingCfg.pagingOcc, 
243             duCfgParam.sib1Params.srvCellCfgCommSib.dlCfg.pcchCfg.firstPDCCHMontioringInfo,MAX_PO_PER_PF);
244    }
245    else
246    {
247       duCfgParam.macCellCfg.cellCfg.sib1Cfg.pagingCfg.poPresent = FALSE;
248    }
249
250    /* fill Intial DL BWP */
251    duCfgParam.macCellCfg.cellCfg.initialDlBwp.bwp.firstPrb = 0;
252    duCfgParam.macCellCfg.cellCfg.initialDlBwp.bwp.numPrb = TOTAL_PRB_20MHZ_MU0; /* configured to total BW */
253    duCfgParam.macCellCfg.cellCfg.initialDlBwp.bwp.scs = duCfgParam.macCellCfg.ssbCfg.scsCmn;
254    duCfgParam.macCellCfg.cellCfg.initialDlBwp.bwp.cyclicPrefix = NORMAL_CYCLIC_PREFIX;
255    duCfgParam.macCellCfg.cellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.searchSpaceId = SEARCHSPACE_1_INDEX;
256    duCfgParam.macCellCfg.cellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.coresetId = CORESET_0_INDEX;
257    duCfgParam.macCellCfg.cellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.monitoringSlot =
258       SS_MONITORING_SLOT_SL1; /* sl1 - all slots */
259    duCfgParam.macCellCfg.cellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.duration = 0;
260    duCfgParam.macCellCfg.cellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.monitoringSymbol =
261       SS_MONITORING_SYMBOL;
262    duCfgParam.macCellCfg.cellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.
263       candidate.aggLevel1       = 8;
264    duCfgParam.macCellCfg.cellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.
265       candidate.aggLevel2       = 4;
266    duCfgParam.macCellCfg.cellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.
267       candidate.aggLevel4       = 2;
268    duCfgParam.macCellCfg.cellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.
269       candidate.aggLevel8       = 1;
270    duCfgParam.macCellCfg.cellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.
271       candidate.aggLevel16      = 0;
272
273    duCfgParam.macCellCfg.cellCfg.initialDlBwp.pdschCommon.numTimeDomAlloc = NUM_TIME_DOM_RSRC_ALLOC;
274    idx = 0;
275    duCfgParam.macCellCfg.cellCfg.initialDlBwp.pdschCommon.timeDomRsrcAllocList[idx].k0 = PDSCH_K0_CFG1;
276    duCfgParam.macCellCfg.cellCfg.initialDlBwp.pdschCommon.timeDomRsrcAllocList[idx].mappingType = 
277       PDSCH_MAPPING_TYPE_A;
278    duCfgParam.macCellCfg.cellCfg.initialDlBwp.pdschCommon.timeDomRsrcAllocList[idx].startSymbol = 
279       PDSCH_START_SYMBOL;
280    duCfgParam.macCellCfg.cellCfg.initialDlBwp.pdschCommon.timeDomRsrcAllocList[idx].lengthSymbol =
281       PDSCH_LENGTH_SYMBOL;
282
283    idx++;
284    duCfgParam.macCellCfg.cellCfg.initialDlBwp.pdschCommon.timeDomRsrcAllocList[idx].k0 = PDSCH_K0_CFG2;
285    duCfgParam.macCellCfg.cellCfg.initialDlBwp.pdschCommon.timeDomRsrcAllocList[idx].mappingType = 
286       PDSCH_MAPPING_TYPE_A;
287    duCfgParam.macCellCfg.cellCfg.initialDlBwp.pdschCommon.timeDomRsrcAllocList[idx].startSymbol = 
288       PDSCH_START_SYMBOL;
289    duCfgParam.macCellCfg.cellCfg.initialDlBwp.pdschCommon.timeDomRsrcAllocList[idx].lengthSymbol =
290       PDSCH_LENGTH_SYMBOL;
291
292    /* ra-searchSpace ID is set to 1 */
293    duCfgParam.macCellCfg.cellCfg.initialDlBwp.pdcchCommon.raSearchSpaceId = SEARCHSPACE_1_INDEX;
294
295    /* fill Intial UL BWP */
296    duCfgParam.macCellCfg.cellCfg.initialUlBwp.bwp.firstPrb = 0;
297    duCfgParam.macCellCfg.cellCfg.initialUlBwp.bwp.numPrb = TOTAL_PRB_20MHZ_MU0; /* configured to total BW */
298    duCfgParam.macCellCfg.cellCfg.initialUlBwp.bwp.scs = duCfgParam.macCellCfg.ssbCfg.scsCmn;
299    duCfgParam.macCellCfg.cellCfg.initialUlBwp.bwp.cyclicPrefix = NORMAL_CYCLIC_PREFIX;
300    duCfgParam.macCellCfg.cellCfg.initialUlBwp.puschCommon.numTimeDomRsrcAlloc = 2;
301    duCfgParam.macCellCfg.cellCfg.initialUlBwp.puschCommon.timeDomRsrcAllocList[0].k2 = PUSCH_K2_CFG1;
302    duCfgParam.macCellCfg.cellCfg.initialUlBwp.puschCommon.timeDomRsrcAllocList[0].mappingType = 
303       PUSCH_MAPPING_TYPE_A;
304    duCfgParam.macCellCfg.cellCfg.initialUlBwp.puschCommon.timeDomRsrcAllocList[0].startSymbol = 
305       PUSCH_START_SYMBOL;
306    duCfgParam.macCellCfg.cellCfg.initialUlBwp.puschCommon.timeDomRsrcAllocList[0].symbolLength =
307       PUSCH_LENGTH_SYMBOL;
308
309    duCfgParam.macCellCfg.cellCfg.initialUlBwp.puschCommon.timeDomRsrcAllocList[1].k2 = PUSCH_K2_CFG2;
310    duCfgParam.macCellCfg.cellCfg.initialUlBwp.puschCommon.timeDomRsrcAllocList[1].mappingType = 
311       PUSCH_MAPPING_TYPE_A;
312    duCfgParam.macCellCfg.cellCfg.initialUlBwp.puschCommon.timeDomRsrcAllocList[1].startSymbol = 
313       PUSCH_START_SYMBOL;
314    duCfgParam.macCellCfg.cellCfg.initialUlBwp.puschCommon.timeDomRsrcAllocList[1].symbolLength =
315       PUSCH_LENGTH_SYMBOL;
316
317    duCfgParam.macCellCfg.ssbCfg.dmrsTypeAPos = DMRS_TYPE_A_POS; 
318
319    /* fill PUCCH config common */
320    duCfgParam.macCellCfg.cellCfg.initialUlBwp.pucchCommon.pucchResourceCommon = PUCCH_RSRC_COMMON;
321    duCfgParam.macCellCfg.cellCfg.initialUlBwp.pucchCommon.pucchGroupHopping = PUCCH_GROUP_HOPPING;
322
323
324 #ifndef O1_ENABLE
325
326    /*Note: Static Configuration, when O1 is not configuring the RRM policy*/
327    RrmPolicyList rrmPolicy;
328    rrmPolicy.id[0] = 1;
329    rrmPolicy.resourceType = PRB;
330    rrmPolicy.rRMMemberNum = 1;
331    memcpy(rrmPolicy.rRMPolicyMemberList[0].mcc,duCfgParam.macCellCfg.cellCfg.plmnInfoList[0].plmn.mcc, 3*sizeof(uint8_t));
332    memcpy(rrmPolicy.rRMPolicyMemberList[0].mnc,duCfgParam.macCellCfg.cellCfg.plmnInfoList[0].plmn.mnc, 3*sizeof(uint8_t));
333    rrmPolicy.rRMPolicyMemberList[0].sst = 1;
334    rrmPolicy.rRMPolicyMemberList[0].sd[0] = 2;
335    rrmPolicy.rRMPolicyMemberList[0].sd[1] = 3;
336    rrmPolicy.rRMPolicyMemberList[0].sd[2] = 4;
337    rrmPolicy.rRMPolicyMaxRatio = 90;
338    rrmPolicy.rRMPolicyMinRatio = 30;
339    rrmPolicy.rRMPolicyDedicatedRatio = 10;
340
341    cpyRrmPolicyInDuCfgParams(&rrmPolicy, 1, &duCfgParam.tempSliceCfg);
342
343 #endif
344
345    return ROK;
346 }
347
348 /*******************************************************************
349  *
350  * @brief Configures the DU Parameters
351  *
352  * @details
353  *
354  *    Function : fillDuPort
355  *
356  *    Functionality:
357  *       - fills the DU Ports.  
358  *
359  * @params[in] duPort array to be filled
360  * @return ROK     - success
361  *         RFAILED - failure
362  *
363  * ****************************************************************/
364 uint8_t fillDuPort(uint16_t *duPort)
365 {
366
367 #ifdef O1_ENABLE
368    duPort[F1_INTERFACE]   = g_cfg.DU_Port;
369    duPort[E2_INTERFACE]   = g_cfg.RIC_Port;
370 #else
371    duPort[F1_INTERFACE]   = F1_SCTP_PORT;     /* DU Port idx  0 38472 */
372    duPort[E2_INTERFACE]   = E2_SCTP_PORT;    /* RIC Port idx 1 36421 */
373 #endif
374    return ROK;
375 }
376
377 /*******************************************************************
378  *
379  * @brief Configures the DU Parameters
380  *
381  * @details
382  *
383  *    Function : calcSliv
384  *
385  *    Functionality:
386  *       - calculate SLIV value from start and length field
387  *
388  * @params[in] start symbol
389  * @params[in] length of symbols
390  * @return SLIV value
391  *
392  * ****************************************************************/
393 uint16_t calcSliv(uint8_t startSymbol, uint8_t lengthSymbol)
394 {
395    uint16_t sliv = 0;
396    if((lengthSymbol-1) <= 7)
397    {
398       sliv = NUM_SYMBOLS_PER_SLOT * (lengthSymbol-1) + startSymbol;
399    }
400    else
401    {
402       sliv = NUM_SYMBOLS_PER_SLOT * (NUM_SYMBOLS_PER_SLOT - lengthSymbol + 1) \
403              + (NUM_SYMBOLS_PER_SLOT - 1 - startSymbol);
404    }
405    return sliv;
406 }
407
408
409 /*******************************************************************
410  *
411  * @brief Configures serving cell config common in sib1
412  *
413  * @details
414  *
415  *    Function : fillServCellCfgCommSib
416  *
417  *    Functionality:
418  *       - fills Serving cell config common for SIB1
419  *
420  * @params[in] SrvCellCfgCommSib pointer
421  * @return ROK     - success
422  *         RFAILED - failure
423  * 
424  ** ****************************************************************/
425 uint8_t fillServCellCfgCommSib(SrvCellCfgCommSib *srvCellCfgComm)
426 {
427    PdcchCfgCommon   pdcchCfg;
428    PdschCfgCommon   pdschCfg;
429    PcchCfg          pcchCfg;
430    RachCfgCommon    rachCfg;
431    PuschCfgCommon   puschCfg;
432    PucchCfgCommon   pucchCfg;
433    TddUlDlCfgCommon   tddCfg;
434
435 #ifdef O1_ENABLE
436    srvCellCfgComm->scs = convertScsValToScsEnum(cellParams.ssbSubCarrierSpacing);
437 #else
438    srvCellCfgComm->scs = NR_SCS;
439 #endif
440
441    /* Configuring DL Config Common for SIB1*/
442    srvCellCfgComm->dlCfg.freqBandInd = NR_FREQ_BAND; 
443    srvCellCfgComm->dlCfg.offsetToPointA = OFFSET_TO_POINT_A;
444 #ifdef O1_ENABLE
445    srvCellCfgComm->dlCfg.dlScsCarrier.scsOffset =  cellParams.ssbOffset;
446    srvCellCfgComm->dlCfg.dlScsCarrier.scs = convertScsValToScsEnum(cellParams.ssbSubCarrierSpacing);
447    srvCellCfgComm->dlCfg.dlScsCarrier.scsBw =  cellParams.bSChannelBwUL;
448 #else
449    srvCellCfgComm->dlCfg.dlScsCarrier.scsOffset = SSB_SUBCARRIER_OFFSET;
450    srvCellCfgComm->dlCfg.dlScsCarrier.scs = NR_SCS;
451    srvCellCfgComm->dlCfg.dlScsCarrier.scsBw = NR_BANDWIDTH;
452 #endif   
453    srvCellCfgComm->dlCfg.locAndBw = FREQ_LOC_BW;
454
455    /* Configuring PDCCH Config Common For SIB1 */
456    pdcchCfg.present = BWP_DownlinkCommon__pdcch_ConfigCommon_PR_setup;
457    pdcchCfg.ctrlRsrcSetZero = CORESET_0_INDEX;
458    pdcchCfg.searchSpcZero = SEARCHSPACE_0_INDEX;
459    pdcchCfg.searchSpcId = PDCCH_SEARCH_SPACE_ID;
460    pdcchCfg.ctrlRsrcSetId = PDCCH_CTRL_RSRC_SET_ID;
461    pdcchCfg.monitorSlotPrdAndOffPresent = SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl1;
462    //pdcchCfg.monitorSlotPrdAndOff = \
463    SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl1;
464    pdcchCfg.monitorSymbolsInSlot[0] = 128;
465    pdcchCfg.monitorSymbolsInSlot[1] = 0;
466    pdcchCfg.numCandAggLvl1 = SearchSpace__nrofCandidates__aggregationLevel1_n8;
467    pdcchCfg.numCandAggLvl2 = SearchSpace__nrofCandidates__aggregationLevel2_n4;
468    pdcchCfg.numCandAggLvl4 = SearchSpace__nrofCandidates__aggregationLevel4_n2;
469    pdcchCfg.numCandAggLvl8 = SearchSpace__nrofCandidates__aggregationLevel8_n1;
470    pdcchCfg.numCandAggLvl16 = SearchSpace__nrofCandidates__aggregationLevel16_n0;
471    pdcchCfg.searchSpcType = SearchSpace__searchSpaceType_PR_common;
472    pdcchCfg.commSrchSpcDciFrmt = PDCCH_SERACH_SPACE_DCI_FORMAT;
473    pdcchCfg.searchSpcSib1 = PDCCH_SEARCH_SPACE_ID_SIB1;
474    pdcchCfg.pagingSearchSpc = PDCCH_SEARCH_SPACE_ID_PAGING;
475    pdcchCfg.raSearchSpc = PDCCH_SEARCH_SPACE_ID_PAGING;
476    srvCellCfgComm->dlCfg.pdcchCfg = pdcchCfg;
477
478    /* Configuring PDSCH Config Common For SIB1 */
479    pdschCfg.present = BWP_DownlinkCommon__pdsch_ConfigCommon_PR_setup;
480    pdschCfg.numTimeDomRsrcAlloc = 2;
481    pdschCfg.timeDomAlloc[0].k0 = PDSCH_K0_CFG1;
482    pdschCfg.timeDomAlloc[0].mapType = PDSCH_TimeDomainResourceAllocation__mappingType_typeA;
483    pdschCfg.timeDomAlloc[0].sliv = calcSliv(PDSCH_START_SYMBOL,PDSCH_LENGTH_SYMBOL);
484
485    pdschCfg.timeDomAlloc[1].k0 = PDSCH_K0_CFG2;
486    pdschCfg.timeDomAlloc[1].mapType = PDSCH_TimeDomainResourceAllocation__mappingType_typeA;
487    pdschCfg.timeDomAlloc[1].sliv = calcSliv(PDSCH_START_SYMBOL,PDSCH_LENGTH_SYMBOL);
488
489    srvCellCfgComm->dlCfg.pdschCfg = pdschCfg;
490
491    /* Configuring BCCH Config for SIB1 */
492    srvCellCfgComm->dlCfg.bcchCfg.modPrdCoeff = BCCH_Config__modificationPeriodCoeff_n16;
493
494    /* Configuring PCCH Config for SIB1 */
495    pcchCfg.dfltPagingCycle = convertPagingCycleEnumToValue(PagingCycle_rf256);
496    pcchCfg.nAndPagingFrmOffsetType = PCCH_Config__nAndPagingFrameOffset_PR_oneT;
497    pcchCfg.pageFrameOffset = 0;
498    pcchCfg.ns = convertNsEnumToValue(PCCH_Config__ns_one);
499    pcchCfg.firstPDCCHMontioringType = PCCH_Config__firstPDCCH_MonitoringOccasionOfPO_PR_sCS30KHZoneT_SCS15KHZhalfT;
500    memset(pcchCfg.firstPDCCHMontioringInfo, 0, sizeof(uint16_t));
501    pcchCfg.firstPDCCHMontioringInfo[0] = 44;
502    
503    srvCellCfgComm->dlCfg.pcchCfg = pcchCfg;
504
505
506    /* Configuring UL Config Common */
507 #ifdef O1_ENABLE
508    srvCellCfgComm->ulCfg.ulScsCarrier.scsOffset =  cellParams.ssbOffset;
509    srvCellCfgComm->ulCfg.ulScsCarrier.scs = convertScsValToScsEnum(cellParams.ssbSubCarrierSpacing);
510    srvCellCfgComm->ulCfg.ulScsCarrier.scsBw = cellParams.bSChannelBwUL; 
511 #else
512    srvCellCfgComm->ulCfg.ulScsCarrier.scsOffset = SSB_SUBCARRIER_OFFSET;
513    srvCellCfgComm->ulCfg.ulScsCarrier.scs = NR_SCS;
514    srvCellCfgComm->ulCfg.ulScsCarrier.scsBw = NR_BANDWIDTH;
515 #endif   
516    srvCellCfgComm->ulCfg.freqBandInd = NR_FREQ_BAND;
517    srvCellCfgComm->ulCfg.pMax = UL_P_MAX;
518    srvCellCfgComm->ulCfg.locAndBw = FREQ_LOC_BW;
519    srvCellCfgComm->ulCfg.timeAlignTimerComm = TimeAlignmentTimer_infinity;
520
521    /* Configuring RACH Config Common for SIB1 */
522    rachCfg.present = BWP_UplinkCommon__rach_ConfigCommon_PR_setup;
523    rachCfg.prachCfgIdx = PRACH_CONFIG_IDX;
524    rachCfg.msg1Fdm = RACH_ConfigGeneric__msg1_FDM_one;
525    rachCfg.msg1FreqStart = PRACH_FREQ_START;
526    rachCfg.zeroCorrZoneCfg = ZERO_CORRELATION_ZONE_CFG;
527    rachCfg.preambleRcvdTgtPwr = PRACH_PREAMBLE_RCVD_TGT_PWR;
528    rachCfg.preambleTransMax = RACH_ConfigGeneric__preambleTransMax_n200;
529    rachCfg.pwrRampingStep = RACH_ConfigGeneric__powerRampingStep_dB2;
530    rachCfg.raRspWindow = RACH_ConfigGeneric__ra_ResponseWindow_sl10;
531    rachCfg.numRaPreamble = NUM_RA_PREAMBLE;
532    rachCfg.numSsbPerRachOcc = RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_one;
533    rachCfg.numCbPreamblePerSsb = CB_PREAMBLE_PER_SSB;
534    rachCfg.contResTimer = RACH_ConfigCommon__ra_ContentionResolutionTimer_sf64;
535    rachCfg.rsrpThreshSsb = RSRP_THRESHOLD_SSB;
536    rachCfg.rootSeqIdxPresent = RACH_ConfigCommon__prach_RootSequenceIndex_PR_l139;
537    rachCfg.rootSeqIdx = ROOT_SEQ_IDX;
538    rachCfg.msg1Scs = PRACH_SUBCARRIER_SPACING ;
539    rachCfg.restrictedSetCfg = PRACH_RESTRICTED_SET_CFG;
540    srvCellCfgComm->ulCfg.rachCfg = rachCfg;
541
542    /* Configuring PUSCH Config Common for SIB1 */
543    puschCfg.puschCfgPresent = BWP_UplinkCommon__pusch_ConfigCommon_PR_setup;
544    puschCfg.numTimeDomRsrcAlloc = 2;
545    puschCfg.timeDomAllocList[0].k2 = PUSCH_K2_CFG1;
546    puschCfg.timeDomAllocList[0].mapType = PUSCH_TimeDomainResourceAllocation__mappingType_typeA;
547    puschCfg.timeDomAllocList[0].sliv = calcSliv(PUSCH_START_SYMBOL,PUSCH_LENGTH_SYMBOL);
548    puschCfg.timeDomAllocList[1].k2 = PUSCH_K2_CFG2;
549    puschCfg.timeDomAllocList[1].mapType = PUSCH_TimeDomainResourceAllocation__mappingType_typeA;
550    puschCfg.timeDomAllocList[1].sliv = calcSliv(PUSCH_START_SYMBOL,PUSCH_LENGTH_SYMBOL);
551    puschCfg.msg3DeltaPreamble = PUSCH_MSG3_DELTA_PREAMBLE;
552    puschCfg.p0NominalWithGrant = PUSCH_P0_NOMINAL_WITH_GRANT;
553    srvCellCfgComm->ulCfg.puschCfg = puschCfg;
554
555    /* Configuring PUCCH Config Common for SIB1 */
556    pucchCfg.present = BWP_UplinkCommon__pucch_ConfigCommon_PR_setup;
557    pucchCfg.rsrcComm = PUCCH_RSRC_COMMON;
558    pucchCfg.grpHop = PUCCH_ConfigCommon__pucch_GroupHopping_neither;
559    pucchCfg.p0Nominal = PUCCH_P0_NOMINAL;
560    srvCellCfgComm->ulCfg.pucchCfg = pucchCfg;
561
562    /* Configuring TDD UL DL config common */
563    tddCfg.refScs = SubcarrierSpacing_kHz30;
564    tddCfg.txPrd = TDD_UL_DL_Pattern__dl_UL_TransmissionPeriodicity_ms5;
565    tddCfg.numDlSlots = NUM_DL_SLOTS;
566    tddCfg.numDlSymbols = NUM_DL_SYMBOLS;
567    tddCfg.numUlSlots = NUM_UL_SLOTS;
568    tddCfg.numUlSymbols = NUM_UL_SYMBOLS;
569    srvCellCfgComm->tddCfg = tddCfg;
570
571    srvCellCfgComm->ssbPosInBurst = 192;
572    srvCellCfgComm->ssbPrdServingCell = SSB_PERIODICITY;
573    srvCellCfgComm->ssPbchBlockPwr = SSB_PBCH_PWR;
574
575    return ROK;
576 }
577
578 /*******************************************************************
579  *
580  * @brief Configures the DU Parameters
581  *
582  * @details
583  *
584  *    Function : readCfg
585  *
586  *    Functionality:
587  *       - Initializes the DuCfg members.  
588  *       - Calls readMacCfg()  
589  *
590  * @params[in] system task ID
591  * @return ROK     - success
592  *         RFAILED - failure
593  *
594  * ****************************************************************/
595
596 uint8_t readCfg()
597 {
598    CmLList *node;
599    uint8_t srvdCellIdx, bandIdx, sliceIdx, plmnIdx, ranFuncIdx, eventTriggerStyleIdx, reportStyleIdx, tnlAssocIdx;
600    uint8_t brdcstPlmnIdx, freqBandIdx, srvdPlmnIdx;
601    uint32_t ipv4_du, ipv4_cu, ipv4_ric;
602    MibParams mib;
603    Sib1Params sib1;
604    F1TaiSliceSuppLst *taiSliceSuppLst;
605    uint8_t measurementInfoIdx =0, measurementInfoLen=0;
606    char shortName[] = SHORT_NAME;
607    char serviceModelOID[]= SERVICE_MODEL_OID;
608    char  description[] = DESCRIPTION;
609    char event_trigger_style_name[]= EVENT_TRIGGER_STYLE_NAME;
610    char ric_report_style_name[]= REPORT_STYLE_NAME;
611
612 #ifndef O1_ENABLE
613    /* Note: Added these below variable for local testing*/
614    Snssai snssai[NUM_OF_SUPPORTED_SLICE] = {{1,{2,3,4}},{5,{6,7,8}}};
615 #endif
616
617    /* Gnb Id */
618    duCb.gnbId = GNB_ID;
619    
620 #ifdef O1_ENABLE
621    if( getStartupConfig(&g_cfg) != ROK )
622    {
623       RETVALUE(RFAILED);
624    }
625    cmInetAddr((S8*)g_cfg.DU_IPV4_Addr, &ipv4_du);
626    cmInetAddr((S8*)g_cfg.CU_IPV4_Addr, &ipv4_cu);
627    cmInetAddr((S8*)g_cfg.RIC_IPV4_Addr, &ipv4_ric);
628
629    duCfgParam.sctpParams.cuPort = g_cfg.CU_Port;
630    duCfgParam.sctpParams.ricPort = g_cfg.RIC_Port;
631 #else   
632    cmInetAddr((S8*)DU_IP_V4_ADDR, &ipv4_du);
633    cmInetAddr((S8*)CU_IP_V4_ADDR, &ipv4_cu);
634    cmInetAddr((S8*)RIC_IP_V4_ADDR, &ipv4_ric);
635
636    duCfgParam.sctpParams.cuPort = F1_SCTP_PORT;
637    duCfgParam.sctpParams.ricPort = E2_SCTP_PORT;
638 #endif
639
640    fillDuPort(duCfgParam.sctpParams.duPort);
641    
642    /* F1 DU IP Address and Port*/
643    duCfgParam.sctpParams.duIpAddr.ipV4Addr = ipv4_du;
644
645    /* F1 CU IP Address and Port*/
646    duCfgParam.sctpParams.cuIpAddr.ipV4Addr = ipv4_cu;
647
648    /* Fill RIC Params */
649    duCfgParam.sctpParams.ricIpAddr.ipV4Addr = ipv4_ric;
650
651    /* EGTP Parameters */
652    duCfgParam.egtpParams.localIp.ipV4Pres = TRUE;
653    duCfgParam.egtpParams.localIp.ipV4Addr = ipv4_du;
654    duCfgParam.egtpParams.localPort = F1_EGTP_PORT;
655    duCfgParam.egtpParams.destIp.ipV4Pres = TRUE;
656    duCfgParam.egtpParams.destIp.ipV4Addr = ipv4_cu;
657    duCfgParam.egtpParams.destPort = F1_EGTP_PORT;
658    duCfgParam.egtpParams.minTunnelId = MIN_TEID;
659    duCfgParam.egtpParams.maxTunnelId = MAX_TEID;
660
661    duCfgParam.maxUe = 32; //TODO: Check
662    
663    /* DU Info */
664    duCfgParam.duId = DU_ID;
665    DU_ALLOC(duCfgParam.duName, sizeof(DU_NAME));
666    if(!duCfgParam.duName)
667    {
668       DU_LOG("\nDEBUG --> DU_APP: readCfg(): Memory allocation failure for DU name");   
669       return RFAILED;
670    }
671    strcpy((char*)duCfgParam.duName,DU_NAME);
672
673    memset(&duCb.e2apDb, 0, sizeof(E2apDb));
674    duCb.e2apDb.e2NodeId =  DU_ID;
675    duCb.e2apDb.e2TransInfo.transIdCounter = 0;
676
677    duCb.e2apDb.numOfTNLAssoc = 1;
678    for(tnlAssocIdx =0; tnlAssocIdx<duCb.e2apDb.numOfTNLAssoc; tnlAssocIdx++)
679    {
680       duCb.e2apDb.tnlAssoc[tnlAssocIdx].localIpAddress.ipV4Pres = duCfgParam.sctpParams.duIpAddr.ipV4Pres;
681       duCb.e2apDb.tnlAssoc[tnlAssocIdx].localIpAddress.ipV4Addr = duCfgParam.sctpParams.duIpAddr.ipV4Addr;
682       duCb.e2apDb.tnlAssoc[tnlAssocIdx].localPort = duCfgParam.sctpParams.duPort[E2_INTERFACE];
683       duCb.e2apDb.tnlAssoc[tnlAssocIdx].destIpAddress.ipV4Pres = duCfgParam.sctpParams.ricIpAddr.ipV4Pres;
684       duCb.e2apDb.tnlAssoc[tnlAssocIdx].destIpAddress.ipV4Addr = duCfgParam.sctpParams.ricIpAddr.ipV4Addr;
685       duCb.e2apDb.tnlAssoc[tnlAssocIdx].destPort = duCfgParam.sctpParams.ricPort;
686       duCb.e2apDb.tnlAssoc[tnlAssocIdx].usage = BOTH_FUNCTIONALITY;
687    }
688    duCb.e2apDb.numOfRanFunction = 1;
689    for(ranFuncIdx =0; ranFuncIdx<duCb.e2apDb.numOfRanFunction; ranFuncIdx++)
690    {
691       duCb.e2apDb.ranFunction[ranFuncIdx].id = ranFuncIdx + 1;
692       memcpy(&duCb.e2apDb.ranFunction[ranFuncIdx].name.shortName, shortName, sizeof(shortName));
693       memcpy(&duCb.e2apDb.ranFunction[ranFuncIdx].name.serviceModelOID, serviceModelOID, sizeof(serviceModelOID));
694       memcpy(&duCb.e2apDb.ranFunction[ranFuncIdx].name.description, description, sizeof(description));
695       duCb.e2apDb.ranFunction[ranFuncIdx].revisionCounter = 0;
696       
697       duCb.e2apDb.ranFunction[ranFuncIdx].numOfEventTriggerStyleSupported  = NUM_OF_EVENT_TRIGGER_STYLE_SUPPORTED;
698       for(eventTriggerStyleIdx=0; eventTriggerStyleIdx<duCb.e2apDb.ranFunction[ranFuncIdx].numOfEventTriggerStyleSupported; eventTriggerStyleIdx++)
699       {
700          duCb.e2apDb.ranFunction[ranFuncIdx].eventTriggerStyleList[eventTriggerStyleIdx].styleType = EVENT_TRIGGER_STYLE_TYPE;
701          duCb.e2apDb.ranFunction[ranFuncIdx].eventTriggerStyleList[eventTriggerStyleIdx].formatType = EVENT_TRIGGER_STYLE_FORMAT_TYPE;
702          memcpy(duCb.e2apDb.ranFunction[ranFuncIdx].eventTriggerStyleList[eventTriggerStyleIdx].name, event_trigger_style_name, sizeof(event_trigger_style_name));
703       }
704       
705       duCb.e2apDb.ranFunction[ranFuncIdx].numOfReportStyleSupported= NUM_OF_RIC_REPORT_STYLE_SUPPORTED;
706       for(reportStyleIdx=0; reportStyleIdx<duCb.e2apDb.ranFunction[ranFuncIdx].numOfReportStyleSupported; reportStyleIdx++)
707       {
708          duCb.e2apDb.ranFunction[ranFuncIdx].reportStyleList[reportStyleIdx].reportStyle.styleType = REPORT_STYLE_TYPE;
709          duCb.e2apDb.ranFunction[ranFuncIdx].reportStyleList[reportStyleIdx].reportStyle.formatType = REPORT_ACTION_FORMAT_TYPE;
710          memcpy(duCb.e2apDb.ranFunction[ranFuncIdx].reportStyleList[reportStyleIdx].reportStyle.name, ric_report_style_name, sizeof(ric_report_style_name));
711          
712          for(measurementInfoIdx =0; measurementInfoIdx<NUM_OF_MEASUREMENT_INFO_SUPPORTED(CONFIG_ADD); measurementInfoIdx++)
713          {
714             measurementInfoLen= strlen(MEASUREMENT_TYPE_NAME[measurementInfoIdx]);
715             MeasurementInfoForAction *measurementInfoForAction;
716             DU_ALLOC(measurementInfoForAction, sizeof(MeasurementInfoForAction));
717             if(measurementInfoForAction)
718             {
719                measurementInfoForAction->measurementTypeId = measurementInfoIdx+1;
720                memcpy(measurementInfoForAction->measurementTypeName, MEASUREMENT_TYPE_NAME[measurementInfoIdx], measurementInfoLen+1);
721             }
722             DU_ALLOC(node, sizeof(CmLList));
723             if(node)
724             {
725                node->node = (PTR) measurementInfoForAction;
726                cmLListAdd2Tail(&duCb.e2apDb.ranFunction[ranFuncIdx].reportStyleList[reportStyleIdx].measurementInfoList, node);
727             }
728             else
729             {
730
731                DU_FREE(measurementInfoForAction, sizeof(MeasurementInfoForAction));
732             }
733          }
734       }
735       
736       duCb.e2apDb.ranFunction[ranFuncIdx].ricIndicationHeaderFormat = RIC_INDICATION_HEADER_FORMAT;
737       duCb.e2apDb.ranFunction[ranFuncIdx].ricIndicationMessageFormat = RIC_INDICATION_MESSAGE_FORMAT; 
738    }
739    memset(duCb.e2apDb.e2TransInfo.e2InitTransaction, 0, MAX_NUM_TRANSACTION * sizeof(E2TransInfo));
740    memset(duCb.e2apDb.e2TransInfo.ricInitTransaction, 0, MAX_NUM_TRANSACTION * sizeof(E2TransInfo));
741    
742    /* Mib Params */
743    mib.sysFrmNum = SYS_FRAME_NUM;
744 #ifdef NR_TDD
745    mib.subCarrierSpacingCommon = MIB__subCarrierSpacingCommon_scs30or120;
746 #else
747    mib.subCarrierSpacingCommon = MIB__subCarrierSpacingCommon_scs15or60;
748 #endif
749    mib.ssb_SubcarrierOffset = SSB_SC_OFFSET; //Kssb
750    mib.dmrs_TypeA_Position = MIB__dmrs_TypeA_Position_pos2;
751    mib.controlResourceSetZero = CORESET_0_INDEX;
752    mib.searchSpaceZero = SEARCHSPACE_0_INDEX;
753    mib.cellBarred = MIB__cellBarred_notBarred;
754    mib.intraFreqReselection = MIB__intraFreqReselection_notAllowed;
755    duCfgParam.mibParams = mib;
756
757    /* SIB1 Params */
758    memset(&sib1.plmn, 0, sizeof(Plmn));
759    sib1.plmn.mcc[0] = PLMN_MCC0;
760    sib1.plmn.mcc[1] = PLMN_MCC1;
761    sib1.plmn.mcc[2] = PLMN_MCC2;
762    sib1.plmn.mnc[0] = PLMN_MNC0;
763    sib1.plmn.mnc[1] = PLMN_MNC1;
764    sib1.ranac = DU_RANAC;
765
766 #ifdef O1_ENABLE
767    sib1.tac =  cellParams.nRTAC;
768    sib1.cellIdentity =  CELL_IDENTITY *  cellParams.cellLocalId;
769    DU_LOG("\nDEBUG --> DU_APP: readCfg(): OAM CellLocalId=%d", \
770               sib1.cellIdentity);
771 #else
772    sib1.tac = DU_TAC;
773    sib1.cellIdentity = CELL_IDENTITY * NR_CELL_ID;
774 #endif
775    sib1.cellResvdForOpUse = PLMN_IdentityInfo__cellReservedForOperatorUse_notReserved;
776    sib1.connEstFailCnt = ConnEstFailureControl__connEstFailCount_n3;
777    sib1.connEstFailOffValidity = ConnEstFailureControl__connEstFailOffsetValidity_s900;
778    sib1.connEstFailOffset = 15;
779    sib1.siSchedInfo.winLen = SI_SchedulingInfo__si_WindowLength_s5;
780    sib1.siSchedInfo.broadcastSta = SchedulingInfo__si_BroadcastStatus_broadcasting;
781    sib1.siSchedInfo.preiodicity = SchedulingInfo__si_Periodicity_rf8;
782    sib1.siSchedInfo.sibType = SIB_TypeInfo__type_sibType2;
783    sib1.siSchedInfo.sibValTag = SIB1_VALUE_TAG;
784
785    fillServCellCfgCommSib(&sib1.srvCellCfgCommSib);
786
787    duCfgParam.sib1Params = sib1;
788
789    for(srvdCellIdx=0; srvdCellIdx<DEFAULT_CELLS; srvdCellIdx++)
790    { 
791       memset(&duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.nrCgi.plmn, 0, sizeof(Plmn));
792       duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.nrCgi.plmn.mcc[0] = PLMN_MCC0;
793       duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.nrCgi.plmn.mcc[1] = PLMN_MCC1;
794       duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.nrCgi.plmn.mcc[2] = PLMN_MCC2;
795       duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.nrCgi.plmn.mnc[0] = PLMN_MNC0;
796       duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.nrCgi.plmn.mnc[1] = PLMN_MNC1;
797
798       /*Cell ID */
799  #ifdef O1_ENABLE
800       duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.nrPci = cellParams.nRPCI;
801  #else
802       duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.nrPci = NR_PCI;
803 #endif
804       /* List of Available PLMN */
805       for(srvdPlmnIdx=0; srvdPlmnIdx<MAX_PLMN; srvdPlmnIdx++)
806       {
807          /* As per spec 38.473, Plmn identity consists of 3 digit from mcc
808           * followed by either 2 digit or 3 digits of mnc */ 
809
810          memset(&duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].plmn, 0,\
811          sizeof(Plmn));
812  #ifdef O1_ENABLE
813          duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].plmn.mcc[0] = cellParams.plmnList[srvdPlmnIdx].mcc[0];
814          duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].plmn.mcc[1] = cellParams.plmnList[srvdPlmnIdx].mcc[1];
815          duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].plmn.mcc[2] = cellParams.plmnList[srvdPlmnIdx].mcc[2];
816          duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].plmn.mnc[0] = cellParams.plmnList[srvdPlmnIdx].mnc[0];
817          duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].plmn.mnc[1] = cellParams.plmnList[srvdPlmnIdx].mnc[1];
818          duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].plmn.mnc[2] = cellParams.plmnList[srvdPlmnIdx].mnc[2];
819  #else
820          duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].plmn.mcc[0] = PLMN_MCC0;
821          duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].plmn.mcc[1] = PLMN_MCC1;
822          duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].plmn.mcc[2] = PLMN_MCC2;
823          duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].plmn.mnc[0] = PLMN_MNC0;
824          duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].plmn.mnc[1] = PLMN_MNC1;
825 #endif
826       }
827       /* List of Extended PLMN */
828       for(srvdPlmnIdx=0; srvdPlmnIdx<MAX_PLMN; srvdPlmnIdx++)
829       {
830          /* As per spec 38.473, Plmn identity consists of 3 digit from mcc
831           * followed by either 2 digit or 3 digits of mnc */ 
832
833          memset(&duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].extPlmn, 0, sizeof(Plmn));
834          duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].extPlmn.mcc[0] = PLMN_MCC0;
835          duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].extPlmn.mcc[1] = PLMN_MCC1;
836          duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].extPlmn.mcc[2] = PLMN_MCC2;
837          duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].extPlmn.mnc[0] = PLMN_MNC0;
838          duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].extPlmn.mnc[1] = PLMN_MNC1;
839       } 
840       /* List of Supporting Slices */
841       for(srvdPlmnIdx=0; srvdPlmnIdx<MAX_PLMN; srvdPlmnIdx++)
842       {
843          taiSliceSuppLst = &duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].\
844          taiSliceSuppLst;
845          
846          /* TODO Calculte the exact number of supported slices once will get
847           * cell configuration from O1 */
848          taiSliceSuppLst->numSupportedSlices = NUM_OF_SUPPORTED_SLICE;
849          if(taiSliceSuppLst->numSupportedSlices > MAX_NUM_OF_SLICE_ITEMS)
850          {
851             DU_LOG("\nERROR --> DU_APP: readCfg(): Number of supported slice [%d] is more than 1024",\
852             taiSliceSuppLst->numSupportedSlices);
853             return RFAILED;
854          }
855
856          DU_ALLOC(taiSliceSuppLst->snssai, taiSliceSuppLst->numSupportedSlices*sizeof(Snssai*));
857          if(taiSliceSuppLst->snssai == NULLP)
858          {
859             DU_LOG("\nERROR --> DU_APP: readCfg():Memory allocation failed");
860             return RFAILED;
861          }
862          
863          for(sliceIdx=0; sliceIdx<taiSliceSuppLst->numSupportedSlices; sliceIdx++)
864          {
865             DU_ALLOC(taiSliceSuppLst->snssai[sliceIdx], sizeof(Snssai));
866             if(taiSliceSuppLst->snssai[sliceIdx] == NULLP)
867             {
868                DU_LOG("\nERROR --> DU_APP: readCfg():Memory allocation failed");
869                return RFAILED;
870             }
871 #ifdef O1_ENABLE
872             memcpy(taiSliceSuppLst->snssai[sliceIdx]->sd, cellParams.plmnList[sliceIdx].sd, \
873                   SD_SIZE*sizeof(uint8_t));
874             taiSliceSuppLst->snssai[sliceIdx]->sst = cellParams.plmnList[sliceIdx].sst;
875 #else
876             memcpy(taiSliceSuppLst->snssai[sliceIdx], &snssai[sliceIdx], sizeof(Snssai));
877 #endif
878          }
879       }
880
881       /* NR Mode info */
882 #ifdef NR_TDD
883       /* NR TDD Mode info */
884 #ifdef O1_ENABLE      
885       duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.nrArfcn = cellParams.arfcnUL;
886       duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.sulInfo.sulArfcn = cellParams.arfcnSUL;
887       duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.sulInfo.sulTxBw.nrScs = convertScsValToScsEnum(cellParams.ssbSubCarrierSpacing);                
888 #else
889       duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.nrArfcn = NR_UL_ARFCN;
890       duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.sulInfo.sulArfcn = SUL_ARFCN;
891       duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.sulInfo.sulTxBw.nrScs = NR_SCS;                 
892 #endif      
893       duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.sulInfo.sulTxBw.nrb = NRB_273;         
894
895       for(freqBandIdx=0; freqBandIdx<MAX_NRCELL_BANDS; freqBandIdx++)
896       {
897          duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.freqBand[freqBandIdx].nrFreqBand =\
898                                                                                                                      NR_FREQ_BAND;
899          for(bandIdx=0; bandIdx<MAX_NRCELL_BANDS; bandIdx++)
900          {
901             duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.freqBand[freqBandIdx].sulBand[bandIdx]\
902                = SUL_BAND;      
903          }
904       }
905 #else
906       /* NR FDD Mode info */
907 #ifdef O1_ENABLE
908       duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.nrArfcn = cellParams.arfcnUL;
909       duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.sulInfo.sulArfcn = cellParams.arfcnSUL;
910       duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.ulTxBw.nrScs = convertScsValToScsEnum(cellParams.ssbSubCarrierSpacing);
911       duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.sulInfo.sulTxBw.nrScs = convertScsValToScsEnum(cellParams.ssbSubCarrierSpacing);
912       duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.nrArfcn = cellParams.arfcnDL;
913       duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.sulInfo.sulArfcn = cellParams.arfcnSUL;
914       duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.sulInfo.sulTxBw.nrScs = convertScsValToScsEnum(cellParams.ssbSubCarrierSpacing);
915       duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.dlTxBw.nrScs = convertScsValToScsEnum(cellParams.ssbSubCarrierSpacing);
916 #else
917       duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.nrArfcn = NR_UL_ARFCN;
918       duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.sulInfo.sulArfcn = SUL_ARFCN;
919       duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.ulTxBw.nrScs = NR_SCS;
920       duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.sulInfo.sulTxBw.nrScs = NR_SCS;
921       duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.nrArfcn = NR_DL_ARFCN;
922       duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.sulInfo.sulArfcn = SUL_ARFCN;
923       duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.sulInfo.sulTxBw.nrScs = NR_SCS;
924       duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.dlTxBw.nrScs = NR_SCS;
925 #endif
926       duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.sulInfo.sulTxBw.nrb = NRB_106;
927       for(freqBandIdx=0; freqBandIdx<MAX_NRCELL_BANDS; freqBandIdx++)
928       {
929          duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.freqBand[freqBandIdx].\
930          nrFreqBand = NR_FREQ_BAND;
931          for(bandIdx=0; bandIdx<MAX_NRCELL_BANDS; bandIdx++)
932          {
933             duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.freqBand[freqBandIdx].\
934             sulBand[bandIdx] = SUL_BAND;
935          }
936       }
937       duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.sulInfo.sulTxBw.nrb = NRB_106;
938       for(freqBandIdx=0; freqBandIdx<MAX_NRCELL_BANDS; freqBandIdx++)
939       {
940          duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.freqBand[freqBandIdx].\
941          nrFreqBand = NR_FREQ_BAND;
942          for(bandIdx=0; bandIdx<MAX_NRCELL_BANDS; bandIdx++)
943          {
944             duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.freqBand[freqBandIdx].\
945             sulBand[bandIdx] = SUL_BAND;
946          }
947       }
948
949       duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.ulTxBw.nrb = NRB_106;
950       duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.dlTxBw.nrb = NRB_106;
951 #endif
952
953       /*Measurement Config and Cell Config */ 
954       duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.measTimeCfgDuration = TIME_CFG; 
955
956       duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellDir = DL_UL; 
957
958       duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellType=CELL_TYPE;
959
960       /* Broadcast PLMN Identity */
961       for(brdcstPlmnIdx=0; brdcstPlmnIdx<MAX_BPLMN_NRCELL_MINUS_1; brdcstPlmnIdx++)
962       { 
963          for(plmnIdx=0; plmnIdx<MAX_PLMN; plmnIdx++)
964          {
965             memset(&duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].plmn[plmnIdx],\
966             0, sizeof(Plmn));
967             duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].plmn[plmnIdx].mcc[0] =\
968             PLMN_MCC0;
969             duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].plmn[plmnIdx].mcc[1] =\
970             PLMN_MCC1;
971             duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].plmn[plmnIdx].mcc[2] =\
972             PLMN_MCC2;
973             duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].plmn[plmnIdx].mnc[0] =\
974             PLMN_MNC0;
975             duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].plmn[plmnIdx].mnc[1] =\
976             PLMN_MNC1;
977          }
978          /* Extended PLMN List */        
979          for(plmnIdx=0; plmnIdx<MAX_PLMN; plmnIdx++)
980          {
981             memset(&duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].\
982             extPlmn[plmnIdx], 0, sizeof(Plmn));
983             duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].\
984             extPlmn[plmnIdx].mcc[0] = PLMN_MCC0;
985             duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].\
986             extPlmn[plmnIdx].mcc[1] = PLMN_MCC1;
987             duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].\
988             extPlmn[plmnIdx].mcc[2] = PLMN_MCC2;
989             duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].\
990             extPlmn[plmnIdx].mnc[0] = PLMN_MNC0;
991             duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].\
992             extPlmn[plmnIdx].mnc[1] = PLMN_MNC1;
993          }
994 #ifdef O1_ENABLE
995          duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.epsTac = cellParams.nRTAC; //TODO : to check and fill
996          duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.tac = cellParams.nRTAC;
997          duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].tac = cellParams.nRTAC;
998          duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].nrCellId = cellParams.cellLocalId;
999 #else       
1000          duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.epsTac = DU_TAC; //TODO : to check and fill
1001          duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.tac = DU_TAC;
1002          duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].tac = DU_TAC;
1003          duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].nrCellId = NR_CELL_ID;
1004 #endif     
1005          duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].ranac = NR_RANAC;
1006       }
1007
1008       /*gnb DU System Info mib msg*/
1009       BuildMibMsg();
1010       DU_ALLOC(duCfgParam.srvdCellLst[srvdCellIdx].duSysInfo.mibMsg, encBufSize);
1011       if(!(duCfgParam.srvdCellLst[srvdCellIdx].duSysInfo.mibMsg))
1012       {
1013          DU_LOG("\nERROR  -->  DU APP : Memory allocation failure at readCfg");
1014          return RFAILED;
1015       }
1016       memcpy(duCfgParam.srvdCellLst[srvdCellIdx].duSysInfo.mibMsg, encBuf, encBufSize);
1017       duCfgParam.srvdCellLst[srvdCellIdx].duSysInfo.mibLen = encBufSize;
1018
1019       /*gnb DU System Info mib msg*/
1020       BuildSib1Msg();
1021       DU_ALLOC(duCfgParam.srvdCellLst[srvdCellIdx].duSysInfo.sib1Msg,\
1022             encBufSize);
1023       if(!(duCfgParam.srvdCellLst[srvdCellIdx].duSysInfo.sib1Msg))
1024       {
1025          DU_LOG("\nERROR  -->  DU APP : Memory allocation failure at readCfg");
1026          return RFAILED;
1027       }
1028       memcpy(duCfgParam.srvdCellLst[srvdCellIdx].duSysInfo.sib1Msg,\
1029             encBuf,encBufSize);
1030       duCfgParam.srvdCellLst[srvdCellIdx].duSysInfo.sib1Len = encBufSize;
1031
1032    }
1033
1034    if(readMacCfg() != ROK)
1035    {
1036       DU_LOG("\nERROR  -->  DU_APP : Failed while reading MAC config");
1037       return RFAILED;
1038    }
1039
1040    return ROK;
1041 }
1042
1043 /*******************************************************************
1044  *
1045  * @brief Copy Slice Cfg in temp structre in duCfgParams 
1046  *
1047  * @details
1048  *
1049  *    Function : cpyRrmPolicyInDuCfgParams
1050  *
1051  *    Functionality:
1052  *      - Copy Slice Cfg in temp structre in duCfgParams 
1053  *
1054  * @params[in] RrmPolicy rrmPolicy[], uint8_t policyNum, uint8_t memberList
1055  * @return ROK     - success
1056  *         RFAILED - failure
1057  *
1058  * ****************************************************************/
1059 uint8_t cpyRrmPolicyInDuCfgParams(RrmPolicyList rrmPolicy[], uint8_t policyNum, MacSliceCfgReq *tempSliceCfg)
1060 {
1061    uint8_t policyIdx = 0, memberListIdx = 0;
1062    if(policyNum)
1063    {
1064       tempSliceCfg->numOfRrmPolicy = policyNum;
1065       DU_ALLOC_SHRABL_BUF(tempSliceCfg->listOfRrmPolicy, tempSliceCfg->numOfRrmPolicy  * sizeof(MacSliceRrmPolicy*));
1066       if(!tempSliceCfg->listOfRrmPolicy)
1067       {
1068          DU_LOG("\nERROR  --> DU APP : Memory allocation failed in cpyRrmPolicyInDuCfgParams");
1069          return RFAILED;
1070       }
1071
1072       for(policyIdx = 0; policyIdx<tempSliceCfg->numOfRrmPolicy; policyIdx++)
1073       {
1074          DU_ALLOC_SHRABL_BUF(tempSliceCfg->listOfRrmPolicy[policyIdx], sizeof(MacSliceRrmPolicy));
1075          if(!tempSliceCfg->listOfRrmPolicy[policyIdx])
1076          {
1077             DU_LOG("\nERROR  --> DU APP : Memory allocation failed in cpyRrmPolicyInDuCfgParams");
1078             return RFAILED;
1079          }
1080
1081          tempSliceCfg->listOfRrmPolicy[policyIdx]->resourceType = rrmPolicy[policyIdx].resourceType;
1082
1083          tempSliceCfg->listOfRrmPolicy[policyIdx]->numOfRrmPolicyMem = rrmPolicy[policyIdx].rRMMemberNum;
1084
1085          if(tempSliceCfg->listOfRrmPolicy[policyIdx]->numOfRrmPolicyMem)
1086          {
1087             DU_ALLOC_SHRABL_BUF(tempSliceCfg->listOfRrmPolicy[policyIdx]->rRMPolicyMemberList,\
1088             tempSliceCfg->listOfRrmPolicy[policyIdx]->numOfRrmPolicyMem * sizeof(RrmPolicyMemberList*));
1089
1090             if(!tempSliceCfg->listOfRrmPolicy[policyIdx]->rRMPolicyMemberList)
1091             {
1092                DU_LOG("\nERROR  --> DU APP : Memory allocation failed in cpyRrmPolicyInDuCfgParams");
1093                return RFAILED;
1094             }
1095
1096
1097             for(memberListIdx = 0; memberListIdx<tempSliceCfg->listOfRrmPolicy[policyIdx]->numOfRrmPolicyMem; memberListIdx++)
1098             {
1099                DU_ALLOC_SHRABL_BUF(tempSliceCfg->listOfRrmPolicy[policyIdx]->rRMPolicyMemberList[memberListIdx], sizeof(RrmPolicyMemberList));
1100                if(!tempSliceCfg->listOfRrmPolicy[policyIdx]->rRMPolicyMemberList[memberListIdx])
1101                {
1102                   DU_LOG("\nERROR  --> DU APP : Memory allocation failed in cpyRrmPolicyInDuCfgParams");
1103                   return RFAILED;
1104                }
1105                memcpy(&tempSliceCfg->listOfRrmPolicy[policyIdx]->rRMPolicyMemberList[memberListIdx]->snssai.sd,\
1106                &rrmPolicy[policyIdx].rRMPolicyMemberList[memberListIdx].sd, 3 * sizeof(uint8_t));
1107                memcpy(&tempSliceCfg->listOfRrmPolicy[policyIdx]->rRMPolicyMemberList[memberListIdx]->snssai.sst,\
1108                &rrmPolicy[policyIdx].rRMPolicyMemberList[memberListIdx].sst, sizeof(uint8_t));
1109                memcpy(&tempSliceCfg->listOfRrmPolicy[policyIdx]->rRMPolicyMemberList[memberListIdx]->plmn.mcc,\
1110                &rrmPolicy[policyIdx].rRMPolicyMemberList[memberListIdx].mcc, 3 * sizeof(uint8_t));
1111                memcpy(&tempSliceCfg->listOfRrmPolicy[policyIdx]->rRMPolicyMemberList[memberListIdx]->plmn.mnc,\
1112                &rrmPolicy[policyIdx].rRMPolicyMemberList[memberListIdx].mnc, 3 * sizeof(uint8_t));
1113             }
1114             tempSliceCfg->listOfRrmPolicy[policyIdx]->policyRatio.maxRatio = rrmPolicy[policyIdx].rRMPolicyMaxRatio;
1115             tempSliceCfg->listOfRrmPolicy[policyIdx]->policyRatio.minRatio = rrmPolicy[policyIdx].rRMPolicyMinRatio;
1116             tempSliceCfg->listOfRrmPolicy[policyIdx]->policyRatio.dedicatedRatio = rrmPolicy[policyIdx].rRMPolicyDedicatedRatio;
1117          }
1118       }
1119    }
1120
1121    return ROK;
1122 }
1123
1124 /*******************************************************************
1125  *
1126  * @brief Reads config and posts message to du_app on completion
1127  *
1128  * @details
1129  *
1130  *    Function : main
1131  *
1132  *    Functionality:
1133  *      - Calls readCfg()
1134  *      - Post to du_app for further processing
1135  *
1136  * @params[in] void
1137  * @return ROK     - success
1138  *         RFAILED - failure
1139  *
1140  * ****************************************************************/
1141 uint8_t duReadCfg()
1142 {
1143    Pst pst;
1144    Buffer *mBuf;
1145
1146    memset(&duCfgParam, 0, sizeof(DuCfgParams));
1147
1148    //Read configs into duCfgParams
1149    if(readCfg() != ROK)
1150    {
1151       DU_LOG("\nERROR  -->  DU_APP : Reading configuration failed");
1152       return RFAILED;
1153    }
1154
1155    //Fill pst structure
1156    memset(&(pst), 0, sizeof(Pst));
1157    pst.srcEnt = (Ent)ENTDUAPP;
1158    pst.srcInst = (Inst)DU_INST;
1159    pst.srcProcId = DU_PROC;
1160    pst.dstEnt = pst.srcEnt;
1161    pst.dstInst = pst.srcInst;
1162    pst.dstProcId = pst.srcProcId;
1163    pst.event = EVTCFG;
1164    pst.selector = ODU_SELECTOR_TC;
1165    pst.pool= DU_POOL;
1166
1167    /* Initialize the timer blocks */
1168    cmInitTimers(&(duCb.e2apDb.e2TimersInfo.e2Timers.e2SetupTimer), 1);
1169    cmInitTimers(&(duCb.e2apDb.e2TimersInfo.e2Timers.ricServiceUpdateTimer.timer), 1);
1170
1171    /* Initialzie the timer queue */   
1172    memset(&(duCb.duTimersInfo.tmrTq), 0, sizeof(CmTqType) * DU_TQ_SIZE);
1173    
1174    /* Initialize the timer control point */
1175    memset(&(duCb.duTimersInfo.tmrTqCp), 0, sizeof(CmTqCp));
1176    duCb.duTimersInfo.tmrTqCp.tmrLen = DU_TQ_SIZE;
1177    
1178    /* Initialize the timer resolution */
1179    duCb.duTimersInfo.tmrRes = DU_TIMER_RESOLUTION;
1180    
1181    /* Timer Registration request to system services */
1182    if (ODU_REG_TMR_MT(pst.srcEnt, pst.srcInst, duCb.duTimersInfo.tmrRes, duActvTmr) != ROK)
1183    {
1184       DU_LOG("\nERROR  -->  DU_APP : Failed to register timer");
1185       return RFAILED;
1186    }   
1187               
1188    if(ODU_GET_MSG_BUF(DFLT_REGION, DU_POOL, &mBuf) != ROK)
1189    {
1190       DU_LOG("\nERROR  -->  DU_APP : Memory allocation failed in duReadCfg");
1191       return RFAILED;
1192    }
1193
1194    if (ODU_POST_TASK(&pst, mBuf) != ROK)
1195    {
1196       DU_LOG("\nERROR  -->  DU_APP : ODU_POST_TASK failed in duReadCfg");
1197       return RFAILED;
1198    }
1199
1200    return ROK;
1201 }
1202
1203 /**********************************************************************
1204   End of file
1205  **********************************************************************/
1206