Merge "Implementation of Slice related configuration and Slice Discovery procedure...
[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       memcpy(&duCfgParam.macCellCfg.ssbCfg.mibPdu, encBuf,encBufSize);
219    }
220    duCfgParam.macCellCfg.ssbCfg.multCarrBand = SSB_MULT_CARRIER_BAND;
221    duCfgParam.macCellCfg.ssbCfg.multCellCarr = MULT_CELL_CARRIER;
222
223    /* PRACH configuration */
224    duCfgParam.macCellCfg.prachCfg.pres = TRUE;
225    duCfgParam.macCellCfg.prachCfg.prachCfgIdx = PRACH_CONFIG_IDX;
226    duCfgParam.macCellCfg.prachCfg.prachSeqLen = PRACH_SEQ_LEN;
227    duCfgParam.macCellCfg.prachCfg.prachSubcSpacing = PRACH_SUBCARRIER_SPACING;
228    duCfgParam.macCellCfg.prachCfg.prachRstSetCfg = PRACH_RESTRICTED_SET_CFG;
229    duCfgParam.macCellCfg.prachCfg.msg1Fdm = NUM_PRACH_FDM;
230    duCfgParam.macCellCfg.prachCfg.msg1FreqStart = PRACH_FREQ_START;
231    duCfgParam.macCellCfg.prachCfg.rootSeqLen    = ROOT_SEQ_LEN;
232    duCfgParam.macCellCfg.prachCfg.fdm[0].rootSeqIdx = ROOT_SEQ_IDX;
233    duCfgParam.macCellCfg.prachCfg.fdm[0].numRootSeq = NUM_ROOT_SEQ;
234    duCfgParam.macCellCfg.prachCfg.fdm[0].k1 = 0;
235    duCfgParam.macCellCfg.prachCfg.fdm[0].zeroCorrZoneCfg = ZERO_CORRELATION_ZONE_CFG;
236    duCfgParam.macCellCfg.prachCfg.fdm[0].numUnusedRootSeq = NUM_UNUSED_ROOT_SEQ;
237    if(duCfgParam.macCellCfg.prachCfg.fdm[0].numUnusedRootSeq != 0)
238    {
239         DU_ALLOC_SHRABL_BUF(duCfgParam.macCellCfg.prachCfg.fdm[0].unsuedRootSeq, 
240         NUM_UNUSED_ROOT_SEQ * sizeof(uint8_t));
241         if(duCfgParam.macCellCfg.prachCfg.fdm[0].unsuedRootSeq == NULLP)
242         {
243             DU_LOG("\nERROR  -->  DU_APP : Memory allocation failed at readMacCfg");
244             return RFAILED;
245         }
246         *(duCfgParam.macCellCfg.prachCfg.fdm[0].unsuedRootSeq) = UNUSED_ROOT_SEQ;
247     }
248    duCfgParam.macCellCfg.prachCfg.ssbPerRach = SSB_PER_RACH;
249    duCfgParam.macCellCfg.prachCfg.prachMultCarrBand = PRACH_MULT_CARRIER_BAND;
250    duCfgParam.macCellCfg.prachCfg.raContResTmr = RA_CONT_RES_TIMER;
251    duCfgParam.macCellCfg.prachCfg.rsrpThreshSsb = RSRP_THRESHOLD_SSB;
252    duCfgParam.macCellCfg.prachCfg.raRspWindow = RA_RSP_WINDOW;
253    duCfgParam.macCellCfg.prachCfg.prachRestrictedSet = PRACH_RESTRICTED_SET;
254 #ifdef NR_TDD   
255    /* TDD configuration */
256    duCfgParam.macCellCfg.tddCfg.pres = TRUE;
257    duCfgParam.macCellCfg.tddCfg.tddPeriod = TDD_PERIODICITY;
258
259    FillSlotConfig();
260
261 #endif
262    /* RSSI Measurement configuration */
263    duCfgParam.macCellCfg.rssiUnit = RSS_MEASUREMENT_UNIT;
264
265    /* fill SIB1 configuration */
266    duCfgParam.macCellCfg.sib1Cfg.sib1PduLen = duCfgParam.srvdCellLst[0].duSysInfo.sib1Len;
267    DU_ALLOC_SHRABL_BUF(duCfgParam.macCellCfg.sib1Cfg.sib1Pdu,duCfgParam.srvdCellLst[0].duSysInfo.sib1Len);
268    memcpy(duCfgParam.macCellCfg.sib1Cfg.sib1Pdu, duCfgParam.srvdCellLst[0].duSysInfo.sib1Msg, \
269          duCfgParam.srvdCellLst[0].duSysInfo.sib1Len);
270    duCfgParam.macCellCfg.sib1Cfg.sib1RepetitionPeriod = SIB1_REPETITION_PERIOD;
271    duCfgParam.macCellCfg.sib1Cfg.coresetZeroIndex = CORESET_0_INDEX;
272    duCfgParam.macCellCfg.sib1Cfg.searchSpaceZeroIndex = SEARCHSPACE_0_INDEX;
273    duCfgParam.macCellCfg.sib1Cfg.sib1Mcs = SIB1_MCS;
274
275
276    /* fill Intial DL BWP */
277    duCfgParam.macCellCfg.initialDlBwp.bwp.firstPrb = 0;
278    duCfgParam.macCellCfg.initialDlBwp.bwp.numPrb = TOTAL_PRB_20MHZ_MU0; /* configured to total BW */
279 #ifdef NR_TDD
280    duCfgParam.macCellCfg.initialDlBwp.bwp.scs = SCS_30KHZ; /* numerology is 1, 30Khz */
281 #else
282    duCfgParam.macCellCfg.initialDlBwp.bwp.scs = SCS_15KHZ; /* numerology is 0, 15Khz */
283 #endif
284    duCfgParam.macCellCfg.initialDlBwp.bwp.cyclicPrefix = NORMAL_CYCLIC_PREFIX;
285    duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.searchSpaceId = SEARCHSPACE_1_INDEX;
286    duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.coresetId = CORESET_0_INDEX;
287    duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.monitoringSlot =
288       SS_MONITORING_SLOT_SL1; /* sl1 - all slots */
289    duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.duration = 0;
290    duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.monitoringSymbol =
291       SS_MONITORING_SYMBOL;
292    duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.
293       candidate.aggLevel1       = 8;
294    duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.
295       candidate.aggLevel2       = 4;
296    duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.
297       candidate.aggLevel4       = 2;
298    duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.
299       candidate.aggLevel8       = 1;
300    duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.
301       candidate.aggLevel16      = 0;
302
303    duCfgParam.macCellCfg.initialDlBwp.pdschCommon.numTimeDomAlloc = 2;
304    idx = 0;
305    duCfgParam.macCellCfg.initialDlBwp.pdschCommon.timeDomRsrcAllocList[idx].k0 = PDSCH_K0_CFG1;
306    duCfgParam.macCellCfg.initialDlBwp.pdschCommon.timeDomRsrcAllocList[idx].mappingType = 
307       PDSCH_MAPPING_TYPE_A;
308    duCfgParam.macCellCfg.initialDlBwp.pdschCommon.timeDomRsrcAllocList[idx].startSymbol = 
309       PDSCH_START_SYMBOL;
310    duCfgParam.macCellCfg.initialDlBwp.pdschCommon.timeDomRsrcAllocList[idx].lengthSymbol =
311       PDSCH_LENGTH_SYMBOL;
312    idx++;
313    duCfgParam.macCellCfg.initialDlBwp.pdschCommon.timeDomRsrcAllocList[idx].k0 = PDSCH_K0_CFG2;
314    duCfgParam.macCellCfg.initialDlBwp.pdschCommon.timeDomRsrcAllocList[idx].mappingType = 
315       PDSCH_MAPPING_TYPE_A;
316    duCfgParam.macCellCfg.initialDlBwp.pdschCommon.timeDomRsrcAllocList[idx].startSymbol = 
317       PDSCH_START_SYMBOL;
318    duCfgParam.macCellCfg.initialDlBwp.pdschCommon.timeDomRsrcAllocList[idx].lengthSymbol =
319       PDSCH_LENGTH_SYMBOL;
320
321    /* ra-searchSpace ID is set to 1 */
322    duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.raSearchSpaceId = SEARCHSPACE_1_INDEX;
323
324    /* fill Intial UL BWP */
325    duCfgParam.macCellCfg.initialUlBwp.bwp.firstPrb = 0;
326    duCfgParam.macCellCfg.initialUlBwp.bwp.numPrb = TOTAL_PRB_20MHZ_MU0; /* configured to total BW */
327 #ifdef NR_TDD
328    duCfgParam.macCellCfg.initialUlBwp.bwp.scs = SCS_30KHZ; /* numerology is 1, 30Khz */
329 #else
330    duCfgParam.macCellCfg.initialUlBwp.bwp.scs = SCS_15KHZ; /* numerology is 0, 15Khz */
331 #endif
332    duCfgParam.macCellCfg.initialUlBwp.bwp.cyclicPrefix = NORMAL_CYCLIC_PREFIX;
333    duCfgParam.macCellCfg.initialUlBwp.puschCommon.numTimeDomRsrcAlloc = 2;
334    duCfgParam.macCellCfg.initialUlBwp.puschCommon.timeDomRsrcAllocList[0].k2 = PUSCH_K2_CFG1;
335    duCfgParam.macCellCfg.initialUlBwp.puschCommon.timeDomRsrcAllocList[0].mappingType = 
336       PUSCH_MAPPING_TYPE_A;
337    duCfgParam.macCellCfg.initialUlBwp.puschCommon.timeDomRsrcAllocList[0].startSymbol = 
338       PUSCH_START_SYMBOL;
339    duCfgParam.macCellCfg.initialUlBwp.puschCommon.timeDomRsrcAllocList[0].symbolLength =
340       PUSCH_LENGTH_SYMBOL;
341
342    duCfgParam.macCellCfg.initialUlBwp.puschCommon.timeDomRsrcAllocList[1].k2 = PUSCH_K2_CFG2;
343    duCfgParam.macCellCfg.initialUlBwp.puschCommon.timeDomRsrcAllocList[1].mappingType = 
344       PUSCH_MAPPING_TYPE_A;
345    duCfgParam.macCellCfg.initialUlBwp.puschCommon.timeDomRsrcAllocList[1].startSymbol = 
346       PUSCH_START_SYMBOL;
347    duCfgParam.macCellCfg.initialUlBwp.puschCommon.timeDomRsrcAllocList[1].symbolLength =
348       PUSCH_LENGTH_SYMBOL;
349
350    duCfgParam.macCellCfg.dmrsTypeAPos = DMRS_TYPE_A_POS; 
351
352    /* fill PUCCH config common */
353    duCfgParam.macCellCfg.initialUlBwp.pucchCommon.pucchResourceCommon = PUCCH_RSRC_COMMON;
354    duCfgParam.macCellCfg.initialUlBwp.pucchCommon.pucchGroupHopping = PUCCH_GROUP_HOPPING;
355
356    return ROK;
357 }
358
359 /*******************************************************************
360  *
361  * @brief Configures the DU Parameters
362  *
363  * @details
364  *
365  *    Function : fillDuPort
366  *
367  *    Functionality:
368  *       - fills the DU Ports.  
369  *
370  * @params[in] duPort array to be filled
371  * @return ROK     - success
372  *         RFAILED - failure
373  *
374  * ****************************************************************/
375 uint8_t fillDuPort(uint16_t *duPort)
376 {
377
378 #ifdef O1_ENABLE
379    duPort[F1_INTERFACE]   = g_cfg.DU_Port;
380    duPort[E2_INTERFACE]   = g_cfg.RIC_Port;
381 #else
382    duPort[F1_INTERFACE]   = DU_PORT;     /* DU Port idx  0 38472 */
383    duPort[E2_INTERFACE]   = RIC_PORT;    /* RIC Port idx 1 38482 */
384 #endif
385    return ROK;
386 }
387
388 /*******************************************************************
389  *
390  * @brief Configures the DU Parameters
391  *
392  * @details
393  *
394  *    Function : calcSliv
395  *
396  *    Functionality:
397  *       - calculate SLIV value from start and length field
398  *
399  * @params[in] start symbol
400  * @params[in] length of symbols
401  * @return SLIV value
402  *
403  * ****************************************************************/
404 uint16_t calcSliv(uint8_t startSymbol, uint8_t lengthSymbol)
405 {
406    uint16_t sliv = 0;
407    if((lengthSymbol-1) <= 7)
408    {
409       sliv = NUM_SYMBOLS_PER_SLOT * (lengthSymbol-1) + startSymbol;
410    }
411    else
412    {
413       sliv = NUM_SYMBOLS_PER_SLOT * (NUM_SYMBOLS_PER_SLOT - lengthSymbol + 1) \
414              + (NUM_SYMBOLS_PER_SLOT - 1 - startSymbol);
415    }
416    return sliv;
417 }
418
419
420 /*******************************************************************
421  *
422  * @brief Configures serving cell config common in sib1
423  *
424  * @details
425  *
426  *    Function : fillServCellCfgCommSib
427  *
428  *    Functionality:
429  *       - fills Serving cell config common for SIB1
430  *
431  * @params[in] SrvCellCfgCommSib pointer
432  * @return ROK     - success
433  *         RFAILED - failure
434  * 
435  ** ****************************************************************/
436 uint8_t fillServCellCfgCommSib(SrvCellCfgCommSib *srvCellCfgComm)
437 {
438    PdcchCfgCommon   pdcchCfg;
439    PdschCfgCommon   pdschCfg;
440    PcchCfg          pcchCfg;
441    RachCfgCommon    rachCfg;
442    PuschCfgCommon   puschCfg;
443    PucchCfgCommon   pucchCfg;
444    TddUlDlCfgCommon   tddCfg;
445
446    /* Configuring DL Config Common for SIB1*/
447    srvCellCfgComm->dlCfg.freqBandInd = NR_FREQ_BAND; 
448    srvCellCfgComm->dlCfg.offsetToPointA = OFFSET_TO_POINT_A;
449    srvCellCfgComm->dlCfg.dlScsCarrier.scsOffset = SSB_SUBCARRIER_OFFSET;
450 #ifdef NR_TDD
451    srvCellCfgComm->dlCfg.dlScsCarrier.scs = SCS_30KHZ;
452    srvCellCfgComm->dlCfg.dlScsCarrier.scsBw = BANDWIDTH_100MHZ;
453 #else
454    srvCellCfgComm->dlCfg.dlScsCarrier.scs = SCS_15KHZ;
455    srvCellCfgComm->dlCfg.dlScsCarrier.scsBw = BANDWIDTH_20MHZ;
456 #endif
457    srvCellCfgComm->dlCfg.locAndBw = FREQ_LOC_BW;
458
459    /* Configuring PDCCH Config Common For SIB1 */
460    pdcchCfg.present = BWP_DownlinkCommon__pdcch_ConfigCommon_PR_setup;
461    pdcchCfg.ctrlRsrcSetZero = CORESET_0_INDEX;
462    pdcchCfg.searchSpcZero = SEARCHSPACE_0_INDEX;
463    pdcchCfg.searchSpcId = PDCCH_SEARCH_SPACE_ID;
464    pdcchCfg.ctrlRsrcSetId = PDCCH_CTRL_RSRC_SET_ID;
465    pdcchCfg.monitorSlotPrdAndOffPresent = \
466       
467       SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl1;
468    //pdcchCfg.monitorSlotPrdAndOff = \
469    SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl1;
470    pdcchCfg.monitorSymbolsInSlot[0] = 128;
471    pdcchCfg.monitorSymbolsInSlot[1] = 0;
472    pdcchCfg.numCandAggLvl1 = SearchSpace__nrofCandidates__aggregationLevel1_n8;
473    pdcchCfg.numCandAggLvl2 = SearchSpace__nrofCandidates__aggregationLevel2_n4;
474    pdcchCfg.numCandAggLvl4 = SearchSpace__nrofCandidates__aggregationLevel4_n2;
475    pdcchCfg.numCandAggLvl8 = SearchSpace__nrofCandidates__aggregationLevel8_n1;
476    pdcchCfg.numCandAggLvl16 = SearchSpace__nrofCandidates__aggregationLevel16_n0;
477    pdcchCfg.searchSpcType = SearchSpace__searchSpaceType_PR_common;
478    pdcchCfg.commSrchSpcDciFrmt = PDCCH_SERACH_SPACE_DCI_FORMAT;
479    pdcchCfg.searchSpcSib1 = PDCCH_SEARCH_SPACE_ID_SIB1;
480    pdcchCfg.pagingSearchSpc = PDCCH_SEARCH_SPACE_ID_PAGING;
481    pdcchCfg.raSearchSpc = PDCCH_SEARCH_SPACE_ID_PAGING;
482    srvCellCfgComm->dlCfg.pdcchCfg = pdcchCfg;
483
484    /* Configuring PDSCH Config Common For SIB1 */
485    pdschCfg.present = BWP_DownlinkCommon__pdsch_ConfigCommon_PR_setup;
486    pdschCfg.numTimeDomRsrcAlloc = 2;
487    pdschCfg.timeDomAlloc[0].k0 = PDSCH_K0_CFG1;
488    pdschCfg.timeDomAlloc[0].mapType = \
489       PDSCH_TimeDomainResourceAllocation__mappingType_typeA;
490    pdschCfg.timeDomAlloc[0].sliv = calcSliv(PDSCH_START_SYMBOL,PDSCH_LENGTH_SYMBOL);
491    pdschCfg.timeDomAlloc[1].k0 = PDSCH_K0_CFG2;
492    pdschCfg.timeDomAlloc[1].mapType = \
493       PDSCH_TimeDomainResourceAllocation__mappingType_typeA;
494    pdschCfg.timeDomAlloc[1].sliv = calcSliv(PDSCH_START_SYMBOL,PDSCH_LENGTH_SYMBOL);
495
496    srvCellCfgComm->dlCfg.pdschCfg = pdschCfg;
497
498    /* Configuring BCCH Config for SIB1 */
499    srvCellCfgComm->dlCfg.bcchCfg.modPrdCoeff = \
500       BCCH_Config__modificationPeriodCoeff_n16;
501
502    /* Configuring PCCH Config for SIB1 */
503    pcchCfg.dfltPagingCycle = PagingCycle_rf256;
504    pcchCfg.nAndPagingFrmOffPresent = PCCH_Config__nAndPagingFrameOffset_PR_oneT;
505    pcchCfg.numPagingOcc = PCCH_Config__ns_four;
506    srvCellCfgComm->dlCfg.pcchCfg = pcchCfg;
507
508
509    /* Configuring UL Config Common */
510    srvCellCfgComm->ulCfg.ulScsCarrier.scsOffset = SSB_SUBCARRIER_OFFSET;
511 #ifdef NR_TDD
512    srvCellCfgComm->ulCfg.ulScsCarrier.scs = SCS_30KHZ;
513    srvCellCfgComm->ulCfg.ulScsCarrier.scsBw = BANDWIDTH_100MHZ;
514 #else
515    srvCellCfgComm->ulCfg.ulScsCarrier.scs = SCS_15KHZ;
516    srvCellCfgComm->ulCfg.ulScsCarrier.scsBw = BANDWIDTH_20MHZ;
517 #endif
518    srvCellCfgComm->ulCfg.pMax = UL_P_MAX;
519    srvCellCfgComm->ulCfg.locAndBw = FREQ_LOC_BW;
520    srvCellCfgComm->ulCfg.timeAlignTimerComm = TimeAlignmentTimer_infinity;
521
522    /* Configuring RACH Config Common for SIB1 */
523    rachCfg.present = BWP_UplinkCommon__rach_ConfigCommon_PR_setup;
524    rachCfg.prachCfgIdx = PRACH_CONFIG_IDX;
525    rachCfg.msg1Fdm = RACH_ConfigGeneric__msg1_FDM_one;
526    rachCfg.msg1FreqStart = PRACH_FREQ_START;
527    rachCfg.zeroCorrZoneCfg = ZERO_CORRELATION_ZONE_CFG;
528    rachCfg.preambleRcvdTgtPwr = PRACH_PREAMBLE_RCVD_TGT_PWR;
529    rachCfg.preambleTransMax = RACH_ConfigGeneric__preambleTransMax_n200;
530    rachCfg.pwrRampingStep = RACH_ConfigGeneric__powerRampingStep_dB2;
531    rachCfg.raRspWindow = RACH_ConfigGeneric__ra_ResponseWindow_sl20;
532    rachCfg.numRaPreamble = NUM_RA_PREAMBLE;
533    rachCfg.ssbPerRachOccPresent = \
534       RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_one;
535    rachCfg.numSsbPerRachOcc = SSB_PER_RACH;
536    rachCfg.contResTimer = RACH_ConfigCommon__ra_ContentionResolutionTimer_sf64;
537    rachCfg.rsrpThreshSsb = RSRP_THRESHOLD_SSB;
538    rachCfg.rootSeqIdxPresent = RACH_ConfigCommon__prach_RootSequenceIndex_PR_l139;
539    rachCfg.rootSeqIdx = ROOT_SEQ_IDX;
540    rachCfg.msg1Scs = PRACH_SUBCARRIER_SPACING ;
541    rachCfg.restrictedSetCfg = PRACH_RESTRICTED_SET_CFG;
542    srvCellCfgComm->ulCfg.rachCfg = rachCfg;
543
544    /* Configuring PUSCH Config Common for SIB1 */
545    puschCfg.puschCfgPresent = BWP_UplinkCommon__pusch_ConfigCommon_PR_setup;
546    puschCfg.numTimeDomRsrcAlloc = 2;
547    puschCfg.timeDomAllocList[0].k2 = PUSCH_K2_CFG1;
548    puschCfg.timeDomAllocList[0].mapType = PUSCH_TimeDomainResourceAllocation__mappingType_typeA;
549    puschCfg.timeDomAllocList[0].sliv = calcSliv(PUSCH_START_SYMBOL,PUSCH_LENGTH_SYMBOL);
550    puschCfg.timeDomAllocList[1].k2 = PUSCH_K2_CFG2;
551    puschCfg.timeDomAllocList[1].mapType = PUSCH_TimeDomainResourceAllocation__mappingType_typeA;
552    puschCfg.timeDomAllocList[1].sliv = calcSliv(PUSCH_START_SYMBOL,PUSCH_LENGTH_SYMBOL);
553    puschCfg.msg3DeltaPreamble = PUSCH_MSG3_DELTA_PREAMBLE;
554    puschCfg.p0NominalWithGrant = PUSCH_P0_NOMINAL_WITH_GRANT;
555    srvCellCfgComm->ulCfg.puschCfg = puschCfg;
556
557    /* Configuring PUCCH Config Common for SIB1 */
558    pucchCfg.present = BWP_UplinkCommon__pucch_ConfigCommon_PR_setup;
559    pucchCfg.rsrcComm = PUCCH_RSRC_COMMON;
560    pucchCfg.grpHop = PUCCH_ConfigCommon__pucch_GroupHopping_neither;
561    pucchCfg.p0Nominal = PUCCH_P0_NOMINAL;
562    srvCellCfgComm->ulCfg.pucchCfg = pucchCfg;
563
564    /* Configuring TDD UL DL config common */
565    tddCfg.refScs = SubcarrierSpacing_kHz30;
566    tddCfg.txPrd = TDD_UL_DL_Pattern__dl_UL_TransmissionPeriodicity_ms5;
567    tddCfg.numDlSlots = NUM_DL_SLOTS;
568    tddCfg.numDlSymbols = NUM_DL_SYMBOLS;
569    tddCfg.numUlSlots = NUM_UL_SLOTS;
570    tddCfg.numUlSymbols = NUM_UL_SYMBOLS;
571    srvCellCfgComm->tddCfg = tddCfg;
572
573    srvCellCfgComm->ssbPosInBurst = 192;
574    srvCellCfgComm->ssbPrdServingCell = SSB_PERIODICITY_20MS;
575    srvCellCfgComm->ssPbchBlockPwr = SSB_PBCH_PWR;
576
577    return ROK;
578 }
579
580 /*******************************************************************
581  *
582  * @brief Configures the DU Parameters
583  *
584  * @details
585  *
586  *    Function : readCfg
587  *
588  *    Functionality:
589  *       - Initializes the DuCfg members.  
590  *       - Calls readMacCfg()  
591  *
592  * @params[in] system task ID
593  * @return ROK     - success
594  *         RFAILED - failure
595  *
596  * ****************************************************************/
597
598 uint8_t readCfg()
599 {
600    uint8_t srvdCellIdx, bandIdx, sliceIdx, plmnIdx;
601    uint8_t brdcstPlmnIdx, freqBandIdx, srvdPlmnIdx;
602    uint32_t ipv4_du, ipv4_cu, ipv4_ric;
603    MibParams mib;
604    Sib1Params sib1;
605    F1TaiSliceSuppLst *taiSliceSuppLst;
606    RrmPolicy  *rrmPolicy;
607
608    /* TODO Added these below variable for local testing, once we will receive the
609     * configuration from O1 we can remove these variable */
610    F1Snsaai snsaai[NUM_OF_SUPPORTED_SLICE] = {{1,{2,3,4}},{5,{6,7,8}}};
611    ResourceType rsrcType = PRB;
612    RrmPolicyRatio policyRatio= {10,20,30};
613    PolicyMemberList memberList;
614    
615    memset(&memberList, 0, sizeof(PolicyMemberList));
616    memberList.snsaai =  snsaai[DEDICATED_SLICE_INDEX];
617
618 #ifdef O1_ENABLE
619    if( getStartupConfig(&g_cfg) != ROK )
620    {
621       RETVALUE(RFAILED);
622    }
623    cmInetAddr((S8*)g_cfg.DU_IPV4_Addr, &ipv4_du);
624    cmInetAddr((S8*)g_cfg.CU_IPV4_Addr, &ipv4_cu);
625    cmInetAddr((S8*)g_cfg.RIC_IPV4_Addr, &ipv4_ric);
626
627    duCfgParam.sctpParams.cuPort = g_cfg.CU_Port;
628    duCfgParam.sctpParams.ricPort = g_cfg.RIC_Port;
629 #else   
630    cmInetAddr((S8*)DU_IP_V4_ADDR, &ipv4_du);
631    cmInetAddr((S8*)CU_IP_V4_ADDR, &ipv4_cu);
632    cmInetAddr((S8*)RIC_IP_V4_ADDR, &ipv4_ric);
633
634    duCfgParam.sctpParams.cuPort = CU_PORT;
635    duCfgParam.sctpParams.ricPort = RIC_PORT;
636 #endif
637
638    fillDuPort(duCfgParam.sctpParams.duPort);
639
640    /* F1 DU IP Address and Port*/
641    duCfgParam.sctpParams.duIpAddr.ipV4Addr = ipv4_du;
642
643    /* F1 CU IP Address and Port*/
644    duCfgParam.sctpParams.cuIpAddr.ipV4Addr = ipv4_cu;
645
646    /* Fill RIC Params */
647    duCfgParam.sctpParams.ricIpAddr.ipV4Addr = ipv4_ric;
648
649    /* EGTP Parameters */
650    duCfgParam.egtpParams.localIp.ipV4Pres = TRUE;
651    duCfgParam.egtpParams.localIp.ipV4Addr = ipv4_du;
652    duCfgParam.egtpParams.localPort = DU_EGTP_PORT;
653    duCfgParam.egtpParams.destIp.ipV4Pres = TRUE;
654    duCfgParam.egtpParams.destIp.ipV4Addr = ipv4_cu;
655    duCfgParam.egtpParams.destPort = CU_EGTP_PORT;
656    duCfgParam.egtpParams.minTunnelId = MIN_TEID;
657    duCfgParam.egtpParams.maxTunnelId = MAX_TEID;
658
659    duCfgParam.maxUe = 32; //TODO: Check
660    /* DU Info */        
661    duCfgParam.duId = DU_ID;     
662    strcpy((char*)duCfgParam.duName,DU_NAME);
663
664    /* Mib Params */
665    mib.sysFrmNum = SYS_FRAME_NUM;
666 #ifdef NR_TDD
667    mib.subCarrierSpacingCommon = MIB__subCarrierSpacingCommon_scs30or120;
668 #else
669    mib.subCarrierSpacingCommon = MIB__subCarrierSpacingCommon_scs15or60;
670 #endif
671    mib.ssb_SubcarrierOffset = SSB_SC_OFFSET; //Kssb
672    mib.dmrs_TypeA_Position = MIB__dmrs_TypeA_Position_pos2;
673    mib.controlResourceSetZero = CORESET_0_INDEX;
674    mib.searchSpaceZero = SEARCHSPACE_0_INDEX;
675    mib.cellBarred = MIB__cellBarred_notBarred;
676    mib.intraFreqReselection =
677       MIB__intraFreqReselection_notAllowed;
678    duCfgParam.mibParams = mib;
679
680    /* SIB1 Params */
681    memset(&sib1.plmn, 0, sizeof(Plmn));
682    sib1.plmn.mcc[0] = PLMN_MCC0;
683    sib1.plmn.mcc[1] = PLMN_MCC1;
684    sib1.plmn.mcc[2] = PLMN_MCC2;
685    sib1.plmn.mnc[0] = PLMN_MNC0;
686    sib1.plmn.mnc[1] = PLMN_MNC1;
687    sib1.tac = DU_TAC;
688    sib1.ranac = DU_RANAC;
689    sib1.cellIdentity = CELL_IDENTITY;
690    sib1.cellResvdForOpUse = PLMN_IdentityInfo__cellReservedForOperatorUse_notReserved;
691    sib1.connEstFailCnt = ConnEstFailureControl__connEstFailCount_n3;
692    sib1.connEstFailOffValidity = ConnEstFailureControl__connEstFailOffsetValidity_s120;
693    sib1.siSchedInfo.winLen = SI_SchedulingInfo__si_WindowLength_s5;
694    sib1.siSchedInfo.broadcastSta = SchedulingInfo__si_BroadcastStatus_broadcasting;
695    sib1.siSchedInfo.preiodicity = SchedulingInfo__si_Periodicity_rf8;
696    sib1.siSchedInfo.sibType = SIB_TypeInfo__type_sibType2;
697    sib1.siSchedInfo.sibValTag = SIB1_VALUE_TAG;
698
699    fillServCellCfgCommSib(&sib1.srvCellCfgCommSib);
700
701    duCfgParam.sib1Params = sib1;
702
703    for(srvdCellIdx=0; srvdCellIdx<DEFAULT_CELLS; srvdCellIdx++)
704    { 
705       memset(&duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.nrCgi.plmn, 0, sizeof(Plmn));
706       duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.nrCgi.plmn.mcc[0] = PLMN_MCC0;
707       duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.nrCgi.plmn.mcc[1] = PLMN_MCC1;
708       duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.nrCgi.plmn.mcc[2] = PLMN_MCC2;
709       duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.nrCgi.plmn.mnc[0] = PLMN_MNC0;
710       duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.nrCgi.plmn.mnc[1] = PLMN_MNC1;
711
712       /*Cell ID */
713       duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.nrCgi.cellId = NR_CELL_ID;
714       duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.nrPci = NR_PCI;
715
716       /* List of Available PLMN */
717       for(srvdPlmnIdx=0; srvdPlmnIdx<MAX_PLMN; srvdPlmnIdx++)
718       {
719          /* As per spec 38.473, Plmn identity consists of 3 digit from mcc
720           * followed by either 2 digit or 3 digits of mnc */ 
721
722          memset(&duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].plmn, 0,\
723          sizeof(Plmn));
724          duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].plmn.mcc[0] = PLMN_MCC0;
725          duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].plmn.mcc[1] = PLMN_MCC1;
726          duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].plmn.mcc[2] = PLMN_MCC2;
727          duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].plmn.mnc[0] = PLMN_MNC0;
728          duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].plmn.mnc[1] = PLMN_MNC1;
729       }
730       /* List of Extended PLMN */
731       for(srvdPlmnIdx=0; srvdPlmnIdx<MAX_PLMN; srvdPlmnIdx++)
732       {
733          /* As per spec 38.473, Plmn identity consists of 3 digit from mcc
734           * followed by either 2 digit or 3 digits of mnc */ 
735
736          memset(&duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].extPlmn, 0, sizeof(Plmn));
737          duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].extPlmn.mcc[0] = PLMN_MCC0;
738          duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].extPlmn.mcc[1] = PLMN_MCC1;
739          duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].extPlmn.mcc[2] = PLMN_MCC2;
740          duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].extPlmn.mnc[0] = PLMN_MNC0;
741          duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].extPlmn.mnc[1] = PLMN_MNC1;
742       } 
743       /* List of Supporting Slices */
744       for(srvdPlmnIdx=0; srvdPlmnIdx<MAX_PLMN; srvdPlmnIdx++)
745       {
746          taiSliceSuppLst = &duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].taiSliceSuppLst;
747
748          taiSliceSuppLst->pres = true;
749          taiSliceSuppLst->numSupportedSlices = NUM_OF_SUPPORTED_SLICE;
750
751          memset(&taiSliceSuppLst->snssai, 0, sizeof(F1Snsaai));
752          for(sliceIdx=0; sliceIdx<NUM_OF_SUPPORTED_SLICE; sliceIdx++)
753          {
754             DU_ALLOC(taiSliceSuppLst->snssai[sliceIdx], sizeof(F1Snsaai));
755             if(taiSliceSuppLst->snssai[sliceIdx] == NULLP)
756             {
757                DU_LOG("\nERROR --> DU_APP: readCfg():Memory allocation failed");
758                return RFAILED;
759             }
760             memcpy(taiSliceSuppLst->snssai[sliceIdx], &snsaai[sliceIdx], sizeof(F1Snsaai));
761             
762             /* Checking rrmPolicy Slice list available or not */
763             if(!memcmp(&snsaai[sliceIdx], &memberList.snsaai, sizeof(F1Snsaai)))
764             {
765                rrmPolicy = &duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].rrmPolicy;
766                rrmPolicy->present = true;
767                rrmPolicy->rsrcType = rsrcType; 
768                rrmPolicy->memberList.snsaai = memberList.snsaai;
769                rrmPolicy->rrmPolicyRatio = policyRatio;
770             }
771          }
772       }
773       /* TAC and EPSTAC */
774       duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.tac = DU_TAC;
775       duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.epsTac = DU_TAC; //to check and fill
776       /* NR Mode info */
777       duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.nrArfcn = NR_UL_ARFCN;
778       duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.sulInfo.sulArfcn = SUL_ARFCN;
779       duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.sulInfo.sulTxBw.nrScs = SCS_15;
780       duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.sulInfo.sulTxBw.nrb = NRB_106;
781
782 #if 0
783       /* NR Mode info */
784       duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.nrArfcn = NR_ARFCN;
785       duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.sulInfo.sulArfcn = SUL_ARFCN;
786       duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.sulInfo.sulTxBw.nrScs = SCS_15;                 
787       duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.sulInfo.sulTxBw.nrb = NRB_106;         
788
789       for(freqBandIdx=0; freqBandIdx<MAX_NRCELL_BANDS; freqBandIdx++)
790       {
791          duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.freqBand[freqBandIdx].nrFreqBand =\
792          NR_FREQ_BAND;
793          for(bandIdx=0; bandIdx<MAX_NRCELL_BANDS; bandIdx++)
794          {
795             duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.freqBand[freqBandIdx].sulBand[bandIdx]\
796             = SUL_BAND;         
797          }
798       }
799 #endif
800       for(freqBandIdx=0; freqBandIdx<MAX_NRCELL_BANDS; freqBandIdx++)
801       {
802          duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.freqBand[freqBandIdx].\
803          nrFreqBand = NR_FREQ_BAND;
804          for(bandIdx=0; bandIdx<MAX_NRCELL_BANDS; bandIdx++)
805          {
806             duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.freqBand[freqBandIdx].\
807             sulBand[bandIdx] = SUL_BAND;
808          }
809       }
810       duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.nrArfcn = NR_DL_ARFCN;
811       duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.sulInfo.sulArfcn = SUL_ARFCN;
812       duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.sulInfo.sulTxBw.nrScs = SCS_15;
813       duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.sulInfo.sulTxBw.nrb = NRB_106;
814       for(freqBandIdx=0; freqBandIdx<MAX_NRCELL_BANDS; freqBandIdx++)
815       {
816          duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.freqBand[freqBandIdx].\
817          nrFreqBand = NR_FREQ_BAND;
818          for(bandIdx=0; bandIdx<MAX_NRCELL_BANDS; bandIdx++)
819          {
820             duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.freqBand[freqBandIdx].\
821             sulBand[bandIdx] = SUL_BAND;
822          }
823       }
824
825       duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.ulTxBw.nrScs = SCS_15;
826       duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.ulTxBw.nrb = NRB_106;
827
828       duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.dlTxBw.nrScs = SCS_15;
829       duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.dlTxBw.nrb = NRB_106;
830
831       /*Measurement Config and Cell Config */ 
832       duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.measTimeCfg = TIME_CFG; 
833
834       duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellDir = DL_UL; 
835
836       duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellType=CELL_TYPE;
837
838       /* Broadcast PLMN Identity */
839       for(brdcstPlmnIdx=0; brdcstPlmnIdx<MAX_BPLMN_NRCELL_MINUS_1; brdcstPlmnIdx++)
840       { 
841          for(plmnIdx=0; plmnIdx<MAX_PLMN; plmnIdx++)
842          {
843             memset(&duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].plmn[plmnIdx],\
844             0, sizeof(Plmn));
845             duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].plmn[plmnIdx].mcc[0] =\
846             PLMN_MCC0;
847             duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].plmn[plmnIdx].mcc[1] =\
848             PLMN_MCC1;
849             duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].plmn[plmnIdx].mcc[2] =\
850             PLMN_MCC2;
851             duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].plmn[plmnIdx].mnc[0] =\
852             PLMN_MNC0;
853             duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].plmn[plmnIdx].mnc[1] =\
854             PLMN_MNC1;
855          }
856          /* Extended PLMN List */        
857          for(plmnIdx=0; plmnIdx<MAX_PLMN; plmnIdx++)
858          {
859             memset(&duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].\
860             extPlmn[plmnIdx], 0, sizeof(Plmn));
861             duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].\
862             extPlmn[plmnIdx].mcc[0] = PLMN_MCC0;
863             duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].\
864             extPlmn[plmnIdx].mcc[1] = PLMN_MCC1;
865             duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].\
866             extPlmn[plmnIdx].mcc[2] = PLMN_MCC2;
867             duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].\
868             extPlmn[plmnIdx].mnc[0] = PLMN_MNC0;
869             duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].\
870             extPlmn[plmnIdx].mnc[1] = PLMN_MNC1;
871          }
872
873          duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].tac = DU_TAC;
874          duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].nrCellId = NR_CELL_ID;
875          duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].ranac = NR_RANAC;
876       }
877
878       /*gnb DU System Info mib msg*/
879       BuildMibMsg();
880       DU_ALLOC(duCfgParam.srvdCellLst[srvdCellIdx].duSysInfo.mibMsg, encBufSize);
881       if(!(duCfgParam.srvdCellLst[srvdCellIdx].duSysInfo.mibMsg))
882       {
883          DU_LOG("\nERROR  -->  DU APP : Memory allocation failure at readCfg");
884          return RFAILED;
885       }
886       memcpy(duCfgParam.srvdCellLst[srvdCellIdx].duSysInfo.mibMsg, encBuf, encBufSize);
887       duCfgParam.srvdCellLst[srvdCellIdx].duSysInfo.mibLen = encBufSize;
888
889       /*gnb DU System Info mib msg*/
890       BuildSib1Msg();
891       DU_ALLOC(duCfgParam.srvdCellLst[srvdCellIdx].duSysInfo.sib1Msg,\
892             encBufSize);
893       if(!(duCfgParam.srvdCellLst[srvdCellIdx].duSysInfo.sib1Msg))
894       {
895          DU_LOG("\nERROR  -->  DU APP : Memory allocation failure at readCfg");
896          return RFAILED;
897       }
898       memcpy(duCfgParam.srvdCellLst[srvdCellIdx].duSysInfo.sib1Msg,\
899             encBuf,encBufSize);
900       duCfgParam.srvdCellLst[srvdCellIdx].duSysInfo.sib1Len = encBufSize;
901
902    }
903
904    if(readMacCfg() != ROK)
905    {
906       DU_LOG("\nERROR  -->  DU_APP : Failed while reading MAC config");
907       return RFAILED;
908    }
909
910    return ROK;
911 }
912
913 /*******************************************************************
914  *
915  * @brief Reads config and posts message to du_app on completion
916  *
917  * @details
918  *
919  *    Function : main
920  *
921  *    Functionality:
922  *      - Calls readCfg()
923  *      - Post to du_app for further processing
924  *
925  * @params[in] void
926  * @return ROK     - success
927  *         RFAILED - failure
928  *
929  * ****************************************************************/
930 uint8_t duReadCfg()
931 {
932    Pst pst;
933    Buffer *mBuf;
934
935    memset(&duCfgParam, 0, sizeof(DuCfgParams));
936
937    //Read configs into duCfgParams
938    if(readCfg() != ROK)
939    {
940       DU_LOG("\nERROR  -->  DU_APP : Reading configuration failed");
941       return RFAILED;
942    }
943
944    //Fill pst structure
945    memset(&(pst), 0, sizeof(Pst));
946    pst.srcEnt = (Ent)ENTDUAPP;
947    pst.srcInst = (Inst)DU_INST;
948    pst.srcProcId = DU_PROC;
949    pst.dstEnt = pst.srcEnt;
950    pst.dstInst = pst.srcInst;
951    pst.dstProcId = pst.srcProcId;
952    pst.event = EVTCFG;
953    pst.selector = ODU_SELECTOR_TC;
954    pst.pool= DU_POOL;
955
956
957    if(ODU_GET_MSG_BUF(DFLT_REGION, DU_POOL, &mBuf) != ROK)
958    {
959       DU_LOG("\nERROR  -->  DU_APP : Memory allocation failed in duReadCfg");
960       return RFAILED;
961    }
962
963    if (ODU_POST_TASK(&pst, mBuf) != ROK)
964    {
965       DU_LOG("\nERROR  -->  DU_APP : ODU_POST_TASK failed in duReadCfg");
966       return RFAILED;
967    }
968
969    return ROK;
970 }
971
972 /**********************************************************************
973   End of file
974  **********************************************************************/
975