[Epic-ID: ODUHIGH-510][Task-ID: ODUHIGH-512] Implementation of E2 setup failure
[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    = convertArfcnToFreqKhz(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.numerology = NR_NUMEROLOGY;
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.initialDlBwp.bwp.firstPrb = 0;
252    duCfgParam.macCellCfg.initialDlBwp.bwp.numPrb = TOTAL_PRB_20MHZ_MU0; /* configured to total BW */
253    duCfgParam.macCellCfg.initialDlBwp.bwp.scs = duCfgParam.macCellCfg.ssbCfg.scsCmn;
254    duCfgParam.macCellCfg.initialDlBwp.bwp.cyclicPrefix = NORMAL_CYCLIC_PREFIX;
255    duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.searchSpaceId = SEARCHSPACE_1_INDEX;
256    duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.coresetId = CORESET_0_INDEX;
257    duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.monitoringSlot =
258       SS_MONITORING_SLOT_SL1; /* sl1 - all slots */
259    duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.duration = 0;
260    duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.monitoringSymbol =
261       SS_MONITORING_SYMBOL;
262    duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.
263       candidate.aggLevel1       = 8;
264    duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.
265       candidate.aggLevel2       = 4;
266    duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.
267       candidate.aggLevel4       = 2;
268    duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.
269       candidate.aggLevel8       = 1;
270    duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.
271       candidate.aggLevel16      = 0;
272
273    duCfgParam.macCellCfg.initialDlBwp.pdschCommon.numTimeDomAlloc = NUM_TIME_DOM_RSRC_ALLOC;
274    idx = 0;
275    duCfgParam.macCellCfg.initialDlBwp.pdschCommon.timeDomRsrcAllocList[idx].k0 = PDSCH_K0_CFG1;
276    duCfgParam.macCellCfg.initialDlBwp.pdschCommon.timeDomRsrcAllocList[idx].mappingType = 
277       PDSCH_MAPPING_TYPE_A;
278    duCfgParam.macCellCfg.initialDlBwp.pdschCommon.timeDomRsrcAllocList[idx].startSymbol = 
279       PDSCH_START_SYMBOL;
280    duCfgParam.macCellCfg.initialDlBwp.pdschCommon.timeDomRsrcAllocList[idx].lengthSymbol =
281       PDSCH_LENGTH_SYMBOL;
282
283    idx++;
284    duCfgParam.macCellCfg.initialDlBwp.pdschCommon.timeDomRsrcAllocList[idx].k0 = PDSCH_K0_CFG2;
285    duCfgParam.macCellCfg.initialDlBwp.pdschCommon.timeDomRsrcAllocList[idx].mappingType = 
286       PDSCH_MAPPING_TYPE_A;
287    duCfgParam.macCellCfg.initialDlBwp.pdschCommon.timeDomRsrcAllocList[idx].startSymbol = 
288       PDSCH_START_SYMBOL;
289    duCfgParam.macCellCfg.initialDlBwp.pdschCommon.timeDomRsrcAllocList[idx].lengthSymbol =
290       PDSCH_LENGTH_SYMBOL;
291
292    /* ra-searchSpace ID is set to 1 */
293    duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.raSearchSpaceId = SEARCHSPACE_1_INDEX;
294
295    /* fill Intial UL BWP */
296    duCfgParam.macCellCfg.initialUlBwp.bwp.firstPrb = 0;
297    duCfgParam.macCellCfg.initialUlBwp.bwp.numPrb = TOTAL_PRB_20MHZ_MU0; /* configured to total BW */
298    duCfgParam.macCellCfg.initialUlBwp.bwp.scs = duCfgParam.macCellCfg.ssbCfg.scsCmn;
299    duCfgParam.macCellCfg.initialUlBwp.bwp.cyclicPrefix = NORMAL_CYCLIC_PREFIX;
300    duCfgParam.macCellCfg.initialUlBwp.puschCommon.numTimeDomRsrcAlloc = 2;
301    duCfgParam.macCellCfg.initialUlBwp.puschCommon.timeDomRsrcAllocList[0].k2 = PUSCH_K2_CFG1;
302    duCfgParam.macCellCfg.initialUlBwp.puschCommon.timeDomRsrcAllocList[0].mappingType = 
303       PUSCH_MAPPING_TYPE_A;
304    duCfgParam.macCellCfg.initialUlBwp.puschCommon.timeDomRsrcAllocList[0].startSymbol = 
305       PUSCH_START_SYMBOL;
306    duCfgParam.macCellCfg.initialUlBwp.puschCommon.timeDomRsrcAllocList[0].symbolLength =
307       PUSCH_LENGTH_SYMBOL;
308
309    duCfgParam.macCellCfg.initialUlBwp.puschCommon.timeDomRsrcAllocList[1].k2 = PUSCH_K2_CFG2;
310    duCfgParam.macCellCfg.initialUlBwp.puschCommon.timeDomRsrcAllocList[1].mappingType = 
311       PUSCH_MAPPING_TYPE_A;
312    duCfgParam.macCellCfg.initialUlBwp.puschCommon.timeDomRsrcAllocList[1].startSymbol = 
313       PUSCH_START_SYMBOL;
314    duCfgParam.macCellCfg.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.initialUlBwp.pucchCommon.pucchResourceCommon = PUCCH_RSRC_COMMON;
321    duCfgParam.macCellCfg.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    uint8_t srvdCellIdx, bandIdx, sliceIdx, plmnIdx;
599    uint8_t brdcstPlmnIdx, freqBandIdx, srvdPlmnIdx;
600    uint32_t ipv4_du, ipv4_cu, ipv4_ric;
601    MibParams mib;
602    Sib1Params sib1;
603    F1TaiSliceSuppLst *taiSliceSuppLst;
604
605    duCb.e2apDb.e2TransInfo.transIdCounter = 0;
606    memset(duCb.e2apDb.e2TransInfo.onGoingTransaction, 0, MAX_NUM_TRANSACTION * sizeof(E2TransInfo));
607
608 #ifndef O1_ENABLE
609    /* Note: Added these below variable for local testing*/
610    Snssai snssai[NUM_OF_SUPPORTED_SLICE] = {{1,{2,3,4}},{5,{6,7,8}}};
611 #endif
612
613 #ifdef O1_ENABLE
614    if( getStartupConfig(&g_cfg) != ROK )
615    {
616       RETVALUE(RFAILED);
617    }
618    cmInetAddr((S8*)g_cfg.DU_IPV4_Addr, &ipv4_du);
619    cmInetAddr((S8*)g_cfg.CU_IPV4_Addr, &ipv4_cu);
620    cmInetAddr((S8*)g_cfg.RIC_IPV4_Addr, &ipv4_ric);
621
622    duCfgParam.sctpParams.cuPort = g_cfg.CU_Port;
623    duCfgParam.sctpParams.ricPort = g_cfg.RIC_Port;
624 #else   
625    cmInetAddr((S8*)DU_IP_V4_ADDR, &ipv4_du);
626    cmInetAddr((S8*)CU_IP_V4_ADDR, &ipv4_cu);
627    cmInetAddr((S8*)RIC_IP_V4_ADDR, &ipv4_ric);
628
629    duCfgParam.sctpParams.cuPort = F1_SCTP_PORT;
630    duCfgParam.sctpParams.ricPort = E2_SCTP_PORT;
631 #endif
632
633    fillDuPort(duCfgParam.sctpParams.duPort);
634
635    /* F1 DU IP Address and Port*/
636    duCfgParam.sctpParams.duIpAddr.ipV4Addr = ipv4_du;
637
638    /* F1 CU IP Address and Port*/
639    duCfgParam.sctpParams.cuIpAddr.ipV4Addr = ipv4_cu;
640
641    /* Fill RIC Params */
642    duCfgParam.sctpParams.ricIpAddr.ipV4Addr = ipv4_ric;
643
644    /* EGTP Parameters */
645    duCfgParam.egtpParams.localIp.ipV4Pres = TRUE;
646    duCfgParam.egtpParams.localIp.ipV4Addr = ipv4_du;
647    duCfgParam.egtpParams.localPort = F1_EGTP_PORT;
648    duCfgParam.egtpParams.destIp.ipV4Pres = TRUE;
649    duCfgParam.egtpParams.destIp.ipV4Addr = ipv4_cu;
650    duCfgParam.egtpParams.destPort = F1_EGTP_PORT;
651    duCfgParam.egtpParams.minTunnelId = MIN_TEID;
652    duCfgParam.egtpParams.maxTunnelId = MAX_TEID;
653
654    duCfgParam.maxUe = 32; //TODO: Check
655
656    /* DU Info */
657    duCfgParam.duId = DU_ID;
658    DU_ALLOC(duCfgParam.duName, sizeof(DU_NAME));
659    if(!duCfgParam.duName)
660    {
661       DU_LOG("\nDEBUG --> DU_APP: readCfg(): Memory allocation failure for DU name");   
662       return RFAILED;
663    }
664    strcpy((char*)duCfgParam.duName,DU_NAME);
665
666    /* Mib Params */
667    mib.sysFrmNum = SYS_FRAME_NUM;
668 #ifdef NR_TDD
669    mib.subCarrierSpacingCommon = MIB__subCarrierSpacingCommon_scs30or120;
670 #else
671    mib.subCarrierSpacingCommon = MIB__subCarrierSpacingCommon_scs15or60;
672 #endif
673    mib.ssb_SubcarrierOffset = SSB_SC_OFFSET; //Kssb
674    mib.dmrs_TypeA_Position = MIB__dmrs_TypeA_Position_pos2;
675    mib.controlResourceSetZero = CORESET_0_INDEX;
676    mib.searchSpaceZero = SEARCHSPACE_0_INDEX;
677    mib.cellBarred = MIB__cellBarred_notBarred;
678    mib.intraFreqReselection = MIB__intraFreqReselection_notAllowed;
679    duCfgParam.mibParams = mib;
680
681    /* SIB1 Params */
682    memset(&sib1.plmn, 0, sizeof(Plmn));
683    sib1.plmn.mcc[0] = PLMN_MCC0;
684    sib1.plmn.mcc[1] = PLMN_MCC1;
685    sib1.plmn.mcc[2] = PLMN_MCC2;
686    sib1.plmn.mnc[0] = PLMN_MNC0;
687    sib1.plmn.mnc[1] = PLMN_MNC1;
688    sib1.ranac = DU_RANAC;
689
690 #ifdef O1_ENABLE
691    sib1.tac =  cellParams.nRTAC;
692    sib1.cellIdentity =  CELL_IDENTITY *  cellParams.cellLocalId;
693    DU_LOG("\nDEBUG --> DU_APP: readCfg(): OAM CellLocalId=%d", \
694               sib1.cellIdentity);
695 #else
696    sib1.tac = DU_TAC;
697    sib1.cellIdentity = CELL_IDENTITY * NR_CELL_ID;
698 #endif
699    sib1.cellResvdForOpUse = PLMN_IdentityInfo__cellReservedForOperatorUse_notReserved;
700    sib1.connEstFailCnt = ConnEstFailureControl__connEstFailCount_n3;
701    sib1.connEstFailOffValidity = ConnEstFailureControl__connEstFailOffsetValidity_s900;
702    sib1.connEstFailOffset = 15;
703    sib1.siSchedInfo.winLen = SI_SchedulingInfo__si_WindowLength_s5;
704    sib1.siSchedInfo.broadcastSta = SchedulingInfo__si_BroadcastStatus_broadcasting;
705    sib1.siSchedInfo.preiodicity = SchedulingInfo__si_Periodicity_rf8;
706    sib1.siSchedInfo.sibType = SIB_TypeInfo__type_sibType2;
707    sib1.siSchedInfo.sibValTag = SIB1_VALUE_TAG;
708
709    fillServCellCfgCommSib(&sib1.srvCellCfgCommSib);
710
711    duCfgParam.sib1Params = sib1;
712
713    for(srvdCellIdx=0; srvdCellIdx<DEFAULT_CELLS; srvdCellIdx++)
714    { 
715       memset(&duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.nrCgi.plmn, 0, sizeof(Plmn));
716       duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.nrCgi.plmn.mcc[0] = PLMN_MCC0;
717       duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.nrCgi.plmn.mcc[1] = PLMN_MCC1;
718       duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.nrCgi.plmn.mcc[2] = PLMN_MCC2;
719       duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.nrCgi.plmn.mnc[0] = PLMN_MNC0;
720       duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.nrCgi.plmn.mnc[1] = PLMN_MNC1;
721
722       /*Cell ID */
723  #ifdef O1_ENABLE
724       duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.nrPci = cellParams.nRPCI;
725  #else
726       duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.nrPci = NR_PCI;
727 #endif
728       /* List of Available PLMN */
729       for(srvdPlmnIdx=0; srvdPlmnIdx<MAX_PLMN; srvdPlmnIdx++)
730       {
731          /* As per spec 38.473, Plmn identity consists of 3 digit from mcc
732           * followed by either 2 digit or 3 digits of mnc */ 
733
734          memset(&duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].plmn, 0,\
735          sizeof(Plmn));
736  #ifdef O1_ENABLE
737          duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].plmn.mcc[0] = cellParams.plmnList[srvdPlmnIdx].mcc[0];
738          duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].plmn.mcc[1] = cellParams.plmnList[srvdPlmnIdx].mcc[1];
739          duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].plmn.mcc[2] = cellParams.plmnList[srvdPlmnIdx].mcc[2];
740          duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].plmn.mnc[0] = cellParams.plmnList[srvdPlmnIdx].mnc[0];
741          duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].plmn.mnc[1] = cellParams.plmnList[srvdPlmnIdx].mnc[1];
742          duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].plmn.mnc[2] = cellParams.plmnList[srvdPlmnIdx].mnc[2];
743  #else
744          duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].plmn.mcc[0] = PLMN_MCC0;
745          duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].plmn.mcc[1] = PLMN_MCC1;
746          duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].plmn.mcc[2] = PLMN_MCC2;
747          duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].plmn.mnc[0] = PLMN_MNC0;
748          duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].plmn.mnc[1] = PLMN_MNC1;
749 #endif
750       }
751       /* List of Extended PLMN */
752       for(srvdPlmnIdx=0; srvdPlmnIdx<MAX_PLMN; srvdPlmnIdx++)
753       {
754          /* As per spec 38.473, Plmn identity consists of 3 digit from mcc
755           * followed by either 2 digit or 3 digits of mnc */ 
756
757          memset(&duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].extPlmn, 0, sizeof(Plmn));
758          duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].extPlmn.mcc[0] = PLMN_MCC0;
759          duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].extPlmn.mcc[1] = PLMN_MCC1;
760          duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].extPlmn.mcc[2] = PLMN_MCC2;
761          duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].extPlmn.mnc[0] = PLMN_MNC0;
762          duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].extPlmn.mnc[1] = PLMN_MNC1;
763       } 
764       /* List of Supporting Slices */
765       for(srvdPlmnIdx=0; srvdPlmnIdx<MAX_PLMN; srvdPlmnIdx++)
766       {
767          taiSliceSuppLst = &duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].\
768          taiSliceSuppLst;
769          
770          /* TODO Calculte the exact number of supported slices once will get
771           * cell configuration from O1 */
772          taiSliceSuppLst->numSupportedSlices = NUM_OF_SUPPORTED_SLICE;
773          if(taiSliceSuppLst->numSupportedSlices > MAX_NUM_OF_SLICE_ITEMS)
774          {
775             DU_LOG("\nERROR --> DU_APP: readCfg(): Number of supported slice [%d] is more than 1024",\
776             taiSliceSuppLst->numSupportedSlices);
777             return RFAILED;
778          }
779
780          DU_ALLOC(taiSliceSuppLst->snssai, taiSliceSuppLst->numSupportedSlices*sizeof(Snssai*));
781          if(taiSliceSuppLst->snssai == NULLP)
782          {
783             DU_LOG("\nERROR --> DU_APP: readCfg():Memory allocation failed");
784             return RFAILED;
785          }
786          
787          for(sliceIdx=0; sliceIdx<taiSliceSuppLst->numSupportedSlices; sliceIdx++)
788          {
789             DU_ALLOC(taiSliceSuppLst->snssai[sliceIdx], sizeof(Snssai));
790             if(taiSliceSuppLst->snssai[sliceIdx] == NULLP)
791             {
792                DU_LOG("\nERROR --> DU_APP: readCfg():Memory allocation failed");
793                return RFAILED;
794             }
795 #ifdef O1_ENABLE
796             memcpy(taiSliceSuppLst->snssai[sliceIdx]->sd, cellParams.plmnList[sliceIdx].sd, \
797                   SD_SIZE*sizeof(uint8_t));
798             taiSliceSuppLst->snssai[sliceIdx]->sst = cellParams.plmnList[sliceIdx].sst;
799 #else
800             memcpy(taiSliceSuppLst->snssai[sliceIdx], &snssai[sliceIdx], sizeof(Snssai));
801 #endif
802          }
803       }
804
805       /* NR Mode info */
806 #ifdef NR_TDD
807       /* NR TDD Mode info */
808 #ifdef O1_ENABLE      
809       duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.nrArfcn = cellParams.arfcnUL;
810       duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.sulInfo.sulArfcn = cellParams.arfcnSUL;
811       duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.sulInfo.sulTxBw.nrScs = cellParams.ssbSubCarrierSpacing;                
812 #else
813       duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.nrArfcn = NR_UL_ARFCN;
814       duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.sulInfo.sulArfcn = SUL_ARFCN;
815       duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.sulInfo.sulTxBw.nrScs = NR_SCS;                 
816 #endif      
817       duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.sulInfo.sulTxBw.nrb = NRB_273;         
818
819       for(freqBandIdx=0; freqBandIdx<MAX_NRCELL_BANDS; freqBandIdx++)
820       {
821          duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.freqBand[freqBandIdx].nrFreqBand =\
822                                                                                                                      NR_FREQ_BAND;
823          for(bandIdx=0; bandIdx<MAX_NRCELL_BANDS; bandIdx++)
824          {
825             duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.freqBand[freqBandIdx].sulBand[bandIdx]\
826                = SUL_BAND;      
827          }
828       }
829 #else
830       /* NR FDD Mode info */
831 #ifdef O1_ENABLE
832       duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.nrArfcn = cellParams.arfcnUL;
833       duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.sulInfo.sulArfcn = cellParams.arfcnSUL;
834       duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.ulTxBw.nrScs = cellParams.ssbSubCarrierSpacing;
835       duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.sulInfo.sulTxBw.nrScs = cellParams.ssbSubCarrierSpacing;
836       duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.nrArfcn = cellParams.arfcnDL;
837       duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.sulInfo.sulArfcn = cellParams.arfcnSUL;
838       duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.sulInfo.sulTxBw.nrScs = cellParams.ssbSubCarrierSpacing;
839       duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.dlTxBw.nrScs = cellParams.ssbSubCarrierSpacing;
840 #else
841       duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.nrArfcn = NR_UL_ARFCN;
842       duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.sulInfo.sulArfcn = SUL_ARFCN;
843       duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.ulTxBw.nrScs = NR_SCS;
844       duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.sulInfo.sulTxBw.nrScs = NR_SCS;
845       duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.nrArfcn = NR_DL_ARFCN;
846       duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.sulInfo.sulArfcn = SUL_ARFCN;
847       duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.sulInfo.sulTxBw.nrScs = NR_SCS;
848       duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.dlTxBw.nrScs = NR_SCS;
849 #endif
850       duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.sulInfo.sulTxBw.nrb = NRB_106;
851       for(freqBandIdx=0; freqBandIdx<MAX_NRCELL_BANDS; freqBandIdx++)
852       {
853          duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.freqBand[freqBandIdx].\
854          nrFreqBand = NR_FREQ_BAND;
855          for(bandIdx=0; bandIdx<MAX_NRCELL_BANDS; bandIdx++)
856          {
857             duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.freqBand[freqBandIdx].\
858             sulBand[bandIdx] = SUL_BAND;
859          }
860       }
861       duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.sulInfo.sulTxBw.nrb = NRB_106;
862       for(freqBandIdx=0; freqBandIdx<MAX_NRCELL_BANDS; freqBandIdx++)
863       {
864          duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.freqBand[freqBandIdx].\
865          nrFreqBand = NR_FREQ_BAND;
866          for(bandIdx=0; bandIdx<MAX_NRCELL_BANDS; bandIdx++)
867          {
868             duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.freqBand[freqBandIdx].\
869             sulBand[bandIdx] = SUL_BAND;
870          }
871       }
872
873       duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.ulTxBw.nrb = NRB_106;
874       duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.dlTxBw.nrb = NRB_106;
875 #endif
876
877       /*Measurement Config and Cell Config */ 
878       duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.measTimeCfgDuration = TIME_CFG; 
879
880       duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellDir = DL_UL; 
881
882       duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellType=CELL_TYPE;
883
884       /* Broadcast PLMN Identity */
885       for(brdcstPlmnIdx=0; brdcstPlmnIdx<MAX_BPLMN_NRCELL_MINUS_1; brdcstPlmnIdx++)
886       { 
887          for(plmnIdx=0; plmnIdx<MAX_PLMN; plmnIdx++)
888          {
889             memset(&duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].plmn[plmnIdx],\
890             0, sizeof(Plmn));
891             duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].plmn[plmnIdx].mcc[0] =\
892             PLMN_MCC0;
893             duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].plmn[plmnIdx].mcc[1] =\
894             PLMN_MCC1;
895             duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].plmn[plmnIdx].mcc[2] =\
896             PLMN_MCC2;
897             duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].plmn[plmnIdx].mnc[0] =\
898             PLMN_MNC0;
899             duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].plmn[plmnIdx].mnc[1] =\
900             PLMN_MNC1;
901          }
902          /* Extended PLMN List */        
903          for(plmnIdx=0; plmnIdx<MAX_PLMN; plmnIdx++)
904          {
905             memset(&duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].\
906             extPlmn[plmnIdx], 0, sizeof(Plmn));
907             duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].\
908             extPlmn[plmnIdx].mcc[0] = PLMN_MCC0;
909             duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].\
910             extPlmn[plmnIdx].mcc[1] = PLMN_MCC1;
911             duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].\
912             extPlmn[plmnIdx].mcc[2] = PLMN_MCC2;
913             duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].\
914             extPlmn[plmnIdx].mnc[0] = PLMN_MNC0;
915             duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].\
916             extPlmn[plmnIdx].mnc[1] = PLMN_MNC1;
917          }
918 #ifdef O1_ENABLE
919          duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.epsTac = cellParams.nRTAC; //TODO : to check and fill
920          duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.tac = cellParams.nRTAC;
921          duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].tac = cellParams.nRTAC;
922          duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].nrCellId = cellParams.cellLocalId;
923 #else       
924          duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.epsTac = DU_TAC; //TODO : to check and fill
925          duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.tac = DU_TAC;
926          duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].tac = DU_TAC;
927          duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].nrCellId = NR_CELL_ID;
928 #endif     
929          duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].ranac = NR_RANAC;
930       }
931
932       /*gnb DU System Info mib msg*/
933       BuildMibMsg();
934       DU_ALLOC(duCfgParam.srvdCellLst[srvdCellIdx].duSysInfo.mibMsg, encBufSize);
935       if(!(duCfgParam.srvdCellLst[srvdCellIdx].duSysInfo.mibMsg))
936       {
937          DU_LOG("\nERROR  -->  DU APP : Memory allocation failure at readCfg");
938          return RFAILED;
939       }
940       memcpy(duCfgParam.srvdCellLst[srvdCellIdx].duSysInfo.mibMsg, encBuf, encBufSize);
941       duCfgParam.srvdCellLst[srvdCellIdx].duSysInfo.mibLen = encBufSize;
942
943       /*gnb DU System Info mib msg*/
944       BuildSib1Msg();
945       DU_ALLOC(duCfgParam.srvdCellLst[srvdCellIdx].duSysInfo.sib1Msg,\
946             encBufSize);
947       if(!(duCfgParam.srvdCellLst[srvdCellIdx].duSysInfo.sib1Msg))
948       {
949          DU_LOG("\nERROR  -->  DU APP : Memory allocation failure at readCfg");
950          return RFAILED;
951       }
952       memcpy(duCfgParam.srvdCellLst[srvdCellIdx].duSysInfo.sib1Msg,\
953             encBuf,encBufSize);
954       duCfgParam.srvdCellLst[srvdCellIdx].duSysInfo.sib1Len = encBufSize;
955
956    }
957
958    if(readMacCfg() != ROK)
959    {
960       DU_LOG("\nERROR  -->  DU_APP : Failed while reading MAC config");
961       return RFAILED;
962    }
963
964    return ROK;
965 }
966
967 /*******************************************************************
968  *
969  * @brief Copy Slice Cfg in temp structre in duCfgParams 
970  *
971  * @details
972  *
973  *    Function : cpyRrmPolicyInDuCfgParams
974  *
975  *    Functionality:
976  *      - Copy Slice Cfg in temp structre in duCfgParams 
977  *
978  * @params[in] RrmPolicy rrmPolicy[], uint8_t policyNum, uint8_t memberList
979  * @return ROK     - success
980  *         RFAILED - failure
981  *
982  * ****************************************************************/
983 uint8_t cpyRrmPolicyInDuCfgParams(RrmPolicyList rrmPolicy[], uint8_t policyNum, MacSliceCfgReq *tempSliceCfg)
984 {
985    uint8_t policyIdx = 0, memberListIdx = 0;
986    if(policyNum)
987    {
988       tempSliceCfg->numOfRrmPolicy = policyNum;
989       DU_ALLOC_SHRABL_BUF(tempSliceCfg->listOfRrmPolicy, tempSliceCfg->numOfRrmPolicy  * sizeof(MacSliceRrmPolicy*));
990       if(!tempSliceCfg->listOfRrmPolicy)
991       {
992          DU_LOG("\nERROR  --> DU APP : Memory allocation failed in cpyRrmPolicyInDuCfgParams");
993          return RFAILED;
994       }
995
996       for(policyIdx = 0; policyIdx<tempSliceCfg->numOfRrmPolicy; policyIdx++)
997       {
998          DU_ALLOC_SHRABL_BUF(tempSliceCfg->listOfRrmPolicy[policyIdx], sizeof(MacSliceRrmPolicy));
999          if(!tempSliceCfg->listOfRrmPolicy[policyIdx])
1000          {
1001             DU_LOG("\nERROR  --> DU APP : Memory allocation failed in cpyRrmPolicyInDuCfgParams");
1002             return RFAILED;
1003          }
1004
1005          tempSliceCfg->listOfRrmPolicy[policyIdx]->resourceType = rrmPolicy[policyIdx].resourceType;
1006
1007          tempSliceCfg->listOfRrmPolicy[policyIdx]->numOfRrmPolicyMem = rrmPolicy[policyIdx].rRMMemberNum;
1008
1009          if(tempSliceCfg->listOfRrmPolicy[policyIdx]->numOfRrmPolicyMem)
1010          {
1011             DU_ALLOC_SHRABL_BUF(tempSliceCfg->listOfRrmPolicy[policyIdx]->rRMPolicyMemberList,\
1012             tempSliceCfg->listOfRrmPolicy[policyIdx]->numOfRrmPolicyMem * sizeof(RrmPolicyMemberList*));
1013
1014             if(!tempSliceCfg->listOfRrmPolicy[policyIdx]->rRMPolicyMemberList)
1015             {
1016                DU_LOG("\nERROR  --> DU APP : Memory allocation failed in cpyRrmPolicyInDuCfgParams");
1017                return RFAILED;
1018             }
1019
1020
1021             for(memberListIdx = 0; memberListIdx<tempSliceCfg->listOfRrmPolicy[policyIdx]->numOfRrmPolicyMem; memberListIdx++)
1022             {
1023                DU_ALLOC_SHRABL_BUF(tempSliceCfg->listOfRrmPolicy[policyIdx]->rRMPolicyMemberList[memberListIdx], sizeof(RrmPolicyMemberList));
1024                if(!tempSliceCfg->listOfRrmPolicy[policyIdx]->rRMPolicyMemberList[memberListIdx])
1025                {
1026                   DU_LOG("\nERROR  --> DU APP : Memory allocation failed in cpyRrmPolicyInDuCfgParams");
1027                   return RFAILED;
1028                }
1029                memcpy(&tempSliceCfg->listOfRrmPolicy[policyIdx]->rRMPolicyMemberList[memberListIdx]->snssai.sd,\
1030                &rrmPolicy[policyIdx].rRMPolicyMemberList[memberListIdx].sd, 3 * sizeof(uint8_t));
1031                memcpy(&tempSliceCfg->listOfRrmPolicy[policyIdx]->rRMPolicyMemberList[memberListIdx]->snssai.sst,\
1032                &rrmPolicy[policyIdx].rRMPolicyMemberList[memberListIdx].sst, sizeof(uint8_t));
1033                memcpy(&tempSliceCfg->listOfRrmPolicy[policyIdx]->rRMPolicyMemberList[memberListIdx]->plmn.mcc,\
1034                &rrmPolicy[policyIdx].rRMPolicyMemberList[memberListIdx].mcc, 3 * sizeof(uint8_t));
1035                memcpy(&tempSliceCfg->listOfRrmPolicy[policyIdx]->rRMPolicyMemberList[memberListIdx]->plmn.mnc,\
1036                &rrmPolicy[policyIdx].rRMPolicyMemberList[memberListIdx].mnc, 3 * sizeof(uint8_t));
1037             }
1038             tempSliceCfg->listOfRrmPolicy[policyIdx]->policyRatio.maxRatio = rrmPolicy[policyIdx].rRMPolicyMaxRatio;
1039             tempSliceCfg->listOfRrmPolicy[policyIdx]->policyRatio.minRatio = rrmPolicy[policyIdx].rRMPolicyMinRatio;
1040             tempSliceCfg->listOfRrmPolicy[policyIdx]->policyRatio.dedicatedRatio = rrmPolicy[policyIdx].rRMPolicyDedicatedRatio;
1041          }
1042       }
1043    }
1044
1045    return ROK;
1046 }
1047
1048 /*******************************************************************
1049  *
1050  * @brief Reads config and posts message to du_app on completion
1051  *
1052  * @details
1053  *
1054  *    Function : main
1055  *
1056  *    Functionality:
1057  *      - Calls readCfg()
1058  *      - Post to du_app for further processing
1059  *
1060  * @params[in] void
1061  * @return ROK     - success
1062  *         RFAILED - failure
1063  *
1064  * ****************************************************************/
1065 uint8_t duReadCfg()
1066 {
1067    Pst pst;
1068    Buffer *mBuf;
1069
1070    memset(&duCfgParam, 0, sizeof(DuCfgParams));
1071
1072    //Read configs into duCfgParams
1073    if(readCfg() != ROK)
1074    {
1075       DU_LOG("\nERROR  -->  DU_APP : Reading configuration failed");
1076       return RFAILED;
1077    }
1078
1079    //Fill pst structure
1080    memset(&(pst), 0, sizeof(Pst));
1081    pst.srcEnt = (Ent)ENTDUAPP;
1082    pst.srcInst = (Inst)DU_INST;
1083    pst.srcProcId = DU_PROC;
1084    pst.dstEnt = pst.srcEnt;
1085    pst.dstInst = pst.srcInst;
1086    pst.dstProcId = pst.srcProcId;
1087    pst.event = EVTCFG;
1088    pst.selector = ODU_SELECTOR_TC;
1089    pst.pool= DU_POOL;
1090
1091    /* Initialize the timer blocks */
1092    cmInitTimers(&(duCb.e2apDb.e2Timers.e2SetupTimer), 1);
1093
1094    /* Initialzie the timer queue */   
1095    memset(&(duCb.duTimersInfo.tmrTq), 0, sizeof(CmTqType) * DU_TQ_SIZE);
1096    
1097    /* Initialize the timer control point */
1098    memset(&(duCb.duTimersInfo.tmrTqCp), 0, sizeof(CmTqCp));
1099    duCb.duTimersInfo.tmrTqCp.tmrLen = DU_TQ_SIZE;
1100    
1101    /* Initialize the timer resolution */
1102    duCb.duTimersInfo.tmrRes = DU_TIMER_RESOLUTION;
1103    
1104    /* Timer Registration request to system services */
1105    if (ODU_REG_TMR_MT(pst.srcEnt, pst.srcInst, duCb.duTimersInfo.tmrRes, duActvTmr) != ROK)
1106    {
1107       DU_LOG("\nERROR  -->  DU_APP : Failed to register timer");
1108       return RFAILED;
1109    }   
1110               
1111    if(ODU_GET_MSG_BUF(DFLT_REGION, DU_POOL, &mBuf) != ROK)
1112    {
1113       DU_LOG("\nERROR  -->  DU_APP : Memory allocation failed in duReadCfg");
1114       return RFAILED;
1115    }
1116
1117    if (ODU_POST_TASK(&pst, mBuf) != ROK)
1118    {
1119       DU_LOG("\nERROR  -->  DU_APP : ODU_POST_TASK failed in duReadCfg");
1120       return RFAILED;
1121    }
1122
1123    return ROK;
1124 }
1125
1126 /**********************************************************************
1127   End of file
1128  **********************************************************************/
1129