Fixes for SIB1 transmission and FAPI STOP.request [Issue-ID: ODUHIGH-325]
[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 "ConfigInterface.h"
57 extern StartupConfig g_cfg;
58 #endif
59
60 DuCfgParams duCfgParam;
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  * @brief Reads the CL Configuration.
126  *
127  * @details
128  *
129  *    Function : readMacCfg
130  *
131  *    Functionality:
132  *       - Fills up the cell configuration for CL.
133  *       - Calls FillSlotConfig()  
134  *
135  * @params[in] void
136  * @return ROK     - success
137  *         RFAILED - failure
138  *
139  * ****************************************************************/
140
141
142 /* This function is used to fill up the cell configuration for CL */
143 uint8_t readMacCfg()
144 {
145    duCfgParam.macCellCfg.carrierId = CARRIER_IDX;
146
147    /* Cell configuration */
148    duCfgParam.macCellCfg.cellId = NR_CELL_ID;
149    duCfgParam.macCellCfg.phyCellId = NR_PCI;
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 NR_TDD
156    duCfgParam.macCellCfg.dlCarrCfg.bw = BANDWIDTH_100MHZ;
157 #else
158    duCfgParam.macCellCfg.dlCarrCfg.bw = BANDWIDTH_20MHZ;
159 #endif
160    duCfgParam.macCellCfg.dlCarrCfg.freq = NR_DL_ARFCN;
161    duCfgParam.macCellCfg.dlCarrCfg.k0[0] = 1;
162    duCfgParam.macCellCfg.dlCarrCfg.k0[1] = 1;
163    duCfgParam.macCellCfg.dlCarrCfg.k0[2] = 1;
164    duCfgParam.macCellCfg.dlCarrCfg.k0[3] = 1;
165    duCfgParam.macCellCfg.dlCarrCfg.k0[4] = 1;
166    duCfgParam.macCellCfg.dlCarrCfg.gridSize[0] = 273;
167    duCfgParam.macCellCfg.dlCarrCfg.gridSize[1] = 1;
168    duCfgParam.macCellCfg.dlCarrCfg.gridSize[2] = 1;
169    duCfgParam.macCellCfg.dlCarrCfg.gridSize[3] = 1;
170    duCfgParam.macCellCfg.dlCarrCfg.gridSize[4] = 1;
171    duCfgParam.macCellCfg.dlCarrCfg.numAnt = NUM_TX_ANT;
172
173    /* UL Carrier configuration */
174    duCfgParam.macCellCfg.ulCarrCfg.pres = TRUE;
175 #ifdef NR_TDD
176    duCfgParam.macCellCfg.dlCarrCfg.bw = BANDWIDTH_100MHZ;
177 #else
178    duCfgParam.macCellCfg.ulCarrCfg.bw = BANDWIDTH_20MHZ;
179 #endif
180    duCfgParam.macCellCfg.ulCarrCfg.freq = NR_UL_ARFCN;
181    duCfgParam.macCellCfg.ulCarrCfg.k0[0] = 1;
182    duCfgParam.macCellCfg.ulCarrCfg.k0[1] = 1;
183    duCfgParam.macCellCfg.ulCarrCfg.k0[2] = 1;
184    duCfgParam.macCellCfg.ulCarrCfg.k0[3] = 1;
185    duCfgParam.macCellCfg.ulCarrCfg.k0[4] = 1;
186    duCfgParam.macCellCfg.ulCarrCfg.gridSize[0] = 1;
187    duCfgParam.macCellCfg.ulCarrCfg.gridSize[1] = 1;
188    duCfgParam.macCellCfg.ulCarrCfg.gridSize[2] = 1;
189    duCfgParam.macCellCfg.ulCarrCfg.gridSize[3] = 1;
190    duCfgParam.macCellCfg.ulCarrCfg.gridSize[4] = 1;
191    duCfgParam.macCellCfg.ulCarrCfg.numAnt = NUM_RX_ANT;
192
193    duCfgParam.macCellCfg.freqShft = FREQ_SHIFT_7P5KHZ;
194
195    /* SSB configuration */
196    duCfgParam.macCellCfg.ssbCfg.ssbPbchPwr = SSB_PBCH_PWR;
197    duCfgParam.macCellCfg.ssbCfg.bchPayloadFlag = BCH_PAYLOAD;
198 #ifdef NR_TDD
199    duCfgParam.macCellCfg.ssbCfg.scsCmn = SCS_30KHZ;
200 #else
201    duCfgParam.macCellCfg.ssbCfg.scsCmn = SCS_15KHZ;
202 #endif
203    duCfgParam.macCellCfg.ssbCfg.ssbOffsetPointA = OFFSET_TO_POINT_A;
204    duCfgParam.macCellCfg.ssbCfg.betaPss = BETA_PSS;
205    duCfgParam.macCellCfg.ssbCfg.ssbPeriod = SSB_PRDCTY_MS_20;
206    duCfgParam.macCellCfg.ssbCfg.ssbScOffset = SSB_SUBCARRIER_OFFSET;
207    duCfgParam.macCellCfg.ssbCfg.ssbMask[0] = 1; /* only one SSB is transmitted */
208    duCfgParam.macCellCfg.ssbCfg.ssbMask[1] = 0;
209    if(BuildMibPdu() != ROK)
210    {
211       DU_LOG("\nERROR  -->  Failed to build MIB PDU");
212       memset(&duCfgParam.macCellCfg.ssbCfg.mibPdu, 0, 3*sizeof(uint8_t));
213    }
214    else
215    {
216       for(uint8_t idx=0; idx<encBufSize; idx++)
217       {
218          duCfgParam.macCellCfg.ssbCfg.mibPdu[idx]=encBuf[idx];
219       }
220    }
221    duCfgParam.macCellCfg.ssbCfg.multCarrBand = SSB_MULT_CARRIER_BAND;
222    duCfgParam.macCellCfg.ssbCfg.multCellCarr = MULT_CELL_CARRIER;
223
224    /* PRACH configuration */
225    duCfgParam.macCellCfg.prachCfg.pres = TRUE;
226    duCfgParam.macCellCfg.prachCfg.prachCfgIdx = PRACH_CONFIG_IDX;
227    duCfgParam.macCellCfg.prachCfg.prachSeqLen = PRACH_SEQ_LEN;
228    duCfgParam.macCellCfg.prachCfg.prachSubcSpacing = PRACH_SUBCARRIER_SPACING;
229    duCfgParam.macCellCfg.prachCfg.prachRstSetCfg = PRACH_RESTRICTED_SET_CFG;
230    duCfgParam.macCellCfg.prachCfg.msg1Fdm = NUM_PRACH_FDM;
231    duCfgParam.macCellCfg.prachCfg.msg1FreqStart = PRACH_FREQ_START;
232    duCfgParam.macCellCfg.prachCfg.rootSeqLen    = ROOT_SEQ_LEN;
233    duCfgParam.macCellCfg.prachCfg.fdm[0].rootSeqIdx = ROOT_SEQ_IDX;
234    duCfgParam.macCellCfg.prachCfg.fdm[0].numRootSeq = NUM_ROOT_SEQ;
235    duCfgParam.macCellCfg.prachCfg.fdm[0].k1 = 0;
236    duCfgParam.macCellCfg.prachCfg.fdm[0].zeroCorrZoneCfg = ZERO_CORRELATION_ZONE_CFG;
237    duCfgParam.macCellCfg.prachCfg.fdm[0].numUnusedRootSeq = NUM_UNUSED_ROOT_SEQ;
238    if(duCfgParam.macCellCfg.prachCfg.fdm[0].numUnusedRootSeq != 0)
239    {
240         DU_ALLOC_SHRABL_BUF(duCfgParam.macCellCfg.prachCfg.fdm[0].unsuedRootSeq, 
241         NUM_UNUSED_ROOT_SEQ * sizeof(uint8_t));
242         if(duCfgParam.macCellCfg.prachCfg.fdm[0].unsuedRootSeq == NULLP)
243         {
244             DU_LOG("\nERROR  -->  DU_APP : Memory allocation failed at readMacCfg");
245             return RFAILED;
246         }
247         *(duCfgParam.macCellCfg.prachCfg.fdm[0].unsuedRootSeq) = UNUSED_ROOT_SEQ;
248     }
249    duCfgParam.macCellCfg.prachCfg.ssbPerRach = SSB_PER_RACH;
250    duCfgParam.macCellCfg.prachCfg.prachMultCarrBand = PRACH_MULT_CARRIER_BAND;
251    duCfgParam.macCellCfg.prachCfg.raContResTmr = RA_CONT_RES_TIMER;
252    duCfgParam.macCellCfg.prachCfg.rsrpThreshSsb = RSRP_THRESHOLD_SSB;
253    duCfgParam.macCellCfg.prachCfg.raRspWindow = RA_RSP_WINDOW;
254    duCfgParam.macCellCfg.prachCfg.prachRestrictedSet = PRACH_RESTRICTED_SET;
255 #ifdef NR_TDD   
256    /* TDD configuration */
257    duCfgParam.macCellCfg.tddCfg.pres = TRUE;
258    duCfgParam.macCellCfg.tddCfg.tddPeriod = TDD_PERIODICITY;
259
260    FillSlotConfig();
261
262 #endif
263    /* RSSI Measurement configuration */
264    duCfgParam.macCellCfg.rssiUnit = RSS_MEASUREMENT_UNIT;
265
266    /* fill SIB1 configuration */
267    duCfgParam.macCellCfg.sib1Cfg.sib1PduLen = duCfgParam.srvdCellLst[0].duSysInfo.sib1Len;
268    DU_ALLOC_SHRABL_BUF(duCfgParam.macCellCfg.sib1Cfg.sib1Pdu,duCfgParam.srvdCellLst[0].duSysInfo.sib1Len);
269    memcpy(duCfgParam.macCellCfg.sib1Cfg.sib1Pdu, duCfgParam.srvdCellLst[0].duSysInfo.sib1Msg, \
270          duCfgParam.srvdCellLst[0].duSysInfo.sib1Len);
271    duCfgParam.macCellCfg.sib1Cfg.sib1RepetitionPeriod = SIB1_REPETITION_PERIOD;
272    duCfgParam.macCellCfg.sib1Cfg.coresetZeroIndex = CORESET_0_INDEX;
273    duCfgParam.macCellCfg.sib1Cfg.searchSpaceZeroIndex = SEARCHSPACE_0_INDEX;
274    duCfgParam.macCellCfg.sib1Cfg.sib1Mcs = SIB1_MCS;
275
276
277    /* fill Intial DL BWP */
278    duCfgParam.macCellCfg.initialDlBwp.bwp.firstPrb = 0;
279    duCfgParam.macCellCfg.initialDlBwp.bwp.numPrb = TOTAL_PRB_20MHZ_MU0; /* configured to total BW */
280 #ifdef NR_TDD
281    duCfgParam.macCellCfg.initialDlBwp.bwp.scs = SCS_30KHZ; /* numerology is 1, 30Khz */
282 #else
283    duCfgParam.macCellCfg.initialDlBwp.bwp.scs = SCS_15KHZ; /* numerology is 0, 15Khz */
284 #endif
285    duCfgParam.macCellCfg.initialDlBwp.bwp.cyclicPrefix = NORMAL_CYCLIC_PREFIX;
286    duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.searchSpaceId = SEARCHSPACE_1_INDEX;
287    duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.coresetId = CORESET_0_INDEX;
288    duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.monitoringSlot =
289       SS_MONITORING_SLOT_SL1; /* sl1 - all slots */
290    duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.duration = 0;
291    duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.monitoringSymbol =
292       SS_MONITORING_SYMBOL;
293    duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.
294       candidate.aggLevel1       = 8;
295    duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.
296       candidate.aggLevel2       = 4;
297    duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.
298       candidate.aggLevel4       = 2;
299    duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.
300       candidate.aggLevel8       = 1;
301    duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.
302       candidate.aggLevel16      = 0;
303    duCfgParam.macCellCfg.initialDlBwp.pdschCommon.k0 = PDSCH_K0;
304    duCfgParam.macCellCfg.initialDlBwp.pdschCommon.mappingType = 
305       PDSCH_MAPPING_TYPE_A;
306    duCfgParam.macCellCfg.initialDlBwp.pdschCommon.startSymbol = 
307       PDSCH_START_SYMBOL;
308    duCfgParam.macCellCfg.initialDlBwp.pdschCommon.lengthSymbol =
309       PDSCH_LENGTH_SYMBOL;
310    /* ra-searchSpace ID is set to 1 */
311    duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.raSearchSpaceId = SEARCHSPACE_1_INDEX;
312
313    /* fill Intial UL BWP */
314    duCfgParam.macCellCfg.initialUlBwp.bwp.firstPrb = 0;
315    duCfgParam.macCellCfg.initialUlBwp.bwp.numPrb = TOTAL_PRB_20MHZ_MU0; /* configured to total BW */
316 #ifdef NR_TDD
317    duCfgParam.macCellCfg.initialUlBwp.bwp.scs = SCS_30KHZ; /* numerology is 1, 30Khz */
318 #else
319    duCfgParam.macCellCfg.initialUlBwp.bwp.scs = SCS_15KHZ; /* numerology is 0, 15Khz */
320 #endif
321    duCfgParam.macCellCfg.initialUlBwp.bwp.cyclicPrefix = NORMAL_CYCLIC_PREFIX;
322    duCfgParam.macCellCfg.initialUlBwp.puschCommon.k2 = PUSCH_K2;
323    duCfgParam.macCellCfg.initialUlBwp.puschCommon.mappingType = 
324       PUSCH_MAPPING_TYPE_A;
325    duCfgParam.macCellCfg.initialUlBwp.puschCommon.startSymbol = 
326       PUSCH_START_SYMBOL;
327    duCfgParam.macCellCfg.initialUlBwp.puschCommon.lengthSymbol =
328       PUSCH_LENGTH_SYMBOL;
329
330    duCfgParam.macCellCfg.dmrsTypeAPos = DMRS_TYPE_A_POS; 
331    /* fill PUCCH config common */
332    duCfgParam.macCellCfg.initialUlBwp.pucchCommon.pucchResourceCommon = PUCCH_RSRC_COMMON;
333    duCfgParam.macCellCfg.initialUlBwp.pucchCommon.pucchGroupHopping = PUCCH_GROUP_HOPPING;
334
335    return ROK;
336 }
337
338 /*******************************************************************
339  *
340  * @brief Configures the DU Parameters
341  *
342  * @details
343  *
344  *    Function : fillDuPort
345  *
346  *    Functionality:
347  *       - fills the DU Ports.  
348  *
349  * @params[in] duPort array to be filled
350  * @return ROK     - success
351  *         RFAILED - failure
352  *
353  * ****************************************************************/
354 uint8_t fillDuPort(uint16_t *duPort)
355 {
356
357 #ifdef O1_ENABLE
358    duPort[F1_INTERFACE]   = g_cfg.DU_Port;
359    duPort[E2_INTERFACE]   = g_cfg.RIC_Port;
360 #else
361    duPort[F1_INTERFACE]   = DU_PORT;     /* DU Port idx  0 38472 */
362    duPort[E2_INTERFACE]   = RIC_PORT;    /* RIC Port idx 1 38482 */
363 #endif
364    return ROK;
365 }
366
367 /*******************************************************************
368  *
369  * @brief Configures the DU Parameters
370  *
371  * @details
372  *
373  *    Function : calcSliv
374  *
375  *    Functionality:
376  *       - calculate SLIV value from start and length field
377  *
378  * @params[in] start symbol
379  * @params[in] length of symbols
380  * @return SLIV value
381  *
382  * ****************************************************************/
383 uint16_t calcSliv(uint8_t startSymbol, uint8_t lengthSymbol)
384 {
385    uint16_t sliv = 0;
386    if((lengthSymbol-1) <= 7)
387    {
388       sliv = NUM_SYMBOLS_PER_SLOT * (lengthSymbol-1) + startSymbol;
389    }
390    else
391    {
392       sliv = NUM_SYMBOLS_PER_SLOT * (NUM_SYMBOLS_PER_SLOT - lengthSymbol + 1) \
393              + (NUM_SYMBOLS_PER_SLOT - 1 - startSymbol);
394    }
395    return sliv;
396 }
397
398
399 /*******************************************************************
400  *
401  * @brief Configures serving cell config common in sib1
402  *
403  * @details
404  *
405  *    Function : fillServCellCfgCommSib
406  *
407  *    Functionality:
408  *       - fills Serving cell config common for SIB1
409  *
410  * @params[in] SrvCellCfgCommSib pointer
411  * @return ROK     - success
412  *         RFAILED - failure
413  * 
414  ** ****************************************************************/
415 uint8_t fillServCellCfgCommSib(SrvCellCfgCommSib *srvCellCfgComm)
416 {
417    PdcchCfgCommon   pdcchCfg;
418    PdschCfgCommon   pdschCfg;
419    PcchCfg          pcchCfg;
420    RachCfgCommon    rachCfg;
421    PuschCfgCommon   puschCfg;
422    PucchCfgCommon   pucchCfg;
423    TddUlDlCfgCommon   tddCfg;
424
425    /* Configuring DL Config Common for SIB1*/
426    srvCellCfgComm->dlCfg.freqBandInd = NR_FREQ_BAND; 
427    srvCellCfgComm->dlCfg.offsetToPointA = OFFSET_TO_POINT_A;
428    srvCellCfgComm->dlCfg.dlScsCarrier.scsOffset = SSB_SUBCARRIER_OFFSET;
429 #ifdef NR_TDD
430    srvCellCfgComm->dlCfg.dlScsCarrier.scs = SCS_30KHZ;
431    srvCellCfgComm->dlCfg.dlScsCarrier.scsBw = BANDWIDTH_100MHZ;
432 #else
433    srvCellCfgComm->dlCfg.dlScsCarrier.scs = SCS_15KHZ;
434    srvCellCfgComm->dlCfg.dlScsCarrier.scsBw = BANDWIDTH_20MHZ;
435 #endif
436    srvCellCfgComm->dlCfg.locAndBw = FREQ_LOC_BW;
437
438    /* Configuring PDCCH Config Common For SIB1 */
439    pdcchCfg.present = BWP_DownlinkCommon__pdcch_ConfigCommon_PR_setup;
440    pdcchCfg.ctrlRsrcSetZero = CORESET_0_INDEX;
441    pdcchCfg.searchSpcZero = SEARCHSPACE_0_INDEX;
442    pdcchCfg.searchSpcId = PDCCH_SEARCH_SPACE_ID;
443    pdcchCfg.ctrlRsrcSetId = PDCCH_CTRL_RSRC_SET_ID;
444    pdcchCfg.monitorSlotPrdAndOffPresent = \
445       SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl1;
446    //pdcchCfg.monitorSlotPrdAndOff = \
447    SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl1;
448    pdcchCfg.monitorSymbolsInSlot[0] = 128;
449    pdcchCfg.monitorSymbolsInSlot[1] = 0;
450    pdcchCfg.numCandAggLvl1 = SearchSpace__nrofCandidates__aggregationLevel1_n8;
451    pdcchCfg.numCandAggLvl2 = SearchSpace__nrofCandidates__aggregationLevel2_n4;
452    pdcchCfg.numCandAggLvl4 = SearchSpace__nrofCandidates__aggregationLevel4_n2;
453    pdcchCfg.numCandAggLvl8 = SearchSpace__nrofCandidates__aggregationLevel8_n1;
454    pdcchCfg.numCandAggLvl16 = SearchSpace__nrofCandidates__aggregationLevel16_n0;
455    pdcchCfg.searchSpcType = SearchSpace__searchSpaceType_PR_common;
456    pdcchCfg.commSrchSpcDciFrmt = PDCCH_SERACH_SPACE_DCI_FORMAT;
457    pdcchCfg.searchSpcSib1 = PDCCH_SEARCH_SPACE_ID_SIB1;
458    pdcchCfg.pagingSearchSpc = PDCCH_SEARCH_SPACE_ID_PAGING;
459    pdcchCfg.raSearchSpc = PDCCH_SEARCH_SPACE_ID_PAGING;
460    srvCellCfgComm->dlCfg.pdcchCfg = pdcchCfg;
461
462    /* Configuring PDSCH Config Common For SIB1 */
463    pdschCfg.present = BWP_DownlinkCommon__pdsch_ConfigCommon_PR_setup;
464    pdschCfg.k0 = PDSCH_K0;
465    pdschCfg.mapType = \
466       PDSCH_TimeDomainResourceAllocation__mappingType_typeA;
467    pdschCfg.sliv = calcSliv(PDSCH_START_SYMBOL,PDSCH_LENGTH_SYMBOL);
468    srvCellCfgComm->dlCfg.pdschCfg = pdschCfg;
469
470    /* Configuring BCCH Config for SIB1 */
471    srvCellCfgComm->dlCfg.bcchCfg.modPrdCoeff = \
472       BCCH_Config__modificationPeriodCoeff_n16;
473
474    /* Configuring PCCH Config for SIB1 */
475    pcchCfg.dfltPagingCycle = PagingCycle_rf256;
476    pcchCfg.nAndPagingFrmOffPresent = PCCH_Config__nAndPagingFrameOffset_PR_oneT;
477    pcchCfg.numPagingOcc = PCCH_Config__ns_four;
478    srvCellCfgComm->dlCfg.pcchCfg = pcchCfg;
479
480
481    /* Configuring UL Config Common */
482    srvCellCfgComm->ulCfg.ulScsCarrier.scsOffset = SSB_SUBCARRIER_OFFSET;
483 #ifdef NR_TDD
484    srvCellCfgComm->ulCfg.ulScsCarrier.scs = SCS_30KHZ;
485    srvCellCfgComm->ulCfg.ulScsCarrier.scsBw = BANDWIDTH_100MHZ;
486 #else
487    srvCellCfgComm->ulCfg.ulScsCarrier.scs = SCS_15KHZ;
488    srvCellCfgComm->ulCfg.ulScsCarrier.scsBw = BANDWIDTH_20MHZ;
489 #endif
490    srvCellCfgComm->ulCfg.pMax = UL_P_MAX;
491    srvCellCfgComm->ulCfg.locAndBw = FREQ_LOC_BW;
492    srvCellCfgComm->ulCfg.timeAlignTimerComm = TimeAlignmentTimer_infinity;
493
494    /* Configuring RACH Config Common for SIB1 */
495    rachCfg.present = BWP_UplinkCommon__rach_ConfigCommon_PR_setup;
496    rachCfg.prachCfgIdx = PRACH_CONFIG_IDX;
497    rachCfg.msg1Fdm = RACH_ConfigGeneric__msg1_FDM_one;
498    rachCfg.msg1FreqStart = PRACH_FREQ_START;
499    rachCfg.zeroCorrZoneCfg = ZERO_CORRELATION_ZONE_CFG;
500    rachCfg.preambleRcvdTgtPwr = PRACH_PREAMBLE_RCVD_TGT_PWR;
501    rachCfg.preambleTransMax = RACH_ConfigGeneric__preambleTransMax_n200;
502    rachCfg.pwrRampingStep = RACH_ConfigGeneric__powerRampingStep_dB2;
503    rachCfg.raRspWindow = RACH_ConfigGeneric__ra_ResponseWindow_sl20;
504    rachCfg.numRaPreamble = NUM_RA_PREAMBLE;
505    rachCfg.ssbPerRachOccPresent = \
506       RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_one;
507    rachCfg.numSsbPerRachOcc = SSB_PER_RACH;
508    rachCfg.contResTimer = RACH_ConfigCommon__ra_ContentionResolutionTimer_sf64;
509    rachCfg.rsrpThreshSsb = RSRP_THRESHOLD_SSB;
510    rachCfg.rootSeqIdxPresent = RACH_ConfigCommon__prach_RootSequenceIndex_PR_l139;
511    rachCfg.rootSeqIdx = ROOT_SEQ_IDX;
512    rachCfg.msg1Scs = PRACH_SUBCARRIER_SPACING ;
513    rachCfg.restrictedSetCfg = PRACH_RESTRICTED_SET_CFG;
514    srvCellCfgComm->ulCfg.rachCfg = rachCfg;
515
516    /* Configuring PUSCH Config Common for SIB1 */
517    puschCfg.present = BWP_UplinkCommon__pusch_ConfigCommon_PR_setup;
518    puschCfg.k2 = PUSCH_K2;
519    puschCfg.mapType = PUSCH_TimeDomainResourceAllocation__mappingType_typeA;
520    puschCfg.sliv = calcSliv(PUSCH_START_SYMBOL,PUSCH_LENGTH_SYMBOL);
521    puschCfg.msg3DeltaPreamble = PUSCH_MSG3_DELTA_PREAMBLE;
522    puschCfg.p0NominalWithGrant = PUSCH_P0_NOMINAL_WITH_GRANT;
523    srvCellCfgComm->ulCfg.puschCfg = puschCfg;
524
525    /* Configuring PUCCH Config Common for SIB1 */
526    pucchCfg.present = BWP_UplinkCommon__pucch_ConfigCommon_PR_setup;
527    pucchCfg.rsrcComm = PUCCH_RSRC_COMMON;
528    pucchCfg.grpHop = PUCCH_ConfigCommon__pucch_GroupHopping_neither;
529    pucchCfg.p0Nominal = PUCCH_P0_NOMINAL;
530    srvCellCfgComm->ulCfg.pucchCfg = pucchCfg;
531
532    /* Configuring TDD UL DL config common */
533    tddCfg.refScs = SubcarrierSpacing_kHz30;
534    tddCfg.txPrd = TDD_UL_DL_Pattern__dl_UL_TransmissionPeriodicity_ms5;
535    tddCfg.numDlSlots = NUM_DL_SLOTS;
536    tddCfg.numDlSymbols = NUM_DL_SYMBOLS;
537    tddCfg.numUlSlots = NUM_UL_SLOTS;
538    tddCfg.numUlSymbols = NUM_UL_SYMBOLS;
539    srvCellCfgComm->tddCfg = tddCfg;
540
541    srvCellCfgComm->ssbPosInBurst = 192;
542    srvCellCfgComm->ssbPrdServingCell = SSB_PERIODICITY_20MS;
543    srvCellCfgComm->ssPbchBlockPwr = SSB_PBCH_PWR;
544
545    return ROK;
546 }
547
548 /*******************************************************************
549  *
550  * @brief Configures the DU Parameters
551  *
552  * @details
553  *
554  *    Function : readCfg
555  *
556  *    Functionality:
557  *       - Initializes the DuCfg members.  
558  *       - Calls readMacCfg()  
559  *
560  * @params[in] system task ID
561  * @return ROK     - success
562  *         RFAILED - failure
563  *
564  * ****************************************************************/
565
566 uint8_t readCfg()
567 {
568    uint8_t i,j,k;
569    uint32_t ipv4_du, ipv4_cu, ipv4_ric;
570    MibParams mib;
571    Sib1Params sib1;     
572
573 #ifdef O1_ENABLE
574    if( getStartupConfig(&g_cfg) != ROK )
575    {
576       RETVALUE(RFAILED);
577    }
578    cmInetAddr((S8*)g_cfg.DU_IPV4_Addr, &ipv4_du);
579    cmInetAddr((S8*)g_cfg.CU_IPV4_Addr, &ipv4_cu);
580    cmInetAddr((S8*)g_cfg.RIC_IPV4_Addr, &ipv4_ric);
581
582    duCfgParam.sctpParams.cuPort = g_cfg.CU_Port;
583    duCfgParam.sctpParams.ricPort = g_cfg.RIC_Port;
584 #else   
585    cmInetAddr((S8*)DU_IP_V4_ADDR, &ipv4_du);
586    cmInetAddr((S8*)CU_IP_V4_ADDR, &ipv4_cu);
587    cmInetAddr((S8*)RIC_IP_V4_ADDR, &ipv4_ric);
588
589    duCfgParam.sctpParams.cuPort = CU_PORT;
590    duCfgParam.sctpParams.ricPort = RIC_PORT;
591 #endif
592
593    fillDuPort(duCfgParam.sctpParams.duPort);
594
595    /* F1 DU IP Address and Port*/
596    duCfgParam.sctpParams.duIpAddr.ipV4Addr = ipv4_du;
597
598    /* F1 CU IP Address and Port*/
599    duCfgParam.sctpParams.cuIpAddr.ipV4Addr = ipv4_cu;
600
601    /* Fill RIC Params */
602    duCfgParam.sctpParams.ricIpAddr.ipV4Addr = ipv4_ric;
603
604    /* EGTP Parameters */
605    duCfgParam.egtpParams.localIp.ipV4Pres = TRUE;
606    duCfgParam.egtpParams.localIp.ipV4Addr = ipv4_du;
607    duCfgParam.egtpParams.localPort = DU_EGTP_PORT;
608    duCfgParam.egtpParams.destIp.ipV4Pres = TRUE;
609    duCfgParam.egtpParams.destIp.ipV4Addr = ipv4_cu;
610    duCfgParam.egtpParams.destPort = CU_EGTP_PORT;
611    duCfgParam.egtpParams.minTunnelId = 0;
612    duCfgParam.egtpParams.maxTunnelId = 10;
613
614    duCfgParam.maxUe = 32; //TODO: Check
615    /* DU Info */        
616    duCfgParam.duId = DU_ID;     
617    strcpy((char*)duCfgParam.duName,DU_NAME);
618
619    /* Mib Params */
620    mib.sysFrmNum = SYS_FRAME_NUM;
621 #ifdef NR_TDD
622    mib.subCarrierSpacingCommon = MIB__subCarrierSpacingCommon_scs30or120;
623 #else
624    mib.subCarrierSpacingCommon = MIB__subCarrierSpacingCommon_scs15or60;
625 #endif
626    mib.ssb_SubcarrierOffset = SSB_SC_OFFSET; //Kssb
627    mib.dmrs_TypeA_Position = MIB__dmrs_TypeA_Position_pos2;
628    mib.controlResourceSetZero = CORESET_0_INDEX;
629    mib.searchSpaceZero = SEARCHSPACE_0_INDEX;
630    mib.cellBarred = MIB__cellBarred_notBarred;
631    mib.intraFreqReselection =
632       MIB__intraFreqReselection_notAllowed;
633    duCfgParam.mibParams = mib;
634
635    /* SIB1 Params */
636    memset(&sib1.plmn, 0, sizeof(Plmn));
637    sib1.plmn.mcc[0] = PLMN_MCC0;
638    sib1.plmn.mcc[1] = PLMN_MCC1;
639    sib1.plmn.mcc[2] = PLMN_MCC2;
640    sib1.plmn.mnc[0] = PLMN_MNC0;
641    sib1.plmn.mnc[1] = PLMN_MNC1;
642    sib1.tac = DU_TAC;
643    sib1.ranac = DU_RANAC;
644    sib1.cellIdentity = CELL_IDENTITY;
645    sib1.cellResvdForOpUse =\
646       PLMN_IdentityInfo__cellReservedForOperatorUse_notReserved;
647    sib1.connEstFailCnt = ConnEstFailureControl__connEstFailCount_n3;
648    sib1.connEstFailOffValidity =\
649       ConnEstFailureControl__connEstFailOffsetValidity_s120;
650    sib1.siSchedInfo.winLen = SI_SchedulingInfo__si_WindowLength_s5;
651    sib1.siSchedInfo.broadcastSta = \
652       SchedulingInfo__si_BroadcastStatus_broadcasting;
653    sib1.siSchedInfo.preiodicity = SchedulingInfo__si_Periodicity_rf8;
654    sib1.siSchedInfo.sibType = SIB_TypeInfo__type_sibType2;
655    sib1.siSchedInfo.sibValTag = SIB1_VALUE_TAG;
656
657    fillServCellCfgCommSib(&sib1.srvCellCfgCommSib);
658
659    duCfgParam.sib1Params = sib1;
660
661    for(i=0; i<DEFAULT_CELLS; i++)
662    { 
663       memset(&duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.nrCgi.plmn, 0, sizeof(Plmn));
664       duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.nrCgi.plmn.mcc[0] = PLMN_MCC0;
665       duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.nrCgi.plmn.mcc[1] = PLMN_MCC1;
666       duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.nrCgi.plmn.mcc[2] = PLMN_MCC2;
667       duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.nrCgi.plmn.mnc[0] = PLMN_MNC0;
668       duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.nrCgi.plmn.mnc[1] = PLMN_MNC1;
669
670       /*Cell ID */
671       duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.nrCgi.cellId = NR_CELL_ID;
672       duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.nrPci = NR_PCI;
673
674       /* List of Available PLMN */
675       for(j=0;j<MAX_PLMN;j++)
676       {
677          memset(&duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.plmn[j], 0, sizeof(Plmn));
678          duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.plmn[j].mcc[0] = PLMN_MCC0;
679          duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.plmn[j].mcc[1] = PLMN_MCC1;
680          duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.plmn[j].mcc[2] = PLMN_MCC2;
681          duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.plmn[j].mnc[0] = PLMN_MNC0;
682          duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.plmn[j].mnc[1] = PLMN_MNC1;
683       }
684       /* List of Extended PLMN */
685       for(j=0;j<MAX_PLMN;j++)
686       {
687          memset(&duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.extPlmn[j], 0, sizeof(Plmn));
688          duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.extPlmn[j].mcc[0] = PLMN_MCC0;
689          duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.extPlmn[j].mcc[1] = PLMN_MCC1;
690          duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.extPlmn[j].mcc[2] = PLMN_MCC2;
691          duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.extPlmn[j].mnc[0] = PLMN_MNC0;
692          duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.extPlmn[j].mnc[1] = PLMN_MNC1;
693       } 
694
695       /* TAC and EPSTAC */
696       duCfgParam.srvdCellLst[i].duCellInfo.tac = DU_TAC;
697       duCfgParam.srvdCellLst[i].duCellInfo.epsTac = DU_TAC; //to check and fill
698       /* NR Mode info */
699       duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.nrArfcn = NR_UL_ARFCN;
700       duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.sulInfo.sulArfcn = SUL_ARFCN;
701       duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.sulInfo.sulTxBw.nrScs = SCS_15;
702       duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.sulInfo.sulTxBw.nrb = NRB_106;
703
704 #if 0
705       /* NR Mode info */
706       duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.nrArfcn = NR_ARFCN;
707       duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.sulInfo.sulArfcn = SUL_ARFCN;
708       duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.sulInfo.sulTxBw.nrScs = SCS_15;           
709       duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.sulInfo.sulTxBw.nrb = NRB_106;           
710
711       for(j=0;j<MAXNRCELLBANDS;j++)
712       {
713          duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.freqBand[j].nrFreqBand = NR_FREQ_BAND;
714          for(k=0;k<MAXNRCELLBANDS;k++)
715          {
716             duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.freqBand[j].sulBand[k] = SUL_BAND;  
717          }
718       }
719 #endif
720       for(j=0;j<MAXNRCELLBANDS;j++)
721       {
722          duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.freqBand[j].nrFreqBand = NR_FREQ_BAND;
723          for(k=0;k<MAXNRCELLBANDS;k++)
724          {
725             duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.freqBand[j].sulBand[k] = SUL_BAND;
726          }
727       }
728       duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.nrArfcn = NR_DL_ARFCN;
729       duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.sulInfo.sulArfcn = SUL_ARFCN;
730       duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.sulInfo.sulTxBw.nrScs = SCS_15;
731       duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.sulInfo.sulTxBw.nrb = NRB_106;
732       for(j=0;j<MAXNRCELLBANDS;j++)
733       {
734          duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.freqBand[j].nrFreqBand = NR_FREQ_BAND;
735          for(k=0;k<MAXNRCELLBANDS;k++)
736          {
737             duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.freqBand[j].sulBand[k] = SUL_BAND;
738          }
739       }
740
741       duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.ulTxBw.nrScs = SCS_15;
742       duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.ulTxBw.nrb = NRB_106;
743
744       duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.dlTxBw.nrScs = SCS_15;
745       duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.dlTxBw.nrb = NRB_106;
746
747 #if 0
748       duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.tdd.nrTxBw.nrScs = SCS_15;
749       duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.tdd.nrTxBw.nrb = NRB_106;
750 #endif
751       /*Measurement Config and Cell Config */ 
752       duCfgParam.srvdCellLst[i].duCellInfo.measTimeCfg = TIME_CFG; 
753
754       duCfgParam.srvdCellLst[i].duCellInfo.cellDir = DL_UL; 
755
756       duCfgParam.srvdCellLst[i].duCellInfo.cellType=CELL_TYPE;
757
758       /* Broadcast PLMN Identity */
759       for(j=0;j<MAXBPLMNNRMINUS1;j++)
760       { 
761          for(k=0;k<MAX_PLMN;k++)
762          {
763             memset(&duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].plmn[k], 0, sizeof(Plmn));
764             duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].plmn[k].mcc[0] = PLMN_MCC0;
765             duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].plmn[k].mcc[1] = PLMN_MCC1;
766             duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].plmn[k].mcc[2] = PLMN_MCC2;
767             duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].plmn[k].mnc[0] = PLMN_MNC0;
768             duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].plmn[k].mnc[1] = PLMN_MNC1;                                         
769          }
770          /* Extended PLMN List */        
771          for(k=0;k<MAX_PLMN;k++)
772          {
773             memset(&duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].extPlmn[k], 0, sizeof(Plmn));
774             duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].extPlmn[k].mcc[0] = PLMN_MCC0;
775             duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].extPlmn[k].mcc[1] = PLMN_MCC1;
776             duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].extPlmn[k].mcc[2] = PLMN_MCC2;
777             duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].extPlmn[k].mnc[0] = PLMN_MNC0;
778             duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].extPlmn[k].mnc[1] = PLMN_MNC1;
779          }
780
781          duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].tac = DU_TAC;
782          duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].nrCellId = NR_CELL_ID;
783          duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].ranac = NR_RANAC;
784       }
785
786       /*gnb DU System Info mib msg*/
787       BuildMibMsg();
788       DU_ALLOC(duCfgParam.srvdCellLst[i].duSysInfo.mibMsg, encBufSize);
789       if(!(duCfgParam.srvdCellLst[i].duSysInfo.mibMsg))
790       {
791          DU_LOG("\nERROR  -->  DU APP : Memory allocation failure at readCfg");
792          return RFAILED;
793       }
794       memcpy(duCfgParam.srvdCellLst[i].duSysInfo.mibMsg, encBuf, encBufSize);
795       duCfgParam.srvdCellLst[i].duSysInfo.mibLen = encBufSize;
796
797       /*gnb DU System Info mib msg*/
798       BuildSib1Msg();
799       DU_ALLOC(duCfgParam.srvdCellLst[i].duSysInfo.sib1Msg,\
800             encBufSize);
801       if(!(duCfgParam.srvdCellLst[i].duSysInfo.sib1Msg))
802       {
803          DU_LOG("\nERROR  -->  DU APP : Memory allocation failure at readCfg");
804          return RFAILED;
805       }
806       memcpy(duCfgParam.srvdCellLst[i].duSysInfo.sib1Msg,\
807             encBuf,encBufSize);
808       duCfgParam.srvdCellLst[i].duSysInfo.sib1Len = encBufSize;
809
810    }
811
812    if(readMacCfg() != ROK)
813    {
814       DU_LOG("\nERROR  -->  DU_APP : Failed while reading MAC config");
815       return RFAILED;
816    }
817
818    return ROK;
819 }
820
821 /*******************************************************************
822  *
823  * @brief Reads config and posts message to du_app on completion
824  *
825  * @details
826  *
827  *    Function : main
828  *
829  *    Functionality:
830  *      - Calls readCfg()
831  *      - Post to du_app for further processing
832  *
833  * @params[in] void
834  * @return ROK     - success
835  *         RFAILED - failure
836  *
837  * ****************************************************************/
838 uint8_t duReadCfg()
839 {
840    Pst pst;
841    Buffer *mBuf;
842
843    memset(&duCfgParam, 0, sizeof(DuCfgParams));
844    //Read configs into duCfgParams
845    if(readCfg() != ROK)
846    {
847       DU_LOG("\nERROR  -->  DU_APP : Reading configuration failed");
848       return RFAILED;
849    }
850
851    //Fill pst structure
852    memset(&(pst), 0, sizeof(Pst));
853    pst.srcEnt = (Ent)ENTDUAPP;
854    pst.srcInst = (Inst)DU_INST;
855    pst.srcProcId = DU_PROC;
856    pst.dstEnt = pst.srcEnt;
857    pst.dstInst = pst.srcInst;
858    pst.dstProcId = pst.srcProcId;
859    pst.event = EVTCFG;
860    pst.selector = ODU_SELECTOR_TC;
861    pst.pool= DU_POOL;
862
863
864    if(ODU_GET_MSG_BUF(DFLT_REGION, DU_POOL, &mBuf) != ROK)
865    {
866       DU_LOG("\nERROR  -->  DU_APP : Memory allocation failed in duReadCfg");
867       return RFAILED;
868    }
869
870    if (ODU_POST_TASK(&pst, mBuf) != ROK)
871    {
872       DU_LOG("\nERROR  -->  DU_APP : ODU_POST_TASK failed in duReadCfg");
873       return RFAILED;
874    }
875
876    return ROK;
877 }
878
879 /**********************************************************************
880   End of file
881  **********************************************************************/
882