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