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"
26 #include "du_app_mac_inf.h"
27 #include "du_app_rlc_inf.h"
28 #include "du_e2ap_mgr.h"
32 #include "du_f1ap_conversions.h"
33 #include "OCTET_STRING.h"
34 #include "BIT_STRING.h"
35 #include "odu_common_codec.h"
37 #include "SearchSpace.h"
38 #include "SIB-TypeInfo.h"
39 #include "SchedulingInfo.h"
40 #include "SI-SchedulingInfo.h"
41 #include "ConnEstFailureControl.h"
42 #include "PLMN-IdentityInfo.h"
43 #include "PDSCH-TimeDomainResourceAllocation.h"
44 #include "BCCH-Config.h"
45 #include "PagingCycle.h"
46 #include "PCCH-Config.h"
47 #include "TimeAlignmentTimer.h"
48 #include "BCCH-DL-SCH-Message.h"
49 #include "RACH-ConfigGeneric.h"
50 #include "PUSCH-TimeDomainResourceAllocation.h"
51 #include "PUCCH-ConfigCommon.h"
52 #include "SubcarrierSpacing.h"
53 #include "TDD-UL-DL-Pattern.h"
54 #include "RACH-ConfigCommon.h"
55 #include "BWP-DownlinkCommon.h"
56 #include "BWP-UplinkCommon.h"
57 #include "TDD-UL-DL-ConfigCommon.h"
58 #include "du_sys_info_hdl.h"
61 #include "CmInterface.h"
62 extern StartupConfig g_cfg;
63 extern NRCellDU cellParams;
66 char encBuf[ENC_BUF_MAX_LEN];
69 /* Filling Slot configuration as :
70 * 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
71 * 0 DL DL DL DL DL DL DL DL DL DL DL DL DL DL
72 * 1 DL DL DL DL DL DL DL DL DL DL DL DL DL DL
73 * 2 DL DL DL DL DL DL DL DL DL DL DL DL DL DL
74 3 DL DL DL DL DL DL DL DL DL DL DL DL DL DL
75 4 DL DL DL DL DL DL DL DL DL DL DL DL DL DL
76 5 DL DL DL DL DL DL DL DL DL DL DL DL DL DL
77 6 DL DL DL DL DL DL DL DL DL DL DL DL DL DL
78 7 DL DL DL DL DL DL DL DL DL DL DL DL F UL
79 8 UL UL UL UL UL UL UL UL UL UL UL UL UL UL
80 9 UL UL UL UL UL UL UL UL UL UL UL UL UL UL
83 /*******************************************************************
84 * @brief Reads the CL Configuration.
88 * Function : readMacCfg
91 * - Fills up the cell configuration for CL.
92 * - Calls FillSlotConfig()
95 * @return ROK - success
98 * ****************************************************************/
102 uint8_t idx=0, sliceIdx=0,plmnIdx = 0;
103 F1TaiSliceSuppLst *taiSliceSuppLst;
105 /* DL carrier configuration */
107 duCfgParam.macCellCfg.cellId = cellParams.cellLocalId;
108 duCfgParam.macCellCfg.carrCfg.dlBw = cellParams.bSChannelBwDL;
109 duCfgParam.macCellCfg.carrCfg.dlFreq = convertArfcnToFreqKhz(cellParams.arfcnDL);
111 duCfgParam.macCellCfg.cellId = NR_CELL_ID;
112 duCfgParam.macCellCfg.carrCfg.dlBw = NR_BANDWIDTH;
113 duCfgParam.macCellCfg.carrCfg.dlFreq = convertArfcnToFreqKhz(NR_DL_ARFCN);
115 duCfgParam.macCellCfg.carrCfg.numTxAnt = NUM_TX_ANT;
116 /* UL Carrier configuration */
118 duCfgParam.macCellCfg.carrCfg.ulBw = cellParams.bSChannelBwUL;
119 duCfgParam.macCellCfg.carrCfg.ulFreq = convertArfcnToFreqKhz(cellParams.arfcnUL);
121 duCfgParam.macCellCfg.carrCfg.ulBw = NR_BANDWIDTH;
122 duCfgParam.macCellCfg.carrCfg.ulFreq = convertArfcnToFreqKhz(NR_UL_ARFCN);
124 duCfgParam.macCellCfg.carrCfg.numRxAnt = NUM_RX_ANT;
126 /* Cell configuration */
128 duCfgParam.macCellCfg.cellCfg.opState = cellParams.operationalState;
129 duCfgParam.macCellCfg.cellCfg.adminState = cellParams.administrativeState;
130 duCfgParam.macCellCfg.cellCfg.cellState = cellParams.cellState;
131 duCfgParam.macCellCfg.cellCfg.phyCellId = cellParams.nRPCI;
132 duCfgParam.macCellCfg.cellCfg.tac = cellParams.nRTAC;
133 duCfgParam.macCellCfg.cellCfg.ssbFreq = convertArfcnToFreqKhz(cellParams.ssbFrequency);
135 duCfgParam.macCellCfg.cellCfg.opState = OP_DISABLED;
136 duCfgParam.macCellCfg.cellCfg.adminState = ADMIN_UNLOCKED;
137 duCfgParam.macCellCfg.cellCfg.cellState = CELL_INACTIVE;
138 duCfgParam.macCellCfg.cellCfg.phyCellId = NR_PCI;
139 duCfgParam.macCellCfg.cellCfg.tac = DU_TAC;
140 duCfgParam.macCellCfg.cellCfg.ssbFreq = SSB_FREQUENCY;
142 /* Plmn And SNSSAI Configuration */
143 for(plmnIdx = 0; plmnIdx < MAX_PLMN; plmnIdx++)
145 memcpy(&duCfgParam.macCellCfg.cellCfg.plmnInfoList[plmnIdx].plmn, &duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.srvdPlmn[plmnIdx].plmn,\
147 taiSliceSuppLst = &duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.srvdPlmn[plmnIdx].taiSliceSuppLst;
148 duCfgParam.macCellCfg.cellCfg.plmnInfoList[plmnIdx].numSupportedSlice = taiSliceSuppLst->numSupportedSlices;
149 if(taiSliceSuppLst->snssai)
151 DU_ALLOC_SHRABL_BUF(duCfgParam.macCellCfg.cellCfg.plmnInfoList[plmnIdx].snssai, (duCfgParam.macCellCfg.cellCfg.plmnInfoList[plmnIdx].numSupportedSlice) * sizeof(Snssai*));
152 if(duCfgParam.macCellCfg.cellCfg.plmnInfoList[plmnIdx].snssai == NULLP)
154 DU_LOG("\nERROR --> DU_APP: Memory allocation failed at readMacCfg");
158 for(sliceIdx=0; sliceIdx < taiSliceSuppLst->numSupportedSlices; sliceIdx++)
160 if(taiSliceSuppLst->snssai[sliceIdx] != NULLP)
162 DU_ALLOC_SHRABL_BUF(duCfgParam.macCellCfg.cellCfg.plmnInfoList[plmnIdx].snssai[sliceIdx], sizeof(Snssai));
163 if(duCfgParam.macCellCfg.cellCfg.plmnInfoList[plmnIdx].snssai[sliceIdx] == NULLP)
165 DU_LOG("\nERROR --> DU_APP: Memory allocation failed at readMacCfg");
168 memcpy(duCfgParam.macCellCfg.cellCfg.plmnInfoList[plmnIdx].snssai[sliceIdx], taiSliceSuppLst->snssai[sliceIdx], sizeof(Snssai));
172 duCfgParam.macCellCfg.cellCfg.numerology = NR_NUMEROLOGY;
173 duCfgParam.macCellCfg.cellCfg.dupType = DUPLEX_MODE;
175 /* SSB configuration */
176 duCfgParam.macCellCfg.ssbCfg.ssbPbchPwr = SSB_PBCH_PWR;
177 duCfgParam.macCellCfg.ssbCfg.bchPayloadFlag = BCH_PAYLOAD;
178 duCfgParam.macCellCfg.ssbCfg.ssbOffsetPointA = OFFSET_TO_POINT_A;
179 duCfgParam.macCellCfg.ssbCfg.betaPss = BETA_PSS;
181 duCfgParam.macCellCfg.ssbCfg.scsCmn = convertScsValToScsEnum(cellParams.ssbSubCarrierSpacing);
182 duCfgParam.macCellCfg.ssbCfg.ssbPeriod = convertSSBPeriodicityToEnum(cellParams.ssbPeriodicity);
183 duCfgParam.macCellCfg.ssbCfg.ssbScOffset = cellParams.ssbOffset;
185 duCfgParam.macCellCfg.ssbCfg.scsCmn = NR_SCS;
186 duCfgParam.macCellCfg.ssbCfg.ssbPeriod = SSB_PRDCTY_MS_20;
187 duCfgParam.macCellCfg.ssbCfg.ssbScOffset = SSB_SUBCARRIER_OFFSET;
189 duCfgParam.macCellCfg.ssbCfg.ssbMask[0] = 1; /* only one SSB is transmitted */
190 if(BuildMibPdu() != ROK)
192 DU_LOG("\nERROR --> Failed to build MIB PDU");
193 memset(&duCfgParam.macCellCfg.ssbCfg.mibPdu, 0, 3*sizeof(uint8_t));
197 memcpy(&duCfgParam.macCellCfg.ssbCfg.mibPdu, encBuf,encBufSize);
200 /* PRACH configuration */
201 duCfgParam.macCellCfg.prachCfg.prachSeqLen = PRACH_SEQ_LEN;
202 duCfgParam.macCellCfg.prachCfg.prachSubcSpacing = convertScsEnumValToScsVal(PRACH_SUBCARRIER_SPACING);
203 duCfgParam.macCellCfg.prachCfg.prachCfgIdx = PRACH_CONFIG_IDX;
204 duCfgParam.macCellCfg.prachCfg.msg1Fdm = NUM_PRACH_FDM;
205 duCfgParam.macCellCfg.prachCfg.fdm[0].rootSeqIdx = ROOT_SEQ_IDX;
206 duCfgParam.macCellCfg.prachCfg.fdm[0].numRootSeq = NUM_ROOT_SEQ;
207 duCfgParam.macCellCfg.prachCfg.fdm[0].k1 = 0;
208 duCfgParam.macCellCfg.prachCfg.fdm[0].zeroCorrZoneCfg = ZERO_CORRELATION_ZONE_CFG;
209 duCfgParam.macCellCfg.prachCfg.prachRstSetCfg = PRACH_RESTRICTED_SET_CFG;
210 duCfgParam.macCellCfg.prachCfg.ssbPerRach = SSB_PER_RACH;
211 duCfgParam.macCellCfg.prachCfg.msg1FreqStart = PRACH_FREQ_START;
213 duCfgParam.macCellCfg.prachCfg.totalNumRaPreamble = NUM_RA_PREAMBLE;
214 duCfgParam.macCellCfg.prachCfg.numCbPreamblePerSsb = CB_PREAMBLE_PER_SSB;
215 duCfgParam.macCellCfg.prachCfg.raRspWindow = RA_RSP_WINDOW;
217 /* TDD configuration */
219 duCfgParam.macCellCfg.tddCfg.tddPeriod = TDD_PERIODICITY;
220 duCfgParam.macCellCfg.tddCfg.nrOfDlSlots = NUM_DL_SLOTS;
221 duCfgParam.macCellCfg.tddCfg.nrOfDlSymbols = NUM_DL_SYMBOLS;
222 duCfgParam.macCellCfg.tddCfg.nrOfUlSlots = NUM_UL_SLOTS;
223 duCfgParam.macCellCfg.tddCfg.nrOfUlSymbols = NUM_UL_SYMBOLS;
229 /* fill SIB1 configuration */
230 duCfgParam.macCellCfg.cellCfg.sib1Cfg.sib1PduLen = duCfgParam.srvdCellLst[0].duSysInfo.sib1Len;
231 DU_ALLOC_SHRABL_BUF(duCfgParam.macCellCfg.cellCfg.sib1Cfg.sib1Pdu,duCfgParam.srvdCellLst[0].duSysInfo.sib1Len);
232 memcpy(duCfgParam.macCellCfg.cellCfg.sib1Cfg.sib1Pdu, duCfgParam.srvdCellLst[0].duSysInfo.sib1Msg, \
233 duCfgParam.srvdCellLst[0].duSysInfo.sib1Len);
234 duCfgParam.macCellCfg.cellCfg.sib1Cfg.pdcchCfgSib1.coresetZeroIndex = CORESET_0_INDEX;
235 duCfgParam.macCellCfg.cellCfg.sib1Cfg.pdcchCfgSib1.searchSpaceZeroIndex = SEARCHSPACE_0_INDEX;
237 duCfgParam.macCellCfg.cellCfg.sib1Cfg.pagingCfg.numPO = duCfgParam.sib1Params.srvCellCfgCommSib.dlCfg.pcchCfg.ns;
238 if((duCfgParam.sib1Params.srvCellCfgCommSib.dlCfg.pcchCfg.firstPDCCHMontioringType != \
239 PCCH_Config__firstPDCCH_MonitoringOccasionOfPO_PR_NOTHING) && (duCfgParam.macCellCfg.cellCfg.sib1Cfg.pagingCfg.numPO != 0))
241 duCfgParam.macCellCfg.cellCfg.sib1Cfg.pagingCfg.poPresent = TRUE;
242 memcpy(duCfgParam.macCellCfg.cellCfg.sib1Cfg.pagingCfg.pagingOcc,
243 duCfgParam.sib1Params.srvCellCfgCommSib.dlCfg.pcchCfg.firstPDCCHMontioringInfo,MAX_PO_PER_PF);
247 duCfgParam.macCellCfg.cellCfg.sib1Cfg.pagingCfg.poPresent = FALSE;
250 /* fill Intial DL BWP */
251 duCfgParam.macCellCfg.initialDlBwp.bwp.firstPrb = 0;
252 duCfgParam.macCellCfg.initialDlBwp.bwp.numPrb = TOTAL_PRB_20MHZ_MU0; /* configured to total BW */
253 duCfgParam.macCellCfg.initialDlBwp.bwp.scs = duCfgParam.macCellCfg.ssbCfg.scsCmn;
254 duCfgParam.macCellCfg.initialDlBwp.bwp.cyclicPrefix = NORMAL_CYCLIC_PREFIX;
255 duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.searchSpaceId = SEARCHSPACE_1_INDEX;
256 duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.coresetId = CORESET_0_INDEX;
257 duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.monitoringSlot =
258 SS_MONITORING_SLOT_SL1; /* sl1 - all slots */
259 duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.duration = 0;
260 duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.monitoringSymbol =
261 SS_MONITORING_SYMBOL;
262 duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.
263 candidate.aggLevel1 = 8;
264 duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.
265 candidate.aggLevel2 = 4;
266 duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.
267 candidate.aggLevel4 = 2;
268 duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.
269 candidate.aggLevel8 = 1;
270 duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.
271 candidate.aggLevel16 = 0;
273 duCfgParam.macCellCfg.initialDlBwp.pdschCommon.numTimeDomAlloc = NUM_TIME_DOM_RSRC_ALLOC;
275 duCfgParam.macCellCfg.initialDlBwp.pdschCommon.timeDomRsrcAllocList[idx].k0 = PDSCH_K0_CFG1;
276 duCfgParam.macCellCfg.initialDlBwp.pdschCommon.timeDomRsrcAllocList[idx].mappingType =
277 PDSCH_MAPPING_TYPE_A;
278 duCfgParam.macCellCfg.initialDlBwp.pdschCommon.timeDomRsrcAllocList[idx].startSymbol =
280 duCfgParam.macCellCfg.initialDlBwp.pdschCommon.timeDomRsrcAllocList[idx].lengthSymbol =
284 duCfgParam.macCellCfg.initialDlBwp.pdschCommon.timeDomRsrcAllocList[idx].k0 = PDSCH_K0_CFG2;
285 duCfgParam.macCellCfg.initialDlBwp.pdschCommon.timeDomRsrcAllocList[idx].mappingType =
286 PDSCH_MAPPING_TYPE_A;
287 duCfgParam.macCellCfg.initialDlBwp.pdschCommon.timeDomRsrcAllocList[idx].startSymbol =
289 duCfgParam.macCellCfg.initialDlBwp.pdschCommon.timeDomRsrcAllocList[idx].lengthSymbol =
292 /* ra-searchSpace ID is set to 1 */
293 duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.raSearchSpaceId = SEARCHSPACE_1_INDEX;
295 /* fill Intial UL BWP */
296 duCfgParam.macCellCfg.initialUlBwp.bwp.firstPrb = 0;
297 duCfgParam.macCellCfg.initialUlBwp.bwp.numPrb = TOTAL_PRB_20MHZ_MU0; /* configured to total BW */
298 duCfgParam.macCellCfg.initialUlBwp.bwp.scs = duCfgParam.macCellCfg.ssbCfg.scsCmn;
299 duCfgParam.macCellCfg.initialUlBwp.bwp.cyclicPrefix = NORMAL_CYCLIC_PREFIX;
300 duCfgParam.macCellCfg.initialUlBwp.puschCommon.numTimeDomRsrcAlloc = 2;
301 duCfgParam.macCellCfg.initialUlBwp.puschCommon.timeDomRsrcAllocList[0].k2 = PUSCH_K2_CFG1;
302 duCfgParam.macCellCfg.initialUlBwp.puschCommon.timeDomRsrcAllocList[0].mappingType =
303 PUSCH_MAPPING_TYPE_A;
304 duCfgParam.macCellCfg.initialUlBwp.puschCommon.timeDomRsrcAllocList[0].startSymbol =
306 duCfgParam.macCellCfg.initialUlBwp.puschCommon.timeDomRsrcAllocList[0].symbolLength =
309 duCfgParam.macCellCfg.initialUlBwp.puschCommon.timeDomRsrcAllocList[1].k2 = PUSCH_K2_CFG2;
310 duCfgParam.macCellCfg.initialUlBwp.puschCommon.timeDomRsrcAllocList[1].mappingType =
311 PUSCH_MAPPING_TYPE_A;
312 duCfgParam.macCellCfg.initialUlBwp.puschCommon.timeDomRsrcAllocList[1].startSymbol =
314 duCfgParam.macCellCfg.initialUlBwp.puschCommon.timeDomRsrcAllocList[1].symbolLength =
317 duCfgParam.macCellCfg.ssbCfg.dmrsTypeAPos = DMRS_TYPE_A_POS;
319 /* fill PUCCH config common */
320 duCfgParam.macCellCfg.initialUlBwp.pucchCommon.pucchResourceCommon = PUCCH_RSRC_COMMON;
321 duCfgParam.macCellCfg.initialUlBwp.pucchCommon.pucchGroupHopping = PUCCH_GROUP_HOPPING;
326 /*Note: Static Configuration, when O1 is not configuring the RRM policy*/
327 RrmPolicyList rrmPolicy;
329 rrmPolicy.resourceType = PRB;
330 rrmPolicy.rRMMemberNum = 1;
331 memcpy(rrmPolicy.rRMPolicyMemberList[0].mcc,duCfgParam.macCellCfg.cellCfg.plmnInfoList[0].plmn.mcc, 3*sizeof(uint8_t));
332 memcpy(rrmPolicy.rRMPolicyMemberList[0].mnc,duCfgParam.macCellCfg.cellCfg.plmnInfoList[0].plmn.mnc, 3*sizeof(uint8_t));
333 rrmPolicy.rRMPolicyMemberList[0].sst = 1;
334 rrmPolicy.rRMPolicyMemberList[0].sd[0] = 2;
335 rrmPolicy.rRMPolicyMemberList[0].sd[1] = 3;
336 rrmPolicy.rRMPolicyMemberList[0].sd[2] = 4;
337 rrmPolicy.rRMPolicyMaxRatio = 90;
338 rrmPolicy.rRMPolicyMinRatio = 30;
339 rrmPolicy.rRMPolicyDedicatedRatio = 10;
341 cpyRrmPolicyInDuCfgParams(&rrmPolicy, 1, &duCfgParam.tempSliceCfg);
348 /*******************************************************************
350 * @brief Configures the DU Parameters
354 * Function : fillDuPort
357 * - fills the DU Ports.
359 * @params[in] duPort array to be filled
360 * @return ROK - success
363 * ****************************************************************/
364 uint8_t fillDuPort(uint16_t *duPort)
368 duPort[F1_INTERFACE] = g_cfg.DU_Port;
369 duPort[E2_INTERFACE] = g_cfg.RIC_Port;
371 duPort[F1_INTERFACE] = F1_SCTP_PORT; /* DU Port idx 0 38472 */
372 duPort[E2_INTERFACE] = E2_SCTP_PORT; /* RIC Port idx 1 36421 */
377 /*******************************************************************
379 * @brief Configures the DU Parameters
383 * Function : calcSliv
386 * - calculate SLIV value from start and length field
388 * @params[in] start symbol
389 * @params[in] length of symbols
392 * ****************************************************************/
393 uint16_t calcSliv(uint8_t startSymbol, uint8_t lengthSymbol)
396 if((lengthSymbol-1) <= 7)
398 sliv = NUM_SYMBOLS_PER_SLOT * (lengthSymbol-1) + startSymbol;
402 sliv = NUM_SYMBOLS_PER_SLOT * (NUM_SYMBOLS_PER_SLOT - lengthSymbol + 1) \
403 + (NUM_SYMBOLS_PER_SLOT - 1 - startSymbol);
409 /*******************************************************************
411 * @brief Configures serving cell config common in sib1
415 * Function : fillServCellCfgCommSib
418 * - fills Serving cell config common for SIB1
420 * @params[in] SrvCellCfgCommSib pointer
421 * @return ROK - success
424 ** ****************************************************************/
425 uint8_t fillServCellCfgCommSib(SrvCellCfgCommSib *srvCellCfgComm)
427 PdcchCfgCommon pdcchCfg;
428 PdschCfgCommon pdschCfg;
430 RachCfgCommon rachCfg;
431 PuschCfgCommon puschCfg;
432 PucchCfgCommon pucchCfg;
433 TddUlDlCfgCommon tddCfg;
436 srvCellCfgComm->scs = convertScsValToScsEnum(cellParams.ssbSubCarrierSpacing);
438 srvCellCfgComm->scs = NR_SCS;
441 /* Configuring DL Config Common for SIB1*/
442 srvCellCfgComm->dlCfg.freqBandInd = NR_FREQ_BAND;
443 srvCellCfgComm->dlCfg.offsetToPointA = OFFSET_TO_POINT_A;
445 srvCellCfgComm->dlCfg.dlScsCarrier.scsOffset = cellParams.ssbOffset;
446 srvCellCfgComm->dlCfg.dlScsCarrier.scs = convertScsValToScsEnum(cellParams.ssbSubCarrierSpacing);
447 srvCellCfgComm->dlCfg.dlScsCarrier.scsBw = cellParams.bSChannelBwUL;
449 srvCellCfgComm->dlCfg.dlScsCarrier.scsOffset = SSB_SUBCARRIER_OFFSET;
450 srvCellCfgComm->dlCfg.dlScsCarrier.scs = NR_SCS;
451 srvCellCfgComm->dlCfg.dlScsCarrier.scsBw = NR_BANDWIDTH;
453 srvCellCfgComm->dlCfg.locAndBw = FREQ_LOC_BW;
455 /* Configuring PDCCH Config Common For SIB1 */
456 pdcchCfg.present = BWP_DownlinkCommon__pdcch_ConfigCommon_PR_setup;
457 pdcchCfg.ctrlRsrcSetZero = CORESET_0_INDEX;
458 pdcchCfg.searchSpcZero = SEARCHSPACE_0_INDEX;
459 pdcchCfg.searchSpcId = PDCCH_SEARCH_SPACE_ID;
460 pdcchCfg.ctrlRsrcSetId = PDCCH_CTRL_RSRC_SET_ID;
461 pdcchCfg.monitorSlotPrdAndOffPresent = SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl1;
462 //pdcchCfg.monitorSlotPrdAndOff = \
463 SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl1;
464 pdcchCfg.monitorSymbolsInSlot[0] = 128;
465 pdcchCfg.monitorSymbolsInSlot[1] = 0;
466 pdcchCfg.numCandAggLvl1 = SearchSpace__nrofCandidates__aggregationLevel1_n8;
467 pdcchCfg.numCandAggLvl2 = SearchSpace__nrofCandidates__aggregationLevel2_n4;
468 pdcchCfg.numCandAggLvl4 = SearchSpace__nrofCandidates__aggregationLevel4_n2;
469 pdcchCfg.numCandAggLvl8 = SearchSpace__nrofCandidates__aggregationLevel8_n1;
470 pdcchCfg.numCandAggLvl16 = SearchSpace__nrofCandidates__aggregationLevel16_n0;
471 pdcchCfg.searchSpcType = SearchSpace__searchSpaceType_PR_common;
472 pdcchCfg.commSrchSpcDciFrmt = PDCCH_SERACH_SPACE_DCI_FORMAT;
473 pdcchCfg.searchSpcSib1 = PDCCH_SEARCH_SPACE_ID_SIB1;
474 pdcchCfg.pagingSearchSpc = PDCCH_SEARCH_SPACE_ID_PAGING;
475 pdcchCfg.raSearchSpc = PDCCH_SEARCH_SPACE_ID_PAGING;
476 srvCellCfgComm->dlCfg.pdcchCfg = pdcchCfg;
478 /* Configuring PDSCH Config Common For SIB1 */
479 pdschCfg.present = BWP_DownlinkCommon__pdsch_ConfigCommon_PR_setup;
480 pdschCfg.numTimeDomRsrcAlloc = 2;
481 pdschCfg.timeDomAlloc[0].k0 = PDSCH_K0_CFG1;
482 pdschCfg.timeDomAlloc[0].mapType = PDSCH_TimeDomainResourceAllocation__mappingType_typeA;
483 pdschCfg.timeDomAlloc[0].sliv = calcSliv(PDSCH_START_SYMBOL,PDSCH_LENGTH_SYMBOL);
485 pdschCfg.timeDomAlloc[1].k0 = PDSCH_K0_CFG2;
486 pdschCfg.timeDomAlloc[1].mapType = PDSCH_TimeDomainResourceAllocation__mappingType_typeA;
487 pdschCfg.timeDomAlloc[1].sliv = calcSliv(PDSCH_START_SYMBOL,PDSCH_LENGTH_SYMBOL);
489 srvCellCfgComm->dlCfg.pdschCfg = pdschCfg;
491 /* Configuring BCCH Config for SIB1 */
492 srvCellCfgComm->dlCfg.bcchCfg.modPrdCoeff = BCCH_Config__modificationPeriodCoeff_n16;
494 /* Configuring PCCH Config for SIB1 */
495 pcchCfg.dfltPagingCycle = convertPagingCycleEnumToValue(PagingCycle_rf256);
496 pcchCfg.nAndPagingFrmOffsetType = PCCH_Config__nAndPagingFrameOffset_PR_oneT;
497 pcchCfg.pageFrameOffset = 0;
498 pcchCfg.ns = convertNsEnumToValue(PCCH_Config__ns_one);
499 pcchCfg.firstPDCCHMontioringType = PCCH_Config__firstPDCCH_MonitoringOccasionOfPO_PR_sCS30KHZoneT_SCS15KHZhalfT;
500 memset(pcchCfg.firstPDCCHMontioringInfo, 0, sizeof(uint16_t));
501 pcchCfg.firstPDCCHMontioringInfo[0] = 44;
503 srvCellCfgComm->dlCfg.pcchCfg = pcchCfg;
506 /* Configuring UL Config Common */
508 srvCellCfgComm->ulCfg.ulScsCarrier.scsOffset = cellParams.ssbOffset;
509 srvCellCfgComm->ulCfg.ulScsCarrier.scs = convertScsValToScsEnum(cellParams.ssbSubCarrierSpacing);
510 srvCellCfgComm->ulCfg.ulScsCarrier.scsBw = cellParams.bSChannelBwUL;
512 srvCellCfgComm->ulCfg.ulScsCarrier.scsOffset = SSB_SUBCARRIER_OFFSET;
513 srvCellCfgComm->ulCfg.ulScsCarrier.scs = NR_SCS;
514 srvCellCfgComm->ulCfg.ulScsCarrier.scsBw = NR_BANDWIDTH;
516 srvCellCfgComm->ulCfg.freqBandInd = NR_FREQ_BAND;
517 srvCellCfgComm->ulCfg.pMax = UL_P_MAX;
518 srvCellCfgComm->ulCfg.locAndBw = FREQ_LOC_BW;
519 srvCellCfgComm->ulCfg.timeAlignTimerComm = TimeAlignmentTimer_infinity;
521 /* Configuring RACH Config Common for SIB1 */
522 rachCfg.present = BWP_UplinkCommon__rach_ConfigCommon_PR_setup;
523 rachCfg.prachCfgIdx = PRACH_CONFIG_IDX;
524 rachCfg.msg1Fdm = RACH_ConfigGeneric__msg1_FDM_one;
525 rachCfg.msg1FreqStart = PRACH_FREQ_START;
526 rachCfg.zeroCorrZoneCfg = ZERO_CORRELATION_ZONE_CFG;
527 rachCfg.preambleRcvdTgtPwr = PRACH_PREAMBLE_RCVD_TGT_PWR;
528 rachCfg.preambleTransMax = RACH_ConfigGeneric__preambleTransMax_n200;
529 rachCfg.pwrRampingStep = RACH_ConfigGeneric__powerRampingStep_dB2;
530 rachCfg.raRspWindow = RACH_ConfigGeneric__ra_ResponseWindow_sl10;
531 rachCfg.numRaPreamble = NUM_RA_PREAMBLE;
532 rachCfg.numSsbPerRachOcc = RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_one;
533 rachCfg.numCbPreamblePerSsb = CB_PREAMBLE_PER_SSB;
534 rachCfg.contResTimer = RACH_ConfigCommon__ra_ContentionResolutionTimer_sf64;
535 rachCfg.rsrpThreshSsb = RSRP_THRESHOLD_SSB;
536 rachCfg.rootSeqIdxPresent = RACH_ConfigCommon__prach_RootSequenceIndex_PR_l139;
537 rachCfg.rootSeqIdx = ROOT_SEQ_IDX;
538 rachCfg.msg1Scs = PRACH_SUBCARRIER_SPACING ;
539 rachCfg.restrictedSetCfg = PRACH_RESTRICTED_SET_CFG;
540 srvCellCfgComm->ulCfg.rachCfg = rachCfg;
542 /* Configuring PUSCH Config Common for SIB1 */
543 puschCfg.puschCfgPresent = BWP_UplinkCommon__pusch_ConfigCommon_PR_setup;
544 puschCfg.numTimeDomRsrcAlloc = 2;
545 puschCfg.timeDomAllocList[0].k2 = PUSCH_K2_CFG1;
546 puschCfg.timeDomAllocList[0].mapType = PUSCH_TimeDomainResourceAllocation__mappingType_typeA;
547 puschCfg.timeDomAllocList[0].sliv = calcSliv(PUSCH_START_SYMBOL,PUSCH_LENGTH_SYMBOL);
548 puschCfg.timeDomAllocList[1].k2 = PUSCH_K2_CFG2;
549 puschCfg.timeDomAllocList[1].mapType = PUSCH_TimeDomainResourceAllocation__mappingType_typeA;
550 puschCfg.timeDomAllocList[1].sliv = calcSliv(PUSCH_START_SYMBOL,PUSCH_LENGTH_SYMBOL);
551 puschCfg.msg3DeltaPreamble = PUSCH_MSG3_DELTA_PREAMBLE;
552 puschCfg.p0NominalWithGrant = PUSCH_P0_NOMINAL_WITH_GRANT;
553 srvCellCfgComm->ulCfg.puschCfg = puschCfg;
555 /* Configuring PUCCH Config Common for SIB1 */
556 pucchCfg.present = BWP_UplinkCommon__pucch_ConfigCommon_PR_setup;
557 pucchCfg.rsrcComm = PUCCH_RSRC_COMMON;
558 pucchCfg.grpHop = PUCCH_ConfigCommon__pucch_GroupHopping_neither;
559 pucchCfg.p0Nominal = PUCCH_P0_NOMINAL;
560 srvCellCfgComm->ulCfg.pucchCfg = pucchCfg;
562 /* Configuring TDD UL DL config common */
563 tddCfg.refScs = SubcarrierSpacing_kHz30;
564 tddCfg.txPrd = TDD_UL_DL_Pattern__dl_UL_TransmissionPeriodicity_ms5;
565 tddCfg.numDlSlots = NUM_DL_SLOTS;
566 tddCfg.numDlSymbols = NUM_DL_SYMBOLS;
567 tddCfg.numUlSlots = NUM_UL_SLOTS;
568 tddCfg.numUlSymbols = NUM_UL_SYMBOLS;
569 srvCellCfgComm->tddCfg = tddCfg;
571 srvCellCfgComm->ssbPosInBurst = 192;
572 srvCellCfgComm->ssbPrdServingCell = SSB_PERIODICITY;
573 srvCellCfgComm->ssPbchBlockPwr = SSB_PBCH_PWR;
578 /*******************************************************************
580 * @brief Configures the DU Parameters
587 * - Initializes the DuCfg members.
588 * - Calls readMacCfg()
590 * @params[in] system task ID
591 * @return ROK - success
594 * ****************************************************************/
598 uint8_t srvdCellIdx, bandIdx, sliceIdx, plmnIdx;
599 uint8_t brdcstPlmnIdx, freqBandIdx, srvdPlmnIdx;
600 uint32_t ipv4_du, ipv4_cu, ipv4_ric;
603 F1TaiSliceSuppLst *taiSliceSuppLst;
605 duCb.e2apDb.e2TransInfo.transIdCounter = 0;
606 memset(duCb.e2apDb.e2TransInfo.onGoingTransaction, 0, MAX_NUM_TRANSACTION * sizeof(E2TransInfo));
609 /* Note: Added these below variable for local testing*/
610 Snssai snssai[NUM_OF_SUPPORTED_SLICE] = {{1,{2,3,4}},{5,{6,7,8}}};
614 if( getStartupConfig(&g_cfg) != ROK )
618 cmInetAddr((S8*)g_cfg.DU_IPV4_Addr, &ipv4_du);
619 cmInetAddr((S8*)g_cfg.CU_IPV4_Addr, &ipv4_cu);
620 cmInetAddr((S8*)g_cfg.RIC_IPV4_Addr, &ipv4_ric);
622 duCfgParam.sctpParams.cuPort = g_cfg.CU_Port;
623 duCfgParam.sctpParams.ricPort = g_cfg.RIC_Port;
625 cmInetAddr((S8*)DU_IP_V4_ADDR, &ipv4_du);
626 cmInetAddr((S8*)CU_IP_V4_ADDR, &ipv4_cu);
627 cmInetAddr((S8*)RIC_IP_V4_ADDR, &ipv4_ric);
629 duCfgParam.sctpParams.cuPort = F1_SCTP_PORT;
630 duCfgParam.sctpParams.ricPort = E2_SCTP_PORT;
633 fillDuPort(duCfgParam.sctpParams.duPort);
635 /* F1 DU IP Address and Port*/
636 duCfgParam.sctpParams.duIpAddr.ipV4Addr = ipv4_du;
638 /* F1 CU IP Address and Port*/
639 duCfgParam.sctpParams.cuIpAddr.ipV4Addr = ipv4_cu;
641 /* Fill RIC Params */
642 duCfgParam.sctpParams.ricIpAddr.ipV4Addr = ipv4_ric;
644 /* EGTP Parameters */
645 duCfgParam.egtpParams.localIp.ipV4Pres = TRUE;
646 duCfgParam.egtpParams.localIp.ipV4Addr = ipv4_du;
647 duCfgParam.egtpParams.localPort = F1_EGTP_PORT;
648 duCfgParam.egtpParams.destIp.ipV4Pres = TRUE;
649 duCfgParam.egtpParams.destIp.ipV4Addr = ipv4_cu;
650 duCfgParam.egtpParams.destPort = F1_EGTP_PORT;
651 duCfgParam.egtpParams.minTunnelId = MIN_TEID;
652 duCfgParam.egtpParams.maxTunnelId = MAX_TEID;
654 duCfgParam.maxUe = 32; //TODO: Check
657 duCfgParam.duId = DU_ID;
658 DU_ALLOC(duCfgParam.duName, sizeof(DU_NAME));
659 if(!duCfgParam.duName)
661 DU_LOG("\nDEBUG --> DU_APP: readCfg(): Memory allocation failure for DU name");
664 strcpy((char*)duCfgParam.duName,DU_NAME);
667 mib.sysFrmNum = SYS_FRAME_NUM;
669 mib.subCarrierSpacingCommon = MIB__subCarrierSpacingCommon_scs30or120;
671 mib.subCarrierSpacingCommon = MIB__subCarrierSpacingCommon_scs15or60;
673 mib.ssb_SubcarrierOffset = SSB_SC_OFFSET; //Kssb
674 mib.dmrs_TypeA_Position = MIB__dmrs_TypeA_Position_pos2;
675 mib.controlResourceSetZero = CORESET_0_INDEX;
676 mib.searchSpaceZero = SEARCHSPACE_0_INDEX;
677 mib.cellBarred = MIB__cellBarred_notBarred;
678 mib.intraFreqReselection = MIB__intraFreqReselection_notAllowed;
679 duCfgParam.mibParams = mib;
682 memset(&sib1.plmn, 0, sizeof(Plmn));
683 sib1.plmn.mcc[0] = PLMN_MCC0;
684 sib1.plmn.mcc[1] = PLMN_MCC1;
685 sib1.plmn.mcc[2] = PLMN_MCC2;
686 sib1.plmn.mnc[0] = PLMN_MNC0;
687 sib1.plmn.mnc[1] = PLMN_MNC1;
688 sib1.ranac = DU_RANAC;
691 sib1.tac = cellParams.nRTAC;
692 sib1.cellIdentity = CELL_IDENTITY * cellParams.cellLocalId;
693 DU_LOG("\nDEBUG --> DU_APP: readCfg(): OAM CellLocalId=%d", \
697 sib1.cellIdentity = CELL_IDENTITY * NR_CELL_ID;
699 sib1.cellResvdForOpUse = PLMN_IdentityInfo__cellReservedForOperatorUse_notReserved;
700 sib1.connEstFailCnt = ConnEstFailureControl__connEstFailCount_n3;
701 sib1.connEstFailOffValidity = ConnEstFailureControl__connEstFailOffsetValidity_s900;
702 sib1.connEstFailOffset = 15;
703 sib1.siSchedInfo.winLen = SI_SchedulingInfo__si_WindowLength_s5;
704 sib1.siSchedInfo.broadcastSta = SchedulingInfo__si_BroadcastStatus_broadcasting;
705 sib1.siSchedInfo.preiodicity = SchedulingInfo__si_Periodicity_rf8;
706 sib1.siSchedInfo.sibType = SIB_TypeInfo__type_sibType2;
707 sib1.siSchedInfo.sibValTag = SIB1_VALUE_TAG;
709 fillServCellCfgCommSib(&sib1.srvCellCfgCommSib);
711 duCfgParam.sib1Params = sib1;
713 for(srvdCellIdx=0; srvdCellIdx<DEFAULT_CELLS; srvdCellIdx++)
715 memset(&duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.nrCgi.plmn, 0, sizeof(Plmn));
716 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.nrCgi.plmn.mcc[0] = PLMN_MCC0;
717 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.nrCgi.plmn.mcc[1] = PLMN_MCC1;
718 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.nrCgi.plmn.mcc[2] = PLMN_MCC2;
719 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.nrCgi.plmn.mnc[0] = PLMN_MNC0;
720 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.nrCgi.plmn.mnc[1] = PLMN_MNC1;
724 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.nrPci = cellParams.nRPCI;
726 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.nrPci = NR_PCI;
728 /* List of Available PLMN */
729 for(srvdPlmnIdx=0; srvdPlmnIdx<MAX_PLMN; srvdPlmnIdx++)
731 /* As per spec 38.473, Plmn identity consists of 3 digit from mcc
732 * followed by either 2 digit or 3 digits of mnc */
734 memset(&duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].plmn, 0,\
737 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].plmn.mcc[0] = cellParams.plmnList[srvdPlmnIdx].mcc[0];
738 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].plmn.mcc[1] = cellParams.plmnList[srvdPlmnIdx].mcc[1];
739 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].plmn.mcc[2] = cellParams.plmnList[srvdPlmnIdx].mcc[2];
740 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].plmn.mnc[0] = cellParams.plmnList[srvdPlmnIdx].mnc[0];
741 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].plmn.mnc[1] = cellParams.plmnList[srvdPlmnIdx].mnc[1];
742 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].plmn.mnc[2] = cellParams.plmnList[srvdPlmnIdx].mnc[2];
744 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].plmn.mcc[0] = PLMN_MCC0;
745 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].plmn.mcc[1] = PLMN_MCC1;
746 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].plmn.mcc[2] = PLMN_MCC2;
747 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].plmn.mnc[0] = PLMN_MNC0;
748 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].plmn.mnc[1] = PLMN_MNC1;
751 /* List of Extended PLMN */
752 for(srvdPlmnIdx=0; srvdPlmnIdx<MAX_PLMN; srvdPlmnIdx++)
754 /* As per spec 38.473, Plmn identity consists of 3 digit from mcc
755 * followed by either 2 digit or 3 digits of mnc */
757 memset(&duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].extPlmn, 0, sizeof(Plmn));
758 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].extPlmn.mcc[0] = PLMN_MCC0;
759 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].extPlmn.mcc[1] = PLMN_MCC1;
760 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].extPlmn.mcc[2] = PLMN_MCC2;
761 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].extPlmn.mnc[0] = PLMN_MNC0;
762 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].extPlmn.mnc[1] = PLMN_MNC1;
764 /* List of Supporting Slices */
765 for(srvdPlmnIdx=0; srvdPlmnIdx<MAX_PLMN; srvdPlmnIdx++)
767 taiSliceSuppLst = &duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].\
770 /* TODO Calculte the exact number of supported slices once will get
771 * cell configuration from O1 */
772 taiSliceSuppLst->numSupportedSlices = NUM_OF_SUPPORTED_SLICE;
773 if(taiSliceSuppLst->numSupportedSlices > MAX_NUM_OF_SLICE_ITEMS)
775 DU_LOG("\nERROR --> DU_APP: readCfg(): Number of supported slice [%d] is more than 1024",\
776 taiSliceSuppLst->numSupportedSlices);
780 DU_ALLOC(taiSliceSuppLst->snssai, taiSliceSuppLst->numSupportedSlices*sizeof(Snssai*));
781 if(taiSliceSuppLst->snssai == NULLP)
783 DU_LOG("\nERROR --> DU_APP: readCfg():Memory allocation failed");
787 for(sliceIdx=0; sliceIdx<taiSliceSuppLst->numSupportedSlices; sliceIdx++)
789 DU_ALLOC(taiSliceSuppLst->snssai[sliceIdx], sizeof(Snssai));
790 if(taiSliceSuppLst->snssai[sliceIdx] == NULLP)
792 DU_LOG("\nERROR --> DU_APP: readCfg():Memory allocation failed");
796 memcpy(taiSliceSuppLst->snssai[sliceIdx]->sd, cellParams.plmnList[sliceIdx].sd, \
797 SD_SIZE*sizeof(uint8_t));
798 taiSliceSuppLst->snssai[sliceIdx]->sst = cellParams.plmnList[sliceIdx].sst;
800 memcpy(taiSliceSuppLst->snssai[sliceIdx], &snssai[sliceIdx], sizeof(Snssai));
807 /* NR TDD Mode info */
809 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.nrArfcn = cellParams.arfcnUL;
810 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.sulInfo.sulArfcn = cellParams.arfcnSUL;
811 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.sulInfo.sulTxBw.nrScs = cellParams.ssbSubCarrierSpacing;
813 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.nrArfcn = NR_UL_ARFCN;
814 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.sulInfo.sulArfcn = SUL_ARFCN;
815 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.sulInfo.sulTxBw.nrScs = NR_SCS;
817 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.sulInfo.sulTxBw.nrb = NRB_273;
819 for(freqBandIdx=0; freqBandIdx<MAX_NRCELL_BANDS; freqBandIdx++)
821 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.freqBand[freqBandIdx].nrFreqBand =\
823 for(bandIdx=0; bandIdx<MAX_NRCELL_BANDS; bandIdx++)
825 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.freqBand[freqBandIdx].sulBand[bandIdx]\
830 /* NR FDD Mode info */
832 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.nrArfcn = cellParams.arfcnUL;
833 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.sulInfo.sulArfcn = cellParams.arfcnSUL;
834 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.ulTxBw.nrScs = cellParams.ssbSubCarrierSpacing;
835 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.sulInfo.sulTxBw.nrScs = cellParams.ssbSubCarrierSpacing;
836 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.nrArfcn = cellParams.arfcnDL;
837 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.sulInfo.sulArfcn = cellParams.arfcnSUL;
838 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.sulInfo.sulTxBw.nrScs = cellParams.ssbSubCarrierSpacing;
839 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.dlTxBw.nrScs = cellParams.ssbSubCarrierSpacing;
841 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.nrArfcn = NR_UL_ARFCN;
842 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.sulInfo.sulArfcn = SUL_ARFCN;
843 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.ulTxBw.nrScs = NR_SCS;
844 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.sulInfo.sulTxBw.nrScs = NR_SCS;
845 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.nrArfcn = NR_DL_ARFCN;
846 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.sulInfo.sulArfcn = SUL_ARFCN;
847 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.sulInfo.sulTxBw.nrScs = NR_SCS;
848 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.dlTxBw.nrScs = NR_SCS;
850 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.sulInfo.sulTxBw.nrb = NRB_106;
851 for(freqBandIdx=0; freqBandIdx<MAX_NRCELL_BANDS; freqBandIdx++)
853 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.freqBand[freqBandIdx].\
854 nrFreqBand = NR_FREQ_BAND;
855 for(bandIdx=0; bandIdx<MAX_NRCELL_BANDS; bandIdx++)
857 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.freqBand[freqBandIdx].\
858 sulBand[bandIdx] = SUL_BAND;
861 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.sulInfo.sulTxBw.nrb = NRB_106;
862 for(freqBandIdx=0; freqBandIdx<MAX_NRCELL_BANDS; freqBandIdx++)
864 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.freqBand[freqBandIdx].\
865 nrFreqBand = NR_FREQ_BAND;
866 for(bandIdx=0; bandIdx<MAX_NRCELL_BANDS; bandIdx++)
868 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.freqBand[freqBandIdx].\
869 sulBand[bandIdx] = SUL_BAND;
873 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.ulTxBw.nrb = NRB_106;
874 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.dlTxBw.nrb = NRB_106;
877 /*Measurement Config and Cell Config */
878 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.measTimeCfgDuration = TIME_CFG;
880 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellDir = DL_UL;
882 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellType=CELL_TYPE;
884 /* Broadcast PLMN Identity */
885 for(brdcstPlmnIdx=0; brdcstPlmnIdx<MAX_BPLMN_NRCELL_MINUS_1; brdcstPlmnIdx++)
887 for(plmnIdx=0; plmnIdx<MAX_PLMN; plmnIdx++)
889 memset(&duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].plmn[plmnIdx],\
891 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].plmn[plmnIdx].mcc[0] =\
893 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].plmn[plmnIdx].mcc[1] =\
895 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].plmn[plmnIdx].mcc[2] =\
897 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].plmn[plmnIdx].mnc[0] =\
899 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].plmn[plmnIdx].mnc[1] =\
902 /* Extended PLMN List */
903 for(plmnIdx=0; plmnIdx<MAX_PLMN; plmnIdx++)
905 memset(&duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].\
906 extPlmn[plmnIdx], 0, sizeof(Plmn));
907 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].\
908 extPlmn[plmnIdx].mcc[0] = PLMN_MCC0;
909 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].\
910 extPlmn[plmnIdx].mcc[1] = PLMN_MCC1;
911 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].\
912 extPlmn[plmnIdx].mcc[2] = PLMN_MCC2;
913 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].\
914 extPlmn[plmnIdx].mnc[0] = PLMN_MNC0;
915 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].\
916 extPlmn[plmnIdx].mnc[1] = PLMN_MNC1;
919 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.epsTac = cellParams.nRTAC; //TODO : to check and fill
920 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.tac = cellParams.nRTAC;
921 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].tac = cellParams.nRTAC;
922 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].nrCellId = cellParams.cellLocalId;
924 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.epsTac = DU_TAC; //TODO : to check and fill
925 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.tac = DU_TAC;
926 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].tac = DU_TAC;
927 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].nrCellId = NR_CELL_ID;
929 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].ranac = NR_RANAC;
932 /*gnb DU System Info mib msg*/
934 DU_ALLOC(duCfgParam.srvdCellLst[srvdCellIdx].duSysInfo.mibMsg, encBufSize);
935 if(!(duCfgParam.srvdCellLst[srvdCellIdx].duSysInfo.mibMsg))
937 DU_LOG("\nERROR --> DU APP : Memory allocation failure at readCfg");
940 memcpy(duCfgParam.srvdCellLst[srvdCellIdx].duSysInfo.mibMsg, encBuf, encBufSize);
941 duCfgParam.srvdCellLst[srvdCellIdx].duSysInfo.mibLen = encBufSize;
943 /*gnb DU System Info mib msg*/
945 DU_ALLOC(duCfgParam.srvdCellLst[srvdCellIdx].duSysInfo.sib1Msg,\
947 if(!(duCfgParam.srvdCellLst[srvdCellIdx].duSysInfo.sib1Msg))
949 DU_LOG("\nERROR --> DU APP : Memory allocation failure at readCfg");
952 memcpy(duCfgParam.srvdCellLst[srvdCellIdx].duSysInfo.sib1Msg,\
954 duCfgParam.srvdCellLst[srvdCellIdx].duSysInfo.sib1Len = encBufSize;
958 if(readMacCfg() != ROK)
960 DU_LOG("\nERROR --> DU_APP : Failed while reading MAC config");
967 /*******************************************************************
969 * @brief Copy Slice Cfg in temp structre in duCfgParams
973 * Function : cpyRrmPolicyInDuCfgParams
976 * - Copy Slice Cfg in temp structre in duCfgParams
978 * @params[in] RrmPolicy rrmPolicy[], uint8_t policyNum, uint8_t memberList
979 * @return ROK - success
982 * ****************************************************************/
983 uint8_t cpyRrmPolicyInDuCfgParams(RrmPolicyList rrmPolicy[], uint8_t policyNum, MacSliceCfgReq *tempSliceCfg)
985 uint8_t policyIdx = 0, memberListIdx = 0;
988 tempSliceCfg->numOfRrmPolicy = policyNum;
989 DU_ALLOC_SHRABL_BUF(tempSliceCfg->listOfRrmPolicy, tempSliceCfg->numOfRrmPolicy * sizeof(MacSliceRrmPolicy*));
990 if(!tempSliceCfg->listOfRrmPolicy)
992 DU_LOG("\nERROR --> DU APP : Memory allocation failed in cpyRrmPolicyInDuCfgParams");
996 for(policyIdx = 0; policyIdx<tempSliceCfg->numOfRrmPolicy; policyIdx++)
998 DU_ALLOC_SHRABL_BUF(tempSliceCfg->listOfRrmPolicy[policyIdx], sizeof(MacSliceRrmPolicy));
999 if(!tempSliceCfg->listOfRrmPolicy[policyIdx])
1001 DU_LOG("\nERROR --> DU APP : Memory allocation failed in cpyRrmPolicyInDuCfgParams");
1005 tempSliceCfg->listOfRrmPolicy[policyIdx]->resourceType = rrmPolicy[policyIdx].resourceType;
1007 tempSliceCfg->listOfRrmPolicy[policyIdx]->numOfRrmPolicyMem = rrmPolicy[policyIdx].rRMMemberNum;
1009 if(tempSliceCfg->listOfRrmPolicy[policyIdx]->numOfRrmPolicyMem)
1011 DU_ALLOC_SHRABL_BUF(tempSliceCfg->listOfRrmPolicy[policyIdx]->rRMPolicyMemberList,\
1012 tempSliceCfg->listOfRrmPolicy[policyIdx]->numOfRrmPolicyMem * sizeof(RrmPolicyMemberList*));
1014 if(!tempSliceCfg->listOfRrmPolicy[policyIdx]->rRMPolicyMemberList)
1016 DU_LOG("\nERROR --> DU APP : Memory allocation failed in cpyRrmPolicyInDuCfgParams");
1021 for(memberListIdx = 0; memberListIdx<tempSliceCfg->listOfRrmPolicy[policyIdx]->numOfRrmPolicyMem; memberListIdx++)
1023 DU_ALLOC_SHRABL_BUF(tempSliceCfg->listOfRrmPolicy[policyIdx]->rRMPolicyMemberList[memberListIdx], sizeof(RrmPolicyMemberList));
1024 if(!tempSliceCfg->listOfRrmPolicy[policyIdx]->rRMPolicyMemberList[memberListIdx])
1026 DU_LOG("\nERROR --> DU APP : Memory allocation failed in cpyRrmPolicyInDuCfgParams");
1029 memcpy(&tempSliceCfg->listOfRrmPolicy[policyIdx]->rRMPolicyMemberList[memberListIdx]->snssai.sd,\
1030 &rrmPolicy[policyIdx].rRMPolicyMemberList[memberListIdx].sd, 3 * sizeof(uint8_t));
1031 memcpy(&tempSliceCfg->listOfRrmPolicy[policyIdx]->rRMPolicyMemberList[memberListIdx]->snssai.sst,\
1032 &rrmPolicy[policyIdx].rRMPolicyMemberList[memberListIdx].sst, sizeof(uint8_t));
1033 memcpy(&tempSliceCfg->listOfRrmPolicy[policyIdx]->rRMPolicyMemberList[memberListIdx]->plmn.mcc,\
1034 &rrmPolicy[policyIdx].rRMPolicyMemberList[memberListIdx].mcc, 3 * sizeof(uint8_t));
1035 memcpy(&tempSliceCfg->listOfRrmPolicy[policyIdx]->rRMPolicyMemberList[memberListIdx]->plmn.mnc,\
1036 &rrmPolicy[policyIdx].rRMPolicyMemberList[memberListIdx].mnc, 3 * sizeof(uint8_t));
1038 tempSliceCfg->listOfRrmPolicy[policyIdx]->policyRatio.maxRatio = rrmPolicy[policyIdx].rRMPolicyMaxRatio;
1039 tempSliceCfg->listOfRrmPolicy[policyIdx]->policyRatio.minRatio = rrmPolicy[policyIdx].rRMPolicyMinRatio;
1040 tempSliceCfg->listOfRrmPolicy[policyIdx]->policyRatio.dedicatedRatio = rrmPolicy[policyIdx].rRMPolicyDedicatedRatio;
1048 /*******************************************************************
1050 * @brief Reads config and posts message to du_app on completion
1058 * - Post to du_app for further processing
1061 * @return ROK - success
1064 * ****************************************************************/
1070 memset(&duCfgParam, 0, sizeof(DuCfgParams));
1072 //Read configs into duCfgParams
1073 if(readCfg() != ROK)
1075 DU_LOG("\nERROR --> DU_APP : Reading configuration failed");
1079 //Fill pst structure
1080 memset(&(pst), 0, sizeof(Pst));
1081 pst.srcEnt = (Ent)ENTDUAPP;
1082 pst.srcInst = (Inst)DU_INST;
1083 pst.srcProcId = DU_PROC;
1084 pst.dstEnt = pst.srcEnt;
1085 pst.dstInst = pst.srcInst;
1086 pst.dstProcId = pst.srcProcId;
1088 pst.selector = ODU_SELECTOR_TC;
1091 /* Initialize the timer blocks */
1092 cmInitTimers(&(duCb.e2apDb.e2Timers.e2SetupTimer), 1);
1094 /* Initialzie the timer queue */
1095 memset(&(duCb.duTimersInfo.tmrTq), 0, sizeof(CmTqType) * DU_TQ_SIZE);
1097 /* Initialize the timer control point */
1098 memset(&(duCb.duTimersInfo.tmrTqCp), 0, sizeof(CmTqCp));
1099 duCb.duTimersInfo.tmrTqCp.tmrLen = DU_TQ_SIZE;
1101 /* Initialize the timer resolution */
1102 duCb.duTimersInfo.tmrRes = DU_TIMER_RESOLUTION;
1104 /* Timer Registration request to system services */
1105 if (ODU_REG_TMR_MT(pst.srcEnt, pst.srcInst, duCb.duTimersInfo.tmrRes, duActvTmr) != ROK)
1107 DU_LOG("\nERROR --> DU_APP : Failed to register timer");
1111 if(ODU_GET_MSG_BUF(DFLT_REGION, DU_POOL, &mBuf) != ROK)
1113 DU_LOG("\nERROR --> DU_APP : Memory allocation failed in duReadCfg");
1117 if (ODU_POST_TASK(&pst, mBuf) != ROK)
1119 DU_LOG("\nERROR --> DU_APP : ODU_POST_TASK failed in duReadCfg");
1126 /**********************************************************************
1128 **********************************************************************/