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