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