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"
27 #include "du_e2ap_mgr.h"
31 #include "du_f1ap_conversions.h"
32 #include "OCTET_STRING.h"
33 #include "BIT_STRING.h"
34 #include "odu_common_codec.h"
36 #include "SearchSpace.h"
37 #include "SIB-TypeInfo.h"
38 #include "SchedulingInfo.h"
39 #include "SI-SchedulingInfo.h"
40 #include "ConnEstFailureControl.h"
41 #include "PLMN-IdentityInfo.h"
42 #include "PDSCH-TimeDomainResourceAllocation.h"
43 #include "BCCH-Config.h"
44 #include "PagingCycle.h"
45 #include "PCCH-Config.h"
46 #include "TimeAlignmentTimer.h"
47 #include "BCCH-DL-SCH-Message.h"
48 #include "RACH-ConfigGeneric.h"
49 #include "PUSCH-TimeDomainResourceAllocation.h"
50 #include "PUCCH-ConfigCommon.h"
51 #include "SubcarrierSpacing.h"
52 #include "TDD-UL-DL-Pattern.h"
53 #include "RACH-ConfigCommon.h"
54 #include "BWP-DownlinkCommon.h"
55 #include "BWP-UplinkCommon.h"
56 #include "TDD-UL-DL-ConfigCommon.h"
57 #include "du_sys_info_hdl.h"
60 #include "CmInterface.h"
61 extern StartupConfig g_cfg;
62 extern NRCellDU cellParams;
65 char encBuf[ENC_BUF_MAX_LEN];
68 /* Filling Slot configuration as :
69 * 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
70 * 0 DL DL DL DL DL DL DL DL DL DL DL DL DL DL
71 * 1 DL DL DL DL DL DL DL DL DL DL DL DL DL DL
72 * 2 DL DL DL DL DL DL DL DL DL DL DL DL DL DL
73 3 DL DL DL DL DL DL DL DL DL DL DL DL DL DL
74 4 DL DL DL DL DL DL DL DL DL DL DL DL DL DL
75 5 DL DL DL DL DL DL DL DL DL DL DL DL DL DL
76 6 DL DL DL DL DL DL DL DL DL DL DL DL DL DL
77 7 DL DL DL DL DL DL DL DL DL DL DL DL F UL
78 8 UL UL UL UL UL UL UL UL UL UL UL UL UL UL
79 9 UL UL UL UL UL UL UL UL UL UL UL UL UL UL
82 /*******************************************************************
83 * @brief Reads the CL Configuration.
87 * Function : readMacCfg
90 * - Fills up the cell configuration for CL.
91 * - Calls FillSlotConfig()
94 * @return ROK - success
97 * ****************************************************************/
101 uint8_t idx=0, sliceIdx=0,plmnIdx = 0;
102 F1TaiSliceSuppLst *taiSliceSuppLst;
104 /* DL carrier configuration */
106 duCfgParam.macCellCfg.cellId = cellParams.cellLocalId;
107 duCfgParam.macCellCfg.carrCfg.dlBw = cellParams.bSChannelBwDL;
108 duCfgParam.macCellCfg.carrCfg.dlFreq = convertArfcnToFreqKhz(cellParams.arfcnDL);
110 duCfgParam.macCellCfg.cellId = NR_CELL_ID;
111 duCfgParam.macCellCfg.carrCfg.dlBw = NR_BANDWIDTH;
112 duCfgParam.macCellCfg.carrCfg.dlFreq = convertArfcnToFreqKhz(NR_DL_ARFCN);
114 duCfgParam.macCellCfg.carrCfg.numTxAnt = NUM_TX_ANT;
115 /* UL Carrier configuration */
117 duCfgParam.macCellCfg.carrCfg.ulBw = cellParams.bSChannelBwUL;
118 duCfgParam.macCellCfg.carrCfg.ulFreq = convertArfcnToFreqKhz(cellParams.arfcnUL);
120 duCfgParam.macCellCfg.carrCfg.ulBw = NR_BANDWIDTH;
121 duCfgParam.macCellCfg.carrCfg.ulFreq = convertArfcnToFreqKhz(NR_UL_ARFCN);
123 duCfgParam.macCellCfg.carrCfg.numRxAnt = NUM_RX_ANT;
125 /* Cell configuration */
127 duCfgParam.macCellCfg.cellCfg.opState = cellParams.operationalState;
128 duCfgParam.macCellCfg.cellCfg.adminState = cellParams.administrativeState;
129 duCfgParam.macCellCfg.cellCfg.cellState = cellParams.cellState;
130 duCfgParam.macCellCfg.cellCfg.phyCellId = cellParams.nRPCI;
131 duCfgParam.macCellCfg.cellCfg.tac = cellParams.nRTAC;
132 duCfgParam.macCellCfg.cellCfg.ssbFreq = convertArfcnToFreqKhz(cellParams.ssbFrequency);
134 duCfgParam.macCellCfg.cellCfg.opState = OP_DISABLED;
135 duCfgParam.macCellCfg.cellCfg.adminState = ADMIN_UNLOCKED;
136 duCfgParam.macCellCfg.cellCfg.cellState = CELL_INACTIVE;
137 duCfgParam.macCellCfg.cellCfg.phyCellId = NR_PCI;
138 duCfgParam.macCellCfg.cellCfg.tac = DU_TAC;
139 duCfgParam.macCellCfg.cellCfg.ssbFreq = SSB_FREQUENCY;
141 /* Plmn And SNSSAI Configuration */
142 for(plmnIdx = 0; plmnIdx < MAX_PLMN; plmnIdx++)
144 memcpy(&duCfgParam.macCellCfg.cellCfg.plmnInfoList[plmnIdx].plmn, &duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.srvdPlmn[plmnIdx].plmn,\
146 taiSliceSuppLst = &duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.srvdPlmn[plmnIdx].taiSliceSuppLst;
147 duCfgParam.macCellCfg.cellCfg.plmnInfoList[plmnIdx].numSupportedSlice = taiSliceSuppLst->numSupportedSlices;
148 if(taiSliceSuppLst->snssai)
150 DU_ALLOC_SHRABL_BUF(duCfgParam.macCellCfg.cellCfg.plmnInfoList[plmnIdx].snssai, (duCfgParam.macCellCfg.cellCfg.plmnInfoList[plmnIdx].numSupportedSlice) * sizeof(Snssai*));
151 if(duCfgParam.macCellCfg.cellCfg.plmnInfoList[plmnIdx].snssai == NULLP)
153 DU_LOG("\nERROR --> DU_APP: Memory allocation failed at readMacCfg");
157 for(sliceIdx=0; sliceIdx < taiSliceSuppLst->numSupportedSlices; sliceIdx++)
159 if(taiSliceSuppLst->snssai[sliceIdx] != NULLP)
161 DU_ALLOC_SHRABL_BUF(duCfgParam.macCellCfg.cellCfg.plmnInfoList[plmnIdx].snssai[sliceIdx], sizeof(Snssai));
162 if(duCfgParam.macCellCfg.cellCfg.plmnInfoList[plmnIdx].snssai[sliceIdx] == NULLP)
164 DU_LOG("\nERROR --> DU_APP: Memory allocation failed at readMacCfg");
167 memcpy(duCfgParam.macCellCfg.cellCfg.plmnInfoList[plmnIdx].snssai[sliceIdx], taiSliceSuppLst->snssai[sliceIdx], sizeof(Snssai));
171 duCfgParam.macCellCfg.cellCfg.numerology = NR_NUMEROLOGY;
172 duCfgParam.macCellCfg.cellCfg.dupType = DUPLEX_MODE;
174 /* SSB configuration */
175 duCfgParam.macCellCfg.ssbCfg.ssbPbchPwr = SSB_PBCH_PWR;
176 duCfgParam.macCellCfg.ssbCfg.bchPayloadFlag = BCH_PAYLOAD;
177 duCfgParam.macCellCfg.ssbCfg.ssbOffsetPointA = OFFSET_TO_POINT_A;
178 duCfgParam.macCellCfg.ssbCfg.betaPss = BETA_PSS;
180 duCfgParam.macCellCfg.ssbCfg.scsCmn = convertScsValToScsEnum(cellParams.ssbSubCarrierSpacing);
181 duCfgParam.macCellCfg.ssbCfg.ssbPeriod = convertSSBPeriodicityToEnum(cellParams.ssbPeriodicity);
182 duCfgParam.macCellCfg.ssbCfg.ssbScOffset = cellParams.ssbOffset;
184 duCfgParam.macCellCfg.ssbCfg.scsCmn = NR_SCS;
185 duCfgParam.macCellCfg.ssbCfg.ssbPeriod = SSB_PRDCTY_MS_20;
186 duCfgParam.macCellCfg.ssbCfg.ssbScOffset = SSB_SUBCARRIER_OFFSET;
188 duCfgParam.macCellCfg.ssbCfg.ssbMask[0] = 1; /* only one SSB is transmitted */
189 if(BuildMibPdu() != ROK)
191 DU_LOG("\nERROR --> Failed to build MIB PDU");
192 memset(&duCfgParam.macCellCfg.ssbCfg.mibPdu, 0, 3*sizeof(uint8_t));
196 memcpy(&duCfgParam.macCellCfg.ssbCfg.mibPdu, encBuf,encBufSize);
199 /* PRACH configuration */
200 duCfgParam.macCellCfg.prachCfg.prachSeqLen = PRACH_SEQ_LEN;
201 duCfgParam.macCellCfg.prachCfg.prachSubcSpacing = convertScsEnumValToScsVal(PRACH_SUBCARRIER_SPACING);
202 duCfgParam.macCellCfg.prachCfg.prachCfgIdx = PRACH_CONFIG_IDX;
203 duCfgParam.macCellCfg.prachCfg.msg1Fdm = NUM_PRACH_FDM;
204 duCfgParam.macCellCfg.prachCfg.fdm[0].rootSeqIdx = ROOT_SEQ_IDX;
205 duCfgParam.macCellCfg.prachCfg.fdm[0].numRootSeq = NUM_ROOT_SEQ;
206 duCfgParam.macCellCfg.prachCfg.fdm[0].k1 = 0;
207 duCfgParam.macCellCfg.prachCfg.fdm[0].zeroCorrZoneCfg = ZERO_CORRELATION_ZONE_CFG;
208 duCfgParam.macCellCfg.prachCfg.prachRstSetCfg = PRACH_RESTRICTED_SET_CFG;
209 duCfgParam.macCellCfg.prachCfg.ssbPerRach = SSB_PER_RACH;
210 duCfgParam.macCellCfg.prachCfg.msg1FreqStart = PRACH_FREQ_START;
212 duCfgParam.macCellCfg.prachCfg.totalNumRaPreamble = NUM_RA_PREAMBLE;
213 duCfgParam.macCellCfg.prachCfg.numCbPreamblePerSsb = CB_PREAMBLE_PER_SSB;
214 duCfgParam.macCellCfg.prachCfg.raRspWindow = RA_RSP_WINDOW;
216 /* TDD configuration */
218 duCfgParam.macCellCfg.tddCfg.tddPeriod = TDD_PERIODICITY;
219 duCfgParam.macCellCfg.tddCfg.nrOfDlSlots = NUM_DL_SLOTS;
220 duCfgParam.macCellCfg.tddCfg.nrOfDlSymbols = NUM_DL_SYMBOLS;
221 duCfgParam.macCellCfg.tddCfg.nrOfUlSlots = NUM_UL_SLOTS;
222 duCfgParam.macCellCfg.tddCfg.nrOfUlSymbols = NUM_UL_SYMBOLS;
228 /* fill SIB1 configuration */
229 duCfgParam.macCellCfg.cellCfg.sib1Cfg.sib1PduLen = duCfgParam.srvdCellLst[0].duSysInfo.sib1Len;
230 DU_ALLOC_SHRABL_BUF(duCfgParam.macCellCfg.cellCfg.sib1Cfg.sib1Pdu,duCfgParam.srvdCellLst[0].duSysInfo.sib1Len);
231 memcpy(duCfgParam.macCellCfg.cellCfg.sib1Cfg.sib1Pdu, duCfgParam.srvdCellLst[0].duSysInfo.sib1Msg, \
232 duCfgParam.srvdCellLst[0].duSysInfo.sib1Len);
233 duCfgParam.macCellCfg.cellCfg.sib1Cfg.pdcchCfgSib1.coresetZeroIndex = CORESET_0_INDEX;
234 duCfgParam.macCellCfg.cellCfg.sib1Cfg.pdcchCfgSib1.searchSpaceZeroIndex = SEARCHSPACE_0_INDEX;
236 duCfgParam.macCellCfg.cellCfg.sib1Cfg.pagingCfg.numPO = duCfgParam.sib1Params.srvCellCfgCommSib.dlCfg.pcchCfg.ns;
237 if((duCfgParam.sib1Params.srvCellCfgCommSib.dlCfg.pcchCfg.firstPDCCHMontioringType != \
238 PCCH_Config__firstPDCCH_MonitoringOccasionOfPO_PR_NOTHING) && (duCfgParam.macCellCfg.cellCfg.sib1Cfg.pagingCfg.numPO != 0))
240 duCfgParam.macCellCfg.cellCfg.sib1Cfg.pagingCfg.poPresent = TRUE;
241 memcpy(duCfgParam.macCellCfg.cellCfg.sib1Cfg.pagingCfg.pagingOcc,
242 duCfgParam.sib1Params.srvCellCfgCommSib.dlCfg.pcchCfg.firstPDCCHMontioringInfo,MAX_PO_PER_PF);
246 duCfgParam.macCellCfg.cellCfg.sib1Cfg.pagingCfg.poPresent = FALSE;
249 /* fill Intial DL BWP */
250 duCfgParam.macCellCfg.initialDlBwp.bwp.firstPrb = 0;
251 duCfgParam.macCellCfg.initialDlBwp.bwp.numPrb = TOTAL_PRB_20MHZ_MU0; /* configured to total BW */
252 duCfgParam.macCellCfg.initialDlBwp.bwp.scs = duCfgParam.macCellCfg.ssbCfg.scsCmn;
253 duCfgParam.macCellCfg.initialDlBwp.bwp.cyclicPrefix = NORMAL_CYCLIC_PREFIX;
254 duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.searchSpaceId = SEARCHSPACE_1_INDEX;
255 duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.coresetId = CORESET_0_INDEX;
256 duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.monitoringSlot =
257 SS_MONITORING_SLOT_SL1; /* sl1 - all slots */
258 duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.duration = 0;
259 duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.monitoringSymbol =
260 SS_MONITORING_SYMBOL;
261 duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.
262 candidate.aggLevel1 = 8;
263 duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.
264 candidate.aggLevel2 = 4;
265 duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.
266 candidate.aggLevel4 = 2;
267 duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.
268 candidate.aggLevel8 = 1;
269 duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.
270 candidate.aggLevel16 = 0;
272 duCfgParam.macCellCfg.initialDlBwp.pdschCommon.numTimeDomAlloc = NUM_TIME_DOM_RSRC_ALLOC;
274 duCfgParam.macCellCfg.initialDlBwp.pdschCommon.timeDomRsrcAllocList[idx].k0 = PDSCH_K0_CFG1;
275 duCfgParam.macCellCfg.initialDlBwp.pdschCommon.timeDomRsrcAllocList[idx].mappingType =
276 PDSCH_MAPPING_TYPE_A;
277 duCfgParam.macCellCfg.initialDlBwp.pdschCommon.timeDomRsrcAllocList[idx].startSymbol =
279 duCfgParam.macCellCfg.initialDlBwp.pdschCommon.timeDomRsrcAllocList[idx].lengthSymbol =
283 duCfgParam.macCellCfg.initialDlBwp.pdschCommon.timeDomRsrcAllocList[idx].k0 = PDSCH_K0_CFG2;
284 duCfgParam.macCellCfg.initialDlBwp.pdschCommon.timeDomRsrcAllocList[idx].mappingType =
285 PDSCH_MAPPING_TYPE_A;
286 duCfgParam.macCellCfg.initialDlBwp.pdschCommon.timeDomRsrcAllocList[idx].startSymbol =
288 duCfgParam.macCellCfg.initialDlBwp.pdschCommon.timeDomRsrcAllocList[idx].lengthSymbol =
291 /* ra-searchSpace ID is set to 1 */
292 duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.raSearchSpaceId = SEARCHSPACE_1_INDEX;
294 /* fill Intial UL BWP */
295 duCfgParam.macCellCfg.initialUlBwp.bwp.firstPrb = 0;
296 duCfgParam.macCellCfg.initialUlBwp.bwp.numPrb = TOTAL_PRB_20MHZ_MU0; /* configured to total BW */
297 duCfgParam.macCellCfg.initialUlBwp.bwp.scs = duCfgParam.macCellCfg.ssbCfg.scsCmn;
298 duCfgParam.macCellCfg.initialUlBwp.bwp.cyclicPrefix = NORMAL_CYCLIC_PREFIX;
299 duCfgParam.macCellCfg.initialUlBwp.puschCommon.numTimeDomRsrcAlloc = 2;
300 duCfgParam.macCellCfg.initialUlBwp.puschCommon.timeDomRsrcAllocList[0].k2 = PUSCH_K2_CFG1;
301 duCfgParam.macCellCfg.initialUlBwp.puschCommon.timeDomRsrcAllocList[0].mappingType =
302 PUSCH_MAPPING_TYPE_A;
303 duCfgParam.macCellCfg.initialUlBwp.puschCommon.timeDomRsrcAllocList[0].startSymbol =
305 duCfgParam.macCellCfg.initialUlBwp.puschCommon.timeDomRsrcAllocList[0].symbolLength =
308 duCfgParam.macCellCfg.initialUlBwp.puschCommon.timeDomRsrcAllocList[1].k2 = PUSCH_K2_CFG2;
309 duCfgParam.macCellCfg.initialUlBwp.puschCommon.timeDomRsrcAllocList[1].mappingType =
310 PUSCH_MAPPING_TYPE_A;
311 duCfgParam.macCellCfg.initialUlBwp.puschCommon.timeDomRsrcAllocList[1].startSymbol =
313 duCfgParam.macCellCfg.initialUlBwp.puschCommon.timeDomRsrcAllocList[1].symbolLength =
316 duCfgParam.macCellCfg.ssbCfg.dmrsTypeAPos = DMRS_TYPE_A_POS;
318 /* fill PUCCH config common */
319 duCfgParam.macCellCfg.initialUlBwp.pucchCommon.pucchResourceCommon = PUCCH_RSRC_COMMON;
320 duCfgParam.macCellCfg.initialUlBwp.pucchCommon.pucchGroupHopping = PUCCH_GROUP_HOPPING;
325 /*Note: Static Configuration, when O1 is not configuring the RRM policy*/
326 RrmPolicyList rrmPolicy;
328 rrmPolicy.resourceType = PRB;
329 rrmPolicy.rRMMemberNum = 1;
330 memcpy(rrmPolicy.rRMPolicyMemberList[0].mcc,duCfgParam.macCellCfg.cellCfg.plmnInfoList[0].plmn.mcc, 3*sizeof(uint8_t));
331 memcpy(rrmPolicy.rRMPolicyMemberList[0].mnc,duCfgParam.macCellCfg.cellCfg.plmnInfoList[0].plmn.mnc, 3*sizeof(uint8_t));
332 rrmPolicy.rRMPolicyMemberList[0].sst = 1;
333 rrmPolicy.rRMPolicyMemberList[0].sd[0] = 2;
334 rrmPolicy.rRMPolicyMemberList[0].sd[1] = 3;
335 rrmPolicy.rRMPolicyMemberList[0].sd[2] = 4;
336 rrmPolicy.rRMPolicyMaxRatio = 90;
337 rrmPolicy.rRMPolicyMinRatio = 30;
338 rrmPolicy.rRMPolicyDedicatedRatio = 10;
340 cpyRrmPolicyInDuCfgParams(&rrmPolicy, 1, &duCfgParam.tempSliceCfg);
347 /*******************************************************************
349 * @brief Configures the DU Parameters
353 * Function : fillDuPort
356 * - fills the DU Ports.
358 * @params[in] duPort array to be filled
359 * @return ROK - success
362 * ****************************************************************/
363 uint8_t fillDuPort(uint16_t *duPort)
367 duPort[F1_INTERFACE] = g_cfg.DU_Port;
368 duPort[E2_INTERFACE] = g_cfg.RIC_Port;
370 duPort[F1_INTERFACE] = F1_SCTP_PORT; /* DU Port idx 0 38472 */
371 duPort[E2_INTERFACE] = E2_SCTP_PORT; /* RIC Port idx 1 36421 */
376 /*******************************************************************
378 * @brief Configures the DU Parameters
382 * Function : calcSliv
385 * - calculate SLIV value from start and length field
387 * @params[in] start symbol
388 * @params[in] length of symbols
391 * ****************************************************************/
392 uint16_t calcSliv(uint8_t startSymbol, uint8_t lengthSymbol)
395 if((lengthSymbol-1) <= 7)
397 sliv = NUM_SYMBOLS_PER_SLOT * (lengthSymbol-1) + startSymbol;
401 sliv = NUM_SYMBOLS_PER_SLOT * (NUM_SYMBOLS_PER_SLOT - lengthSymbol + 1) \
402 + (NUM_SYMBOLS_PER_SLOT - 1 - startSymbol);
408 /*******************************************************************
410 * @brief Configures serving cell config common in sib1
414 * Function : fillServCellCfgCommSib
417 * - fills Serving cell config common for SIB1
419 * @params[in] SrvCellCfgCommSib pointer
420 * @return ROK - success
423 ** ****************************************************************/
424 uint8_t fillServCellCfgCommSib(SrvCellCfgCommSib *srvCellCfgComm)
426 PdcchCfgCommon pdcchCfg;
427 PdschCfgCommon pdschCfg;
429 RachCfgCommon rachCfg;
430 PuschCfgCommon puschCfg;
431 PucchCfgCommon pucchCfg;
432 TddUlDlCfgCommon tddCfg;
435 srvCellCfgComm->scs = convertScsValToScsEnum(cellParams.ssbSubCarrierSpacing);
437 srvCellCfgComm->scs = NR_SCS;
440 /* Configuring DL Config Common for SIB1*/
441 srvCellCfgComm->dlCfg.freqBandInd = NR_FREQ_BAND;
442 srvCellCfgComm->dlCfg.offsetToPointA = OFFSET_TO_POINT_A;
444 srvCellCfgComm->dlCfg.dlScsCarrier.scsOffset = cellParams.ssbOffset;
445 srvCellCfgComm->dlCfg.dlScsCarrier.scs = convertScsValToScsEnum(cellParams.ssbSubCarrierSpacing);
446 srvCellCfgComm->dlCfg.dlScsCarrier.scsBw = cellParams.bSChannelBwUL;
448 srvCellCfgComm->dlCfg.dlScsCarrier.scsOffset = SSB_SUBCARRIER_OFFSET;
449 srvCellCfgComm->dlCfg.dlScsCarrier.scs = NR_SCS;
450 srvCellCfgComm->dlCfg.dlScsCarrier.scsBw = NR_BANDWIDTH;
452 srvCellCfgComm->dlCfg.locAndBw = FREQ_LOC_BW;
454 /* Configuring PDCCH Config Common For SIB1 */
455 pdcchCfg.present = BWP_DownlinkCommon__pdcch_ConfigCommon_PR_setup;
456 pdcchCfg.ctrlRsrcSetZero = CORESET_0_INDEX;
457 pdcchCfg.searchSpcZero = SEARCHSPACE_0_INDEX;
458 pdcchCfg.searchSpcId = PDCCH_SEARCH_SPACE_ID;
459 pdcchCfg.ctrlRsrcSetId = PDCCH_CTRL_RSRC_SET_ID;
460 pdcchCfg.monitorSlotPrdAndOffPresent = SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl1;
461 //pdcchCfg.monitorSlotPrdAndOff = \
462 SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl1;
463 pdcchCfg.monitorSymbolsInSlot[0] = 128;
464 pdcchCfg.monitorSymbolsInSlot[1] = 0;
465 pdcchCfg.numCandAggLvl1 = SearchSpace__nrofCandidates__aggregationLevel1_n8;
466 pdcchCfg.numCandAggLvl2 = SearchSpace__nrofCandidates__aggregationLevel2_n4;
467 pdcchCfg.numCandAggLvl4 = SearchSpace__nrofCandidates__aggregationLevel4_n2;
468 pdcchCfg.numCandAggLvl8 = SearchSpace__nrofCandidates__aggregationLevel8_n1;
469 pdcchCfg.numCandAggLvl16 = SearchSpace__nrofCandidates__aggregationLevel16_n0;
470 pdcchCfg.searchSpcType = SearchSpace__searchSpaceType_PR_common;
471 pdcchCfg.commSrchSpcDciFrmt = PDCCH_SERACH_SPACE_DCI_FORMAT;
472 pdcchCfg.searchSpcSib1 = PDCCH_SEARCH_SPACE_ID_SIB1;
473 pdcchCfg.pagingSearchSpc = PDCCH_SEARCH_SPACE_ID_PAGING;
474 pdcchCfg.raSearchSpc = PDCCH_SEARCH_SPACE_ID_PAGING;
475 srvCellCfgComm->dlCfg.pdcchCfg = pdcchCfg;
477 /* Configuring PDSCH Config Common For SIB1 */
478 pdschCfg.present = BWP_DownlinkCommon__pdsch_ConfigCommon_PR_setup;
479 pdschCfg.numTimeDomRsrcAlloc = 2;
480 pdschCfg.timeDomAlloc[0].k0 = PDSCH_K0_CFG1;
481 pdschCfg.timeDomAlloc[0].mapType = PDSCH_TimeDomainResourceAllocation__mappingType_typeA;
482 pdschCfg.timeDomAlloc[0].sliv = calcSliv(PDSCH_START_SYMBOL,PDSCH_LENGTH_SYMBOL);
484 pdschCfg.timeDomAlloc[1].k0 = PDSCH_K0_CFG2;
485 pdschCfg.timeDomAlloc[1].mapType = PDSCH_TimeDomainResourceAllocation__mappingType_typeA;
486 pdschCfg.timeDomAlloc[1].sliv = calcSliv(PDSCH_START_SYMBOL,PDSCH_LENGTH_SYMBOL);
488 srvCellCfgComm->dlCfg.pdschCfg = pdschCfg;
490 /* Configuring BCCH Config for SIB1 */
491 srvCellCfgComm->dlCfg.bcchCfg.modPrdCoeff = BCCH_Config__modificationPeriodCoeff_n16;
493 /* Configuring PCCH Config for SIB1 */
494 pcchCfg.dfltPagingCycle = convertPagingCycleEnumToValue(PagingCycle_rf256);
495 pcchCfg.nAndPagingFrmOffsetType = PCCH_Config__nAndPagingFrameOffset_PR_oneT;
496 pcchCfg.pageFrameOffset = 0;
497 pcchCfg.ns = convertNsEnumToValue(PCCH_Config__ns_one);
498 pcchCfg.firstPDCCHMontioringType = PCCH_Config__firstPDCCH_MonitoringOccasionOfPO_PR_sCS30KHZoneT_SCS15KHZhalfT;
499 memset(pcchCfg.firstPDCCHMontioringInfo, 0, sizeof(uint16_t));
500 pcchCfg.firstPDCCHMontioringInfo[0] = 44;
502 srvCellCfgComm->dlCfg.pcchCfg = pcchCfg;
505 /* Configuring UL Config Common */
507 srvCellCfgComm->ulCfg.ulScsCarrier.scsOffset = cellParams.ssbOffset;
508 srvCellCfgComm->ulCfg.ulScsCarrier.scs = convertScsValToScsEnum(cellParams.ssbSubCarrierSpacing);
509 srvCellCfgComm->ulCfg.ulScsCarrier.scsBw = cellParams.bSChannelBwUL;
511 srvCellCfgComm->ulCfg.ulScsCarrier.scsOffset = SSB_SUBCARRIER_OFFSET;
512 srvCellCfgComm->ulCfg.ulScsCarrier.scs = NR_SCS;
513 srvCellCfgComm->ulCfg.ulScsCarrier.scsBw = NR_BANDWIDTH;
515 srvCellCfgComm->ulCfg.freqBandInd = NR_FREQ_BAND;
516 srvCellCfgComm->ulCfg.pMax = UL_P_MAX;
517 srvCellCfgComm->ulCfg.locAndBw = FREQ_LOC_BW;
518 srvCellCfgComm->ulCfg.timeAlignTimerComm = TimeAlignmentTimer_infinity;
520 /* Configuring RACH Config Common for SIB1 */
521 rachCfg.present = BWP_UplinkCommon__rach_ConfigCommon_PR_setup;
522 rachCfg.prachCfgIdx = PRACH_CONFIG_IDX;
523 rachCfg.msg1Fdm = RACH_ConfigGeneric__msg1_FDM_one;
524 rachCfg.msg1FreqStart = PRACH_FREQ_START;
525 rachCfg.zeroCorrZoneCfg = ZERO_CORRELATION_ZONE_CFG;
526 rachCfg.preambleRcvdTgtPwr = PRACH_PREAMBLE_RCVD_TGT_PWR;
527 rachCfg.preambleTransMax = RACH_ConfigGeneric__preambleTransMax_n200;
528 rachCfg.pwrRampingStep = RACH_ConfigGeneric__powerRampingStep_dB2;
529 rachCfg.raRspWindow = RACH_ConfigGeneric__ra_ResponseWindow_sl10;
530 rachCfg.numRaPreamble = NUM_RA_PREAMBLE;
531 rachCfg.numSsbPerRachOcc = RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_one;
532 rachCfg.numCbPreamblePerSsb = CB_PREAMBLE_PER_SSB;
533 rachCfg.contResTimer = RACH_ConfigCommon__ra_ContentionResolutionTimer_sf64;
534 rachCfg.rsrpThreshSsb = RSRP_THRESHOLD_SSB;
535 rachCfg.rootSeqIdxPresent = RACH_ConfigCommon__prach_RootSequenceIndex_PR_l139;
536 rachCfg.rootSeqIdx = ROOT_SEQ_IDX;
537 rachCfg.msg1Scs = PRACH_SUBCARRIER_SPACING ;
538 rachCfg.restrictedSetCfg = PRACH_RESTRICTED_SET_CFG;
539 srvCellCfgComm->ulCfg.rachCfg = rachCfg;
541 /* Configuring PUSCH Config Common for SIB1 */
542 puschCfg.puschCfgPresent = BWP_UplinkCommon__pusch_ConfigCommon_PR_setup;
543 puschCfg.numTimeDomRsrcAlloc = 2;
544 puschCfg.timeDomAllocList[0].k2 = PUSCH_K2_CFG1;
545 puschCfg.timeDomAllocList[0].mapType = PUSCH_TimeDomainResourceAllocation__mappingType_typeA;
546 puschCfg.timeDomAllocList[0].sliv = calcSliv(PUSCH_START_SYMBOL,PUSCH_LENGTH_SYMBOL);
547 puschCfg.timeDomAllocList[1].k2 = PUSCH_K2_CFG2;
548 puschCfg.timeDomAllocList[1].mapType = PUSCH_TimeDomainResourceAllocation__mappingType_typeA;
549 puschCfg.timeDomAllocList[1].sliv = calcSliv(PUSCH_START_SYMBOL,PUSCH_LENGTH_SYMBOL);
550 puschCfg.msg3DeltaPreamble = PUSCH_MSG3_DELTA_PREAMBLE;
551 puschCfg.p0NominalWithGrant = PUSCH_P0_NOMINAL_WITH_GRANT;
552 srvCellCfgComm->ulCfg.puschCfg = puschCfg;
554 /* Configuring PUCCH Config Common for SIB1 */
555 pucchCfg.present = BWP_UplinkCommon__pucch_ConfigCommon_PR_setup;
556 pucchCfg.rsrcComm = PUCCH_RSRC_COMMON;
557 pucchCfg.grpHop = PUCCH_ConfigCommon__pucch_GroupHopping_neither;
558 pucchCfg.p0Nominal = PUCCH_P0_NOMINAL;
559 srvCellCfgComm->ulCfg.pucchCfg = pucchCfg;
561 /* Configuring TDD UL DL config common */
562 tddCfg.refScs = SubcarrierSpacing_kHz30;
563 tddCfg.txPrd = TDD_UL_DL_Pattern__dl_UL_TransmissionPeriodicity_ms5;
564 tddCfg.numDlSlots = NUM_DL_SLOTS;
565 tddCfg.numDlSymbols = NUM_DL_SYMBOLS;
566 tddCfg.numUlSlots = NUM_UL_SLOTS;
567 tddCfg.numUlSymbols = NUM_UL_SYMBOLS;
568 srvCellCfgComm->tddCfg = tddCfg;
570 srvCellCfgComm->ssbPosInBurst = 192;
571 srvCellCfgComm->ssbPrdServingCell = SSB_PERIODICITY;
572 srvCellCfgComm->ssPbchBlockPwr = SSB_PBCH_PWR;
577 /*******************************************************************
579 * @brief Configures the DU Parameters
586 * - Initializes the DuCfg members.
587 * - Calls readMacCfg()
589 * @params[in] system task ID
590 * @return ROK - success
593 * ****************************************************************/
597 uint8_t srvdCellIdx, bandIdx, sliceIdx, plmnIdx;
598 uint8_t brdcstPlmnIdx, freqBandIdx, srvdPlmnIdx;
599 uint32_t ipv4_du, ipv4_cu, ipv4_ric;
602 F1TaiSliceSuppLst *taiSliceSuppLst;
604 duCb.e2apDb.transIdCounter = 0;
605 memset(duCb.e2apDb.onGoingTransaction, 0, MAX_NUM_TRANSACTION * sizeof(E2TransInfo));
608 /* Note: Added these below variable for local testing*/
609 Snssai snssai[NUM_OF_SUPPORTED_SLICE] = {{1,{2,3,4}},{5,{6,7,8}}};
613 if( getStartupConfig(&g_cfg) != ROK )
617 cmInetAddr((S8*)g_cfg.DU_IPV4_Addr, &ipv4_du);
618 cmInetAddr((S8*)g_cfg.CU_IPV4_Addr, &ipv4_cu);
619 cmInetAddr((S8*)g_cfg.RIC_IPV4_Addr, &ipv4_ric);
621 duCfgParam.sctpParams.cuPort = g_cfg.CU_Port;
622 duCfgParam.sctpParams.ricPort = g_cfg.RIC_Port;
624 cmInetAddr((S8*)DU_IP_V4_ADDR, &ipv4_du);
625 cmInetAddr((S8*)CU_IP_V4_ADDR, &ipv4_cu);
626 cmInetAddr((S8*)RIC_IP_V4_ADDR, &ipv4_ric);
628 duCfgParam.sctpParams.cuPort = F1_SCTP_PORT;
629 duCfgParam.sctpParams.ricPort = E2_SCTP_PORT;
632 fillDuPort(duCfgParam.sctpParams.duPort);
634 /* F1 DU IP Address and Port*/
635 duCfgParam.sctpParams.duIpAddr.ipV4Addr = ipv4_du;
637 /* F1 CU IP Address and Port*/
638 duCfgParam.sctpParams.cuIpAddr.ipV4Addr = ipv4_cu;
640 /* Fill RIC Params */
641 duCfgParam.sctpParams.ricIpAddr.ipV4Addr = ipv4_ric;
643 /* EGTP Parameters */
644 duCfgParam.egtpParams.localIp.ipV4Pres = TRUE;
645 duCfgParam.egtpParams.localIp.ipV4Addr = ipv4_du;
646 duCfgParam.egtpParams.localPort = F1_EGTP_PORT;
647 duCfgParam.egtpParams.destIp.ipV4Pres = TRUE;
648 duCfgParam.egtpParams.destIp.ipV4Addr = ipv4_cu;
649 duCfgParam.egtpParams.destPort = F1_EGTP_PORT;
650 duCfgParam.egtpParams.minTunnelId = MIN_TEID;
651 duCfgParam.egtpParams.maxTunnelId = MAX_TEID;
653 duCfgParam.maxUe = 32; //TODO: Check
656 duCfgParam.duId = DU_ID;
657 DU_ALLOC(duCfgParam.duName, sizeof(DU_NAME));
658 if(!duCfgParam.duName)
660 DU_LOG("\nDEBUG --> DU_APP: readCfg(): Memory allocation failure for DU name");
663 strcpy((char*)duCfgParam.duName,DU_NAME);
666 mib.sysFrmNum = SYS_FRAME_NUM;
668 mib.subCarrierSpacingCommon = MIB__subCarrierSpacingCommon_scs30or120;
670 mib.subCarrierSpacingCommon = MIB__subCarrierSpacingCommon_scs15or60;
672 mib.ssb_SubcarrierOffset = SSB_SC_OFFSET; //Kssb
673 mib.dmrs_TypeA_Position = MIB__dmrs_TypeA_Position_pos2;
674 mib.controlResourceSetZero = CORESET_0_INDEX;
675 mib.searchSpaceZero = SEARCHSPACE_0_INDEX;
676 mib.cellBarred = MIB__cellBarred_notBarred;
677 mib.intraFreqReselection = MIB__intraFreqReselection_notAllowed;
678 duCfgParam.mibParams = mib;
681 memset(&sib1.plmn, 0, sizeof(Plmn));
682 sib1.plmn.mcc[0] = PLMN_MCC0;
683 sib1.plmn.mcc[1] = PLMN_MCC1;
684 sib1.plmn.mcc[2] = PLMN_MCC2;
685 sib1.plmn.mnc[0] = PLMN_MNC0;
686 sib1.plmn.mnc[1] = PLMN_MNC1;
687 sib1.ranac = DU_RANAC;
690 sib1.tac = cellParams.nRTAC;
691 sib1.cellIdentity = CELL_IDENTITY * cellParams.cellLocalId;
692 DU_LOG("\nDEBUG --> DU_APP: readCfg(): OAM CellLocalId=%d", \
696 sib1.cellIdentity = CELL_IDENTITY * NR_CELL_ID;
698 sib1.cellResvdForOpUse = PLMN_IdentityInfo__cellReservedForOperatorUse_notReserved;
699 sib1.connEstFailCnt = ConnEstFailureControl__connEstFailCount_n3;
700 sib1.connEstFailOffValidity = ConnEstFailureControl__connEstFailOffsetValidity_s900;
701 sib1.connEstFailOffset = 15;
702 sib1.siSchedInfo.winLen = SI_SchedulingInfo__si_WindowLength_s5;
703 sib1.siSchedInfo.broadcastSta = SchedulingInfo__si_BroadcastStatus_broadcasting;
704 sib1.siSchedInfo.preiodicity = SchedulingInfo__si_Periodicity_rf8;
705 sib1.siSchedInfo.sibType = SIB_TypeInfo__type_sibType2;
706 sib1.siSchedInfo.sibValTag = SIB1_VALUE_TAG;
708 fillServCellCfgCommSib(&sib1.srvCellCfgCommSib);
710 duCfgParam.sib1Params = sib1;
712 for(srvdCellIdx=0; srvdCellIdx<DEFAULT_CELLS; srvdCellIdx++)
714 memset(&duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.nrCgi.plmn, 0, sizeof(Plmn));
715 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.nrCgi.plmn.mcc[0] = PLMN_MCC0;
716 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.nrCgi.plmn.mcc[1] = PLMN_MCC1;
717 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.nrCgi.plmn.mcc[2] = PLMN_MCC2;
718 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.nrCgi.plmn.mnc[0] = PLMN_MNC0;
719 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.nrCgi.plmn.mnc[1] = PLMN_MNC1;
723 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.nrPci = cellParams.nRPCI;
725 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.nrPci = NR_PCI;
727 /* List of Available PLMN */
728 for(srvdPlmnIdx=0; srvdPlmnIdx<MAX_PLMN; srvdPlmnIdx++)
730 /* As per spec 38.473, Plmn identity consists of 3 digit from mcc
731 * followed by either 2 digit or 3 digits of mnc */
733 memset(&duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].plmn, 0,\
736 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].plmn.mcc[0] = cellParams.plmnList[srvdPlmnIdx].mcc[0];
737 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].plmn.mcc[1] = cellParams.plmnList[srvdPlmnIdx].mcc[1];
738 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].plmn.mcc[2] = cellParams.plmnList[srvdPlmnIdx].mcc[2];
739 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].plmn.mnc[0] = cellParams.plmnList[srvdPlmnIdx].mnc[0];
740 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].plmn.mnc[1] = cellParams.plmnList[srvdPlmnIdx].mnc[1];
741 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].plmn.mnc[2] = cellParams.plmnList[srvdPlmnIdx].mnc[2];
743 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].plmn.mcc[0] = PLMN_MCC0;
744 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].plmn.mcc[1] = PLMN_MCC1;
745 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].plmn.mcc[2] = PLMN_MCC2;
746 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].plmn.mnc[0] = PLMN_MNC0;
747 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].plmn.mnc[1] = PLMN_MNC1;
750 /* List of Extended 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].extPlmn, 0, sizeof(Plmn));
757 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].extPlmn.mcc[0] = PLMN_MCC0;
758 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].extPlmn.mcc[1] = PLMN_MCC1;
759 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].extPlmn.mcc[2] = PLMN_MCC2;
760 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].extPlmn.mnc[0] = PLMN_MNC0;
761 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].extPlmn.mnc[1] = PLMN_MNC1;
763 /* List of Supporting Slices */
764 for(srvdPlmnIdx=0; srvdPlmnIdx<MAX_PLMN; srvdPlmnIdx++)
766 taiSliceSuppLst = &duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellInfo.srvdPlmn[srvdPlmnIdx].\
769 /* TODO Calculte the exact number of supported slices once will get
770 * cell configuration from O1 */
771 taiSliceSuppLst->numSupportedSlices = NUM_OF_SUPPORTED_SLICE;
772 if(taiSliceSuppLst->numSupportedSlices > MAX_NUM_OF_SLICE_ITEMS)
774 DU_LOG("\nERROR --> DU_APP: readCfg(): Number of supported slice [%d] is more than 1024",\
775 taiSliceSuppLst->numSupportedSlices);
779 DU_ALLOC(taiSliceSuppLst->snssai, taiSliceSuppLst->numSupportedSlices*sizeof(Snssai*));
780 if(taiSliceSuppLst->snssai == NULLP)
782 DU_LOG("\nERROR --> DU_APP: readCfg():Memory allocation failed");
786 for(sliceIdx=0; sliceIdx<taiSliceSuppLst->numSupportedSlices; sliceIdx++)
788 DU_ALLOC(taiSliceSuppLst->snssai[sliceIdx], sizeof(Snssai));
789 if(taiSliceSuppLst->snssai[sliceIdx] == NULLP)
791 DU_LOG("\nERROR --> DU_APP: readCfg():Memory allocation failed");
795 memcpy(taiSliceSuppLst->snssai[sliceIdx]->sd, cellParams.plmnList[sliceIdx].sd, \
796 SD_SIZE*sizeof(uint8_t));
797 taiSliceSuppLst->snssai[sliceIdx]->sst = cellParams.plmnList[sliceIdx].sst;
799 memcpy(taiSliceSuppLst->snssai[sliceIdx], &snssai[sliceIdx], sizeof(Snssai));
806 /* NR TDD Mode info */
808 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.nrArfcn = cellParams.arfcnUL;
809 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.sulInfo.sulArfcn = cellParams.arfcnSUL;
810 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.sulInfo.sulTxBw.nrScs = cellParams.ssbSubCarrierSpacing;
812 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.nrArfcn = NR_UL_ARFCN;
813 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.sulInfo.sulArfcn = SUL_ARFCN;
814 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.sulInfo.sulTxBw.nrScs = NR_SCS;
816 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.sulInfo.sulTxBw.nrb = NRB_273;
818 for(freqBandIdx=0; freqBandIdx<MAX_NRCELL_BANDS; freqBandIdx++)
820 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.freqBand[freqBandIdx].nrFreqBand =\
822 for(bandIdx=0; bandIdx<MAX_NRCELL_BANDS; bandIdx++)
824 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.freqBand[freqBandIdx].sulBand[bandIdx]\
829 /* NR FDD Mode info */
831 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.nrArfcn = cellParams.arfcnUL;
832 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.sulInfo.sulArfcn = cellParams.arfcnSUL;
833 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.ulTxBw.nrScs = cellParams.ssbSubCarrierSpacing;
834 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.sulInfo.sulTxBw.nrScs = cellParams.ssbSubCarrierSpacing;
835 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.nrArfcn = cellParams.arfcnDL;
836 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.sulInfo.sulArfcn = cellParams.arfcnSUL;
837 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.sulInfo.sulTxBw.nrScs = cellParams.ssbSubCarrierSpacing;
838 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.dlTxBw.nrScs = cellParams.ssbSubCarrierSpacing;
840 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.nrArfcn = NR_UL_ARFCN;
841 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.sulInfo.sulArfcn = SUL_ARFCN;
842 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.ulTxBw.nrScs = NR_SCS;
843 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.sulInfo.sulTxBw.nrScs = NR_SCS;
844 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.nrArfcn = NR_DL_ARFCN;
845 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.sulInfo.sulArfcn = SUL_ARFCN;
846 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.sulInfo.sulTxBw.nrScs = NR_SCS;
847 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.dlTxBw.nrScs = NR_SCS;
849 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.sulInfo.sulTxBw.nrb = NRB_106;
850 for(freqBandIdx=0; freqBandIdx<MAX_NRCELL_BANDS; freqBandIdx++)
852 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.freqBand[freqBandIdx].\
853 nrFreqBand = NR_FREQ_BAND;
854 for(bandIdx=0; bandIdx<MAX_NRCELL_BANDS; bandIdx++)
856 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.freqBand[freqBandIdx].\
857 sulBand[bandIdx] = SUL_BAND;
860 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.sulInfo.sulTxBw.nrb = NRB_106;
861 for(freqBandIdx=0; freqBandIdx<MAX_NRCELL_BANDS; freqBandIdx++)
863 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.freqBand[freqBandIdx].\
864 nrFreqBand = NR_FREQ_BAND;
865 for(bandIdx=0; bandIdx<MAX_NRCELL_BANDS; bandIdx++)
867 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.freqBand[freqBandIdx].\
868 sulBand[bandIdx] = SUL_BAND;
872 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.ulTxBw.nrb = NRB_106;
873 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.f1Mode.mode.fdd.dlTxBw.nrb = NRB_106;
876 /*Measurement Config and Cell Config */
877 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.measTimeCfgDuration = TIME_CFG;
879 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellDir = DL_UL;
881 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.cellType=CELL_TYPE;
883 /* Broadcast PLMN Identity */
884 for(brdcstPlmnIdx=0; brdcstPlmnIdx<MAX_BPLMN_NRCELL_MINUS_1; brdcstPlmnIdx++)
886 for(plmnIdx=0; plmnIdx<MAX_PLMN; plmnIdx++)
888 memset(&duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].plmn[plmnIdx],\
890 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].plmn[plmnIdx].mcc[0] =\
892 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].plmn[plmnIdx].mcc[1] =\
894 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].plmn[plmnIdx].mcc[2] =\
896 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].plmn[plmnIdx].mnc[0] =\
898 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].plmn[plmnIdx].mnc[1] =\
901 /* Extended PLMN List */
902 for(plmnIdx=0; plmnIdx<MAX_PLMN; plmnIdx++)
904 memset(&duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].\
905 extPlmn[plmnIdx], 0, sizeof(Plmn));
906 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].\
907 extPlmn[plmnIdx].mcc[0] = PLMN_MCC0;
908 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].\
909 extPlmn[plmnIdx].mcc[1] = PLMN_MCC1;
910 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].\
911 extPlmn[plmnIdx].mcc[2] = PLMN_MCC2;
912 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].\
913 extPlmn[plmnIdx].mnc[0] = PLMN_MNC0;
914 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].\
915 extPlmn[plmnIdx].mnc[1] = PLMN_MNC1;
918 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.epsTac = cellParams.nRTAC; //TODO : to check and fill
919 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.tac = cellParams.nRTAC;
920 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].tac = cellParams.nRTAC;
921 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].nrCellId = cellParams.cellLocalId;
923 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.epsTac = DU_TAC; //TODO : to check and fill
924 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.tac = DU_TAC;
925 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].tac = DU_TAC;
926 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].nrCellId = NR_CELL_ID;
928 duCfgParam.srvdCellLst[srvdCellIdx].duCellInfo.brdcstPlmnInfo[brdcstPlmnIdx].ranac = NR_RANAC;
931 /*gnb DU System Info mib msg*/
933 DU_ALLOC(duCfgParam.srvdCellLst[srvdCellIdx].duSysInfo.mibMsg, encBufSize);
934 if(!(duCfgParam.srvdCellLst[srvdCellIdx].duSysInfo.mibMsg))
936 DU_LOG("\nERROR --> DU APP : Memory allocation failure at readCfg");
939 memcpy(duCfgParam.srvdCellLst[srvdCellIdx].duSysInfo.mibMsg, encBuf, encBufSize);
940 duCfgParam.srvdCellLst[srvdCellIdx].duSysInfo.mibLen = encBufSize;
942 /*gnb DU System Info mib msg*/
944 DU_ALLOC(duCfgParam.srvdCellLst[srvdCellIdx].duSysInfo.sib1Msg,\
946 if(!(duCfgParam.srvdCellLst[srvdCellIdx].duSysInfo.sib1Msg))
948 DU_LOG("\nERROR --> DU APP : Memory allocation failure at readCfg");
951 memcpy(duCfgParam.srvdCellLst[srvdCellIdx].duSysInfo.sib1Msg,\
953 duCfgParam.srvdCellLst[srvdCellIdx].duSysInfo.sib1Len = encBufSize;
957 if(readMacCfg() != ROK)
959 DU_LOG("\nERROR --> DU_APP : Failed while reading MAC config");
966 /*******************************************************************
968 * @brief Copy Slice Cfg in temp structre in duCfgParams
972 * Function : cpyRrmPolicyInDuCfgParams
975 * - Copy Slice Cfg in temp structre in duCfgParams
977 * @params[in] RrmPolicy rrmPolicy[], uint8_t policyNum, uint8_t memberList
978 * @return ROK - success
981 * ****************************************************************/
982 uint8_t cpyRrmPolicyInDuCfgParams(RrmPolicyList rrmPolicy[], uint8_t policyNum, MacSliceCfgReq *tempSliceCfg)
984 uint8_t policyIdx = 0, memberListIdx = 0;
987 tempSliceCfg->numOfRrmPolicy = policyNum;
988 DU_ALLOC_SHRABL_BUF(tempSliceCfg->listOfRrmPolicy, tempSliceCfg->numOfRrmPolicy * sizeof(MacSliceRrmPolicy*));
989 if(!tempSliceCfg->listOfRrmPolicy)
991 DU_LOG("\nERROR --> DU APP : Memory allocation failed in cpyRrmPolicyInDuCfgParams");
995 for(policyIdx = 0; policyIdx<tempSliceCfg->numOfRrmPolicy; policyIdx++)
997 DU_ALLOC_SHRABL_BUF(tempSliceCfg->listOfRrmPolicy[policyIdx], sizeof(MacSliceRrmPolicy));
998 if(!tempSliceCfg->listOfRrmPolicy[policyIdx])
1000 DU_LOG("\nERROR --> DU APP : Memory allocation failed in cpyRrmPolicyInDuCfgParams");
1004 tempSliceCfg->listOfRrmPolicy[policyIdx]->resourceType = rrmPolicy[policyIdx].resourceType;
1006 tempSliceCfg->listOfRrmPolicy[policyIdx]->numOfRrmPolicyMem = rrmPolicy[policyIdx].rRMMemberNum;
1008 if(tempSliceCfg->listOfRrmPolicy[policyIdx]->numOfRrmPolicyMem)
1010 DU_ALLOC_SHRABL_BUF(tempSliceCfg->listOfRrmPolicy[policyIdx]->rRMPolicyMemberList,\
1011 tempSliceCfg->listOfRrmPolicy[policyIdx]->numOfRrmPolicyMem * sizeof(RrmPolicyMemberList*));
1013 if(!tempSliceCfg->listOfRrmPolicy[policyIdx]->rRMPolicyMemberList)
1015 DU_LOG("\nERROR --> DU APP : Memory allocation failed in cpyRrmPolicyInDuCfgParams");
1020 for(memberListIdx = 0; memberListIdx<tempSliceCfg->listOfRrmPolicy[policyIdx]->numOfRrmPolicyMem; memberListIdx++)
1022 DU_ALLOC_SHRABL_BUF(tempSliceCfg->listOfRrmPolicy[policyIdx]->rRMPolicyMemberList[memberListIdx], sizeof(RrmPolicyMemberList));
1023 if(!tempSliceCfg->listOfRrmPolicy[policyIdx]->rRMPolicyMemberList[memberListIdx])
1025 DU_LOG("\nERROR --> DU APP : Memory allocation failed in cpyRrmPolicyInDuCfgParams");
1028 memcpy(&tempSliceCfg->listOfRrmPolicy[policyIdx]->rRMPolicyMemberList[memberListIdx]->snssai.sd,\
1029 &rrmPolicy[policyIdx].rRMPolicyMemberList[memberListIdx].sd, 3 * sizeof(uint8_t));
1030 memcpy(&tempSliceCfg->listOfRrmPolicy[policyIdx]->rRMPolicyMemberList[memberListIdx]->snssai.sst,\
1031 &rrmPolicy[policyIdx].rRMPolicyMemberList[memberListIdx].sst, sizeof(uint8_t));
1032 memcpy(&tempSliceCfg->listOfRrmPolicy[policyIdx]->rRMPolicyMemberList[memberListIdx]->plmn.mcc,\
1033 &rrmPolicy[policyIdx].rRMPolicyMemberList[memberListIdx].mcc, 3 * sizeof(uint8_t));
1034 memcpy(&tempSliceCfg->listOfRrmPolicy[policyIdx]->rRMPolicyMemberList[memberListIdx]->plmn.mnc,\
1035 &rrmPolicy[policyIdx].rRMPolicyMemberList[memberListIdx].mnc, 3 * sizeof(uint8_t));
1037 tempSliceCfg->listOfRrmPolicy[policyIdx]->policyRatio.maxRatio = rrmPolicy[policyIdx].rRMPolicyMaxRatio;
1038 tempSliceCfg->listOfRrmPolicy[policyIdx]->policyRatio.minRatio = rrmPolicy[policyIdx].rRMPolicyMinRatio;
1039 tempSliceCfg->listOfRrmPolicy[policyIdx]->policyRatio.dedicatedRatio = rrmPolicy[policyIdx].rRMPolicyDedicatedRatio;
1047 /*******************************************************************
1049 * @brief Reads config and posts message to du_app on completion
1057 * - Post to du_app for further processing
1060 * @return ROK - success
1063 * ****************************************************************/
1069 memset(&duCfgParam, 0, sizeof(DuCfgParams));
1071 //Read configs into duCfgParams
1072 if(readCfg() != ROK)
1074 DU_LOG("\nERROR --> DU_APP : Reading configuration failed");
1078 //Fill pst structure
1079 memset(&(pst), 0, sizeof(Pst));
1080 pst.srcEnt = (Ent)ENTDUAPP;
1081 pst.srcInst = (Inst)DU_INST;
1082 pst.srcProcId = DU_PROC;
1083 pst.dstEnt = pst.srcEnt;
1084 pst.dstInst = pst.srcInst;
1085 pst.dstProcId = pst.srcProcId;
1087 pst.selector = ODU_SELECTOR_TC;
1091 if(ODU_GET_MSG_BUF(DFLT_REGION, DU_POOL, &mBuf) != ROK)
1093 DU_LOG("\nERROR --> DU_APP : Memory allocation failed in duReadCfg");
1097 if (ODU_POST_TASK(&pst, mBuf) != ROK)
1099 DU_LOG("\nERROR --> DU_APP : ODU_POST_TASK failed in duReadCfg");
1106 /**********************************************************************
1108 **********************************************************************/