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 extern DuCfgParams duCfgParam;
56 extern 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] = 1;
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_PERIODICITY_20MS;
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 = 1;
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;
294 /* This should be calculated based on
295 (number of mandatory parameters) + (number of otional parameters being filled) */
296 duCfgParam.macCellCfg.numTlv = 40;
301 /*******************************************************************
303 * @brief Configures the DU Parameters
307 * Function : fillDuPort
310 * - fills the DU Ports.
312 * @params[in] duPort array to be filled
313 * @return ROK - success
316 * ****************************************************************/
317 uint8_t fillDuPort(uint16_t *duPort)
319 duPort[F1_INTERFACE] = DU_PORT; /* DU Port idx 0 38472 */
320 duPort[E2_INTERFACE] = RIC_PORT; /* RIC Port idx 1 38482 */
325 /*******************************************************************
327 * @brief Configures the DU Parameters
331 * Function : calcSliv
334 * - calculate SLIV value from start and length field
336 * @params[in] start symbol
337 * @params[in] length of symbols
340 * ****************************************************************/
341 uint16_t calcSliv(uint8_t startSymbol, uint8_t lengthSymbol)
344 if((lengthSymbol-1) <= 7)
346 sliv = NUM_SYMBOLS_PER_SLOT * (lengthSymbol-1) + startSymbol;
350 sliv = NUM_SYMBOLS_PER_SLOT * (NUM_SYMBOLS_PER_SLOT - lengthSymbol + 1) \
351 + (NUM_SYMBOLS_PER_SLOT - 1 - startSymbol);
357 /*******************************************************************
359 * @brief Configures serving cell config common in sib1
363 * Function : fillServCellCfgCommSib
366 * - fills Serving cell config common for SIB1
368 * @params[in] SrvCellCfgCommSib pointer
369 * @return ROK - success
372 ** ****************************************************************/
373 uint8_t fillServCellCfgCommSib(SrvCellCfgCommSib *srvCellCfgComm)
375 PdcchCfgCommon pdcchCfg;
376 PdschCfgCommon pdschCfg;
378 RachCfgCommon rachCfg;
379 PuschCfgCommon puschCfg;
380 PucchCfgCommon pucchCfg;
381 TddUlDlCfgCommon tddCfg;
383 /* Configuring DL Config Common for SIB1*/
384 srvCellCfgComm->dlCfg.freqBandInd = NR_FREQ_BAND_IND;
385 srvCellCfgComm->dlCfg.offsetToPointA = OFFSET_TO_POINT_A;
386 srvCellCfgComm->dlCfg.dlScsCarrier.scsOffset = SSB_SUBCARRIER_OFFSET;
387 srvCellCfgComm->dlCfg.dlScsCarrier.scs = SUBCARRIER_SPACING;
388 srvCellCfgComm->dlCfg.dlScsCarrier.scsBw = SCS_CARRIER_BANDWIDTH;
389 srvCellCfgComm->dlCfg.locAndBw = FREQ_LOC_BW;
391 /* Configuring PDCCH Config Common For SIB1 */
392 pdcchCfg.present = BWP_DownlinkCommon__pdcch_ConfigCommon_PR_setup;
393 pdcchCfg.ctrlRsrcSetZero = PDCCH_CTRL_RSRC_SET_ZERO;
394 pdcchCfg.searchSpcZero = PDCCH_SEARCH_SPACE_ZERO;
395 pdcchCfg.searchSpcId = PDCCH_SEARCH_SPACE_ID;
396 pdcchCfg.ctrlRsrcSetId = PDCCH_CTRL_RSRC_SET_ID;
397 pdcchCfg.monitorSlotPrdAndOffPresent = \
398 SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl1;
399 //pdcchCfg.monitorSlotPrdAndOff = \
400 SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl1;
401 pdcchCfg.monitorSymbolsInSlot[0] = 128;
402 pdcchCfg.monitorSymbolsInSlot[1] = 0;
403 pdcchCfg.numCandAggLvl1 = SearchSpace__nrofCandidates__aggregationLevel1_n8;
404 pdcchCfg.numCandAggLvl2 = SearchSpace__nrofCandidates__aggregationLevel2_n4;
405 pdcchCfg.numCandAggLvl4 = SearchSpace__nrofCandidates__aggregationLevel4_n2;
406 pdcchCfg.numCandAggLvl8 = SearchSpace__nrofCandidates__aggregationLevel8_n1;
407 pdcchCfg.numCandAggLvl16 = SearchSpace__nrofCandidates__aggregationLevel16_n0;
408 pdcchCfg.searchSpcType = SearchSpace__searchSpaceType_PR_common;
409 pdcchCfg.commSrchSpcDciFrmt = PDCCH_SERACH_SPACE_DCI_FORMAT;
410 pdcchCfg.searchSpcSib1 = PDCCH_SEARCH_SPACE_ID_SIB1;
411 pdcchCfg.pagingSearchSpc = PDCCH_SEARCH_SPACE_ID_PAGING;
412 pdcchCfg.raSearchSpc = PDCCH_SEARCH_SPACE_ID_PAGING;
413 srvCellCfgComm->dlCfg.pdcchCfg = pdcchCfg;
415 /* Configuring PDSCH Config Common For SIB1 */
416 pdschCfg.present = BWP_DownlinkCommon__pdsch_ConfigCommon_PR_setup;
417 pdschCfg.k0 = PDSCH_K0;
419 PDSCH_TimeDomainResourceAllocation__mappingType_typeA;
420 pdschCfg.sliv = calcSliv(PDSCH_START_SYMBOL,PDSCH_LENGTH_SYMBOL);
421 srvCellCfgComm->dlCfg.pdschCfg = pdschCfg;
423 /* Configuring BCCH Config for SIB1 */
424 srvCellCfgComm->dlCfg.bcchCfg.modPrdCoeff = \
425 BCCH_Config__modificationPeriodCoeff_n16;
427 /* Configuring PCCH Config for SIB1 */
428 pcchCfg.dfltPagingCycle = PagingCycle_rf64;
429 pcchCfg.nAndPagingFrmOffPresent = PCCH_Config__nAndPagingFrameOffset_PR_oneT;
430 pcchCfg.numPagingOcc = PCCH_Config__ns_four;
431 srvCellCfgComm->dlCfg.pcchCfg = pcchCfg;
434 /* Configuring UL Config Common */
435 srvCellCfgComm->ulCfg.ulScsCarrier.scsOffset = SSB_SUBCARRIER_OFFSET;
436 srvCellCfgComm->ulCfg.ulScsCarrier.scs = SUBCARRIER_SPACING;
437 srvCellCfgComm->ulCfg.ulScsCarrier.scsBw = SCS_CARRIER_BANDWIDTH;
438 srvCellCfgComm->ulCfg.pMax = UL_P_MAX;
439 srvCellCfgComm->ulCfg.locAndBw = FREQ_LOC_BW;
440 srvCellCfgComm->ulCfg.timeAlignTimerComm = TimeAlignmentTimer_infinity;
442 /* Configuring RACH Config Common for SIB1 */
443 rachCfg.present = BWP_UplinkCommon__rach_ConfigCommon_PR_setup;
444 rachCfg.prachCfgIdx = PRACH_CONFIG_IDX;
445 rachCfg.msg1Fdm = RACH_ConfigGeneric__msg1_FDM_one;
446 rachCfg.msg1FreqStart = PRACH_FREQ_START;
447 rachCfg.zeroCorrZoneCfg = ZERO_CORRELATION_ZONE_CFG;
448 rachCfg.preambleRcvdTgtPwr = PRACH_PREAMBLE_RCVD_TGT_PWR;
449 rachCfg.preambleTransMax = RACH_ConfigGeneric__preambleTransMax_n200;
450 rachCfg.pwrRampingStep = RACH_ConfigGeneric__powerRampingStep_dB2;
451 rachCfg.raRspWindow = RACH_ConfigGeneric__ra_ResponseWindow_sl20;
452 rachCfg.numRaPreamble = NUM_RA_PREAMBLE;
453 rachCfg.ssbPerRachOccPresent = \
454 RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_one;
455 rachCfg.numSsbPerRachOcc = SSB_PER_RACH;
456 rachCfg.contResTimer = RACH_ConfigCommon__ra_ContentionResolutionTimer_sf64;
457 rachCfg.rsrpThreshSsb = RSRP_THRESHOLD_SSB;
458 rachCfg.rootSeqIdxPresent = RACH_ConfigCommon__prach_RootSequenceIndex_PR_l139;
459 rachCfg.rootSeqIdx = ROOT_SEQ_IDX;
460 rachCfg.msg1Scs = PRACH_SUBCARRIER_SPACING ;
461 rachCfg.restrictedSetCfg = PRACH_RESTRICTED_SET_CFG;
462 srvCellCfgComm->ulCfg.rachCfg = rachCfg;
464 /* Configuring PUSCH Config Common for SIB1 */
465 puschCfg.present = BWP_UplinkCommon__pusch_ConfigCommon_PR_setup;
466 puschCfg.k2 = PUSCH_K2;
467 puschCfg.mapType = PUSCH_TimeDomainResourceAllocation__mappingType_typeA;
468 puschCfg.sliv = calcSliv(PUSCH_START_SYMBOL,PUSCH_LENGTH_SYMBOL);
469 puschCfg.msg3DeltaPreamble = PUSCH_MSG3_DELTA_PREAMBLE;
470 puschCfg.p0NominalWithGrant = PUSCH_P0_NOMINAL_WITH_GRANT;
471 srvCellCfgComm->ulCfg.puschCfg = puschCfg;
473 /* Configuring PUCCH Config Common for SIB1 */
474 pucchCfg.present = BWP_UplinkCommon__pucch_ConfigCommon_PR_setup;
475 pucchCfg.rsrcComm = PUCCH_RSRC_COMMON;
476 pucchCfg.grpHop = PUCCH_ConfigCommon__pucch_GroupHopping_neither;
477 pucchCfg.p0Nominal = PUCCH_P0_NOMINAL;
478 srvCellCfgComm->ulCfg.pucchCfg = pucchCfg;
480 /* Configuring TDD UL DL config common */
481 tddCfg.refScs = SubcarrierSpacing_kHz30;
482 tddCfg.txPrd = TDD_UL_DL_Pattern__dl_UL_TransmissionPeriodicity_ms2p5;
483 tddCfg.numDlSlots = NUM_DL_SLOTS;
484 tddCfg.numDlSymbols = NUM_DL_SYMBOLS;
485 tddCfg.numUlSlots = NUM_UL_SLOTS;
486 tddCfg.numUlSymbols = NUM_UL_SYMBOLS;
487 srvCellCfgComm->tddCfg = tddCfg;
489 srvCellCfgComm->ssbPosInBurst = 192;
490 srvCellCfgComm->ssbPrdServingCell = SSB_PERIODICITY_20MS;
491 srvCellCfgComm->ssPbchBlockPwr = SSB_PBCH_PWR;
496 /*******************************************************************
498 * @brief Configures the DU Parameters
505 * - Initializes the DuCfg members.
506 * - Calls readMacCfg()
508 * @params[in] system task ID
509 * @return ROK - success
512 * ****************************************************************/
517 uint32_t ipv4_du, ipv4_cu, ipv4_ric;
521 cmInetAddr((S8*)DU_IP_V4_ADDR, &ipv4_du);
522 cmInetAddr((S8*)CU_IP_V4_ADDR, &ipv4_cu);
523 cmInetAddr((S8*)RIC_IP_V4_ADDR, &ipv4_ric);
524 fillDuPort(duCfgParam.sctpParams.duPort);
526 /* F1 DU IP Address and Port*/
527 duCfgParam.sctpParams.duIpAddr.ipV4Addr = ipv4_du;
529 /* F1 CU IP Address and Port*/
530 duCfgParam.sctpParams.cuIpAddr.ipV4Addr = ipv4_cu;
531 duCfgParam.sctpParams.cuPort = CU_PORT;
533 /* Fill RIC Params */
534 duCfgParam.sctpParams.ricIpAddr.ipV4Addr = ipv4_ric;
535 duCfgParam.sctpParams.ricPort = RIC_PORT;
536 /* EGTP Parameters */
537 duCfgParam.egtpParams.localIp.ipV4Pres = TRUE;
538 duCfgParam.egtpParams.localIp.ipV4Addr = ipv4_du;
539 duCfgParam.egtpParams.localPort = DU_EGTP_PORT;
540 duCfgParam.egtpParams.destIp.ipV4Pres = TRUE;
541 duCfgParam.egtpParams.destIp.ipV4Addr = ipv4_cu;
542 duCfgParam.egtpParams.destPort = CU_EGTP_PORT;
543 duCfgParam.egtpParams.minTunnelId = 0;
544 duCfgParam.egtpParams.maxTunnelId = 10;
546 duCfgParam.maxUe = 32; //TODO: Check
548 duCfgParam.duId = DU_ID;
549 strcpy((char*)duCfgParam.duName,DU_NAME);
552 mib.sysFrmNum = SYS_FRAME_NUM;
553 mib.subCarrierSpacingCommon = MIB__subCarrierSpacingCommon_scs15or60;
554 mib.ssb_SubcarrierOffset = SSB_SC_OFFSET;
555 mib.dmrs_TypeA_Position = MIB__dmrs_TypeA_Position_pos2;
556 mib.controlResourceSetZero = CORESET_ZERO;
557 mib.searchSpaceZero = SEARCH_SPACE_ZERO;
558 mib.cellBarred = MIB__cellBarred_barred;
559 mib.intraFreqReselection =
560 MIB__intraFreqReselection_notAllowed;
561 duCfgParam.mibParams = mib;
564 sib1.plmn.mcc[0] = PLMN_MCC0;
565 sib1.plmn.mcc[1] = PLMN_MCC1;
566 sib1.plmn.mcc[2] = PLMN_MCC2;
567 sib1.plmn.mnc[0] = PLMN_MNC0;
568 sib1.plmn.mnc[1] = PLMN_MNC1;
569 sib1.plmn.mnc[2] = PLMN_MNC2;
571 sib1.ranac = DU_RANAC;
572 sib1.cellIdentity = CELL_IDENTITY;
573 sib1.cellResvdForOpUse =\
574 PLMN_IdentityInfo__cellReservedForOperatorUse_notReserved;
575 sib1.connEstFailCnt = ConnEstFailureControl__connEstFailCount_n3;
576 sib1.connEstFailOffValidity =\
577 ConnEstFailureControl__connEstFailOffsetValidity_s120;
578 sib1.siSchedInfo.winLen = SI_SchedulingInfo__si_WindowLength_s5;
579 sib1.siSchedInfo.broadcastSta = \
580 SchedulingInfo__si_BroadcastStatus_broadcasting;
581 sib1.siSchedInfo.preiodicity = SchedulingInfo__si_Periodicity_rf8;
582 sib1.siSchedInfo.sibType = SIB_TypeInfo__type_sibType2;
583 sib1.siSchedInfo.sibValTag = SIB1_VALUE_TAG;
585 fillServCellCfgCommSib(&sib1.srvCellCfgCommSib);
587 duCfgParam.sib1Params = sib1;
589 for(i=0; i<DEFAULT_CELLS; i++)
591 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.nrCgi.plmn.mcc[0] = PLMN_MCC0;
592 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.nrCgi.plmn.mcc[1] = PLMN_MCC1;
593 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.nrCgi.plmn.mcc[2] = PLMN_MCC2;
594 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.nrCgi.plmn.mnc[0] = PLMN_MNC0;
595 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.nrCgi.plmn.mnc[1] = PLMN_MNC1;
596 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.nrCgi.plmn.mnc[2] = PLMN_MNC2;
599 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.nrCgi.cellId = NR_CELL_ID;
600 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.nrPci = NR_PCI;
602 /* List of Available PLMN */
603 for(j=0;j<MAX_PLMN;j++)
605 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.plmn[j].mcc[0] = PLMN_MCC0;
606 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.plmn[j].mcc[1] = PLMN_MCC1;
607 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.plmn[j].mcc[2] = PLMN_MCC2;
608 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.plmn[j].mnc[0] = PLMN_MNC0;
609 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.plmn[j].mnc[1] = PLMN_MNC1;
610 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.plmn[j].mnc[2] = PLMN_MNC2;
612 /* List of Extended PLMN */
613 for(j=0;j<MAX_PLMN;j++)
615 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.extPlmn[j].mcc[0] = PLMN_MCC0;
616 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.extPlmn[j].mcc[1] = PLMN_MCC1;
617 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.extPlmn[j].mcc[2] = PLMN_MCC2;
618 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.extPlmn[j].mnc[0] = PLMN_MNC0;
619 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.extPlmn[j].mnc[1] = PLMN_MNC1;
620 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.extPlmn[j].mnc[2] = PLMN_MNC2;
624 duCfgParam.srvdCellLst[i].duCellInfo.tac = DU_TAC;
625 duCfgParam.srvdCellLst[i].duCellInfo.epsTac = DU_TAC; //to check and fill
627 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.nrArfcn = NR_UL_ARFCN;
628 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.sulInfo.sulArfcn = SUL_ARFCN;
629 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.sulInfo.sulTxBw.nrScs = SCS_120;
630 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.sulInfo.sulTxBw.nrb = NRB_66;
634 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.nrArfcn = NR_ARFCN;
635 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.sulInfo.sulArfcn = SUL_ARFCN;
636 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.sulInfo.sulTxBw.nrScs = SCS_15;
637 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.sulInfo.sulTxBw.nrb = NRB_160;
639 for(j=0;j<MAXNRCELLBANDS;j++)
641 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.freqBand[j].nrFreqBand = NR_FREQ_BAND;
642 for(k=0;k<MAXNRCELLBANDS;k++)
644 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.freqBand[j].sulBand[k] = SUL_BAND;
648 for(j=0;j<MAXNRCELLBANDS;j++)
650 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.freqBand[j].nrFreqBand = NR_FREQ_BAND;
651 for(k=0;k<MAXNRCELLBANDS;k++)
653 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.freqBand[j].sulBand[k] = SUL_BAND;
656 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.nrArfcn = NR_DL_ARFCN;
657 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.sulInfo.sulArfcn = SUL_ARFCN;
658 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.sulInfo.sulTxBw.nrScs = SCS_120;
659 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.sulInfo.sulTxBw.nrb = NRB_66;
660 for(j=0;j<MAXNRCELLBANDS;j++)
662 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.freqBand[j].nrFreqBand = NR_FREQ_BAND;
663 for(k=0;k<MAXNRCELLBANDS;k++)
665 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.freqBand[j].sulBand[k] = SUL_BAND;
669 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.ulTxBw.nrScs = SCS_120;
670 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.ulTxBw.nrb = NRB_66;
672 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.dlTxBw.nrScs = SCS_120;
673 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.dlTxBw.nrb = NRB_66;
676 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.tdd.nrTxBw.nrScs = SCS_15;
677 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.tdd.nrTxBw.nrb = NRB_160;
679 /*Measurement Config and Cell Config */
680 duCfgParam.srvdCellLst[i].duCellInfo.measTimeCfg = TIME_CFG;
682 duCfgParam.srvdCellLst[i].duCellInfo.cellDir = DL_UL;
684 duCfgParam.srvdCellLst[i].duCellInfo.cellType=CELL_TYPE;
686 /* Broadcast PLMN Identity */
687 for(j=0;j<MAXBPLMNNRMINUS1;j++)
689 for(k=0;k<MAX_PLMN;k++)
691 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].plmn[k].mcc[0] = PLMN_MCC0;
692 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].plmn[k].mcc[1] = PLMN_MCC1;
693 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].plmn[k].mcc[2] = PLMN_MCC2;
694 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].plmn[k].mnc[0] = PLMN_MNC0;
695 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].plmn[k].mnc[1] = PLMN_MNC1;
696 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].plmn[k].mnc[2] = PLMN_MNC2;
698 /* Extended PLMN List */
699 for(k=0;k<MAX_PLMN;k++)
701 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].extPlmn[k].mcc[0] = PLMN_MCC0;
702 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].extPlmn[k].mcc[1] = PLMN_MCC1;
703 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].extPlmn[k].mcc[2] = PLMN_MCC2;
704 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].extPlmn[k].mnc[0] = PLMN_MNC0;
705 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].extPlmn[k].mnc[1] = PLMN_MNC1;
706 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].extPlmn[k].mnc[2] = PLMN_MNC2;
709 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].tac = DU_TAC;
710 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].nrCellId = NR_CELL_ID;
711 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].ranac = NR_RANAC;
714 /*gnb DU System Info mib msg*/
716 DU_ALLOC(duCfgParam.srvdCellLst[i].duSysInfo.mibMsg,\
718 if(!(duCfgParam.srvdCellLst[i].duSysInfo.mibMsg))
720 DU_LOG("\nDU_APP: Memory allocation failure");
723 strcpy((char *)duCfgParam.srvdCellLst[i].duSysInfo.mibMsg, encBuf);
724 duCfgParam.srvdCellLst[i].duSysInfo.mibLen = encBufSize;
726 /*gnb DU System Info mib msg*/
728 DU_ALLOC(duCfgParam.srvdCellLst[i].duSysInfo.sib1Msg,\
730 if(!(duCfgParam.srvdCellLst[i].duSysInfo.sib1Msg))
732 DU_LOG("\nDU_APP: Memory allocation failure");
735 memcpy(duCfgParam.srvdCellLst[i].duSysInfo.sib1Msg,\
737 duCfgParam.srvdCellLst[i].duSysInfo.sib1Len = encBufSize;
741 if(readMacCfg() != ROK)
743 DU_LOG("\nDU_APP : Failed while reading MAC config");
750 /*******************************************************************
752 * @brief Reads config and posts message to du_app on completion
760 * - Post to du_app for further processing
763 * @return ROK - success
766 * ****************************************************************/
772 memset(&duCfgParam, 0, sizeof(DuCfgParams));
773 //Read configs into duCfgParams
776 DU_LOG("\nDU_APP : Reading configuration failed");
781 memset(&(pst), 0, sizeof(Pst));
782 pst.srcEnt = (Ent)ENTDUAPP;
783 pst.srcInst = (Inst)DU_INST;
784 pst.srcProcId = DU_PROC;
785 pst.dstEnt = pst.srcEnt;
786 pst.dstInst = pst.srcInst;
787 pst.dstProcId = pst.srcProcId;
789 pst.selector = ODU_SELECTOR_TC;
793 if(ODU_GET_MSG_BUF(DFLT_REGION, DU_POOL, &mBuf) != ROK)
795 DU_LOG("\nDU_APP : Memory allocation failed in duReadCfg");
799 if (ODU_POST_TASK(&pst, mBuf) != ROK)
801 DU_LOG("\nDU_APP : ODU_POST_TASK failed in duReadCfg");
808 /**********************************************************************
810 **********************************************************************/