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