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