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 if(BuildMibPdu() != ROK)
219 DU_LOG("\nERROR --> Failed to build MIB PDU");
220 memset(&duCfgParam.macCellCfg.ssbCfg.mibPdu, 0, 3*sizeof(uint8_t));
224 memcpy(&duCfgParam.macCellCfg.ssbCfg.mibPdu, encBuf,encBufSize);
226 duCfgParam.macCellCfg.ssbCfg.multCarrBand = SSB_MULT_CARRIER_BAND;
227 duCfgParam.macCellCfg.ssbCfg.multCellCarr = MULT_CELL_CARRIER;
229 /* PRACH configuration */
230 duCfgParam.macCellCfg.prachCfg.pres = TRUE;
231 duCfgParam.macCellCfg.prachCfg.prachCfgIdx = PRACH_CONFIG_IDX;
232 duCfgParam.macCellCfg.prachCfg.prachSeqLen = PRACH_SEQ_LEN;
233 duCfgParam.macCellCfg.prachCfg.prachSubcSpacing = convertScsEnumValToScsVal(PRACH_SUBCARRIER_SPACING);
234 duCfgParam.macCellCfg.prachCfg.prachRstSetCfg = PRACH_RESTRICTED_SET_CFG;
235 duCfgParam.macCellCfg.prachCfg.msg1Fdm = NUM_PRACH_FDM;
236 duCfgParam.macCellCfg.prachCfg.msg1FreqStart = PRACH_FREQ_START;
237 duCfgParam.macCellCfg.prachCfg.rootSeqLen = ROOT_SEQ_LEN;
238 duCfgParam.macCellCfg.prachCfg.fdm[0].rootSeqIdx = ROOT_SEQ_IDX;
239 duCfgParam.macCellCfg.prachCfg.fdm[0].numRootSeq = NUM_ROOT_SEQ;
240 duCfgParam.macCellCfg.prachCfg.fdm[0].k1 = 0;
241 duCfgParam.macCellCfg.prachCfg.fdm[0].zeroCorrZoneCfg = ZERO_CORRELATION_ZONE_CFG;
242 duCfgParam.macCellCfg.prachCfg.fdm[0].numUnusedRootSeq = NUM_UNUSED_ROOT_SEQ;
243 if(duCfgParam.macCellCfg.prachCfg.fdm[0].numUnusedRootSeq != 0)
245 DU_ALLOC_SHRABL_BUF(duCfgParam.macCellCfg.prachCfg.fdm[0].unsuedRootSeq,
246 NUM_UNUSED_ROOT_SEQ * sizeof(uint8_t));
247 if(duCfgParam.macCellCfg.prachCfg.fdm[0].unsuedRootSeq == NULLP)
249 DU_LOG("\nERROR --> DU_APP : Memory allocation failed at readMacCfg");
252 *(duCfgParam.macCellCfg.prachCfg.fdm[0].unsuedRootSeq) = UNUSED_ROOT_SEQ;
254 duCfgParam.macCellCfg.prachCfg.ssbPerRach = SSB_PER_RACH;
255 duCfgParam.macCellCfg.prachCfg.prachMultCarrBand = PRACH_MULT_CARRIER_BAND;
256 duCfgParam.macCellCfg.prachCfg.raContResTmr = RA_CONT_RES_TIMER;
257 duCfgParam.macCellCfg.prachCfg.rsrpThreshSsb = RSRP_THRESHOLD_SSB;
258 duCfgParam.macCellCfg.prachCfg.raRspWindow = RA_RSP_WINDOW;
259 duCfgParam.macCellCfg.prachCfg.prachRestrictedSet = PRACH_RESTRICTED_SET;
261 /* TDD configuration */
262 duCfgParam.macCellCfg.tddCfg.pres = TRUE;
263 duCfgParam.macCellCfg.tddCfg.tddPeriod = TDD_PERIODICITY;
268 /* RSSI Measurement configuration */
269 duCfgParam.macCellCfg.rssiUnit = RSS_MEASUREMENT_UNIT;
271 /* fill SIB1 configuration */
272 duCfgParam.macCellCfg.sib1Cfg.sib1PduLen = duCfgParam.srvdCellLst[0].duSysInfo.sib1Len;
273 DU_ALLOC_SHRABL_BUF(duCfgParam.macCellCfg.sib1Cfg.sib1Pdu,duCfgParam.srvdCellLst[0].duSysInfo.sib1Len);
274 memcpy(duCfgParam.macCellCfg.sib1Cfg.sib1Pdu, duCfgParam.srvdCellLst[0].duSysInfo.sib1Msg, \
275 duCfgParam.srvdCellLst[0].duSysInfo.sib1Len);
276 duCfgParam.macCellCfg.sib1Cfg.sib1RepetitionPeriod = SIB1_REPETITION_PERIOD;
277 duCfgParam.macCellCfg.sib1Cfg.coresetZeroIndex = CORESET_0_INDEX;
278 duCfgParam.macCellCfg.sib1Cfg.searchSpaceZeroIndex = SEARCHSPACE_0_INDEX;
279 duCfgParam.macCellCfg.sib1Cfg.sib1Mcs = DEFAULT_MCS;
281 GET_NUM_PAGING_OCC(duCfgParam.sib1Params.srvCellCfgCommSib.dlCfg.pcchCfg.ns,
282 duCfgParam.macCellCfg.sib1Cfg.pagingCfg.numPO);
283 if(duCfgParam.sib1Params.srvCellCfgCommSib.dlCfg.pcchCfg.firstPDCCHMontioringType != \
284 PCCH_Config__firstPDCCH_MonitoringOccasionOfPO_PR_NOTHING)
286 duCfgParam.macCellCfg.sib1Cfg.pagingCfg.poPresent = TRUE;
287 memcpy(duCfgParam.macCellCfg.sib1Cfg.pagingCfg.pagingOcc,
288 duCfgParam.sib1Params.srvCellCfgCommSib.dlCfg.pcchCfg.firstPDCCHMontioringInfo,MAX_PO_PER_PF);
292 duCfgParam.macCellCfg.sib1Cfg.pagingCfg.poPresent = FALSE;
295 /* fill Intial DL BWP */
296 duCfgParam.macCellCfg.initialDlBwp.bwp.firstPrb = 0;
297 duCfgParam.macCellCfg.initialDlBwp.bwp.numPrb = TOTAL_PRB_20MHZ_MU0; /* configured to total BW */
298 duCfgParam.macCellCfg.initialDlBwp.bwp.scs = duCfgParam.macCellCfg.ssbCfg.scsCmn;
299 duCfgParam.macCellCfg.initialDlBwp.bwp.cyclicPrefix = NORMAL_CYCLIC_PREFIX;
300 duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.searchSpaceId = SEARCHSPACE_1_INDEX;
301 duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.coresetId = CORESET_0_INDEX;
302 duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.monitoringSlot =
303 SS_MONITORING_SLOT_SL1; /* sl1 - all slots */
304 duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.duration = 0;
305 duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.monitoringSymbol =
306 SS_MONITORING_SYMBOL;
307 duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.
308 candidate.aggLevel1 = 8;
309 duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.
310 candidate.aggLevel2 = 4;
311 duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.
312 candidate.aggLevel4 = 2;
313 duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.
314 candidate.aggLevel8 = 1;
315 duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.
316 candidate.aggLevel16 = 0;
318 duCfgParam.macCellCfg.initialDlBwp.pdschCommon.numTimeDomAlloc = NUM_TIME_DOM_RSRC_ALLOC;
320 duCfgParam.macCellCfg.initialDlBwp.pdschCommon.timeDomRsrcAllocList[idx].k0 = PDSCH_K0_CFG1;
321 duCfgParam.macCellCfg.initialDlBwp.pdschCommon.timeDomRsrcAllocList[idx].mappingType =
322 PDSCH_MAPPING_TYPE_A;
323 duCfgParam.macCellCfg.initialDlBwp.pdschCommon.timeDomRsrcAllocList[idx].startSymbol =
325 duCfgParam.macCellCfg.initialDlBwp.pdschCommon.timeDomRsrcAllocList[idx].lengthSymbol =
329 duCfgParam.macCellCfg.initialDlBwp.pdschCommon.timeDomRsrcAllocList[idx].k0 = PDSCH_K0_CFG2;
330 duCfgParam.macCellCfg.initialDlBwp.pdschCommon.timeDomRsrcAllocList[idx].mappingType =
331 PDSCH_MAPPING_TYPE_A;
332 duCfgParam.macCellCfg.initialDlBwp.pdschCommon.timeDomRsrcAllocList[idx].startSymbol =
334 duCfgParam.macCellCfg.initialDlBwp.pdschCommon.timeDomRsrcAllocList[idx].lengthSymbol =
337 /* ra-searchSpace ID is set to 1 */
338 duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.raSearchSpaceId = SEARCHSPACE_1_INDEX;
340 /* fill Intial UL BWP */
341 duCfgParam.macCellCfg.initialUlBwp.bwp.firstPrb = 0;
342 duCfgParam.macCellCfg.initialUlBwp.bwp.numPrb = TOTAL_PRB_20MHZ_MU0; /* configured to total BW */
343 duCfgParam.macCellCfg.initialUlBwp.bwp.scs = duCfgParam.macCellCfg.ssbCfg.scsCmn;
344 duCfgParam.macCellCfg.initialUlBwp.bwp.cyclicPrefix = NORMAL_CYCLIC_PREFIX;
345 duCfgParam.macCellCfg.initialUlBwp.puschCommon.numTimeDomRsrcAlloc = 2;
346 duCfgParam.macCellCfg.initialUlBwp.puschCommon.timeDomRsrcAllocList[0].k2 = PUSCH_K2_CFG1;
347 duCfgParam.macCellCfg.initialUlBwp.puschCommon.timeDomRsrcAllocList[0].mappingType =
348 PUSCH_MAPPING_TYPE_A;
349 duCfgParam.macCellCfg.initialUlBwp.puschCommon.timeDomRsrcAllocList[0].startSymbol =
351 duCfgParam.macCellCfg.initialUlBwp.puschCommon.timeDomRsrcAllocList[0].symbolLength =
354 duCfgParam.macCellCfg.initialUlBwp.puschCommon.timeDomRsrcAllocList[1].k2 = PUSCH_K2_CFG2;
355 duCfgParam.macCellCfg.initialUlBwp.puschCommon.timeDomRsrcAllocList[1].mappingType =
356 PUSCH_MAPPING_TYPE_A;
357 duCfgParam.macCellCfg.initialUlBwp.puschCommon.timeDomRsrcAllocList[1].startSymbol =
359 duCfgParam.macCellCfg.initialUlBwp.puschCommon.timeDomRsrcAllocList[1].symbolLength =
362 duCfgParam.macCellCfg.dmrsTypeAPos = DMRS_TYPE_A_POS;
364 /* fill PUCCH config common */
365 duCfgParam.macCellCfg.initialUlBwp.pucchCommon.pucchResourceCommon = PUCCH_RSRC_COMMON;
366 duCfgParam.macCellCfg.initialUlBwp.pucchCommon.pucchGroupHopping = PUCCH_GROUP_HOPPING;
368 /* Plmn And SNSSAI Configuration */
369 memcpy(&duCfgParam.macCellCfg.plmnInfoList.plmn, &duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.srvdPlmn[0].plmn,\
371 taiSliceSuppLst = &duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.srvdPlmn[0].taiSliceSuppLst;
372 duCfgParam.macCellCfg.plmnInfoList.numSupportedSlice = taiSliceSuppLst->numSupportedSlices;
373 if(taiSliceSuppLst->snssai)
375 DU_ALLOC_SHRABL_BUF(duCfgParam.macCellCfg.plmnInfoList.snssai, (duCfgParam.macCellCfg.plmnInfoList.numSupportedSlice) * sizeof(Snssai*));
376 if(duCfgParam.macCellCfg.plmnInfoList.snssai == NULLP)
378 DU_LOG("\nERROR --> DU_APP: Memory allocation failed at readMacCfg");
382 for(sliceIdx=0; sliceIdx<taiSliceSuppLst->numSupportedSlices; sliceIdx++)
384 if(taiSliceSuppLst->snssai[sliceIdx] != NULLP)
386 DU_ALLOC_SHRABL_BUF(duCfgParam.macCellCfg.plmnInfoList.snssai[sliceIdx], sizeof(Snssai));
387 if(duCfgParam.macCellCfg.plmnInfoList.snssai[sliceIdx] == NULLP)
389 DU_LOG("\nERROR --> DU_APP: Memory allocation failed at readMacCfg");
392 memcpy(duCfgParam.macCellCfg.plmnInfoList.snssai[sliceIdx], taiSliceSuppLst->snssai[sliceIdx], sizeof(Snssai));
398 /*******************************************************************
400 * @brief Configures the DU Parameters
404 * Function : fillDuPort
407 * - fills the DU Ports.
409 * @params[in] duPort array to be filled
410 * @return ROK - success
413 * ****************************************************************/
414 uint8_t fillDuPort(uint16_t *duPort)
418 duPort[F1_INTERFACE] = g_cfg.DU_Port;
419 duPort[E2_INTERFACE] = g_cfg.RIC_Port;
421 duPort[F1_INTERFACE] = DU_PORT; /* DU Port idx 0 38472 */
422 duPort[E2_INTERFACE] = RIC_PORT; /* RIC Port idx 1 38482 */
427 /*******************************************************************
429 * @brief Configures the DU Parameters
433 * Function : calcSliv
436 * - calculate SLIV value from start and length field
438 * @params[in] start symbol
439 * @params[in] length of symbols
442 * ****************************************************************/
443 uint16_t calcSliv(uint8_t startSymbol, uint8_t lengthSymbol)
446 if((lengthSymbol-1) <= 7)
448 sliv = NUM_SYMBOLS_PER_SLOT * (lengthSymbol-1) + startSymbol;
452 sliv = NUM_SYMBOLS_PER_SLOT * (NUM_SYMBOLS_PER_SLOT - lengthSymbol + 1) \
453 + (NUM_SYMBOLS_PER_SLOT - 1 - startSymbol);
459 /*******************************************************************
461 * @brief Configures serving cell config common in sib1
465 * Function : fillServCellCfgCommSib
468 * - fills Serving cell config common for SIB1
470 * @params[in] SrvCellCfgCommSib pointer
471 * @return ROK - success
474 ** ****************************************************************/
475 uint8_t fillServCellCfgCommSib(SrvCellCfgCommSib *srvCellCfgComm)
477 PdcchCfgCommon pdcchCfg;
478 PdschCfgCommon pdschCfg;
480 RachCfgCommon rachCfg;
481 PuschCfgCommon puschCfg;
482 PucchCfgCommon pucchCfg;
483 TddUlDlCfgCommon tddCfg;
485 /* Configuring DL Config Common for SIB1*/
486 srvCellCfgComm->dlCfg.freqBandInd = NR_FREQ_BAND;
487 srvCellCfgComm->dlCfg.offsetToPointA = OFFSET_TO_POINT_A;
489 srvCellCfgComm->dlCfg.dlScsCarrier.scsOffset = cellParams.ssbOffset;
490 srvCellCfgComm->dlCfg.dlScsCarrier.scs = convertScsValToScsEnum(cellParams.ssbSubCarrierSpacing);
491 srvCellCfgComm->dlCfg.dlScsCarrier.scsBw = cellParams.bSChannelBwUL;
493 srvCellCfgComm->dlCfg.dlScsCarrier.scsOffset = SSB_SUBCARRIER_OFFSET;
494 srvCellCfgComm->dlCfg.dlScsCarrier.scs = NR_SCS;
495 srvCellCfgComm->dlCfg.dlScsCarrier.scsBw = NR_BANDWIDTH;
497 srvCellCfgComm->dlCfg.locAndBw = FREQ_LOC_BW;
499 /* Configuring PDCCH Config Common For SIB1 */
500 pdcchCfg.present = BWP_DownlinkCommon__pdcch_ConfigCommon_PR_setup;
501 pdcchCfg.ctrlRsrcSetZero = CORESET_0_INDEX;
502 pdcchCfg.searchSpcZero = SEARCHSPACE_0_INDEX;
503 pdcchCfg.searchSpcId = PDCCH_SEARCH_SPACE_ID;
504 pdcchCfg.ctrlRsrcSetId = PDCCH_CTRL_RSRC_SET_ID;
505 pdcchCfg.monitorSlotPrdAndOffPresent = \
507 SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl1;
508 //pdcchCfg.monitorSlotPrdAndOff = \
509 SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl1;
510 pdcchCfg.monitorSymbolsInSlot[0] = 128;
511 pdcchCfg.monitorSymbolsInSlot[1] = 0;
512 pdcchCfg.numCandAggLvl1 = SearchSpace__nrofCandidates__aggregationLevel1_n8;
513 pdcchCfg.numCandAggLvl2 = SearchSpace__nrofCandidates__aggregationLevel2_n4;
514 pdcchCfg.numCandAggLvl4 = SearchSpace__nrofCandidates__aggregationLevel4_n2;
515 pdcchCfg.numCandAggLvl8 = SearchSpace__nrofCandidates__aggregationLevel8_n1;
516 pdcchCfg.numCandAggLvl16 = SearchSpace__nrofCandidates__aggregationLevel16_n0;
517 pdcchCfg.searchSpcType = SearchSpace__searchSpaceType_PR_common;
518 pdcchCfg.commSrchSpcDciFrmt = PDCCH_SERACH_SPACE_DCI_FORMAT;
519 pdcchCfg.searchSpcSib1 = PDCCH_SEARCH_SPACE_ID_SIB1;
520 pdcchCfg.pagingSearchSpc = PDCCH_SEARCH_SPACE_ID_PAGING;
521 pdcchCfg.raSearchSpc = PDCCH_SEARCH_SPACE_ID_PAGING;
522 srvCellCfgComm->dlCfg.pdcchCfg = pdcchCfg;
524 /* Configuring PDSCH Config Common For SIB1 */
525 pdschCfg.present = BWP_DownlinkCommon__pdsch_ConfigCommon_PR_setup;
526 pdschCfg.numTimeDomRsrcAlloc = 2;
527 pdschCfg.timeDomAlloc[0].k0 = PDSCH_K0_CFG1;
528 pdschCfg.timeDomAlloc[0].mapType = \
529 PDSCH_TimeDomainResourceAllocation__mappingType_typeA;
530 pdschCfg.timeDomAlloc[0].sliv = calcSliv(PDSCH_START_SYMBOL,PDSCH_LENGTH_SYMBOL);
532 pdschCfg.timeDomAlloc[1].k0 = PDSCH_K0_CFG2;
533 pdschCfg.timeDomAlloc[1].mapType = \
534 PDSCH_TimeDomainResourceAllocation__mappingType_typeA;
535 pdschCfg.timeDomAlloc[1].sliv = calcSliv(PDSCH_START_SYMBOL,PDSCH_LENGTH_SYMBOL);
537 srvCellCfgComm->dlCfg.pdschCfg = pdschCfg;
539 /* Configuring BCCH Config for SIB1 */
540 srvCellCfgComm->dlCfg.bcchCfg.modPrdCoeff = \
541 BCCH_Config__modificationPeriodCoeff_n16;
543 /* Configuring PCCH Config for SIB1 */
544 pcchCfg.dfltPagingCycle = PagingCycle_rf256;
545 pcchCfg.nAndPagingFrmOffsetType = PCCH_Config__nAndPagingFrameOffset_PR_oneT;
546 pcchCfg.pageFrameOffset = 0;
547 pcchCfg.ns = PCCH_Config__ns_one;
548 pcchCfg.firstPDCCHMontioringType = PCCH_Config__firstPDCCH_MonitoringOccasionOfPO_PR_sCS30KHZoneT_SCS15KHZhalfT;
549 memset(pcchCfg.firstPDCCHMontioringInfo, 0, sizeof(uint16_t));
550 pcchCfg.firstPDCCHMontioringInfo[0] = 44;
552 srvCellCfgComm->dlCfg.pcchCfg = pcchCfg;
555 /* Configuring UL Config Common */
557 srvCellCfgComm->ulCfg.ulScsCarrier.scsOffset = cellParams.ssbOffset;
558 srvCellCfgComm->ulCfg.ulScsCarrier.scs = convertScsValToScsEnum(cellParams.ssbSubCarrierSpacing);
559 srvCellCfgComm->ulCfg.ulScsCarrier.scsBw = cellParams.bSChannelBwUL;
561 srvCellCfgComm->ulCfg.ulScsCarrier.scsOffset = SSB_SUBCARRIER_OFFSET;
562 srvCellCfgComm->ulCfg.ulScsCarrier.scs = NR_SCS;
563 srvCellCfgComm->ulCfg.ulScsCarrier.scsBw = NR_BANDWIDTH;
565 srvCellCfgComm->ulCfg.pMax = UL_P_MAX;
566 srvCellCfgComm->ulCfg.locAndBw = FREQ_LOC_BW;
567 srvCellCfgComm->ulCfg.timeAlignTimerComm = TimeAlignmentTimer_infinity;
569 /* Configuring RACH Config Common for SIB1 */
570 rachCfg.present = BWP_UplinkCommon__rach_ConfigCommon_PR_setup;
571 rachCfg.prachCfgIdx = PRACH_CONFIG_IDX;
572 rachCfg.msg1Fdm = RACH_ConfigGeneric__msg1_FDM_one;
573 rachCfg.msg1FreqStart = PRACH_FREQ_START;
574 rachCfg.zeroCorrZoneCfg = ZERO_CORRELATION_ZONE_CFG;
575 rachCfg.preambleRcvdTgtPwr = PRACH_PREAMBLE_RCVD_TGT_PWR;
576 rachCfg.preambleTransMax = RACH_ConfigGeneric__preambleTransMax_n200;
577 rachCfg.pwrRampingStep = RACH_ConfigGeneric__powerRampingStep_dB2;
578 rachCfg.raRspWindow = RACH_ConfigGeneric__ra_ResponseWindow_sl10;
579 rachCfg.numRaPreamble = NUM_RA_PREAMBLE;
580 rachCfg.ssbPerRachOccPresent = \
581 RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_one;
582 rachCfg.numSsbPerRachOcc = SSB_PER_RACH;
583 rachCfg.contResTimer = RACH_ConfigCommon__ra_ContentionResolutionTimer_sf64;
584 rachCfg.rsrpThreshSsb = RSRP_THRESHOLD_SSB;
585 rachCfg.rootSeqIdxPresent = RACH_ConfigCommon__prach_RootSequenceIndex_PR_l139;
586 rachCfg.rootSeqIdx = ROOT_SEQ_IDX;
587 rachCfg.msg1Scs = PRACH_SUBCARRIER_SPACING ;
588 rachCfg.restrictedSetCfg = PRACH_RESTRICTED_SET_CFG;
589 srvCellCfgComm->ulCfg.rachCfg = rachCfg;
591 /* Configuring PUSCH Config Common for SIB1 */
592 puschCfg.puschCfgPresent = BWP_UplinkCommon__pusch_ConfigCommon_PR_setup;
593 puschCfg.numTimeDomRsrcAlloc = 2;
594 puschCfg.timeDomAllocList[0].k2 = PUSCH_K2_CFG1;
595 puschCfg.timeDomAllocList[0].mapType = PUSCH_TimeDomainResourceAllocation__mappingType_typeA;
596 puschCfg.timeDomAllocList[0].sliv = calcSliv(PUSCH_START_SYMBOL,PUSCH_LENGTH_SYMBOL);
597 puschCfg.timeDomAllocList[1].k2 = PUSCH_K2_CFG2;
598 puschCfg.timeDomAllocList[1].mapType = PUSCH_TimeDomainResourceAllocation__mappingType_typeA;
599 puschCfg.timeDomAllocList[1].sliv = calcSliv(PUSCH_START_SYMBOL,PUSCH_LENGTH_SYMBOL);
600 puschCfg.msg3DeltaPreamble = PUSCH_MSG3_DELTA_PREAMBLE;
601 puschCfg.p0NominalWithGrant = PUSCH_P0_NOMINAL_WITH_GRANT;
602 srvCellCfgComm->ulCfg.puschCfg = puschCfg;
604 /* Configuring PUCCH Config Common for SIB1 */
605 pucchCfg.present = BWP_UplinkCommon__pucch_ConfigCommon_PR_setup;
606 pucchCfg.rsrcComm = PUCCH_RSRC_COMMON;
607 pucchCfg.grpHop = PUCCH_ConfigCommon__pucch_GroupHopping_neither;
608 pucchCfg.p0Nominal = PUCCH_P0_NOMINAL;
609 srvCellCfgComm->ulCfg.pucchCfg = pucchCfg;
611 /* Configuring TDD UL DL config common */
612 tddCfg.refScs = SubcarrierSpacing_kHz30;
613 tddCfg.txPrd = TDD_UL_DL_Pattern__dl_UL_TransmissionPeriodicity_ms5;
614 tddCfg.numDlSlots = NUM_DL_SLOTS;
615 tddCfg.numDlSymbols = NUM_DL_SYMBOLS;
616 tddCfg.numUlSlots = NUM_UL_SLOTS;
617 tddCfg.numUlSymbols = NUM_UL_SYMBOLS;
618 srvCellCfgComm->tddCfg = tddCfg;
620 srvCellCfgComm->ssbPosInBurst = 192;
621 srvCellCfgComm->ssbPrdServingCell = SSB_PERIODICITY_20MS;
622 srvCellCfgComm->ssPbchBlockPwr = SSB_PBCH_PWR;
627 /*******************************************************************
629 * @brief Configures the DU Parameters
636 * - Initializes the DuCfg members.
637 * - Calls readMacCfg()
639 * @params[in] system task ID
640 * @return ROK - success
643 * ****************************************************************/
647 uint8_t srvdCellIdx, bandIdx, sliceIdx, plmnIdx;
648 uint8_t brdcstPlmnIdx, freqBandIdx, srvdPlmnIdx;
649 uint32_t ipv4_du, ipv4_cu, ipv4_ric;
652 F1TaiSliceSuppLst *taiSliceSuppLst;
655 /* Note: Added these below variable for local testing*/
656 Snssai snssai[NUM_OF_SUPPORTED_SLICE] = {{1,{2,3,4}},{5,{6,7,8}}};
660 if( getStartupConfig(&g_cfg) != ROK )
664 cmInetAddr((S8*)g_cfg.DU_IPV4_Addr, &ipv4_du);
665 cmInetAddr((S8*)g_cfg.CU_IPV4_Addr, &ipv4_cu);
666 cmInetAddr((S8*)g_cfg.RIC_IPV4_Addr, &ipv4_ric);
668 duCfgParam.sctpParams.cuPort = g_cfg.CU_Port;
669 duCfgParam.sctpParams.ricPort = g_cfg.RIC_Port;
671 cmInetAddr((S8*)DU_IP_V4_ADDR, &ipv4_du);
672 cmInetAddr((S8*)CU_IP_V4_ADDR, &ipv4_cu);
673 cmInetAddr((S8*)RIC_IP_V4_ADDR, &ipv4_ric);
675 duCfgParam.sctpParams.cuPort = CU_PORT;
676 duCfgParam.sctpParams.ricPort = RIC_PORT;
679 fillDuPort(duCfgParam.sctpParams.duPort);
681 /* F1 DU IP Address and Port*/
682 duCfgParam.sctpParams.duIpAddr.ipV4Addr = ipv4_du;
684 /* F1 CU IP Address and Port*/
685 duCfgParam.sctpParams.cuIpAddr.ipV4Addr = ipv4_cu;
687 /* Fill RIC Params */
688 duCfgParam.sctpParams.ricIpAddr.ipV4Addr = ipv4_ric;
690 /* EGTP Parameters */
691 duCfgParam.egtpParams.localIp.ipV4Pres = TRUE;
692 duCfgParam.egtpParams.localIp.ipV4Addr = ipv4_du;
693 duCfgParam.egtpParams.localPort = DU_EGTP_PORT;
694 duCfgParam.egtpParams.destIp.ipV4Pres = TRUE;
695 duCfgParam.egtpParams.destIp.ipV4Addr = ipv4_cu;
696 duCfgParam.egtpParams.destPort = CU_EGTP_PORT;
697 duCfgParam.egtpParams.minTunnelId = MIN_TEID;
698 duCfgParam.egtpParams.maxTunnelId = MAX_TEID;
700 duCfgParam.maxUe = 32; //TODO: Check
702 duCfgParam.duId = DU_ID;
703 strcpy((char*)duCfgParam.duName,DU_NAME);
706 mib.sysFrmNum = SYS_FRAME_NUM;
708 mib.subCarrierSpacingCommon = MIB__subCarrierSpacingCommon_scs30or120;
710 mib.subCarrierSpacingCommon = MIB__subCarrierSpacingCommon_scs15or60;
712 mib.ssb_SubcarrierOffset = SSB_SC_OFFSET; //Kssb
713 mib.dmrs_TypeA_Position = MIB__dmrs_TypeA_Position_pos2;
714 mib.controlResourceSetZero = CORESET_0_INDEX;
715 mib.searchSpaceZero = SEARCHSPACE_0_INDEX;
716 mib.cellBarred = MIB__cellBarred_notBarred;
717 mib.intraFreqReselection =
718 MIB__intraFreqReselection_notAllowed;
719 duCfgParam.mibParams = mib;
722 memset(&sib1.plmn, 0, sizeof(Plmn));
723 sib1.plmn.mcc[0] = PLMN_MCC0;
724 sib1.plmn.mcc[1] = PLMN_MCC1;
725 sib1.plmn.mcc[2] = PLMN_MCC2;
726 sib1.plmn.mnc[0] = PLMN_MNC0;
727 sib1.plmn.mnc[1] = PLMN_MNC1;
728 sib1.ranac = DU_RANAC;
731 sib1.tac = cellParams.nRTAC;
732 sib1.cellIdentity = CELL_IDENTITY * cellParams.cellLocalId;
733 DU_LOG("\n*********DEBUG --> DU_APP: readCfg(): OAM CellLocalId=%d", \
737 sib1.cellIdentity = CELL_IDENTITY * NR_CELL_ID;
739 sib1.cellResvdForOpUse = PLMN_IdentityInfo__cellReservedForOperatorUse_notReserved;
740 sib1.connEstFailCnt = ConnEstFailureControl__connEstFailCount_n3;
741 sib1.connEstFailOffValidity = ConnEstFailureControl__connEstFailOffsetValidity_s120;
742 sib1.siSchedInfo.winLen = SI_SchedulingInfo__si_WindowLength_s5;
743 sib1.siSchedInfo.broadcastSta = SchedulingInfo__si_BroadcastStatus_broadcasting;
744 sib1.siSchedInfo.preiodicity = SchedulingInfo__si_Periodicity_rf8;
745 sib1.siSchedInfo.sibType = SIB_TypeInfo__type_sibType2;
746 sib1.siSchedInfo.sibValTag = SIB1_VALUE_TAG;
748 fillServCellCfgCommSib(&sib1.srvCellCfgCommSib);
750 duCfgParam.sib1Params = sib1;
752 for(srvdCellIdx=0; srvdCellIdx<DEFAULT_CELLS; srvdCellIdx++)
754 memset(&duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.nrCgi.plmn, 0, sizeof(Plmn));
755 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.nrCgi.plmn.mcc[0] = PLMN_MCC0;
756 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.nrCgi.plmn.mcc[1] = PLMN_MCC1;
757 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.nrCgi.plmn.mcc[2] = PLMN_MCC2;
758 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.nrCgi.plmn.mnc[0] = PLMN_MNC0;
759 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.nrCgi.plmn.mnc[1] = PLMN_MNC1;
763 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.nrPci = cellParams.nRPCI;
765 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.nrPci = NR_PCI;
767 /* List of Available PLMN */
768 for(srvdPlmnIdx=0; srvdPlmnIdx<MAX_PLMN; srvdPlmnIdx++)
770 /* As per spec 38.473, Plmn identity consists of 3 digit from mcc
771 * followed by either 2 digit or 3 digits of mnc */
773 memset(&duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].plmn, 0,\
776 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].plmn.mcc[0] = cellParams.plmnList[srvdPlmnIdx].mcc[0];
777 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].plmn.mcc[1] = cellParams.plmnList[srvdPlmnIdx].mcc[1];
778 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].plmn.mcc[2] = cellParams.plmnList[srvdPlmnIdx].mcc[2];
779 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].plmn.mnc[0] = cellParams.plmnList[srvdPlmnIdx].mnc[0];
780 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].plmn.mnc[1] = cellParams.plmnList[srvdPlmnIdx].mnc[1];
781 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].plmn.mnc[2] = cellParams.plmnList[srvdPlmnIdx].mnc[2];
783 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].plmn.mcc[0] = PLMN_MCC0;
784 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].plmn.mcc[1] = PLMN_MCC1;
785 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].plmn.mcc[2] = PLMN_MCC2;
786 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].plmn.mnc[0] = PLMN_MNC0;
787 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].plmn.mnc[1] = PLMN_MNC1;
790 /* List of Extended PLMN */
791 for(srvdPlmnIdx=0; srvdPlmnIdx<MAX_PLMN; srvdPlmnIdx++)
793 /* As per spec 38.473, Plmn identity consists of 3 digit from mcc
794 * followed by either 2 digit or 3 digits of mnc */
796 memset(&duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].extPlmn, 0, sizeof(Plmn));
797 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].extPlmn.mcc[0] = PLMN_MCC0;
798 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].extPlmn.mcc[1] = PLMN_MCC1;
799 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].extPlmn.mcc[2] = PLMN_MCC2;
800 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].extPlmn.mnc[0] = PLMN_MNC0;
801 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].extPlmn.mnc[1] = PLMN_MNC1;
803 /* List of Supporting Slices */
804 for(srvdPlmnIdx=0; srvdPlmnIdx<MAX_PLMN; srvdPlmnIdx++)
806 taiSliceSuppLst = &duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].\
809 /* TODO Calculte the exact number of supported slices once will get
810 * cell configuration from O1 */
811 taiSliceSuppLst->numSupportedSlices = NUM_OF_SUPPORTED_SLICE;
812 if(taiSliceSuppLst->numSupportedSlices > MAX_NUM_OF_SLICE_ITEMS)
814 DU_LOG("\nERROR --> DU_APP: readCfg(): Number of supported slice [%d] is more than 1024",\
815 taiSliceSuppLst->numSupportedSlices);
819 DU_ALLOC(taiSliceSuppLst->snssai, taiSliceSuppLst->numSupportedSlices*sizeof(Snssai*));
820 if(taiSliceSuppLst->snssai == NULLP)
822 DU_LOG("\nERROR --> DU_APP: readCfg():Memory allocation failed");
826 for(sliceIdx=0; sliceIdx<taiSliceSuppLst->numSupportedSlices; sliceIdx++)
828 DU_ALLOC(taiSliceSuppLst->snssai[sliceIdx], sizeof(Snssai));
829 if(taiSliceSuppLst->snssai[sliceIdx] == NULLP)
831 DU_LOG("\nERROR --> DU_APP: readCfg():Memory allocation failed");
835 memcpy(taiSliceSuppLst->snssai[sliceIdx]->sd, cellParams.plmnList[sliceIdx].sd, \
836 SD_SIZE*sizeof(uint8_t));
837 taiSliceSuppLst->snssai[sliceIdx]->sst = cellParams.plmnList[sliceIdx].sst;
839 memcpy(taiSliceSuppLst->snssai[sliceIdx], &snssai[sliceIdx], sizeof(Snssai));
846 /* NR TDD Mode info */
848 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.nrArfcn = cellParams.arfcnUL;
849 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.sulInfo.sulArfcn = cellParams.arfcnSUL;
850 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.sulInfo.sulTxBw.nrScs = convertScsPeriodicityToEnum(cellParams.ssbPeriodicity);
852 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.nrArfcn = NR_UL_ARFCN;
853 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.sulInfo.sulArfcn = SUL_ARFCN;
854 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.sulInfo.sulTxBw.nrScs = SSB_PRDCTY_MS_20;
856 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.sulInfo.sulTxBw.nrb = NRB_106;
858 for(freqBandIdx=0; freqBandIdx<MAX_NRCELL_BANDS; freqBandIdx++)
860 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.freqBand[freqBandIdx].nrFreqBand =\
862 for(bandIdx=0; bandIdx<MAX_NRCELL_BANDS; bandIdx++)
864 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.freqBand[freqBandIdx].sulBand[bandIdx]\
869 /* NR FDD Mode info */
871 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.nrArfcn = cellParams.arfcnUL;
872 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.sulInfo.sulArfcn = cellParams.arfcnSUL;
873 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.ulTxBw.nrScs = convertScsPeriodicityToEnum(cellParams.ssbPeriodicity);
874 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.sulInfo.sulTxBw.nrScs = convertScsPeriodicityToEnum(cellParams.ssbPeriodicity);
875 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.nrArfcn = cellParams.arfcnDL;
876 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.sulInfo.sulArfcn = cellParams.arfcnSUL;
877 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.sulInfo.sulTxBw.nrScs = convertScsPeriodicityToEnum(cellParams.ssbPeriodicity);
878 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.dlTxBw.nrScs = convertScsPeriodicityToEnum(cellParams.ssbPeriodicity);
880 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.nrArfcn = NR_UL_ARFCN;
881 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.sulInfo.sulArfcn = SUL_ARFCN;
882 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.ulTxBw.nrScs = SSB_PRDCTY_MS_20;
883 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.sulInfo.sulTxBw.nrScs = SSB_PRDCTY_MS_20;
884 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.nrArfcn = NR_DL_ARFCN;
885 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.sulInfo.sulArfcn = SUL_ARFCN;
886 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.sulInfo.sulTxBw.nrScs = SSB_PRDCTY_MS_20;
887 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.dlTxBw.nrScs = SSB_PRDCTY_MS_20;
889 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.sulInfo.sulTxBw.nrb = NRB_106;
890 for(freqBandIdx=0; freqBandIdx<MAX_NRCELL_BANDS; freqBandIdx++)
892 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.freqBand[freqBandIdx].\
893 nrFreqBand = NR_FREQ_BAND;
894 for(bandIdx=0; bandIdx<MAX_NRCELL_BANDS; bandIdx++)
896 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.freqBand[freqBandIdx].\
897 sulBand[bandIdx] = SUL_BAND;
900 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.sulInfo.sulTxBw.nrb = NRB_106;
901 for(freqBandIdx=0; freqBandIdx<MAX_NRCELL_BANDS; freqBandIdx++)
903 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.freqBand[freqBandIdx].\
904 nrFreqBand = NR_FREQ_BAND;
905 for(bandIdx=0; bandIdx<MAX_NRCELL_BANDS; bandIdx++)
907 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.freqBand[freqBandIdx].\
908 sulBand[bandIdx] = SUL_BAND;
912 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.ulTxBw.nrb = NRB_106;
913 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.dlTxBw.nrb = NRB_106;
916 /*Measurement Config and Cell Config */
917 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.measTimeCfg = TIME_CFG;
919 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellDir = DL_UL;
921 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellType=CELL_TYPE;
923 /* Broadcast PLMN Identity */
924 for(brdcstPlmnIdx=0; brdcstPlmnIdx<MAX_BPLMN_NRCELL_MINUS_1; brdcstPlmnIdx++)
926 for(plmnIdx=0; plmnIdx<MAX_PLMN; plmnIdx++)
928 memset(&duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].plmn[plmnIdx],\
930 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].plmn[plmnIdx].mcc[0] =\
932 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].plmn[plmnIdx].mcc[1] =\
934 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].plmn[plmnIdx].mcc[2] =\
936 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].plmn[plmnIdx].mnc[0] =\
938 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].plmn[plmnIdx].mnc[1] =\
941 /* Extended PLMN List */
942 for(plmnIdx=0; plmnIdx<MAX_PLMN; plmnIdx++)
944 memset(&duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].\
945 extPlmn[plmnIdx], 0, sizeof(Plmn));
946 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].\
947 extPlmn[plmnIdx].mcc[0] = PLMN_MCC0;
948 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].\
949 extPlmn[plmnIdx].mcc[1] = PLMN_MCC1;
950 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].\
951 extPlmn[plmnIdx].mcc[2] = PLMN_MCC2;
952 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].\
953 extPlmn[plmnIdx].mnc[0] = PLMN_MNC0;
954 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].\
955 extPlmn[plmnIdx].mnc[1] = PLMN_MNC1;
958 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.epsTac = cellParams.nRTAC; //TODO : to check and fill
959 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.tac = cellParams.nRTAC;
960 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].tac = cellParams.nRTAC;
961 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].nrCellId = cellParams.cellLocalId;
963 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.epsTac = DU_TAC; //TODO : to check and fill
964 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.tac = DU_TAC;
965 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].tac = DU_TAC;
966 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].nrCellId = NR_CELL_ID;
968 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].ranac = NR_RANAC;
971 /*gnb DU System Info mib msg*/
973 DU_ALLOC(duCfgParam.srvdCellLst[srvdCellIdx].duSysInfo.mibMsg, encBufSize);
974 if(!(duCfgParam.srvdCellLst[srvdCellIdx].duSysInfo.mibMsg))
976 DU_LOG("\nERROR --> DU APP : Memory allocation failure at readCfg");
979 memcpy(duCfgParam.srvdCellLst[srvdCellIdx].duSysInfo.mibMsg, encBuf, encBufSize);
980 duCfgParam.srvdCellLst[srvdCellIdx].duSysInfo.mibLen = encBufSize;
982 /*gnb DU System Info mib msg*/
984 DU_ALLOC(duCfgParam.srvdCellLst[srvdCellIdx].duSysInfo.sib1Msg,\
986 if(!(duCfgParam.srvdCellLst[srvdCellIdx].duSysInfo.sib1Msg))
988 DU_LOG("\nERROR --> DU APP : Memory allocation failure at readCfg");
991 memcpy(duCfgParam.srvdCellLst[srvdCellIdx].duSysInfo.sib1Msg,\
993 duCfgParam.srvdCellLst[srvdCellIdx].duSysInfo.sib1Len = encBufSize;
997 if(readMacCfg() != ROK)
999 DU_LOG("\nERROR --> DU_APP : Failed while reading MAC config");
1006 /*******************************************************************
1008 * @brief Copy Slice Cfg in temp structre in duCfgParams
1012 * Function : cpyRrmPolicyInDuCfgParams
1015 * - Copy Slice Cfg in temp structre in duCfgParams
1017 * @params[in] RrmPolicy rrmPolicy[], uint8_t policyNum, uint8_t memberList
1018 * @return ROK - success
1021 * ****************************************************************/
1023 uint8_t cpyRrmPolicyInDuCfgParams(RrmPolicyList rrmPolicy[], uint8_t policyNum, CopyOfRecvdSliceCfg *tempSliceCfg)
1025 uint8_t policyIdx = 0, memberListIdx = 0, count = 0;
1029 tempSliceCfg->totalRrmPolicy = policyNum;
1030 DU_ALLOC(tempSliceCfg->rrmPolicy, tempSliceCfg->totalRrmPolicy * sizeof(RrmPolicy*));
1031 if(tempSliceCfg->rrmPolicy == NULLP)
1033 DU_LOG("\nERROR --> DU APP : Memory allocation failed in cpyRrmPolicyInDuCfgParams");
1037 for(policyIdx = 0; policyIdx<tempSliceCfg->totalRrmPolicy; policyIdx++)
1039 DU_ALLOC(tempSliceCfg->rrmPolicy[policyIdx], sizeof(RrmPolicy));
1040 if(tempSliceCfg->rrmPolicy[policyIdx] == NULLP)
1042 DU_LOG("\nERROR --> DU APP : Memory allocation failed in cpyRrmPolicyInDuCfgParams");
1046 if(rrmPolicy[policyIdx].rRMMemberNum)
1048 tempSliceCfg->rrmPolicy[policyIdx]->numMemberList = rrmPolicy[policyIdx].rRMMemberNum;
1049 DU_ALLOC(tempSliceCfg->rrmPolicy[policyIdx]->memberList, tempSliceCfg->rrmPolicy[policyIdx]->numMemberList * sizeof(PolicyMemberList*))
1050 if(tempSliceCfg->rrmPolicy[policyIdx]->memberList == NULLP)
1052 DU_LOG("\nERROR --> DU APP : Memory allocation failed in cpyRrmPolicyInDuCfgParams");
1056 for(memberListIdx = 0; memberListIdx<tempSliceCfg->rrmPolicy[policyIdx]->numMemberList; memberListIdx++)
1058 DU_ALLOC(tempSliceCfg->rrmPolicy[policyIdx]->memberList[memberListIdx], sizeof(PolicyMemberList))
1059 if(tempSliceCfg->rrmPolicy[policyIdx]->memberList[memberListIdx] == NULLP)
1061 DU_LOG("\nERROR --> DU APP : Memory allocation failed in cpyRrmPolicyInDuCfgParams");
1064 memcpy(&tempSliceCfg->rrmPolicy[policyIdx]->memberList[memberListIdx]->snssai.sd, &rrmPolicy[policyIdx].rRMPolicyMemberList[memberListIdx].sd, 3 * sizeof(uint8_t));
1065 memcpy(&tempSliceCfg->rrmPolicy[policyIdx]->memberList[memberListIdx]->snssai.sst, &rrmPolicy[policyIdx].rRMPolicyMemberList[memberListIdx].sst, sizeof(uint8_t));
1066 memcpy(&tempSliceCfg->rrmPolicy[policyIdx]->memberList[memberListIdx]->plmn.mcc, &rrmPolicy[policyIdx].rRMPolicyMemberList[memberListIdx].mcc, 3 * sizeof(uint8_t));
1067 memcpy(&tempSliceCfg->rrmPolicy[policyIdx]->memberList[memberListIdx]->plmn.mnc, &rrmPolicy[policyIdx].rRMPolicyMemberList[memberListIdx].mnc, 3 * sizeof(uint8_t));
1072 tempSliceCfg->rrmPolicy[policyIdx]->rsrcType = rrmPolicy[policyIdx].resourceType;
1073 tempSliceCfg->rrmPolicy[policyIdx]->policyMaxRatio = rrmPolicy[policyIdx].rRMPolicyMaxRatio;
1074 tempSliceCfg->rrmPolicy[policyIdx]->policyMinRatio = rrmPolicy[policyIdx].rRMPolicyMinRatio;
1075 tempSliceCfg->rrmPolicy[policyIdx]->policyDedicatedRatio = rrmPolicy[policyIdx].rRMPolicyDedicatedRatio;
1078 tempSliceCfg->totalSliceCount = count;
1083 /*******************************************************************
1085 * @brief Reads config and posts message to du_app on completion
1093 * - Post to du_app for further processing
1096 * @return ROK - success
1099 * ****************************************************************/
1105 memset(&duCfgParam, 0, sizeof(DuCfgParams));
1107 //Read configs into duCfgParams
1108 if(readCfg() != ROK)
1110 DU_LOG("\nERROR --> DU_APP : Reading configuration failed");
1114 //Fill pst structure
1115 memset(&(pst), 0, sizeof(Pst));
1116 pst.srcEnt = (Ent)ENTDUAPP;
1117 pst.srcInst = (Inst)DU_INST;
1118 pst.srcProcId = DU_PROC;
1119 pst.dstEnt = pst.srcEnt;
1120 pst.dstInst = pst.srcInst;
1121 pst.dstProcId = pst.srcProcId;
1123 pst.selector = ODU_SELECTOR_TC;
1127 if(ODU_GET_MSG_BUF(DFLT_REGION, DU_POOL, &mBuf) != ROK)
1129 DU_LOG("\nERROR --> DU_APP : Memory allocation failed in duReadCfg");
1133 if (ODU_POST_TASK(&pst, mBuf) != ROK)
1135 DU_LOG("\nERROR --> DU_APP : ODU_POST_TASK failed in duReadCfg");
1142 /**********************************************************************
1144 **********************************************************************/