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