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