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