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 */
21 #include "du_sys_info_hdl.h"
23 #include "SearchSpace.h"
24 #include "SIB-TypeInfo.h"
25 #include "SchedulingInfo.h"
26 #include "SI-SchedulingInfo.h"
27 #include "ConnEstFailureControl.h"
28 #include "PLMN-IdentityInfo.h"
29 #include "odu_common_codec.h"
30 #include "PDSCH-TimeDomainResourceAllocation.h"
31 #include "BCCH-Config.h"
32 #include "PagingCycle.h"
33 #include "PCCH-Config.h"
34 #include "TimeAlignmentTimer.h"
35 #include "RACH-ConfigGeneric.h"
36 #include "PUSCH-TimeDomainResourceAllocation.h"
37 #include "PUCCH-ConfigCommon.h"
38 #include "SubcarrierSpacing.h"
39 #include "TDD-UL-DL-Pattern.h"
40 #include "RACH-ConfigCommon.h"
41 #include "BWP-DownlinkCommon.h"
42 #include "BWP-UplinkCommon.h"
44 extern DuCfgParams duCfgParam;
45 extern char encBuf[ENC_BUF_MAX_LEN];
48 /* Filling Slot configuration as :
49 * 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
50 * 0 DL DL DL DL DL DL DL DL DL DL DL DL DL DL
51 * 1 DL DL DL DL DL DL DL DL DL DL DL DL DL DL
52 * 2 DL DL DL DL DL DL DL DL DL DL DL DL DL DL
53 * 3 DL DL DL DL DL DL DL DL DL DL GD GD GD UL
54 * 4 UL UL UL UL UL UL UL UL UL UL UL UL UL UL
57 /*******************************************************************
59 * @brief Fills the Slot configuration
63 * Function : FillSlotConfig
65 * Functionality:Fill the Slot configuration values
68 * @return ROK - success
71 * ****************************************************************/
77 for(slot = 0; slot <= 3; slot++)
79 for(symbol = 0; symbol < MAX_SYMB_PER_SLOT; symbol++)
80 duCfgParam.macCellCfg.tddCfg.slotCfg[slot][symbol] = DL_SLOT;
83 duCfgParam.macCellCfg.tddCfg.slotCfg[3][10] = GUARD_SLOT;
84 duCfgParam.macCellCfg.tddCfg.slotCfg[3][11] = GUARD_SLOT;
85 duCfgParam.macCellCfg.tddCfg.slotCfg[3][12] = GUARD_SLOT;
86 duCfgParam.macCellCfg.tddCfg.slotCfg[3][13] = UL_SLOT;
88 for(symbol = 0; symbol < MAX_SYMB_PER_SLOT; symbol++)
89 duCfgParam.macCellCfg.tddCfg.slotCfg[4][symbol] = UL_SLOT;
93 /*******************************************************************
95 * @brief Reads the CL Configuration.
99 * Function : readMacCfg
102 * - Fills up the cell configuration for CL.
103 * - Calls FillSlotConfig()
106 * @return ROK - success
109 * ****************************************************************/
112 /* This function is used to fill up the cell configuration for CL */
115 duCfgParam.macCellCfg.carrierId = CARRIER_IDX;
117 /* Cell configuration */
118 duCfgParam.macCellCfg.cellId = NR_CELL_ID;
119 duCfgParam.macCellCfg.phyCellId = NR_PCI;
120 duCfgParam.macCellCfg.dupType = DUPLEX_MODE;
122 /* DL carrier configuration */
123 duCfgParam.macCellCfg.dlCarrCfg.pres = TRUE;
124 duCfgParam.macCellCfg.dlCarrCfg.bw = BANDWIDTH;
125 duCfgParam.macCellCfg.dlCarrCfg.freq = NR_ARFCN;
126 duCfgParam.macCellCfg.dlCarrCfg.k0[0] = 1;
127 duCfgParam.macCellCfg.dlCarrCfg.k0[1] = 1;
128 duCfgParam.macCellCfg.dlCarrCfg.k0[2] = 1;
129 duCfgParam.macCellCfg.dlCarrCfg.k0[3] = 1;
130 duCfgParam.macCellCfg.dlCarrCfg.k0[4] = 1;
131 duCfgParam.macCellCfg.dlCarrCfg.gridSize[0] = 1;
132 duCfgParam.macCellCfg.dlCarrCfg.gridSize[1] = 1;
133 duCfgParam.macCellCfg.dlCarrCfg.gridSize[2] = 1;
134 duCfgParam.macCellCfg.dlCarrCfg.gridSize[3] = 1;
135 duCfgParam.macCellCfg.dlCarrCfg.gridSize[4] = 1;
136 duCfgParam.macCellCfg.dlCarrCfg.numAnt = NUM_TX_ANT;
138 /* UL Carrier configuration */
139 duCfgParam.macCellCfg.ulCarrCfg.pres = TRUE;
140 duCfgParam.macCellCfg.ulCarrCfg.bw = SUL_ARFCN;
141 duCfgParam.macCellCfg.ulCarrCfg.freq = NR_ARFCN;
142 duCfgParam.macCellCfg.ulCarrCfg.k0[0] = 1;
143 duCfgParam.macCellCfg.ulCarrCfg.k0[1] = 1;
144 duCfgParam.macCellCfg.ulCarrCfg.k0[2] = 1;
145 duCfgParam.macCellCfg.ulCarrCfg.k0[3] = 1;
146 duCfgParam.macCellCfg.ulCarrCfg.k0[4] = 1;
147 duCfgParam.macCellCfg.ulCarrCfg.gridSize[0] = 1;
148 duCfgParam.macCellCfg.ulCarrCfg.gridSize[1] = 1;
149 duCfgParam.macCellCfg.ulCarrCfg.gridSize[2] = 1;
150 duCfgParam.macCellCfg.ulCarrCfg.gridSize[3] = 1;
151 duCfgParam.macCellCfg.ulCarrCfg.gridSize[4] = 1;
152 duCfgParam.macCellCfg.ulCarrCfg.numAnt = NUM_RX_ANT;
154 duCfgParam.macCellCfg.freqShft = FREQ_SHIFT_7P5KHZ;
156 /* SSB configuration */
157 duCfgParam.macCellCfg.ssbCfg.ssbPbchPwr = SSB_PBCH_PWR;
158 duCfgParam.macCellCfg.ssbCfg.bchPayloadFlag = BCH_PAYLOAD;
159 duCfgParam.macCellCfg.ssbCfg.scsCmn = SUBCARRIER_SPACING;
160 duCfgParam.macCellCfg.ssbCfg.ssbOffsetPointA = OFFSET_TO_POINT_A;
161 duCfgParam.macCellCfg.ssbCfg.betaPss = BETA_PSS;
162 duCfgParam.macCellCfg.ssbCfg.ssbPeriod = SSB_PERIODICITY;
163 duCfgParam.macCellCfg.ssbCfg.ssbScOffset = SSB_SUBCARRIER_OFFSET;
164 duCfgParam.macCellCfg.ssbCfg.ssbMask[0] = 1; /* only one SSB is transmitted */
165 duCfgParam.macCellCfg.ssbCfg.ssbMask[1] = 0;
166 if(BuildMibPdu() != ROK)
168 DU_LOG("\nFailed to build MIB PDU");
169 memset(&duCfgParam.macCellCfg.ssbCfg.mibPdu, 0, 3*sizeof(uint8_t));
173 for(uint8_t idx=0; idx<encBufSize; idx++)
175 duCfgParam.macCellCfg.ssbCfg.mibPdu[idx]=encBuf[idx];
178 duCfgParam.macCellCfg.ssbCfg.multCarrBand = SSB_MULT_CARRIER_BAND;
179 duCfgParam.macCellCfg.ssbCfg.multCellCarr = MULT_CELL_CARRIER;
181 /* PRACH configuration */
182 duCfgParam.macCellCfg.prachCfg.pres = TRUE;
183 duCfgParam.macCellCfg.prachCfg.prachCfgIdx = PRACH_CONFIG_IDX;
184 duCfgParam.macCellCfg.prachCfg.prachSeqLen = PRACH_SEQ_LEN;
185 duCfgParam.macCellCfg.prachCfg.prachSubcSpacing = PRACH_SUBCARRIER_SPACING;
186 duCfgParam.macCellCfg.prachCfg.prachRstSetCfg = PRACH_RESTRICTED_SET_CFG;
187 duCfgParam.macCellCfg.prachCfg.msg1Fdm = NUM_PRACH_FDM;
188 duCfgParam.macCellCfg.prachCfg.msg1FreqStart = PRACH_FREQ_START;
189 duCfgParam.macCellCfg.prachCfg.fdm[0].rootSeqIdx = ROOT_SEQ_IDX;
190 duCfgParam.macCellCfg.prachCfg.fdm[0].numRootSeq = NUM_ROOT_SEQ;
191 duCfgParam.macCellCfg.prachCfg.fdm[0].k1 = 1;
192 duCfgParam.macCellCfg.prachCfg.fdm[0].zeroCorrZoneCfg = ZERO_CORRELATION_ZONE_CFG;
193 duCfgParam.macCellCfg.prachCfg.fdm[0].numUnusedRootSeq = NUM_UNUSED_ROOT_SEQ;
194 if(duCfgParam.macCellCfg.prachCfg.fdm[0].numUnusedRootSeq != 0)
196 DU_ALLOC(duCfgParam.macCellCfg.prachCfg.fdm[0].unsuedRootSeq,
197 NUM_UNUSED_ROOT_SEQ * sizeof(U8));
198 if(duCfgParam.macCellCfg.prachCfg.fdm[0].unsuedRootSeq == NULLP)
200 DU_LOG("\nDU_APP : Memory allocation failed");
203 *(duCfgParam.macCellCfg.prachCfg.fdm[0].unsuedRootSeq) = UNUSED_ROOT_SEQ;
205 duCfgParam.macCellCfg.prachCfg.ssbPerRach = SSB_PER_RACH;
206 duCfgParam.macCellCfg.prachCfg.prachMultCarrBand = PRACH_MULT_CARRIER_BAND;
207 duCfgParam.macCellCfg.prachCfg.raContResTmr = RA_CONT_RES_TIMER;
208 duCfgParam.macCellCfg.prachCfg.rsrpThreshSsb = RSRP_THRESHOLD_SSB;
209 duCfgParam.macCellCfg.prachCfg.raRspWindow = RA_RSP_WINDOW;
210 duCfgParam.macCellCfg.prachCfg.prachRestrictedSet = PRACH_RESTRICTED_SET;
211 /* TDD configuration */
212 duCfgParam.macCellCfg.tddCfg.pres = TRUE;
213 duCfgParam.macCellCfg.tddCfg.tddPeriod = TDD_PERIODICITY;
217 /* RSSI Measurement configuration */
218 duCfgParam.macCellCfg.rssiUnit = RSS_MEASUREMENT_UNIT;
220 /* fill SIB1 configuration */
221 duCfgParam.macCellCfg.sib1Cfg.sib1PduLen = duCfgParam.srvdCellLst[0].duSysInfo.sib1Len;
222 DU_ALLOC(duCfgParam.macCellCfg.sib1Cfg.sib1Pdu,duCfgParam.srvdCellLst[0].duSysInfo.sib1Len);
223 memcpy(duCfgParam.macCellCfg.sib1Cfg.sib1Pdu, duCfgParam.srvdCellLst[0].duSysInfo.sib1Msg, \
224 duCfgParam.srvdCellLst[0].duSysInfo.sib1Len);
225 duCfgParam.macCellCfg.sib1Cfg.sib1NewTxPeriod = SIB1_NEW_TX_PERIOD;
226 duCfgParam.macCellCfg.sib1Cfg.sib1RepetitionPeriod = SIB1_REPETITION_PERIOD;
227 duCfgParam.macCellCfg.sib1Cfg.coresetZeroIndex = CORESET_0_INDEX;
228 duCfgParam.macCellCfg.sib1Cfg.searchSpaceZeroIndex = SEARCHSPACE_0_INDEX;
229 duCfgParam.macCellCfg.sib1Cfg.sib1Mcs = SIB1_MCS;
232 /* fill Intial DL BWP */
233 duCfgParam.macCellCfg.initialDlBwp.bwp.firstPrb = 0;
234 duCfgParam.macCellCfg.initialDlBwp.bwp.numPrb = TOTAL_PRB_BW; /* configured to total BW */
235 duCfgParam.macCellCfg.initialDlBwp.bwp.scs = SUBCARRIER_SPACING; /* numerology is 0, 15Khz */
236 duCfgParam.macCellCfg.initialDlBwp.bwp.cyclicPrefix = NORMAL_CYCLIC_PREFIX;
237 duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.raSearchSpace.searchSpaceId = SEARCHSPACE_1_INDEX;
238 duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.raSearchSpace.coresetId = CORESET_0_INDEX;
239 duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.raSearchSpace.monitoringSlot =
240 SS_MONITORING_SLOT_SL1; /* sl1 - all slots */
241 duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.raSearchSpace.duration = 0;
242 duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.raSearchSpace.monitoringSymbol =
243 SS_MONITORING_SYMBOL;
244 duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.raSearchSpace.
245 candidate.aggLevel1 = 8;
246 duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.raSearchSpace.
247 candidate.aggLevel2 = 4;
248 duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.raSearchSpace.
249 candidate.aggLevel4 = 2;
250 duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.raSearchSpace.
251 candidate.aggLevel8 = 1;
252 duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.raSearchSpace.
253 candidate.aggLevel16 = 0;
254 duCfgParam.macCellCfg.initialDlBwp.pdschCommon.k0 = PDSCH_K0;
255 duCfgParam.macCellCfg.initialDlBwp.pdschCommon.mappingType =
256 PDSCH_MAPPING_TYPE_A;
257 duCfgParam.macCellCfg.initialDlBwp.pdschCommon.startSymbol =
259 duCfgParam.macCellCfg.initialDlBwp.pdschCommon.lengthSymbol =
262 /* fill Intial DL BWP */
263 duCfgParam.macCellCfg.initialUlBwp.bwp.firstPrb = 0;
264 duCfgParam.macCellCfg.initialUlBwp.bwp.numPrb = TOTAL_PRB_BW; /* configured to total BW */
265 duCfgParam.macCellCfg.initialUlBwp.bwp.scs = SUBCARRIER_SPACING; /* numerology is 0, 15Khz */
266 duCfgParam.macCellCfg.initialUlBwp.bwp.cyclicPrefix = NORMAL_CYCLIC_PREFIX;
267 duCfgParam.macCellCfg.initialUlBwp.puschCommon.k2 = PUSCH_K2;
268 duCfgParam.macCellCfg.initialUlBwp.puschCommon.mappingType =
269 PUSCH_MAPPING_TYPE_A;
270 duCfgParam.macCellCfg.initialUlBwp.puschCommon.startSymbol =
272 duCfgParam.macCellCfg.initialUlBwp.puschCommon.lengthSymbol =
276 /* This should be calculated based on
277 (number of mandatory parameters) + (number of otional parameters being filled) */
278 duCfgParam.macCellCfg.numTlv = 39;
283 /*******************************************************************
285 * @brief Configures the DU Parameters
289 * Function : fillDuPort
292 * - fills the DU Ports.
294 * @params[in] duPort array to be filled
295 * @return ROK - success
298 * ****************************************************************/
299 S16 fillDuPort(U16 *duPort)
301 duPort[F1_INTERFACE] = DU_PORT; /* DU Port idx 0 38472 */
302 duPort[E2_INTERFACE] = RIC_PORT; /* RIC Port idx 1 38482 */
307 /*******************************************************************
309 * @brief Configures the DU Parameters
313 * Function : calcSliv
316 * - calculate SLIV value from start and length field
318 * @params[in] start symbol
319 * @params[in] length of symbols
322 * ****************************************************************/
323 uint16_t calcSliv(uint8_t startSymbol, uint8_t lengthSymbol)
326 if((lengthSymbol-1) <= 7)
328 sliv = 14 * (lengthSymbol-1) + startSymbol;
332 sliv = 14 * (14-lengthSymbol+1) + (14-1-startSymbol);
338 /*******************************************************************
340 * @brief Configures serving cell config common in sib1
344 * Function : fillServCellCfgCommSib
347 * - fills Serving cell config common for SIB1
349 * @params[in] SrvCellCfgCommSib pointer
350 * @return ROK - success
353 ** ****************************************************************/
354 S16 fillServCellCfgCommSib(SrvCellCfgCommSib *srvCellCfgComm)
356 PdcchCfgCommon pdcchCfg;
357 PdschCfgCommon pdschCfg;
359 RachCfgCommon rachCfg;
360 PuschCfgCommon puschCfg;
361 PucchCfgCommon pucchCfg;
362 TddUlDlCfgCommon tddCfg;
364 /* Configuring DL Config Common for SIB1*/
365 srvCellCfgComm->dlCfg.freqBandInd = NR_FREQ_BAND_IND;
366 srvCellCfgComm->dlCfg.offsetToPointA = OFFSET_TO_POINT_A;
367 srvCellCfgComm->dlCfg.dlScsCarrier.scsOffset = SSB_SUBCARRIER_OFFSET;
368 srvCellCfgComm->dlCfg.dlScsCarrier.scs = SUBCARRIER_SPACING;
369 srvCellCfgComm->dlCfg.dlScsCarrier.scsBw = SCS_CARRIER_BANDWIDTH;
370 srvCellCfgComm->dlCfg.locAndBw = FREQ_LOC_BW;
372 /* Configuring PDCCH Config Common For SIB1 */
373 pdcchCfg.present = BWP_DownlinkCommon__pdcch_ConfigCommon_PR_setup;
374 pdcchCfg.ctrlRsrcSetZero = PDCCH_CTRL_RSRC_SET_ZERO;
375 pdcchCfg.searchSpcZero = PDCCH_SEARCH_SPACE_ZERO;
376 pdcchCfg.searchSpcId = PDCCH_SEARCH_SPACE_ID;
377 pdcchCfg.ctrlRsrcSetId = PDCCH_CTRL_RSRC_SET_ID;
378 pdcchCfg.monitorSlotPrdAndOffPresent = \
379 SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl1;
380 //pdcchCfg.monitorSlotPrdAndOff = \
381 SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl1;
382 pdcchCfg.monitorSymbolsInSlot[0] = 128;
383 pdcchCfg.monitorSymbolsInSlot[1] = 0;
384 pdcchCfg.numCandAggLvl1 = SearchSpace__nrofCandidates__aggregationLevel1_n8;
385 pdcchCfg.numCandAggLvl2 = SearchSpace__nrofCandidates__aggregationLevel2_n4;
386 pdcchCfg.numCandAggLvl4 = SearchSpace__nrofCandidates__aggregationLevel4_n2;
387 pdcchCfg.numCandAggLvl8 = SearchSpace__nrofCandidates__aggregationLevel8_n1;
388 pdcchCfg.numCandAggLvl16 = SearchSpace__nrofCandidates__aggregationLevel16_n0;
389 pdcchCfg.searchSpcType = SearchSpace__searchSpaceType_PR_common;
390 pdcchCfg.commSrchSpcDciFrmt = PDCCH_SERACH_SPACE_DCI_FORMAT;
391 pdcchCfg.searchSpcSib1 = PDCCH_SEARCH_SPACE_ID_SIB1;
392 pdcchCfg.pagingSearchSpc = PDCCH_SEARCH_SPACE_ID_PAGING;
393 pdcchCfg.raSearchSpc = PDCCH_SEARCH_SPACE_ID_PAGING;
394 srvCellCfgComm->dlCfg.pdcchCfg = pdcchCfg;
396 /* Configuring PDSCH Config Common For SIB1 */
397 pdschCfg.present = BWP_DownlinkCommon__pdsch_ConfigCommon_PR_setup;
398 pdschCfg.k0 = PDSCH_K0;
400 PDSCH_TimeDomainResourceAllocation__mappingType_typeA;
401 pdschCfg.sliv = calcSliv(PDSCH_START_SYMBOL,PDSCH_LENGTH_SYMBOL);
402 srvCellCfgComm->dlCfg.pdschCfg = pdschCfg;
404 /* Configuring BCCH Config for SIB1 */
405 srvCellCfgComm->dlCfg.bcchCfg.modPrdCoeff = \
406 BCCH_Config__modificationPeriodCoeff_n16;
408 /* Configuring PCCH Config for SIB1 */
409 pcchCfg.dfltPagingCycle = PagingCycle_rf64;
410 pcchCfg.nAndPagingFrmOffPresent = PCCH_Config__nAndPagingFrameOffset_PR_oneT;
411 pcchCfg.numPagingOcc = PCCH_Config__ns_four;
412 srvCellCfgComm->dlCfg.pcchCfg = pcchCfg;
415 /* Configuring UL Config Common */
416 srvCellCfgComm->ulCfg.ulScsCarrier.scsOffset = SSB_SUBCARRIER_OFFSET;
417 srvCellCfgComm->ulCfg.ulScsCarrier.scs = SUBCARRIER_SPACING;
418 srvCellCfgComm->ulCfg.ulScsCarrier.scsBw = SCS_CARRIER_BANDWIDTH;
419 srvCellCfgComm->ulCfg.pMax = UL_P_MAX;
420 srvCellCfgComm->ulCfg.locAndBw = FREQ_LOC_BW;
421 srvCellCfgComm->ulCfg.timeAlignTimerComm = TimeAlignmentTimer_infinity;
423 /* Configuring RACH Config Common for SIB1 */
424 rachCfg.present = BWP_UplinkCommon__rach_ConfigCommon_PR_setup;
425 rachCfg.prachCfgIdx = PRACH_CONFIG_IDX;
426 rachCfg.msg1Fdm = RACH_ConfigGeneric__msg1_FDM_one;
427 rachCfg.msg1FreqStart = PRACH_FREQ_START;
428 rachCfg.zeroCorrZoneCfg = ZERO_CORRELATION_ZONE_CFG;
429 rachCfg.preambleRcvdTgtPwr = PRACH_PREAMBLE_RCVD_TGT_PWR;
430 rachCfg.preambleTransMax = RACH_ConfigGeneric__preambleTransMax_n200;
431 rachCfg.pwrRampingStep = RACH_ConfigGeneric__powerRampingStep_dB2;
432 rachCfg.raRspWindow = RACH_ConfigGeneric__ra_ResponseWindow_sl20;
433 rachCfg.numRaPreamble = NUM_RA_PREAMBLE;
434 rachCfg.ssbPerRachOccPresent = \
435 RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_one;
436 rachCfg.numSsbPerRachOcc = SSB_PER_RACH;
437 rachCfg.contResTimer = RACH_ConfigCommon__ra_ContentionResolutionTimer_sf64;
438 rachCfg.rsrpThreshSsb = RSRP_THRESHOLD_SSB;
439 rachCfg.rootSeqIdxPresent = RACH_ConfigCommon__prach_RootSequenceIndex_PR_l139;
440 rachCfg.rootSeqIdx = ROOT_SEQ_IDX;
441 rachCfg.msg1Scs = PRACH_SUBCARRIER_SPACING ;
442 rachCfg.restrictedSetCfg = PRACH_RESTRICTED_SET_CFG;
443 srvCellCfgComm->ulCfg.rachCfg = rachCfg;
445 /* Configuring PUSCH Config Common for SIB1 */
446 puschCfg.present = BWP_UplinkCommon__pusch_ConfigCommon_PR_setup;
447 puschCfg.k2 = PUSCH_K2;
448 puschCfg.mapType = PUSCH_TimeDomainResourceAllocation__mappingType_typeA;
449 puschCfg.sliv = calcSliv(PUSCH_START_SYMBOL,PUSCH_LENGTH_SYMBOL);
450 puschCfg.msg3DeltaPreamble = PUSCH_MSG3_DELTA_PREAMBLE;
451 puschCfg.p0NominalWithGrant = PUSCH_P0_NOMINAL_WITH_GRANT;
452 srvCellCfgComm->ulCfg.puschCfg = puschCfg;
454 /* Configuring PUCCH Config Common for SIB1 */
455 pucchCfg.present = BWP_UplinkCommon__pucch_ConfigCommon_PR_setup;
456 pucchCfg.rsrcComm = PUCCH_RSRC_COMMON;
457 pucchCfg.grpHop = PUCCH_ConfigCommon__pucch_GroupHopping_neither;
458 pucchCfg.p0Nominal = PUCCH_P0_NOMINAL;
459 srvCellCfgComm->ulCfg.pucchCfg = pucchCfg;
461 /* Configuring TDD UL DL config common */
462 tddCfg.refScs = SubcarrierSpacing_kHz30;
463 tddCfg.txPrd = TDD_UL_DL_Pattern__dl_UL_TransmissionPeriodicity_ms2p5;
464 tddCfg.numDlSlots = NUM_DL_SLOTS;
465 tddCfg.numDlSymbols = NUM_DL_SYMBOLS;
466 tddCfg.numUlSlots = NUM_UL_SLOTS;
467 tddCfg.numUlSymbols = NUM_UL_SYMBOLS;
468 srvCellCfgComm->tddCfg = tddCfg;
470 srvCellCfgComm->ssbPosInBurst = 192;
471 srvCellCfgComm->ssbPrdServingCell = SSB_PERIODICITY;
472 srvCellCfgComm->ssPbchBlockPwr = SSB_PBCH_PWR;
477 /*******************************************************************
479 * @brief Configures the DU Parameters
486 * - Initializes the DuCfg members.
487 * - Calls readMacCfg()
489 * @params[in] system task ID
490 * @return ROK - success
493 * ****************************************************************/
498 U32 ipv4_du, ipv4_cu, ipv4_ric;
502 cmInetAddr((S8*)DU_IP_V4_ADDR, &ipv4_du);
503 cmInetAddr((S8*)CU_IP_V4_ADDR, &ipv4_cu);
504 cmInetAddr((S8*)RIC_IP_V4_ADDR, &ipv4_ric);
505 fillDuPort(duCfgParam.sctpParams.duPort);
507 /* F1 DU IP Address and Port*/
508 duCfgParam.sctpParams.duIpAddr.ipV4Addr = ipv4_du;
510 /* F1 CU IP Address and Port*/
511 duCfgParam.sctpParams.cuIpAddr.ipV4Addr = ipv4_cu;
512 duCfgParam.sctpParams.cuPort = CU_PORT;
514 /* Fill RIC Params */
515 duCfgParam.sctpParams.ricIpAddr.ipV4Addr = ipv4_ric;
516 duCfgParam.sctpParams.ricPort = RIC_PORT;
517 /* EGTP Parameters */
518 duCfgParam.egtpParams.localIp.ipV4Pres = TRUE;
519 duCfgParam.egtpParams.localIp.ipV4Addr = ipv4_du;
520 duCfgParam.egtpParams.localPort = DU_EGTP_PORT;
521 duCfgParam.egtpParams.destIp.ipV4Pres = TRUE;
522 duCfgParam.egtpParams.destIp.ipV4Addr = ipv4_cu;
523 duCfgParam.egtpParams.destPort = CU_EGTP_PORT;
524 duCfgParam.egtpParams.minTunnelId = 0;
525 duCfgParam.egtpParams.maxTunnelId = 10;
527 duCfgParam.maxUe = 32; //TODO: Check
529 duCfgParam.duId = DU_ID;
530 strcpy((char*)duCfgParam.duName,DU_NAME);
533 mib.sysFrmNum = SYS_FRAME_NUM;
534 mib.subCarrierSpacingCommon = MIB__subCarrierSpacingCommon_scs15or60;
535 mib.ssb_SubcarrierOffset = SSB_SC_OFFSET;
536 mib.dmrs_TypeA_Position = MIB__dmrs_TypeA_Position_pos2;
537 mib.controlResourceSetZero = CORESET_ZERO;
538 mib.searchSpaceZero = SEARCH_SPACE_ZERO;
539 mib.cellBarred = MIB__cellBarred_barred;
540 mib.intraFreqReselection =
541 MIB__intraFreqReselection_notAllowed;
542 duCfgParam.mibParams = mib;
545 sib1.plmn.mcc[0] = PLMN_MCC0;
546 sib1.plmn.mcc[1] = PLMN_MCC1;
547 sib1.plmn.mcc[2] = PLMN_MCC2;
548 sib1.plmn.mnc[0] = PLMN_MNC0;
549 sib1.plmn.mnc[1] = PLMN_MNC1;
550 sib1.plmn.mnc[2] = PLMN_MNC2;
552 sib1.ranac = DU_RANAC;
553 sib1.cellIdentity = CELL_IDENTITY;
554 sib1.cellResvdForOpUse =\
555 PLMN_IdentityInfo__cellReservedForOperatorUse_notReserved;
556 sib1.connEstFailCnt = ConnEstFailureControl__connEstFailCount_n3;
557 sib1.connEstFailOffValidity =\
558 ConnEstFailureControl__connEstFailOffsetValidity_s120;
559 sib1.siSchedInfo.winLen = SI_SchedulingInfo__si_WindowLength_s5;
560 sib1.siSchedInfo.broadcastSta = \
561 SchedulingInfo__si_BroadcastStatus_broadcasting;
562 sib1.siSchedInfo.preiodicity = SchedulingInfo__si_Periodicity_rf8;
563 sib1.siSchedInfo.sibType = SIB_TypeInfo__type_sibType2;
564 sib1.siSchedInfo.sibValTag = SIB1_VALUE_TAG;
566 fillServCellCfgCommSib(&sib1.srvCellCfgCommSib);
568 duCfgParam.sib1Params = sib1;
570 for(i=0; i<DEFAULT_CELLS; i++)
572 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.nrCgi.plmn.mcc[0] = PLMN_MCC0;
573 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.nrCgi.plmn.mcc[1] = PLMN_MCC1;
574 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.nrCgi.plmn.mcc[2] = PLMN_MCC2;
575 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.nrCgi.plmn.mnc[0] = PLMN_MNC0;
576 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.nrCgi.plmn.mnc[1] = PLMN_MNC1;
577 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.nrCgi.plmn.mnc[2] = PLMN_MNC2;
580 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.nrCgi.cellId = NR_CELL_ID;
581 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.nrPci = NR_PCI;
583 /* List of Available PLMN */
584 for(j=0;j<MAX_PLMN;j++)
586 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.plmn[j].mcc[0] = PLMN_MCC0;
587 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.plmn[j].mcc[1] = PLMN_MCC1;
588 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.plmn[j].mcc[2] = PLMN_MCC2;
589 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.plmn[j].mnc[0] = PLMN_MNC0;
590 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.plmn[j].mnc[1] = PLMN_MNC1;
591 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.plmn[j].mnc[2] = PLMN_MNC2;
593 /* List of Extended PLMN */
594 for(j=0;j<MAX_PLMN;j++)
596 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.extPlmn[j].mcc[0] = PLMN_MCC0;
597 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.extPlmn[j].mcc[1] = PLMN_MCC1;
598 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.extPlmn[j].mcc[2] = PLMN_MCC2;
599 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.extPlmn[j].mnc[0] = PLMN_MNC0;
600 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.extPlmn[j].mnc[1] = PLMN_MNC1;
601 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.extPlmn[j].mnc[2] = PLMN_MNC2;
605 duCfgParam.srvdCellLst[i].duCellInfo.tac = DU_TAC;
606 duCfgParam.srvdCellLst[i].duCellInfo.epsTac = DU_TAC; //to check and fill
608 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.nrArfcn = NR_ARFCN;
609 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.sulInfo.sulArfcn = SUL_ARFCN;
610 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.sulInfo.sulTxBw.nrScs = SCS_120;
611 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.sulInfo.sulTxBw.nrb = NRB_66;
615 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.nrArfcn = NR_ARFCN;
616 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.sulInfo.sulArfcn = SUL_ARFCN;
617 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.sulInfo.sulTxBw.nrScs = SCS_15;
618 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.sulInfo.sulTxBw.nrb = NRB_160;
620 for(j=0;j<MAXNRCELLBANDS;j++)
622 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.freqBand[j].nrFreqBand = NR_FREQ_BAND;
623 for(k=0;k<MAXNRCELLBANDS;k++)
625 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.freqBand[j].sulBand[k] = SUL_BAND;
629 for(j=0;j<MAXNRCELLBANDS;j++)
631 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.freqBand[j].nrFreqBand = NR_FREQ_BAND;
632 for(k=0;k<MAXNRCELLBANDS;k++)
634 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.freqBand[j].sulBand[k] = SUL_BAND;
637 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.nrArfcn = NR_ARFCN;
638 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.sulInfo.sulArfcn = SUL_ARFCN;
639 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.sulInfo.sulTxBw.nrScs = SCS_120;
640 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.sulInfo.sulTxBw.nrb = NRB_66;
641 for(j=0;j<MAXNRCELLBANDS;j++)
643 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.freqBand[j].nrFreqBand = NR_FREQ_BAND;
644 for(k=0;k<MAXNRCELLBANDS;k++)
646 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.freqBand[j].sulBand[k] = SUL_BAND;
650 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.ulTxBw.nrScs = SCS_120;
651 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.ulTxBw.nrb = NRB_66;
653 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.dlTxBw.nrScs = SCS_120;
654 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.dlTxBw.nrb = NRB_66;
657 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.tdd.nrTxBw.nrScs = SCS_15;
658 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.tdd.nrTxBw.nrb = NRB_160;
660 /*Measurement Config and Cell Config */
661 duCfgParam.srvdCellLst[i].duCellInfo.measTimeCfg = TIME_CFG;
663 duCfgParam.srvdCellLst[i].duCellInfo.cellDir = DL_UL;
665 duCfgParam.srvdCellLst[i].duCellInfo.cellType=CELL_TYPE;
667 /* Broadcast PLMN Identity */
668 for(j=0;j<MAXBPLMNNRMINUS1;j++)
670 for(k=0;k<MAX_PLMN;k++)
672 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].plmn[k].mcc[0] = PLMN_MCC0;
673 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].plmn[k].mcc[1] = PLMN_MCC1;
674 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].plmn[k].mcc[2] = PLMN_MCC2;
675 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].plmn[k].mnc[0] = PLMN_MNC0;
676 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].plmn[k].mnc[1] = PLMN_MNC1;
677 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].plmn[k].mnc[2] = PLMN_MNC2;
679 /* Extended PLMN List */
680 for(k=0;k<MAX_PLMN;k++)
682 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].extPlmn[k].mcc[0] = PLMN_MCC0;
683 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].extPlmn[k].mcc[1] = PLMN_MCC1;
684 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].extPlmn[k].mcc[2] = PLMN_MCC2;
685 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].extPlmn[k].mnc[0] = PLMN_MNC0;
686 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].extPlmn[k].mnc[1] = PLMN_MNC1;
687 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].extPlmn[k].mnc[2] = PLMN_MNC2;
690 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].tac = DU_TAC;
691 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].nrCellId = NR_CELL_ID;
692 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].ranac = NR_RANAC;
695 /*gnb DU System Info mib msg*/
697 DU_ALLOC(duCfgParam.srvdCellLst[i].duSysInfo.mibMsg,\
699 if(!(duCfgParam.srvdCellLst[i].duSysInfo.mibMsg))
701 DU_LOG("\nDU_APP: Memory allocation failure");
704 strcpy((char *)duCfgParam.srvdCellLst[i].duSysInfo.mibMsg, encBuf);
705 duCfgParam.srvdCellLst[i].duSysInfo.mibLen = encBufSize;
707 /*gnb DU System Info mib msg*/
709 DU_ALLOC(duCfgParam.srvdCellLst[i].duSysInfo.sib1Msg,\
711 if(!(duCfgParam.srvdCellLst[i].duSysInfo.sib1Msg))
713 DU_LOG("\nDU_APP: Memory allocation failure");
716 memcpy(duCfgParam.srvdCellLst[i].duSysInfo.sib1Msg,\
718 duCfgParam.srvdCellLst[i].duSysInfo.sib1Len = encBufSize;
722 if(readMacCfg() != ROK)
724 DU_LOG("\nDU_APP : Failed while reading MAC config");
731 /*******************************************************************
733 * @brief Reads config and posts message to du_app on completion
741 * - Post to du_app for further processing
744 * @return ROK - success
747 * ****************************************************************/
753 cmMemset((U8 *)&duCfgParam, 0, sizeof(DuCfgParams));
754 //Read configs into duCfgParams
757 DU_LOG("\nDU_APP : Reading configuration failed");
762 cmMemset((U8 *)&(pst), 0, sizeof(Pst));
763 pst.srcEnt = (Ent)ENTDUAPP;
764 pst.srcInst = (Inst)DU_INST;
765 pst.srcProcId = DU_PROC;
766 pst.dstEnt = pst.srcEnt;
767 pst.dstInst = pst.srcInst;
768 pst.dstProcId = pst.srcProcId;
770 pst.selector = DU_SELECTOR_TC;
774 if(SGetMsg(DFLT_REGION, DU_POOL, &mBuf) != ROK)
776 DU_LOG("\nDU_APP : Memory allocation failed in duReadCfg");
780 if (SPstTsk(&pst, mBuf) != ROK)
782 DU_LOG("\nDU_APP : SPstTsk failed in duReadCfg");
789 /*******************************************************************
791 * @brief Converts bit strings to integer
795 * Function : bitStringToInt
798 * - Converts ASN bit string format IEs to integer type
801 * @return ROK - success
804 * ****************************************************************/
805 S16 bitStringToInt(BIT_STRING_t *bitString, U16 *val)
808 if(bitString->buf == NULL || bitString->size <= 0)
810 DU_LOG("\nDU_APP : Bit string is empty");
814 for(idx=0; idx< bitString->size-1; idx++)
816 *val |= bitString->buf[idx];
820 *val |= bitString->buf[idx];
821 *val >>= bitString->bits_unused;
827 /**********************************************************************
829 **********************************************************************/