[Epic-ID: ODUHIGH-406][Task-ID: ODUHIGH-415]: Paging Configuration
[o-du/l2.git] / src / du_app / du_sys_info_hdl.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 ASN codec for MIB and SIB1 msgs */
20 #include "common_def.h"
21 #include "lrg.h"
22 #include "lkw.x"
23 #include "lrg.x"
24 #include "legtp.h"
25 #include "du_app_mac_inf.h"
26 #include "du_cfg.h"
27 #include "du_utils.h"
28 #include "BCCH-BCH-Message.h"
29 #include "MIB.h"
30 #include "PLMN-IdentityInfo.h"
31 #include "PLMN-IdentitY.h"
32 #include "SIB-TypeInfo.h"
33 #include "SchedulingInfo.h"
34 #include "SI-SchedulingInfo.h"
35 #include "ConnEstFailureControl.h"
36 #include "FrequencyInfoDL-SIB.h"
37 #include "SearchSpace.h"
38 #include "SCS-SpecificCarrier.h"
39 #include "NR-MultiBandInfo.h"
40 #include "PDCCH-ConfigCommon.h"
41 #include "PDSCH-TimeDomainResourceAllocation.h"
42 #include "PDSCH-TimeDomainResourceAllocationList.h"
43 #include "PDSCH-ConfigCommon.h"
44 #include "BWP-DownlinkCommon.h"
45 #include "DownlinkConfigCommonSIB.h"
46 #include "RACH-ConfigCommon.h"
47 #include "PUSCH-TimeDomainResourceAllocation.h"
48 #include "PUSCH-TimeDomainResourceAllocationList.h"
49 #include "PUSCH-ConfigCommon.h"
50 #include "PUCCH-ConfigCommon.h"
51 #include "UplinkConfigCommonSIB.h"
52 #include "TDD-UL-DL-ConfigCommon.h"
53 #include "ServingCellConfigCommonSIB.h"
54 #include "MCC.h"
55 #include "SIB1.h"
56 #include "odu_common_codec.h"
57 #include "du_sys_info_hdl.h"
58
59 void FreeSib1Msg(SIB1_t *sib1Msg);
60 uint8_t FreqInfoUlret = RFAILED;
61 uint8_t RachCfgCommonret = RFAILED;
62 uint8_t PuschCfgCommonret = RFAILED;
63 uint8_t UlCfgCommSibret = RFAILED;
64 uint8_t FreqInfoDlret = RFAILED;
65 uint8_t DlCfgCommSibret = RFAILED;
66 uint8_t CommonSerachSpaceListret = RFAILED;
67
68 /*******************************************************************
69  *
70  * @brief Builds MIB
71  *
72  * @details
73  *
74  *    Function : BuildMib
75  *
76  *    Functionality: Building MIB
77  *
78  * @return ROK     - success
79  *         RFAILED - failure
80  *
81  * ****************************************************************/
82 uint8_t BuildMib(MIB_t *mib)
83 {
84    mib->systemFrameNumber.size = sizeof(uint8_t);
85    DU_ALLOC(mib->systemFrameNumber.buf, mib->systemFrameNumber.size);
86    if(!(mib->systemFrameNumber.buf))
87    {
88       DU_LOG("\nERROR  -->  DU APP: MIB msg memory allocation failure");
89       return RFAILED;
90    }
91
92    *(mib->systemFrameNumber.buf) =  duCfgParam.mibParams.sysFrmNum;
93    mib->systemFrameNumber.bits_unused = ODU_VALUE_TWO;
94
95    mib->subCarrierSpacingCommon = duCfgParam.mibParams.subCarrierSpacingCommon;
96    mib->ssb_SubcarrierOffset = duCfgParam.mibParams.ssb_SubcarrierOffset;
97    mib->dmrs_TypeA_Position = duCfgParam.mibParams.dmrs_TypeA_Position;
98    mib->pdcch_ConfigSIB1.controlResourceSetZero = duCfgParam.mibParams.controlResourceSetZero;
99    mib->pdcch_ConfigSIB1.searchSpaceZero = duCfgParam.mibParams.searchSpaceZero;
100    mib->cellBarred = duCfgParam.mibParams.cellBarred;
101    mib->intraFreqReselection = duCfgParam.mibParams.intraFreqReselection;
102    mib->spare.size = sizeof(uint8_t);
103    DU_ALLOC(mib->spare.buf, mib->spare.size);
104    if(!mib->spare.buf)
105    {
106       DU_LOG("\nERROR  -->  DU APP: MIB msg memory allocation failure");
107       return RFAILED;
108    }
109    *(mib->spare.buf) = SPARE;
110    mib->spare.bits_unused = ODU_VALUE_SEVEN;
111    return ROK;
112 }
113 /*******************************************************************
114  *
115  * @brief Free MIB PDU for broadcast
116  *
117  * @details
118  *
119  *    Function : FreeMibPdu
120  *
121  *    Functionality: Deallocating MIB PDU for system broadcast
122  *
123  * @param[in]: BCCH_BCH_Message_t *bcchMsg
124  *
125  * @return void         
126  *
127  * ****************************************************************/
128 void FreeMibPdu(BCCH_BCH_Message_t *bcchMsg)
129 {
130    if(!bcchMsg)
131    {
132       if(!bcchMsg->message.choice.mib)
133       {
134          if(!(bcchMsg->message.choice.mib->systemFrameNumber.buf))
135          {
136             if(!bcchMsg->message.choice.mib->spare.buf)
137             {
138                DU_FREE(bcchMsg->message.choice.mib->spare.buf,\
139                      bcchMsg->message.choice.mib->spare.size);
140             }
141             DU_FREE(bcchMsg->message.choice.mib->systemFrameNumber.buf,
142                   bcchMsg->message.choice.mib->systemFrameNumber.size);
143          }
144          DU_FREE(bcchMsg->message.choice.mib, sizeof(MIB_t));
145       }
146       DU_FREE(bcchMsg, sizeof(BCCH_BCH_Message_t));
147    }
148 }
149 /*******************************************************************
150  *
151  * @brief Builds MIB PDU for broadcast
152  *
153  * @details
154  *
155  *    Function : BuildMibPdu
156  *
157  *    Functionality: Building MIB PDU for system broadcast
158  *
159  * @return ROK     - success
160  *         RFAILED - failure
161  *
162  * ****************************************************************/
163 uint8_t BuildMibPdu()
164 {
165    uint8_t ret = RFAILED;
166    BCCH_BCH_Message_t *bcchMsg;
167    asn_enc_rval_t encRetVal;        /* Encoder return value */
168    while(true)
169    {
170       DU_ALLOC(bcchMsg, sizeof(BCCH_BCH_Message_t));
171       if(!bcchMsg)
172       {
173          DU_LOG("\nERROR  -->  Memory allocation failure in BuildMibPdu");
174          break;
175       }
176
177       bcchMsg->message.present = BCCH_BCH_MessageType_PR_mib;
178       DU_ALLOC(bcchMsg->message.choice.mib, sizeof(MIB_t));
179       if(!bcchMsg->message.choice.mib)
180       {
181          DU_LOG("\nERROR  -->  Memory allocation failure in BuildMibPdu");
182          break;
183       }
184       if(BuildMib(bcchMsg->message.choice.mib) != ROK)
185       {
186          break;
187       }
188       xer_fprint(stdout, &asn_DEF_BCCH_BCH_Message, bcchMsg);
189       memset(encBuf, 0, ENC_BUF_MAX_LEN);
190       encBufSize = 0;
191       encRetVal = aper_encode(&asn_DEF_BCCH_BCH_Message, 0,
192             bcchMsg, PrepFinalEncBuf, encBuf);
193       printf("\nencbufSize:%d\n", encBufSize);
194       if(encRetVal.encoded == -1) 
195       {   
196          DU_LOG("\nERROR  -->  DU APP: Could not encode BCCH BCH Message Type structure(at %s)\n", 
197                encRetVal.failed_type?\
198                encRetVal.failed_type->name
199                :"unknown");
200          break;
201       }    
202
203       /* Print encoded buffer */
204       for(int i=0; i< encBufSize; i++)
205       {
206          printf("%x\t",encBuf[i]);
207       } 
208       printf("\n");
209
210       ret = ROK;
211       break;
212    }
213    /* Free allocated memory */
214    FreeMibPdu(bcchMsg);
215
216    return ret;
217
218 }
219 /*******************************************************************
220  *
221  * @brief free MIB message in Served Cell Info
222  *
223  * @details
224  *
225  *    Function : FreeMibMsg
226  *
227  *    Functionality: deallocating MIB message in Served Cell Info
228  *
229  * @param[in]   MIB_t *mibMsg
230  *
231  * @return void
232  *        
233  *
234  * ****************************************************************/
235 void FreeMibMsg( MIB_t *mibMsg)
236 {
237    if(!mibMsg)
238    {
239       if(!(mibMsg->systemFrameNumber.buf))
240       {   
241          if(!mibMsg->spare.buf)
242          {
243             DU_FREE(mibMsg->spare.buf, mibMsg->spare.size);
244          }
245          DU_FREE(mibMsg->systemFrameNumber.buf,
246                mibMsg->systemFrameNumber.size);
247       }
248       DU_FREE(mibMsg, sizeof(MIB_t));
249    }
250 }
251 /*******************************************************************
252  *
253  * @brief Builds MIB message in Served Cell Info
254  *
255  * @details
256  *
257  *    Function : BuildMibMsg
258  *
259  *    Functionality: Building MIB message in Served Cell Info
260  *
261  * @return ROK     - success
262  *         RFAILED - failure
263  *
264  * ****************************************************************/
265 uint8_t BuildMibMsg()
266 {
267    MIB_t          *mibMsg;
268    asn_enc_rval_t encRetVal;        /* Encoder return value */
269    uint8_t ret = RFAILED;
270    while(true)
271    {
272       DU_ALLOC(mibMsg, sizeof(MIB_t));
273       if(!mibMsg)
274       {
275          DU_LOG("\nERROR  -->  DU APP: MIB msg memory allocation failure");
276          return RFAILED;
277       }
278       if(BuildMib(mibMsg) != ROK)
279       {
280          break;
281       }
282       xer_fprint(stdout, &asn_DEF_MIB, mibMsg);
283       memset(encBuf, 0, ENC_BUF_MAX_LEN);
284       encBufSize = 0;
285       encRetVal = aper_encode(&asn_DEF_MIB, 0,
286             mibMsg, PrepFinalEncBuf, encBuf);
287       printf("\nencbufSize:%d\n", encBufSize);
288       if(encRetVal.encoded      == -1) 
289       {   
290          DU_LOG("\nERROR  -->  DU APP: Could not encode MIB structure(at %s)\n", 
291                encRetVal.failed_type?\
292                encRetVal.failed_type->name
293                :"unknown");
294          break;
295       }  
296
297       /* Print encoded buffer */
298       for(int i=0; i< encBufSize; i++)
299       {
300          printf("%x\t",encBuf[i]);
301       } 
302       printf("\n");
303
304       /* Free allocated memory */
305       ret = ROK;
306       break;
307    }
308
309    FreeMibMsg(mibMsg);
310
311    return ret;
312
313 }
314
315 /*******************************************************************
316  *
317  * @brief Builds CellIdentity  within SIB1 message
318  *
319  * @details
320  *
321  *    Function : BuildCellIdentity
322  *
323  *    Functionality: Building RAN area code in SIB1 message 
324  *
325  * @params[in] RAN_AreaCode_t **ranAreaCode 
326  * @return ROK     - success
327  *         RFAILED - failure
328  *
329  * ****************************************************************/
330 uint8_t BuildCellIdentity(CellIdentity_t  *cellIdentity)
331 {
332    cellIdentity->size = ODU_VALUE_FIVE*sizeof(uint8_t);
333    cellIdentity->bits_unused = ODU_VALUE_FOUR;
334
335    DU_ALLOC(cellIdentity->buf, cellIdentity->size);
336    if(!cellIdentity->buf)
337    {   
338       DU_LOG("\nERROR  -->  DU APP: CellIdentity memory allocation failure");
339       return RFAILED;
340    }
341    memset(cellIdentity->buf, 0,  cellIdentity->size);
342    cellIdentity->buf[4] = duCfgParam.sib1Params.cellIdentity;
343
344    return ROK;
345 }
346 /*******************************************************************
347  *
348  * @brief Builds RANAC within SIB1 message
349  *
350  * @details
351  *
352  *    Function : BuildRanac
353  *
354  *    Functionality: Building RAN area code in SIB1 message 
355  *
356  * @params[in] RAN_AreaCode_t **ranAreaCode 
357  * @return ROK     - success
358  *         RFAILED - failure
359  *
360  * ****************************************************************/
361 uint8_t BuildRanac(RAN_AreaCode_t **ranAreaCode)
362 {
363    RAN_AreaCode_t *ranac;
364    DU_ALLOC(ranac, sizeof(RAN_AreaCode_t));
365    if(!ranac)
366    {   
367       DU_LOG("\nERROR  -->  DU APP: RANAC memory allocation failure");
368       return RFAILED;
369    }   
370    *ranac = duCfgParam.sib1Params.ranac;
371    *ranAreaCode = ranac;
372    return ROK;
373 }
374 /*******************************************************************
375  *
376  * @brief Builds TAC within SIB1 message
377  *
378  * @details
379  *
380  *    Function : BuildTac
381  *
382  *    Functionality: Building Tracking area code in SIB1 message 
383  *
384  * @params[in] TrackingAreaCode_t **tac 
385  * @return ROK     - success
386  *         RFAILED - failure
387  *
388  * ****************************************************************/
389 uint8_t BuildTac(TrackingAreaCode_t **trackAreaCode)
390 {
391    TrackingAreaCode_t *tac;
392
393
394    DU_ALLOC(tac, sizeof(TrackingAreaCode_t));
395    if(!tac)
396    {   
397       DU_LOG("\nERROR  -->  DU APP: TAC memory allocation failure");
398       return RFAILED;
399    }   
400
401    tac->size = ODU_VALUE_THREE*sizeof(uint8_t);
402    DU_ALLOC(tac->buf, tac->size);
403    if(!tac->buf)
404    {   
405       DU_LOG("\nERROR  -->  DU APP: TAC memory allocation failure");
406       return RFAILED;
407    }   
408    *(tac->buf) = duCfgParam.sib1Params.tac;
409    tac->bits_unused = ODU_VALUE_ZERO;
410    *trackAreaCode = tac;
411
412    return ROK;
413 }
414
415 /*******************************************************************
416  *
417  * @brief Builds PLMN list within SIB1 message
418  *
419  * @details
420  *
421  *    Function : BuildPlmnList
422  *
423  *    Functionality: Building PLMN list in SIB1 message 
424  *
425  * @params[in] CellAccessRelatedInfo_t *cellAccessInfo 
426  * @return ROK     - success
427  *         RFAILED - failure
428  *
429  * ****************************************************************/
430 uint8_t BuildPlmnList(CellAccessRelatedInfo_t *cellAccessInfo)
431 {
432    uint8_t            idx;
433    uint8_t            idx1;
434    uint8_t            idx2;
435    uint8_t            elementCnt;
436    TrackingAreaCode_t **tac;
437    RAN_AreaCode_t     **ranac;
438    CellIdentity_t     *cellIdentity;
439    uint8_t            ret;      
440    struct PLMN_IdentityInfo__plmn_IdentityList
441       *plmnIdInfo;
442
443    DU_ALLOC(cellAccessInfo->plmn_IdentityList.list.array,
444          cellAccessInfo->plmn_IdentityList.list.size);
445    if(!cellAccessInfo->plmn_IdentityList.list.array)
446    {   
447       DU_LOG("\nERROR  -->  DU APP: BuildPlmnList memory allocation failure");
448       return RFAILED;
449    }   
450    elementCnt = cellAccessInfo->plmn_IdentityList.list.count; 
451    for(idx=0; idx<elementCnt; idx++)
452    {   
453       DU_ALLOC(cellAccessInfo->plmn_IdentityList.list.array[idx],
454             sizeof(PLMN_IdentityInfo_t));
455       if(!cellAccessInfo->plmn_IdentityList.list.array[idx])
456       {
457          DU_LOG("\nERROR  -->  DU APP: BuildPlmnList memory allocation failure");
458          return RFAILED;
459       }
460    }
461
462    idx = 0;
463    /* PLMN list */
464    elementCnt = ODU_VALUE_ONE;
465
466    plmnIdInfo = &cellAccessInfo->plmn_IdentityList.list.array[idx]->\
467                 plmn_IdentityList;
468    plmnIdInfo->list.count = elementCnt;
469    plmnIdInfo->list.size  = elementCnt * sizeof(PLMN_IdentitY_t *);
470    DU_ALLOC(plmnIdInfo->list.array, plmnIdInfo->list.size);
471    if(!plmnIdInfo->list.array)
472    {
473       DU_LOG("\nERROR  -->  DU APP: BuildPlmnList memory allocation failure");
474       return RFAILED;
475    }
476
477    for(idx1=0; idx1<elementCnt; idx1++)
478    {
479       DU_ALLOC(plmnIdInfo->list.array[idx1],
480             sizeof(PLMN_IdentitY_t));
481       if(!(plmnIdInfo->list.array[idx1]))
482       {
483          DU_LOG("\nERROR  -->  DU APP: BuildPlmnList memory allocation failure");
484          return RFAILED;
485       }
486    }
487    idx1 = 0;
488    DU_ALLOC(plmnIdInfo->list.array[idx1]->mcc,
489          sizeof(MCC_t));
490    if(!plmnIdInfo->list.array[idx1]->mcc)
491    {
492       DU_LOG("\nERROR  -->  DU APP: BuildPlmnList memory allocation failure");
493       return RFAILED;
494    }
495
496    elementCnt = ODU_VALUE_THREE;
497    plmnIdInfo->list.array[idx1]->mcc->list.count = elementCnt;
498    plmnIdInfo->list.array[idx1]->mcc->list.size =\
499    elementCnt * sizeof(MCC_MNC_Digit_t *);
500    DU_ALLOC(plmnIdInfo->list.array[idx1]->mcc->list.array,
501          plmnIdInfo->list.array[idx1]->mcc->list.size)
502       if(!(plmnIdInfo->list.array[idx1]->mcc->list.array))
503       {
504          DU_LOG("\nERROR  -->  DU APP: BuildPlmnList memory allocation failure");
505          return RFAILED;
506       }
507    for(idx2=0; idx2<elementCnt; idx2++)
508    {
509       DU_ALLOC(plmnIdInfo->list.array[idx1]->mcc->list.array[idx2],
510             sizeof(MCC_MNC_Digit_t));
511       if(!plmnIdInfo->list.array[idx1]->mcc->list.array[idx2])
512       {
513          DU_LOG("\nERROR  -->  DU APP: BuildPlmnList memory allocation failure");
514          return RFAILED;
515       }
516       *(plmnIdInfo->list.array[idx1]->mcc->list.array[idx2])=\
517       duCfgParam.sib1Params.plmn.mcc[idx2];
518    }
519    idx2 = 0;
520    plmnIdInfo->list.array[idx1]->mnc.list.count = elementCnt;
521    plmnIdInfo->list.array[idx1]->mnc.list.size =\
522    elementCnt * sizeof(MCC_MNC_Digit_t *);
523    DU_ALLOC(plmnIdInfo->list.array[idx1]->mnc.list.array,\
524    plmnIdInfo->list.array[idx1]->mnc.list.size);
525    if(!plmnIdInfo->list.array[idx1]->mnc.list.array)
526    {
527       DU_LOG("\nERROR  -->  DU APP: BuildPlmnList memory allocation failure");
528       return RFAILED;
529    }
530    for(idx2=0; idx2<elementCnt; idx2++)
531    {
532       DU_ALLOC(plmnIdInfo->list.array[idx1]->mnc.list.array[idx2],
533             sizeof(MCC_MNC_Digit_t));
534       if(!plmnIdInfo->list.array[idx1]->mnc.list.array[idx2])
535       {
536          DU_LOG("\nERROR  -->  DU APP: BuildPlmnList memory allocation failure");
537          return RFAILED;
538       }
539       *(plmnIdInfo->list.array[idx1]->mnc.list.array[idx2])=\
540       duCfgParam.sib1Params.plmn.mnc[idx2];
541    }
542
543    /* Tracking Area Code */
544    tac = &cellAccessInfo->plmn_IdentityList.list.array[idx]->trackingAreaCode;
545    ret = BuildTac(tac);
546    if(ret != ROK)
547    {
548       return RFAILED;
549    }
550
551    /* RANAC */
552    ranac = &cellAccessInfo->plmn_IdentityList.list.array[idx]->ranac;
553    ret=BuildRanac(ranac);
554    if(ret != ROK)
555    {
556       return RFAILED;
557    }
558
559    /* CellIdentity */
560    cellIdentity = &cellAccessInfo->plmn_IdentityList.list.array[idx]->cellIdentity;
561    ret=BuildCellIdentity(cellIdentity);
562    if(ret != ROK)
563    {
564       return RFAILED;
565    }
566
567    /* cellReservedForOperatorUse */
568    cellAccessInfo->plmn_IdentityList.list.array[idx]->\
569    cellReservedForOperatorUse = duCfgParam.sib1Params.cellResvdForOpUse;
570
571
572    return ROK;
573 }
574
575 /*******************************************************************
576  *
577  * @brief  Build SIB Map Info List
578  *
579  * @details
580  *
581  *    Function : BuildSibMapInfoList
582  *
583  *    Functionality:
584  *       Build SIB MapInfo List
585  *
586  * @params[in] SIB_Mapping_t pointer
587  * @return ROK     - success
588  *         RFAILED - failure
589  *
590  * ****************************************************************/
591 uint8_t BuildSibMapInfoList(SIB_Mapping_t *sibMapInfo)
592 {
593    uint8_t   itr;         /* List iterator */
594    uint8_t   elementCnt;  /* Number of elements in list */
595    SIB_TypeInfo_t *sibTypeInfo;  /* Scheduling info */
596
597    /* SI scheduling info list */
598    DU_ALLOC(sibMapInfo->list.array, sibMapInfo->list.size);
599    if(!sibMapInfo->list.array)
600    {
601       DU_LOG("\nERROR  -->  DU APP: BuildSibMapInfoList memory allocation failure");
602       return RFAILED;
603    }
604
605    elementCnt = sibMapInfo->list.count;
606    for(itr = 0; itr < elementCnt; itr++)
607    {
608       DU_ALLOC(sibMapInfo->list.array[itr], sizeof(SIB_TypeInfo_t));
609       if(!sibMapInfo->list.array[itr])
610       {
611          DU_LOG("\nERROR  -->  DU APP: BuildSibMapInfoList memory allocation failure");
612          return RFAILED;
613       }
614    }
615
616    itr = 0;
617    sibTypeInfo = sibMapInfo->list.array[itr];
618    sibTypeInfo->type = duCfgParam.sib1Params.siSchedInfo.sibType;
619    DU_ALLOC(sibTypeInfo->valueTag, sizeof(long));
620    if(!sibTypeInfo->valueTag)
621    {
622       DU_LOG("\nERROR  -->  DU APP: BuildSibMapInfoList memory allocation failure");
623       return RFAILED;
624    }
625
626    *sibTypeInfo->valueTag = duCfgParam.sib1Params.siSchedInfo.sibValTag;
627
628    return ROK;
629 }
630
631 /*******************************************************************
632  *
633  * @brief Builds SI Scheduling info list within SIB1 message 
634  *
635  * @details
636  *
637  *    Function : BuildSiSchedInfoList 
638  *
639  *    Functionality: 
640  *        Building SI Scheduling info list in SIB1 message
641  *
642  * @params[in] struct SI_SchedulingInfo__schedulingInfoList *si_SchedulingInfo
643  * @return ROK     - success
644  *         RFAILED - failure
645  *
646  * ****************************************************************/
647 uint8_t BuildSiSchedInfoList(struct SI_SchedulingInfo__schedulingInfoList *si_SchedulingInfoList)
648 {
649    uint8_t   itr;         /* List iterator */
650    uint8_t   elementCnt;  /* Number of elements in list */
651    uint8_t   ret;
652    SchedulingInfo_t *schedInfo;  /* Scheduling info */
653
654    /* SI scheduling info list */
655    DU_ALLOC(si_SchedulingInfoList->list.array, si_SchedulingInfoList->list.size);
656    if(!si_SchedulingInfoList->list.array)
657    {
658       DU_LOG("\nERROR  -->  DU APP: BuildSiSchedInfoList memory allocation failure");
659       return RFAILED;
660    }
661
662    elementCnt = si_SchedulingInfoList->list.count;
663    for(itr = 0; itr < elementCnt; itr++)
664    {
665       DU_ALLOC(si_SchedulingInfoList->list.array[itr], sizeof(struct SchedulingInfo));
666       if(!si_SchedulingInfoList->list.array[itr])
667       {
668          DU_LOG("\nERROR  -->  DU APP: BuildSiSchedInfoList memory allocation failure");
669          return RFAILED;
670       }
671    }
672
673    itr = 0;
674    schedInfo = si_SchedulingInfoList->list.array[itr];
675    schedInfo->si_BroadcastStatus = duCfgParam.sib1Params.siSchedInfo.broadcastSta;
676    schedInfo->si_Periodicity = duCfgParam.sib1Params.siSchedInfo.preiodicity;
677
678    elementCnt = ODU_VALUE_ONE; 
679    schedInfo->sib_MappingInfo.list.count = elementCnt;
680    schedInfo->sib_MappingInfo.list.size = elementCnt * sizeof(SIB_TypeInfo_t *);
681
682    ret = BuildSibMapInfoList(&schedInfo->sib_MappingInfo);
683    if(ret != ROK)
684    {
685       return RFAILED;
686    }
687
688    return ROK;
689 }
690
691 /*******************************************************************
692  *
693  * @brief Builds SCS Specific carrier list for DL 
694  *
695  * @details
696  *
697  *    Function : BuildScsSpecificCarrierListDl
698  *
699  *    Functionality:
700  *       Builds Subcarrier specific carrier list for downlink
701  *
702  * @params[in] FrequencyInfoDL_SIB__scs_SpecificCarrierList pointer
703  * @return ROK     - success
704  *         RFAILED - failure
705  *
706  * ****************************************************************/
707 uint8_t BuildScsSpecificCarrierListDl( struct FrequencyInfoDL_SIB__scs_SpecificCarrierList *scsCarrierList)
708 {
709    uint8_t idx;
710    ScsSpecCarrier   duScsSpecCarrier;
711
712    duScsSpecCarrier = duCfgParam.sib1Params.srvCellCfgCommSib.dlCfg.dlScsCarrier;
713
714    DU_ALLOC(scsCarrierList->list.array, scsCarrierList->list.size);
715    if(!scsCarrierList->list.array)
716    {
717       DU_LOG("\nERROR  -->  DU APP : SCS Specific Carrier list memory allocation failed"); 
718       return RFAILED;
719    }
720
721    for(idx = 0; idx < scsCarrierList->list.count; idx++)
722    {
723       DU_ALLOC(scsCarrierList->list.array[idx], sizeof(SCS_SpecificCarrier_t));
724       if(!scsCarrierList->list.array[idx])
725       {
726          DU_LOG("\nERROR  -->  DU APP : SCS Specific Carrier list memory allocation failed");
727          return RFAILED;
728       }
729    }
730
731    idx = 0;
732    scsCarrierList->list.array[idx]->offsetToCarrier = duScsSpecCarrier.scsOffset; 
733    scsCarrierList->list.array[idx]->subcarrierSpacing = duScsSpecCarrier.scs;
734    scsCarrierList->list.array[idx]->carrierBandwidth = duScsSpecCarrier.scsBw;
735
736    return ROK;
737 } /* End of BuildScsSpecificCarrierListDl */
738
739 /*******************************************************************
740  *
741  * @brief Builds common search space list 
742  *
743  * @details
744  *
745  *    Function : BuildCommonSerachSpaceList
746  *
747  *    Functionality:
748  *      Builds common search space list
749  *
750  * @params[in] PDCCH_ConfigCommon__commonSearchSpaceList pointer
751  * @return ROK     - success
752  *         RFAILED - failure
753  *
754  * ****************************************************************/
755 uint8_t BuildCommonSerachSpaceList( struct PDCCH_ConfigCommon__commonSearchSpaceList *searchSpclist)
756 {
757    uint8_t idx;
758    SearchSpace_t    *searchSpace;
759    PdcchCfgCommon   duPdcchCfg;
760
761    duPdcchCfg = duCfgParam.sib1Params.srvCellCfgCommSib.dlCfg.pdcchCfg;
762
763    DU_ALLOC(searchSpclist->list.array, searchSpclist->list.size)
764    if(!searchSpclist->list.array)
765    {
766       DU_LOG("\nERROR  -->  DU APP : Common search space list memory alloc failed");
767       return RFAILED;
768    }
769
770    for(idx = 0; idx < searchSpclist->list.count; idx++)
771    {
772       DU_ALLOC(searchSpclist->list.array[idx], sizeof(SearchSpace_t));
773       if(!searchSpclist->list.array[idx])
774       {
775          DU_LOG("\nERROR  -->  DU APP : Common search space list memory alloc failed");
776          return RFAILED;
777       }
778    }
779
780    idx = 0;
781    searchSpace = searchSpclist->list.array[idx];
782
783    /* Search Space id */
784    searchSpace->searchSpaceId = duPdcchCfg.searchSpcId;
785
786    /* Control Resource Set Id */
787    DU_ALLOC(searchSpace->controlResourceSetId, sizeof(ControlResourceSetId_t));
788    if(!searchSpace->controlResourceSetId)
789    {
790       DU_LOG("\nERROR  -->  DU APP : Common search space list memory alloc failed");
791       return RFAILED;
792    }
793    *searchSpace->controlResourceSetId = duPdcchCfg.ctrlRsrcSetId;
794
795    /* Monitoring Slot periodicity and offset */
796    DU_ALLOC(searchSpace->monitoringSlotPeriodicityAndOffset,\
797    sizeof(struct SearchSpace__monitoringSlotPeriodicityAndOffset));
798    if(!searchSpace->monitoringSlotPeriodicityAndOffset)
799    {
800       DU_LOG("\nERROR  -->  DU APP : Common search space list memory alloc failed");
801       return RFAILED;
802    }
803    searchSpace->monitoringSlotPeriodicityAndOffset->present = \
804    duPdcchCfg.monitorSlotPrdAndOffPresent;
805    switch(searchSpace->monitoringSlotPeriodicityAndOffset->present)
806    {
807       case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl1:
808       {
809          //searchSpace->monitoringSlotPeriodicityAndOffset->choice.s11 =  duPdcchCfg.monitorSlotPrdAndOff;
810          break;
811       }
812       case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl2:
813       {
814          //TODO
815          break;
816       }
817       case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl4:
818       {
819          //TODO
820          break;
821       }
822       case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl5:
823       {
824          //TODO
825          break;
826       }
827       case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl8:
828       {
829          //TODO
830          break;
831       }
832       case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl10:
833       {
834          //TODO
835          break;
836       }
837       case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl16:
838       {
839          //TODO;
840          break;
841       }
842       case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl20:
843       {
844          //TODO
845          break;
846       }
847       case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl40:
848       {
849          //TODO
850          break;
851       }
852       case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl80:
853       {
854          //TODO
855          break;
856       }
857       case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl160:
858       {
859          //TODO
860          break;
861       }
862       case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl320:
863       {
864         //TODO
865          break;
866       }
867       case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl640:
868       {
869          //TODO
870          break;
871       }
872       case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl1280:
873       {
874          //TODO
875          break;
876       }
877       case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl2560:
878       {
879          //TODO
880          break;
881       }
882       default:
883       {
884          DU_LOG("\nERROR  -->  DU APP : Invalid value:Montoring slot periodicity and offset");
885          return RFAILED;
886       }
887    }
888
889    /* Monitoring Symbols Within Slot */
890    DU_ALLOC(searchSpace->monitoringSymbolsWithinSlot,\
891    sizeof(BIT_STRING_t));
892    if(!searchSpace->monitoringSymbolsWithinSlot)
893    {
894       DU_LOG("\nERROR  -->  DU APP : Common search space list memory alloc failed");
895       return RFAILED;
896    }
897    searchSpace->monitoringSymbolsWithinSlot->size = 2*sizeof(uint8_t);
898    DU_ALLOC(searchSpace->monitoringSymbolsWithinSlot->buf, \
899    searchSpace->monitoringSymbolsWithinSlot->size );
900    if(!searchSpace->monitoringSymbolsWithinSlot->buf)
901    {  
902       DU_LOG("\nERROR  -->  DU APP : Common search space list memory alloc failed");
903       return RFAILED;
904    }
905    searchSpace->monitoringSymbolsWithinSlot->buf[0] = duPdcchCfg.monitorSymbolsInSlot[0];
906    searchSpace->monitoringSymbolsWithinSlot->buf[1] = duPdcchCfg.monitorSymbolsInSlot[1];
907    searchSpace->monitoringSymbolsWithinSlot->bits_unused = 2;
908
909    /* Number of candidates per aggregation level */
910    DU_ALLOC(searchSpace->nrofCandidates,\
911          sizeof(struct SearchSpace__nrofCandidates));
912    if(!searchSpace->nrofCandidates)
913    {
914       DU_LOG("\nERROR  -->  DU APP : Common search space list memory alloc failed");
915       return RFAILED;
916    }
917    searchSpace->nrofCandidates->aggregationLevel1 = duPdcchCfg.numCandAggLvl1;
918    searchSpace->nrofCandidates->aggregationLevel2 = duPdcchCfg.numCandAggLvl2;
919    searchSpace->nrofCandidates->aggregationLevel4 = duPdcchCfg.numCandAggLvl4;
920    searchSpace->nrofCandidates->aggregationLevel8 = duPdcchCfg.numCandAggLvl8;
921    searchSpace->nrofCandidates->aggregationLevel16 = duPdcchCfg.numCandAggLvl16;
922
923    /* Search Space type and  DCI Format */
924    DU_ALLOC(searchSpace->searchSpaceType,\
925    sizeof( struct SearchSpace__searchSpaceType));
926    if(!searchSpace->searchSpaceType)
927    {
928       DU_LOG("\nERROR  -->  DU APP : Common search space list memory alloc failed");
929       return RFAILED;
930    }
931
932    searchSpace->searchSpaceType->present = duPdcchCfg.searchSpcType; 
933    switch(searchSpace->searchSpaceType->present)
934    {
935       case SearchSpace__searchSpaceType_PR_NOTHING:
936       {
937          //TODO
938          break;
939       }
940       case SearchSpace__searchSpaceType_PR_common:
941       {
942          DU_ALLOC(searchSpace->searchSpaceType->choice.common, sizeof(struct SearchSpace__searchSpaceType__common));
943          if(!searchSpace->searchSpaceType->choice.common)
944          {
945             DU_LOG("\nERROR  -->  DU APP : Common search space list memory alloc failed");
946             return RFAILED;
947          }
948
949          DU_ALLOC(searchSpace->searchSpaceType->choice.common->\
950          dci_Format0_0_AndFormat1_0, sizeof(struct \
951          SearchSpace__searchSpaceType__common__dci_Format0_0_AndFormat1_0));
952          if(!searchSpace->searchSpaceType->choice.common->dci_Format0_0_AndFormat1_0)
953          {
954             DU_LOG("\nERROR  -->  DU APP : Common search space list memory alloc failed");
955             return RFAILED;
956          }
957          break;
958       }
959       case SearchSpace__searchSpaceType_PR_ue_Specific:
960       {
961          break;
962       }
963       default:
964       {
965          DU_LOG("\nERROR  -->  DU_APP: Invalid Search Space type");
966          return RFAILED;
967       }
968    }
969
970    return ROK;
971 }/* BuildCommonSerachSpaceList */
972
973 /*******************************************************************
974  *
975  * @brief Builds PDCCH configuration common 
976  *
977  * @details
978  *
979  *    Function : BuildPdcchCfgCommon
980  *
981  *    Functionality:
982  *      Builds PDCCH configuration common
983  *
984  * @params[in] BWP_DownlinkCommon__pdcch_ConfigCommon pointer
985  * @return ROK     - success
986  *         RFAILED - failure
987  *
988  * ****************************************************************/
989 uint8_t BuildPdcchCfgCommon(struct BWP_DownlinkCommon__pdcch_ConfigCommon *pdcchCfg)
990 {
991    uint8_t   ret;
992    uint8_t   elementCnt;
993    PdcchCfgCommon   duPdcchCfg;
994    PDCCH_ConfigCommon_t  *pdcchSetup;
995
996    duPdcchCfg = duCfgParam.sib1Params.srvCellCfgCommSib.dlCfg.pdcchCfg;
997
998    pdcchCfg->present = duPdcchCfg.present;
999
1000    switch(pdcchCfg->present)
1001    {
1002       case BWP_DownlinkCommon__pdcch_ConfigCommon_PR_NOTHING:
1003       {
1004          //TODO
1005          break;
1006       }
1007       case BWP_DownlinkCommon__pdcch_ConfigCommon_PR_release:
1008       {
1009          //TODO
1010          break;
1011       }
1012       case BWP_DownlinkCommon__pdcch_ConfigCommon_PR_setup:
1013       {
1014          DU_ALLOC(pdcchCfg->choice.setup, sizeof(PDCCH_ConfigCommon_t));
1015          if(!pdcchCfg->choice.setup)
1016          {
1017             DU_LOG("\nERROR  -->  DU APP : PDCCH Config memory alloc failed");
1018             return RFAILED;
1019          }
1020          pdcchSetup = pdcchCfg->choice.setup;
1021
1022          /* Control Resource Set Zero */
1023          DU_ALLOC(pdcchSetup->controlResourceSetZero, sizeof(ControlResourceSetZero_t)); 
1024          if(!pdcchSetup->controlResourceSetZero)
1025          {
1026             DU_LOG("\nERROR  -->  DU APP : PDCCH Config memory alloc failed");
1027             return RFAILED;
1028          }
1029          *pdcchSetup->controlResourceSetZero = duPdcchCfg.ctrlRsrcSetZero;
1030
1031          /* Search space zero */
1032          DU_ALLOC(pdcchSetup->searchSpaceZero, sizeof(SearchSpaceZero_t));
1033          if(!pdcchSetup->searchSpaceZero)
1034          {
1035             DU_LOG("\nERROR  -->  DU APP : PDCCH Config memory alloc failed");
1036             return RFAILED;
1037          }
1038          *pdcchSetup->searchSpaceZero = duPdcchCfg.searchSpcZero;
1039
1040          /* Common Search Space List */
1041          DU_ALLOC(pdcchSetup->commonSearchSpaceList,\
1042                   sizeof(struct PDCCH_ConfigCommon__commonSearchSpaceList));
1043          if(!pdcchSetup->commonSearchSpaceList)
1044          {
1045             DU_LOG("\nERROR  -->  DU APP : PDCCH Config memory alloc failed");
1046             return RFAILED;
1047          }
1048          elementCnt = ODU_VALUE_ONE;
1049          pdcchSetup->commonSearchSpaceList->list.count = elementCnt;
1050          pdcchSetup->commonSearchSpaceList->list.size =  elementCnt * sizeof(SearchSpace_t *);
1051          ret = BuildCommonSerachSpaceList(pdcchSetup->commonSearchSpaceList);
1052          if(ret != ROK)
1053          {
1054             return RFAILED;
1055          }
1056          CommonSerachSpaceListret=ROK;
1057
1058          /* Search Space for SIB1 */
1059          DU_ALLOC(pdcchSetup->searchSpaceSIB1, sizeof(SearchSpaceId_t));
1060          if(!pdcchSetup->searchSpaceSIB1)
1061          {
1062             DU_LOG("\nERROR  -->  DU APP : PDCCH Config memory alloc failed");
1063             return RFAILED;
1064          }
1065          *pdcchSetup->searchSpaceSIB1 = duPdcchCfg.searchSpcSib1;
1066
1067          /* Serach Space for Paging */
1068          DU_ALLOC(pdcchSetup->pagingSearchSpace, sizeof(SearchSpaceId_t));
1069          if(!pdcchSetup->pagingSearchSpace)
1070          {
1071             DU_LOG("\nERROR  -->  DU APP : PDCCH Config memory alloc failed");
1072             return RFAILED;
1073          }  
1074          *pdcchSetup->pagingSearchSpace = duPdcchCfg.pagingSearchSpc;
1075
1076          /* Search space for Random Access */
1077          DU_ALLOC(pdcchSetup->ra_SearchSpace, sizeof(SearchSpaceId_t));
1078          if(!pdcchSetup->ra_SearchSpace)
1079          {
1080             DU_LOG("\nERROR  -->  DU APP : PDCCH Config memory alloc failed");
1081             return RFAILED;
1082          }             
1083          *pdcchSetup->ra_SearchSpace = duPdcchCfg.raSearchSpc;
1084
1085          break;
1086       }
1087       default :
1088       {
1089          DU_LOG("\nERROR  -->  DU APP : Invalid PDCCH Config type");
1090          return RFAILED; 
1091       }
1092    }
1093
1094    return ROK;
1095 } /* BuildPdcchCfgCommon */
1096
1097 /*******************************************************************
1098  *
1099  * @brief Builds PDSCH configuration common 
1100  *
1101  * @details
1102  *
1103  *    Function : BuildPdschCfgCommon
1104  *
1105  *    Functionality:
1106  *       Builds PDSCH configuration common
1107  *
1108  * @params[in] BWP_DownlinkCommon__pdsch_ConfigCommon pointer
1109  * @return ROK     - success
1110  *         RFAILED - failure
1111  *
1112  * ****************************************************************/
1113 uint8_t BuildPdschCfgCommon(struct BWP_DownlinkCommon__pdsch_ConfigCommon *pdschCfg)
1114 {
1115    uint8_t   idx;
1116    uint8_t   elementCnt;
1117    PdschCfgCommon   duPdschCfg;
1118    PDSCH_ConfigCommon_t  *pdschSetup;
1119    PDSCH_TimeDomainResourceAllocation_t  *timeDomRsrcAllocInfo;
1120
1121    duPdschCfg = duCfgParam.sib1Params.srvCellCfgCommSib.dlCfg.pdschCfg;
1122
1123    pdschCfg->present = duPdschCfg.present;
1124
1125    switch(pdschCfg->present)
1126    {
1127       case BWP_DownlinkCommon__pdsch_ConfigCommon_PR_NOTHING:
1128       {
1129          //TODO
1130          break;
1131       }
1132       case BWP_DownlinkCommon__pdsch_ConfigCommon_PR_release:
1133       {
1134          //TODO
1135          break;
1136       }
1137       case BWP_DownlinkCommon__pdsch_ConfigCommon_PR_setup:
1138       {
1139          DU_ALLOC(pdschCfg->choice.setup, sizeof(PDSCH_ConfigCommon_t));
1140          if(!pdschCfg->choice.setup)
1141          {
1142             DU_LOG("\nERROR  -->  DU APP : PDCCH Config memory alloc failed");
1143             return RFAILED;
1144          }
1145          pdschSetup = pdschCfg->choice.setup; 
1146
1147          /* Time Domain Allocation List */
1148          DU_ALLOC(pdschSetup->pdsch_TimeDomainAllocationList, \
1149                   sizeof(PDSCH_TimeDomainResourceAllocationList_t));
1150          if(!pdschSetup->pdsch_TimeDomainAllocationList)
1151          {
1152             DU_LOG("\nERROR  -->  DU APP : PDCCH Config memory alloc failed");
1153             return RFAILED;
1154          }
1155          elementCnt = duPdschCfg.numTimeDomRsrcAlloc;
1156          pdschSetup->pdsch_TimeDomainAllocationList->list.count = elementCnt;
1157          pdschSetup->pdsch_TimeDomainAllocationList->list.size =  elementCnt * sizeof(PDSCH_TimeDomainResourceAllocation_t *);
1158
1159          DU_ALLOC(pdschSetup->pdsch_TimeDomainAllocationList->list.array,\
1160          pdschSetup->pdsch_TimeDomainAllocationList->list.size);
1161          if(!pdschSetup->pdsch_TimeDomainAllocationList->list.array)
1162          {
1163             DU_LOG("\nERROR  -->  DU APP : PDCCH Config memory alloc failed");
1164             return RFAILED;
1165          }
1166
1167          for(idx=0; idx<elementCnt; idx++)
1168          {
1169             DU_ALLOC(pdschSetup->pdsch_TimeDomainAllocationList->list.array[idx],\
1170             sizeof(PDSCH_TimeDomainResourceAllocation_t));
1171             if(!pdschSetup->pdsch_TimeDomainAllocationList->list.array[idx])
1172             {
1173                DU_LOG("\nERROR  -->  DU APP : PDCCH Config memory alloc failed");
1174                return RFAILED;
1175             }
1176          }
1177
1178     for(idx = 0; idx < pdschSetup->pdsch_TimeDomainAllocationList->list.count; idx++)
1179     {
1180        timeDomRsrcAllocInfo = pdschSetup->pdsch_TimeDomainAllocationList->list.array[idx];
1181
1182        /* K0 */
1183        DU_ALLOC(timeDomRsrcAllocInfo->k0, sizeof(long));
1184        if(!timeDomRsrcAllocInfo->k0)
1185        {
1186           DU_LOG("\nERROR  -->  DU APP : PDCCH Config memory alloc failed");
1187           return RFAILED;
1188        }
1189        *timeDomRsrcAllocInfo->k0 = duPdschCfg.timeDomAlloc[idx].k0;
1190
1191        timeDomRsrcAllocInfo->mappingType = duPdschCfg.timeDomAlloc[idx].mapType;
1192        timeDomRsrcAllocInfo->startSymbolAndLength = duPdschCfg.timeDomAlloc[idx].sliv;
1193     }
1194          break;
1195       }
1196       default:
1197       {
1198          DU_LOG("\nERROR  -->  DU APP: Invalid PDSCH Configuration type");
1199          return RFAILED;
1200       }
1201    }
1202
1203    return ROK;
1204 }/* BuildPdschCfgCommon */
1205
1206 /*******************************************************************
1207  *
1208  * @brief Builds DL BWP common 
1209  *
1210  * @details
1211  *
1212  *    Function : BuildBwpDlCommon
1213  *
1214  *    Functionality:
1215  *      Builds DL BWP common
1216  *
1217  * @params[in] BWP_DownlinkCommon_t pointer
1218  * @return ROK     - success
1219  *         RFAILED - failure
1220  *
1221  * ****************************************************************/
1222 uint8_t BuildBwpDlCommon(BWP_DownlinkCommon_t *bwp)
1223 {
1224    uint8_t ret;
1225    DlCfgCommon duDlCfg;
1226
1227    duDlCfg = duCfgParam.sib1Params.srvCellCfgCommSib.dlCfg;
1228
1229    bwp->genericParameters.locationAndBandwidth = duDlCfg.locAndBw;
1230    bwp->genericParameters.subcarrierSpacing = duDlCfg.dlScsCarrier.scs;
1231
1232    /* PDCCH Config Common */
1233    DU_ALLOC(bwp->pdcch_ConfigCommon, \
1234          sizeof(struct BWP_DownlinkCommon__pdcch_ConfigCommon));
1235    if(!bwp->pdcch_ConfigCommon)
1236    {
1237       DU_LOG("\nERROR  -->  DU APP : DL BWP memory allocation failed");
1238       return RFAILED;
1239    }
1240    ret=BuildPdcchCfgCommon(bwp->pdcch_ConfigCommon);
1241    if(ret != ROK)
1242    {
1243       return RFAILED;
1244    }
1245    /* PDSCH Config Common */
1246    DU_ALLOC(bwp->pdsch_ConfigCommon, \
1247          sizeof(struct BWP_DownlinkCommon__pdsch_ConfigCommon));
1248    if(!bwp->pdsch_ConfigCommon)
1249    {
1250       DU_LOG("\nERROR  -->  DU APP : DL BWP memory allocation failed");
1251       return RFAILED;
1252    }
1253    ret=BuildPdschCfgCommon(bwp->pdsch_ConfigCommon);
1254    if(ret != ROK)
1255    {
1256       return RFAILED;
1257    }
1258    return ROK;
1259 } /* BuildBwpDlCommon */
1260
1261 /*******************************************************************
1262  *
1263  * @brief Build BCCH configuration 
1264  *
1265  * @details
1266  *
1267  *    Function : BuildBcchConfig
1268  *
1269  *    Functionality:
1270  *      Build BCCH configuration
1271  *
1272  * @params[in] BCCH_Config_t pointer
1273  * @return ROK     - success
1274  *         RFAILED - failure
1275  *
1276  * ****************************************************************/
1277
1278 uint8_t BuildBcchConfig(BCCH_Config_t *bcchCfg)
1279 {
1280    BcchCfg   duBcchCfg;
1281
1282    duBcchCfg = duCfgParam.sib1Params.srvCellCfgCommSib.dlCfg.bcchCfg;
1283
1284    bcchCfg->modificationPeriodCoeff = duBcchCfg.modPrdCoeff;
1285
1286    return ROK;
1287 }/* BuildBcchConfig */
1288
1289 /*******************************************************************
1290  *
1291  * @brief fills First PDCCH monitoring Paging occasions 
1292  *
1293  * @details
1294  *
1295  *    Function : fillFirstPdcchMonitoringOcc
1296  *
1297  *    Functionality:
1298  *        Fills PDCCH Monitoring PO in PCCH configuration
1299  *
1300  * @params[in] 
1301  * @return ROK     - success
1302  *         RFAILED - failure
1303  *
1304  * ****************************************************************/
1305 uint8_t fillFirstPdcchMonitoringOcc(struct PCCH_Config__firstPDCCH_MonitoringOccasionOfPO *firstPO,\
1306                                       PcchCfg *srcPcchCfg)
1307 {
1308    uint8_t numPO = 0, poIdx = 0;
1309
1310    firstPO->present = srcPcchCfg->firstPDCCHMontioringType;
1311
1312    GET_NUM_PAGING_OCC(srcPcchCfg->ns, numPO);
1313    if(srcPcchCfg->ns == 0)
1314    {
1315       DU_LOG("\nINFO   -->  DU APP : Paging Occasions is ZERO, no need to fill further");
1316       return ROK;
1317    }
1318
1319    /*Note: Valid values for each number of PO is from Spec 36.331: PCCH-COnfig*/
1320    switch(firstPO->present)
1321    {
1322       case PCCH_Config__firstPDCCH_MonitoringOccasionOfPO_PR_NOTHING:
1323          {
1324             break;
1325          }
1326       case PCCH_Config__firstPDCCH_MonitoringOccasionOfPO_PR_sCS15KHZoneT:
1327          {
1328             DU_ALLOC(firstPO->choice.sCS15KHZoneT, \
1329                   sizeof(struct PCCH_Config__firstPDCCH_MonitoringOccasionOfPO__sCS15KHZoneT));
1330
1331             if(firstPO->choice.sCS15KHZoneT == NULLP)
1332             {
1333                DU_LOG("\nERROR  -->  DU APP : FirstPdcchMonitoringPO Memory allocation failure");
1334                return RFAILED;
1335             }
1336             firstPO->choice.sCS15KHZoneT->list.count = numPO;
1337             firstPO->choice.sCS15KHZoneT->list.size = numPO * sizeof(long *);
1338
1339             DU_ALLOC(firstPO->choice.sCS15KHZoneT->list.array, firstPO->choice.sCS15KHZoneT->list.size);
1340             if(!firstPO->choice.sCS15KHZoneT->list.array)
1341             {
1342                DU_LOG("\nERROR  -->  DU APP : FirstPdcchMonitoringPO Memory allocation failure");
1343                return RFAILED;
1344             }
1345
1346             for(poIdx = 0; poIdx < numPO; poIdx++)
1347             {
1348                /* Spec 36.331: PCCH-Config: firstPDCCH-MonitoringOccasionOfPO [MAX of sCS15KHZoneT]
1349                 * Since FirstPDCCHMonitoring_PO is not valid thus no need to continue further*/
1350                if(srcPcchCfg->firstPDCCHMontioringInfo[poIdx] > 139)
1351                {
1352                   DU_LOG("\nERROR  -->  DU APP : Invalid Paging Ocassion value for 15kHz");
1353                   return RFAILED;
1354                }
1355                DU_ALLOC(firstPO->choice.sCS15KHZoneT->list.array[poIdx], sizeof(long));
1356                if(!firstPO->choice.sCS15KHZoneT->list.array[poIdx])
1357                {
1358                   DU_LOG("\nERROR  -->  DU APP : FirstPdcchMonitoringPO Memory allocation failure");
1359                   return RFAILED;
1360                }
1361             }
1362
1363             poIdx = 0;
1364             *firstPO->choice.sCS15KHZoneT->list.array[poIdx] = srcPcchCfg->firstPDCCHMontioringInfo[poIdx];
1365
1366             break;
1367          }
1368       case PCCH_Config__firstPDCCH_MonitoringOccasionOfPO_PR_sCS30KHZoneT_SCS15KHZhalfT:
1369          {
1370             DU_ALLOC(firstPO->choice.sCS30KHZoneT_SCS15KHZhalfT, \
1371                   sizeof(struct PCCH_Config__firstPDCCH_MonitoringOccasionOfPO__sCS30KHZoneT_SCS15KHZhalfT));
1372
1373             if(firstPO->choice.sCS30KHZoneT_SCS15KHZhalfT == NULLP)
1374             {
1375                DU_LOG("\nERROR  -->  DU APP : FirstPdcchMonitoringPO Memory allocation failure");
1376                return RFAILED;
1377             }
1378             firstPO->choice.sCS30KHZoneT_SCS15KHZhalfT->list.count = numPO;
1379             firstPO->choice.sCS30KHZoneT_SCS15KHZhalfT->list.size = numPO * sizeof(long *);
1380
1381             DU_ALLOC(firstPO->choice.sCS30KHZoneT_SCS15KHZhalfT->list.array, \
1382                   firstPO->choice.sCS30KHZoneT_SCS15KHZhalfT->list.size);
1383
1384             if(!firstPO->choice.sCS30KHZoneT_SCS15KHZhalfT->list.array)
1385             {
1386                DU_LOG("\nERROR  -->  DU APP : FirstPdcchMonitoringPO Memory allocation failure");
1387                return RFAILED;
1388             }
1389
1390             for(poIdx = 0; poIdx < numPO; poIdx++)
1391             {
1392                /* Spec 36.331: PCCH-Config:firstPDCCH-MonitoringOccasionOfPO [MAX of sCS30KHZoneT-SCS15KHZhalfT]
1393                 * Since FirstPDCCHMonitoring_PO is not valid thus no need to continue further*/
1394                if(srcPcchCfg->firstPDCCHMontioringInfo[poIdx] > 279)
1395                {
1396                   DU_LOG("\nERROR  -->  DU APP : Invalid Paging Ocassion value for 30kHz or 15kHz HAlFT");
1397                   return RFAILED;
1398                }
1399                DU_ALLOC(firstPO->choice.sCS30KHZoneT_SCS15KHZhalfT->list.array[poIdx], sizeof(long));
1400                if(!firstPO->choice.sCS30KHZoneT_SCS15KHZhalfT->list.array[poIdx])
1401                {
1402                   DU_LOG("\nERROR  -->  DU APP : FirstPdcchMonitoringPO Memory allocation failure");
1403                   return RFAILED;
1404                }
1405             }
1406
1407             poIdx = 0;
1408             *firstPO->choice.sCS30KHZoneT_SCS15KHZhalfT->list.array[poIdx] = srcPcchCfg->firstPDCCHMontioringInfo[poIdx];
1409             break;
1410          }
1411          //TODO for other cases
1412       default:
1413          {
1414             DU_LOG("\nERROR  -->  DU APP : Invalid firstPDCCH-MonitoringOccasionOfPO");
1415             return RFAILED;
1416
1417             break;
1418          }
1419    }
1420    return ROK;
1421 }
1422 /*******************************************************************
1423  *
1424  * @brief Builds PCCH configuration 
1425  *
1426  * @details
1427  *
1428  *    Function : BuildPcchConfig
1429  *
1430  *    Functionality:
1431  *        Builds PCCH configuration
1432  *
1433  * @params[in] 
1434  * @return ROK     - success
1435  *         RFAILED - failure
1436  *
1437  * ****************************************************************/
1438 uint8_t BuildPcchConfig(PCCH_Config_t *pcchCfg)
1439 {
1440    PcchCfg   duPcchCfg;
1441
1442    duPcchCfg = duCfgParam.sib1Params.srvCellCfgCommSib.dlCfg.pcchCfg;
1443
1444    pcchCfg->defaultPagingCycle = duPcchCfg.dfltPagingCycle;
1445    pcchCfg->nAndPagingFrameOffset.present =  duPcchCfg.nAndPagingFrmOffsetType;
1446    switch(pcchCfg->nAndPagingFrameOffset.present)
1447    {
1448       /**Note: PagingFrame Offset Value differs for each Paging Duration
1449        *(oneT, halfT,...). The Range of Offset given in Spec 38.331,Pcch-Config*/
1450       case PCCH_Config__nAndPagingFrameOffset_PR_NOTHING:
1451          {
1452             //TODO          
1453             break;
1454          }
1455       case PCCH_Config__nAndPagingFrameOffset_PR_oneT:
1456          {
1457             pcchCfg->nAndPagingFrameOffset.choice.oneT = NULLD;
1458             break;
1459          }
1460       case PCCH_Config__nAndPagingFrameOffset_PR_halfT:
1461          {
1462             /*Spec 38.331: PCCH_Config: nAndPagingFrameOffset [MAX value of halfT] */
1463             if(duPcchCfg.pageFrameOffset > 1)
1464             {
1465                DU_LOG("\nERROR  -->  DU APP : Invalid PagingFrameOffset for HALF_T");
1466                return RFAILED;
1467             }
1468             pcchCfg->nAndPagingFrameOffset.choice.halfT = duPcchCfg.pageFrameOffset;
1469             break;
1470          }
1471       case PCCH_Config__nAndPagingFrameOffset_PR_quarterT:
1472          {
1473             /*Spec 38.331: PCCH_Config: nAndPagingFrameOffset [MAX value of quarterT] */
1474             if(duPcchCfg.pageFrameOffset > 3)
1475             {
1476                DU_LOG("\nERROR  -->  DU APP : Invalid PagingFrameOffset for QUARTER_T");
1477                return RFAILED;
1478             }
1479             pcchCfg->nAndPagingFrameOffset.choice.quarterT = duPcchCfg.pageFrameOffset;
1480             break;
1481          }
1482       case PCCH_Config__nAndPagingFrameOffset_PR_oneEighthT:
1483          {
1484             /*Spec 38.331: PCCH_Config: nAndPagingFrameOffset [MAX value of oneEighthT] */
1485             if(duPcchCfg.pageFrameOffset > 7)
1486             {
1487                DU_LOG("\nERROR  -->  DU APP : Invalid PagingFrameOffset for ONE_EIGHTH_T");
1488                return RFAILED;
1489             }
1490             pcchCfg->nAndPagingFrameOffset.choice.oneEighthT = duPcchCfg.pageFrameOffset;
1491             break;
1492          }
1493       case PCCH_Config__nAndPagingFrameOffset_PR_oneSixteenthT:
1494          {
1495             /*Spec 38.331: PCCH_Config: nAndPagingFrameOffset [MAX value of oneSixteenthT] */
1496             if(duPcchCfg.pageFrameOffset > 15)
1497             {
1498                DU_LOG("\nERROR  -->  DU APP : Invalid PagingFrameOffset for ONE_SIXTEENTH_T");
1499                return RFAILED;
1500             }
1501             pcchCfg->nAndPagingFrameOffset.choice.oneSixteenthT = duPcchCfg.pageFrameOffset;
1502             break;
1503          }
1504       default:
1505          {
1506             DU_LOG("\nERROR  -->  DU APP : Invalid nAndPagingFrameOffset configuration");
1507             return RFAILED;
1508          }
1509    }
1510    pcchCfg->ns = duPcchCfg.ns;
1511
1512    DU_ALLOC(pcchCfg->firstPDCCH_MonitoringOccasionOfPO, \
1513          sizeof(struct PCCH_Config__firstPDCCH_MonitoringOccasionOfPO));
1514    if(pcchCfg->firstPDCCH_MonitoringOccasionOfPO == NULLP)
1515    {
1516       DU_LOG("\nERROR  -->  DU APP : BuildPcchConfig >> Memory Allocation fails");
1517       return RFAILED;
1518    }
1519
1520    if(fillFirstPdcchMonitoringOcc(pcchCfg->firstPDCCH_MonitoringOccasionOfPO, &duPcchCfg) == RFAILED)
1521    {
1522       DU_LOG("\nERROR  -->  DU APP : BuildPcchConfig >> Filling of Paging Occ failed");
1523       return RFAILED;
1524    }
1525    return ROK;
1526 }/* BuildPcchConfig */
1527
1528 /*******************************************************************
1529  *
1530  * @brief Builds Frequency Info for Downlink 
1531  *
1532  * @details
1533  *
1534  *    Function : BuildFreqInfoDl
1535  *
1536  *    Functionality:
1537  *     Builds Frequency Info for Downlink
1538  *
1539  * @params[in] 
1540  * @return ROK     - success
1541  *         RFAILED - failure
1542  *
1543  * ****************************************************************/
1544
1545 uint8_t BuildFreqInfoDl(FrequencyInfoDL_SIB_t *frequencyInfoDL)
1546 {
1547    uint8_t ret;
1548    uint8_t idx;
1549    uint8_t elementCnt;
1550    DlCfgCommon  dlCfg;
1551    NR_MultiBandInfo_t  *multiBandInfo;
1552
1553    dlCfg = duCfgParam.sib1Params.srvCellCfgCommSib.dlCfg;
1554
1555    /* NR Multi-Band Info */
1556    elementCnt = ODU_VALUE_ONE;   
1557    frequencyInfoDL->frequencyBandList.list.count = elementCnt;  
1558    frequencyInfoDL->frequencyBandList.list.size = \
1559    elementCnt * sizeof(NR_MultiBandInfo_t *);
1560
1561    DU_ALLOC(frequencyInfoDL->frequencyBandList.list.array, \
1562    frequencyInfoDL->frequencyBandList.list.size);
1563    if(!frequencyInfoDL->frequencyBandList.list.array)
1564    {
1565       DU_LOG("\nERROR  -->  DU APP : SIB1 DL Configuration memory allocation failed");
1566       return RFAILED;
1567    }
1568
1569    for(idx = 0; idx < elementCnt; idx++)
1570    {
1571       DU_ALLOC(frequencyInfoDL->frequencyBandList.list.array[idx],\
1572       sizeof(NR_MultiBandInfo_t));
1573       if(!frequencyInfoDL->frequencyBandList.list.array[idx])
1574       {
1575          DU_LOG("\nERROR  -->  DU APP : SIB1 DL Configuration memory allocation failed");
1576          return RFAILED;
1577       }
1578    }
1579
1580    idx = 0;
1581    multiBandInfo = frequencyInfoDL->frequencyBandList.list.array[idx];
1582
1583    /* Frequency band indicator */
1584    DU_ALLOC(multiBandInfo->freqBandIndicatorNR, sizeof(FreqBandIndicatorNR_t));
1585    if(!multiBandInfo->freqBandIndicatorNR)
1586    {
1587       DU_LOG("\nERROR  -->  DU APP : SIB1 DL Configuration memory allocation failed");
1588       return RFAILED;
1589    }
1590    *multiBandInfo->freqBandIndicatorNR = dlCfg.freqBandInd;
1591
1592    /* Offset to Point A */
1593    frequencyInfoDL->offsetToPointA = dlCfg.offsetToPointA;
1594
1595    /* Subcarrier Spacing specifc carrier */
1596    elementCnt = ODU_VALUE_ONE;
1597    frequencyInfoDL->scs_SpecificCarrierList.list.count = elementCnt;
1598    frequencyInfoDL->scs_SpecificCarrierList.list.size = \
1599    elementCnt * sizeof(SCS_SpecificCarrier_t *);
1600    ret= BuildScsSpecificCarrierListDl(&frequencyInfoDL->scs_SpecificCarrierList);
1601
1602    if(ret != ROK)
1603    {
1604       return RFAILED;
1605    }
1606    return ROK;
1607 }/* BuildFreqInfoDl */
1608
1609 /*******************************************************************
1610  *
1611  * @brief Builds DL configuration common for SIB
1612  *
1613  * @details
1614  *
1615  *    Function : BuildDlCfgCommSib
1616  *
1617  *    Functionality:
1618  *     Builds DL configuration common for SIB
1619  *
1620  * @params[in] DownlinkConfigCommonSIB_t pointer 
1621  * @return ROK     - success
1622  *         RFAILED - failure
1623  *
1624  * ****************************************************************/
1625
1626 uint8_t BuildDlCfgCommSib(DownlinkConfigCommonSIB_t *dlCfg)
1627 {
1628    /* DL frequency info */
1629    uint8_t ret;
1630    ret = BuildFreqInfoDl(&dlCfg->frequencyInfoDL);
1631    if(ret != ROK)
1632    {
1633       return RFAILED;
1634    }
1635    FreqInfoDlret=ROK;
1636    /* BWP Downlink Common */
1637    ret = BuildBwpDlCommon(&dlCfg->initialDownlinkBWP);
1638    if(ret != ROK)
1639    {
1640       return RFAILED;
1641    }
1642    /* BCCH Config */
1643    ret = BuildBcchConfig(&dlCfg->bcch_Config);
1644    if(ret != ROK)
1645    {
1646       return RFAILED;
1647    }
1648    /* PCCH Config */
1649    ret = BuildPcchConfig(&dlCfg->pcch_Config);
1650    if(ret != ROK)
1651    {
1652       return RFAILED;
1653    }
1654    return ROK;
1655 } /* BuildDlCfgCommSib */
1656
1657 /*******************************************************************
1658  *
1659  * @brief Builds SCS specific carrier list for UL 
1660  *
1661  * @details
1662  *
1663  *    Function : BuildScsSpecificCarrierListUl
1664  *
1665  *    Functionality:
1666  *       Builds SCS specific carrier list for UL
1667  *
1668  * @params[in] 
1669  * @return ROK     - success
1670  *         RFAILED - failure
1671  *
1672  * ****************************************************************/
1673
1674 uint8_t BuildScsSpecificCarrierListUl
1675 (
1676 struct FrequencyInfoUL_SIB__scs_SpecificCarrierList *scsCarrierList
1677 )
1678 {
1679    uint8_t idx;
1680    ScsSpecCarrier   duScsSpecCarrier;
1681
1682    duScsSpecCarrier = duCfgParam.sib1Params.srvCellCfgCommSib.ulCfg.ulScsCarrier;
1683
1684    DU_ALLOC(scsCarrierList->list.array, scsCarrierList->list.size);
1685    if(!scsCarrierList->list.array)
1686    {
1687       DU_LOG("\nERROR  -->  DU APP : SCS Specific Carrier list memory allocation failed");
1688       return RFAILED;
1689    }
1690
1691    for(idx = 0; idx < scsCarrierList->list.count; idx++)
1692    {
1693       DU_ALLOC(scsCarrierList->list.array[idx], sizeof(SCS_SpecificCarrier_t));
1694       if(!scsCarrierList->list.array[idx])
1695       {
1696          DU_LOG("\nERROR  -->  DU APP : SCS Specific Carrier list memory allocation failed");
1697          return RFAILED;
1698       }
1699    }
1700    idx = 0;
1701    scsCarrierList->list.array[idx]->offsetToCarrier = duScsSpecCarrier.scsOffset;
1702    scsCarrierList->list.array[idx]->subcarrierSpacing = duScsSpecCarrier.scs;
1703    scsCarrierList->list.array[idx]->carrierBandwidth = duScsSpecCarrier.scsBw;
1704
1705    return ROK;
1706 } /* End of BuildScsSpecificCarrierListUl */
1707
1708 /*******************************************************************
1709  *
1710  * @brief Builds frequency infor for UL 
1711  *
1712  * @details
1713  *
1714  *    Function : BuildFreqInfoUl
1715  *
1716  *    Functionality:
1717  *       Builds frequency infor for UL
1718  *
1719  * @params[in] FrequencyInfoUL_SIB_t pointer
1720  * @return ROK     - success
1721  *         RFAILED - failure
1722  *
1723  * ****************************************************************/
1724
1725 uint8_t BuildFreqInfoUl(FrequencyInfoUL_SIB_t *frequencyInfoUL)
1726 {
1727    uint8_t      elementCnt;
1728    UlCfgCommon  ulCfg;
1729    uint8_t      ret;
1730    ulCfg = duCfgParam.sib1Params.srvCellCfgCommSib.ulCfg;
1731
1732    /* Subcarrier Spacing specifc carrier */
1733    elementCnt = ODU_VALUE_ONE;
1734    frequencyInfoUL->scs_SpecificCarrierList.list.count = elementCnt;
1735    frequencyInfoUL->scs_SpecificCarrierList.list.size = \
1736    elementCnt * sizeof(SCS_SpecificCarrier_t *);
1737    ret=BuildScsSpecificCarrierListUl(&frequencyInfoUL->scs_SpecificCarrierList);
1738    if(ret != ROK)
1739    {
1740       return RFAILED;
1741    }
1742    /* P-MAX */
1743    DU_ALLOC(frequencyInfoUL->p_Max, sizeof(P_Max_t));
1744    if(!frequencyInfoUL->p_Max)
1745    {
1746       DU_LOG("\nERROR  -->  DU APP : UL Frequency Infoo  memory allocation failure");
1747       return RFAILED;
1748    }
1749    *frequencyInfoUL->p_Max = ulCfg.pMax;
1750    FreqInfoUlret=ROK;
1751    return ROK;
1752 }/* BuildFreqInfoUl */
1753
1754 /*******************************************************************
1755  *
1756  * @brief Builds RACH configuration common 
1757  *
1758  * @details
1759  *
1760  *    Function : BuildRachCfgCommon
1761  *
1762  *    Functionality:
1763  *      Builds RACH configuration common
1764  *
1765  * @params[in] BWP_UplinkCommon__rach_ConfigCommon pointer
1766  * @return ROK     - success
1767  *         RFAILED - failure
1768  *
1769  * ****************************************************************/
1770
1771 uint8_t  BuildRachCfgCommon(struct BWP_UplinkCommon__rach_ConfigCommon *rachCfg)
1772 {
1773    RachCfgCommon    duRachCfg;
1774    RACH_ConfigCommon_t  *setup;
1775
1776    duRachCfg = duCfgParam.sib1Params.srvCellCfgCommSib.ulCfg.rachCfg;
1777
1778    rachCfg->present = duRachCfg.present;
1779    switch(rachCfg->present)
1780    {
1781       case BWP_UplinkCommon__rach_ConfigCommon_PR_NOTHING:
1782       {
1783          //TODO
1784          break;
1785       }
1786       case BWP_UplinkCommon__rach_ConfigCommon_PR_release:
1787       {
1788          //TODO
1789          break;
1790       }
1791       case BWP_UplinkCommon__rach_ConfigCommon_PR_setup:
1792       {
1793          DU_ALLOC(rachCfg->choice.setup, sizeof(RACH_ConfigCommon_t)); 
1794          if(!rachCfg->choice.setup)
1795          {
1796             DU_LOG("\nERROR  -->  DU APP : Rach Config memory alloc failed");
1797             return RFAILED;
1798          }
1799          setup = rachCfg->choice.setup;
1800
1801          /* Generic RACH Configuration */
1802          setup->rach_ConfigGeneric.prach_ConfigurationIndex = duRachCfg.prachCfgIdx;
1803          setup->rach_ConfigGeneric.msg1_FDM = duRachCfg.msg1Fdm;
1804          setup->rach_ConfigGeneric.msg1_FrequencyStart = duRachCfg.msg1FreqStart;
1805          setup->rach_ConfigGeneric.zeroCorrelationZoneConfig = duRachCfg.zeroCorrZoneCfg;
1806          setup->rach_ConfigGeneric.preambleReceivedTargetPower = duRachCfg.preambleRcvdTgtPwr; 
1807          setup->rach_ConfigGeneric.preambleTransMax = duRachCfg.preambleTransMax;
1808          setup->rach_ConfigGeneric.powerRampingStep = duRachCfg.pwrRampingStep;
1809          setup->rach_ConfigGeneric.ra_ResponseWindow = duRachCfg.raRspWindow;
1810
1811          /* Total number of RA preambles */
1812          DU_ALLOC(setup->totalNumberOfRA_Preambles, sizeof(long));
1813          if(!setup->totalNumberOfRA_Preambles)
1814          {
1815             DU_LOG("\nERROR  -->  DU APP : Rach Config memory alloc failed");
1816             return RFAILED;
1817          }
1818          *setup->totalNumberOfRA_Preambles = duRachCfg.numRaPreamble;
1819
1820          /* SSB per RACH occassion and CB Preambles per SSB */
1821          DU_ALLOC(setup->ssb_perRACH_OccasionAndCB_PreamblesPerSSB,\
1822          sizeof(struct RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB));
1823          if(!setup->ssb_perRACH_OccasionAndCB_PreamblesPerSSB)
1824          {
1825             DU_LOG("\nERROR  -->  DU APP : Rach Config memory alloc failed");
1826             return RFAILED;
1827          }
1828          setup->ssb_perRACH_OccasionAndCB_PreamblesPerSSB->present = \
1829          duRachCfg.ssbPerRachOccPresent;
1830          switch(setup->ssb_perRACH_OccasionAndCB_PreamblesPerSSB->present)
1831          {
1832             case RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_NOTHING:
1833             {
1834                //TODO
1835                break;
1836             }
1837             case RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_oneEighth:
1838             {
1839                //TODO
1840                break;
1841             }
1842             case RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_oneFourth:
1843             {
1844                //TODO
1845                break;
1846             }
1847             case RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_oneHalf:
1848             {
1849                //TODO
1850                break;
1851             }
1852             case RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_one:
1853             {
1854               setup->ssb_perRACH_OccasionAndCB_PreamblesPerSSB->choice.one =\
1855               duRachCfg.numSsbPerRachOcc;
1856             }
1857             case RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_two:
1858             {
1859                //TODO
1860                break;
1861             }
1862             case RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_four:
1863             {
1864                //TODO
1865                break;
1866             }
1867             case RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_eight:
1868             {
1869                //TODO
1870                 break;
1871             }
1872             case RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_sixteen:
1873             {
1874                //TODO
1875                break;
1876             }
1877             default:
1878             {
1879                DU_LOG("\nERROR  -->  DU APP: Invalid value for \
1880                ssb_PerRach_OccassionAndCB_PreamblesPerSSB");
1881                return RFAILED;
1882             }
1883          }
1884
1885          /* RA Contention Resolution Timer */
1886          setup->ra_ContentionResolutionTimer = duRachCfg.contResTimer;
1887
1888          /* RSRP Threshold SSB */
1889          DU_ALLOC(setup->rsrp_ThresholdSSB, sizeof(RSRP_Range_t));
1890          if(!setup->rsrp_ThresholdSSB)
1891          {
1892             DU_LOG("\nERROR  -->  DU APP : Rach Config memory alloc failed");
1893             return RFAILED;
1894          }
1895          *setup->rsrp_ThresholdSSB = duRachCfg.rsrpThreshSsb;
1896
1897          /* Root Sequence index */
1898          setup->prach_RootSequenceIndex.present = duRachCfg.rootSeqIdxPresent;
1899          switch(setup->prach_RootSequenceIndex.present)
1900          {
1901             case RACH_ConfigCommon__prach_RootSequenceIndex_PR_NOTHING:
1902             {
1903                //TODO
1904                break;
1905             }
1906             case RACH_ConfigCommon__prach_RootSequenceIndex_PR_l839:
1907             {
1908                //TODO
1909                break;
1910             }
1911             case RACH_ConfigCommon__prach_RootSequenceIndex_PR_l139:
1912             {
1913                setup->prach_RootSequenceIndex.choice.l139 = duRachCfg.rootSeqIdx;
1914                break;
1915             }
1916             default:
1917             {
1918                DU_LOG("\nERROR  -->  DU APP: Inavlid PRACH root sequence index type");
1919                return RFAILED;
1920             }
1921          }
1922
1923          /* Msg 1 Subcarrier spacing */
1924          DU_ALLOC(setup->msg1_SubcarrierSpacing, sizeof(SubcarrierSpacing_t));
1925          if(!setup->msg1_SubcarrierSpacing)
1926          {
1927             DU_LOG("\nERROR  -->  DU APP : Rach Config memory alloc failed");
1928             return RFAILED;
1929          }
1930          *setup->msg1_SubcarrierSpacing = duRachCfg.msg1Scs;
1931
1932          /* Restricted Set Config */
1933          setup->restrictedSetConfig = duRachCfg.restrictedSetCfg;
1934
1935          break;
1936       }
1937       default:
1938       {
1939          DU_LOG("\nERROR  -->  DU APP : Invalid RACH Config type ");
1940          return RFAILED;
1941       }
1942    }
1943    return ROK;
1944 }/* BuildRachCfgCommon */
1945
1946 /*******************************************************************
1947  *
1948  * @brief Builds PUSCH configuration for common 
1949  *
1950  * @details
1951  *
1952  *    Function : BuildPuschCfgCommon
1953  *
1954  *    Functionality:
1955  *      Builds PUSCH configuration for common
1956  *
1957  * @params[in] 
1958  * @return ROK     - success
1959  *         RFAILED - failure
1960  *
1961  * ****************************************************************/
1962
1963 uint8_t BuildPuschCfgCommon(struct BWP_UplinkCommon__pusch_ConfigCommon *puschCfg)
1964 {
1965    uint8_t           idx;
1966    uint8_t           elementCnt;   
1967    PuschCfgCommon    duPuschCfg;
1968    PUSCH_ConfigCommon_t *setup;
1969    PUSCH_TimeDomainResourceAllocation_t  *timeDomRsrcAllocInfo;
1970
1971    duPuschCfg = duCfgParam.sib1Params.srvCellCfgCommSib.ulCfg.puschCfg;
1972
1973    puschCfg->present = duPuschCfg.puschCfgPresent;
1974    switch(puschCfg->present)
1975    {
1976       case BWP_UplinkCommon__pusch_ConfigCommon_PR_NOTHING:
1977       {
1978          //TODO
1979          break;
1980       }
1981       case BWP_UplinkCommon__pusch_ConfigCommon_PR_release:
1982       {
1983          //TODO
1984          break;
1985       }
1986       case BWP_UplinkCommon__pusch_ConfigCommon_PR_setup:
1987       {
1988          DU_ALLOC(puschCfg->choice.setup, sizeof(PUSCH_ConfigCommon_t));
1989          if(!puschCfg->choice.setup)
1990          {
1991             DU_LOG("\nERROR  -->  DU APP : PUSCH Config memory alloc failed");
1992             return RFAILED;
1993          }
1994          setup = puschCfg->choice.setup;
1995
1996          /* Time Domain Resource Allocation List */
1997          DU_ALLOC(setup->pusch_TimeDomainAllocationList,\
1998          sizeof(PUSCH_TimeDomainResourceAllocationList_t)); 
1999          if(!setup->pusch_TimeDomainAllocationList)
2000          {
2001             DU_LOG("\nERROR  -->  DU APP : PUSCH Config memory alloc failed");
2002             return RFAILED;
2003          }
2004          elementCnt = duPuschCfg.numTimeDomRsrcAlloc;
2005          setup->pusch_TimeDomainAllocationList->list.count = elementCnt;
2006          setup->pusch_TimeDomainAllocationList->list.size = \
2007          elementCnt * sizeof(PUSCH_TimeDomainResourceAllocation_t *);
2008
2009          DU_ALLOC(setup->pusch_TimeDomainAllocationList->list.array, \
2010          setup->pusch_TimeDomainAllocationList->list.size);
2011          if(!setup->pusch_TimeDomainAllocationList->list.array)
2012          {
2013             DU_LOG("\nERROR  -->  DU APP : PUSCH Config memory alloc failed");
2014             return RFAILED;
2015          }
2016
2017          for(idx=0; idx<elementCnt; idx++)
2018          {
2019             DU_ALLOC(setup->pusch_TimeDomainAllocationList->list.array[idx],\
2020             sizeof(PUSCH_TimeDomainResourceAllocation_t));
2021             if(!setup->pusch_TimeDomainAllocationList->list.array[idx])
2022             {
2023                DU_LOG("\nERROR  -->  DU APP : PUSCH Config memory alloc failed");
2024                return RFAILED;
2025             }
2026          }
2027
2028          for(idx = 0; idx < elementCnt; idx++)
2029     {
2030        timeDomRsrcAllocInfo = setup->pusch_TimeDomainAllocationList->list.array[idx];
2031
2032        /* K2 */
2033        DU_ALLOC(timeDomRsrcAllocInfo->k2, sizeof(long));
2034        if(!timeDomRsrcAllocInfo->k2)
2035        {
2036           DU_LOG("\nERROR  -->  DU APP : PUSCH Config memory alloc failed");
2037           return RFAILED;
2038        }
2039        *timeDomRsrcAllocInfo->k2 = duPuschCfg.timeDomAllocList[idx].k2;
2040        timeDomRsrcAllocInfo->mappingType = duPuschCfg.timeDomAllocList[idx].mapType;
2041        timeDomRsrcAllocInfo->startSymbolAndLength = duPuschCfg.timeDomAllocList[idx].sliv;
2042     }
2043          /* Msg3 Delta Preamble */
2044          DU_ALLOC(setup->msg3_DeltaPreamble, sizeof(long));
2045          if(!setup->msg3_DeltaPreamble)
2046          {
2047             DU_LOG("\nERROR  -->  DU APP : PUSCH Config memory alloc failed");
2048             return RFAILED;
2049          }
2050          *setup->msg3_DeltaPreamble = duPuschCfg.msg3DeltaPreamble;
2051
2052          /* P0 Nominal with grnat */
2053          DU_ALLOC(setup->p0_NominalWithGrant, sizeof(long));
2054          if(!setup->p0_NominalWithGrant)
2055          {
2056             DU_LOG("\nERROR  -->  DU APP : PUSCH Config memory alloc failed");
2057             return RFAILED;
2058          }
2059          *setup->p0_NominalWithGrant = duPuschCfg.p0NominalWithGrant;
2060
2061          break;
2062       }
2063       default:
2064       {
2065          DU_LOG("\nERROR  -->  DU APP : Invalid PUSCH configuration type ");
2066          return RFAILED;
2067       }
2068    }
2069
2070    return ROK;
2071 }/* BuildPuschCfgCommon */
2072
2073 /*******************************************************************
2074  *
2075  * @brief  Builds PUCCH configuration common
2076  *
2077  * @details
2078  *
2079  *    Function : BuildPucchCfgCommon
2080  *
2081  *    Functionality:
2082  *      Builds PUCCH configuration common
2083  *
2084  * @params[in] 
2085  * @return ROK     - success
2086  *         RFAILED - failure
2087  *
2088  * ****************************************************************/
2089
2090 uint8_t BuildPucchCfgCommon( struct BWP_UplinkCommon__pucch_ConfigCommon *pucchCfg)
2091 {
2092    PucchCfgCommon    duPucchCfg;
2093    PUCCH_ConfigCommon_t *setup;
2094
2095    duPucchCfg = duCfgParam.sib1Params.srvCellCfgCommSib.ulCfg.pucchCfg;
2096
2097    pucchCfg->present = duPucchCfg.present;
2098    switch(pucchCfg->present)
2099    {
2100       case BWP_UplinkCommon__pucch_ConfigCommon_PR_NOTHING:
2101       {
2102          //TODO
2103          break;
2104       }
2105       case BWP_UplinkCommon__pucch_ConfigCommon_PR_release:
2106       {
2107          //TODO
2108          break;
2109       }
2110       case BWP_UplinkCommon__pucch_ConfigCommon_PR_setup:
2111       {
2112          DU_ALLOC(pucchCfg->choice.setup, sizeof(PUCCH_ConfigCommon_t));
2113          if(!pucchCfg->choice.setup)
2114          {
2115             DU_LOG("\nERROR  -->  DU APP : PUCCH Config memory alloc failed");
2116             return RFAILED;
2117          }
2118          setup = pucchCfg->choice.setup;
2119
2120          /* Resource Common */
2121          DU_ALLOC(setup->pucch_ResourceCommon, sizeof(long));
2122          if(!setup->pucch_ResourceCommon)
2123          {
2124             DU_LOG("\nERROR  -->  DU APP : PUCCH Config memory alloc failed");
2125             return RFAILED;
2126          }
2127          *setup->pucch_ResourceCommon = duPucchCfg.rsrcComm;
2128
2129          /* Group hopping */
2130          setup->pucch_GroupHopping = duPucchCfg.grpHop;
2131
2132          /* P0 nominal */
2133          DU_ALLOC(setup->p0_nominal, sizeof(long));
2134          if(!setup->p0_nominal)
2135          {
2136             DU_LOG("\nERROR  -->  DU APP : PUCCH Config memory alloc failed");
2137             return RFAILED;
2138          }
2139          *setup->p0_nominal = duPucchCfg.p0Nominal;
2140
2141          break;
2142       }
2143       default:
2144       {
2145          DU_LOG("\nERROR  -->  DU APP : Invalid PUCCH Config type");
2146          return RFAILED;
2147       }
2148    }
2149    return ROK;
2150 }/* BuildPucchCfgCommon */
2151
2152 /*******************************************************************
2153  *
2154  * @brief Builds UL BWP Common 
2155  *
2156  * @details
2157  *
2158  *    Function : BuildBwpUlCommon
2159  *
2160  *    Functionality:
2161  *      Builds UL BWP Common 
2162  *
2163  * @params[in] BWP_UplinkCommon_t pointer
2164  * @return ROK     - success
2165  *         RFAILED - failure
2166  *
2167  * ****************************************************************/
2168
2169 uint8_t BuildBwpUlCommon(BWP_UplinkCommon_t *bwp)
2170 {
2171    uint8_t     ret;
2172    UlCfgCommon duUlCfg;
2173
2174    duUlCfg = duCfgParam.sib1Params.srvCellCfgCommSib.ulCfg;
2175
2176    bwp->genericParameters.locationAndBandwidth = duUlCfg.locAndBw;
2177    bwp->genericParameters.subcarrierSpacing = duUlCfg.ulScsCarrier.scs;
2178
2179    /* RACH Config Common */
2180    DU_ALLOC(bwp->rach_ConfigCommon,\
2181    sizeof(struct BWP_UplinkCommon__rach_ConfigCommon));
2182    if(!bwp->rach_ConfigCommon)
2183    {
2184       DU_LOG("\nERROR  -->  DU APP : UL BWP memory allocation failed");
2185       return RFAILED;
2186    }
2187    ret = BuildRachCfgCommon(bwp->rach_ConfigCommon);
2188    if(ret != ROK)
2189    {
2190       return RFAILED;
2191    }
2192    RachCfgCommonret=ROK;
2193
2194    /* PUSCH Config Common */
2195    DU_ALLOC(bwp->pusch_ConfigCommon,\
2196    sizeof(struct BWP_UplinkCommon__pusch_ConfigCommon));
2197    if(!bwp->pusch_ConfigCommon)
2198    {
2199       DU_LOG("\nERROR  -->  DU APP : UL BWP memory allocation failed");
2200       return RFAILED;
2201    } 
2202    ret = BuildPuschCfgCommon(bwp->pusch_ConfigCommon);
2203    if(ret != ROK)
2204    {
2205       return RFAILED;
2206    }
2207    PuschCfgCommonret = ROK;
2208
2209    /* PUCCH Config Common */
2210    DU_ALLOC(bwp->pucch_ConfigCommon,\
2211    sizeof(struct BWP_UplinkCommon__pucch_ConfigCommon));
2212    if(!bwp->pucch_ConfigCommon)
2213    {
2214       DU_LOG("\nERROR  -->  DU APP : UL BWP memory allocation failed");
2215       return RFAILED;
2216    } 
2217    ret = BuildPucchCfgCommon(bwp->pucch_ConfigCommon);
2218    if(ret != ROK)
2219    {
2220       return RFAILED;
2221    }
2222    return ROK;
2223 }/* BuildBwpUlCommon */
2224
2225 /*******************************************************************
2226  *
2227  * @brief Builds UL config common for SIB 
2228  *
2229  * @details
2230  *
2231  *    Function : BuildUlCfgCommSib
2232  *
2233  *    Functionality:
2234  *      Builds UL config common for SIB
2235  *
2236  * @params[in] UplinkConfigCommonSIB_t pointer
2237  * @return ROK     - success
2238  *         RFAILED - failure
2239  *
2240  * ****************************************************************/
2241
2242 uint8_t BuildUlCfgCommSib(UplinkConfigCommonSIB_t *ulCfg)
2243 {
2244    uint8_t ret;
2245    /* UL frequency info */
2246    ret = BuildFreqInfoUl(&ulCfg->frequencyInfoUL);
2247    if(ret != ROK)
2248    {
2249       return RFAILED;
2250    }
2251    /* BWP Uplink Common */
2252    ret = BuildBwpUlCommon(&ulCfg->initialUplinkBWP);
2253    if(ret != ROK)
2254    {
2255       return RFAILED;
2256    }
2257    /* Time Alignment timer */
2258    ulCfg->timeAlignmentTimerCommon = \
2259    duCfgParam.sib1Params.srvCellCfgCommSib.ulCfg.timeAlignTimerComm;
2260
2261    return ROK;
2262 }/* BuildUlCfgCommSib */
2263
2264 /*******************************************************************
2265  *
2266  * @brief Builds TDD UL DL configuration common 
2267  *
2268  * @details
2269  *
2270  *    Function : BuildTddUlDlCfgComm
2271  *
2272  *    Functionality:
2273  *      Builds TDD UL DL configuration common
2274  *
2275  * @params[in] TDD_UL_DL_ConfigCommon_t pointer 
2276  * @return ROK     - success
2277  *         RFAILED - failure
2278  *
2279  * ****************************************************************/
2280
2281 uint8_t BuildTddUlDlCfgComm(TDD_UL_DL_ConfigCommon_t *tddCfg)
2282 {
2283    TddUlDlCfgCommon duTddCfg;
2284
2285    duTddCfg = duCfgParam.sib1Params.srvCellCfgCommSib.tddCfg;
2286
2287    /* Reference Subcarrier spacing */
2288    tddCfg->referenceSubcarrierSpacing = duTddCfg.refScs;
2289
2290    /* Pattern 1*/
2291    tddCfg->pattern1.dl_UL_TransmissionPeriodicity = duTddCfg.txPrd;
2292    tddCfg->pattern1.nrofDownlinkSlots = duTddCfg.numDlSlots;
2293    tddCfg->pattern1.nrofDownlinkSymbols = duTddCfg.numDlSymbols;
2294    tddCfg->pattern1.nrofUplinkSlots = duTddCfg.numUlSlots;
2295    tddCfg->pattern1.nrofUplinkSymbols = duTddCfg.numUlSymbols;
2296
2297    return ROK;
2298
2299 }/* BuildTddUlDlCfgComm */
2300
2301 /*******************************************************************
2302  * 
2303  * @brief Builds Serving cell config common in SIB1 message 
2304  * 
2305  * @details
2306  * 
2307  *     Function : BuildServCellCfgCommonSib
2308  * 
2309  *    Functionality: 
2310  *       Building Serving cell config common in SIB1 message
2311  *
2312  * @params[in] ServingCellConfigCommonSIB_t pointer
2313  * @return ROK     - success
2314  *         RFAILED - failure
2315  *
2316  * ****************************************************************/
2317 uint8_t BuildServCellCfgCommonSib(ServingCellConfigCommonSIB_t *srvCellCfg)
2318 {
2319    SrvCellCfgCommSib    duSrvCellCfg;
2320    BIT_STRING_t         *ssbPosInBurst;
2321    uint8_t              ret;
2322    duSrvCellCfg = duCfgParam.sib1Params.srvCellCfgCommSib;
2323
2324    /* SSB Position in Burst */
2325    ssbPosInBurst = &srvCellCfg->ssb_PositionsInBurst.inOneGroup;
2326    ssbPosInBurst->size = 1;
2327    DU_ALLOC(ssbPosInBurst->buf, ssbPosInBurst->size * sizeof(uint8_t));
2328    if(!ssbPosInBurst->buf)
2329    {
2330       DU_LOG("\nERROR  -->  DU APP : Serving cell config common  memory allocation failure");
2331       return RFAILED;
2332    } 
2333    ssbPosInBurst->buf[0] = duSrvCellCfg.ssbPosInBurst;  
2334    ssbPosInBurst->bits_unused = 0;
2335
2336    switch(duSrvCellCfg.ssbPrdServingCell)
2337    {
2338       case SSB_PERIODICITY_5MS:
2339          srvCellCfg->ssb_PeriodicityServingCell = \
2340          ServingCellConfigCommonSIB__ssb_PeriodicityServingCell_ms5;
2341          break;
2342       case SSB_PERIODICITY_10MS:
2343          srvCellCfg->ssb_PeriodicityServingCell = \
2344          ServingCellConfigCommonSIB__ssb_PeriodicityServingCell_ms10;
2345          break;
2346       case SSB_PERIODICITY_20MS:
2347          srvCellCfg->ssb_PeriodicityServingCell = \
2348          ServingCellConfigCommonSIB__ssb_PeriodicityServingCell_ms20;
2349          break;
2350       case SSB_PERIODICITY_40MS:
2351          srvCellCfg->ssb_PeriodicityServingCell = \
2352          ServingCellConfigCommonSIB__ssb_PeriodicityServingCell_ms40;
2353          break;
2354       case SSB_PERIODICITY_80MS:
2355          srvCellCfg->ssb_PeriodicityServingCell = \
2356          ServingCellConfigCommonSIB__ssb_PeriodicityServingCell_ms80;
2357          break;
2358       case SSB_PERIODICITY_160MS:
2359          srvCellCfg->ssb_PeriodicityServingCell = \
2360          ServingCellConfigCommonSIB__ssb_PeriodicityServingCell_ms160;
2361          break;
2362    }
2363
2364    srvCellCfg->ss_PBCH_BlockPower = duSrvCellCfg.ssPbchBlockPwr;
2365
2366    /* Downlink config common */
2367    ret = BuildDlCfgCommSib(&srvCellCfg->downlinkConfigCommon);
2368    if(ret != ROK)
2369    {
2370       return RFAILED;
2371    }
2372    DlCfgCommSibret = ROK;
2373
2374    /* Uplink Config Comm */
2375    DU_ALLOC(srvCellCfg->uplinkConfigCommon, sizeof(UplinkConfigCommonSIB_t));
2376    if(!srvCellCfg->uplinkConfigCommon)
2377    {
2378       DU_LOG("\nERROR  -->  DU APP : Serving cell config common  memory allocation failure");
2379       return RFAILED;
2380    }
2381    ret = BuildUlCfgCommSib(srvCellCfg->uplinkConfigCommon);
2382    if(ret != ROK)
2383    {
2384       return RFAILED;
2385    }
2386    UlCfgCommSibret=ROK;
2387
2388    /* TDD UL DL Config Comm */
2389    DU_ALLOC(srvCellCfg->tdd_UL_DL_ConfigurationCommon, sizeof(TDD_UL_DL_ConfigCommon_t));
2390    if(!srvCellCfg->tdd_UL_DL_ConfigurationCommon)
2391    {
2392       DU_LOG("\nERROR  -->  DU APP : Serving cell config common  memory allocation failure");
2393       return RFAILED;
2394    }
2395    ret = BuildTddUlDlCfgComm(srvCellCfg->tdd_UL_DL_ConfigurationCommon);
2396    if(ret != ROK)
2397    {
2398       return RFAILED;
2399    }
2400    return ROK;
2401 }
2402
2403 /*******************************************************************
2404  *
2405  * @brief Builds SIB message in Served Cell Info
2406  *
2407  * @details
2408  *
2409  *    Function : BuildSib1Msg
2410  *
2411  *    Functionality: Building SIB message in Served Cell Info
2412  *
2413  * @return ROK     - success
2414  *         RFAILED - failure
2415  *
2416  * ****************************************************************/
2417 uint8_t BuildSib1Msg()
2418 {
2419    SIB1_t                   *sib1Msg;
2420    CellAccessRelatedInfo_t  *cellAccessInfo;
2421    uint8_t                  elementCnt;
2422    uint8_t                  ret1;
2423    asn_enc_rval_t           encRetVal; 
2424    uint8_t                  ret = RFAILED;
2425
2426    do
2427    {
2428       DU_ALLOC(sib1Msg, sizeof(SIB1_t));
2429       if(!sib1Msg)
2430       {   
2431          DU_LOG("\nERROR  -->  DU APP: SIB1 msg memory allocation failure");
2432          break;
2433       }   
2434
2435       elementCnt = ODU_VALUE_ONE;
2436
2437       /* PLMN list */
2438       cellAccessInfo = &sib1Msg->cellAccessRelatedInfo;
2439       cellAccessInfo->plmn_IdentityList.list.count = elementCnt;
2440       cellAccessInfo->plmn_IdentityList.list.size = elementCnt * sizeof(PLMN_IdentityInfo_t *);
2441
2442       ret1 =  BuildPlmnList(cellAccessInfo);
2443       if(ret1 != ROK)
2444       {
2445          break;
2446       }
2447       /* Connection Establish Failure Control */
2448       DU_ALLOC(sib1Msg->connEstFailureControl, sizeof(ConnEstFailureControl_t));
2449       if(!sib1Msg->connEstFailureControl)
2450       {
2451          DU_LOG("\nERROR  -->  DU APP: sib1Msg->connEstFailureControl memory allocation failure");
2452          break;
2453       }
2454       sib1Msg->connEstFailureControl->connEstFailCount =\
2455       duCfgParam.sib1Params.connEstFailCnt;
2456       sib1Msg->connEstFailureControl->connEstFailOffsetValidity =\
2457       duCfgParam.sib1Params.connEstFailOffValidity;
2458
2459       /* SI Scheduling Info */
2460       DU_ALLOC(sib1Msg->si_SchedulingInfo, sizeof(SI_SchedulingInfo_t));
2461       if(!sib1Msg->si_SchedulingInfo)
2462       {
2463          DU_LOG("\nERROR  -->  DU APP: sib1Msg->si_SchedulingInfo memory allocation failure");
2464          break;
2465       } 
2466       elementCnt = ODU_VALUE_ONE;
2467       sib1Msg->si_SchedulingInfo->schedulingInfoList.list.count = elementCnt;
2468       sib1Msg->si_SchedulingInfo->schedulingInfoList.list.size = elementCnt *
2469          sizeof(struct SchedulingInfo *);
2470       ret1 = BuildSiSchedInfoList(&sib1Msg->si_SchedulingInfo->schedulingInfoList);
2471       if(ret1 != ROK)
2472       {
2473          break;
2474       }
2475       sib1Msg->si_SchedulingInfo->si_WindowLength = duCfgParam.sib1Params.siSchedInfo.winLen;
2476
2477       /* Serving Cell Config Common */
2478       DU_ALLOC(sib1Msg->servingCellConfigCommon, sizeof(ServingCellConfigCommonSIB_t));
2479       if(!sib1Msg->servingCellConfigCommon)
2480       {
2481          DU_LOG("\nERROR  -->  DU APP: sib1Msg->servingCellConfigCommon memory allocation failure");
2482          break;
2483       }
2484       ret1 =  BuildServCellCfgCommonSib(sib1Msg->servingCellConfigCommon);
2485       if(ret1 != ROK)
2486       {
2487          break;
2488       }
2489
2490       xer_fprint(stdout, &asn_DEF_SIB1, sib1Msg);
2491
2492       /* Encode the F1SetupRequest type as APER */
2493       memset(encBuf, 0, ENC_BUF_MAX_LEN);
2494       encBufSize = 0;
2495       encRetVal = aper_encode(&asn_DEF_SIB1, 0, sib1Msg, PrepFinalEncBuf,\
2496             encBuf);
2497       printf("\nencbufSize: %d\n", encBufSize);
2498       if(encRetVal.encoded == -1)
2499       {
2500          DU_LOG("\nERROR  -->  DU APP : Could not encode SIB1 structure (at %s)\n",\
2501                encRetVal.failed_type ?
2502                encRetVal.failed_type->name :
2503                "unknown");
2504          break;
2505       }
2506       for(int i=0; i< encBufSize; i++)
2507       {
2508          printf("%x\t",encBuf[i]);
2509       }
2510       printf("\n");
2511
2512       ret = ROK;
2513       break; 
2514    }while(true);
2515
2516    FreeSib1Msg(sib1Msg);
2517
2518    return ret;
2519
2520
2521 }
2522 /*******************************************************************
2523  *
2524  * @brief      :  deallocating the memory of BuildSib1Msg 
2525  *
2526  * @details
2527  *
2528  *     Function : FreeFreqInfoDl
2529  *
2530  *    Functionality: Freeing memory of BuildFreqInfoDl 
2531  *
2532  * @params[in] : FrequencyInfoDL_SIB_t *frequencyInfoDL
2533  * @return     :  void
2534  *
2535  *******************************************************************/
2536 void FreeFreqInfoDl(FrequencyInfoDL_SIB_t *frequencyInfoDL)
2537 {
2538    uint8_t idx=0;
2539    uint8_t idx1=0;
2540
2541    /* Free DL frequency info */
2542    if(!frequencyInfoDL->frequencyBandList.list.array)
2543    {
2544       /*Free Frequency band indicator */
2545       if(!frequencyInfoDL->frequencyBandList.list.array[idx])
2546       {
2547          if(!frequencyInfoDL->frequencyBandList.list.array[idx]->\
2548                freqBandIndicatorNR)
2549          { 
2550             if(!frequencyInfoDL->scs_SpecificCarrierList.list.array)
2551             {
2552                for(idx1 = 0;idx1<frequencyInfoDL->scs_SpecificCarrierList.list.count;idx1++)
2553                {
2554                   if(!frequencyInfoDL->scs_SpecificCarrierList.list.array[idx1])
2555                   {
2556                      DU_FREE(frequencyInfoDL->scs_SpecificCarrierList.list.\
2557                            array[idx1], sizeof(SCS_SpecificCarrier_t));
2558                   }
2559                }
2560                DU_FREE(frequencyInfoDL->scs_SpecificCarrierList.list.array,
2561                      frequencyInfoDL->scs_SpecificCarrierList.list.size);
2562             }
2563             DU_FREE(frequencyInfoDL->frequencyBandList.list.\
2564                   array[idx]->freqBandIndicatorNR, sizeof(FreqBandIndicatorNR_t));
2565          }
2566       }
2567       for(idx = 0; idx <frequencyInfoDL->frequencyBandList.list.count; idx++)
2568       {
2569          if(!frequencyInfoDL->frequencyBandList.list.array[idx])
2570          { 
2571             DU_FREE(frequencyInfoDL->frequencyBandList.list.array[idx],\
2572                   sizeof(NR_MultiBandInfo_t));
2573          }
2574       }
2575       DU_FREE(frequencyInfoDL->frequencyBandList.list.array,\
2576             frequencyInfoDL->frequencyBandList.list.size);
2577    }
2578 }
2579 /*******************************************************************
2580  *
2581  * @brief  :  deallocating the memory of BuildSib1Msg
2582  *
2583  * @details
2584  *
2585  *     Function :  FreeCommonSerachSpaceList
2586  *
2587  *     Functionality:  deallocating the memory of BuildCommonSerachSpaceList
2588  *
2589  * @params[in] :struct PDCCH_ConfigCommon__commonSearchSpaceList  *searchSpclist
2590  * @return  : void
2591  *
2592  *******************************************************************/
2593 void FreeCommonSerachSpaceList( struct PDCCH_ConfigCommon__commonSearchSpaceList
2594       *searchSpclist)
2595 {
2596    uint8_t idx=0;
2597    SearchSpace_t *searchSpace= NULLP;
2598
2599    if(!searchSpclist->list.array)
2600    {
2601       if( searchSpclist->list.array[idx] != NULLP)
2602       {
2603          searchSpace= searchSpclist->list.array[idx];
2604          if(!searchSpace->controlResourceSetId)
2605          {
2606             if(!searchSpace->monitoringSlotPeriodicityAndOffset)
2607             {
2608                if(!searchSpace->monitoringSymbolsWithinSlot)
2609                {
2610                   if(!searchSpace->monitoringSymbolsWithinSlot->buf)
2611                   {
2612                      if(!searchSpace->nrofCandidates)
2613                      {
2614                         if(!searchSpace->searchSpaceType)
2615                         {
2616                            switch(searchSpace->searchSpaceType->present)
2617                            {
2618                               case SearchSpace__searchSpaceType_PR_NOTHING:
2619                                  break;
2620                               case SearchSpace__searchSpaceType_PR_common:
2621                               {    
2622                                  if(!searchSpace->searchSpaceType->choice.common)
2623                                  {
2624                                     if(!searchSpace->searchSpaceType->choice.\
2625                                           common->dci_Format0_0_AndFormat1_0)
2626                                     {
2627                                        DU_FREE(searchSpace->searchSpaceType->choice.\
2628                                              common->dci_Format0_0_AndFormat1_0,sizeof(struct\
2629                                                 SearchSpace__searchSpaceType__common__dci_Format0_0_AndFormat1_0));
2630                                     }
2631                                     DU_FREE(searchSpace->searchSpaceType->choice.common,\
2632                                           sizeof(struct SearchSpace__searchSpaceType__common));
2633                                  }
2634                                  break;
2635                               }
2636                               case SearchSpace__searchSpaceType_PR_ue_Specific:
2637                                  break;
2638                               default:
2639                                  break;
2640                            }
2641                            DU_FREE(searchSpace->searchSpaceType,\
2642                                  sizeof( struct SearchSpace__searchSpaceType));
2643                         }
2644                         DU_FREE(searchSpace->nrofCandidates,\
2645                               sizeof(struct SearchSpace__nrofCandidates));
2646                      }
2647                      DU_FREE(searchSpace->monitoringSymbolsWithinSlot->buf,\
2648                            searchSpace->monitoringSymbolsWithinSlot->size);
2649                   }
2650                   DU_FREE(searchSpace->monitoringSymbolsWithinSlot,\
2651                         sizeof(BIT_STRING_t));
2652                }
2653                DU_FREE(searchSpace->monitoringSlotPeriodicityAndOffset,\
2654                      sizeof(struct SearchSpace__monitoringSlotPeriodicityAndOffset));
2655             }
2656             DU_FREE(searchSpace->controlResourceSetId,sizeof(ControlResourceSetId_t));
2657          }
2658       }  
2659       for(idx = 0; idx < searchSpclist->list.count; idx++)
2660       {  
2661          if(!searchSpclist->list.array[idx])
2662          { 
2663             DU_FREE(searchSpclist->list.array[idx], sizeof(SearchSpace_t));
2664          }
2665       }
2666       DU_FREE(searchSpclist->list.array, searchSpclist->list.size)
2667    }
2668 }
2669 /*******************************************************************
2670  *
2671  * @brief : deallocating the memory of BuildSib1Msg
2672  *
2673  * @details
2674  *
2675  *     Function : FreeBwpDlCommon
2676  *
2677  *     Functionality :Deallocating memory of BuildBwpDlCommon
2678  *
2679  * @params[in] : BWP_DownlinkCommon_t *bwp
2680  *
2681  * @return      : void
2682  *
2683  *******************************************************************/
2684 void FreeBwpDlCommon(BWP_DownlinkCommon_t *bwp)
2685 {
2686    uint8_t idx =0;
2687    struct BWP_DownlinkCommon__pdsch_ConfigCommon *pdschCfg=bwp->pdsch_ConfigCommon;
2688    struct BWP_DownlinkCommon__pdcch_ConfigCommon *pdcchCfg=bwp->pdcch_ConfigCommon;
2689    pdcchCfg->present=duCfgParam.sib1Params.srvCellCfgCommSib.dlCfg.pdcchCfg.present; 
2690    pdschCfg->present=duCfgParam.sib1Params.srvCellCfgCommSib.dlCfg.pdschCfg.present;
2691
2692    if(!bwp->pdcch_ConfigCommon)
2693    {
2694       if(!bwp->pdsch_ConfigCommon)
2695       {
2696          switch( pdschCfg->present)
2697          {
2698             case BWP_DownlinkCommon__pdsch_ConfigCommon_PR_NOTHING:
2699             {
2700                //TODO
2701                break;
2702             }
2703             case  BWP_DownlinkCommon__pdsch_ConfigCommon_PR_release:
2704             { 
2705                //TODO
2706                break;
2707             }
2708             case BWP_DownlinkCommon__pdsch_ConfigCommon_PR_setup:
2709             {
2710                if(!pdschCfg->choice.setup)
2711                {
2712                   if(!pdschCfg->choice.setup->pdsch_TimeDomainAllocationList)
2713                   {
2714                      if(!pdschCfg->choice.setup->pdsch_TimeDomainAllocationList->list.array)
2715                      {
2716                         if(pdschCfg->choice.setup->pdsch_TimeDomainAllocationList->list.array[idx]!= NULLP)
2717                         {
2718                            if(!pdschCfg->choice.setup->pdsch_TimeDomainAllocationList->list.array[idx]->k0)
2719                            {
2720                               DU_FREE(pdschCfg->choice.setup->pdsch_TimeDomainAllocationList->list.array[idx]->k0,\
2721                                     sizeof(long)); 
2722                            }
2723                         }
2724                         for(idx=0; idx<pdschCfg->choice.setup->pdsch_TimeDomainAllocationList->list.count ; idx++)
2725                         {
2726                            if(pdschCfg->choice.setup->pdsch_TimeDomainAllocationList->list.array[idx]!=
2727                                  NULLP)
2728                            {
2729                               DU_FREE(pdschCfg->choice.setup->pdsch_TimeDomainAllocationList->list.array[idx],\
2730                                     sizeof(PDSCH_TimeDomainResourceAllocation_t));
2731                            }
2732                         }
2733                         DU_FREE(pdschCfg->choice.setup->pdsch_TimeDomainAllocationList->list.array,\
2734                               pdschCfg->choice.setup->pdsch_TimeDomainAllocationList->list.size);
2735                      }
2736                      DU_FREE(pdschCfg->choice.setup->pdsch_TimeDomainAllocationList,\
2737                            sizeof(PDSCH_TimeDomainResourceAllocationList_t));
2738                   }
2739                   DU_FREE(pdschCfg->choice.setup,
2740                         sizeof(PDSCH_ConfigCommon_t));
2741                }
2742             }
2743             default:
2744                break;
2745          }
2746          DU_FREE(bwp->pdsch_ConfigCommon,\
2747                sizeof(struct BWP_DownlinkCommon__pdsch_ConfigCommon));
2748       }
2749
2750       switch(pdcchCfg->present)
2751       {
2752          case BWP_DownlinkCommon__pdcch_ConfigCommon_PR_NOTHING:
2753          {
2754             //TODO
2755             break;
2756          }
2757          case BWP_DownlinkCommon__pdcch_ConfigCommon_PR_release:
2758          {
2759             //TODO
2760             break;
2761          }
2762          case BWP_DownlinkCommon__pdcch_ConfigCommon_PR_setup:
2763          {
2764             if(!pdcchCfg->choice.setup)
2765             {
2766                /* Control Resource Set Zero */
2767                if(! pdcchCfg->choice.setup->controlResourceSetZero)
2768                {
2769                   /* Search space zero */
2770                   if(! pdcchCfg->choice.setup->searchSpaceZero)
2771                   {
2772                      /* Common Search Space List */
2773                      if(! pdcchCfg->choice.setup->commonSearchSpaceList)
2774                      {
2775                         if(CommonSerachSpaceListret==ROK)
2776                         {
2777                            if(!pdcchCfg->choice.setup->searchSpaceSIB1)
2778                            {
2779                               if(!pdcchCfg->choice.setup->pagingSearchSpace)
2780                               {
2781                                  if(!pdcchCfg->choice.setup->ra_SearchSpace)
2782                                  {
2783                                     DU_FREE(pdcchCfg->choice.setup->ra_SearchSpace,
2784                                           sizeof(SearchSpaceId_t));
2785                                  }
2786                                  DU_FREE( pdcchCfg->choice.setup->pagingSearchSpace,
2787                                        sizeof(SearchSpaceId_t));
2788                               }
2789                               DU_FREE( pdcchCfg->choice.setup->searchSpaceSIB1,
2790                                     sizeof(SearchSpaceId_t));
2791                            }
2792                         }
2793
2794                         FreeCommonSerachSpaceList(pdcchCfg->choice.setup->commonSearchSpaceList);
2795
2796                         DU_FREE( pdcchCfg->choice.setup->commonSearchSpaceList,\
2797                               sizeof(struct
2798                                  PDCCH_ConfigCommon__commonSearchSpaceList));
2799                      }
2800                      DU_FREE( pdcchCfg->choice.setup->searchSpaceZero,
2801                            sizeof(SearchSpaceZero_t));
2802                   }
2803                   DU_FREE( pdcchCfg->choice.setup->controlResourceSetZero,
2804                         sizeof(ControlResourceSetZero_t));
2805                }
2806                DU_FREE(pdcchCfg->choice.setup,
2807                      sizeof(PDCCH_ConfigCommon_t));
2808             }
2809             break;
2810          }
2811          default:
2812             break;
2813       }
2814       DU_FREE(bwp->pdcch_ConfigCommon,sizeof(struct BWP_DownlinkCommon__pdcch_ConfigCommon));
2815    }
2816 }
2817 /*******************************************************************
2818  *
2819  * @brief  deallocating the memory of BuildSib1Msg
2820  *
2821  * @details
2822  *
2823  *     Function: FreeUlCfgCommSib
2824  *
2825  *     Functionality deallocating the memory of BuildUlCfgCommSib
2826  *
2827  * @params[in] : UplinkConfigCommonSIB_t *ulCfg
2828  *
2829  * @return : void
2830  *
2831  *******************************************************************/
2832 void FreeUlCfgCommSib(UplinkConfigCommonSIB_t *ulCfg)
2833 {
2834    uint8_t                 idx=0;
2835    RACH_ConfigCommon_t    *setup;
2836    BWP_UplinkCommon_t     *bwp=&ulCfg->initialUplinkBWP;
2837    struct FrequencyInfoUL_SIB__scs_SpecificCarrierList *scsCarrierList;
2838    struct BWP_UplinkCommon__rach_ConfigCommon  *rachCfg;
2839    struct BWP_UplinkCommon__pucch_ConfigCommon *pucchCfg;
2840    struct BWP_UplinkCommon__pusch_ConfigCommon *puschCfg;
2841    puschCfg=ulCfg->initialUplinkBWP.pusch_ConfigCommon;
2842    rachCfg =bwp->rach_ConfigCommon;
2843    scsCarrierList    = &ulCfg->frequencyInfoUL.scs_SpecificCarrierList;
2844
2845    if(!scsCarrierList->list.array)
2846    {
2847       if(!ulCfg->frequencyInfoUL.p_Max)
2848       {
2849          if(FreqInfoUlret == ROK)
2850          {
2851             if(!bwp->rach_ConfigCommon)
2852             {
2853                if(RachCfgCommonret== ROK)
2854                {
2855                   if(!bwp->pusch_ConfigCommon)
2856                   {
2857
2858                      if(PuschCfgCommonret==ROK)
2859                      {
2860                         if(!bwp->pucch_ConfigCommon)
2861                         {
2862                            pucchCfg=bwp->pucch_ConfigCommon;
2863                            switch(pucchCfg->present)
2864                            {
2865                               case BWP_UplinkCommon__pucch_ConfigCommon_PR_NOTHING:
2866                                  break;
2867                               case BWP_UplinkCommon__pucch_ConfigCommon_PR_release:
2868                                  break;
2869                               case BWP_UplinkCommon__pucch_ConfigCommon_PR_setup:
2870                               {
2871                                  if(!pucchCfg->choice.setup)
2872                                  {
2873
2874                                     if(!pucchCfg->choice.setup->pucch_ResourceCommon)
2875                                     {
2876                                        if(!pucchCfg->choice.setup->p0_nominal)
2877                                        {
2878                                           DU_FREE(pucchCfg->choice.setup->p0_nominal,
2879                                                 sizeof(long));
2880                                        }
2881                                        DU_FREE(pucchCfg->choice.setup->pucch_ResourceCommon,
2882                                              sizeof(long));
2883                                     }
2884                                     DU_FREE(pucchCfg->choice.setup,
2885                                           sizeof(PUCCH_ConfigCommon_t));
2886                                  }
2887                               }
2888                               default:
2889                                  break;
2890                            }
2891                            DU_FREE(bwp->pucch_ConfigCommon,\
2892                            sizeof(struct BWP_UplinkCommon__pucch_ConfigCommon));
2893                         }
2894                      }
2895                      switch(puschCfg->present)
2896                      {
2897                         case BWP_UplinkCommon__pusch_ConfigCommon_PR_NOTHING:
2898                            break;
2899                         case BWP_UplinkCommon__pusch_ConfigCommon_PR_release:
2900                            break;
2901                         case BWP_UplinkCommon__pusch_ConfigCommon_PR_setup:
2902                         {
2903                            if(!puschCfg->choice.setup)
2904                            {
2905
2906                               if(! puschCfg->choice.setup->pusch_TimeDomainAllocationList)
2907                               {
2908                                  if(! puschCfg->choice.setup->pusch_TimeDomainAllocationList->list.array)
2909                                  {
2910                                     if(!puschCfg->choice.setup->pusch_TimeDomainAllocationList->list.array[idx])
2911                                     {
2912                                        if(!puschCfg->choice.setup->pusch_TimeDomainAllocationList->list.array[idx]->k2)
2913                                        {
2914                                           if(! puschCfg->choice.setup->msg3_DeltaPreamble)
2915                                           {
2916                                              if(!puschCfg->choice.setup->p0_NominalWithGrant)
2917                                              {
2918                                                 DU_FREE(puschCfg->choice.setup->p0_NominalWithGrant,
2919                                                       sizeof(long));
2920                                              }
2921                                              DU_FREE(puschCfg->choice.setup->msg3_DeltaPreamble,
2922                                                    sizeof(long));
2923                                           }
2924                                           DU_FREE(puschCfg->choice.setup->pusch_TimeDomainAllocationList->list.\
2925                                                 array[idx]->k2, sizeof(long));
2926                                        }
2927                                     }
2928                                     for(idx=0;
2929                                           idx<puschCfg->choice.setup->pusch_TimeDomainAllocationList->list.count;
2930                                           idx++)
2931                                     {
2932                                        if(!puschCfg->choice.setup->pusch_TimeDomainAllocationList->list.array[idx])
2933                                        {
2934                                           DU_FREE(puschCfg->choice.setup->pusch_TimeDomainAllocationList->list.array[idx],\
2935                                                 sizeof(PUSCH_TimeDomainResourceAllocation_t));
2936                                        }
2937                                     }
2938                                     DU_FREE(puschCfg->choice.setup->pusch_TimeDomainAllocationList->list.array,\
2939                                           puschCfg->choice.setup->pusch_TimeDomainAllocationList->list.size);
2940                                  }
2941                                  DU_FREE(puschCfg->choice.setup->pusch_TimeDomainAllocationList,\
2942                                        sizeof(PUSCH_TimeDomainResourceAllocationList_t));
2943                               }
2944                               DU_FREE(puschCfg->choice.setup,
2945                                     sizeof(PUSCH_ConfigCommon_t));
2946                            }
2947                         }
2948                         default :
2949                            break;
2950                      }
2951
2952                      DU_FREE(bwp->pusch_ConfigCommon,\
2953                            sizeof(struct BWP_UplinkCommon__pusch_ConfigCommon));
2954                   }
2955                }
2956                switch(rachCfg->present)
2957                {
2958                   case BWP_UplinkCommon__rach_ConfigCommon_PR_NOTHING:
2959                      break;
2960                   case BWP_UplinkCommon__rach_ConfigCommon_PR_release:
2961                      break;
2962                   case BWP_UplinkCommon__rach_ConfigCommon_PR_setup:
2963                   {
2964                      if(!rachCfg->choice.setup)
2965                      {
2966                         setup = rachCfg->choice.setup;
2967                         if(!setup->totalNumberOfRA_Preambles)
2968                         {
2969                            if(!setup->ssb_perRACH_OccasionAndCB_PreamblesPerSSB)
2970                            {
2971                               if(!setup->rsrp_ThresholdSSB)
2972                               {
2973                                  if(!setup->msg1_SubcarrierSpacing)
2974                                  {
2975                                     DU_FREE(setup->msg1_SubcarrierSpacing,
2976                                           sizeof(SubcarrierSpacing_t));
2977                                  }
2978                                  DU_FREE(setup->rsrp_ThresholdSSB,
2979                                        sizeof(RSRP_Range_t));
2980                               }
2981                               DU_FREE(setup->ssb_perRACH_OccasionAndCB_PreamblesPerSSB,\
2982                                     sizeof(struct
2983                                        RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB));
2984                            }
2985                            DU_FREE(setup->totalNumberOfRA_Preambles,
2986                                  sizeof(long));
2987                         }
2988
2989                         DU_FREE(rachCfg->choice.setup,
2990                               sizeof(RACH_ConfigCommon_t));
2991                      }
2992                   }
2993                   default:
2994                      break;
2995                }
2996                DU_FREE(bwp->rach_ConfigCommon,\
2997                sizeof(struct BWP_UplinkCommon__rach_ConfigCommon));
2998             }
2999          }
3000          DU_FREE(ulCfg->frequencyInfoUL.p_Max, sizeof(P_Max_t));
3001       }    
3002       for(idx = 0; idx < scsCarrierList->list.count; idx++)
3003       {
3004          if(!scsCarrierList->list.array[idx])
3005          {
3006             DU_FREE(scsCarrierList->list.array[idx],
3007                   sizeof(SCS_SpecificCarrier_t));
3008          }
3009       }
3010       DU_FREE(scsCarrierList->list.array, scsCarrierList->list.size);
3011    }
3012 }
3013 /*******************************************************************
3014  *
3015  * @brief : Deallocating memory of  SIB1 message
3016  *
3017  * @details
3018  *
3019  *   Function : FreeServCellCfgCommonSib
3020  *
3021  *   Functionality: Deallocating memory of BuildServCellCfgCommonSib
3022  *
3023  * @params[in] : ServingCellConfigCommonSIB_t *srvCellCfg
3024  * @return     : void
3025  *
3026  *******************************************************************/
3027 void FreeServCellCfgCommonSib(ServingCellConfigCommonSIB_t *srvCellCfg)
3028 {
3029    BIT_STRING_t         *ssbPosInBurst;
3030    ssbPosInBurst = &srvCellCfg->ssb_PositionsInBurst.inOneGroup;
3031    DownlinkConfigCommonSIB_t *dlCfg=&srvCellCfg->downlinkConfigCommon;
3032
3033    if(!ssbPosInBurst->buf)
3034    {
3035       /* Free DL frequency info */
3036       if(FreqInfoDlret == ROK)
3037       {
3038          if(DlCfgCommSibret == ROK)
3039          {
3040             /* Uplink Config Comm */
3041             if(!srvCellCfg->uplinkConfigCommon)
3042             {
3043                if(UlCfgCommSibret==ROK)
3044                {
3045                   /* TDD UL DL Config Comm */
3046                   if(!srvCellCfg->tdd_UL_DL_ConfigurationCommon)
3047                   {
3048                      DU_FREE(srvCellCfg->tdd_UL_DL_ConfigurationCommon,
3049                            sizeof(TDD_UL_DL_ConfigCommon_t));
3050                   }
3051                }
3052                FreeUlCfgCommSib(srvCellCfg->uplinkConfigCommon);
3053                DU_FREE(srvCellCfg->uplinkConfigCommon,
3054                      sizeof(UplinkConfigCommonSIB_t));  
3055             }
3056          }
3057          FreeBwpDlCommon(&dlCfg->initialDownlinkBWP);
3058       }
3059       FreeFreqInfoDl(&dlCfg->frequencyInfoDL);
3060       DU_FREE(ssbPosInBurst->buf, ssbPosInBurst->size * sizeof(uint8_t));
3061    }
3062 }
3063 /*******************************************************************
3064  *
3065  * @brief   : Deallcating memory of the function BuildSib1Msg
3066  *
3067  * @details
3068  *
3069  *     Function :  FreeSib1Msg
3070  *
3071  *    Functionality: Deallcating memory of the function BuildSib1Msg
3072  *
3073  * @params[in] ServingCellConfigCommonSIB_t pointer
3074  * @return   void
3075  *
3076  *******************************************************************/
3077 void FreeSib1Msg(SIB1_t *sib1Msg)
3078 {
3079    uint8_t idx=0;
3080    uint8_t idx1=0;
3081    uint8_t idx2=0; 
3082    CellIdentity_t           *cellIdentity = NULLP;
3083    CellAccessRelatedInfo_t  *cellAccessInfo ;
3084    struct PLMN_IdentityInfo__plmn_IdentityList     *plmnIdInfo;
3085
3086
3087    if(sib1Msg != NULLP)
3088    {
3089       cellAccessInfo = &sib1Msg->cellAccessRelatedInfo;
3090       if(cellAccessInfo->plmn_IdentityList.list.array !=NULLP)
3091       {
3092          if(cellAccessInfo->plmn_IdentityList.list.array[idx]!=NULLP)
3093          {
3094             plmnIdInfo =
3095                &cellAccessInfo->plmn_IdentityList.list.array[idx]->plmn_IdentityList;
3096
3097             if(plmnIdInfo->list.array !=NULLP)
3098             {
3099                if(!plmnIdInfo->list.array[idx])
3100                {
3101                   if(!plmnIdInfo->list.array[idx]->mcc)
3102                   {
3103                      if(!(plmnIdInfo->list.array[idx]->mcc->list.array))
3104                      {
3105                         if(!plmnIdInfo->list.array[idx]->mnc.list.array)
3106                         {             
3107                            /*Free Tracking Area Code */
3108                            if(!cellAccessInfo->plmn_IdentityList.list.array[idx]->trackingAreaCode)
3109                            {        
3110                               /*Free RANAC */
3111                               if(!cellAccessInfo->plmn_IdentityList.list.array[idx]->trackingAreaCode->buf)
3112                               {    
3113                                  /* Free CellIdentity */
3114                                  if(!cellAccessInfo->plmn_IdentityList.list.array[idx]->ranac)
3115                                  {
3116                                     cellIdentity
3117                                        =&cellAccessInfo->plmn_IdentityList.\
3118                                        list.array[idx]->cellIdentity;
3119                                     if(!cellIdentity->buf)
3120                                     {
3121                                        /*Free Connection Establish Failure Control */
3122                                        if(!sib1Msg->connEstFailureControl)
3123                                        {
3124                                           /*Free Serving Cell Config Common */
3125                                           if(!sib1Msg->si_SchedulingInfo)
3126                                           {
3127                                              /* Free Serving Cell Config Common* */
3128                                              if(!sib1Msg->servingCellConfigCommon)
3129                                              {
3130                                                 /*Free BuildServCellCfgCommonSib*/
3131                                                 FreeServCellCfgCommonSib(\
3132                                                       sib1Msg->servingCellConfigCommon);
3133
3134                                                 DU_FREE(sib1Msg->servingCellConfigCommon,
3135                                                       sizeof(ServingCellConfigCommonSIB_t));
3136                                              }
3137
3138                                              DU_FREE(sib1Msg->si_SchedulingInfo,
3139                                                    sizeof(SI_SchedulingInfo_t));
3140                                           }
3141
3142                                           DU_FREE(sib1Msg->connEstFailureControl,
3143                                                 sizeof(ConnEstFailureControl_t));
3144                                        }
3145                                        DU_FREE(cellIdentity->buf,cellIdentity->size);
3146
3147                                     }
3148                                     DU_FREE(cellAccessInfo->plmn_IdentityList.list.array[idx]->ranac, sizeof(RAN_AreaCode_t)); 
3149
3150                                  }
3151                                  DU_FREE(cellAccessInfo->plmn_IdentityList.list.array[idx]->trackingAreaCode->buf,\
3152                                        cellAccessInfo->plmn_IdentityList.list.array[idx]->trackingAreaCode->size);
3153
3154                               }
3155                               DU_FREE(cellAccessInfo->plmn_IdentityList.list.array[idx]->trackingAreaCode\
3156                                     , sizeof(TrackingAreaCode_t));
3157                            }
3158
3159                            for(idx2=0; idx2<plmnIdInfo->list.array[idx1]->mnc.list.count; idx2++)
3160                            {
3161                               if(!plmnIdInfo->list.array[idx2]->mnc.list.array[idx2])
3162                               {
3163                                  DU_FREE(plmnIdInfo->list.array[idx2]->mnc.list.array[idx2],
3164                                        sizeof(MCC_MNC_Digit_t));
3165                               } 
3166                            }
3167                            DU_FREE(plmnIdInfo->list.array[idx]->mnc.list.array,
3168                                  plmnIdInfo->list.array[idx1]->mnc.list.size);
3169                         }
3170
3171                         for(idx1=0; idx1<plmnIdInfo->list.array[idx]->mcc->list.count; idx1++)
3172                         {
3173                            if(plmnIdInfo->list.array[idx]->mcc->list.array[idx1]!=NULLP)
3174                            {
3175                               DU_FREE(plmnIdInfo->list.array[idx]->mcc->list.array[idx1],\
3176                                     sizeof(MCC_MNC_Digit_t));
3177                            }
3178
3179                         }
3180                         DU_FREE(plmnIdInfo->list.array[idx]->mcc->list.array,\
3181                               plmnIdInfo->list.array[idx]->mcc->list.size)
3182                      }
3183                      DU_FREE(plmnIdInfo->list.array[idx]->mcc,sizeof(MCC_t));
3184                   }
3185                }
3186                for(idx1=0; idx1<plmnIdInfo->list.count; idx1++)
3187                {
3188                   if(!(plmnIdInfo->list.array[idx1]))
3189                   {
3190                      DU_FREE(plmnIdInfo->list.array[idx1],
3191                            sizeof(PLMN_IdentitY_t));
3192                   }
3193                }
3194                DU_FREE(plmnIdInfo->list.array, plmnIdInfo->list.size);
3195             }
3196          }
3197          for(idx=0; idx<cellAccessInfo->plmn_IdentityList.list.count; idx++)
3198          {
3199             if(cellAccessInfo->plmn_IdentityList.list.array[idx]!=NULLP)
3200             { 
3201                DU_FREE(cellAccessInfo->plmn_IdentityList.list.array[idx],
3202                      sizeof(PLMN_IdentityInfo_t));
3203             }
3204          }
3205          DU_FREE(cellAccessInfo->plmn_IdentityList.list.array,
3206                cellAccessInfo->plmn_IdentityList.list.size);
3207       }
3208       DU_FREE(sib1Msg, sizeof(SIB1_t)); 
3209    }
3210
3211 }
3212
3213 /**********************************************************************
3214   End of file
3215  **********************************************************************/