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"
27 #include "du_sys_info_hdl.h"
29 #include "SearchSpace.h"
30 #include "SIB-TypeInfo.h"
31 #include "SchedulingInfo.h"
32 #include "SI-SchedulingInfo.h"
33 #include "ConnEstFailureControl.h"
34 #include "PLMN-IdentityInfo.h"
35 #include "odu_common_codec.h"
36 #include "PDSCH-TimeDomainResourceAllocation.h"
37 #include "BCCH-Config.h"
38 #include "PagingCycle.h"
39 #include "PCCH-Config.h"
40 #include "TimeAlignmentTimer.h"
41 #include "RACH-ConfigGeneric.h"
42 #include "PUSCH-TimeDomainResourceAllocation.h"
43 #include "PUCCH-ConfigCommon.h"
44 #include "SubcarrierSpacing.h"
45 #include "TDD-UL-DL-Pattern.h"
46 #include "RACH-ConfigCommon.h"
47 #include "BWP-DownlinkCommon.h"
48 #include "BWP-UplinkCommon.h"
50 extern DuCfgParams duCfgParam;
51 extern char encBuf[ENC_BUF_MAX_LEN];
54 /* Filling Slot configuration as :
55 * 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
56 * 0 DL DL DL DL DL DL DL DL DL DL DL DL DL DL
57 * 1 DL DL DL DL DL DL DL DL DL DL DL DL DL DL
58 * 2 DL DL DL DL DL DL DL DL DL DL DL DL DL DL
59 * 3 DL DL DL DL DL DL DL DL DL DL GD GD GD UL
60 * 4 UL UL UL UL UL UL UL UL UL UL UL UL UL UL
63 /*******************************************************************
65 * @brief Fills the Slot configuration
69 * Function : FillSlotConfig
71 * Functionality:Fill the Slot configuration values
74 * @return ROK - success
77 * ****************************************************************/
83 for(slot = 0; slot <= 3; slot++)
85 for(symbol = 0; symbol < MAX_SYMB_PER_SLOT; symbol++)
86 duCfgParam.macCellCfg.tddCfg.slotCfg[slot][symbol] = DL_SLOT;
89 duCfgParam.macCellCfg.tddCfg.slotCfg[3][10] = GUARD_SLOT;
90 duCfgParam.macCellCfg.tddCfg.slotCfg[3][11] = GUARD_SLOT;
91 duCfgParam.macCellCfg.tddCfg.slotCfg[3][12] = GUARD_SLOT;
92 duCfgParam.macCellCfg.tddCfg.slotCfg[3][13] = UL_SLOT;
94 for(symbol = 0; symbol < MAX_SYMB_PER_SLOT; symbol++)
95 duCfgParam.macCellCfg.tddCfg.slotCfg[4][symbol] = UL_SLOT;
99 /*******************************************************************
101 * @brief Reads the CL Configuration.
105 * Function : readMacCfg
108 * - Fills up the cell configuration for CL.
109 * - Calls FillSlotConfig()
112 * @return ROK - success
115 * ****************************************************************/
118 /* This function is used to fill up the cell configuration for CL */
121 duCfgParam.macCellCfg.carrierId = CARRIER_IDX;
123 /* Cell configuration */
124 duCfgParam.macCellCfg.cellId = NR_CELL_ID;
125 duCfgParam.macCellCfg.phyCellId = NR_PCI;
126 duCfgParam.macCellCfg.dupType = DUPLEX_MODE;
128 /* DL carrier configuration */
129 duCfgParam.macCellCfg.dlCarrCfg.pres = TRUE;
130 duCfgParam.macCellCfg.dlCarrCfg.bw = BANDWIDTH;
131 duCfgParam.macCellCfg.dlCarrCfg.freq = NR_ARFCN;
132 duCfgParam.macCellCfg.dlCarrCfg.k0[0] = 1;
133 duCfgParam.macCellCfg.dlCarrCfg.k0[1] = 1;
134 duCfgParam.macCellCfg.dlCarrCfg.k0[2] = 1;
135 duCfgParam.macCellCfg.dlCarrCfg.k0[3] = 1;
136 duCfgParam.macCellCfg.dlCarrCfg.k0[4] = 1;
137 duCfgParam.macCellCfg.dlCarrCfg.gridSize[0] = 1;
138 duCfgParam.macCellCfg.dlCarrCfg.gridSize[1] = 1;
139 duCfgParam.macCellCfg.dlCarrCfg.gridSize[2] = 1;
140 duCfgParam.macCellCfg.dlCarrCfg.gridSize[3] = 1;
141 duCfgParam.macCellCfg.dlCarrCfg.gridSize[4] = 1;
142 duCfgParam.macCellCfg.dlCarrCfg.numAnt = NUM_TX_ANT;
144 /* UL Carrier configuration */
145 duCfgParam.macCellCfg.ulCarrCfg.pres = TRUE;
146 duCfgParam.macCellCfg.ulCarrCfg.bw = SUL_ARFCN;
147 duCfgParam.macCellCfg.ulCarrCfg.freq = NR_ARFCN;
148 duCfgParam.macCellCfg.ulCarrCfg.k0[0] = 1;
149 duCfgParam.macCellCfg.ulCarrCfg.k0[1] = 1;
150 duCfgParam.macCellCfg.ulCarrCfg.k0[2] = 1;
151 duCfgParam.macCellCfg.ulCarrCfg.k0[3] = 1;
152 duCfgParam.macCellCfg.ulCarrCfg.k0[4] = 1;
153 duCfgParam.macCellCfg.ulCarrCfg.gridSize[0] = 1;
154 duCfgParam.macCellCfg.ulCarrCfg.gridSize[1] = 1;
155 duCfgParam.macCellCfg.ulCarrCfg.gridSize[2] = 1;
156 duCfgParam.macCellCfg.ulCarrCfg.gridSize[3] = 1;
157 duCfgParam.macCellCfg.ulCarrCfg.gridSize[4] = 1;
158 duCfgParam.macCellCfg.ulCarrCfg.numAnt = NUM_RX_ANT;
160 duCfgParam.macCellCfg.freqShft = FREQ_SHIFT_7P5KHZ;
162 /* SSB configuration */
163 duCfgParam.macCellCfg.ssbCfg.ssbPbchPwr = SSB_PBCH_PWR;
164 duCfgParam.macCellCfg.ssbCfg.bchPayloadFlag = BCH_PAYLOAD;
165 duCfgParam.macCellCfg.ssbCfg.scsCmn = SUBCARRIER_SPACING;
166 duCfgParam.macCellCfg.ssbCfg.ssbOffsetPointA = OFFSET_TO_POINT_A;
167 duCfgParam.macCellCfg.ssbCfg.betaPss = BETA_PSS;
168 duCfgParam.macCellCfg.ssbCfg.ssbPeriod = SSB_PERIODICITY_20MS;
169 duCfgParam.macCellCfg.ssbCfg.ssbScOffset = SSB_SUBCARRIER_OFFSET;
170 duCfgParam.macCellCfg.ssbCfg.ssbMask[0] = 1; /* only one SSB is transmitted */
171 duCfgParam.macCellCfg.ssbCfg.ssbMask[1] = 0;
172 if(BuildMibPdu() != ROK)
174 DU_LOG("\nFailed to build MIB PDU");
175 memset(&duCfgParam.macCellCfg.ssbCfg.mibPdu, 0, 3*sizeof(uint8_t));
179 for(uint8_t idx=0; idx<encBufSize; idx++)
181 duCfgParam.macCellCfg.ssbCfg.mibPdu[idx]=encBuf[idx];
184 duCfgParam.macCellCfg.ssbCfg.multCarrBand = SSB_MULT_CARRIER_BAND;
185 duCfgParam.macCellCfg.ssbCfg.multCellCarr = MULT_CELL_CARRIER;
187 /* PRACH configuration */
188 duCfgParam.macCellCfg.prachCfg.pres = TRUE;
189 duCfgParam.macCellCfg.prachCfg.prachCfgIdx = PRACH_CONFIG_IDX;
190 duCfgParam.macCellCfg.prachCfg.prachSeqLen = PRACH_SEQ_LEN;
191 duCfgParam.macCellCfg.prachCfg.prachSubcSpacing = PRACH_SUBCARRIER_SPACING;
192 duCfgParam.macCellCfg.prachCfg.prachRstSetCfg = PRACH_RESTRICTED_SET_CFG;
193 duCfgParam.macCellCfg.prachCfg.msg1Fdm = NUM_PRACH_FDM;
194 duCfgParam.macCellCfg.prachCfg.msg1FreqStart = PRACH_FREQ_START;
195 duCfgParam.macCellCfg.prachCfg.rootSeqLen = ROOT_SEQ_LEN;
196 duCfgParam.macCellCfg.prachCfg.fdm[0].rootSeqIdx = ROOT_SEQ_IDX;
197 duCfgParam.macCellCfg.prachCfg.fdm[0].numRootSeq = NUM_ROOT_SEQ;
198 duCfgParam.macCellCfg.prachCfg.fdm[0].k1 = 1;
199 duCfgParam.macCellCfg.prachCfg.fdm[0].zeroCorrZoneCfg = ZERO_CORRELATION_ZONE_CFG;
200 duCfgParam.macCellCfg.prachCfg.fdm[0].numUnusedRootSeq = NUM_UNUSED_ROOT_SEQ;
201 if(duCfgParam.macCellCfg.prachCfg.fdm[0].numUnusedRootSeq != 0)
203 DU_ALLOC(duCfgParam.macCellCfg.prachCfg.fdm[0].unsuedRootSeq,
204 NUM_UNUSED_ROOT_SEQ * sizeof(U8));
205 if(duCfgParam.macCellCfg.prachCfg.fdm[0].unsuedRootSeq == NULLP)
207 DU_LOG("\nDU_APP : Memory allocation failed");
210 *(duCfgParam.macCellCfg.prachCfg.fdm[0].unsuedRootSeq) = UNUSED_ROOT_SEQ;
212 duCfgParam.macCellCfg.prachCfg.ssbPerRach = SSB_PER_RACH;
213 duCfgParam.macCellCfg.prachCfg.prachMultCarrBand = PRACH_MULT_CARRIER_BAND;
214 duCfgParam.macCellCfg.prachCfg.raContResTmr = RA_CONT_RES_TIMER;
215 duCfgParam.macCellCfg.prachCfg.rsrpThreshSsb = RSRP_THRESHOLD_SSB;
216 duCfgParam.macCellCfg.prachCfg.raRspWindow = RA_RSP_WINDOW;
217 duCfgParam.macCellCfg.prachCfg.prachRestrictedSet = PRACH_RESTRICTED_SET;
218 /* TDD configuration */
219 duCfgParam.macCellCfg.tddCfg.pres = TRUE;
220 duCfgParam.macCellCfg.tddCfg.tddPeriod = TDD_PERIODICITY;
224 /* RSSI Measurement configuration */
225 duCfgParam.macCellCfg.rssiUnit = RSS_MEASUREMENT_UNIT;
227 /* fill SIB1 configuration */
228 duCfgParam.macCellCfg.sib1Cfg.sib1PduLen = duCfgParam.srvdCellLst[0].duSysInfo.sib1Len;
229 DU_ALLOC(duCfgParam.macCellCfg.sib1Cfg.sib1Pdu,duCfgParam.srvdCellLst[0].duSysInfo.sib1Len);
230 memcpy(duCfgParam.macCellCfg.sib1Cfg.sib1Pdu, duCfgParam.srvdCellLst[0].duSysInfo.sib1Msg, \
231 duCfgParam.srvdCellLst[0].duSysInfo.sib1Len);
232 duCfgParam.macCellCfg.sib1Cfg.sib1NewTxPeriod = SIB1_NEW_TX_PERIOD;
233 duCfgParam.macCellCfg.sib1Cfg.sib1RepetitionPeriod = SIB1_REPETITION_PERIOD;
234 duCfgParam.macCellCfg.sib1Cfg.coresetZeroIndex = CORESET_0_INDEX;
235 duCfgParam.macCellCfg.sib1Cfg.searchSpaceZeroIndex = SEARCHSPACE_0_INDEX;
236 duCfgParam.macCellCfg.sib1Cfg.sib1Mcs = SIB1_MCS;
239 /* fill Intial DL BWP */
240 duCfgParam.macCellCfg.initialDlBwp.bwp.firstPrb = 0;
241 duCfgParam.macCellCfg.initialDlBwp.bwp.numPrb = TOTAL_PRB_BW; /* configured to total BW */
242 duCfgParam.macCellCfg.initialDlBwp.bwp.scs = SUBCARRIER_SPACING; /* numerology is 0, 15Khz */
243 duCfgParam.macCellCfg.initialDlBwp.bwp.cyclicPrefix = NORMAL_CYCLIC_PREFIX;
244 duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.searchSpaceId = SEARCHSPACE_1_INDEX;
245 duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.coresetId = CORESET_0_INDEX;
246 duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.monitoringSlot =
247 SS_MONITORING_SLOT_SL1; /* sl1 - all slots */
248 duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.duration = 0;
249 duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.monitoringSymbol =
250 SS_MONITORING_SYMBOL;
251 duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.
252 candidate.aggLevel1 = 8;
253 duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.
254 candidate.aggLevel2 = 4;
255 duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.
256 candidate.aggLevel4 = 2;
257 duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.
258 candidate.aggLevel8 = 1;
259 duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.
260 candidate.aggLevel16 = 0;
261 duCfgParam.macCellCfg.initialDlBwp.pdschCommon.k0 = PDSCH_K0;
262 duCfgParam.macCellCfg.initialDlBwp.pdschCommon.mappingType =
263 PDSCH_MAPPING_TYPE_A;
264 duCfgParam.macCellCfg.initialDlBwp.pdschCommon.startSymbol =
266 duCfgParam.macCellCfg.initialDlBwp.pdschCommon.lengthSymbol =
268 /* ra-searchSpace ID is set to 1 */
269 duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.raSearchSpaceId = SEARCHSPACE_1_INDEX;
271 /* fill Intial UL BWP */
272 duCfgParam.macCellCfg.initialUlBwp.bwp.firstPrb = 0;
273 duCfgParam.macCellCfg.initialUlBwp.bwp.numPrb = TOTAL_PRB_BW; /* configured to total BW */
274 duCfgParam.macCellCfg.initialUlBwp.bwp.scs = SUBCARRIER_SPACING; /* numerology is 0, 15Khz */
275 duCfgParam.macCellCfg.initialUlBwp.bwp.cyclicPrefix = NORMAL_CYCLIC_PREFIX;
276 duCfgParam.macCellCfg.initialUlBwp.puschCommon.k2 = PUSCH_K2;
277 duCfgParam.macCellCfg.initialUlBwp.puschCommon.mappingType =
278 PUSCH_MAPPING_TYPE_A;
279 duCfgParam.macCellCfg.initialUlBwp.puschCommon.startSymbol =
281 duCfgParam.macCellCfg.initialUlBwp.puschCommon.lengthSymbol =
284 duCfgParam.macCellCfg.dmrsTypeAPos = DMRS_TYPE_A_POS;
285 /* fill PUCCH config common */
286 duCfgParam.macCellCfg.initialUlBwp.pucchCommon.pucchResourceCommon = PUCCH_RSRC_COMMON;
287 duCfgParam.macCellCfg.initialUlBwp.pucchCommon.pucchGroupHopping = PUCCH_GROUP_HOPPING;
289 /* This should be calculated based on
290 (number of mandatory parameters) + (number of otional parameters being filled) */
291 duCfgParam.macCellCfg.numTlv = 40;
296 /*******************************************************************
298 * @brief Configures the DU Parameters
302 * Function : fillDuPort
305 * - fills the DU Ports.
307 * @params[in] duPort array to be filled
308 * @return ROK - success
311 * ****************************************************************/
312 S16 fillDuPort(U16 *duPort)
314 duPort[F1_INTERFACE] = DU_PORT; /* DU Port idx 0 38472 */
315 duPort[E2_INTERFACE] = RIC_PORT; /* RIC Port idx 1 38482 */
320 /*******************************************************************
322 * @brief Configures the DU Parameters
326 * Function : calcSliv
329 * - calculate SLIV value from start and length field
331 * @params[in] start symbol
332 * @params[in] length of symbols
335 * ****************************************************************/
336 uint16_t calcSliv(uint8_t startSymbol, uint8_t lengthSymbol)
339 if((lengthSymbol-1) <= 7)
341 sliv = 14 * (lengthSymbol-1) + startSymbol;
345 sliv = 14 * (14-lengthSymbol+1) + (14-1-startSymbol);
351 /*******************************************************************
353 * @brief Configures serving cell config common in sib1
357 * Function : fillServCellCfgCommSib
360 * - fills Serving cell config common for SIB1
362 * @params[in] SrvCellCfgCommSib pointer
363 * @return ROK - success
366 ** ****************************************************************/
367 S16 fillServCellCfgCommSib(SrvCellCfgCommSib *srvCellCfgComm)
369 PdcchCfgCommon pdcchCfg;
370 PdschCfgCommon pdschCfg;
372 RachCfgCommon rachCfg;
373 PuschCfgCommon puschCfg;
374 PucchCfgCommon pucchCfg;
375 TddUlDlCfgCommon tddCfg;
377 /* Configuring DL Config Common for SIB1*/
378 srvCellCfgComm->dlCfg.freqBandInd = NR_FREQ_BAND_IND;
379 srvCellCfgComm->dlCfg.offsetToPointA = OFFSET_TO_POINT_A;
380 srvCellCfgComm->dlCfg.dlScsCarrier.scsOffset = SSB_SUBCARRIER_OFFSET;
381 srvCellCfgComm->dlCfg.dlScsCarrier.scs = SUBCARRIER_SPACING;
382 srvCellCfgComm->dlCfg.dlScsCarrier.scsBw = SCS_CARRIER_BANDWIDTH;
383 srvCellCfgComm->dlCfg.locAndBw = FREQ_LOC_BW;
385 /* Configuring PDCCH Config Common For SIB1 */
386 pdcchCfg.present = BWP_DownlinkCommon__pdcch_ConfigCommon_PR_setup;
387 pdcchCfg.ctrlRsrcSetZero = PDCCH_CTRL_RSRC_SET_ZERO;
388 pdcchCfg.searchSpcZero = PDCCH_SEARCH_SPACE_ZERO;
389 pdcchCfg.searchSpcId = PDCCH_SEARCH_SPACE_ID;
390 pdcchCfg.ctrlRsrcSetId = PDCCH_CTRL_RSRC_SET_ID;
391 pdcchCfg.monitorSlotPrdAndOffPresent = \
392 SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl1;
393 //pdcchCfg.monitorSlotPrdAndOff = \
394 SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl1;
395 pdcchCfg.monitorSymbolsInSlot[0] = 128;
396 pdcchCfg.monitorSymbolsInSlot[1] = 0;
397 pdcchCfg.numCandAggLvl1 = SearchSpace__nrofCandidates__aggregationLevel1_n8;
398 pdcchCfg.numCandAggLvl2 = SearchSpace__nrofCandidates__aggregationLevel2_n4;
399 pdcchCfg.numCandAggLvl4 = SearchSpace__nrofCandidates__aggregationLevel4_n2;
400 pdcchCfg.numCandAggLvl8 = SearchSpace__nrofCandidates__aggregationLevel8_n1;
401 pdcchCfg.numCandAggLvl16 = SearchSpace__nrofCandidates__aggregationLevel16_n0;
402 pdcchCfg.searchSpcType = SearchSpace__searchSpaceType_PR_common;
403 pdcchCfg.commSrchSpcDciFrmt = PDCCH_SERACH_SPACE_DCI_FORMAT;
404 pdcchCfg.searchSpcSib1 = PDCCH_SEARCH_SPACE_ID_SIB1;
405 pdcchCfg.pagingSearchSpc = PDCCH_SEARCH_SPACE_ID_PAGING;
406 pdcchCfg.raSearchSpc = PDCCH_SEARCH_SPACE_ID_PAGING;
407 srvCellCfgComm->dlCfg.pdcchCfg = pdcchCfg;
409 /* Configuring PDSCH Config Common For SIB1 */
410 pdschCfg.present = BWP_DownlinkCommon__pdsch_ConfigCommon_PR_setup;
411 pdschCfg.k0 = PDSCH_K0;
413 PDSCH_TimeDomainResourceAllocation__mappingType_typeA;
414 pdschCfg.sliv = calcSliv(PDSCH_START_SYMBOL,PDSCH_LENGTH_SYMBOL);
415 srvCellCfgComm->dlCfg.pdschCfg = pdschCfg;
417 /* Configuring BCCH Config for SIB1 */
418 srvCellCfgComm->dlCfg.bcchCfg.modPrdCoeff = \
419 BCCH_Config__modificationPeriodCoeff_n16;
421 /* Configuring PCCH Config for SIB1 */
422 pcchCfg.dfltPagingCycle = PagingCycle_rf64;
423 pcchCfg.nAndPagingFrmOffPresent = PCCH_Config__nAndPagingFrameOffset_PR_oneT;
424 pcchCfg.numPagingOcc = PCCH_Config__ns_four;
425 srvCellCfgComm->dlCfg.pcchCfg = pcchCfg;
428 /* Configuring UL Config Common */
429 srvCellCfgComm->ulCfg.ulScsCarrier.scsOffset = SSB_SUBCARRIER_OFFSET;
430 srvCellCfgComm->ulCfg.ulScsCarrier.scs = SUBCARRIER_SPACING;
431 srvCellCfgComm->ulCfg.ulScsCarrier.scsBw = SCS_CARRIER_BANDWIDTH;
432 srvCellCfgComm->ulCfg.pMax = UL_P_MAX;
433 srvCellCfgComm->ulCfg.locAndBw = FREQ_LOC_BW;
434 srvCellCfgComm->ulCfg.timeAlignTimerComm = TimeAlignmentTimer_infinity;
436 /* Configuring RACH Config Common for SIB1 */
437 rachCfg.present = BWP_UplinkCommon__rach_ConfigCommon_PR_setup;
438 rachCfg.prachCfgIdx = PRACH_CONFIG_IDX;
439 rachCfg.msg1Fdm = RACH_ConfigGeneric__msg1_FDM_one;
440 rachCfg.msg1FreqStart = PRACH_FREQ_START;
441 rachCfg.zeroCorrZoneCfg = ZERO_CORRELATION_ZONE_CFG;
442 rachCfg.preambleRcvdTgtPwr = PRACH_PREAMBLE_RCVD_TGT_PWR;
443 rachCfg.preambleTransMax = RACH_ConfigGeneric__preambleTransMax_n200;
444 rachCfg.pwrRampingStep = RACH_ConfigGeneric__powerRampingStep_dB2;
445 rachCfg.raRspWindow = RACH_ConfigGeneric__ra_ResponseWindow_sl20;
446 rachCfg.numRaPreamble = NUM_RA_PREAMBLE;
447 rachCfg.ssbPerRachOccPresent = \
448 RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_one;
449 rachCfg.numSsbPerRachOcc = SSB_PER_RACH;
450 rachCfg.contResTimer = RACH_ConfigCommon__ra_ContentionResolutionTimer_sf64;
451 rachCfg.rsrpThreshSsb = RSRP_THRESHOLD_SSB;
452 rachCfg.rootSeqIdxPresent = RACH_ConfigCommon__prach_RootSequenceIndex_PR_l139;
453 rachCfg.rootSeqIdx = ROOT_SEQ_IDX;
454 rachCfg.msg1Scs = PRACH_SUBCARRIER_SPACING ;
455 rachCfg.restrictedSetCfg = PRACH_RESTRICTED_SET_CFG;
456 srvCellCfgComm->ulCfg.rachCfg = rachCfg;
458 /* Configuring PUSCH Config Common for SIB1 */
459 puschCfg.present = BWP_UplinkCommon__pusch_ConfigCommon_PR_setup;
460 puschCfg.k2 = PUSCH_K2;
461 puschCfg.mapType = PUSCH_TimeDomainResourceAllocation__mappingType_typeA;
462 puschCfg.sliv = calcSliv(PUSCH_START_SYMBOL,PUSCH_LENGTH_SYMBOL);
463 puschCfg.msg3DeltaPreamble = PUSCH_MSG3_DELTA_PREAMBLE;
464 puschCfg.p0NominalWithGrant = PUSCH_P0_NOMINAL_WITH_GRANT;
465 srvCellCfgComm->ulCfg.puschCfg = puschCfg;
467 /* Configuring PUCCH Config Common for SIB1 */
468 pucchCfg.present = BWP_UplinkCommon__pucch_ConfigCommon_PR_setup;
469 pucchCfg.rsrcComm = PUCCH_RSRC_COMMON;
470 pucchCfg.grpHop = PUCCH_ConfigCommon__pucch_GroupHopping_neither;
471 pucchCfg.p0Nominal = PUCCH_P0_NOMINAL;
472 srvCellCfgComm->ulCfg.pucchCfg = pucchCfg;
474 /* Configuring TDD UL DL config common */
475 tddCfg.refScs = SubcarrierSpacing_kHz30;
476 tddCfg.txPrd = TDD_UL_DL_Pattern__dl_UL_TransmissionPeriodicity_ms2p5;
477 tddCfg.numDlSlots = NUM_DL_SLOTS;
478 tddCfg.numDlSymbols = NUM_DL_SYMBOLS;
479 tddCfg.numUlSlots = NUM_UL_SLOTS;
480 tddCfg.numUlSymbols = NUM_UL_SYMBOLS;
481 srvCellCfgComm->tddCfg = tddCfg;
483 srvCellCfgComm->ssbPosInBurst = 192;
484 srvCellCfgComm->ssbPrdServingCell = SSB_PERIODICITY_20MS;
485 srvCellCfgComm->ssPbchBlockPwr = SSB_PBCH_PWR;
490 /*******************************************************************
492 * @brief Configures the DU Parameters
499 * - Initializes the DuCfg members.
500 * - Calls readMacCfg()
502 * @params[in] system task ID
503 * @return ROK - success
506 * ****************************************************************/
511 U32 ipv4_du, ipv4_cu, ipv4_ric;
515 cmInetAddr((S8*)DU_IP_V4_ADDR, &ipv4_du);
516 cmInetAddr((S8*)CU_IP_V4_ADDR, &ipv4_cu);
517 cmInetAddr((S8*)RIC_IP_V4_ADDR, &ipv4_ric);
518 fillDuPort(duCfgParam.sctpParams.duPort);
520 /* F1 DU IP Address and Port*/
521 duCfgParam.sctpParams.duIpAddr.ipV4Addr = ipv4_du;
523 /* F1 CU IP Address and Port*/
524 duCfgParam.sctpParams.cuIpAddr.ipV4Addr = ipv4_cu;
525 duCfgParam.sctpParams.cuPort = CU_PORT;
527 /* Fill RIC Params */
528 duCfgParam.sctpParams.ricIpAddr.ipV4Addr = ipv4_ric;
529 duCfgParam.sctpParams.ricPort = RIC_PORT;
530 /* EGTP Parameters */
531 duCfgParam.egtpParams.localIp.ipV4Pres = TRUE;
532 duCfgParam.egtpParams.localIp.ipV4Addr = ipv4_du;
533 duCfgParam.egtpParams.localPort = DU_EGTP_PORT;
534 duCfgParam.egtpParams.destIp.ipV4Pres = TRUE;
535 duCfgParam.egtpParams.destIp.ipV4Addr = ipv4_cu;
536 duCfgParam.egtpParams.destPort = CU_EGTP_PORT;
537 duCfgParam.egtpParams.minTunnelId = 0;
538 duCfgParam.egtpParams.maxTunnelId = 10;
540 duCfgParam.maxUe = 32; //TODO: Check
542 duCfgParam.duId = DU_ID;
543 strcpy((char*)duCfgParam.duName,DU_NAME);
546 mib.sysFrmNum = SYS_FRAME_NUM;
547 mib.subCarrierSpacingCommon = MIB__subCarrierSpacingCommon_scs15or60;
548 mib.ssb_SubcarrierOffset = SSB_SC_OFFSET;
549 mib.dmrs_TypeA_Position = MIB__dmrs_TypeA_Position_pos2;
550 mib.controlResourceSetZero = CORESET_ZERO;
551 mib.searchSpaceZero = SEARCH_SPACE_ZERO;
552 mib.cellBarred = MIB__cellBarred_barred;
553 mib.intraFreqReselection =
554 MIB__intraFreqReselection_notAllowed;
555 duCfgParam.mibParams = mib;
558 sib1.plmn.mcc[0] = PLMN_MCC0;
559 sib1.plmn.mcc[1] = PLMN_MCC1;
560 sib1.plmn.mcc[2] = PLMN_MCC2;
561 sib1.plmn.mnc[0] = PLMN_MNC0;
562 sib1.plmn.mnc[1] = PLMN_MNC1;
563 sib1.plmn.mnc[2] = PLMN_MNC2;
565 sib1.ranac = DU_RANAC;
566 sib1.cellIdentity = CELL_IDENTITY;
567 sib1.cellResvdForOpUse =\
568 PLMN_IdentityInfo__cellReservedForOperatorUse_notReserved;
569 sib1.connEstFailCnt = ConnEstFailureControl__connEstFailCount_n3;
570 sib1.connEstFailOffValidity =\
571 ConnEstFailureControl__connEstFailOffsetValidity_s120;
572 sib1.siSchedInfo.winLen = SI_SchedulingInfo__si_WindowLength_s5;
573 sib1.siSchedInfo.broadcastSta = \
574 SchedulingInfo__si_BroadcastStatus_broadcasting;
575 sib1.siSchedInfo.preiodicity = SchedulingInfo__si_Periodicity_rf8;
576 sib1.siSchedInfo.sibType = SIB_TypeInfo__type_sibType2;
577 sib1.siSchedInfo.sibValTag = SIB1_VALUE_TAG;
579 fillServCellCfgCommSib(&sib1.srvCellCfgCommSib);
581 duCfgParam.sib1Params = sib1;
583 for(i=0; i<DEFAULT_CELLS; i++)
585 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.nrCgi.plmn.mcc[0] = PLMN_MCC0;
586 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.nrCgi.plmn.mcc[1] = PLMN_MCC1;
587 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.nrCgi.plmn.mcc[2] = PLMN_MCC2;
588 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.nrCgi.plmn.mnc[0] = PLMN_MNC0;
589 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.nrCgi.plmn.mnc[1] = PLMN_MNC1;
590 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.nrCgi.plmn.mnc[2] = PLMN_MNC2;
593 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.nrCgi.cellId = NR_CELL_ID;
594 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.nrPci = NR_PCI;
596 /* List of Available PLMN */
597 for(j=0;j<MAX_PLMN;j++)
599 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.plmn[j].mcc[0] = PLMN_MCC0;
600 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.plmn[j].mcc[1] = PLMN_MCC1;
601 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.plmn[j].mcc[2] = PLMN_MCC2;
602 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.plmn[j].mnc[0] = PLMN_MNC0;
603 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.plmn[j].mnc[1] = PLMN_MNC1;
604 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.plmn[j].mnc[2] = PLMN_MNC2;
606 /* List of Extended PLMN */
607 for(j=0;j<MAX_PLMN;j++)
609 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.extPlmn[j].mcc[0] = PLMN_MCC0;
610 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.extPlmn[j].mcc[1] = PLMN_MCC1;
611 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.extPlmn[j].mcc[2] = PLMN_MCC2;
612 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.extPlmn[j].mnc[0] = PLMN_MNC0;
613 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.extPlmn[j].mnc[1] = PLMN_MNC1;
614 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.extPlmn[j].mnc[2] = PLMN_MNC2;
618 duCfgParam.srvdCellLst[i].duCellInfo.tac = DU_TAC;
619 duCfgParam.srvdCellLst[i].duCellInfo.epsTac = DU_TAC; //to check and fill
621 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.nrArfcn = NR_ARFCN;
622 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.sulInfo.sulArfcn = SUL_ARFCN;
623 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.sulInfo.sulTxBw.nrScs = SCS_120;
624 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.sulInfo.sulTxBw.nrb = NRB_66;
628 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.nrArfcn = NR_ARFCN;
629 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.sulInfo.sulArfcn = SUL_ARFCN;
630 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.sulInfo.sulTxBw.nrScs = SCS_15;
631 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.sulInfo.sulTxBw.nrb = NRB_160;
633 for(j=0;j<MAXNRCELLBANDS;j++)
635 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.freqBand[j].nrFreqBand = NR_FREQ_BAND;
636 for(k=0;k<MAXNRCELLBANDS;k++)
638 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.freqBand[j].sulBand[k] = SUL_BAND;
642 for(j=0;j<MAXNRCELLBANDS;j++)
644 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.freqBand[j].nrFreqBand = NR_FREQ_BAND;
645 for(k=0;k<MAXNRCELLBANDS;k++)
647 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.freqBand[j].sulBand[k] = SUL_BAND;
650 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.nrArfcn = NR_ARFCN;
651 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.sulInfo.sulArfcn = SUL_ARFCN;
652 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.sulInfo.sulTxBw.nrScs = SCS_120;
653 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.sulInfo.sulTxBw.nrb = NRB_66;
654 for(j=0;j<MAXNRCELLBANDS;j++)
656 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.freqBand[j].nrFreqBand = NR_FREQ_BAND;
657 for(k=0;k<MAXNRCELLBANDS;k++)
659 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.freqBand[j].sulBand[k] = SUL_BAND;
663 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.ulTxBw.nrScs = SCS_120;
664 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.ulTxBw.nrb = NRB_66;
666 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.dlTxBw.nrScs = SCS_120;
667 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.dlTxBw.nrb = NRB_66;
670 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.tdd.nrTxBw.nrScs = SCS_15;
671 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.tdd.nrTxBw.nrb = NRB_160;
673 /*Measurement Config and Cell Config */
674 duCfgParam.srvdCellLst[i].duCellInfo.measTimeCfg = TIME_CFG;
676 duCfgParam.srvdCellLst[i].duCellInfo.cellDir = DL_UL;
678 duCfgParam.srvdCellLst[i].duCellInfo.cellType=CELL_TYPE;
680 /* Broadcast PLMN Identity */
681 for(j=0;j<MAXBPLMNNRMINUS1;j++)
683 for(k=0;k<MAX_PLMN;k++)
685 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].plmn[k].mcc[0] = PLMN_MCC0;
686 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].plmn[k].mcc[1] = PLMN_MCC1;
687 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].plmn[k].mcc[2] = PLMN_MCC2;
688 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].plmn[k].mnc[0] = PLMN_MNC0;
689 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].plmn[k].mnc[1] = PLMN_MNC1;
690 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].plmn[k].mnc[2] = PLMN_MNC2;
692 /* Extended PLMN List */
693 for(k=0;k<MAX_PLMN;k++)
695 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].extPlmn[k].mcc[0] = PLMN_MCC0;
696 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].extPlmn[k].mcc[1] = PLMN_MCC1;
697 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].extPlmn[k].mcc[2] = PLMN_MCC2;
698 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].extPlmn[k].mnc[0] = PLMN_MNC0;
699 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].extPlmn[k].mnc[1] = PLMN_MNC1;
700 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].extPlmn[k].mnc[2] = PLMN_MNC2;
703 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].tac = DU_TAC;
704 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].nrCellId = NR_CELL_ID;
705 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].ranac = NR_RANAC;
708 /*gnb DU System Info mib msg*/
710 DU_ALLOC(duCfgParam.srvdCellLst[i].duSysInfo.mibMsg,\
712 if(!(duCfgParam.srvdCellLst[i].duSysInfo.mibMsg))
714 DU_LOG("\nDU_APP: Memory allocation failure");
717 strcpy((char *)duCfgParam.srvdCellLst[i].duSysInfo.mibMsg, encBuf);
718 duCfgParam.srvdCellLst[i].duSysInfo.mibLen = encBufSize;
720 /*gnb DU System Info mib msg*/
722 DU_ALLOC(duCfgParam.srvdCellLst[i].duSysInfo.sib1Msg,\
724 if(!(duCfgParam.srvdCellLst[i].duSysInfo.sib1Msg))
726 DU_LOG("\nDU_APP: Memory allocation failure");
729 memcpy(duCfgParam.srvdCellLst[i].duSysInfo.sib1Msg,\
731 duCfgParam.srvdCellLst[i].duSysInfo.sib1Len = encBufSize;
735 if(readMacCfg() != ROK)
737 DU_LOG("\nDU_APP : Failed while reading MAC config");
744 /*******************************************************************
746 * @brief Reads config and posts message to du_app on completion
754 * - Post to du_app for further processing
757 * @return ROK - success
760 * ****************************************************************/
766 cmMemset((U8 *)&duCfgParam, 0, sizeof(DuCfgParams));
767 //Read configs into duCfgParams
770 DU_LOG("\nDU_APP : Reading configuration failed");
775 cmMemset((U8 *)&(pst), 0, sizeof(Pst));
776 pst.srcEnt = (Ent)ENTDUAPP;
777 pst.srcInst = (Inst)DU_INST;
778 pst.srcProcId = DU_PROC;
779 pst.dstEnt = pst.srcEnt;
780 pst.dstInst = pst.srcInst;
781 pst.dstProcId = pst.srcProcId;
783 pst.selector = ODU_SELECTOR_TC;
787 if(SGetMsg(DFLT_REGION, DU_POOL, &mBuf) != ROK)
789 DU_LOG("\nDU_APP : Memory allocation failed in duReadCfg");
793 if (SPstTsk(&pst, mBuf) != ROK)
795 DU_LOG("\nDU_APP : SPstTsk failed in duReadCfg");
802 /*******************************************************************
804 * @brief Converts bit strings to integer
808 * Function : bitStringToInt
811 * - Converts ASN bit string format IEs to integer type
814 * @return ROK - success
817 * ****************************************************************/
818 S16 bitStringToInt(BIT_STRING_t *bitString, U16 *val)
821 if(bitString->buf == NULL || bitString->size <= 0)
823 DU_LOG("\nDU_APP : Bit string is empty");
827 for(idx=0; idx< bitString->size-1; idx++)
829 *val |= bitString->buf[idx];
833 *val |= bitString->buf[idx];
834 *val >>= bitString->bits_unused;
840 /**********************************************************************
842 **********************************************************************/