1 /*******************************************************************************
2 ################################################################################
3 # Copyright (c) [2017-2019] [Radisys] #
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 #
9 # http://www.apache.org/licenses/LICENSE-2.0 #
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 *******************************************************************************/
19 /* This file contains all utility functions */
20 #include "common_def.h"
25 #include "du_app_mac_inf.h"
26 #include "du_app_rlc_inf.h"
30 #include "OCTET_STRING.h"
31 #include "BIT_STRING.h"
32 #include "odu_common_codec.h"
33 #include "du_sys_info_hdl.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"
56 #include "CmInterface.h"
57 extern StartupConfig g_cfg;
58 extern NRCellDU cellParams;
61 char encBuf[ENC_BUF_MAX_LEN];
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
79 /*******************************************************************
81 * @brief Fills the Slot configuration
85 * Function : FillSlotConfig
87 * Functionality:Fill the Slot configuration values
90 * @return ROK - success
93 * ****************************************************************/
99 memset(duCfgParam.macCellCfg.tddCfg.slotCfg, 0, sizeof(duCfgParam.macCellCfg.tddCfg.slotCfg[slot][symbol]* \
100 MAX_TDD_PERIODICITY_SLOTS*MAX_SYMB_PER_SLOT));
102 //Filling the DL Slots and initializing flexi slot
103 for(slot = 0; slot <= NUM_DL_SLOTS; slot++)
105 for(symbol =0; symbol < MAX_SYMB_PER_SLOT; symbol++)
107 duCfgParam.macCellCfg.tddCfg.slotCfg[slot][symbol] = DL_SLOT;
112 for(slot = NUM_DL_SLOTS+1; slot <= NUM_DL_SLOTS+NUM_UL_SLOTS; slot++)
114 for(symbol = 0; symbol < MAX_SYMB_PER_SLOT; symbol++)
115 duCfgParam.macCellCfg.tddCfg.slotCfg[slot][symbol] = UL_SLOT;
117 //Updating Flexi Slot
119 duCfgParam.macCellCfg.tddCfg.slotCfg[slot][12] = FLEXI_SLOT;
120 duCfgParam.macCellCfg.tddCfg.slotCfg[slot][13] = UL_SLOT;
125 /*******************************************************************
126 * @brief Reads the CL Configuration.
130 * Function : readMacCfg
133 * - Fills up the cell configuration for CL.
134 * - Calls FillSlotConfig()
137 * @return ROK - success
140 * ****************************************************************/
144 uint8_t idx=0, sliceIdx=0;
145 F1TaiSliceSuppLst *taiSliceSuppLst;
147 duCfgParam.macCellCfg.carrierId = CARRIER_IDX;
149 /* Cell configuration */
150 duCfgParam.macCellCfg.numerology = NR_NUMEROLOGY;
151 duCfgParam.macCellCfg.dupType = DUPLEX_MODE;
153 /* DL carrier configuration */
154 duCfgParam.macCellCfg.dlCarrCfg.pres = TRUE;
156 duCfgParam.macCellCfg.cellId = cellParams.cellLocalId;
157 duCfgParam.macCellCfg.phyCellId = cellParams.nRPCI;
158 duCfgParam.macCellCfg.dlCarrCfg.bw = cellParams.bSChannelBwUL;
159 duCfgParam.macCellCfg.dlCarrCfg.freq = cellParams.bSChannelBwDL;
161 duCfgParam.macCellCfg.cellId = NR_CELL_ID;
162 duCfgParam.macCellCfg.phyCellId = NR_PCI;
163 duCfgParam.macCellCfg.dlCarrCfg.bw = NR_BANDWIDTH;
164 duCfgParam.macCellCfg.dlCarrCfg.freq = NR_DL_ARFCN;
167 duCfgParam.macCellCfg.dlCarrCfg.k0[0] = 1;
168 duCfgParam.macCellCfg.dlCarrCfg.k0[1] = 1;
169 duCfgParam.macCellCfg.dlCarrCfg.k0[2] = 1;
170 duCfgParam.macCellCfg.dlCarrCfg.k0[3] = 1;
171 duCfgParam.macCellCfg.dlCarrCfg.k0[4] = 1;
172 duCfgParam.macCellCfg.dlCarrCfg.gridSize[0] = 273;
173 duCfgParam.macCellCfg.dlCarrCfg.gridSize[1] = 1;
174 duCfgParam.macCellCfg.dlCarrCfg.gridSize[2] = 1;
175 duCfgParam.macCellCfg.dlCarrCfg.gridSize[3] = 1;
176 duCfgParam.macCellCfg.dlCarrCfg.gridSize[4] = 1;
177 duCfgParam.macCellCfg.dlCarrCfg.numAnt = NUM_TX_ANT;
179 /* UL Carrier configuration */
180 duCfgParam.macCellCfg.ulCarrCfg.pres = TRUE;
182 duCfgParam.macCellCfg.ulCarrCfg.bw = cellParams.bSChannelBwUL;
183 duCfgParam.macCellCfg.ulCarrCfg.freq = cellParams.bSChannelBwDL;
185 duCfgParam.macCellCfg.ulCarrCfg.bw = NR_BANDWIDTH;
186 duCfgParam.macCellCfg.ulCarrCfg.freq = NR_UL_ARFCN;
188 duCfgParam.macCellCfg.ulCarrCfg.k0[0] = 1;
189 duCfgParam.macCellCfg.ulCarrCfg.k0[1] = 1;
190 duCfgParam.macCellCfg.ulCarrCfg.k0[2] = 1;
191 duCfgParam.macCellCfg.ulCarrCfg.k0[3] = 1;
192 duCfgParam.macCellCfg.ulCarrCfg.k0[4] = 1;
193 duCfgParam.macCellCfg.ulCarrCfg.gridSize[0] = 1;
194 duCfgParam.macCellCfg.ulCarrCfg.gridSize[1] = 1;
195 duCfgParam.macCellCfg.ulCarrCfg.gridSize[2] = 1;
196 duCfgParam.macCellCfg.ulCarrCfg.gridSize[3] = 1;
197 duCfgParam.macCellCfg.ulCarrCfg.gridSize[4] = 1;
198 duCfgParam.macCellCfg.ulCarrCfg.numAnt = NUM_RX_ANT;
200 duCfgParam.macCellCfg.freqShft = FREQ_SHIFT_7P5KHZ;
202 /* SSB configuration */
203 duCfgParam.macCellCfg.ssbCfg.ssbPbchPwr = SSB_PBCH_PWR;
204 duCfgParam.macCellCfg.ssbCfg.bchPayloadFlag = BCH_PAYLOAD;
205 duCfgParam.macCellCfg.ssbCfg.ssbOffsetPointA = OFFSET_TO_POINT_A;
206 duCfgParam.macCellCfg.ssbCfg.betaPss = BETA_PSS;
208 duCfgParam.macCellCfg.ssbCfg.scsCmn = convertScsValToScsEnum(cellParams.ssbSubCarrierSpacing);
209 duCfgParam.macCellCfg.ssbCfg.ssbPeriod = convertScsPeriodicityToEnum(cellParams.ssbPeriodicity);
210 duCfgParam.macCellCfg.ssbCfg.ssbScOffset = cellParams.ssbOffset;
212 duCfgParam.macCellCfg.ssbCfg.scsCmn = NR_SCS;
213 duCfgParam.macCellCfg.ssbCfg.ssbPeriod = SSB_PRDCTY_MS_20;
214 duCfgParam.macCellCfg.ssbCfg.ssbScOffset = SSB_SUBCARRIER_OFFSET;
216 duCfgParam.macCellCfg.ssbCfg.ssbMask[0] = 1; /* only one SSB is transmitted */
217 duCfgParam.macCellCfg.ssbCfg.ssbMask[1] = 0;
218 if(BuildMibPdu() != ROK)
220 DU_LOG("\nERROR --> Failed to build MIB PDU");
221 memset(&duCfgParam.macCellCfg.ssbCfg.mibPdu, 0, 3*sizeof(uint8_t));
225 memcpy(&duCfgParam.macCellCfg.ssbCfg.mibPdu, encBuf,encBufSize);
227 duCfgParam.macCellCfg.ssbCfg.multCarrBand = SSB_MULT_CARRIER_BAND;
228 duCfgParam.macCellCfg.ssbCfg.multCellCarr = MULT_CELL_CARRIER;
230 /* PRACH configuration */
231 duCfgParam.macCellCfg.prachCfg.pres = TRUE;
232 duCfgParam.macCellCfg.prachCfg.prachCfgIdx = PRACH_CONFIG_IDX;
233 duCfgParam.macCellCfg.prachCfg.prachSeqLen = PRACH_SEQ_LEN;
234 duCfgParam.macCellCfg.prachCfg.prachSubcSpacing = convertScsEnumValToScsVal(PRACH_SUBCARRIER_SPACING);
235 duCfgParam.macCellCfg.prachCfg.prachRstSetCfg = PRACH_RESTRICTED_SET_CFG;
236 duCfgParam.macCellCfg.prachCfg.msg1Fdm = NUM_PRACH_FDM;
237 duCfgParam.macCellCfg.prachCfg.msg1FreqStart = PRACH_FREQ_START;
238 duCfgParam.macCellCfg.prachCfg.rootSeqLen = ROOT_SEQ_LEN;
239 duCfgParam.macCellCfg.prachCfg.fdm[0].rootSeqIdx = ROOT_SEQ_IDX;
240 duCfgParam.macCellCfg.prachCfg.fdm[0].numRootSeq = NUM_ROOT_SEQ;
241 duCfgParam.macCellCfg.prachCfg.fdm[0].k1 = 0;
242 duCfgParam.macCellCfg.prachCfg.fdm[0].zeroCorrZoneCfg = ZERO_CORRELATION_ZONE_CFG;
243 duCfgParam.macCellCfg.prachCfg.fdm[0].numUnusedRootSeq = NUM_UNUSED_ROOT_SEQ;
244 if(duCfgParam.macCellCfg.prachCfg.fdm[0].numUnusedRootSeq != 0)
246 DU_ALLOC_SHRABL_BUF(duCfgParam.macCellCfg.prachCfg.fdm[0].unsuedRootSeq,
247 NUM_UNUSED_ROOT_SEQ * sizeof(uint8_t));
248 if(duCfgParam.macCellCfg.prachCfg.fdm[0].unsuedRootSeq == NULLP)
250 DU_LOG("\nERROR --> DU_APP : Memory allocation failed at readMacCfg");
253 *(duCfgParam.macCellCfg.prachCfg.fdm[0].unsuedRootSeq) = UNUSED_ROOT_SEQ;
255 duCfgParam.macCellCfg.prachCfg.ssbPerRach = SSB_PER_RACH;
256 duCfgParam.macCellCfg.prachCfg.prachMultCarrBand = PRACH_MULT_CARRIER_BAND;
257 duCfgParam.macCellCfg.prachCfg.raContResTmr = RA_CONT_RES_TIMER;
258 duCfgParam.macCellCfg.prachCfg.rsrpThreshSsb = RSRP_THRESHOLD_SSB;
259 duCfgParam.macCellCfg.prachCfg.raRspWindow = RA_RSP_WINDOW;
260 duCfgParam.macCellCfg.prachCfg.prachRestrictedSet = PRACH_RESTRICTED_SET;
262 /* TDD configuration */
263 duCfgParam.macCellCfg.tddCfg.pres = TRUE;
264 duCfgParam.macCellCfg.tddCfg.tddPeriod = TDD_PERIODICITY;
269 /* RSSI Measurement configuration */
270 duCfgParam.macCellCfg.rssiUnit = RSS_MEASUREMENT_UNIT;
272 /* fill SIB1 configuration */
273 duCfgParam.macCellCfg.sib1Cfg.sib1PduLen = duCfgParam.srvdCellLst[0].duSysInfo.sib1Len;
274 DU_ALLOC_SHRABL_BUF(duCfgParam.macCellCfg.sib1Cfg.sib1Pdu,duCfgParam.srvdCellLst[0].duSysInfo.sib1Len);
275 memcpy(duCfgParam.macCellCfg.sib1Cfg.sib1Pdu, duCfgParam.srvdCellLst[0].duSysInfo.sib1Msg, \
276 duCfgParam.srvdCellLst[0].duSysInfo.sib1Len);
277 duCfgParam.macCellCfg.sib1Cfg.sib1RepetitionPeriod = SIB1_REPETITION_PERIOD;
278 duCfgParam.macCellCfg.sib1Cfg.coresetZeroIndex = CORESET_0_INDEX;
279 duCfgParam.macCellCfg.sib1Cfg.searchSpaceZeroIndex = SEARCHSPACE_0_INDEX;
280 duCfgParam.macCellCfg.sib1Cfg.sib1Mcs = DEFAULT_MCS;
283 /* fill Intial DL BWP */
284 duCfgParam.macCellCfg.initialDlBwp.bwp.firstPrb = 0;
285 duCfgParam.macCellCfg.initialDlBwp.bwp.numPrb = TOTAL_PRB_20MHZ_MU0; /* configured to total BW */
286 duCfgParam.macCellCfg.initialDlBwp.bwp.scs = duCfgParam.macCellCfg.ssbCfg.scsCmn;
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;
306 duCfgParam.macCellCfg.initialDlBwp.pdschCommon.numTimeDomAlloc = 2;
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 =
313 duCfgParam.macCellCfg.initialDlBwp.pdschCommon.timeDomRsrcAllocList[idx].lengthSymbol =
317 duCfgParam.macCellCfg.initialDlBwp.pdschCommon.timeDomRsrcAllocList[idx].k0 = PDSCH_K0_CFG2;
318 duCfgParam.macCellCfg.initialDlBwp.pdschCommon.timeDomRsrcAllocList[idx].mappingType =
319 PDSCH_MAPPING_TYPE_A;
320 duCfgParam.macCellCfg.initialDlBwp.pdschCommon.timeDomRsrcAllocList[idx].startSymbol =
322 duCfgParam.macCellCfg.initialDlBwp.pdschCommon.timeDomRsrcAllocList[idx].lengthSymbol =
325 /* ra-searchSpace ID is set to 1 */
326 duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.raSearchSpaceId = SEARCHSPACE_1_INDEX;
328 /* fill Intial UL BWP */
329 duCfgParam.macCellCfg.initialUlBwp.bwp.firstPrb = 0;
330 duCfgParam.macCellCfg.initialUlBwp.bwp.numPrb = TOTAL_PRB_20MHZ_MU0; /* configured to total BW */
331 duCfgParam.macCellCfg.initialUlBwp.bwp.scs = duCfgParam.macCellCfg.ssbCfg.scsCmn;
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 =
339 duCfgParam.macCellCfg.initialUlBwp.puschCommon.timeDomRsrcAllocList[0].symbolLength =
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 =
347 duCfgParam.macCellCfg.initialUlBwp.puschCommon.timeDomRsrcAllocList[1].symbolLength =
350 duCfgParam.macCellCfg.dmrsTypeAPos = DMRS_TYPE_A_POS;
352 /* fill PUCCH config common */
353 duCfgParam.macCellCfg.initialUlBwp.pucchCommon.pucchResourceCommon = PUCCH_RSRC_COMMON;
354 duCfgParam.macCellCfg.initialUlBwp.pucchCommon.pucchGroupHopping = PUCCH_GROUP_HOPPING;
356 /* Plmn And SNSSAI Configuration */
357 memset(&duCfgParam.macCellCfg.plmnInfoList.plmn, &duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.srvdPlmn[0].plmn,\
359 taiSliceSuppLst = &duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.srvdPlmn[0].taiSliceSuppLst;
360 duCfgParam.macCellCfg.plmnInfoList.numSupportedSlice = taiSliceSuppLst->numSupportedSlices;
361 if(taiSliceSuppLst->snssai)
363 DU_ALLOC_SHRABL_BUF(duCfgParam.macCellCfg.plmnInfoList.snssai, (duCfgParam.macCellCfg.plmnInfoList.numSupportedSlice) * sizeof(Snssai*));
364 if(duCfgParam.macCellCfg.plmnInfoList.snssai == NULLP)
366 DU_LOG("\nERROR --> DU_APP: Memory allocation failed at readMacCfg");
370 for(sliceIdx=0; sliceIdx<taiSliceSuppLst->numSupportedSlices; sliceIdx++)
372 if(taiSliceSuppLst->snssai[sliceIdx] != NULLP)
374 DU_ALLOC_SHRABL_BUF(duCfgParam.macCellCfg.plmnInfoList.snssai[sliceIdx], sizeof(Snssai));
375 if(duCfgParam.macCellCfg.plmnInfoList.snssai[sliceIdx] == NULLP)
377 DU_LOG("\nERROR --> DU_APP: Memory allocation failed at readMacCfg");
380 memcpy(duCfgParam.macCellCfg.plmnInfoList.snssai[sliceIdx], taiSliceSuppLst->snssai[sliceIdx], sizeof(Snssai));
386 /*******************************************************************
388 * @brief Configures the DU Parameters
392 * Function : fillDuPort
395 * - fills the DU Ports.
397 * @params[in] duPort array to be filled
398 * @return ROK - success
401 * ****************************************************************/
402 uint8_t fillDuPort(uint16_t *duPort)
406 duPort[F1_INTERFACE] = g_cfg.DU_Port;
407 duPort[E2_INTERFACE] = g_cfg.RIC_Port;
409 duPort[F1_INTERFACE] = DU_PORT; /* DU Port idx 0 38472 */
410 duPort[E2_INTERFACE] = RIC_PORT; /* RIC Port idx 1 38482 */
415 /*******************************************************************
417 * @brief Configures the DU Parameters
421 * Function : calcSliv
424 * - calculate SLIV value from start and length field
426 * @params[in] start symbol
427 * @params[in] length of symbols
430 * ****************************************************************/
431 uint16_t calcSliv(uint8_t startSymbol, uint8_t lengthSymbol)
434 if((lengthSymbol-1) <= 7)
436 sliv = NUM_SYMBOLS_PER_SLOT * (lengthSymbol-1) + startSymbol;
440 sliv = NUM_SYMBOLS_PER_SLOT * (NUM_SYMBOLS_PER_SLOT - lengthSymbol + 1) \
441 + (NUM_SYMBOLS_PER_SLOT - 1 - startSymbol);
447 /*******************************************************************
449 * @brief Configures serving cell config common in sib1
453 * Function : fillServCellCfgCommSib
456 * - fills Serving cell config common for SIB1
458 * @params[in] SrvCellCfgCommSib pointer
459 * @return ROK - success
462 ** ****************************************************************/
463 uint8_t fillServCellCfgCommSib(SrvCellCfgCommSib *srvCellCfgComm)
465 PdcchCfgCommon pdcchCfg;
466 PdschCfgCommon pdschCfg;
468 RachCfgCommon rachCfg;
469 PuschCfgCommon puschCfg;
470 PucchCfgCommon pucchCfg;
471 TddUlDlCfgCommon tddCfg;
473 /* Configuring DL Config Common for SIB1*/
474 srvCellCfgComm->dlCfg.freqBandInd = NR_FREQ_BAND;
475 srvCellCfgComm->dlCfg.offsetToPointA = OFFSET_TO_POINT_A;
477 srvCellCfgComm->dlCfg.dlScsCarrier.scsOffset = cellParams.ssbOffset;
478 srvCellCfgComm->dlCfg.dlScsCarrier.scs = convertScsValToScsEnum(cellParams.ssbSubCarrierSpacing);
479 srvCellCfgComm->dlCfg.dlScsCarrier.scsBw = cellParams.bSChannelBwUL;
481 srvCellCfgComm->dlCfg.dlScsCarrier.scsOffset = SSB_SUBCARRIER_OFFSET;
482 srvCellCfgComm->dlCfg.dlScsCarrier.scs = NR_SCS;
483 srvCellCfgComm->dlCfg.dlScsCarrier.scsBw = NR_BANDWIDTH;
485 srvCellCfgComm->dlCfg.locAndBw = FREQ_LOC_BW;
487 /* Configuring PDCCH Config Common For SIB1 */
488 pdcchCfg.present = BWP_DownlinkCommon__pdcch_ConfigCommon_PR_setup;
489 pdcchCfg.ctrlRsrcSetZero = CORESET_0_INDEX;
490 pdcchCfg.searchSpcZero = SEARCHSPACE_0_INDEX;
491 pdcchCfg.searchSpcId = PDCCH_SEARCH_SPACE_ID;
492 pdcchCfg.ctrlRsrcSetId = PDCCH_CTRL_RSRC_SET_ID;
493 pdcchCfg.monitorSlotPrdAndOffPresent = \
495 SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl1;
496 //pdcchCfg.monitorSlotPrdAndOff = \
497 SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl1;
498 pdcchCfg.monitorSymbolsInSlot[0] = 128;
499 pdcchCfg.monitorSymbolsInSlot[1] = 0;
500 pdcchCfg.numCandAggLvl1 = SearchSpace__nrofCandidates__aggregationLevel1_n8;
501 pdcchCfg.numCandAggLvl2 = SearchSpace__nrofCandidates__aggregationLevel2_n4;
502 pdcchCfg.numCandAggLvl4 = SearchSpace__nrofCandidates__aggregationLevel4_n2;
503 pdcchCfg.numCandAggLvl8 = SearchSpace__nrofCandidates__aggregationLevel8_n1;
504 pdcchCfg.numCandAggLvl16 = SearchSpace__nrofCandidates__aggregationLevel16_n0;
505 pdcchCfg.searchSpcType = SearchSpace__searchSpaceType_PR_common;
506 pdcchCfg.commSrchSpcDciFrmt = PDCCH_SERACH_SPACE_DCI_FORMAT;
507 pdcchCfg.searchSpcSib1 = PDCCH_SEARCH_SPACE_ID_SIB1;
508 pdcchCfg.pagingSearchSpc = PDCCH_SEARCH_SPACE_ID_PAGING;
509 pdcchCfg.raSearchSpc = PDCCH_SEARCH_SPACE_ID_PAGING;
510 srvCellCfgComm->dlCfg.pdcchCfg = pdcchCfg;
512 /* Configuring PDSCH Config Common For SIB1 */
513 pdschCfg.present = BWP_DownlinkCommon__pdsch_ConfigCommon_PR_setup;
514 pdschCfg.numTimeDomRsrcAlloc = 2;
515 pdschCfg.timeDomAlloc[0].k0 = PDSCH_K0_CFG1;
516 pdschCfg.timeDomAlloc[0].mapType = \
517 PDSCH_TimeDomainResourceAllocation__mappingType_typeA;
518 pdschCfg.timeDomAlloc[0].sliv = calcSliv(PDSCH_START_SYMBOL,PDSCH_LENGTH_SYMBOL);
520 pdschCfg.timeDomAlloc[1].k0 = PDSCH_K0_CFG2;
521 pdschCfg.timeDomAlloc[1].mapType = \
522 PDSCH_TimeDomainResourceAllocation__mappingType_typeA;
523 pdschCfg.timeDomAlloc[1].sliv = calcSliv(PDSCH_START_SYMBOL,PDSCH_LENGTH_SYMBOL);
525 srvCellCfgComm->dlCfg.pdschCfg = pdschCfg;
527 /* Configuring BCCH Config for SIB1 */
528 srvCellCfgComm->dlCfg.bcchCfg.modPrdCoeff = \
529 BCCH_Config__modificationPeriodCoeff_n16;
531 /* Configuring PCCH Config for SIB1 */
532 pcchCfg.dfltPagingCycle = PagingCycle_rf256;
533 pcchCfg.nAndPagingFrmOffPresent = PCCH_Config__nAndPagingFrameOffset_PR_oneT;
534 pcchCfg.numPagingOcc = PCCH_Config__ns_four;
535 srvCellCfgComm->dlCfg.pcchCfg = pcchCfg;
538 /* Configuring UL Config Common */
540 srvCellCfgComm->ulCfg.ulScsCarrier.scsOffset = cellParams.ssbOffset;
541 srvCellCfgComm->ulCfg.ulScsCarrier.scs = convertScsValToScsEnum(cellParams.ssbSubCarrierSpacing);
542 srvCellCfgComm->ulCfg.ulScsCarrier.scsBw = cellParams.bSChannelBwUL;
544 srvCellCfgComm->ulCfg.ulScsCarrier.scsOffset = SSB_SUBCARRIER_OFFSET;
545 srvCellCfgComm->ulCfg.ulScsCarrier.scs = NR_SCS;
546 srvCellCfgComm->ulCfg.ulScsCarrier.scsBw = NR_BANDWIDTH;
548 srvCellCfgComm->ulCfg.pMax = UL_P_MAX;
549 srvCellCfgComm->ulCfg.locAndBw = FREQ_LOC_BW;
550 srvCellCfgComm->ulCfg.timeAlignTimerComm = TimeAlignmentTimer_infinity;
552 /* Configuring RACH Config Common for SIB1 */
553 rachCfg.present = BWP_UplinkCommon__rach_ConfigCommon_PR_setup;
554 rachCfg.prachCfgIdx = PRACH_CONFIG_IDX;
555 rachCfg.msg1Fdm = RACH_ConfigGeneric__msg1_FDM_one;
556 rachCfg.msg1FreqStart = PRACH_FREQ_START;
557 rachCfg.zeroCorrZoneCfg = ZERO_CORRELATION_ZONE_CFG;
558 rachCfg.preambleRcvdTgtPwr = PRACH_PREAMBLE_RCVD_TGT_PWR;
559 rachCfg.preambleTransMax = RACH_ConfigGeneric__preambleTransMax_n200;
560 rachCfg.pwrRampingStep = RACH_ConfigGeneric__powerRampingStep_dB2;
561 rachCfg.raRspWindow = RACH_ConfigGeneric__ra_ResponseWindow_sl10;
562 rachCfg.numRaPreamble = NUM_RA_PREAMBLE;
563 rachCfg.ssbPerRachOccPresent = \
564 RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_one;
565 rachCfg.numSsbPerRachOcc = SSB_PER_RACH;
566 rachCfg.contResTimer = RACH_ConfigCommon__ra_ContentionResolutionTimer_sf64;
567 rachCfg.rsrpThreshSsb = RSRP_THRESHOLD_SSB;
568 rachCfg.rootSeqIdxPresent = RACH_ConfigCommon__prach_RootSequenceIndex_PR_l139;
569 rachCfg.rootSeqIdx = ROOT_SEQ_IDX;
570 rachCfg.msg1Scs = PRACH_SUBCARRIER_SPACING ;
571 rachCfg.restrictedSetCfg = PRACH_RESTRICTED_SET_CFG;
572 srvCellCfgComm->ulCfg.rachCfg = rachCfg;
574 /* Configuring PUSCH Config Common for SIB1 */
575 puschCfg.puschCfgPresent = BWP_UplinkCommon__pusch_ConfigCommon_PR_setup;
576 puschCfg.numTimeDomRsrcAlloc = 2;
577 puschCfg.timeDomAllocList[0].k2 = PUSCH_K2_CFG1;
578 puschCfg.timeDomAllocList[0].mapType = PUSCH_TimeDomainResourceAllocation__mappingType_typeA;
579 puschCfg.timeDomAllocList[0].sliv = calcSliv(PUSCH_START_SYMBOL,PUSCH_LENGTH_SYMBOL);
580 puschCfg.timeDomAllocList[1].k2 = PUSCH_K2_CFG2;
581 puschCfg.timeDomAllocList[1].mapType = PUSCH_TimeDomainResourceAllocation__mappingType_typeA;
582 puschCfg.timeDomAllocList[1].sliv = calcSliv(PUSCH_START_SYMBOL,PUSCH_LENGTH_SYMBOL);
583 puschCfg.msg3DeltaPreamble = PUSCH_MSG3_DELTA_PREAMBLE;
584 puschCfg.p0NominalWithGrant = PUSCH_P0_NOMINAL_WITH_GRANT;
585 srvCellCfgComm->ulCfg.puschCfg = puschCfg;
587 /* Configuring PUCCH Config Common for SIB1 */
588 pucchCfg.present = BWP_UplinkCommon__pucch_ConfigCommon_PR_setup;
589 pucchCfg.rsrcComm = PUCCH_RSRC_COMMON;
590 pucchCfg.grpHop = PUCCH_ConfigCommon__pucch_GroupHopping_neither;
591 pucchCfg.p0Nominal = PUCCH_P0_NOMINAL;
592 srvCellCfgComm->ulCfg.pucchCfg = pucchCfg;
594 /* Configuring TDD UL DL config common */
595 tddCfg.refScs = SubcarrierSpacing_kHz30;
596 tddCfg.txPrd = TDD_UL_DL_Pattern__dl_UL_TransmissionPeriodicity_ms5;
597 tddCfg.numDlSlots = NUM_DL_SLOTS;
598 tddCfg.numDlSymbols = NUM_DL_SYMBOLS;
599 tddCfg.numUlSlots = NUM_UL_SLOTS;
600 tddCfg.numUlSymbols = NUM_UL_SYMBOLS;
601 srvCellCfgComm->tddCfg = tddCfg;
603 srvCellCfgComm->ssbPosInBurst = 192;
604 srvCellCfgComm->ssbPrdServingCell = SSB_PERIODICITY_20MS;
605 srvCellCfgComm->ssPbchBlockPwr = SSB_PBCH_PWR;
610 /*******************************************************************
612 * @brief Configures the DU Parameters
619 * - Initializes the DuCfg members.
620 * - Calls readMacCfg()
622 * @params[in] system task ID
623 * @return ROK - success
626 * ****************************************************************/
630 uint8_t srvdCellIdx, bandIdx, sliceIdx, plmnIdx;
631 uint8_t brdcstPlmnIdx, freqBandIdx, srvdPlmnIdx;
632 uint32_t ipv4_du, ipv4_cu, ipv4_ric;
635 F1TaiSliceSuppLst *taiSliceSuppLst;
638 /* Note: Added these below variable for local testing*/
639 Snssai snssai[NUM_OF_SUPPORTED_SLICE] = {{1,{2,3,4}},{5,{6,7,8}}};
643 if( getStartupConfig(&g_cfg) != ROK )
647 cmInetAddr((S8*)g_cfg.DU_IPV4_Addr, &ipv4_du);
648 cmInetAddr((S8*)g_cfg.CU_IPV4_Addr, &ipv4_cu);
649 cmInetAddr((S8*)g_cfg.RIC_IPV4_Addr, &ipv4_ric);
651 duCfgParam.sctpParams.cuPort = g_cfg.CU_Port;
652 duCfgParam.sctpParams.ricPort = g_cfg.RIC_Port;
654 cmInetAddr((S8*)DU_IP_V4_ADDR, &ipv4_du);
655 cmInetAddr((S8*)CU_IP_V4_ADDR, &ipv4_cu);
656 cmInetAddr((S8*)RIC_IP_V4_ADDR, &ipv4_ric);
658 duCfgParam.sctpParams.cuPort = CU_PORT;
659 duCfgParam.sctpParams.ricPort = RIC_PORT;
662 fillDuPort(duCfgParam.sctpParams.duPort);
664 /* F1 DU IP Address and Port*/
665 duCfgParam.sctpParams.duIpAddr.ipV4Addr = ipv4_du;
667 /* F1 CU IP Address and Port*/
668 duCfgParam.sctpParams.cuIpAddr.ipV4Addr = ipv4_cu;
670 /* Fill RIC Params */
671 duCfgParam.sctpParams.ricIpAddr.ipV4Addr = ipv4_ric;
673 /* EGTP Parameters */
674 duCfgParam.egtpParams.localIp.ipV4Pres = TRUE;
675 duCfgParam.egtpParams.localIp.ipV4Addr = ipv4_du;
676 duCfgParam.egtpParams.localPort = DU_EGTP_PORT;
677 duCfgParam.egtpParams.destIp.ipV4Pres = TRUE;
678 duCfgParam.egtpParams.destIp.ipV4Addr = ipv4_cu;
679 duCfgParam.egtpParams.destPort = CU_EGTP_PORT;
680 duCfgParam.egtpParams.minTunnelId = MIN_TEID;
681 duCfgParam.egtpParams.maxTunnelId = MAX_TEID;
683 duCfgParam.maxUe = 32; //TODO: Check
685 duCfgParam.duId = DU_ID;
686 strcpy((char*)duCfgParam.duName,DU_NAME);
689 mib.sysFrmNum = SYS_FRAME_NUM;
691 mib.subCarrierSpacingCommon = MIB__subCarrierSpacingCommon_scs30or120;
693 mib.subCarrierSpacingCommon = MIB__subCarrierSpacingCommon_scs15or60;
695 mib.ssb_SubcarrierOffset = SSB_SC_OFFSET; //Kssb
696 mib.dmrs_TypeA_Position = MIB__dmrs_TypeA_Position_pos2;
697 mib.controlResourceSetZero = CORESET_0_INDEX;
698 mib.searchSpaceZero = SEARCHSPACE_0_INDEX;
699 mib.cellBarred = MIB__cellBarred_notBarred;
700 mib.intraFreqReselection =
701 MIB__intraFreqReselection_notAllowed;
702 duCfgParam.mibParams = mib;
705 memset(&sib1.plmn, 0, sizeof(Plmn));
706 sib1.plmn.mcc[0] = PLMN_MCC0;
707 sib1.plmn.mcc[1] = PLMN_MCC1;
708 sib1.plmn.mcc[2] = PLMN_MCC2;
709 sib1.plmn.mnc[0] = PLMN_MNC0;
710 sib1.plmn.mnc[1] = PLMN_MNC1;
711 sib1.ranac = DU_RANAC;
714 sib1.tac = cellParams.nRTAC;
715 sib1.cellIdentity = CELL_IDENTITY * cellParams.cellLocalId;
716 DU_LOG("\n*********DEBUG --> DU_APP: readCfg(): OAM CellLocalId=%d", \
720 sib1.cellIdentity = CELL_IDENTITY * NR_CELL_ID;
722 sib1.cellResvdForOpUse = PLMN_IdentityInfo__cellReservedForOperatorUse_notReserved;
723 sib1.connEstFailCnt = ConnEstFailureControl__connEstFailCount_n3;
724 sib1.connEstFailOffValidity = ConnEstFailureControl__connEstFailOffsetValidity_s120;
725 sib1.siSchedInfo.winLen = SI_SchedulingInfo__si_WindowLength_s5;
726 sib1.siSchedInfo.broadcastSta = SchedulingInfo__si_BroadcastStatus_broadcasting;
727 sib1.siSchedInfo.preiodicity = SchedulingInfo__si_Periodicity_rf8;
728 sib1.siSchedInfo.sibType = SIB_TypeInfo__type_sibType2;
729 sib1.siSchedInfo.sibValTag = SIB1_VALUE_TAG;
731 fillServCellCfgCommSib(&sib1.srvCellCfgCommSib);
733 duCfgParam.sib1Params = sib1;
735 for(srvdCellIdx=0; srvdCellIdx<DEFAULT_CELLS; srvdCellIdx++)
737 memset(&duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.nrCgi.plmn, 0, sizeof(Plmn));
738 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.nrCgi.plmn.mcc[0] = PLMN_MCC0;
739 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.nrCgi.plmn.mcc[1] = PLMN_MCC1;
740 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.nrCgi.plmn.mcc[2] = PLMN_MCC2;
741 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.nrCgi.plmn.mnc[0] = PLMN_MNC0;
742 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.nrCgi.plmn.mnc[1] = PLMN_MNC1;
746 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.nrPci = cellParams.nRPCI;
748 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.nrPci = NR_PCI;
750 /* List of Available PLMN */
751 for(srvdPlmnIdx=0; srvdPlmnIdx<MAX_PLMN; srvdPlmnIdx++)
753 /* As per spec 38.473, Plmn identity consists of 3 digit from mcc
754 * followed by either 2 digit or 3 digits of mnc */
756 memset(&duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].plmn, 0,\
759 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].plmn.mcc[0] = cellParams.plmnList[srvdPlmnIdx].mcc[0];
760 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].plmn.mcc[1] = cellParams.plmnList[srvdPlmnIdx].mcc[1];
761 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].plmn.mcc[2] = cellParams.plmnList[srvdPlmnIdx].mcc[2];
762 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].plmn.mnc[0] = cellParams.plmnList[srvdPlmnIdx].mnc[0];
763 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].plmn.mnc[1] = cellParams.plmnList[srvdPlmnIdx].mnc[1];
764 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].plmn.mnc[2] = cellParams.plmnList[srvdPlmnIdx].mnc[2];
766 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].plmn.mcc[0] = PLMN_MCC0;
767 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].plmn.mcc[1] = PLMN_MCC1;
768 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].plmn.mcc[2] = PLMN_MCC2;
769 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].plmn.mnc[0] = PLMN_MNC0;
770 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].plmn.mnc[1] = PLMN_MNC1;
773 /* List of Extended PLMN */
774 for(srvdPlmnIdx=0; srvdPlmnIdx<MAX_PLMN; srvdPlmnIdx++)
776 /* As per spec 38.473, Plmn identity consists of 3 digit from mcc
777 * followed by either 2 digit or 3 digits of mnc */
779 memset(&duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].extPlmn, 0, sizeof(Plmn));
780 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].extPlmn.mcc[0] = PLMN_MCC0;
781 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].extPlmn.mcc[1] = PLMN_MCC1;
782 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].extPlmn.mcc[2] = PLMN_MCC2;
783 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].extPlmn.mnc[0] = PLMN_MNC0;
784 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].extPlmn.mnc[1] = PLMN_MNC1;
786 /* List of Supporting Slices */
787 for(srvdPlmnIdx=0; srvdPlmnIdx<MAX_PLMN; srvdPlmnIdx++)
789 taiSliceSuppLst = &duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].\
792 /* TODO Calculte the exact number of supported slices once will get
793 * cell configuration from O1 */
794 taiSliceSuppLst->numSupportedSlices = NUM_OF_SUPPORTED_SLICE;
795 if(taiSliceSuppLst->numSupportedSlices > MAX_NUM_OF_SLICE_ITEMS)
797 DU_LOG("\nERROR --> DU_APP: readCfg(): Number of supported slice [%d] is more than 1024",\
798 taiSliceSuppLst->numSupportedSlices);
802 DU_ALLOC(taiSliceSuppLst->snssai, taiSliceSuppLst->numSupportedSlices*sizeof(Snssai*));
803 if(taiSliceSuppLst->snssai == NULLP)
805 DU_LOG("\nERROR --> DU_APP: readCfg():Memory allocation failed");
809 for(sliceIdx=0; sliceIdx<taiSliceSuppLst->numSupportedSlices; sliceIdx++)
811 DU_ALLOC(taiSliceSuppLst->snssai[sliceIdx], sizeof(Snssai));
812 if(taiSliceSuppLst->snssai[sliceIdx] == NULLP)
814 DU_LOG("\nERROR --> DU_APP: readCfg():Memory allocation failed");
818 memcpy(taiSliceSuppLst->snssai[sliceIdx]->sd, cellParams.plmnList[sliceIdx].sd, \
819 SD_SIZE*sizeof(uint8_t));
820 taiSliceSuppLst->snssai[sliceIdx]->sst = cellParams.plmnList[sliceIdx].sst;
822 memcpy(taiSliceSuppLst->snssai[sliceIdx], &snssai[sliceIdx], sizeof(Snssai));
829 /* NR TDD Mode info */
831 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.nrArfcn = cellParams.arfcnUL;
832 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.sulInfo.sulArfcn = cellParams.arfcnSUL;
833 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.sulInfo.sulTxBw.nrScs = convertScsPeriodicityToEnum(cellParams.ssbPeriodicity);
835 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.nrArfcn = NR_UL_ARFCN;
836 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.sulInfo.sulArfcn = SUL_ARFCN;
837 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.sulInfo.sulTxBw.nrScs = SSB_PRDCTY_MS_20;
839 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.sulInfo.sulTxBw.nrb = NRB_106;
841 for(freqBandIdx=0; freqBandIdx<MAX_NRCELL_BANDS; freqBandIdx++)
843 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.freqBand[freqBandIdx].nrFreqBand =\
845 for(bandIdx=0; bandIdx<MAX_NRCELL_BANDS; bandIdx++)
847 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.freqBand[freqBandIdx].sulBand[bandIdx]\
852 /* NR FDD Mode info */
854 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.nrArfcn = cellParams.arfcnUL;
855 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.sulInfo.sulArfcn = cellParams.arfcnSUL;
856 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.ulTxBw.nrScs = convertScsPeriodicityToEnum(cellParams.ssbPeriodicity);
857 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.sulInfo.sulTxBw.nrScs = convertScsPeriodicityToEnum(cellParams.ssbPeriodicity);
858 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.nrArfcn = cellParams.arfcnDL;
859 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.sulInfo.sulArfcn = cellParams.arfcnSUL;
860 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.sulInfo.sulTxBw.nrScs = convertScsPeriodicityToEnum(cellParams.ssbPeriodicity);
861 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.dlTxBw.nrScs = convertScsPeriodicityToEnum(cellParams.ssbPeriodicity);
863 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.nrArfcn = NR_UL_ARFCN;
864 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.sulInfo.sulArfcn = SUL_ARFCN;
865 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.ulTxBw.nrScs = SSB_PRDCTY_MS_20;
866 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.sulInfo.sulTxBw.nrScs = SSB_PRDCTY_MS_20;
867 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.nrArfcn = NR_DL_ARFCN;
868 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.sulInfo.sulArfcn = SUL_ARFCN;
869 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.sulInfo.sulTxBw.nrScs = SSB_PRDCTY_MS_20;
870 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.dlTxBw.nrScs = SSB_PRDCTY_MS_20;
872 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.sulInfo.sulTxBw.nrb = NRB_106;
873 for(freqBandIdx=0; freqBandIdx<MAX_NRCELL_BANDS; freqBandIdx++)
875 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.freqBand[freqBandIdx].\
876 nrFreqBand = NR_FREQ_BAND;
877 for(bandIdx=0; bandIdx<MAX_NRCELL_BANDS; bandIdx++)
879 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.freqBand[freqBandIdx].\
880 sulBand[bandIdx] = SUL_BAND;
883 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.sulInfo.sulTxBw.nrb = NRB_106;
884 for(freqBandIdx=0; freqBandIdx<MAX_NRCELL_BANDS; freqBandIdx++)
886 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.freqBand[freqBandIdx].\
887 nrFreqBand = NR_FREQ_BAND;
888 for(bandIdx=0; bandIdx<MAX_NRCELL_BANDS; bandIdx++)
890 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.freqBand[freqBandIdx].\
891 sulBand[bandIdx] = SUL_BAND;
895 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.ulTxBw.nrb = NRB_106;
896 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.dlTxBw.nrb = NRB_106;
899 /*Measurement Config and Cell Config */
900 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.measTimeCfg = TIME_CFG;
902 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellDir = DL_UL;
904 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellType=CELL_TYPE;
906 /* Broadcast PLMN Identity */
907 for(brdcstPlmnIdx=0; brdcstPlmnIdx<MAX_BPLMN_NRCELL_MINUS_1; brdcstPlmnIdx++)
909 for(plmnIdx=0; plmnIdx<MAX_PLMN; plmnIdx++)
911 memset(&duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].plmn[plmnIdx],\
913 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].plmn[plmnIdx].mcc[0] =\
915 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].plmn[plmnIdx].mcc[1] =\
917 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].plmn[plmnIdx].mcc[2] =\
919 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].plmn[plmnIdx].mnc[0] =\
921 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].plmn[plmnIdx].mnc[1] =\
924 /* Extended PLMN List */
925 for(plmnIdx=0; plmnIdx<MAX_PLMN; plmnIdx++)
927 memset(&duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].\
928 extPlmn[plmnIdx], 0, sizeof(Plmn));
929 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].\
930 extPlmn[plmnIdx].mcc[0] = PLMN_MCC0;
931 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].\
932 extPlmn[plmnIdx].mcc[1] = PLMN_MCC1;
933 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].\
934 extPlmn[plmnIdx].mcc[2] = PLMN_MCC2;
935 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].\
936 extPlmn[plmnIdx].mnc[0] = PLMN_MNC0;
937 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].\
938 extPlmn[plmnIdx].mnc[1] = PLMN_MNC1;
941 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.epsTac = cellParams.nRTAC; //TODO : to check and fill
942 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.tac = cellParams.nRTAC;
943 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].tac = cellParams.nRTAC;
944 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].nrCellId = cellParams.cellLocalId;
946 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.epsTac = DU_TAC; //TODO : to check and fill
947 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.tac = DU_TAC;
948 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].tac = DU_TAC;
949 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].nrCellId = NR_CELL_ID;
951 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].ranac = NR_RANAC;
954 /*gnb DU System Info mib msg*/
956 DU_ALLOC(duCfgParam.srvdCellLst[srvdCellIdx].duSysInfo.mibMsg, encBufSize);
957 if(!(duCfgParam.srvdCellLst[srvdCellIdx].duSysInfo.mibMsg))
959 DU_LOG("\nERROR --> DU APP : Memory allocation failure at readCfg");
962 memcpy(duCfgParam.srvdCellLst[srvdCellIdx].duSysInfo.mibMsg, encBuf, encBufSize);
963 duCfgParam.srvdCellLst[srvdCellIdx].duSysInfo.mibLen = encBufSize;
965 /*gnb DU System Info mib msg*/
967 DU_ALLOC(duCfgParam.srvdCellLst[srvdCellIdx].duSysInfo.sib1Msg,\
969 if(!(duCfgParam.srvdCellLst[srvdCellIdx].duSysInfo.sib1Msg))
971 DU_LOG("\nERROR --> DU APP : Memory allocation failure at readCfg");
974 memcpy(duCfgParam.srvdCellLst[srvdCellIdx].duSysInfo.sib1Msg,\
976 duCfgParam.srvdCellLst[srvdCellIdx].duSysInfo.sib1Len = encBufSize;
980 if(readMacCfg() != ROK)
982 DU_LOG("\nERROR --> DU_APP : Failed while reading MAC config");
989 /*******************************************************************
991 * @brief Copy Slice Cfg in temp structre in duCfgParams
995 * Function : cpyRrmPolicyInDuCfgParams
998 * - Copy Slice Cfg in temp structre in duCfgParams
1000 * @params[in] RrmPolicy rrmPolicy[], uint8_t policyNum, uint8_t memberList
1001 * @return ROK - success
1004 * ****************************************************************/
1006 uint8_t cpyRrmPolicyInDuCfgParams(RrmPolicyList rrmPolicy[], uint8_t policyNum, CopyOfRecvdSliceCfg *tempSliceCfg)
1008 uint8_t policyIdx = 0, memberListIdx = 0, count = 0;
1012 tempSliceCfg->totalRrmPolicy = policyNum;
1013 DU_ALLOC(tempSliceCfg->rrmPolicy, tempSliceCfg->totalRrmPolicy * sizeof(RrmPolicy*));
1014 if(tempSliceCfg->rrmPolicy == NULLP)
1016 DU_LOG("\nERROR --> DU APP : Memory allocation failed in cpyRrmPolicyInDuCfgParams");
1020 for(policyIdx = 0; policyIdx<tempSliceCfg->totalRrmPolicy; policyIdx++)
1022 DU_ALLOC(tempSliceCfg->rrmPolicy[policyIdx], sizeof(RrmPolicy));
1023 if(tempSliceCfg->rrmPolicy[policyIdx] == NULLP)
1025 DU_LOG("\nERROR --> DU APP : Memory allocation failed in cpyRrmPolicyInDuCfgParams");
1029 if(rrmPolicy[policyIdx].rRMMemberNum)
1031 tempSliceCfg->rrmPolicy[policyIdx]->numMemberList = rrmPolicy[policyIdx].rRMMemberNum;
1032 DU_ALLOC(tempSliceCfg->rrmPolicy[policyIdx]->memberList, tempSliceCfg->rrmPolicy[policyIdx]->numMemberList * sizeof(PolicyMemberList*))
1033 if(tempSliceCfg->rrmPolicy[policyIdx]->memberList == NULLP)
1035 DU_LOG("\nERROR --> DU APP : Memory allocation failed in cpyRrmPolicyInDuCfgParams");
1039 for(memberListIdx = 0; memberListIdx<tempSliceCfg->rrmPolicy[policyIdx]->numMemberList; memberListIdx++)
1041 DU_ALLOC(tempSliceCfg->rrmPolicy[policyIdx]->memberList[memberListIdx], sizeof(PolicyMemberList))
1042 if(tempSliceCfg->rrmPolicy[policyIdx]->memberList[memberListIdx] == NULLP)
1044 DU_LOG("\nERROR --> DU APP : Memory allocation failed in cpyRrmPolicyInDuCfgParams");
1047 memcpy(&tempSliceCfg->rrmPolicy[policyIdx]->memberList[memberListIdx]->snssai.sd, &rrmPolicy[policyIdx].rRMPolicyMemberList[memberListIdx].sd, 3 * sizeof(uint8_t));
1048 memcpy(&tempSliceCfg->rrmPolicy[policyIdx]->memberList[memberListIdx]->snssai.sst, &rrmPolicy[policyIdx].rRMPolicyMemberList[memberListIdx].sst, sizeof(uint8_t));
1049 memcpy(&tempSliceCfg->rrmPolicy[policyIdx]->memberList[memberListIdx]->plmn.mcc, &rrmPolicy[policyIdx].rRMPolicyMemberList[memberListIdx].mcc, 3 * sizeof(uint8_t));
1050 memcpy(&tempSliceCfg->rrmPolicy[policyIdx]->memberList[memberListIdx]->plmn.mnc, &rrmPolicy[policyIdx].rRMPolicyMemberList[memberListIdx].mnc, 3 * sizeof(uint8_t));
1055 tempSliceCfg->rrmPolicy[policyIdx]->rsrcType = rrmPolicy[policyIdx].resourceType;
1056 tempSliceCfg->rrmPolicy[policyIdx]->policyMaxRatio = rrmPolicy[policyIdx].rRMPolicyMaxRatio;
1057 tempSliceCfg->rrmPolicy[policyIdx]->policyMinRatio = rrmPolicy[policyIdx].rRMPolicyMinRatio;
1058 tempSliceCfg->rrmPolicy[policyIdx]->policyDedicatedRatio = rrmPolicy[policyIdx].rRMPolicyDedicatedRatio;
1061 tempSliceCfg->totalSliceCount = count;
1066 /*******************************************************************
1068 * @brief Reads config and posts message to du_app on completion
1076 * - Post to du_app for further processing
1079 * @return ROK - success
1082 * ****************************************************************/
1088 memset(&duCfgParam, 0, sizeof(DuCfgParams));
1090 //Read configs into duCfgParams
1091 if(readCfg() != ROK)
1093 DU_LOG("\nERROR --> DU_APP : Reading configuration failed");
1097 //Fill pst structure
1098 memset(&(pst), 0, sizeof(Pst));
1099 pst.srcEnt = (Ent)ENTDUAPP;
1100 pst.srcInst = (Inst)DU_INST;
1101 pst.srcProcId = DU_PROC;
1102 pst.dstEnt = pst.srcEnt;
1103 pst.dstInst = pst.srcInst;
1104 pst.dstProcId = pst.srcProcId;
1106 pst.selector = ODU_SELECTOR_TC;
1110 if(ODU_GET_MSG_BUF(DFLT_REGION, DU_POOL, &mBuf) != ROK)
1112 DU_LOG("\nERROR --> DU_APP : Memory allocation failed in duReadCfg");
1116 if (ODU_POST_TASK(&pst, mBuf) != ROK)
1118 DU_LOG("\nERROR --> DU_APP : ODU_POST_TASK failed in duReadCfg");
1125 /**********************************************************************
1127 **********************************************************************/