Trigger_macCellCfg
[o-du/l2.git] / src / du_app / du_cfg.c
1 /*******************************************************************************
2 ################################################################################
3 #   Copyright (c) [2017-2019] [Radisys]                                        #
4 #                                                                              #
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                                    #
8 #                                                                              #
9 #       http://www.apache.org/licenses/LICENSE-2.0                             #
10 #                                                                              #
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 *******************************************************************************/
18
19 /* This file contains all utility functions */
20 #include "du_mgr.h"
21 #include "MIB.h"
22 #include "PLMN-IdentityInfo.h"
23 #include "odu_common_codec.h"
24
25 extern DuCfgParams duCfgParam;
26 extern char encBuf[ENC_BUF_MAX_LEN];
27
28
29 /* Filling Slot configuration as :
30  * 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
31  *   0   DL    DL    DL    DL    DL    DL    DL    DL    DL    DL    DL    DL    DL    DL
32  *   1   DL    DL    DL    DL    DL    DL    DL    DL    DL    DL    DL    DL    DL    DL
33  *   2   DL    DL    DL    DL    DL    DL    DL    DL    DL    DL    DL    DL    DL    DL
34  *   3   DL    DL    DL    DL    DL    DL    DL    DL    DL    DL    GD    GD    GD    UL
35  *   4   UL    UL    UL    UL    UL    UL    UL    UL    UL    UL    UL    UL    UL    UL
36 */
37
38 /*******************************************************************
39  *
40  * @brief Fills the Slot configuration 
41  *
42  * @details
43  *
44  *    Function : FillSlotConfig
45  *
46  *    Functionality:Fill the Slot configuration values
47  * 
48  *  @params[in] void
49  * @return ROK     - success
50  *         RFAILED - failure
51  *
52  * ****************************************************************/
53 void FillSlotConfig()
54 {
55    U8 slot;
56    U8 symbol;
57
58    for(slot = 0; slot <= 3; slot++)
59    {
60       for(symbol = 0; symbol < MAX_SYMB_PER_SLOT; symbol++)
61          duCfgParam.macCellCfg.tddCfg.slotCfg[slot][symbol] = DL_SLOT;
62    }
63
64    duCfgParam.macCellCfg.tddCfg.slotCfg[3][10] = GUARD_SLOT;
65    duCfgParam.macCellCfg.tddCfg.slotCfg[3][11] = GUARD_SLOT;
66    duCfgParam.macCellCfg.tddCfg.slotCfg[3][12] = GUARD_SLOT;
67    duCfgParam.macCellCfg.tddCfg.slotCfg[3][13] = UL_SLOT;
68
69    for(symbol = 0; symbol < MAX_SYMB_PER_SLOT; symbol++)
70       duCfgParam.macCellCfg.tddCfg.slotCfg[4][symbol] = UL_SLOT;
71
72 }
73
74 /*******************************************************************
75  *
76  * @brief Reads the CL Configuration.
77  *
78  * @details
79  *
80  *    Function : readMacCfg
81  *
82  *    Functionality:
83  *       - Fills up the cell configuration for CL.
84  *       - Calls FillSlotConfig()  
85  *
86  * @params[in] void
87  * @return ROK     - success
88  *         RFAILED - failure
89  *
90  * ****************************************************************/
91
92
93 /* This function is used to fill up the cell configuration for CL */
94 S16 readMacCfg()
95 {
96    duCfgParam.macCellCfg.carrierId = CARRIER_IDX;
97
98    /* Cell configuration */
99    duCfgParam.macCellCfg.cellId = NR_CELL_ID;
100    duCfgParam.macCellCfg.phyCellId = NR_PCI;
101    duCfgParam.macCellCfg.dupType = DUPLEX_MODE;
102
103    /* DL carrier configuration */
104    duCfgParam.macCellCfg.dlCarrCfg.pres = TRUE;
105    duCfgParam.macCellCfg.dlCarrCfg.bw = SUL_ARFCN;
106    duCfgParam.macCellCfg.dlCarrCfg.freq = NR_ARFCN;
107    duCfgParam.macCellCfg.dlCarrCfg.k0[0] = 1;
108    duCfgParam.macCellCfg.dlCarrCfg.k0[1] = 1;
109    duCfgParam.macCellCfg.dlCarrCfg.k0[2] = 1;
110    duCfgParam.macCellCfg.dlCarrCfg.k0[3] = 1;
111    duCfgParam.macCellCfg.dlCarrCfg.k0[4] = 1;
112    duCfgParam.macCellCfg.dlCarrCfg.gridSize[0] = 1;
113    duCfgParam.macCellCfg.dlCarrCfg.gridSize[1] = 1;
114    duCfgParam.macCellCfg.dlCarrCfg.gridSize[2] = 1;
115    duCfgParam.macCellCfg.dlCarrCfg.gridSize[3] = 1;
116    duCfgParam.macCellCfg.dlCarrCfg.gridSize[4] = 1;
117    duCfgParam.macCellCfg.dlCarrCfg.numAnt = NUM_TX_ANT;
118
119    /* UL Carrier configuration */
120    duCfgParam.macCellCfg.ulCarrCfg.pres = TRUE;
121    duCfgParam.macCellCfg.ulCarrCfg.bw = SUL_ARFCN;
122    duCfgParam.macCellCfg.ulCarrCfg.freq = NR_ARFCN;
123    duCfgParam.macCellCfg.ulCarrCfg.k0[0] = 1;
124    duCfgParam.macCellCfg.ulCarrCfg.k0[1] = 1;
125    duCfgParam.macCellCfg.ulCarrCfg.k0[2] = 1;
126    duCfgParam.macCellCfg.ulCarrCfg.k0[3] = 1;
127    duCfgParam.macCellCfg.ulCarrCfg.k0[4] = 1;
128    duCfgParam.macCellCfg.ulCarrCfg.gridSize[0] = 1;
129    duCfgParam.macCellCfg.ulCarrCfg.gridSize[1] = 1;
130    duCfgParam.macCellCfg.ulCarrCfg.gridSize[2] = 1;
131    duCfgParam.macCellCfg.ulCarrCfg.gridSize[3] = 1;
132    duCfgParam.macCellCfg.ulCarrCfg.gridSize[4] = 1;
133    duCfgParam.macCellCfg.ulCarrCfg.numAnt = NUM_RX_ANT;
134
135    duCfgParam.macCellCfg.freqShft = FREQ_SHIFT_7P5KHZ;
136
137    /* SSB configuration */
138    duCfgParam.macCellCfg.ssbCfg.ssbPbchPwr = SSB_PBCH_PWR;
139    duCfgParam.macCellCfg.ssbCfg.bchPayloadFlag = BCH_PAYLOAD;
140    duCfgParam.macCellCfg.ssbCfg.scsCmn = SUBCARRIER_SPACING;
141    duCfgParam.macCellCfg.ssbCfg.ssbOffsetPointA = OFFSET_TO_POINT_A;
142    duCfgParam.macCellCfg.ssbCfg.betaPss = BETA_PSS;
143    duCfgParam.macCellCfg.ssbCfg.ssbPeriod = SSB_PERIODICITTY;
144    duCfgParam.macCellCfg.ssbCfg.ssbScOffset = SSB_SUBCARRIER_OFFSET;
145    duCfgParam.macCellCfg.ssbCfg.mibPdu[0] = 0x01;
146    duCfgParam.macCellCfg.ssbCfg.mibPdu[1] = 0x01;
147    duCfgParam.macCellCfg.ssbCfg.mibPdu[2] = 0x84;
148    duCfgParam.macCellCfg.ssbCfg.ssbMask[0] = 1; /* only one SSB is transmitted */
149    duCfgParam.macCellCfg.ssbCfg.ssbMask[1] = 0;
150    duCfgParam.macCellCfg.ssbCfg.multCarrBand = SSB_MULT_CARRIER_BAND;
151    duCfgParam.macCellCfg.ssbCfg.multCellCarr = MULT_CELL_CARRIER;
152
153    /* PRACH configuration */
154    duCfgParam.macCellCfg.prachCfg.pres = TRUE;
155    duCfgParam.macCellCfg.prachCfg.prachSeqLen = PRACH_SEQ_LEN;
156    duCfgParam.macCellCfg.prachCfg.prachSubcSpacing = PRACH_SUBCARRIER_SPACING;
157    duCfgParam.macCellCfg.prachCfg.prachRstSetCfg = PRACH_RESTRICTED_SET_CFG;
158    duCfgParam.macCellCfg.prachCfg.prachFdm = NUM_PRACH_FDM;
159    duCfgParam.macCellCfg.prachCfg.fdm[0].rootSeqIdx = ROOT_SEQ_IDX;
160    duCfgParam.macCellCfg.prachCfg.fdm[0].numRootSeq = NUM_ROOT_SEQ;
161    duCfgParam.macCellCfg.prachCfg.fdm[0].k1 = 1;
162    duCfgParam.macCellCfg.prachCfg.fdm[0].zeroCorrZoneCfg = ZERO_CORRELATION_ZONE_CFG;
163    duCfgParam.macCellCfg.prachCfg.fdm[0].numUnusedRootSeq = NUM_UNUSED_ROOT_SEQ;
164    DU_ALLOC(duCfgParam.macCellCfg.prachCfg.fdm[0].unsuedRootSeq, NUM_UNUSED_ROOT_SEQ * sizeof(U8));
165    if(duCfgParam.macCellCfg.prachCfg.fdm[0].unsuedRootSeq == NULLP)
166    {
167       DU_LOG("\nDU_APP : Memory allocation failed");
168       RETVALUE(RFAILED);
169    }
170    *(duCfgParam.macCellCfg.prachCfg.fdm[0].unsuedRootSeq) = UNUSED_ROOT_SEQ;
171    duCfgParam.macCellCfg.prachCfg.ssbPerRach = SSB_PER_RACH;
172    duCfgParam.macCellCfg.prachCfg.prachMultCarrBand = PRACH_MULT_CARRIER_BAND;
173
174    /* TDD configuration */
175    duCfgParam.macCellCfg.tddCfg.pres = TRUE;
176    duCfgParam.macCellCfg.tddCfg.tddPeriod = TDD_PERIODICITY;
177
178    FillSlotConfig();
179
180    /* RSSI Measurement configuration */
181    duCfgParam.macCellCfg.rssiUnit = RSS_MEASUREMENT_UNIT;
182
183    /* fill SIB1 configuration */
184    duCfgParam.macCellCfg.sib1Cfg.sib1PduLen = duCfgParam.srvdCellLst[0].duSysInfo.sib1Len;
185    DU_ALLOC(duCfgParam.macCellCfg.sib1Cfg.sib1Pdu,duCfgParam.srvdCellLst[0].duSysInfo.sib1Len);
186    memcpy(duCfgParam.macCellCfg.sib1Cfg.sib1Pdu, duCfgParam.srvdCellLst[0].duSysInfo.sib1Msg, \
187           duCfgParam.srvdCellLst[0].duSysInfo.sib1Len);
188    duCfgParam.macCellCfg.sib1Cfg.sib1NewTxPeriod = SIB1_NEW_TX_PERIOD;
189    duCfgParam.macCellCfg.sib1Cfg.sib1RepetitionPeriod = SIB1_REPETITION_PERIOD;
190    duCfgParam.macCellCfg.sib1Cfg.coresetZeroIndex = CORESET_0_INDEX;
191    duCfgParam.macCellCfg.sib1Cfg.searchSpaceZeroIndex = SEARCHSPACE_0_INDEX;
192    duCfgParam.macCellCfg.sib1Cfg.sib1Mcs = SIB1_MCS;
193
194    /* This should be calculated based on
195       (number of mandatory parameters) + (number of otional parameters being filled) */
196    duCfgParam.macCellCfg.numTlv = 39;
197
198    RETVALUE(ROK);
199 }
200
201 /*******************************************************************
202  *
203  * @brief Configures the DU Parameters
204  *
205  * @details
206  *
207  *    Function : fillDuPort
208  *
209  *    Functionality:
210  *       - fills the DU Ports.  
211  *
212  * @params[in] duPort array to be filled
213  * @return ROK     - success
214  *         RFAILED - failure
215  *
216  * ****************************************************************/
217
218 S16 fillDuPort(U16 *duPort)
219 {
220    duPort[F1_INTERFACE]   = DU_PORT;     /* DU Port idx  0 38472 */
221    duPort[E2_INTERFACE]   = RIC_PORT;    /* RIC Port idx 1 38482 */
222
223    RETVALUE(ROK);
224 }
225
226 /*******************************************************************
227  *
228  * @brief Configures the DU Parameters
229  *
230  * @details
231  *
232  *    Function : readCfg
233  *
234  *    Functionality:
235  *       - Initializes the DuCfg members.  
236  *       - Calls readMacCfg()  
237  *
238  * @params[in] system task ID
239  * @return ROK     - success
240  *         RFAILED - failure
241  *
242  * ****************************************************************/
243
244 S16 readCfg()
245 {
246    U8 i,j,k;
247    U32 ipv4_du, ipv4_cu, ipv4_ric;
248         MibParams mib;
249    Sib1Params sib1;     
250
251    cmInetAddr((S8*)DU_IP_V4_ADDR, &ipv4_du);
252    cmInetAddr((S8*)CU_IP_V4_ADDR, &ipv4_cu);
253    cmInetAddr((S8*)RIC_IP_V4_ADDR, &ipv4_ric);
254    fillDuPort(duCfgParam.sctpParams.duPort);
255
256    /* F1 DU IP Address and Port*/
257    duCfgParam.sctpParams.duIpAddr.ipV4Addr = ipv4_du;
258
259    /* F1 CU IP Address and Port*/
260    duCfgParam.sctpParams.cuIpAddr.ipV4Addr = ipv4_cu;
261    duCfgParam.sctpParams.cuPort = CU_PORT;
262
263    /* Fill RIC Params */
264    duCfgParam.sctpParams.ricIpAddr.ipV4Addr = ipv4_ric;
265    duCfgParam.sctpParams.ricPort            = RIC_PORT;
266
267
268    /* EGTP Parameters */
269    duCfgParam.egtpParams.localIp.ipV4Pres = TRUE;
270    duCfgParam.egtpParams.localIp.ipV4Addr = ipv4_du;
271    duCfgParam.egtpParams.localPort = DU_EGTP_PORT;
272    duCfgParam.egtpParams.destIp.ipV4Pres = TRUE;
273    duCfgParam.egtpParams.destIp.ipV4Addr = ipv4_cu;
274    duCfgParam.egtpParams.destPort = CU_EGTP_PORT;
275    duCfgParam.egtpParams.minTunnelId = 0;
276    duCfgParam.egtpParams.maxTunnelId = 10;
277
278    duCfgParam.maxUe = 32; //TODO: Check
279    /* DU Info */        
280    duCfgParam.duId = DU_ID;     
281    strcpy((char*)duCfgParam.duName,DU_NAME);
282
283    /* Mib Params */
284         mib.sysFrmNum = SYS_FRAME_NUM;
285         mib.subCarrierSpacingCommon = MIB__subCarrierSpacingCommon_scs15or60;
286         mib.ssb_SubcarrierOffset = SSB_SC_OFFSET; 
287         mib.dmrs_TypeA_Position = MIB__dmrs_TypeA_Position_pos2;
288         mib.controlResourceSetZero = CORESET_ZERO;
289         mib.searchSpaceZero = SEARCH_SPACE_ZERO;
290         mib.cellBarred = MIB__cellBarred_barred;
291         mib.intraFreqReselection =
292                 MIB__intraFreqReselection_notAllowed;
293         duCfgParam.mibParams = mib;
294
295    /* SIB1 Params */
296         sib1.plmn.mcc[0] = PLMN_MCC0;
297         sib1.plmn.mcc[1] = PLMN_MCC1;
298         sib1.plmn.mcc[2] = PLMN_MCC2;
299         sib1.plmn.mnc[0] = PLMN_MNC0;
300         sib1.plmn.mnc[1] = PLMN_MNC1;
301         sib1.plmn.mnc[2] = PLMN_MNC2;
302         sib1.tac = DU_TAC;
303         sib1.ranac = DU_RANAC;
304         sib1.cellIdentity = CELL_IDENTITY;
305         sib1.cellResvdForOpUse =\ 
306                 PLMN_IdentityInfo__cellReservedForOperatorUse_notReserved;
307         duCfgParam.sib1Params = sib1;
308
309    for(i=0; i<DEFAULT_CELLS; i++)
310    { 
311       duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.nrCgi.plmn.mcc[0] = PLMN_MCC0;
312       duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.nrCgi.plmn.mcc[1] = PLMN_MCC1;
313       duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.nrCgi.plmn.mcc[2] = PLMN_MCC2;
314       duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.nrCgi.plmn.mnc[0] = PLMN_MNC0;
315       duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.nrCgi.plmn.mnc[1] = PLMN_MNC1;
316       duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.nrCgi.plmn.mnc[2] = PLMN_MNC2;
317
318       /*Cell ID */
319       duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.nrCgi.cellId = NR_CELL_ID;
320       duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.nrPci = NR_PCI;
321
322       /* List of Available PLMN */
323       for(j=0;j<MAX_PLMN;j++)
324       {
325          duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.plmn[j].mcc[0] = PLMN_MCC0;
326          duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.plmn[j].mcc[1] = PLMN_MCC1;
327          duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.plmn[j].mcc[2] = PLMN_MCC2;
328          duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.plmn[j].mnc[0] = PLMN_MNC0;
329          duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.plmn[j].mnc[1] = PLMN_MNC1;
330          duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.plmn[j].mnc[2] = PLMN_MNC2;
331       }
332       /* List of Extended PLMN */
333       for(j=0;j<MAX_PLMN;j++)
334       {
335          duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.extPlmn[j].mcc[0] = PLMN_MCC0;
336          duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.extPlmn[j].mcc[1] = PLMN_MCC1;
337          duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.extPlmn[j].mcc[2] = PLMN_MCC2;
338          duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.extPlmn[j].mnc[0] = PLMN_MNC0;
339          duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.extPlmn[j].mnc[1] = PLMN_MNC1;
340          duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.extPlmn[j].mnc[2] = PLMN_MNC2;
341       } 
342
343       /* TAC and EPSTAC */
344       duCfgParam.srvdCellLst[i].duCellInfo.tac = DU_TAC;
345       duCfgParam.srvdCellLst[i].duCellInfo.epsTac = DU_TAC; //to check and fill
346       /* NR Mode info */
347       duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.nrArfcn = NR_ARFCN;
348       duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.sulInfo.sulArfcn = SUL_ARFCN;
349       duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.sulInfo.sulTxBw.nrScs = SCS_120;
350       duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.sulInfo.sulTxBw.nrb = NRB_66;
351
352 #if 0
353       /* NR Mode info */
354       duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.nrArfcn = NR_ARFCN;
355       duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.sulInfo.sulArfcn = SUL_ARFCN;
356       duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.sulInfo.sulTxBw.nrScs = SCS_15;           
357       duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.sulInfo.sulTxBw.nrb = NRB_160;           
358
359       for(j=0;j<MAXNRCELLBANDS;j++)
360       {
361          duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.freqBand[j].nrFreqBand = NR_FREQ_BAND;
362          for(k=0;k<MAXNRCELLBANDS;k++)
363          {
364             duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.freqBand[j].sulBand[k] = SUL_BAND;  
365          }
366       }
367 #endif
368       for(j=0;j<MAXNRCELLBANDS;j++)
369       {
370          duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.freqBand[j].nrFreqBand = NR_FREQ_BAND;
371          for(k=0;k<MAXNRCELLBANDS;k++)
372          {
373             duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.freqBand[j].sulBand[k] = SUL_BAND;
374          }
375       }
376       duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.nrArfcn = NR_ARFCN;
377       duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.sulInfo.sulArfcn = SUL_ARFCN;
378       duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.sulInfo.sulTxBw.nrScs = SCS_120;
379       duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.sulInfo.sulTxBw.nrb = NRB_66;
380       for(j=0;j<MAXNRCELLBANDS;j++)
381       {
382          duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.freqBand[j].nrFreqBand = NR_FREQ_BAND;
383          for(k=0;k<MAXNRCELLBANDS;k++)
384          {
385             duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.freqBand[j].sulBand[k] = SUL_BAND;
386          }
387       }
388
389       duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.ulTxBw.nrScs = SCS_120;
390       duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.ulTxBw.nrb = NRB_66;
391
392       duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.dlTxBw.nrScs = SCS_120;
393       duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.dlTxBw.nrb = NRB_66;
394
395 #if 0
396       duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.tdd.nrTxBw.nrScs = SCS_15;
397       duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.tdd.nrTxBw.nrb = NRB_160;
398 #endif
399       /*Measurement Config and Cell Config */ 
400       duCfgParam.srvdCellLst[i].duCellInfo.measTimeCfg = TIME_CFG; 
401
402       duCfgParam.srvdCellLst[i].duCellInfo.cellDir = DL_UL; 
403
404       duCfgParam.srvdCellLst[i].duCellInfo.cellType=CELL_TYPE;
405
406       /* Broadcast PLMN Identity */
407       for(j=0;j<MAXBPLMNNRMINUS1;j++)
408       {  
409          for(k=0;k<MAX_PLMN;k++)
410          {
411             duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].plmn[k].mcc[0] = PLMN_MCC0;
412             duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].plmn[k].mcc[1] = PLMN_MCC1;
413             duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].plmn[k].mcc[2] = PLMN_MCC2;
414             duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].plmn[k].mnc[0] = PLMN_MNC0;
415             duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].plmn[k].mnc[1] = PLMN_MNC1;                                         
416             duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].plmn[k].mnc[2] = PLMN_MNC2;
417          }
418          /* Extended PLMN List */        
419          for(k=0;k<MAX_PLMN;k++)
420          {
421             duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].extPlmn[k].mcc[0] = PLMN_MCC0;
422             duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].extPlmn[k].mcc[1] = PLMN_MCC1;
423             duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].extPlmn[k].mcc[2] = PLMN_MCC2;
424             duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].extPlmn[k].mnc[0] = PLMN_MNC0;
425             duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].extPlmn[k].mnc[1] = PLMN_MNC1;
426             duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].extPlmn[k].mnc[2] = PLMN_MNC2;
427          }
428
429          duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].tac = DU_TAC;
430          duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].nrCellId = NR_CELL_ID;
431          duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].ranac = NR_RANAC;
432       }
433
434       /*gnb DU System Info mib msg*/
435            BuildMibMsg();
436                 DU_ALLOC(duCfgParam.srvdCellLst[i].duSysInfo.mibMsg,\
437                                 strlen(encBuf));
438            if(!(duCfgParam.srvdCellLst[i].duSysInfo.mibMsg))
439                 {
440          DU_LOG("\nDU_APP: Memory allocation failure");
441                         return RFAILED;
442                 }
443                 strcpy(duCfgParam.srvdCellLst[i].duSysInfo.mibMsg, encBuf);
444                 duCfgParam.srvdCellLst[i].duSysInfo.mibLen = encBufSize;
445
446       /*gnb DU System Info mib msg*/
447       BuildSib1Msg();
448                 DU_ALLOC(duCfgParam.srvdCellLst[i].duSysInfo.sib1Msg,\
449                                 encBufSize);
450            if(!(duCfgParam.srvdCellLst[i].duSysInfo.sib1Msg))
451                 {
452          DU_LOG("\nDU_APP: Memory allocation failure");
453                         return RFAILED;
454                 }
455                 memcpy(duCfgParam.srvdCellLst[i].duSysInfo.sib1Msg,\
456                        encBuf,encBufSize);
457                 duCfgParam.srvdCellLst[i].duSysInfo.sib1Len = encBufSize;
458
459    }
460
461    if(readMacCfg() != ROK)
462    {
463       DU_LOG("\nDU_APP : Failed while reading MAC config");
464       RETVALUE(RFAILED);
465    }
466
467    RETVALUE(ROK);
468 }
469
470 /*******************************************************************
471  *
472  * @brief Reads config and posts message to du_app on completion
473  *
474  * @details
475  *
476  *    Function : main
477  *
478  *    Functionality:
479  *      - Calls readCfg()
480  *      - Post to du_app for further processing
481  *
482  * @params[in] void
483  * @return ROK     - success
484  *         RFAILED - failure
485  *
486  * ****************************************************************/
487 S16 duReadCfg()
488 {
489    Pst pst;
490    Buffer *mBuf;
491
492    cmMemset((U8 *)&duCfgParam, 0, sizeof(DuCfgParams));
493    //Read configs into duCfgParams
494    if(readCfg() != ROK)
495    {
496       DU_LOG("\nDU_APP : Reading configuration failed");
497       RETVALUE(RFAILED);
498    }
499
500    //Fill pst structure
501    cmMemset((U8 *)&(pst), 0, sizeof(Pst));
502    pst.srcEnt = (Ent)ENTDUAPP;
503    pst.srcInst = (Inst)DU_INST;
504    pst.srcProcId = DU_PROC;
505    pst.dstEnt = pst.srcEnt;
506    pst.dstInst = pst.srcInst;
507    pst.dstProcId = pst.srcProcId;
508    pst.event = EVTCFG;
509    pst.selector = DU_SELECTOR_TC;
510    pst.pool= DU_POOL;
511
512
513    if(SGetMsg(DFLT_REGION, DU_POOL, &mBuf) != ROK)
514    {
515       DU_LOG("\nDU_APP : Memory allocation failed in duReadCfg");
516       return RFAILED;
517    }
518
519    if (SPstTsk(&pst, mBuf) != ROK)
520    {
521       DU_LOG("\nDU_APP : SPstTsk failed in duReadCfg");
522       return RFAILED;
523    }
524
525    return ROK;
526 }
527
528 /*******************************************************************
529  *
530  * @brief Converts bit strings to integer
531  *
532  * @details
533  *
534  *    Function : bitStringToInt
535  *
536  *    Functionality:
537  *      - Converts ASN bit string format IEs to integer type
538  *
539  * @params[in] void
540  * @return ROK     - success
541  *         RFAILED - failure
542  *
543  * ****************************************************************/
544 S16 bitStringToInt(BIT_STRING_t *bitString, U16 *val)
545 {
546    U16 numOctets, idx;
547    if(bitString->buf == NULL || bitString->size <= 0)
548    {
549       DU_LOG("\nDU_APP : Bit string is empty");
550       return RFAILED;
551    }
552
553    for(idx=0; idx<bitString->size-1; idx++)
554    {
555       *val |= bitString->buf[idx];
556       *val <<= 8;
557    }
558
559    *val |= bitString->buf[idx];
560    *val >>= bitString->bits_unused;
561
562    return ROK;
563 }
564
565
566 /**********************************************************************
567   End of file
568  **********************************************************************/
569