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"
55 DuCfgParams duCfgParam;
56 char encBuf[ENC_BUF_MAX_LEN];
59 /* Filling Slot configuration as :
60 * 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
61 * 0 DL DL DL DL DL DL DL DL DL DL DL DL DL DL
62 * 1 DL DL DL DL DL DL DL DL DL DL DL DL DL DL
63 * 2 DL DL DL DL DL DL DL DL DL DL DL DL DL DL
64 * 3 DL DL DL DL DL DL DL DL DL DL GD GD GD UL
65 * 4 UL UL UL UL UL UL UL UL UL UL UL UL UL UL
68 /*******************************************************************
70 * @brief Fills the Slot configuration
74 * Function : FillSlotConfig
76 * Functionality:Fill the Slot configuration values
79 * @return ROK - success
82 * ****************************************************************/
88 for(slot = 0; slot <= 3; slot++)
90 for(symbol = 0; symbol < MAX_SYMB_PER_SLOT; symbol++)
91 duCfgParam.macCellCfg.tddCfg.slotCfg[slot][symbol] = DL_SLOT;
94 duCfgParam.macCellCfg.tddCfg.slotCfg[3][10] = GUARD_SLOT;
95 duCfgParam.macCellCfg.tddCfg.slotCfg[3][11] = GUARD_SLOT;
96 duCfgParam.macCellCfg.tddCfg.slotCfg[3][12] = GUARD_SLOT;
97 duCfgParam.macCellCfg.tddCfg.slotCfg[3][13] = UL_SLOT;
99 for(symbol = 0; symbol < MAX_SYMB_PER_SLOT; symbol++)
100 duCfgParam.macCellCfg.tddCfg.slotCfg[4][symbol] = UL_SLOT;
104 /*******************************************************************
106 * @brief Reads the CL Configuration.
110 * Function : readMacCfg
113 * - Fills up the cell configuration for CL.
114 * - Calls FillSlotConfig()
117 * @return ROK - success
120 * ****************************************************************/
123 /* This function is used to fill up the cell configuration for CL */
126 duCfgParam.macCellCfg.carrierId = CARRIER_IDX;
128 /* Cell configuration */
129 duCfgParam.macCellCfg.cellId = NR_CELL_ID;
130 duCfgParam.macCellCfg.phyCellId = NR_PCI;
131 duCfgParam.macCellCfg.numerology = NR_NUMEROLOGY;
132 duCfgParam.macCellCfg.dupType = DUPLEX_MODE;
134 /* DL carrier configuration */
135 duCfgParam.macCellCfg.dlCarrCfg.pres = TRUE;
136 duCfgParam.macCellCfg.dlCarrCfg.bw = BANDWIDTH_20MHZ;
137 duCfgParam.macCellCfg.dlCarrCfg.freq = NR_DL_ARFCN;
138 duCfgParam.macCellCfg.dlCarrCfg.k0[0] = 1;
139 duCfgParam.macCellCfg.dlCarrCfg.k0[1] = 1;
140 duCfgParam.macCellCfg.dlCarrCfg.k0[2] = 1;
141 duCfgParam.macCellCfg.dlCarrCfg.k0[3] = 1;
142 duCfgParam.macCellCfg.dlCarrCfg.k0[4] = 1;
143 duCfgParam.macCellCfg.dlCarrCfg.gridSize[0] = 273;
144 duCfgParam.macCellCfg.dlCarrCfg.gridSize[1] = 1;
145 duCfgParam.macCellCfg.dlCarrCfg.gridSize[2] = 1;
146 duCfgParam.macCellCfg.dlCarrCfg.gridSize[3] = 1;
147 duCfgParam.macCellCfg.dlCarrCfg.gridSize[4] = 1;
148 duCfgParam.macCellCfg.dlCarrCfg.numAnt = NUM_TX_ANT;
150 /* UL Carrier configuration */
151 duCfgParam.macCellCfg.ulCarrCfg.pres = TRUE;
152 duCfgParam.macCellCfg.ulCarrCfg.bw = BANDWIDTH_20MHZ;
153 duCfgParam.macCellCfg.ulCarrCfg.freq = NR_UL_ARFCN;
154 duCfgParam.macCellCfg.ulCarrCfg.k0[0] = 1;
155 duCfgParam.macCellCfg.ulCarrCfg.k0[1] = 1;
156 duCfgParam.macCellCfg.ulCarrCfg.k0[2] = 1;
157 duCfgParam.macCellCfg.ulCarrCfg.k0[3] = 1;
158 duCfgParam.macCellCfg.ulCarrCfg.k0[4] = 1;
159 duCfgParam.macCellCfg.ulCarrCfg.gridSize[0] = 1;
160 duCfgParam.macCellCfg.ulCarrCfg.gridSize[1] = 1;
161 duCfgParam.macCellCfg.ulCarrCfg.gridSize[2] = 1;
162 duCfgParam.macCellCfg.ulCarrCfg.gridSize[3] = 1;
163 duCfgParam.macCellCfg.ulCarrCfg.gridSize[4] = 1;
164 duCfgParam.macCellCfg.ulCarrCfg.numAnt = NUM_RX_ANT;
166 duCfgParam.macCellCfg.freqShft = FREQ_SHIFT_7P5KHZ;
168 /* SSB configuration */
169 duCfgParam.macCellCfg.ssbCfg.ssbPbchPwr = SSB_PBCH_PWR;
170 duCfgParam.macCellCfg.ssbCfg.bchPayloadFlag = BCH_PAYLOAD;
171 duCfgParam.macCellCfg.ssbCfg.scsCmn = SUBCARRIER_SPACING;
172 duCfgParam.macCellCfg.ssbCfg.ssbOffsetPointA = OFFSET_TO_POINT_A;
173 duCfgParam.macCellCfg.ssbCfg.betaPss = BETA_PSS;
174 duCfgParam.macCellCfg.ssbCfg.ssbPeriod = SSB_PRDCTY_MS_20;
175 duCfgParam.macCellCfg.ssbCfg.ssbScOffset = SSB_SUBCARRIER_OFFSET;
176 duCfgParam.macCellCfg.ssbCfg.ssbMask[0] = 1; /* only one SSB is transmitted */
177 duCfgParam.macCellCfg.ssbCfg.ssbMask[1] = 0;
178 if(BuildMibPdu() != ROK)
180 DU_LOG("\nFailed to build MIB PDU");
181 memset(&duCfgParam.macCellCfg.ssbCfg.mibPdu, 0, 3*sizeof(uint8_t));
185 for(uint8_t idx=0; idx<encBufSize; idx++)
187 duCfgParam.macCellCfg.ssbCfg.mibPdu[idx]=encBuf[idx];
190 duCfgParam.macCellCfg.ssbCfg.multCarrBand = SSB_MULT_CARRIER_BAND;
191 duCfgParam.macCellCfg.ssbCfg.multCellCarr = MULT_CELL_CARRIER;
193 /* PRACH configuration */
194 duCfgParam.macCellCfg.prachCfg.pres = TRUE;
195 duCfgParam.macCellCfg.prachCfg.prachCfgIdx = PRACH_CONFIG_IDX;
196 duCfgParam.macCellCfg.prachCfg.prachSeqLen = PRACH_SEQ_LEN;
197 duCfgParam.macCellCfg.prachCfg.prachSubcSpacing = PRACH_SUBCARRIER_SPACING;
198 duCfgParam.macCellCfg.prachCfg.prachRstSetCfg = PRACH_RESTRICTED_SET_CFG;
199 duCfgParam.macCellCfg.prachCfg.msg1Fdm = NUM_PRACH_FDM;
200 duCfgParam.macCellCfg.prachCfg.msg1FreqStart = PRACH_FREQ_START;
201 duCfgParam.macCellCfg.prachCfg.rootSeqLen = ROOT_SEQ_LEN;
202 duCfgParam.macCellCfg.prachCfg.fdm[0].rootSeqIdx = ROOT_SEQ_IDX;
203 duCfgParam.macCellCfg.prachCfg.fdm[0].numRootSeq = NUM_ROOT_SEQ;
204 duCfgParam.macCellCfg.prachCfg.fdm[0].k1 = 0;
205 duCfgParam.macCellCfg.prachCfg.fdm[0].zeroCorrZoneCfg = ZERO_CORRELATION_ZONE_CFG;
206 duCfgParam.macCellCfg.prachCfg.fdm[0].numUnusedRootSeq = NUM_UNUSED_ROOT_SEQ;
207 if(duCfgParam.macCellCfg.prachCfg.fdm[0].numUnusedRootSeq != 0)
209 DU_ALLOC_SHRABL_BUF(duCfgParam.macCellCfg.prachCfg.fdm[0].unsuedRootSeq,
210 NUM_UNUSED_ROOT_SEQ * sizeof(uint8_t));
211 if(duCfgParam.macCellCfg.prachCfg.fdm[0].unsuedRootSeq == NULLP)
213 DU_LOG("\nDU_APP : Memory allocation failed");
216 *(duCfgParam.macCellCfg.prachCfg.fdm[0].unsuedRootSeq) = UNUSED_ROOT_SEQ;
218 duCfgParam.macCellCfg.prachCfg.ssbPerRach = SSB_PER_RACH;
219 duCfgParam.macCellCfg.prachCfg.prachMultCarrBand = PRACH_MULT_CARRIER_BAND;
220 duCfgParam.macCellCfg.prachCfg.raContResTmr = RA_CONT_RES_TIMER;
221 duCfgParam.macCellCfg.prachCfg.rsrpThreshSsb = RSRP_THRESHOLD_SSB;
222 duCfgParam.macCellCfg.prachCfg.raRspWindow = RA_RSP_WINDOW;
223 duCfgParam.macCellCfg.prachCfg.prachRestrictedSet = PRACH_RESTRICTED_SET;
224 /* TDD configuration */
225 duCfgParam.macCellCfg.tddCfg.pres = TRUE;
226 duCfgParam.macCellCfg.tddCfg.tddPeriod = TDD_PERIODICITY;
230 /* RSSI Measurement configuration */
231 duCfgParam.macCellCfg.rssiUnit = RSS_MEASUREMENT_UNIT;
233 /* fill SIB1 configuration */
234 duCfgParam.macCellCfg.sib1Cfg.sib1PduLen = duCfgParam.srvdCellLst[0].duSysInfo.sib1Len;
235 DU_ALLOC_SHRABL_BUF(duCfgParam.macCellCfg.sib1Cfg.sib1Pdu,duCfgParam.srvdCellLst[0].duSysInfo.sib1Len);
236 memcpy(duCfgParam.macCellCfg.sib1Cfg.sib1Pdu, duCfgParam.srvdCellLst[0].duSysInfo.sib1Msg, \
237 duCfgParam.srvdCellLst[0].duSysInfo.sib1Len);
238 duCfgParam.macCellCfg.sib1Cfg.sib1NewTxPeriod = SIB1_NEW_TX_PERIOD;
239 duCfgParam.macCellCfg.sib1Cfg.sib1RepetitionPeriod = SIB1_REPETITION_PERIOD;
240 duCfgParam.macCellCfg.sib1Cfg.coresetZeroIndex = CORESET_0_INDEX;
241 duCfgParam.macCellCfg.sib1Cfg.searchSpaceZeroIndex = SEARCHSPACE_0_INDEX;
242 duCfgParam.macCellCfg.sib1Cfg.sib1Mcs = SIB1_MCS;
245 /* fill Intial DL BWP */
246 duCfgParam.macCellCfg.initialDlBwp.bwp.firstPrb = 0;
247 duCfgParam.macCellCfg.initialDlBwp.bwp.numPrb = TOTAL_PRB_20MHZ_MU0; /* configured to total BW */
248 duCfgParam.macCellCfg.initialDlBwp.bwp.scs = SUBCARRIER_SPACING; /* numerology is 0, 15Khz */
249 duCfgParam.macCellCfg.initialDlBwp.bwp.cyclicPrefix = NORMAL_CYCLIC_PREFIX;
250 duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.searchSpaceId = SEARCHSPACE_1_INDEX;
251 duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.coresetId = CORESET_0_INDEX;
252 duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.monitoringSlot =
253 SS_MONITORING_SLOT_SL1; /* sl1 - all slots */
254 duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.duration = 0;
255 duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.monitoringSymbol =
256 SS_MONITORING_SYMBOL;
257 duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.
258 candidate.aggLevel1 = 8;
259 duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.
260 candidate.aggLevel2 = 4;
261 duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.
262 candidate.aggLevel4 = 2;
263 duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.
264 candidate.aggLevel8 = 1;
265 duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.
266 candidate.aggLevel16 = 0;
267 duCfgParam.macCellCfg.initialDlBwp.pdschCommon.k0 = PDSCH_K0;
268 duCfgParam.macCellCfg.initialDlBwp.pdschCommon.mappingType =
269 PDSCH_MAPPING_TYPE_A;
270 duCfgParam.macCellCfg.initialDlBwp.pdschCommon.startSymbol =
272 duCfgParam.macCellCfg.initialDlBwp.pdschCommon.lengthSymbol =
274 /* ra-searchSpace ID is set to 1 */
275 duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.raSearchSpaceId = SEARCHSPACE_1_INDEX;
277 /* fill Intial UL BWP */
278 duCfgParam.macCellCfg.initialUlBwp.bwp.firstPrb = 0;
279 duCfgParam.macCellCfg.initialUlBwp.bwp.numPrb = TOTAL_PRB_20MHZ_MU0; /* configured to total BW */
280 duCfgParam.macCellCfg.initialUlBwp.bwp.scs = SUBCARRIER_SPACING; /* numerology is 0, 15Khz */
281 duCfgParam.macCellCfg.initialUlBwp.bwp.cyclicPrefix = NORMAL_CYCLIC_PREFIX;
282 duCfgParam.macCellCfg.initialUlBwp.puschCommon.k2 = PUSCH_K2;
283 duCfgParam.macCellCfg.initialUlBwp.puschCommon.mappingType =
284 PUSCH_MAPPING_TYPE_A;
285 duCfgParam.macCellCfg.initialUlBwp.puschCommon.startSymbol =
287 duCfgParam.macCellCfg.initialUlBwp.puschCommon.lengthSymbol =
290 duCfgParam.macCellCfg.dmrsTypeAPos = DMRS_TYPE_A_POS;
291 /* fill PUCCH config common */
292 duCfgParam.macCellCfg.initialUlBwp.pucchCommon.pucchResourceCommon = PUCCH_RSRC_COMMON;
293 duCfgParam.macCellCfg.initialUlBwp.pucchCommon.pucchGroupHopping = PUCCH_GROUP_HOPPING;
298 /*******************************************************************
300 * @brief Configures the DU Parameters
304 * Function : fillDuPort
307 * - fills the DU Ports.
309 * @params[in] duPort array to be filled
310 * @return ROK - success
313 * ****************************************************************/
314 uint8_t fillDuPort(uint16_t *duPort)
316 duPort[F1_INTERFACE] = DU_PORT; /* DU Port idx 0 38472 */
317 duPort[E2_INTERFACE] = RIC_PORT; /* RIC Port idx 1 38482 */
322 /*******************************************************************
324 * @brief Configures the DU Parameters
328 * Function : calcSliv
331 * - calculate SLIV value from start and length field
333 * @params[in] start symbol
334 * @params[in] length of symbols
337 * ****************************************************************/
338 uint16_t calcSliv(uint8_t startSymbol, uint8_t lengthSymbol)
341 if((lengthSymbol-1) <= 7)
343 sliv = NUM_SYMBOLS_PER_SLOT * (lengthSymbol-1) + startSymbol;
347 sliv = NUM_SYMBOLS_PER_SLOT * (NUM_SYMBOLS_PER_SLOT - lengthSymbol + 1) \
348 + (NUM_SYMBOLS_PER_SLOT - 1 - startSymbol);
354 /*******************************************************************
356 * @brief Configures serving cell config common in sib1
360 * Function : fillServCellCfgCommSib
363 * - fills Serving cell config common for SIB1
365 * @params[in] SrvCellCfgCommSib pointer
366 * @return ROK - success
369 ** ****************************************************************/
370 uint8_t fillServCellCfgCommSib(SrvCellCfgCommSib *srvCellCfgComm)
372 PdcchCfgCommon pdcchCfg;
373 PdschCfgCommon pdschCfg;
375 RachCfgCommon rachCfg;
376 PuschCfgCommon puschCfg;
377 PucchCfgCommon pucchCfg;
378 TddUlDlCfgCommon tddCfg;
380 /* Configuring DL Config Common for SIB1*/
381 srvCellCfgComm->dlCfg.freqBandInd = NR_FREQ_BAND_IND;
382 srvCellCfgComm->dlCfg.offsetToPointA = OFFSET_TO_POINT_A;
383 srvCellCfgComm->dlCfg.dlScsCarrier.scsOffset = SSB_SUBCARRIER_OFFSET;
384 srvCellCfgComm->dlCfg.dlScsCarrier.scs = SUBCARRIER_SPACING;
385 srvCellCfgComm->dlCfg.dlScsCarrier.scsBw = BANDWIDTH_20MHZ;
386 srvCellCfgComm->dlCfg.locAndBw = FREQ_LOC_BW;
388 /* Configuring PDCCH Config Common For SIB1 */
389 pdcchCfg.present = BWP_DownlinkCommon__pdcch_ConfigCommon_PR_setup;
390 pdcchCfg.ctrlRsrcSetZero = CORESET_0_INDEX;
391 pdcchCfg.searchSpcZero = SEARCHSPACE_0_INDEX;
392 pdcchCfg.searchSpcId = PDCCH_SEARCH_SPACE_ID;
393 pdcchCfg.ctrlRsrcSetId = PDCCH_CTRL_RSRC_SET_ID;
394 pdcchCfg.monitorSlotPrdAndOffPresent = \
395 SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl1;
396 //pdcchCfg.monitorSlotPrdAndOff = \
397 SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl1;
398 pdcchCfg.monitorSymbolsInSlot[0] = 128;
399 pdcchCfg.monitorSymbolsInSlot[1] = 0;
400 pdcchCfg.numCandAggLvl1 = SearchSpace__nrofCandidates__aggregationLevel1_n8;
401 pdcchCfg.numCandAggLvl2 = SearchSpace__nrofCandidates__aggregationLevel2_n4;
402 pdcchCfg.numCandAggLvl4 = SearchSpace__nrofCandidates__aggregationLevel4_n2;
403 pdcchCfg.numCandAggLvl8 = SearchSpace__nrofCandidates__aggregationLevel8_n1;
404 pdcchCfg.numCandAggLvl16 = SearchSpace__nrofCandidates__aggregationLevel16_n0;
405 pdcchCfg.searchSpcType = SearchSpace__searchSpaceType_PR_common;
406 pdcchCfg.commSrchSpcDciFrmt = PDCCH_SERACH_SPACE_DCI_FORMAT;
407 pdcchCfg.searchSpcSib1 = PDCCH_SEARCH_SPACE_ID_SIB1;
408 pdcchCfg.pagingSearchSpc = PDCCH_SEARCH_SPACE_ID_PAGING;
409 pdcchCfg.raSearchSpc = PDCCH_SEARCH_SPACE_ID_PAGING;
410 srvCellCfgComm->dlCfg.pdcchCfg = pdcchCfg;
412 /* Configuring PDSCH Config Common For SIB1 */
413 pdschCfg.present = BWP_DownlinkCommon__pdsch_ConfigCommon_PR_setup;
414 pdschCfg.k0 = PDSCH_K0;
416 PDSCH_TimeDomainResourceAllocation__mappingType_typeA;
417 pdschCfg.sliv = calcSliv(PDSCH_START_SYMBOL,PDSCH_LENGTH_SYMBOL);
418 srvCellCfgComm->dlCfg.pdschCfg = pdschCfg;
420 /* Configuring BCCH Config for SIB1 */
421 srvCellCfgComm->dlCfg.bcchCfg.modPrdCoeff = \
422 BCCH_Config__modificationPeriodCoeff_n16;
424 /* Configuring PCCH Config for SIB1 */
425 pcchCfg.dfltPagingCycle = PagingCycle_rf256;
426 pcchCfg.nAndPagingFrmOffPresent = PCCH_Config__nAndPagingFrameOffset_PR_oneT;
427 pcchCfg.numPagingOcc = PCCH_Config__ns_four;
428 srvCellCfgComm->dlCfg.pcchCfg = pcchCfg;
431 /* Configuring UL Config Common */
432 srvCellCfgComm->ulCfg.ulScsCarrier.scsOffset = SSB_SUBCARRIER_OFFSET;
433 srvCellCfgComm->ulCfg.ulScsCarrier.scs = SUBCARRIER_SPACING;
434 srvCellCfgComm->ulCfg.ulScsCarrier.scsBw = BANDWIDTH_20MHZ;
435 srvCellCfgComm->ulCfg.pMax = UL_P_MAX;
436 srvCellCfgComm->ulCfg.locAndBw = FREQ_LOC_BW;
437 srvCellCfgComm->ulCfg.timeAlignTimerComm = TimeAlignmentTimer_infinity;
439 /* Configuring RACH Config Common for SIB1 */
440 rachCfg.present = BWP_UplinkCommon__rach_ConfigCommon_PR_setup;
441 rachCfg.prachCfgIdx = PRACH_CONFIG_IDX;
442 rachCfg.msg1Fdm = RACH_ConfigGeneric__msg1_FDM_one;
443 rachCfg.msg1FreqStart = PRACH_FREQ_START;
444 rachCfg.zeroCorrZoneCfg = ZERO_CORRELATION_ZONE_CFG;
445 rachCfg.preambleRcvdTgtPwr = PRACH_PREAMBLE_RCVD_TGT_PWR;
446 rachCfg.preambleTransMax = RACH_ConfigGeneric__preambleTransMax_n200;
447 rachCfg.pwrRampingStep = RACH_ConfigGeneric__powerRampingStep_dB2;
448 rachCfg.raRspWindow = RACH_ConfigGeneric__ra_ResponseWindow_sl20;
449 rachCfg.numRaPreamble = NUM_RA_PREAMBLE;
450 rachCfg.ssbPerRachOccPresent = \
451 RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_one;
452 rachCfg.numSsbPerRachOcc = SSB_PER_RACH;
453 rachCfg.contResTimer = RACH_ConfigCommon__ra_ContentionResolutionTimer_sf64;
454 rachCfg.rsrpThreshSsb = RSRP_THRESHOLD_SSB;
455 rachCfg.rootSeqIdxPresent = RACH_ConfigCommon__prach_RootSequenceIndex_PR_l139;
456 rachCfg.rootSeqIdx = ROOT_SEQ_IDX;
457 rachCfg.msg1Scs = PRACH_SUBCARRIER_SPACING ;
458 rachCfg.restrictedSetCfg = PRACH_RESTRICTED_SET_CFG;
459 srvCellCfgComm->ulCfg.rachCfg = rachCfg;
461 /* Configuring PUSCH Config Common for SIB1 */
462 puschCfg.present = BWP_UplinkCommon__pusch_ConfigCommon_PR_setup;
463 puschCfg.k2 = PUSCH_K2;
464 puschCfg.mapType = PUSCH_TimeDomainResourceAllocation__mappingType_typeA;
465 puschCfg.sliv = calcSliv(PUSCH_START_SYMBOL,PUSCH_LENGTH_SYMBOL);
466 puschCfg.msg3DeltaPreamble = PUSCH_MSG3_DELTA_PREAMBLE;
467 puschCfg.p0NominalWithGrant = PUSCH_P0_NOMINAL_WITH_GRANT;
468 srvCellCfgComm->ulCfg.puschCfg = puschCfg;
470 /* Configuring PUCCH Config Common for SIB1 */
471 pucchCfg.present = BWP_UplinkCommon__pucch_ConfigCommon_PR_setup;
472 pucchCfg.rsrcComm = PUCCH_RSRC_COMMON;
473 pucchCfg.grpHop = PUCCH_ConfigCommon__pucch_GroupHopping_neither;
474 pucchCfg.p0Nominal = PUCCH_P0_NOMINAL;
475 srvCellCfgComm->ulCfg.pucchCfg = pucchCfg;
477 /* Configuring TDD UL DL config common */
478 tddCfg.refScs = SubcarrierSpacing_kHz30;
479 tddCfg.txPrd = TDD_UL_DL_Pattern__dl_UL_TransmissionPeriodicity_ms2p5;
480 tddCfg.numDlSlots = NUM_DL_SLOTS;
481 tddCfg.numDlSymbols = NUM_DL_SYMBOLS;
482 tddCfg.numUlSlots = NUM_UL_SLOTS;
483 tddCfg.numUlSymbols = NUM_UL_SYMBOLS;
484 srvCellCfgComm->tddCfg = tddCfg;
486 srvCellCfgComm->ssbPosInBurst = 192;
487 srvCellCfgComm->ssbPrdServingCell = SSB_PERIODICITY_20MS;
488 srvCellCfgComm->ssPbchBlockPwr = SSB_PBCH_PWR;
493 /*******************************************************************
495 * @brief Configures the DU Parameters
502 * - Initializes the DuCfg members.
503 * - Calls readMacCfg()
505 * @params[in] system task ID
506 * @return ROK - success
509 * ****************************************************************/
514 uint32_t ipv4_du, ipv4_cu, ipv4_ric;
518 cmInetAddr((S8*)DU_IP_V4_ADDR, &ipv4_du);
519 cmInetAddr((S8*)CU_IP_V4_ADDR, &ipv4_cu);
520 cmInetAddr((S8*)RIC_IP_V4_ADDR, &ipv4_ric);
521 fillDuPort(duCfgParam.sctpParams.duPort);
523 /* F1 DU IP Address and Port*/
524 duCfgParam.sctpParams.duIpAddr.ipV4Addr = ipv4_du;
526 /* F1 CU IP Address and Port*/
527 duCfgParam.sctpParams.cuIpAddr.ipV4Addr = ipv4_cu;
528 duCfgParam.sctpParams.cuPort = CU_PORT;
530 /* Fill RIC Params */
531 duCfgParam.sctpParams.ricIpAddr.ipV4Addr = ipv4_ric;
532 duCfgParam.sctpParams.ricPort = RIC_PORT;
533 /* EGTP Parameters */
534 duCfgParam.egtpParams.localIp.ipV4Pres = TRUE;
535 duCfgParam.egtpParams.localIp.ipV4Addr = ipv4_du;
536 duCfgParam.egtpParams.localPort = DU_EGTP_PORT;
537 duCfgParam.egtpParams.destIp.ipV4Pres = TRUE;
538 duCfgParam.egtpParams.destIp.ipV4Addr = ipv4_cu;
539 duCfgParam.egtpParams.destPort = CU_EGTP_PORT;
540 duCfgParam.egtpParams.minTunnelId = 0;
541 duCfgParam.egtpParams.maxTunnelId = 10;
543 duCfgParam.maxUe = 32; //TODO: Check
545 duCfgParam.duId = DU_ID;
546 strcpy((char*)duCfgParam.duName,DU_NAME);
549 mib.sysFrmNum = SYS_FRAME_NUM;
550 mib.subCarrierSpacingCommon = MIB__subCarrierSpacingCommon_scs15or60;
551 mib.ssb_SubcarrierOffset = SSB_SC_OFFSET;
552 mib.dmrs_TypeA_Position = MIB__dmrs_TypeA_Position_pos2;
553 mib.controlResourceSetZero = CORESET_0_INDEX;
554 mib.searchSpaceZero = SEARCHSPACE_0_INDEX;
555 mib.cellBarred = MIB__cellBarred_barred;
556 mib.intraFreqReselection =
557 MIB__intraFreqReselection_notAllowed;
558 duCfgParam.mibParams = mib;
561 memset(&sib1.plmn, 0, sizeof(Plmn));
562 sib1.plmn.mcc[0] = PLMN_MCC0;
563 sib1.plmn.mcc[1] = PLMN_MCC1;
564 sib1.plmn.mcc[2] = PLMN_MCC2;
565 sib1.plmn.mnc[0] = PLMN_MNC0;
566 sib1.plmn.mnc[1] = PLMN_MNC1;
568 sib1.ranac = DU_RANAC;
569 sib1.cellIdentity = CELL_IDENTITY;
570 sib1.cellResvdForOpUse =\
571 PLMN_IdentityInfo__cellReservedForOperatorUse_notReserved;
572 sib1.connEstFailCnt = ConnEstFailureControl__connEstFailCount_n3;
573 sib1.connEstFailOffValidity =\
574 ConnEstFailureControl__connEstFailOffsetValidity_s120;
575 sib1.siSchedInfo.winLen = SI_SchedulingInfo__si_WindowLength_s5;
576 sib1.siSchedInfo.broadcastSta = \
577 SchedulingInfo__si_BroadcastStatus_broadcasting;
578 sib1.siSchedInfo.preiodicity = SchedulingInfo__si_Periodicity_rf8;
579 sib1.siSchedInfo.sibType = SIB_TypeInfo__type_sibType2;
580 sib1.siSchedInfo.sibValTag = SIB1_VALUE_TAG;
582 fillServCellCfgCommSib(&sib1.srvCellCfgCommSib);
584 duCfgParam.sib1Params = sib1;
586 for(i=0; i<DEFAULT_CELLS; i++)
588 memset(&duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.nrCgi.plmn, 0, sizeof(Plmn));
589 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.nrCgi.plmn.mcc[0] = PLMN_MCC0;
590 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.nrCgi.plmn.mcc[1] = PLMN_MCC1;
591 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.nrCgi.plmn.mcc[2] = PLMN_MCC2;
592 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.nrCgi.plmn.mnc[0] = PLMN_MNC0;
593 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.nrCgi.plmn.mnc[1] = PLMN_MNC1;
596 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.nrCgi.cellId = NR_CELL_ID;
597 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.nrPci = NR_PCI;
599 /* List of Available PLMN */
600 for(j=0;j<MAX_PLMN;j++)
602 memset(&duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.plmn[j], 0, sizeof(Plmn));
603 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.plmn[j].mcc[0] = PLMN_MCC0;
604 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.plmn[j].mcc[1] = PLMN_MCC1;
605 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.plmn[j].mcc[2] = PLMN_MCC2;
606 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.plmn[j].mnc[0] = PLMN_MNC0;
607 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.plmn[j].mnc[1] = PLMN_MNC1;
609 /* List of Extended PLMN */
610 for(j=0;j<MAX_PLMN;j++)
612 memset(&duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.extPlmn[j], 0, sizeof(Plmn));
613 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.extPlmn[j].mcc[0] = PLMN_MCC0;
614 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.extPlmn[j].mcc[1] = PLMN_MCC1;
615 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.extPlmn[j].mcc[2] = PLMN_MCC2;
616 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.extPlmn[j].mnc[0] = PLMN_MNC0;
617 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.extPlmn[j].mnc[1] = PLMN_MNC1;
621 duCfgParam.srvdCellLst[i].duCellInfo.tac = DU_TAC;
622 duCfgParam.srvdCellLst[i].duCellInfo.epsTac = DU_TAC; //to check and fill
624 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.nrArfcn = NR_UL_ARFCN;
625 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.sulInfo.sulArfcn = SUL_ARFCN;
626 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.sulInfo.sulTxBw.nrScs = SCS_15;
627 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.sulInfo.sulTxBw.nrb = NRB_106;
631 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.nrArfcn = NR_ARFCN;
632 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.sulInfo.sulArfcn = SUL_ARFCN;
633 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.sulInfo.sulTxBw.nrScs = SCS_15;
634 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.sulInfo.sulTxBw.nrb = NRB_106;
636 for(j=0;j<MAXNRCELLBANDS;j++)
638 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.freqBand[j].nrFreqBand = NR_FREQ_BAND;
639 for(k=0;k<MAXNRCELLBANDS;k++)
641 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.freqBand[j].sulBand[k] = SUL_BAND;
645 for(j=0;j<MAXNRCELLBANDS;j++)
647 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.freqBand[j].nrFreqBand = NR_FREQ_BAND;
648 for(k=0;k<MAXNRCELLBANDS;k++)
650 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.freqBand[j].sulBand[k] = SUL_BAND;
653 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.nrArfcn = NR_DL_ARFCN;
654 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.sulInfo.sulArfcn = SUL_ARFCN;
655 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.sulInfo.sulTxBw.nrScs = SCS_15;
656 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.sulInfo.sulTxBw.nrb = NRB_106;
657 for(j=0;j<MAXNRCELLBANDS;j++)
659 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.freqBand[j].nrFreqBand = NR_FREQ_BAND;
660 for(k=0;k<MAXNRCELLBANDS;k++)
662 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.freqBand[j].sulBand[k] = SUL_BAND;
666 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.ulTxBw.nrScs = SCS_15;
667 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.ulTxBw.nrb = NRB_106;
669 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.dlTxBw.nrScs = SCS_15;
670 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.dlTxBw.nrb = NRB_106;
673 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.tdd.nrTxBw.nrScs = SCS_15;
674 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.tdd.nrTxBw.nrb = NRB_106;
676 /*Measurement Config and Cell Config */
677 duCfgParam.srvdCellLst[i].duCellInfo.measTimeCfg = TIME_CFG;
679 duCfgParam.srvdCellLst[i].duCellInfo.cellDir = DL_UL;
681 duCfgParam.srvdCellLst[i].duCellInfo.cellType=CELL_TYPE;
683 /* Broadcast PLMN Identity */
684 for(j=0;j<MAXBPLMNNRMINUS1;j++)
686 for(k=0;k<MAX_PLMN;k++)
688 memset(&duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].plmn[k], 0, sizeof(Plmn));
689 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].plmn[k].mcc[0] = PLMN_MCC0;
690 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].plmn[k].mcc[1] = PLMN_MCC1;
691 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].plmn[k].mcc[2] = PLMN_MCC2;
692 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].plmn[k].mnc[0] = PLMN_MNC0;
693 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].plmn[k].mnc[1] = PLMN_MNC1;
695 /* Extended PLMN List */
696 for(k=0;k<MAX_PLMN;k++)
698 memset(&duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].extPlmn[k], 0, sizeof(Plmn));
699 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].extPlmn[k].mcc[0] = PLMN_MCC0;
700 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].extPlmn[k].mcc[1] = PLMN_MCC1;
701 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].extPlmn[k].mcc[2] = PLMN_MCC2;
702 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].extPlmn[k].mnc[0] = PLMN_MNC0;
703 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].extPlmn[k].mnc[1] = PLMN_MNC1;
706 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].tac = DU_TAC;
707 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].nrCellId = NR_CELL_ID;
708 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].ranac = NR_RANAC;
711 /*gnb DU System Info mib msg*/
713 DU_ALLOC(duCfgParam.srvdCellLst[i].duSysInfo.mibMsg,\
715 if(!(duCfgParam.srvdCellLst[i].duSysInfo.mibMsg))
717 DU_LOG("\nDU_APP: Memory allocation failure");
720 strcpy((char *)duCfgParam.srvdCellLst[i].duSysInfo.mibMsg, encBuf);
721 duCfgParam.srvdCellLst[i].duSysInfo.mibLen = encBufSize;
723 /*gnb DU System Info mib msg*/
725 DU_ALLOC(duCfgParam.srvdCellLst[i].duSysInfo.sib1Msg,\
727 if(!(duCfgParam.srvdCellLst[i].duSysInfo.sib1Msg))
729 DU_LOG("\nDU_APP: Memory allocation failure");
732 memcpy(duCfgParam.srvdCellLst[i].duSysInfo.sib1Msg,\
734 duCfgParam.srvdCellLst[i].duSysInfo.sib1Len = encBufSize;
738 if(readMacCfg() != ROK)
740 DU_LOG("\nDU_APP : Failed while reading MAC config");
747 /*******************************************************************
749 * @brief Reads config and posts message to du_app on completion
757 * - Post to du_app for further processing
760 * @return ROK - success
763 * ****************************************************************/
769 memset(&duCfgParam, 0, sizeof(DuCfgParams));
770 //Read configs into duCfgParams
773 DU_LOG("\nDU_APP : Reading configuration failed");
778 memset(&(pst), 0, sizeof(Pst));
779 pst.srcEnt = (Ent)ENTDUAPP;
780 pst.srcInst = (Inst)DU_INST;
781 pst.srcProcId = DU_PROC;
782 pst.dstEnt = pst.srcEnt;
783 pst.dstInst = pst.srcInst;
784 pst.dstProcId = pst.srcProcId;
786 pst.selector = ODU_SELECTOR_TC;
790 if(ODU_GET_MSG_BUF(DFLT_REGION, DU_POOL, &mBuf) != ROK)
792 DU_LOG("\nDU_APP : Memory allocation failed in duReadCfg");
796 if (ODU_POST_TASK(&pst, mBuf) != ROK)
798 DU_LOG("\nDU_APP : ODU_POST_TASK failed in duReadCfg");
805 /**********************************************************************
807 **********************************************************************/