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 "du_cfg_hdl.h"
22 extern DuCfgParams duCfgParam;
25 /* Filling Slot configuration as :
26 * 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
27 * 0 DL DL DL DL DL DL DL DL DL DL DL DL DL DL
28 * 1 DL DL DL DL DL DL DL DL DL DL DL DL DL DL
29 * 2 DL DL DL DL DL DL DL DL DL DL DL DL DL DL
30 * 3 DL DL DL DL DL DL DL DL DL DL GD GD GD UL
31 * 4 UL UL UL UL UL UL UL UL UL UL UL UL UL UL
34 /*******************************************************************
36 * @brief Fills the Slot configuration
40 * Function : fillSlotConfig
42 * Functionality:Fill the Slot configuration values
45 * @return ROK - success
48 * ****************************************************************/
54 for(slot = 0; slot <= 3; slot++)
56 for(symbol = 0; symbol < MAX_SYMB_PER_SLOT; symbol++)
57 duCfgParam.clCellCfg.tddCfg.slotCfg[slot][symbol] = DL_SLOT;
60 duCfgParam.clCellCfg.tddCfg.slotCfg[3][10] = GUARD_SLOT;
61 duCfgParam.clCellCfg.tddCfg.slotCfg[3][11] = GUARD_SLOT;
62 duCfgParam.clCellCfg.tddCfg.slotCfg[3][12] = GUARD_SLOT;
63 duCfgParam.clCellCfg.tddCfg.slotCfg[3][13] = UL_SLOT;
65 for(symbol = 0; symbol < MAX_SYMB_PER_SLOT; symbol++)
66 duCfgParam.clCellCfg.tddCfg.slotCfg[4][symbol] = UL_SLOT;
70 /*******************************************************************
72 * @brief Reads the CL Configuration.
76 * Function : readClCfg
79 * - Fills up the cell configuration for CL.
80 * - Calls fillSlotConfig()
83 * @return ROK - success
86 * ****************************************************************/
89 /* This function is used to fill up the cell configuration for CL */
92 duCfgParam.clCellCfg.carrierId = CARRIER_IDX;
94 /* Cell configuration */
95 duCfgParam.clCellCfg.cellId = NR_CELL_ID;
96 duCfgParam.clCellCfg.phyCellId = NR_PCI;
97 duCfgParam.clCellCfg.dupType = DUPLEX_MODE;
99 /* DL carrier configuration */
100 duCfgParam.clCellCfg.dlCarrCfg.pres = TRUE;
101 duCfgParam.clCellCfg.dlCarrCfg.bw = SUL_ARFCN;
102 duCfgParam.clCellCfg.dlCarrCfg.freq = NR_ARFCN;
103 duCfgParam.clCellCfg.dlCarrCfg.k0[0] = 1;
104 duCfgParam.clCellCfg.dlCarrCfg.k0[1] = 1;
105 duCfgParam.clCellCfg.dlCarrCfg.k0[2] = 1;
106 duCfgParam.clCellCfg.dlCarrCfg.k0[3] = 1;
107 duCfgParam.clCellCfg.dlCarrCfg.k0[4] = 1;
108 duCfgParam.clCellCfg.dlCarrCfg.gridSize[0] = 1;
109 duCfgParam.clCellCfg.dlCarrCfg.gridSize[1] = 1;
110 duCfgParam.clCellCfg.dlCarrCfg.gridSize[2] = 1;
111 duCfgParam.clCellCfg.dlCarrCfg.gridSize[3] = 1;
112 duCfgParam.clCellCfg.dlCarrCfg.gridSize[4] = 1;
113 duCfgParam.clCellCfg.dlCarrCfg.numAnt = NUM_TX_ANT;
115 /* UL Carrier configuration */
116 duCfgParam.clCellCfg.ulCarrCfg.pres = TRUE;
117 duCfgParam.clCellCfg.ulCarrCfg.bw = SUL_ARFCN;
118 duCfgParam.clCellCfg.ulCarrCfg.freq = NR_ARFCN;
119 duCfgParam.clCellCfg.ulCarrCfg.k0[0] = 1;
120 duCfgParam.clCellCfg.ulCarrCfg.k0[1] = 1;
121 duCfgParam.clCellCfg.ulCarrCfg.k0[2] = 1;
122 duCfgParam.clCellCfg.ulCarrCfg.k0[3] = 1;
123 duCfgParam.clCellCfg.ulCarrCfg.k0[4] = 1;
124 duCfgParam.clCellCfg.ulCarrCfg.gridSize[0] = 1;
125 duCfgParam.clCellCfg.ulCarrCfg.gridSize[1] = 1;
126 duCfgParam.clCellCfg.ulCarrCfg.gridSize[2] = 1;
127 duCfgParam.clCellCfg.ulCarrCfg.gridSize[3] = 1;
128 duCfgParam.clCellCfg.ulCarrCfg.gridSize[4] = 1;
129 duCfgParam.clCellCfg.ulCarrCfg.numAnt = NUM_RX_ANT;
131 duCfgParam.clCellCfg.freqShft = FREQ_SHIFT_7P5KHZ;
133 /* SSB configuration */
134 duCfgParam.clCellCfg.ssbCfg.ssbPbchPwr = SSB_PBCH_PWR;
135 duCfgParam.clCellCfg.ssbCfg.bchPayload = BCH_PAYLOAD;
136 duCfgParam.clCellCfg.ssbCfg.scsCmn = SUBCARRIER_SPACING;
137 duCfgParam.clCellCfg.ssbCfg.ssbPrbOffset = PRB_OFFSET;
138 duCfgParam.clCellCfg.ssbCfg.betaPss = BETA_PSS;
139 duCfgParam.clCellCfg.ssbCfg.ssbPeriod = SSB_PERIODICITTY;
140 duCfgParam.clCellCfg.ssbCfg.ssbSubcOffset = SSB_SUBCARRIER_OFFSET;
141 duCfgParam.clCellCfg.ssbCfg.mibPdu = 104;
142 duCfgParam.clCellCfg.ssbCfg.nSSBMask[0] = 2162721;
143 duCfgParam.clCellCfg.ssbCfg.nSSBMask[1] = 0;
144 duCfgParam.clCellCfg.ssbCfg.multCarrBand = SSB_MULT_CARRIER_BAND;
145 duCfgParam.clCellCfg.ssbCfg.multCellCarr = MULT_CELL_CARRIER;
147 /* PRACH configuration */
148 duCfgParam.clCellCfg.prachCfg.pres = TRUE;
149 duCfgParam.clCellCfg.prachCfg.prachSeqLen = PRACH_SEQ_LEN;
150 duCfgParam.clCellCfg.prachCfg.prachSubcSpacing = PRACH_SUBCARRIER_SPACING;
151 duCfgParam.clCellCfg.prachCfg.prachRstSetCfg = PRACH_RESTRICTED_SET_CFG;
152 duCfgParam.clCellCfg.prachCfg.prachFdm = NUM_PRACH_FDM;
153 duCfgParam.clCellCfg.prachCfg.fdm[0].rootSeqIdx = ROOT_SEQ_IDX;
154 duCfgParam.clCellCfg.prachCfg.fdm[0].numRootSeq = NUM_ROOT_SEQ;
155 duCfgParam.clCellCfg.prachCfg.fdm[0].k1 = 1;
156 duCfgParam.clCellCfg.prachCfg.fdm[0].zeroCorrZoneCfg = ZERO_CORRELATION_ZONE_CFG;
157 duCfgParam.clCellCfg.prachCfg.fdm[0].numUnusedRootSeq = NUM_UNUSED_ROOT_SEQ;
158 DU_ALLOC(duCfgParam.clCellCfg.prachCfg.fdm[0].unsuedRootSeq, NUM_UNUSED_ROOT_SEQ * sizeof(U8));
159 if(duCfgParam.clCellCfg.prachCfg.fdm[0].unsuedRootSeq == NULLP)
161 DU_LOG("\nDU_APP : Memory allocation failed");
164 *(duCfgParam.clCellCfg.prachCfg.fdm[0].unsuedRootSeq) = UNUSED_ROOT_SEQ;
165 duCfgParam.clCellCfg.prachCfg.ssbPerRach = SSB_PER_RACH;
166 duCfgParam.clCellCfg.prachCfg.prachMultCarrBand = PRACH_MULT_CARRIER_BAND;
168 /* TDD configuration */
169 duCfgParam.clCellCfg.tddCfg.pres = TRUE;
170 duCfgParam.clCellCfg.tddCfg.tddPeriod = TDD_PERIODICITY;
174 /* RSSI Measurement configuration */
175 duCfgParam.clCellCfg.rssiUnit = RSS_MEASUREMENT_UNIT;
177 /* This should be calculated based on
178 (number of mandatory parameters) + (number of otional parameters being filled) */
179 duCfgParam.clCellCfg.numTlv = 39;
183 /*******************************************************************
185 * @brief Configures the DU Parameters
192 * - Initializes the DuCfg members.
193 * - Calls readClCfg()
195 * @params[in] system task ID
196 * @return ROK - success
199 * ****************************************************************/
204 U32 ipv4_du, ipv4_cu;
206 cmInetAddr((S8*)DU_IP_V4_ADDR, &ipv4_du);
207 cmInetAddr((S8*)CU_IP_V4_ADDR, &ipv4_cu);
209 /* F1 DU IP Address and Port*/
210 duCfgParam.sctpParams.duIpAddr.ipV4Pres = TRUE;
211 duCfgParam.sctpParams.duIpAddr.ipV4Addr = ipv4_du;
212 duCfgParam.sctpParams.duPort = DU_PORT;
214 /* F1 CU IP Address and Port*/
215 duCfgParam.sctpParams.cuIpAddr.ipV4Pres = TRUE;
216 duCfgParam.sctpParams.cuIpAddr.ipV4Addr = ipv4_cu;
217 duCfgParam.sctpParams.cuPort = CU_PORT;
220 /* EGTP Parameters */
221 duCfgParam.egtpParams.localIp.ipV4Pres = TRUE;
222 duCfgParam.egtpParams.localIp.ipV4Addr = ipv4_du;
223 duCfgParam.egtpParams.localPort = DU_EGTP_PORT;
224 duCfgParam.egtpParams.destIp.ipV4Pres = TRUE;
225 duCfgParam.egtpParams.destIp.ipV4Addr = ipv4_cu;
226 duCfgParam.egtpParams.destPort = CU_EGTP_PORT;
227 duCfgParam.egtpParams.minTunnelId = 0;
228 duCfgParam.egtpParams.maxTunnelId = 10;
230 duCfgParam.maxUe = 32; //TODO: Check
232 duCfgParam.duId = DU_ID;
233 strcpy((char*)duCfgParam.duName,DU_NAME);
235 for(i=0; i<DEFAULT_CELLS; i++)
237 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.nrCgi.plmn.mcc[0] = PLMN_MCC0;
238 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.nrCgi.plmn.mcc[1] = PLMN_MCC1;
239 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.nrCgi.plmn.mcc[2] = PLMN_MCC2;
240 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.nrCgi.plmn.mnc[0] = PLMN_MNC0;
241 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.nrCgi.plmn.mnc[1] = PLMN_MNC1;
242 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.nrCgi.plmn.mnc[2] = PLMN_MNC2;
245 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.nrCgi.cellId = NR_CELL_ID;
246 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.nrPci = NR_PCI;
248 /* List of Available PLMN */
249 for(j=0;j<MAX_PLMN;j++)
251 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.plmn[j].mcc[0] = PLMN_MCC0;
252 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.plmn[j].mcc[1] = PLMN_MCC1;
253 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.plmn[j].mcc[2] = PLMN_MCC2;
254 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.plmn[j].mnc[0] = PLMN_MNC0;
255 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.plmn[j].mnc[1] = PLMN_MNC1;
256 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.plmn[j].mnc[2] = PLMN_MNC2;
258 /* List of Extended PLMN */
259 for(j=0;j<MAX_PLMN;j++)
261 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.extPlmn[j].mcc[0] = PLMN_MCC0;
262 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.extPlmn[j].mcc[1] = PLMN_MCC1;
263 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.extPlmn[j].mcc[2] = PLMN_MCC2;
264 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.extPlmn[j].mnc[0] = PLMN_MNC0;
265 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.extPlmn[j].mnc[1] = PLMN_MNC1;
266 duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.extPlmn[j].mnc[2] = PLMN_MNC2;
270 duCfgParam.srvdCellLst[i].duCellInfo.tac = DU_TAC;
271 duCfgParam.srvdCellLst[i].duCellInfo.epsTac = DU_TAC; //to check and fill
273 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.nrArfcn = NR_ARFCN;
274 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.sulInfo.sulArfcn = SUL_ARFCN;
275 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.sulInfo.sulTxBw.nrScs = SCS_120;
276 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.sulInfo.sulTxBw.nrb = NRB_66;
280 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.nrArfcn = NR_ARFCN;
281 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.sulInfo.sulArfcn = SUL_ARFCN;
282 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.sulInfo.sulTxBw.nrScs = SCS_15;
283 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.sulInfo.sulTxBw.nrb = NRB_160;
285 for(j=0;j<MAXNRCELLBANDS;j++)
287 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.freqBand[j].nrFreqBand = NR_FREQ_BAND;
288 for(k=0;k<MAXNRCELLBANDS;k++)
290 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.freqBand[j].sulBand[k] = SUL_BAND;
294 for(j=0;j<MAXNRCELLBANDS;j++)
296 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.freqBand[j].nrFreqBand = NR_FREQ_BAND;
297 for(k=0;k<MAXNRCELLBANDS;k++)
299 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.freqBand[j].sulBand[k] = SUL_BAND;
302 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.nrArfcn = NR_ARFCN;
303 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.sulInfo.sulArfcn = SUL_ARFCN;
304 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.sulInfo.sulTxBw.nrScs = SCS_120;
305 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.sulInfo.sulTxBw.nrb = NRB_66;
306 for(j=0;j<MAXNRCELLBANDS;j++)
308 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.freqBand[j].nrFreqBand = NR_FREQ_BAND;
309 for(k=0;k<MAXNRCELLBANDS;k++)
311 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.freqBand[j].sulBand[k] = SUL_BAND;
315 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.ulTxBw.nrScs = SCS_120;
316 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.ulTxBw.nrb = NRB_66;
318 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.dlTxBw.nrScs = SCS_120;
319 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.dlTxBw.nrb = NRB_66;
322 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.tdd.nrTxBw.nrScs = SCS_15;
323 duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.tdd.nrTxBw.nrb = NRB_160;
325 /*Measurement Config and Cell Config */
326 duCfgParam.srvdCellLst[i].duCellInfo.measTimeCfg = TIME_CFG;
328 duCfgParam.srvdCellLst[i].duCellInfo.cellDir = DL_UL;
330 duCfgParam.srvdCellLst[i].duCellInfo.cellType=CELL_TYPE;
332 /* Broadcast PLMN Identity */
333 for(j=0;j<MAXBPLMNNRMINUS1;j++)
335 for(k=0;k<MAX_PLMN;k++)
337 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].plmn[k].mcc[0] = PLMN_MCC0;
338 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].plmn[k].mcc[1] = PLMN_MCC1;
339 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].plmn[k].mcc[2] = PLMN_MCC2;
340 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].plmn[k].mnc[0] = PLMN_MNC0;
341 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].plmn[k].mnc[1] = PLMN_MNC1;
342 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].plmn[k].mnc[2] = PLMN_MNC2;
344 /* Extended PLMN List */
345 for(k=0;k<MAX_PLMN;k++)
347 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].extPlmn[k].mcc[0] = PLMN_MCC0;
348 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].extPlmn[k].mcc[1] = PLMN_MCC1;
349 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].extPlmn[k].mcc[2] = PLMN_MCC2;
350 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].extPlmn[k].mnc[0] = PLMN_MNC0;
351 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].extPlmn[k].mnc[1] = PLMN_MNC1;
352 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].extPlmn[k].mnc[2] = PLMN_MNC2;
355 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].tac = DU_TAC;
356 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].nrCellId = NR_CELL_ID;
357 duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].ranac = NR_RANAC;
360 /*gnb DU System Info */
361 //TODO: uncomment duCfgParam.srvdCellLst[i].duSysInfo.mibMsg; //to do
362 //TODO: uncomment duCfgParam.srvdCellLst[i].duSysInfo.sib1Msg; //to do
365 /* RRC Version,Extended RRC Version */
366 //TODO: uncomment duCfgParam.rrcVersion.rrcVer; //to do
367 //TODO: uncomment duCfgParam.rrcVersion.extRrcVer; //to do
369 if(readClCfg() != ROK)
371 DU_LOG("\nDU_APP : Failed while reading CL config");
378 /*******************************************************************
380 * @brief Reads config and posts message to du_app on completion
388 * - Post to du_app for further processing
391 * @return ROK - success
394 * ****************************************************************/
400 cmMemset((U8 *)&duCfgParam, 0, sizeof(DuCfgParams));
401 //Read configs into duCfgParams
404 DU_LOG("\nDU_APP : Reading configuration failed");
409 cmMemset((U8 *)&(pst), 0, sizeof(Pst));
410 pst.srcEnt = (Ent)ENTDUAPP;
411 pst.srcInst = (Inst)DU_INST;
412 pst.srcProcId = DU_PROC;
413 pst.dstEnt = pst.srcEnt;
414 pst.dstInst = pst.srcInst;
415 pst.dstProcId = pst.srcProcId;
417 pst.selector = DU_SELECTOR_TC;
421 if(SGetMsg(DFLT_REGION, DU_POOL, &mBuf) != ROK)
423 DU_LOG("\nDU_APP : Memory allocation failed in duReadCfg");
427 if (SPstTsk(&pst, mBuf) != ROK)
429 DU_LOG("\nDU_APP : SPstTsk failed in duReadCfg");
436 /*******************************************************************
438 * @brief Converts bit strings to integer
442 * Function : bitStringToInt
445 * - Converts ASN bit string format IEs to integer type
448 * @return ROK - success
451 * ****************************************************************/
452 S16 bitStringToInt(BIT_STRING_t *bitString, U16 *val)
455 if(bitString->buf == NULL || bitString->size <= 0)
457 DU_LOG("\nDU_APP : Bit string is empty");
461 numOctets = (bitString->size + 7 )/8;
462 for(idx=0; idx< numOctets; idx++)
464 *val |= bitString->buf[idx];
468 *val |= bitString->buf[numOctets -1];
469 *val >>= ((numOctets * 8) - bitString->size);
475 /**********************************************************************
477 **********************************************************************/