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