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