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