Added missing files
[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_cfg.h"
21
22 extern DuCfgParams duCfgParam;
23
24
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
32 */
33
34 /*******************************************************************
35  *
36  * @brief Fills the Slot configuration 
37  *
38  * @details
39  *
40  *    Function : fillSlotConfig
41  *
42  *    Functionality:Fill the Slot configuration values
43  * 
44  *  @params[in] void
45  * @return ROK     - success
46  *         RFAILED - failure
47  *
48  * ****************************************************************/
49 void fillSlotConfig()
50 {
51    U8 slot;
52    U8 symbol;
53
54    for(slot = 0; slot <= 3; slot++)
55    {
56       for(symbol = 0; symbol < MAX_SYMB_PER_SLOT; symbol++)
57          duCfgParam.clCellCfg.tddCfg.slotCfg[slot][symbol] = DL_SLOT;
58    }
59
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;
64
65    for(symbol = 0; symbol < MAX_SYMB_PER_SLOT; symbol++)
66       duCfgParam.clCellCfg.tddCfg.slotCfg[4][symbol] = UL_SLOT;
67
68 }
69
70 /*******************************************************************
71  *
72  * @brief Reads the CL Configuration.
73  *
74  * @details
75  *
76  *    Function : readClCfg
77  *
78  *    Functionality:
79  *       - Fills up the cell configuration for CL.
80  *       - Calls fillSlotConfig()  
81  *
82  * @params[in] void
83  * @return ROK     - success
84  *         RFAILED - failure
85  *
86  * ****************************************************************/
87
88
89 /* This function is used to fill up the cell configuration for CL */
90 S16 readClCfg()
91 {
92    duCfgParam.clCellCfg.carrierId = CARRIER_IDX;
93
94    /* Cell configuration */
95    duCfgParam.clCellCfg.cellId = NR_CELL_ID;
96    duCfgParam.clCellCfg.phyCellId = NR_PCI;
97    duCfgParam.clCellCfg.dupType = DUPLEX_MODE;
98
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;
114
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;
130
131    duCfgParam.clCellCfg.freqShft = FREQ_SHIFT_7P5KHZ;
132
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;
146
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)
160    {
161       DU_LOG("\nDU_APP : Memory allocation failed");
162       RETVALUE(RFAILED);
163    }
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;
167
168    /* TDD configuration */
169    duCfgParam.clCellCfg.tddCfg.pres = TRUE;
170    duCfgParam.clCellCfg.tddCfg.tddPeriod = TDD_PERIODICITY;
171
172    fillSlotConfig();
173
174    /* RSSI Measurement configuration */
175    duCfgParam.clCellCfg.rssiUnit = RSS_MEASUREMENT_UNIT;
176
177    /* This should be calculated based on
178       (number of mandatory parameters) + (number of otional parameters being filled) */
179    duCfgParam.clCellCfg.numTlv = 39;
180
181    RETVALUE(ROK);
182 }
183 /*******************************************************************
184  *
185  * @brief Configures the DU Parameters
186  *
187  * @details
188  *
189  *    Function : readCfg
190  *
191  *    Functionality:
192  *       - Initializes the DuCfg members.  
193  *       - Calls readClCfg()  
194  *
195  * @params[in] system task ID
196  * @return ROK     - success
197  *         RFAILED - failure
198  *
199  * ****************************************************************/
200
201 S16 readCfg()
202 {
203    U8 i,j,k;
204    U32 ipv4_du, ipv4_cu;
205
206    cmInetAddr((S8*)DU_IP_V4_ADDR, &ipv4_du);
207    cmInetAddr((S8*)CU_IP_V4_ADDR, &ipv4_cu);
208
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;
213
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;
218
219
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;
229
230    duCfgParam.maxUe = 32; //TODO: Check
231    /* DU Info */        
232    duCfgParam.duId = DU_ID;     
233    strcpy((char*)duCfgParam.duName,DU_NAME);
234
235    for(i=0; i<DEFAULT_CELLS; i++)
236    { 
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;
243
244       /*Cell ID */
245       duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.nrCgi.cellId = NR_CELL_ID;
246       duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.nrPci = NR_PCI;
247
248       /* List of Available PLMN */
249       for(j=0;j<MAX_PLMN;j++)
250       {
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;
257       }
258       /* List of Extended PLMN */
259       for(j=0;j<MAX_PLMN;j++)
260       {
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;
267       } 
268
269       /* TAC and EPSTAC */
270       duCfgParam.srvdCellLst[i].duCellInfo.tac = DU_TAC;
271       duCfgParam.srvdCellLst[i].duCellInfo.epsTac = DU_TAC; //to check and fill
272       /* NR Mode info */
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;
277
278 #if 0
279       /* NR Mode info */
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;           
284
285       for(j=0;j<MAXNRCELLBANDS;j++)
286       {
287          duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.freqBand[j].nrFreqBand = NR_FREQ_BAND;
288          for(k=0;k<MAXNRCELLBANDS;k++)
289          {
290             duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.freqBand[j].sulBand[k] = SUL_BAND;  
291          }
292       }
293 #endif
294       for(j=0;j<MAXNRCELLBANDS;j++)
295       {
296          duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.freqBand[j].nrFreqBand = NR_FREQ_BAND;
297          for(k=0;k<MAXNRCELLBANDS;k++)
298          {
299             duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.freqBand[j].sulBand[k] = SUL_BAND;
300          }
301       }
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++)
307       {
308          duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.freqBand[j].nrFreqBand = NR_FREQ_BAND;
309          for(k=0;k<MAXNRCELLBANDS;k++)
310          {
311             duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.freqBand[j].sulBand[k] = SUL_BAND;
312          }
313       }
314
315       duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.ulTxBw.nrScs = SCS_120;
316       duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.ulTxBw.nrb = NRB_66;
317
318       duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.dlTxBw.nrScs = SCS_120;
319       duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.dlTxBw.nrb = NRB_66;
320
321 #if 0
322       duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.tdd.nrTxBw.nrScs = SCS_15;
323       duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.tdd.nrTxBw.nrb = NRB_160;
324 #endif
325       /*Measurement Config and Cell Config */ 
326       duCfgParam.srvdCellLst[i].duCellInfo.measTimeCfg = TIME_CFG; 
327
328       duCfgParam.srvdCellLst[i].duCellInfo.cellDir = DL_UL; 
329
330       duCfgParam.srvdCellLst[i].duCellInfo.cellType=CELL_TYPE;
331
332       /* Broadcast PLMN Identity */
333       for(j=0;j<MAXBPLMNNRMINUS1;j++)
334       {  
335          for(k=0;k<MAX_PLMN;k++)
336          {
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;
343          }
344          /* Extended PLMN List */        
345          for(k=0;k<MAX_PLMN;k++)
346          {
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;
353          }
354
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;
358       }
359
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
363    }
364
365    /* RRC Version,Extended RRC Version */
366    //TODO: uncomment duCfgParam.rrcVersion.rrcVer; //to do
367    //TODO: uncomment duCfgParam.rrcVersion.extRrcVer; //to do
368
369    if(readClCfg() != ROK)
370    {
371       DU_LOG("\nDU_APP : Failed while reading CL config");
372       RETVALUE(RFAILED);
373    }
374
375    RETVALUE(ROK);
376 }
377
378 /*******************************************************************
379  *
380  * @brief Reads config and posts message to du_app on completion
381  *
382  * @details
383  *
384  *    Function : main
385  *
386  *    Functionality:
387  *      - Calls readCfg()
388  *      - Post to du_app for further processing
389  *
390  * @params[in] void
391  * @return ROK     - success
392  *         RFAILED - failure
393  *
394  * ****************************************************************/
395 S16 duReadCfg()
396 {
397    Pst pst;
398    Buffer *mBuf;
399
400    cmMemset((U8 *)&duCfgParam, 0, sizeof(DuCfgParams));
401    //Read configs into duCfgParams
402    if(readCfg() != ROK)
403    {
404       DU_LOG("\nDU_APP : Reading configuration failed");
405       RETVALUE(RFAILED);
406    }
407
408    //Fill pst structure
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;
416    pst.event = EVTCFG;
417    pst.selector = DU_SELECTOR_TC;
418    pst.pool= DU_POOL;
419
420
421    if(SGetMsg(DFLT_REGION, DU_POOL, &mBuf) != ROK)
422    {
423       DU_LOG("\nDU_APP : Memory allocation failed in duReadCfg");
424       return RFAILED;
425    }
426
427    if (SPstTsk(&pst, mBuf) != ROK)
428    {
429       DU_LOG("\nDU_APP : SPstTsk failed in duReadCfg");
430       return RFAILED;
431    }
432
433    return ROK;
434 }
435
436 /*******************************************************************
437  *
438  * @brief Converts bit strings to integer
439  *
440  * @details
441  *
442  *    Function : bitStringToInt
443  *
444  *    Functionality:
445  *      - Converts ASN bit string format IEs to integer type
446  *
447  * @params[in] void
448  * @return ROK     - success
449  *         RFAILED - failure
450  *
451  * ****************************************************************/
452 S16 bitStringToInt(BIT_STRING_t *bitString, U16 *val)
453 {
454    U16 numOctets, idx;
455    if(bitString->buf == NULL || bitString->size <= 0)
456    {
457       DU_LOG("\nDU_APP : Bit string is empty");
458       return RFAILED;
459    }
460
461    numOctets = (bitString->size + 7 )/8;
462    for(idx=0; idx< numOctets; idx++)
463    {
464       *val |= bitString->buf[idx];
465       *val <<= 8;
466    }
467
468    *val |= bitString->buf[numOctets -1];
469    *val >>= ((numOctets * 8) - bitString->size);
470
471    return ROK;
472 }
473
474
475 /**********************************************************************
476   End of file
477  **********************************************************************/
478