Merge "UE CB creation at MAC and SCH [Issue-ID: ODUHIGH-177]"
[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 "common_def.h"
21 #include "legtp.h"
22 #include "lrg.h"
23 #include "lkw.x"
24 #include "lrg.x"
25 #include "du_cfg.h"
26 #include "du_mgr.h"
27 #include "du_sys_info_hdl.h"
28 #include "MIB.h"
29 #include "SearchSpace.h"
30 #include "SIB-TypeInfo.h"
31 #include "SchedulingInfo.h"
32 #include "SI-SchedulingInfo.h"
33 #include "ConnEstFailureControl.h"
34 #include "PLMN-IdentityInfo.h"
35 #include "odu_common_codec.h"
36 #include "PDSCH-TimeDomainResourceAllocation.h"
37 #include "BCCH-Config.h"
38 #include "PagingCycle.h"
39 #include "PCCH-Config.h"
40 #include "TimeAlignmentTimer.h"
41 #include "RACH-ConfigGeneric.h"
42 #include "PUSCH-TimeDomainResourceAllocation.h"
43 #include "PUCCH-ConfigCommon.h"
44 #include "SubcarrierSpacing.h"
45 #include "TDD-UL-DL-Pattern.h"
46 #include "RACH-ConfigCommon.h"
47 #include "BWP-DownlinkCommon.h"
48 #include "BWP-UplinkCommon.h"
49
50 extern DuCfgParams duCfgParam;
51 extern char encBuf[ENC_BUF_MAX_LEN];
52
53
54 /* Filling Slot configuration as :
55  * 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
56  *   0   DL    DL    DL    DL    DL    DL    DL    DL    DL    DL    DL    DL    DL    DL
57  *   1   DL    DL    DL    DL    DL    DL    DL    DL    DL    DL    DL    DL    DL    DL
58  *   2   DL    DL    DL    DL    DL    DL    DL    DL    DL    DL    DL    DL    DL    DL
59  *   3   DL    DL    DL    DL    DL    DL    DL    DL    DL    DL    GD    GD    GD    UL
60  *   4   UL    UL    UL    UL    UL    UL    UL    UL    UL    UL    UL    UL    UL    UL
61  */
62
63 /*******************************************************************
64  *
65  * @brief Fills the Slot configuration 
66  *
67  * @details
68  *
69  *    Function : FillSlotConfig
70  *
71  *    Functionality:Fill the Slot configuration values
72  * 
73  *  @params[in] void
74  * @return ROK     - success
75  *         RFAILED - failure
76  *
77  * ****************************************************************/
78 void FillSlotConfig()
79 {
80    U8 slot;
81    U8 symbol;
82
83    for(slot = 0; slot <= 3; slot++)
84    {
85       for(symbol = 0; symbol < MAX_SYMB_PER_SLOT; symbol++)
86          duCfgParam.macCellCfg.tddCfg.slotCfg[slot][symbol] = DL_SLOT;
87    }
88
89    duCfgParam.macCellCfg.tddCfg.slotCfg[3][10] = GUARD_SLOT;
90    duCfgParam.macCellCfg.tddCfg.slotCfg[3][11] = GUARD_SLOT;
91    duCfgParam.macCellCfg.tddCfg.slotCfg[3][12] = GUARD_SLOT;
92    duCfgParam.macCellCfg.tddCfg.slotCfg[3][13] = UL_SLOT;
93
94    for(symbol = 0; symbol < MAX_SYMB_PER_SLOT; symbol++)
95       duCfgParam.macCellCfg.tddCfg.slotCfg[4][symbol] = UL_SLOT;
96
97 }
98
99 /*******************************************************************
100  *
101  * @brief Reads the CL Configuration.
102  *
103  * @details
104  *
105  *    Function : readMacCfg
106  *
107  *    Functionality:
108  *       - Fills up the cell configuration for CL.
109  *       - Calls FillSlotConfig()  
110  *
111  * @params[in] void
112  * @return ROK     - success
113  *         RFAILED - failure
114  *
115  * ****************************************************************/
116
117
118 /* This function is used to fill up the cell configuration for CL */
119 S16 readMacCfg()
120 {
121    duCfgParam.macCellCfg.carrierId = CARRIER_IDX;
122
123    /* Cell configuration */
124    duCfgParam.macCellCfg.cellId = NR_CELL_ID;
125    duCfgParam.macCellCfg.phyCellId = NR_PCI;
126    duCfgParam.macCellCfg.dupType = DUPLEX_MODE;
127
128    /* DL carrier configuration */
129    duCfgParam.macCellCfg.dlCarrCfg.pres = TRUE;
130    duCfgParam.macCellCfg.dlCarrCfg.bw = BANDWIDTH;
131    duCfgParam.macCellCfg.dlCarrCfg.freq = NR_ARFCN;
132    duCfgParam.macCellCfg.dlCarrCfg.k0[0] = 1;
133    duCfgParam.macCellCfg.dlCarrCfg.k0[1] = 1;
134    duCfgParam.macCellCfg.dlCarrCfg.k0[2] = 1;
135    duCfgParam.macCellCfg.dlCarrCfg.k0[3] = 1;
136    duCfgParam.macCellCfg.dlCarrCfg.k0[4] = 1;
137    duCfgParam.macCellCfg.dlCarrCfg.gridSize[0] = 1;
138    duCfgParam.macCellCfg.dlCarrCfg.gridSize[1] = 1;
139    duCfgParam.macCellCfg.dlCarrCfg.gridSize[2] = 1;
140    duCfgParam.macCellCfg.dlCarrCfg.gridSize[3] = 1;
141    duCfgParam.macCellCfg.dlCarrCfg.gridSize[4] = 1;
142    duCfgParam.macCellCfg.dlCarrCfg.numAnt = NUM_TX_ANT;
143
144    /* UL Carrier configuration */
145    duCfgParam.macCellCfg.ulCarrCfg.pres = TRUE;
146    duCfgParam.macCellCfg.ulCarrCfg.bw = SUL_ARFCN;
147    duCfgParam.macCellCfg.ulCarrCfg.freq = NR_ARFCN;
148    duCfgParam.macCellCfg.ulCarrCfg.k0[0] = 1;
149    duCfgParam.macCellCfg.ulCarrCfg.k0[1] = 1;
150    duCfgParam.macCellCfg.ulCarrCfg.k0[2] = 1;
151    duCfgParam.macCellCfg.ulCarrCfg.k0[3] = 1;
152    duCfgParam.macCellCfg.ulCarrCfg.k0[4] = 1;
153    duCfgParam.macCellCfg.ulCarrCfg.gridSize[0] = 1;
154    duCfgParam.macCellCfg.ulCarrCfg.gridSize[1] = 1;
155    duCfgParam.macCellCfg.ulCarrCfg.gridSize[2] = 1;
156    duCfgParam.macCellCfg.ulCarrCfg.gridSize[3] = 1;
157    duCfgParam.macCellCfg.ulCarrCfg.gridSize[4] = 1;
158    duCfgParam.macCellCfg.ulCarrCfg.numAnt = NUM_RX_ANT;
159
160    duCfgParam.macCellCfg.freqShft = FREQ_SHIFT_7P5KHZ;
161
162    /* SSB configuration */
163    duCfgParam.macCellCfg.ssbCfg.ssbPbchPwr = SSB_PBCH_PWR;
164    duCfgParam.macCellCfg.ssbCfg.bchPayloadFlag = BCH_PAYLOAD;
165    duCfgParam.macCellCfg.ssbCfg.scsCmn = SUBCARRIER_SPACING;
166    duCfgParam.macCellCfg.ssbCfg.ssbOffsetPointA = OFFSET_TO_POINT_A;
167    duCfgParam.macCellCfg.ssbCfg.betaPss = BETA_PSS;
168    duCfgParam.macCellCfg.ssbCfg.ssbPeriod = SSB_PERIODICITY_20MS;
169    duCfgParam.macCellCfg.ssbCfg.ssbScOffset = SSB_SUBCARRIER_OFFSET;
170    duCfgParam.macCellCfg.ssbCfg.ssbMask[0] = 1; /* only one SSB is transmitted */
171    duCfgParam.macCellCfg.ssbCfg.ssbMask[1] = 0;
172    if(BuildMibPdu() != ROK)
173    {
174       DU_LOG("\nFailed to build MIB PDU");
175       memset(&duCfgParam.macCellCfg.ssbCfg.mibPdu, 0, 3*sizeof(uint8_t));
176    }
177    else
178    {
179       for(uint8_t idx=0; idx<encBufSize; idx++)
180       {
181          duCfgParam.macCellCfg.ssbCfg.mibPdu[idx]=encBuf[idx];
182       }
183    }
184    duCfgParam.macCellCfg.ssbCfg.multCarrBand = SSB_MULT_CARRIER_BAND;
185    duCfgParam.macCellCfg.ssbCfg.multCellCarr = MULT_CELL_CARRIER;
186
187    /* PRACH configuration */
188    duCfgParam.macCellCfg.prachCfg.pres = TRUE;
189    duCfgParam.macCellCfg.prachCfg.prachCfgIdx = PRACH_CONFIG_IDX;
190    duCfgParam.macCellCfg.prachCfg.prachSeqLen = PRACH_SEQ_LEN;
191    duCfgParam.macCellCfg.prachCfg.prachSubcSpacing = PRACH_SUBCARRIER_SPACING;
192    duCfgParam.macCellCfg.prachCfg.prachRstSetCfg = PRACH_RESTRICTED_SET_CFG;
193    duCfgParam.macCellCfg.prachCfg.msg1Fdm = NUM_PRACH_FDM;
194    duCfgParam.macCellCfg.prachCfg.msg1FreqStart = PRACH_FREQ_START;
195    duCfgParam.macCellCfg.prachCfg.rootSeqLen    = ROOT_SEQ_LEN;
196    duCfgParam.macCellCfg.prachCfg.fdm[0].rootSeqIdx = ROOT_SEQ_IDX;
197    duCfgParam.macCellCfg.prachCfg.fdm[0].numRootSeq = NUM_ROOT_SEQ;
198    duCfgParam.macCellCfg.prachCfg.fdm[0].k1 = 1;
199    duCfgParam.macCellCfg.prachCfg.fdm[0].zeroCorrZoneCfg = ZERO_CORRELATION_ZONE_CFG;
200    duCfgParam.macCellCfg.prachCfg.fdm[0].numUnusedRootSeq = NUM_UNUSED_ROOT_SEQ;
201    if(duCfgParam.macCellCfg.prachCfg.fdm[0].numUnusedRootSeq != 0)
202    {
203       DU_ALLOC(duCfgParam.macCellCfg.prachCfg.fdm[0].unsuedRootSeq, 
204             NUM_UNUSED_ROOT_SEQ * sizeof(U8));
205       if(duCfgParam.macCellCfg.prachCfg.fdm[0].unsuedRootSeq == NULLP)
206       {
207          DU_LOG("\nDU_APP : Memory allocation failed");
208          RETVALUE(RFAILED);
209       }
210       *(duCfgParam.macCellCfg.prachCfg.fdm[0].unsuedRootSeq) = UNUSED_ROOT_SEQ;
211    }
212    duCfgParam.macCellCfg.prachCfg.ssbPerRach = SSB_PER_RACH;
213    duCfgParam.macCellCfg.prachCfg.prachMultCarrBand = PRACH_MULT_CARRIER_BAND;
214    duCfgParam.macCellCfg.prachCfg.raContResTmr = RA_CONT_RES_TIMER;
215    duCfgParam.macCellCfg.prachCfg.rsrpThreshSsb = RSRP_THRESHOLD_SSB;
216    duCfgParam.macCellCfg.prachCfg.raRspWindow = RA_RSP_WINDOW;
217    duCfgParam.macCellCfg.prachCfg.prachRestrictedSet = PRACH_RESTRICTED_SET;
218    /* TDD configuration */
219    duCfgParam.macCellCfg.tddCfg.pres = TRUE;
220    duCfgParam.macCellCfg.tddCfg.tddPeriod = TDD_PERIODICITY;
221
222    FillSlotConfig();
223
224    /* RSSI Measurement configuration */
225    duCfgParam.macCellCfg.rssiUnit = RSS_MEASUREMENT_UNIT;
226
227    /* fill SIB1 configuration */
228    duCfgParam.macCellCfg.sib1Cfg.sib1PduLen = duCfgParam.srvdCellLst[0].duSysInfo.sib1Len;
229    DU_ALLOC(duCfgParam.macCellCfg.sib1Cfg.sib1Pdu,duCfgParam.srvdCellLst[0].duSysInfo.sib1Len);
230    memcpy(duCfgParam.macCellCfg.sib1Cfg.sib1Pdu, duCfgParam.srvdCellLst[0].duSysInfo.sib1Msg, \
231          duCfgParam.srvdCellLst[0].duSysInfo.sib1Len);
232    duCfgParam.macCellCfg.sib1Cfg.sib1NewTxPeriod = SIB1_NEW_TX_PERIOD;
233    duCfgParam.macCellCfg.sib1Cfg.sib1RepetitionPeriod = SIB1_REPETITION_PERIOD;
234    duCfgParam.macCellCfg.sib1Cfg.coresetZeroIndex = CORESET_0_INDEX;
235    duCfgParam.macCellCfg.sib1Cfg.searchSpaceZeroIndex = SEARCHSPACE_0_INDEX;
236    duCfgParam.macCellCfg.sib1Cfg.sib1Mcs = SIB1_MCS;
237
238
239    /* fill Intial DL BWP */
240    duCfgParam.macCellCfg.initialDlBwp.bwp.firstPrb = 0;
241    duCfgParam.macCellCfg.initialDlBwp.bwp.numPrb = TOTAL_PRB_BW; /* configured to total BW */
242    duCfgParam.macCellCfg.initialDlBwp.bwp.scs = SUBCARRIER_SPACING; /* numerology is 0, 15Khz */
243    duCfgParam.macCellCfg.initialDlBwp.bwp.cyclicPrefix = NORMAL_CYCLIC_PREFIX;
244    duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.searchSpaceId = SEARCHSPACE_1_INDEX;
245    duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.coresetId = CORESET_0_INDEX;
246    duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.monitoringSlot =
247       SS_MONITORING_SLOT_SL1; /* sl1 - all slots */
248    duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.duration = 0;
249    duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.monitoringSymbol =
250       SS_MONITORING_SYMBOL;
251    duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.
252       candidate.aggLevel1       = 8;
253    duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.
254       candidate.aggLevel2       = 4;
255    duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.
256       candidate.aggLevel4       = 2;
257    duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.
258       candidate.aggLevel8       = 1;
259    duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.commonSearchSpace.
260       candidate.aggLevel16      = 0;
261    duCfgParam.macCellCfg.initialDlBwp.pdschCommon.k0 = PDSCH_K0;
262    duCfgParam.macCellCfg.initialDlBwp.pdschCommon.mappingType = 
263       PDSCH_MAPPING_TYPE_A;
264    duCfgParam.macCellCfg.initialDlBwp.pdschCommon.startSymbol = 
265       PDSCH_START_SYMBOL;
266    duCfgParam.macCellCfg.initialDlBwp.pdschCommon.lengthSymbol =
267       PDSCH_LENGTH_SYMBOL;
268    /* ra-searchSpace ID is set to 1 */
269    duCfgParam.macCellCfg.initialDlBwp.pdcchCommon.raSearchSpaceId = SEARCHSPACE_1_INDEX;
270
271    /* fill Intial UL BWP */
272    duCfgParam.macCellCfg.initialUlBwp.bwp.firstPrb = 0;
273    duCfgParam.macCellCfg.initialUlBwp.bwp.numPrb = TOTAL_PRB_BW; /* configured to total BW */
274    duCfgParam.macCellCfg.initialUlBwp.bwp.scs = SUBCARRIER_SPACING; /* numerology is 0, 15Khz */
275    duCfgParam.macCellCfg.initialUlBwp.bwp.cyclicPrefix = NORMAL_CYCLIC_PREFIX;
276    duCfgParam.macCellCfg.initialUlBwp.puschCommon.k2 = PUSCH_K2;
277    duCfgParam.macCellCfg.initialUlBwp.puschCommon.mappingType = 
278       PUSCH_MAPPING_TYPE_A;
279    duCfgParam.macCellCfg.initialUlBwp.puschCommon.startSymbol = 
280       PUSCH_START_SYMBOL;
281    duCfgParam.macCellCfg.initialUlBwp.puschCommon.lengthSymbol =
282       PUSCH_LENGTH_SYMBOL;
283
284    duCfgParam.macCellCfg.dmrsTypeAPos = DMRS_TYPE_A_POS; 
285    /* fill PUCCH config common */
286    duCfgParam.macCellCfg.initialUlBwp.pucchCommon.pucchResourceCommon = PUCCH_RSRC_COMMON;
287    duCfgParam.macCellCfg.initialUlBwp.pucchCommon.pucchGroupHopping = PUCCH_GROUP_HOPPING;
288
289    /* This should be calculated based on
290       (number of mandatory parameters) + (number of otional parameters being filled) */
291    duCfgParam.macCellCfg.numTlv = 40;
292
293    RETVALUE(ROK);
294 }
295
296 /*******************************************************************
297  *
298  * @brief Configures the DU Parameters
299  *
300  * @details
301  *
302  *    Function : fillDuPort
303  *
304  *    Functionality:
305  *       - fills the DU Ports.  
306  *
307  * @params[in] duPort array to be filled
308  * @return ROK     - success
309  *         RFAILED - failure
310  *
311  * ****************************************************************/
312 S16 fillDuPort(U16 *duPort)
313 {
314    duPort[F1_INTERFACE]   = DU_PORT;     /* DU Port idx  0 38472 */
315    duPort[E2_INTERFACE]   = RIC_PORT;    /* RIC Port idx 1 38482 */
316
317    RETVALUE(ROK);
318 }
319
320 /*******************************************************************
321  *
322  * @brief Configures the DU Parameters
323  *
324  * @details
325  *
326  *    Function : calcSliv
327  *
328  *    Functionality:
329  *       - calculate SLIV value from start and length field
330  *
331  * @params[in] start symbol
332  * @params[in] length of symbols
333  * @return SLIV value
334  *
335  * ****************************************************************/
336 uint16_t calcSliv(uint8_t startSymbol, uint8_t lengthSymbol)
337 {
338    uint16_t sliv = 0;
339    if((lengthSymbol-1) <= 7)
340    {
341       sliv = NUM_SYMBOLS_PER_SLOT * (lengthSymbol-1) + startSymbol;
342    }
343    else
344    {
345       sliv = NUM_SYMBOLS_PER_SLOT * (NUM_SYMBOLS_PER_SLOT - lengthSymbol + 1) \
346              + (NUM_SYMBOLS_PER_SLOT - 1 - startSymbol);
347    }
348    return sliv;
349 }
350
351
352 /*******************************************************************
353  *
354  * @brief Configures serving cell config common in sib1
355  *
356  * @details
357  *
358  *    Function : fillServCellCfgCommSib
359  *
360  *    Functionality:
361  *       - fills Serving cell config common for SIB1
362  *
363  * @params[in] SrvCellCfgCommSib pointer
364  * @return ROK     - success
365  *         RFAILED - failure
366  * 
367  ** ****************************************************************/
368 S16 fillServCellCfgCommSib(SrvCellCfgCommSib *srvCellCfgComm)
369 {
370    PdcchCfgCommon   pdcchCfg;
371    PdschCfgCommon   pdschCfg;
372    PcchCfg          pcchCfg;
373    RachCfgCommon    rachCfg;
374    PuschCfgCommon   puschCfg;
375    PucchCfgCommon   pucchCfg;
376    TddUlDlCfgCommon   tddCfg;
377
378    /* Configuring DL Config Common for SIB1*/
379    srvCellCfgComm->dlCfg.freqBandInd = NR_FREQ_BAND_IND; 
380    srvCellCfgComm->dlCfg.offsetToPointA = OFFSET_TO_POINT_A;
381    srvCellCfgComm->dlCfg.dlScsCarrier.scsOffset = SSB_SUBCARRIER_OFFSET;
382    srvCellCfgComm->dlCfg.dlScsCarrier.scs = SUBCARRIER_SPACING;
383    srvCellCfgComm->dlCfg.dlScsCarrier.scsBw = SCS_CARRIER_BANDWIDTH;
384    srvCellCfgComm->dlCfg.locAndBw = FREQ_LOC_BW;
385
386    /* Configuring PDCCH Config Common For SIB1 */
387    pdcchCfg.present = BWP_DownlinkCommon__pdcch_ConfigCommon_PR_setup;
388    pdcchCfg.ctrlRsrcSetZero = PDCCH_CTRL_RSRC_SET_ZERO;
389    pdcchCfg.searchSpcZero = PDCCH_SEARCH_SPACE_ZERO;
390    pdcchCfg.searchSpcId = PDCCH_SEARCH_SPACE_ID;
391    pdcchCfg.ctrlRsrcSetId = PDCCH_CTRL_RSRC_SET_ID;
392    pdcchCfg.monitorSlotPrdAndOffPresent = \
393       SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl1;
394    //pdcchCfg.monitorSlotPrdAndOff = \
395    SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl1;
396    pdcchCfg.monitorSymbolsInSlot[0] = 128;
397    pdcchCfg.monitorSymbolsInSlot[1] = 0;
398    pdcchCfg.numCandAggLvl1 = SearchSpace__nrofCandidates__aggregationLevel1_n8;
399    pdcchCfg.numCandAggLvl2 = SearchSpace__nrofCandidates__aggregationLevel2_n4;
400    pdcchCfg.numCandAggLvl4 = SearchSpace__nrofCandidates__aggregationLevel4_n2;
401    pdcchCfg.numCandAggLvl8 = SearchSpace__nrofCandidates__aggregationLevel8_n1;
402    pdcchCfg.numCandAggLvl16 = SearchSpace__nrofCandidates__aggregationLevel16_n0;
403    pdcchCfg.searchSpcType = SearchSpace__searchSpaceType_PR_common;
404    pdcchCfg.commSrchSpcDciFrmt = PDCCH_SERACH_SPACE_DCI_FORMAT;
405    pdcchCfg.searchSpcSib1 = PDCCH_SEARCH_SPACE_ID_SIB1;
406    pdcchCfg.pagingSearchSpc = PDCCH_SEARCH_SPACE_ID_PAGING;
407    pdcchCfg.raSearchSpc = PDCCH_SEARCH_SPACE_ID_PAGING;
408    srvCellCfgComm->dlCfg.pdcchCfg = pdcchCfg;
409
410    /* Configuring PDSCH Config Common For SIB1 */
411    pdschCfg.present = BWP_DownlinkCommon__pdsch_ConfigCommon_PR_setup;
412    pdschCfg.k0 = PDSCH_K0;
413    pdschCfg.mapType = \
414       PDSCH_TimeDomainResourceAllocation__mappingType_typeA;
415    pdschCfg.sliv = calcSliv(PDSCH_START_SYMBOL,PDSCH_LENGTH_SYMBOL);
416    srvCellCfgComm->dlCfg.pdschCfg = pdschCfg;
417
418    /* Configuring BCCH Config for SIB1 */
419    srvCellCfgComm->dlCfg.bcchCfg.modPrdCoeff = \
420       BCCH_Config__modificationPeriodCoeff_n16;
421
422    /* Configuring PCCH Config for SIB1 */
423    pcchCfg.dfltPagingCycle = PagingCycle_rf64;
424    pcchCfg.nAndPagingFrmOffPresent = PCCH_Config__nAndPagingFrameOffset_PR_oneT;
425    pcchCfg.numPagingOcc = PCCH_Config__ns_four;
426    srvCellCfgComm->dlCfg.pcchCfg = pcchCfg;
427
428
429    /* Configuring UL Config Common */
430    srvCellCfgComm->ulCfg.ulScsCarrier.scsOffset = SSB_SUBCARRIER_OFFSET;
431    srvCellCfgComm->ulCfg.ulScsCarrier.scs = SUBCARRIER_SPACING;
432    srvCellCfgComm->ulCfg.ulScsCarrier.scsBw = SCS_CARRIER_BANDWIDTH;
433    srvCellCfgComm->ulCfg.pMax = UL_P_MAX;
434    srvCellCfgComm->ulCfg.locAndBw = FREQ_LOC_BW;
435    srvCellCfgComm->ulCfg.timeAlignTimerComm = TimeAlignmentTimer_infinity;
436
437    /* Configuring RACH Config Common for SIB1 */
438    rachCfg.present = BWP_UplinkCommon__rach_ConfigCommon_PR_setup;
439    rachCfg.prachCfgIdx = PRACH_CONFIG_IDX;
440    rachCfg.msg1Fdm = RACH_ConfigGeneric__msg1_FDM_one;
441    rachCfg.msg1FreqStart = PRACH_FREQ_START;
442    rachCfg.zeroCorrZoneCfg = ZERO_CORRELATION_ZONE_CFG;
443    rachCfg.preambleRcvdTgtPwr = PRACH_PREAMBLE_RCVD_TGT_PWR;
444    rachCfg.preambleTransMax = RACH_ConfigGeneric__preambleTransMax_n200;
445    rachCfg.pwrRampingStep = RACH_ConfigGeneric__powerRampingStep_dB2;
446    rachCfg.raRspWindow = RACH_ConfigGeneric__ra_ResponseWindow_sl20;
447    rachCfg.numRaPreamble = NUM_RA_PREAMBLE;
448    rachCfg.ssbPerRachOccPresent = \
449       RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_one;
450    rachCfg.numSsbPerRachOcc = SSB_PER_RACH;
451    rachCfg.contResTimer = RACH_ConfigCommon__ra_ContentionResolutionTimer_sf64;
452    rachCfg.rsrpThreshSsb = RSRP_THRESHOLD_SSB;
453    rachCfg.rootSeqIdxPresent = RACH_ConfigCommon__prach_RootSequenceIndex_PR_l139;
454    rachCfg.rootSeqIdx = ROOT_SEQ_IDX;
455    rachCfg.msg1Scs = PRACH_SUBCARRIER_SPACING ;
456    rachCfg.restrictedSetCfg = PRACH_RESTRICTED_SET_CFG;
457    srvCellCfgComm->ulCfg.rachCfg = rachCfg;
458
459    /* Configuring PUSCH Config Common for SIB1 */
460    puschCfg.present = BWP_UplinkCommon__pusch_ConfigCommon_PR_setup;
461    puschCfg.k2 = PUSCH_K2;
462    puschCfg.mapType = PUSCH_TimeDomainResourceAllocation__mappingType_typeA;
463    puschCfg.sliv = calcSliv(PUSCH_START_SYMBOL,PUSCH_LENGTH_SYMBOL);
464    puschCfg.msg3DeltaPreamble = PUSCH_MSG3_DELTA_PREAMBLE;
465    puschCfg.p0NominalWithGrant = PUSCH_P0_NOMINAL_WITH_GRANT;
466    srvCellCfgComm->ulCfg.puschCfg = puschCfg;
467
468    /* Configuring PUCCH Config Common for SIB1 */
469    pucchCfg.present = BWP_UplinkCommon__pucch_ConfigCommon_PR_setup;
470    pucchCfg.rsrcComm = PUCCH_RSRC_COMMON;
471    pucchCfg.grpHop = PUCCH_ConfigCommon__pucch_GroupHopping_neither;
472    pucchCfg.p0Nominal = PUCCH_P0_NOMINAL;
473    srvCellCfgComm->ulCfg.pucchCfg = pucchCfg;
474
475    /* Configuring TDD UL DL config common */
476    tddCfg.refScs = SubcarrierSpacing_kHz30;
477    tddCfg.txPrd = TDD_UL_DL_Pattern__dl_UL_TransmissionPeriodicity_ms2p5;
478    tddCfg.numDlSlots = NUM_DL_SLOTS;
479    tddCfg.numDlSymbols = NUM_DL_SYMBOLS;
480    tddCfg.numUlSlots = NUM_UL_SLOTS;
481    tddCfg.numUlSymbols = NUM_UL_SYMBOLS;
482    srvCellCfgComm->tddCfg = tddCfg;
483
484    srvCellCfgComm->ssbPosInBurst = 192;
485    srvCellCfgComm->ssbPrdServingCell = SSB_PERIODICITY_20MS;
486    srvCellCfgComm->ssPbchBlockPwr = SSB_PBCH_PWR;
487
488    return ROK;
489 }
490
491 /*******************************************************************
492  *
493  * @brief Configures the DU Parameters
494  *
495  * @details
496  *
497  *    Function : readCfg
498  *
499  *    Functionality:
500  *       - Initializes the DuCfg members.  
501  *       - Calls readMacCfg()  
502  *
503  * @params[in] system task ID
504  * @return ROK     - success
505  *         RFAILED - failure
506  *
507  * ****************************************************************/
508
509 S16 readCfg()
510 {
511    U8 i,j,k;
512    U32 ipv4_du, ipv4_cu, ipv4_ric;
513    MibParams mib;
514    Sib1Params sib1;     
515
516    cmInetAddr((S8*)DU_IP_V4_ADDR, &ipv4_du);
517    cmInetAddr((S8*)CU_IP_V4_ADDR, &ipv4_cu);
518    cmInetAddr((S8*)RIC_IP_V4_ADDR, &ipv4_ric);
519    fillDuPort(duCfgParam.sctpParams.duPort);
520
521    /* F1 DU IP Address and Port*/
522    duCfgParam.sctpParams.duIpAddr.ipV4Addr = ipv4_du;
523
524    /* F1 CU IP Address and Port*/
525    duCfgParam.sctpParams.cuIpAddr.ipV4Addr = ipv4_cu;
526    duCfgParam.sctpParams.cuPort = CU_PORT;
527
528    /* Fill RIC Params */
529    duCfgParam.sctpParams.ricIpAddr.ipV4Addr = ipv4_ric;
530    duCfgParam.sctpParams.ricPort            = RIC_PORT;
531    /* EGTP Parameters */
532    duCfgParam.egtpParams.localIp.ipV4Pres = TRUE;
533    duCfgParam.egtpParams.localIp.ipV4Addr = ipv4_du;
534    duCfgParam.egtpParams.localPort = DU_EGTP_PORT;
535    duCfgParam.egtpParams.destIp.ipV4Pres = TRUE;
536    duCfgParam.egtpParams.destIp.ipV4Addr = ipv4_cu;
537    duCfgParam.egtpParams.destPort = CU_EGTP_PORT;
538    duCfgParam.egtpParams.minTunnelId = 0;
539    duCfgParam.egtpParams.maxTunnelId = 10;
540
541    duCfgParam.maxUe = 32; //TODO: Check
542    /* DU Info */        
543    duCfgParam.duId = DU_ID;     
544    strcpy((char*)duCfgParam.duName,DU_NAME);
545
546    /* Mib Params */
547    mib.sysFrmNum = SYS_FRAME_NUM;
548    mib.subCarrierSpacingCommon = MIB__subCarrierSpacingCommon_scs15or60;
549    mib.ssb_SubcarrierOffset = SSB_SC_OFFSET; 
550    mib.dmrs_TypeA_Position = MIB__dmrs_TypeA_Position_pos2;
551    mib.controlResourceSetZero = CORESET_ZERO;
552    mib.searchSpaceZero = SEARCH_SPACE_ZERO;
553    mib.cellBarred = MIB__cellBarred_barred;
554    mib.intraFreqReselection =
555       MIB__intraFreqReselection_notAllowed;
556    duCfgParam.mibParams = mib;
557
558    /* SIB1 Params */
559    sib1.plmn.mcc[0] = PLMN_MCC0;
560    sib1.plmn.mcc[1] = PLMN_MCC1;
561    sib1.plmn.mcc[2] = PLMN_MCC2;
562    sib1.plmn.mnc[0] = PLMN_MNC0;
563    sib1.plmn.mnc[1] = PLMN_MNC1;
564    sib1.plmn.mnc[2] = PLMN_MNC2;
565    sib1.tac = DU_TAC;
566    sib1.ranac = DU_RANAC;
567    sib1.cellIdentity = CELL_IDENTITY;
568    sib1.cellResvdForOpUse =\
569       PLMN_IdentityInfo__cellReservedForOperatorUse_notReserved;
570    sib1.connEstFailCnt = ConnEstFailureControl__connEstFailCount_n3;
571    sib1.connEstFailOffValidity =\
572       ConnEstFailureControl__connEstFailOffsetValidity_s120;
573    sib1.siSchedInfo.winLen = SI_SchedulingInfo__si_WindowLength_s5;
574    sib1.siSchedInfo.broadcastSta = \
575       SchedulingInfo__si_BroadcastStatus_broadcasting;
576    sib1.siSchedInfo.preiodicity = SchedulingInfo__si_Periodicity_rf8;
577    sib1.siSchedInfo.sibType = SIB_TypeInfo__type_sibType2;
578    sib1.siSchedInfo.sibValTag = SIB1_VALUE_TAG;
579
580    fillServCellCfgCommSib(&sib1.srvCellCfgCommSib);
581
582    duCfgParam.sib1Params = sib1;
583
584    for(i=0; i<DEFAULT_CELLS; i++)
585    { 
586       duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.nrCgi.plmn.mcc[0] = PLMN_MCC0;
587       duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.nrCgi.plmn.mcc[1] = PLMN_MCC1;
588       duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.nrCgi.plmn.mcc[2] = PLMN_MCC2;
589       duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.nrCgi.plmn.mnc[0] = PLMN_MNC0;
590       duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.nrCgi.plmn.mnc[1] = PLMN_MNC1;
591       duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.nrCgi.plmn.mnc[2] = PLMN_MNC2;
592
593       /*Cell ID */
594       duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.nrCgi.cellId = NR_CELL_ID;
595       duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.nrPci = NR_PCI;
596
597       /* List of Available PLMN */
598       for(j=0;j<MAX_PLMN;j++)
599       {
600          duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.plmn[j].mcc[0] = PLMN_MCC0;
601          duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.plmn[j].mcc[1] = PLMN_MCC1;
602          duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.plmn[j].mcc[2] = PLMN_MCC2;
603          duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.plmn[j].mnc[0] = PLMN_MNC0;
604          duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.plmn[j].mnc[1] = PLMN_MNC1;
605          duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.plmn[j].mnc[2] = PLMN_MNC2;
606       }
607       /* List of Extended PLMN */
608       for(j=0;j<MAX_PLMN;j++)
609       {
610          duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.extPlmn[j].mcc[0] = PLMN_MCC0;
611          duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.extPlmn[j].mcc[1] = PLMN_MCC1;
612          duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.extPlmn[j].mcc[2] = PLMN_MCC2;
613          duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.extPlmn[j].mnc[0] = PLMN_MNC0;
614          duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.extPlmn[j].mnc[1] = PLMN_MNC1;
615          duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.extPlmn[j].mnc[2] = PLMN_MNC2;
616       } 
617
618       /* TAC and EPSTAC */
619       duCfgParam.srvdCellLst[i].duCellInfo.tac = DU_TAC;
620       duCfgParam.srvdCellLst[i].duCellInfo.epsTac = DU_TAC; //to check and fill
621       /* NR Mode info */
622       duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.nrArfcn = NR_ARFCN;
623       duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.sulInfo.sulArfcn = SUL_ARFCN;
624       duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.sulInfo.sulTxBw.nrScs = SCS_120;
625       duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.sulInfo.sulTxBw.nrb = NRB_66;
626
627 #if 0
628       /* NR Mode info */
629       duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.nrArfcn = NR_ARFCN;
630       duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.sulInfo.sulArfcn = SUL_ARFCN;
631       duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.sulInfo.sulTxBw.nrScs = SCS_15;           
632       duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.sulInfo.sulTxBw.nrb = NRB_160;           
633
634       for(j=0;j<MAXNRCELLBANDS;j++)
635       {
636          duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.freqBand[j].nrFreqBand = NR_FREQ_BAND;
637          for(k=0;k<MAXNRCELLBANDS;k++)
638          {
639             duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.freqBand[j].sulBand[k] = SUL_BAND;  
640          }
641       }
642 #endif
643       for(j=0;j<MAXNRCELLBANDS;j++)
644       {
645          duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.freqBand[j].nrFreqBand = NR_FREQ_BAND;
646          for(k=0;k<MAXNRCELLBANDS;k++)
647          {
648             duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.freqBand[j].sulBand[k] = SUL_BAND;
649          }
650       }
651       duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.nrArfcn = NR_ARFCN;
652       duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.sulInfo.sulArfcn = SUL_ARFCN;
653       duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.sulInfo.sulTxBw.nrScs = SCS_120;
654       duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.sulInfo.sulTxBw.nrb = NRB_66;
655       for(j=0;j<MAXNRCELLBANDS;j++)
656       {
657          duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.freqBand[j].nrFreqBand = NR_FREQ_BAND;
658          for(k=0;k<MAXNRCELLBANDS;k++)
659          {
660             duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.freqBand[j].sulBand[k] = SUL_BAND;
661          }
662       }
663
664       duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.ulTxBw.nrScs = SCS_120;
665       duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.ulTxBw.nrb = NRB_66;
666
667       duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.dlTxBw.nrScs = SCS_120;
668       duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.dlTxBw.nrb = NRB_66;
669
670 #if 0
671       duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.tdd.nrTxBw.nrScs = SCS_15;
672       duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.tdd.nrTxBw.nrb = NRB_160;
673 #endif
674       /*Measurement Config and Cell Config */ 
675       duCfgParam.srvdCellLst[i].duCellInfo.measTimeCfg = TIME_CFG; 
676
677       duCfgParam.srvdCellLst[i].duCellInfo.cellDir = DL_UL; 
678
679       duCfgParam.srvdCellLst[i].duCellInfo.cellType=CELL_TYPE;
680
681       /* Broadcast PLMN Identity */
682       for(j=0;j<MAXBPLMNNRMINUS1;j++)
683       {  
684          for(k=0;k<MAX_PLMN;k++)
685          {
686             duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].plmn[k].mcc[0] = PLMN_MCC0;
687             duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].plmn[k].mcc[1] = PLMN_MCC1;
688             duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].plmn[k].mcc[2] = PLMN_MCC2;
689             duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].plmn[k].mnc[0] = PLMN_MNC0;
690             duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].plmn[k].mnc[1] = PLMN_MNC1;                                         
691             duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].plmn[k].mnc[2] = PLMN_MNC2;
692          }
693          /* Extended PLMN List */        
694          for(k=0;k<MAX_PLMN;k++)
695          {
696             duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].extPlmn[k].mcc[0] = PLMN_MCC0;
697             duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].extPlmn[k].mcc[1] = PLMN_MCC1;
698             duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].extPlmn[k].mcc[2] = PLMN_MCC2;
699             duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].extPlmn[k].mnc[0] = PLMN_MNC0;
700             duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].extPlmn[k].mnc[1] = PLMN_MNC1;
701             duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].extPlmn[k].mnc[2] = PLMN_MNC2;
702          }
703
704          duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].tac = DU_TAC;
705          duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].nrCellId = NR_CELL_ID;
706          duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].ranac = NR_RANAC;
707       }
708
709       /*gnb DU System Info mib msg*/
710       BuildMibMsg();
711       DU_ALLOC(duCfgParam.srvdCellLst[i].duSysInfo.mibMsg,\
712             strlen(encBuf));
713       if(!(duCfgParam.srvdCellLst[i].duSysInfo.mibMsg))
714       {
715          DU_LOG("\nDU_APP: Memory allocation failure");
716          return RFAILED;
717       }
718       strcpy((char *)duCfgParam.srvdCellLst[i].duSysInfo.mibMsg, encBuf);
719       duCfgParam.srvdCellLst[i].duSysInfo.mibLen = encBufSize;
720
721       /*gnb DU System Info mib msg*/
722       BuildSib1Msg();
723       DU_ALLOC(duCfgParam.srvdCellLst[i].duSysInfo.sib1Msg,\
724             encBufSize);
725       if(!(duCfgParam.srvdCellLst[i].duSysInfo.sib1Msg))
726       {
727          DU_LOG("\nDU_APP: Memory allocation failure");
728          return RFAILED;
729       }
730       memcpy(duCfgParam.srvdCellLst[i].duSysInfo.sib1Msg,\
731             encBuf,encBufSize);
732       duCfgParam.srvdCellLst[i].duSysInfo.sib1Len = encBufSize;
733
734    }
735
736    if(readMacCfg() != ROK)
737    {
738       DU_LOG("\nDU_APP : Failed while reading MAC config");
739       RETVALUE(RFAILED);
740    }
741
742    RETVALUE(ROK);
743 }
744
745 /*******************************************************************
746  *
747  * @brief Reads config and posts message to du_app on completion
748  *
749  * @details
750  *
751  *    Function : main
752  *
753  *    Functionality:
754  *      - Calls readCfg()
755  *      - Post to du_app for further processing
756  *
757  * @params[in] void
758  * @return ROK     - success
759  *         RFAILED - failure
760  *
761  * ****************************************************************/
762 S16 duReadCfg()
763 {
764    Pst pst;
765    Buffer *mBuf;
766
767    cmMemset((U8 *)&duCfgParam, 0, sizeof(DuCfgParams));
768    //Read configs into duCfgParams
769    if(readCfg() != ROK)
770    {
771       DU_LOG("\nDU_APP : Reading configuration failed");
772       RETVALUE(RFAILED);
773    }
774
775    //Fill pst structure
776    cmMemset((U8 *)&(pst), 0, sizeof(Pst));
777    pst.srcEnt = (Ent)ENTDUAPP;
778    pst.srcInst = (Inst)DU_INST;
779    pst.srcProcId = DU_PROC;
780    pst.dstEnt = pst.srcEnt;
781    pst.dstInst = pst.srcInst;
782    pst.dstProcId = pst.srcProcId;
783    pst.event = EVTCFG;
784    pst.selector = ODU_SELECTOR_TC;
785    pst.pool= DU_POOL;
786
787
788    if(SGetMsg(DFLT_REGION, DU_POOL, &mBuf) != ROK)
789    {
790       DU_LOG("\nDU_APP : Memory allocation failed in duReadCfg");
791       return RFAILED;
792    }
793
794    if (SPstTsk(&pst, mBuf) != ROK)
795    {
796       DU_LOG("\nDU_APP : SPstTsk failed in duReadCfg");
797       return RFAILED;
798    }
799
800    return ROK;
801 }
802
803 /*******************************************************************
804  *
805  * @brief Converts bit strings to integer
806  *
807  * @details
808  *
809  *    Function : bitStringToInt
810  *
811  *    Functionality:
812  *      - Converts ASN bit string format IEs to integer type
813  *
814  * @params[in] void
815  * @return ROK     - success
816  *         RFAILED - failure
817  *
818  * ****************************************************************/
819 S16 bitStringToInt(BIT_STRING_t *bitString, U16 *val)
820 {
821    U16 idx;
822    if(bitString->buf == NULL || bitString->size <= 0)
823    {
824       DU_LOG("\nDU_APP : Bit string is empty");
825       return RFAILED;
826    }
827
828    for(idx=0; idx< bitString->size-1; idx++)
829    {
830       *val |= bitString->buf[idx];
831       *val <<= 8;
832    }
833
834    *val |= bitString->buf[idx];
835    *val >>= bitString->bits_unused;
836
837    return ROK;
838 }
839
840
841 /**********************************************************************
842   End of file
843  **********************************************************************/
844