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.prachSeqLen = PRACH_SEQ_LEN;
184 duCfgParam.macCellCfg.prachCfg.prachSubcSpacing = PRACH_SUBCARRIER_SPACING;
185 duCfgParam.macCellCfg.prachCfg.prachRstSetCfg = PRACH_RESTRICTED_SET_CFG;
186 duCfgParam.macCellCfg.prachCfg.prachFdm = NUM_PRACH_FDM;
187 duCfgParam.macCellCfg.prachCfg.fdm[0].rootSeqIdx = ROOT_SEQ_IDX;
188 duCfgParam.macCellCfg.prachCfg.fdm[0].numRootSeq = NUM_ROOT_SEQ;
189 duCfgParam.macCellCfg.prachCfg.fdm[0].k1 = 1;
190 duCfgParam.macCellCfg.prachCfg.fdm[0].zeroCorrZoneCfg = ZERO_CORRELATION_ZONE_CFG;
191 duCfgParam.macCellCfg.prachCfg.fdm[0].numUnusedRootSeq = NUM_UNUSED_ROOT_SEQ;
192 DU_ALLOC(duCfgParam.macCellCfg.prachCfg.fdm[0].unsuedRootSeq, NUM_UNUSED_ROOT_SEQ * sizeof(U8));
193 if(duCfgParam.macCellCfg.prachCfg.fdm[0].unsuedRootSeq == NULLP)
195 DU_LOG("\nDU_APP : Memory allocation failed");
198 *(duCfgParam.macCellCfg.prachCfg.fdm[0].unsuedRootSeq) = UNUSED_ROOT_SEQ;
199 duCfgParam.macCellCfg.prachCfg.ssbPerRach = SSB_PER_RACH;
200 duCfgParam.macCellCfg.prachCfg.prachMultCarrBand = PRACH_MULT_CARRIER_BAND;
202 /* TDD configuration */
203 duCfgParam.macCellCfg.tddCfg.pres = TRUE;
204 duCfgParam.macCellCfg.tddCfg.tddPeriod = TDD_PERIODICITY;
208 /* RSSI Measurement configuration */
209 duCfgParam.macCellCfg.rssiUnit = RSS_MEASUREMENT_UNIT;
211 /* fill SIB1 configuration */
212 duCfgParam.macCellCfg.sib1Cfg.sib1PduLen = duCfgParam.srvdCellLst[0].duSysInfo.sib1Len;
213 DU_ALLOC(duCfgParam.macCellCfg.sib1Cfg.sib1Pdu,duCfgParam.srvdCellLst[0].duSysInfo.sib1Len);
214 memcpy(duCfgParam.macCellCfg.sib1Cfg.sib1Pdu, duCfgParam.srvdCellLst[0].duSysInfo.sib1Msg, \
215 duCfgParam.srvdCellLst[0].duSysInfo.sib1Len);
216 duCfgParam.macCellCfg.sib1Cfg.sib1NewTxPeriod = SIB1_NEW_TX_PERIOD;
217 duCfgParam.macCellCfg.sib1Cfg.sib1RepetitionPeriod = SIB1_REPETITION_PERIOD;
218 duCfgParam.macCellCfg.sib1Cfg.coresetZeroIndex = CORESET_0_INDEX;
219 duCfgParam.macCellCfg.sib1Cfg.searchSpaceZeroIndex = SEARCHSPACE_0_INDEX;
220 duCfgParam.macCellCfg.sib1Cfg.sib1Mcs = SIB1_MCS;
222 /* This should be calculated based on
223 (number of mandatory parameters) + (number of otional parameters being filled) */
224 duCfgParam.macCellCfg.numTlv = 39;
229 /*******************************************************************
231 * @brief Configures the DU Parameters
235 * Function : fillDuPort
238 * - fills the DU Ports.
240 * @params[in] duPort array to be filled
241 * @return ROK - success
244 * ****************************************************************/
245 S16 fillDuPort(U16 *duPort)
247 duPort[F1_INTERFACE] = DU_PORT; /* DU Port idx 0 38472 */
248 duPort[E2_INTERFACE] = RIC_PORT; /* RIC Port idx 1 38482 */
255 /*******************************************************************
257 * @brief Configures serving cell config common in sib1
261 * Function : fillServCellCfgCommSib
264 * - fills Serving cell config common for SIB1
266 * @params[in] SrvCellCfgCommSib pointer
267 * @return ROK - success
270 ** ****************************************************************/
271 S16 fillServCellCfgCommSib(SrvCellCfgCommSib *srvCellCfgComm)
273 PdcchCfgCommon pdcchCfg;
274 PdschCfgCommon pdschCfg;
276 RachCfgCommon rachCfg;
277 PuschCfgCommon puschCfg;
278 PucchCfgCommon pucchCfg;
279 TddUlDlCfgCommon tddCfg;
281 /* Configuring DL Config Common for SIB1*/
282 srvCellCfgComm->dlCfg.freqBandInd = NR_FREQ_BAND_IND;
283 srvCellCfgComm->dlCfg.offsetToPointA = OFFSET_TO_POINT_A;
284 srvCellCfgComm->dlCfg.dlScsCarrier.scsOffset = SSB_SUBCARRIER_OFFSET;
285 srvCellCfgComm->dlCfg.dlScsCarrier.scs = SUBCARRIER_SPACING;
286 srvCellCfgComm->dlCfg.dlScsCarrier.scsBw = SCS_CARRIER_BANDWIDTH;
287 srvCellCfgComm->dlCfg.locAndBw = FREQ_LOC_BW;
289 /* Configuring PDCCH Config Common For SIB1 */
290 pdcchCfg.present = BWP_DownlinkCommon__pdcch_ConfigCommon_PR_setup;
291 pdcchCfg.ctrlRsrcSetZero = PDCCH_CTRL_RSRC_SET_ZERO;
292 pdcchCfg.searchSpcZero = PDCCH_SEARCH_SPACE_ZERO;
293 pdcchCfg.searchSpcId = PDCCH_SEARCH_SPACE_ID;
294 pdcchCfg.ctrlRsrcSetId = PDCCH_CTRL_RSRC_SET_ID;
295 pdcchCfg.monitorSlotPrdAndOffPresent = \
296 SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl1;
297 //pdcchCfg.monitorSlotPrdAndOff = \
298 SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl1;
299 pdcchCfg.monitorSymbolsInSlot[0] = 128;
300 pdcchCfg.monitorSymbolsInSlot[1] = 0;
301 pdcchCfg.numCandAggLvl1 = SearchSpace__nrofCandidates__aggregationLevel1_n8;
302 pdcchCfg.numCandAggLvl2 = SearchSpace__nrofCandidates__aggregationLevel2_n4;
303 pdcchCfg.numCandAggLvl4 = SearchSpace__nrofCandidates__aggregationLevel4_n2;
304 pdcchCfg.numCandAggLvl8 = SearchSpace__nrofCandidates__aggregationLevel8_n1;
305 pdcchCfg.numCandAggLvl16 = SearchSpace__nrofCandidates__aggregationLevel16_n0;
306 pdcchCfg.searchSpcType = SearchSpace__searchSpaceType_PR_common;
307 pdcchCfg.commSrchSpcDciFrmt = PDCCH_SERACH_SPACE_DCI_FORMAT;
308 pdcchCfg.searchSpcSib1 = PDCCH_SEARCH_SPACE_ID_SIB1;
309 pdcchCfg.pagingSearchSpc = PDCCH_SEARCH_SPACE_ID_PAGING;
310 pdcchCfg.raSearchSpc = PDCCH_SEARCH_SPACE_ID_PAGING;
311 srvCellCfgComm->dlCfg.pdcchCfg = pdcchCfg;
313 /* Configuring PDSCH Config Common For SIB1 */
314 pdschCfg.present = BWP_DownlinkCommon__pdsch_ConfigCommon_PR_setup;
315 pdschCfg.k0 = PDSCH_K0;
317 PDSCH_TimeDomainResourceAllocation__mappingType_typeA;
318 pdschCfg.startSymbAndLen = PDSCH_START_SYMB_AND_LEN;
319 srvCellCfgComm->dlCfg.pdschCfg = pdschCfg;
321 /* Configuring BCCH Config for SIB1 */
322 srvCellCfgComm->dlCfg.bcchCfg.modPrdCoeff = \
323 BCCH_Config__modificationPeriodCoeff_n16;
325 /* Configuring PCCH Config for SIB1 */
326 pcchCfg.dfltPagingCycle = PagingCycle_rf64;
327 pcchCfg.nAndPagingFrmOffPresent = PCCH_Config__nAndPagingFrameOffset_PR_oneT;
328 pcchCfg.numPagingOcc = PCCH_Config__ns_four;
329 srvCellCfgComm->dlCfg.pcchCfg = pcchCfg;
332 /* Configuring UL Config Common */
333 srvCellCfgComm->ulCfg.ulScsCarrier.scsOffset = SSB_SUBCARRIER_OFFSET;
334 srvCellCfgComm->ulCfg.ulScsCarrier.scs = SUBCARRIER_SPACING;
335 srvCellCfgComm->ulCfg.ulScsCarrier.scsBw = SCS_CARRIER_BANDWIDTH;
336 srvCellCfgComm->ulCfg.pMax = UL_P_MAX;
337 srvCellCfgComm->ulCfg.locAndBw = FREQ_LOC_BW;
338 srvCellCfgComm->ulCfg.timeAlignTimerComm = TimeAlignmentTimer_infinity;
340 /* Configuring RACH Config Common for SIB1 */
341 rachCfg.present = BWP_UplinkCommon__rach_ConfigCommon_PR_setup;
342 rachCfg.prachCfgIdx = PRACH_CONFIG_IDX;
343 rachCfg.msg1Fdm = RACH_ConfigGeneric__msg1_FDM_one;
344 rachCfg.msg1FreqStart = PRACH_FREQ_START;
345 rachCfg.zeroCorrZoneCfg = ZERO_CORRELATION_ZONE_CFG;
346 rachCfg.preambleRcvdTgtPwr = PRACH_PREAMBLE_RCVD_TGT_PWR;
347 rachCfg.preambleTransMax = RACH_ConfigGeneric__preambleTransMax_n200;
348 rachCfg.pwrRampingStep = RACH_ConfigGeneric__powerRampingStep_dB2;
349 rachCfg.raRspWindow = RACH_ConfigGeneric__ra_ResponseWindow_sl20;
350 rachCfg.numRaPreamble = NUM_RA_PREAMBLE;
351 rachCfg.ssbPerRachOccPresent = \
352 RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_one;
353 rachCfg.numSsbPerRachOcc = SSB_PER_RACH;
354 rachCfg.contResTimer = RACH_ConfigCommon__ra_ContentionResolutionTimer_sf64;
355 rachCfg.rsrpThreshSsb = RSRP_THRESHOLD_SSB;
356 rachCfg.rootSeqIdxPresent = RACH_ConfigCommon__prach_RootSequenceIndex_PR_l139;
357 rachCfg.rootSeqIdx = ROOT_SEQ_IDX;
358 rachCfg.msg1Scs = PRACH_SUBCARRIER_SPACING ;
359 rachCfg.restrictedSetCfg = PRACH_RESTRICTED_SET_CFG;
360 srvCellCfgComm->ulCfg.rachCfg = rachCfg;
362 /* Configuring PUSCH Config Common for SIB1 */
363 puschCfg.present = BWP_UplinkCommon__pusch_ConfigCommon_PR_setup;
364 puschCfg.k2 = PUSCH_K0;
365 puschCfg.mapType = PUSCH_TimeDomainResourceAllocation__mappingType_typeA;
366 puschCfg.startSymbAndLen = PUSCH_START_SYMB_AND_LEN;
367 puschCfg.msg3DeltaPreamble = PUSCH_MSG3_DELTA_PREAMBLE;
368 puschCfg.p0NominalWithGrant = PUSCH_P0_NOMINAL_WITH_GRANT;
369 srvCellCfgComm->ulCfg.puschCfg = puschCfg;
371 /* Configuring PUCCH Config Common for SIB1 */
372 pucchCfg.present = BWP_UplinkCommon__pucch_ConfigCommon_PR_setup;
373 pucchCfg.rsrcComm = PUCCH_RSRC_COMMON;
374 pucchCfg.grpHop = PUCCH_ConfigCommon__pucch_GroupHopping_neither;
375 pucchCfg.p0Nominal = PUCCH_P0_NOMINAL;
376 srvCellCfgComm->ulCfg.pucchCfg = pucchCfg;
378 /* Configuring TDD UL DL config common */
379 tddCfg.refScs = SubcarrierSpacing_kHz30;
380 tddCfg.txPrd = TDD_UL_DL_Pattern__dl_UL_TransmissionPeriodicity_ms2p5;
381 tddCfg.numDlSlots = NUM_DL_SLOTS;
382 tddCfg.numDlSymbols = NUM_DL_SYMBOLS;
383 tddCfg.numUlSlots = NUM_UL_SLOTS;
384 tddCfg.numUlSymbols = NUM_UL_SYMBOLS;
385 srvCellCfgComm->tddCfg = tddCfg;
387 srvCellCfgComm->ssbPosInBurst = 192;
388 srvCellCfgComm->ssbPrdServingCell = SSB_PERIODICITY;
389 srvCellCfgComm->ssPbchBlockPwr = SSB_PBCH_PWR;
394 /*******************************************************************
396 * @brief Configures the DU Parameters
403 * - Initializes the DuCfg members.
404 * - Calls readMacCfg()
406 * @params[in] system task ID
407 * @return ROK - success
410 * ****************************************************************/
415 U32 ipv4_du, ipv4_cu, ipv4_ric;
419 cmInetAddr((S8*)DU_IP_V4_ADDR, &ipv4_du);
420 cmInetAddr((S8*)CU_IP_V4_ADDR, &ipv4_cu);
421 cmInetAddr((S8*)RIC_IP_V4_ADDR, &ipv4_ric);
422 fillDuPort(duCfgParam.sctpParams.duPort);
424 /* F1 DU IP Address and Port*/
425 duCfgParam.sctpParams.duIpAddr.ipV4Addr = ipv4_du;
427 /* F1 CU IP Address and Port*/
428 duCfgParam.sctpParams.cuIpAddr.ipV4Addr = ipv4_cu;
429 duCfgParam.sctpParams.cuPort = CU_PORT;
431 /* Fill RIC Params */
432 duCfgParam.sctpParams.ricIpAddr.ipV4Addr = ipv4_ric;
433 duCfgParam.sctpParams.ricPort = RIC_PORT;
434 /* EGTP Parameters */
435 duCfgParam.egtpParams.localIp.ipV4Pres = TRUE;
436 duCfgParam.egtpParams.localIp.ipV4Addr = ipv4_du;
437 duCfgParam.egtpParams.localPort = DU_EGTP_PORT;
438 duCfgParam.egtpParams.destIp.ipV4Pres = TRUE;
439 duCfgParam.egtpParams.destIp.ipV4Addr = ipv4_cu;
440 duCfgParam.egtpParams.destPort = CU_EGTP_PORT;
441 duCfgParam.egtpParams.minTunnelId = 0;
442 duCfgParam.egtpParams.maxTunnelId = 10;
444 duCfgParam.maxUe = 32; //TODO: Check
446 duCfgParam.duId = DU_ID;
447 strcpy((char*)duCfgParam.duName,DU_NAME);
450 mib.sysFrmNum = SYS_FRAME_NUM;
451 mib.subCarrierSpacingCommon = MIB__subCarrierSpacingCommon_scs15or60;
452 mib.ssb_SubcarrierOffset = SSB_SC_OFFSET;
453 mib.dmrs_TypeA_Position = MIB__dmrs_TypeA_Position_pos2;
454 mib.controlResourceSetZero = CORESET_ZERO;
455 mib.searchSpaceZero = SEARCH_SPACE_ZERO;
456 mib.cellBarred = MIB__cellBarred_barred;
457 mib.intraFreqReselection =
458 MIB__intraFreqReselection_notAllowed;
459 duCfgParam.mibParams = mib;
462 sib1.plmn.mcc[0] = PLMN_MCC0;
463 sib1.plmn.mcc[1] = PLMN_MCC1;
464 sib1.plmn.mcc[2] = PLMN_MCC2;
465 sib1.plmn.mnc[0] = PLMN_MNC0;
466 sib1.plmn.mnc[1] = PLMN_MNC1;
467 sib1.plmn.mnc[2] = PLMN_MNC2;
469 sib1.ranac = DU_RANAC;
470 sib1.cellIdentity = CELL_IDENTITY;
471 sib1.cellResvdForOpUse =\
472 PLMN_IdentityInfo__cellReservedForOperatorUse_notReserved;
473 sib1.connEstFailCnt = ConnEstFailureControl__connEstFailCount_n3;
474 sib1.connEstFailOffValidity =\
475 ConnEstFailureControl__connEstFailOffsetValidity_s120;
476 sib1.siSchedInfo.winLen = SI_SchedulingInfo__si_WindowLength_s5;
477 sib1.siSchedInfo.broadcastSta = \
478 SchedulingInfo__si_BroadcastStatus_broadcasting;
479 sib1.siSchedInfo.preiodicity = SchedulingInfo__si_Periodicity_rf8;
480 sib1.siSchedInfo.sibType = SIB_TypeInfo__type_sibType2;
481 sib1.siSchedInfo.sibValTag = SIB1_VALUE_TAG;
483 fillServCellCfgCommSib(&sib1.srvCellCfgCommSib);
485 duCfgParam.sib1Params = sib1;
487 for(i=0; i<DEFAULT_CELLS; i++)
489 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.nrCgi.plmn.mcc[0] = PLMN_MCC0;
490 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.nrCgi.plmn.mcc[1] = PLMN_MCC1;
491 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.nrCgi.plmn.mcc[2] = PLMN_MCC2;
492 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.nrCgi.plmn.mnc[0] = PLMN_MNC0;
493 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.nrCgi.plmn.mnc[1] = PLMN_MNC1;
494 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.nrCgi.plmn.mnc[2] = PLMN_MNC2;
497 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.nrCgi.cellId = NR_CELL_ID;
498 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.nrPci = NR_PCI;
500 /* List of Available PLMN */
501 for(j=0;j<MAX_PLMN;j++)
503 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.plmn[j].mcc[0] = PLMN_MCC0;
504 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.plmn[j].mcc[1] = PLMN_MCC1;
505 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.plmn[j].mcc[2] = PLMN_MCC2;
506 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.plmn[j].mnc[0] = PLMN_MNC0;
507 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.plmn[j].mnc[1] = PLMN_MNC1;
508 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.plmn[j].mnc[2] = PLMN_MNC2;
510 /* List of Extended PLMN */
511 for(j=0;j<MAX_PLMN;j++)
513 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.extPlmn[j].mcc[0] = PLMN_MCC0;
514 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.extPlmn[j].mcc[1] = PLMN_MCC1;
515 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.extPlmn[j].mcc[2] = PLMN_MCC2;
516 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.extPlmn[j].mnc[0] = PLMN_MNC0;
517 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.extPlmn[j].mnc[1] = PLMN_MNC1;
518 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.extPlmn[j].mnc[2] = PLMN_MNC2;
522 duCfgParam.srvdCellLst[i].duCellInfo.tac = DU_TAC;
523 duCfgParam.srvdCellLst[i].duCellInfo.epsTac = DU_TAC; //to check and fill
525 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.nrArfcn = NR_ARFCN;
526 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.sulInfo.sulArfcn = SUL_ARFCN;
527 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.sulInfo.sulTxBw.nrScs = SCS_120;
528 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.sulInfo.sulTxBw.nrb = NRB_66;
532 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.nrArfcn = NR_ARFCN;
533 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.sulInfo.sulArfcn = SUL_ARFCN;
534 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.sulInfo.sulTxBw.nrScs = SCS_15;
535 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.sulInfo.sulTxBw.nrb = NRB_160;
537 for(j=0;j<MAXNRCELLBANDS;j++)
539 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.freqBand[j].nrFreqBand = NR_FREQ_BAND;
540 for(k=0;k<MAXNRCELLBANDS;k++)
542 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.freqBand[j].sulBand[k] = SUL_BAND;
546 for(j=0;j<MAXNRCELLBANDS;j++)
548 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.freqBand[j].nrFreqBand = NR_FREQ_BAND;
549 for(k=0;k<MAXNRCELLBANDS;k++)
551 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.freqBand[j].sulBand[k] = SUL_BAND;
554 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.nrArfcn = NR_ARFCN;
555 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.sulInfo.sulArfcn = SUL_ARFCN;
556 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.sulInfo.sulTxBw.nrScs = SCS_120;
557 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.sulInfo.sulTxBw.nrb = NRB_66;
558 for(j=0;j<MAXNRCELLBANDS;j++)
560 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.freqBand[j].nrFreqBand = NR_FREQ_BAND;
561 for(k=0;k<MAXNRCELLBANDS;k++)
563 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.freqBand[j].sulBand[k] = SUL_BAND;
567 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.ulTxBw.nrScs = SCS_120;
568 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.ulTxBw.nrb = NRB_66;
570 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.dlTxBw.nrScs = SCS_120;
571 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.dlTxBw.nrb = NRB_66;
574 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.tdd.nrTxBw.nrScs = SCS_15;
575 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.tdd.nrTxBw.nrb = NRB_160;
577 /*Measurement Config and Cell Config */
578 duCfgParam.srvdCellLst[i].duCellInfo.measTimeCfg = TIME_CFG;
580 duCfgParam.srvdCellLst[i].duCellInfo.cellDir = DL_UL;
582 duCfgParam.srvdCellLst[i].duCellInfo.cellType=CELL_TYPE;
584 /* Broadcast PLMN Identity */
585 for(j=0;j<MAXBPLMNNRMINUS1;j++)
587 for(k=0;k<MAX_PLMN;k++)
589 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].plmn[k].mcc[0] = PLMN_MCC0;
590 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].plmn[k].mcc[1] = PLMN_MCC1;
591 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].plmn[k].mcc[2] = PLMN_MCC2;
592 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].plmn[k].mnc[0] = PLMN_MNC0;
593 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].plmn[k].mnc[1] = PLMN_MNC1;
594 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].plmn[k].mnc[2] = PLMN_MNC2;
596 /* Extended PLMN List */
597 for(k=0;k<MAX_PLMN;k++)
599 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].extPlmn[k].mcc[0] = PLMN_MCC0;
600 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].extPlmn[k].mcc[1] = PLMN_MCC1;
601 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].extPlmn[k].mcc[2] = PLMN_MCC2;
602 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].extPlmn[k].mnc[0] = PLMN_MNC0;
603 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].extPlmn[k].mnc[1] = PLMN_MNC1;
604 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].extPlmn[k].mnc[2] = PLMN_MNC2;
607 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].tac = DU_TAC;
608 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].nrCellId = NR_CELL_ID;
609 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].ranac = NR_RANAC;
612 /*gnb DU System Info mib msg*/
614 DU_ALLOC(duCfgParam.srvdCellLst[i].duSysInfo.mibMsg,\
616 if(!(duCfgParam.srvdCellLst[i].duSysInfo.mibMsg))
618 DU_LOG("\nDU_APP: Memory allocation failure");
621 strcpy(duCfgParam.srvdCellLst[i].duSysInfo.mibMsg, encBuf);
622 duCfgParam.srvdCellLst[i].duSysInfo.mibLen = encBufSize;
624 /*gnb DU System Info mib msg*/
626 DU_ALLOC(duCfgParam.srvdCellLst[i].duSysInfo.sib1Msg,\
628 if(!(duCfgParam.srvdCellLst[i].duSysInfo.sib1Msg))
630 DU_LOG("\nDU_APP: Memory allocation failure");
633 memcpy(duCfgParam.srvdCellLst[i].duSysInfo.sib1Msg,\
635 duCfgParam.srvdCellLst[i].duSysInfo.sib1Len = encBufSize;
639 if(readMacCfg() != ROK)
641 DU_LOG("\nDU_APP : Failed while reading MAC config");
648 /*******************************************************************
650 * @brief Reads config and posts message to du_app on completion
658 * - Post to du_app for further processing
661 * @return ROK - success
664 * ****************************************************************/
670 cmMemset((U8 *)&duCfgParam, 0, sizeof(DuCfgParams));
671 //Read configs into duCfgParams
674 DU_LOG("\nDU_APP : Reading configuration failed");
679 cmMemset((U8 *)&(pst), 0, sizeof(Pst));
680 pst.srcEnt = (Ent)ENTDUAPP;
681 pst.srcInst = (Inst)DU_INST;
682 pst.srcProcId = DU_PROC;
683 pst.dstEnt = pst.srcEnt;
684 pst.dstInst = pst.srcInst;
685 pst.dstProcId = pst.srcProcId;
687 pst.selector = DU_SELECTOR_TC;
691 if(SGetMsg(DFLT_REGION, DU_POOL, &mBuf) != ROK)
693 DU_LOG("\nDU_APP : Memory allocation failed in duReadCfg");
697 if (SPstTsk(&pst, mBuf) != ROK)
699 DU_LOG("\nDU_APP : SPstTsk failed in duReadCfg");
706 /*******************************************************************
708 * @brief Converts bit strings to integer
712 * Function : bitStringToInt
715 * - Converts ASN bit string format IEs to integer type
718 * @return ROK - success
721 * ****************************************************************/
722 S16 bitStringToInt(BIT_STRING_t *bitString, U16 *val)
725 if(bitString->buf == NULL || bitString->size <= 0)
727 DU_LOG("\nDU_APP : Bit string is empty");
731 for(idx=0; idx< bitString->size-1; idx++)
733 *val |= bitString->buf[idx];
737 *val |= bitString->buf[idx];
738 *val >>= bitString->bits_unused;
744 /**********************************************************************
746 **********************************************************************/