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.dupType = DUPLEX_MODE;
133 /* DL carrier configuration */
134 duCfgParam.macCellCfg.dlCarrCfg.pres = TRUE;
135 duCfgParam.macCellCfg.dlCarrCfg.bw = BANDWIDTH;
136 duCfgParam.macCellCfg.dlCarrCfg.freq = NR_DL_ARFCN;
137 duCfgParam.macCellCfg.dlCarrCfg.k0[0] = 1;
138 duCfgParam.macCellCfg.dlCarrCfg.k0[1] = 1;
139 duCfgParam.macCellCfg.dlCarrCfg.k0[2] = 1;
140 duCfgParam.macCellCfg.dlCarrCfg.k0[3] = 1;
141 duCfgParam.macCellCfg.dlCarrCfg.k0[4] = 1;
142 duCfgParam.macCellCfg.dlCarrCfg.gridSize[0] = 273;
143 duCfgParam.macCellCfg.dlCarrCfg.gridSize[1] = 1;
144 duCfgParam.macCellCfg.dlCarrCfg.gridSize[2] = 1;
145 duCfgParam.macCellCfg.dlCarrCfg.gridSize[3] = 1;
146 duCfgParam.macCellCfg.dlCarrCfg.gridSize[4] = 1;
147 duCfgParam.macCellCfg.dlCarrCfg.numAnt = NUM_TX_ANT;
149 /* UL Carrier configuration */
150 duCfgParam.macCellCfg.ulCarrCfg.pres = TRUE;
151 duCfgParam.macCellCfg.ulCarrCfg.bw = BANDWIDTH;
152 duCfgParam.macCellCfg.ulCarrCfg.freq = NR_UL_ARFCN;
153 duCfgParam.macCellCfg.ulCarrCfg.k0[0] = 1;
154 duCfgParam.macCellCfg.ulCarrCfg.k0[1] = 1;
155 duCfgParam.macCellCfg.ulCarrCfg.k0[2] = 1;
156 duCfgParam.macCellCfg.ulCarrCfg.k0[3] = 1;
157 duCfgParam.macCellCfg.ulCarrCfg.k0[4] = 1;
158 duCfgParam.macCellCfg.ulCarrCfg.gridSize[0] = 1;
159 duCfgParam.macCellCfg.ulCarrCfg.gridSize[1] = 1;
160 duCfgParam.macCellCfg.ulCarrCfg.gridSize[2] = 1;
161 duCfgParam.macCellCfg.ulCarrCfg.gridSize[3] = 1;
162 duCfgParam.macCellCfg.ulCarrCfg.gridSize[4] = 1;
163 duCfgParam.macCellCfg.ulCarrCfg.numAnt = NUM_RX_ANT;
165 duCfgParam.macCellCfg.freqShft = FREQ_SHIFT_7P5KHZ;
167 /* SSB configuration */
168 duCfgParam.macCellCfg.ssbCfg.ssbPbchPwr = SSB_PBCH_PWR;
169 duCfgParam.macCellCfg.ssbCfg.bchPayloadFlag = BCH_PAYLOAD;
170 duCfgParam.macCellCfg.ssbCfg.scsCmn = SUBCARRIER_SPACING;
171 duCfgParam.macCellCfg.ssbCfg.ssbOffsetPointA = OFFSET_TO_POINT_A;
172 duCfgParam.macCellCfg.ssbCfg.betaPss = BETA_PSS;
173 duCfgParam.macCellCfg.ssbCfg.ssbPeriod = SSB_PRDCTY_MS_20;
174 duCfgParam.macCellCfg.ssbCfg.ssbScOffset = SSB_SUBCARRIER_OFFSET;
175 duCfgParam.macCellCfg.ssbCfg.ssbMask[0] = 1; /* only one SSB is transmitted */
176 duCfgParam.macCellCfg.ssbCfg.ssbMask[1] = 0;
177 if(BuildMibPdu() != ROK)
179 DU_LOG("\nFailed to build MIB PDU");
180 memset(&duCfgParam.macCellCfg.ssbCfg.mibPdu, 0, 3*sizeof(uint8_t));
184 for(uint8_t idx=0; idx<encBufSize; idx++)
186 duCfgParam.macCellCfg.ssbCfg.mibPdu[idx]=encBuf[idx];
189 duCfgParam.macCellCfg.ssbCfg.multCarrBand = SSB_MULT_CARRIER_BAND;
190 duCfgParam.macCellCfg.ssbCfg.multCellCarr = MULT_CELL_CARRIER;
192 /* PRACH configuration */
193 duCfgParam.macCellCfg.prachCfg.pres = TRUE;
194 duCfgParam.macCellCfg.prachCfg.prachCfgIdx = PRACH_CONFIG_IDX;
195 duCfgParam.macCellCfg.prachCfg.prachSeqLen = PRACH_SEQ_LEN;
196 duCfgParam.macCellCfg.prachCfg.prachSubcSpacing = PRACH_SUBCARRIER_SPACING;
197 duCfgParam.macCellCfg.prachCfg.prachRstSetCfg = PRACH_RESTRICTED_SET_CFG;
198 duCfgParam.macCellCfg.prachCfg.msg1Fdm = NUM_PRACH_FDM;
199 duCfgParam.macCellCfg.prachCfg.msg1FreqStart = PRACH_FREQ_START;
200 duCfgParam.macCellCfg.prachCfg.rootSeqLen = ROOT_SEQ_LEN;
201 duCfgParam.macCellCfg.prachCfg.fdm[0].rootSeqIdx = ROOT_SEQ_IDX;
202 duCfgParam.macCellCfg.prachCfg.fdm[0].numRootSeq = NUM_ROOT_SEQ;
203 duCfgParam.macCellCfg.prachCfg.fdm[0].k1 = 0;
204 duCfgParam.macCellCfg.prachCfg.fdm[0].zeroCorrZoneCfg = ZERO_CORRELATION_ZONE_CFG;
205 duCfgParam.macCellCfg.prachCfg.fdm[0].numUnusedRootSeq = NUM_UNUSED_ROOT_SEQ;
206 if(duCfgParam.macCellCfg.prachCfg.fdm[0].numUnusedRootSeq != 0)
208 DU_ALLOC_SHRABL_BUF(duCfgParam.macCellCfg.prachCfg.fdm[0].unsuedRootSeq,
209 NUM_UNUSED_ROOT_SEQ * sizeof(uint8_t));
210 if(duCfgParam.macCellCfg.prachCfg.fdm[0].unsuedRootSeq == NULLP)
212 DU_LOG("\nDU_APP : Memory allocation failed");
215 *(duCfgParam.macCellCfg.prachCfg.fdm[0].unsuedRootSeq) = UNUSED_ROOT_SEQ;
217 duCfgParam.macCellCfg.prachCfg.ssbPerRach = SSB_PER_RACH;
218 duCfgParam.macCellCfg.prachCfg.prachMultCarrBand = PRACH_MULT_CARRIER_BAND;
219 duCfgParam.macCellCfg.prachCfg.raContResTmr = RA_CONT_RES_TIMER;
220 duCfgParam.macCellCfg.prachCfg.rsrpThreshSsb = RSRP_THRESHOLD_SSB;
221 duCfgParam.macCellCfg.prachCfg.raRspWindow = RA_RSP_WINDOW;
222 duCfgParam.macCellCfg.prachCfg.prachRestrictedSet = PRACH_RESTRICTED_SET;
223 /* TDD configuration */
224 duCfgParam.macCellCfg.tddCfg.pres = TRUE;
225 duCfgParam.macCellCfg.tddCfg.tddPeriod = TDD_PERIODICITY;
229 /* RSSI Measurement configuration */
230 duCfgParam.macCellCfg.rssiUnit = RSS_MEASUREMENT_UNIT;
232 /* fill SIB1 configuration */
233 duCfgParam.macCellCfg.sib1Cfg.sib1PduLen = duCfgParam.srvdCellLst[0].duSysInfo.sib1Len;
234 DU_ALLOC_SHRABL_BUF(duCfgParam.macCellCfg.sib1Cfg.sib1Pdu,duCfgParam.srvdCellLst[0].duSysInfo.sib1Len);
235 memcpy(duCfgParam.macCellCfg.sib1Cfg.sib1Pdu, duCfgParam.srvdCellLst[0].duSysInfo.sib1Msg, \
236 duCfgParam.srvdCellLst[0].duSysInfo.sib1Len);
237 duCfgParam.macCellCfg.sib1Cfg.sib1NewTxPeriod = SIB1_NEW_TX_PERIOD;
238 duCfgParam.macCellCfg.sib1Cfg.sib1RepetitionPeriod = SIB1_REPETITION_PERIOD;
239 duCfgParam.macCellCfg.sib1Cfg.coresetZeroIndex = CORESET_0_INDEX;
240 duCfgParam.macCellCfg.sib1Cfg.searchSpaceZeroIndex = SEARCHSPACE_0_INDEX;
241 duCfgParam.macCellCfg.sib1Cfg.sib1Mcs = SIB1_MCS;
244 /* fill Intial DL BWP */
245 duCfgParam.macCellCfg.initialDlBwp.bwp.firstPrb = 0;
246 duCfgParam.macCellCfg.initialDlBwp.bwp.numPrb = TOTAL_PRB_BW; /* configured to total BW */
247 duCfgParam.macCellCfg.initialDlBwp.bwp.scs = SUBCARRIER_SPACING; /* numerology is 0, 15Khz */
248 duCfgParam.macCellCfg.initialDlBwp.bwp.cyclicPrefix = NORMAL_CYCLIC_PREFIX;
249 duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.searchSpaceId = SEARCHSPACE_1_INDEX;
250 duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.coresetId = CORESET_0_INDEX;
251 duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.monitoringSlot =
252 SS_MONITORING_SLOT_SL1; /* sl1 - all slots */
253 duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.duration = 0;
254 duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.monitoringSymbol =
255 SS_MONITORING_SYMBOL;
256 duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.
257 candidate.aggLevel1 = 8;
258 duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.
259 candidate.aggLevel2 = 4;
260 duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.
261 candidate.aggLevel4 = 2;
262 duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.
263 candidate.aggLevel8 = 1;
264 duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.
265 candidate.aggLevel16 = 0;
266 duCfgParam.macCellCfg.initialDlBwp.pdschCommon.k0 = PDSCH_K0;
267 duCfgParam.macCellCfg.initialDlBwp.pdschCommon.mappingType =
268 PDSCH_MAPPING_TYPE_A;
269 duCfgParam.macCellCfg.initialDlBwp.pdschCommon.startSymbol =
271 duCfgParam.macCellCfg.initialDlBwp.pdschCommon.lengthSymbol =
273 /* ra-searchSpace ID is set to 1 */
274 duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.raSearchSpaceId = SEARCHSPACE_1_INDEX;
276 /* fill Intial UL BWP */
277 duCfgParam.macCellCfg.initialUlBwp.bwp.firstPrb = 0;
278 duCfgParam.macCellCfg.initialUlBwp.bwp.numPrb = TOTAL_PRB_BW; /* configured to total BW */
279 duCfgParam.macCellCfg.initialUlBwp.bwp.scs = SUBCARRIER_SPACING; /* numerology is 0, 15Khz */
280 duCfgParam.macCellCfg.initialUlBwp.bwp.cyclicPrefix = NORMAL_CYCLIC_PREFIX;
281 duCfgParam.macCellCfg.initialUlBwp.puschCommon.k2 = PUSCH_K2;
282 duCfgParam.macCellCfg.initialUlBwp.puschCommon.mappingType =
283 PUSCH_MAPPING_TYPE_A;
284 duCfgParam.macCellCfg.initialUlBwp.puschCommon.startSymbol =
286 duCfgParam.macCellCfg.initialUlBwp.puschCommon.lengthSymbol =
289 duCfgParam.macCellCfg.dmrsTypeAPos = DMRS_TYPE_A_POS;
290 /* fill PUCCH config common */
291 duCfgParam.macCellCfg.initialUlBwp.pucchCommon.pucchResourceCommon = PUCCH_RSRC_COMMON;
292 duCfgParam.macCellCfg.initialUlBwp.pucchCommon.pucchGroupHopping = PUCCH_GROUP_HOPPING;
297 /*******************************************************************
299 * @brief Configures the DU Parameters
303 * Function : fillDuPort
306 * - fills the DU Ports.
308 * @params[in] duPort array to be filled
309 * @return ROK - success
312 * ****************************************************************/
313 uint8_t fillDuPort(uint16_t *duPort)
315 duPort[F1_INTERFACE] = DU_PORT; /* DU Port idx 0 38472 */
316 duPort[E2_INTERFACE] = RIC_PORT; /* RIC Port idx 1 38482 */
321 /*******************************************************************
323 * @brief Configures the DU Parameters
327 * Function : calcSliv
330 * - calculate SLIV value from start and length field
332 * @params[in] start symbol
333 * @params[in] length of symbols
336 * ****************************************************************/
337 uint16_t calcSliv(uint8_t startSymbol, uint8_t lengthSymbol)
340 if((lengthSymbol-1) <= 7)
342 sliv = NUM_SYMBOLS_PER_SLOT * (lengthSymbol-1) + startSymbol;
346 sliv = NUM_SYMBOLS_PER_SLOT * (NUM_SYMBOLS_PER_SLOT - lengthSymbol + 1) \
347 + (NUM_SYMBOLS_PER_SLOT - 1 - startSymbol);
353 /*******************************************************************
355 * @brief Configures serving cell config common in sib1
359 * Function : fillServCellCfgCommSib
362 * - fills Serving cell config common for SIB1
364 * @params[in] SrvCellCfgCommSib pointer
365 * @return ROK - success
368 ** ****************************************************************/
369 uint8_t fillServCellCfgCommSib(SrvCellCfgCommSib *srvCellCfgComm)
371 PdcchCfgCommon pdcchCfg;
372 PdschCfgCommon pdschCfg;
374 RachCfgCommon rachCfg;
375 PuschCfgCommon puschCfg;
376 PucchCfgCommon pucchCfg;
377 TddUlDlCfgCommon tddCfg;
379 /* Configuring DL Config Common for SIB1*/
380 srvCellCfgComm->dlCfg.freqBandInd = NR_FREQ_BAND_IND;
381 srvCellCfgComm->dlCfg.offsetToPointA = OFFSET_TO_POINT_A;
382 srvCellCfgComm->dlCfg.dlScsCarrier.scsOffset = SSB_SUBCARRIER_OFFSET;
383 srvCellCfgComm->dlCfg.dlScsCarrier.scs = SUBCARRIER_SPACING;
384 srvCellCfgComm->dlCfg.dlScsCarrier.scsBw = SCS_CARRIER_BANDWIDTH;
385 srvCellCfgComm->dlCfg.locAndBw = FREQ_LOC_BW;
387 /* Configuring PDCCH Config Common For SIB1 */
388 pdcchCfg.present = BWP_DownlinkCommon__pdcch_ConfigCommon_PR_setup;
389 pdcchCfg.ctrlRsrcSetZero = PDCCH_CTRL_RSRC_SET_ZERO;
390 pdcchCfg.searchSpcZero = PDCCH_SEARCH_SPACE_ZERO;
391 pdcchCfg.searchSpcId = PDCCH_SEARCH_SPACE_ID;
392 pdcchCfg.ctrlRsrcSetId = PDCCH_CTRL_RSRC_SET_ID;
393 pdcchCfg.monitorSlotPrdAndOffPresent = \
394 SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl1;
395 //pdcchCfg.monitorSlotPrdAndOff = \
396 SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl1;
397 pdcchCfg.monitorSymbolsInSlot[0] = 128;
398 pdcchCfg.monitorSymbolsInSlot[1] = 0;
399 pdcchCfg.numCandAggLvl1 = SearchSpace__nrofCandidates__aggregationLevel1_n8;
400 pdcchCfg.numCandAggLvl2 = SearchSpace__nrofCandidates__aggregationLevel2_n4;
401 pdcchCfg.numCandAggLvl4 = SearchSpace__nrofCandidates__aggregationLevel4_n2;
402 pdcchCfg.numCandAggLvl8 = SearchSpace__nrofCandidates__aggregationLevel8_n1;
403 pdcchCfg.numCandAggLvl16 = SearchSpace__nrofCandidates__aggregationLevel16_n0;
404 pdcchCfg.searchSpcType = SearchSpace__searchSpaceType_PR_common;
405 pdcchCfg.commSrchSpcDciFrmt = PDCCH_SERACH_SPACE_DCI_FORMAT;
406 pdcchCfg.searchSpcSib1 = PDCCH_SEARCH_SPACE_ID_SIB1;
407 pdcchCfg.pagingSearchSpc = PDCCH_SEARCH_SPACE_ID_PAGING;
408 pdcchCfg.raSearchSpc = PDCCH_SEARCH_SPACE_ID_PAGING;
409 srvCellCfgComm->dlCfg.pdcchCfg = pdcchCfg;
411 /* Configuring PDSCH Config Common For SIB1 */
412 pdschCfg.present = BWP_DownlinkCommon__pdsch_ConfigCommon_PR_setup;
413 pdschCfg.k0 = PDSCH_K0;
415 PDSCH_TimeDomainResourceAllocation__mappingType_typeA;
416 pdschCfg.sliv = calcSliv(PDSCH_START_SYMBOL,PDSCH_LENGTH_SYMBOL);
417 srvCellCfgComm->dlCfg.pdschCfg = pdschCfg;
419 /* Configuring BCCH Config for SIB1 */
420 srvCellCfgComm->dlCfg.bcchCfg.modPrdCoeff = \
421 BCCH_Config__modificationPeriodCoeff_n16;
423 /* Configuring PCCH Config for SIB1 */
424 pcchCfg.dfltPagingCycle = PagingCycle_rf64;
425 pcchCfg.nAndPagingFrmOffPresent = PCCH_Config__nAndPagingFrameOffset_PR_oneT;
426 pcchCfg.numPagingOcc = PCCH_Config__ns_four;
427 srvCellCfgComm->dlCfg.pcchCfg = pcchCfg;
430 /* Configuring UL Config Common */
431 srvCellCfgComm->ulCfg.ulScsCarrier.scsOffset = SSB_SUBCARRIER_OFFSET;
432 srvCellCfgComm->ulCfg.ulScsCarrier.scs = SUBCARRIER_SPACING;
433 srvCellCfgComm->ulCfg.ulScsCarrier.scsBw = SCS_CARRIER_BANDWIDTH;
434 srvCellCfgComm->ulCfg.pMax = UL_P_MAX;
435 srvCellCfgComm->ulCfg.locAndBw = FREQ_LOC_BW;
436 srvCellCfgComm->ulCfg.timeAlignTimerComm = TimeAlignmentTimer_infinity;
438 /* Configuring RACH Config Common for SIB1 */
439 rachCfg.present = BWP_UplinkCommon__rach_ConfigCommon_PR_setup;
440 rachCfg.prachCfgIdx = PRACH_CONFIG_IDX;
441 rachCfg.msg1Fdm = RACH_ConfigGeneric__msg1_FDM_one;
442 rachCfg.msg1FreqStart = PRACH_FREQ_START;
443 rachCfg.zeroCorrZoneCfg = ZERO_CORRELATION_ZONE_CFG;
444 rachCfg.preambleRcvdTgtPwr = PRACH_PREAMBLE_RCVD_TGT_PWR;
445 rachCfg.preambleTransMax = RACH_ConfigGeneric__preambleTransMax_n200;
446 rachCfg.pwrRampingStep = RACH_ConfigGeneric__powerRampingStep_dB2;
447 rachCfg.raRspWindow = RACH_ConfigGeneric__ra_ResponseWindow_sl20;
448 rachCfg.numRaPreamble = NUM_RA_PREAMBLE;
449 rachCfg.ssbPerRachOccPresent = \
450 RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_one;
451 rachCfg.numSsbPerRachOcc = SSB_PER_RACH;
452 rachCfg.contResTimer = RACH_ConfigCommon__ra_ContentionResolutionTimer_sf64;
453 rachCfg.rsrpThreshSsb = RSRP_THRESHOLD_SSB;
454 rachCfg.rootSeqIdxPresent = RACH_ConfigCommon__prach_RootSequenceIndex_PR_l139;
455 rachCfg.rootSeqIdx = ROOT_SEQ_IDX;
456 rachCfg.msg1Scs = PRACH_SUBCARRIER_SPACING ;
457 rachCfg.restrictedSetCfg = PRACH_RESTRICTED_SET_CFG;
458 srvCellCfgComm->ulCfg.rachCfg = rachCfg;
460 /* Configuring PUSCH Config Common for SIB1 */
461 puschCfg.present = BWP_UplinkCommon__pusch_ConfigCommon_PR_setup;
462 puschCfg.k2 = PUSCH_K2;
463 puschCfg.mapType = PUSCH_TimeDomainResourceAllocation__mappingType_typeA;
464 puschCfg.sliv = calcSliv(PUSCH_START_SYMBOL,PUSCH_LENGTH_SYMBOL);
465 puschCfg.msg3DeltaPreamble = PUSCH_MSG3_DELTA_PREAMBLE;
466 puschCfg.p0NominalWithGrant = PUSCH_P0_NOMINAL_WITH_GRANT;
467 srvCellCfgComm->ulCfg.puschCfg = puschCfg;
469 /* Configuring PUCCH Config Common for SIB1 */
470 pucchCfg.present = BWP_UplinkCommon__pucch_ConfigCommon_PR_setup;
471 pucchCfg.rsrcComm = PUCCH_RSRC_COMMON;
472 pucchCfg.grpHop = PUCCH_ConfigCommon__pucch_GroupHopping_neither;
473 pucchCfg.p0Nominal = PUCCH_P0_NOMINAL;
474 srvCellCfgComm->ulCfg.pucchCfg = pucchCfg;
476 /* Configuring TDD UL DL config common */
477 tddCfg.refScs = SubcarrierSpacing_kHz30;
478 tddCfg.txPrd = TDD_UL_DL_Pattern__dl_UL_TransmissionPeriodicity_ms2p5;
479 tddCfg.numDlSlots = NUM_DL_SLOTS;
480 tddCfg.numDlSymbols = NUM_DL_SYMBOLS;
481 tddCfg.numUlSlots = NUM_UL_SLOTS;
482 tddCfg.numUlSymbols = NUM_UL_SYMBOLS;
483 srvCellCfgComm->tddCfg = tddCfg;
485 srvCellCfgComm->ssbPosInBurst = 192;
486 srvCellCfgComm->ssbPrdServingCell = SSB_PERIODICITY_20MS;
487 srvCellCfgComm->ssPbchBlockPwr = SSB_PBCH_PWR;
492 /*******************************************************************
494 * @brief Configures the DU Parameters
501 * - Initializes the DuCfg members.
502 * - Calls readMacCfg()
504 * @params[in] system task ID
505 * @return ROK - success
508 * ****************************************************************/
513 uint32_t ipv4_du, ipv4_cu, ipv4_ric;
517 cmInetAddr((S8*)DU_IP_V4_ADDR, &ipv4_du);
518 cmInetAddr((S8*)CU_IP_V4_ADDR, &ipv4_cu);
519 cmInetAddr((S8*)RIC_IP_V4_ADDR, &ipv4_ric);
520 fillDuPort(duCfgParam.sctpParams.duPort);
522 /* F1 DU IP Address and Port*/
523 duCfgParam.sctpParams.duIpAddr.ipV4Addr = ipv4_du;
525 /* F1 CU IP Address and Port*/
526 duCfgParam.sctpParams.cuIpAddr.ipV4Addr = ipv4_cu;
527 duCfgParam.sctpParams.cuPort = CU_PORT;
529 /* Fill RIC Params */
530 duCfgParam.sctpParams.ricIpAddr.ipV4Addr = ipv4_ric;
531 duCfgParam.sctpParams.ricPort = RIC_PORT;
532 /* EGTP Parameters */
533 duCfgParam.egtpParams.localIp.ipV4Pres = TRUE;
534 duCfgParam.egtpParams.localIp.ipV4Addr = ipv4_du;
535 duCfgParam.egtpParams.localPort = DU_EGTP_PORT;
536 duCfgParam.egtpParams.destIp.ipV4Pres = TRUE;
537 duCfgParam.egtpParams.destIp.ipV4Addr = ipv4_cu;
538 duCfgParam.egtpParams.destPort = CU_EGTP_PORT;
539 duCfgParam.egtpParams.minTunnelId = 0;
540 duCfgParam.egtpParams.maxTunnelId = 10;
542 duCfgParam.maxUe = 32; //TODO: Check
544 duCfgParam.duId = DU_ID;
545 strcpy((char*)duCfgParam.duName,DU_NAME);
548 mib.sysFrmNum = SYS_FRAME_NUM;
549 mib.subCarrierSpacingCommon = MIB__subCarrierSpacingCommon_scs15or60;
550 mib.ssb_SubcarrierOffset = SSB_SC_OFFSET;
551 mib.dmrs_TypeA_Position = MIB__dmrs_TypeA_Position_pos2;
552 mib.controlResourceSetZero = CORESET_ZERO;
553 mib.searchSpaceZero = SEARCH_SPACE_ZERO;
554 mib.cellBarred = MIB__cellBarred_barred;
555 mib.intraFreqReselection =
556 MIB__intraFreqReselection_notAllowed;
557 duCfgParam.mibParams = mib;
560 memset(&sib1.plmn, 0, sizeof(Plmn));
561 sib1.plmn.mcc[0] = PLMN_MCC0;
562 sib1.plmn.mcc[1] = PLMN_MCC1;
563 sib1.plmn.mcc[2] = PLMN_MCC2;
564 sib1.plmn.mnc[0] = PLMN_MNC0;
565 sib1.plmn.mnc[1] = PLMN_MNC1;
567 sib1.ranac = DU_RANAC;
568 sib1.cellIdentity = CELL_IDENTITY;
569 sib1.cellResvdForOpUse =\
570 PLMN_IdentityInfo__cellReservedForOperatorUse_notReserved;
571 sib1.connEstFailCnt = ConnEstFailureControl__connEstFailCount_n3;
572 sib1.connEstFailOffValidity =\
573 ConnEstFailureControl__connEstFailOffsetValidity_s120;
574 sib1.siSchedInfo.winLen = SI_SchedulingInfo__si_WindowLength_s5;
575 sib1.siSchedInfo.broadcastSta = \
576 SchedulingInfo__si_BroadcastStatus_broadcasting;
577 sib1.siSchedInfo.preiodicity = SchedulingInfo__si_Periodicity_rf8;
578 sib1.siSchedInfo.sibType = SIB_TypeInfo__type_sibType2;
579 sib1.siSchedInfo.sibValTag = SIB1_VALUE_TAG;
581 fillServCellCfgCommSib(&sib1.srvCellCfgCommSib);
583 duCfgParam.sib1Params = sib1;
585 for(i=0; i<DEFAULT_CELLS; i++)
587 memset(&duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.nrCgi.plmn, 0, sizeof(Plmn));
588 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.nrCgi.plmn.mcc[0] = PLMN_MCC0;
589 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.nrCgi.plmn.mcc[1] = PLMN_MCC1;
590 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.nrCgi.plmn.mcc[2] = PLMN_MCC2;
591 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.nrCgi.plmn.mnc[0] = PLMN_MNC0;
592 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.nrCgi.plmn.mnc[1] = PLMN_MNC1;
595 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.nrCgi.cellId = NR_CELL_ID;
596 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.nrPci = NR_PCI;
598 /* List of Available PLMN */
599 for(j=0;j<MAX_PLMN;j++)
601 memset(&duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.plmn[j], 0, sizeof(Plmn));
602 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.plmn[j].mcc[0] = PLMN_MCC0;
603 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.plmn[j].mcc[1] = PLMN_MCC1;
604 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.plmn[j].mcc[2] = PLMN_MCC2;
605 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.plmn[j].mnc[0] = PLMN_MNC0;
606 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.plmn[j].mnc[1] = PLMN_MNC1;
608 /* List of Extended PLMN */
609 for(j=0;j<MAX_PLMN;j++)
611 memset(&duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.extPlmn[j], 0, sizeof(Plmn));
612 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.extPlmn[j].mcc[0] = PLMN_MCC0;
613 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.extPlmn[j].mcc[1] = PLMN_MCC1;
614 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.extPlmn[j].mcc[2] = PLMN_MCC2;
615 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.extPlmn[j].mnc[0] = PLMN_MNC0;
616 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.extPlmn[j].mnc[1] = PLMN_MNC1;
620 duCfgParam.srvdCellLst[i].duCellInfo.tac = DU_TAC;
621 duCfgParam.srvdCellLst[i].duCellInfo.epsTac = DU_TAC; //to check and fill
623 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.nrArfcn = NR_UL_ARFCN;
624 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.sulInfo.sulArfcn = SUL_ARFCN;
625 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.sulInfo.sulTxBw.nrScs = SCS_15;
626 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.sulInfo.sulTxBw.nrb = NRB_106;
630 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.nrArfcn = NR_ARFCN;
631 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.sulInfo.sulArfcn = SUL_ARFCN;
632 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.sulInfo.sulTxBw.nrScs = SCS_15;
633 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.sulInfo.sulTxBw.nrb = NRB_106;
635 for(j=0;j<MAXNRCELLBANDS;j++)
637 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.freqBand[j].nrFreqBand = NR_FREQ_BAND;
638 for(k=0;k<MAXNRCELLBANDS;k++)
640 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.freqBand[j].sulBand[k] = SUL_BAND;
644 for(j=0;j<MAXNRCELLBANDS;j++)
646 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.freqBand[j].nrFreqBand = NR_FREQ_BAND;
647 for(k=0;k<MAXNRCELLBANDS;k++)
649 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.freqBand[j].sulBand[k] = SUL_BAND;
652 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.nrArfcn = NR_DL_ARFCN;
653 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.sulInfo.sulArfcn = SUL_ARFCN;
654 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.sulInfo.sulTxBw.nrScs = SCS_15;
655 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.sulInfo.sulTxBw.nrb = NRB_106;
656 for(j=0;j<MAXNRCELLBANDS;j++)
658 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.freqBand[j].nrFreqBand = NR_FREQ_BAND;
659 for(k=0;k<MAXNRCELLBANDS;k++)
661 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.freqBand[j].sulBand[k] = SUL_BAND;
665 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.ulTxBw.nrScs = SCS_15;
666 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.ulTxBw.nrb = NRB_106;
668 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.dlTxBw.nrScs = SCS_15;
669 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.dlTxBw.nrb = NRB_106;
672 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.tdd.nrTxBw.nrScs = SCS_15;
673 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.tdd.nrTxBw.nrb = NRB_106;
675 /*Measurement Config and Cell Config */
676 duCfgParam.srvdCellLst[i].duCellInfo.measTimeCfg = TIME_CFG;
678 duCfgParam.srvdCellLst[i].duCellInfo.cellDir = DL_UL;
680 duCfgParam.srvdCellLst[i].duCellInfo.cellType=CELL_TYPE;
682 /* Broadcast PLMN Identity */
683 for(j=0;j<MAXBPLMNNRMINUS1;j++)
685 for(k=0;k<MAX_PLMN;k++)
687 memset(&duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].plmn[k], 0, sizeof(Plmn));
688 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].plmn[k].mcc[0] = PLMN_MCC0;
689 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].plmn[k].mcc[1] = PLMN_MCC1;
690 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].plmn[k].mcc[2] = PLMN_MCC2;
691 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].plmn[k].mnc[0] = PLMN_MNC0;
692 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].plmn[k].mnc[1] = PLMN_MNC1;
694 /* Extended PLMN List */
695 for(k=0;k<MAX_PLMN;k++)
697 memset(&duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].extPlmn[k], 0, sizeof(Plmn));
698 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].extPlmn[k].mcc[0] = PLMN_MCC0;
699 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].extPlmn[k].mcc[1] = PLMN_MCC1;
700 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].extPlmn[k].mcc[2] = PLMN_MCC2;
701 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].extPlmn[k].mnc[0] = PLMN_MNC0;
702 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].extPlmn[k].mnc[1] = PLMN_MNC1;
705 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].tac = DU_TAC;
706 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].nrCellId = NR_CELL_ID;
707 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].ranac = NR_RANAC;
710 /*gnb DU System Info mib msg*/
712 DU_ALLOC(duCfgParam.srvdCellLst[i].duSysInfo.mibMsg,\
714 if(!(duCfgParam.srvdCellLst[i].duSysInfo.mibMsg))
716 DU_LOG("\nDU_APP: Memory allocation failure");
719 strcpy((char *)duCfgParam.srvdCellLst[i].duSysInfo.mibMsg, encBuf);
720 duCfgParam.srvdCellLst[i].duSysInfo.mibLen = encBufSize;
722 /*gnb DU System Info mib msg*/
724 DU_ALLOC(duCfgParam.srvdCellLst[i].duSysInfo.sib1Msg,\
726 if(!(duCfgParam.srvdCellLst[i].duSysInfo.sib1Msg))
728 DU_LOG("\nDU_APP: Memory allocation failure");
731 memcpy(duCfgParam.srvdCellLst[i].duSysInfo.sib1Msg,\
733 duCfgParam.srvdCellLst[i].duSysInfo.sib1Len = encBufSize;
737 if(readMacCfg() != ROK)
739 DU_LOG("\nDU_APP : Failed while reading MAC config");
746 /*******************************************************************
748 * @brief Reads config and posts message to du_app on completion
756 * - Post to du_app for further processing
759 * @return ROK - success
762 * ****************************************************************/
768 memset(&duCfgParam, 0, sizeof(DuCfgParams));
769 //Read configs into duCfgParams
772 DU_LOG("\nDU_APP : Reading configuration failed");
777 memset(&(pst), 0, sizeof(Pst));
778 pst.srcEnt = (Ent)ENTDUAPP;
779 pst.srcInst = (Inst)DU_INST;
780 pst.srcProcId = DU_PROC;
781 pst.dstEnt = pst.srcEnt;
782 pst.dstInst = pst.srcInst;
783 pst.dstProcId = pst.srcProcId;
785 pst.selector = ODU_SELECTOR_TC;
789 if(ODU_GET_MSG_BUF(DFLT_REGION, DU_POOL, &mBuf) != ROK)
791 DU_LOG("\nDU_APP : Memory allocation failed in duReadCfg");
795 if (ODU_POST_TASK(&pst, mBuf) != ROK)
797 DU_LOG("\nDU_APP : ODU_POST_TASK failed in duReadCfg");
804 /**********************************************************************
806 **********************************************************************/