Moving all common header file into common_def.h file
[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 = 14 * (lengthSymbol-1) + startSymbol;
342         }
343         else
344         {
345            sliv = 14 * (14-lengthSymbol+1) + (14-1-startSymbol);
346         }
347         return sliv;
348 }
349
350
351 /*******************************************************************
352  *
353  * @brief Configures serving cell config common in sib1
354  *
355  * @details
356  *
357  *    Function : fillServCellCfgCommSib
358  *
359  *    Functionality:
360  *       - fills Serving cell config common for SIB1
361  *
362  * @params[in] SrvCellCfgCommSib pointer
363  * @return ROK     - success
364  *         RFAILED - failure
365  * 
366  ** ****************************************************************/
367 S16 fillServCellCfgCommSib(SrvCellCfgCommSib *srvCellCfgComm)
368 {
369    PdcchCfgCommon   pdcchCfg;
370    PdschCfgCommon   pdschCfg;
371    PcchCfg          pcchCfg;
372    RachCfgCommon    rachCfg;
373    PuschCfgCommon   puschCfg;
374    PucchCfgCommon   pucchCfg;
375    TddUlDlCfgCommon   tddCfg;
376
377    /* Configuring DL Config Common for SIB1*/
378    srvCellCfgComm->dlCfg.freqBandInd = NR_FREQ_BAND_IND; 
379    srvCellCfgComm->dlCfg.offsetToPointA = OFFSET_TO_POINT_A;
380    srvCellCfgComm->dlCfg.dlScsCarrier.scsOffset = SSB_SUBCARRIER_OFFSET;
381    srvCellCfgComm->dlCfg.dlScsCarrier.scs = SUBCARRIER_SPACING;
382    srvCellCfgComm->dlCfg.dlScsCarrier.scsBw = SCS_CARRIER_BANDWIDTH;
383    srvCellCfgComm->dlCfg.locAndBw = FREQ_LOC_BW;
384    
385    /* Configuring PDCCH Config Common For SIB1 */
386    pdcchCfg.present = BWP_DownlinkCommon__pdcch_ConfigCommon_PR_setup;
387    pdcchCfg.ctrlRsrcSetZero = PDCCH_CTRL_RSRC_SET_ZERO;
388    pdcchCfg.searchSpcZero = PDCCH_SEARCH_SPACE_ZERO;
389    pdcchCfg.searchSpcId = PDCCH_SEARCH_SPACE_ID;
390    pdcchCfg.ctrlRsrcSetId = PDCCH_CTRL_RSRC_SET_ID;
391    pdcchCfg.monitorSlotPrdAndOffPresent = \
392       SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl1;
393    //pdcchCfg.monitorSlotPrdAndOff = \
394       SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl1;
395    pdcchCfg.monitorSymbolsInSlot[0] = 128;
396    pdcchCfg.monitorSymbolsInSlot[1] = 0;
397    pdcchCfg.numCandAggLvl1 = SearchSpace__nrofCandidates__aggregationLevel1_n8;
398    pdcchCfg.numCandAggLvl2 = SearchSpace__nrofCandidates__aggregationLevel2_n4;
399    pdcchCfg.numCandAggLvl4 = SearchSpace__nrofCandidates__aggregationLevel4_n2;
400    pdcchCfg.numCandAggLvl8 = SearchSpace__nrofCandidates__aggregationLevel8_n1;
401    pdcchCfg.numCandAggLvl16 = SearchSpace__nrofCandidates__aggregationLevel16_n0;
402    pdcchCfg.searchSpcType = SearchSpace__searchSpaceType_PR_common;
403    pdcchCfg.commSrchSpcDciFrmt = PDCCH_SERACH_SPACE_DCI_FORMAT;
404    pdcchCfg.searchSpcSib1 = PDCCH_SEARCH_SPACE_ID_SIB1;
405    pdcchCfg.pagingSearchSpc = PDCCH_SEARCH_SPACE_ID_PAGING;
406    pdcchCfg.raSearchSpc = PDCCH_SEARCH_SPACE_ID_PAGING;
407    srvCellCfgComm->dlCfg.pdcchCfg = pdcchCfg;
408
409    /* Configuring PDSCH Config Common For SIB1 */
410    pdschCfg.present = BWP_DownlinkCommon__pdsch_ConfigCommon_PR_setup;
411    pdschCfg.k0 = PDSCH_K0;
412    pdschCfg.mapType = \
413       PDSCH_TimeDomainResourceAllocation__mappingType_typeA;
414    pdschCfg.sliv = calcSliv(PDSCH_START_SYMBOL,PDSCH_LENGTH_SYMBOL);
415    srvCellCfgComm->dlCfg.pdschCfg = pdschCfg;
416
417    /* Configuring BCCH Config for SIB1 */
418    srvCellCfgComm->dlCfg.bcchCfg.modPrdCoeff = \
419       BCCH_Config__modificationPeriodCoeff_n16;
420
421    /* Configuring PCCH Config for SIB1 */
422    pcchCfg.dfltPagingCycle = PagingCycle_rf64;
423    pcchCfg.nAndPagingFrmOffPresent = PCCH_Config__nAndPagingFrameOffset_PR_oneT;
424    pcchCfg.numPagingOcc = PCCH_Config__ns_four;
425    srvCellCfgComm->dlCfg.pcchCfg = pcchCfg;
426
427
428    /* Configuring UL Config Common */
429    srvCellCfgComm->ulCfg.ulScsCarrier.scsOffset = SSB_SUBCARRIER_OFFSET;
430    srvCellCfgComm->ulCfg.ulScsCarrier.scs = SUBCARRIER_SPACING;
431    srvCellCfgComm->ulCfg.ulScsCarrier.scsBw = SCS_CARRIER_BANDWIDTH;
432    srvCellCfgComm->ulCfg.pMax = UL_P_MAX;
433    srvCellCfgComm->ulCfg.locAndBw = FREQ_LOC_BW;
434    srvCellCfgComm->ulCfg.timeAlignTimerComm = TimeAlignmentTimer_infinity;
435
436    /* Configuring RACH Config Common for SIB1 */
437    rachCfg.present = BWP_UplinkCommon__rach_ConfigCommon_PR_setup;
438    rachCfg.prachCfgIdx = PRACH_CONFIG_IDX;
439    rachCfg.msg1Fdm = RACH_ConfigGeneric__msg1_FDM_one;
440    rachCfg.msg1FreqStart = PRACH_FREQ_START;
441    rachCfg.zeroCorrZoneCfg = ZERO_CORRELATION_ZONE_CFG;
442    rachCfg.preambleRcvdTgtPwr = PRACH_PREAMBLE_RCVD_TGT_PWR;
443    rachCfg.preambleTransMax = RACH_ConfigGeneric__preambleTransMax_n200;
444    rachCfg.pwrRampingStep = RACH_ConfigGeneric__powerRampingStep_dB2;
445    rachCfg.raRspWindow = RACH_ConfigGeneric__ra_ResponseWindow_sl20;
446    rachCfg.numRaPreamble = NUM_RA_PREAMBLE;
447    rachCfg.ssbPerRachOccPresent = \
448       RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_one;
449    rachCfg.numSsbPerRachOcc = SSB_PER_RACH;
450    rachCfg.contResTimer = RACH_ConfigCommon__ra_ContentionResolutionTimer_sf64;
451    rachCfg.rsrpThreshSsb = RSRP_THRESHOLD_SSB;
452    rachCfg.rootSeqIdxPresent = RACH_ConfigCommon__prach_RootSequenceIndex_PR_l139;
453    rachCfg.rootSeqIdx = ROOT_SEQ_IDX;
454    rachCfg.msg1Scs = PRACH_SUBCARRIER_SPACING ;
455    rachCfg.restrictedSetCfg = PRACH_RESTRICTED_SET_CFG;
456    srvCellCfgComm->ulCfg.rachCfg = rachCfg;
457
458    /* Configuring PUSCH Config Common for SIB1 */
459    puschCfg.present = BWP_UplinkCommon__pusch_ConfigCommon_PR_setup;
460    puschCfg.k2 = PUSCH_K2;
461    puschCfg.mapType = PUSCH_TimeDomainResourceAllocation__mappingType_typeA;
462    puschCfg.sliv = calcSliv(PUSCH_START_SYMBOL,PUSCH_LENGTH_SYMBOL);
463    puschCfg.msg3DeltaPreamble = PUSCH_MSG3_DELTA_PREAMBLE;
464    puschCfg.p0NominalWithGrant = PUSCH_P0_NOMINAL_WITH_GRANT;
465    srvCellCfgComm->ulCfg.puschCfg = puschCfg;
466
467    /* Configuring PUCCH Config Common for SIB1 */
468    pucchCfg.present = BWP_UplinkCommon__pucch_ConfigCommon_PR_setup;
469    pucchCfg.rsrcComm = PUCCH_RSRC_COMMON;
470    pucchCfg.grpHop = PUCCH_ConfigCommon__pucch_GroupHopping_neither;
471    pucchCfg.p0Nominal = PUCCH_P0_NOMINAL;
472    srvCellCfgComm->ulCfg.pucchCfg = pucchCfg;
473
474    /* Configuring TDD UL DL config common */
475    tddCfg.refScs = SubcarrierSpacing_kHz30;
476    tddCfg.txPrd = TDD_UL_DL_Pattern__dl_UL_TransmissionPeriodicity_ms2p5;
477    tddCfg.numDlSlots = NUM_DL_SLOTS;
478    tddCfg.numDlSymbols = NUM_DL_SYMBOLS;
479    tddCfg.numUlSlots = NUM_UL_SLOTS;
480    tddCfg.numUlSymbols = NUM_UL_SYMBOLS;
481    srvCellCfgComm->tddCfg = tddCfg;
482
483    srvCellCfgComm->ssbPosInBurst = 192;
484    srvCellCfgComm->ssbPrdServingCell = SSB_PERIODICITY_20MS;
485    srvCellCfgComm->ssPbchBlockPwr = SSB_PBCH_PWR;
486
487    return ROK;
488 }
489
490 /*******************************************************************
491  *
492  * @brief Configures the DU Parameters
493  *
494  * @details
495  *
496  *    Function : readCfg
497  *
498  *    Functionality:
499  *       - Initializes the DuCfg members.  
500  *       - Calls readMacCfg()  
501  *
502  * @params[in] system task ID
503  * @return ROK     - success
504  *         RFAILED - failure
505  *
506  * ****************************************************************/
507
508 S16 readCfg()
509 {
510    U8 i,j,k;
511    U32 ipv4_du, ipv4_cu, ipv4_ric;
512         MibParams mib;
513    Sib1Params sib1;     
514
515    cmInetAddr((S8*)DU_IP_V4_ADDR, &ipv4_du);
516    cmInetAddr((S8*)CU_IP_V4_ADDR, &ipv4_cu);
517         cmInetAddr((S8*)RIC_IP_V4_ADDR, &ipv4_ric);
518         fillDuPort(duCfgParam.sctpParams.duPort);
519
520    /* F1 DU IP Address and Port*/
521    duCfgParam.sctpParams.duIpAddr.ipV4Addr = ipv4_du;
522
523    /* F1 CU IP Address and Port*/
524    duCfgParam.sctpParams.cuIpAddr.ipV4Addr = ipv4_cu;
525    duCfgParam.sctpParams.cuPort = CU_PORT;
526
527         /* Fill RIC Params */
528         duCfgParam.sctpParams.ricIpAddr.ipV4Addr = ipv4_ric;
529         duCfgParam.sctpParams.ricPort            = RIC_PORT;
530    /* EGTP Parameters */
531    duCfgParam.egtpParams.localIp.ipV4Pres = TRUE;
532    duCfgParam.egtpParams.localIp.ipV4Addr = ipv4_du;
533    duCfgParam.egtpParams.localPort = DU_EGTP_PORT;
534    duCfgParam.egtpParams.destIp.ipV4Pres = TRUE;
535    duCfgParam.egtpParams.destIp.ipV4Addr = ipv4_cu;
536    duCfgParam.egtpParams.destPort = CU_EGTP_PORT;
537    duCfgParam.egtpParams.minTunnelId = 0;
538    duCfgParam.egtpParams.maxTunnelId = 10;
539
540    duCfgParam.maxUe = 32; //TODO: Check
541    /* DU Info */        
542    duCfgParam.duId = DU_ID;     
543    strcpy((char*)duCfgParam.duName,DU_NAME);
544
545    /* Mib Params */
546         mib.sysFrmNum = SYS_FRAME_NUM;
547         mib.subCarrierSpacingCommon = MIB__subCarrierSpacingCommon_scs15or60;
548         mib.ssb_SubcarrierOffset = SSB_SC_OFFSET; 
549         mib.dmrs_TypeA_Position = MIB__dmrs_TypeA_Position_pos2;
550         mib.controlResourceSetZero = CORESET_ZERO;
551         mib.searchSpaceZero = SEARCH_SPACE_ZERO;
552         mib.cellBarred = MIB__cellBarred_barred;
553         mib.intraFreqReselection =
554                 MIB__intraFreqReselection_notAllowed;
555         duCfgParam.mibParams = mib;
556
557    /* SIB1 Params */
558         sib1.plmn.mcc[0] = PLMN_MCC0;
559         sib1.plmn.mcc[1] = PLMN_MCC1;
560         sib1.plmn.mcc[2] = PLMN_MCC2;
561         sib1.plmn.mnc[0] = PLMN_MNC0;
562         sib1.plmn.mnc[1] = PLMN_MNC1;
563         sib1.plmn.mnc[2] = PLMN_MNC2;
564         sib1.tac = DU_TAC;
565         sib1.ranac = DU_RANAC;
566         sib1.cellIdentity = CELL_IDENTITY;
567         sib1.cellResvdForOpUse =\
568                 PLMN_IdentityInfo__cellReservedForOperatorUse_notReserved;
569    sib1.connEstFailCnt = ConnEstFailureControl__connEstFailCount_n3;
570    sib1.connEstFailOffValidity =\
571       ConnEstFailureControl__connEstFailOffsetValidity_s120;
572    sib1.siSchedInfo.winLen = SI_SchedulingInfo__si_WindowLength_s5;
573    sib1.siSchedInfo.broadcastSta = \
574       SchedulingInfo__si_BroadcastStatus_broadcasting;
575    sib1.siSchedInfo.preiodicity = SchedulingInfo__si_Periodicity_rf8;
576    sib1.siSchedInfo.sibType = SIB_TypeInfo__type_sibType2;
577    sib1.siSchedInfo.sibValTag = SIB1_VALUE_TAG;
578
579    fillServCellCfgCommSib(&sib1.srvCellCfgCommSib);
580
581         duCfgParam.sib1Params = sib1;
582
583    for(i=0; i<DEFAULT_CELLS; i++)
584    { 
585       duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.nrCgi.plmn.mcc[0] = PLMN_MCC0;
586       duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.nrCgi.plmn.mcc[1] = PLMN_MCC1;
587       duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.nrCgi.plmn.mcc[2] = PLMN_MCC2;
588       duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.nrCgi.plmn.mnc[0] = PLMN_MNC0;
589       duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.nrCgi.plmn.mnc[1] = PLMN_MNC1;
590       duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.nrCgi.plmn.mnc[2] = PLMN_MNC2;
591
592       /*Cell ID */
593       duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.nrCgi.cellId = NR_CELL_ID;
594       duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.nrPci = NR_PCI;
595
596       /* List of Available PLMN */
597       for(j=0;j<MAX_PLMN;j++)
598       {
599          duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.plmn[j].mcc[0] = PLMN_MCC0;
600          duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.plmn[j].mcc[1] = PLMN_MCC1;
601          duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.plmn[j].mcc[2] = PLMN_MCC2;
602          duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.plmn[j].mnc[0] = PLMN_MNC0;
603          duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.plmn[j].mnc[1] = PLMN_MNC1;
604          duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.plmn[j].mnc[2] = PLMN_MNC2;
605       }
606       /* List of Extended PLMN */
607       for(j=0;j<MAX_PLMN;j++)
608       {
609          duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.extPlmn[j].mcc[0] = PLMN_MCC0;
610          duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.extPlmn[j].mcc[1] = PLMN_MCC1;
611          duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.extPlmn[j].mcc[2] = PLMN_MCC2;
612          duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.extPlmn[j].mnc[0] = PLMN_MNC0;
613          duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.extPlmn[j].mnc[1] = PLMN_MNC1;
614          duCfgParam.srvdCellLst[i].duCellInfo.cellInfo.extPlmn[j].mnc[2] = PLMN_MNC2;
615       } 
616
617       /* TAC and EPSTAC */
618       duCfgParam.srvdCellLst[i].duCellInfo.tac = DU_TAC;
619       duCfgParam.srvdCellLst[i].duCellInfo.epsTac = DU_TAC; //to check and fill
620       /* NR Mode info */
621       duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.nrArfcn = NR_ARFCN;
622       duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.sulInfo.sulArfcn = SUL_ARFCN;
623       duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.sulInfo.sulTxBw.nrScs = SCS_120;
624       duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.sulInfo.sulTxBw.nrb = NRB_66;
625
626 #if 0
627       /* NR Mode info */
628       duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.nrArfcn = NR_ARFCN;
629       duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.sulInfo.sulArfcn = SUL_ARFCN;
630       duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.sulInfo.sulTxBw.nrScs = SCS_15;           
631       duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.sulInfo.sulTxBw.nrb = NRB_160;           
632
633       for(j=0;j<MAXNRCELLBANDS;j++)
634       {
635          duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.freqBand[j].nrFreqBand = NR_FREQ_BAND;
636          for(k=0;k<MAXNRCELLBANDS;k++)
637          {
638             duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.freqBand[j].sulBand[k] = SUL_BAND;  
639          }
640       }
641 #endif
642       for(j=0;j<MAXNRCELLBANDS;j++)
643       {
644          duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.freqBand[j].nrFreqBand = NR_FREQ_BAND;
645          for(k=0;k<MAXNRCELLBANDS;k++)
646          {
647             duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.freqBand[j].sulBand[k] = SUL_BAND;
648          }
649       }
650       duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.nrArfcn = NR_ARFCN;
651       duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.sulInfo.sulArfcn = SUL_ARFCN;
652       duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.sulInfo.sulTxBw.nrScs = SCS_120;
653       duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.sulInfo.sulTxBw.nrb = NRB_66;
654       for(j=0;j<MAXNRCELLBANDS;j++)
655       {
656          duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.freqBand[j].nrFreqBand = NR_FREQ_BAND;
657          for(k=0;k<MAXNRCELLBANDS;k++)
658          {
659             duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.freqBand[j].sulBand[k] = SUL_BAND;
660          }
661       }
662
663       duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.ulTxBw.nrScs = SCS_120;
664       duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.ulTxBw.nrb = NRB_66;
665
666       duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.dlTxBw.nrScs = SCS_120;
667       duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.fdd.dlTxBw.nrb = NRB_66;
668
669 #if 0
670       duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.tdd.nrTxBw.nrScs = SCS_15;
671       duCfgParam.srvdCellLst[i].duCellInfo.f1Mode.mode.tdd.nrTxBw.nrb = NRB_160;
672 #endif
673       /*Measurement Config and Cell Config */ 
674       duCfgParam.srvdCellLst[i].duCellInfo.measTimeCfg = TIME_CFG; 
675
676       duCfgParam.srvdCellLst[i].duCellInfo.cellDir = DL_UL; 
677
678       duCfgParam.srvdCellLst[i].duCellInfo.cellType=CELL_TYPE;
679
680       /* Broadcast PLMN Identity */
681       for(j=0;j<MAXBPLMNNRMINUS1;j++)
682       {  
683          for(k=0;k<MAX_PLMN;k++)
684          {
685             duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].plmn[k].mcc[0] = PLMN_MCC0;
686             duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].plmn[k].mcc[1] = PLMN_MCC1;
687             duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].plmn[k].mcc[2] = PLMN_MCC2;
688             duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].plmn[k].mnc[0] = PLMN_MNC0;
689             duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].plmn[k].mnc[1] = PLMN_MNC1;                                         
690             duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].plmn[k].mnc[2] = PLMN_MNC2;
691          }
692          /* Extended PLMN List */        
693          for(k=0;k<MAX_PLMN;k++)
694          {
695             duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].extPlmn[k].mcc[0] = PLMN_MCC0;
696             duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].extPlmn[k].mcc[1] = PLMN_MCC1;
697             duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].extPlmn[k].mcc[2] = PLMN_MCC2;
698             duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].extPlmn[k].mnc[0] = PLMN_MNC0;
699             duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].extPlmn[k].mnc[1] = PLMN_MNC1;
700             duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].extPlmn[k].mnc[2] = PLMN_MNC2;
701          }
702
703          duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].tac = DU_TAC;
704          duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].nrCellId = NR_CELL_ID;
705          duCfgParam.srvdCellLst[i].duCellInfo.brdcstPlmnInfo[j].ranac = NR_RANAC;
706       }
707
708       /*gnb DU System Info mib msg*/
709            BuildMibMsg();
710                 DU_ALLOC(duCfgParam.srvdCellLst[i].duSysInfo.mibMsg,\
711                                 strlen(encBuf));
712            if(!(duCfgParam.srvdCellLst[i].duSysInfo.mibMsg))
713                 {
714          DU_LOG("\nDU_APP: Memory allocation failure");
715                         return RFAILED;
716                 }
717       strcpy((char *)duCfgParam.srvdCellLst[i].duSysInfo.mibMsg, encBuf);
718       duCfgParam.srvdCellLst[i].duSysInfo.mibLen = encBufSize;
719
720       /*gnb DU System Info mib msg*/
721       BuildSib1Msg();
722                 DU_ALLOC(duCfgParam.srvdCellLst[i].duSysInfo.sib1Msg,\
723                                 encBufSize);
724            if(!(duCfgParam.srvdCellLst[i].duSysInfo.sib1Msg))
725                 {
726          DU_LOG("\nDU_APP: Memory allocation failure");
727                         return RFAILED;
728                 }
729                 memcpy(duCfgParam.srvdCellLst[i].duSysInfo.sib1Msg,\
730                        encBuf,encBufSize);
731                 duCfgParam.srvdCellLst[i].duSysInfo.sib1Len = encBufSize;
732
733    }
734
735    if(readMacCfg() != ROK)
736    {
737       DU_LOG("\nDU_APP : Failed while reading MAC config");
738       RETVALUE(RFAILED);
739    }
740
741    RETVALUE(ROK);
742 }
743
744 /*******************************************************************
745  *
746  * @brief Reads config and posts message to du_app on completion
747  *
748  * @details
749  *
750  *    Function : main
751  *
752  *    Functionality:
753  *      - Calls readCfg()
754  *      - Post to du_app for further processing
755  *
756  * @params[in] void
757  * @return ROK     - success
758  *         RFAILED - failure
759  *
760  * ****************************************************************/
761 S16 duReadCfg()
762 {
763    Pst pst;
764    Buffer *mBuf;
765
766    cmMemset((U8 *)&duCfgParam, 0, sizeof(DuCfgParams));
767    //Read configs into duCfgParams
768    if(readCfg() != ROK)
769    {
770       DU_LOG("\nDU_APP : Reading configuration failed");
771       RETVALUE(RFAILED);
772    }
773
774    //Fill pst structure
775    cmMemset((U8 *)&(pst), 0, sizeof(Pst));
776    pst.srcEnt = (Ent)ENTDUAPP;
777    pst.srcInst = (Inst)DU_INST;
778    pst.srcProcId = DU_PROC;
779    pst.dstEnt = pst.srcEnt;
780    pst.dstInst = pst.srcInst;
781    pst.dstProcId = pst.srcProcId;
782    pst.event = EVTCFG;
783    pst.selector = ODU_SELECTOR_TC;
784    pst.pool= DU_POOL;
785
786
787    if(SGetMsg(DFLT_REGION, DU_POOL, &mBuf) != ROK)
788    {
789       DU_LOG("\nDU_APP : Memory allocation failed in duReadCfg");
790       return RFAILED;
791    }
792
793    if (SPstTsk(&pst, mBuf) != ROK)
794    {
795       DU_LOG("\nDU_APP : SPstTsk failed in duReadCfg");
796       return RFAILED;
797    }
798
799    return ROK;
800 }
801
802 /*******************************************************************
803  *
804  * @brief Converts bit strings to integer
805  *
806  * @details
807  *
808  *    Function : bitStringToInt
809  *
810  *    Functionality:
811  *      - Converts ASN bit string format IEs to integer type
812  *
813  * @params[in] void
814  * @return ROK     - success
815  *         RFAILED - failure
816  *
817  * ****************************************************************/
818 S16 bitStringToInt(BIT_STRING_t *bitString, U16 *val)
819 {
820    U16 idx;
821    if(bitString->buf == NULL || bitString->size <= 0)
822    {
823       DU_LOG("\nDU_APP : Bit string is empty");
824       return RFAILED;
825    }
826
827    for(idx=0; idx< bitString->size-1; idx++)
828    {
829       *val |= bitString->buf[idx];
830       *val <<= 8;
831    }
832
833    *val |= bitString->buf[idx];
834         *val >>= bitString->bits_unused;
835
836    return ROK;
837 }
838
839
840 /**********************************************************************
841   End of file
842  **********************************************************************/
843