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