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 */
22 #include<netinet/in.h>
31 #define DU_IP_V4_ADDR "10.0.2.20"
32 #define CU_IP_V4_ADDR "10.0.2.25"
33 #define DU_IP_V6_ADDR "0000:0000:0000:0000:0000:0000:0000:0001"
38 #define DU_NAME "ORAN_OAM_DU"
39 #define CELL_DIR UL_DL
40 #define CELL_TYPE SMALL
41 #define DUPLEX_MODE DUP_MODE_TDD
49 #define NR_ARFCN 2079427
51 #define NR_FREQ_BAND 257
58 #define FREQ_SHIFT_7P5KHZ FALSE
59 #define SSB_PBCH_PWR 0
60 #define BCH_PAYLOAD MAC_GEN_FULL_PBCH_PAYLD
61 #define SUBCARRIER_SPACING 3
63 #define BETA_PSS BETA_PSS_0DB
64 #define SSB_PERIODICITTY SSB_PRDCTY_MS_20
65 #define SSB_SUBCARRIER_OFFSET 0
66 #define SSB_MULT_CARRIER_BAND FALSE
67 #define MULT_CELL_CARRIER FALSE
69 #define PRACH_SEQ_LEN SHORT_SEQUENCE
70 #define PRACH_SUBCARRIER_SPACING 3
71 #define PRACH_RESTRICTED_SET_CFG UNRESTRICTED
72 #define NUM_PRACH_FDM 1
73 #define ROOT_SEQ_IDX 0
74 #define NUM_ROOT_SEQ 1
75 #define ZERO_CORRELATION_ZONE_CFG 2
76 #define NUM_UNUSED_ROOT_SEQ 1
77 #define UNUSED_ROOT_SEQ 1
78 #define SSB_PER_RACH 3
79 #define PRACH_MULT_CARRIER_BAND FALSE
80 #define TDD_PERIODICITY TX_PRDCTY_MS_2P5
81 #define RSS_MEASUREMENT_UNIT DONT_REPORT_RSSI
83 /* Filling Slot configuration as :
84 * 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
85 * 0 DL DL DL DL DL DL DL DL DL DL DL DL DL DL
86 * 1 DL DL DL DL DL DL DL DL DL DL DL DL DL DL
87 * 2 DL DL DL DL DL DL DL DL DL DL DL DL DL DL
88 * 3 DL DL DL DL DL DL DL DL DL DL GD GD GD UL
89 * 4 UL UL UL UL UL UL UL UL UL UL UL UL UL UL
92 /*******************************************************************
94 * @brief Fills the Slot configuration
98 * Function : fillSlotConfig
100 * Functionality:Fill the Slot configuration values
103 * @return ROK - success
106 * ****************************************************************/
107 void fillSlotConfig()
112 for(slot = 0; slot <= 3; slot++)
114 for(symbol = 0; symbol < MAX_SYMB_PER_SLOT; symbol++)
115 duCfgParam.clCellCfg.tddCfg.slotCfg[slot][symbol] = DL_SLOT;
118 duCfgParam.clCellCfg.tddCfg.slotCfg[3][10] = GUARD_SLOT;
119 duCfgParam.clCellCfg.tddCfg.slotCfg[3][11] = GUARD_SLOT;
120 duCfgParam.clCellCfg.tddCfg.slotCfg[3][12] = GUARD_SLOT;
121 duCfgParam.clCellCfg.tddCfg.slotCfg[3][13] = UL_SLOT;
123 for(symbol = 0; symbol < MAX_SYMB_PER_SLOT; symbol++)
124 duCfgParam.clCellCfg.tddCfg.slotCfg[4][symbol] = UL_SLOT;
128 /*******************************************************************
130 * @brief Reads the CL Configuration.
134 * Function : readClCfg
137 * - Fills up the cell configuration for CL.
138 * - Calls fillSlotConfig()
141 * @return ROK - success
144 * ****************************************************************/
147 /* This function is used to fill up the cell configuration for CL */
150 duCfgParam.clCellCfg.carrierId = CARRIER_IDX;
152 /* Cell configuration */
153 duCfgParam.clCellCfg.cellId = NR_CELL_ID;
154 duCfgParam.clCellCfg.phyCellId = NR_PCI;
155 duCfgParam.clCellCfg.dupType = DUPLEX_MODE;
157 /* DL carrier configuration */
158 duCfgParam.clCellCfg.dlCarrCfg.pres = TRUE;
159 duCfgParam.clCellCfg.dlCarrCfg.bw = SUL_ARFCN;
160 duCfgParam.clCellCfg.dlCarrCfg.freq = NR_ARFCN;
161 duCfgParam.clCellCfg.dlCarrCfg.k0[0] = 1;
162 duCfgParam.clCellCfg.dlCarrCfg.k0[1] = 1;
163 duCfgParam.clCellCfg.dlCarrCfg.k0[2] = 1;
164 duCfgParam.clCellCfg.dlCarrCfg.k0[3] = 1;
165 duCfgParam.clCellCfg.dlCarrCfg.k0[4] = 1;
166 duCfgParam.clCellCfg.dlCarrCfg.gridSize[0] = 1;
167 duCfgParam.clCellCfg.dlCarrCfg.gridSize[1] = 1;
168 duCfgParam.clCellCfg.dlCarrCfg.gridSize[2] = 1;
169 duCfgParam.clCellCfg.dlCarrCfg.gridSize[3] = 1;
170 duCfgParam.clCellCfg.dlCarrCfg.gridSize[4] = 1;
171 duCfgParam.clCellCfg.dlCarrCfg.numAnt = NUM_TX_ANT;
173 /* UL Carrier configuration */
174 duCfgParam.clCellCfg.ulCarrCfg.pres = TRUE;
175 duCfgParam.clCellCfg.ulCarrCfg.bw = SUL_ARFCN;
176 duCfgParam.clCellCfg.ulCarrCfg.freq = NR_ARFCN;
177 duCfgParam.clCellCfg.ulCarrCfg.k0[0] = 1;
178 duCfgParam.clCellCfg.ulCarrCfg.k0[1] = 1;
179 duCfgParam.clCellCfg.ulCarrCfg.k0[2] = 1;
180 duCfgParam.clCellCfg.ulCarrCfg.k0[3] = 1;
181 duCfgParam.clCellCfg.ulCarrCfg.k0[4] = 1;
182 duCfgParam.clCellCfg.ulCarrCfg.gridSize[0] = 1;
183 duCfgParam.clCellCfg.ulCarrCfg.gridSize[1] = 1;
184 duCfgParam.clCellCfg.ulCarrCfg.gridSize[2] = 1;
185 duCfgParam.clCellCfg.ulCarrCfg.gridSize[3] = 1;
186 duCfgParam.clCellCfg.ulCarrCfg.gridSize[4] = 1;
187 duCfgParam.clCellCfg.ulCarrCfg.numAnt = NUM_RX_ANT;
189 duCfgParam.clCellCfg.freqShft = FREQ_SHIFT_7P5KHZ;
191 /* SSB configuration */
192 duCfgParam.clCellCfg.ssbCfg.ssbPbchPwr = SSB_PBCH_PWR;
193 duCfgParam.clCellCfg.ssbCfg.bchPayload = BCH_PAYLOAD;
194 duCfgParam.clCellCfg.ssbCfg.scsCmn = SUBCARRIER_SPACING;
195 duCfgParam.clCellCfg.ssbCfg.ssbPrbOffset = PRB_OFFSET;
196 duCfgParam.clCellCfg.ssbCfg.betaPss = BETA_PSS;
197 duCfgParam.clCellCfg.ssbCfg.ssbPeriod = SSB_PERIODICITTY;
198 duCfgParam.clCellCfg.ssbCfg.ssbSubcOffset = SSB_SUBCARRIER_OFFSET;
199 duCfgParam.clCellCfg.ssbCfg.mibPdu = 104;
200 duCfgParam.clCellCfg.ssbCfg.nSSBMask[0] = 2162721;
201 duCfgParam.clCellCfg.ssbCfg.nSSBMask[1] = 0;
202 duCfgParam.clCellCfg.ssbCfg.multCarrBand = SSB_MULT_CARRIER_BAND;
203 duCfgParam.clCellCfg.ssbCfg.multCellCarr = MULT_CELL_CARRIER;
205 /* PRACH configuration */
206 duCfgParam.clCellCfg.prachCfg.pres = TRUE;
207 duCfgParam.clCellCfg.prachCfg.prachSeqLen = PRACH_SEQ_LEN;
208 duCfgParam.clCellCfg.prachCfg.prachSubcSpacing = PRACH_SUBCARRIER_SPACING;
209 duCfgParam.clCellCfg.prachCfg.prachRstSetCfg = PRACH_RESTRICTED_SET_CFG;
210 duCfgParam.clCellCfg.prachCfg.prachFdm = NUM_PRACH_FDM;
211 duCfgParam.clCellCfg.prachCfg.fdm[0].rootSeqIdx = ROOT_SEQ_IDX;
212 duCfgParam.clCellCfg.prachCfg.fdm[0].numRootSeq = NUM_ROOT_SEQ;
213 duCfgParam.clCellCfg.prachCfg.fdm[0].k1 = 1;
214 duCfgParam.clCellCfg.prachCfg.fdm[0].zeroCorrZoneCfg = ZERO_CORRELATION_ZONE_CFG;
215 duCfgParam.clCellCfg.prachCfg.fdm[0].numUnusedRootSeq = NUM_UNUSED_ROOT_SEQ;
216 if(SGetSBuf(DU_APP_MEM_REGION, DU_POOL, (Data **)&(duCfgParam.clCellCfg.prachCfg.fdm[0].unsuedRootSeq), NUM_UNUSED_ROOT_SEQ * sizeof(U8)))
218 printf("\nMemory allocation failed");
221 *(duCfgParam.clCellCfg.prachCfg.fdm[0].unsuedRootSeq) = UNUSED_ROOT_SEQ;
222 duCfgParam.clCellCfg.prachCfg.ssbPerRach = SSB_PER_RACH;
223 duCfgParam.clCellCfg.prachCfg.prachMultCarrBand = PRACH_MULT_CARRIER_BAND;
225 /* TDD configuration */
226 duCfgParam.clCellCfg.tddCfg.pres = TRUE;
227 duCfgParam.clCellCfg.tddCfg.tddPeriod = TDD_PERIODICITY;
231 /* RSSI Measurement configuration */
232 duCfgParam.clCellCfg.rssiUnit = RSS_MEASUREMENT_UNIT;
234 /* This should be calculated based on
235 (number of mandatory parameters) + (number of otional parameters being filled) */
236 duCfgParam.clCellCfg.numTlv = 39;
240 /*******************************************************************
242 * @brief Configures the DU Parameters
249 * - Initializes the DuCfg members.
250 * - Calls readClCfg()
252 * @params[in] system task ID
253 * @return ROK - success
256 * ****************************************************************/
261 U32 ipv4_du, ipv4_cu;
263 cmInetAddr((S8*)DU_IP_V4_ADDR, &ipv4_du);
264 cmInetAddr((S8*)CU_IP_V4_ADDR, &ipv4_cu);
265 //U32 ipv6_int = inet_addr(DU_IP_V6_ADDR);
267 /* F1 DU IP Address and Port*/
268 duCfgParam.sctpParams.duIpAddr.ipV4Pres = TRUE;
269 duCfgParam.sctpParams.duIpAddr.ipV4Addr = ipv4_du;
270 duCfgParam.sctpParams.duIpAddr.ipV6Pres = FALSE;
271 //strcpy(duCfgParam.sctpParams.duIpAddr.ipV6Addr, (char*)DU_IP_V6_ADDR);
272 duCfgParam.sctpParams.duPort = DU_PORT;
274 /* F1 CU IP Address and Port*/
275 duCfgParam.sctpParams.cuIpAddr.ipV4Pres = TRUE;
276 duCfgParam.sctpParams.cuIpAddr.ipV4Addr = ipv4_cu;
277 duCfgParam.sctpParams.cuIpAddr.ipV6Pres = FALSE;
278 //strcpy(duCfgParam.sctpParams.cuIpAddr.ipV6Addr, DU_IP_V6_ADDR);
279 duCfgParam.sctpParams.cuPort = CU_PORT;
281 duCfgParam.maxUe = 32; //TODO: Check
283 duCfgParam.duId = DU_ID;
284 strcpy((char*)duCfgParam.duName,DU_NAME);
286 for(i=0;i<MAXCELLINGNBDU;i++)
288 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.nrCgi.plmn.mcc[0] = PLMN_MCC0;
289 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.nrCgi.plmn.mcc[1] = PLMN_MCC1;
290 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.nrCgi.plmn.mcc[2] = PLMN_MCC2;
291 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.nrCgi.plmn.mnc[0] = PLMN_MNC0;
292 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.nrCgi.plmn.mnc[1] = PLMN_MNC1;
293 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.nrCgi.plmn.mnc[2] = PLMN_MNC2;
296 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.nrCgi.cellId = NR_CELL_ID;
297 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.nrPci = NR_PCI;
299 /* List of Available PLMN */
300 for(j=0;j<MAXNUMOFBPLMN;j++)
302 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.plmn[j].mcc[0] = PLMN_MCC0;
303 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.plmn[j].mcc[1] = PLMN_MCC1;
304 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.plmn[j].mcc[2] = PLMN_MCC2;
305 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.plmn[j].mnc[0] = PLMN_MNC0;
306 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.plmn[j].mnc[1] = PLMN_MNC1;
307 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.plmn[j].mnc[2] = PLMN_MNC2;
309 /* List of Extended PLMN */
310 for(j=0;j<MAXNUMOFBPLMN;j++)
312 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.extPlmn[j].mcc[0] = PLMN_MCC0;
313 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.extPlmn[j].mcc[1] = PLMN_MCC1;
314 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.extPlmn[j].mcc[2] = PLMN_MCC2;
315 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.extPlmn[j].mnc[0] = PLMN_MNC0;
316 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.extPlmn[j].mnc[1] = PLMN_MNC1;
317 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.extPlmn[j].mnc[2] = PLMN_MNC2;
321 duCfgParam.srvdCellLst[i].duCellInfo.tac.pres = TRUE;
322 duCfgParam.srvdCellLst[i].duCellInfo.tac.tac = DU_TAC;
323 duCfgParam.srvdCellLst[i].duCellInfo.epsTac.pres = TRUE; //to check and fill.
324 duCfgParam.srvdCellLst[i].duCellInfo.epsTac.tac =DU_TAC; //to check and fill
327 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.nrArfcn = NR_ARFCN;
328 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.sulInfo.pres = TRUE;
329 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.sulInfo.sulArfcn = SUL_ARFCN;
330 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.sulInfo.sulTxBw.nrScs = SCS_15;
331 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.sulInfo.sulTxBw.nrb = NRB_160;
333 for(j=0;j<MAXNRCELLBANDS;j++)
335 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.freqBand[j].nrFreqBand = NR_FREQ_BAND;
336 for(k=0;k<MAXNRCELLBANDS;k++)
338 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.freqBand[j].sulBand[k] = SUL_BAND;
342 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.tdd.nrTxBw.nrScs = SCS_15;
343 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.tdd.nrTxBw.nrb = NRB_160;
345 /*Measurement Config and Cell Config */
346 duCfgParam.srvdCellLst[i].duCellInfo.measTimeCfg = TIME_CFG;
348 duCfgParam.srvdCellLst[i].duCellInfo.cellDir = CELL_DIR;
350 duCfgParam.srvdCellLst[i].duCellInfo.cellType=CELL_TYPE;
352 /* Broadcast PLMN Identity */
353 for(j=0;j<MAXBPLMNNRMINUS1;j++)
355 for(k=0;k<MAXNUMOFBPLMN;k++)
357 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].plmn[k].mcc[0] = PLMN_MCC0;
358 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].plmn[k].mcc[1] = PLMN_MCC1;
359 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].plmn[k].mcc[2] = PLMN_MCC2;
360 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].plmn[k].mnc[0] = PLMN_MNC0;
361 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].plmn[k].mnc[1] = PLMN_MNC1;
362 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].plmn[k].mnc[2] = PLMN_MNC2;
364 /* Extended PLMN List */
365 for(k=0;k<MAXNUMOFBPLMN;k++)
367 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].extPlmn[k].mcc[0] = PLMN_MCC0;
368 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].extPlmn[k].mcc[1] = PLMN_MCC1;
369 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].extPlmn[k].mcc[2] = PLMN_MCC2;
370 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].extPlmn[k].mnc[0] = PLMN_MNC0;
371 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].extPlmn[k].mnc[1] = PLMN_MNC1;
372 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].extPlmn[k].mnc[2] = PLMN_MNC2;
375 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].tac.pres = TRUE;
376 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].tac.tac = DU_TAC;
377 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].nrCellId = NR_CELL_ID;
378 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].ranac = NR_RANAC;
381 /*gnb DU System Info */
382 //TODO: uncomment duCfgParam.srvdCellLst[i].duSysInfo.mibMsg; //to do
383 //TODO: uncomment duCfgParam.srvdCellLst[i].duSysInfo.sib1Msg; //to do
386 /* RRC Version,Extended RRC Version */
387 //TODO: uncomment duCfgParam.rrcVersion.rrcVer; //to do
388 //TODO: uncomment duCfgParam.rrcVersion.extRrcVer; //to do
390 if(readClCfg() != ROK)
392 printf("\nFailed while reading CL config");
399 /*******************************************************************
401 * @brief Reads config and posts message to du_app on completion
409 * - Post to du_app for further processing
412 * @return ROK - success
415 * ****************************************************************/
420 //Read configs into duCfgParams
423 printf("\nReading configuration failed");
428 cmMemset((U8 *)&(pst), 0, sizeof(Pst));
429 pst.srcEnt = (Ent)ENTDUAPP;
430 pst.srcInst = (Inst)DU_INST;
431 pst.srcProcId = DU_PROC;
432 pst.dstEnt = pst.srcEnt;
433 pst.dstInst = pst.srcInst;
434 pst.dstProcId = pst.srcProcId;
436 pst.selector = DU_SELECTOR_TC;
440 if(SGetMsg(DFLT_REGION, DU_POOL, &mBuf) != ROK)
442 printf("\nMemory allocation failed in duReadCfg");
446 if (SPstTsk(&pst, mBuf) != ROK)
448 printf("\nSPstTsk failed in duReadCfg");
455 /**********************************************************************
457 **********************************************************************/