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